Module ida_xref
[frames] | no frames]

Module ida_xref

IDA Plugin SDK API wrapper: xref

Classes
  cases_and_targets_t
Proxy of C++ cases_and_targets_t class
  xrefblk_t
Proxy of C++ xrefblk_t class
  casevec_t
Proxy of C++ qvector<(qvector<(sval_t)>)> class
Functions
bool
create_switch_xrefs(ea, si)
This function creates xrefs from the indirect jump.
cases_and_targets_t
calc_switch_cases(ea, si)
Get information about a switch's cases.
bool
create_switch_table(ea, si)
Create switch table from the switch information
char
xrefchar(xrtype)
Get character describing the xref type.
bool
add_cref(frm, to, type)
Create a code cross-reference.
int
del_cref(frm, to, expand)
Delete a code cross-reference.
bool
add_dref(frm, to, type)
Create a data cross-reference.
 
del_dref(frm, to)
Delete a data cross-reference.
ea_t
get_first_dref_from(frm)
Get first data referenced from the specified address.
ea_t
get_next_dref_from(frm, current)
Get next data referenced from the specified address.
ea_t
get_first_dref_to(to)
Get address of instruction/data referencing to the specified data.
ea_t
get_next_dref_to(to, current)
Get address of instruction/data referencing to the specified data
ea_t
get_first_cref_from(frm)
Get first instruction referenced from the specified instruction.
ea_t
get_next_cref_from(frm, current)
Get next instruction referenced from the specified instruction.
ea_t
get_first_cref_to(to)
Get first instruction referencing to the specified instruction.
ea_t
get_next_cref_to(to, current)
Get next instruction referencing to the specified instruction.
ea_t
get_first_fcref_from(frm)
ea_t
get_next_fcref_from(frm, current)
ea_t
get_first_fcref_to(to)
ea_t
get_next_fcref_to(to, current)
bool
has_external_refs(pfn, ea)
Has a location external to the function references?
 
delete_switch_table(jump_ea, si)
Variables
  fl_U = 0
  fl_CF = 16
  fl_CN = 17
  fl_JF = 18
  fl_JN = 19
  fl_USobsolete = 20
  fl_F = 21
  dr_U = 0
  dr_O = 1
  dr_W = 2
  dr_R = 3
  dr_T = 4
  dr_I = 5
  XREF_USER = 32
User specified xref.
  XREF_TAIL = 64
Reference to tail byte in extrn symbols.
  XREF_BASE = 128
Reference to the base part of an offset.
  XREF_MASK = 31
Mask to get xref type.
  XREF_PASTEND = 256
Reference is past item.
  XREF_ALL = 0
return all references
  XREF_FAR = 1
don't return ordinary flow xrefs
  XREF_DATA = 2
return data references only
  __package__ = None
Function Details

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.

Parameters:
  • ea - address of the 'indirect jump' instruction
  • si - switch information
Returns: bool
Boolean

calc_switch_cases(ea, si)

 
Get information about a switch's cases.

The returned information can be used as follows:

    for idx in xrange(len(results.cases)):
        cur_case = results.cases[idx]
        for cidx in xrange(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'.

Returns: cases_and_targets_t

create_switch_table(ea, si)

 

Create switch table from the switch information

Parameters:
  • ea - address of the 'indirect jump' instruction
  • si - switch information
Returns: bool
Boolean

xrefchar(xrtype)

 

Get character describing the xref type.

Parameters:
  • xrtype - combination of Cross-Reference type flags and a cref_t of dref_t value (C++: char)
Returns: char

add_cref(frm, to, type)

 

Create a code cross-reference.

Parameters:
  • to - linear address of referenced instruction (C++: ea_t)
  • type - cross-reference type (C++: cref_t)
Returns: bool
success

del_cref(frm, to, expand)

 

Delete a code cross-reference.

Parameters:
  • to - linear address of referenced instruction (C++: ea_t)
  • 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 (C++: bool)
Returns: int

add_dref(frm, to, type)

 

Create a data cross-reference.

Parameters:
  • to - linear address of referenced data (C++: ea_t)
  • type - cross-reference type (C++: dref_t)
Returns: bool
success (may fail if user-defined xref exists from->to)

del_dref(frm, to)

 

Delete a data cross-reference.

Parameters:
  • to - linear address of referenced data (C++: ea_t)

get_first_dref_from(frm)

 

Get first data referenced from the specified address.

Returns: ea_t
linear address of first (lowest) data referenced from the specified address. The lastXR variable contains type of the reference. Return BADADDR if the specified instruction/data doesn't reference to anything.

get_next_dref_from(frm, current)

 

Get next data referenced from the specified address.

Parameters:
  • 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. (C++: ea_t)
Returns: ea_t
linear address of next data or BADADDR . The lastXR variable contains type of the reference

get_first_dref_to(to)

 

Get address of instruction/data referencing to the specified data.

Parameters:
  • to - linear address of referencing instruction or data (C++: ea_t)
Returns: ea_t
BADADDR if nobody refers to the specified data. The lastXR variable contains type of the reference.

get_next_dref_to(to, current)

 

Get address of instruction/data referencing to the specified data

Parameters:
  • to - linear address of referencing instruction or data (C++: ea_t)
  • current - current linear address. This value is returned by get_first_dref_to() or previous call to get_next_dref_to() functions. (C++: ea_t)
Returns: ea_t
BADADDR if nobody refers to the specified data. The lastXR variable contains type of the reference.

get_first_cref_from(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: ea_t
first referenced address. The lastXR variable contains type of the reference. If the specified instruction doesn't reference to other instructions then returns BADADDR .

get_next_cref_from(frm, current)

 

Get next instruction referenced from the specified instruction.

Parameters:
  • 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. (C++: ea_t)
Returns: ea_t
next referenced address or BADADDR . The lastXR variable contains type of the reference.

get_first_cref_to(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!).

Parameters:
  • to - linear address of referenced instruction (C++: ea_t)
Returns: ea_t
linear address of the first referencing instruction or BADADDR . The lastXR variable contains type of the reference.

get_next_cref_to(to, current)

 

Get next instruction referencing to the specified instruction.

Parameters:
  • to - linear address of referenced instruction (C++: ea_t)
  • 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. (C++: ea_t)
Returns: ea_t
linear address of the next referencing instruction or BADADDR . The lastXR variable contains type of the reference.

has_external_refs(pfn, ea)

 

Has a location external to the function references?

Parameters:
  • pfn, (C++ - func_t *)
  • ea, (C++ - ea_t)
Returns: bool

Variables Details

XREF_USER

User specified xref. This xref will not be deleted by IDA. This bit should be combined with the existing xref types ( 'cref_t' & 'dref_t' ) Can not be used for fl_F xrefs

Value:
32

XREF_PASTEND

Reference is past item. This bit may be passed to 'add_dref()' functions but it won't be saved in the database. It will prevent the destruction of eventual alignment directives.

Value:
256