mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-21 12:22:34 +08:00
Merge branch 'master' of
https://github.com/NationalSecurityAgency/ghidra into spell
This commit is contained in:
@@ -377,7 +377,6 @@ src/main/help/help/topics/FunctionComparison/images/ListingCodeComparisonOptions
|
||||
src/main/help/help/topics/FunctionComparison/images/MultiFunctionComparisonWindow.png||GHIDRA||||END|
|
||||
src/main/help/help/topics/FunctionComparison/images/NavNextIcon.png||GHIDRA||||END|
|
||||
src/main/help/help/topics/FunctionComparison/images/NavPreviousIcon.png||GHIDRA||||END|
|
||||
src/main/help/help/topics/FunctionComparison/images/NavSelectedIcon.png||GHIDRA||||END|
|
||||
src/main/help/help/topics/FunctionComparison/images/RemoveFromComparisonIcon.png||GHIDRA||||END|
|
||||
src/main/help/help/topics/FunctionComparison/images/binaryData.gif||GHIDRA||||END|
|
||||
src/main/help/help/topics/FunctionComparison/images/class.png||GHIDRA||||END|
|
||||
@@ -725,7 +724,7 @@ src/main/help/help/topics/ShowInstructionInfoPlugin/images/ProcessorManualOption
|
||||
src/main/help/help/topics/ShowInstructionInfoPlugin/images/RawInstructionDisplay.png||GHIDRA||||END|
|
||||
src/main/help/help/topics/ShowInstructionInfoPlugin/images/ShowInstructionInfo.png||GHIDRA||||END|
|
||||
src/main/help/help/topics/ShowInstructionInfoPlugin/images/UnableToLaunch.png||GHIDRA||||END|
|
||||
src/main/help/help/topics/Snapshots/Snapshots.html||GHIDRA||reviewed||END|
|
||||
src/main/help/help/topics/Snapshots/Snapshots.html||GHIDRA||||END|
|
||||
src/main/help/help/topics/Snapshots/images/camera-photo.png||Tango Icons - Public Domain|||tango|END|
|
||||
src/main/help/help/topics/StackEditor/StackEditor.html||GHIDRA||||END|
|
||||
src/main/help/help/topics/StackEditor/images/Array.png||GHIDRA||||END|
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
-1
@@ -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.
|
||||
|
||||
+48
-12
@@ -17,9 +17,11 @@ package ghidra.app.context;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.*;
|
||||
import docking.action.DockingAction;
|
||||
import docking.action.KeyBindingType;
|
||||
import ghidra.app.nav.Navigatable;
|
||||
import ghidra.app.services.GoToService;
|
||||
|
||||
public abstract class NavigatableContextAction extends DockingAction {
|
||||
|
||||
@@ -33,23 +35,61 @@ public abstract class NavigatableContextAction extends DockingAction {
|
||||
|
||||
@Override
|
||||
public boolean isEnabledForContext(ActionContext context) {
|
||||
if (!(context instanceof NavigatableActionContext)) {
|
||||
NavigatableActionContext appropriateContext = getAppropriateContext(context);
|
||||
if (appropriateContext == null) {
|
||||
return false;
|
||||
}
|
||||
return isEnabledForContext((NavigatableActionContext) context);
|
||||
return isEnabledForContext(appropriateContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionContext context) {
|
||||
actionPerformed((NavigatableActionContext) context);
|
||||
actionPerformed(getAppropriateContext(context));
|
||||
}
|
||||
|
||||
private NavigatableActionContext getAppropriateContext(ActionContext context) {
|
||||
if (context instanceof NavigatableActionContext &&
|
||||
isValidNavigationContext((NavigatableActionContext) context)) {
|
||||
return (NavigatableActionContext) context;
|
||||
}
|
||||
return getGlobalNavigationContext(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidContext(ActionContext context) {
|
||||
if (!(context instanceof NavigatableActionContext)) {
|
||||
return false;
|
||||
public final boolean isValidContext(ActionContext context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean isValidNavigationContext(NavigatableActionContext context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private NavigatableActionContext getGlobalNavigationContext(ActionContext context) {
|
||||
Tool tool = getTool(context.getComponentProvider());
|
||||
|
||||
if (tool == null) {
|
||||
return null;
|
||||
}
|
||||
return isValidContext((NavigatableActionContext) context);
|
||||
GoToService service = tool.getService(GoToService.class);
|
||||
if (service == null) {
|
||||
return null;
|
||||
}
|
||||
Navigatable defaultNavigatable = service.getDefaultNavigatable();
|
||||
if (defaultNavigatable.getProgram() == null) {
|
||||
return null;
|
||||
}
|
||||
return new NavigatableActionContext(null, defaultNavigatable);
|
||||
}
|
||||
|
||||
private Tool getTool(ComponentProvider provider) {
|
||||
if (provider != null) {
|
||||
return provider.getTool();
|
||||
}
|
||||
DockingWindowManager manager = DockingWindowManager.getActiveInstance();
|
||||
if (manager != null) {
|
||||
return manager.getTool();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,10 +100,6 @@ public abstract class NavigatableContextAction extends DockingAction {
|
||||
return isAddToPopup((NavigatableActionContext) context);
|
||||
}
|
||||
|
||||
protected boolean isValidContext(NavigatableActionContext context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean isEnabledForContext(NavigatableActionContext context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public class ListingMergePanelProvider extends ComponentProviderAdapter
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DockingActionIf> getPopupActions(DockingTool dt, ActionContext context) {
|
||||
public List<DockingActionIf> getPopupActions(Tool dt, ActionContext context) {
|
||||
ListingPanel resultPanel = mergePanel.getResultPanel();
|
||||
if (resultPanel != null) {
|
||||
return resultPanel.getHeaderActions(getName());
|
||||
|
||||
@@ -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,16 +15,16 @@
|
||||
*/
|
||||
package ghidra.app.nav;
|
||||
|
||||
import ghidra.framework.model.Tool;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
|
||||
public class NavigatableRegistry {
|
||||
private static Map<Long, Navigatable> navigatableMap = new HashMap<Long, Navigatable>();
|
||||
private static Map<Tool, List<Navigatable>> toolMap = new HashMap<Tool, List<Navigatable>>();
|
||||
private static Map<PluginTool, List<Navigatable>> toolMap =
|
||||
new HashMap<PluginTool, List<Navigatable>>();
|
||||
|
||||
|
||||
public static void registerNavigatable(Tool tool, Navigatable navigatable) {
|
||||
public static void registerNavigatable(PluginTool tool, Navigatable navigatable) {
|
||||
navigatableMap.put(navigatable.getInstanceID(), navigatable);
|
||||
List<Navigatable> list = toolMap.get(tool);
|
||||
if (list == null) {
|
||||
@@ -35,7 +34,7 @@ public class NavigatableRegistry {
|
||||
list.add(navigatable);
|
||||
}
|
||||
|
||||
public static void unregisterNavigatable(Tool tool, Navigatable navigatable) {
|
||||
public static void unregisterNavigatable(PluginTool tool, Navigatable navigatable) {
|
||||
navigatableMap.remove(navigatable.getInstanceID());
|
||||
List<Navigatable> list = toolMap.get(tool);
|
||||
if (list == null) {
|
||||
@@ -46,13 +45,15 @@ public class NavigatableRegistry {
|
||||
toolMap.remove(tool);
|
||||
}
|
||||
}
|
||||
public static List<Navigatable> getRegisteredNavigatables(Tool tool) {
|
||||
|
||||
public static List<Navigatable> getRegisteredNavigatables(PluginTool tool) {
|
||||
List<Navigatable> list = toolMap.get(tool);
|
||||
if (list == null) {
|
||||
list = new ArrayList<Navigatable>(navigatableMap.values());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static Navigatable getNavigatable(long navigationID) {
|
||||
return navigatableMap.get(navigationID);
|
||||
}
|
||||
|
||||
@@ -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,8 @@
|
||||
*/
|
||||
package ghidra.app.nav;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import ghidra.app.context.*;
|
||||
import ghidra.app.plugin.core.navigation.NavigationOptions;
|
||||
import ghidra.app.services.GoToService;
|
||||
@@ -24,8 +25,6 @@ import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.listing.CodeUnit;
|
||||
import ghidra.program.util.ProgramSelection;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class NextRangeAction extends NavigatableContextAction {
|
||||
|
||||
private PluginTool tool;
|
||||
@@ -39,7 +38,7 @@ public abstract class NextRangeAction extends NavigatableContextAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isValidContext(NavigatableActionContext context) {
|
||||
protected boolean isValidNavigationContext(NavigatableActionContext context) {
|
||||
//
|
||||
// We want the nav actions to work in the current view that supports this, which right
|
||||
// now is the ListingActionContext. If the current context does not support that, then
|
||||
@@ -51,13 +50,12 @@ public abstract class NextRangeAction extends NavigatableContextAction {
|
||||
@Override
|
||||
public boolean isEnabledForContext(NavigatableActionContext context) {
|
||||
Address currentAddress = context.getAddress();
|
||||
ListingActionContext listingContext = (ListingActionContext) context;
|
||||
ProgramSelection selection = getSelection(listingContext);
|
||||
ProgramSelection selection = getSelection(context);
|
||||
if (selection == null || selection.isEmpty() || currentAddress == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CodeUnit cu = listingContext.getProgram().getListing().getCodeUnitAt(currentAddress);
|
||||
CodeUnit cu = context.getProgram().getListing().getCodeUnitAt(currentAddress);
|
||||
if (cu != null) {
|
||||
currentAddress = cu.getMaxAddress();
|
||||
}
|
||||
@@ -71,13 +69,10 @@ public abstract class NextRangeAction extends NavigatableContextAction {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(NavigatableActionContext context) {
|
||||
// Note: we verified above that the context we are grabbing here is the correct type
|
||||
ListingActionContext listingContext = (ListingActionContext) context;
|
||||
|
||||
Address goToAddress = getGoToAddress(listingContext);
|
||||
Address goToAddress = getGoToAddress(context);
|
||||
GoToService service = tool.getService(GoToService.class);
|
||||
if (service != null) {
|
||||
service.goTo(listingContext.getNavigatable(), goToAddress);
|
||||
service.goTo(context.getNavigatable(), goToAddress);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,8 @@
|
||||
*/
|
||||
package ghidra.app.nav;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import ghidra.app.context.*;
|
||||
import ghidra.app.plugin.core.navigation.NavigationOptions;
|
||||
import ghidra.app.services.GoToService;
|
||||
@@ -23,8 +24,6 @@ import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.util.ProgramSelection;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class PreviousRangeAction extends NavigatableContextAction {
|
||||
|
||||
private PluginTool tool;
|
||||
@@ -39,7 +38,7 @@ public abstract class PreviousRangeAction extends NavigatableContextAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isValidContext(NavigatableActionContext context) {
|
||||
protected boolean isValidNavigationContext(NavigatableActionContext context) {
|
||||
//
|
||||
// We want the nav actions to work in the current view that supports this, which right
|
||||
// now is the ListingActionContext. If the current context does not support that, then
|
||||
@@ -58,9 +57,8 @@ public abstract class PreviousRangeAction extends NavigatableContextAction {
|
||||
}
|
||||
|
||||
private Address getGoToAddress(NavigatableActionContext context) {
|
||||
ListingActionContext listingContext = (ListingActionContext) context;
|
||||
ProgramSelection selection = getSelection(listingContext);
|
||||
Address currentAddress = listingContext.getAddress();
|
||||
ProgramSelection selection = getSelection(context);
|
||||
Address currentAddress = context.getAddress();
|
||||
|
||||
AddressRangeIterator it = selection.getAddressRanges(currentAddress, false);
|
||||
if (!it.hasNext()) {
|
||||
@@ -94,8 +92,7 @@ public abstract class PreviousRangeAction extends NavigatableContextAction {
|
||||
@Override
|
||||
public boolean isEnabledForContext(NavigatableActionContext context) {
|
||||
Address currentAddress = context.getAddress();
|
||||
ListingActionContext listingContext = (ListingActionContext) context;
|
||||
ProgramSelection selection = getSelection(listingContext);
|
||||
ProgramSelection selection = getSelection(context);
|
||||
if (selection == null || selection.isEmpty() || currentAddress == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+2
-10
@@ -22,7 +22,7 @@ import javax.swing.Icon;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.DockingTool;
|
||||
import docking.Tool;
|
||||
import docking.action.*;
|
||||
import docking.actions.PopupActionProvider;
|
||||
import docking.widgets.table.GTable;
|
||||
@@ -362,10 +362,6 @@ public class BookmarkPlugin extends ProgramPlugin
|
||||
getBookmarkNavigator(bookmarkMgr.getBookmarkType(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* Bookmark has been changed.
|
||||
* @param bookmark
|
||||
*/
|
||||
private void bookmarkChanged(Bookmark bookmark) {
|
||||
if (bookmark == null) {
|
||||
scheduleUpdate(null);
|
||||
@@ -378,10 +374,6 @@ public class BookmarkPlugin extends ProgramPlugin
|
||||
provider.bookmarkChanged(bookmark);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bookmark has been added.
|
||||
* @param bookmark
|
||||
*/
|
||||
private void bookmarkAdded(Bookmark bookmark) {
|
||||
if (bookmark == null) {
|
||||
scheduleUpdate(null);
|
||||
@@ -496,7 +488,7 @@ public class BookmarkPlugin extends ProgramPlugin
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DockingActionIf> getPopupActions(DockingTool tool, ActionContext context) {
|
||||
public List<DockingActionIf> getPopupActions(Tool activeTool, ActionContext context) {
|
||||
Object contextObject = context.getContextObject();
|
||||
if (!(contextObject instanceof MarkerLocation)) {
|
||||
return null;
|
||||
|
||||
@@ -26,7 +26,7 @@ import ghidra.app.context.ListingContextAction;
|
||||
import ghidra.app.plugin.PluginCategoryNames;
|
||||
import ghidra.framework.cmd.Command;
|
||||
import ghidra.framework.plugintool.*;
|
||||
import ghidra.framework.plugintool.util.*;
|
||||
import ghidra.framework.plugintool.util.PluginStatus;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressSet;
|
||||
import ghidra.program.model.data.*;
|
||||
@@ -264,12 +264,6 @@ public class ClearPlugin extends Plugin {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidGlobalContext(ActionContext context) {
|
||||
// it's too dangerous to let the clear action work globally
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
int menuOrdinal = 1;
|
||||
|
||||
+1
-1
@@ -952,7 +952,7 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DockingActionIf> getPopupActions(DockingTool dt, ActionContext context) {
|
||||
public List<DockingActionIf> getPopupActions(Tool dt, ActionContext context) {
|
||||
if (context.getComponentProvider() == this) {
|
||||
return listingPanel.getHeaderActions(getName());
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ package ghidra.app.plugin.core.comments;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.action.*;
|
||||
import ghidra.app.CorePluginPackage;
|
||||
import ghidra.app.cmd.comments.SetCommentCmd;
|
||||
@@ -187,11 +186,6 @@ public class CommentsPlugin extends Plugin implements OptionsChangeListener {
|
||||
getPopupMenuData().setMenuPath(new String[] { "Comments", "Delete" });
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidGlobalContext(ActionContext globalContext) {
|
||||
return false; // only work on active provider context.
|
||||
}
|
||||
};
|
||||
deleteAction.setPopupMenuData(new MenuData(DELETE_MENUPATH, null, "comments"));
|
||||
deleteAction.setKeyBindingData(new KeyBindingData(KeyEvent.VK_DELETE, 0));
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ import javax.swing.SwingUtilities;
|
||||
import javax.swing.tree.TreePath;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.DockingTool;
|
||||
import docking.Tool;
|
||||
import docking.action.*;
|
||||
import docking.actions.PopupActionProvider;
|
||||
import docking.widgets.tree.GTreeNode;
|
||||
@@ -678,7 +678,7 @@ public class DataTypeManagerPlugin extends ProgramPlugin
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DockingActionIf> getPopupActions(DockingTool dockingTool, ActionContext context) {
|
||||
public List<DockingActionIf> getPopupActions(Tool dockingTool, ActionContext context) {
|
||||
if (!(context instanceof DataTypesActionContext)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+2
-2
@@ -22,8 +22,8 @@ import javax.swing.ComboBoxModel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import docking.ComponentProvider;
|
||||
import docking.actions.DockingToolActions;
|
||||
import docking.actions.SharedDockingActionPlaceholder;
|
||||
import docking.actions.ToolActions;
|
||||
import docking.widgets.checkbox.GCheckBox;
|
||||
import docking.widgets.combobox.GhidraComboBox;
|
||||
import docking.widgets.label.GLabel;
|
||||
@@ -163,7 +163,7 @@ public class DataTypeEditorManager
|
||||
}
|
||||
|
||||
private void registerAction(String name) {
|
||||
ToolActions toolActions = plugin.getTool().getToolActions();
|
||||
DockingToolActions toolActions = plugin.getTool().getToolActions();
|
||||
toolActions.registerSharedActionPlaceholder(new DtSharedActionPlaceholder(name));
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ import java.awt.event.KeyEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.action.*;
|
||||
import docking.widgets.OptionDialog;
|
||||
import ghidra.app.CorePluginPackage;
|
||||
@@ -374,8 +373,8 @@ public class EquatePlugin extends Plugin {
|
||||
Program program = context.getProgram();
|
||||
List<Integer> opIndices = getInstructionMatches(program, inst, equate);
|
||||
Address addr = inst.getAddress();
|
||||
for (int i = 0; i < opIndices.size(); i++) {
|
||||
bgCmd.add(createRenameCmd(oldName, newName, addr, opIndices.get(i)));
|
||||
for (Integer opIndice : opIndices) {
|
||||
bgCmd.add(createRenameCmd(oldName, newName, addr, opIndice));
|
||||
}
|
||||
}
|
||||
else if (cu instanceof Data) {
|
||||
@@ -429,9 +428,9 @@ public class EquatePlugin extends Plugin {
|
||||
|
||||
Program program = context.getProgram();
|
||||
List<Integer> opIndexes = getInstructionMatches(program, instr, equate);
|
||||
for (int i = 0; i < opIndexes.size(); i++) {
|
||||
for (Integer opIndexe : opIndexes) {
|
||||
bckCmd.add(
|
||||
new ClearEquateCmd(equate.getName(), instr.getAddress(), opIndexes.get(i)));
|
||||
new ClearEquateCmd(equate.getName(), instr.getAddress(), opIndexe));
|
||||
}
|
||||
}
|
||||
else if (cu instanceof Data) {
|
||||
@@ -728,12 +727,6 @@ public class EquatePlugin extends Plugin {
|
||||
protected boolean isEnabledForContext(ListingActionContext context) {
|
||||
return getEquate(context) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidGlobalContext(ActionContext globalContext) {
|
||||
return false; // only work on active provider context.
|
||||
}
|
||||
|
||||
};
|
||||
removeAction.setPopupMenuData(new MenuData(REMOVE_MENUPATH, null, GROUP_NAME));
|
||||
removeAction.setKeyBindingData(new KeyBindingData(KeyEvent.VK_DELETE, 0));
|
||||
|
||||
-6
@@ -17,7 +17,6 @@ package ghidra.app.plugin.core.function;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.action.KeyBindingData;
|
||||
import docking.action.MenuData;
|
||||
import ghidra.app.cmd.function.DeleteFunctionCmd;
|
||||
@@ -71,9 +70,4 @@ class DeleteFunctionAction extends ListingContextAction {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidGlobalContext(ActionContext globalContext) {
|
||||
return false; // only work on active provider context.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-6
@@ -17,7 +17,6 @@ package ghidra.app.plugin.core.function;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.action.KeyBindingData;
|
||||
import docking.action.MenuData;
|
||||
import ghidra.app.cmd.function.CallDepthChangeInfo;
|
||||
@@ -73,9 +72,4 @@ class RemoveStackDepthChangeAction extends ListingContextAction {
|
||||
context.getAddress()) != null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidGlobalContext(ActionContext globalContext) {
|
||||
return false; // only work on active provider context.
|
||||
}
|
||||
}
|
||||
|
||||
-5
@@ -17,7 +17,6 @@ package ghidra.app.plugin.core.function;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.action.KeyBindingData;
|
||||
import docking.action.KeyBindingType;
|
||||
import ghidra.app.cmd.function.SetVariableCommentCmd;
|
||||
@@ -89,8 +88,4 @@ class VariableCommentDeleteAction extends ListingContextAction {
|
||||
return (loc instanceof VariableCommentFieldLocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidGlobalContext(ActionContext globalContext) {
|
||||
return false; // only work on active provider context.
|
||||
}
|
||||
}
|
||||
|
||||
-6
@@ -17,7 +17,6 @@ package ghidra.app.plugin.core.function;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.action.KeyBindingData;
|
||||
import docking.action.MenuData;
|
||||
import ghidra.app.cmd.function.DeleteVariableCmd;
|
||||
@@ -105,9 +104,4 @@ class VariableDeleteAction extends ListingContextAction {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidGlobalContext(ActionContext globalContext) {
|
||||
return false; // only work on active provider context.
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ import java.awt.event.MouseEvent;
|
||||
import java.util.*;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.DockingTool;
|
||||
import docking.Tool;
|
||||
import docking.action.DockingAction;
|
||||
import docking.action.DockingActionIf;
|
||||
import docking.actions.PopupActionProvider;
|
||||
@@ -130,7 +130,7 @@ public class FunctionComparisonProvider extends ComponentProviderAdapter
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DockingActionIf> getPopupActions(DockingTool tool, ActionContext context) {
|
||||
public List<DockingActionIf> getPopupActions(Tool tool, ActionContext context) {
|
||||
if (context.getComponentProvider() == this) {
|
||||
ListingCodeComparisonPanel dualListingPanel =
|
||||
functionComparisonPanel.getDualListingPanel();
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ public final class GoToServicePlugin extends ProgramPlugin {
|
||||
* Creates a new instance of the <CODE>GoToServicePlugin</CODE>
|
||||
*/
|
||||
public GoToServicePlugin(PluginTool plugintool) {
|
||||
super(plugintool, true, false);
|
||||
super(plugintool, true, true);
|
||||
|
||||
gotoService = new GoToServiceImpl(this, new DefaultNavigatable());
|
||||
|
||||
|
||||
+1
-1
@@ -245,7 +245,7 @@ public class InstructionSearchPlugin extends ProgramPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isValidContext(NavigatableActionContext context) {
|
||||
protected boolean isValidNavigationContext(NavigatableActionContext context) {
|
||||
return !(context instanceof RestrictedAddressSetContext);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,7 +19,6 @@ import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.action.*;
|
||||
import ghidra.app.context.ListingActionContext;
|
||||
import ghidra.app.context.ListingContextAction;
|
||||
@@ -66,11 +65,6 @@ class RemoveLabelAction extends ListingContextAction {
|
||||
return !plugin.isOnExternalReference(context) && isOnSymbol(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidGlobalContext(ActionContext globalContext) {
|
||||
return false; // only work on active provider context.
|
||||
}
|
||||
|
||||
boolean isOnSymbol(ListingActionContext context) {
|
||||
Symbol s = plugin.getSymbol(context);
|
||||
return ((s instanceof CodeSymbol) && !s.isDynamic()) ||
|
||||
|
||||
-20
@@ -316,16 +316,6 @@ public class NextPrevAddressPlugin extends Plugin {
|
||||
setDescription(isNext ? "Go to next location" : "Go to previous location");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidContext(ActionContext context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidGlobalContext(ActionContext globalContext) {
|
||||
return (globalContext instanceof NavigatableActionContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabledForContext(ActionContext context) {
|
||||
Navigatable navigatable = getNavigatable(context);
|
||||
@@ -426,16 +416,6 @@ public class NextPrevAddressPlugin extends Plugin {
|
||||
setMenuBarData(menuData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidContext(ActionContext context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidGlobalContext(ActionContext globalContext) {
|
||||
return (globalContext instanceof NavigatableActionContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabledForContext(ActionContext context) {
|
||||
Navigatable navigatable = getNavigatable(context);
|
||||
|
||||
+1
-1
@@ -326,7 +326,7 @@ public final class LanguageProviderPlugin extends Plugin implements FrontEndable
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
ToolServices toolServices = tool.getToolServices();
|
||||
String defaultToolName = toolServices.getDefaultToolTemplate(file).getName();
|
||||
for (Tool t : toolServices.getRunningTools()) {
|
||||
for (PluginTool t : toolServices.getRunningTools()) {
|
||||
if (t.getName().equals(defaultToolName)) {
|
||||
openTool = (PluginTool) t;
|
||||
break;
|
||||
|
||||
-7
@@ -17,7 +17,6 @@ package ghidra.app.plugin.core.references;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.action.KeyBindingData;
|
||||
import docking.action.MenuData;
|
||||
import ghidra.app.cmd.refs.RemoveAllReferencesCmd;
|
||||
@@ -116,10 +115,4 @@ public class DeleteReferencesAction extends ListingContextAction {
|
||||
}
|
||||
return actionOK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidGlobalContext(ActionContext globalContext) {
|
||||
return false; // only work on active provider context.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -167,11 +167,6 @@ public class RegisterPlugin extends ProgramPlugin {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidGlobalContext(ActionContext globalContext) {
|
||||
return false; // only work on active provider context.
|
||||
}
|
||||
};
|
||||
deleteRegisterRangeAction.setKeyBindingData(new KeyBindingData(KeyEvent.VK_DELETE, 0));
|
||||
|
||||
|
||||
+1
-1
@@ -145,7 +145,7 @@ public class ScalarSearchPlugin extends ProgramPlugin implements DomainObjectLis
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isValidContext(NavigatableActionContext context) {
|
||||
protected boolean isValidNavigationContext(NavigatableActionContext context) {
|
||||
return !(context instanceof RestrictedAddressSetContext);
|
||||
}
|
||||
};
|
||||
|
||||
+2
-2
@@ -350,7 +350,7 @@ public class MemSearchPlugin extends Plugin implements OptionsChangeListener,
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isValidContext(NavigatableActionContext context) {
|
||||
protected boolean isValidNavigationContext(NavigatableActionContext context) {
|
||||
return !(context instanceof RestrictedAddressSetContext);
|
||||
}
|
||||
};
|
||||
@@ -374,7 +374,7 @@ public class MemSearchPlugin extends Plugin implements OptionsChangeListener,
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isValidContext(NavigatableActionContext context) {
|
||||
protected boolean isValidNavigationContext(NavigatableActionContext context) {
|
||||
return !(context instanceof RestrictedAddressSetContext);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -95,6 +95,7 @@ public class BinaryLoader extends AbstractProgramLoader {
|
||||
long length = 0;
|
||||
long fileOffset = 0;
|
||||
long origFileLength;
|
||||
boolean isOverlay = false;
|
||||
try {
|
||||
origFileLength = provider.length();
|
||||
}
|
||||
@@ -174,6 +175,7 @@ public class BinaryLoader extends AbstractProgramLoader {
|
||||
if (!Boolean.class.isAssignableFrom(option.getValueClass())) {
|
||||
return OPTION_NAME_IS_OVERLAY + " must be a boolean";
|
||||
}
|
||||
isOverlay = (boolean) option.getValue();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
@@ -194,7 +196,7 @@ public class BinaryLoader extends AbstractProgramLoader {
|
||||
return "Invalid length specified";
|
||||
}
|
||||
if (program != null) {
|
||||
if (program.getMemory().intersects(baseAddr, baseAddr.add(length - 1))) {
|
||||
if (program.getMemory().intersects(baseAddr, baseAddr.add(length - 1)) && !isOverlay) {
|
||||
return "Memory Conflict: Use <Options...> to change the base address!";
|
||||
}
|
||||
}
|
||||
@@ -340,7 +342,7 @@ public class BinaryLoader extends AbstractProgramLoader {
|
||||
FileBytes fileBytes, long length, MessageLog log)
|
||||
throws AddressOverflowException, IOException {
|
||||
|
||||
if (prog.getMemory().intersects(baseAddr, baseAddr.add(length - 1))) {
|
||||
if (prog.getMemory().intersects(baseAddr, baseAddr.add(length - 1)) && !isOverlay) {
|
||||
throw new IOException("Can't load " + length + " bytes at address " + baseAddr +
|
||||
" since it conflicts with existing memory blocks!");
|
||||
}
|
||||
|
||||
@@ -166,7 +166,8 @@ class FunctionsXmlMgr {
|
||||
|
||||
String regularComment = getElementText(parser, "REGULAR_CMT");
|
||||
func.setComment(regularComment);
|
||||
getElementText(parser, "REPEATABLE_CMT");
|
||||
String repeatableComment = getElementText(parser, "REPEATABLE_CMT");
|
||||
func.setRepeatableComment(repeatableComment);
|
||||
String typeInfoComment = getElementText(parser, "TYPEINFO_CMT");
|
||||
List<Variable> stackParams = new ArrayList<>();
|
||||
List<Variable> stackVariables = new ArrayList<>();
|
||||
@@ -533,6 +534,7 @@ class FunctionsXmlMgr {
|
||||
writeReturnType(writer, func);
|
||||
writeAddressRange(writer, func);
|
||||
writeRegularComment(writer, func.getComment());
|
||||
writeRepeatableComment(writer, func.getRepeatableComment());
|
||||
if (func.getSignatureSource() != SourceType.DEFAULT) {
|
||||
writeTypeInfoComment(writer, func);
|
||||
}
|
||||
@@ -602,6 +604,12 @@ class FunctionsXmlMgr {
|
||||
}
|
||||
}
|
||||
|
||||
private void writeRepeatableComment(XmlWriter writer, String comment) {
|
||||
if (comment != null && comment.length() > 0) {
|
||||
writer.writeElement("REPEATABLE_CMT", null, comment);
|
||||
}
|
||||
}
|
||||
|
||||
private void writeStackFrame(XmlWriter writer, Function func) {
|
||||
StackFrame frame = func.getStackFrame();
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import docking.ActionContext;
|
||||
import docking.widgets.tree.GTreeNode;
|
||||
import ghidra.app.services.ProgramManager;
|
||||
import ghidra.formats.gfilesystem.*;
|
||||
import ghidra.framework.model.Tool;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.util.Msg;
|
||||
|
||||
@@ -60,7 +59,7 @@ public class FSBUtils {
|
||||
}
|
||||
|
||||
public static FSBRootNode getNodesRoot(FSBNode node) {
|
||||
GTreeNode tmp = (GTreeNode) node;
|
||||
GTreeNode tmp = node;
|
||||
while (tmp != null && !(tmp instanceof FSBRootNode)) {
|
||||
tmp = tmp.getParent();
|
||||
}
|
||||
@@ -102,13 +101,11 @@ public class FSBUtils {
|
||||
|
||||
public static List<PluginTool> getRunningProgramManagerTools(PluginTool tool) {
|
||||
List<PluginTool> pluginTools = new ArrayList<>();
|
||||
for (Tool runningTool : tool.getToolServices().getRunningTools()) {
|
||||
if (runningTool instanceof PluginTool) {
|
||||
PluginTool pt = (PluginTool) runningTool;
|
||||
ProgramManager pmService = pt.getService(ProgramManager.class);
|
||||
if (pmService != null) {
|
||||
pluginTools.add(pt);
|
||||
}
|
||||
for (PluginTool runningTool : tool.getToolServices().getRunningTools()) {
|
||||
PluginTool pt = runningTool;
|
||||
ProgramManager pmService = pt.getService(ProgramManager.class);
|
||||
if (pmService != null) {
|
||||
pluginTools.add(pt);
|
||||
}
|
||||
}
|
||||
return pluginTools;
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.*;
|
||||
|
||||
import generic.test.AbstractGenericTest;
|
||||
import ghidra.framework.model.*;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.framework.store.LockException;
|
||||
import ghidra.program.database.ProgramDB;
|
||||
import ghidra.program.model.lang.*;
|
||||
@@ -155,18 +156,18 @@ public class ProjectTestUtils {
|
||||
return dir.delete();
|
||||
}
|
||||
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
if (files[i].isDirectory()) {
|
||||
for (File file : files) {
|
||||
if (file.isDirectory()) {
|
||||
// use a dummy monitor as not to ruin our progress
|
||||
if (!deleteDir(files[i])) {
|
||||
Msg.debug(ProjectTestUtils.class, "Unable to delete directory: " + files[i]);
|
||||
if (!deleteDir(file)) {
|
||||
Msg.debug(ProjectTestUtils.class, "Unable to delete directory: " + file);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!files[i].delete()) {
|
||||
if (!ignoredDeleteNames.contains(files[i].getName())) {
|
||||
Msg.debug(ProjectTestUtils.class, "Unable to delete file: " + files[i]);
|
||||
if (!file.delete()) {
|
||||
if (!ignoredDeleteNames.contains(file.getName())) {
|
||||
Msg.debug(ProjectTestUtils.class, "Unable to delete file: " + file);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -186,6 +187,10 @@ public class ProjectTestUtils {
|
||||
* @param folder domain folder within the specified project which the
|
||||
* user has permission to write. If null, the root data folder will be used.
|
||||
* @return new domain file.
|
||||
* @throws InvalidNameException if the filename is invalid
|
||||
* @throws CancelledException if the opening is cancelled
|
||||
* @throws LanguageNotFoundException if the language cannot be found
|
||||
* @throws IOException if there is an exception creating the program or domain file
|
||||
*/
|
||||
public static DomainFile createProgramFile(Project proj, String progName, Language language,
|
||||
CompilerSpec compilerSpec, DomainFolder folder) throws InvalidNameException,
|
||||
@@ -210,8 +215,9 @@ public class ProjectTestUtils {
|
||||
* @param project the project to which the tool belongs
|
||||
* @param toolName name of the tool to get from the active workspace.
|
||||
* If null, launch a new empty tool in the active workspace.
|
||||
* @return the tool
|
||||
*/
|
||||
public static Tool getTool(Project project, String toolName) {
|
||||
public static PluginTool getTool(Project project, String toolName) {
|
||||
|
||||
ToolManager tm = project.getToolManager();
|
||||
|
||||
@@ -222,7 +228,7 @@ public class ProjectTestUtils {
|
||||
// use the first one for the testing
|
||||
Workspace activeWorkspace = workspaces[0];
|
||||
|
||||
Tool tool = null;
|
||||
PluginTool tool = null;
|
||||
if (toolName == null) {
|
||||
// create a new empty tool
|
||||
tool = activeWorkspace.createTool();
|
||||
@@ -244,7 +250,7 @@ public class ProjectTestUtils {
|
||||
* @param tool The tool to be saved
|
||||
* @return The tool template for the given tool.
|
||||
*/
|
||||
public static ToolTemplate saveTool(Project project, Tool tool) {
|
||||
public static ToolTemplate saveTool(Project project, PluginTool tool) {
|
||||
// save the tool to the project tool chest
|
||||
ToolChest toolChest = project.getLocalToolChest();
|
||||
ToolTemplate toolTemplate = tool.saveToolToToolTemplate();
|
||||
@@ -254,8 +260,8 @@ public class ProjectTestUtils {
|
||||
|
||||
/**
|
||||
* Remove the specified tool if it exists.
|
||||
* @param project
|
||||
* @param toolName
|
||||
* @param project the project
|
||||
* @param toolName the tool name
|
||||
* @return true if it existed and was removed from the local tool chest.
|
||||
*/
|
||||
public static boolean deleteTool(Project project, String toolName) {
|
||||
|
||||
@@ -640,7 +640,7 @@ public class TestEnv {
|
||||
* NOTE: This array will not contain any of the TestTools!
|
||||
* @return an array of tools spawned by the Ghidra environment
|
||||
*/
|
||||
public Tool[] getGhidraCreatedTools() {
|
||||
public PluginTool[] getGhidraCreatedTools() {
|
||||
return gp.getProject().getToolManager().getRunningTools();
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.List;
|
||||
|
||||
import ghidra.app.plugin.core.datamgr.util.DataTypeUtils;
|
||||
import ghidra.app.services.DataTypeQueryService;
|
||||
import ghidra.app.services.DataTypeManagerService;
|
||||
import ghidra.program.database.data.DataTypeUtilities;
|
||||
import ghidra.program.database.data.ProgramDataTypeManager;
|
||||
import ghidra.program.model.data.*;
|
||||
@@ -440,8 +439,21 @@ public class DataTypeParser {
|
||||
|
||||
private static String getBaseString(String dataTypeString) {
|
||||
int nextIndex = 0;
|
||||
int templateCount = 0;
|
||||
while (nextIndex < dataTypeString.length()) {
|
||||
char c = dataTypeString.charAt(nextIndex);
|
||||
if (c == '<') {
|
||||
templateCount++;
|
||||
}
|
||||
else if (c == '>') {
|
||||
templateCount--;
|
||||
}
|
||||
|
||||
if (templateCount != 0) {
|
||||
++nextIndex;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c == '*' || c == '[' || c == ':' || c == '{') {
|
||||
return dataTypeString.substring(0, nextIndex).trim();
|
||||
}
|
||||
|
||||
@@ -610,7 +610,7 @@ public class ComponentProviderActionsTest extends AbstractGhidraHeadedIntegratio
|
||||
}
|
||||
|
||||
private void performLaunchKeyStrokeDialogAction() {
|
||||
ToolActions toolActions = ((AbstractDockingTool) tool).getToolActions();
|
||||
ToolActions toolActions = (ToolActions) ((AbstractDockingTool) tool).getToolActions();
|
||||
Action action = toolActions.getAction(KeyStroke.getKeyStroke("F4"));
|
||||
assertNotNull(action);
|
||||
runSwing(() -> action.actionPerformed(new ActionEvent(this, 0, "")), false);
|
||||
@@ -624,7 +624,7 @@ public class ComponentProviderActionsTest extends AbstractGhidraHeadedIntegratio
|
||||
|
||||
private JComponent component = new JTextField("Hey!");
|
||||
|
||||
TestActionsComponentProvider(DockingTool tool) {
|
||||
TestActionsComponentProvider(Tool tool) {
|
||||
super(tool, PROVIDER_NAME, "Fooberry Plugin");
|
||||
}
|
||||
|
||||
@@ -637,7 +637,7 @@ public class ComponentProviderActionsTest extends AbstractGhidraHeadedIntegratio
|
||||
private class HasDefaultKeyBindingComponentProvider extends ComponentProvider {
|
||||
private JComponent component = new JTextField("Hey!");
|
||||
|
||||
HasDefaultKeyBindingComponentProvider(DockingTool tool) {
|
||||
HasDefaultKeyBindingComponentProvider(Tool tool) {
|
||||
super(tool, HasDefaultKeyBindingComponentProvider.class.getSimpleName(),
|
||||
"Fooberry Plugin");
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ import ghidra.test.DummyTool;
|
||||
|
||||
public class DockingWindowManagerTest extends AbstractDockingTest {
|
||||
|
||||
private DockingTool tool = new DummyTool();
|
||||
private Tool tool = new DummyTool();
|
||||
|
||||
@Test
|
||||
public void testDefaultGroupWindowPosition() {
|
||||
|
||||
@@ -25,8 +25,8 @@ import javax.swing.*;
|
||||
import org.junit.*;
|
||||
|
||||
import docking.*;
|
||||
import docking.actions.DockingToolActions;
|
||||
import docking.actions.KeyEntryDialog;
|
||||
import docking.actions.ToolActions;
|
||||
import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;
|
||||
import ghidra.app.plugin.core.navigation.GoToAddressLabelPlugin;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
@@ -197,7 +197,7 @@ public class KeyEntryDialogTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
|
||||
public DockingAction getKeyBindingAction() {
|
||||
|
||||
ToolActions toolActions = tool.getToolActions();
|
||||
DockingToolActions toolActions = tool.getToolActions();
|
||||
KeyBindingsManager kbm =
|
||||
(KeyBindingsManager) getInstanceField("keyBindingsManager", toolActions);
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
+2
-3
@@ -28,8 +28,7 @@ import org.junit.Test;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.action.DockingActionIf;
|
||||
import docking.actions.KeyBindingUtils;
|
||||
import docking.actions.ToolActions;
|
||||
import docking.actions.*;
|
||||
|
||||
public class GhidraScriptMgrPlugin1Test extends AbstractGhidraScriptMgrPluginTest {
|
||||
|
||||
@@ -147,7 +146,7 @@ public class GhidraScriptMgrPlugin1Test extends AbstractGhidraScriptMgrPluginTes
|
||||
KeyStroke actionKs = toolAction.getKeyBinding();
|
||||
assertEquals(newKs, actionKs);
|
||||
|
||||
ToolActions toolActions = plugin.getTool().getToolActions();
|
||||
ToolActions toolActions = (ToolActions) plugin.getTool().getToolActions();
|
||||
Action toolActionByKeyStroke = toolActions.getAction(newKs);
|
||||
assertNotNull(toolActionByKeyStroke);
|
||||
}
|
||||
|
||||
+6
-5
@@ -15,11 +15,12 @@
|
||||
*/
|
||||
package ghidra.framework.project;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.*;
|
||||
|
||||
import ghidra.framework.model.*;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.framework.protocol.ghidra.GhidraURL;
|
||||
import ghidra.program.database.ProgramBuilder;
|
||||
import ghidra.program.model.listing.Program;
|
||||
@@ -73,7 +74,7 @@ public class CreateDomainObjectTest extends AbstractGhidraHeadedIntegrationTest
|
||||
|
||||
// test 1 create a program and add it to a project
|
||||
Program program1 = createProgram(project, "Prog1", this);
|
||||
Tool consumer2 = new DummyTool();
|
||||
PluginTool consumer2 = new DummyTool();
|
||||
Program program2 = null;
|
||||
try {
|
||||
// test 2 - get the object from the project and make sure it is the
|
||||
@@ -213,7 +214,7 @@ public class CreateDomainObjectTest extends AbstractGhidraHeadedIntegrationTest
|
||||
|
||||
private static void createProgramReadOnly(Project proj, String progName) throws Exception {
|
||||
|
||||
Tool t = new DummyTool();
|
||||
PluginTool t = new DummyTool();
|
||||
Program p = createDefaultProgram(progName, ProgramBuilder._TOY, t);
|
||||
|
||||
try {
|
||||
@@ -295,7 +296,7 @@ public class CreateDomainObjectTest extends AbstractGhidraHeadedIntegrationTest
|
||||
DomainFolder f3 = f.createFolder("Y");
|
||||
DomainFolder f4 = f.createFolder("Z");
|
||||
|
||||
Tool t = new DummyTool("Tool1");
|
||||
PluginTool t = new DummyTool("Tool1");
|
||||
|
||||
Program p1 = null;
|
||||
Program p2 = null;
|
||||
@@ -344,7 +345,7 @@ public class CreateDomainObjectTest extends AbstractGhidraHeadedIntegrationTest
|
||||
DomainFolder f3 = f.getFolder("Y");
|
||||
DomainFolder f4 = f.getFolder("Z");
|
||||
|
||||
Tool t = new DummyTool("Tool1");
|
||||
PluginTool t = new DummyTool("Tool1");
|
||||
|
||||
if ((f.getFile("AAA") == null) || (f.getFile("BBB") == null) ||
|
||||
(f2.getFile("CCC") == null) || (f3.getFile("DDD") == null) ||
|
||||
|
||||
+2
-2
@@ -200,9 +200,9 @@ public abstract class AbstractToolSavingTest extends AbstractGhidraHeadedIntegra
|
||||
protected List<PluginTool> findOpenTools() {
|
||||
ToolManager tm = testEnv.getProject().getToolManager();
|
||||
Workspace activeWorkspace = tm.getActiveWorkspace();
|
||||
Tool[] tools = activeWorkspace.getTools();
|
||||
PluginTool[] tools = activeWorkspace.getTools();
|
||||
List<PluginTool> pluginToolList = new ArrayList<>(tools.length);
|
||||
for (Tool tool : tools) {
|
||||
for (PluginTool tool : tools) {
|
||||
pluginToolList.add((PluginTool) tool);
|
||||
}
|
||||
return pluginToolList;
|
||||
|
||||
+8
-14
@@ -17,8 +17,10 @@ package ghidra.framework.project.tool;
|
||||
|
||||
import org.junit.*;
|
||||
|
||||
import generic.test.AbstractGenericTest;
|
||||
import ghidra.framework.model.*;
|
||||
import generic.test.AbstractGTest;
|
||||
import ghidra.framework.model.DomainFile;
|
||||
import ghidra.framework.model.Project;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.program.database.ProgramBuilder;
|
||||
import ghidra.test.*;
|
||||
|
||||
@@ -30,20 +32,12 @@ import ghidra.test.*;
|
||||
*/
|
||||
public class ChangeToolDataTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
|
||||
private final static String DIRECTORY_NAME = AbstractGenericTest.getTestDirectoryPath();
|
||||
private final static String DIRECTORY_NAME = AbstractGTest.getTestDirectoryPath();
|
||||
private final static String DATA_NAME_1 = "TestData1";
|
||||
private final static String DATA_NAME_2 = "TestData2";
|
||||
|
||||
private Project project;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param arg0
|
||||
*/
|
||||
public ChangeToolDataTest() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
ProjectTestUtils.deleteProject(DIRECTORY_NAME, PROJECT_NAME);
|
||||
@@ -56,8 +50,8 @@ public class ChangeToolDataTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
ProjectTestUtils.deleteProject(DIRECTORY_NAME, PROJECT_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* This doTest() routine tests the following requirements:
|
||||
/*
|
||||
* Tests the following requirements:
|
||||
* (1) connect two running tools by one or more specified events
|
||||
* (2) disconnect one or more specified events between two connected tools
|
||||
* @param args same as args to main()
|
||||
@@ -72,7 +66,7 @@ public class ChangeToolDataTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
//
|
||||
// setup the running tool
|
||||
//
|
||||
Tool runningTool = new DummyTool();
|
||||
PluginTool runningTool = new DummyTool();
|
||||
|
||||
//
|
||||
// TEST 1: set the data for a tool running without data
|
||||
|
||||
+1
-3
@@ -53,10 +53,8 @@ public class CloseToolTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
executeOnSwingWithoutBlocking(() -> env.dispose());
|
||||
|
||||
env.dispose();
|
||||
closeAllWindows();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+7
-14
@@ -17,8 +17,9 @@ package ghidra.framework.project.tool;
|
||||
|
||||
import org.junit.*;
|
||||
|
||||
import generic.test.AbstractGenericTest;
|
||||
import generic.test.AbstractGTest;
|
||||
import ghidra.framework.model.*;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.test.*;
|
||||
|
||||
/**
|
||||
@@ -30,18 +31,10 @@ import ghidra.test.*;
|
||||
public class ConnectToolsTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
|
||||
private final static String BAD_EVENT_NAME = "TEST_CONNECT_FOR_BAD_EVENT";
|
||||
private final static String DIRECTORY_NAME = AbstractGenericTest.getTestDirectoryPath();
|
||||
private final static String DIRECTORY_NAME = AbstractGTest.getTestDirectoryPath();
|
||||
|
||||
private Project project;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param arg0
|
||||
*/
|
||||
public ConnectToolsTest() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
@@ -56,16 +49,16 @@ public class ConnectToolsTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This doTest() routine tests the following requirements:
|
||||
/*
|
||||
* Tests the following requirements:
|
||||
* (1) connect two running tools by one or more specified events
|
||||
* (2) disconnect one or more specified events between two connected tools
|
||||
*/
|
||||
@Test
|
||||
public void testConnectTools() throws Exception {
|
||||
|
||||
Tool producer = new DummyTool("ProducerTool");
|
||||
Tool consumer = new DummyTool("ConsumerTool");
|
||||
PluginTool producer = new DummyTool("ProducerTool");
|
||||
PluginTool consumer = new DummyTool("ConsumerTool");
|
||||
|
||||
ToolConnection tc;
|
||||
String eventName = null;
|
||||
|
||||
+10
-18
@@ -17,8 +17,10 @@ package ghidra.framework.project.tool;
|
||||
|
||||
import org.junit.*;
|
||||
|
||||
import generic.test.AbstractGenericTest;
|
||||
import ghidra.framework.model.*;
|
||||
import generic.test.AbstractGTest;
|
||||
import ghidra.framework.model.Project;
|
||||
import ghidra.framework.model.ToolManager;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.test.AbstractGhidraHeadedIntegrationTest;
|
||||
import ghidra.test.ProjectTestUtils;
|
||||
|
||||
@@ -29,20 +31,10 @@ import ghidra.test.ProjectTestUtils;
|
||||
*/
|
||||
public class CreateToolTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
|
||||
private final static String DIRECTORY_NAME = AbstractGenericTest.getTestDirectoryPath();
|
||||
private final static String DIRECTORY_NAME = AbstractGTest.getTestDirectoryPath();
|
||||
|
||||
private Project project;
|
||||
// private Workspace activeWorkspace;
|
||||
|
||||
private Tool tool;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param arg0
|
||||
*/
|
||||
public CreateToolTest() {
|
||||
super();
|
||||
}
|
||||
private PluginTool tool;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@@ -56,7 +48,7 @@ public class CreateToolTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
ProjectTestUtils.deleteProject(DIRECTORY_NAME, PROJECT_NAME);
|
||||
}
|
||||
|
||||
private void closeTool(final Tool theTool) {
|
||||
private void closeTool(final PluginTool theTool) {
|
||||
executeOnSwingWithoutBlocking(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -65,10 +57,10 @@ public class CreateToolTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
});
|
||||
|
||||
// this handles the save changes dialog and potential analysis dialogs
|
||||
closeAllWindowsAndFrames();
|
||||
closeAllWindows();
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* Do the test.
|
||||
* This doTest() routine tests the following requirements:
|
||||
* (1) create (launch) an empty tool in the active workspace
|
||||
@@ -92,7 +84,7 @@ public class CreateToolTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
try {
|
||||
// verify the tool is actually running before declaring success
|
||||
ToolManager tm = project.getToolManager();
|
||||
Tool[] runningTools = tm.getRunningTools();
|
||||
PluginTool[] runningTools = tm.getRunningTools();
|
||||
for (int t = 0; !verified && t < runningTools.length; t++) {
|
||||
if (runningTools[t].equals(tool)) {
|
||||
verified = true;
|
||||
|
||||
+3
-2
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package ghidra.framework.project.tool;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.junit.*;
|
||||
|
||||
import generic.test.AbstractGenericTest;
|
||||
import ghidra.framework.model.*;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.framework.store.LockException;
|
||||
import ghidra.test.AbstractGhidraHeadedIntegrationTest;
|
||||
import ghidra.test.ProjectTestUtils;
|
||||
@@ -138,7 +139,7 @@ public class CreateWorkspaceTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
}
|
||||
});
|
||||
|
||||
Tool[] runningTools = wspaces[0].getTools();
|
||||
PluginTool[] runningTools = wspaces[0].getTools();
|
||||
assertEquals(1, runningTools.length);
|
||||
|
||||
setWorkspaceActive(wspaces[1]);
|
||||
|
||||
+6
-13
@@ -17,8 +17,9 @@ package ghidra.framework.project.tool;
|
||||
|
||||
import org.junit.*;
|
||||
|
||||
import generic.test.AbstractGenericTest;
|
||||
import generic.test.AbstractGTest;
|
||||
import ghidra.framework.model.*;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.test.AbstractGhidraHeadedIntegrationTest;
|
||||
import ghidra.test.ProjectTestUtils;
|
||||
|
||||
@@ -30,20 +31,12 @@ import ghidra.test.ProjectTestUtils;
|
||||
*/
|
||||
public class DeleteToolTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
|
||||
private final static String PROJECT_DIRECTORY = AbstractGenericTest.getTestDirectoryPath();
|
||||
private final static String PROJECT_DIRECTORY = AbstractGTest.getTestDirectoryPath();
|
||||
private final static String TOOL_NAME = "TestTool";
|
||||
|
||||
private Tool runningTool;
|
||||
private PluginTool runningTool;
|
||||
private Project project;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param arg0
|
||||
*/
|
||||
public DeleteToolTest() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
ProjectTestUtils.deleteProject(PROJECT_DIRECTORY, PROJECT_NAME);
|
||||
@@ -56,8 +49,8 @@ public class DeleteToolTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
ProjectTestUtils.deleteProject(PROJECT_DIRECTORY, PROJECT_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* This doTest() routine tests the following requirements:
|
||||
/*
|
||||
* Tsts the following requirements:
|
||||
* (1) delete a non-running tool from the user's project space
|
||||
* (2) delete a running tool from the user's project space
|
||||
*
|
||||
|
||||
+14
-29
@@ -15,16 +15,13 @@
|
||||
*/
|
||||
package ghidra.framework.project.tool;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.beans.PropertyVetoException;
|
||||
|
||||
import javax.swing.SwingUtilities;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.*;
|
||||
|
||||
import generic.test.AbstractGenericTest;
|
||||
import generic.test.AbstractGTest;
|
||||
import ghidra.framework.model.*;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.test.AbstractGhidraHeadedIntegrationTest;
|
||||
import ghidra.test.ProjectTestUtils;
|
||||
|
||||
@@ -36,20 +33,12 @@ import ghidra.test.ProjectTestUtils;
|
||||
*/
|
||||
public class RunToolTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
|
||||
private final static String DIRECTORY_NAME = AbstractGenericTest.getTestDirectoryPath();
|
||||
private final static String DIRECTORY_NAME = AbstractGTest.getTestDirectoryPath();
|
||||
private final static String TOOL_NAME = "TestTool";
|
||||
|
||||
private Project project;
|
||||
private Tool runningTool;
|
||||
private Tool tool;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param arg0
|
||||
*/
|
||||
public RunToolTest() {
|
||||
super();
|
||||
}
|
||||
private PluginTool runningTool;
|
||||
private PluginTool tool;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@@ -59,7 +48,7 @@ public class RunToolTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
runSwing(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
project.save();
|
||||
@@ -69,7 +58,7 @@ public class RunToolTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
ProjectTestUtils.deleteProject(DIRECTORY_NAME, PROJECT_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* Do the test.
|
||||
* This doTest() routine tests the following requirements:
|
||||
* (1) Run Project Tool Without Data
|
||||
@@ -84,22 +73,18 @@ public class RunToolTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
ProjectTestUtils.deleteTool(project, TOOL_NAME);
|
||||
|
||||
// Create tool and save tool config
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
runSwing(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
tool = ProjectTestUtils.getTool(project, null);
|
||||
try {
|
||||
tool.setToolName(TOOL_NAME);
|
||||
}
|
||||
catch (PropertyVetoException e) {
|
||||
}
|
||||
tool.setToolName(TOOL_NAME);
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
|
||||
final ToolTemplate toolConfig = ProjectTestUtils.saveTool(project, tool);
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
runSwing(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
tool.close();
|
||||
@@ -118,14 +103,14 @@ public class RunToolTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
// use the first one for the test
|
||||
final Workspace activeWorkspace = workspaces[0];
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
runSwing(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
runningTool = activeWorkspace.runTool(toolConfig);
|
||||
}
|
||||
});
|
||||
assertNotNull(runningTool);
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
runSwing(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
runningTool.close();
|
||||
@@ -135,7 +120,7 @@ public class RunToolTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
}
|
||||
finally {
|
||||
// Don't leave the tool in the tool chest
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
runSwing(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ProjectTestUtils.deleteTool(project, TOOL_NAME);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user