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
Numbered types

Functions to work with numbered (ordinal) types. More...

Functions

idaman bool ida_export enable_numbered_types (til_t *ti, bool enable)
 Enable the use of numbered types in til. More...
 
idaman bool ida_export get_numbered_type (const til_t *ti, uint32 ordinal, const type_t **type=nullptr, const p_list **fields=nullptr, const char **cmt=nullptr, const p_list **fieldcmts=nullptr, sclass_t *sclass=nullptr)
 Retrieve a type by its ordinal number.
 
idaman uint32 ida_export alloc_type_ordinals (til_t *ti, int qty)
 Allocate a range of ordinal numbers for new types. More...
 
uint32 alloc_type_ordinal (til_t *ti)
 alloc_type_ordinals(ti, 1)
 
idaman uint32 ida_export get_ordinal_limit (const til_t *ti=nullptr)
 Get number of allocated ordinals + 1. More...
 
uint32 get_ordinal_count (const til_t *ti=nullptr)
 Get number of allocated ordinals. More...
 
idaman tinfo_code_t ida_export set_numbered_type (til_t *ti, uint32 ordinal, int ntf_flags, const char *name, const type_t *type, const p_list *fields=nullptr, const char *cmt=nullptr, const p_list *fldcmts=nullptr, const sclass_t *sclass=nullptr)
 Store a type in the til. More...
 
idaman bool ida_export del_numbered_type (til_t *ti, uint32 ordinal)
 Delete a numbered type.
 
idaman bool ida_export set_type_alias (til_t *ti, uint32 src_ordinal, uint32 dst_ordinal)
 Create a type alias. More...
 
idaman uint32 ida_export get_alias_target (const til_t *ti, uint32 ordinal)
 Find the final alias destination. More...
 
idaman int32 ida_export get_type_ordinal (const til_t *ti, const char *name)
 Get type ordinal by its name.
 
idaman const char *ida_export get_numbered_type_name (const til_t *ti, uint32 ordinal)
 Get type name (if exists) by its ordinal. More...
 
idaman ssize_t ida_export create_numbered_type_name (qstring *buf, int32 ord)
 Create anonymous name for numbered type. More...
 
idaman bool ida_export is_ordinal_name (const char *name, uint32 *ord=nullptr)
 Check if the name is an ordinal name. More...
 
idaman int ida_export get_ordinal_from_idb_type (const char *name, const type_t *type)
 Get ordinal number of an idb type (struct/enum). More...
 
bool idaapi is_autosync (const char *name, const type_t *type)
 Is the specified idb type automatically synchronized?
 
bool idaapi is_autosync (const char *name, const tinfo_t &tif)
 Is the specified idb type automatically synchronized? More...
 
idaman void ida_export build_anon_type_name (qstring *buf, const type_t *type, const p_list *fields)
 Generate a name like $hex_numbers based on the field types and names.
 
idaman int ida_export compact_numbered_types (til_t *ti, uint32 min_ord=0, intvec_t *p_ordmap=nullptr, int flags=0)
 Compact numbered types to get rid of empty slots. More...
 
idaman bool ida_export is_type_choosable (const til_t *ti, uint32 ordinal)
 Check if a struct/union type is choosable. More...
 
idaman void ida_export set_type_choosable (til_t *ti, uint32 ordinal, bool value)
 Enable/disable 'choosability' flag for a struct/union type. More...
 

Detailed Description

Functions to work with numbered (ordinal) types.

Numbered types may be named or anonymous. They are referenced by their ordinal number. Access to them is faster because there is no need to resolve their names. Also, they can stay anonymous and be aliased. They can be used only in the local type library created by IDA (in idati).

Function Documentation

◆ enable_numbered_types()

idaman bool ida_export enable_numbered_types ( til_t ti,
bool  enable 
)

Enable the use of numbered types in til.

Currently it is impossible to disable numbered types once they are enabled

◆ alloc_type_ordinals()

idaman uint32 ida_export alloc_type_ordinals ( til_t ti,
int  qty 
)

Allocate a range of ordinal numbers for new types.

Parameters
titype library
qtynumber of ordinals to allocate
Returns
the first ordinal. 0 means failure.

◆ get_ordinal_limit()

idaman uint32 ida_export get_ordinal_limit ( const til_t ti = nullptr)

Get number of allocated ordinals + 1.

If there are no allocated ordinals, return 0. To enumerate all ordinals, use: for ( uint32 i = 1; i < limit; ++i )

Parameters
titype library; nullptr means the local types for the current database.
Returns
uint32(-1) if ordinals have not been enabled for the til. For local types (idati), ordinals are always enabled.

◆ get_ordinal_count()

uint32 get_ordinal_count ( const til_t ti = nullptr)
inline

Get number of allocated ordinals.

Parameters
titype library; nullptr means the local types for the current database.
Returns
0 if ordinals have not been enabled for the til.

◆ set_numbered_type()

idaman tinfo_code_t ida_export set_numbered_type ( til_t ti,
uint32  ordinal,
int  ntf_flags,
const char *  name,
const type_t type,
const p_list fields = nullptr,
const char *  cmt = nullptr,
const p_list fldcmts = nullptr,
const sclass_t sclass = nullptr 
)

Store a type in the til.

'name' may be nullptr for anonymous types. To replace the existed type use NTF_REPLACE

◆ set_type_alias()

idaman bool ida_export set_type_alias ( til_t ti,
uint32  src_ordinal,
uint32  dst_ordinal 
)

Create a type alias.

Redirects all references to source type to the destination type. This is equivalent to instantaneous replacement all references to srctype by dsttype.

◆ get_alias_target()

idaman uint32 ida_export get_alias_target ( const til_t ti,
uint32  ordinal 
)

Find the final alias destination.

If the ordinal has not been aliased, return the specified ordinal itself If failed, returns 0.

◆ get_numbered_type_name()

idaman const char *ida_export get_numbered_type_name ( const til_t ti,
uint32  ordinal 
)

Get type name (if exists) by its ordinal.

If the type is anonymous, returns "". If failed, returns nullptr

◆ create_numbered_type_name()

idaman ssize_t ida_export create_numbered_type_name ( qstring buf,
int32  ord 
)

Create anonymous name for numbered type.

This name can be used to reference a numbered type by its ordinal Ordinal names have the following format: '#' + set_de(ord) Returns: -1 if error, otherwise the name length

◆ is_ordinal_name()

idaman bool ida_export is_ordinal_name ( const char *  name,
uint32 ord = nullptr 
)

Check if the name is an ordinal name.

Ordinal names have the following format: '#' + set_de(ord)

◆ get_ordinal_from_idb_type()

idaman int ida_export get_ordinal_from_idb_type ( const char *  name,
const type_t type 
)

Get ordinal number of an idb type (struct/enum).

The 'type' parameter is used only to determine the kind of the type (struct or enum) Use this function to find out the correspondence between idb types and til types

◆ is_autosync()

bool idaapi is_autosync ( const char *  name,
const tinfo_t tif 
)
inline

Is the specified idb type automatically synchronized?

◆ compact_numbered_types()

idaman int ida_export compact_numbered_types ( til_t ti,
uint32  min_ord = 0,
intvec_t p_ordmap = nullptr,
int  flags = 0 
)

Compact numbered types to get rid of empty slots.

Parameters
titype library to compact
min_ordminimal ordinal number to start to compact. lower ordinals are not modified
p_ordmapthe resulting mapping (for example, the new ordinal of min_ord will be in ordmap[0])
flagsreserved
Returns
number of freed type slots

◆ is_type_choosable()

idaman bool ida_export is_type_choosable ( const til_t ti,
uint32  ordinal 
)

Check if a struct/union type is choosable.

Parameters
titype library
ordinalordinal number of a UDT type

◆ set_type_choosable()

idaman void ida_export set_type_choosable ( til_t ti,
uint32  ordinal,
bool  value 
)

Enable/disable 'choosability' flag for a struct/union type.

Parameters
titype library
ordinalordinal number of a UDT type
valueflag value