Last active
July 17, 2018 07:18
-
-
Save SilverBut/7306d5bb839ace49a5c541d2c63b373a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.