Ghidra is a software reverse engineering (SRE) framework
GP-474 - Add 2 (+3) PDB type records and associated processing; fix fallback type logic; improve warning messages
ghizard294f5454516f
diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/TypeParser.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/TypeParser.javaindex 2464139f43..a8b09f944a 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/TypeParser.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/TypeParser.java@@ -530,6 +530,25 @@ public class TypeParser {type = new UserDefinedTypeModuleSourceAndLineMsType(pdb, reader);//TODO: more workbreak;+ case Class19MsType.PDB_ID:+ type = new Class19MsType(pdb, reader);+ break;+ case Structure19MsType.PDB_ID:+ type = new Structure19MsType(pdb, reader);+ break;+ // TODO: the following three types are only hypothetical and might be in the wrong+ // order with the wrong PDB_IDs and the wrong internal elements and parsing.+ // These are here as partial implementations until they are seen and can be+ // cleaned up and put into service.+// case Union19MsType.PDB_ID:+// type = new Union19MsType(pdb, reader);+// break;+// case Enum19MsType.PDB_ID:+// type = new Enum19MsType(pdb, reader);+// break;+// case Interface19MsType.PDB_ID:+// type = new Interface19MsType(pdb, reader);+// break;default:// This should never happen (unless we missed something// or MSFT has added new in a version we do not handle.diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/AbstractComplexMsType.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/AbstractComplexMsType.javaindex a98145c600..bf5b41736f 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/AbstractComplexMsType.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/AbstractComplexMsType.java@@ -26,8 +26,9 @@ import mdemangler.MDMang;* Enums.*/public abstract class AbstractComplexMsType extends AbstractMsType {-- protected int count;+ // -1 is a flag to prevent the count from being emitted, which is what is desired if there+ // is not a count field for the child type. 0 and up are valid values.+ protected int count = -1;protected RecordNumber fieldDescriptorListRecordNumber;protected MsProperty property;protected String name;diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/AbstractCompositeMsType.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/AbstractCompositeMsType.javaindex dfbae9ecfa..21f3915864 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/AbstractCompositeMsType.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/AbstractCompositeMsType.java@@ -110,8 +110,10 @@ public abstract class AbstractCompositeMsType extends AbstractComplexMsType {myBuilder.append(" ");myBuilder.append(name);myBuilder.append("<");- myBuilder.append(count);- myBuilder.append(",");+ if (count != -1) {+ myBuilder.append(count);+ myBuilder.append(",");+ }myBuilder.append(property);myBuilder.append(">");AbstractMsType fieldType = getFieldDescriptorListType();diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/AbstractEnumMsType.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/AbstractEnumMsType.javaindex 9fa49701f5..c3b874410b 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/AbstractEnumMsType.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/AbstractEnumMsType.java@@ -72,8 +72,10 @@ public abstract class AbstractEnumMsType extends AbstractComplexMsType {myBuilder.append(" ");myBuilder.append(name);myBuilder.append("<");- myBuilder.append(count);- myBuilder.append(",");+ if (count != -1) {+ myBuilder.append(count);+ myBuilder.append(",");+ }myBuilder.append(pdb.getTypeRecord(underlyingRecordNumber));myBuilder.append(",");myBuilder.append(property);diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/Class19MsType.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/Class19MsType.javanew file mode 100644index 0000000000..ec73092f84--- /dev/null+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/Class19MsType.java@@ -0,0 +1,82 @@+/* ###+ * 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.bin.format.pdb2.pdbreader.type;++import ghidra.app.util.bin.format.pdb2.pdbreader.*;++/*+ * TODO this record type is a guess, using only data (no documentation) in its crafting.+ * Thus, it can be cleaned up using trusted, msft-originated documentation if it becomes+ * available and/or using more data analysis and/or non-trusted documentation.+ * We are fairly certain that 0x1608 is some sort of class, but it could be a typedef class.+ */+/**+ * This class represents the VS19 <B>MsType</B> flavor of C++ Class type. (At this time,+ * PDB_ID is guessed to be a class similar to {@link ClassMsType}, eliminating+ * the redundant count field, and adding other unknown field parsing.)+ * <P>+ * Note that class, struct, and interface are very closed related and have many of the same+ * constructs and parsing procedures. However, they are separate. If any of the internals+ * of one of these is changed, it is highly suggested that the others be changed as well as+ * there is not code-shared between these other than by code duplication.+ * <P>+ * Note: we do not necessarily understand each of these data type classes. Refer to the+ * base class for more information.+ */+public class Class19MsType extends AbstractClassMsType {++ public static final int PDB_ID = 0x1608;++ /**+ * Constructor for this type.+ * @param pdb {@link AbstractPdb} to which this type belongs.+ * @param reader {@link PdbByteReader} from which this type is deserialized.+ * @throws PdbException upon error parsing a field.+ */+ public Class19MsType(AbstractPdb pdb, PdbByteReader reader) throws PdbException {+ super(pdb, reader);+ property = new MsProperty(reader);+ int x = reader.parseUnsignedShortVal(); //unknown+ fieldDescriptorListRecordNumber = RecordNumber.parse(pdb, reader, RecordCategory.TYPE, 32);+ derivedFromListRecordNumber = RecordNumber.parse(pdb, reader, RecordCategory.TYPE, 32);+ vShapeTableRecordNumber = RecordNumber.parse(pdb, reader, RecordCategory.TYPE, 32);+ //TODO: has more... guessing below... commented out some other conditions, but we+ // might want to investigate if any data hits them.+ Numeric numericUnknown = new Numeric(reader); //unknown. Might even be just a short.+ Numeric numeric = new Numeric(reader);+ if (!numeric.isIntegral()) {+ throw new PdbException("Expecting integral numeric");+ }+ size = numeric.getIntegral();+ if (reader.hasMoreNonPad()) {+ name = reader.parseString(pdb, StringParseType.StringNt);+ if (reader.hasMoreNonPad()) {+ mangledName = reader.parseString(pdb, StringParseType.StringNt);+ }+// else if (reader.hasMore()) {+// }+ }+// else {+// }+ reader.skipPadding();+ }++ @Override+ public int getPdbId() {+ return PDB_ID;+ }++}diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/Enum19MsType.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/Enum19MsType.javanew file mode 100644index 0000000000..189939ea76--- /dev/null+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/Enum19MsType.java@@ -0,0 +1,83 @@+/* ###+ * 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.bin.format.pdb2.pdbreader.type;++import ghidra.app.util.bin.format.pdb2.pdbreader.*;++/*+ * TODO this record type is a guess, using only data (no documentation) in its crafting.+ * Thus, it can be cleaned up using trusted, msft-originated documentation if it becomes+ * available and/or using more data analysis and/or non-trusted documentation.+ * We believe there must be a union, enum, and interface (stubbed only guesses at PDB_IDs and can+ * be incorrectly assigned) that are similar to the 0x1608 and 0x1609 class and struct classes,+ * and yet similar to their older versions of union, enum, and interface as well.+ */+/**+ * This class represents the VS19 <B>MsType</B> flavor of Enum type. (At this time,+ * PDB_ID is guessed to be an enum similar to {@link EnumMsType}, eliminating+ * the redundant count field, and adding other unknown field parsing.)+ * <P>+ * Note: we do not necessarily understand each of these data type classes. Refer to the+ * base class for more information.+ */+public class Enum19MsType extends AbstractEnumMsType {++ public static final int PDB_ID = 0x160b;++ protected String mangledName;++ /**+ * Constructor for this type.+ * @param pdb {@link AbstractPdb} to which this type belongs.+ * @param reader {@link PdbByteReader} from which this type is deserialized.+ * @throws PdbException upon error parsing a field.+ */+ public Enum19MsType(AbstractPdb pdb, PdbByteReader reader) throws PdbException {+ super(pdb, reader);+ property = new MsProperty(reader);+ int x = reader.parseUnsignedShortVal(); //unknown+ underlyingRecordNumber = RecordNumber.parse(pdb, reader, RecordCategory.TYPE, 32);+ fieldDescriptorListRecordNumber = RecordNumber.parse(pdb, reader, RecordCategory.TYPE, 32);+ //TODO: has more... guessing below... commented out some other conditions, but we+ // might want to investigate if any data hits them.+ if (reader.hasMoreNonPad()) {+ name = reader.parseString(pdb, StringParseType.StringNt);+ if (reader.hasMoreNonPad()) {+ // Additional parsing+ mangledName = reader.parseString(pdb, StringParseType.StringNt);+ }+// else if (reader.hasMore()) {+// }+ }+// else {+// }+ reader.skipPadding();+ }++ @Override+ public int getPdbId() {+ return PDB_ID;+ }++ /**+ * Returns the mangled name field+ * @return Mangled name.+ */+ public String getMangledName() {+ return mangledName;+ }++}diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/Interface19MsType.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/Interface19MsType.javanew file mode 100644index 0000000000..85f948e161--- /dev/null+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/Interface19MsType.java@@ -0,0 +1,109 @@+/* ###+ * 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.bin.format.pdb2.pdbreader.type;++import ghidra.app.util.bin.format.pdb2.pdbreader.*;++/*+ * TODO this record type is a guess, using only data (no documentation) in its crafting.+ * Thus, it can be cleaned up using trusted, msft-originated documentation if it becomes+ * available and/or using more data analysis and/or non-trusted documentation.+ * We believe there must be a union, enum, and interface (stubbed only guesses at PDB_IDs and can+ * be incorrectly assigned) that are similar to the 0x1608 and 0x1609 class and struct classes,+ * and yet similar to their older versions of union, enum, and interface as well.+ * TODO: If this is a actual record type (for VS19), then we need to test it and to consider an+ * abstract interface type (and also consider whether the emit should belong in the abstract+ * composite type).+ */+/**+ * This class represents the VS19 <B>MsType</B> flavor of Interface type. (At this time,+ * PDB_ID is guessed to be a class similar to {@link InterfaceMsType}, eliminating+ * the redundant count field, and adding other unknown field parsing.)+ * <P>+ * Note that class, struct, and interface are very closed related and have many of the same+ * constructs and parsing procedures. However, they are separate. If any of the internals+ * of one of these is changed, it is highly suggested that the others be changed as well as+ * there is not code-shared between these other than by code duplication.+ * <P>+ * Note: we do not necessarily understand each of these data type classes. Refer to the+ * base class for more information.+ */+public class Interface19MsType extends AbstractCompositeMsType {++ public static final int PDB_ID = 0x160c;++ private static final String TYPE_STRING = "interface";++ /**+ * Constructor for this type.+ * @param pdb {@link AbstractPdb} to which this type belongs.+ * @param reader {@link PdbByteReader} from which this type is deserialized.+ * @throws PdbException upon error parsing a field.+ */+ public Interface19MsType(AbstractPdb pdb, PdbByteReader reader) throws PdbException {+ super(pdb, reader);+ property = new MsProperty(reader);+ int x = reader.parseUnsignedShortVal(); //unknown+ fieldDescriptorListRecordNumber = RecordNumber.parse(pdb, reader, RecordCategory.TYPE, 32);+ derivedFromListRecordNumber = RecordNumber.parse(pdb, reader, RecordCategory.TYPE, 32);+ vShapeTableRecordNumber = RecordNumber.parse(pdb, reader, RecordCategory.TYPE, 32);+ //TODO: has more... guessing below... commented out some other conditions, but we+ // might want to investigate if any data hits them.+ Numeric numericUnknown = new Numeric(reader); //unknown. Might even be just a short.+ Numeric numeric = new Numeric(reader);+ if (!numeric.isIntegral()) {+ throw new PdbException("Expecting integral numeric");+ }+ size = numeric.getIntegral();+ if (reader.hasMoreNonPad()) {+ name = reader.parseString(pdb, StringParseType.StringNt);+ if (reader.hasMoreNonPad()) {+ mangledName = reader.parseString(pdb, StringParseType.StringNt);+ }+// else if (reader.hasMore()) {+// }+ }+// else {+// }+ reader.skipPadding();+ }++ @Override+ public int getPdbId() {+ return PDB_ID;+ }++ @Override+ public void emit(StringBuilder builder, Bind bind) {+ StringBuilder myBuilder = new StringBuilder();+ myBuilder.append(getTypeString());+ myBuilder.append(" ");+ myBuilder.append(name);+ myBuilder.append("<");+ myBuilder.append(property);+ myBuilder.append(">");+ AbstractMsType fieldType = getFieldDescriptorListType();+ myBuilder.append(fieldType);+ myBuilder.append(" ");+ builder.insert(0, myBuilder);+ }++ @Override+ protected String getTypeString() {+ return TYPE_STRING;+ }++}diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/Structure19MsType.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/Structure19MsType.javanew file mode 100644index 0000000000..0266555aab--- /dev/null+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/Structure19MsType.java@@ -0,0 +1,82 @@+/* ###+ * 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.bin.format.pdb2.pdbreader.type;++import ghidra.app.util.bin.format.pdb2.pdbreader.*;++/*+ * TODO this record type is a guess, using only data (no documentation) in its crafting.+ * Thus, it can be cleaned up using trusted, msft-originated documentation if it becomes+ * available and/or using more data analysis and/or non-trusted documentation.+ * /We are fairly certain that 0x1609 is some sort of struct, but it could be a typedef struct.+ */+/**+ * This class represents the VS19 <B>MsType</B> flavor of C/C++ Struct type. (At this time,+ * PDB_ID is guessed to be a structure similar to {@link StructureMsType}, eliminating+ * the redundant count field, and adding other unknown field parsing.)+ * <P>+ * Note that class, struct, and interface are very closed related and have many of the same+ * constructs and parsing procedures. However, they are separate. If any of the internals+ * of one of these is changed, it is highly suggested that the others be changed as well as+ * there is not code-shared between these other than by code duplication.+ * <P>+ * Note: we do not necessarily understand each of these data type classes. Refer to the+ * base class for more information.+ */+public class Structure19MsType extends AbstractStructureMsType {++ public static final int PDB_ID = 0x1609;++ /**+ * Constructor for this type.+ * @param pdb {@link AbstractPdb} to which this type belongs.+ * @param reader {@link PdbByteReader} from which this type is deserialized.+ * @throws PdbException upon error parsing a field.+ */+ public Structure19MsType(AbstractPdb pdb, PdbByteReader reader) throws PdbException {+ super(pdb, reader);+ property = new MsProperty(reader);+ int x = reader.parseUnsignedShortVal(); //unknown+ fieldDescriptorListRecordNumber = RecordNumber.parse(pdb, reader, RecordCategory.TYPE, 32);+ derivedFromListRecordNumber = RecordNumber.parse(pdb, reader, RecordCategory.TYPE, 32);+ vShapeTableRecordNumber = RecordNumber.parse(pdb, reader, RecordCategory.TYPE, 32);+ //TODO: has more... guessing below... commented out some other conditions, but we+ // might want to investigate if any data hits them.+ Numeric numericUnknown = new Numeric(reader); //unknown. Might even be just a short.+ Numeric numeric = new Numeric(reader);+ if (!numeric.isIntegral()) {+ throw new PdbException("Expecting integral numeric");+ }+ size = numeric.getIntegral();+ if (reader.hasMoreNonPad()) {+ name = reader.parseString(pdb, StringParseType.StringNt);+ if (reader.hasMoreNonPad()) {+ mangledName = reader.parseString(pdb, StringParseType.StringNt);+ }+// else if (reader.hasMore()) {+// }+ }+// else {+// }+ reader.skipPadding();+ }++ @Override+ public int getPdbId() {+ return PDB_ID;+ }++}diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/Union19MsType.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/Union19MsType.javanew file mode 100644index 0000000000..2432ff6aa1--- /dev/null+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/Union19MsType.java@@ -0,0 +1,83 @@+/* ###+ * 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.bin.format.pdb2.pdbreader.type;++import ghidra.app.util.bin.format.pdb2.pdbreader.*;++/*+ * TODO this record type is a guess, using only data (no documentation) in its crafting.+ * Thus, it can be cleaned up using trusted, msft-originated documentation if it becomes+ * available and/or using more data analysis and/or non-trusted documentation.+ * We believe there must be a union, enum, and interface (stubbed only guesses at PDB_IDs and can+ * be incorrectly assigned) that are similar to the 0x1608 and 0x1609 class and struct classes,+ * and yet similar to their older versions of union, enum, and interface as well.+ */+/**+ * This class represents the VS19 <B>MsType</B> flavor of C/C++ Union type. (At this time,+ * PDB_ID is guessed to be an enum similar to {@link EnumMsType}, eliminating+ * the redundant count field, and adding other unknown field parsing.)+ * <P>+ * Note that class, struct, and interface are very closed related and have many of the same+ * constructs and parsing procedures. However, they are separate. If any of the internals+ * of one of these is changed, it is highly suggested that the others be changed as well as+ * there is not code-shared between these other than by code duplication.+ * <P>+ * Note: we do not necessarily understand each of these data type classes. Refer to the+ * base class for more information.+ */+public class Union19MsType extends AbstractUnionMsType {++ public static final int PDB_ID = 0x160a;++ /**+ * Constructor for this type.+ * @param pdb {@link AbstractPdb} to which this type belongs.+ * @param reader {@link PdbByteReader} from which this type is deserialized.+ * @throws PdbException upon error parsing a field.+ */+ public Union19MsType(AbstractPdb pdb, PdbByteReader reader) throws PdbException {+ super(pdb, reader);+ property = new MsProperty(reader);+ int x = reader.parseUnsignedShortVal(); //unknown+ fieldDescriptorListRecordNumber = RecordNumber.parse(pdb, reader, RecordCategory.TYPE, 32);+ // no derivedFromListRecordNumber or vShapeTableRecordNumber+ //TODO: has more... guessing below... commented out some other conditions, but we+ // might want to investigate if any data hits them.+ Numeric numericUnknown = new Numeric(reader); //unknown. Might even be just a short.+ Numeric numeric = new Numeric(reader);+ if (!numeric.isIntegral()) {+ throw new PdbException("Expecting integral numeric");+ }+ size = numeric.getIntegral();+ if (reader.hasMoreNonPad()) {+ name = reader.parseString(pdb, StringParseType.StringNt);+ if (reader.hasMoreNonPad()) {+ mangledName = reader.parseString(pdb, StringParseType.StringNt);+ }+// else if (reader.hasMore()) {+// }+ }+// else {+// }+ reader.skipPadding();+ }++ @Override+ public int getPdbId() {+ return PDB_ID;+ }++}diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/ArgumentsListTypeApplier.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/ArgumentsListTypeApplier.javaindex 872512e445..81de55596a 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/ArgumentsListTypeApplier.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/ArgumentsListTypeApplier.java@@ -135,16 +135,36 @@ public class ArgumentsListTypeApplier extends MsTypeApplier {DataType argDataType = argApplier.getDataType();if (argDataType == null) {- String message =+ applicator.appendLogMsg("PDB Warning: No type conversion for " + argApplier.getMsType().toString() +- " for parameter " + parameterCount + " of " + functionDefinition.getName();- applicator.appendLogMsg(message);+ " for parameter " + parameterCount + " of " + functionDefinition.getName());}else {- ParameterDefinition parameterDefinition =- new ParameterDefinitionImpl(null, argDataType, "");- parameterDefinitionList.add(parameterDefinition);- parameterCount++;+ try {+ ParameterDefinition parameterDefinition =+ new ParameterDefinitionImpl(null, argDataType, "");+ parameterDefinitionList.add(parameterDefinition);+ parameterCount++;+ }+ catch (IllegalArgumentException e) {+ try {+ DataType substitute =+ Undefined.getUndefinedDataType(argDataType.getLength());+ ParameterDefinition parameterDefinition =+ new ParameterDefinitionImpl(null, substitute, "");+ parameterDefinitionList.add(parameterDefinition);+ parameterCount++;+ applicator.appendLogMsg("PDB Warning: Could not apply type " + argDataType ++ " for parameter " + parameterCount + " of " ++ functionDefinition.getName() + ". Using undefined type instead.");+ }+ catch (IllegalArgumentException e1) {+ applicator.appendLogMsg("PDB Warning: Could not apply type " + argDataType ++ " for parameter " + parameterCount + " of " ++ functionDefinition.getName() + ". Undefined failed: " + e1);++ }+ }}}functionDefinition.setArguments(parameterDefinitionList.toArray(diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/FunctionSymbolApplier.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/FunctionSymbolApplier.javaindex 586055f5f9..8fb88b10c4 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/FunctionSymbolApplier.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/FunctionSymbolApplier.java@@ -309,7 +309,8 @@ public class FunctionSymbolApplier extends MsSymbolApplier {new ApplyFunctionSignatureCmd(address, def, SourceType.IMPORTED);if (!sigCmd.applyTo(applicator.getProgram(), monitor)) {applicator.appendLogMsg(- "failed to apply signature to function at address " + address.toString());+ "PDB Warning: Failed to apply signature to function at address " + address ++ " due to " + sigCmd.getStatusMsg() + "; dataType: " + def.getName());return false;}}diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PdbApplicator.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PdbApplicator.javaindex 9c2fd53c5c..2d10d2f3eb 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PdbApplicator.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PdbApplicator.java@@ -552,8 +552,7 @@ public class PdbApplicator {int num = pdb.getDebugInfo().getNumModules();for (int index = 1; index <= num; index++) {monitor.checkCanceled();- String moduleName =- pdb.getDebugInfo().getModuleInformation(index).getModuleName();+ String moduleName = pdb.getDebugInfo().getModuleInformation(index).getModuleName();categoryNames.add(moduleName);}@@ -1266,7 +1265,9 @@ public class PdbApplicator {NamespaceUtils.getNonFunctionNamespace(program, path.getParent());if (parentNamespace == null) {String type = isClass ? "class" : "namespace";- log.appendMsg("Error: failed to define " + type + ": " + path);+ log.appendMsg(+ "PDB Warning: Because parent namespace does not exist, failed to define " ++ type + ": " + path);continue;}defineNamespace(parentNamespace, path.getName(), isClass);@@ -1294,8 +1295,9 @@ public class PdbApplicator {else if (namespace.getSymbol().getSymbolType() == SymbolType.NAMESPACE) {return;}- log.appendMsg("Unable to create class namespace due to conflicting symbol: " +- namespace.getName(true));+ log.appendMsg(+ "PDB Warning: Unable to create class namespace due to conflicting symbol: " ++ namespace.getName(true));}else if (isClass) {symbolTable.createClass(parentNamespace, name, SourceType.IMPORTED);@@ -1305,8 +1307,9 @@ public class PdbApplicator {}}catch (InvalidInputException | DuplicateNameException e) {- log.appendMsg("Unable to create class namespace: " + parentNamespace.getName(true) +- Namespace.DELIMITER + name + " due to exception: " + e.toString());+ log.appendMsg(+ "PDB Warning: Unable to create class namespace due to exception: " + e.toString() ++ "; Namespace: " + parentNamespace.getName(true) + Namespace.DELIMITER + name);}}@@ -1407,7 +1410,7 @@ public class PdbApplicator {return true;}catch (InvalidInputException e) {- log.appendMsg("Unable to create symbol: " + e.getMessage());+ log.appendMsg("PDB Warning: Unable to create symbol: " + e.getMessage());}return false;}@@ -1532,7 +1535,8 @@ public class PdbApplicator {namespace, name, SourceType.IMPORTED);}catch (InvalidInputException e) {- appendLogMsg("Unable to create symbol " + symbolPathString + " at " + address);+ log.appendMsg("PDB Warning: Unable to create symbol at " + address ++ " due to exception: " + e.toString() + "; symbolPathName: " + symbolPathString);}return symbol;}diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PointerTypeApplier.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PointerTypeApplier.javaindex 719dd045aa..d82b377af7 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PointerTypeApplier.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/PointerTypeApplier.java@@ -93,11 +93,13 @@ public class PointerTypeApplier extends MsTypeApplier {if (underlyingType == null) {// TODO: we have seen underlyingTypeApplier is for NoTypeApplier for VtShapeMsType// Figure it out, and perhaps create an applier that creates a structure or something?- return new VoidDataType(applicator.getDataTypeManager());-// throw new PdbException("Underlying type missing for pointer.");+ underlyingType = applicator.getPdbPrimitiveTypeApplicator().getVoidType();+ applicator.appendLogMsg(+ "PDB Warning: No type conversion for " + underlyingApplier.getMsType().toString() ++ " as underlying type for pointer. Using void.");}- int size = getSizeInt();+ int size = type.getSize().intValueExact();if (size == applicator.getDataOrganization().getPointerSize()) {size = -1; // Use default}diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/TypeApplierFactory.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/TypeApplierFactory.javaindex f4445884b4..b5d499f45e 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/TypeApplierFactory.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/TypeApplierFactory.java@@ -494,6 +494,29 @@ public class TypeApplierFactory {case UserDefinedTypeModuleSourceAndLineMsType.PDB_ID:applier = new UdtSourceLineTypeApplier(applicator, type);break;+ case Class19MsType.PDB_ID:+ applier = new CompositeTypeApplier(applicator, (Class19MsType) type);+ break;+ case Structure19MsType.PDB_ID:+ applier = new CompositeTypeApplier(applicator, (Structure19MsType) type);+ break;+ // TODO: the following three types are only hypothetical and might be in the wrong+ // order with the wrong PDB_IDs and the wrong internal elements and parsing.+ // These are here as partial implementations until they are seen and can be+ // cleaned up and put into service.+// case Union19MsType.PDB_ID:+// applier = new CompositeTypeApplier(applicator, (Union19MsType) type);+// break;+// case Enum19MsType.PDB_ID:+// applier = new EnumTypeApplier(applicator, (Enum19MsType) type);+// break;+// case Interface19MsType.PDB_ID:+// // TODO InterfaceTypeApplier does not exist, and the two types we would+// // want to send it would need to either be abstracted to one abstract type+// // or a generic AbstractMsType would have to be sent and then verified+// // internal to the applier.+// applier = new InterfaceTypeApplier(applicator, (Interface19MsType) type);+// break;// If all of the above are enabled, this should never happen (unless we missed// something or MSFT has added new in a version we do not handle.diff --git a/Ghidra/Features/PDB/src/test/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/TypesTest.java b/Ghidra/Features/PDB/src/test/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/TypesTest.javaindex eef52c1238..4001e78165 100644--- a/Ghidra/Features/PDB/src/test/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/TypesTest.java+++ b/Ghidra/Features/PDB/src/test/java/ghidra/app/util/bin/format/pdb2/pdbreader/type/TypesTest.java@@ -401,6 +401,29 @@ public class TypesTest extends AbstractGenericTest {assertEquals("class ClassName<2,packed ctor>DummyMsType", result);}+ //TODO: Might need adjusting fields of record are understood.+ @Test+ public void testClass19MsType() throws Exception {+ PdbByteWriter writer = new PdbByteWriter();+ writer.putUnsignedShort(Class19MsType.PDB_ID);+ byte[] propertyBuffer = createMsPropertyBuffer();+ writer.putBytes(propertyBuffer);+ writer.putUnsignedShort(0); // unknown field+ writer.putUnsignedInt(4096); // Type index of field descriptor list.+ writer.putUnsignedInt(4096); // If not zero, is type index of derived-from list+ writer.putUnsignedInt(vtShapeMsType1); // Type index of the VtShapeMsType (vshape table).+ writer.putNumeric(new BigInteger("0", 16), 0x8002); // unk field. Not sure if Numeric+ writer.putNumeric(new BigInteger("10", 16), 0x8002); // size of class.+ writer.putNullTerminatedString("ClassName");+ writer.putNullTerminatedString("OtherName");+ writer.putAlign(2);+ PdbByteReader reader = new PdbByteReader(writer.get());+ AbstractMsType type = typeParser.parse(reader);+ assertEquals(type instanceof Class19MsType, true);+ String result = type.toString().trim();+ assertEquals("class ClassName<packed ctor>DummyMsType", result);+ }+@Testpublic void testStructure16MsType() throws Exception {PdbByteWriter writer = new PdbByteWriter();@@ -463,6 +486,29 @@ public class TypesTest extends AbstractGenericTest {assertEquals("struct StructureName<2,packed ctor>DummyMsType", result);}+ //TODO: Might need adjusting fields of record are understood.+ @Test+ public void testStructure19MsType() throws Exception {+ PdbByteWriter writer = new PdbByteWriter();+ writer.putUnsignedShort(Structure19MsType.PDB_ID);+ byte[] propertyBuffer = createMsPropertyBuffer();+ writer.putBytes(propertyBuffer);+ writer.putUnsignedShort(0); // unknown field+ writer.putUnsignedInt(4096); // Type index of field descriptor list.+ writer.putUnsignedInt(4096); // If not zero, is type index of derived-from list+ writer.putUnsignedInt(vtShapeMsType1); // Type index of the VtShapeMsType (vshape table).+ writer.putNumeric(new BigInteger("0", 16), 0x8002); // unk field. Not sure if Numeric+ writer.putNumeric(new BigInteger("10", 16), 0x8002); // size of structure.+ writer.putNullTerminatedString("StructureName");+ writer.putNullTerminatedString("OtherName");+ writer.putAlign(2);+ PdbByteReader reader = new PdbByteReader(writer.get());+ AbstractMsType type = typeParser.parse(reader);+ assertEquals(type instanceof Structure19MsType, true);+ String result = type.toString().trim();+ assertEquals("struct StructureName<packed ctor>DummyMsType", result);+ }+@Testpublic void testInterfaceMsType() throws Exception {PdbByteWriter writer = new PdbByteWriter();@@ -484,15 +530,38 @@ public class TypesTest extends AbstractGenericTest {assertEquals("interface InterfaceName<2,packed ctor>DummyMsType", result);}+ //TODO: Hypothetical type... will need adjusting as record type is adjusted.+// @Test+// public void testInterface19MsType() throws Exception {+// PdbByteWriter writer = new PdbByteWriter();+// writer.putUnsignedShort(Interface19MsType.PDB_ID);+// byte[] propertyBuffer = createMsPropertyBuffer();+// writer.putBytes(propertyBuffer);+// writer.putUnsignedShort(0); // unknown field+// writer.putUnsignedInt(4096); // Type index of field descriptor list.+// writer.putUnsignedInt(4096); // If not zero, is type index of derived-from list+// writer.putUnsignedInt(vtShapeMsType1); // Type index of the VtShapeMsType (vshape table).+// writer.putNumeric(new BigInteger("0", 16), 0x8002); // unk field. Not sure if Numeric+// writer.putNumeric(new BigInteger("10", 16), 0x8002); // size of interface.+// writer.putNullTerminatedString("InterfaceName");+// writer.putNullTerminatedString("OtherName");+// writer.putAlign(2);+// PdbByteReader reader = new PdbByteReader(writer.get());+// AbstractMsType type = typeParser.parse(reader);+// assertEquals(type instanceof Interface19MsType, true);+// String result = type.toString().trim();+// assertEquals("interface InterfaceName<packed ctor>DummyMsType", result);+// }+@Testpublic void testUnion16MsType() throws Exception {PdbByteWriter writer = new PdbByteWriter();writer.putUnsignedShort(Union16MsType.PDB_ID);- writer.putUnsignedShort(2); // Count of number of elements in the class.+ writer.putUnsignedShort(2); // Count of number of elements in the union.writer.putUnsignedShort(4096); // Type index of field descriptor list.byte[] propertyBuffer = createMsPropertyBuffer();writer.putBytes(propertyBuffer);- writer.putNumeric(new BigInteger("10", 16), 0x8002); // size of class.+ writer.putNumeric(new BigInteger("10", 16), 0x8002); // size of union.writer.putByteLengthPrefixedString("UnionName16");writer.putPadding(2);PdbByteReader reader = new PdbByteReader(writer.get());@@ -506,11 +575,11 @@ public class TypesTest extends AbstractGenericTest {public void testUnionStMsType() throws Exception {PdbByteWriter writer = new PdbByteWriter();writer.putUnsignedShort(UnionStMsType.PDB_ID);- writer.putUnsignedShort(2); // Count of number of elements in the class.+ writer.putUnsignedShort(2); // Count of number of elements in the union.byte[] propertyBuffer = createMsPropertyBuffer();writer.putBytes(propertyBuffer);writer.putUnsignedInt(4096); // Type index of field descriptor list.- writer.putNumeric(new BigInteger("10", 16), 0x8002); // size of class.+ writer.putNumeric(new BigInteger("10", 16), 0x8002); // size of union.writer.putByteLengthPrefixedString("UnionNameSt");writer.putByteLengthPrefixedString("OtherNameSt");writer.putAlign(2);@@ -525,11 +594,11 @@ public class TypesTest extends AbstractGenericTest {public void testUnionMsType() throws Exception {PdbByteWriter writer = new PdbByteWriter();writer.putUnsignedShort(UnionMsType.PDB_ID);- writer.putUnsignedShort(2); // Count of number of elements in the class.+ writer.putUnsignedShort(2); // Count of number of elements in the union.byte[] propertyBuffer = createMsPropertyBuffer();writer.putBytes(propertyBuffer);writer.putUnsignedInt(4096); // Type index of field descriptor list.- writer.putNumeric(new BigInteger("10", 16), 0x8002); // size of class.+ writer.putNumeric(new BigInteger("10", 16), 0x8002); // size of union.writer.putNullTerminatedString("UnionName");writer.putNullTerminatedString("OtherName");writer.putAlign(2);@@ -540,6 +609,27 @@ public class TypesTest extends AbstractGenericTest {assertEquals("union UnionName<2,packed ctor>DummyMsType", result);}+ //TODO: Hypothetical type... will need adjusting as record type is adjusted.+// @Test+// public void testUnion19MsType() throws Exception {+// PdbByteWriter writer = new PdbByteWriter();+// writer.putUnsignedShort(Union19MsType.PDB_ID);+// byte[] propertyBuffer = createMsPropertyBuffer();+// writer.putBytes(propertyBuffer);+// writer.putUnsignedShort(0); // unknown field+// writer.putUnsignedInt(4096); // Type index of field descriptor list.+// writer.putNumeric(new BigInteger("0", 16), 0x8002); // unk field. Not sure if Numeric+// writer.putNumeric(new BigInteger("10", 16), 0x8002); // size of union.+// writer.putNullTerminatedString("UnionName");+// writer.putNullTerminatedString("OtherName");+// writer.putAlign(2);+// PdbByteReader reader = new PdbByteReader(writer.get());+// AbstractMsType type = typeParser.parse(reader);+// assertEquals(type instanceof Union19MsType, true);+// String result = type.toString().trim();+// assertEquals("union UnionName<packed ctor>DummyMsType", result);+// }+@Testpublic void testEnum16MsType() throws Exception {PdbByteWriter writer = new PdbByteWriter();@@ -596,6 +686,26 @@ public class TypesTest extends AbstractGenericTest {assertEquals("enum EnumName<2,DummyMsType,packed ctor>DummyMsType", result);}+ //TODO: Hypothetical type... will need adjusting as record type is adjusted.+// @Test+// public void testEnum19MsType() throws Exception {+// PdbByteWriter writer = new PdbByteWriter();+// writer.putUnsignedShort(Enum19MsType.PDB_ID);+// byte[] propertyBuffer = createMsPropertyBuffer();+// writer.putBytes(propertyBuffer);+// writer.putUnsignedShort(0); // unknown field+// writer.putUnsignedInt(4096); // Underlying type index.+// writer.putUnsignedInt(4096); // Type index of field descriptor list.+// writer.putNullTerminatedString("EnumName");+// writer.putNullTerminatedString("OtherName");+// writer.putAlign(2);+// PdbByteReader reader = new PdbByteReader(writer.get());+// AbstractMsType type = typeParser.parse(reader);+// assertEquals(type instanceof Enum19MsType, true);+// String result = type.toString().trim();+// assertEquals("enum EnumName<DummyMsType,packed ctor>DummyMsType", result);+// }+@Testpublic void testProcedure16MsType() throws Exception {PdbByteWriter writer = new PdbByteWriter();