Skip to content

Instantly share code, notes, and snippets.

@SilverBut
Last active July 17, 2018 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SilverBut/7306d5bb839ace49a5c541d2c63b373a to your computer and use it in GitHub Desktop.
Save SilverBut/7306d5bb839ace49a5c541d2c63b373a to your computer and use it in GitHub Desktop.
# Reversing CPP program is painful, especially when it contains tempalte classes
# But rename them is not a bad idea...
def rename_copy(ord_old, name_new, ord_new=None):
py_til = ida_typeinf.get_idati()
py_ti = ida_typeinf.tinfo_t()
py_ti.get_numbered_type(py_til, ord_old)
if not ord_new:
ord_new = ida_typeinf.alloc_type_ordinal(py_til)
print(py_ti.set_numbered_type(py_til, ord_new, 4, name_new))
return ord_new
def rename_ref(ord_old, name_new, ord_new=None):
py_til = ida_typeinf.get_idati()
if not ord_new:
ord_new = ida_typeinf.alloc_type_ordinal(py_til)
py_ti = ida_typeinf.tinfo_t()
py_td = ida_typeinf.typedef_type_data_t(py_til, ord_old)
py_ti.create_typedef(py_td)
print(py_ti.set_numbered_type(
py_til,
ord_new,
ida_typeinf.NTF_REPLACE,
name_new))
return ord_new
def rename_onsite(ord_old, name_new):
return rename_copy(ord_old, name_new, ord_old)
@SilverBut
Copy link
Author

Only works for IDA 7.1. Some code from https://github.com/rigmar/ida_type_storage/blob/93cfa651572a85d3384b717ec2f0ec57d7e0bd17/IdaTypeStorage.py and will be removed later if possible.

@SilverBut
Copy link
Author

Seems okay now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment