From bc25516bb39360e2f0e1719b51bf58c9bf5f62e0 Mon Sep 17 00:00:00 2001 From: nicolaas Date: Tue, 31 Mar 2026 10:37:20 -0400 Subject: [PATCH 1/2] Disable Decompiler Switch Analysis --- .../ofrak_pyghidra/standalone/pyghidra_analysis.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/disassemblers/ofrak_pyghidra/src/ofrak_pyghidra/standalone/pyghidra_analysis.py b/disassemblers/ofrak_pyghidra/src/ofrak_pyghidra/standalone/pyghidra_analysis.py index 1d3c428dd..0bf929422 100644 --- a/disassemblers/ofrak_pyghidra/src/ofrak_pyghidra/standalone/pyghidra_analysis.py +++ b/disassemblers/ofrak_pyghidra/src/ofrak_pyghidra/standalone/pyghidra_analysis.py @@ -44,7 +44,7 @@ def unpack( program_file = os.path.join(tempdir, "program") with open(program_file, "wb") as f: f.write(b"\x00") - with pyghidra.open_program(program_file, language=language) as flat_api: + with pyghidra.open_program(program_file, language=language, analyze=False) as flat_api: LOGGER.info("Analysis completed. Caching analysis to JSON") # Java packages must be imported after pyghidra.start or pyghidra.open_program from ghidra.app.decompiler import DecompInterface, DecompileOptions @@ -54,9 +54,12 @@ def unpack( from java.math import BigInteger from java.io import ByteArrayInputStream + program = flat_api.getCurrentProgram() + program.getOptions("Analyzers").setBoolean("Decompiler Switch Analysis", False) + GhidraProject.analyze(program) + # If memory_regions are provided, delete all data and create new regions: if memory_regions: - program = flat_api.getCurrentProgram() memory = program.getMemory() address_factory = program.getAddressFactory() default_space = address_factory.getDefaultAddressSpace() @@ -103,7 +106,6 @@ def unpack( base_address = int(base_address) # Rebase the program to the specified base address - program = flat_api.getCurrentProgram() address_factory = program.getAddressFactory() new_base_addr = address_factory.getDefaultAddressSpace().getAddress( hex(base_address) @@ -476,12 +478,14 @@ def _decompile(func, decomp_interface, task_monitor): def decompile_all_functions(program_file, language): - with pyghidra.open_program(program_file, language=language) as flat_api: + with pyghidra.open_program(program_file, language=language, analyze=False) as flat_api: from ghidra.app.decompiler import DecompInterface, DecompileOptions from ghidra.util.task import TaskMonitor decomp = DecompInterface() program = flat_api.getCurrentProgram() + program.getOptions("Analyzers").setBoolean("Decompiler Switch Analysis", False) + GhidraProject.analyze(program) prog_options = DecompileOptions() prog_options.grabFromProgram(program) decomp.setOptions(prog_options) From 317106c8a490123499d600d97eeb53d3827f13bd Mon Sep 17 00:00:00 2001 From: nicolaas Date: Tue, 31 Mar 2026 11:55:02 -0400 Subject: [PATCH 2/2] Add missing GhidraProject import --- .../src/ofrak_pyghidra/standalone/pyghidra_analysis.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/disassemblers/ofrak_pyghidra/src/ofrak_pyghidra/standalone/pyghidra_analysis.py b/disassemblers/ofrak_pyghidra/src/ofrak_pyghidra/standalone/pyghidra_analysis.py index 0bf929422..e221ee353 100644 --- a/disassemblers/ofrak_pyghidra/src/ofrak_pyghidra/standalone/pyghidra_analysis.py +++ b/disassemblers/ofrak_pyghidra/src/ofrak_pyghidra/standalone/pyghidra_analysis.py @@ -51,6 +51,7 @@ def unpack( from ghidra.util.task import TaskMonitor from ghidra.program.model.block import BasicBlockModel from ghidra.program.model.symbol import RefType + from ghidra.base.project import GhidraProject from java.math import BigInteger from java.io import ByteArrayInputStream @@ -481,6 +482,7 @@ def decompile_all_functions(program_file, language): with pyghidra.open_program(program_file, language=language, analyze=False) as flat_api: from ghidra.app.decompiler import DecompInterface, DecompileOptions from ghidra.util.task import TaskMonitor + from ghidra.base.project import GhidraProject decomp = DecompInterface() program = flat_api.getCurrentProgram()