From 9011177909529852181726329626234110099652 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Mon, 24 Feb 2025 17:08:50 -0500 Subject: Python: Make copy_expr copy with location Co-Authored-By: ltlly --- python/highlevelil.py | 15 ++++++++++++++- python/lowlevelil.py | 7 ++++++- python/mediumlevelil.py | 15 ++++++++++++++- 3 files changed, 34 insertions(+), 3 deletions(-) (limited to 'python') diff --git a/python/highlevelil.py b/python/highlevelil.py index c73df7f0..b665c6cb 100644 --- a/python/highlevelil.py +++ b/python/highlevelil.py @@ -461,6 +461,10 @@ class HighLevelILInstruction(BaseILInstruction): def source_operand(self) -> ExpressionIndex: 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 @@ -572,6 +572,10 @@ class LowLevelILInstruction(BaseILInstruction): def source_operand(self) -> Optional[ExpressionIndex]: 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)""" @@ -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 @@ -988,6 +988,10 @@ class MediumLevelILInstruction(BaseILInstruction): def source_operand(self) -> ExpressionIndex: 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: """ -- cgit v1.3.1