From e4615453db8631c71e3a8768b02dc6273d203be4 Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Thu, 24 Sep 2020 12:44:46 +0200 Subject: [PATCH] Ghidra: Don't allow script execution without C types (#83) --- .../Outputs/ScriptResources/Targets/Ghidra.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Il2CppInspector.Common/Outputs/ScriptResources/Targets/Ghidra.py b/Il2CppInspector.Common/Outputs/ScriptResources/Targets/Ghidra.py index 350dc87..cc23e0a 100644 --- a/Il2CppInspector.Common/Outputs/ScriptResources/Targets/Ghidra.py +++ b/Il2CppInspector.Common/Outputs/ScriptResources/Targets/Ghidra.py @@ -59,6 +59,12 @@ def SetHeaderComment(addr, text): setPlateComment(toAddr(addr), text) def CustomInitializer(): + # Check that the user has parsed the C headers first + if len(getDataTypes('Il2CppObject')) == 0: + print('STOP! You must import the generated C header file (%TYPE_HEADER_RELATIVE_PATH%) before running this script.') + print('See https://github.com/djkaty/Il2CppInspector/blob/master/README.md#adding-metadata-to-your-ghidra-workflow for instructions.') + sys.exit() + # Ghidra sets the image base for ELF to 0x100000 for some reason # https://github.com/NationalSecurityAgency/ghidra/issues/1020 if currentProgram.getExecutableFormat().endswith('(ELF)'):