fix negative address in some places (#2645)

* fix negative

* fix negative

* fix negative

* fix negative

* fix negative

* fix negative
pull/2650/head
patryk4815 12 months ago committed by GitHub
parent 652b29945a
commit 2fb8a687ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -316,7 +316,9 @@ class DisassemblyAssistant:
# Don't mask immediates - some computations depend on their signed values # Don't mask immediates - some computations depend on their signed values
if op.type is not CS_OP_IMM: if op.type is not CS_OP_IMM:
op.before_value &= pwndbg.aglib.arch.ptrmask op.before_value &= pwndbg.aglib.arch.ptrmask
op.symbol = MemoryColor.attempt_colorized_symbol(op.before_value)
if op.before_value >= 0:
op.symbol = MemoryColor.attempt_colorized_symbol(op.before_value)
op.before_value_resolved = self._resolve_used_value( op.before_value_resolved = self._resolve_used_value(
op.before_value, instruction, op, emu op.before_value, instruction, op, emu
@ -1000,7 +1002,7 @@ class DisassemblyAssistant:
left, right = instruction.operands left, right = instruction.operands
# If we already used emulation, use the result, otherwise take the source operand before_value # If we already used emulation, use the result, otherwise take the source operand before_value
result = left.after_value or right.before_value result = left.after_value or right.before_value
if result is not None: if result is not None and result >= 0:
TELESCOPE_DEPTH = max(0, int(pwndbg.config.disasm_telescope_depth)) TELESCOPE_DEPTH = max(0, int(pwndbg.config.disasm_telescope_depth))
telescope_addresses = self._telescope( telescope_addresses = self._telescope(

@ -106,6 +106,8 @@ def resolve_addr(addr: int) -> str | None:
Resolution is performed in the following order: Resolution is performed in the following order:
- Global scope symbols. - Global scope symbols.
""" """
assert addr >= 0, "address must be positive"
symbol_name = pwndbg.dbg.selected_inferior().symbol_name_at_address(addr) symbol_name = pwndbg.dbg.selected_inferior().symbol_name_at_address(addr)
if symbol_name: if symbol_name:
return symbol_name return symbol_name

@ -29,6 +29,8 @@ def find(address: int | pwndbg.dbg_mod.Value | None) -> pwndbg.lib.memory.Page |
return None return None
address = int(address) address = int(address)
if address < 0:
return None
for page in get(): for page in get():
if address in page: if address in page:

@ -54,6 +54,7 @@ def get(
""" """
if address is None: if address is None:
return None return None
assert address >= 0, "address must be positive"
limit = int(limit) limit = int(limit)
@ -138,7 +139,7 @@ def format(
arrow_right = c.arrow(f" {config_arrow_right} ") arrow_right = c.arrow(f" {config_arrow_right} ")
# Colorize the chain # Colorize the chain
rest = [M.get_address_and_symbol(link) for link in chain] rest = [M.get_address_and_symbol(addr) if addr >= 0 else "" for addr in chain]
# If the dereference limit is zero, skip any enhancements. # If the dereference limit is zero, skip any enhancements.
if limit == 0: if limit == 0:

Loading…
Cancel
Save