Skip to content

structures ¤

Add, load, show, edit, or delete custom structures.

For the compilation of the structures zig is being used under the hood, unless gcc-config-path is specified.

Functions:

  • compile_structure

    Compile a C file that contains custom struct definitions.

  • get_struct_path

    Get a Path for a name (usually in ~/.cache/pwndbg/custom-structures/).

  • get_struct_path_if_exists

    Get a Path for a name (usually in ~/.cache/pwndbg/custom-structures/) if the

  • unload

    Unload structures from the debugger by set name.

  • remove

    Unload structures from the debugger and delete the backing file by set name.

  • load_with_path

    Load structures from set name name, located at struct_path into the debbuger.

  • load

    Load structures from set name name.

  • saved_names

    Returns all set names.

  • create_temp_header_file

    Creates a temporary file with content content and returns the Path to it.

  • add

    Add structures defined in content (C code) by reference structure set name name and load

Attributes:

loaded_structures module-attribute ¤

loaded_structures: dict[str, str] = {}

storage_location module-attribute ¤

storage_location: Path = cachedir('custom-structures')

compile_structure ¤

compile_structure(
    struct_path: Path, compiled_path: str | None = None
) -> tuple[str, Status]

Compile a C file that contains custom struct definitions.

Zig is being used unless gcc-config-path is specified. Naturally the compiled output file will have debug info.

Parameters:

  • struct_path (Path) –

    Path to the .c / .h file to compile.

  • compiled_path (str | None, default: None ) –

    The path of the output file. If not specified, it will be an automatically generated filename in /tmp/.

Returns:

  • tuple[str, Status]

    A (compiled_path, err) tuple.

get_struct_path ¤

get_struct_path(name: str) -> Path

Get a Path for a name (usually in ~/.cache/pwndbg/custom-structures/).

get_struct_path_if_exists ¤

get_struct_path_if_exists(name: str) -> Path | None

Get a Path for a name (usually in ~/.cache/pwndbg/custom-structures/) if the file exists, otherwise return None.

unload ¤

unload(name: str) -> None

Unload structures from the debugger by set name.

remove ¤

remove(name: str) -> Status

Unload structures from the debugger and delete the backing file by set name.

load_with_path ¤

load_with_path(name: str, struct_path: Path) -> Status

Load structures from set name name, located at struct_path into the debbuger.

Requires the set to have already been added.

load ¤

load(name: str) -> Status

Load structures from set name name.

Requires the set to have already been added.

saved_names ¤

saved_names() -> list[str]

Returns all set names.

create_temp_header_file ¤

create_temp_header_file(content: str) -> Path

Creates a temporary file with content content and returns the Path to it.

add ¤

add(name: str, content: str) -> Status

Add structures defined in content (C code) by reference structure set name name and load them into the debugger.

If a name structure set file already exists, it will be overwritten.

The name will be prefixed with _internal_ to separate from user-defined structures.