summaryrefslogtreecommitdiff
path: root/rust/src/low_level_il/function.rs
diff options
context:
space:
mode:
authorMark Rowe <mrowe@bdash.net.nz>2025-05-27 12:34:30 -0700
committerMason Reed <mason@vector35.com>2025-05-30 19:17:10 -0400
commitbcec9c097cd913a06d2877d958cc53065476a82c (patch)
treee8e11f937aaa79e1be59f1fd6843faf9fec398bd /rust/src/low_level_il/function.rs
parent4e8060d23deec18f5b6985b918d7163f65c01e32 (diff)
[Rust] Add LowLevelILInstruction::basic_block / LowLevelILFunction::basic_block_containing_index
Diffstat (limited to 'rust/src/low_level_il/function.rs')
-rw-r--r--rust/src/low_level_il/function.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/rust/src/low_level_il/function.rs b/rust/src/low_level_il/function.rs
index d46350dc..6bd1847a 100644
--- a/rust/src/low_level_il/function.rs
+++ b/rust/src/low_level_il/function.rs
@@ -159,6 +159,21 @@ where
Array::new(blocks, count, context)
}
}
+
+ /// Returns the [`BasicBlock`] at the given instruction `index`.
+ ///
+ /// You can also retrieve this using [`LowLevelILInstruction::basic_block`].
+ pub fn basic_block_containing_index(
+ &self,
+ index: LowLevelInstructionIndex,
+ ) -> Option<Ref<BasicBlock<LowLevelILBlock<M, F>>>> {
+ let block = unsafe { BNGetLowLevelILBasicBlockForInstruction(self.handle, index.0) };
+ if block.is_null() {
+ None
+ } else {
+ Some(unsafe { BasicBlock::ref_from_raw(block, LowLevelILBlock { function: self }) })
+ }
+ }
}
impl<M: FunctionMutability> LowLevelILFunction<M, NonSSA> {