IDAPython 9.0
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
 
class  casevec_t
 
class  xrefblk_t
 

Functions

 create_switch_xrefs (ea, si)
 
 calc_switch_cases (ea, si)
 
 create_switch_table (ea, si)
 
'char' xrefchar ('char' xrtype)
 
bool add_cref (ida_idaapi.ea_t frm, ida_idaapi.ea_t to, 'cref_t' type)
 
bool del_cref (ida_idaapi.ea_t frm, ida_idaapi.ea_t to, bool expand)
 
bool add_dref (ida_idaapi.ea_t frm, ida_idaapi.ea_t to, 'dref_t' type)
 
None del_dref (ida_idaapi.ea_t frm, ida_idaapi.ea_t to)
 
ida_idaapi.ea_t get_first_dref_from (ida_idaapi.ea_t frm)
 
ida_idaapi.ea_t get_next_dref_from (ida_idaapi.ea_t frm, ida_idaapi.ea_t current)
 
ida_idaapi.ea_t get_first_dref_to (ida_idaapi.ea_t to)
 
ida_idaapi.ea_t get_next_dref_to (ida_idaapi.ea_t to, ida_idaapi.ea_t current)
 
ida_idaapi.ea_t get_first_cref_from (ida_idaapi.ea_t frm)
 
ida_idaapi.ea_t get_next_cref_from (ida_idaapi.ea_t frm, ida_idaapi.ea_t current)
 
ida_idaapi.ea_t get_first_cref_to (ida_idaapi.ea_t to)
 
ida_idaapi.ea_t get_next_cref_to (ida_idaapi.ea_t to, ida_idaapi.ea_t current)
 
ida_idaapi.ea_t get_first_fcref_from (ida_idaapi.ea_t frm)
 
ida_idaapi.ea_t get_next_fcref_from (ida_idaapi.ea_t frm, ida_idaapi.ea_t current)
 
ida_idaapi.ea_t get_first_fcref_to (ida_idaapi.ea_t to)
 
ida_idaapi.ea_t get_next_fcref_to (ida_idaapi.ea_t to, ida_idaapi.ea_t current)
 
bool has_external_refs ('func_t *' pfn, ida_idaapi.ea_t ea)
 
bool has_jump_or_flow_xref (ida_idaapi.ea_t ea)
 
None delete_switch_table (ida_idaapi.ea_t jump_ea, 'switch_info_t' 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_FLOW = _ida_xref.XREF_FLOW
 
 XREF_NOFLOW = _ida_xref.XREF_NOFLOW
 
 XREF_DATA = _ida_xref.XREF_DATA
 
 XREF_CODE = _ida_xref.XREF_CODE
 
 XREF_EA = _ida_xref.XREF_EA
 
 XREF_TID = _ida_xref.XREF_TID
 
 XREF_ALL = _ida_xref.XREF_ALL
 
 XREF_FAR = _ida_xref.XREF_FAR
 

Function Documentation

◆ add_cref()

bool add_cref ( ida_idaapi.ea_t frm,
ida_idaapi.ea_t to,
'cref_t' type )
Create a code cross-reference. 
    
@param to: linear address of referenced instruction
@param type: cross-reference type
@returns success

◆ add_dref()

bool add_dref ( ida_idaapi.ea_t frm,
ida_idaapi.ea_t to,
'dref_t' type )
Create a data cross-reference. 
    
@param to: linear address of referenced data
@param type: cross-reference type
@returns success (may fail if user-defined xref exists from->to)

◆ calc_switch_cases()

calc_switch_cases ( ea,
si )
Get information about a switch's cases.

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])

@param ea: address of the 'indirect jump' instruction
@param si: switch information

@return: a structure with 2 members: 'cases', and 'targets'.

◆ create_switch_table()

create_switch_table ( ea,
si )
Create switch table from the switch information

@param ea: address of the 'indirect jump' instruction
@param si: switch information

@return: Boolean

◆ create_switch_xrefs()

create_switch_xrefs ( ea,
si )
This function creates xrefs from the indirect jump.

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.

@param ea: address of the 'indirect jump' instruction
@param si: switch information

@return: Boolean

◆ del_cref()

bool del_cref ( ida_idaapi.ea_t frm,
ida_idaapi.ea_t to,
bool expand )
Delete a code cross-reference. 
    
@param to: linear address of referenced instruction
@param expand: 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
@retval true: if the referenced instruction will be deleted

◆ del_dref()

None del_dref ( ida_idaapi.ea_t frm,
ida_idaapi.ea_t to )
Delete a data cross-reference. 
    
@param to: linear address of referenced data

◆ delete_switch_table()

None delete_switch_table ( ida_idaapi.ea_t jump_ea,
'switch_info_t' si )

◆ get_first_cref_from()

ida_idaapi.ea_t get_first_cref_from ( ida_idaapi.ea_t frm)
Get first instruction referenced from the specified instruction. 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!). 
    
@returns first referenced address. If the specified instruction doesn't reference to other instructions then returns BADADDR.

◆ get_first_cref_to()

ida_idaapi.ea_t get_first_cref_to ( ida_idaapi.ea_t to)
Get first instruction referencing to the specified instruction. 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!). 
    
@param to: linear address of referenced instruction
@returns linear address of the first referencing instruction or BADADDR.

◆ get_first_dref_from()

ida_idaapi.ea_t get_first_dref_from ( ida_idaapi.ea_t frm)
Get first data referenced from the specified address. 
    
@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()

ida_idaapi.ea_t get_first_dref_to ( ida_idaapi.ea_t to)
Get address of instruction/data referencing to the specified data. 
    
@param to: linear address of referencing instruction or data
@returns BADADDR if nobody refers to the specified data.

◆ get_first_fcref_from()

ida_idaapi.ea_t get_first_fcref_from ( ida_idaapi.ea_t frm)

◆ get_first_fcref_to()

ida_idaapi.ea_t get_first_fcref_to ( ida_idaapi.ea_t to)

◆ get_next_cref_from()

ida_idaapi.ea_t get_next_cref_from ( ida_idaapi.ea_t frm,
ida_idaapi.ea_t current )
Get next instruction referenced from the specified instruction. 
    
@param current: 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()

ida_idaapi.ea_t get_next_cref_to ( ida_idaapi.ea_t to,
ida_idaapi.ea_t current )
Get next instruction referencing to the specified instruction. 
    
@param to: linear address of referenced instruction
@param current: 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()

ida_idaapi.ea_t get_next_dref_from ( ida_idaapi.ea_t frm,
ida_idaapi.ea_t current )
Get next data referenced from the specified address. 
    
@param current: 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()

ida_idaapi.ea_t get_next_dref_to ( ida_idaapi.ea_t to,
ida_idaapi.ea_t current )
Get address of instruction/data referencing to the specified data 
    
@param to: linear address of referencing instruction or data
@param current: 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()

ida_idaapi.ea_t get_next_fcref_from ( ida_idaapi.ea_t frm,
ida_idaapi.ea_t current )

◆ get_next_fcref_to()

ida_idaapi.ea_t get_next_fcref_to ( ida_idaapi.ea_t to,
ida_idaapi.ea_t current )

◆ has_external_refs()

bool has_external_refs ( 'func_t *' pfn,
ida_idaapi.ea_t ea )
Does 'ea' have references from outside of 'pfn'?

◆ has_jump_or_flow_xref()

bool has_jump_or_flow_xref ( ida_idaapi.ea_t ea)
Are there jump or flow references to EA?

◆ xrefchar()

'char' xrefchar ( 'char' xrtype)
Get character describing the xref type. 
    
@param xrtype: 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_CODE

XREF_CODE = _ida_xref.XREF_CODE

◆ XREF_DATA

XREF_DATA = _ida_xref.XREF_DATA

◆ XREF_EA

XREF_EA = _ida_xref.XREF_EA

◆ XREF_FAR

XREF_FAR = _ida_xref.XREF_FAR

◆ XREF_FLOW

XREF_FLOW = _ida_xref.XREF_FLOW

◆ XREF_MASK

XREF_MASK = _ida_xref.XREF_MASK

◆ XREF_NOFLOW

XREF_NOFLOW = _ida_xref.XREF_NOFLOW

◆ XREF_PASTEND

XREF_PASTEND = _ida_xref.XREF_PASTEND

◆ XREF_TAIL

XREF_TAIL = _ida_xref.XREF_TAIL

◆ XREF_TID

XREF_TID = _ida_xref.XREF_TID

◆ XREF_USER

XREF_USER = _ida_xref.XREF_USER