GP-5 Fixed WindowsResource Analyzer wasting time decompiling functions

that have previously failed to decompile due to timeout
This commit is contained in:
emteere 2023-07-10 20:40:57 +00:00
parent f82dc0c466
commit b02101298f

View file

@ -36,8 +36,7 @@ import ghidra.app.script.GhidraScript;
import ghidra.framework.options.ToolOptions; import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.PluginTool; import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.OptionsService; import ghidra.framework.plugintool.util.OptionsService;
import ghidra.program.model.address.Address; import ghidra.program.model.address.*;
import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.listing.*; import ghidra.program.model.listing.*;
import ghidra.program.model.pcode.*; import ghidra.program.model.pcode.*;
import ghidra.program.model.symbol.*; import ghidra.program.model.symbol.*;
@ -57,6 +56,9 @@ public class WindowsResourceReference extends GhidraScript {
protected AddressSetPropertyMap alreadyDoneAddressSetPropertyMap; protected AddressSetPropertyMap alreadyDoneAddressSetPropertyMap;
// set of functions that decompilation failed on
protected AddressSet badDecompFunctions = new AddressSet();
public AddressSetPropertyMap getOrCreatePropertyMap(Program program, String mapName) { public AddressSetPropertyMap getOrCreatePropertyMap(Program program, String mapName) {
if (alreadyDoneAddressSetPropertyMap != null) { if (alreadyDoneAddressSetPropertyMap != null) {
return alreadyDoneAddressSetPropertyMap; return alreadyDoneAddressSetPropertyMap;
@ -368,6 +370,11 @@ public class WindowsResourceReference extends GhidraScript {
return; return;
} }
// check if decompilation of this function failed previously
if (badDecompFunctions.contains(f.getEntryPoint())) {
return;
}
Instruction instr = prog.getListing().getInstructionAt(refAddr); Instruction instr = prog.getListing().getInstructionAt(refAddr);
if (instr == null) { if (instr == null) {
return; return;
@ -376,7 +383,9 @@ public class WindowsResourceReference extends GhidraScript {
decompileFunction(f, decompiler); decompileFunction(f, decompiler);
if (hfunction == null) { if (hfunction == null) {
return; // failed to decompile // failed to decompile, add to bad list
badDecompFunctions.add(f.getEntryPoint());
return;
} }
Iterator<PcodeOpAST> ops = hfunction.getPcodeOps(refAddr); Iterator<PcodeOpAST> ops = hfunction.getPcodeOps(refAddr);