summaryrefslogtreecommitdiff
path: root/python/mediumlevelil.py
diff options
context:
space:
mode:
authorGlenn Smith <glenn@vector35.com>2025-02-24 17:04:34 -0500
committerGlenn Smith <glenn@vector35.com>2025-03-05 16:39:57 -0500
commit0964368357272921723837998074043356784550 (patch)
treeef6ff8dbc260177984ef2e5a9d10c035157d6089 /python/mediumlevelil.py
parentf2d653fd89262d73fa9d4f221cd45bae873a6ca9 (diff)
Python: Add ability to construct expressions with locations
Co-Authored-By: ltlly <a1253213025@163.com>
Diffstat (limited to 'python/mediumlevelil.py')
-rw-r--r--python/mediumlevelil.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py
index 4ec79d8d..9a73e95f 100644
--- a/python/mediumlevelil.py
+++ b/python/mediumlevelil.py
@@ -42,7 +42,8 @@ from .interaction import show_graph_report
from .commonil import (
BaseILInstruction, Constant, BinaryOperation, UnaryOperation, Comparison, SSA, Phi, FloatingPoint, ControlFlow,
Terminal, Call, Localcall, Syscall, Tailcall, Return, Signed, Arithmetic, Carry, DoublePrecision, Memory, Load,
- Store, RegisterStack, SetVar, Intrinsic, VariableInstruction, SSAVariableInstruction, AliasedVariableInstruction
+ Store, RegisterStack, SetVar, Intrinsic, VariableInstruction, SSAVariableInstruction, AliasedVariableInstruction,
+ ILSourceLocation
)
TokenList = List['function.InstructionTextToken']
@@ -3494,14 +3495,29 @@ class MediumLevelILFunction:
def expr(
self, operation: MediumLevelILOperation, a: int = 0, b: int = 0, c: int = 0, d: int = 0, e: int = 0,
- size: int = 0
+ size: int = 0,
+ source_location: Optional['ILSourceLocation'] = None
) -> ExpressionIndex:
_operation = operation
if isinstance(operation, str):
_operation = MediumLevelILOperation[operation]
elif isinstance(operation, MediumLevelILOperation):
_operation = operation.value
- return ExpressionIndex(core.BNMediumLevelILAddExpr(self.handle, _operation, size, a, b, c, d, e))
+ if source_location is not None:
+ return ExpressionIndex(core.BNMediumLevelILAddExprWithLocation(
+ self.handle,
+ _operation,
+ source_location.address,
+ source_location.source_operand,
+ size,
+ a,
+ b,
+ c,
+ d,
+ e
+ ))
+ else:
+ return ExpressionIndex(core.BNMediumLevelILAddExpr(self.handle, _operation, size, a, b, c, d, e))
def get_expr_count(self) -> int:
"""