diff --git a/pwndbg/aglib/disasm/arch.py b/pwndbg/aglib/disasm/arch.py index d88618a6c..4f522f8bf 100644 --- a/pwndbg/aglib/disasm/arch.py +++ b/pwndbg/aglib/disasm/arch.py @@ -316,7 +316,9 @@ class DisassemblyAssistant: # Don't mask immediates - some computations depend on their signed values if op.type is not CS_OP_IMM: 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, instruction, op, emu @@ -1000,7 +1002,7 @@ class DisassemblyAssistant: left, right = instruction.operands # If we already used emulation, use the result, otherwise take the source operand 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_addresses = self._telescope( diff --git a/pwndbg/aglib/symbol.py b/pwndbg/aglib/symbol.py index 58e8ea628..4c1ba93e8 100644 --- a/pwndbg/aglib/symbol.py +++ b/pwndbg/aglib/symbol.py @@ -106,6 +106,8 @@ def resolve_addr(addr: int) -> str | None: Resolution is performed in the following order: - Global scope symbols. """ + assert addr >= 0, "address must be positive" + symbol_name = pwndbg.dbg.selected_inferior().symbol_name_at_address(addr) if symbol_name: return symbol_name diff --git a/pwndbg/aglib/vmmap.py b/pwndbg/aglib/vmmap.py index f992c9adc..072768212 100644 --- a/pwndbg/aglib/vmmap.py +++ b/pwndbg/aglib/vmmap.py @@ -29,6 +29,8 @@ def find(address: int | pwndbg.dbg_mod.Value | None) -> pwndbg.lib.memory.Page | return None address = int(address) + if address < 0: + return None for page in get(): if address in page: diff --git a/pwndbg/chain.py b/pwndbg/chain.py index 433c0f3b6..d7cce09ef 100644 --- a/pwndbg/chain.py +++ b/pwndbg/chain.py @@ -54,6 +54,7 @@ def get( """ if address is None: return None + assert address >= 0, "address must be positive" limit = int(limit) @@ -138,7 +139,7 @@ def format( arrow_right = c.arrow(f" {config_arrow_right} ") # 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 limit == 0: