Ghidra is a software reverse engineering (SRE) framework
move weird static call into GhidraScriptAnalyzer class
Jason P. Leasured79b193d207f
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/script/GhidraScriptUtil.java b/Ghidra/Features/Base/src/main/java/ghidra/app/script/GhidraScriptUtil.javaindex d84f1e0884..5bbb20f5ee 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/script/GhidraScriptUtil.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/script/GhidraScriptUtil.java@@ -24,10 +24,8 @@ import generic.jar.ResourceFile;import ghidra.app.plugin.core.osgi.BundleHost;import ghidra.app.plugin.core.osgi.OSGiException;import ghidra.framework.Application;-import ghidra.program.model.listing.Program;import ghidra.util.Msg;import ghidra.util.classfinder.ClassSearcher;-import ghidra.util.task.TaskMonitor;/*** A utility class for managing script directories and ScriptInfo objects.@@ -357,40 +355,4 @@ public class GhidraScriptUtil {return null;}- /* only used by GhidraScriptAnalyzerAdapter */- /**- * Runs the specified script with the specified state- *- * @param scriptState state representing environment variables that the script is able to access- * @param script Script to be run- * @param writer the writer to which warning and error messages will be written- * @param originator the client class requesting the script run; used for logging- * @param monitor the task monitor- * @return whether the script successfully completed running- */- @Deprecated- public static boolean runScript(GhidraState scriptState, GhidraScript script,- PrintWriter writer, Object originator, TaskMonitor monitor) {-- ResourceFile srcFile = script.getSourceFile();- String scriptName =- srcFile != null ? srcFile.getAbsolutePath() : (script.getClass().getName() + ".class");-- try {- Msg.info(originator, "SCRIPT: " + scriptName);- script.execute(scriptState, monitor, writer);- writer.flush();- }- catch (Exception exc) {- Program prog = scriptState.getCurrentProgram();- String path = (prog != null ? prog.getExecutablePath() : "Current program is null.");- String logErrorMsg =- path + "\nREPORT SCRIPT ERROR: " + scriptName + " : " + exc.getMessage();- Msg.error(originator, logErrorMsg, exc);- return false;- }-- return true;- }-}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/framework/analysis/GhidraScriptAnalyzerAdapter.java b/Ghidra/Features/Base/src/main/java/ghidra/framework/analysis/GhidraScriptAnalyzerAdapter.javaindex 5a3219450c..72586924a4 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/framework/analysis/GhidraScriptAnalyzerAdapter.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/framework/analysis/GhidraScriptAnalyzerAdapter.java@@ -70,7 +70,30 @@ public class GhidraScriptAnalyzerAdapter extends AbstractAnalyzer {Project project = null;GhidraState scriptState = new GhidraState(null, project, program, loc, selection, null);- return GhidraScriptUtil.runScript(scriptState, script, writer, this, monitor);+ return runScript(scriptState, monitor);+ }++ private boolean runScript(GhidraState scriptState, TaskMonitor monitor) {++ ResourceFile srcFile = script.getSourceFile();+ String scriptName =+ srcFile != null ? srcFile.getAbsolutePath() : (script.getClass().getName() + ".class");++ try {+ Msg.info(this, "SCRIPT: " + scriptName);+ script.execute(scriptState, monitor, writer);+ writer.flush();+ }+ catch (Exception exc) {+ Program prog = scriptState.getCurrentProgram();+ String path = (prog != null ? prog.getExecutablePath() : "Current program is null.");+ String logErrorMsg =+ path + "\nREPORT SCRIPT ERROR: " + scriptName + " : " + exc.getMessage();+ Msg.error(this, logErrorMsg, exc);+ return false;+ }++ return true;}private GhidraScript getGhidraScript() {