Skip to content

Commit 255d616

Browse files
committed
[Rust] Misc API additions/docs and formatting fixes
1 parent 0c34857 commit 255d616

File tree

5 files changed

+36
-12
lines changed

5 files changed

+36
-12
lines changed

plugins/pdb-ng/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ impl PDBParser {
538538

539539
impl CustomDebugInfoParser for PDBParser {
540540
fn is_valid(&self, view: &BinaryView) -> bool {
541-
view.type_name() == "PE" || is_pdb(view)
541+
view.view_type() == "PE" || is_pdb(view)
542542
}
543543

544544
fn parse_info(

rust/src/binary_view.rs

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,6 @@ pub trait BinaryViewExt: BinaryViewBase {
192192
}
193193
}
194194

195-
fn type_name(&self) -> String {
196-
let ptr: *mut c_char = unsafe { BNGetViewType(self.as_ref().handle) };
197-
unsafe { BnString::into_string(ptr) }
198-
}
199-
200195
fn parent_view(&self) -> Option<Ref<BinaryView>> {
201196
let raw_view_ptr = unsafe { BNGetParentView(self.as_ref().handle) };
202197
match raw_view_ptr.is_null() {
@@ -284,18 +279,46 @@ pub trait BinaryViewExt: BinaryViewBase {
284279
unsafe { BNSetAnalysisHold(self.as_ref().handle, enable) }
285280
}
286281

282+
/// Runs the analysis pipeline, analyzing any data that has been marked for updates.
283+
///
284+
/// You can explicitly mark a function to be updated with:
285+
/// - [`Function::mark_updates_required`]
286+
/// - [`Function::mark_caller_updates_required`]
287+
///
288+
/// NOTE: This is a **non-blocking** call, use [`BinaryViewExt::update_analysis_and_wait`] if you
289+
/// require analysis to have completed before moving on.
287290
fn update_analysis(&self) {
288291
unsafe {
289292
BNUpdateAnalysis(self.as_ref().handle);
290293
}
291294
}
292295

296+
/// Runs the analysis pipeline, analyzing any data that has been marked for updates.
297+
///
298+
/// You can explicitly mark a function to be updated with:
299+
/// - [`Function::mark_updates_required`]
300+
/// - [`Function::mark_caller_updates_required`]
301+
///
302+
/// NOTE: This is a **blocking** call, use [`BinaryViewExt::update_analysis`] if you do not
303+
/// need to wait for the analysis update to finish.
293304
fn update_analysis_and_wait(&self) {
294305
unsafe {
295306
BNUpdateAnalysisAndWait(self.as_ref().handle);
296307
}
297308
}
298309

310+
/// Causes **all** functions to be reanalyzed.
311+
///
312+
/// Use [`BinaryViewExt::update_analysis`] or [`BinaryViewExt::update_analysis_and_wait`] instead
313+
/// if you want to incrementally update analysis.
314+
///
315+
/// NOTE: This function does not wait for the analysis to finish.
316+
fn reanalyze(&self) {
317+
unsafe {
318+
BNReanalyzeAllFunctions(self.as_ref().handle);
319+
}
320+
}
321+
299322
fn abort_analysis(&self) {
300323
unsafe { BNAbortAnalysis(self.as_ref().handle) }
301324
}
@@ -570,7 +593,7 @@ pub trait BinaryViewExt: BinaryViewBase {
570593
}
571594
}
572595

573-
/// You likely would also like to call [`Self::define_user_symbol`] to bind this data variable with a name
596+
/// You likely would also like to call [`BinaryViewExt::define_user_symbol`] to bind this data variable with a name
574597
fn define_user_data_var<'a, T: Into<Conf<&'a Type>>>(&self, addr: u64, ty: T) {
575598
let mut owned_raw_ty = Conf::<&Type>::into_raw(ty.into());
576599
unsafe {
@@ -2034,7 +2057,7 @@ unsafe impl Sync for BinaryView {}
20342057
impl std::fmt::Debug for BinaryView {
20352058
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20362059
f.debug_struct("BinaryView")
2037-
.field("type_name", &self.type_name())
2060+
.field("view_type", &self.view_type())
20382061
.field("file", &self.file())
20392062
.field("original_image_base", &self.original_image_base())
20402063
.field("start", &self.start())

rust/src/file_metadata.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ impl FileMetadata {
222222
}
223223

224224
/// Get the [`BinaryView`] for the view type.
225-
///
225+
///
226226
/// # Example
227-
///
227+
///
228228
/// ```no_run
229229
/// use binaryninja::file_metadata::FileMetadata;
230230
/// # let file: FileMetadata = unimplemented!();

rust/src/function.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2442,7 +2442,8 @@ impl Function {
24422442
) -> Ref<FlowGraph> {
24432443
let settings_raw = settings.map(|s| s.handle).unwrap_or(std::ptr::null_mut());
24442444
let raw_view_type = FunctionViewType::into_raw(view_type);
2445-
let result = unsafe { BNCreateImmediateFunctionGraph(self.handle, raw_view_type, settings_raw) };
2445+
let result =
2446+
unsafe { BNCreateImmediateFunctionGraph(self.handle, raw_view_type, settings_raw) };
24462447
FunctionViewType::free_raw(raw_view_type);
24472448
unsafe { FlowGraph::ref_from_raw(result) }
24482449
}

rust/src/medium_level_il/lift.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::variable::{ConstantData, SSAVariable, Variable};
66
use std::collections::BTreeMap;
77
use std::fmt::{Debug, Formatter};
88

9-
#[derive(Clone)]
9+
#[derive(Clone, Debug)]
1010
pub enum MediumLevelILLiftedOperand {
1111
ConstantData(ConstantData),
1212
Intrinsic(CoreIntrinsic),

0 commit comments

Comments
 (0)