Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 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

This comment has been minimized.

Copy link
Owner Author

commented Jul 16, 2018

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

This comment has been minimized.

Copy link
Owner Author

commented Jul 17, 2018

Seems okay now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.