mirror of
https://github.com/NationalSecurityAgency/ghidra
synced 2024-07-17 11:08:13 +00:00
Merge branch 'GP-2318_ryanmkurtz_oneshot' (Closes #4589)
This commit is contained in:
commit
6256f00b2d
|
@ -28,6 +28,7 @@ import docking.widgets.dialogs.MultiLineMessageDialog;
|
|||
import ghidra.GhidraOptions;
|
||||
import ghidra.app.CorePluginPackage;
|
||||
import ghidra.app.context.ListingActionContext;
|
||||
import ghidra.app.context.ListingContextAction;
|
||||
import ghidra.app.events.*;
|
||||
import ghidra.app.plugin.PluginCategoryNames;
|
||||
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 Program canAnalyzeProgram;
|
||||
private boolean canAnalyze;
|
||||
|
@ -331,31 +332,26 @@ public class AutoAnalysisPlugin extends Plugin implements AutoAnalysisManagerLis
|
|||
null, ANALYZE_GROUP_NAME));
|
||||
setHelpLocation(new HelpLocation("AutoAnalysisPlugin", "Auto_Analyzers"));
|
||||
|
||||
setEnabled(false);
|
||||
setSupportsDefaultToolContext(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionContext context) {
|
||||
if (!(context instanceof ListingActionContext)) {
|
||||
return;
|
||||
}
|
||||
ListingActionContext programContext = (ListingActionContext) context;
|
||||
public void actionPerformed(ListingActionContext context) {
|
||||
AddressSetView set;
|
||||
if (programContext.hasSelection()) {
|
||||
set = programContext.getSelection();
|
||||
if (context.hasSelection()) {
|
||||
set = context.getSelection();
|
||||
}
|
||||
else {
|
||||
Memory memory = programContext.getProgram().getMemory();
|
||||
Memory memory = context.getProgram().getMemory();
|
||||
AddressSet external = new AddressSet(AddressSpace.EXTERNAL_SPACE.getMinAddress(),
|
||||
AddressSpace.EXTERNAL_SPACE.getMaxAddress());
|
||||
set = memory.union(external);
|
||||
}
|
||||
|
||||
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.getOptions(analyzer.getName());
|
||||
analyzer.optionsChanged(options, program);
|
||||
|
@ -368,12 +364,8 @@ public class AutoAnalysisPlugin extends Plugin implements AutoAnalysisManagerLis
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabledForContext(ActionContext context) {
|
||||
if (!(context instanceof ListingActionContext)) {
|
||||
return false;
|
||||
}
|
||||
ListingActionContext programContext = (ListingActionContext) context;
|
||||
Program p = programContext.getProgram();
|
||||
public boolean isEnabledForContext(ListingActionContext context) {
|
||||
Program p = context.getProgram();
|
||||
if (p != canAnalyzeProgram) {
|
||||
canAnalyzeProgram = p;
|
||||
canAnalyze = analyzer.canAnalyze(p);
|
||||
|
|
Loading…
Reference in a new issue