From a07babb2fb72c00233e492be160b7916fb38a3e7 Mon Sep 17 00:00:00 2001 From: clearbluejar <3752074+clearbluejar@users.noreply.github.com> Date: Fri, 8 Sep 2023 00:15:28 +0000 Subject: [PATCH] cppexport bug fix for Ghidra 10.3.3 breaking api change, fixes #10 --- ghidrecomp/decompile.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ghidrecomp/decompile.py b/ghidrecomp/decompile.py index 24f9104..4f1c1e9 100644 --- a/ghidrecomp/decompile.py +++ b/ghidrecomp/decompile.py @@ -89,7 +89,13 @@ def decompile_to_single_file(path: Path, else: monitor = ConsoleTaskMonitor().DUMMY - decompiler = CppExporter(create_header, create_file, emit_types, exclude_tags, tags) + try: + # Ghidra CppExporter before 10.3.3 and later + decompiler = CppExporter(None,create_header, create_file, emit_types, exclude_tags, tags) + except TypeError: + # Ghidra CppExporter before 10.3.3 + decompiler = CppExporter(create_header, create_file, emit_types, exclude_tags, tags) + decompiler.export(c_file, prog, prog.getMemory(), monitor) @@ -200,6 +206,9 @@ def decompile(args: Namespace): if skip_count > 0: print(f'Skipped {skip_count} functions that failed to match any of {args.filters}') + decompilations = [] + callgraphs = [] + if args.cppexport: print(f"Decompiling {len(all_funcs)} functions using Ghidra's CppExporter") c_file = Path(args.output_path) / Path(bin_path.name + '.c') @@ -211,10 +220,7 @@ def decompile(args: Namespace): print(f'Decompiling {len(all_funcs)} functions using {thread_count} threads') decompilers = setup_decompliers(program, thread_count) - completed = 0 - decompilations = [] - callgraphs = [] # Decompile all files start = time()