Merge remote-tracking branch 'origin/GP-0-dragonmacher-test-fixes-5-7-26'

This commit is contained in:
Ryan Kurtz
2026-05-07 11:07:10 -04:00
9 changed files with 107 additions and 115 deletions
+3 -3
View File
@@ -704,9 +704,9 @@ src/main/help/help/topics/Search/images/SearchMemoryRegex.png||GHIDRA||||END|
src/main/help/help/topics/Search/images/SearchText.png||GHIDRA||||END|
src/main/help/help/topics/Search/images/StringSearchDialog.png||GHIDRA||||END|
src/main/help/help/topics/Search/images/StringSearchResults.png||GHIDRA||||END|
src/main/help/help/topics/SelectBlockPlugin/Select_Block_Help.html||GHIDRA||||END|
src/main/help/help/topics/SelectBlockPlugin/images/Dialog.png||GHIDRA||||END|
src/main/help/help/topics/SelectBlockPlugin/images/ToBadAddr.png||GHIDRA||||END|
src/main/help/help/topics/SelectBytesPlugin/Select_Bytes_Help.html||GHIDRA||||END|
src/main/help/help/topics/SelectBytesPlugin/images/Dialog.png||GHIDRA||||END|
src/main/help/help/topics/SelectBytesPlugin/images/ToBadAddr.png||GHIDRA||||END|
src/main/help/help/topics/Selection/Selecting.htm||GHIDRA||||END|
src/main/help/help/topics/SetHighlightPlugin/Highlighting.htm||GHIDRA||||END|
src/main/help/help/topics/ShowInstructionInfoPlugin/ShowInstructionInfo.htm||GHIDRA||||END|
@@ -10,81 +10,84 @@
<body>
<h1 align="center">Select Bytes</h1>
<p><br>
<p>
This tool allows the user to select a range of bytes starting from the cursor position.
</p>
<div align="center">
&nbsp;
</div>
<div align="center">
<img src="images/Dialog.png">
&nbsp;<br>
</div>
&nbsp;
<div align="left">
<TABLE x-use-null-cells="" width="100%">
<TBODY>
<TR>
<TD align="center" width="100%"><IMG border="1" src="images/Dialog.png" /></TD>
</TR>
</TBODY>
</TABLE>
<h3>By Method Options</h3>
<blockquote>
<p><i><b>Select All: &nbsp;<br>
<p><i><b>Select All: &nbsp;
</b></i></p>
<p>Makes a selection that covers all of the bytes in a file.<br>
<i><b><br>
To Address: &nbsp;<br>
<p>Makes a selection that covers all of the bytes in a file.
<i><b>
To Address: &nbsp;
</b></i></p>
<p>Makes a selection from current cursor position to a selected address, if
the address exists. &nbsp;If the address is an invalid address, the user is
prompted to select another address. &nbsp;If the address is outside of the
current program's memory, the selection will contain bytes from the cursor
position to the beginning or end of the program's memory.<br>
<i><b><br>
Select Forward: &nbsp;<br>
position to the beginning or end of the program's memory.
<i><b>
Select Forward: &nbsp;
</b></i></p>
<p>Default direction. &nbsp;Makes a selection of size <i>n </i>from
the cursor position to <i>n-1</i> number of bytes.<br>
<i><b><br>
Select Backward: &nbsp;<br>
the cursor position to <i>n-1</i> number of bytes.
<i><b>
Select Backward: &nbsp;
</b></i></p>
<p>Makes a selection of size <i>m</i> from the cursor position to <i>m-1</i>
number of bytes.<br>
number of bytes.
</p>
</blockquote>
<h3>Byte Selection</h3>
<blockquote>
<p><i><b>Ending Address: &nbsp;<br>
<p><i><b>Ending Address: &nbsp;
</b></i></p>
<p>Enter an appropriate address that will be either the ending address of the bytes (if
the selected address is greater than the current address) or the starting
address of the bytes (if the selected address is lower than the current
address). This value may be in either <b>hex</b> or <b>decimal</b><br>
<p><i><b>Length: &nbsp;<br>
address). This value may be in either <b>hex</b> or <b>decimal</b>
<p><i><b>Length: &nbsp;
</b></i></p>
<p>Enter an appropriate length (number of bytes to be contained in the
selection) that will point to either the ending address of the bytes (if
the selected address is greater than the current address) or the starting
address of the bytes (if the selected address is lower than the current
address). This value may be in either <b>hex</b> or <b>decimal</b><br>
address). This value may be in either <b>hex</b> or <b>decimal</b>
</blockquote>
<h3>Error Messages</h3>
<blockquote>
<p><i><b>To Address Error Message:</b></i></p>
<div align="center">
<img src="images/ToBadAddr.png"><br>
</div>
<p><i><b>To Address Error Message:</b></i></p>
<img src="images/ToBadAddr.png">
<p></p>
<p align="left">This occurs only when an invalid address is entered. &nbsp;The
user is prompted to enter a valid address.<br>
<br>
<br>
user is prompted to enter a valid address.
</p>
<br>
<br>
</blockquote>
<p class="providedbyplugin">Provided By: <i>Select Block</i> Plugin</p>
<p class="providedbyplugin">Provided By: <i>Select Bytes</i> Plugin</p>
<p class="relatedtopic">Related Topics</p>
<ul>
<li><a href="help/topics/Selection/Selecting.htm">Selection</a></li>
</ul>
<br>
</body>
@@ -37,7 +37,7 @@ import ghidra.util.layout.PairLayout;
/**
* Dialog for making program selections
*/
class SelectBlockDialog extends ReusableDialogComponentProvider {
class SelectBytesDialog extends ReusableDialogComponentProvider {
private PluginTool tool;
private Navigatable navigatable;
@@ -49,7 +49,7 @@ class SelectBlockDialog extends ReusableDialogComponentProvider {
private JRadioButton allButton;
private JRadioButton toButton;
SelectBlockDialog(PluginTool tool, Navigatable navigatable) {
SelectBytesDialog(PluginTool tool, Navigatable navigatable) {
super("Select Bytes", false, true, true, false);
this.tool = tool;
this.navigatable = navigatable;
@@ -58,7 +58,7 @@ class SelectBlockDialog extends ReusableDialogComponentProvider {
addOKButton();
setOkButtonText("Select Bytes");
addDismissButton();
setHelpLocation(new HelpLocation("SelectBlockPlugin", "Select_Block_Help"));
setHelpLocation(new HelpLocation("SelectBytesPlugin", "Select_Bytes_Help"));
setItemsEnabled(false);
forwardButton.doClick();
@@ -72,14 +72,13 @@ class SelectBlockDialog extends ReusableDialogComponentProvider {
gbc.insets = new Insets(2, 2, 2, 2);
gbc.gridx = 0;
gbc.gridy = 0;
mainPanel.add(methodPanel(), gbc);
mainPanel.add(buildMethodPanel(), gbc);
gbc.gridx++;
mainPanel.add(buildBlockPanel(), gbc);
mainPanel.getAccessibleContext().setAccessibleName("Select Block");
mainPanel.add(buildInputPanel(), gbc);
return mainPanel;
}
private JPanel buildBlockPanel() {
private JPanel buildInputPanel() {
JPanel main = new JPanel();
main.setBorder(BorderFactory.createTitledBorder("Byte Selection"));
@@ -94,12 +93,10 @@ class SelectBlockDialog extends ReusableDialogComponentProvider {
lengthField = new IntegerTextField(10);
lengthField.getComponent().getAccessibleContext().setAccessibleName("Number Input");
lengthField.setMinValue(BigInteger.ZERO);
main.add(lengthField.getComponent());
main.getAccessibleContext().setAccessibleName("Block");
return main;
}
private JPanel methodPanel() {
private JPanel buildMethodPanel() {
ButtonGroup buttonGroup = new ButtonGroup();
JPanel main = new JPanel();
main.setBorder(BorderFactory.createTitledBorder("By Method"));
@@ -175,6 +172,10 @@ class SelectBlockDialog extends ReusableDialogComponentProvider {
repack();
}
void setLength(int length) {
lengthField.setText(Integer.toString(length));
}
private void setItemsEnabled(boolean enabled) {
setAddressFieldEnabled(enabled);
setLengthInputEnabled(enabled);
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -30,12 +30,7 @@ import ghidra.framework.plugintool.util.PluginStatus;
import ghidra.util.HelpLocation;
/**
* This plugin class contains the structure needed for the user to
* select blocks of data anywhere inside of the Code Browser and Byte Viewer.
* <p>
* Note: This plugin used to refer to selections as blocks instead of lengths
* of bytes. The GUI has been changed, but the internal comments and
* variable names have not.
* This plugin allows users to select bytes anywhere inside of the Code Browser and Byte Viewer.
*/
//@formatter:off
@PluginInfo(
@@ -43,16 +38,15 @@ import ghidra.util.HelpLocation;
packageName = CorePluginPackage.NAME,
category = PluginCategoryNames.COMMON,
shortDescription = "Select Bytes",
description = "Allows the user to select different size "
+ "lengths of bytes from the Byte Viewer "
description = "Allows the user to select different size lengths of bytes, "
+ "generally starting from the cursor position or entire file"
)
//@formatter:on
public class SelectBlockPlugin extends Plugin {
private DockingAction toolBarAction;
private SelectBlockDialog dialog;
public class SelectBytesPlugin extends Plugin {
private DockingAction action;
private SelectBytesDialog dialog;
public SelectBlockPlugin(PluginTool tool) {
public SelectBytesPlugin(PluginTool tool) {
super(tool);
createActions();
}
@@ -68,7 +62,7 @@ public class SelectBlockPlugin extends Plugin {
private void createActions() {
toolBarAction = new NavigatableContextAction("SelectBlock", getName()) {
action = new NavigatableContextAction("SelectBytes", getName()) {
@Override
public void actionPerformed(NavigatableActionContext context) {
showDialog(context.getComponentProvider(), context.getNavigatable());
@@ -84,13 +78,13 @@ public class SelectBlockPlugin extends Plugin {
new MenuData(new String[] { ToolConstants.MENU_SELECTION, "Bytes..." }, null,
"Select Group 2");
menuData.setMenuSubGroup("1");
toolBarAction.setMenuBarData(menuData);
toolBarAction.addToWindowWhen(NavigatableActionContext.class);
action.setMenuBarData(menuData);
action.addToWindowWhen(NavigatableActionContext.class);
toolBarAction.setEnabled(false);
toolBarAction.setDescription("Allows user to select blocks of data.");
toolBarAction.setHelpLocation(new HelpLocation("SelectBlockPlugin", "Select_Block_Help"));
tool.addAction(toolBarAction);
action.setEnabled(false);
action.setDescription("Allows user to select bytes of data.");
action.setHelpLocation(new HelpLocation("SelectBytesPlugin", "Select_Bytes_Help"));
tool.addAction(action);
}
protected void updateNavigatable(ActionContext context) {
@@ -109,7 +103,7 @@ public class SelectBlockPlugin extends Plugin {
if (dialog != null) {
dialog.close();
}
dialog = new SelectBlockDialog(tool, navigatable);
dialog = new SelectBytesDialog(tool, navigatable);
dialog.show(provider);
}
@@ -45,7 +45,7 @@ import ghidra.util.task.TaskMonitor;
/**
* Test class to test the Select Bytes dialog.
*/
public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest {
public class SelectBytesPluginTest extends AbstractGhidraHeadedIntegrationTest {
private static final String SELECT_BYTES_BUTTON_NAME = "Select Bytes";
@@ -64,9 +64,9 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest {
configureTool(tool);
browser = env.getPlugin(CodeBrowserPlugin.class);
SelectBlockPlugin plugin = env.getPlugin(SelectBlockPlugin.class);
SelectBytesPlugin plugin = env.getPlugin(SelectBytesPlugin.class);
showDialogAction = (DockingActionIf) getInstanceField("toolBarAction", plugin);
showDialogAction = getAction(plugin, "SelectBytes");
}
@After
@@ -97,7 +97,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest {
toolToConfigure.addPlugin(NextPrevAddressPlugin.class.getName());
toolToConfigure.addPlugin(CodeBrowserPlugin.class.getName());
toolToConfigure.addPlugin(GoToAddressLabelPlugin.class.getName());
toolToConfigure.addPlugin(SelectBlockPlugin.class.getName());
toolToConfigure.addPlugin(SelectBytesPlugin.class.getName());
}
@Test
@@ -107,7 +107,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest {
openProgram();
assertTrue(showDialogAction.isEnabledForContext(getContext()));
SelectBlockDialog dialog = showDialog();
SelectBytesDialog dialog = showDialog();
closeProgram();
assertTrue(!showDialogAction.isEnabledForContext(getContext()));
@@ -117,7 +117,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testSelectAll() throws Exception {
openProgram();
SelectBlockDialog dialog = showDialog();
SelectBytesDialog dialog = showDialog();
pressSelectAll(dialog);
pressSelectBytes(dialog);
@@ -132,7 +132,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest {
openProgram();
goTo(addr(0x1006420));
SelectBlockDialog dialog = showDialog();
SelectBytesDialog dialog = showDialog();
pressSelectAll(dialog);
assertAddressFieldDisabled(dialog);
@@ -157,7 +157,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest {
openProgram();
goTo(addr(0x1006420));
SelectBlockDialog dialog = showDialog();
SelectBytesDialog dialog = showDialog();
pressSelectForward(dialog);
@@ -173,7 +173,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest {
openProgram();
goTo(addr(0x1006420));
SelectBlockDialog dialog = showDialog();
SelectBytesDialog dialog = showDialog();
pressSelectBackward(dialog);
@@ -192,7 +192,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest {
openProgram();
goTo(addr(0x1006420));
SelectBlockDialog dialog = showDialog();
SelectBytesDialog dialog = showDialog();
pressSelectToAddress(dialog);
@@ -216,7 +216,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest {
Address overlayEnd = block.getEnd();
goTo(overlayStart);
SelectBlockDialog dialog = showDialog();
SelectBytesDialog dialog = showDialog();
pressSelectForward(dialog);
@@ -241,7 +241,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest {
Address overlayEnd = block.getEnd();
goTo(overlayStart);
SelectBlockDialog dialog = showDialog();
SelectBytesDialog dialog = showDialog();
pressSelectForward(dialog);
@@ -266,7 +266,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest {
Address overlayEnd = block.getEnd();
goTo(overlayEnd);
SelectBlockDialog dialog = showDialog();
SelectBytesDialog dialog = showDialog();
pressSelectBackward(dialog);
@@ -291,7 +291,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest {
Address overlayEnd = block.getEnd();
goTo(overlayEnd);
SelectBlockDialog dialog = showDialog();
SelectBytesDialog dialog = showDialog();
pressSelectBackward(dialog);
@@ -311,7 +311,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest {
Address startAddress = addr(0x6420);
goTo(startAddress);
SelectBlockDialog dialog = showDialog();
SelectBytesDialog dialog = showDialog();
pressSelectAll(dialog);
@@ -381,14 +381,14 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest {
// Private Methods
//=================================================================================================
private void pressSelectToAddress(SelectBlockDialog dialog) {
private void pressSelectToAddress(SelectBytesDialog dialog) {
JRadioButton toButton = (JRadioButton) findComponentByName(dialog, "toButton");
pressButton(toButton, true);
}
private SelectBlockDialog showDialog() {
private SelectBytesDialog showDialog() {
performAction(showDialogAction, getContext(), true);
SelectBlockDialog dialog = waitForDialogComponent(SelectBlockDialog.class);
SelectBytesDialog dialog = waitForDialogComponent(SelectBytesDialog.class);
return dialog;
}
@@ -420,51 +420,49 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest {
}
}
private void pressSelectBackward(SelectBlockDialog dialog) {
private void pressSelectBackward(SelectBytesDialog dialog) {
JRadioButton backwardButton = (JRadioButton) findComponentByName(dialog, "backwardButton");
pressButton(backwardButton, true);
}
private void setAddress(SelectBlockDialog dialog, String text) {
private void setAddress(SelectBytesDialog dialog, String text) {
final JTextField addressInputField =
(JTextField) getInstanceField("toAddressField", dialog);
runSwing(() -> addressInputField.setText(text));
}
private void setLength(SelectBlockDialog dialog, int length) {
IntegerTextField inputField =
(IntegerTextField) getInstanceField("numberInputField", dialog);
runSwing(() -> inputField.setValue(length));
private void setLength(SelectBytesDialog dialog, int length) {
runSwing(() -> dialog.setLength(length));
}
private void pressSelectForward(SelectBlockDialog dialog) {
private void pressSelectForward(SelectBytesDialog dialog) {
JRadioButton forwardButton = (JRadioButton) findComponentByName(dialog, "forwardButton");
pressButton(forwardButton, true);
}
private void assertLengthFieldDisabled(SelectBlockDialog dialog) {
private void assertLengthFieldDisabled(SelectBytesDialog dialog) {
IntegerTextField inputField =
(IntegerTextField) getInstanceField("numberInputField", dialog);
(IntegerTextField) getInstanceField("lengthField", dialog);
assertFalse(inputField.getComponent().isEnabled());
}
private void assertLengthFieldEnabled(SelectBlockDialog dialog) {
private void assertLengthFieldEnabled(SelectBytesDialog dialog) {
IntegerTextField inputField =
(IntegerTextField) getInstanceField("numberInputField", dialog);
(IntegerTextField) getInstanceField("lengthField", dialog);
assertTrue(inputField.getComponent().isEnabled());
}
private void assertAddressFieldDisabled(SelectBlockDialog dialog) {
private void assertAddressFieldDisabled(SelectBytesDialog dialog) {
JTextField addressInputField = (JTextField) getInstanceField("toAddressField", dialog);
assertFalse(addressInputField.isEnabled());
}
private void assertAddressFieldEnabled(SelectBlockDialog dialog) {
private void assertAddressFieldEnabled(SelectBytesDialog dialog) {
JTextField addressInputField = (JTextField) getInstanceField("toAddressField", dialog);
assertTrue(addressInputField.isEnabled());
}
private void pressSelectAll(SelectBlockDialog dialog) {
private void pressSelectAll(SelectBytesDialog dialog) {
JRadioButton allButton = (JRadioButton) findComponentByName(dialog, "allButton");
pressButton(allButton, true);
}
@@ -477,7 +475,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest {
runSwing(() -> browser.getProvider().setSelection(null));
}
private void pressSelectBytes(final SelectBlockDialog dialog) {
private void pressSelectBytes(final SelectBytesDialog dialog) {
executeOnSwingWithoutBlocking(
() -> pressButtonByText(dialog, SELECT_BYTES_BUTTON_NAME, true));
@@ -399,7 +399,7 @@
<li><a href="help/topics/Charsets/Charsets.htm">Charsets</a></li>
<li><a href="help/topics/CodeBrowserPlugin/CodeBrowser.htm">Code Browser</a></li>
<li><a href="help/topics/Tool/Configure_Tool.htm">Configure Tool</a></li>
<li><a href="help/topics/SelectBlockPlugin/Select_Block_Help.html">Select Bytes</a></li>
<li><a href="help/topics/SelectBytesPlugin/Select_Bytes_Help.html">Select Bytes</a></li>
</ul>
<p></p>
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,24 +22,20 @@ import org.junit.Test;
import docking.DialogComponentProvider;
public class SelectBlockPluginScreenShots extends GhidraScreenShotGenerator {
public class SelectBytesPluginScreenShots extends GhidraScreenShotGenerator {
public SelectBlockPluginScreenShots() {
super();
}
@Test
public void testDialog() {
@Test
public void testDialog() {
performAction("SelectBlock", "SelectBlockPlugin", false);
performAction("SelectBytes", "SelectBytesPlugin", false);
captureDialog();
}
@Test
@Test
public void testToBadAddr() {
performAction("SelectBlock", "SelectBlockPlugin", false);
performAction("SelectBytes", "SelectBytesPlugin", false);
DialogComponentProvider dialog = getDialog();