``class BinaryView`` implements a view on binary data, and presents a queryable interface of a binary file. One key job of BinaryView is file format parsing which allows Binary Ninja to read, write, insert, remove portions of the file given a virtual address. For the purposes of this documentati
| 2465 | core.BNResetMemoryMap(self.handle) |
| 2466 | |
| 2467 | class BinaryView: |
| 2468 | """ |
| 2469 | ``class BinaryView`` implements a view on binary data, and presents a queryable interface of a binary file. One key |
| 2470 | job of BinaryView is file format parsing which allows Binary Ninja to read, write, insert, remove portions |
| 2471 | of the file given a virtual address. For the purposes of this documentation we define a virtual address as the |
| 2472 | memory address that the various pieces of the physical file will be loaded at. |
| 2473 | |
| 2474 | A binary file does not have to have just one BinaryView, thus much of the interface to manipulate disassembly exists |
| 2475 | within or is accessed through a BinaryView. All files are guaranteed to have at least the ``Raw`` BinaryView. The |
| 2476 | ``Raw`` BinaryView is simply a hex editor, but is helpful for manipulating binary files via their absolute addresses. |
| 2477 | |
| 2478 | BinaryViews are plugins and thus registered with Binary Ninja at startup, and thus should **never** be instantiated |
| 2479 | directly as this is already done. The list of available BinaryViews can be seen in the BinaryViewType class which |
| 2480 | provides an iterator and map of the various installed BinaryViews:: |
| 2481 | |
| 2482 | >>> list(BinaryViewType) |
| 2483 | [<view type: 'Raw'>, <view type: 'ELF'>, <view type: 'Mach-O'>, <view type: 'PE'>] |
| 2484 | >>> BinaryViewType['ELF'] |
| 2485 | <view type: 'ELF'> |
| 2486 | |
| 2487 | To open a file with a given BinaryView the following code is recommended: |
| 2488 | |
| 2489 | >>> with load("/bin/ls") as bv: |
| 2490 | ... bv |
| 2491 | <BinaryView: '/bin/ls', start 0x100000000, len 0x142c8> |
| 2492 | |
| 2493 | `By convention in the rest of this document we will use bv to mean an open and, analyzed, BinaryView of an executable file.` |
| 2494 | When a BinaryView is open on an executable view analysis is automatically run unless specific named parameters are used |
| 2495 | to disable updates. If such a parameter is used, updates can be triggered using the :py:func:`update_analysis_and_wait` method |
| 2496 | which disassembles the executable and returns when all disassembly and analysis is complete:: |
| 2497 | |
| 2498 | >>> bv.update_analysis_and_wait() |
| 2499 | >>> |
| 2500 | |
| 2501 | Since BinaryNinja's analysis is multi-threaded (depending on version) this can also be done in the background |
| 2502 | by using the :py:func:`update_analysis` method instead. |
| 2503 | |
| 2504 | By standard python convention methods which start with '_' should be considered private and should not |
| 2505 | be called externally. Additionally, methods which begin with ``perform_`` should not be called directly |
| 2506 | either and are used explicitly for subclassing a BinaryView. |
| 2507 | |
| 2508 | .. note:: An important note on the ``*_user_*()`` methods. Binary Ninja makes a distinction between edits \ |
| 2509 | performed by the user and actions performed by auto analysis. Auto analysis actions that can quickly be recalculated \ |
| 2510 | are not saved to the database. Auto analysis actions that take a long time and all user edits are stored in the \ |
| 2511 | database (e.g. :py:func:`remove_user_function` rather than :py:func:`remove_function`). Thus use ``_user_`` methods if saving \ |
| 2512 | to the database is desired. |
| 2513 | """ |
| 2514 | name: Optional[str] = None |
| 2515 | long_name: Optional[str] = None |
| 2516 | _registered = False |
| 2517 | _registered_cb = None |
| 2518 | registered_view_type = None |
| 2519 | _associated_data = {} |
| 2520 | _registered_instances = [] |
| 2521 | _cached_instances = {} |
| 2522 | |
| 2523 | @classmethod |
| 2524 | def _cache_insert(cls, instance): |
no outgoing calls
no test coverage detected