Module index

Module ida_struct

IDA Plugin SDK API wrapper: struct

Global variables

var MF_BASECLASS
a special member representing base class
var MF_BYTIL
the member was created due to the type system
var MF_DTOR
a special member representing destructor
var MF_DUPNAME
duplicate name resolved with _N suffix (N==soff)
var MF_HASTI
has type information?
var MF_HASUNI
has members of type "union"?
var MF_OK
is the member ok? (always yes)
var MF_UNIMEM
is a member of a union?
var SET_MEMTI_BYTIL
new type was created by the type subsystem
var SET_MEMTI_COMPATIBLE
new type must be compatible with the old
var SET_MEMTI_FUNCARG
mptr is function argument (cannot create arrays)
var SET_MEMTI_MAY_DESTROY
may destroy other members
var SET_MEMTI_USERTI
user-specified type
var SF_ALIGN
alignment (shift amount: 0..31)
var SF_FRAME
the structure is a function frame
var SF_GHOST
ghost copy of a local type
var SF_HASUNI
has members of type "union"?
var SF_HIDDEN
the structure is collapsed
var SF_NOLIST
don't include in the chooser list
var SF_TYPLIB
the structure comes from type library
var SF_UNION
is a union? varunions are prohibited!
var SF_VAR
is variable size structure (varstruct)? a variable size structure is one with the zero size last member. if the last member is a varstruct, then the current structure is a varstruct too.
var SMT_ARRAY
SMT_ARRAY = -2
var SMT_BADARG
SMT_BADARG = -6
var SMT_FAILED
SMT_FAILED = 0
var SMT_KEEP
SMT_KEEP = 2
var SMT_NOCOMPAT
SMT_NOCOMPAT = -5
var SMT_OK
SMT_OK = 1
var SMT_OVERLAP
SMT_OVERLAP = -1
var SMT_SIZE
SMT_SIZE = -3
var SMT_WORSE
SMT_WORSE = -4
var STRNFL_REGEX
apply regular expressions to beautify the name
var STRUC_ERROR_MEMBER_NAME
STRUC_ERROR_MEMBER_NAME = -1
var STRUC_ERROR_MEMBER_NESTED
STRUC_ERROR_MEMBER_NESTED = -8
var STRUC_ERROR_MEMBER_OFFSET
STRUC_ERROR_MEMBER_OFFSET = -2
var STRUC_ERROR_MEMBER_OK
STRUC_ERROR_MEMBER_OK = 0
var STRUC_ERROR_MEMBER_SIZE
STRUC_ERROR_MEMBER_SIZE = -3
var STRUC_ERROR_MEMBER_STRUCT
STRUC_ERROR_MEMBER_STRUCT = -5
var STRUC_ERROR_MEMBER_TINFO
STRUC_ERROR_MEMBER_TINFO = -4
var STRUC_ERROR_MEMBER_UNIVAR
STRUC_ERROR_MEMBER_UNIVAR = -6
var STRUC_ERROR_MEMBER_VARLAST
STRUC_ERROR_MEMBER_VARLAST = -7
var STRUC_SEPARATOR
structname.fieldname

Functions

def add_struc(*args) ‑> tid_t
Create a structure type. if idx== 'BADADDR' then add as the last idx. if name==NULL then a name will be generated "struct_%d".
add_struc(idx, name, is_union=False) -> tid_t
idx (C++: uval_t)
name (C++: const char *)
is_union (C++: bool)
def add_struc_member(*args) ‑> struc_error_t
Add member to existing structure.
add_struc_member(sptr, fieldname, offset, flag, mt, nbytes) -> struc_error_t
sptr: structure to modify (C++: struc_t *)
fieldname: if NULL, then "anonymous_#" name will be generated
(C++: const char *)
offset: BADADDR means add to the end of structure (C++: ea_t)
flag: type + representation bits (C++: flags_t)
mt: additional info about member type. must be present for
structs, offsets, enums, strings, struct offsets. (C++: const opinfo_t *)
nbytes: if == 0 then the structure will be a varstruct. in this
case the member should be the last member in the structure (C++: asize_t)
def del_member_tinfo(*args) ‑> bool
Delete tinfo for given member.
del_member_tinfo(sptr, mptr) -> bool
sptr (C++: struc_t *)
mptr (C++: member_t *)
def del_struc(*args) ‑> bool
Delete a structure type.
del_struc(sptr) -> bool
sptr (C++: struc_t *)
def del_struc_member(*args) ‑> bool
Delete member at given offset.
del_struc_member(sptr, offset) -> bool
sptr (C++: struc_t *)
offset (C++: ea_t)
def del_struc_members(*args) ‑> int
Delete members which occupy range of offsets (off1..off2).
del_struc_members(sptr, off1, off2) -> int
sptr (C++: struc_t *)
off1 (C++: ea_t)
off2 (C++: ea_t)
return: number of deleted members or -1 on error
def expand_struc(*args) ‑> bool
Expand/Shrink structure type.
expand_struc(sptr, offset, delta, recalc=True) -> bool
sptr (C++: struc_t *)
offset (C++: ea_t)
delta (C++: adiff_t)
recalc (C++: bool)
def get_best_fit_member(*args) ‑> member_t *
Get member that is most likely referenced by the specified offset. Useful for offsets > sizeof(struct).
get_best_fit_member(sptr, offset) -> member_t
sptr (C++: const struc_t *)
offset (C++: asize_t)
def get_first_struc_idx(*args) ‑> uval_t
Get index of first structure.
def get_innermost_member(*args) ‑> PyObject *
get_innermost_member(sptr, offset) -> PyObject *
Get the innermost member at the given offset
sptr: the starting structure
offset: offset into the starting structure
return:
  • None on failure
  • tuple(member_t, struct_t, offset)
    where member_t: a member in SPTR (it is not a structure),
    struct_t: the innermost structure, offset: remaining offset into the returned member
def get_last_struc_idx(*args) ‑> uval_t
Get index of last structure.
def get_max_offset(*args) ‑> ea_t
For unions: returns number of members, for structs: returns size of structure.
get_max_offset(sptr) -> ea_t
sptr (C++: struc_t *)
def get_member(*args) ‑> member_t *
Get member at given offset.
get_member(sptr, offset) -> member_t
sptr (C++: const struc_t *)
offset (C++: asize_t)
def get_member_by_fullname(*args) ‑> struc_t **
Get a member by its fully qualified name, "struct.field".
get_member_by_fullname(fullname) -> member_t
fullname (C++: const char *)
def get_member_by_id(*args) ‑> qstring *, struc_t **
Check if the specified member id points to a struct member.
get_member_by_id(mid) -> member_t
mid (C++: tid_t)
def get_member_by_name(*args) ‑> member_t *
Get a member by its name, like "field44".
get_member_by_name(sptr, membername) -> member_t
sptr (C++: const struc_t *)
membername (C++: const char *)
def get_member_cmt(*args) ‑> qstring *
Get comment of structure member.
get_member_cmt(mid, repeatable) -> str
mid (C++: tid_t)
repeatable (C++: bool)
def get_member_fullname(*args) ‑> qstring *
Get a member's fully qualified name, "struct.field".
get_member_fullname(mid) -> str
mid (C++: tid_t)
def get_member_id(*args) ‑> tid_t
Get member id at given offset.
get_member_id(sptr, offset) -> tid_t
sptr (C++: const struc_t *)
offset (C++: asize_t)
def get_member_name(*args) ‑> qstring *
Get name of structure member.
get_member_name(mid) -> str
mid (C++: tid_t)
def get_member_size(*args) ‑> asize_t
Get size of structure member. May return 0 for the last member of varstruct. For union members, returns 'member_t::eoff' .
get_member_size(mptr) -> asize_t
mptr (C++: const member_t *)
def get_member_struc(*args) ‑> struc_t *
Get containing structure of member by its full name "struct.field".
get_member_struc(fullname) -> struc_t
fullname (C++: const char *)
def get_member_tinfo(*args) ‑> bool
Get tinfo for given member.
get_member_tinfo(tif, mptr) -> bool
tif (C++: tinfo_t *)
mptr (C++: const member_t *)
def get_next_member_idx(*args) ‑> ssize_t
Get the next member idx, if it does not exist, return -1.
get_next_member_idx(sptr, off) -> ssize_t
sptr (C++: const struc_t *)
off (C++: asize_t)
def get_next_struc_idx(*args) ‑> uval_t
Get next struct index.
get_next_struc_idx(idx) -> uval_t
idx (C++: uval_t)
return: BADADDR if resulting index is out of bounds, otherwise idx++
def get_or_guess_member_tinfo(*args) ‑> bool
Try to get tinfo for given member - if failed, generate a tinfo using information about the member id from the disassembly
get_or_guess_member_tinfo(tif, mptr) -> bool
tif (C++: tinfo_t *)
mptr (C++: const member_t *)
def get_prev_member_idx(*args) ‑> ssize_t
Get the prev member idx, if it does not exist, return -1.
get_prev_member_idx(sptr, off) -> ssize_t
sptr (C++: const struc_t *)
off (C++: asize_t)
def get_prev_struc_idx(*args) ‑> uval_t
Get previous struct index.
get_prev_struc_idx(idx) -> uval_t
idx (C++: uval_t)
return: BADADDR if resulting index is negative, otherwise idx - 1
def get_sptr(*args) ‑> struc_t *
Get child struct if member is a struct.
get_sptr(mptr) -> struc_t
mptr (C++: const member_t *)
def get_struc(*args) ‑> struc_t *
Get pointer to struct type info.
get_struc(id) -> struc_t
id (C++: tid_t)
def get_struc_by_idx(*args) ‑> tid_t
Get struct id by struct number.
get_struc_by_idx(idx) -> tid_t
idx (C++: uval_t)
def get_struc_cmt(*args) ‑> qstring *
Get struct comment.
get_struc_cmt(id, repeatable) -> str
id (C++: tid_t)
repeatable (C++: bool)
def get_struc_first_offset(*args) ‑> ea_t
Get offset of first member.
get_struc_first_offset(sptr) -> ea_t
sptr (C++: const struc_t *)
return: BADADDR if memqty == 0
def get_struc_id(*args) ‑> tid_t
Get struct id by name.
get_struc_id(name) -> tid_t
name (C++: const char *)
def get_struc_idx(*args) ‑> uval_t
Get internal number of the structure.
get_struc_idx(id) -> uval_t
id (C++: tid_t)
def get_struc_last_offset(*args) ‑> ea_t
Get offset of last member.
get_struc_last_offset(sptr) -> ea_t
sptr (C++: const struc_t *)
return: BADADDR if memqty == 0
def get_struc_name(*args) ‑> qstring *
Get struct name by id
get_struc_name(id, flags=0) -> str
id: struct id (C++: tid_t)
flags: Struct name flags (C++: int)
def get_struc_next_offset(*args) ‑> ea_t
Get offset of member with smallest offset larger than 'offset'.
get_struc_next_offset(sptr, offset) -> ea_t
sptr (C++: const struc_t *)
offset (C++: ea_t)
return: BADADDR if no next offset
def get_struc_prev_offset(*args) ‑> ea_t
Get offset of member with largest offset less than 'offset'.
get_struc_prev_offset(sptr, offset) -> ea_t
sptr (C++: const struc_t *)
offset (C++: ea_t)
return: BADADDR if no prev offset
def get_struc_qty(*args) ‑> size_t
Get number of known structures.
def get_struc_size(*args) ‑> asize_t
Get struct size (also see 'get_struc_size(tid_t)' )
get_struc_size(sptr) -> asize_t
sptr (C++: const struc_t *)
get_struc_size(id) -> asize_t
id: tid_t
def is_anonymous_member_name(*args) ‑> bool
Is member name prefixed with "anonymous"?
is_anonymous_member_name(name) -> bool
name (C++: const char *)
def is_dummy_member_name(*args) ‑> bool
Is member name an auto-generated name?
is_dummy_member_name(name) -> bool
name (C++: const char *)
def is_member_id(*args) ‑> bool
Is a member id?
is_member_id(mid) -> bool
mid (C++: tid_t)
def is_special_member(*args) ‑> bool
Is a special member with the name beginning with ' '?
is_special_member(id) -> bool
id (C++: tid_t)
def is_union(*args) ‑> bool
Is a union?
is_union(id) -> bool
id (C++: tid_t)
def is_varmember(*args) ‑> bool
Is variable size member?
is_varmember(mptr) -> bool
mptr (C++: const member_t *)
def is_varstr(*args) ‑> bool
Is variable size structure?
is_varstr(id) -> bool
id (C++: tid_t)
def retrieve_member_info(*args) ‑> opinfo_t *
Get operand type info for member.
retrieve_member_info(buf, mptr) -> opinfo_t
buf (C++: opinfo_t *)
mptr (C++: const member_t *)
def save_struc(*args) ‑> void
Update struct information in the database (internal function)
save_struc(sptr, may_update_ltypes=True)
sptr (C++: struc_t *)
may_update_ltypes (C++: bool)
def set_member_cmt(*args) ‑> bool
Set member comment.
set_member_cmt(mptr, cmt, repeatable) -> bool
mptr (C++: member_t *)
cmt (C++: const char *)
repeatable (C++: bool)
def set_member_name(*args) ‑> bool
Set name of member at given offset.
set_member_name(sptr, offset, name) -> bool
sptr (C++: struc_t *)
offset (C++: ea_t)
name (C++: const char *)
def set_member_tinfo(*args) ‑> smt_code_t
Set tinfo for given member.
set_member_tinfo(sptr, mptr, memoff, tif, flags) -> smt_code_t
sptr: containing struct (C++: struc_t *)
mptr: target member (C++: member_t *)
memoff: offset within member (C++: uval_t)
tif: type info (C++: const tinfo_t &)
flags: Set member tinfo flags (C++: int)
def set_member_type(*args) ‑> bool
Set type of member at given offset (also see 'add_struc_member()' )
set_member_type(sptr, offset, flag, mt, nbytes) -> bool
sptr (C++: struc_t *)
offset (C++: ea_t)
flag (C++: flags_t)
mt (C++: const opinfo_t *)
nbytes (C++: asize_t)
def set_struc_align(*args) ‑> bool
Set structure alignment ( 'SF_ALIGN' )
set_struc_align(sptr, shift) -> bool
sptr (C++: struc_t *)
shift (C++: int)
def set_struc_cmt(*args) ‑> bool
Set structure comment.
set_struc_cmt(id, cmt, repeatable) -> bool
id (C++: tid_t)
cmt (C++: const char *)
repeatable (C++: bool)
def set_struc_hidden(*args) ‑> void
Hide/unhide a struct type.
set_struc_hidden(sptr, is_hidden)
sptr (C++: struc_t *)
is_hidden (C++: bool)
def set_struc_idx(*args) ‑> bool
Set internal number of struct. Also see 'get_struc_idx()' , 'get_struc_by_idx()' .
set_struc_idx(sptr, idx) -> bool
sptr (C++: const struc_t *)
idx (C++: uval_t)
def set_struc_listed(*args) ‑> void
Add/remove a struct type from the struct list.
set_struc_listed(sptr, is_listed)
sptr (C++: struc_t *)
is_listed (C++: bool)
def set_struc_name(*args) ‑> bool
Set structure name.
set_struc_name(id, name) -> bool
id (C++: tid_t)
name (C++: const char *)
def stroff_as_size(*args) ‑> bool
Should display a structure offset expression as the structure size?
stroff_as_size(plen, sptr, value) -> bool
plen (C++: int)
sptr (C++: const struc_t *)
value (C++: asize_t)
def visit_stroff_fields(*args) ‑> adiff_t *
Visit structure fields in a stroff expression or in a reference to a struct data variable. This function can be used to enumerate all components of an expression like 'a.b.c'.
visit_stroff_fields(sfv, path, disp, appzero) -> flags_t
sfv: visitor object (C++: struct_field_visitor_t &)
path: struct path (path[0] contains the initial struct id)
(C++: const tid_t *)
disp: offset into structure (C++: adiff_t *)
appzero: should visit field at offset zero? (C++: bool)

Classes

class dyn_member_ref_array (*args)
Proxy of C++ dynamic_wrapped_array_t< member_t > class.
__init__(self, _data, _count) -> dyn_member_ref_array
_data: member_t * _count: size_t

Instance variables

var count
dyn_member_ref_array_count_get(self) -> size_t
var data
dyn_member_ref_array_data_get(self) -> member_t
class member_t (*args)
Proxy of C++ member_t class.
__init__(self) -> member_t

Instance variables

var eoff
member_t_eoff_get(self) -> ea_t
var flag
member_t_flag_get(self) -> flags_t
var id
member_t_id_get(self) -> tid_t
var props
member_t_props_get(self) -> uint32
var soff
member_t_soff_get(self) -> ea_t

Methods

def by_til(self, *args) ‑> bool
Was the member created due to the type system?
def get_soff(self, *args) ‑> ea_t
Get start offset (for unions - returns 0)
def has_ti(self, *args) ‑> bool
Has type information?
def has_union(self, *args) ‑> bool
Has members of type "union"?
def is_baseclass(self, *args) ‑> bool
Is a base class member?
def is_destructor(self, *args) ‑> bool
Is a virtual destructor?
def is_dupname(self, *args) ‑> bool
Duplicate name was resolved during import?
def unimem(self, *args) ‑> bool
Is a member of a union?
class struc_t (*args, **kwargs)
Proxy of C++ struc_t class.

Instance variables

var age
struc_t_age_get(self) -> ushort
var id
struc_t_id_get(self) -> tid_t
var members : dynamic_wrapped_array_t< member_t >
__get_members__(self) -> dyn_member_ref_array
var memqty
struc_t_memqty_get(self) -> uint32
var ordinal
struc_t_ordinal_get(self) -> int32
var props
struc_t_props_get(self) -> uint32

Methods

def from_til(self, *args) ‑> bool
Does structure come from a type library?
def get_alignment(self, *args) ‑> int
See 'SF_ALIGN' .
def get_member(self, index)
def has_union(self, *args) ‑> bool
Has members of type "union"?
def is_choosable(self, *args) ‑> bool
Is included in chooser list? Use 'set_struc_listed' to change the listed status
def is_frame(self, *args) ‑> bool
Is this structure a function frame?
def is_ghost(self, *args) ‑> bool
Is a ghost copy of a local type?
def is_hidden(self, *args) ‑> bool
Is the structure collapsed? Use 'set_struc_hidden' to change the hidden status
def is_union(self, *args) ‑> bool
Is a union?
def is_varstr(self, *args) ‑> bool
Is variable size structure?
def set_alignment(self, *args) ‑> void
Do not use; use 'set_struc_align()'
set_alignment(self, shift)
shift (C++: int)
def set_ghost(self, *args) ‑> void
set_ghost(self, _is_ghost)
_is_ghost (C++: bool)
class struct_field_visitor_t (*args)
Proxy of C++ struct_field_visitor_t class.
__init__(self) -> struct_field_visitor_t
self: PyObject *

Methods

def visit_field(self, *args) ‑> int
visit_field(self, sptr, mptr) -> int
sptr (C++: struc_t *)
mptr (C++: member_t *)