mirror of
https://github.com/Perfare/Il2CppDumper.git
synced 2025-01-09 11:17:35 -03:00
Fixed compatibility with ghidra's vanilla python interpreter. Added more error handling (#539)
* Add error handling for CodeUnitInsertionException. (Fixes set_type() on duplicates) * Add script to convert il2cpp.h for ghidra. * Reformatted for ghidra's interpreter. Added more error handling. Co-authored-by: Perfare <hjyqwert@126.com>
This commit is contained in:
parent
43ffffe820
commit
22c6374f6f
1 changed files with 15 additions and 8 deletions
|
@ -20,8 +20,11 @@ def get_addr(addr):
|
|||
return baseAddress.add(addr)
|
||||
|
||||
def set_name(addr, name):
|
||||
name = name.replace(' ', '-')
|
||||
createLabel(addr, name, True, USER_DEFINED)
|
||||
try:
|
||||
name = name.replace(' ', '-')
|
||||
createLabel(addr, name, True, USER_DEFINED)
|
||||
except:
|
||||
print("set_name() Failed.")
|
||||
|
||||
def set_type(addr, type):
|
||||
# Requires types (il2cpp.h) to be imported first
|
||||
|
@ -47,15 +50,16 @@ def set_type(addr, type):
|
|||
try:
|
||||
createData(addr, addrType)
|
||||
except ghidra.program.model.util.CodeUnitInsertionException:
|
||||
print("Warning: unable to set type")
|
||||
print(type + "at address" + addr + "(CodeUnitInsertionException)")
|
||||
print("Skipping.")
|
||||
print("Warning: unable to set type (CodeUnitInsertionException)")
|
||||
|
||||
|
||||
def make_function(start):
|
||||
func = getFunctionAt(start)
|
||||
if func is None:
|
||||
createFunction(start, None)
|
||||
try:
|
||||
createFunction(start, None)
|
||||
except:
|
||||
print("Warning: Unable to create function")
|
||||
|
||||
def set_sig(addr, name, sig):
|
||||
try:
|
||||
|
@ -74,8 +78,11 @@ def set_sig(addr, name, sig):
|
|||
print("Skipping.")
|
||||
return
|
||||
if typeSig is not None:
|
||||
typeSig.setName(name)
|
||||
ApplyFunctionSignatureCmd(addr, typeSig, USER_DEFINED, False, True).applyTo(currentProgram)
|
||||
try:
|
||||
typeSig.setName(name)
|
||||
ApplyFunctionSignatureCmd(addr, typeSig, USER_DEFINED, False, True).applyTo(currentProgram)
|
||||
except:
|
||||
print("Warning: unable to set Signature. ApplyFunctionSignatureCmd() Failed.")
|
||||
|
||||
f = askFile("script.json from Il2cppdumper", "Open")
|
||||
data = json.loads(open(f.absolutePath, 'rb').read().decode('utf-8'))
|
||||
|
|
Loading…
Reference in a new issue