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.
  casevec_t
Proxy of C++ qvector< qvector< sval_t > > class.
  xrefblk_t
Proxy of C++ xrefblk_t class.
Functions
bool
add_cref(frm, to, type)
Create a code cross-reference.
bool
add_dref(frm, to, type)
Create a data cross-reference.
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
bool
create_switch_xrefs(ea, si)
This function creates xrefs from the indirect jump.
int
del_cref(frm, to, expand)
Delete a code cross-reference.
 
del_dref(frm, to)
Delete a data cross-reference.
 
delete_switch_table(jump_ea, si)
ea_t
get_first_cref_from(frm)
Get first instruction referenced from the specified instruction.
ea_t
get_first_cref_to(to)
Get first instruction referencing to the specified instruction.
ea_t
get_first_dref_from(frm)
Get first 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_first_fcref_from(frm)
ea_t
get_first_fcref_to(to)
ea_t
get_next_cref_from(frm, current)
Get next instruction referenced from the specified instruction.
ea_t
get_next_cref_to(to, current)
Get next instruction referencing to the specified instruction.
ea_t
get_next_dref_from(frm, current)
Get next data referenced from the specified address.
ea_t
get_next_dref_to(to, current)
Get address of instruction/data referencing to the specified data
ea_t
get_next_fcref_from(frm, current)
ea_t
get_next_fcref_to(to, current)
bool
has_external_refs(pfn, ea)
Has a location external to the function references?
char
xrefchar(xrtype)
Get character describing the xref type.
Variables
  SWIG_PYTHON_LEGACY_BOOL = 1
  XREF_ALL = 0
  XREF_BASE = 128
  XREF_DATA = 2
  XREF_FAR = 1
  XREF_MASK = 31
  XREF_PASTEND = 256
  XREF_TAIL = 64
  XREF_USER = 32
  __package__ = None
  dr_I = 5
  dr_O = 1
  dr_R = 3
  dr_S = 6
  dr_T = 4
  dr_U = 0
  dr_W = 2
  fl_CF = 16
  fl_CN = 17
  fl_F = 21
  fl_JF = 18
  fl_JN = 19
  fl_U = 0
  fl_USobsolete = 20
Function Details

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

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)

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'.

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

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

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

del_dref(frm, to)

 

Delete a data cross-reference.

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

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_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_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_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_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_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.

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_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.

has_external_refs(pfn, ea)

 

Has a location external to the function references?

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

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