diff options
| author | Glenn Smith <glenn@vector35.com> | 2025-07-01 18:01:05 -0400 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2025-07-01 23:23:20 -0400 |
| commit | 7331610128610368846206388081524749722648 (patch) | |
| tree | aaf5747bb213d5600e84ad38a0c71dc405107a93 /python | |
| parent | 7323550247538688397481951258523679955041 (diff) | |
Python: get_instruction_index_for_expr for all ILs
Diffstat (limited to 'python')
| -rw-r--r-- | python/highlevelil.py | 10 | ||||
| -rw-r--r-- | python/lowlevelil.py | 2 | ||||
| -rw-r--r-- | python/mediumlevelil.py | 10 |
3 files changed, 21 insertions, 1 deletions
diff --git a/python/highlevelil.py b/python/highlevelil.py index 6398bc26..8869fedd 100644 --- a/python/highlevelil.py +++ b/python/highlevelil.py @@ -4713,6 +4713,16 @@ class HighLevelILFunction: return [] + def get_instruction_index_for_expr(self, expr: ExpressionIndex) -> Optional[InstructionIndex]: + result = core.BNGetHighLevelILInstructionForExpr(self.handle, expr) + if result >= core.BNGetHighLevelILInstructionCount(self.handle): + return None + return InstructionIndex(result) + + def get_expr_index_for_instruction(self, instr: InstructionIndex) -> ExpressionIndex: + result = core.BNGetHighLevelILIndexForInstruction(self.handle, instr) + return ExpressionIndex(result) + def get_medium_level_il_expr_index(self, expr: ExpressionIndex) -> Optional['mediumlevelil.ExpressionIndex']: medium_il = self.medium_level_il if medium_il is None: diff --git a/python/lowlevelil.py b/python/lowlevelil.py index ae2cc932..31d6bc0b 100644 --- a/python/lowlevelil.py +++ b/python/lowlevelil.py @@ -6230,7 +6230,7 @@ class LowLevelILFunction: return InstructionIndex(result) def get_expr_index_for_instruction(self, instr: InstructionIndex) -> ExpressionIndex: - result = core.BNGetLowLevelILInstructionForExpr(self.handle, instr) + result = core.BNGetLowLevelILIndexForInstruction(self.handle, instr) return ExpressionIndex(result) def get_medium_level_il_instruction_index(self, diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py index 1fa580c3..73bfc620 100644 --- a/python/mediumlevelil.py +++ b/python/mediumlevelil.py @@ -5516,6 +5516,16 @@ class MediumLevelILFunction: result = variable.RegisterValue.from_BNRegisterValue(value, self._arch) return result + def get_instruction_index_for_expr(self, expr: ExpressionIndex) -> Optional[InstructionIndex]: + result = core.BNGetMediumLevelILInstructionForExpr(self.handle, expr) + if result >= core.BNGetMediumLevelILInstructionCount(self.handle): + return None + return InstructionIndex(result) + + def get_expr_index_for_instruction(self, instr: InstructionIndex) -> ExpressionIndex: + result = core.BNGetMediumLevelILIndexForInstruction(self.handle, instr) + return ExpressionIndex(result) + def get_low_level_il_instruction_index(self, instr: InstructionIndex) -> Optional['lowlevelil.InstructionIndex']: low_il = self.low_level_il if low_il is None: |
