This commit is contained in:
Perfare 2021-12-12 14:17:09 +08:00
commit 266ca1a8cf
2 changed files with 43 additions and 1 deletions

View file

@ -44,7 +44,13 @@ def set_type(addr, type):
if addrType is None:
print("Could not identify type " + type + "(parsed as '" + newType + "')")
else:
createData(addr, addrType)
try:
createData(addr, addrType)
except ghidra.program.model.util.CodeUnitInsertionException:
print("Warning: unable to set type")
print(type + "at address" + addr + "(CodeUnitInsertionException)")
print("Skipping.")
def make_function(start):
func = getFunctionAt(start)

View file

@ -0,0 +1,36 @@
import re
header = "typedef unsigned __int8 uint8_t;\n" \
"typedef unsigned __int16 uint16_t;\n" \
"typedef unsigned __int32 uint32_t;\n" \
"typedef unsigned __int64 uint64_t;\n" \
"typedef __int8 int8_t;\n" \
"typedef __int16 int16_t;\n" \
"typedef __int32 int32_t;\n" \
"typedef __int64 int64_t;\n" \
"typedef __int64 intptr_t;\n" \
"typedef __int64 uintptr_t;\n" \
"typedef unsigned __int64 size_t;\n"
def main():
fixed_header_data = ""
with open("il2cpp.h", 'r') as f:
print("il2cpp.h opened...")
original_header_data = f.read()
print("il2cpp.h read...")
fixed_header_data = re.sub(r": (\w+) {", r"{\n \1 super;", original_header_data)
print("il2cpp.h data fixed...")
print("il2cpp.h closed.")
with open("il2cpp_ghidra.h", 'w') as f:
print("il2cpp_ghidra.h opened...")
f.write(header)
print("header written...")
f.write(fixed_header_data)
print("fixed data written...")
print("il2cpp_ghidra.h closed.")
if __name__ == '__main__':
print("Script started...")
main()