diff options
| author | Mason Reed <mason@vector35.com> | 2025-06-13 15:47:15 -0400 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2025-06-13 16:13:40 -0400 |
| commit | 255d616d33004a042b773e2ea3cbedefd76db3ab (patch) | |
| tree | 01ec0662a5fd53e9661da1e6b3a1593044f06500 /rust | |
| parent | 0c34857925e6b0c220871f921f5cf4d59bbdb403 (diff) | |
[Rust] Misc API additions/docs and formatting fixes
Diffstat (limited to 'rust')
| -rw-r--r-- | rust/src/binary_view.rs | 37 | ||||
| -rw-r--r-- | rust/src/file_metadata.rs | 4 | ||||
| -rw-r--r-- | rust/src/function.rs | 3 | ||||
| -rw-r--r-- | rust/src/medium_level_il/lift.rs | 2 |
4 files changed, 35 insertions, 11 deletions
diff --git a/rust/src/binary_view.rs b/rust/src/binary_view.rs index cae53e66..a5d3ea6b 100644 --- a/rust/src/binary_view.rs +++ b/rust/src/binary_view.rs @@ -192,11 +192,6 @@ pub trait BinaryViewExt: BinaryViewBase { } } - fn type_name(&self) -> String { - let ptr: *mut c_char = unsafe { BNGetViewType(self.as_ref().handle) }; - unsafe { BnString::into_string(ptr) } - } - fn parent_view(&self) -> Option<Ref<BinaryView>> { let raw_view_ptr = unsafe { BNGetParentView(self.as_ref().handle) }; match raw_view_ptr.is_null() { @@ -284,18 +279,46 @@ pub trait BinaryViewExt: BinaryViewBase { unsafe { BNSetAnalysisHold(self.as_ref().handle, enable) } } + /// Runs the analysis pipeline, analyzing any data that has been marked for updates. + /// + /// You can explicitly mark a function to be updated with: + /// - [`Function::mark_updates_required`] + /// - [`Function::mark_caller_updates_required`] + /// + /// NOTE: This is a **non-blocking** call, use [`BinaryViewExt::update_analysis_and_wait`] if you + /// require analysis to have completed before moving on. fn update_analysis(&self) { unsafe { BNUpdateAnalysis(self.as_ref().handle); } } + /// Runs the analysis pipeline, analyzing any data that has been marked for updates. + /// + /// You can explicitly mark a function to be updated with: + /// - [`Function::mark_updates_required`] + /// - [`Function::mark_caller_updates_required`] + /// + /// NOTE: This is a **blocking** call, use [`BinaryViewExt::update_analysis`] if you do not + /// need to wait for the analysis update to finish. fn update_analysis_and_wait(&self) { unsafe { BNUpdateAnalysisAndWait(self.as_ref().handle); } } + /// Causes **all** functions to be reanalyzed. + /// + /// Use [`BinaryViewExt::update_analysis`] or [`BinaryViewExt::update_analysis_and_wait`] instead + /// if you want to incrementally update analysis. + /// + /// NOTE: This function does not wait for the analysis to finish. + fn reanalyze(&self) { + unsafe { + BNReanalyzeAllFunctions(self.as_ref().handle); + } + } + fn abort_analysis(&self) { unsafe { BNAbortAnalysis(self.as_ref().handle) } } @@ -570,7 +593,7 @@ pub trait BinaryViewExt: BinaryViewBase { } } - /// You likely would also like to call [`Self::define_user_symbol`] to bind this data variable with a name + /// You likely would also like to call [`BinaryViewExt::define_user_symbol`] to bind this data variable with a name fn define_user_data_var<'a, T: Into<Conf<&'a Type>>>(&self, addr: u64, ty: T) { let mut owned_raw_ty = Conf::<&Type>::into_raw(ty.into()); unsafe { @@ -2034,7 +2057,7 @@ unsafe impl Sync for BinaryView {} impl std::fmt::Debug for BinaryView { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("BinaryView") - .field("type_name", &self.type_name()) + .field("view_type", &self.view_type()) .field("file", &self.file()) .field("original_image_base", &self.original_image_base()) .field("start", &self.start()) diff --git a/rust/src/file_metadata.rs b/rust/src/file_metadata.rs index 6d123373..4cbbfd0a 100644 --- a/rust/src/file_metadata.rs +++ b/rust/src/file_metadata.rs @@ -222,9 +222,9 @@ impl FileMetadata { } /// Get the [`BinaryView`] for the view type. - /// + /// /// # Example - /// + /// /// ```no_run /// use binaryninja::file_metadata::FileMetadata; /// # let file: FileMetadata = unimplemented!(); diff --git a/rust/src/function.rs b/rust/src/function.rs index 33b22d19..1c2bb21b 100644 --- a/rust/src/function.rs +++ b/rust/src/function.rs @@ -2442,7 +2442,8 @@ impl Function { ) -> Ref<FlowGraph> { let settings_raw = settings.map(|s| s.handle).unwrap_or(std::ptr::null_mut()); let raw_view_type = FunctionViewType::into_raw(view_type); - let result = unsafe { BNCreateImmediateFunctionGraph(self.handle, raw_view_type, settings_raw) }; + let result = + unsafe { BNCreateImmediateFunctionGraph(self.handle, raw_view_type, settings_raw) }; FunctionViewType::free_raw(raw_view_type); unsafe { FlowGraph::ref_from_raw(result) } } diff --git a/rust/src/medium_level_il/lift.rs b/rust/src/medium_level_il/lift.rs index e563f26d..ff12c0e2 100644 --- a/rust/src/medium_level_il/lift.rs +++ b/rust/src/medium_level_il/lift.rs @@ -6,7 +6,7 @@ use crate::variable::{ConstantData, SSAVariable, Variable}; use std::collections::BTreeMap; use std::fmt::{Debug, Formatter}; -#[derive(Clone)] +#[derive(Clone, Debug)] pub enum MediumLevelILLiftedOperand { ConstantData(ConstantData), Intrinsic(CoreIntrinsic), |
