diff options
| author | Glenn Smith <glenn@vector35.com> | 2025-03-04 13:38:37 -0500 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2025-03-05 16:40:00 -0500 |
| commit | 2395433337891264861080811000353596496845 (patch) | |
| tree | 98c5944ae1efa8b71a66aba0fa92aabcd82db48e /python/lowlevelil.py | |
| parent | 9011177909529852181726329626234110099652 (diff) | |
Python: Add source location parameter to LLIL builders
Diffstat (limited to 'python/lowlevelil.py')
| -rw-r--r-- | python/lowlevelil.py | 644 |
1 files changed, 437 insertions, 207 deletions
diff --git a/python/lowlevelil.py b/python/lowlevelil.py index 04e9ab5f..b592e5bb 100644 --- a/python/lowlevelil.py +++ b/python/lowlevelil.py @@ -3919,18 +3919,19 @@ class LowLevelILFunction: """ return core.BNLowLevelILAddInstruction(self.handle, expr) - def nop(self) -> ExpressionIndex: + def nop(self, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``nop`` no operation, this instruction does nothing + :param ILSourceLocation loc: location of returned expression :return: The no operation expression :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_NOP) + return self.expr(LowLevelILOperation.LLIL_NOP, source_location=loc) def set_reg( self, size: int, reg: 'architecture.RegisterType', value: ExpressionIndex, - flags: Optional['architecture.FlagType'] = None + flags: Optional['architecture.FlagType'] = None, loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``set_reg`` sets the register ``reg`` of size ``size`` to the expression ``value`` @@ -3939,17 +3940,18 @@ class LowLevelILFunction: :param str reg: the register name :param ExpressionIndex value: an expression to set the register to :param str flags: which flags are set by this operation + :param ILSourceLocation loc: location of returned expression :return: The expression ``reg = value`` :rtype: ExpressionIndex """ _reg = ExpressionIndex(self.arch.get_reg_index(reg)) if flags is None: flags = architecture.FlagIndex(0) - return self.expr(LowLevelILOperation.LLIL_SET_REG, _reg, value, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_SET_REG, _reg, value, size=size, flags=flags, source_location=loc) def set_reg_split( self, size: int, hi: 'architecture.RegisterType', lo: 'architecture.RegisterType', value: ExpressionIndex, - flags: Optional['architecture.FlagType'] = None + flags: Optional['architecture.FlagType'] = None, loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``set_reg_split`` uses ``hi`` and ``lo`` as a single extended register setting ``hi:lo`` to the expression @@ -3960,6 +3962,7 @@ class LowLevelILFunction: :param str lo: the low register name :param ExpressionIndex value: an expression to set the split registers to :param str flags: which flags are set by this operation + :param ILSourceLocation loc: location of returned expression :return: The expression ``hi:lo = value`` :rtype: ExpressionIndex """ @@ -3967,11 +3970,11 @@ class LowLevelILFunction: _lo = ExpressionIndex(self.arch.get_reg_index(lo)) if flags is None: flags = architecture.FlagIndex(0) - return self.expr(LowLevelILOperation.LLIL_SET_REG_SPLIT, _hi, _lo, value, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_SET_REG_SPLIT, _hi, _lo, value, size=size, flags=flags, source_location=loc) def set_reg_stack_top_relative( self, size: int, reg_stack: 'architecture.RegisterStackType', entry: ExpressionIndex, value: ExpressionIndex, - flags: Optional['architecture.FlagType'] = None + flags: Optional['architecture.FlagType'] = None, loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``set_reg_stack_top_relative`` sets the top-relative entry ``entry`` of size ``size`` in register @@ -3982,17 +3985,18 @@ class LowLevelILFunction: :param ExpressionIndex entry: an expression for which stack entry to set :param ExpressionIndex value: an expression to set the entry to :param str flags: which flags are set by this operation + :param ILSourceLocation loc: location of returned expression :return: The expression ``reg_stack[entry] = value`` :rtype: ExpressionIndex """ _reg_stack = ExpressionIndex(self.arch.get_reg_stack_index(reg_stack)) if flags is None: flags = architecture.FlagIndex(0) - return self.expr(LowLevelILOperation.LLIL_SET_REG_STACK_REL, _reg_stack, entry, value, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_SET_REG_STACK_REL, _reg_stack, entry, value, size=size, flags=flags, source_location=loc) def reg_stack_push( self, size: int, reg_stack: 'architecture.RegisterStackType', value: ExpressionIndex, - flags: Optional['architecture.FlagType'] = None + flags: Optional['architecture.FlagType'] = None, loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``reg_stack_push`` pushes the expression ``value`` of size ``size`` onto the top of the register @@ -4002,38 +4006,45 @@ class LowLevelILFunction: :param str reg_stack: the register stack name :param ExpressionIndex value: an expression to push :param str flags: which flags are set by this operation + :param ILSourceLocation loc: location of returned expression :return: The expression ``reg_stack.push(value)`` :rtype: ExpressionIndex """ _reg_stack = ExpressionIndex(self.arch.get_reg_stack_index(reg_stack)) if flags is None: flags = architecture.FlagIndex(0) - return self.expr(LowLevelILOperation.LLIL_REG_STACK_PUSH, _reg_stack, value, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_REG_STACK_PUSH, _reg_stack, value, size=size, flags=flags, source_location=loc) - def set_flag(self, flag: 'architecture.FlagName', value: ExpressionIndex) -> ExpressionIndex: + def set_flag( + self, flag: 'architecture.FlagName', value: ExpressionIndex, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``set_flag`` sets the flag ``flag`` to the ExpressionIndex ``value`` :param str flag: the low register name :param ExpressionIndex value: an expression to set the flag to + :param ILSourceLocation loc: location of returned expression :return: The expression FLAG.flag = value :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_SET_FLAG, ExpressionIndex(self.arch.get_flag_by_name(flag)), value) + return self.expr(LowLevelILOperation.LLIL_SET_FLAG, ExpressionIndex(self.arch.get_flag_by_name(flag)), value, source_location=loc) - def load(self, size: int, addr: ExpressionIndex) -> ExpressionIndex: + def load(self, size: int, addr: ExpressionIndex, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``load`` Reads ``size`` bytes from the expression ``addr`` :param int size: number of bytes to read :param ExpressionIndex addr: the expression to read memory from + :param ILSourceLocation loc: location of returned expression :return: The expression ``[addr].size`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_LOAD, addr, size=size) + return self.expr(LowLevelILOperation.LLIL_LOAD, addr, size=size, source_location=loc) def store( - self, size: int, addr: ExpressionIndex, value: ExpressionIndex, flags: Optional['architecture.FlagName'] = None + self, size: int, addr: ExpressionIndex, value: ExpressionIndex, flags: Optional['architecture.FlagName'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``store`` Writes ``size`` bytes to expression ``addr`` read from expression ``value`` @@ -4042,60 +4053,69 @@ class LowLevelILFunction: :param ExpressionIndex addr: the expression to write to :param ExpressionIndex value: the expression to be written :param FlagName flags: which flags are set by this operation + :param ILSourceLocation loc: location of returned expression :return: The expression ``[addr].size = value`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_STORE, addr, value, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_STORE, addr, value, size=size, flags=flags, source_location=loc) - def push(self, size: int, value: ExpressionIndex) -> ExpressionIndex: + def push(self, size: int, value: ExpressionIndex, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``push`` writes ``size`` bytes from expression ``value`` to the stack, adjusting the stack by ``size``. :param int size: number of bytes to write and adjust the stack by :param ExpressionIndex value: the expression to write + :param ILSourceLocation loc: location of returned expression :return: The expression push(value) :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_PUSH, value, size=size) + return self.expr(LowLevelILOperation.LLIL_PUSH, value, size=size, source_location=loc) - def pop(self, size: int) -> ExpressionIndex: + def pop(self, size: int, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``pop`` reads ``size`` bytes from the stack, adjusting the stack by ``size``. :param int size: number of bytes to read from the stack + :param ILSourceLocation loc: location of returned expression :return: The expression ``pop`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_POP, size=size) + return self.expr(LowLevelILOperation.LLIL_POP, size=size, source_location=loc) - def reg(self, size: int, reg: 'architecture.RegisterType') -> ExpressionIndex: + def reg(self, size: int, reg: 'architecture.RegisterType', loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``reg`` returns a register of size ``size`` with name ``reg`` :param int size: the size of the register in bytes :param str reg: the name of the register + :param ILSourceLocation loc: location of returned expression :return: A register expression for the given string :rtype: ExpressionIndex """ _reg = ExpressionIndex(self.arch.get_reg_index(reg)) - return self.expr(LowLevelILOperation.LLIL_REG, _reg, size=size) + return self.expr(LowLevelILOperation.LLIL_REG, _reg, size=size, source_location=loc) - def reg_split(self, size: int, hi: 'architecture.RegisterType', lo: 'architecture.RegisterType') -> ExpressionIndex: + def reg_split( + self, size: int, hi: 'architecture.RegisterType', lo: 'architecture.RegisterType', + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``reg_split`` combines registers of size ``size`` with names ``hi`` and ``lo`` :param int size: the size of the register in bytes :param str hi: register holding high part of value :param str lo: register holding low part of value + :param ILSourceLocation loc: location of returned expression :return: The expression ``hi:lo`` :rtype: ExpressionIndex """ _hi = ExpressionIndex(self.arch.get_reg_index(hi)) _lo = ExpressionIndex(self.arch.get_reg_index(lo)) - return self.expr(LowLevelILOperation.LLIL_REG_SPLIT, _hi, _lo, size=size) + return self.expr(LowLevelILOperation.LLIL_REG_SPLIT, _hi, _lo, size=size, source_location=loc) def reg_stack_top_relative( - self, size: int, reg_stack: 'architecture.RegisterStackType', entry: ExpressionIndex + self, size: int, reg_stack: 'architecture.RegisterStackType', entry: ExpressionIndex, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``reg_stack_top_relative`` returns a register stack entry of size ``size`` at top-relative @@ -4104,114 +4124,130 @@ class LowLevelILFunction: :param int size: the size of the register in bytes :param str reg_stack: the name of the register stack :param ExpressionIndex entry: an expression for which stack entry to fetch + :param ILSourceLocation loc: location of returned expression :return: The expression ``reg_stack[entry]`` :rtype: ExpressionIndex """ _reg_stack = self.arch.get_reg_stack_index(reg_stack) - return self.expr(LowLevelILOperation.LLIL_REG_STACK_REL, _reg_stack, entry, size=size) + return self.expr(LowLevelILOperation.LLIL_REG_STACK_REL, _reg_stack, entry, size=size, source_location=loc) - def reg_stack_pop(self, size: int, reg_stack: 'architecture.RegisterStackType') -> ExpressionIndex: + def reg_stack_pop( + self, size: int, reg_stack: 'architecture.RegisterStackType', + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``reg_stack_pop`` returns the top entry of size ``size`` in register stack with name ``reg_stack``, and removes the entry from the stack :param int size: the size of the register in bytes :param str reg_stack: the name of the register stack + :param ILSourceLocation loc: location of returned expression :return: The expression ``reg_stack.pop`` :rtype: ExpressionIndex """ _reg_stack = ExpressionIndex(self.arch.get_reg_stack_index(reg_stack)) - return self.expr(LowLevelILOperation.LLIL_REG_STACK_POP, _reg_stack, size=size) + return self.expr(LowLevelILOperation.LLIL_REG_STACK_POP, _reg_stack, size=size, source_location=loc) - def const(self, size: int, value: int) -> ExpressionIndex: + def const(self, size: int, value: int, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``const`` returns an expression for the constant integer ``value`` with size ``size`` :param int size: the size of the constant in bytes :param int value: integer value of the constant + :param ILSourceLocation loc: location of returned expression :return: A constant expression of given value and size :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_CONST, ExpressionIndex(value), size=size) + return self.expr(LowLevelILOperation.LLIL_CONST, ExpressionIndex(value), size=size, source_location=loc) - def const_pointer(self, size: int, value: int) -> ExpressionIndex: + def const_pointer(self, size: int, value: int, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``const_pointer`` returns an expression for the constant pointer ``value`` with size ``size`` :param int size: the size of the pointer in bytes :param int value: address referenced by pointer + :param ILSourceLocation loc: location of returned expression :return: A constant expression of given value and size :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_CONST_PTR, value, size=size) + return self.expr(LowLevelILOperation.LLIL_CONST_PTR, value, size=size, source_location=loc) - def reloc_pointer(self, size: int, value: int) -> ExpressionIndex: + def reloc_pointer(self, size: int, value: int, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``reloc_pointer`` returns an expression for the constant relocated pointer ``value`` with size ``size`` :param int size: the size of the pointer in bytes :param int value: address referenced by pointer + :param ILSourceLocation loc: location of returned expression :return: A constant expression of given value and size :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_EXTERN_PTR, value, size=size) + return self.expr(LowLevelILOperation.LLIL_EXTERN_PTR, value, size=size, source_location=loc) - def float_const_raw(self, size: int, value: int) -> ExpressionIndex: + def float_const_raw(self, size: int, value: int, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``float_const_raw`` returns an expression for the constant raw binary floating point value ``value`` with size ``size`` :param int size: the size of the constant in bytes :param int value: integer value for the raw binary representation of the constant + :param ILSourceLocation loc: location of returned expression :return: A constant expression of given value and size :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_FLOAT_CONST, value, size=size) + return self.expr(LowLevelILOperation.LLIL_FLOAT_CONST, value, size=size, source_location=loc) - def float_const_single(self, value: float) -> ExpressionIndex: + def float_const_single(self, value: float, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``float_const_single`` returns an expression for the single precision floating point value ``value`` :param float value: float value for the constant + :param ILSourceLocation loc: location of returned expression :return: A constant expression of given value and size :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_FLOAT_CONST, struct.unpack("I", struct.pack("f", value))[0], size=4) + return self.expr(LowLevelILOperation.LLIL_FLOAT_CONST, struct.unpack("I", struct.pack("f", value))[0], size=4, source_location=loc) - def float_const_double(self, value: float) -> ExpressionIndex: + def float_const_double(self, value: float, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``float_const_double`` returns an expression for the double precision floating point value ``value`` :param float value: float value for the constant + :param ILSourceLocation loc: location of returned expression :return: A constant expression of given value and size :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_FLOAT_CONST, struct.unpack("Q", struct.pack("d", value))[0], size=8) + return self.expr(LowLevelILOperation.LLIL_FLOAT_CONST, struct.unpack("Q", struct.pack("d", value))[0], size=8, source_location=loc) - def flag(self, reg: 'architecture.FlagName') -> ExpressionIndex: + def flag(self, reg: 'architecture.FlagName', loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``flag`` returns a flag expression for the given flag name. :param architecture.FlagName reg: name of the flag expression to retrieve + :param ILSourceLocation loc: location of returned expression :return: A flag expression of given flag name :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_FLAG, self.arch.get_flag_by_name(reg)) + return self.expr(LowLevelILOperation.LLIL_FLAG, self.arch.get_flag_by_name(reg), source_location=loc) - def flag_bit(self, size: int, reg: 'architecture.FlagName', bit: int) -> ExpressionIndex: + def flag_bit( + self, size: int, reg: 'architecture.FlagName', bit: int, loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``flag_bit`` sets the flag named ``reg`` and size ``size`` to the constant integer value ``bit`` :param int size: the size of the flag :param str reg: flag value :param int bit: integer value to set the bit to + :param ILSourceLocation loc: location of returned expression :return: A constant expression of given value and size ``FLAG.reg = bit`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_FLAG_BIT, self.arch.get_flag_by_name(reg), bit, size=size) + return self.expr(LowLevelILOperation.LLIL_FLAG_BIT, self.arch.get_flag_by_name(reg), bit, size=size, source_location=loc) def add( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``add`` adds expression ``a`` to expression ``b`` potentially setting flags ``flags`` and returning @@ -4221,14 +4257,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``add.<size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_ADD, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_ADD, a, b, size=size, flags=flags, source_location=loc) def add_carry( self, size: int, a: ExpressionIndex, b: ExpressionIndex, carry: ExpressionIndex, - flags: Optional['architecture.FlagType'] = None + flags: Optional['architecture.FlagType'] = None, loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``add_carry`` adds with carry expression ``a`` to expression ``b`` potentially setting flags ``flags`` and @@ -4239,13 +4276,15 @@ class LowLevelILFunction: :param ExpressionIndex b: RHS expression :param ExpressionIndex carry: Carry flag expression :param str flags: flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``adc.<size>{<flags>}(a, b, carry)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_ADC, a, b, carry, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_ADC, a, b, carry, size=size, flags=flags, source_location=loc) def sub( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``sub`` subtracts expression ``b`` from expression ``a`` potentially setting flags ``flags`` and returning @@ -4255,14 +4294,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``sub.<size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_SUB, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_SUB, a, b, size=size, flags=flags, source_location=loc) def sub_borrow( self, size: int, a: ExpressionIndex, b: ExpressionIndex, carry: ExpressionIndex, - flags: Optional['architecture.FlagType'] = None + flags: Optional['architecture.FlagType'] = None, loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``sub_borrow`` subtracts with borrow expression ``b`` from expression ``a`` potentially setting flags ``flags`` @@ -4273,13 +4313,15 @@ class LowLevelILFunction: :param ExpressionIndex b: RHS expression :param ExpressionIndex carry: Carry flag expression :param str flags: flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``sbb.<size>{<flags>}(a, b, carry)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_SBB, a, b, carry, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_SBB, a, b, carry, size=size, flags=flags, source_location=loc) def and_expr( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``and_expr`` bitwise and's expression ``a`` and expression ``b`` potentially setting flags ``flags`` @@ -4289,13 +4331,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``and.<size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_AND, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_AND, a, b, size=size, flags=flags, source_location=loc) def or_expr( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``or_expr`` bitwise or's expression ``a`` and expression ``b`` potentially setting flags ``flags`` @@ -4305,13 +4349,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``or.<size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_OR, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_OR, a, b, size=size, flags=flags, source_location=loc) def xor_expr( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``xor_expr`` xor's expression ``a`` with expression ``b`` potentially setting flags ``flags`` @@ -4321,13 +4367,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``xor.<size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_XOR, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_XOR, a, b, size=size, flags=flags, source_location=loc) def shift_left( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``shift_left`` shifts left expression ``a`` by expression ``b`` from expression ``a`` potentially setting flags ``flags`` @@ -4337,13 +4385,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``lsl.<size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_LSL, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_LSL, a, b, size=size, flags=flags, source_location=loc) def logical_shift_right( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``logical_shift_right`` shifts logically right expression ``a`` by expression ``b`` potentially setting flags @@ -4353,13 +4403,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``lsr.<size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_LSR, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_LSR, a, b, size=size, flags=flags, source_location=loc) def arith_shift_right( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``arith_shift_right`` shifts arithmetic right expression ``a`` by expression ``b`` potentially setting flags @@ -4369,13 +4421,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``asr.<size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_ASR, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_ASR, a, b, size=size, flags=flags, source_location=loc) def rotate_left( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``rotate_left`` bitwise rotates left expression ``a`` by expression ``b`` potentially setting flags ``flags`` @@ -4385,14 +4439,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``rol.<size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_ROL, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_ROL, a, b, size=size, flags=flags, source_location=loc) def rotate_left_carry( self, size: int, a: ExpressionIndex, b: ExpressionIndex, carry: ExpressionIndex, - flags: Optional['architecture.FlagType'] = None + flags: Optional['architecture.FlagType'] = None, loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``rotate_left_carry`` bitwise rotates left with carry expression ``a`` by expression ``b`` potentially setting @@ -4403,13 +4458,15 @@ class LowLevelILFunction: :param ExpressionIndex b: RHS expression :param ExpressionIndex carry: Carry flag expression :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``rlc.<size>{<flags>}(a, b, carry)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_RLC, a, b, carry, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_RLC, a, b, carry, size=size, flags=flags, source_location=loc) def rotate_right( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``rotate_right`` bitwise rotates right expression ``a`` by expression ``b`` potentially setting flags ``flags`` @@ -4419,14 +4476,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``ror.<size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_ROR, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_ROR, a, b, size=size, flags=flags, source_location=loc) def rotate_right_carry( self, size: int, a: ExpressionIndex, b: ExpressionIndex, carry: ExpressionIndex, - flags: Optional['architecture.FlagType'] = None + flags: Optional['architecture.FlagType'] = None, loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``rotate_right_carry`` bitwise rotates right with carry expression ``a`` by expression ``b`` potentially setting @@ -4437,13 +4495,15 @@ class LowLevelILFunction: :param ExpressionIndex b: RHS expression :param ExpressionIndex carry: Carry flag expression :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``rrc.<size>{<flags>}(a, b, carry)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_RRC, a, b, carry, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_RRC, a, b, carry, size=size, flags=flags, source_location=loc) def mult( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``mult`` multiplies expression ``a`` by expression ``b`` potentially setting flags ``flags`` and returning an @@ -4453,13 +4513,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``mul.<size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_MUL, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_MUL, a, b, size=size, flags=flags, source_location=loc) def mult_double_prec_signed( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``mult_double_prec_signed`` multiplies signed with double precision expression ``a`` by expression ``b``, @@ -4469,13 +4531,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``muls.dp.<2*size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_MULS_DP, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_MULS_DP, a, b, size=size, flags=flags, source_location=loc) def mult_double_prec_unsigned( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``mult_double_prec_unsigned`` multiplies unsigned with double precision expression ``a`` by expression ``b``, @@ -4485,13 +4549,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``mulu.dp.<2*size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_MULU_DP, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_MULU_DP, a, b, size=size, flags=flags, source_location=loc) def div_signed( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``div_signed`` signed divide expression ``a`` by expression ``b`` potentially setting flags ``flags`` @@ -4501,13 +4567,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``divs.<size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_DIVS, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_DIVS, a, b, size=size, flags=flags, source_location=loc) def div_double_prec_signed( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``div_double_prec_signed`` signed double precision divide using expression ``a`` as a @@ -4518,13 +4586,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``divs.dp.<size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_DIVS_DP, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_DIVS_DP, a, b, size=size, flags=flags, source_location=loc) def div_unsigned( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``div_unsigned`` unsigned divide expression ``a`` by expression ``b`` potentially setting flags ``flags`` @@ -4534,13 +4604,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``divu.<size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_DIVU, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_DIVU, a, b, size=size, flags=flags, source_location=loc) def div_double_prec_unsigned( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``div_double_prec_unsigned`` unsigned double precision divide using expression ``a`` as @@ -4551,13 +4623,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``divu.dp.<size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_DIVU_DP, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_DIVU_DP, a, b, size=size, flags=flags, source_location=loc) def mod_signed( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``mod_signed`` signed modulus expression ``a`` by expression ``b`` potentially setting flags ``flags`` @@ -4567,13 +4641,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``mods.<size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_MODS, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_MODS, a, b, size=size, flags=flags, source_location=loc) def mod_double_prec_signed( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``mod_double_prec_signed`` signed double precision modulus using expression ``a`` as a single @@ -4584,13 +4660,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``mods.dp.<size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_MODS_DP, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_MODS_DP, a, b, size=size, flags=flags, source_location=loc) def mod_unsigned( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``mod_unsigned`` unsigned modulus expression ``a`` by expression ``b`` potentially setting flags ``flags`` @@ -4600,13 +4678,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``modu.<size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_MODU, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_MODU, a, b, size=size, flags=flags, source_location=loc) def mod_double_prec_unsigned( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``mod_double_prec_unsigned`` unsigned double precision modulus using expression ``a`` as @@ -4617,141 +4697,169 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``modu.dp.<size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_MODU_DP, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_MODU_DP, a, b, size=size, flags=flags, source_location=loc) - def neg_expr(self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None) -> ExpressionIndex: + def neg_expr( + self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``neg_expr`` two's complement sign negation of expression ``value`` of size ``size`` potentially setting flags :param int size: the size of the result in bytes :param ExpressionIndex value: the expression to negate :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``neg.<size>{<flags>}(value)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_NEG, value, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_NEG, value, size=size, flags=flags, source_location=loc) - def not_expr(self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None) -> ExpressionIndex: + def not_expr( + self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``not_expr`` bitwise inverse of expression ``value`` of size ``size`` potentially setting flags :param int size: the size of the result in bytes :param ExpressionIndex value: the expression to bitwise invert :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``not.<size>{<flags>}(value)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_NOT, value, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_NOT, value, size=size, flags=flags, source_location=loc) - def sign_extend(self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None) -> ExpressionIndex: + def sign_extend( + self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``sign_extend`` two's complement sign-extends the expression in ``value`` to ``size`` bytes :param int size: the size of the result in bytes :param ExpressionIndex value: the expression to sign extend :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``sx.<size>(value)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_SX, value, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_SX, value, size=size, flags=flags, source_location=loc) - def zero_extend(self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None) -> ExpressionIndex: + def zero_extend( + self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``zero_extend`` zero-extends the expression in ``value`` to ``size`` bytes :param int size: the size of the result in bytes :param ExpressionIndex value: the expression to zero extend + :param ILSourceLocation loc: location of returned expression :return: The expression ``zx.<size>(value)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_ZX, value, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_ZX, value, size=size, flags=flags, source_location=loc) - def low_part(self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None) -> ExpressionIndex: + def low_part( + self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``low_part`` truncates ``value`` to ``size`` bytes :param int size: the size of the result in bytes :param ExpressionIndex value: the expression to truncate + :param ILSourceLocation loc: location of returned expression :return: The expression ``(value).<size>`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_LOW_PART, value, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_LOW_PART, value, size=size, flags=flags, source_location=loc) - def jump(self, dest: ExpressionIndex) -> ExpressionIndex: + def jump(self, dest: ExpressionIndex, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``jump`` returns an expression which jumps (branches) to the expression ``dest`` :param ExpressionIndex dest: the expression to jump to + :param ILSourceLocation loc: location of returned expression :return: The expression ``jump(dest)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_JUMP, dest) + return self.expr(LowLevelILOperation.LLIL_JUMP, dest, source_location=loc) - def call(self, dest: ExpressionIndex) -> ExpressionIndex: + def call(self, dest: ExpressionIndex, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``call`` returns an expression which first pushes the address of the next instruction onto the stack then jumps (branches) to the expression ``dest`` :param ExpressionIndex dest: the expression to call + :param ILSourceLocation loc: location of returned expression :return: The expression ``call(dest)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_CALL, dest) + return self.expr(LowLevelILOperation.LLIL_CALL, dest, source_location=loc) - def call_stack_adjust(self, dest: ExpressionIndex, stack_adjust: int) -> ExpressionIndex: + def call_stack_adjust(self, dest: ExpressionIndex, stack_adjust: int, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``call_stack_adjust`` returns an expression which first pushes the address of the next instruction onto the stack then jumps (branches) to the expression ``dest``. After the function exits, ``stack_adjust`` is added to the stack pointer register. :param ExpressionIndex dest: the expression to call + :param ILSourceLocation loc: location of returned expression :return: The expression ``call(dest), stack += stack_adjust`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_CALL_STACK_ADJUST, dest, stack_adjust) + return self.expr(LowLevelILOperation.LLIL_CALL_STACK_ADJUST, dest, stack_adjust, source_location=loc) - def tailcall(self, dest: ExpressionIndex) -> ExpressionIndex: + def tailcall(self, dest: ExpressionIndex, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``tailcall`` returns an expression which jumps (branches) to the expression ``dest`` :param ExpressionIndex dest: the expression to jump to + :param ILSourceLocation loc: location of returned expression :return: The expression ``tailcall(dest)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_TAILCALL, dest) + return self.expr(LowLevelILOperation.LLIL_TAILCALL, dest, source_location=loc) - def ret(self, dest: ExpressionIndex) -> ExpressionIndex: + def ret(self, dest: ExpressionIndex, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``ret`` returns an expression which jumps (branches) to the expression ``dest``. ``ret`` is a special alias for jump that makes the disassembler stop disassembling. :param ExpressionIndex dest: the expression to jump to + :param ILSourceLocation loc: location of returned expression :return: The expression ``jump(dest)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_RET, dest) + return self.expr(LowLevelILOperation.LLIL_RET, dest, source_location=loc) - def no_ret(self) -> ExpressionIndex: + def no_ret(self, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``no_ret`` returns an expression that halts disassembly + :param ILSourceLocation loc: location of returned expression :return: The expression ``noreturn`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_NORET) + return self.expr(LowLevelILOperation.LLIL_NORET, source_location=loc) def flag_condition( self, cond: Union[str, LowLevelILFlagCondition, int], - sem_class: Optional['architecture.SemanticClassType'] = None + sem_class: Optional['architecture.SemanticClassType'] = None, loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``flag_condition`` returns a flag_condition expression for the given LowLevelILFlagCondition :param LowLevelILFlagCondition cond: Flag condition expression to retrieve :param str sem_class: Optional semantic flag class + :param ILSourceLocation loc: location of returned expression :return: A flag_condition expression :rtype: ExpressionIndex """ @@ -4760,20 +4868,23 @@ class LowLevelILFunction: elif isinstance(cond, LowLevelILFlagCondition): cond = cond.value class_index = self.arch.get_semantic_flag_class_index(sem_class) - return self.expr(LowLevelILOperation.LLIL_FLAG_COND, cond, architecture.SemanticClassIndex(class_index)) + return self.expr(LowLevelILOperation.LLIL_FLAG_COND, cond, architecture.SemanticClassIndex(class_index), source_location=loc) - def flag_group(self, sem_group: 'architecture.SemanticGroupName') -> ExpressionIndex: + def flag_group(self, sem_group: 'architecture.SemanticGroupName', loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``flag_group`` returns a flag_group expression for the given semantic flag group :param SemanticGroupName sem_group: Semantic flag group to access + :param ILSourceLocation loc: location of returned expression :return: A flag_group expression :rtype: ExpressionIndex """ group = self.arch.get_semantic_flag_group_index(sem_group) - return self.expr(LowLevelILOperation.LLIL_FLAG_GROUP, group) + return self.expr(LowLevelILOperation.LLIL_FLAG_GROUP, group, source_location=loc) - def compare_equal(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex: + def compare_equal( + self, size: int, a: ExpressionIndex, b: ExpressionIndex, loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``compare_equal`` returns comparison expression of size ``size`` checking if expression ``a`` is equal to expression ``b`` @@ -4781,12 +4892,15 @@ class LowLevelILFunction: :param int size: size in bytes :param ExpressionIndex a: LHS of comparison :param ExpressionIndex b: RHS of comparison + :param ILSourceLocation loc: location of returned expression :return: a comparison expression. :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_CMP_E, a, b, size=size) + return self.expr(LowLevelILOperation.LLIL_CMP_E, a, b, size=size, source_location=loc) - def compare_not_equal(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex: + def compare_not_equal( + self, size: int, a: ExpressionIndex, b: ExpressionIndex, loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``compare_not_equal`` returns comparison expression of size ``size`` checking if expression ``a`` is not equal to expression ``b`` @@ -4794,12 +4908,15 @@ class LowLevelILFunction: :param int size: size in bytes :param ExpressionIndex a: LHS of comparison :param ExpressionIndex b: RHS of comparison + :param ILSourceLocation loc: location of returned expression :return: a comparison expression. :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_CMP_NE, a, b, size=size) + return self.expr(LowLevelILOperation.LLIL_CMP_NE, a, b, size=size, source_location=loc) - def compare_signed_less_than(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex: + def compare_signed_less_than( + self, size: int, a: ExpressionIndex, b: ExpressionIndex, loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``compare_signed_less_than`` returns comparison expression of size ``size`` checking if expression ``a`` is signed less than expression ``b`` @@ -4807,12 +4924,15 @@ class LowLevelILFunction: :param int size: size in bytes :param ExpressionIndex a: LHS of comparison :param ExpressionIndex b: RHS of comparison + :param ILSourceLocation loc: location of returned expression :return: a comparison expression. :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_CMP_SLT, a, b, size=size) + return self.expr(LowLevelILOperation.LLIL_CMP_SLT, a, b, size=size, source_location=loc) - def compare_unsigned_less_than(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex: + def compare_unsigned_less_than( + self, size: int, a: ExpressionIndex, b: ExpressionIndex, loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``compare_unsigned_less_than`` returns comparison expression of size ``size`` checking if expression ``a`` is unsigned less than expression ``b`` @@ -4820,12 +4940,15 @@ class LowLevelILFunction: :param int size: size in bytes :param ExpressionIndex a: LHS of comparison :param ExpressionIndex b: RHS of comparison + :param ILSourceLocation loc: location of returned expression :return: a comparison expression. :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_CMP_ULT, a, b, size=size) + return self.expr(LowLevelILOperation.LLIL_CMP_ULT, a, b, size=size, source_location=loc) - def compare_signed_less_equal(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex: + def compare_signed_less_equal( + self, size: int, a: ExpressionIndex, b: ExpressionIndex, loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``compare_signed_less_equal`` returns comparison expression of size ``size`` checking if expression ``a`` is signed less than or equal to expression ``b`` @@ -4833,12 +4956,15 @@ class LowLevelILFunction: :param int size: size in bytes :param ExpressionIndex a: LHS of comparison :param ExpressionIndex b: RHS of comparison + :param ILSourceLocation loc: location of returned expression :return: a comparison expression. :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_CMP_SLE, a, b, size=size) + return self.expr(LowLevelILOperation.LLIL_CMP_SLE, a, b, size=size, source_location=loc) - def compare_unsigned_less_equal(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex: + def compare_unsigned_less_equal( + self, size: int, a: ExpressionIndex, b: ExpressionIndex, loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``compare_unsigned_less_equal`` returns comparison expression of size ``size`` checking if expression ``a`` is unsigned less than or equal to expression ``b`` @@ -4846,12 +4972,15 @@ class LowLevelILFunction: :param int size: size in bytes :param ExpressionIndex a: LHS of comparison :param ExpressionIndex b: RHS of comparison + :param ILSourceLocation loc: location of returned expression :return: a comparison expression. :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_CMP_ULE, a, b, size=size) + return self.expr(LowLevelILOperation.LLIL_CMP_ULE, a, b, size=size, source_location=loc) - def compare_signed_greater_equal(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex: + def compare_signed_greater_equal( + self, size: int, a: ExpressionIndex, b: ExpressionIndex, loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``compare_signed_greater_equal`` returns comparison expression of size ``size`` checking if expression ``a`` is signed greater than or equal to expression ``b`` @@ -4859,12 +4988,15 @@ class LowLevelILFunction: :param int size: size in bytes :param ExpressionIndex a: LHS of comparison :param ExpressionIndex b: RHS of comparison + :param ILSourceLocation loc: location of returned expression :return: a comparison expression. :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_CMP_SGE, a, b, size=size) + return self.expr(LowLevelILOperation.LLIL_CMP_SGE, a, b, size=size, source_location=loc) - def compare_unsigned_greater_equal(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex: + def compare_unsigned_greater_equal( + self, size: int, a: ExpressionIndex, b: ExpressionIndex, loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``compare_unsigned_greater_equal`` returns comparison expression of size ``size`` checking if expression ``a`` is unsigned greater than or equal to expression ``b`` @@ -4872,12 +5004,15 @@ class LowLevelILFunction: :param int size: size in bytes :param ExpressionIndex a: LHS of comparison :param ExpressionIndex b: RHS of comparison + :param ILSourceLocation loc: location of returned expression :return: a comparison expression. :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_CMP_UGE, a, b, size=size) + return self.expr(LowLevelILOperation.LLIL_CMP_UGE, a, b, size=size, source_location=loc) - def compare_signed_greater_than(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex: + def compare_signed_greater_than( + self, size: int, a: ExpressionIndex, b: ExpressionIndex, loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``compare_signed_greater_than`` returns comparison expression of size ``size`` checking if expression ``a`` is signed greater than or equal to expression ``b`` @@ -4885,12 +5020,15 @@ class LowLevelILFunction: :param int size: size in bytes :param ExpressionIndex a: LHS of comparison :param ExpressionIndex b: RHS of comparison + :param ILSourceLocation loc: location of returned expression :return: a comparison expression. :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_CMP_SGT, a, b, size=size) + return self.expr(LowLevelILOperation.LLIL_CMP_SGT, a, b, size=size, source_location=loc) - def compare_unsigned_greater_than(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex: + def compare_unsigned_greater_than( + self, size: int, a: ExpressionIndex, b: ExpressionIndex, loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``compare_unsigned_greater_than`` returns comparison expression of size ``size`` checking if expression ``a`` is unsigned greater than or equal to expression ``b`` @@ -4898,12 +5036,13 @@ class LowLevelILFunction: :param int size: size in bytes :param ExpressionIndex a: LHS of comparison :param ExpressionIndex b: RHS of comparison + :param ILSourceLocation loc: location of returned expression :return: a comparison expression. :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_CMP_UGT, a, b, size=size) + return self.expr(LowLevelILOperation.LLIL_CMP_UGT, a, b, size=size, source_location=loc) - def test_bit(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex: + def test_bit(self, size: int, a: ExpressionIndex, b: ExpressionIndex, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``test_bit`` returns an expression of size ``size`` that tells whether expression ``a`` has its bit with an index of the expression ``b`` is set @@ -4911,38 +5050,42 @@ class LowLevelILFunction: :param int size: size in bytes :param ExpressionIndex a: an expression to be tested :param ExpressionIndex b: an expression for the index of the big + :param ILSourceLocation loc: location of returned expression :return: the result expression. :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_TEST_BIT, a, b, size=size) + return self.expr(LowLevelILOperation.LLIL_TEST_BIT, a, b, size=size, source_location=loc) - def bool_to_int(self, size: int, a: ExpressionIndex) -> ExpressionIndex: + def bool_to_int(self, size: int, a: ExpressionIndex, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``bool_to_int`` returns an expression of size ``size`` converting the boolean expression ``a`` to an integer :param int size: size in bytes :param ExpressionIndex a: boolean expression to be converted + :param ILSourceLocation loc: location of returned expression :return: the converted integer expression. :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_BOOL_TO_INT, a, size=size) + return self.expr(LowLevelILOperation.LLIL_BOOL_TO_INT, a, size=size, source_location=loc) - def system_call(self) -> ExpressionIndex: + def system_call(self, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``system_call`` return a system call expression. + :param ILSourceLocation loc: location of returned expression :return: a system call expression. :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_SYSCALL) + return self.expr(LowLevelILOperation.LLIL_SYSCALL, source_location=loc) def intrinsic( self, outputs: List[Union[ILRegisterType, ILFlag, 'architecture.RegisterInfo']], intrinsic: 'architecture.IntrinsicType', - params: List[ExpressionIndex], flags: Optional['architecture.FlagType'] = None + params: List[ExpressionIndex], flags: Optional['architecture.FlagType'] = None, loc: Optional['ILSourceLocation'] = None ): """ ``intrinsic`` return an intrinsic expression. + :param ILSourceLocation loc: location of returned expression :return: an intrinsic expression. :rtype: ExpressionIndex """ @@ -4969,61 +5112,67 @@ class LowLevelILFunction: call_param = self.expr(LowLevelILOperation.LLIL_CALL_PARAM, len(params), self.add_operand_list(param_list)) return self.expr( LowLevelILOperation.LLIL_INTRINSIC, len(outputs), self.add_operand_list(output_list), - self.arch.get_intrinsic_index(intrinsic), call_param, flags=flags + self.arch.get_intrinsic_index(intrinsic), call_param, flags=flags, source_location=loc ) - def breakpoint(self) -> ExpressionIndex: + def breakpoint(self, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``breakpoint`` returns a processor breakpoint expression. + :param ILSourceLocation loc: location of returned expression :return: a breakpoint expression. :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_BP) + return self.expr(LowLevelILOperation.LLIL_BP, source_location=loc) - def trap(self, value: int) -> ExpressionIndex: + def trap(self, value: int, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``trap`` returns a processor trap (interrupt) expression of the given integer ``value``. :param int value: trap (interrupt) number + :param ILSourceLocation loc: location of returned expression :return: a trap expression. :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_TRAP, value) + return self.expr(LowLevelILOperation.LLIL_TRAP, value, source_location=loc) - def undefined(self) -> ExpressionIndex: + def undefined(self, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``undefined`` returns the undefined expression. This should be used for instructions which perform functions but aren't important for dataflow or partial emulation purposes. + :param ILSourceLocation loc: location of returned expression :return: the undefined expression. :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_UNDEF) + return self.expr(LowLevelILOperation.LLIL_UNDEF, source_location=loc) - def unimplemented(self) -> ExpressionIndex: + def unimplemented(self, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``unimplemented`` returns the unimplemented expression. This should be used for all instructions which aren't implemented. + :param ILSourceLocation loc: location of returned expression :return: the unimplemented expression. :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_UNIMPL) + return self.expr(LowLevelILOperation.LLIL_UNIMPL, source_location=loc) - def unimplemented_memory_ref(self, size: int, addr: ExpressionIndex) -> ExpressionIndex: + def unimplemented_memory_ref(self, size: int, addr: ExpressionIndex, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``unimplemented_memory_ref`` a memory reference to expression ``addr`` of size ``size`` with unimplemented operation. :param int size: size in bytes of the memory reference :param ExpressionIndex addr: expression to reference memory + :param ILSourceLocation loc: location of returned expression :return: the unimplemented memory reference expression. :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_UNIMPL_MEM, addr, size=size) + return self.expr(LowLevelILOperation.LLIL_UNIMPL_MEM, addr, size=size, source_location=loc) def float_add( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``float_add`` adds floating point expression ``a`` to expression ``b`` potentially setting flags ``flags`` @@ -5033,13 +5182,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``fadd.<size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_FADD, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_FADD, a, b, size=size, flags=flags, source_location=loc) def float_sub( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``float_sub`` subtracts floating point expression ``b`` from expression ``a`` potentially setting flags ``flags`` @@ -5049,13 +5200,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``fsub.<size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_FSUB, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_FSUB, a, b, size=size, flags=flags, source_location=loc) def float_mult( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``float_mult`` multiplies floating point expression ``a`` by expression ``b`` potentially setting flags ``flags`` @@ -5065,13 +5218,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``fmul.<size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_FMUL, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_FMUL, a, b, size=size, flags=flags, source_location=loc) def float_div( - self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``float_div`` divides floating point expression ``a`` by expression ``b`` potentially setting flags ``flags`` @@ -5081,73 +5236,95 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``fdiv.<size>{<flags>}(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_FDIV, a, b, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_FDIV, a, b, size=size, flags=flags, source_location=loc) - def float_sqrt(self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None) -> ExpressionIndex: + def float_sqrt( + self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``float_sqrt`` returns square root of floating point expression ``value`` of size ``size`` potentially setting flags :param int size: the size of the result in bytes :param ExpressionIndex value: the expression to calculate the square root of :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``sqrt.<size>{<flags>}(value)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_FSQRT, value, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_FSQRT, value, size=size, flags=flags, source_location=loc) - def float_neg(self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None) -> ExpressionIndex: + def float_neg( + self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``float_neg`` returns sign negation of floating point expression ``value`` of size ``size`` potentially setting flags :param int size: the size of the result in bytes :param ExpressionIndex value: the expression to negate :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``fneg.<size>{<flags>}(value)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_FNEG, value, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_FNEG, value, size=size, flags=flags, source_location=loc) - def float_abs(self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None) -> ExpressionIndex: + def float_abs( + self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``float_abs`` returns absolute value of floating point expression ``value`` of size ``size`` potentially setting flags :param int size: the size of the result in bytes :param ExpressionIndex value: the expression to get the absolute value of :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``fabs.<size>{<flags>}(value)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_FABS, value, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_FABS, value, size=size, flags=flags, source_location=loc) - def float_to_int(self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None) -> ExpressionIndex: + def float_to_int( + self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``float_to_int`` returns integer value of floating point expression ``value`` of size ``size`` potentially setting flags :param int size: the size of the result in bytes :param ExpressionIndex value: the expression to convert to an int :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``int.<size>{<flags>}(value)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_FLOAT_TO_INT, value, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_FLOAT_TO_INT, value, size=size, flags=flags, source_location=loc) - def int_to_float(self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None) -> ExpressionIndex: + def int_to_float( + self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``int_to_float`` returns floating point value of integer expression ``value`` of size ``size`` potentially setting flags :param int size: the size of the result in bytes :param ExpressionIndex value: the expression to convert to a float :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``float.<size>{<flags>}(value)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_INT_TO_FLOAT, value, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_INT_TO_FLOAT, value, size=size, flags=flags, source_location=loc) def float_convert( - self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None + self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None ) -> ExpressionIndex: """ ``int_to_float`` converts floating point value of expression ``value`` to size ``size`` potentially setting flags @@ -5155,60 +5332,79 @@ class LowLevelILFunction: :param int size: the size of the result in bytes :param ExpressionIndex value: the expression to negate :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``fconvert.<size>{<flags>}(value)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_FLOAT_CONV, value, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_FLOAT_CONV, value, size=size, flags=flags, source_location=loc) - def round_to_int(self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None) -> ExpressionIndex: + def round_to_int( + self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``round_to_int`` rounds a floating point value to the nearest integer :param int size: the size of the result in bytes :param ExpressionIndex value: the expression to round to the nearest integer :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``roundint.<size>{<flags>}(value)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_ROUND_TO_INT, value, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_ROUND_TO_INT, value, size=size, flags=flags, source_location=loc) - def floor(self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None) -> ExpressionIndex: + def floor( + self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``floor`` rounds a floating point value to an integer towards negative infinity :param int size: the size of the result in bytes :param ExpressionIndex value: the expression to round down :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``roundint.<size>{<flags>}(value)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_FLOOR, value, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_FLOOR, value, size=size, flags=flags, source_location=loc) - def ceil(self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None) -> ExpressionIndex: + def ceil( + self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``ceil`` rounds a floating point value to an integer towards positive infinity :param int size: the size of the result in bytes :param ExpressionIndex value: the expression to round up :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``roundint.<size>{<flags>}(value)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_CEIL, value, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_CEIL, value, size=size, flags=flags, source_location=loc) - def float_trunc(self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None) -> ExpressionIndex: + def float_trunc( + self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``float_trunc`` rounds a floating point value to an integer towards zero :param int size: the size of the result in bytes :param ExpressionIndex value: the expression to truncate :param str flags: optional, flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``roundint.<size>{<flags>}(value)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_FTRUNC, value, size=size, flags=flags) + return self.expr(LowLevelILOperation.LLIL_FTRUNC, value, size=size, flags=flags, source_location=loc) - def float_compare_equal(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex: + def float_compare_equal( + self, size: int, a: ExpressionIndex, b: ExpressionIndex, loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``float_compare_equal`` returns floating point comparison expression of size ``size`` checking if expression ``a`` is equal to expression ``b`` @@ -5217,12 +5413,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``a f== b`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_FCMP_E, a, b) + return self.expr(LowLevelILOperation.LLIL_FCMP_E, a, b, source_location=loc) - def float_compare_not_equal(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex: + def float_compare_not_equal( + self, size: int, a: ExpressionIndex, b: ExpressionIndex, loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``float_compare_not_equal`` returns floating point comparison expression of size ``size`` checking if expression ``a`` is not equal to expression ``b`` @@ -5231,12 +5430,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``a f!= b`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_FCMP_NE, a, b) + return self.expr(LowLevelILOperation.LLIL_FCMP_NE, a, b, source_location=loc) - def float_compare_less_than(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex: + def float_compare_less_than( + self, size: int, a: ExpressionIndex, b: ExpressionIndex, loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``float_compare_less_than`` returns floating point comparison expression of size ``size`` checking if expression ``a`` is less than expression ``b`` @@ -5245,12 +5447,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``a f< b`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_FCMP_LT, a, b) + return self.expr(LowLevelILOperation.LLIL_FCMP_LT, a, b, source_location=loc) - def float_compare_less_equal(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex: + def float_compare_less_equal( + self, size: int, a: ExpressionIndex, b: ExpressionIndex, loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``float_compare_less_equal`` returns floating point comparison expression of size ``size`` checking if expression ``a`` is less than or equal to expression ``b`` @@ -5259,12 +5464,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``a f<= b`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_FCMP_LE, a, b) + return self.expr(LowLevelILOperation.LLIL_FCMP_LE, a, b, source_location=loc) - def float_compare_greater_equal(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex: + def float_compare_greater_equal( + self, size: int, a: ExpressionIndex, b: ExpressionIndex, loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``float_compare_greater_equal`` returns floating point comparison expression of size ``size`` checking if expression ``a`` is greater than or equal to expression ``b`` @@ -5273,12 +5481,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``a f>= b`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_FCMP_GE, a, b) + return self.expr(LowLevelILOperation.LLIL_FCMP_GE, a, b, source_location=loc) - def float_compare_greater_than(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex: + def float_compare_greater_than( + self, size: int, a: ExpressionIndex, b: ExpressionIndex, loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``float_compare_greater_than`` returns floating point comparison expression of size ``size`` checking if expression ``a`` is greater than expression ``b`` @@ -5287,12 +5498,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``a f> b`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_FCMP_GT, a, b) + return self.expr(LowLevelILOperation.LLIL_FCMP_GT, a, b, source_location=loc) - def float_compare_ordered(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex: + def float_compare_ordered( + self, size: int, a: ExpressionIndex, b: ExpressionIndex, loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``float_compare_ordered`` returns floating point comparison expression of size ``size`` checking if expression ``a`` is ordered relative to expression ``b`` @@ -5301,12 +5515,15 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``is_ordered(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_FCMP_O, a, b) + return self.expr(LowLevelILOperation.LLIL_FCMP_O, a, b, source_location=loc) - def float_compare_unordered(self, size: int, a: ExpressionIndex, b: ExpressionIndex) -> ExpressionIndex: + def float_compare_unordered( + self, size: int, a: ExpressionIndex, b: ExpressionIndex, loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``float_compare_unordered`` returns floating point comparison expression of size ``size`` checking if expression ``a`` is unordered relative to expression ``b`` @@ -5315,22 +5532,30 @@ class LowLevelILFunction: :param ExpressionIndex a: LHS expression :param ExpressionIndex b: RHS expression :param str flags: flags to set + :param ILSourceLocation loc: location of returned expression :return: The expression ``is_unordered(a, b)`` :rtype: ExpressionIndex """ - return self.expr(LowLevelILOperation.LLIL_FCMP_UO, a, b) + return self.expr(LowLevelILOperation.LLIL_FCMP_UO, a, b, source_location=loc) - def goto(self, label: LowLevelILLabel) -> ExpressionIndex: + def goto(self, label: LowLevelILLabel, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``goto`` returns a goto expression which jumps to the provided LowLevelILLabel. :param LowLevelILLabel label: Label to jump to + :param ILSourceLocation loc: location of returned expression :return: the ExpressionIndex that jumps to the provided label :rtype: ExpressionIndex """ - return ExpressionIndex(core.BNLowLevelILGoto(self.handle, label.handle)) + if loc is not None: + return ExpressionIndex(core.BNLowLevelILGotoWithLocation(self.handle, label.handle, loc.address, loc.source_operand)) + else: + return ExpressionIndex(core.BNLowLevelILGoto(self.handle, label.handle)) - def if_expr(self, operand: ExpressionIndex, t: LowLevelILLabel, f: LowLevelILLabel) -> ExpressionIndex: + def if_expr( + self, operand: ExpressionIndex, t: LowLevelILLabel, f: LowLevelILLabel, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``if_expr`` returns the ``if`` expression which depending on condition ``operand`` jumps to the LowLevelILLabel ``t`` when the condition expression ``operand`` is non-zero and ``f`` when it's zero. @@ -5338,10 +5563,14 @@ class LowLevelILFunction: :param ExpressionIndex operand: comparison expression to evaluate. :param LowLevelILLabel t: Label for the true branch :param LowLevelILLabel f: Label for the false branch + :param ILSourceLocation loc: location of returned expression :return: the ExpressionIndex for the if expression :rtype: ExpressionIndex """ - return ExpressionIndex(core.BNLowLevelILIf(self.handle, operand, t.handle, f.handle)) + if loc is not None: + return ExpressionIndex(core.BNLowLevelILIfWithLocation(self.handle, operand, t.handle, f.handle, loc.address, loc.source_operand)) + else: + return ExpressionIndex(core.BNLowLevelILIf(self.handle, operand, t.handle, f.handle)) def mark_label(self, label: LowLevelILLabel) -> None: """ @@ -5352,12 +5581,13 @@ class LowLevelILFunction: """ core.BNLowLevelILMarkLabel(self.handle, label.handle) - def add_label_map(self, labels: Dict[int, LowLevelILLabel]) -> ExpressionIndex: + def add_label_map(self, labels: Dict[int, LowLevelILLabel], loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex: """ ``add_label_map`` returns a label list expression for the given list of LowLevelILLabel objects. :param labels: the list of LowLevelILLabel to get a label list expression from :type labels: dict(int, LowLevelILLabel) + :param ILSourceLocation loc: location of returned expression :return: the label list expression :rtype: ExpressionIndex """ |
