summaryrefslogtreecommitdiff
path: root/rust/src/low_level_il/function.rs
diff options
context:
space:
mode:
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> {