Module ida_struct
[frames] | no frames]

Module ida_struct

IDA Plugin SDK API wrapper: struct

Classes
  member_t
Proxy of C++ member_t class
  struc_t
Proxy of C++ struc_t class
  struct_field_visitor_t
Proxy of C++ struct_field_visitor_t class
Functions
asize_t
get_member_size(nonnul_mptr)
Get size of structure member.
size_t
get_struc_qty()
Get number of known structures.
uval_t
get_first_struc_idx()
Get index of first structure.
uval_t
get_last_struc_idx()
Get index of last structure.
uval_t
get_prev_struc_idx(idx)
Get previous struct index.
uval_t
get_next_struc_idx(idx)
Get next struct index.
uval_t
get_struc_idx(id)
Get internal number of the structure.
tid_t
get_struc_by_idx(idx)
Get struct id by struct number.
struc_t
get_struc(id)
Get pointer to struct type info.
tid_t
get_struc_id(name)
Get struct id by name.
ssize_t
get_struc_name(id)
Get struct name by id.
ssize_t
get_struc_cmt(id, repeatable)
Get struct comment.
asize_t
get_struc_size(sptr)
get_struc_size(id) -> asize_t
ea_t
get_struc_prev_offset(sptr, offset)
Get offset of member with largest offset less than 'offset'.
ea_t
get_struc_next_offset(sptr, offset)
Get offset of member with smallest offset larger than 'offset'.
ea_t
get_struc_last_offset(sptr)
Get offset of last member.
ea_t
get_struc_first_offset(sptr)
Get offset of first member.
ea_t
get_max_offset(sptr)
For unions: returns number of members, for structs: returns size of structure.
bool
is_varstr(id)
Is variable size structure?
bool
is_union(id)
Is a union?
struc_t
get_member_struc(fullname)
Get containing structure of member by its full name "struct.field".
struc_t
get_sptr(mptr)
Get child struct if member is a struct.
member_t
get_member(sptr, offset)
Get member at given offset.
tid_t
get_member_id(sptr, offset)
Get member id at given offset.
member_t
get_member_by_name(sptr, membername)
Get a member by its name, like "field44".
member_t
get_member_by_fullname(fullname)
Get a member by its fully qualified name, "struct.field".
ssize_t
get_member_fullname(mid)
Get a member's fully qualified name, "struct.field".
ssize_t
get_member_name(mid)
Get name of structure member.
ssize_t
get_member_cmt(mid, repeatable)
Get comment of structure member.
bool
is_varmember(mptr)
Is variable size member?
member_t
get_best_fit_member(sptr, offset)
Get member that is most likely referenced by the specified offset.
ssize_t
get_next_member_idx(sptr, off)
Get the next member idx, if it does not exist, return -1.
ssize_t
get_prev_member_idx(sptr, off)
Get the prev member idx, if it does not exist, return -1.
tid_t
add_struc(idx, name, is_union=False)
Create a structure type.
bool
del_struc(sptr)
Delete a structure type.
bool
set_struc_idx(sptr, idx)
Set internal number of struct.
bool
set_struc_align(sptr, shift)
Set structure alignment ( 'SF_ALIGN' )
bool
set_struc_name(id, name)
Set structure name.
bool
set_struc_cmt(id, cmt, repeatable)
Set structure comment.
struc_error_t
add_struc_member(sptr, fieldname, offset, flag, mt, nbytes)
Add member to existing structure.
bool
del_struc_member(sptr, offset)
Delete member at given offset.
int
del_struc_members(sptr, off1, off2)
Delete members which occupy range of offsets (off1..off2).
bool
set_member_name(sptr, offset, name)
Set name of member at given offset.
bool
set_member_type(sptr, offset, flag, mt, nbytes)
Set type of member at given offset (also see 'add_struc_member()' )
bool
set_member_cmt(mptr, cmt, repeatable)
Set member comment.
bool
expand_struc(sptr, offset, delta, recalc=True)
Expand/Shrink structure type.
 
save_struc(sptr, may_update_ltypes=True)
Update struct information in the database (internal function)
 
set_struc_hidden(sptr, is_hidden)
Hide/unhide a struct type.
 
set_struc_listed(sptr, is_listed)
Add/remove a struct type from the struct list.
bool
get_member_tinfo(tif, mptr)
Get tinfo for given member.
bool
del_member_tinfo(sptr, mptr)
Delete tinfo for given member.
smt_code_t
set_member_tinfo(sptr, mptr, memoff, tif, flags)
Set tinfo for given member.
bool
get_or_guess_member_tinfo(tif, mptr)
Try to get tinfo for given member - if failed, generate a tinfo using information about the member id from the disassembly
opinfo_t
retrieve_member_info(buf, mptr)
Get operand type info for member.
bool
is_anonymous_member_name(name)
Is member name prefixed with "anonymous"?
bool
is_dummy_member_name(name)
Is member name an auto-generated name?
member_t
get_member_by_id(mid)
Check if the specified member id points to a struct member.
bool
is_member_id(mid)
Is a member id?
bool
is_special_member(id)
Is a special member with the name beginning with ' '?
flags_t
visit_stroff_fields(sfv, path, disp, appzero)
Visit structure fields in a stroff expression or in a reference to a struct data variable.
bool
stroff_as_size(plen, sptr, value)
Should display a structure offset expression as the structure size?
Variables
  STRUC_SEPARATOR = '.'
structname.fieldname
  MF_OK = 1
is the member ok? (always yes)
  MF_UNIMEM = 2
is a member of a union?
  MF_HASUNI = 4
has members of type "union"?
  MF_BYTIL = 8
the member was created due to the type system
  MF_HASTI = 16
has type information?
  MF_BASECLASS = 32
a special member representing base class
  MF_DTOR = 64
a special member representing destructor
  MF_DUPNAME = 128
duplicate name resolved with _N suffix (N==soff)
  SF_VAR = 1
is variable size structure (varstruct)? a variable size structure is one with the zero size last member.
  SF_UNION = 2
varunions are prohibited!
  SF_HASUNI = 4
has members of type "union"?
  SF_NOLIST = 8
don't include in the chooser list
  SF_TYPLIB = 16
the structure comes from type library
  SF_HIDDEN = 32
the structure is collapsed
  SF_FRAME = 64
the structure is a function frame
  SF_ALIGN = 3968
alignment (shift amount: 0..31)
  SF_GHOST = 4096
ghost copy of a local type
  STRUC_ERROR_MEMBER_OK = 0
  STRUC_ERROR_MEMBER_NAME = -1
  STRUC_ERROR_MEMBER_OFFSET = -2
  STRUC_ERROR_MEMBER_SIZE = -3
  STRUC_ERROR_MEMBER_TINFO = -4
  STRUC_ERROR_MEMBER_STRUCT = -5
  STRUC_ERROR_MEMBER_UNIVAR = -6
  STRUC_ERROR_MEMBER_VARLAST = -7
  STRUC_ERROR_MEMBER_NESTED = -8
  SMT_BADARG = -6
  SMT_NOCOMPAT = -5
  SMT_WORSE = -4
  SMT_SIZE = -3
  SMT_ARRAY = -2
  SMT_OVERLAP = -1
  SMT_FAILED = 0
  SMT_OK = 1
  SMT_KEEP = 2
  SET_MEMTI_MAY_DESTROY = 1
may destroy other members
  SET_MEMTI_COMPATIBLE = 2
new type must be compatible with the old
  SET_MEMTI_FUNCARG = 4
mptr is function argument (cannot create arrays)
  SET_MEMTI_BYTIL = 8
new type was created by the type subsystem
  SET_MEMTI_USERTI = 16
user-specified type
  __package__ = None
Function Details

get_member_size(nonnul_mptr)

 

Get size of structure member. May return 0 for the last member of varstruct. For union members, returns 'member_t::eoff' .

Returns: asize_t

get_first_struc_idx()

 

Get index of first structure.

Returns: uval_t
BADADDR if no known structures, 0 otherwise

get_last_struc_idx()

 

Get index of last structure.

Returns: uval_t
BADADDR if no known structures, get_struc_qty() -1 otherwise

get_prev_struc_idx(idx)

 

Get previous struct index.

Parameters:
  • idx, (C++ - uval_t)
Returns: uval_t
BADADDR if resulting index is negative, otherwise idx - 1

get_next_struc_idx(idx)

 

Get next struct index.

Parameters:
  • idx, (C++ - uval_t)
Returns: uval_t
BADADDR if resulting index is out of bounds, otherwise idx++

get_struc_idx(id)

 

Get internal number of the structure.

Parameters:
  • id, (C++ - tid_t)
Returns: uval_t

get_struc_by_idx(idx)

 

Get struct id by struct number.

Parameters:
  • idx, (C++ - uval_t)
Returns: tid_t

get_struc(id)

 

Get pointer to struct type info.

Parameters:
  • id, (C++ - tid_t)
Returns: struc_t

get_struc_id(name)

 

Get struct id by name.

Parameters:
  • name, (C++ - const char *)
Returns: tid_t

get_struc_name(id)

 

Get struct name by id.

Parameters:
  • id, (C++ - tid_t)
Returns: ssize_t

get_struc_cmt(id, repeatable)

 

Get struct comment.

Parameters:
  • id, (C++ - tid_t)
  • repeatable, (C++ - bool)
Returns: ssize_t

get_struc_size(sptr)

 
  get_struc_size(id) -> asize_t


Get struct size (also see 'get_struc_size(tid_t)' )


@param sptr (C++: const  struc_t  *)
  

Returns: asize_t

get_struc_prev_offset(sptr, offset)

 

Get offset of member with largest offset less than 'offset'.

Parameters:
  • sptr, (C++ - const struc_t *)
  • offset, (C++ - ea_t)
Returns: ea_t
BADADDR if no prev offset

get_struc_next_offset(sptr, offset)

 

Get offset of member with smallest offset larger than 'offset'.

Parameters:
  • sptr, (C++ - const struc_t *)
  • offset, (C++ - ea_t)
Returns: ea_t
BADADDR if no next offset

get_struc_last_offset(sptr)

 

Get offset of last member.

Parameters:
  • sptr, (C++ - const struc_t *)
Returns: ea_t
BADADDR if memqty == 0

get_struc_first_offset(sptr)

 

Get offset of first member.

Parameters:
  • sptr, (C++ - const struc_t *)
Returns: ea_t
BADADDR if memqty == 0

get_max_offset(sptr)

 

For unions: returns number of members, for structs: returns size of structure.

Parameters:
  • sptr, (C++ - struc_t *)
Returns: ea_t

is_varstr(id)

 

Is variable size structure?

Parameters:
  • id, (C++ - tid_t)
Returns: bool

is_union(id)

 

Is a union?

Parameters:
  • id, (C++ - tid_t)
Returns: bool

get_member_struc(fullname)

 

Get containing structure of member by its full name "struct.field".

Parameters:
  • fullname, (C++ - const char *)
Returns: struc_t

get_sptr(mptr)

 

Get child struct if member is a struct.

Parameters:
  • mptr, (C++ - const member_t *)
Returns: struc_t

get_member(sptr, offset)

 

Get member at given offset.

Parameters:
  • sptr, (C++ - const struc_t *)
  • offset, (C++ - asize_t)
Returns: member_t

get_member_id(sptr, offset)

 

Get member id at given offset.

Parameters:
  • sptr, (C++ - const struc_t *)
  • offset, (C++ - asize_t)
Returns: tid_t

get_member_by_name(sptr, membername)

 

Get a member by its name, like "field44".

Parameters:
  • sptr, (C++ - const struc_t *)
  • membername, (C++ - const char *)
Returns: member_t

get_member_by_fullname(fullname)

 

Get a member by its fully qualified name, "struct.field".

Parameters:
  • fullname, (C++ - const char *)
Returns: member_t

get_member_fullname(mid)

 

Get a member's fully qualified name, "struct.field".

Parameters:
  • mid, (C++ - tid_t)
Returns: ssize_t

get_member_name(mid)

 

Get name of structure member.

Parameters:
  • mid, (C++ - tid_t)
Returns: ssize_t

get_member_cmt(mid, repeatable)

 

Get comment of structure member.

Parameters:
  • mid, (C++ - tid_t)
  • repeatable, (C++ - bool)
Returns: ssize_t

is_varmember(mptr)

 

Is variable size member?

Parameters:
  • mptr, (C++ - const member_t *)
Returns: bool

get_best_fit_member(sptr, offset)

 

Get member that is most likely referenced by the specified offset. Useful for offsets > sizeof(struct).

Parameters:
  • sptr, (C++ - const struc_t *)
  • offset, (C++ - asize_t)
Returns: member_t

get_next_member_idx(sptr, off)

 

Get the next member idx, if it does not exist, return -1.

Parameters:
  • sptr, (C++ - const struc_t *)
  • off, (C++ - asize_t)
Returns: ssize_t

get_prev_member_idx(sptr, off)

 

Get the prev member idx, if it does not exist, return -1.

Parameters:
  • sptr, (C++ - const struc_t *)
  • off, (C++ - asize_t)
Returns: ssize_t

add_struc(idx, name, is_union=False)

 

Create a structure type. if idx== 'BADADDR' then add as the last idx. if name==NULL then a name will be generated "struct_%d".

Parameters:
  • idx, (C++ - uval_t)
  • name, (C++ - const char *)
  • is_union, (C++ - bool)
Returns: tid_t

del_struc(sptr)

 

Delete a structure type.

Parameters:
  • sptr, (C++ - struc_t *)
Returns: bool

set_struc_idx(sptr, idx)

 

Set internal number of struct. Also see 'get_struc_idx()' , 'get_struc_by_idx()' .

Parameters:
  • sptr, (C++ - const struc_t *)
  • idx, (C++ - uval_t)
Returns: bool

set_struc_align(sptr, shift)

 

Set structure alignment ( 'SF_ALIGN' )

Parameters:
  • sptr, (C++ - struc_t *)
  • shift, (C++ - int)
Returns: bool

set_struc_name(id, name)

 

Set structure name.

Parameters:
  • id, (C++ - tid_t)
  • name, (C++ - const char *)
Returns: bool

set_struc_cmt(id, cmt, repeatable)

 

Set structure comment.

Parameters:
  • id, (C++ - tid_t)
  • cmt, (C++ - const char *)
  • repeatable, (C++ - bool)
Returns: bool

add_struc_member(sptr, fieldname, offset, flag, mt, nbytes)

 

Add member to existing structure.

Parameters:
  • 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)
Returns: struc_error_t

del_struc_member(sptr, offset)

 

Delete member at given offset.

Parameters:
  • sptr, (C++ - struc_t *)
  • offset, (C++ - ea_t)
Returns: bool

del_struc_members(sptr, off1, off2)

 

Delete members which occupy range of offsets (off1..off2).

Parameters:
  • sptr, (C++ - struc_t *)
  • off1, (C++ - ea_t)
  • off2, (C++ - ea_t)
Returns: int
number of deleted members or -1 on error

set_member_name(sptr, offset, name)

 

Set name of member at given offset.

Parameters:
  • sptr, (C++ - struc_t *)
  • offset, (C++ - ea_t)
  • name, (C++ - const char *)
Returns: bool

set_member_type(sptr, offset, flag, mt, nbytes)

 

Set type of member at given offset (also see 'add_struc_member()' )

Parameters:
  • sptr, (C++ - struc_t *)
  • offset, (C++ - ea_t)
  • flag, (C++ - flags_t)
  • mt, (C++ - const opinfo_t *)
  • nbytes, (C++ - asize_t)
Returns: bool

set_member_cmt(mptr, cmt, repeatable)

 

Set member comment.

Parameters:
  • mptr, (C++ - member_t *)
  • cmt, (C++ - const char *)
  • repeatable, (C++ - bool)
Returns: bool

expand_struc(sptr, offset, delta, recalc=True)

 

Expand/Shrink structure type.

Parameters:
  • sptr, (C++ - struc_t *)
  • offset, (C++ - ea_t)
  • delta, (C++ - adiff_t)
  • recalc, (C++ - bool)
Returns: bool

save_struc(sptr, may_update_ltypes=True)

 

Update struct information in the database (internal function)

Parameters:
  • sptr, (C++ - struc_t *)
  • may_update_ltypes, (C++ - bool)

set_struc_hidden(sptr, is_hidden)

 

Hide/unhide a struct type.

Parameters:
  • sptr, (C++ - struc_t *)
  • is_hidden, (C++ - bool)

set_struc_listed(sptr, is_listed)

 

Add/remove a struct type from the struct list.

Parameters:
  • sptr, (C++ - struc_t *)
  • is_listed, (C++ - bool)

get_member_tinfo(tif, mptr)

 

Get tinfo for given member.

Parameters:
  • tif, (C++ - tinfo_t *)
  • mptr, (C++ - const member_t *)
Returns: bool

del_member_tinfo(sptr, mptr)

 

Delete tinfo for given member.

Parameters:
  • sptr, (C++ - struc_t *)
  • mptr, (C++ - member_t *)
Returns: bool

set_member_tinfo(sptr, mptr, memoff, tif, flags)

 

Set tinfo for given member.

Parameters:
  • 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)
Returns: smt_code_t

get_or_guess_member_tinfo(tif, mptr)

 

Try to get tinfo for given member - if failed, generate a tinfo using information about the member id from the disassembly

Parameters:
  • tif, (C++ - tinfo_t *)
  • mptr, (C++ - const member_t *)
Returns: bool

retrieve_member_info(buf, mptr)

 

Get operand type info for member.

Parameters:
  • buf, (C++ - opinfo_t *)
  • mptr, (C++ - const member_t *)
Returns: opinfo_t

is_anonymous_member_name(name)

 

Is member name prefixed with "anonymous"?

Parameters:
  • name, (C++ - const char *)
Returns: bool

is_dummy_member_name(name)

 

Is member name an auto-generated name?

Parameters:
  • name, (C++ - const char *)
Returns: bool

get_member_by_id(mid)

 

Check if the specified member id points to a struct member.

Parameters:
  • mid, (C++ - tid_t)
Returns: member_t

is_member_id(mid)

 

Is a member id?

Parameters:
  • mid, (C++ - tid_t)
Returns: bool

is_special_member(id)

 

Is a special member with the name beginning with ' '?

Parameters:
  • id, (C++ - tid_t)
Returns: bool

visit_stroff_fields(sfv, path, disp, appzero)

 

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

Parameters:
  • 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)
Returns: flags_t

stroff_as_size(plen, sptr, value)

 

Should display a structure offset expression as the structure size?

Parameters:
  • plen, (C++ - int)
  • sptr, (C++ - const struc_t *)
  • value, (C++ - asize_t)
Returns: bool

Variables Details

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.

Value:
1

SF_UNION

varunions are prohibited!

is a union?

Value:
2