mirror of https://github.com/pwndbg/pwndbg.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
838 B
Python
31 lines
838 B
Python
import gdb
|
|
import gef.types
|
|
import gef.memory
|
|
|
|
|
|
def get(address, limit=5):
|
|
"""
|
|
Recursively dereferences an address.
|
|
|
|
Returns:
|
|
A list containing ``address``, followed by up to ``limit`` valid pointers.
|
|
"""
|
|
result = [int(address)]
|
|
for i in range(limit):
|
|
try:
|
|
# Convert the current address to a void**
|
|
address = gef.memory.poi(gef.types.ppvoid, address)
|
|
|
|
# Ensure that it's a valid pointer by dereferencing it
|
|
# *AND* attempting to get the resulting value.
|
|
#
|
|
# GDB will let you .dereference() anything, the int() throws
|
|
# the gdb.MemoryError.
|
|
int(address.dereference())
|
|
|
|
# Save it off
|
|
result.append(int(address))
|
|
except gdb.MemoryError:
|
|
break
|
|
return result
|