Latest available version: IDA and decompilers v8.4.240320sp1 see all releases
Hex-Rays logo State-of-the-art binary code analysis tools
email icon
Named types

functions to work with named types More...

Modules

 Flags for named types
 
 C/C++ naming flags
 

Enumerations

enum  tinfo_code_t {
  TERR_OK = 0 , TERR_SAVE_ERROR = -1 , TERR_SERIALIZE = -2 , TERR_BAD_NAME = -3 ,
  TERR_BAD_SYNC = -4 , TERR_BAD_ARG = -5 , TERR_BAD_TYPE = -6 , TERR_BAD_SIZE = -7 ,
  TERR_BAD_INDEX = -8 , TERR_BAD_ARRAY = -9 , TERR_BAD_BF = -10 , TERR_BAD_OFFSET = -11 ,
  TERR_BAD_UNIVAR = -12 , TERR_BAD_VARLAST = -13 , TERR_OVERLAP = -14 , TERR_BAD_SUBTYPE = -15 ,
  TERR_BAD_VALUE = -16 , TERR_NO_BMASK = -17 , TERR_BAD_BMASK = -18 , TERR_BAD_MSKVAL = -19 ,
  TERR_BAD_REPR = -20 , TERR_GRP_NOEMPTY = -21 , TERR_DUPNAME = -22 , TERR_UNION_BF = -23 ,
  TERR_BAD_TAH = -24 , TERR_BAD_BASE = -25 , TERR_BAD_GAP = -26 , TERR_NESTED = -27 ,
  TERR_NOT_COMPAT = -28 , TERR_BAD_LAYOUT = -29 , TERR_BAD_GROUPS = -30 , TERR_BAD_SERIAL = -31 ,
  TERR_ALIEN_NAME = -32 , TERR_STOCK = -33 , TERR_ENUM_SIZE = -34 , TERR_NOT_IMPL = -35 ,
  TERR_COUNT = 36
}
 Error codes various tinfo functions: More...
 

Functions

idaman int ida_export get_named_type (const til_t *ti, const char *name, int ntf_flags, const type_t **type=nullptr, const p_list **fields=nullptr, const char **cmt=nullptr, const p_list **fieldcmts=nullptr, sclass_t *sclass=nullptr, uint32 *value=nullptr)
 Get named typeinfo. More...
 
int idaapi get_named_type64 (const til_t *ti, const char *name, int ntf_flags, const type_t **type=nullptr, const p_list **fields=nullptr, const char **cmt=nullptr, const p_list **fieldcmts=nullptr, sclass_t *sclass=nullptr, uint64 *value=nullptr)
 See get_named_type() above. More...
 
idaman const char *ida_export tinfo_errstr (tinfo_code_t code)
 Helper function to convert an error code into a printable string. More...
 
idaman bool ida_export del_named_type (til_t *ti, const char *name, int ntf_flags)
 Delete information about a symbol. More...
 
idaman const char *ida_export first_named_type (const til_t *ti, int ntf_flags)
 Enumerate types. More...
 
idaman const char *ida_export next_named_type (const til_t *ti, const char *name, int ntf_flags)
 Enumerate types. More...
 
idaman uint32 ida_export copy_named_type (til_t *dsttil, const til_t *srctil, const char *name)
 Copy a named type from one til to another. More...
 
idaman bool ida_export decorate_name (qstring *out, const char *name, bool mangle, cm_t cc=CM_CC_UNKNOWN, const tinfo_t *type=nullptr)
 Decorate/undecorate a C symbol name. More...
 
idaman bool ida_export gen_decorate_name (qstring *out, const char *name, bool mangle, cm_t cc, const tinfo_t *type)
 Generic function for decorate_name() (may be used in IDP modules)
 
idaman ssize_t ida_export calc_c_cpp_name (qstring *out, const char *name, const tinfo_t *type, int ccn_flags)
 Get C or C++ form of the name. More...
 

Detailed Description

functions to work with named types

Enumeration Type Documentation

◆ tinfo_code_t

Error codes various tinfo functions:

Enumerator
TERR_OK 

ok

TERR_SAVE_ERROR 

failed to save

TERR_SERIALIZE 

failed to serialize

TERR_BAD_NAME 

name s is not acceptable

TERR_BAD_SYNC 

failed to synchronize with IDB

TERR_BAD_ARG 

bad argument

TERR_BAD_TYPE 

bad type

TERR_BAD_SIZE 

bad size d

TERR_BAD_INDEX 

bad index d

TERR_BAD_ARRAY 

arrays are forbidden as function arguments

TERR_BAD_BF 

bitfields are forbidden as function arguments

TERR_BAD_OFFSET 

bad member offset s

TERR_BAD_UNIVAR 

unions cannot have variable sized members

TERR_BAD_VARLAST 

variable sized member must be the last member in the structure

TERR_OVERLAP 

the member overlaps with other members that cannot be deleted

TERR_BAD_SUBTYPE 

recursive structure nesting is forbidden

TERR_BAD_VALUE 

value 0xI64X is not acceptable

TERR_NO_BMASK 

bitmask 0xI64X is not found

TERR_BAD_BMASK 

Bad enum member mask 0xI64X. The specified mask should not intersect with any existing mask in the enum. Zero masks are prohibited too.

TERR_BAD_MSKVAL 

bad bmask and value combination (value=0xI64X; bitmask 0xI64X)

TERR_BAD_REPR 

bad or incompatible field representation

TERR_GRP_NOEMPTY 

could not delete group mask for not empty group 0xI64X

TERR_DUPNAME 

duplicate name s

TERR_UNION_BF 

unions cannot have bitfields

TERR_BAD_TAH 

bad bits in the type attributes (TAH bits)

TERR_BAD_BASE 

bad base class

TERR_BAD_GAP 

bad gap

TERR_NESTED 

recursive structure nesting is forbidden

TERR_NOT_COMPAT 

the new type is not compatible with the old type

TERR_BAD_LAYOUT 

failed to calculate the structure/union layout

TERR_BAD_GROUPS 

bad group sizes for bitmask enum

TERR_BAD_SERIAL 

enum value has too many serials

TERR_ALIEN_NAME 

enum member name is used in another enum

TERR_STOCK 

stock type info cannot be modified

TERR_ENUM_SIZE 

bad enum size

TERR_NOT_IMPL 

not implemented

Function Documentation

◆ get_named_type()

idaman int ida_export get_named_type ( const til_t ti,
const char *  name,
int  ntf_flags,
const type_t **  type = nullptr,
const p_list **  fields = nullptr,
const char **  cmt = nullptr,
const p_list **  fieldcmts = nullptr,
sclass_t sclass = nullptr,
uint32 value = nullptr 
)

Get named typeinfo.

The returned pointers are pointers to static storage.
They are valid until free_til(), set_named_type(), del_named_type(),
rename_named_type(), set_numbered_type(), del_numbered_type(),
and idb structure/enum manipulation (in other words, until til_t is changed).

Parameters
tipointer to type information library
namename of type
ntf_flagscombination of Flags for named types
typeptr to ptr to output buffer for the type info
fieldsptr to ptr to the field/args names. may be nullptr
cmtptr to ptr to the main comment. may be nullptr the comment may has TPOS_REGCMT as its first byte
fieldcmtsptr to ptr to the field/args comments. may be nullptr
sclassptr to storage class
valueptr to symbol value. for types, ptr to the ordinal number
Return values
0can't find the named type (or name==nullptr)
1ok, the buffers are filled with information (if not nullptr)
2ok, found it in a base til

◆ get_named_type64()

int idaapi get_named_type64 ( const til_t ti,
const char *  name,
int  ntf_flags,
const type_t **  type = nullptr,
const p_list **  fields = nullptr,
const char **  cmt = nullptr,
const p_list **  fieldcmts = nullptr,
sclass_t sclass = nullptr,
uint64 *  value = nullptr 
)
inline

See get_named_type() above.

Note
If the value in the 'ti' library is 32-bit, it will be sign-extended before being stored in the 'value' pointer.

◆ tinfo_errstr()

idaman const char *ida_export tinfo_errstr ( tinfo_code_t  code)

Helper function to convert an error code into a printable string.

Additional arguments are handled using the functions from err.h

◆ del_named_type()

idaman bool ida_export del_named_type ( til_t ti,
const char *  name,
int  ntf_flags 
)

Delete information about a symbol.

Parameters
titype library
namename of symbol
ntf_flagscombination of Flags for named types
Returns
success

◆ first_named_type()

idaman const char *ida_export first_named_type ( const til_t ti,
int  ntf_flags 
)

Enumerate types.

Parameters
titype library. nullptr means the local type library for the current database.
ntf_flagscombination of Flags for named types
Returns
Type or symbol names, depending of ntf_flags. Returns mangled names. Never returns anonymous types. To include them, enumerate types by ordinals.

◆ next_named_type()

idaman const char *ida_export next_named_type ( const til_t ti,
const char *  name,
int  ntf_flags 
)

Enumerate types.

Parameters
titype library. nullptr means the local type library for the current database.
ntf_flagscombination of Flags for named types
Returns
Type or symbol names, depending of ntf_flags. Returns mangled names. Never returns anonymous types. To include them, enumerate types by ordinals.
Parameters
namethe current name. the name that follows this one will be returned.

◆ copy_named_type()

idaman uint32 ida_export copy_named_type ( til_t dsttil,
const til_t srctil,
const char *  name 
)

Copy a named type from one til to another.

This function will copy the specified type and all dependent types from the source type library to the destination library.

Parameters
dsttilDestination til. It must have orginal types enabled
srctilSource til.
namename of the type to copy
Returns
ordinal number of the copied type. 0 means error

◆ decorate_name()

idaman bool ida_export decorate_name ( qstring out,
const char *  name,
bool  mangle,
cm_t  cc = CM_CC_UNKNOWN,
const tinfo_t type = nullptr 
)

Decorate/undecorate a C symbol name.

Parameters
outoutput buffer
namename of symbol
mangletrue-mangle, false-unmangle
cccalling convention
typename type (nullptr-unknown)
Returns
success

◆ calc_c_cpp_name()

idaman ssize_t ida_export calc_c_cpp_name ( qstring out,
const char *  name,
const tinfo_t type,
int  ccn_flags 
)

Get C or C++ form of the name.

Parameters
outoutput buffer
nameoriginal (mangled or decorated) name
typename type if known, otherwise nullptr
ccn_flagsone of C/C++ naming flags