Skip to content

Xrefs

xrefs

Classes:

  • CodeRefType

    Code reference types.

  • DataRefType

    Data reference types.

  • Xrefs

    Provides access to cross-reference (xref) analysis in the IDA database.

  • XrefsKind

    Enumeration for IDA Xrefs types.

Functions:

CodeRefType

Bases: IntEnum

Code reference types.

Attributes:

CALL_FAR class-attribute instance-attribute

CALL_FAR = fl_CF

CALL_NEAR class-attribute instance-attribute

CALL_NEAR = fl_CN

JUMP_FAR class-attribute instance-attribute

JUMP_FAR = fl_JF

JUMP_NEAR class-attribute instance-attribute

JUMP_NEAR = fl_JN

ORDINARY_FLOW class-attribute instance-attribute

ORDINARY_FLOW = fl_F

UNKNOWN class-attribute instance-attribute

UNKNOWN = fl_U

USER_SPECIFIED class-attribute instance-attribute

USER_SPECIFIED = fl_USobsolete

DataRefType

Bases: IntEnum

Data reference types.

Attributes:

INFORMATIONAL class-attribute instance-attribute

INFORMATIONAL = dr_I

OFFSET class-attribute instance-attribute

OFFSET = dr_O

READ class-attribute instance-attribute

READ = dr_R

SYMBOLIC class-attribute instance-attribute

SYMBOLIC = dr_S

TEXT class-attribute instance-attribute

TEXT = dr_T

UNKNOWN class-attribute instance-attribute

UNKNOWN = dr_U

WRITE class-attribute instance-attribute

WRITE = dr_W

Xrefs

Xrefs(database: 'Database')

Provides access to cross-reference (xref) analysis in the IDA database.

Constructs a xrefs handler for the given database.

Args: database: Reference to the active IDA database.

Methods:

  • get_calls_from

    Get all call references from the specified address.

  • get_calls_to

    Get all call references to the specified address.

  • get_data_reads_of

    Get all places that read data from the specified address.

  • get_data_writes_to

    Get all places that write data to the specified address.

  • get_from

    Creates an iterator over all xrefs originating from a given address.

  • get_jumps_from

    Get all jump references from the specified address.

  • get_jumps_to

    Get all jump references to the specified address.

  • get_name

    Get human-readable xref type name.

  • get_ref_type_name

    Get human-readable name for xref type.

  • get_to

    Creates an iterator over all xrefs pointing to a given address.

  • is_call_ref

    Check if xref type is a call reference.

  • is_code_ref

    Check if xref type is a code reference.

  • is_data_ref

    Check if xref type is a data reference.

  • is_jump_ref

    Check if xref type is a jump reference.

  • is_offset_ref

    Check if xref type is an offset reference.

  • is_read_ref

    Check if xref type is a data read reference.

  • is_write_ref

    Check if xref type is a data write reference.

Attributes:

m_database instance-attribute

m_database = database

get_calls_from

get_calls_from(ea: int)

Get all call references from the specified address.

Args: ea: Source effective address.

Returns: An iterator over call references from the address.

get_calls_to

get_calls_to(ea: int)

Get all call references to the specified address.

Args: ea: Target effective address.

Returns: An iterator over call references to the address.

get_data_reads_of

get_data_reads_of(ea: int)

Get all places that read data from the specified address.

Args: ea: Target effective address (the data being read).

Returns: An iterator over references that read data from the address.

get_data_writes_to

get_data_writes_to(ea: int)

Get all places that write data to the specified address.

Args: ea: Target effective address (the data being written to).

Returns: An iterator over references that write data to the address.

get_from

get_from(
    ea: int, kind: XrefsKind = ALL, flow: bool = False
)

Creates an iterator over all xrefs originating from a given address.

Args: ea: Source effective address. kind: Xrefs kind (defaults to XrefsKind.ALL). flow: Follow normal code flow or not (defaults to True).

Returns: An iterator over outgoing xrefs.

get_jumps_from

get_jumps_from(ea: int)

Get all jump references from the specified address.

Args: ea: Source effective address.

Returns: An iterator over jump references from the address.

get_jumps_to

get_jumps_to(ea: int)

Get all jump references to the specified address.

Args: ea: Target effective address.

Returns: An iterator over jump references to the address.

get_name

get_name(ref: xrefblk_t())

Get human-readable xref type name.

Args: ref: A xref block.

Returns: A human-readable xref type name.

get_ref_type_name

get_ref_type_name(
    xref_type: Union[int, CodeRefType, DataRefType],
) -> str

Get human-readable name for xref type.

get_to

get_to(ea: int, kind: XrefsKind = ALL, flow: bool = True)

Creates an iterator over all xrefs pointing to a given address.

Args: ea: Target effective address. kind: Xrefs kind (defaults to XrefsKind.ALL). flow: Follow normal code flow or not (defaults to True).

Returns: An iterator over references to input target addresses.

is_call_ref

is_call_ref(
    xref_type: Union[int, CodeRefType, DataRefType],
) -> bool

Check if xref type is a call reference.

is_code_ref

is_code_ref(
    xref_type: Union[int, CodeRefType, DataRefType],
) -> bool

Check if xref type is a code reference.

is_data_ref

is_data_ref(
    xref_type: Union[int, CodeRefType, DataRefType],
) -> bool

Check if xref type is a data reference.

is_jump_ref

is_jump_ref(
    xref_type: Union[int, CodeRefType, DataRefType],
) -> bool

Check if xref type is a jump reference.

is_offset_ref

is_offset_ref(
    xref_type: Union[int, CodeRefType, DataRefType],
) -> bool

Check if xref type is an offset reference.

is_read_ref

is_read_ref(
    xref_type: Union[int, CodeRefType, DataRefType],
) -> bool

Check if xref type is a data read reference.

is_write_ref

is_write_ref(
    xref_type: Union[int, CodeRefType, DataRefType],
) -> bool

Check if xref type is a data write reference.

XrefsKind

Bases: Enum

Enumeration for IDA Xrefs types.

Attributes:

ALL class-attribute instance-attribute

ALL = 'all'

CODE class-attribute instance-attribute

CODE = 'code'

DATA class-attribute instance-attribute

DATA = 'data'

get_ref_type_name

get_ref_type_name(
    xref_type: Union[int, CodeRefType, DataRefType],
) -> str

Get human-readable name for xref type.

is_call_ref

is_call_ref(
    xref_type: Union[int, CodeRefType, DataRefType],
) -> bool

Check if xref type is a call reference.

is_code_ref

is_code_ref(
    xref_type: Union[int, CodeRefType, DataRefType],
) -> bool

Check if xref type is a code reference.

is_data_ref

is_data_ref(
    xref_type: Union[int, CodeRefType, DataRefType],
) -> bool

Check if xref type is a data reference.

is_jump_ref

is_jump_ref(
    xref_type: Union[int, CodeRefType, DataRefType],
) -> bool

Check if xref type is a jump reference.

is_offset_ref

is_offset_ref(
    xref_type: Union[int, CodeRefType, DataRefType],
) -> bool

Check if xref type is an offset reference.

is_read_ref

is_read_ref(
    xref_type: Union[int, CodeRefType, DataRefType],
) -> bool

Check if xref type is a data read reference.

is_write_ref

is_write_ref(
    xref_type: Union[int, CodeRefType, DataRefType],
) -> bool

Check if xref type is a data write reference.