Skip to content

Instantly share code, notes, and snippets.

@gabriel-nsiqueira
Created February 4, 2021 19:22
Show Gist options
  • Save gabriel-nsiqueira/d7081911918f3af1966cadc1e86f7a6b to your computer and use it in GitHub Desktop.
Save gabriel-nsiqueira/d7081911918f3af1966cadc1e86f7a6b to your computer and use it in GitHub Desktop.
Generates headers using script.json from il2cpp dumper output
# Header Generator
import json
import re as regex
header = ""
def address(addr):
return "0x%X" % addr
def remove_method_info(d):
e = d.replace(', const MethodInfo* method', "").replace("const MethodInfo* method", "")
e = regex.sub("const MethodInfo_..... method", "", regex.sub(", const MethodInfo_..... method", "", e))
return e
def make_function(start, name, signature):
if 'Beebyte' in name or 'Mono' in name or 'System' in name or 'Locale' in name:
return ""
n_old = name.replace(".", "_").replace("$", "_")
n = n_old.replace("'", '').replace("<", "__").replace(">", "__").replace(", ", "_")
print(n)
return "#define " + n + "_ptr " + address(start) + "\ntypedef " + \
remove_method_info(signature).replace(n_old, n + "_def") + \
"\n" + n + "_def* " + n + " = (" + n + "_def*) getRealOffset(" + n + "_ptr);" + \
"\n" + remove_method_info(signature).replace(n_old, n + "_old") + "\n"
data = json.loads(open("script.json").read())
if "ScriptMethod" in data and "ScriptMethod":
scriptMethods = data["ScriptMethod"]
for x in range(0, len(scriptMethods) - 1, 2):
scriptMethod = scriptMethods[x]
addr = scriptMethod["Address"]
name = scriptMethod["Name"]
signature = scriptMethod["Signature"]
header = header + make_function(addr, name, signature)
open("functions.h", "w").write(header)
print('Written output to functions.h')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment