From ddd7aa4e7cd5a1aa07a16c3895d1f91ebf49347b Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Tue, 24 Mar 2026 09:05:49 -0700 Subject: Add a hook to allow BinaryView subclasses to run code after snapshot data is applied Snapshot data is applied when loading from a database, rebasing the view, etc. --- python/binaryview.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'python/binaryview.py') diff --git a/python/binaryview.py b/python/binaryview.py index 5c86e101..add0d02a 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -3173,6 +3173,7 @@ class BinaryView: self._cb.isRelocatable = self._cb.isRelocatable.__class__(self._is_relocatable) self._cb.getAddressSize = self._cb.getAddressSize.__class__(self._get_address_size) self._cb.save = self._cb.save.__class__(self._save) + self._cb.onAfterSnapshotDataApplied = self._cb.onAfterSnapshotDataApplied.__class__(self._on_after_snapshot_data_applied) if file_metadata is None: raise Exception("Attempting to create a BinaryView with FileMetadata which is None") self._file = file_metadata @@ -4482,6 +4483,15 @@ class BinaryView: log_error_for_exception("Unhandled Python exception in BinaryView._save") return False + def _on_after_snapshot_data_applied(self, ctxt): + try: + self.perform_on_after_snapshot_data_applied() + except: + log_error_for_exception("Unhandled Python exception in BinaryView._on_after_snapshot_data_applied") + + def perform_on_after_snapshot_data_applied(self) -> None: + pass + def init(self) -> bool: return True -- cgit v1.3.1