From 8fbf9ca9c0c32c600008dc6d85cacf84276736f8 Mon Sep 17 00:00:00 2001 From: Brandon Miller Date: Fri, 22 May 2026 15:44:53 -0400 Subject: Rust APIs for custom function lifters --- rust/src/binary_view.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'rust/src/binary_view.rs') diff --git a/rust/src/binary_view.rs b/rust/src/binary_view.rs index c455635a..cda76ef2 100644 --- a/rust/src/binary_view.rs +++ b/rust/src/binary_view.rs @@ -1808,17 +1808,22 @@ impl BinaryView { address: u64, platform: &Platform, ) -> Option> { - self.add_auto_function_ext(address, platform, None) + self.add_auto_function_ext(address, platform, None, false) } /// Add an auto function at the given `address` with the `platform` and function type. /// + /// The `auto_discovered` flag is used to prevent or allow this created function to be deleted if + /// it is never used (the function has no xrefs), if you are confident that this is a valid function + /// set this to `false`. + /// /// NOTE: If the view's default platform is not set, this will set it to `platform`. pub fn add_auto_function_ext( &self, address: u64, platform: &Platform, func_type: Option<&Type>, + auto_discovered: bool, ) -> Option> { unsafe { let func_type = match func_type { @@ -1826,8 +1831,13 @@ impl BinaryView { None => std::ptr::null_mut(), }; - let handle = - BNAddFunctionForAnalysis(self.handle, platform.handle, address, true, func_type); + let handle = BNAddFunctionForAnalysis( + self.handle, + platform.handle, + address, + auto_discovered, + func_type, + ); if handle.is_null() { return None; -- cgit v1.3.1