Il2CppInspector icon indicating copy to clipboard operation
Il2CppInspector copied to clipboard

Python output uses Windows-specific paths

Open palant opened this issue 3 years ago • 1 comments

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.

palant avatar Feb 16 '21 11:02 palant

Thanks for this! I'll confirm it works on Windows as well and make the changes.

djkaty avatar Feb 23 '21 22:02 djkaty