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
Type parsing

Format/Parse/Print type information. More...

Modules

 Type formatting flags
 
 Type parsing flags
 
 Type printing flags
 

Typedefs

typedef int idaapi h2ti_type_cb(const char *name, const tinfo_t &tif, const char *cmt, const uint64 *value, void *cb_data)
 This callback will be called for each type/variable declaration. More...
 
typedef int printer_t(const char *format,...)
 Specify a printing callback when parsing types. More...
 

Functions

idaman int ida_export h2ti (til_t *ti, lexer_t *lx, const char *input, int flags=HTI_HIGH, h2ti_type_cb *type_cb=nullptr, h2ti_type_cb *var_cb=nullptr, printer_t *print_cb=nullptr, void *_cb_data=nullptr, abs_t _isabs=ABS_UNK)
 Convert declarations to type_t*. More...
 
THREAD_SAFE int convert_pt_flags_to_hti (int pt_flags)
 Convert Type parsing flags to Type formatting flags. More...
 
idaman bool ida_export parse_decl (tinfo_t *out_tif, qstring *out_name, til_t *til, const char *decl, int pt_flags)
 Parse ONE declaration. More...
 
idaman int ida_export parse_decls (til_t *til, const char *input, printer_t *printer, int hti_flags)
 Parse many declarations and store them in a til. More...
 
idaman bool ida_export print_type (qstring *out, ea_t ea, int prtype_flags)
 Get type declaration for the specified address. More...
 

Detailed Description

Format/Parse/Print type information.

Typedef Documentation

◆ h2ti_type_cb

typedef int idaapi h2ti_type_cb(const char *name, const tinfo_t &tif, const char *cmt, const uint64 *value, void *cb_data)

This callback will be called for each type/variable declaration.

Parameters
namevar/func/type name
tiftype info
cmtmain comment
valuesymbol value
cb_datadata passed to callback
Return values
T_CBBRKDEFthe type declaration won't be saved in the til

◆ printer_t

typedef int printer_t(const char *format,...)

Specify a printing callback when parsing types.

See h2ti() and parse_decls().

Function Documentation

◆ h2ti()

idaman int ida_export h2ti ( til_t ti,
lexer_t *  lx,
const char *  input,
int  flags = HTI_HIGH,
h2ti_type_cb type_cb = nullptr,
h2ti_type_cb var_cb = nullptr,
printer_t print_cb = nullptr,
void *  _cb_data = nullptr,
abs_t  _isabs = ABS_UNK 
)

Convert declarations to type_t*.

This is a low level function - use parse_decls() or parse_decl()

Parameters
titype info library
lxinput lexer. may be nullptr. always destroyed by h2ti()
inputfile name or C declaration
flagscombination of Type formatting flags
type_cbcallback - for each type
var_cbcallback - for each var
print_cbmay pass msg() here
_cb_datadata passed to callbacks
_isabsthe expected abstracness of the type declaration(s)
Returns
number of errors (they are displayed using print_cb). zero means ok

◆ convert_pt_flags_to_hti()

THREAD_SAFE int convert_pt_flags_to_hti ( int  pt_flags)
inline

Convert Type parsing flags to Type formatting flags.

Type parsing flags lesser than 0x10 don't have stable meaning and will be ignored (more on these flags can be seen in idc.idc)

◆ parse_decl()

idaman bool ida_export parse_decl ( tinfo_t out_tif,
qstring out_name,
til_t til,
const char *  decl,
int  pt_flags 
)

Parse ONE declaration.

If the input string contains more than one declaration, the first complete type declaration (PT_TYP) or the last variable declaration (PT_VAR) will be used.

Note
name & tif may be empty after the call!
Parameters
[out]out_tiftype info
[out]out_namedeclared name
tiltype library to use. may be nullptr
declC declaration to parse
pt_flagscombination of Type parsing flags bits
Return values
trueok
falsedeclaration is bad, the error message is displayed if !PT_SIL

◆ parse_decls()

idaman int ida_export parse_decls ( til_t til,
const char *  input,
printer_t printer,
int  hti_flags 
)

Parse many declarations and store them in a til.

If there are any errors, they will be printed using 'printer'. This function uses default include path and predefined macros from the database settings. It always uses the HTI_DCL bit.

Parameters
tiltype library to store the result
inputinput string or file name (see hti_flags)
printerfunction to output error messages (use msg or nullptr or your own callback)
hti_flagscombination of Type formatting flags
Returns
number of errors, 0 means ok.

◆ print_type()

idaman bool ida_export print_type ( qstring out,
ea_t  ea,
int  prtype_flags 
)

Get type declaration for the specified address.

Parameters
outoutput buffer
eaaddress
prtype_flagscombination of Type printing flags
Returns
success