Skip to content

Ghidra is a software reverse engineering (SRE) framework

Test fixes

dragonmachere9931dfeaaa4
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/table/TableComponentProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/table/TableComponentProvider.java
index 66328c5e66..a664345e88 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/table/TableComponentProvider.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/table/TableComponentProvider.java
@@ -69,23 +69,23 @@ public class TableComponentProvider<T> extends ComponentProviderAdapter
private HelpLocation helpLoc = new HelpLocation(HelpTopics.SEARCH, "Query_Results");
TableComponentProvider(TableServicePlugin plugin, String title, String name,
- GhidraProgramTableModel<T> model, String programName, GoToService gotoService,
+ GhidraProgramTableModel<T> model, Program program, GoToService gotoService,
String windowSubMenu, Navigatable navigatable) {
- this(plugin, title, name, model, programName, gotoService, null, null, null, windowSubMenu,
+ this(plugin, title, name, model, program, gotoService, null, null, null, windowSubMenu,
navigatable);
}
TableComponentProvider(TableServicePlugin plugin, String title, String name,
- GhidraProgramTableModel<T> model, String programName, GoToService gotoService,
+ GhidraProgramTableModel<T> model, Program program, GoToService gotoService,
MarkerService markerService, Color markerColor, Icon markerIcon, String windowSubMenu,
Navigatable navigatable) {
super(plugin.getTool(), name, plugin.getName());
this.tableServicePlugin = plugin;
this.navigatable = navigatable;
- this.program = navigatable.getProgram();
+ this.program = program;
this.model = model;
- this.programName = programName;
+ this.programName = program.getDomainFile().getName();
this.markerService = markerService;
this.windowSubMenu = windowSubMenu;
setIcon(new GIcon("icon.plugin.table.service"));
@@ -130,14 +130,18 @@ public class TableComponentProvider<T> extends ComponentProviderAdapter
tool.contextChanged(TableComponentProvider.this);
});
- // only allow global actions through if we are derived from the connect/primary navigatable
- table.setActionsEnabled(navigatable.isConnected());
-
if (navigatable != null) {
+ // Only allow global actions if we are derived from the connect/primary navigatable.
+ // This allows the the primary navigatable to process key events without the user having
+ // to focus first focus the primary navigatable.
+ table.setActionsEnabled(navigatable.isConnected());
navigatable.addNavigatableListener(this);
table.installNavigation(tool, navigatable);
}
else {
+ // allow the table to use the default navigation behavior. If the GoToService later
+ // becomes available, then navigation will work.
+ table.setActionsEnabled(true); // default navigatable will be used
table.installNavigation(tool);
}
@@ -147,11 +151,18 @@ public class TableComponentProvider<T> extends ComponentProviderAdapter
return panel;
}
- private void createActions(final Plugin plugin) {
+ private void createActions(Plugin plugin) {
GhidraTable table = threadedPanel.getTable();
- selectAction =
- new MakeProgramSelectionAction(navigatable, tableServicePlugin.getName(), table);
+ if (navigatable != null) {
+ selectAction =
+ new MakeProgramSelectionAction(navigatable, tableServicePlugin.getName(), table);
+ }
+ else {
+ selectAction =
+ new MakeProgramSelectionAction(tableServicePlugin, table);
+ }
+
selectAction.setHelpLocation(new HelpLocation(HelpTopics.SEARCH, "Make_Selection"));
selectionNavigationAction = new SelectionNavigationAction(plugin, table);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/table/TableServicePlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/table/TableServicePlugin.java
index b267a6880b..344812c4b5 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/table/TableServicePlugin.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/table/TableServicePlugin.java
@@ -140,7 +140,7 @@ public class TableServicePlugin extends ProgramPlugin
GoToService gotoService = tool.getService(GoToService.class);
Program program = model.getProgram();
TableComponentProvider<T> cp = new TableComponentProvider<>(this, title, tableTypeName,
- model, program.getDomainFile().getName(), gotoService, windowSubMenu, navigatable);
+ model, program, gotoService, windowSubMenu, navigatable);
addProvider(program, cp);
return cp;
}
@@ -154,8 +154,8 @@ public class TableServicePlugin extends ProgramPlugin
MarkerService markerService = tool.getService(MarkerService.class);
Program program = model.getProgram();
TableComponentProvider<T> cp = new TableComponentProvider<>(this, title, tableTypeName,
- model, program.getDomainFile().getName(), gotoService, markerService, markerColor,
- markerIcon, windowSubMenu, navigatable);
+ model, program, gotoService, markerService, markerColor, markerIcon, windowSubMenu,
+ navigatable);
addProvider(program, cp);
return cp;
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/services/GoToService.java b/Ghidra/Features/Base/src/main/java/ghidra/app/services/GoToService.java
index 2c775e3d66..1c005d70cc 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/services/GoToService.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/services/GoToService.java
@@ -205,7 +205,8 @@ public interface GoToService {
GoToServiceListener listener, TaskMonitor monitor);
/**
- * Returns the default navigatable that is the destination for GoTo events.
+ * Returns the default navigatable that is the destination for GoTo events. This navigatable
+ * will not be null.
* @return the navigatable
*/
public Navigatable getDefaultNavigatable();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/util/table/actions/MakeProgramSelectionAction.java b/Ghidra/Features/Base/src/main/java/ghidra/util/table/actions/MakeProgramSelectionAction.java
index 89a91f6846..31810b8b4b 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/util/table/actions/MakeProgramSelectionAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/util/table/actions/MakeProgramSelectionAction.java
@@ -89,7 +89,7 @@ public class MakeProgramSelectionAction extends DockingAction {
*/
public MakeProgramSelectionAction(Plugin plugin, GhidraTable table) {
super("Make Selection", plugin.getName(), KeyBindingType.SHARED);
- this.plugin = plugin;
+ this.plugin = Objects.requireNonNull(plugin);
this.table = Objects.requireNonNull(table);
init();
}
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/instructionsearch/InstructionSearchTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/instructionsearch/InstructionSearchTest.java
index bf92df9625..332c9f10a3 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/instructionsearch/InstructionSearchTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/instructionsearch/InstructionSearchTest.java
@@ -15,8 +15,7 @@
*/
package ghidra.app.plugin.core.instructionsearch;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.*;
import java.awt.Container;
import java.awt.Window;
@@ -66,7 +65,7 @@ public class InstructionSearchTest extends AbstractGhidraHeadedIntegrationTest {
private GhidraTable instructionTable;
private GTable previewTable;
- /**
+ /*
* Test setup. Each test will start with a simple program having a selection
* encompassing the entire range.
*/
@@ -98,7 +97,7 @@ public class InstructionSearchTest extends AbstractGhidraHeadedIntegrationTest {
env.dispose();
}
- /**
+ /*
* This builds a small program based on a section of WinHelloCpp.exe. The specific
* section disassembles as follows:
*
@@ -112,7 +111,6 @@ public class InstructionSearchTest extends AbstractGhidraHeadedIntegrationTest {
* 004065ef 83 c4 0c ADD ESP,nope
* 004065f2 89 45 fc MOV [EBP + local_8],EAX
*
- * @throws Exception
*/
private Program buildProgram() throws Exception {
@@ -480,11 +478,10 @@ public class InstructionSearchTest extends AbstractGhidraHeadedIntegrationTest {
assertResultsTableRowCount(1);
}
- /**
+ /*
* Tests that we can perform a search over the entire memory space and return multiple
* results. To do this we're going to have to select the "PUSH EDI" instruction and mask
* out the operand, which should yield 2 matches.
- * @throws Exception
*/
@Test
public void testSearchEntireProgramMultipleResults() throws Exception {
@@ -821,12 +818,11 @@ public class InstructionSearchTest extends AbstractGhidraHeadedIntegrationTest {
waitForSwing();
}
- /**
+ /*
* Loads the instructions in the given range into the instruction table.
*
* @param addr1 address in the form "0x01234567"
- * @param addr2 address in the form "0x01234567"
- * @throws Exception
+ * @param addr2 address in the form "0x01234567"
*/
private void loadSelection(String addr1, String addr2) throws Exception {