2

Is there a way to get all ordinals of the local types view with the ida python api?

i have tried to get all ordinals for structs with: [ida_struct.get_struc(id).ordinal for _, id, _ in Structs()]. This also works for enums if you replace Structs() with Enums() but this is not complete. Some structs are just in the local types view and i dont know how to get this ordinals.

  • 2
    Please add what did you've tried already. – Paweł Łukasik Mar 12 at 13:47
  • i have tried to get all ordinals for structs with: [ida_struct.get_struc(id).ordinal for _, id, _ in Structs()]. This also works for enums if you replace Structs() with Enums() but this is not complete. Some structs are just in the local types view and i dont know how to get this ordinals. – AdministrativeChip4 Mar 13 at 12:19
  • 1
    please put that into your question so that people can see you did some work before jumping with the questions. – Paweł Łukasik Mar 13 at 14:55
2

This should do it: you need to iterate over all the ordinals as defined in the local type information library returned by get_idati(). They are annoyingly indexed 1-up. For each ordinal you can get the corresponding tinfo_t with get_numbered_type.

import ida_typeinf

idati = ida_typeinf.get_idati()

for ordinal in xrange(1, ida_typeinf.get_ordinal_qty(idati)+1):
    ti = ida_typeinf.tinfo_t()
    if ti.get_numbered_type(idati, ordinal):
        print ordinal, ti

Not the answer you're looking for? Browse other questions tagged or ask your own question.