+
+ Use Encoded Anonymous Namespace -
+ This output option is used to create a more unique namespace node from the
+ standard output for anonymous namespaces, thus helping to prevent collisions
+ between multiple types of the same name, but each in their own unique anonymous
+ namespace. When turned on, variations of the standard namespace
+ `anonymous namespace' will be replaced with a more specific namespace of
+ the form _anon_ABCD1234 where the hexadecimal number comes from a number
+ encoded in the mangled string. The trade-off is that when this option is turned on,
+ the resultant namespace will not match non-mangled names that have the standard,
+ non-specific anonymous namespace.
+
+
+
+
+
+ Apply Argument UDT Tags -
+ This output option controls whether user-defined type tags (e.g., class, enum,
+ struct, union) are placed in front of the named type when the type is used as a
+ template or function argument. When turned on, the demangled string matches the
+ common demangler standard. When turned off, the standard demangled strings of
+ struct AAA<class BBB> and struct AAA<struct BBB> would
+ both be reduced to struct AAA<BBB>.
+
+
+
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/demangler/DemanglerOptions.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/demangler/DemanglerOptions.java
index 101153f5b7..4c696baad2 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/demangler/DemanglerOptions.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/demangler/DemanglerOptions.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.
@@ -15,15 +15,17 @@
*/
package ghidra.app.util.demangler;
+import generic.json.Json;
+
/**
* A simple class to contain the various settings for demangling
*/
public class DemanglerOptions {
- private boolean applyCallingConvention = true;
- private boolean applySignature = true;
- private boolean doDisassembly = true;
- private boolean demangleOnlyKnownPatterns = true;
+ protected boolean applyCallingConvention = true;
+ protected boolean applySignature = true;
+ protected boolean doDisassembly = true;
+ protected boolean demangleOnlyKnownPatterns = true;
public DemanglerOptions() {
// use default values
@@ -118,12 +120,6 @@ public class DemanglerOptions {
@Override
public String toString() {
- //@formatter:off
- return "{\n" +
- "\tdoDisassembly: " + doDisassembly + ",\n" +
- "\tapplySignature: " + applySignature + ",\n" +
- "\tdemangleOnlyKnownPatterns: " + demangleOnlyKnownPatterns + ",\n" +
- "}";
- //@formatter:on
+ return Json.toString(this);
}
}
diff --git a/Ghidra/Features/MicrosoftDemangler/src/main/java/ghidra/app/plugin/core/analysis/MicrosoftDemanglerAnalyzer.java b/Ghidra/Features/MicrosoftDemangler/src/main/java/ghidra/app/plugin/core/analysis/MicrosoftDemanglerAnalyzer.java
index ef10a5c9c5..038fbcbee8 100644
--- a/Ghidra/Features/MicrosoftDemangler/src/main/java/ghidra/app/plugin/core/analysis/MicrosoftDemanglerAnalyzer.java
+++ b/Ghidra/Features/MicrosoftDemangler/src/main/java/ghidra/app/plugin/core/analysis/MicrosoftDemanglerAnalyzer.java
@@ -17,7 +17,9 @@ package ghidra.app.plugin.core.analysis;
import ghidra.app.util.demangler.*;
import ghidra.app.util.demangler.microsoft.*;
+import ghidra.app.util.demangler.microsoft.options.*;
import ghidra.app.util.importer.MessageLog;
+import ghidra.framework.options.OptionType;
import ghidra.framework.options.Options;
import ghidra.program.model.listing.Program;
import ghidra.util.HelpLocation;
@@ -58,6 +60,12 @@ public class MicrosoftDemanglerAnalyzer extends AbstractDemanglerAnalyzer {
private boolean demangleOnlyKnownPatterns = false;
private MsCInterpretation interpretation = MsCInterpretation.FUNCTION_IF_EXISTS;
+ private static final String APPLY_OPTIONS_LABEL = "msdApplyOptions";
+ private static final String OUTPUT_OPTIONS_LABEL = "msdOutputOptions";
+
+ private MsdApplyOption applyOption;
+ private MsdOutputOption outputOption;
+
public MicrosoftDemanglerAnalyzer() {
super(NAME, DESCRIPTION);
demangler = new MicrosoftDemangler();
@@ -71,43 +79,36 @@ public class MicrosoftDemanglerAnalyzer extends AbstractDemanglerAnalyzer {
@Override
public void registerOptions(Options options, Program program) {
-
HelpLocation help = new HelpLocation("AutoAnalysisPlugin", "Demangler_Analyzer");
- options.registerOption(OPTION_NAME_APPLY_SIGNATURE, applyFunctionSignature, help,
- OPTION_DESCRIPTION_APPLY_SIGNATURE);
+ options.registerOption(APPLY_OPTIONS_LABEL, OptionType.CUSTOM_TYPE,
+ new MsdApplyOption(), help, "Configures how demangling is applied",
+ () -> new MsdApplyOptionsEditor());
+ applyOption =
+ (MsdApplyOption) options.getCustomOption(APPLY_OPTIONS_LABEL, null);
- options.registerOption(OPTION_NAME_APPLY_CALLING_CONVENTION, applyCallingConvention, help,
- OPTION_DESCRIPTION_APPLY_CALLING_CONVENTION);
-
- options.registerOption(OPTION_NAME_DEMANGLE_USE_KNOWN_PATTERNS, demangleOnlyKnownPatterns,
- help, OPTION_DESCRIPTION_USE_KNOWN_PATTERNS);
-
- options.registerOption(OPTION_NAME_MS_C_INTERPRETATION, interpretation, help,
- OPTION_DESCRIPTION_MS_C_INTERPRETATION);
+ options.registerOption(OUTPUT_OPTIONS_LABEL, OptionType.CUSTOM_TYPE,
+ new MsdOutputOption(), help, "Controls demangled output",
+ () -> new MsdOutputOptionsEditor());
+ outputOption = (MsdOutputOption) options.getCustomOption(OUTPUT_OPTIONS_LABEL, null);
}
@Override
public void optionsChanged(Options options, Program program) {
- applyFunctionSignature =
- options.getBoolean(OPTION_NAME_APPLY_SIGNATURE, applyFunctionSignature);
-
- applyCallingConvention =
- options.getBoolean(OPTION_NAME_APPLY_CALLING_CONVENTION, applyCallingConvention);
-
- demangleOnlyKnownPatterns =
- options.getBoolean(OPTION_NAME_DEMANGLE_USE_KNOWN_PATTERNS, demangleOnlyKnownPatterns);
-
- interpretation = options.getEnum(OPTION_NAME_MS_C_INTERPRETATION, interpretation);
+ applyOption = (MsdApplyOption) options.getCustomOption(APPLY_OPTIONS_LABEL, applyOption);
+ outputOption =
+ (MsdOutputOption) options.getCustomOption(OUTPUT_OPTIONS_LABEL, outputOption);
}
@Override
protected DemanglerOptions getOptions() {
MicrosoftDemanglerOptions options = new MicrosoftDemanglerOptions();
- options.setApplySignature(applyFunctionSignature);
- options.setApplyCallingConvention(applyCallingConvention);
- options.setDemangleOnlyKnownPatterns(demangleOnlyKnownPatterns);
- options.setInterpretation(interpretation);
+ options.setApplySignature(applyOption.applySignature());
+ options.setApplyCallingConvention(applyOption.applyCallingConvention());
+ options.setDemangleOnlyKnownPatterns(applyOption.demangleOnlyKnownPatterns());
+ options.setInterpretation(applyOption.getInterpretation());
+ options.setUseEncodedAnonymousNamespace(outputOption.getUseEncodedAnonymousNamespace());
+ options.setApplyUdtArgumentTypeTag(outputOption.getApplyUdtArgumentTypeTag());
options.setErrorOnRemainingChars(true);
return options;
}
diff --git a/Ghidra/Features/MicrosoftDemangler/src/main/java/ghidra/app/util/demangler/microsoft/MicrosoftDemangler.java b/Ghidra/Features/MicrosoftDemangler/src/main/java/ghidra/app/util/demangler/microsoft/MicrosoftDemangler.java
index 5e1daa680e..fe412af3a1 100644
--- a/Ghidra/Features/MicrosoftDemangler/src/main/java/ghidra/app/util/demangler/microsoft/MicrosoftDemangler.java
+++ b/Ghidra/Features/MicrosoftDemangler/src/main/java/ghidra/app/util/demangler/microsoft/MicrosoftDemangler.java
@@ -64,13 +64,24 @@ public class MicrosoftDemangler implements Demangler {
demangler.setDemangleOnlyKnownPatterns(options.demangleOnlyKnownPatterns());
demangler.setArchitectureSize(mContext.getArchitectureSize());
demangler.setIsFunction(mContext.shouldInterpretAsFunction());
+
try {
item = demangler.demangle();
if (item == null) {
return null;
}
+ // The item.toString() method is influenced by the demangler output options, so we get
+ // the originalDemangled string before we change the output options to what we desire
+ // for Ghidra processing.
String originalDemangled = item.toString();
- demangler.getOutputOptions().setUseEncodedAnonymousNamespace(true);
+ // Now we set the particular output options that we didt't want to affect what was
+ // in the originalDemangled string above. Once set, then when
+ // MicrosoftDemanglerUtil.convertToDemangledObject() method is called, the newly
+ // set output options affect the object result.
+ demangler.getOutputOptions()
+ .setUseEncodedAnonymousNamespace(options.getUseEncodedAnonymousNamespace());
+ demangler.getOutputOptions()
+ .setApplyUdtArgumentTypeTag(options.getApplyUdtArgumentTypeTag());
object =
MicrosoftDemanglerUtil.convertToDemangledObject(item, mangled, originalDemangled);
if (object != null) {
@@ -112,8 +123,18 @@ public class MicrosoftDemangler implements Demangler {
if (mdType == null) {
return null;
}
+ // The item.toString() method is influenced by the demangler output options, so we get
+ // the originalDemangled string before we change the output options to what we desire
+ // for Ghidra processing.
String originalDemangled = mdType.toString();
- demangler.getOutputOptions().setUseEncodedAnonymousNamespace(true);
+ // Now we set the particular output options that we didt't want to affect what was
+ // in the originalDemangled string above. Once set, then when
+ // MicrosoftDemanglerUtil.convertToDemangledObject() method is called, the newly
+ // set output options affect the object result.
+ demangler.getOutputOptions()
+ .setUseEncodedAnonymousNamespace(options.getUseEncodedAnonymousNamespace());
+ demangler.getOutputOptions()
+ .setApplyUdtArgumentTypeTag(options.getApplyUdtArgumentTypeTag());
dataType = MicrosoftDemanglerUtil.convertToDemangledDataType(mdType, mangled,
originalDemangled);
if (dataType != null) {
diff --git a/Ghidra/Features/MicrosoftDemangler/src/main/java/ghidra/app/util/demangler/microsoft/MicrosoftDemanglerOptions.java b/Ghidra/Features/MicrosoftDemangler/src/main/java/ghidra/app/util/demangler/microsoft/MicrosoftDemanglerOptions.java
index ecf8360f8c..a2272a4a39 100644
--- a/Ghidra/Features/MicrosoftDemangler/src/main/java/ghidra/app/util/demangler/microsoft/MicrosoftDemanglerOptions.java
+++ b/Ghidra/Features/MicrosoftDemangler/src/main/java/ghidra/app/util/demangler/microsoft/MicrosoftDemanglerOptions.java
@@ -15,6 +15,7 @@
*/
package ghidra.app.util.demangler.microsoft;
+import generic.json.Json;
import ghidra.app.util.demangler.DemanglerOptions;
/**
@@ -22,24 +23,29 @@ import ghidra.app.util.demangler.DemanglerOptions;
*/
public class MicrosoftDemanglerOptions extends DemanglerOptions {
+ // Processing options
private boolean errorOnRemainingChars;
private MsCInterpretation interpretation;
+ // Output options:
+ private boolean useEncodedAnonymousNamespace;
+ private boolean applyUdtArgumentTypeTag; // specific to MS for now
+
+ /**
+ * Constructor for MicrosoftDemanglerOptions
+ * @param errorOnRemainingCharsArg {@code true} to error on remaining characters
+ */
+ public MicrosoftDemanglerOptions(boolean errorOnRemainingCharsArg) {
+ this();
+ errorOnRemainingChars = errorOnRemainingCharsArg; // override defaultInits()
+ }
+
/**
* Default constructor for MicrosoftDemanglerOptions
*/
public MicrosoftDemanglerOptions() {
- this(true);
- interpretation = MsCInterpretation.FUNCTION_IF_EXISTS;
- }
-
- /**
- * Constructor for MicrosoftDemanglerOptions
- * @param errorOnRemainingChars {@code true} to error on remaining characters
- */
- public MicrosoftDemanglerOptions(boolean errorOnRemainingChars) {
super();
- this.errorOnRemainingChars = errorOnRemainingChars;
+ defaultInits();
}
/**
@@ -48,17 +54,24 @@ public class MicrosoftDemanglerOptions extends DemanglerOptions {
*/
public MicrosoftDemanglerOptions(DemanglerOptions copy) {
super(copy);
-
if (copy instanceof MicrosoftDemanglerOptions mCopy) {
errorOnRemainingChars = mCopy.errorOnRemainingChars;
interpretation = mCopy.interpretation;
+ useEncodedAnonymousNamespace = mCopy.useEncodedAnonymousNamespace;
+ applyUdtArgumentTypeTag = mCopy.applyUdtArgumentTypeTag;
}
else {
- errorOnRemainingChars = true;
- interpretation = MsCInterpretation.FUNCTION_IF_EXISTS;
+ defaultInits();
}
}
+ private void defaultInits() {
+ errorOnRemainingChars = true;
+ interpretation = MsCInterpretation.FUNCTION_IF_EXISTS;
+ useEncodedAnonymousNamespace = true;
+ applyUdtArgumentTypeTag = true;
+ }
+
/**
* Sets the control for erroring on remaining characters at demangler completion
* @param errorOnRemainingCharsArg {@code true} to error when remaining characters exist
@@ -94,16 +107,46 @@ public class MicrosoftDemanglerOptions extends DemanglerOptions {
return interpretation;
}
+ /**
+ * Sets the output flag to use an anonymous namespace's encoded number to craft a namespace
+ * containing this number instead of using the generic "`anonymous namespace'" name. Default
+ * is true (to create a namespace containing the encoded number)
+ * @param useEncodedAnonymousNamespaceArg {@code true} to use
+ */
+ public void setUseEncodedAnonymousNamespace(boolean useEncodedAnonymousNamespaceArg) {
+ useEncodedAnonymousNamespace = useEncodedAnonymousNamespaceArg;
+ }
+
+ /**
+ * Returns {@code true} if the output flag is set to use an anonymous namespace's encoded
+ * number to craft a namespace containing the number instead of using the generic
+ * "`anonymous namespace'" name.
+ * @return {@code true} if encoded number is used to craft a namespace
+ */
+ public boolean getUseEncodedAnonymousNamespace() {
+ return useEncodedAnonymousNamespace;
+ }
+
+ /**
+ * Sets the output flag for applying user-defined tags (e.g., class, struct, union, enum)
+ * within template and function arguments. Default is {@code true} (to apply)
+ * @param applyUdtArgumentTypeTagArg {@code true} to apply the tags
+ */
+ public void setApplyUdtArgumentTypeTag(boolean applyUdtArgumentTypeTagArg) {
+ applyUdtArgumentTypeTag = applyUdtArgumentTypeTagArg;
+ }
+
+ /**
+ * Returns {@code true} if the output interpretation is set to apply user-defined type
+ * tags (e.g., class, struct, union, enum) within template and function arguments.
+ * @return {@code true} if applying the tags
+ */
+ public boolean getApplyUdtArgumentTypeTag() {
+ return applyUdtArgumentTypeTag;
+ }
+
@Override
public String toString() {
- //@formatter:off
- return "{\n" +
- "\tdoDisassembly: " + doDisassembly() + ",\n" +
- "\tapplySignature: " + applySignature() + ",\n" +
- "\terrorOnRemainingChars: " + errorOnRemainingChars + ",\n" +
- "\tinterpretation: " + interpretation + ",\n" +
- "\tdemangleOnlyKnownPatterns: " + demangleOnlyKnownPatterns() + ",\n" +
- "}";
- //@formatter:on
+ return Json.toString(this);
}
}
diff --git a/Ghidra/Features/MicrosoftDemangler/src/main/java/ghidra/app/util/demangler/microsoft/MicrosoftMangledContext.java b/Ghidra/Features/MicrosoftDemangler/src/main/java/ghidra/app/util/demangler/microsoft/MicrosoftMangledContext.java
index e260ef8a37..44b50ae88b 100644
--- a/Ghidra/Features/MicrosoftDemangler/src/main/java/ghidra/app/util/demangler/microsoft/MicrosoftMangledContext.java
+++ b/Ghidra/Features/MicrosoftDemangler/src/main/java/ghidra/app/util/demangler/microsoft/MicrosoftMangledContext.java
@@ -37,6 +37,15 @@ public class MicrosoftMangledContext extends MangledContext {
super(program, options, mangled, address);
}
+ /**
+ * Returns the demangler options
+ * @return the options
+ */
+ @Override
+ public MicrosoftDemanglerOptions getOptions() {
+ return (MicrosoftDemanglerOptions) options;
+ }
+
/**
* Returns the program architecture size
* @return the architecture size or zero if not known (program is null)
diff --git a/Ghidra/Features/MicrosoftDemangler/src/main/java/ghidra/app/util/demangler/microsoft/options/MsdApplyOption.java b/Ghidra/Features/MicrosoftDemangler/src/main/java/ghidra/app/util/demangler/microsoft/options/MsdApplyOption.java
new file mode 100644
index 0000000000..cb4692a138
--- /dev/null
+++ b/Ghidra/Features/MicrosoftDemangler/src/main/java/ghidra/app/util/demangler/microsoft/options/MsdApplyOption.java
@@ -0,0 +1,118 @@
+/* ###
+ * 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.util.demangler.microsoft.options;
+
+import java.util.Objects;
+
+import ghidra.app.plugin.core.analysis.MicrosoftDemanglerAnalyzer;
+import ghidra.app.util.demangler.DemanglerOptions;
+import ghidra.app.util.demangler.microsoft.MicrosoftDemanglerOptions;
+import ghidra.app.util.demangler.microsoft.MsCInterpretation;
+import ghidra.framework.options.CustomOption;
+import ghidra.framework.options.GProperties;
+
+/**
+ * Option class that is paired with the {@link MsdApplyOptionsEditor} so that we can have a
+ * custom editor for an "Apply" option panel for the {@link MicrosoftDemanglerAnalyzer}.
+ * Also see {@link MsdOutputOption}, which is another panel.
+ * The results of both get pushed into the {@link MicrosoftDemanglerOptions} to control the
+ * analyzer and underlying demangler.
+ */
+public class MsdApplyOption extends DemanglerOptions implements CustomOption {
+
+ private static final String DEMANGLE_USE_KNOWN_PATTERNS = "demangleOnlyKnownMangledSymbols";
+ private static final String APPLY_SIGNATURE = "applyFunctionSignatures";
+ private static final String APPLY_CALLING_CONVENTION = "applyFunctionCallingConventions";
+ private static final String MS_C_INTERPRETATION = "C-StyleSymbolInterpretation";
+
+ private static boolean DEFAULT_DEMANGLE_USE_KNOWN_PATTERNS = false;
+ private static boolean DEFAULT_APPLY_SIGNATURE = true;
+ private static boolean DEFAULT_APPLY_CALLING_CONVENTION = true;
+ private static MsCInterpretation DEFAULT_MS_C_INTERPRETATION =
+ MsCInterpretation.FUNCTION_IF_EXISTS;
+
+ private MsCInterpretation interpretation;
+
+ public MsdApplyOption() {
+ // required for persistence, but also using for overriding initializations of parent
+ setDemangleOnlyKnownPatterns(DEFAULT_DEMANGLE_USE_KNOWN_PATTERNS);
+ setApplySignature(DEFAULT_APPLY_SIGNATURE);
+ setApplyCallingConvention(DEFAULT_APPLY_CALLING_CONVENTION);
+ interpretation = DEFAULT_MS_C_INTERPRETATION;
+ }
+
+ /**
+ * Sets the interpretation for processing a C-style mangled symbol if there could be multiple
+ * interpretations
+ * @param interpretationArg the interpretation to use
+ */
+ public void setInterpretation(MsCInterpretation interpretationArg) {
+ interpretation = interpretationArg;
+ }
+
+ /**
+ * Returns the interpretation for processing a C-style mangled symbol if there could be multiple
+ * interpretations
+ * @return the interpretation used
+ */
+ public MsCInterpretation getInterpretation() {
+ return interpretation;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof MsdApplyOption other)) {
+ return false;
+ }
+
+ if (this == obj) {
+ return true;
+ }
+
+ return demangleOnlyKnownPatterns == other.demangleOnlyKnownPatterns &&
+ applyCallingConvention == other.applyCallingConvention &&
+ applySignature == other.applySignature &&
+ interpretation == other.interpretation;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(demangleOnlyKnownPatterns, applyCallingConvention,
+ applySignature, interpretation);
+ }
+
+//==================================================================================================
+// Persistence
+//==================================================================================================
+
+ @Override
+ public void readState(GProperties properties) {
+ demangleOnlyKnownPatterns =
+ properties.getBoolean(DEMANGLE_USE_KNOWN_PATTERNS, demangleOnlyKnownPatterns);
+ applySignature = properties.getBoolean(APPLY_SIGNATURE, applySignature);
+ applyCallingConvention =
+ properties.getBoolean(APPLY_CALLING_CONVENTION, applyCallingConvention);
+ interpretation = properties.getEnum(MS_C_INTERPRETATION, interpretation);
+ }
+
+ @Override
+ public void writeState(GProperties properties) {
+ properties.putBoolean(DEMANGLE_USE_KNOWN_PATTERNS, demangleOnlyKnownPatterns);
+ properties.putBoolean(APPLY_SIGNATURE, applySignature);
+ properties.putBoolean(APPLY_CALLING_CONVENTION, applyCallingConvention);
+ properties.putEnum(MS_C_INTERPRETATION, interpretation);
+ }
+}
diff --git a/Ghidra/Features/MicrosoftDemangler/src/main/java/ghidra/app/util/demangler/microsoft/options/MsdApplyOptionsEditor.java b/Ghidra/Features/MicrosoftDemangler/src/main/java/ghidra/app/util/demangler/microsoft/options/MsdApplyOptionsEditor.java
new file mode 100644
index 0000000000..b5544b61d5
--- /dev/null
+++ b/Ghidra/Features/MicrosoftDemangler/src/main/java/ghidra/app/util/demangler/microsoft/options/MsdApplyOptionsEditor.java
@@ -0,0 +1,282 @@
+/* ###
+ * 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.util.demangler.microsoft.options;
+
+import java.awt.*;
+import java.beans.PropertyEditorSupport;
+
+import javax.swing.*;
+import javax.swing.border.Border;
+import javax.swing.border.TitledBorder;
+
+import docking.options.editor.OptionsEditorAlignable;
+import docking.widgets.checkbox.GCheckBox;
+import docking.widgets.combobox.GComboBox;
+import ghidra.app.util.demangler.microsoft.MsCInterpretation;
+import ghidra.framework.options.CustomOptionsEditor;
+import ghidra.util.HTMLUtilities;
+import ghidra.util.layout.PairLayout;
+
+/**
+ * Editor used presenting and receiving GUI changes to {@link MsdApplyOption}
+ */
+public class MsdApplyOptionsEditor extends PropertyEditorSupport
+ implements CustomOptionsEditor {
+
+ private static final String USE_KNOWN_PATTERNS_LABEL = "Demangle Only Known Mangled Symbols";
+ public static final String APPLY_SIGNATURE_LABEL = "Apply Function Signatures";
+ public static final String APPLY_CALLING_CONVENTION_LABEL =
+ "Apply Function Calling Conventions";
+
+ public static final String MS_C_INTERPRETATION_LABEL = "C-Style Symbol Interpretation";
+
+ private static final String[] NAMES = { USE_KNOWN_PATTERNS_LABEL, APPLY_SIGNATURE_LABEL,
+ APPLY_CALLING_CONVENTION_LABEL, MS_C_INTERPRETATION_LABEL };
+
+ // help tooltips
+ private static final String USE_KNOWN_PATTERNS_TOOLTIP = HTMLUtilities.toWrappedHTML(
+ "Only demangle symbols that follow known compiler mangling patterns. " +
+ "Leaving this option off may cause non-mangled symbols to get demangled.",
+ 75);
+ private static final String APPLY_SIGNATURE_TOOLTIP = HTMLUtilities.toWrappedHTML(
+ "Apply any recovered function signature, in addition to the function name",
+ 75);
+ private static final String APPLY_CALLING_CONVENTION_TOOLTIP = HTMLUtilities.toWrappedHTML(
+ "Apply any recovered function signature calling convention",
+ 75);
+ private static final String MS_C_INTERPRETATION_TOOLTIP = HTMLUtilities.toWrappedHTML(
+ "When ambiguous, treat C-Style mangled symbol as: function, variable," +
+ " or function if a function exists",
+ 75);
+
+ private static final String[] DESCRIPTIONS = { USE_KNOWN_PATTERNS_TOOLTIP,
+ APPLY_SIGNATURE_TOOLTIP, APPLY_CALLING_CONVENTION_TOOLTIP, MS_C_INTERPRETATION_TOOLTIP };
+
+ private MsdApplyOption applyOption;
+
+ private Component editorComponent;
+
+ private JLabel interpretationLabel;
+ private JLabel callingConventionLabel;
+ private JLabel signatureLabel;
+ private JLabel knownPatternsLabel;
+
+ private JCheckBox knownPatternsCb;
+ private JCheckBox signatureCb;
+ private JCheckBox callingConventionCb;
+ private JComboBox