factor GhidraScriptInfoManager out of GhidraScriptUtil

- move bundlehost to ghidrascriptmgrplugin
This commit is contained in:
Jason P. Leasure
2020-04-27 15:41:42 -04:00
parent a26ce496ef
commit 2b49816c6c
21 changed files with 375 additions and 344 deletions

View File

@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +15,9 @@
*/
package ghidra.app.plugin.prototype.MicrosoftCodeAnalyzerPlugin;
import java.io.PrintWriter;
import generic.jar.ResourceFile;
import ghidra.app.plugin.core.analysis.AutoAnalysisManager;
import ghidra.app.script.*;
import ghidra.app.services.*;
@@ -32,8 +34,6 @@ import ghidra.util.Msg;
import ghidra.util.exception.CancelledException;
import ghidra.util.task.TaskMonitor;
import java.io.PrintWriter;
public class WindowsResourceReferenceAnalyzer extends AbstractAnalyzer {
private static final String NAME = "WindowsResourceReference";
private static final String DESCRIPTION =
@@ -81,23 +81,21 @@ public class WindowsResourceReferenceAnalyzer extends AbstractAnalyzer {
PluginTool tool = analysisManager.getAnalysisTool();
Project project = findProject(tool);
GhidraState state =
new GhidraState(tool, project, program, new ProgramLocation(program,
set.getMinAddress()), new ProgramSelection(set), null);
GhidraState state = new GhidraState(tool, project, program,
new ProgramLocation(program, set.getMinAddress()), new ProgramSelection(set), null);
try {
ScriptInfo scriptInfo = GhidraScriptUtil.findScriptByName(scriptName);
if (scriptInfo == null) {
ResourceFile sourceFile = GhidraScriptUtil.findScriptByName(scriptName);
if (sourceFile == null) {
throw new IllegalAccessException("Couldn't find script");
}
GhidraScriptProvider provider =
GhidraScriptUtil.getProvider(scriptInfo.getSourceFile());
GhidraScriptProvider provider = GhidraScriptUtil.getProvider(sourceFile);
if (provider == null) {
throw new IllegalAccessException("Couldn't find script provider");
}
PrintWriter writer = getOutputMsgStream(tool);
GhidraScript script = provider.getScriptInstance(scriptInfo.getSourceFile(), writer);
GhidraScript script = provider.getScriptInstance(sourceFile, writer);
script.set(state, monitor, writer);
// This code was added so the analyzer won't print script messages to console