summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorMark Rowe <mark@vector35.com>2026-04-13 13:07:09 -0700
committerMark Rowe <mark@vector35.com>2026-04-22 15:20:52 -0700
commitaa8dab21d44b4e0dd863f0867c7e735cfb878a4d (patch)
tree256ca89364716afed1735521106130571b0fdb9b /python
parent84d66dc7e6244e6ef78ebb3a2aa24b57a6ed4345 (diff)
Always show the triage view when opening a shared cache or kernel cache
BinaryViewType gains a HasNoInitialContent function that views can use to suppress layout restoration when opening a file. The layout will still be restored when the view is loaded from a saved database. Fixes https://github.com/Vector35/binaryninja-api/issues/8083.
Diffstat (limited to 'python')
-rw-r--r--python/binaryview.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/python/binaryview.py b/python/binaryview.py
index 9368caa7..72768060 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -1514,6 +1514,11 @@ class BinaryViewType(metaclass=_BinaryViewTypeMetaclass):
"""returns if the BinaryViewType is force loadable (read-only)"""
return core.BNIsBinaryViewTypeForceLoadable(self.handle)
+ @property
+ def has_no_initial_content(self) -> bool:
+ """returns if instances of this BinaryViewType start with no loaded content (read-only)"""
+ return core.BNBinaryViewTypeHasNoInitialContent(self.handle)
+
def create(self, data: 'BinaryView') -> Optional['BinaryView']:
view = core.BNCreateBinaryViewOfType(self.handle, data.handle)
if view is None:
@@ -3328,6 +3333,9 @@ class BinaryView:
cls._registered_cb.getLoadSettingsForData = cls._registered_cb.getLoadSettingsForData.__class__(
cls._get_load_settings_for_data
)
+ cls._registered_cb.hasNoInitialContent = cls._registered_cb.hasNoInitialContent.__class__(
+ cls._has_no_initial_content
+ )
view_handle = core.BNRegisterBinaryViewType(cls.name, cls.long_name, cls._registered_cb)
assert view_handle is not None, "core.BNRegisterBinaryViewType returned None"
cls.registered_view_type = BinaryViewType(view_handle)
@@ -3405,6 +3413,17 @@ class BinaryView:
return False
@classmethod
+ def _has_no_initial_content(cls, ctxt):
+ if not callable(getattr(cls, 'has_no_initial_content', None)):
+ return False
+
+ try:
+ return cls.has_no_initial_content() # type: ignore
+ except:
+ log_error_for_exception("Unhandled Python exception in BinaryView._has_no_initial_content")
+ return False
+
+ @classmethod
def _get_load_settings_for_data(cls, ctxt, data):
try:
attr = getattr(cls, "get_load_settings_for_data", None)