diff options
| author | Mason Reed <mason@vector35.com> | 2025-07-04 16:43:31 -0400 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2025-07-04 16:43:31 -0400 |
| commit | 88eba55a93f4f750ccdfe81575c91c59a73f3a8c (patch) | |
| tree | 5a5bc20457550dfb376187ebabbf1eeebaa73f5a /rust/src/low_level_il/function.rs | |
| parent | f8d3c5eab487e06ad4b944cc92f689e2e367107d (diff) | |
[WARP] Fix possible skipped instructions when multiple IL expressions are appended for a given instruction
Diffstat (limited to 'rust/src/low_level_il/function.rs')
| -rw-r--r-- | rust/src/low_level_il/function.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/rust/src/low_level_il/function.rs b/rust/src/low_level_il/function.rs index f5fcf25f..cf3a432a 100644 --- a/rust/src/low_level_il/function.rs +++ b/rust/src/low_level_il/function.rs @@ -93,6 +93,31 @@ where } } + /// Get all the contiguous instructions for a given location. + /// + /// NOTE: This won't get you every instruction for a location, only the instructions + /// that are sequential from the starting instruction. + pub fn instructions_at<L: Into<Location>>(&self, loc: L) -> Vec<LowLevelILInstruction<M, F>> { + let loc = loc.into(); + // TODO: Instructions sharing the same address are not always sequential. + // Gather all of the sequential instructions with the same address and same block. + self.instruction_index_at(loc) + .map(|mut idx| { + let mut instructions = Vec::new(); + let block = self.basic_block_containing_index(idx); + while idx.0 < self.instruction_count() { + let instr = LowLevelILInstruction::new(self, idx); + if instr.address() != loc.addr || instr.basic_block() != block { + break; + } + instructions.push(instr); + idx = idx.next(); + } + instructions + }) + .unwrap_or_default() + } + pub fn instruction_at<L: Into<Location>>(&self, loc: L) -> Option<LowLevelILInstruction<M, F>> { Some(LowLevelILInstruction::new( self, |
