summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Smith <glenn@vector35.com>2025-02-24 17:08:50 -0500
committerGlenn Smith <glenn@vector35.com>2025-03-05 16:39:59 -0500
commit9011177909529852181726329626234110099652 (patch)
treefdbd8ef3591182c45ccbaf00974bf7b7ef86c6ad
parent4501746424590380578222766731587320816671 (diff)
Python: Make copy_expr copy with location
Co-Authored-By: ltlly <a1253213025@163.com>
-rw-r--r--python/highlevelil.py15
-rw-r--r--python/lowlevelil.py7
-rw-r--r--python/mediumlevelil.py15
3 files changed, 34 insertions, 3 deletions
diff --git a/python/highlevelil.py b/python/highlevelil.py
index c73df7f0..b665c6cb 100644
--- a/python/highlevelil.py
+++ b/python/highlevelil.py
@@ -462,6 +462,10 @@ class HighLevelILInstruction(BaseILInstruction):
return ExpressionIndex(self.core_instr.source_operand)
@property
+ def source_location(self) -> ILSourceLocation:
+ return ILSourceLocation.from_instruction(self)
+
+ @property
def core_operands(self) -> OperandsType:
return self.core_instr.operands
@@ -2911,7 +2915,16 @@ class HighLevelILFunction:
:param HighLevelILInstruction original: the original IL Instruction you want to copy
:return: The index of the newly copied expression
"""
- return self.expr(original.operation, original.raw_operands[0], original.raw_operands[1], original.raw_operands[2], original.raw_operands[3], original.raw_operands[4], original.size)
+ return self.expr(
+ original.operation,
+ original.raw_operands[0],
+ original.raw_operands[1],
+ original.raw_operands[2],
+ original.raw_operands[3],
+ original.raw_operands[4],
+ original.size,
+ original.source_location
+ )
def replace_expr(self, original: InstructionOrExpression, new: InstructionOrExpression) -> None:
"""
diff --git a/python/lowlevelil.py b/python/lowlevelil.py
index 3f2616b5..04e9ab5f 100644
--- a/python/lowlevelil.py
+++ b/python/lowlevelil.py
@@ -573,6 +573,10 @@ class LowLevelILInstruction(BaseILInstruction):
return self.instr.source_operand
@property
+ def source_location(self) -> ILSourceLocation:
+ return ILSourceLocation.from_instruction(self)
+
+ @property
def tokens(self) -> TokenList:
"""LLIL tokens (read-only)"""
# special case for those instructions that don't have tokens
@@ -3859,7 +3863,8 @@ class LowLevelILFunction:
original.raw_operands[2],
original.raw_operands[3],
original.size,
- original.raw_flags
+ original.raw_flags,
+ original.source_location
)
def replace_expr(self, original: InstructionOrExpression, new: InstructionOrExpression) -> None:
diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py
index 9a73e95f..d5b1c029 100644
--- a/python/mediumlevelil.py
+++ b/python/mediumlevelil.py
@@ -989,6 +989,10 @@ class MediumLevelILInstruction(BaseILInstruction):
return ExpressionIndex(self.instr.source_operand)
@property
+ def source_location(self) -> ILSourceLocation:
+ return ILSourceLocation.from_instruction(self)
+
+ @property
def core_operands(self) -> OperandsType:
return self.instr.operands
@@ -3554,7 +3558,16 @@ class MediumLevelILFunction:
:param MediumLevelILInstruction original: the original IL Instruction you want to copy
:return: The index of the newly copied expression
"""
- return self.expr(original.operation, original.raw_operands[0], original.raw_operands[1], original.raw_operands[2], original.raw_operands[3], original.raw_operands[4], original.size)
+ return self.expr(
+ original.operation,
+ original.raw_operands[0],
+ original.raw_operands[1],
+ original.raw_operands[2],
+ original.raw_operands[3],
+ original.raw_operands[4],
+ original.size,
+ original.source_location
+ )
def replace_expr(self, original: InstructionOrExpression, new: InstructionOrExpression) -> None:
"""