Module ida_offset
[frames] | no frames]

Module ida_offset

IDA Plugin SDK API wrapper: offset

Functions
ea_t
add_refinfo_dref(insn, _from, ri, opval, type, opoff)
Add xrefs for a reference from the given instruction (\insn_t{ea}).
ea_t
calc_basevalue(target, base)
Calculate the value of the reference base.
ea_t
calc_offset_base(ea, n)
Try to calculate the offset base This function takes into account the fixup information, current ds and cs values.
ea_t
calc_probable_base_by_value(ea, off)
Try to calculate the offset base.
bool
calc_reference_data(target, base, _from, ri, opval)
Calculate the target and base addresses of an offset expression.
ea_t
calc_target(_from, opval, ri)
calc_target(_from, ea, n, opval) -> ea_t
ea_t
can_be_off32(ea)
Does the specified address contain a valid OFF32 value?.
reftype_t
get_default_reftype(ea)
Get default reference type depending on the segment.
ea_t
get_offbase(ea, n)
Get offset base value
str
get_offset_expr(ea, n, ri, _from, offset, getn_flags=0)
See 'get_offset_expression()'
str
get_offset_expression(ea, n, _from, offset, getn_flags=0)
Get offset expression (in the form "offset name+displ").
int
op_offset(ea, n, type, target=BADADDR, base=0, tdelta=0)
See 'op_offset_ex()'
int
op_offset_ex(ea, n, ri)
Convert operand to a reference.
bool
op_plain_offset(ea, n, base)
Convert operand to a reference with the default reference type.
Variables
  SWIG_PYTHON_LEGACY_BOOL = 1
  __package__ = None
Function Details

add_refinfo_dref(insn, _from, ri, opval, type, opoff)

 

Add xrefs for a reference from the given instruction (\insn_t{ea}). This function creates a cross references to the target and the base. 'insn_t::add_off_drefs()' calls this function to create xrefs for 'offset' operand.

Parameters:
  • insn - the referencing instruction (C++: const insn_t &)
  • _from - the referencing instruction/data address (C++: ea_t)
  • ri - reference info block from the database (C++: const refinfo_t &)
  • opval - operand value (usually op_t::value or op_t::addr ) (C++: adiff_t)
  • type - type of xref (C++: dref_t)
  • opoff - offset of the operand from the start of instruction (C++: int)
Returns: ea_t
the target address of the reference

calc_basevalue(target, base)

 

Calculate the value of the reference base.

Parameters:
  • target, (C++ - ea_t)
  • base, (C++ - ea_t)
Returns: ea_t

calc_offset_base(ea, n)

 

Try to calculate the offset base This function takes into account the fixup information, current ds and cs values.

Parameters:
  • ea - the referencing instruction/data address (C++: ea_t)
  • n - operand number 0: first operand 1: other operand (C++: int)
Returns: ea_t
output base address or BADADDR

calc_probable_base_by_value(ea, off)

 

Try to calculate the offset base. 2 bases are checked: current ds and cs. If fails, return 'BADADDR'

Parameters:
  • ea, (C++ - ea_t)
  • off, (C++ - uval_t)
Returns: ea_t

calc_reference_data(target, base, _from, ri, opval)

 

Calculate the target and base addresses of an offset expression. The calculated target and base addresses are returned in the locations pointed by 'base' and 'target'. In case 'ri.base' is 'BADADDR' , the function calculates the offset base address from the referencing instruction/data address. The target address is copied from ri.target. If ri.target is 'BADADDR' then the target is calculated using the base address and 'opval'. This function also checks if 'opval' matches the full value of the reference and takes in account the memory-mapping.

Parameters:
  • target - output target address (C++: ea_t *)
  • base - output base address (C++: ea_t *)
  • _from - the referencing instruction/data address (C++: ea_t)
  • ri - reference info block from the database (C++: const refinfo_t &)
  • opval - operand value (usually op_t::value or op_t::addr ) (C++: adiff_t)
Returns: bool
success

calc_target(_from, opval, ri)

 

calc_target(_from, ea, n, opval) -> ea_t

Calculates the target, using the provided 'refinfo_t' .

Parameters:
  • _from, (C++ - ea_t)
  • opval, (C++ - adiff_t)
  • ri, (C++ - const refinfo_t &)
Returns: ea_t

can_be_off32(ea)

 

Does the specified address contain a valid OFF32 value?. For symbols in special segments the displacement is not taken into account. If yes, then the target address of OFF32 will be returned. If not, then 'BADADDR' is returned.

Parameters:
  • ea, (C++ - ea_t)
Returns: ea_t

get_default_reftype(ea)

 

Get default reference type depending on the segment.

Parameters:
  • ea, (C++ - ea_t)
Returns: reftype_t
one of REF_OFF8 , REF_OFF16 , REF_OFF32

get_offbase(ea, n)

 

Get offset base value

Parameters:
  • ea - linear address (C++: ea_t)
  • n - number of operand (C++: int)
Returns: ea_t
offset base or BADADDR

get_offset_expr(ea, n, ri, _from, offset, getn_flags=0)

 

See 'get_offset_expression()'

Parameters:
  • ea, (C++ - ea_t)
  • n, (C++ - int)
  • ri, (C++ - const refinfo_t &)
  • _from, (C++ - ea_t)
  • offset, (C++ - adiff_t)
  • getn_flags, (C++ - int)
Returns: str

get_offset_expression(ea, n, _from, offset, getn_flags=0)

 

Get offset expression (in the form "offset name+displ"). This function uses offset translation function (\ph{translate}) if your IDP module has such a function. Translation function is used to map linear addresses in the program (only for offsets).Example: suppose we have instruction at linear address 0x00011000: \v{mov ax, [bx+7422h]} and at ds:7422h: \v{array dw ...} We want to represent the second operand with an offset expression, so then we call: \v{ get_offset_expresion(0x001100, 1, 0x001102, 0x7422, buf); | | | | | | | | | +output buffer | | | +value of offset expression | | +address offset value in the instruction | +the second operand +address of instruction } and the function will return a colored string: \v{offset array}

Parameters:
  • ea - start of instruction or data with the offset expression (C++: ea_t)
  • n - number of operand (may be ORed with OPND_OUTER ) 0: first operand 1: second operand (C++: int)
  • _from - linear address of instruction operand or data referring to the name. This address will be used to get fixup information, so it should point to exact position of operand in the instruction. (C++: ea_t)
  • offset - value of operand or its part. The function will return text representation of this value as offset expression. (C++: adiff_t)
  • getn_flags - combination of: GETN_APPZERO : meaningful only if the name refers to a structure. appends the struct field name if the field offset is zero GETN_NODUMMY : do not generate dummy names for the expression but pretend they already exist (useful to verify that the offset expression can be represented) (C++: int)
Returns: str

op_offset(ea, n, type, target=BADADDR, base=0, tdelta=0)

 

See 'op_offset_ex()'

Parameters:
  • ea, (C++ - ea_t)
  • n, (C++ - int)
  • type, (C++ - reftype_t)
  • target, (C++ - ea_t)
  • base, (C++ - ea_t)
  • tdelta, (C++ - adiff_t)
Returns: int

op_offset_ex(ea, n, ri)

 

Convert operand to a reference. To delete an offset, use 'clr_op_type()' function.

Parameters:
  • ea - linear address. if 'ea' has unexplored bytes, try to convert them to no segment: fail 16bit segment: to 16bit word data 32bit segment: to dword (C++: ea_t)
  • n - number of operand (may be ORed with OPND_OUTER ) 0: first 1: second 2: third OPND_MASK : all operands (C++: int)
  • ri - reference information (C++: const refinfo_t *)
Returns: int
success

op_plain_offset(ea, n, base)

 

Convert operand to a reference with the default reference type.

Parameters:
  • ea, (C++ - ea_t)
  • n, (C++ - int)
  • base, (C++ - ea_t)
Returns: bool