Skip to content

chain ¤

Functions:

  • get

    Recursively dereferences an address. For bare metal, it will stop when the address is not in any of vmmap pages to avoid redundant dereference.

  • format

    Recursively dereferences an address into string representation, or convert the list representation

Attributes:

LIMIT module-attribute ¤

LIMIT = add_param(
    "dereference-limit", 5, "max number of pointers to dereference in a chain"
)

c module-attribute ¤

c = ColorConfig(
    "chain",
    [
        ColorParamSpec("arrow", "normal", "color of chain formatting (arrow)"),
        ColorParamSpec(
            "contiguous-marker",
            "normal",
            "color of chain formatting (contiguous marker)",
        ),
    ],
)

config_arrow_left module-attribute ¤

config_arrow_left = add_param(
    "chain-arrow-left", "◂—", "left arrow of chain formatting"
)

config_arrow_right module-attribute ¤

config_arrow_right = add_param(
    "chain-arrow-right", "—▸", "right arrow of chain formatting"
)

config_contiguous module-attribute ¤

config_contiguous = add_param(
    "chain-contiguous-marker", "...", "contiguous marker of chain formatting"
)

get ¤

get(
    address: int | None,
    limit: int = LIMIT,
    offset: int = 0,
    hard_stop: int | None = None,
    hard_end: int = 0,
    include_start: bool = True,
    safe_linking: bool = False,
) -> list[int] | None

Recursively dereferences an address. For bare metal, it will stop when the address is not in any of vmmap pages to avoid redundant dereference.

Parameters:

  • address (int | None) –

    the first address to begin dereferencing

  • limit (int, default: LIMIT ) –

    number of valid pointers

  • offset (int, default: 0 ) –

    offset into the address to get the next pointer

  • hard_stop (int | None, default: None ) –

    address to stop at

  • hard_end (int, default: 0 ) –

    value to append when hard_stop is reached

  • include_start (bool, default: True ) –

    whether to include starting address or not

  • safe_linking (bool, default: False ) –

    whether this chain use safe-linking

Returns:

  • list[int] | None

    A list representing pointers of each address and reference

format ¤

format(
    value: int | list[int] | None,
    limit: int = LIMIT,
    code: bool = True,
    offset: int = 0,
    hard_stop: int | None = None,
    hard_end: int = 0,
    safe_linking: bool = False,
    enhance_string_len: int | None = None,
) -> str

Recursively dereferences an address into string representation, or convert the list representation of address dereferences into string representation.

Parameters:

  • value (int | list[int] | None) –

    Either the starting address to be sent to get, or the result of get (a list)

  • limit (int, default: LIMIT ) –

    Number of valid pointers

  • code (bool, default: True ) –

    Hint that indicates the value may be an instruction

  • offset (int, default: 0 ) –

    Offset into the address to get the next pointer

  • hard_stop (int | None, default: None ) –

    Value to stop on

  • hard_end (int, default: 0 ) –

    Value to append when hard_stop is reached: null, value of hard stop, a string.

  • safe_linking (bool, default: False ) –

    whether this chain use safe-linking

  • enhance_string_len (int | None, default: None ) –

    The length of string to display for enhancement of the last pointer

Returns: A string representing pointers of each address and reference Strings format: 0x0804a10 —▸ 0x08061000 ◂— 0x41414141