mirror of
https://github.com/NationalSecurityAgency/ghidra
synced 2024-08-28 21:40:28 +00:00
GP-2318: One shot analyzers are now enabled when the Listing does not
have context
This commit is contained in:
parent
49def9960a
commit
9e4fdf55ec
|
@ -28,6 +28,7 @@ import docking.widgets.dialogs.MultiLineMessageDialog;
|
||||||
import ghidra.GhidraOptions;
|
import ghidra.GhidraOptions;
|
||||||
import ghidra.app.CorePluginPackage;
|
import ghidra.app.CorePluginPackage;
|
||||||
import ghidra.app.context.ListingActionContext;
|
import ghidra.app.context.ListingActionContext;
|
||||||
|
import ghidra.app.context.ListingContextAction;
|
||||||
import ghidra.app.events.*;
|
import ghidra.app.events.*;
|
||||||
import ghidra.app.plugin.PluginCategoryNames;
|
import ghidra.app.plugin.PluginCategoryNames;
|
||||||
import ghidra.app.services.Analyzer;
|
import ghidra.app.services.Analyzer;
|
||||||
|
@ -319,7 +320,7 @@ public class AutoAnalysisPlugin extends Plugin implements AutoAnalysisManagerLis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class OneShotAnalyzerAction extends DockingAction {
|
class OneShotAnalyzerAction extends ListingContextAction {
|
||||||
private Analyzer analyzer;
|
private Analyzer analyzer;
|
||||||
private Program canAnalyzeProgram;
|
private Program canAnalyzeProgram;
|
||||||
private boolean canAnalyze;
|
private boolean canAnalyze;
|
||||||
|
@ -331,31 +332,26 @@ public class AutoAnalysisPlugin extends Plugin implements AutoAnalysisManagerLis
|
||||||
null, ANALYZE_GROUP_NAME));
|
null, ANALYZE_GROUP_NAME));
|
||||||
setHelpLocation(new HelpLocation("AutoAnalysisPlugin", "Auto_Analyzers"));
|
setHelpLocation(new HelpLocation("AutoAnalysisPlugin", "Auto_Analyzers"));
|
||||||
|
|
||||||
setEnabled(false);
|
|
||||||
setSupportsDefaultToolContext(true);
|
setSupportsDefaultToolContext(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionContext context) {
|
public void actionPerformed(ListingActionContext context) {
|
||||||
if (!(context instanceof ListingActionContext)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ListingActionContext programContext = (ListingActionContext) context;
|
|
||||||
AddressSetView set;
|
AddressSetView set;
|
||||||
if (programContext.hasSelection()) {
|
if (context.hasSelection()) {
|
||||||
set = programContext.getSelection();
|
set = context.getSelection();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Memory memory = programContext.getProgram().getMemory();
|
Memory memory = context.getProgram().getMemory();
|
||||||
AddressSet external = new AddressSet(AddressSpace.EXTERNAL_SPACE.getMinAddress(),
|
AddressSet external = new AddressSet(AddressSpace.EXTERNAL_SPACE.getMinAddress(),
|
||||||
AddressSpace.EXTERNAL_SPACE.getMaxAddress());
|
AddressSpace.EXTERNAL_SPACE.getMaxAddress());
|
||||||
set = memory.union(external);
|
set = memory.union(external);
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoAnalysisManager analysisMgr =
|
AutoAnalysisManager analysisMgr =
|
||||||
AutoAnalysisManager.getAnalysisManager(programContext.getProgram());
|
AutoAnalysisManager.getAnalysisManager(context.getProgram());
|
||||||
|
|
||||||
Program program = programContext.getProgram();
|
Program program = context.getProgram();
|
||||||
Options options = program.getOptions(Program.ANALYSIS_PROPERTIES);
|
Options options = program.getOptions(Program.ANALYSIS_PROPERTIES);
|
||||||
options = options.getOptions(analyzer.getName());
|
options = options.getOptions(analyzer.getName());
|
||||||
analyzer.optionsChanged(options, program);
|
analyzer.optionsChanged(options, program);
|
||||||
|
@ -368,12 +364,8 @@ public class AutoAnalysisPlugin extends Plugin implements AutoAnalysisManagerLis
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabledForContext(ActionContext context) {
|
public boolean isEnabledForContext(ListingActionContext context) {
|
||||||
if (!(context instanceof ListingActionContext)) {
|
Program p = context.getProgram();
|
||||||
return false;
|
|
||||||
}
|
|
||||||
ListingActionContext programContext = (ListingActionContext) context;
|
|
||||||
Program p = programContext.getProgram();
|
|
||||||
if (p != canAnalyzeProgram) {
|
if (p != canAnalyzeProgram) {
|
||||||
canAnalyzeProgram = p;
|
canAnalyzeProgram = p;
|
||||||
canAnalyze = analyzer.canAnalyze(p);
|
canAnalyze = analyzer.canAnalyze(p);
|
||||||
|
|
Loading…
Reference in a new issue