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 Far - creates a function at referenced location

CALL_NEAR class-attribute instance-attribute

CALL_NEAR = fl_CN

Call Near - creates a function at referenced location

JUMP_FAR class-attribute instance-attribute

JUMP_FAR = fl_JF

Jump Far

JUMP_NEAR class-attribute instance-attribute

JUMP_NEAR = fl_JN

Jump Near

ORDINARY_FLOW class-attribute instance-attribute

ORDINARY_FLOW = fl_F

Ordinary flow to next instruction

UNKNOWN class-attribute instance-attribute

UNKNOWN = fl_U

Unknown - for compatibility with old versions

USER_SPECIFIED class-attribute instance-attribute

USER_SPECIFIED = fl_USobsolete

User specified (obsolete)

DataRefType

Bases: IntEnum

Data reference types.

Attributes:

  • INFORMATIONAL

    Informational reference

  • OFFSET

    Offset reference or OFFSET flag set

  • READ

    Read access

  • SYMBOLIC

    Reference to enum member (symbolic constant)

  • TEXT

    Text (for forced operands only)

  • UNKNOWN

    Unknown - for compatibility with old versions

  • WRITE

    Write access

INFORMATIONAL class-attribute instance-attribute

INFORMATIONAL = dr_I

Informational reference

OFFSET class-attribute instance-attribute

OFFSET = dr_O

Offset reference or OFFSET flag set

READ class-attribute instance-attribute

READ = dr_R

Read access

SYMBOLIC class-attribute instance-attribute

SYMBOLIC = dr_S

Reference to enum member (symbolic constant)

TEXT class-attribute instance-attribute

TEXT = dr_T

Text (for forced operands only)

UNKNOWN class-attribute instance-attribute

UNKNOWN = dr_U

Unknown - for compatibility with old versions

WRITE class-attribute instance-attribute

WRITE = dr_W

Write access

Xrefs

Xrefs(database: Database)

Bases: DatabaseEntity

Provides access to cross-reference (xref) analysis in the IDA 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:

database property

database: Database

Get the database reference, guaranteed to be non-None when called from methods decorated with @check_db_open.

Returns: The active database instance.

Note: This property should only be used in methods decorated with @check_db_open, which ensures m_database is not None.

m_database instance-attribute

m_database = database

get_calls_from

get_calls_from(ea: ea_t) -> Iterator[Any]

Get all call references from the specified address.

Args: ea: Source effective address.

Returns: An iterator over call references from the address.

Raises: InvalidEAError: If the effective address is invalid.

get_calls_to

get_calls_to(ea: ea_t) -> Iterator[Any]

Get all call references to the specified address.

Args: ea: Target effective address.

Returns: An iterator over call references to the address.

Raises: InvalidEAError: If the effective address is invalid.

get_data_reads_of

get_data_reads_of(ea: ea_t) -> Iterator[Any]

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.

Raises: InvalidEAError: If the effective address is invalid.

get_data_writes_to

get_data_writes_to(ea: ea_t) -> Iterator[Any]

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.

Raises: InvalidEAError: If the effective address is invalid.

get_from

get_from(
    ea: ea_t, kind: XrefsKind = ALL, flow: bool = False
) -> Iterator[Any]

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.

Raises: InvalidEAError: If the effective address is invalid.

get_jumps_from

get_jumps_from(ea: ea_t) -> Iterator[Any]

Get all jump references from the specified address.

Args: ea: Source effective address.

Returns: An iterator over jump references from the address.

Raises: InvalidEAError: If the effective address is invalid.

get_jumps_to

get_jumps_to(ea: ea_t) -> Iterator[Any]

Get all jump references to the specified address.

Args: ea: Target effective address.

Returns: An iterator over jump references to the address. Raises: InvalidEAError: If the effective address is invalid.

get_name

get_name(ref: xrefblk_t) -> str

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: ea_t, kind: XrefsKind = ALL, flow: bool = True
) -> Iterator[Any]

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.

Raises: InvalidEAError: If the effective address is invalid.

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.