Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-4478: More review changes GP-4478: Review changes GP-4478 Add help to assembler Add help to assembler Initial commit

ghidranoob6096a500424c
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/assembler/AssemblyDualTextField.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/assembler/AssemblyDualTextField.java
index 876ff130fc..6c4366e019 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/assembler/AssemblyDualTextField.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/assembler/AssemblyDualTextField.java
@@ -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.
@@ -46,8 +46,8 @@ import ghidra.program.model.address.Address;
import ghidra.program.model.lang.*;
import ghidra.program.model.listing.*;
import ghidra.program.model.mem.ByteMemBufferImpl;
-import ghidra.util.Msg;
-import ghidra.util.NumericUtilities;
+import ghidra.util.*;
+import help.Help;
/**
* A pair of text fields suitable for guided assembly
@@ -69,7 +69,7 @@ public class AssemblyDualTextField {
private static final String FONT_ID = "font.plugin.assembly.dual.text.field";
private static final Color FG_PREFERENCE_MOST =
new GColor("color.fg.plugin.assembler.completion.most");
- private static final Color FG_PREFERENCE_MIDDLE =
+ private static final Color FG_PREFERENCE_MIDDLE =
new GColor("color.fg.plugin.assembler.completion.middle");
private static final Color FG_PREFERENCE_LEAST =
new GColor("color.fg.plugin.assembler.completion.least");
@@ -402,13 +402,14 @@ public class AssemblyDualTextField {
private static final String CMD_ZERO = "Zero undefined bits";
private JLabel hints;
+ private EmptyBorderToggleButton button;
@Override
protected void addContent(JPanel content) {
JPanel panel = new JPanel(new BorderLayout());
Box controls = Box.createHorizontalBox();
Icon icon = new GIcon("icon.plugin.assembler.question");
- EmptyBorderToggleButton button = new EmptyBorderToggleButton(icon);
+ button = new EmptyBorderToggleButton(icon);
button.setToolTipText("Exhaust unspecified bits, otherwise zero them");
button.addActionListener((e) -> {
exhaustUndefined = CMD_EXHAUST.equals(e.getActionCommand());
@@ -426,8 +427,9 @@ public class AssemblyDualTextField {
hints = new JLabel();
panel.add(hints);
content.add(panel, BorderLayout.SOUTH);
-
+
addAutocompletionListener(this);
+
}
@Override
@@ -632,6 +634,15 @@ public class AssemblyDualTextField {
public JTextField getOperandsField() {
return operands;
}
+
+ /**
+ * Get the button that toggles bit exhaustion
+ *
+ * @return the button
+ */
+ public JButton getExhaustButton() {
+ return auto.button;
+ }
/**
* For single mode: Get the text field containing the full assembly text
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/assembler/PatchInstructionAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/assembler/PatchInstructionAction.java
index 058c4e19d1..9a364299ab 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/assembler/PatchInstructionAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/assembler/PatchInstructionAction.java
@@ -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.
@@ -47,6 +47,7 @@ import ghidra.util.HelpLocation;
import ghidra.util.Msg;
import ghidra.util.task.CachingSwingWorker;
import ghidra.util.task.TaskMonitor;
+import help.Help;
/**
* A context menu action to assemble an instruction at the current address
@@ -145,14 +146,19 @@ public class PatchInstructionAction extends AbstractPatchAction {
setPopupMenuData(new MenuData(new String[] { name }, MENU_GROUP));
setKeyBindingData(new KeyBindingData(KEYBIND_PATCH_INSTRUCTION));
- setHelpLocation(new HelpLocation(owner.getName(), "patch_instruction"));
+ HelpLocation location = new HelpLocation(owner.getName(), "patch_instruction");
+ setHelpLocation(location);
input.getMnemonicField().setBorder(BorderFactory.createLineBorder(Colors.ERROR, 2));
input.getOperandsField().setBorder(BorderFactory.createLineBorder(Colors.ERROR, 2));
input.getAssemblyField().setBorder(BorderFactory.createLineBorder(Colors.ERROR, 2));
input.getAutocompleter().addAutocompletionListener(listenerForAccept);
-
+
+ Help.getHelpService().registerHelp(input.getMnemonicField(), location);
+ Help.getHelpService().registerHelp(input.getOperandsField(), location);
+ Help.getHelpService().registerHelp(input.getExhaustButton(), location);
+
init();
}