Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-880 - MDMang: add developer parse info script; fix issue with earlier error detection; reduce failure messages for managed code symbols; do some clean-up

ghizard549cd0d29b63
diff --git a/Ghidra/Features/MicrosoftDmang/developer_scripts/DeveloperDumpMDMangParseInfoScript.java b/Ghidra/Features/MicrosoftDmang/developer_scripts/DeveloperDumpMDMangParseInfoScript.java
new file mode 100644
index 0000000000..1c14b01111
--- /dev/null
+++ b/Ghidra/Features/MicrosoftDmang/developer_scripts/DeveloperDumpMDMangParseInfoScript.java
@@ -0,0 +1,108 @@
+/* ###
+ * 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.
+ */
+//Output MDMang parse information to the console.
+//
+//@category Demangler
+
+import docking.*;
+import ghidra.app.context.ProgramSymbolActionContext;
+import ghidra.app.script.GhidraScript;
+import ghidra.program.model.address.Address;
+import ghidra.program.model.listing.Data;
+import ghidra.program.model.listing.Function;
+import ghidra.program.model.symbol.Symbol;
+import ghidra.program.util.*;
+import ghidra.util.Msg;
+import mdemangler.MDException;
+import mdemangler.MDMangParseInfo;
+
+public class DeveloperDumpMDMangParseInfoScript extends GhidraScript {
+
+ @Override
+ protected void run() throws Exception {
+ DockingWindowManager windowManager = DockingWindowManager.getActiveInstance();
+ ComponentProvider provider = windowManager.getActiveComponentProvider();
+ ActionContext actionContext = provider.getActionContext(null);
+ if (actionContext instanceof ProgramSymbolActionContext) {
+ ProgramSymbolActionContext symbolContext = (ProgramSymbolActionContext) actionContext;
+ for (Symbol s : symbolContext.getSymbols()) {
+ demangle(s.getAddress(), s.getName());
+ }
+ }
+ else if (currentLocation instanceof FunctionSignatureFieldLocation) {
+ Function function = getFunctionAt(currentAddress);
+ if (function != null) {
+ demangle(currentAddress, function.getName());
+ }
+ }
+ else if (currentLocation instanceof LabelFieldLocation) {
+ LabelFieldLocation lfl = (LabelFieldLocation) currentLocation;
+ demangle(currentAddress, lfl.getName());
+ }
+ else if (currentLocation instanceof OperandFieldLocation) {
+ Data data = getDataAt(currentAddress);
+ if (data == null) {
+ return;
+ }
+
+ Object value = data.getValue();
+ if (!(value instanceof Address)) {
+ return;
+ }
+
+ Address symbolAddr = (Address) value;
+ Symbol sym = getSymbolAt(symbolAddr);
+ if (sym == null) {
+ popup("Symbol not found at the address " + symbolAddr +
+ " referenced by the selected pointer");
+ return;
+ }
+ demangle(symbolAddr, sym.getName());
+ }
+ else {
+ Symbol sym = getSymbolAt(currentAddress);
+ if (sym != null) {
+ demangle(currentAddress, sym.getName());
+ }
+ else {
+ println("Nothing to demangle at " + currentAddress);
+ }
+ }
+ }
+
+ private void demangle(Address address, String name) {
+
+ if (name == null || name.length() == 0) {
+ Msg.info(this, "Invalid name.\n");
+ return;
+ }
+
+ StringBuilder builder = new StringBuilder();
+ builder.append("\nName: " + name + "\n");
+ MDMangParseInfo demangler = new MDMangParseInfo();
+ try {
+ demangler.demangle(name, false);
+ String parseInfo = demangler.getParseInfoIncremental();
+ builder.append(parseInfo);
+ builder.append("Num remaining chars:" + demangler.getNumCharsRemaining() + "\n");
+ }
+ catch (MDException e) {
+ builder.append("Demangler failure: " + e.getMessage() + "\n");
+ }
+ Msg.info(this, builder);
+ }
+
+}
diff --git a/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/MDFuzzyFit.java b/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/MDFuzzyFit.java
index 85b9b9201b..1c9b08f591 100644
--- a/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/MDFuzzyFit.java
+++ b/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/MDFuzzyFit.java
@@ -15,11 +15,16 @@
*/
package mdemangler;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
import java.util.*;
import ghidra.util.Msg;
import mdemangler.datatype.MDDataType;
+import mdemangler.datatype.MDDataTypeParser;
import mdemangler.functiontype.MDFunctionType;
+import mdemangler.typeinfo.MDTypeInfo;
+import mdemangler.typeinfo.MDTypeInfoParser;
/**
* This class is still not used and might be turned into a derivative of the MDMang class.
@@ -49,12 +54,23 @@ public class MDFuzzyFit {
// TODO: Figure out the factory model stuff
classList.add(MDDataType.class); // TODO: remove; needs factory
classList.add(MDFunctionType.class);
+
}
// 20161007: Started development--not complete. Depends on all parsable
// types for dmang to
// be based on MDType, which is not true yet. TODO.
public boolean fuzz(String mangledArg) {
+
+ Msg.info(this, "Symbol: " + mangledArg);
+ Msg.info(this, "Length: " + mangledArg.length());
+
+ int bestTypeInfoLocation = getBestTypeInfoLocation(mangledArg);
+ Msg.info(this, "Best type location: " + bestTypeInfoLocation);
+
+ int bestTypeLocation = getBestTypeLocation(mangledArg);
+ Msg.info(this, "Best type location: " + bestTypeLocation);
+
StringBuilder outputBuilder = new StringBuilder();
if (mangledArg == null) {
// errorMessage = "MDMang: Mangled string is null.";
@@ -67,64 +83,150 @@ public class MDFuzzyFit {
outputBuilder.append("Symbol: ");
outputBuilder.append(mangledArg);
while (--offset >= 0) {
- try {
- substring = mangledArg.substring(offset);
- Iterator<Class<? extends MDParsableItem>> classIter = classList.iterator();
- while (classIter.hasNext()) {
- Class<? extends MDParsableItem> tryClass = classIter.next();
- boolean pass = true;
- try {
- dmang.setMangledSymbol(substring);
- dmang.pushContext();
- numCharsRemaining = substring.length();
- MDParsableItem tryItem = tryClass.newInstance();
- tryItem.setMDMang(dmang);
- tryItem.parse();
- numCharsRemaining = dmang.getNumCharsRemaining();
- dmang.popContext();
- StringBuilder builder = new StringBuilder();
- tryItem.insert(builder);
- String substringDemangled = builder.toString();
- if (numCharsRemaining == 0) {
- // System.out.println("Offset: " + offset + ";
- // Class: " +
- // tryClass.getSimpleName() + "; Output:" +
- // substringDemangled);
- outputBuilder.append("Offset: ");
- outputBuilder.append(offset);
- outputBuilder.append("; Class: ");
- outputBuilder.append(tryClass.getSimpleName());
- outputBuilder.append("; Output:");
- outputBuilder.append(substringDemangled);
- }
+ substring = mangledArg.substring(offset);
+ Iterator<Class<? extends MDParsableItem>> classIter = classList.iterator();
+ while (classIter.hasNext()) {
+ Class<? extends MDParsableItem> tryClass = classIter.next();
+ boolean pass = true;
+ try {
+ dmang.setMangledSymbol(substring);
+ dmang.pushContext();
+ numCharsRemaining = substring.length();
+ MDParsableItem tryItem = createItem(tryClass, dmang);
+ tryItem.parse();
+ numCharsRemaining = dmang.getNumCharsRemaining();
+ dmang.popContext();
+ StringBuilder builder = new StringBuilder();
+ tryItem.insert(builder);
+ String substringDemangled = builder.toString();
+ if (numCharsRemaining == 0) {
+ // System.out.println("Offset: " + offset + ";
+ // Class: " +
+ // tryClass.getSimpleName() + "; Output:" +
+ // substringDemangled);
+ outputBuilder.append("Offset: ");
+ outputBuilder.append(offset);
+ outputBuilder.append("; Class: ");
+ outputBuilder.append(tryClass.getSimpleName());
+ outputBuilder.append("; Output:");
+ outputBuilder.append(substringDemangled);
}
- catch (MDException e) {
- // errorMessage = e.getMessage();
- pass = false;
- }
- // errorMessage = "";
- // System.out.println("Offset: " + offset + "; Class: " +
- // tryClass.getSimpleName() + "; GoodResult: " + pass);
- outputBuilder.append("Offset: ");
- outputBuilder.append(offset);
- outputBuilder.append("; Class: ");
- outputBuilder.append(tryClass.getSimpleName());
- outputBuilder.append("; GoodResult: ");
- outputBuilder.append(pass);
}
- }
- catch (IllegalAccessException e) {
- Msg.warn(this, e.getMessage());
- return false;
- }
- catch (InstantiationException e) {
- Msg.warn(this, e.getMessage());
- return false;
+ catch (MDException e) {
+ // errorMessage = e.getMessage();
+ pass = false;
+ }
+ // errorMessage = "";
+ // System.out.println("Offset: " + offset + "; Class: " +
+ // tryClass.getSimpleName() + "; GoodResult: " + pass);
+ outputBuilder.append("Offset: ");
+ outputBuilder.append(offset);
+ outputBuilder.append("; Class: ");
+ outputBuilder.append(tryClass.getSimpleName());
+ outputBuilder.append("; GoodResult: ");
+ outputBuilder.append(pass);
}
}
Msg.info(this, outputBuilder);
return true;
}
+
+ private int getBestTypeInfoLocation(String mangledArg) {
+ MDMang dmang = new MDMang();
+ int offset = mangledArg.length();
+ boolean highest = false;
+ int bestOffset = offset;
+
+ while (--offset >= 0) {
+ try {
+ String substring = mangledArg.substring(offset);
+ dmang.setMangledSymbol(substring);
+ dmang.pushContext();
+ MDTypeInfo typeInfo = MDTypeInfoParser.parse(dmang, -1);
+ typeInfo.parse();
+ int num = dmang.getNumCharsRemaining();
+ dmang.popContext();
+ if (num == 0) {
+ bestOffset = offset;
+ }
+ }
+ catch (MDException mde) {
+ // Ignore for now
+ int a = 1;
+ a = a + 1;
+ }
+ catch (Exception e) {
+ // Ignore for now
+ int a = 1;
+ a = a + 1;
+ }
+ }
+
+ return bestOffset;
+ }
+
+ private int getBestTypeLocation(String mangledArg) {
+ MDMang dmang = new MDMang();
+ int offset = mangledArg.length();
+ boolean highest = false;
+ int bestOffset = offset;
+
+ while (--offset >= 0) {
+ try {
+ String substring = mangledArg.substring(offset);
+ dmang.setMangledSymbol(substring);
+ dmang.pushContext();
+ MDDataType type = MDDataTypeParser.parseDataType(dmang, highest);
+ type.parse();
+ int num = dmang.getNumCharsRemaining();
+ dmang.popContext();
+ if (num == 0) {
+ bestOffset = offset;
+ }
+ }
+ catch (MDException mde) {
+ // Ignore for now
+ int a = 1;
+ a = a + 1;
+ }
+ catch (Exception e) {
+ // Ignore for now
+ int a = 1;
+ a = a + 1;
+ }
+ }
+
+ return bestOffset;
+ }
+
+ private MDParsableItem createItem(Class<? extends MDParsableItem> clazz, MDMang dmang)
+ throws MDException {
+ Class<?>[] constructorClassArgs = new Class[1];
+ constructorClassArgs[0] = MDMang.class;
+ Constructor<? extends MDParsableItem> constructor;
+ try {
+ constructor = clazz.getDeclaredConstructor(constructorClassArgs);
+ }
+ catch (SecurityException e) {
+ throw new MDException("Security exception when getting constructor for class: " +
+ clazz.getName() + ": " + e);
+ }
+ catch (NoSuchMethodException e) {
+ throw new MDException("Constructor not found for class: " + clazz.getName() + ": " + e);
+ }
+
+ MDParsableItem item;
+ try {
+ item = constructor.newInstance(dmang);
+ }
+ catch (InstantiationException | IllegalAccessException | IllegalArgumentException
+ | InvocationTargetException e) {
+ throw new MDException("Cannot create new instance of: " + clazz.getName() + ": " + e);
+ }
+
+ return item;
+ }
+
}
/******************************************************************************/
diff --git a/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/MDMang.java b/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/MDMang.java
index 99eb059f4a..5473e99b13 100644
--- a/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/MDMang.java
+++ b/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/MDMang.java
@@ -40,7 +40,6 @@ public class MDMang {
protected String mangled;
protected MDCharacterIterator iter;
- protected int numCharsRemaining = 0;
protected String errorMessage = "";
protected MDParsableItem item;
@@ -48,7 +47,7 @@ public class MDMang {
/**
* Demangles the string passed in.
- *
+ *
* @param mangledIn
* the string to be demangled.
* @param errorOnRemainingChars
@@ -66,7 +65,7 @@ public class MDMang {
/**
* Demangles the string passed in.
- *
+ *
* @param errorOnRemainingChars
* boolean flag indicating whether remaining characters causes an
* error.
@@ -82,7 +81,7 @@ public class MDMang {
// MDMANG SPECIALIZATION USED.
item = getEmbeddedObject((MDObjectCPP) item);
}
- numCharsRemaining = iter.getLength() - iter.getIndex();
+ int numCharsRemaining = getNumCharsRemaining();
popContext();
if (errorOnRemainingChars && (numCharsRemaining > 0)) {
throw new MDException(
@@ -93,7 +92,7 @@ public class MDMang {
/**
* Sets the mangled string to be demangled.
- *
+ *
* @param mangledIn
* the string to be demangled.
*/
@@ -104,7 +103,7 @@ public class MDMang {
/**
* Gets the mangled string being demangled.
- *
+ *
* @return the string being demangled.
*/
public String getMangledSymbol() {
@@ -113,7 +112,7 @@ public class MDMang {
/**
* Returns the error message when demangle() returns null.
- *
+ *
* @return the error message for the demangle() call.
*/
public String getErrorMessage() {
@@ -124,11 +123,11 @@ public class MDMang {
* Returns the number of unprocessed mangled characters. Note that
* demangle() has a flag controlling whether remaining characters causes an
* error.
- *
+ *
* @return the integer number of characters that remain.
*/
public int getNumCharsRemaining() {
- return numCharsRemaining;
+ return iter.getLength() - iter.getIndex();
}
/******************************************************************************/
@@ -164,7 +163,7 @@ public class MDMang {
/**
* Returns the current index.
- *
+ *
* @return the current index.
*/
public int getIndex() {
@@ -173,7 +172,7 @@ public class MDMang {
/**
* Returns the next character without incrementing the current index.
- *
+ *
* @return the next character without incrementing the current index
*/
public char peek() {
@@ -184,7 +183,7 @@ public class MDMang {
/**
* Peeks at the character current index + lookAhead. Returns DONE if the
* computed position is out of range.
- *
+ *
* @param lookAhead
* number of characters to look ahead
* @return the character at index+lookAhead
@@ -200,7 +199,7 @@ public class MDMang {
* current index is reset to the end index and a value of DONE is returned.
* For extended reasons, the user should try not to use this method--and use
* of it should be selective, based on extended class reasons.
- *
+ *
* @return the character at the new position or DONE
*/
public char next() {
@@ -212,7 +211,7 @@ public class MDMang {
* Returns the character at the current index and then increments the index
* by one. If the resulting index is greater or equal to the end index, the
* current index is reset to the end index and a value of DONE is returned.
- *
+ *
* @return the character at the new position or DONE
*/
public char getAndIncrement() {
@@ -232,7 +231,7 @@ public class MDMang {
/**
* Moves to the next character in the iterator.
* Does no testing for whether it surpasses the length of the string.
- *
+ *
* @param count
* number of characters to move ahead
*/
@@ -475,6 +474,7 @@ public class MDMang {
* embedded object (see MDBasicName). In this default case, we do not
* return the embedded object, but just return the object itself. A
* derived class can elect to return the embedded.
+ * @param obj the object from which to the embedded object is retrieved for return.
* @return An MDObjectCPP representing the original or the embedded object.
*/
public MDObjectCPP getEmbeddedObject(MDObjectCPP obj) {
@@ -486,6 +486,8 @@ public class MDMang {
* object. In this default case (MDMang), we properly process the
* hashed object. Overridden methods might just throw an exception,
* allowing a failed demangling.
+ * @param obj the MDObjectCPP for which to process as a hashed object
+ * @throws MDException on parsing error.
*/
public void processHashedObject(MDObjectCPP obj) throws MDException {
obj.processHashedObject();
diff --git a/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/MDMangGenericize.java b/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/MDMangGenericize.java
index c87735bbc2..e98181ac9b 100644
--- a/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/MDMangGenericize.java
+++ b/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/MDMangGenericize.java
@@ -68,7 +68,7 @@ public class MDMangGenericize extends MDMang {
if (item != null) {
item.parse();
}
- numCharsRemaining = iter.getLength() - iter.getIndex();
+ int numCharsRemaining = getNumCharsRemaining();
appendRemainder();
popContext();
// if (errorOnRemainingChars && (numCharsRemaining > 0)) {
diff --git a/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/MDMangGhidra.java b/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/MDMangGhidra.java
index 52749c8e43..f78a7bbf10 100644
--- a/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/MDMangGhidra.java
+++ b/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/MDMangGhidra.java
@@ -145,7 +145,8 @@ public class MDMangGhidra extends MDMang {
}
//TODO: put other objectReserved derivative types here and return something that Ghidra can use.
else {
- object = new DemangledUnknown(mangledSource, demangledSource, null);
+ object =
+ new DemangledUnknown(mangledSource, demangledSource, objectReserved.toString());
}
return object;
}
@@ -207,32 +208,37 @@ public class MDMangGhidra extends MDMang {
}
}
else if (typeinfo instanceof MDFunctionInfo) {
- DemangledFunction function =
- new DemangledFunction(mangledSource, demangledSource, objectCPP.getName());
- function.setNamespace(processNamespace(objectCPP.getQualfication()));
- resultObject = function;
- objectResult = processFunction((MDFunctionInfo) typeinfo, function);
- // Any other special values to be set?
- if (typeinfo instanceof MDMemberFunctionInfo) {
- if (typeinfo instanceof MDVCall) {
- // Empty for now--placeholder for possible future logic.
- }
- else if (typeinfo instanceof MDVFAdjustor) {
- // Empty for now--placeholder for possible future logic.
- }
- else if (typeinfo instanceof MDVtordisp) {
- // Empty for now--placeholder for possible future logic.
- }
- else if (typeinfo instanceof MDVtordispex) {
- // Empty for now--placeholder for possible future logic.
+ if (typeinfo.getSpecialHandlingCode() == 'F') {
+ resultObject = new DemangledUnknown(mangledSource, demangledSource, null);
+ }
+ else {
+ DemangledFunction function =
+ new DemangledFunction(mangledSource, demangledSource, objectCPP.getName());
+ function.setNamespace(processNamespace(objectCPP.getQualfication()));
+ resultObject = function;
+ objectResult = processFunction((MDFunctionInfo) typeinfo, function);
+ // Any other special values to be set?
+ if (typeinfo instanceof MDMemberFunctionInfo) {
+ if (typeinfo instanceof MDVCall) {
+ // Empty for now--placeholder for possible future logic.
+ }
+ else if (typeinfo instanceof MDVFAdjustor) {
+ // Empty for now--placeholder for possible future logic.
+ }
+ else if (typeinfo instanceof MDVtordisp) {
+ // Empty for now--placeholder for possible future logic.
+ }
+ else if (typeinfo instanceof MDVtordispex) {
+ // Empty for now--placeholder for possible future logic.
+ }
+ else {
+ // plain member function
+ }
}
else {
- // plain member function
+ // global function
}
}
- else {
- // global function
- }
}
else if (typeinfo instanceof MDVxTable) { //Includes VFTable, VBTable, and RTTI4
MDVxTable vxtable = (MDVxTable) typeinfo;
@@ -345,7 +351,7 @@ public class MDMangGhidra extends MDMang {
MDFunctionType functionType = (MDFunctionType) functionInfo.getMDType();
String convention = functionType.getCallingConvention().toString();
if ("__cdecl".equals(convention) && functionInfo.isMember() && !functionInfo.isStatic()) {
- // TODO: ultimately the presence of a 'this' parareter will not be keyed
+ // TODO: ultimately the presence of a 'this' parareter will not be keyed
// to the calling convention, but for now we need to force it
convention = CompilerSpec.CALLING_CONVENTION_thiscall;
}
@@ -521,7 +527,7 @@ public class MDMangGhidra extends MDMang {
MDDataType datatype) {
if (resultDataType == null) {
resultDataType =
- new DemangledDataType(mangledSource, demangledSource, datatype.getTypeName());
+ new DemangledDataType(mangledSource, demangledSource, getDataTypeName(datatype));
}
if (datatype.isSpecifiedSigned()) {
// Returns true if default signed or specified signed. TODO: There is no place to
@@ -573,8 +579,8 @@ public class MDMangGhidra extends MDMang {
// return processFunction(ref, resultDataType);
}
else if (modifierType.getReferencedType() instanceof MDDataType) {
- MDType ref = modifierType.getReferencedType();
- return processDataType(resultDataType, (MDDataType) ref);
+ return processDataType(resultDataType,
+ (MDDataType) modifierType.getReferencedType());
}
else {
// Empty for now--placeholder for possible future logic.
@@ -601,11 +607,11 @@ public class MDMangGhidra extends MDMang {
}
return fp;
}
- resultDataType.incrementPointerLevels();
// modifierType.getArrayString();
// resultDataType.setArray();
- DemangledDataType dataType =
- processDataType(resultDataType, (MDDataType) modifierType.getReferencedType());
+ //Processing the referenced type (for Ghidra, and then setting attributes on it)
+ processDataType(resultDataType, (MDDataType) modifierType.getReferencedType());
+ resultDataType.incrementPointerLevels();
if (modifierType.getCVMod().isConst()) {
resultDataType.setConst();
}
@@ -615,7 +621,7 @@ public class MDMangGhidra extends MDMang {
if (modifierType.getCVMod().isPointer64()) {
resultDataType.setPointer64();
}
- return dataType;
+ return resultDataType;
}
// TODO: fix. Following is a kludge because DemangledObject has no
// DemangledReference
@@ -641,9 +647,9 @@ public class MDMangGhidra extends MDMang {
}
return fr;
}
+ //Processing the referenced type (for Ghidra, and then setting attributes on it)
+ processDataType(resultDataType, (MDDataType) modifierType.getReferencedType());
resultDataType.setReference(); // Not sure if we should do/use this.
- DemangledDataType dataType =
- processDataType(resultDataType, (MDDataType) modifierType.getReferencedType());
if (modifierType.getCVMod().isConst()) {
resultDataType.setConst();
}
@@ -653,7 +659,7 @@ public class MDMangGhidra extends MDMang {
if (modifierType.getCVMod().isPointer64()) {
resultDataType.setPointer64();
}
- return dataType;
+ return resultDataType;
}
// TODO: fix. Following is a kludge because DemangledObject has no DemangledReference
// with corresponding referencedType.
@@ -676,18 +682,18 @@ public class MDMangGhidra extends MDMang {
return fd;
}
else if (modifierType instanceof MDPointerRefDataType) {
- resultDataType.setName(datatype.getTypeName());
+ resultDataType.setName(getDataTypeName(datatype));
// Not sure if this is the correct thing to do for MDPointerRefDataType, but we
// are just going to assign the referred-to type:
- MDType ref = modifierType.getReferencedType();
- return processDataType(resultDataType, (MDDataType) ref);
+ //Processing the referenced type (for Ghidra, and then setting attributes on it)
+ return processDataType(resultDataType,
+ (MDDataType) modifierType.getReferencedType());
}
else if (modifierType instanceof MDDataReferenceType) {
- resultDataType.setName(datatype.getTypeName());
// Not sure if this is the correct thing to do for MDDataReferenceType, but we
// are just going to assign the referred-to type:
- MDType ref = modifierType.getReferencedType();
- processDataType(resultDataType, (MDDataType) ref);
+ //Processing the referenced type (for Ghidra, and then setting attributes on it)
+ processDataType(resultDataType, (MDDataType) modifierType.getReferencedType());
if (modifierType.getCVMod().isConst()) {
resultDataType.setConst();
}
@@ -697,8 +703,8 @@ public class MDMangGhidra extends MDMang {
return resultDataType;
}
else if (modifierType instanceof MDDataRefRefType) {
- resultDataType.setName(datatype.getTypeName());
if ((modifierType.getReferencedType() instanceof MDFunctionType)) {
+ resultDataType.setName(getDataTypeName(datatype));
// TODO---------what are we returning... need to work on called routine.
DemangledFunctionReference fr = processDemangledFunctionReference(modifierType);
// TODO: fix. Following is a kludge because DemangledObject has no
@@ -717,9 +723,9 @@ public class MDMangGhidra extends MDMang {
}
return fr;
}
+ //Processing the referenced type (for Ghidra, and then setting attributes on it)
+ processDataType(resultDataType, (MDDataType) modifierType.getReferencedType());
resultDataType.setReference(); // Not sure if we should do/use this.
- DemangledDataType dataType =
- processDataType(resultDataType, (MDDataType) modifierType.getReferencedType());
if (modifierType.getCVMod().isConst()) {
resultDataType.setConst();
}
@@ -729,7 +735,7 @@ public class MDMangGhidra extends MDMang {
if (modifierType.getCVMod().isPointer64()) {
resultDataType.setPointer64();
}
- return dataType;
+ return resultDataType;
}
else if (modifierType instanceof MDStdNullPtrType) {
resultDataType.setName(datatype.toString());
@@ -814,7 +820,7 @@ public class MDMangGhidra extends MDMang {
// MDDataType
// TODO MDW64Type needs repeated reference type parsing, just as modifier types need
// them.
- resultDataType.setName(datatype.getTypeName());
+ resultDataType.setName(getDataTypeName(datatype));
}
// TODO: No place to indicate a general pointer--we can indicate Pointer64
// TODO: Not sure if anything fits this: resultDataType.setComplex();
@@ -826,13 +832,17 @@ public class MDMangGhidra extends MDMang {
return resultDataType;
}
- /******************************************************************************/
- /******************************************************************************/
- // SPECIALIZATION METHODS
-
- @Override
- public MDObjectCPP getEmbeddedObject(MDObjectCPP obj) {
- return obj.getEmbeddedObject();
+ /**
+ * Returns either a formal type name or a representative type name to fill into a
+ * MangledDataType if the formal name is blank
+ * @return the name
+ */
+ private String getDataTypeName(MDDataType dataType) {
+ String name = dataType.getName();
+ if (name.isBlank()) {
+ return dataType.toString();
+ }
+ return name;
}
}
diff --git a/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/typeinfo/MDTypeInfo.java b/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/typeinfo/MDTypeInfo.java
index 515428cc04..8109724fb2 100644
--- a/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/typeinfo/MDTypeInfo.java
+++ b/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/typeinfo/MDTypeInfo.java
@@ -18,7 +18,7 @@ package mdemangler.typeinfo;
import mdemangler.*;
/**
- *
+ *
*/
public class MDTypeInfo extends MDParsableItem {
private static final String PRIVATE = "private: ";
@@ -48,6 +48,7 @@ public class MDTypeInfo extends MDParsableItem {
private boolean isThunk = false;
private boolean isMember = true;
private boolean isExternC = false;
+ private char specialHandlingCode = '\0';
protected MDType mdtype;
protected boolean isTypeCast;
@@ -118,6 +119,14 @@ public class MDTypeInfo extends MDParsableItem {
return isExternC;
}
+ public void setSpecialHandlingCode(char code) {
+ specialHandlingCode = code;
+ }
+
+ public char getSpecialHandlingCode() {
+ return specialHandlingCode;
+ }
+
public void setNonMember() {
isMember = false;
}
diff --git a/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/typeinfo/MDTypeInfoParser.java b/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/typeinfo/MDTypeInfoParser.java
index 4eecb197b6..9c1943e5c3 100644
--- a/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/typeinfo/MDTypeInfoParser.java
+++ b/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/typeinfo/MDTypeInfoParser.java
@@ -108,7 +108,7 @@ public class MDTypeInfoParser {
break;
case '8':
// All but the RTTI except RTT4 seem to show up here
- // under case '8'; RTTI4 is co-mingled under case '6' with VFTable.
+ // under case '8'; RTTI4 is co-mingled under case '6' with VFTable.
// TODO: UINFO: metatype (we had isVBTable = true, but I now believe
// that
// is wrong).
@@ -324,6 +324,7 @@ public class MDTypeInfoParser {
default:
throw new MDException("Access Level $$, unknown case: " + ch2);
}
+ typeInfo.setSpecialHandlingCode(ch2);
break;
// TODO: see following UINFO.
// UINFO:
diff --git a/Ghidra/Features/MicrosoftDmang/src/test/java/mdemangler/MDBaseTestConfiguration.java b/Ghidra/Features/MicrosoftDmang/src/test/java/mdemangler/MDBaseTestConfiguration.java
index ae74fe6b5b..adcf4beab1 100644
--- a/Ghidra/Features/MicrosoftDmang/src/test/java/mdemangler/MDBaseTestConfiguration.java
+++ b/Ghidra/Features/MicrosoftDmang/src/test/java/mdemangler/MDBaseTestConfiguration.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,7 +15,10 @@
*/
package mdemangler;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.rules.TestName;
import ghidra.util.Msg;
import mdemangler.datatype.MDDataType;
@@ -62,6 +65,7 @@ public class MDBaseTestConfiguration {
/**
* Runs through the process of creating a demangler, demangling a symbol string,
* testing the output, and performing other ancillary outputs and tests.
+ * @param testName TestName of the test being run.
* @param mangledArg Mangled string to process
* @param mdtruth Truth that "we" (developers of this demangler) believe is truth
* @param mstruth Truth that was output from one of the Microsoft tools (e.g., undname).
@@ -69,13 +73,15 @@ public class MDBaseTestConfiguration {
* @param ms2013truth Like mstruth, but from Visual Studio 2013 version of tool.
* @throws Exception if any exceptions are thrown
*/
- public void demangleAndTest(String mangledArg, String mdtruth, String mstruth, String ghtruth,
- String ms2013truth) throws Exception {
+ public void demangleAndTest(TestName testName, String mangledArg, String mdtruth,
+ String mstruth, String ghtruth, String ms2013truth) throws Exception {
mangled = mangledArg;
setTruth(mdtruth, mstruth, ghtruth, ms2013truth);
outputInfo = new StringBuilder();
if (verboseOutput) {
+ outputInfo.append("\n Test: ");
+ outputInfo.append(testName.getMethodName());
outputInfo.append(getNumberHeader(mangledArg.length()));
outputInfo.append(getTestHeader());
}
diff --git a/Ghidra/Features/MicrosoftDmang/src/test/java/mdemangler/MDMangBaseTest.java b/Ghidra/Features/MicrosoftDmang/src/test/java/mdemangler/MDMangBaseTest.java
index 8974827dc6..f463e575ef 100644
--- a/Ghidra/Features/MicrosoftDmang/src/test/java/mdemangler/MDMangBaseTest.java
+++ b/Ghidra/Features/MicrosoftDmang/src/test/java/mdemangler/MDMangBaseTest.java
@@ -64,7 +64,7 @@ import ghidra.util.Msg;
* was able to make a change to this code base and run against the core set of tests below
* and found that I broke no tests, but when I ran against the Windows 10 symbols, I failed
* more than 1300 of these tests when the norm was to fail 73. Note too, that I immediately
- * throw away symbols from these sets that I can immediately say that Microsoft has gotten
+ * throw away symbols from these sets that I can immediately say that Microsoft has gotten
* wrong (e.g., has "??" in the demangled string), but this approach gives general direction
* and it often (as in my example case) leads me to grab another symbol or two to put into
* the core set of tests to provide constraints around this living design.
@@ -179,7 +179,8 @@ public class MDMangBaseTest extends AbstractGenericTest {
};
private void demangleAndTest() throws Exception {
- testConfiguration.demangleAndTest(mangled, mdTruth, msTruth, ghTruth, ms2013Truth);
+ testConfiguration.demangleAndTest(testName, mangled, mdTruth, msTruth, ghTruth,
+ ms2013Truth);
}
@Test
@@ -188,7 +189,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
msTruth = "void __clrcall `dynamic initializer for 'const name1::name0::`vftable'''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'const name1::name0::`vftable'''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -199,7 +199,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
"void __clrcall zz::z::`dynamic initializer for 'const name1::name0::`vftable'{for `xx::x's `yy::y'}''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall zz::z::`dynamic initializer for 'const name1::name0::`vftable'{for `xx::x's `yy::y'}''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -210,7 +209,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
"void __clrcall z::`dynamic initializer for 'const name1::name0::`vftable'''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall z::`dynamic initializer for 'const name1::name0::`vftable'''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -276,7 +274,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
msTruth = "void __clrcall name1::`dynamic initializer for 'name0''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall name1::`dynamic initializer for 'name0''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -295,7 +292,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
"void __clrcall `dynamic initializer for 'public: static bool <name2>::name1::name0''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'public: static bool <name2>::name1::name0''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -329,7 +325,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
msTruth = "void __clrcall `dynamic initializer for 'const name0::`vftable'''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'const name0::`vftable'''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -339,7 +334,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
msTruth = "void __clrcall name1::`dynamic initializer for 'const name0::`vftable'''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall name1::`dynamic initializer for 'const name0::`vftable'''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -349,7 +343,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
msTruth = "void __clrcall `dynamic initializer for 'int name1::name0''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'int name1::name0''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -359,7 +352,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
msTruth = "void __clrcall name1::`dynamic initializer for 'name0''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall name1::`dynamic initializer for 'name0''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -370,7 +362,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
"void __clrcall `dynamic initializer for 'public: static bool <name2>::name1::name0''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'public: static bool <name2>::name1::name0''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -382,7 +373,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
"void __clrcall `dynamic initializer for 'private: static class name2::name3<class name5::name4 ^ __ptr64> name2::name1::name0''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'private: static class name2::name3<class name5::name4 ^ __ptr64> name2::name1::name0''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -393,7 +383,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
"void __clrcall `dynamic initializer for 'public: static enum name2::name4::name3 name2::name1::name0''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'public: static enum name2::name4::name3 name2::name1::name0''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -404,7 +393,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
"void __clrcall `dynamic initializer for 'public: static int name2::name1::name0''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'public: static int name2::name1::name0''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -415,7 +403,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
"void __clrcall `dynamic initializer for 'public: static enum name2::name4::name3 name2::name1::name0''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'public: static enum name2::name4::name3 name2::name1::name0''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -426,7 +413,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
"void __clrcall `dynamic initializer for 'public: static enum name2::name4::name3 name2::name1::name0''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'public: static enum name2::name4::name3 name2::name1::name0''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -436,7 +422,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
msTruth = "void __clrcall `dynamic initializer for 'const name0::`vftable'''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'const name0::`vftable'''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -1306,7 +1291,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
"void __clrcall `dynamic initializer for 'public: static bool <name2>::name1::name0''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'public: static bool <name2>::name1::name0''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -1316,7 +1300,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
msTruth = "void __clrcall `dynamic initializer for 'const name0::`vftable'''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'const name0::`vftable'''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -3485,7 +3468,7 @@ public class MDMangBaseTest extends AbstractGenericTest {
demangleAndTest();
}
- //Manufactured; Keep.
+ //Manufactured; Keep.
@Test
public void testTemplateParameter_BQRS_DirectArgModifiers() throws Exception {
//BQRS modifiers are only valid on direct arguments of functions and templates.
@@ -4722,7 +4705,7 @@ public class MDMangBaseTest extends AbstractGenericTest {
//_P is prefix for another special name, such that:
// "?_PE" that looks like (prefix) and "?E" or
// "?_P_E" that looks like (prefix) and "?_E"
- // Prefix is "`udt returning'"
+ // Prefix is "`udt returning'"
mangled = "??_PENameSpace@@$$FQAEPAXI@Z";
msTruth = "public: void * __thiscall NameSpace::`udt returning'operator++(unsigned int)";
mdTruth = msTruth;
@@ -4735,7 +4718,7 @@ public class MDMangBaseTest extends AbstractGenericTest {
//_P is prefix for another special name, such that:
// "?_PE" that looks like (prefix) and "?E" or
// "?_P_E" that looks like (prefix) and "?_E"
- // Prefix is "`udt returning'"
+ // Prefix is "`udt returning'"
mangled = "??_P_P_PENameSpace@@$$FQAEPAXI@Z";
msTruth =
"public: void * __thiscall NameSpace::`udt returning'`udt returning'`udt returning'operator++(unsigned int)";
@@ -4748,7 +4731,7 @@ public class MDMangBaseTest extends AbstractGenericTest {
@Test
public void testSpecialNames_Q() throws Exception {
//name = "`EH'"; //must have more embedding as we haven't gotten undname to return yet.
- //manufactured and not sure if good example or not... needs to output "`EH'" ???
+ //manufactured and not sure if good example or not... needs to output "`EH'" ???
//TODO: need to look closer... as this must be a function, I think (but so do all of those other operators above).
mangled = "??_QNamespace1@Namespace2@@$$FQAEPAXI@Z";
msTruth = "public: void * __thiscall Namespace2::Namespace1::(unsigned int)";
@@ -7340,7 +7323,7 @@ public class MDMangBaseTest extends AbstractGenericTest {
//Following is OK to move to LOW--test is already on LOW in WineDemanglerTest.
// //TODO: Research this. Not sure about this symbol and result. Came from WineDemanglerTest.
// //MSFT 2015 undname yields: "S358<`template-parameter-2',CHelper_AD::tARootDir,AVCString * const volatile,void,unsigned char, ?? &>"
-// // This is wrong for multiple reasons: "??" and "GetADRoot" -> "tARoot..."
+// // This is wrong for multiple reasons: "??" and "GetADRoot" -> "tARoot..."
// @Test
// public void testOrigTest_bq() throws Exception {
// mangled = "?$S358@?1??GetADRootDir@CHelper_AD@@SA?AVCString@@XZ@4EA";
@@ -7464,7 +7447,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
"void __clrcall `dynamic initializer for 'public: static bool name2::name1::name0''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'public: static bool name2::name1::name0''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -7475,7 +7457,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
"void __clrcall `dynamic initializer for 'public: static bool <name2>::name1::name0''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'public: static bool <name2>::name1::name0''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -8081,7 +8062,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
"void __clrcall `dynamic initializer for 'public: static bool name2::name1::name0''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'public: static bool name2::name1::name0''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -8884,7 +8864,7 @@ public class MDMangBaseTest extends AbstractGenericTest {
// Added Y01 (array) to exercise Override code in MDDataReferenceType. This
// symbol is supposed to fail.
- // Original symbol was: "?var@@3$$CBHA"
+ // Original symbol was: "?var@@3$$CBHA"
// TODO:
// Ultimately $$C (MDDataReferenceType) needs to extend MDModifiedType (not MDModifierType), but MDModifiedType
// is still under construction. The MDArrayReferenceType (Y (Y01)) is only to be found in the MDmodifierType.
@@ -9866,7 +9846,7 @@ public class MDMangBaseTest extends AbstractGenericTest {
// Manufactured --KEEP, Need to add tests for isC and referredToType
@Test
public void testManagedProperties_ai() throws Exception {
- //NEW HAND-MADE
+ //NEW HAND-MADE
mangled = "?FN@@QEAM@BE$AAVCL@@@Z";
msTruth = "public: __clrcall FN(class CL % __ptr64 volatile) __ptr64";
mdTruth = msTruth;
@@ -10522,7 +10502,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
"void __clrcall `dynamic initializer for 'public: static enum name2::name4::name3 name2::name1::name0''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'public: static enum name2::name4::name3 name2::name1::name0''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -10533,7 +10512,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
"void __clrcall `dynamic initializer for 'public: static int name2::name1::name0''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'public: static int name2::name1::name0''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -10544,7 +10522,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
"void __clrcall `dynamic initializer for 'public: static enum name2::name4::name3 name2::name1::name0''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'public: static enum name2::name4::name3 name2::name1::name0''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -10555,7 +10532,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
"void __clrcall `dynamic initializer for 'public: static enum name2::name4::name3 name2::name1::name0''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'public: static enum name2::name4::name3 name2::name1::name0''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -10585,7 +10561,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
"void __clrcall `dynamic initializer for 'private: static class name2::name3<class name5::name4 ^ __ptr64> name2::name1::name0''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'private: static class name2::name3<class name5::name4 ^ __ptr64> name2::name1::name0''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -10596,7 +10571,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
"void __clrcall `dynamic initializer for 'public: static int name2::name1::name0''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'public: static int name2::name1::name0''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -10608,7 +10582,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
"void __clrcall `dynamic atexit destructor for 'private: static class name2::name3<class name5::name4 ^ __ptr64> name2::name1::name0''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic atexit destructor for 'private: static class name2::name3<class name5::name4 ^ __ptr64> name2::name1::name0''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -10619,7 +10592,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
"void __clrcall `dynamic initializer for 'public: static enum name2::name4::name3 name2::name1::name0''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'public: static enum name2::name4::name3 name2::name1::name0''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -10630,7 +10602,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
"void __clrcall `dynamic initializer for 'public: static bool name2::name1::name0''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'public: static bool name2::name1::name0''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -11529,7 +11500,7 @@ public class MDMangBaseTest extends AbstractGenericTest {
demangleAndTest();
}
- //Test showing that we can have a full typeinfo after (note '$' becomes part of name--not template)
+ //Test showing that we can have a full typeinfo after (note '$' becomes part of name--not template)
@Test
public void testCodeView_Simple_01test_with_typeinfo() throws Exception {
mangled = "?@?$name@H@@3HA";
@@ -11599,7 +11570,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
mangled = "?@???__Eabc@@3HA";
msTruth = "CV: int `dynamic initializer for 'abc''";
mdTruth = msTruth;
- ghTruth = "int `dynamic initializer for 'abc''"; //makes typeinfo avail at high level too
demangleAndTest();
}
@@ -11650,7 +11620,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
msTruth = "void __clrcall `dynamic initializer for '__mpnhHeap''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for '__mpnhHeap''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -11707,7 +11676,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
"void __clrcall `dynamic initializer for 'const std::bad_alloc::`vftable'''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'const std::bad_alloc::`vftable'''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -11726,7 +11694,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
msTruth = "void __clrcall `dynamic initializer for '_AtlModule''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for '_AtlModule''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -13775,7 +13742,7 @@ public class MDMangBaseTest extends AbstractGenericTest {
demangleAndTest();
}
- //TODO: Need to do dispatcher for VS2017? vs. VS2015? We do not have VS2017 yet to see what it does.
+ //TODO: Need to do dispatcher for VS2017? vs. VS2015? We do not have VS2017 yet to see what it does.
//TODO (20170331): Need to do some testing/fuzzing with something more up-to-date than VS2015.
//Problem is at location 29-31 where we have a '?' followed by a 'C', which is trying to determine the encoded number, but the 'C'
// is followed by an invalid character 'i' for an encoded number. This sequence is repeated later.
@@ -13931,7 +13898,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
"void __clrcall `dynamic initializer for 'const std::bad_alloc::`vftable'''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'const std::bad_alloc::`vftable'''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -13985,7 +13951,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
msTruth = "void __clrcall `dynamic initializer for 'const bad_cast::`vftable'''(void)";
mdTruth =
"void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'const bad_cast::`vftable'''(void)(void)";
- ghTruth = msTruth;
demangleAndTest();
}
@@ -14443,7 +14408,6 @@ public class MDMangBaseTest extends AbstractGenericTest {
mdTruth =
"[MEP] void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'PBBBMbr''(void)(void)";
msTruth = dbTruth;
- ghTruth = dbTruth;
demangleAndTest();
}
@@ -14590,6 +14554,63 @@ public class MDMangBaseTest extends AbstractGenericTest {
demangleAndTest();
}
+ @Test
+ public void testFunctionIndirectWithBlankCallingConvention() throws Exception {
+ mangled = "?FN@@QAAH$$A6KH@Z@Z";
+ msTruth = "public: int __cdecl FN(int ())";
+ mdTruth = msTruth;
+ demangleAndTest();
+ }
+
+ @Test
+ public void testCPPManagedILMain_1() throws Exception {
+ mangled = "?main@@$$HYAHXZ";
+ msTruth = "int __cdecl main(void)";
+ mdTruth = msTruth;
+ demangleAndTest();
+ }
+
+ @Test
+ // Not happy with this next thing.... might be CPPManagedILDLLImporData, but not yet sure.
+ public void testCPPManagedILDLLImportData_1() throws Exception {
+ mangled =
+ "???__E?Initialized@CurrentDomain@<CrtImplementationDetails>@@$$Q2HA@@YMXXZ@?A0x1ed4f156@@$$FYMXXZ";
+ msTruth =
+ "void __clrcall `dynamic initializer for 'public: static int <CrtImplementationDetails>::CurrentDomain::Initialized''(void)";
+ mdTruth =
+ "void __clrcall `anonymous namespace'::void __clrcall `dynamic initializer for 'public: static int <CrtImplementationDetails>::CurrentDomain::Initialized''(void)(void)";
+ demangleAndTest();
+ }
+
+ @Category(MDMangFailingTestCategory.class)
+ @Test
+ public void testCPPManagedILFunction_1() throws Exception {
+ mangled =
+ "?A0x1ed4f156.??__E?Initialized@CurrentDomain@<CrtImplementationDetails>@@$$Q2HA@@YMXXZ";
+ msTruth = "unknown";
+ mdTruth = msTruth;
+ demangleAndTest();
+ }
+
+ // Temporary counterpoint in trying to figure out the above.
+ @Test
+ public void testXXXCounterpoint2() throws Exception {
+ mangled = ".?AV?$name1@Vname2@@Uname3@name4@@@name4@@";
+ mdTruth = "class name4::name1<class name2,struct name4::name3>";
+ msTruth = mdTruth;
+ demangleAndTest();
+ }
+
+ // Temporary test for trying to fuzz solutions for the above.
+ @Test
+ public void testXXXFuzz() throws Exception {
+ mangled = "??__E?Initialized@CurrentDomain@<CrtImplementationDetails>@@$$Q2HA@@YMXXZ";
+ msTruth =
+ "void __clrcall `dynamic initializer for 'public: static int <CrtImplementationDetails>::CurrentDomain::Initialized''(void)";
+ mdTruth = msTruth;
+ demangleAndTest();
+ }
+
//TODO: ignore for now.
@Ignore
public void testFuzzyFit() throws Exception {