From aa8dab21d44b4e0dd863f0867c7e735cfb878a4d Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Mon, 13 Apr 2026 13:07:09 -0700 Subject: 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. --- python/binaryview.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'python') 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) @@ -3404,6 +3412,17 @@ class BinaryView: log_error_for_exception("Unhandled Python exception in BinaryView._is_force_loadable") 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: -- cgit v1.3.1