IDA SDK
Classes | Functions | Macros | Typedefs | Variables
enum.hpp File Reference

Detailed Description

Assembly level enum management.

Enums and bitfields are represented as enum_t.

Classes

struct  enum_member_visitor_t
 Enum member visitor - see for_all_enum_members(). More...
 

Functions

idaman size_t ida_export get_enum_qty (void)
 Get number of declared enum_t types.
 
idaman enum_t ida_export getn_enum (size_t n)
 Get enum by its ordinal number (0..n).
 
idaman uval_t ida_export get_enum_idx (enum_t id)
 Get serial number of enum. More...
 
idaman enum_t ida_export get_enum (const char *name)
 Get enum by name.
 
idaman bool ida_export is_bf (enum_t id)
 Is enum a bitfield? (otherwise - plain enum, no bitmasks except for DEFMASK are allowed)
 
idaman bool ida_export is_enum_hidden (enum_t id)
 Is enum collapsed?
 
idaman bool ida_export set_enum_hidden (enum_t id, bool hidden)
 Collapse enum.
 
idaman bool ida_export is_enum_fromtil (enum_t id)
 Does enum come from type library?
 
idaman bool ida_export set_enum_fromtil (enum_t id, bool fromtil)
 Specify that enum comes from a type library.
 
idaman bool ida_export is_ghost_enum (enum_t id)
 Is a ghost copy of a local type?
 
idaman bool ida_export set_enum_ghost (enum_t id, bool ghost)
 Specify that enum is a ghost copy of a local type.
 
idaman ssize_t ida_export get_enum_name (qstring *out, enum_t id)
 Get name of enum.
 
qstring get_enum_name (tid_t id)
 
idaman size_t ida_export get_enum_width (enum_t id)
 Get the width of a enum element allowed values: 0 (unspecified),1,2,4,8,16,32,64.
 
idaman bool ida_export set_enum_width (enum_t id, int width)
 See comment for get_enum_width()
 
idaman ssize_t ida_export get_enum_cmt (qstring *buf, enum_t id, bool repeatable)
 Get enum comment.
 
idaman size_t ida_export get_enum_size (enum_t id)
 Get the number of the members of the enum.
 
idaman flags_t ida_export get_enum_flag (enum_t id)
 Get flags determining the representation of the enum. More...
 
idaman const_t ida_export get_enum_member_by_name (const char *name)
 Get a reference to an enum member by its name.
 
idaman uval_t ida_export get_enum_member_value (const_t id)
 Get value of an enum member.
 
idaman enum_t ida_export get_enum_member_enum (const_t id)
 Get the parent enum of an enum member.
 
idaman bmask_t ida_export get_enum_member_bmask (const_t id)
 Get bitmask of an enum member.
 
idaman const_t ida_export get_enum_member (enum_t id, uval_t value, uchar serial, bmask_t mask)
 Find an enum member by enum, value and bitmask.
 
idaman ssize_t ida_export get_enum_member_name (qstring *out, const_t id)
 Get name of an enum member by const_t.
 
idaman ssize_t ida_export get_enum_member_cmt (qstring *buf, const_t id, bool repeatable)
 Get enum member's comment.
 
idaman int ida_export for_all_enum_members (enum_t id, enum_member_visitor_t &cv)
 Visit all members of a given enum.
 
idaman uchar ida_export get_enum_member_serial (const_t cid)
 Get serial number of an enum member.
 
idaman int32 ida_export get_enum_type_ordinal (enum_t id)
 Get corresponding type ordinal number.
 
idaman void ida_export set_enum_type_ordinal (enum_t id, int32 ord)
 Set corresponding type ordinal number.
 
idaman enum_t ida_export add_enum (size_t idx, const char *name, flags_t flag)
 Add new enum type. More...
 
idaman void ida_export del_enum (enum_t id)
 Delete an enum type.
 
idaman bool ida_export set_enum_idx (enum_t id, size_t idx)
 Set serial number of enum. More...
 
idaman bool ida_export set_enum_bf (enum_t id, bool bf)
 Set 'bitfield' bit of enum (i.e. convert it to a bitfield)
 
idaman bool ida_export set_enum_name (enum_t id, const char *name)
 Set name of enum type.
 
idaman bool ida_export set_enum_cmt (enum_t id, const char *cmt, bool repeatable)
 Set comment for enum type.
 
idaman bool ida_export set_enum_flag (enum_t id, flags_t flag)
 Set data representation flags.
 
idaman int ida_export add_enum_member (enum_t id, const char *name, uval_t value, bmask_t bmask=DEFMASK)
 Add member to enum type. More...
 
idaman bool ida_export del_enum_member (enum_t id, uval_t value, uchar serial, bmask_t bmask)
 Delete member of enum type.
 
idaman bool ida_export set_enum_member_name (const_t id, const char *name)
 Set name of enum member.
 
bool set_enum_member_cmt (const_t id, const char *cmt, bool repeatable)
 Set comment for enum member.
 
bool is_one_bit_mask (bmask_t mask)
 Is bitmask one bit?
 
Access to all used bitmasks in an enum
idaman bmask_t ida_export get_first_bmask (enum_t id)
 
idaman bmask_t ida_export get_last_bmask (enum_t id)
 
idaman bmask_t ida_export get_next_bmask (enum_t id, bmask_t bmask)
 
idaman bmask_t ida_export get_prev_bmask (enum_t id, bmask_t bmask)
 
Access to all enum members with specified bitmask
Note
these functions return values, not const_t!
idaman uval_t ida_export get_first_enum_member (enum_t id, bmask_t bmask=DEFMASK)
 
idaman uval_t ida_export get_last_enum_member (enum_t id, bmask_t bmask=DEFMASK)
 
idaman uval_t ida_export get_next_enum_member (enum_t id, uval_t value, bmask_t bmask=DEFMASK)
 
idaman uval_t ida_export get_prev_enum_member (enum_t id, uval_t value, bmask_t bmask=DEFMASK)
 
Access to all enum members with specified value and mask

A sample loop looks like this:

const_t main_cid;
uchar serial;
for ( const_t cid=main_cid=get_first_serial_enum_member(&serial, id, v, mask);
cid != BADNODE;
cid = get_next_serial_enum_member(&serial, main_cid) )
{
...
}

The 'out_serial' argument of get_first_serial_enum_member/get_last_serial_enum_member can be NULL. The 'in_out_serial' is required for the other functions.

idaman const_t ida_export get_first_serial_enum_member (uchar *out_serial, enum_t id, uval_t value, bmask_t bmask)
 
idaman const_t ida_export get_last_serial_enum_member (uchar *out_serial, enum_t id, uval_t value, bmask_t bmask)
 
idaman const_t ida_export get_next_serial_enum_member (uchar *in_out_serial, const_t first_cid)
 
idaman const_t ida_export get_prev_serial_enum_member (uchar *in_out_serial, const_t first_cid)
 
Work with the bitmask name & comment
idaman bool ida_export set_bmask_name (enum_t id, bmask_t bmask, const char *name)
 
idaman ssize_t ida_export get_bmask_name (qstring *out, enum_t id, bmask_t bmask)
 
idaman bool ida_export set_bmask_cmt (enum_t id, bmask_t bmask, const char *cmt, bool repeatable)
 
idaman ssize_t ida_export get_bmask_cmt (qstring *buf, enum_t id, bmask_t bmask, bool repeatable)
 

Macros

#define DEFMASK   (bmask_t(-1))
 default bitmask
 
#define ENUM_MEMBER_ERROR_NAME   1
 already have member with this name (bad name)
 
#define ENUM_MEMBER_ERROR_VALUE   2
 already have 256 members with this value
 
#define ENUM_MEMBER_ERROR_ENUM   3
 bad enum id
 
#define ENUM_MEMBER_ERROR_MASK   4
 bad bmask
 
#define ENUM_MEMBER_ERROR_ILLV   5
 bad bmask and value combination (~bmask & value != 0)
 

Typedefs

typedef tid_t enum_t
 Enums and bitfields.
 
typedef uval_t bmask_t
 unsigned value that describes a bitmask a bit mask is 32/64 bits. More...
 
typedef uval_t const_t
 members of enums
 

Variables

const uchar MAX_ENUM_SERIAL = 255
 Max number of identical constants allowed for one enum type.
 

Typedef Documentation

typedef uval_t bmask_t

unsigned value that describes a bitmask a bit mask is 32/64 bits.

Function Documentation

idaman uval_t ida_export get_enum_idx ( enum_t  id)

Get serial number of enum.

The serial number determines the place of the enum in the enum window.

idaman flags_t ida_export get_enum_flag ( enum_t  id)

Get flags determining the representation of the enum.

(currently they define the numeric base: octal, decimal, hex, bin) and signness.

idaman enum_t ida_export add_enum ( size_t  idx,
const char *  name,
flags_t  flag 
)

Add new enum type.

  • if idx==BADADDR then add as the last idx
  • if name==NULL then generate a unique name "enum_%d"
idaman bool ida_export set_enum_idx ( enum_t  id,
size_t  idx 
)

Set serial number of enum.

Also see get_enum_idx().

idaman int ida_export add_enum_member ( enum_t  id,
const char *  name,
uval_t  value,
bmask_t  bmask = DEFMASK 
)

Add member to enum type.

Returns
0 if ok, otherwise one of Add enum member result codes