Skip to content

Commit

Permalink
Fix applied type IDA types, add function sig fn
Browse files Browse the repository at this point in the history
  • Loading branch information
stevemk14ebr committed Oct 12, 2023
1 parent 41c8b47 commit 5f3a1ad
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions IDAPython/goresym_rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ def is_autosync(name, tif):
struc.ordinal = -1
idaapi.save_struc(struc, False)

def get_type_by_name(name):
ti = idaapi.get_idati()
type_ord = idaapi.get_type_ordinal(ti, name)
# typ_type, typ_fields, typ_cmt, typ_fieldcmts, typ_sclass
return ida_typeinf.get_numbered_type(ti, type_ord)

def set_function_signature(ea, typedef):
idaapi.apply_type(ea, ida_typeinf.parse_decl(typedef, ida_typeinf.PT_SIL), idaapi.TINFO_DEFINITE)

def import_primitives():
type_map = {
"BUILTIN_STRING": "string",
Expand Down Expand Up @@ -119,8 +128,8 @@ def forward_declare_structs(types):

# IDA often thinks these are string pointers, lets undefine that, then set the type correctly
ida_bytes.del_items(typ['VA'], 0, 4)
py_type = idaapi.idc_parse_decl(idaapi.cvar.idati, "void* ptr;", 1)
idaapi.apply_type(idaapi.cvar.idati, py_type[1], py_type[2], typ['VA'], idaapi.TINFO_DEFINITE)
abi_typ, abi_typ_fields, _, _, _ = get_type_by_name("abi_Type")
idaapi.apply_type(idaapi.get_idati(), abi_typ, abi_typ_fields, typ['VA'], idaapi.TINFO_DEFINITE)

if iterable(hints['Interfaces']):
for typ in hints['Interfaces']:
Expand All @@ -129,8 +138,8 @@ def forward_declare_structs(types):

# IDA often thinks these are string pointers, lets undefine that, then set the type correctly
ida_bytes.del_items(typ['VA'], 0, 4)
py_type = idaapi.idc_parse_decl(idaapi.cvar.idati, "void* ptr;", 1)
idaapi.apply_type(idaapi.cvar.idati, py_type[1], py_type[2], typ['VA'], idaapi.TINFO_DEFINITE)
abi_typ, abi_typ_fields, _, _, _ = get_type_by_name("abi_Type")
idaapi.apply_type(idaapi.get_idati(), abi_typ, abi_typ_fields, typ['VA'], idaapi.TINFO_DEFINITE)

if hints['TabMeta'] is not None:
tabmeta = hints['TabMeta']
Expand Down

0 comments on commit 5f3a1ad

Please sign in to comment.