mirror of
https://github.com/Perfare/Il2CppDumper.git
synced 2025-01-09 19:27:17 -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)
|
return baseAddress.add(addr)
|
||||||
|
|
||||||
def set_name(addr, name):
|
def set_name(addr, name):
|
||||||
name = name.replace(' ', '-')
|
try:
|
||||||
createLabel(addr, name, True, USER_DEFINED)
|
name = name.replace(' ', '-')
|
||||||
|
createLabel(addr, name, True, USER_DEFINED)
|
||||||
|
except:
|
||||||
|
print("set_name() Failed.")
|
||||||
|
|
||||||
def set_type(addr, type):
|
def set_type(addr, type):
|
||||||
# Requires types (il2cpp.h) to be imported first
|
# Requires types (il2cpp.h) to be imported first
|
||||||
|
@ -47,15 +50,16 @@ def set_type(addr, type):
|
||||||
try:
|
try:
|
||||||
createData(addr, addrType)
|
createData(addr, addrType)
|
||||||
except ghidra.program.model.util.CodeUnitInsertionException:
|
except ghidra.program.model.util.CodeUnitInsertionException:
|
||||||
print("Warning: unable to set type")
|
print("Warning: unable to set type (CodeUnitInsertionException)")
|
||||||
print(type + "at address" + addr + "(CodeUnitInsertionException)")
|
|
||||||
print("Skipping.")
|
|
||||||
|
|
||||||
|
|
||||||
def make_function(start):
|
def make_function(start):
|
||||||
func = getFunctionAt(start)
|
func = getFunctionAt(start)
|
||||||
if func is None:
|
if func is None:
|
||||||
createFunction(start, None)
|
try:
|
||||||
|
createFunction(start, None)
|
||||||
|
except:
|
||||||
|
print("Warning: Unable to create function")
|
||||||
|
|
||||||
def set_sig(addr, name, sig):
|
def set_sig(addr, name, sig):
|
||||||
try:
|
try:
|
||||||
|
@ -74,8 +78,11 @@ def set_sig(addr, name, sig):
|
||||||
print("Skipping.")
|
print("Skipping.")
|
||||||
return
|
return
|
||||||
if typeSig is not None:
|
if typeSig is not None:
|
||||||
typeSig.setName(name)
|
try:
|
||||||
ApplyFunctionSignatureCmd(addr, typeSig, USER_DEFINED, False, True).applyTo(currentProgram)
|
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")
|
f = askFile("script.json from Il2cppdumper", "Open")
|
||||||
data = json.loads(open(f.absolutePath, 'rb').read().decode('utf-8'))
|
data = json.loads(open(f.absolutePath, 'rb').read().decode('utf-8'))
|
||||||
|
|
Loading…
Reference in a new issue