diff options
| author | Glenn Smith <glenn@vector35.com> | 2025-02-24 17:04:34 -0500 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2025-03-05 16:39:57 -0500 |
| commit | 0964368357272921723837998074043356784550 (patch) | |
| tree | ef6ff8dbc260177984ef2e5a9d10c035157d6089 /python/lowlevelil.py | |
| parent | f2d653fd89262d73fa9d4f221cd45bae873a6ca9 (diff) | |
Python: Add ability to construct expressions with locations
Co-Authored-By: ltlly <a1253213025@163.com>
Diffstat (limited to 'python/lowlevelil.py')
| -rw-r--r-- | python/lowlevelil.py | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/python/lowlevelil.py b/python/lowlevelil.py index 4c2f0de9..76ee18cf 100644 --- a/python/lowlevelil.py +++ b/python/lowlevelil.py @@ -40,7 +40,7 @@ from .interaction import show_graph_report from .commonil import ( BaseILInstruction, Constant, BinaryOperation, Tailcall, UnaryOperation, Comparison, SSA, Phi, FloatingPoint, ControlFlow, Terminal, Syscall, Localcall, StackOperation, Return, Signed, Arithmetic, Carry, DoublePrecision, - Memory, Load, Store, RegisterStack, SetReg, Intrinsic + Memory, Load, Store, RegisterStack, SetReg, Intrinsic, ILSourceLocation ) ExpressionIndex = NewType('ExpressionIndex', int) @@ -3779,7 +3779,8 @@ class LowLevelILFunction: def expr( self, operation, a: ExpressionIndex = 0, b: ExpressionIndex = 0, c: ExpressionIndex = 0, d: ExpressionIndex = 0, size: int = 0, - flags: Optional[Union['architecture.FlagWriteTypeName', 'architecture.FlagType', 'architecture.FlagIndex']] = None + flags: Optional[Union['architecture.FlagWriteTypeName', 'architecture.FlagType', 'architecture.FlagIndex']] = None, + source_location: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: _flags = architecture.FlagIndex(0) if isinstance(operation, str): @@ -3796,7 +3797,21 @@ class LowLevelILFunction: _flags = architecture.FlagIndex(0) else: assert False, "flags type unsupported" - return ExpressionIndex(core.BNLowLevelILAddExpr(self.handle, operation, size, _flags, a, b, c, d)) + if source_location is not None: + return ExpressionIndex(core.BNLowLevelILAddExprWithLocation( + self.handle, + source_location.address, + source_location.source_operand, + operation, + size, + _flags, + a, + b, + c, + d + )) + else: + return ExpressionIndex(core.BNLowLevelILAddExpr(self.handle, operation, size, _flags, a, b, c, d)) def get_expr_count(self) -> int: """ |
