Skip to content

Commit 432a8cd

Browse files
committed
Callback for address changes #2166
1 parent 31165bf commit 432a8cd

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

examples/uinotification/uinotification.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ void NotificationListener::OnViewChange(UIContext* context, ViewFrame* frame, co
8585
}
8686

8787

88+
void NotificationListener::OnAddressChange(UIContext* context, ViewFrame* frame, View* view, const ViewLocation& location)
89+
{
90+
LogInfo("OnAddressChange: %llx", location.getOffset());
91+
}
92+
93+
8894
extern "C"
8995
{
9096
BINARYNINJAPLUGIN bool UIPluginInit()

examples/uinotification/uinotification.h

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class NotificationListener: UIContextNotification
1717
virtual bool OnBeforeCloseFile(UIContext* context, FileContext* file, ViewFrame* frame) override;
1818
virtual void OnAfterCloseFile(UIContext* context, FileContext* file, ViewFrame* frame) override;
1919
virtual void OnViewChange(UIContext* context, ViewFrame* frame, const QString& type) override;
20+
virtual void OnAddressChange(UIContext* context, ViewFrame* frame, View* view, const ViewLocation& location) override;
2021

2122
static void init();
2223
};

python/examples/ui_notifications.py

+6
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ def OnViewChange(self, context, frame, type):
7171
else:
7272
print("py OnViewChange")
7373

74+
def OnAddressChange(self, context, frame, view, location):
75+
if frame:
76+
print(f"py OnAddressChange {frame.getShortFileName()} {location.getOffset()}")
77+
else:
78+
print(f"py OnAddressChange {location.getOffset()}")
79+
7480

7581
# Register as a global so it doesn't get destructed
7682
notif = UINotification()

ui/uicontext.h

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ typedef void (*UIPluginDependencyFunction)(void);
1616
class ViewFrame;
1717
class UIActionHandler;
1818
class FileContext;
19+
class ViewLocation;
1920

2021
class BINARYNINJAUIAPI UIContextNotification
2122
{
@@ -33,6 +34,7 @@ class BINARYNINJAUIAPI UIContextNotification
3334
virtual void OnAfterCloseFile(UIContext* context, FileContext* file, ViewFrame* frame) { (void)context; (void)file; (void)frame; }
3435

3536
virtual void OnViewChange(UIContext* context, ViewFrame* frame, const QString& type) { (void)context; (void)frame; (void)type; }
37+
virtual void OnAddressChange(UIContext* context, ViewFrame* frame, View* view, const ViewLocation& location) { (void)context; (void)frame; (void)view; (void)location; };
3638
};
3739

3840
class BINARYNINJAUIAPI UIContextHandler
@@ -86,6 +88,7 @@ class BINARYNINJAUIAPI UIContext
8688
void NotifyOnAfterCloseFile(FileContext* file, ViewFrame* frame);
8789

8890
void NotifyOnViewChange(ViewFrame* frame, const QString& type);
91+
void NotifyOnAddressChange(ViewFrame* frame, View* view, const ViewLocation& location);
8992

9093
static void setHandler(UIContextHandler* handler);
9194

0 commit comments

Comments
 (0)