It's obviously doable (you already noted the
Create C header file functionality), but if you want to customize the output, you'll have to code it yourself.
Here's what you'll need:
ida_typeinf.next_named_type to iterate through all of the type names in a TIL (i.e., the main TIL for an IDB).
- To retrieve a
tinfo_t type object from a type name, create
tif = ida_typeinf.tinfo_t(), then do
tif.get_named_type(name) with the name returned from the functions above.
- Once you have the
tinfo_t tif object, if
True, you can get the structure details via the function
tif.get_udt_details by passing it a new
ida_typeinf.udt_type_data_t data structure.
ida_typeinf.udt_type_data_t is a vector of
udt_member_t objects (plus additional information, e.g. size and alignment). Each
udt_member_t object describes one field in a
union. You can retrieve member names via the
.name field, and each field's
tinfo_t type via the
That's all you need. However, if you've never worked with types programmatically before, you're going to find it tricky. It is already evident from the above that
tinfo_t is a mutually recursive data structure, i.e., the
tinfo_t for a structure contains other data structures (like
udt_type_data_t) that themselves contain
tinfo_t objects to describe structure field types. Due to the mutual recursion in the data structures, functions involving
tinfo_t objects are often mutually recursive.