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. --- rust/src/custom_binary_view.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'rust') diff --git a/rust/src/custom_binary_view.rs b/rust/src/custom_binary_view.rs index 8c880fc1..84f39171 100644 --- a/rust/src/custom_binary_view.rs +++ b/rust/src/custom_binary_view.rs @@ -75,6 +75,16 @@ where }) } + extern "C" fn cb_has_no_initial_content(ctxt: *mut c_void) -> bool + where + T: CustomBinaryViewType, + { + ffi_wrap!("BinaryViewTypeBase::has_no_initial_content", unsafe { + let view_type = &*(ctxt as *mut T); + view_type.has_no_initial_content() + }) + } + extern "C" fn cb_create(ctxt: *mut c_void, data: *mut BNBinaryView) -> *mut BNBinaryView where T: CustomBinaryViewType, @@ -159,6 +169,7 @@ where isDeprecated: Some(cb_deprecated::), isForceLoadable: Some(cb_force_loadable::), getLoadSettingsForData: Some(cb_load_settings::), + hasNoInitialContent: Some(cb_has_no_initial_content::), }; unsafe { @@ -199,6 +210,17 @@ pub trait BinaryViewTypeBase: AsRef { false } + /// Do instances of this [`BinaryViewType`] start with no loaded content? + /// + /// When true, the view has no meaningful default state: the user must make a + /// selection (e.g. load images from a shared cache) before any content exists. + /// Callers can use this to suppress restoring previously-saved view state for + /// files not being loaded from a database, since a saved layout would reference + /// content that isn't available on reopen. + fn has_no_initial_content(&self) -> bool { + false + } + fn default_load_settings_for_data(&self, data: &BinaryView) -> Option> { let settings_handle = unsafe { BNGetBinaryViewDefaultLoadSettingsForData(self.as_ref().handle, data.handle) }; @@ -386,6 +408,10 @@ impl BinaryViewTypeBase for BinaryViewType { unsafe { BNIsBinaryViewTypeForceLoadable(self.handle) } } + fn has_no_initial_content(&self) -> bool { + unsafe { BNBinaryViewTypeHasNoInitialContent(self.handle) } + } + fn load_settings_for_data(&self, data: &BinaryView) -> Option> { let settings_handle = unsafe { BNGetBinaryViewLoadSettingsForData(self.handle, data.handle) }; -- cgit v1.3.1