IDAPython 8.4
Loading...
Searching...
No Matches
ida_xref Namespace Reference

Detailed Description

Functions that deal with cross-references.

There are 2 types of xrefs: CODE and DATA references. All xrefs are kept in the
bTree except ordinary execution flow to the next instruction. Ordinary execution
flow to the next instruction is kept in flags (see bytes.hpp)

The source address of a cross-reference must be an item head (is_head) or a
structure member id.

Cross-references are automatically sorted.

Classes

class  cases_and_targets_t
 Proxy of C++ cases_and_targets_t class. More...
 
class  casevec_t
 Proxy of C++ qvector< qvector< sval_t > > class. More...
 
class  xrefblk_t
 Proxy of C++ xrefblk_t class. More...
 

Functions

"bool" create_switch_xrefs (*args)
 create_switch_xrefs(ea, si) -> bool This function creates xrefs from the indirect jump.
 
"cases_and_targets_t *" calc_switch_cases (*args)
 calc_switch_cases(ea, si) -> cases_and_targets_t Get information about a switch's cases.
 
"bool" create_switch_table (*args)
 create_switch_table(ea, si) -> bool Create switch table from the switch information
 
"char" xrefchar (*args)
 xrefchar(xrtype) -> char Get character describing the xref type.
 
"bool" add_cref (*args)
 add_cref(frm, to, type) -> bool Create a code cross-reference.
 
"bool" del_cref (*args)
 del_cref(frm, to, expand) -> bool Delete a code cross-reference.
 
"bool" add_dref (*args)
 add_dref(frm, to, type) -> bool Create a data cross-reference.
 
"void" del_dref (*args)
 del_dref(frm, to) Delete a data cross-reference.
 
"ea_t" get_first_dref_from (*args)
 get_first_dref_from(frm) -> ea_t Get first data referenced from the specified address.
 
"ea_t" get_next_dref_from (*args)
 get_next_dref_from(frm, current) -> ea_t Get next data referenced from the specified address.
 
"ea_t" get_first_dref_to (*args)
 get_first_dref_to(to) -> ea_t Get address of instruction/data referencing to the specified data.
 
"ea_t" get_next_dref_to (*args)
 get_next_dref_to(to, current) -> ea_t Get address of instruction/data referencing to the specified data
 
"ea_t" get_first_cref_from (*args)
 get_first_cref_from(frm) -> ea_t Get first instruction referenced from the specified instruction.
 
"ea_t" get_next_cref_from (*args)
 get_next_cref_from(frm, current) -> ea_t Get next instruction referenced from the specified instruction.
 
"ea_t" get_first_cref_to (*args)
 get_first_cref_to(to) -> ea_t Get first instruction referencing to the specified instruction.
 
"ea_t" get_next_cref_to (*args)
 get_next_cref_to(to, current) -> ea_t Get next instruction referencing to the specified instruction.
 
"ea_t" get_first_fcref_from (*args)
 get_first_fcref_from(frm) -> ea_t
 
"ea_t" get_next_fcref_from (*args)
 get_next_fcref_from(frm, current) -> ea_t
 
"ea_t" get_first_fcref_to (*args)
 get_first_fcref_to(to) -> ea_t
 
"ea_t" get_next_fcref_to (*args)
 get_next_fcref_to(to, current) -> ea_t
 
"bool" has_external_refs (*args)
 has_external_refs(pfn, ea) -> bool Does 'ea' have references from outside of 'pfn'?
 
"void" delete_switch_table (*args)
 delete_switch_table(jump_ea, si)
 

Variables

 fl_U = _ida_xref.fl_U
 
 fl_CF = _ida_xref.fl_CF
 
 fl_CN = _ida_xref.fl_CN
 
 fl_JF = _ida_xref.fl_JF
 
 fl_JN = _ida_xref.fl_JN
 
 fl_USobsolete = _ida_xref.fl_USobsolete
 
 fl_F = _ida_xref.fl_F
 
 dr_U = _ida_xref.dr_U
 
 dr_O = _ida_xref.dr_O
 
 dr_W = _ida_xref.dr_W
 
 dr_R = _ida_xref.dr_R
 
 dr_T = _ida_xref.dr_T
 
 dr_I = _ida_xref.dr_I
 
 dr_S = _ida_xref.dr_S
 
 XREF_USER = _ida_xref.XREF_USER
 
 XREF_TAIL = _ida_xref.XREF_TAIL
 
 XREF_BASE = _ida_xref.XREF_BASE
 
 XREF_MASK = _ida_xref.XREF_MASK
 
 XREF_PASTEND = _ida_xref.XREF_PASTEND
 
 XREF_ALL = _ida_xref.XREF_ALL
 
 XREF_FAR = _ida_xref.XREF_FAR
 
 XREF_DATA = _ida_xref.XREF_DATA
 

Function Documentation

◆ add_cref()

"bool" add_cref ( * args)
Parameters
from(C++: ea_t) linear address of referencing instruction
to(C++: ea_t) linear address of referenced instruction
type(C++: cref_t) cross-reference type
Returns
: success

◆ add_dref()

"bool" add_dref ( * args)
Parameters
from(C++: ea_t) linear address of referencing instruction or data
to(C++: ea_t) linear address of referenced data
type(C++: dref_t) cross-reference type
Returns
: success (may fail if user-defined xref exists from->to)

◆ calc_switch_cases()

"cases_and_targets_t *" calc_switch_cases ( * args)

The returned information can be used as follows:

for idx in range(len(results.cases)):
    cur_case = results.cases[idx]
    for cidx in range(len(cur_case)):
        print("case: %d" % cur_case[cidx])
    print("  goto 0x%x" % results.targets[idx])
Parameters
eaaddress of the 'indirect jump' instruction
siswitch information
Returns
: a structure with 2 members: 'cases', and 'targets'.

◆ create_switch_table()

"bool" create_switch_table ( * args)
Parameters
eaaddress of the 'indirect jump' instruction
siswitch information
Returns
: Boolean

◆ create_switch_xrefs()

"bool" create_switch_xrefs ( * args)

Usually there is no need to call this function directly because the kernel will call it for switch tables

Note: Custom switch information are not supported yet.

Parameters
eaaddress of the 'indirect jump' instruction
siswitch information
Returns
: Boolean

◆ del_cref()

"bool" del_cref ( * args)
Parameters
from(C++: ea_t) linear address of referencing instruction
to(C++: ea_t) linear address of referenced instruction
expand(C++: bool) policy to delete the referenced instruction
  • 1: plan to delete the referenced instruction if it has no more references.
  • 0: don't delete the referenced instruction even if no more cross-references point to it
Return values
trueif the referenced instruction will be deleted

◆ del_dref()

"void" del_dref ( * args)
Parameters
from(C++: ea_t) linear address of referencing instruction or data
to(C++: ea_t) linear address of referenced data

◆ delete_switch_table()

"void" delete_switch_table ( * args)
Parameters
jump_eaea_t
siswitch_info_t const &

◆ get_first_cref_from()

"ea_t" get_first_cref_from ( * args)

If the specified instruction passes execution to the next instruction then the next instruction is returned. Otherwise the lowest referenced address is returned (remember that xrefs are kept sorted!).

Parameters
from(C++: ea_t) linear address of referencing instruction
Returns
: first referenced address. If the specified instruction doesn't reference to other instructions then returns BADADDR.

◆ get_first_cref_to()

"ea_t" get_first_cref_to ( * args)

If the specified instruction may be executed immediately after its previous instruction then the previous instruction is returned. Otherwise the lowest referencing address is returned. (remember that xrefs are kept sorted!).

Parameters
to(C++: ea_t) linear address of referenced instruction
Returns
: linear address of the first referencing instruction or BADADDR.

◆ get_first_dref_from()

"ea_t" get_first_dref_from ( * args)
Parameters
from(C++: ea_t) linear address of referencing instruction or data
Returns
: linear address of first (lowest) data referenced from the specified address. Return BADADDR if the specified instruction/data doesn't reference to anything.

◆ get_first_dref_to()

"ea_t" get_first_dref_to ( * args)
Parameters
to(C++: ea_t) linear address of referencing instruction or data
Returns
: BADADDR if nobody refers to the specified data.

◆ get_first_fcref_from()

"ea_t" get_first_fcref_from ( * args)
Parameters
fromea_t

◆ get_first_fcref_to()

"ea_t" get_first_fcref_to ( * args)
Parameters
toea_t

◆ get_next_cref_from()

"ea_t" get_next_cref_from ( * args)
Parameters
from(C++: ea_t) linear address of referencing instruction
current(C++: ea_t) linear address of current referenced instruction This value is returned by get_first_cref_from() or previous call to get_next_cref_from() functions.
Returns
: next referenced address or BADADDR.

◆ get_next_cref_to()

"ea_t" get_next_cref_to ( * args)
Parameters
to(C++: ea_t) linear address of referenced instruction
current(C++: ea_t) linear address of current referenced instruction This value is returned by get_first_cref_to() or previous call to get_next_cref_to() functions.
Returns
: linear address of the next referencing instruction or BADADDR.

◆ get_next_dref_from()

"ea_t" get_next_dref_from ( * args)
Parameters
from(C++: ea_t) linear address of referencing instruction or data
current(C++: ea_t) linear address of current referenced data. This value is returned by get_first_dref_from() or previous call to get_next_dref_from() functions.
Returns
: linear address of next data or BADADDR.

◆ get_next_dref_to()

"ea_t" get_next_dref_to ( * args)
Parameters
to(C++: ea_t) linear address of referencing instruction or data
current(C++: ea_t) current linear address. This value is returned by get_first_dref_to() or previous call to get_next_dref_to() functions.
Returns
: BADADDR if nobody refers to the specified data.

◆ get_next_fcref_from()

"ea_t" get_next_fcref_from ( * args)
Parameters
fromea_t
currentea_t

◆ get_next_fcref_to()

"ea_t" get_next_fcref_to ( * args)
Parameters
toea_t
currentea_t

◆ has_external_refs()

"bool" has_external_refs ( * args)
Parameters
pfn(C++: func_t *)
ea(C++: ea_t)

◆ xrefchar()

"char" xrefchar ( * args)
Parameters
xrtype(C++: char) combination of Cross-Reference type flags and a cref_t of dref_t value

Variable Documentation

◆ dr_I

dr_I = _ida_xref.dr_I

◆ dr_O

dr_O = _ida_xref.dr_O

◆ dr_R

dr_R = _ida_xref.dr_R

◆ dr_S

dr_S = _ida_xref.dr_S

◆ dr_T

dr_T = _ida_xref.dr_T

◆ dr_U

dr_U = _ida_xref.dr_U

◆ dr_W

dr_W = _ida_xref.dr_W

◆ fl_CF

fl_CF = _ida_xref.fl_CF

◆ fl_CN

fl_CN = _ida_xref.fl_CN

◆ fl_F

fl_F = _ida_xref.fl_F

◆ fl_JF

fl_JF = _ida_xref.fl_JF

◆ fl_JN

fl_JN = _ida_xref.fl_JN

◆ fl_U

fl_U = _ida_xref.fl_U

◆ fl_USobsolete

fl_USobsolete = _ida_xref.fl_USobsolete

◆ XREF_ALL

XREF_ALL = _ida_xref.XREF_ALL

◆ XREF_BASE

XREF_BASE = _ida_xref.XREF_BASE

◆ XREF_DATA

XREF_DATA = _ida_xref.XREF_DATA

◆ XREF_FAR

XREF_FAR = _ida_xref.XREF_FAR

◆ XREF_MASK

XREF_MASK = _ida_xref.XREF_MASK

◆ XREF_PASTEND

XREF_PASTEND = _ida_xref.XREF_PASTEND

◆ XREF_TAIL

XREF_TAIL = _ida_xref.XREF_TAIL

◆ XREF_USER

XREF_USER = _ida_xref.XREF_USER