Il2CppInspector
Il2CppInspector copied to clipboard
Python output uses Windows-specific paths
The generated Ghidra Python output contains the following line:
with open(os.path.join(GetScriptDirectory(), ".\\metadata.json"), "r") as jsonFile:
When running Ghidra on Linux, the script fails because this doesn’t result in a valid path. The problem is with the following line:
https://github.com/djkaty/Il2CppInspector/blob/9746a6f4a83002ce3a800eb5bfbf687756587226/Il2CppInspector.Common/Outputs/ScriptResources/shared-main.py#L136
Changing it as follows should fix it:
with open(os.path.join(GetScriptDirectory(), *"%JSON_METADATA_RELATIVE_PATH%".split("\\")), "r") as jsonFile:
This splits the relative path by backslashes and passes each of the resulting list elements as individual parameter to os.path.join()
to do its platform-specific magic. Same change should be implemented here:
https://github.com/djkaty/Il2CppInspector/blob/370d15e8d99c2e1b7ddaa83000ca873b6fb8016e/Il2CppInspector.Common/Outputs/ScriptResources/Targets/IDA.py#L54
For me the script works fine on Linux once the path is corrected.
Thanks for this! I'll confirm it works on Windows as well and make the changes.