``AddressField`` prompts the user for an address. By passing the optional view and current_address parameters \ offsets can be used instead of just an address. The result is stored as in int in self.result. .. note:: This API currently functions differently on the command-line, as the view and
| 193 | |
| 194 | |
| 195 | class AddressField: |
| 196 | """ |
| 197 | ``AddressField`` prompts the user for an address. By passing the optional view and current_address parameters \ |
| 198 | offsets can be used instead of just an address. The result is stored as in int in self.result. |
| 199 | |
| 200 | .. note:: This API currently functions differently on the command-line, as the view and current_address are \ |
| 201 | disregarded. Additionally where as in the UI the result defaults to hexadecimal on the command-line 0x must be \ |
| 202 | specified. |
| 203 | |
| 204 | """ |
| 205 | def __init__(self, prompt: str, view: Optional['binaryview.BinaryView'] = None, current_address: int = 0, default: Optional[int] = None): |
| 206 | self._prompt = prompt |
| 207 | self._view = view |
| 208 | self._current_address = current_address |
| 209 | self._default = default |
| 210 | self._result = None |
| 211 | |
| 212 | def _fill_core_struct(self, value): |
| 213 | value.type = FormInputFieldType.AddressFormField |
| 214 | value.prompt = self._prompt |
| 215 | value.view = None |
| 216 | if self._view is not None: |
| 217 | value.view = self._view.handle |
| 218 | value.currentAddress = self._current_address |
| 219 | value.hasDefault = self._default is not None |
| 220 | if self._default is not None: |
| 221 | value.addressDefault = self._default |
| 222 | |
| 223 | def _fill_core_result(self, value): |
| 224 | value.addressResult = self._result |
| 225 | |
| 226 | def _get_result(self, value): |
| 227 | self._result = value.addressResult |
| 228 | |
| 229 | @property |
| 230 | def prompt(self): |
| 231 | """prompt to be presented to the user""" |
| 232 | return self._prompt |
| 233 | |
| 234 | @prompt.setter |
| 235 | def prompt(self, value): |
| 236 | self._prompt = value |
| 237 | |
| 238 | @property |
| 239 | def view(self): |
| 240 | """BinaryView for the address""" |
| 241 | return self._view |
| 242 | |
| 243 | @view.setter |
| 244 | def view(self, value): |
| 245 | self._view = value |
| 246 | |
| 247 | @property |
| 248 | def current_address(self): |
| 249 | """current address to use as a base for relative calculations""" |
| 250 | return self._current_address |
| 251 | |
| 252 | @current_address.setter |