Skip to content

Commit

Permalink
Merge branch 'master' of
Browse files Browse the repository at this point in the history
  • Loading branch information
io12 authored and dragonmacher committed Jan 29, 2020
2 parents 9edc7a6 + 92fce52 commit 74fae2f
Show file tree
Hide file tree
Showing 142 changed files with 1,266 additions and 1,592 deletions.
3 changes: 1 addition & 2 deletions Ghidra/Features/Base/certification.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down Expand Up @@ -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|
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@

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 {

Expand All @@ -33,23 +35,61 @@ public NavigatableContextAction(String name, String owner, KeyBindingType type)

@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;
}
GoToService service = tool.getService(GoToService.class);
if (service == null) {
return null;
}
return isValidContext((NavigatableActionContext) context);
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
Expand All @@ -60,10 +100,6 @@ public boolean isAddToPopup(ActionContext context) {
return isAddToPopup((NavigatableActionContext) context);
}

protected boolean isValidContext(NavigatableActionContext context) {
return true;
}

protected boolean isEnabledForContext(NavigatableActionContext context) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void dispose() {
}

@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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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) {
Expand All @@ -35,7 +34,7 @@ public static void registerNavigatable(Tool tool, Navigatable navigatable) {
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) {
Expand All @@ -46,13 +45,15 @@ public static void unregisterNavigatable(Tool tool, Navigatable navigatable) {
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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand All @@ -24,8 +25,6 @@
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.util.ProgramSelection;

import java.util.Set;

public abstract class NextRangeAction extends NavigatableContextAction {

private PluginTool tool;
Expand All @@ -39,7 +38,7 @@ public NextRangeAction(PluginTool tool, String name, String owner, NavigationOpt
}

@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
Expand All @@ -51,13 +50,12 @@ protected boolean isValidContext(NavigatableActionContext context) {
@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();
}
Expand All @@ -71,13 +69,10 @@ public boolean isEnabledForContext(NavigatableActionContext context) {

@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);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -16,15 +15,15 @@
*/
package ghidra.app.nav;

import java.util.Set;

import ghidra.app.context.*;
import ghidra.app.plugin.core.navigation.NavigationOptions;
import ghidra.app.services.GoToService;
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;
Expand All @@ -39,7 +38,7 @@ public PreviousRangeAction(PluginTool tool, String name, String owner,
}

@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
Expand All @@ -58,9 +57,8 @@ public void actionPerformed(NavigatableActionContext context) {
}

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()) {
Expand Down Expand Up @@ -94,8 +92,7 @@ private Address getGoToAddress(NavigatableActionContext context) {
@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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
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;
Expand Down Expand Up @@ -362,10 +362,6 @@ private void typeAdded(String type) {
getBookmarkNavigator(bookmarkMgr.getBookmarkType(type));
}

/**
* Bookmark has been changed.
* @param bookmark
*/
private void bookmarkChanged(Bookmark bookmark) {
if (bookmark == null) {
scheduleUpdate(null);
Expand All @@ -378,10 +374,6 @@ private void bookmarkChanged(Bookmark bookmark) {
provider.bookmarkChanged(bookmark);
}

/**
* Bookmark has been added.
* @param bookmark
*/
private void bookmarkAdded(Bookmark bookmark) {
if (bookmark == null) {
scheduleUpdate(null);
Expand Down Expand Up @@ -496,7 +488,7 @@ private void select(ProgramSelection selection) {
}

@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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
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.*;
Expand Down Expand Up @@ -264,12 +264,6 @@ else if ((loc != null) && (loc.getAddress() != null) &&
}
return false;
}

@Override
public boolean isValidGlobalContext(ActionContext context) {
// it's too dangerous to let the clear action work globally
return false;
}
};

int menuOrdinal = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ public void setView(AddressSetView view) {
}

@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());
}
Expand Down
Loading

0 comments on commit 74fae2f

Please sign in to comment.