Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Ghidra scripts to load which IL2CppDumper exported (forked from @worawit's one)
#TODO write a description for this script
#@category _NEW_
# forked from:
# see also:
# -*- coding: utf-8 -*-
import ghidra.program.model.symbol.SourceType
import re
addressFactory = currentProgram.getAddressFactory()
functionManager = currentProgram.getFunctionManager()
minAddress = currentProgram.getMinAddress()
baseAddress = currentProgram.getImageBase()
USER_DEFINED = ghidra.program.model.symbol.SourceType.USER_DEFINED
index = 1
def addrToInt(addr):
return int(addr.toString(), 16)
def hexToAddr(hexaddr):
return addressFactory.getAddress(hexaddr)
def _convert_arg_string(arg):
if arg.startswith('r'):
return arg[2:-1] # remove prefix 'r' and quote
return arg[1:-1] # remove quote
def do_SetName(hexaddr, name):
print("from %s to %s" % (hexaddr, name))
addr = hexToAddr(hexaddr)
name = _convert_arg_string(name)
func = functionManager.getFunctionAt(addr)
if func != None:
func.setName(name, USER_DEFINED)
createFunction(addr, name)
def do_idc_MakeComm(arg1, arg2):
addr = hexToAddr(arg1)
text = _convert_arg_string(arg2)
setEOLComment(addr, text)
def do_SetString(arg1, arg2):
addr = hexToAddr(arg1)
text = _convert_arg_string(arg2)
global index
name = "StringLiteral_" + str(index);
createLabel(addr, name, True, USER_DEFINED)
setEOLComment(addr, text)
index += 1
def do_MakeFunction(start, end):
start_addr = hexToAddr(start)
end_addr = hexToAddr(end)
func = functionManager.getFunctionAt(start_addr)
if func is None:
func = createFunction(start_addr, None)
f = askFile(" from Il2cppdumper", "Open")
for line in file(f.absolutePath):
match ="^([\w+\.]+)\((\w+),\s*(.*)\)$", line)
if match:
name, arg1, arg2 = match.groups()
res = globals()['do_'+name.replace('.', '_')](arg1, arg2)
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.