Apply caller-selected analyzer opt-outs before Ghidra analysis, reject unknown or ineffective names, and commit raw/header imports to the same analyzer profile. Use supported x86 raw compiler specs and cover the real analyzer/readback and raw workflows. Adopts the original implementation from #1800 with validated corrections. Refs #1783, #1836. Co-authored-by: akushonkamen <74654766+akushonkamen@users.noreply.github.com> Co-authored-by: N0zoM1z0 <161784452+N0zoM1z0@users.noreply.github.com> Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
39 lines
1.7 KiB
Java
39 lines
1.7 KiB
Java
import java.util.Map;
|
|
|
|
import ghidra.app.plugin.core.analysis.AutoAnalysisManager;
|
|
import ghidra.app.util.headless.HeadlessScript;
|
|
|
|
/** Disable the named auto-analyzers before default auto-analysis. */
|
|
public final class ReaGhidraAnalysisOptions extends HeadlessScript {
|
|
@Override
|
|
public void run() throws Exception {
|
|
String[] arguments = getScriptArgs();
|
|
if (arguments.length != 1 || arguments[0].isBlank()) {
|
|
throw new IllegalArgumentException(
|
|
"ReaGhidraAnalysisOptions requires one comma-separated analyzer-name argument");
|
|
}
|
|
String[] names = arguments[0].split(",");
|
|
AutoAnalysisManager analysis = AutoAnalysisManager.getAnalysisManager(currentProgram);
|
|
Map<String, String> options = getCurrentAnalysisOptionsAndValues(currentProgram);
|
|
for (String requestedName : names) {
|
|
monitor.checkCancelled();
|
|
String name = requestedName.trim();
|
|
if (analysis.getAnalyzer(name) == null || !options.containsKey(name)) {
|
|
throw new IllegalArgumentException("Unknown Ghidra analyzer for this program: " + name);
|
|
}
|
|
}
|
|
for (String requestedName : names) {
|
|
monitor.checkCancelled();
|
|
setAnalysisOption(currentProgram, requestedName.trim(), "false");
|
|
}
|
|
options = getCurrentAnalysisOptionsAndValues(currentProgram);
|
|
for (String requestedName : names) {
|
|
monitor.checkCancelled();
|
|
String name = requestedName.trim();
|
|
if (!"false".equals(options.get(name))) {
|
|
throw new IllegalStateException("Ghidra analyzer remained enabled: " + name);
|
|
}
|
|
}
|
|
}
|
|
}
|