Skip to content

Memory

GdbDict = Dict[str, Union['GdbDict', int]] module-attribute

MMAP_MIN_ADDR = 32768 module-attribute

byte(addr)

byte(addr) -> int

Read one byte at the specified address

cast_pointer(type, addr)

Create a Value containing given address and cast it to the pointer of specified type

convert_pwndbg_value_to_python_value(dbg_value)

find_lower_boundary(addr, max_pages=1024)

find_lower_boundary(addr, max_pages=1024) -> int

Brute-force search the lower boundary of a memory mapping, by reading the first byte of each page, until an unmapped page is found.

find_upper_boundary(addr, max_pages=1024)

find_upper_boundary(addr, max_pages=1024) -> int

Brute-force search the upper boundary of a memory mapping, by reading the first byte of each page, until an unmapped page is found.

get_typed_pointer(type, addr)

Look up a type by name if necessary and return a Value of addr cast to that type

get_typed_pointer_value(type_name, addr)

Read the pointer value of addr cast to type specified by type_name

is_readable_address(address)

is_readable_address(address) -> bool

Check if the address can be read by GDB.

Parameters:

Name Type Description Default
address(int)

Address to read

required

Returns:

Type Description
bool

class:bool: Whether the address is readable.

pack_struct_into_dictionary(fetched_struct, include_only_fields=None, exclude_fields=None)

peek(address)

peek(address) -> str

Read one byte from the specified address.

Parameters:

Name Type Description Default
address(int)

Address to read

required

Returns:

Type Description
str | None

class:str: A single byte of data, or None if the

str | None

address cannot be read.

poke(address)

poke(address)

Checks whether an address is writable.

Parameters:

Name Type Description Default
address(int)

Address to check

required

Returns:

Type Description
bool

class:bool: Whether the address is writable.

pvoid(addr)

pvoid(addr) -> int

Read one pointer from the specified address.

read(addr, count, partial=False)

read(addr, count, partial=False) -> bytearray

Read memory from the program being debugged.

Parameters:

Name Type Description Default
addr(int)

Address to read

required
count(int)

Number of bytes to read

required
partial(bool)

Whether less than count bytes can be returned

required

Returns:

Type Description
bytearray

class:bytearray: The memory at the specified address,

bytearray

or None.

readtype(type, addr)

readtype(type, addr) -> int

Reads an integer-type (e.g. uint64) and returns a Python native integer representation of the same.

Parameters:

Name Type Description Default
type(pwndbg.dbg_mod.Type)

GDB type to read

required
addr(int)

Address at which the value to be read resides

required

Returns:

Type Description
int

class:int

resolve_renamed_struct_field(struct_name, possible_field_names)

s16(addr)

s16(addr) -> int

Read one int16_t from the specified address.

s32(addr)

s32(addr) -> int

Read one int32_t from the specified address.

s64(addr)

s64(addr) -> int

Read one int64_t from the specified address.

s8(addr)

s8(addr) -> int

Read one int8_t from the specified address

string(addr, max=4096)

Reads a null-terminated string from memory.

Parameters:

Name Type Description Default
addr(int)

Address to read from

required
max(int)

Maximum string length (default 4096)

required

Returns:

Type Description
bytearray

An empty bytearray, or a NULL-terminated bytearray.

u(addr, size=None)

u(addr, size=None) -> int

Read one unsigned integer from the specified address, with the bit-width specified by size, which defaults to the pointer width.

u16(addr)

u16(addr) -> int

Read one uint16_t from the specified address.

u32(addr)

u32(addr) -> int

Read one uint32_t from the specified address.

u64(addr)

u64(addr) -> int

Read one uint64_t from the specified address.

u8(addr)

u8(addr) -> int

Read one uint8_t from the specified address.

uchar(addr)

uchar(addr) -> int

Read one unsigned char at the specified address.

uint(addr)

uint(addr) -> int

Read one unsigned int at the specified address.

update_min_addr()

ushort(addr)

ushort(addr) -> int

Read one unisgned short at the specified address.

write(addr, data)

write(addr, data)

Writes data into the memory of the process being debugged.

Parameters:

Name Type Description Default
addr(int)

Address to write

required
data(str,bytes,bytearray)

Data to write

required