mirror of
https://github.com/NationalSecurityAgency/ghidra
synced 2024-09-18 01:31:53 +00:00
Merge remote-tracking branch
'origin/GT-3619_ghidorahrex_pattern_search_edit_bytes' Fixes #1675
This commit is contained in:
commit
1df6fa79da
|
@ -128,6 +128,7 @@ public class InsertBytesWidget extends DialogComponentProvider implements KeyLis
|
|||
@Override
|
||||
protected void dialogShown() {
|
||||
populateDialog();
|
||||
toFront();
|
||||
}
|
||||
|
||||
/*********************************************************************************************
|
||||
|
@ -142,7 +143,7 @@ public class InsertBytesWidget extends DialogComponentProvider implements KeyLis
|
|||
protected JPanel createWorkPanel() {
|
||||
|
||||
JPanel contentPanel = new JPanel();
|
||||
contentPanel.setMinimumSize(new Dimension(300, 150));
|
||||
contentPanel.setMinimumSize(new Dimension(500, 300));
|
||||
|
||||
// Create the input text widget and give it a scrollbar.
|
||||
inputBytesTA = new HintTextAreaIS(HINT_TEXT);
|
||||
|
@ -210,7 +211,6 @@ public class InsertBytesWidget extends DialogComponentProvider implements KeyLis
|
|||
// clicking the appropriate button.
|
||||
inputBytesTA.setText(sb.toString());
|
||||
selectionModeWidget.setInputMode(InputMode.BINARY);
|
||||
selectionModeWidget.hexRB.doClick();
|
||||
|
||||
inputBytesTA.setSelectionStart(0);
|
||||
inputBytesTA.setSelectionEnd(inputBytesTA.getText().length());
|
||||
|
@ -470,6 +470,20 @@ public class InsertBytesWidget extends DialogComponentProvider implements KeyLis
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flags the given string as invalid input
|
||||
*
|
||||
*/
|
||||
public void setInputInvalid() {
|
||||
inputBytesTA.setError();
|
||||
if (selectionModeWidget.getInputMode() == InputMode.BINARY) {
|
||||
errorMsg = ERROR_MSG_BINARY_INPUT;
|
||||
}
|
||||
else {
|
||||
errorMsg = ERROR_MSG_HEX_INPUT;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
// Do nothing.
|
||||
|
|
|
@ -24,6 +24,7 @@ import javax.swing.*;
|
|||
|
||||
import docking.widgets.button.GRadioButton;
|
||||
import ghidra.app.plugin.core.instructionsearch.util.InstructionSearchUtils;
|
||||
import ghidra.util.Msg;
|
||||
|
||||
/**
|
||||
* Allows the user to specify whether the input mode is BINARY or HEX for the {@link InsertBytesWidget}.
|
||||
|
@ -78,16 +79,10 @@ public class SelectionModeWidget extends ControlPanelWidget {
|
|||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
// If input is invalid, just exit.
|
||||
if (!parent.validateInput()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we're already in hex, do nothing.
|
||||
if (inputMode == InputMode.HEX) {
|
||||
return;
|
||||
}
|
||||
|
||||
inputMode = InputMode.HEX;
|
||||
|
||||
// CONVERSION
|
||||
|
@ -102,7 +97,7 @@ public class SelectionModeWidget extends ControlPanelWidget {
|
|||
groups = InstructionSearchUtils.getGroupSizes(parent.getInputString().trim(),
|
||||
InputMode.BINARY);
|
||||
|
||||
// Now convert whatever is in the input box to binary.
|
||||
// Now convert whatever is in the input box to hex.
|
||||
String hexStr =
|
||||
InstructionSearchUtils.toHex(parent.getInputString().trim(), true);
|
||||
|
||||
|
@ -114,8 +109,11 @@ public class SelectionModeWidget extends ControlPanelWidget {
|
|||
parent.setInputString(hexStr);
|
||||
parent.validateInput();
|
||||
}
|
||||
catch (NumberFormatException e2) {
|
||||
parent.setInputInvalid();
|
||||
}
|
||||
catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
Msg.error(this, e1.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,11 +124,6 @@ public class SelectionModeWidget extends ControlPanelWidget {
|
|||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
// If input is invalid, just exit.
|
||||
if (!parent.validateInput()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we're already in binary, do nothing.
|
||||
if (inputMode == InputMode.BINARY) {
|
||||
return;
|
||||
|
@ -161,8 +154,11 @@ public class SelectionModeWidget extends ControlPanelWidget {
|
|||
parent.setInputString(binaryStr);
|
||||
parent.validateInput();
|
||||
}
|
||||
catch (NumberFormatException e2) {
|
||||
parent.setInputInvalid();
|
||||
}
|
||||
catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
Msg.error(this, e1.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue