Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-620 - Fixed stack trace caused by incorrect options usage

dragonmacherb5c7e7104c42
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/DataTypeListingHover.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/DataTypeListingHover.java
index ea3ea5e675..9705f14050 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/DataTypeListingHover.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/DataTypeListingHover.java
@@ -20,9 +20,8 @@ import javax.swing.JComponent;
import docking.widgets.fieldpanel.field.Field;
import docking.widgets.fieldpanel.support.FieldLocation;
import ghidra.GhidraOptions;
-import ghidra.app.plugin.core.hover.AbstractDataTypeHover;
+import ghidra.app.plugin.core.hover.AbstractConfigurableHover;
import ghidra.app.util.ToolTipUtils;
-import ghidra.framework.options.Options;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.address.Address;
import ghidra.program.model.data.*;
@@ -33,7 +32,7 @@ import ghidra.program.util.*;
import ghidra.util.HTMLUtilities;
import ghidra.util.UniversalID;
-public class DataTypeListingHover extends AbstractDataTypeHover implements ListingHoverService {
+public class DataTypeListingHover extends AbstractConfigurableHover implements ListingHoverService {
private static final String NAME = "Data Type Display";
private static final String DESCRIPTION =
@@ -41,23 +40,23 @@ public class DataTypeListingHover extends AbstractDataTypeHover implements Listi
"when the mouse hovers over a data type.";
private static final int PRIORITY = 20;
- ///////////////////////////////////////////////////////////
-
public DataTypeListingHover(PluginTool tool) {
super(tool, PRIORITY);
}
@Override
- public void initializeOptions() {
- options = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_POPUPS);
- options.registerOption(NAME, true, null, DESCRIPTION);
- setOptions(options, NAME);
- options.addOptionsChangeListener(this);
+ protected String getName() {
+ return NAME;
+ }
+
+ @Override
+ protected String getDescription() {
+ return DESCRIPTION;
}
@Override
- public void setOptions(Options options, String name) {
- enabled = options.getBoolean(NAME, true);
+ protected String getOptionsCategory() {
+ return GhidraOptions.CATEGORY_BROWSER_POPUPS;
}
@Override
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/FunctionNameListingHover.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/FunctionNameListingHover.java
index 536ab84a2e..1600a211b5 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/FunctionNameListingHover.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/FunctionNameListingHover.java
@@ -21,7 +21,6 @@ import docking.widgets.fieldpanel.field.Field;
import docking.widgets.fieldpanel.support.FieldLocation;
import ghidra.GhidraOptions;
import ghidra.app.plugin.core.hover.AbstractConfigurableHover;
-import ghidra.framework.options.Options;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.listing.*;
import ghidra.program.model.symbol.*;
@@ -43,25 +42,23 @@ public class FunctionNameListingHover extends AbstractConfigurableHover
"when displaying namespaces.";
private static final int PRIORITY = 20;
- ///////////////////////////////////////////////////////////
-
public FunctionNameListingHover(PluginTool tool) {
super(tool, PRIORITY);
}
@Override
- public void initializeOptions() {
- options = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_POPUPS);
- options.registerOption(NAME, true, null, DESCRIPTION);
- setOptions(options, NAME);
- options.addOptionsChangeListener(this);
+ protected String getName() {
+ return NAME;
}
@Override
- public void setOptions(Options options, String optionName) {
- if (optionName.equals(NAME)) {
- enabled = options.getBoolean(NAME, true);
- }
+ protected String getDescription() {
+ return DESCRIPTION;
+ }
+
+ @Override
+ protected String getOptionsCategory() {
+ return GhidraOptions.CATEGORY_BROWSER_POPUPS;
}
@Override
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/ProgramAddressRelationshipListingHover.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/ProgramAddressRelationshipListingHover.java
index 55c1bb5815..2a4a22ac0d 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/ProgramAddressRelationshipListingHover.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/ProgramAddressRelationshipListingHover.java
@@ -23,7 +23,6 @@ import docking.widgets.fieldpanel.field.Field;
import docking.widgets.fieldpanel.support.FieldLocation;
import ghidra.GhidraOptions;
import ghidra.app.plugin.core.hover.AbstractConfigurableHover;
-import ghidra.framework.options.Options;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.database.mem.AddressSourceInfo;
import ghidra.program.model.address.*;
@@ -59,18 +58,18 @@ public class ProgramAddressRelationshipListingHover extends AbstractConfigurable
}
@Override
- public void initializeOptions() {
- options = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_POPUPS);
- options.registerOption(NAME, true, null, DESCRIPTION);
- setOptions(options, NAME);
- options.addOptionsChangeListener(this);
+ protected String getName() {
+ return NAME;
}
@Override
- public void setOptions(Options options, String optionName) {
- if (optionName.equals(NAME)) {
- enabled = options.getBoolean(NAME, true);
- }
+ protected String getDescription() {
+ return DESCRIPTION;
+ }
+
+ @Override
+ protected String getOptionsCategory() {
+ return GhidraOptions.CATEGORY_BROWSER_POPUPS;
}
@Override
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/ReferenceListingHover.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/ReferenceListingHover.java
index 5d2579495b..ca6a3bddee 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/ReferenceListingHover.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/ReferenceListingHover.java
@@ -18,14 +18,11 @@ package ghidra.app.plugin.core.codebrowser.hover;
import ghidra.GhidraOptions;
import ghidra.app.plugin.core.hover.AbstractReferenceHover;
import ghidra.app.services.CodeFormatService;
-import ghidra.app.util.HelpTopics;
-import ghidra.framework.options.Options;
import ghidra.framework.plugintool.PluginTool;
-import ghidra.util.HelpLocation;
public class ReferenceListingHover extends AbstractReferenceHover implements ListingHoverService {
- protected static final String NAME = "Reference Code Viewer";
+ private static final String NAME = "Reference Code Viewer";
private static final String DESCRIPTION =
"Shows \"referred to\" code and data within the listing.";
@@ -41,23 +38,18 @@ public class ReferenceListingHover extends AbstractReferenceHover implements Lis
}
@Override
- public void initializeOptions() {
- options = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_POPUPS);
-
- options.setOptionsHelpLocation(new HelpLocation(HelpTopics.CODE_BROWSER, "MouseHover"));
- HelpLocation help = new HelpLocation(HelpTopics.CODE_BROWSER, "ReferenceHover");
- options.getOptions(NAME).setOptionsHelpLocation(help);
-
- options.registerOption(NAME, true, help, DESCRIPTION);
-
- options.registerOption(NAME + Options.DELIMITER + "Dialog Height", 400, help,
- "Height of the popup window");
- options.registerOption(NAME + Options.DELIMITER + "Dialog Width", 600, help,
- "Width of the popup window");
+ protected String getName() {
+ return NAME;
+ }
- setOptions(options, NAME);
- options.addOptionsChangeListener(this);
+ @Override
+ protected String getDescription() {
+ return DESCRIPTION;
}
+ @Override
+ protected String getOptionsCategory() {
+ return GhidraOptions.CATEGORY_BROWSER_POPUPS;
+ }
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/ScalarOperandListingHover.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/ScalarOperandListingHover.java
index 5d4575d1e0..edd40669e5 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/ScalarOperandListingHover.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/ScalarOperandListingHover.java
@@ -23,7 +23,6 @@ import docking.widgets.fieldpanel.field.Field;
import docking.widgets.fieldpanel.support.FieldLocation;
import ghidra.GhidraOptions;
import ghidra.app.plugin.core.hover.AbstractScalarOperandHover;
-import ghidra.framework.options.Options;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.address.Address;
import ghidra.program.model.lang.InstructionPrototype;
@@ -47,18 +46,18 @@ public class ScalarOperandListingHover extends AbstractScalarOperandHover
}
@Override
- public void initializeOptions() {
- options = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_POPUPS);
- options.registerOption(NAME, true, null, DESCRIPTION);
- setOptions(options, NAME);
- options.addOptionsChangeListener(this);
+ protected String getName() {
+ return NAME;
}
@Override
- public void setOptions(Options options, String optionName) {
- if (optionName.equals(NAME)) {
- enabled = options.getBoolean(NAME, true);
- }
+ protected String getDescription() {
+ return DESCRIPTION;
+ }
+
+ @Override
+ protected String getOptionsCategory() {
+ return GhidraOptions.CATEGORY_BROWSER_POPUPS;
}
@Override
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/TruncatedTextListingHover.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/TruncatedTextListingHover.java
index 48ec9d0452..2ed7e9921f 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/TruncatedTextListingHover.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/TruncatedTextListingHover.java
@@ -21,15 +21,12 @@ import javax.swing.JToolTip;
import docking.widgets.fieldpanel.field.Field;
import docking.widgets.fieldpanel.support.FieldLocation;
import ghidra.GhidraOptions;
-import ghidra.app.plugin.core.hover.AbstractTruncatedTextHover;
-import ghidra.app.util.HelpTopics;
+import ghidra.app.plugin.core.hover.AbstractConfigurableHover;
import ghidra.app.util.viewer.field.ListingTextField;
-import ghidra.framework.options.Options;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.listing.Program;
import ghidra.program.util.ProgramLocation;
import ghidra.util.HTMLUtilities;
-import ghidra.util.HelpLocation;
/**
* A hover service to show tool tip text for hovering over a truncated field, containing a "...",
@@ -38,18 +35,34 @@ import ghidra.util.HelpLocation;
* This provides the hover capability for the TruncatedTextHoverPlugin and can
* also be used to directly provide this hover capability to a listing.
*/
-public class TruncatedTextListingHover extends AbstractTruncatedTextHover
+public class TruncatedTextListingHover extends AbstractConfigurableHover
implements ListingHoverService {
private static final String NAME = "Truncated Text Display";
+ private static final String DESCRIPTION =
+ "Toggle whether truncated text is displayed in a tooltip " +
+ "when the mouse hovers over a field that is truncated.";
private static final int POPUP_PRIORITY = 10;
- ///////////////////////////////////////////////////////////
-
public TruncatedTextListingHover(PluginTool tool) {
super(tool, POPUP_PRIORITY);
}
+ @Override
+ protected String getName() {
+ return NAME;
+ }
+
+ @Override
+ protected String getDescription() {
+ return DESCRIPTION;
+ }
+
+ @Override
+ protected String getOptionsCategory() {
+ return GhidraOptions.CATEGORY_BROWSER_POPUPS;
+ }
+
@Override
public JComponent getHoverComponent(Program program, ProgramLocation programLocation,
FieldLocation fieldLocation, Field field) {
@@ -68,21 +81,4 @@ public class TruncatedTextListingHover extends AbstractTruncatedTextHover
return null;
}
-
- @Override
- public void initializeOptions() {
- options = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_POPUPS);
- options.setOptionsHelpLocation(new HelpLocation(HelpTopics.CODE_BROWSER, "MouseHover"));
- options.registerOption(NAME, true,
- new HelpLocation(HelpTopics.CODE_BROWSER, "TruncatedTextPopup"),
- "Toggle whether truncated text is displayed in a tooltip " +
- "when the mouse hovers over a field that is truncated.");
- setOptions(options, NAME);
- options.addOptionsChangeListener(this);
- }
-
- @Override
- public void setOptions(Options options, String name) {
- enabled = options.getBoolean(NAME, true);
- }
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/hover/AbstractConfigurableHover.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/hover/AbstractConfigurableHover.java
index 436e07f7e1..b4fb6e390e 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/hover/AbstractConfigurableHover.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/hover/AbstractConfigurableHover.java
@@ -15,13 +15,15 @@
*/
package ghidra.app.plugin.core.hover;
-import ghidra.framework.options.ToolOptions;
+import ghidra.framework.options.*;
import ghidra.framework.plugintool.PluginTool;
+import ghidra.util.Disposable;
/**
* A listing or decompiler hover that employs some degree of configurability.
*/
-public abstract class AbstractConfigurableHover extends AbstractHover implements ConfigurableHover {
+public abstract class AbstractConfigurableHover extends AbstractHover
+ implements Disposable, OptionsChangeListener {
protected ToolOptions options;
@@ -30,6 +32,12 @@ public abstract class AbstractConfigurableHover extends AbstractHover implements
initializeOptions();
}
+ protected abstract String getName();
+
+ protected abstract String getDescription();
+
+ protected abstract String getOptionsCategory();
+
@Override
public void dispose() {
if (options != null) {
@@ -39,8 +47,24 @@ public abstract class AbstractConfigurableHover extends AbstractHover implements
}
@Override
- public void optionsChanged(ToolOptions theOptions, String optionName, Object oldValue, Object newValue) {
+ public void optionsChanged(ToolOptions theOptions, String optionName, Object oldValue,
+ Object newValue) {
setOptions(theOptions, optionName);
}
+ public void initializeOptions() {
+ options = tool.getOptions(getOptionsCategory());
+
+ String hoverName = getName();
+ options.registerOption(hoverName, true, null, getDescription());
+ setOptions(options, hoverName);
+ options.addOptionsChangeListener(this);
+ }
+
+ public void setOptions(Options options, String optionName) {
+ String hoverName = getName();
+ if (optionName.equals(hoverName)) {
+ enabled = options.getBoolean(hoverName, true);
+ }
+ }
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/hover/AbstractDataTypeHover.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/hover/AbstractDataTypeHover.java
deleted file mode 100644
index 37c62ca0f6..0000000000
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/hover/AbstractDataTypeHover.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* ###
- * IP: GHIDRA
- *
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package ghidra.app.plugin.core.hover;
-
-import ghidra.framework.plugintool.PluginTool;
-
-/**
- * A hover service to show tool tip text for hovering over data types.
- * The tooltip shows a preview of the data type.
- * This provides the hover capability for the DataTypeHoverPlugin and can
- * also be used to directly provide this hover capability to a listing.
- */
-public abstract class AbstractDataTypeHover extends AbstractConfigurableHover {
-
- public AbstractDataTypeHover(PluginTool tool, int priority) {
- super(tool, priority);
- }
-
-}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/hover/AbstractReferenceHover.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/hover/AbstractReferenceHover.java
index ee2335e0c1..54f9c71394 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/hover/AbstractReferenceHover.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/hover/AbstractReferenceHover.java
@@ -15,7 +15,7 @@
*/
package ghidra.app.plugin.core.hover;
-import static ghidra.util.HTMLUtilities.HTML;
+import static ghidra.util.HTMLUtilities.*;
import java.awt.*;
@@ -35,6 +35,7 @@ import ghidra.program.model.listing.*;
import ghidra.program.model.symbol.*;
import ghidra.program.util.*;
import ghidra.util.HTMLUtilities;
+import ghidra.util.HelpLocation;
import ghidra.util.bean.opteditor.OptionsVetoException;
/**
@@ -42,15 +43,14 @@ import ghidra.util.bean.opteditor.OptionsVetoException;
*/
public abstract class AbstractReferenceHover extends AbstractConfigurableHover {
- public static final int WINDOW_OFFSET = 50;
+ private static final int WINDOW_OFFSET = 50;
+ private static final Color BACKGROUND_COLOR = new Color(255, 255, 230);
- protected static final Color BACKGROUND_COLOR = new Color(255, 255, 230);
-
- protected CodeFormatService codeFormatService;
- protected ListingPanel panel;
- protected JToolTip toolTip;
- protected ProgramLocation previewLocation;
- protected GoToHelper gotoHelper;
+ private CodeFormatService codeFormatService;
+ private ListingPanel panel;
+ private JToolTip toolTip;
+ private ProgramLocation previewLocation;
+ private GoToHelper gotoHelper;
public AbstractReferenceHover(PluginTool tool, int priority) {
this(tool, null, priority);
@@ -82,23 +82,55 @@ public abstract class AbstractReferenceHover extends AbstractConfigurableHover {
}
@Override
- public void setOptions(Options options, String name) {
- enabled = options.getBoolean(name, true);
- int dialogWidth = options.getInt(name + Options.DELIMITER + "Dialog Width", 600);
- if (dialogWidth <= 0) {
- throw new OptionsVetoException(
- "Reference Code Viewer Dialog Width must be greater than 0");
- }
+ public void initializeOptions() {
+
+ options = tool.getOptions(getOptionsCategory());
+
+ options.setOptionsHelpLocation(new HelpLocation(HelpTopics.CODE_BROWSER, "MouseHover"));
+ HelpLocation help = new HelpLocation(HelpTopics.CODE_BROWSER, "ReferenceHover");
+
+ String hoverName = getName();
+ options.getOptions(hoverName).setOptionsHelpLocation(help);
+ options.registerOption(hoverName, true, null, getDescription());
- int dialogHeight = options.getInt(name + Options.DELIMITER + "Dialog Height", 400);
- if (dialogHeight <= 0) {
- throw new OptionsVetoException(
- "Reference Code Viewer Dialog Height must be greater than 0");
+ options.registerOption(hoverName + Options.DELIMITER + "Dialog Height", 400, help,
+ "Height of the popup window");
+ options.registerOption(hoverName + Options.DELIMITER + "Dialog Width", 600, help,
+ "Width of the popup window");
+
+ setOptions(options, hoverName);
+ options.addOptionsChangeListener(this);
+ }
+
+ @Override
+ public void setOptions(Options options, String optionName) {
+
+ String hoverName = getName();
+ if (optionName.equals(hoverName)) {
+ enabled = options.getBoolean(hoverName, true);
+ return;
}
- Dimension d = new Dimension(dialogWidth, dialogHeight);
- if (panel != null) {
- panel.setPreferredSize(d);
+ String widthOptionName = optionName + Options.DELIMITER + "Dialog Width";
+ String heightOptionName = optionName + Options.DELIMITER + "Dialog Height";
+
+ if (optionName.equals(widthOptionName) ||
+ optionName.equals(heightOptionName)) {
+ int dialogWidth = options.getInt(widthOptionName, 600);
+ if (dialogWidth <= 0) {
+ throw new OptionsVetoException(
+ "Reference Code Viewer Dialog Width must be greater than 0");
+ }
+ int dialogHeight = options.getInt(heightOptionName, 400);
+ if (dialogHeight <= 0) {
+ throw new OptionsVetoException(
+ "Reference Code Viewer Dialog Height must be greater than 0");
+ }
+
+ Dimension d = new Dimension(dialogWidth, dialogHeight);
+ if (panel != null) {
+ panel.setPreferredSize(d);
+ }
}
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/hover/AbstractScalarOperandHover.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/hover/AbstractScalarOperandHover.java
index 8fd28fc1f3..40ad9230ec 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/hover/AbstractScalarOperandHover.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/hover/AbstractScalarOperandHover.java
@@ -131,14 +131,14 @@ public abstract class AbstractScalarOperandHover extends AbstractConfigurableHov
if (localHTMLText.length() > 0) {
htmlText.append("<hr>");
htmlText.append("<table width=\"100%\">") //
- .append(localHTMLText) //
- .append("</table>");
+ .append(localHTMLText) //
+ .append("</table>");
}
}
private String appendCharDataTypeFormattedHTML(String prevCharVal, DataType charDt,
ByteMemBufferImpl charMemBuffer, StringBuilder htmlText) {
- // appends a HTML table row to the stringbuilder with the scalar displayed as the
+ // appends a HTML table row to the string builder with the scalar displayed as the
// specified data type, only if its a value that hasn't already been added to the buffer.
if (charMemBuffer.getLength() >= charDt.getLength()) {
@@ -155,11 +155,11 @@ public abstract class AbstractScalarOperandHover extends AbstractConfigurableHov
|| hasEncodingError(charVal);
if (!shouldSkip) {
htmlText.append("<tr><td>") //
- .append(charDt.getName()) //
- .append(isArray ? "[]" : "");
+ .append(charDt.getName()) //
+ .append(isArray ? "[]" : "");
htmlText.append("</td><td>") //
- .append(HTMLUtilities.friendlyEncodeHTML(charRep)) //
- .append("</td></tr>");
+ .append(HTMLUtilities.friendlyEncodeHTML(charRep)) //
+ .append("</td></tr>");
prevCharVal = charVal;
}
}
@@ -213,8 +213,9 @@ public abstract class AbstractScalarOperandHover extends AbstractConfigurableHov
}
private boolean hasEncodingError(String s) {
- return s.codePoints().anyMatch(
- codePoint -> codePoint == StringUtilities.UNICODE_REPLACEMENT);
+ return s.codePoints()
+ .anyMatch(
+ codePoint -> codePoint == StringUtilities.UNICODE_REPLACEMENT);
}
private ByteMemBufferImpl getScalarOperandAsMemBuffer(Address addr, Scalar scalar,
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/hover/AbstractTruncatedTextHover.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/hover/AbstractTruncatedTextHover.java
deleted file mode 100644
index 0f17417040..0000000000
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/hover/AbstractTruncatedTextHover.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* ###
- * IP: GHIDRA
- *
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package ghidra.app.plugin.core.hover;
-
-import ghidra.framework.plugintool.PluginTool;
-
-public abstract class AbstractTruncatedTextHover extends AbstractConfigurableHover {
-
- public AbstractTruncatedTextHover(PluginTool tool, int priority) {
- super(tool, priority);
- }
-}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/hover/ConfigurableHover.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/hover/ConfigurableHover.java
deleted file mode 100644
index 940010d902..0000000000
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/hover/ConfigurableHover.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/* ###
- * IP: GHIDRA
- *
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package ghidra.app.plugin.core.hover;
-
-import ghidra.framework.options.Options;
-import ghidra.framework.options.OptionsChangeListener;
-import ghidra.util.Disposable;
-
-public interface ConfigurableHover extends OptionsChangeListener, Disposable {
-
- public void initializeOptions();
-
- public void setOptions(Options options, String optionName);
-
-}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/hover/DataTypeDecompilerHover.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/hover/DataTypeDecompilerHover.java
index 93e5a5e4b5..4dd0896557 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/hover/DataTypeDecompilerHover.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/hover/DataTypeDecompilerHover.java
@@ -22,9 +22,8 @@ import docking.widgets.fieldpanel.support.FieldLocation;
import ghidra.GhidraOptions;
import ghidra.app.decompiler.*;
import ghidra.app.decompiler.component.ClangTextField;
-import ghidra.app.plugin.core.hover.AbstractDataTypeHover;
+import ghidra.app.plugin.core.hover.AbstractConfigurableHover;
import ghidra.app.util.ToolTipUtils;
-import ghidra.framework.options.Options;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.data.DataType;
import ghidra.program.model.listing.Program;
@@ -32,7 +31,7 @@ import ghidra.program.model.pcode.HighVariable;
import ghidra.program.model.pcode.Varnode;
import ghidra.program.util.ProgramLocation;
-public class DataTypeDecompilerHover extends AbstractDataTypeHover
+public class DataTypeDecompilerHover extends AbstractConfigurableHover
implements DecompilerHoverService {
private static final String NAME = "Data Type Display";
@@ -45,18 +44,18 @@ public class DataTypeDecompilerHover extends AbstractDataTypeHover
}
@Override
- public void initializeOptions() {
- options = tool.getOptions(GhidraOptions.CATEGORY_DECOMPILER_POPUPS);
- options.registerOption(NAME, true, null, DESCRIPTION);
- setOptions(options, NAME);
- options.addOptionsChangeListener(this);
+ protected String getName() {
+ return NAME;
}
@Override
- public void setOptions(Options options, String optionName) {
- if (optionName.equals(NAME)) {
- enabled = options.getBoolean(NAME, true);
- }
+ protected String getDescription() {
+ return DESCRIPTION;
+ }
+
+ @Override
+ protected String getOptionsCategory() {
+ return GhidraOptions.CATEGORY_DECOMPILER_POPUPS;
}
@Override
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/hover/FunctionSignatureDecompilerHover.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/hover/FunctionSignatureDecompilerHover.java
index 3ab693a3a6..5c0872040b 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/hover/FunctionSignatureDecompilerHover.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/hover/FunctionSignatureDecompilerHover.java
@@ -26,7 +26,6 @@ import ghidra.app.decompiler.*;
import ghidra.app.decompiler.component.ClangTextField;
import ghidra.app.plugin.core.hover.AbstractConfigurableHover;
import ghidra.app.util.ToolTipUtils;
-import ghidra.framework.options.Options;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.address.*;
import ghidra.program.model.data.AbstractIntegerDataType;
@@ -55,18 +54,18 @@ public class FunctionSignatureDecompilerHover extends AbstractConfigurableHover
}
@Override
- public void initializeOptions() {
- options = tool.getOptions(GhidraOptions.CATEGORY_DECOMPILER_POPUPS);
- options.registerOption(NAME, true, null, DESCRIPTION);
- setOptions(options, NAME);
- options.addOptionsChangeListener(this);
+ protected String getName() {
+ return NAME;
}
@Override
- public void setOptions(Options options, String optionName) {
- if (optionName.equals(NAME)) {
- enabled = options.getBoolean(NAME, true);
- }
+ protected String getDescription() {
+ return DESCRIPTION;
+ }
+
+ @Override
+ protected String getOptionsCategory() {
+ return GhidraOptions.CATEGORY_DECOMPILER_POPUPS;
}
@Override
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/hover/ReferenceDecompilerHover.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/hover/ReferenceDecompilerHover.java
index ef33798b13..830be23ddf 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/hover/ReferenceDecompilerHover.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/hover/ReferenceDecompilerHover.java
@@ -21,20 +21,16 @@ import docking.widgets.fieldpanel.field.Field;
import docking.widgets.fieldpanel.support.FieldLocation;
import ghidra.GhidraOptions;
import ghidra.app.plugin.core.hover.AbstractReferenceHover;
-import ghidra.app.util.HelpTopics;
-import ghidra.framework.options.Options;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.Function;
import ghidra.program.model.listing.Program;
import ghidra.program.util.ProgramLocation;
-import ghidra.util.HelpLocation;
public class ReferenceDecompilerHover extends AbstractReferenceHover
implements DecompilerHoverService {
- protected static final String NAME = "Decompiler Reference Viewer";
-
+ private static final String NAME = "Decompiler Reference Viewer";
private static final String DESCRIPTION =
"Shows \"referred to\" code and data from the decompiler.";
@@ -45,22 +41,18 @@ public class ReferenceDecompilerHover extends AbstractReferenceHover
}
@Override
- public void initializeOptions() {
- options = tool.getOptions(GhidraOptions.CATEGORY_DECOMPILER_POPUPS);
-
- options.setOptionsHelpLocation(new HelpLocation(HelpTopics.CODE_BROWSER, "MouseHover"));
- HelpLocation help = new HelpLocation(HelpTopics.CODE_BROWSER, "ReferenceHover");
- options.getOptions(NAME).setOptionsHelpLocation(help);
-
- options.registerOption(NAME, true, null, DESCRIPTION);
+ protected String getName() {
+ return NAME;
+ }
- options.registerOption(NAME + Options.DELIMITER + "Dialog Height", 400, help,
- "Height of the popup window");
- options.registerOption(NAME + Options.DELIMITER + "Dialog Width", 600, help,
- "Width of the popup window");
+ @Override
+ protected String getDescription() {
+ return DESCRIPTION;
+ }
- setOptions(options, NAME);
- options.addOptionsChangeListener(this);
+ @Override
+ protected String getOptionsCategory() {
+ return GhidraOptions.CATEGORY_DECOMPILER_POPUPS;
}
@Override
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/hover/ScalarValueDecompilerHover.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/hover/ScalarValueDecompilerHover.java
index 501aee4dc2..e36a659af8 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/hover/ScalarValueDecompilerHover.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/hover/ScalarValueDecompilerHover.java
@@ -24,7 +24,6 @@ import ghidra.app.decompiler.ClangToken;
import ghidra.app.decompiler.ClangVariableToken;
import ghidra.app.decompiler.component.ClangTextField;
import ghidra.app.plugin.core.hover.AbstractScalarOperandHover;
-import ghidra.framework.options.Options;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.address.Address;
import ghidra.program.model.data.AbstractIntegerDataType;
@@ -39,8 +38,8 @@ public class ScalarValueDecompilerHover extends AbstractScalarOperandHover
private static final int PRIORITY = 20;
- protected static final String NAME = "Scalar Operand Display";
- protected static final String DESCRIPTION =
+ private static final String NAME = "Scalar Operand Display";
+ private static final String DESCRIPTION =
"Scalars are shown as 1-, 2-, 4-, and 8-byte values, each in decimal, hexadecimal, and " +
"as ASCII character sequences.";
@@ -49,18 +48,18 @@ public class ScalarValueDecompilerHover extends AbstractScalarOperandHover
}
@Override
- public void initializeOptions() {
- options = tool.getOptions(GhidraOptions.CATEGORY_DECOMPILER_POPUPS);
- options.registerOption(NAME, true, null, DESCRIPTION);
- setOptions(options, NAME);
- options.addOptionsChangeListener(this);
+ protected String getName() {
+ return NAME;
}
@Override
- public void setOptions(Options options, String optionName) {
- if (optionName.equals(NAME)) {
- enabled = options.getBoolean(NAME, true);
- }
+ protected String getDescription() {
+ return DESCRIPTION;
+ }
+
+ @Override
+ protected String getOptionsCategory() {
+ return GhidraOptions.CATEGORY_DECOMPILER_POPUPS;
}
@Override