diff options
| author | Brandon Miller <brandon@vector35.com> | 2025-09-25 08:55:34 -0400 |
|---|---|---|
| committer | Brandon Miller <brandon@vector35.com> | 2025-09-29 07:07:41 -0400 |
| commit | 9a9d7d98c2b49c734771397a8d37aca0279dfa21 (patch) | |
| tree | 7925d31daeeb265e58995bc392f0960a58c7a065 /rust/src | |
| parent | 63e37dfb1185552135e397a786e92cd8669880a8 (diff) | |
Rust APIs needed for guided analysis mode
Required for implementing guided analysis mode in custom
implementations of analyze_basic_blocks
Diffstat (limited to 'rust/src')
| -rw-r--r-- | rust/src/architecture.rs | 4 | ||||
| -rw-r--r-- | rust/src/basic_block.rs | 4 | ||||
| -rw-r--r-- | rust/src/function.rs | 16 |
3 files changed, 24 insertions, 0 deletions
diff --git a/rust/src/architecture.rs b/rust/src/architecture.rs index 87182a56..1f37a4df 100644 --- a/rust/src/architecture.rs +++ b/rust/src/architecture.rs @@ -1949,6 +1949,8 @@ pub struct BasicBlockAnalysisContext { pub indirect_branches: Vec<IndirectBranchInfo>, pub indirect_no_return_calls: HashSet<ArchAndAddr>, pub analysis_skip_override: BNFunctionAnalysisSkipOverride, + pub guided_analysis_mode: bool, + pub trigger_guided_on_invalid_instruction: bool, pub translate_tail_calls: bool, pub disallow_branch_to_string: bool, pub max_function_size: u64, @@ -2036,6 +2038,8 @@ impl BasicBlockAnalysisContext { indirect_branches, indirect_no_return_calls, analysis_skip_override: ctx_ref.analysisSkipOverride, + guided_analysis_mode: ctx_ref.guidedAnalysisMode, + trigger_guided_on_invalid_instruction: ctx_ref.triggerGuidedOnInvalidInstruction, translate_tail_calls: ctx_ref.translateTailCalls, disallow_branch_to_string: ctx_ref.disallowBranchToString, max_function_size: ctx_ref.maxFunctionSize, diff --git a/rust/src/basic_block.rs b/rust/src/basic_block.rs index da41e712..d415b148 100644 --- a/rust/src/basic_block.rs +++ b/rust/src/basic_block.rs @@ -205,6 +205,10 @@ impl<C: BlockContext> BasicBlock<C> { } } + pub fn has_invalid_instructions(&self) -> bool { + unsafe { BNBasicBlockHasInvalidInstructions(self.handle) } + } + pub fn raw_length(&self) -> u64 { unsafe { BNGetBasicBlockLength(self.handle) } } diff --git a/rust/src/function.rs b/rust/src/function.rs index 692eb817..1a4add05 100644 --- a/rust/src/function.rs +++ b/rust/src/function.rs @@ -49,6 +49,7 @@ use crate::variable::{ StackVariableReference, Variable, }; use crate::workflow::Workflow; +use std::collections::HashSet; use std::ffi::CStr; use std::fmt::{Debug, Formatter}; use std::ptr::NonNull; @@ -2586,6 +2587,21 @@ impl Function { let key = key.to_cstr(); unsafe { BNFunctionRemoveMetadata(self.handle, key.as_ptr()) }; } + + pub fn guided_source_blocks(&self) -> HashSet<ArchAndAddr> { + let mut count = 0; + let raw = unsafe { BNGetGuidedSourceBlocks(self.handle, &mut count) }; + if raw.is_null() || count == 0 { + return HashSet::new(); + } + + (0..count) + .map(|i| { + let raw = unsafe { std::ptr::read(raw.add(i)) }; + ArchAndAddr::from(raw) + }) + .collect::<HashSet<_>>() + } } impl Debug for Function { |
