From bcec9c097cd913a06d2877d958cc53065476a82c Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Tue, 27 May 2025 12:34:30 -0700 Subject: [Rust] Add LowLevelILInstruction::basic_block / LowLevelILFunction::basic_block_containing_index --- rust/src/low_level_il/function.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'rust/src/low_level_il/function.rs') 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>>> { + 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 LowLevelILFunction { -- cgit v1.3.1