diff options
| author | Glenn Smith <glenn@vector35.com> | 2025-06-30 18:07:36 -0400 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2025-07-01 12:52:08 -0400 |
| commit | 669410255fc2994d38b68c41d3ee0644366ff189 (patch) | |
| tree | b337fdce23ba3f503af1cb98f9e5878283c10635 /python/lowlevelil.py | |
| parent | 975b4a852c57599276bc69ef9d93cd553c8eff09 (diff) | |
Python: Add LLILFunction.get_instruction_index_for_expr
Diffstat (limited to 'python/lowlevelil.py')
| -rw-r--r-- | python/lowlevelil.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/python/lowlevelil.py b/python/lowlevelil.py index c9c478dd..ae2cc932 100644 --- a/python/lowlevelil.py +++ b/python/lowlevelil.py @@ -510,6 +510,8 @@ class LowLevelILInstruction(BaseILInstruction): inst = core.BNGetLowLevelILByIndex(func.handle, expr_index) assert inst is not None, "core.BNGetLowLevelILByIndex returned None" core_inst = CoreLowLevelILInstruction.from_BNLowLevelILInstruction(inst) + if instr_index is None: + instr_index = func.get_instruction_index_for_expr(expr_index) return ILInstruction[core_inst.operation](func, expr_index, core_inst, instr_index) # type: ignore def copy_to( @@ -6221,6 +6223,16 @@ class LowLevelILFunction: result = variable.RegisterValue.from_BNRegisterValue(value, self._arch) return result + def get_instruction_index_for_expr(self, expr: ExpressionIndex) -> Optional[InstructionIndex]: + result = core.BNGetLowLevelILInstructionForExpr(self.handle, expr) + if result >= core.BNGetLowLevelILInstructionCount(self.handle): + return None + return InstructionIndex(result) + + def get_expr_index_for_instruction(self, instr: InstructionIndex) -> ExpressionIndex: + result = core.BNGetLowLevelILInstructionForExpr(self.handle, instr) + return ExpressionIndex(result) + def get_medium_level_il_instruction_index(self, instr: InstructionIndex) -> Optional['mediumlevelil.InstructionIndex']: med_il = self.medium_level_il |
