mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-26 05:56:32 +08:00
avoid calling GhidraScriptUtils.getScriptSourceDirectories
- when called from the GUI, the bundle host manages paths - when used to find a script by name, use findScriptByName
This commit is contained in:
@@ -59,34 +59,31 @@ public class PythonScript extends GhidraScript {
|
||||
throw new AssertException("Could not get Ghidra Python interpreter!");
|
||||
}
|
||||
}
|
||||
|
||||
for (ResourceFile dir : GhidraScriptUtil.getScriptSourceDirectories()) {
|
||||
ResourceFile scriptSource = new ResourceFile(dir, scriptName);
|
||||
if (scriptSource.exists()) {
|
||||
GhidraScriptProvider provider = GhidraScriptUtil.getProvider(scriptSource);
|
||||
GhidraScript ghidraScript = provider.getScriptInstance(scriptSource, writer);
|
||||
if (ghidraScript == null) {
|
||||
throw new IllegalArgumentException("Script does not exist: " + scriptName);
|
||||
}
|
||||
|
||||
if (scriptState == state) {
|
||||
updateStateFromVariables();
|
||||
}
|
||||
|
||||
if (ghidraScript instanceof PythonScript) {
|
||||
ghidraScript.set(scriptState, monitor, writer);
|
||||
PythonScript pythonScript = (PythonScript) ghidraScript;
|
||||
interpreter.execFile(pythonScript.getSourceFile(), pythonScript);
|
||||
}
|
||||
else {
|
||||
ghidraScript.execute(scriptState, monitor, writer);
|
||||
}
|
||||
|
||||
if (scriptState == state) {
|
||||
loadVariablesFromState();
|
||||
}
|
||||
return;
|
||||
ResourceFile scriptSource = GhidraScriptUtil.findScriptByName(scriptName);
|
||||
if (scriptSource != null) {
|
||||
GhidraScriptProvider provider = GhidraScriptUtil.getProvider(scriptSource);
|
||||
GhidraScript ghidraScript = provider.getScriptInstance(scriptSource, writer);
|
||||
if (ghidraScript == null) {
|
||||
throw new IllegalArgumentException("Script does not exist: " + scriptName);
|
||||
}
|
||||
|
||||
if (scriptState == state) {
|
||||
updateStateFromVariables();
|
||||
}
|
||||
|
||||
if (ghidraScript instanceof PythonScript) {
|
||||
ghidraScript.set(scriptState, monitor, writer);
|
||||
PythonScript pythonScript = (PythonScript) ghidraScript;
|
||||
interpreter.execFile(pythonScript.getSourceFile(), pythonScript);
|
||||
}
|
||||
else {
|
||||
ghidraScript.execute(scriptState, monitor, writer);
|
||||
}
|
||||
|
||||
if (scriptState == state) {
|
||||
loadVariablesFromState();
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw new IllegalArgumentException("Script does not exist: " + scriptName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user