diff options
| author | Brian Potchik <brian@vector35.com> | 2025-08-18 12:36:40 -0400 |
|---|---|---|
| committer | Brian Potchik <brian@vector35.com> | 2025-08-18 12:36:40 -0400 |
| commit | 3afb333272dd7133236d5fbffc64ec3e61ee2af8 (patch) | |
| tree | a9fd3518eda8dc9c0fd06adf8a65f71d0fad408c | |
| parent | f898679226e1051695c45758047fa853acb68532 (diff) | |
Add ability to rebase the current view through the UIContext.
| -rw-r--r-- | python/binaryview.py | 7 | ||||
| -rw-r--r-- | ui/uicontext.h | 9 |
2 files changed, 15 insertions, 1 deletions
diff --git a/python/binaryview.py b/python/binaryview.py index ff106f28..e0c6cf10 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -9506,7 +9506,8 @@ to a the type "tagRECT" found in the typelibrary "winX64common" ``rebase`` rebase the existing :py:class:`BinaryView` into a new :py:class:`BinaryView` at the specified virtual address .. note:: This method does not update corresponding UI components. If the `BinaryView` is associated with \ - UI components then initiate the rebase operation within the UI, e.g. using the command palette. If working with views that \ + UI components then initiate the rebase operation within the UI, e.g. using the command palette or \ + ``binaryninjaui.UIContext.activeContext().rebaseCurrentView()``. If working with views that \ are not associated with UI components while the UI is active, then set ``force`` to ``True`` to enable rebasing. :param int address: virtual address of the start of the :py:class:`BinaryView` @@ -9521,6 +9522,10 @@ to a the type "tagRECT" found in the typelibrary "winX64common" >>> newbv = bv.rebase(0x400000) >>> print(newbv) <BinaryView: '/bin/ls', start 0x400000, len 0x182f8> + >>> + >>> # For rebasing the current view in the UI: + >>> import binaryninjaui + >>> execute_on_main_thread_and_wait(lambda: binaryninjaui.UIContext.activeContext().rebaseCurrentView(0x800000)) """ result = False if core.BNIsUIEnabled() and not force: diff --git a/ui/uicontext.h b/ui/uicontext.h index bfa265a9..b59db8b1 100644 --- a/ui/uicontext.h +++ b/ui/uicontext.h @@ -449,11 +449,13 @@ public: Get the currently visible View for the currently visible ViewFrame (if it exists) \return Current View or nullptr if the current ViewFrame is null or does not have a View */ + virtual View* getCurrentView() = 0; /*! Get the currently visible ViewFrame (if it exists) \return Current ViewFrame or nullptr if the current widget does not have a ViewFrame */ + virtual ViewFrame* getCurrentViewFrame() = 0; /*! Get the current Action Handler for the focused widget @@ -462,6 +464,13 @@ public: virtual UIActionHandler* getCurrentActionHandler() = 0; /*! + Rebase the current BinaryView to a new address, updating the UI appropriately. + \param address New address for rebasing the current BinaryView + \return True if the rebase was successful, false otherwise + */ + virtual bool rebaseCurrentView(uint64_t address) = 0; + + /*! Open a tab containing the given widget with the given name \param name Name for tab \param widget Widget to display in the tab (optionally a ViewFrame) |
