Ghidra is a software reverse engineering (SRE) framework
GT-2731 More changes from first review. Enums and javadoc on getters.
ghizardf0a59426af7c
diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/DelimiterState.java b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/DelimiterState.javaindex 5cc2afde98..4b7f3ad2ee 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/DelimiterState.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/DelimiterState.java@@ -42,6 +42,20 @@ public class DelimiterState {first = true;}+ /**+ * Method that adds delimiter information (based on the state to the {@link String}+ * representation of the input object. The boolean argument is available to give the+ * caller a single-line way of calling the method in a conditional sense (i.e., eliminates+ * the need for a conditional block wrapping the call).+ * @param output True: act as though called; false: act as though call was not made.+ * @param obj {@link Object} to be output.+ * @return {@link String} result that contains the {@link AbstractParsableItem} and any+ * delimiter output based on the state.+ */+ public String out(boolean output, Object obj) {+ return out(output, String.valueOf(obj));+ }+/*** Method that adds delimiter information (based on the state to the {@link String}* representation of the input argument. The boolean argument is available to give thediff --git a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/symbol/RegisterName.java b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/symbol/RegisterName.javaindex 2e9413ccfe..0723fa9a04 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/symbol/RegisterName.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/symbol/RegisterName.java@@ -865,8 +865,8 @@ public class RegisterName extends AbstractParsableItem {}/**- * Tells whether the property is true.- * @return Truth about the property.+ * Tells if there is no register.+ * @return True if there is no register.*/public boolean isRegNone() {return (register == 0);diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/AbstractMethodRecordMs.java b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/AbstractMethodRecordMs.javaindex 320173db49..4acbf9de1c 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/AbstractMethodRecordMs.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/AbstractMethodRecordMs.java@@ -50,7 +50,7 @@ public abstract class AbstractMethodRecordMs extends AbstractParsableItem {builder.append(attributes);builder.append(": ");builder.append(pdb.getTypeRecord(procedureRecordNumber.get()));- if (attributes.getPropertyVal() == 4) {+ if (attributes.getProperty() == ClassFieldMsAttributes.Property.INTRO) {builder.append(",");builder.append(optionalOffset);}diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/AbstractOneMethodMsType.java b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/AbstractOneMethodMsType.javaindex 0be0e2b768..e62b6c59fc 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/AbstractOneMethodMsType.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/AbstractOneMethodMsType.java@@ -40,7 +40,8 @@ public abstract class AbstractOneMethodMsType extends AbstractMsType {pdb.pushDependencyStack(new CategoryIndex(CategoryIndex.Category.DATA, procedureTypeRecordIndex.get()));pdb.popDependencyStack();- if ((attribute.getPropertyVal() == 0x04) || (attribute.getPropertyVal() == 0x06)) {+ if ((attribute.getProperty() == ClassFieldMsAttributes.Property.INTRO) ||+ (attribute.getProperty() == ClassFieldMsAttributes.Property.INTRO_PURE)) {offsetInVFTableIfIntroVirtual = reader.parseUnsignedIntVal();}else {diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/AbstractPointerMsType.java b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/AbstractPointerMsType.javaindex 0c5126c439..dd921add67 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/AbstractPointerMsType.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/AbstractPointerMsType.java@@ -15,91 +15,158 @@*/package ghidra.pdb.pdbreader.type;+import java.util.HashMap;+import java.util.Map;+import ghidra.pdb.PdbByteReader;import ghidra.pdb.PdbException;import ghidra.pdb.pdbreader.*;public abstract class AbstractPointerMsType extends AbstractMsType {- private static final int TYPE_NEAR = 0x00; // 16-bit pointer- private static final int TYPE_FAR = 0x01; // 16:16 far pointer- private static final int TYPE_HUGE = 0x02; // 16:16 huge pointer- private static final int TYPE_SEGMENT_BASED = 0x03;- private static final int TYPE_VALUE_BASED = 0x04;- private static final int TYPE_SEGMENT_VALUE_BASED = 0x05;- private static final int TYPE_ADDRESS_BASED = 0x06;- private static final int TYPE_SEGMENT_ADDRESS_BASED = 0x07;- private static final int TYPE_TYPE_BASED = 0x08;- private static final int TYPE_SELF_BASED = 0x09;- private static final int TYPE_NEAR32 = 0x0a; // 32-bit pointer- private static final int TYPE_FAR32 = 0x0b; // 16:32 pointer- private static final int TYPE_PTR64 = 0x0c; // 64-bit pointer-- private static final String[] TYPE_STRING = new String[14];- static {- TYPE_STRING[0] = "near";- TYPE_STRING[1] = "far";- TYPE_STRING[2] = "huge";- TYPE_STRING[3] = "base(seg)";- TYPE_STRING[4] = "base(val)";- TYPE_STRING[5] = "base(segval)";- TYPE_STRING[6] = "base(addr)";- TYPE_STRING[7] = "base(segaddr)";- TYPE_STRING[8] = "base(type)";- TYPE_STRING[9] = "base(self)";- TYPE_STRING[10] = "";- TYPE_STRING[11] = "far32";- TYPE_STRING[12] = "far64";- TYPE_STRING[13] = "unspecified";+ public enum PointerType {++ INVALID("invalid", -1),+ NEAR("near", 0), // 16-bit pointer+ FAR("far", 1), // 16:16 far pointer+ HUGE("huge", 2), // 16:16 huge pointer+ SEGMENT_BASED("base(seg)", 3),+ VALUE_BASED("base(val)", 4),+ SEGMENT_VALUE_BASED("base(segval)", 5),+ ADDRESS_BASED("base(addr)", 6),+ SEGMENT_ADDRESS_BASED("base(segaddr)", 7),+ TYPE_BASED("base(type)", 8),+ SELF_BASED("base(addr)", 9),+ NEAR32("", 10), // 32-bit pointer+ FAR32("far32", 11), // 16:32 pointer+ PTR64("far64", 12), // 64-bit pointer+ UNSPECIFIED("unspecified", 13);++ private static final Map<Integer, PointerType> BY_VALUE = new HashMap<>();+ static {+ for (PointerType val : values()) {+ BY_VALUE.put(val.value, val);+ }+ }++ public final String label;+ public final int value;++ @Override+ public String toString() {+ return label;+ }++ public static PointerType fromValue(int val) {+ return BY_VALUE.getOrDefault(val, INVALID);+ }++ private PointerType(String label, int value) {+ this.label = label;+ this.value = value;+ }+}- private static final int MODE_POINTER = 0x00; // Normal- private static final int MODE_OLD_REFERENCE = 0x01; // Same as LVALUE_REFERENCE- private static final int MODE_LVALUE_REFERENCE = 0x01; // Same as OLD_REFERENCE- private static final int MODE_MEMBER_DATA_POINTER = 0x02;- private static final int MODE_MEMBER_FUNCTION_POINTER = 0x03;- private static final int MODE_RVALUE_REFERENCE = 0x04;- private static final int MODE_RESERVED = 0x05;-- private static final String[] MEMBER_POINTER_ATTRIBUTE_STRING = new String[14];- static {- MEMBER_POINTER_ATTRIBUTE_STRING[0] = "pdm16_nonvirt";- MEMBER_POINTER_ATTRIBUTE_STRING[1] = "pdm16_vfcn";- MEMBER_POINTER_ATTRIBUTE_STRING[2] = "pdm16_vbase";- MEMBER_POINTER_ATTRIBUTE_STRING[3] = "pdm32_nvvfcn";- MEMBER_POINTER_ATTRIBUTE_STRING[4] = "pdm32_vbase";- MEMBER_POINTER_ATTRIBUTE_STRING[5] = "pmf16_nearnvsa";- MEMBER_POINTER_ATTRIBUTE_STRING[6] = "pmf16_nearnvma";- MEMBER_POINTER_ATTRIBUTE_STRING[7] = "pmf16_nearvbase";- MEMBER_POINTER_ATTRIBUTE_STRING[8] = "pmf16_farnvsa";- MEMBER_POINTER_ATTRIBUTE_STRING[9] = "pmf16_farnvma";- MEMBER_POINTER_ATTRIBUTE_STRING[10] = "pmf16_farvbase";- MEMBER_POINTER_ATTRIBUTE_STRING[11] = "pmf32_nvsa";- MEMBER_POINTER_ATTRIBUTE_STRING[12] = "pmf32_nvma";- MEMBER_POINTER_ATTRIBUTE_STRING[13] = "pmf32_vbase";+ public enum PointerMode {++ INVALID("", -1), // Our default+ POINTER("*", 0), // Normal+ LVALUE_REFERENCE("&", 1), // Same as older style reference+ MEMBER_DATA_POINTER("::*", 2),+ MEMBER_FUNCTION_POINTER("::*", 3),+ RVALUE_REFERENCE("&&", 4),+ RESERVED("", 5);++ private static final Map<Integer, PointerMode> BY_VALUE = new HashMap<>();+ static {+ for (PointerMode val : values()) {+ BY_VALUE.put(val.value, val);+ }+ }++ public final String label;+ public final int value;++ /**+ * Emits {@link String} output of this class into the provided {@link StringBuilder}.+ * @param builder The {@link StringBuilder} into which the output is created.+ */+ public void emit(StringBuilder builder) {+ builder.append(this.getClass().getSimpleName());+ }++ @Override+ public String toString() {+ return label;+ }++ public static PointerMode fromValue(int val) {+ return BY_VALUE.getOrDefault(val, INVALID);+ }++ private PointerMode(String label, int value) {+ this.label = label;+ this.value = value;+ }+}- private static final int MEMBER_POINTER_UNSPECIFIED = 0x00;- private static final int MEMBER_POINTER_DATA_SINGLE_INHERITANCE = 0x01;- private static final int MEMBER_POINTER_DATA_MULTIPLE_INHERITANCE = 0x02;- private static final int MEMBER_POINTER_DATA_VIRTUAL_INHERITANCE = 0x03;- private static final int MEMBER_POINTER_DATA_GENERAL = 0x04;- private static final int MEMBER_POINTER_FUNCTION_SINGLE_INHERITANCE = 0x05;- private static final int MEMBER_POINTER_FUNCTION_MULTIPLE_INHERITANCE = 0x06;- private static final int MEMBER_POINTER_FUNCTION_VIRTUAL_INHERITANCE = 0x07;- private static final int MEMBER_POINTER_FUNCTION_GENERAL = 0x08;+ public enum MemberPointerType {++ INVALID("invalid", -1),+ UNSPECIFIED("pdm16_nonvirt", 0), // 16-bit pointer+ DATA_SINGLE_INHERITANCE("pdm16_vfcn", 1), // 16:16 far pointer+ DATA_MULTIPLE_INHERITANCE("pdm16_vbase", 2), // 16:16 huge pointer+ DATA_VIRTUAL_INHERITANCE("pdm32_nvvfcn", 3),+ DATA_GENERAL("pdm32_vbase", 4),+ FUNCTION_SINGLE_INHERITANCE("pmf16_nearnvsa", 5),+ FUNCTION_MULTIPLE_INHERITANCE("pmf16_nearnvma", 6),+ FUNCTION_VIRTUAL_INHERITANCE("pmf16_nearvbase", 7),+ FUNCTION_SINGLE_INHERITANCE_1632("pmf16_farnvsa", 8),+ FUNCTION_MULTIPLE_INHERITANCE_1632("pmf16_farnvma", 9),+ FUNCTION_VIRTUAL_INHERITANCE_1632("pmf16_farnvbase", 10),+ FUNCTION_SINGLE_INHERITANCE_32("pmf32_nvsa", 11),+ FUNCTION_MULTIPLE_INHERITANCE_32("pmf32_nvma", 12),+ FUNCTION_VIRTUAL_INHERITANCE_32("pmf32_nvbase", 13);++ private static final Map<Integer, MemberPointerType> BY_VALUE = new HashMap<>();+ static {+ for (MemberPointerType val : values()) {+ BY_VALUE.put(val.value, val);+ }+ }++ public final String label;+ public final int value;++ @Override+ public String toString() {+ return label;+ }++ public static MemberPointerType fromValue(int val) {+ return BY_VALUE.getOrDefault(val, INVALID);+ }++ private MemberPointerType(String label, int value) {+ this.label = label;+ this.value = value;+ }++ }//==============================================================================================protected AbstractTypeIndex underlyingTypeIndex;- protected int pointerTypeAttribute;- protected int pointerModeAttribute;+ protected PointerType pointerType;+ protected PointerMode pointerMode;protected boolean isFlat; // 0:32 pointerprotected boolean isVolatile;protected boolean isConst;protected boolean isUnaligned;protected AbstractTypeIndex memberPointerContainingClassIndex;- protected int memberPointerFormat;+ protected MemberPointerType memberPointerType;protected int baseSegment;protected AbstractString baseSymbol;@@ -121,19 +188,19 @@ public abstract class AbstractPointerMsType extends AbstractMsType {new CategoryIndex(CategoryIndex.Category.DATA, underlyingTypeIndex.get()));pdb.popDependencyStack();- if (pointerModeAttribute == MODE_MEMBER_DATA_POINTER ||- pointerModeAttribute == MODE_MEMBER_FUNCTION_POINTER) {+ if (pointerMode == PointerMode.MEMBER_DATA_POINTER ||+ pointerMode == PointerMode.MEMBER_FUNCTION_POINTER) {memberPointerContainingClassIndex.parse(reader);pdb.pushDependencyStack(new CategoryIndex(CategoryIndex.Category.DATA,memberPointerContainingClassIndex.get()));pdb.popDependencyStack();- memberPointerFormat = reader.parseUnsignedShortVal();+ memberPointerType = MemberPointerType.fromValue(reader.parseUnsignedShortVal());if (reader.hasMore()) {//TODO: I think there might be possible paddingreader.parseBytesRemaining();}}- else if (pointerTypeAttribute == TYPE_SEGMENT_BASED) {+ else if (pointerType == PointerType.SEGMENT_BASED) {baseSegment = reader.parseUnsignedShortVal();if (reader.hasMore()) {//TODO: I think there might be possible padding@@ -141,7 +208,7 @@ public abstract class AbstractPointerMsType extends AbstractMsType {reader.parseBytesRemaining();}}- else if (pointerTypeAttribute == TYPE_TYPE_BASED) {+ else if (pointerType == PointerType.TYPE_BASED) {pointerBaseTypeIndex = reader.parseInt();name.parse(reader);reader.skipPadding();@@ -152,7 +219,7 @@ public abstract class AbstractPointerMsType extends AbstractMsType {}}// Something needs to trigger this code (might be a mode or a type- else if (pointerTypeAttribute == -1) {+ else if (pointerType == PointerType.INVALID) {baseSymbol.parse(reader);//System.out.println(reader.dump());reader.skipPadding();@@ -190,261 +257,49 @@ public abstract class AbstractPointerMsType extends AbstractMsType {}/**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isNear() {- return (pointerTypeAttribute == TYPE_NEAR);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isFar() {- return (pointerTypeAttribute == TYPE_FAR);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isHuge() {- return (pointerTypeAttribute == TYPE_HUGE);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isSegmentBased() {- return (pointerTypeAttribute == TYPE_SEGMENT_BASED);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isValueBased() {- return (pointerTypeAttribute == TYPE_VALUE_BASED);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isSegmentValueBased() {- return (pointerTypeAttribute == TYPE_SEGMENT_VALUE_BASED);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isAddressBased() {- return (pointerTypeAttribute == TYPE_ADDRESS_BASED);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isSegmentAddressBased() {- return (pointerTypeAttribute == TYPE_SEGMENT_ADDRESS_BASED);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isTypeBased() {- return (pointerTypeAttribute == TYPE_TYPE_BASED);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.+ * Returns {@link PointerType} attribute.+ * @return {@link PointerType} attribute.*/- public boolean isSelfBased() {- return (pointerTypeAttribute == TYPE_SELF_BASED);+ public PointerType getPointerType() {+ return pointerType;}/**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.+ * Returns {@link PointerMode} attribute.+ * @return {@link PointerMode} attribute.*/- public boolean isNear32() {- return (pointerTypeAttribute == TYPE_NEAR32);+ public PointerMode getPointerMode() {+ return pointerMode;}/**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.+ * Returns {@link MemberPointerType} attribute.+ * @return {@link MemberPointerType} attribute.*/- public boolean isFar32() {- return (pointerTypeAttribute == TYPE_FAR32);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isPtr64() {- return (pointerTypeAttribute == TYPE_PTR64);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isNormal() {- return (pointerModeAttribute == MODE_POINTER);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isLOldReference() {- return (pointerModeAttribute == MODE_OLD_REFERENCE);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isLValueReference() {- return (pointerModeAttribute == MODE_LVALUE_REFERENCE);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isMemberDataPointer() {- return (pointerModeAttribute == MODE_MEMBER_DATA_POINTER);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isMemberFunctionPointer() {- return (pointerModeAttribute == MODE_MEMBER_FUNCTION_POINTER);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isFValueReference() {- return (pointerModeAttribute == MODE_RVALUE_REFERENCE);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isModeReserved() {- return (pointerModeAttribute == MODE_RESERVED);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isUnspecified() {- return (memberPointerFormat == MEMBER_POINTER_UNSPECIFIED);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isDataSingleInheritance() {- return (memberPointerFormat == MEMBER_POINTER_DATA_SINGLE_INHERITANCE);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isDataMultipleInheritance() {- return (memberPointerFormat == MEMBER_POINTER_DATA_MULTIPLE_INHERITANCE);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isDataVirtualInheritance() {- return (memberPointerFormat == MEMBER_POINTER_DATA_VIRTUAL_INHERITANCE);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isDataGeneral() {- return (memberPointerFormat == MEMBER_POINTER_DATA_GENERAL);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isFunctionSingleInheritance() {- return (memberPointerFormat == MEMBER_POINTER_FUNCTION_SINGLE_INHERITANCE);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isFunctionMultipleInheritance() {- return (memberPointerFormat == MEMBER_POINTER_FUNCTION_MULTIPLE_INHERITANCE);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isFunctionVirtualInheritance() {- return (memberPointerFormat == MEMBER_POINTER_FUNCTION_VIRTUAL_INHERITANCE);- }-- /**- * Returns boolean regarding the fact of the property.- * @return Truth about the property.- */- public boolean isFunctionGeneral() {- return (memberPointerFormat == MEMBER_POINTER_FUNCTION_GENERAL);+ public MemberPointerType getMemberPointerType() {+ return memberPointerType;}@Overridepublic void emit(StringBuilder builder, Bind bind) {StringBuilder myBuilder = new StringBuilder();myBuilder.append(isFlat ? "flat " : "");- switch (pointerModeAttribute) {- case MODE_POINTER:- myBuilder.append(TYPE_STRING[pointerTypeAttribute]);- myBuilder.append("*");- break;- case MODE_LVALUE_REFERENCE:- myBuilder.append(TYPE_STRING[pointerTypeAttribute]);- myBuilder.append("&");- break;- case MODE_RVALUE_REFERENCE:- myBuilder.append(TYPE_STRING[pointerTypeAttribute]);- myBuilder.append("&&");- break;- case MODE_MEMBER_DATA_POINTER:- case MODE_MEMBER_FUNCTION_POINTER:+ switch (pointerMode) {+ case MEMBER_DATA_POINTER:+ case MEMBER_FUNCTION_POINTER:pdb.getTypeRecord(memberPointerContainingClassIndex.get()).emit(builder, Bind.NONE);- myBuilder.append("::* <");- myBuilder.append(MEMBER_POINTER_ATTRIBUTE_STRING[memberPointerFormat]);+ myBuilder.append(pointerMode);+ myBuilder.append(" <");+ myBuilder.append(memberPointerType);myBuilder.append(">");break;+ case POINTER:+ case LVALUE_REFERENCE:+ case RVALUE_REFERENCE:+ default:+ myBuilder.append(pointerType);+ myBuilder.append(pointerMode);+ break;}myBuilder.append(isConst ? "const " : "");myBuilder.append(isVolatile ? "volatile " : "");@@ -477,8 +332,8 @@ public abstract class AbstractPointerMsType extends AbstractMsType {* Parses the attributes of the pointer.* <P>* Implementing class must, in the appropriate order pertinent to itself, parse- * certain attributes, which at a minimum will fill in {@link #pointerTypeAttribute},- * {@link #pointerModeAttribute}, {@link #isFlat}, {@link #isVolatile}, {@link #isConst},+ * certain attributes, which at a minimum will fill in {@link #pointerType},+ * {@link #pointerMode}, {@link #isFlat}, {@link #isVolatile}, {@link #isConst},* and {@link #isUnaligned}.* @param reader {@link PdbByteReader} from which the attributes are parsed.* @throws PdbException Upon not enough data left to parse.diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/ClassFieldMsAttributes.java b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/ClassFieldMsAttributes.javaindex 5ae3c6a12c..05627ef60e 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/ClassFieldMsAttributes.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/ClassFieldMsAttributes.java@@ -15,6 +15,9 @@*/package ghidra.pdb.pdbreader.type;+import java.util.HashMap;+import java.util.Map;+import ghidra.pdb.*;/**@@ -22,196 +25,153 @@ import ghidra.pdb.*;*/public class ClassFieldMsAttributes extends AbstractParsableItem {- private static final int ACCESS_BLANK = 0;- private static final int ACCESS_PRIVATE = 1;- private static final int ACCESS_PROTECTED = 2;- private static final int ACCESS_PUBLIC = 3;-- private static final int PROPERTY_BLANK = 0;- private static final int PROPERTY_VIRTUAL = 1;- private static final int PROPERTY_STATIC = 2;- private static final int PROPERTY_FRIEND = 3;- private static final int PROPERTY_INTRO = 4;- private static final int PROPERTY_PURE = 5;- private static final int PROPERTY_INTRO_PURE = 6;- private static final int PROPERTY_RESV = 7;-- private static final String[] ACCESS_STRING = new String[4];- static {- ACCESS_STRING[0] = "";- ACCESS_STRING[1] = "private";- ACCESS_STRING[2] = "protected";- ACCESS_STRING[3] = "public";+ public enum Access {- }- private static final String[] PROPERTY_STRING = new String[8];- static {- PROPERTY_STRING[0] = "";- PROPERTY_STRING[1] = "virtual";- PROPERTY_STRING[2] = "static";- PROPERTY_STRING[3] = "friend";- PROPERTY_STRING[4] = "<intro>";- PROPERTY_STRING[5] = "<pure>";- PROPERTY_STRING[6] = "<intro,pure>";- PROPERTY_STRING[7] = "";+ INVALID("", -1), // Our default+ BLANK("", 0),+ PRIVATE("private", 1),+ PROTECTED("protected", 2),+ PUBLIC("public", 3);- }+ private static final Map<Integer, Access> BY_VALUE = new HashMap<>();+ static {+ for (Access val : values()) {+ BY_VALUE.put(val.value, val);+ }+ }- //==============================================================================================- private boolean compilerGenerateFunctionDoesNotExist;- private boolean cannotBeInherited;- private boolean cannotBeConstructed;- private boolean compilerGenerateFunctionDoesExist;- private boolean cannotBeOverriden;- private int accessVal;- private int propertyVal;+ public final String label;+ public final int value;- //==============================================================================================- /**- * Constructor for ClassFieldAttributes/- * @param reader {@link PdbByteReader} from which this type is deserialized.- * @throws PdbException Upon not enough data left to parse.- */- public ClassFieldMsAttributes(PdbByteReader reader) throws PdbException {- int attributes = reader.parseUnsignedShortVal();- processAttributes(attributes);- }+ /**+ * Emits {@link String} output of this class into the provided {@link StringBuilder}.+ * @param builder The {@link StringBuilder} into which the output is created.+ */+ public void emit(StringBuilder builder) {+ builder.append(this.getClass().getSimpleName());+ }- /**- * Returns the value (index) of the Access Value.- * @return Index of Access Value.- */- public int getAccessVal() {- return accessVal;- }+ @Override+ public String toString() {+ return label;+ }- /**- * Returns the value (index) of the Property Value.- * @return Index of Property Value.- */- public int getPropertyVal() {- return propertyVal;- }+ public static Access fromValue(int val) {+ return BY_VALUE.getOrDefault(val, INVALID);+ }- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean isAccessBlank() {- return (accessVal == ACCESS_BLANK);- }+ private Access(String label, int value) {+ this.label = label;+ this.value = value;+ }- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean isAccessPrivate() {- return (accessVal == ACCESS_PRIVATE);}- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean isAccessProtected() {- return (accessVal == ACCESS_PROTECTED);- }+ public enum Property {- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean isAccessPublic() {- return (accessVal == ACCESS_PUBLIC);- }+ INVALID("", -1),+ BLANK("", 0),+ VIRTUAL("virtual", 1),+ STATIC("static", 2),+ FRIEND("friend", 3),+ INTRO("<intro>", 4),+ PURE("<pure>", 5),+ INTRO_PURE("<intro,pure>", 6),+ RESERVED("", 7);- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean isPropertyBlank() {- return (propertyVal == PROPERTY_BLANK);- }+ private static final Map<Integer, Property> BY_VALUE = new HashMap<>();+ static {+ for (Property val : values()) {+ BY_VALUE.put(val.value, val);+ }+ }- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean isPropertyVirtual() {- return (propertyVal == PROPERTY_VIRTUAL);- }+ public final String label;+ public final int value;- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean isPropertyStatic() {- return (propertyVal == PROPERTY_STATIC);- }+ /**+ * Emits {@link String} output of this class into the provided {@link StringBuilder}.+ * @param builder The {@link StringBuilder} into which the output is created.+ */+ public void emit(StringBuilder builder) {+ builder.append(this.getClass().getSimpleName());+ }- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean isPropertyFriend() {- return (propertyVal == PROPERTY_FRIEND);- }+ @Override+ public String toString() {+ return label;+ }++ public static Property fromValue(int val) {+ return BY_VALUE.getOrDefault(val, INVALID);+ }++ private Property(String label, int value) {+ this.label = label;+ this.value = value;+ }- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean isPropertyIntro() {- return (propertyVal == PROPERTY_INTRO);}+ //==============================================================================================+ private boolean compilerGenerateFunctionDoesNotExist;+ private boolean cannotBeInherited;+ private boolean cannotBeConstructed;+ private boolean compilerGenerateFunctionDoesExist;+ private boolean cannotBeOverridden;+ private Access access;+ private Property property;++ //==============================================================================================/**- * Tells whether the property is true.- * @return Truth about the property.+ * Constructor for ClassFieldAttributes/+ * @param reader {@link PdbByteReader} from which this type is deserialized.+ * @throws PdbException Upon not enough data left to parse.*/- public boolean isPropertyPure() {- return (propertyVal == PROPERTY_PURE);+ public ClassFieldMsAttributes(PdbByteReader reader) throws PdbException {+ int attributes = reader.parseUnsignedShortVal();+ processAttributes(attributes);}/**- * Tells whether the property is true.- * @return Truth about the property.+ * Returns the {@link Access}.+ * @return the {@link Access}.*/- public boolean isPropertyIntroPure() {- return (propertyVal == PROPERTY_INTRO_PURE);+ public Access getAccess() {+ return access;}/**- * Tells whether the property is true.- * @return Truth about the property.+ * Returns the {@link Property}.+ * @return the {@link Property}.*/- public boolean isPropertyReserved() {- return (propertyVal == PROPERTY_RESV);+ public Property getProperty() {+ return property;}/**- * Tells whether the property is true.- * @return Truth about the property.+ * Tells whether a compiler generated function exists.+ * @return True if a compiler generated function exists.*/public boolean isCompilerGeneratedFunctionDoesExist() {return compilerGenerateFunctionDoesExist;}/**- * Tells whether the property is true.- * @return Truth about the property.+ * Tells if it cannot be overridden.+ * @return True if it cannot be overridden.*/- public boolean isCannotBeOverriden() {- return cannotBeOverriden;+ public boolean isCannotBeOverridden() {+ return cannotBeOverridden;}@Overridepublic void emit(StringBuilder builder) {- builder.append(ACCESS_STRING[accessVal]);- if ((accessVal != 0) && (propertyVal != 0)) {+ builder.append(access);+ if ((access != Access.BLANK) && (property != Property.BLANK)) {builder.append(" ");}- builder.append(PROPERTY_STRING[propertyVal]);+ builder.append(property);if (compilerGenerateFunctionDoesNotExist || cannotBeInherited || cannotBeConstructed) {DelimiterState ds = new DelimiterState("<", ", ");builder.append(ds.out(compilerGenerateFunctionDoesNotExist, "pseudo"));@@ -222,9 +182,9 @@ public class ClassFieldMsAttributes extends AbstractParsableItem {}private void processAttributes(int attributes) {- accessVal = (attributes & 0x0003);+ access = Access.fromValue(attributes & 0x0003);attributes >>= 2;- propertyVal = (attributes & 0x0007);+ property = Property.fromValue(attributes & 0x0007);attributes >>= 3;compilerGenerateFunctionDoesNotExist = ((attributes & 0x0001) == 0x0001);attributes >>= 1;@@ -234,7 +194,7 @@ public class ClassFieldMsAttributes extends AbstractParsableItem {attributes >>= 1;compilerGenerateFunctionDoesExist = ((attributes & 0x0001) == 0x0001);attributes >>= 1;- cannotBeOverriden = ((attributes & 0x0001) == 0x0001);+ cannotBeOverridden = ((attributes & 0x0001) == 0x0001);}}diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/HighLevelShaderLanguageMsType.java b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/HighLevelShaderLanguageMsType.javaindex 2c9f178b99..a813d9d702 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/HighLevelShaderLanguageMsType.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/HighLevelShaderLanguageMsType.java@@ -15,6 +15,9 @@*/package ghidra.pdb.pdbreader.type;+import java.util.HashMap;+import java.util.Map;+import ghidra.pdb.PdbByteReader;import ghidra.pdb.PdbException;import ghidra.pdb.pdbreader.*;@@ -23,46 +26,73 @@ public class HighLevelShaderLanguageMsType extends AbstractMsType {public static final int PDB_ID = 0x1517;- private static final int BUILTIN_HLSL_INTERFACE_POINTER = 0x0200;- private static final int BUILTIN_HLSL_TEXTURE_1D = 0x0201;- private static final int BUILTIN_HLSL_TEXTURE_1D_ARRAY = 0x0202;- private static final int BUILTIN_HLSL_TEXTURE_2D = 0x0203;- private static final int BUILTIN_HLSL_TEXTURE_2D_ARRAY = 0x0204;- private static final int BUILTIN_HLSL_TEXTURE_3D = 0x0205;- private static final int BUILTIN_HLSL_TEXTURE_CUBE = 0x0206;- private static final int BUILTIN_HLSL_TEXTURE_CUBE_ARRAY = 0x0207;- private static final int BUILTIN_HLSL_TEXTURE_2D_MS = 0x0208;- private static final int BUILTIN_HLSL_TEXTURE_2D_MS_ARRAY = 0x0209;- private static final int BUILTIN_HLSL_SAMPLER = 0x020a;- private static final int BUILTIN_HLSL_SAMPLER_COMPARISON = 0x020b;- private static final int BUILTIN_HLSL_BUFFER = 0x020c;- private static final int BUILTIN_HLSL_POINT_STREAM = 0x020d;- private static final int BUILTIN_HLSL_LINE_STREAM = 0x020e;- private static final int BUILTIN_HLSL_TRIANGLE_STREAM = 0x020f;- private static final int BUILTIN_HLSL_INPUT_PATCH = 0x0210;- private static final int BUILTIN_HLSL_OUTPUT_PATCH = 0x0211;- private static final int BUILTIN_HLSL_RW_TEXTURE_1D = 0x0212;- private static final int BUILTIN_HLSL_RW_TEXTURE_1D_ARRAY = 0x0213;- private static final int BUILTIN_HLSL_RW_TEXTURE_2D = 0x0214;- private static final int BUILTIN_HLSL_RW_TEXTURE_2D_ARRAY = 0x0215;- private static final int BUILTIN_HLSL_RW_TEXTURE_3D = 0x0216;- private static final int BUILTIN_HLSL_RW_BUFFER = 0x0217;- private static final int BUILTIN_HLSL_BYTE_ADDRESS_BUFFER = 0x0218;- private static final int BUILTIN_HLSL_RW_BYTE_ADDRESS_BUFFER = 0x0219;- private static final int BUILTIN_HLSL_STRUCTURED_BUFFER = 0x021a;- private static final int BUILTIN_HLSL_RW_STRUCTURED_BUFFER = 0x021b;- private static final int BUILTIN_HLSL_APPEND_STRUCTURED_BUFFER = 0x021c;- private static final int BUILTIN_HLSL_CONSUME_STRUCTURED_BUFFER = 0x021d;- private static final int BUILTIN_HLSL_MIN_8FLOAT = 0x021e;- private static final int BUILTIN_HLSL_MIN_10FLOAT = 0x021f;- private static final int BUILTIN_HLSL_MIN_16FLOAT = 0x0220;- private static final int BUILTIN_HLSL_MIN_12INT = 0x0221;- private static final int BUILTIN_HLSL_MIN_16INT = 0x0222;- private static final int BUILTIN_HLSL_MIN_16UINT = 0x0223;+ public enum Kind {+ INVALID("invalid", -1),+ INTERFACE_POINTER("InterfacePointer", 0x0200),+ TEXTURE_1D("Texture1D", 0x0201),+ TEXTURE_1D_ARRAY("Texture1DArray", 0x0202),+ TEXTURE_2D("Texture2D", 0x0203),+ TEXTURE_2D_ARRAY("Texture2DArray", 0x0204),+ TEXTURE_3D("Texture3D", 0x0205),+ TEXTURE_CUBE("TextureCube", 0x0206),+ TEXTURE_CUBE_ARRAY("TextureCubeArray", 0x0207),+ TEXTURE_2D_MS("Texture2DMs", 0x0208),+ TEXTURE_2D_MS_ARRAY("Texture2DMsArray", 0x0209),+ SAMPLER("Sampler", 0x020a),+ SAMPLER_COMPARISON("SamplerComparison", 0x020b),+ BUFFER("Buffer", 0x020c),+ POINT_STREAM("PointStream", 0x020d),+ LINE_STREAM("LineStream", 0x020e),+ TRIANGLE_STREAM("TriangleStream", 0x020f),+ INPUT_PATCH("InputPatch", 0x0210),+ OUTPUT_PATCH("OutputPatch", 0x0211),+ RW_TEXTURE_1D("RwTexture1D", 0x0212),+ RW_TEXTURE_1D_ARRAY("RwTexture1DArray", 0x0213),+ RW_TEXTURE_2D("RwTexture2D", 0x0214),+ RW_TEXTURE_2D_ARRAY("RwTexture2DArray", 0x0215),+ RW_TEXTURE_3D("RwTexture3D", 0x0216),+ RW_BUFFER("RwBuffer", 0x0217),+ BYTE_ADDRESS_BUFFER("ByteAddressBuffer", 0x0218),+ RW_BYTE_ADDRESS_BUFFER("RwByteAddressBuffer", 0x0219),+ STRUCTURED_BUFFER("StructuredBuffer", 0x021a),+ RW_STRUCTURED_BUFFER("RwStructuredBuffer", 0x021b),+ APPEND_STRUCTURED_BUFFER("AppendStructuredBuffer", 0x021c),+ CONSUME_STRUCTURED_BUFFER("ConsumeStructuredBuffer", 0x021d),+ MIN_8FLOAT("Min8Float", 0x021e),+ MIN_10FLOAT("Min10Float", 0x021f),+ MIN_16FLOAT("Min16Float", 0x0220),+ MIN_12INT("Min12Int", 0x0221),+ MIN_16INT("Min16Int", 0x0222),+ MIN_16UINT("Min16UInt", 0x0223);++ private static final Map<Integer, Kind> BY_VALUE = new HashMap<>();+ static {+ for (Kind val : values()) {+ BY_VALUE.put(val.value, val);+ }+ }++ public final String label;+ public final int value;++ @Override+ public String toString() {+ return label;+ }++ public static Kind fromValue(int val) {+ return BY_VALUE.getOrDefault(val, INVALID);+ }++ private Kind(String label, int value) {+ this.label = label;+ this.value = value;+ }+ }//==============================================================================================private AbstractTypeIndex subtypeIndex;- private int kind;+ private Kind kind;private int numNumericProperties;private byte[] data;@@ -78,7 +108,7 @@ public class HighLevelShaderLanguageMsType extends AbstractMsType {super(pdb, reader);subtypeIndex = new TypeIndex32();subtypeIndex.parse(reader);- kind = reader.parseUnsignedShortVal();+ kind = Kind.fromValue(reader.parseUnsignedShortVal());numNumericProperties = reader.parseUnsignedShortVal() & 0x000f;data = reader.parseBytesRemaining();}@@ -97,301 +127,13 @@ public class HighLevelShaderLanguageMsType extends AbstractMsType {}/**- * Returns the integer "kind" value for this class.- * @return The "kind" value.+ * Returns the {@link Kind} attribute.+ * @return The {@link Kind} attribute.*/- public int getKind() {+ public Kind getKind() {return kind;}- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindInterfacePointer() {- return (kind == BUILTIN_HLSL_INTERFACE_POINTER);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindTexture1D() {- return (kind == BUILTIN_HLSL_TEXTURE_1D);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindTexture1DArray() {- return (kind == BUILTIN_HLSL_TEXTURE_1D_ARRAY);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindTexture2D() {- return (kind == BUILTIN_HLSL_TEXTURE_2D);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindTecture2DArray() {- return (kind == BUILTIN_HLSL_TEXTURE_2D_ARRAY);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindTexture3D() {- return (kind == BUILTIN_HLSL_TEXTURE_3D);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindTextureCube() {- return (kind == BUILTIN_HLSL_TEXTURE_CUBE);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindTextureCubeArray() {- return (kind == BUILTIN_HLSL_TEXTURE_CUBE_ARRAY);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindTexture2DMs() {- return (kind == BUILTIN_HLSL_TEXTURE_2D_MS);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKind2DMsArray() {- return (kind == BUILTIN_HLSL_TEXTURE_2D_MS_ARRAY);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindSampler() {- return (kind == BUILTIN_HLSL_SAMPLER);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindSamplerComparison() {- return (kind == BUILTIN_HLSL_SAMPLER_COMPARISON);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindBuffer() {- return (kind == BUILTIN_HLSL_BUFFER);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindPointStream() {- return (kind == BUILTIN_HLSL_POINT_STREAM);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindLineStream() {- return (kind == BUILTIN_HLSL_LINE_STREAM);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindTriangleStream() {- return (kind == BUILTIN_HLSL_TRIANGLE_STREAM);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindInputPatch() {- return (kind == BUILTIN_HLSL_INPUT_PATCH);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindOutputPatch() {- return (kind == BUILTIN_HLSL_OUTPUT_PATCH);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindRwTexture1D() {- return (kind == BUILTIN_HLSL_RW_TEXTURE_1D);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindRwTexture1DArray() {- return (kind == BUILTIN_HLSL_RW_TEXTURE_1D_ARRAY);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindRwTexture2D() {- return (kind == BUILTIN_HLSL_RW_TEXTURE_2D);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindRwTexture2DArray() {- return (kind == BUILTIN_HLSL_RW_TEXTURE_2D_ARRAY);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindRwTexture3D() {- return (kind == BUILTIN_HLSL_RW_TEXTURE_3D);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindRwBuffer() {- return (kind == BUILTIN_HLSL_RW_BUFFER);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindByteAddressBuffer() {- return (kind == BUILTIN_HLSL_BYTE_ADDRESS_BUFFER);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindRwByteAddressBuffer() {- return (kind == BUILTIN_HLSL_RW_BYTE_ADDRESS_BUFFER);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindStructuredBuffer() {- return (kind == BUILTIN_HLSL_STRUCTURED_BUFFER);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindRwStructuredBuffer() {- return (kind == BUILTIN_HLSL_RW_STRUCTURED_BUFFER);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindAppendStructuredBuffer() {- return (kind == BUILTIN_HLSL_APPEND_STRUCTURED_BUFFER);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindConsumeStructuredBuffer() {- return (kind == BUILTIN_HLSL_CONSUME_STRUCTURED_BUFFER);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindMin8Float() {- return (kind == BUILTIN_HLSL_MIN_8FLOAT);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindMin10Float() {- return (kind == BUILTIN_HLSL_MIN_10FLOAT);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindMin16Float() {- return (kind == BUILTIN_HLSL_MIN_16FLOAT);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindMin12Int() {- return (kind == BUILTIN_HLSL_MIN_12INT);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindMin16Int() {- return (kind == BUILTIN_HLSL_MIN_16INT);- }-- /**- * Tells whether the "kind" property is true.- * @return Truth about this "kind" property.- */- public boolean isKindMin16Uint() {- return (kind == BUILTIN_HLSL_MIN_16UINT);- }-/*** Returns {@code byte[]} of the additional Data for this class.* @return Additional data for this class.@@ -405,116 +147,7 @@ public class HighLevelShaderLanguageMsType extends AbstractMsType {// No API for this. Just outputting something that might be useful.// At this time, not doing anything with bind here; don't think it is warranted.builder.append("Built-In HLSL: ");- switch (kind) {- case BUILTIN_HLSL_INTERFACE_POINTER:- builder.append("InterfacePointer");- break;- case BUILTIN_HLSL_TEXTURE_1D:- builder.append("Texture1D");- break;- case BUILTIN_HLSL_TEXTURE_1D_ARRAY:- builder.append("Texture1DArray");- break;- case BUILTIN_HLSL_TEXTURE_2D:- builder.append("Texture2D");- break;- case BUILTIN_HLSL_TEXTURE_2D_ARRAY:- builder.append("Texture2DArray");- break;- case BUILTIN_HLSL_TEXTURE_3D:- builder.append("Texture3D");- break;- case BUILTIN_HLSL_TEXTURE_CUBE:- builder.append("TextureCube");- break;- case BUILTIN_HLSL_TEXTURE_CUBE_ARRAY:- builder.append("TextureCubeArray");- break;- case BUILTIN_HLSL_TEXTURE_2D_MS:- builder.append("Texture2DMs");- break;- case BUILTIN_HLSL_TEXTURE_2D_MS_ARRAY:- builder.append("Texture2DMsArray");- break;- case BUILTIN_HLSL_SAMPLER:- builder.append("Sampler");- break;- case BUILTIN_HLSL_SAMPLER_COMPARISON:- builder.append("SamplerComparison");- break;- case BUILTIN_HLSL_BUFFER:- builder.append("Buffer");- break;- case BUILTIN_HLSL_POINT_STREAM:- builder.append("PointStream");- break;- case BUILTIN_HLSL_LINE_STREAM:- builder.append("LineStream");- break;- case BUILTIN_HLSL_TRIANGLE_STREAM:- builder.append("TriangleStream");- break;- case BUILTIN_HLSL_INPUT_PATCH:- builder.append("InputPatch");- break;- case BUILTIN_HLSL_OUTPUT_PATCH:- builder.append("OutputPatch");- break;- case BUILTIN_HLSL_RW_TEXTURE_1D:- builder.append("RwTexture1D");- break;- case BUILTIN_HLSL_RW_TEXTURE_1D_ARRAY:- builder.append("RwTexture1DArray");- break;- case BUILTIN_HLSL_RW_TEXTURE_2D:- builder.append("RwTexture2D");- break;- case BUILTIN_HLSL_RW_TEXTURE_2D_ARRAY:- builder.append("RwTexture2DArray");- break;- case BUILTIN_HLSL_RW_TEXTURE_3D:- builder.append("RwTexture3D");- break;- case BUILTIN_HLSL_RW_BUFFER:- builder.append("RwBuffer");- break;- case BUILTIN_HLSL_BYTE_ADDRESS_BUFFER:- builder.append("ByteAddressBuffer");- break;- case BUILTIN_HLSL_RW_BYTE_ADDRESS_BUFFER:- builder.append("RwByteAddressBuffer");- break;- case BUILTIN_HLSL_STRUCTURED_BUFFER:- builder.append("StructuredBuffer");- break;- case BUILTIN_HLSL_RW_STRUCTURED_BUFFER:- builder.append("RwStructuredBuffer");- break;- case BUILTIN_HLSL_APPEND_STRUCTURED_BUFFER:- builder.append("AppendStructuredBuffer");- break;- case BUILTIN_HLSL_CONSUME_STRUCTURED_BUFFER:- builder.append("ConsumeStructuredBuffer");- break;- case BUILTIN_HLSL_MIN_8FLOAT:- builder.append("Min8Float");- break;- case BUILTIN_HLSL_MIN_10FLOAT:- builder.append("Min10Float");- break;- case BUILTIN_HLSL_MIN_16FLOAT:- builder.append("Min16Float");- break;- case BUILTIN_HLSL_MIN_12INT:- builder.append("Min12Int");- break;- case BUILTIN_HLSL_MIN_16INT:- builder.append("Min16Int");- break;- case BUILTIN_HLSL_MIN_16UINT:- builder.append("Min16UInt");- break;- }+ builder.append(kind);builder.append(String.format(" <numProperties=%d>", numNumericProperties));// TODO: output more? What does it mean?}diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/LabelMsType.java b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/LabelMsType.javaindex cbfe63cdd7..8d1e3ee3d9 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/LabelMsType.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/LabelMsType.java@@ -47,16 +47,16 @@ public class LabelMsType extends AbstractMsType {}/**- * Tells whether the property is true.- * @return Truth about the property.+ * Tells whether if is a near address.+ * @return True if it is a near address.*/public boolean isNear() {return (mode == ADDRESS_MODE_NEAR);}/**- * Tells whether the property is true.- * @return Truth about the property.+ * Tells whether it is a far address.+ * @return True if it is a far address.*/public boolean isFar() {return (mode == ADDRESS_MODE_FAR);diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/MethodRecord16Ms.java b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/MethodRecord16Ms.javaindex 5fe4c4bdee..e08b3b17ba 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/MethodRecord16Ms.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/MethodRecord16Ms.java@@ -41,7 +41,7 @@ public class MethodRecord16Ms extends AbstractMethodRecordMs {protected void parseFields(PdbByteReader reader) throws PdbException {attributes = new ClassFieldMsAttributes(reader);procedureRecordNumber.parse(reader);- if (attributes.getPropertyVal() == 4) {+ if (attributes.getProperty() == ClassFieldMsAttributes.Property.INTRO) {optionalOffset = reader.parseUnsignedIntVal();}else {diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/MethodRecordMs.java b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/MethodRecordMs.javaindex 66eda258ed..aec2c28b56 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/MethodRecordMs.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/MethodRecordMs.java@@ -45,7 +45,8 @@ public class MethodRecordMs extends AbstractMethodRecordMs {// API says optional offset "if intro virtual" but we have seen it for 6=<intro.pure>, so// it could be that we need to also include 2=virtual here; i.e., each 2, 4, and 6// (virtual, <intro>, and <intro,pure>) could have this optional field.- if ((attributes.getPropertyVal() == 4) || (attributes.getPropertyVal() == 6)) {+ if ((attributes.getProperty() == ClassFieldMsAttributes.Property.INTRO) ||+ (attributes.getProperty() == ClassFieldMsAttributes.Property.INTRO_PURE)) {optionalOffset = reader.parseUnsignedIntVal();}else {diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/ModifierExMsType.java b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/ModifierExMsType.javaindex a9db2d8e87..29089c79c7 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/ModifierExMsType.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/ModifierExMsType.java@@ -15,8 +15,7 @@*/package ghidra.pdb.pdbreader.type;-import java.util.ArrayList;-import java.util.List;+import java.util.*;import ghidra.pdb.PdbByteReader;import ghidra.pdb.PdbException;@@ -26,54 +25,61 @@ public class ModifierExMsType extends AbstractMsType {public static final int PDB_ID = 0x1518;- // Standard modifiers (reserved 0x0000 - 0x01ff)- private static final int MOD_INVALID = 0x0000;- private static final int MOD_CONST = 0x0001;- private static final int MOD_VOLATILE = 0x0002;- private static final int MOD_UNALIGNED = 0x0003;+ public enum Modifier {- // HLSL modifiers 0x0200 - 0x03ff- private static final int MOD_HLSL_UNIFORM = 0x0200;- private static final int MOD_HLSL_LINE = 0x0201;- private static final int MOD_HLSL_TRIANGLE = 0x0202;- private static final int MOD_HLSL_LINEADJ = 0x0203;- private static final int MOD_HLSL_TRIANGLEADJ = 0x0204;- private static final int MOD_HLSL_LINEAR = 0x0205;- private static final int MOD_HLSL_CENTROID = 0x0206;- private static final int MOD_HLSL_CONSTINTERP = 0x0207;- private static final int MOD_HLSL_NOPERSPECTIVE = 0x0208;- private static final int MOD_HLSL_SAMPLE = 0x0209;- private static final int MOD_HLSL_CENTER = 0x020a;- private static final int MOD_HLSL_SNORM = 0x020b;- private static final int MOD_HLSL_UNORM = 0x020c;- private static final int MOD_HLSL_PRECISE = 0x020d;- private static final int MOD_HLSL_UAV_GLOBALLY_COHERENT = 0x020e;+ INVALID("INVALID ", 0),+ CONST("const ", 1),+ VOLATILE("volatile ", 2),+ UNALIGNED("__unaligned ", 3),+ // HLSL modifiers 0x0200 - 0x03ff+ HLSL_UNIFORM("__uniform__ ", 0x0200),+ HLSL_LINE("__line__ ", 0x0201),+ HLSL_TRIANGLE("__triangle__ ", 0x0202),+ HLSL_LINEADJ("__lineadj__ ", 0x0203),+ HLSL_TRIANGLEADJ("__triangleadj__ ", 0x0204),+ HLSL_LINEAR("__linear__ ", 0x0205),+ HLSL_CENTROID("__centroid__ ", 0x0206),+ HLSL_CONSTINTERP("__constinterp__ ", 0x0207),+ HLSL_NOPERSPECTIVE("__noperspective__ ", 0x0208),+ HLSL_SAMPLE("__sample__ ", 0x0209),+ HLSL_CENTER("__center__ ", 0x020a),+ HLSL_SNORM("__snorm__ ", 0x020b),+ HLSL_UNORM("__unorm__ ", 0x020c),+ HLSL_PRECISE("__precise__ ", 0x020d),+ HLSL_UAV_GLOBALLY_COHERENT("__uav_globally_coherent__ ", 0x020e);- private static final String[] STANDARD_MOD_STRING = new String[4];- static {- STANDARD_MOD_STRING[0] = "INVALID ";- STANDARD_MOD_STRING[1] = "const ";- STANDARD_MOD_STRING[2] = "volatile ";- STANDARD_MOD_STRING[3] = "__unaligned ";+ private static final Map<Integer, Modifier> BY_VALUE = new HashMap<>();+ static {+ for (Modifier val : values()) {+ BY_VALUE.put(val.value, val);+ }+ }++ public final String label;+ public final int value;++ /**+ * Emits {@link String} output of this class into the provided {@link StringBuilder}.+ * @param builder The {@link StringBuilder} into which the output is created.+ */+ public void emit(StringBuilder builder) {+ builder.append(this.getClass().getSimpleName());+ }++ @Override+ public String toString() {+ return label;+ }++ public static Modifier fromValue(int val) {+ return BY_VALUE.getOrDefault(val, INVALID);+ }++ private Modifier(String label, int value) {+ this.label = label;+ this.value = value;+ }- }- private static final String[] HLSL_MOD_STRING = new String[15];- static {- HLSL_MOD_STRING[0] = "__uniform__ ";- HLSL_MOD_STRING[1] = "__line__ ";- HLSL_MOD_STRING[2] = "__triangle__ ";- HLSL_MOD_STRING[3] = "__lineadj__ ";- HLSL_MOD_STRING[4] = "__triangleadj__ ";- HLSL_MOD_STRING[5] = "__linear__ ";- HLSL_MOD_STRING[6] = "__centroid__ ";- HLSL_MOD_STRING[7] = "__constinterp__ ";- HLSL_MOD_STRING[8] = "__noperspective__ ";- HLSL_MOD_STRING[9] = "__sample__ ";- HLSL_MOD_STRING[10] = "__center__ ";- HLSL_MOD_STRING[11] = "__snorm__ ";- HLSL_MOD_STRING[12] = "__unorm__ ";- HLSL_MOD_STRING[13] = "__precise__ ";- HLSL_MOD_STRING[14] = "__uav_globally_coherent__ ";}//==============================================================================================@@ -82,7 +88,7 @@ public class ModifierExMsType extends AbstractMsType {// methods in place to test (e.g., public boolean isConst()). Then emit() method would// have to put the modifier strings in a predesigned order instead of the order that they// were found in the record.- private List<Integer> modifierList = new ArrayList<>();+ private List<Modifier> modifiers = new ArrayList<>();//==============================================================================================/**@@ -101,11 +107,11 @@ public class ModifierExMsType extends AbstractMsType {int count = reader.parseUnsignedShortVal();for (int i = 0; i < count; i++) {// TODO: Not sure if these are unsigned short or int.- int modifier = reader.parseUnsignedShortVal();- if (modifier == MOD_INVALID) {+ Modifier modifier = Modifier.fromValue(reader.parseUnsignedShortVal());+ if (modifier == Modifier.INVALID) {// Should not happen, but could output a warning.}- modifierList.add(modifier);+ modifiers.add(modifier);}}@@ -115,257 +121,22 @@ public class ModifierExMsType extends AbstractMsType {}/**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean isConst() {- for (int val : modifierList) {- if (val == MOD_CONST) {- return true;- }- }- return false;- }-- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean isVolatile() {- for (int val : modifierList) {- if (val == MOD_VOLATILE) {- return true;- }- }- return false;- }-- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean isUnaligned() {- for (int val : modifierList) {- if (val == MOD_UNALIGNED) {- return true;- }- }- return false;- }-- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean IsHlslUniform() {- for (int val : modifierList) {- if (val == MOD_HLSL_UNIFORM) {- return true;- }- }- return false;- }-- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean IsHlslLine() {- for (int val : modifierList) {- if (val == MOD_HLSL_LINE) {- return true;- }- }- return false;- }-- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean IsHlslTriangle() {- for (int val : modifierList) {- if (val == MOD_HLSL_TRIANGLE) {- return true;- }- }- return false;- }-- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean IsHlslLindAdj() {- for (int val : modifierList) {- if (val == MOD_HLSL_LINEADJ) {- return true;- }- }- return false;- }-- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean IsHlslTriangleAdj() {- for (int val : modifierList) {- if (val == MOD_HLSL_TRIANGLEADJ) {- return true;- }- }- return false;- }-- /**- * Tells whether the property is true.- * @return Truth about the property.+ * Tells whether the the {@link Modifier} is present.+ * @param modifier the {@link Modifier} to check.+ * @return True if the {@link Modifier} is present.*/- public boolean IsHlslLinear() {- for (int val : modifierList) {- if (val == MOD_HLSL_LINEAR) {- return true;- }- }- return false;- }-- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean IsHlslCentroid() {- for (int val : modifierList) {- if (val == MOD_HLSL_CENTROID) {- return true;- }- }- return false;- }-- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean IsHlslConstInterp() {- for (int val : modifierList) {- if (val == MOD_HLSL_CONSTINTERP) {- return true;- }- }- return false;- }-- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean IsHlslNoPerspective() {- for (int val : modifierList) {- if (val == MOD_HLSL_NOPERSPECTIVE) {- return true;- }- }- return false;- }-- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean IsHlslSample() {- for (int val : modifierList) {- if (val == MOD_HLSL_SAMPLE) {- return true;- }- }- return false;- }-- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean IsHlslCenter() {- for (int val : modifierList) {- if (val == MOD_HLSL_CENTER) {- return true;- }- }- return false;- }-- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean IsHlslSNorm() {- for (int val : modifierList) {- if (val == MOD_HLSL_SNORM) {- return true;- }- }- return false;- }-- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean IsHlslUNorm() {- for (int val : modifierList) {- if (val == MOD_HLSL_UNORM) {- return true;- }- }- return false;- }-- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean IsHlslPrecise() {- for (int val : modifierList) {- if (val == MOD_HLSL_PRECISE) {- return true;- }- }- return false;- }-- /**- * Tells whether the property is true.- * @return Truth about the property.- */- public boolean IsHlslUavGloballyCoherent() {- for (int val : modifierList) {- if (val == MOD_HLSL_UAV_GLOBALLY_COHERENT) {- return true;- }- }- return false;+ public boolean hasModifier(Modifier modifier) {+ return modifiers.contains(modifier);}@Overridepublic void emit(StringBuilder builder, Bind bind) {StringBuilder modBuilder = new StringBuilder();- for (int modifier : modifierList) {- modBuilder.append(getModifierString(modifier));+ for (Modifier modifier : modifiers) {+ modBuilder.append(modifier);}modBuilder.append(pdb.getTypeRecord(modifiedTypeIndex.get()));builder.insert(0, modBuilder);}- private String getModifierString(int modifierVal) {- if ((modifierVal >= 0x0000) && (modifierVal <= 0x0003)) {- return STANDARD_MOD_STRING[modifierVal];- }- else if ((modifierVal >= 0x0200) && (modifierVal <= 0x020e)) {- return HLSL_MOD_STRING[modifierVal - 0x0200];- }- return STANDARD_MOD_STRING[0];- }-}diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/MsProperty.java b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/MsProperty.javaindex c694f03bae..4e46417dbc 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/MsProperty.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/MsProperty.java@@ -15,6 +15,9 @@*/package ghidra.pdb.pdbreader.type;+import java.util.HashMap;+import java.util.Map;+import ghidra.pdb.*;/**@@ -22,31 +25,62 @@ import ghidra.pdb.*;*/public class MsProperty extends AbstractParsableItem {- public static final int HFA_NONE = 0;- public static final int HFA_FLOAT = 1;- public static final int HFA_DOUBLE = 2;- public static final int HFA_RESV = 3;+ public enum Hfa {++ NONE("", 0), FLOAT("hfaFloat", 1), DOUBLE("hfaDouble", 2), RESV("hfa(3)", 3);++ private static final Map<Integer, Hfa> BY_VALUE = new HashMap<>();+ static {+ for (Hfa val : values()) {+ BY_VALUE.put(val.value, val);+ }+ }- public static final int MOCOM_NONE = 0;- public static final int MOCOM_REF = 1;- public static final int MOCOM_VALUE = 2;- public static final int MOCOM_INTERFACE = 3;+ public final String label;+ public final int value;- private static final String[] HFA_STRING = new String[4];- static {- HFA_STRING[0] = "";- HFA_STRING[1] = "hfaFloat";- HFA_STRING[2] = "hfaDouble";- HFA_STRING[3] = "hfa(3)";+ @Override+ public String toString() {+ return label;+ }+ public static Hfa fromValue(int val) {+ return BY_VALUE.getOrDefault(val, NONE);+ }++ private Hfa(String label, int value) {+ this.label = label;+ this.value = value;+ }}- private static final String[] MOCOM_STRING = new String[4];- static {- MOCOM_STRING[0] = "";- MOCOM_STRING[1] = "ref";- MOCOM_STRING[2] = "value";- MOCOM_STRING[3] = "interface";+ public enum Mocom {++ NONE("", 0), REF("ref", 1), VALUE("value", 2), INTERFACE("interface", 3);++ private static final Map<Integer, Mocom> BY_VALUE = new HashMap<>();+ static {+ for (Mocom val : values()) {+ BY_VALUE.put(val.value, val);+ }+ }++ public final String label;+ public final int value;++ @Override+ public String toString() {+ return label;+ }++ public static Mocom fromValue(int val) {+ return BY_VALUE.getOrDefault(val, NONE);+ }++ private Mocom(String label, int value) {+ this.label = label;+ this.value = value;+ }}private static final String PACKED_STRING = "packed";@@ -76,8 +110,8 @@ public class MsProperty extends AbstractParsableItem {private boolean sealed; // Cannot be used as a base classprivate boolean isIntrinsic; // (e.g., _m128d)- private int hfaVal; // ???- private int mocomVal; // ????+ private Hfa hfa; // ???+ private Mocom mocom; // ????//==============================================================================================/**@@ -91,115 +125,115 @@ public class MsProperty extends AbstractParsableItem {}/**- * Tells whether the property is true.- * @return Truth about the property.+ * Tells whether the structure is packed.+ * @return True if structure is packed.*/public boolean isPacked() {return packedStructure;}/**- * Tells whether the property is true.- * @return Truth about the property.+ * Tells whether a constructor or destructor is present.+ * @return True if a constructor or destructor is present.*/public boolean hasConstructorOrDestructor() {return constructorOrDestructorPresent;}/**- * Tells whether the property is true.- * @return Truth about the property.+ * Tells whether there are overloaded operators.+ * @return True if there are overloaded operators.*/public boolean hasOverloadedOperators() {return overloadedOperatorsPresent;}/**- * Tells whether the property is true.- * @return Truth about the property.+ * Tells whether the class is a nested class.+ * @return True if the class is a nested class.*/public boolean isNestedClass() {return isNestedClass;}/**- * Tells whether the property is true.- * @return Truth about the property.+ * Tells whether there are contained nested types.+ * @return True if there are nested types.*/public boolean containsNestedTypes() {return containsNestedTypes;}/**- * Tells whether the property is true.- * @return Truth about the property.+ * Tells whether there is an overloaded assignment.+ * @return True if there is an overloaded assignment.*/public boolean hasOverloadedAssignment() {return hasOverloadedAssignment;}/**- * Tells whether the property is true.- * @return Truth about the property.+ * Tells whether there are casting methods.+ * @return True if there are casting methods.*/public boolean hasCastingMethods() {return hasCastingMethods;}/**- * Tells whether the property is true.- * @return Truth about the property.+ * Tells whether it is a forward reference.+ * @return True if it is a forward reference.*/public boolean isForwardReference() {return isForwardReference;}/**- * Tells whether the property is true.- * @return Truth about the property.+ * Tells whether the the definition is scoped.+ * @return True if there definition is scoped.*/public boolean hasScopedDefinition() {return scopedDefinition;}/**- * Tells whether the property is true.- * @return Truth about the property.+ * Tells if it has a unique name.+ * @return True if it has a unique name.*/public boolean hasUniqueName() {return hasUniqueName;}/**- * Tells whether the property is true.- * @return Truth about the property.+ * Tells whether it can be a base class+ * @return True if it can be a base class.*/public boolean cannotBeBaseClass() {return sealed;}/**- * Tells whether the property is true.- * @return Truth about the property.+ * Tells whether it is intrinsic.+ * @return True if it is intrinsic.*/public boolean isIntrinsic() {return isIntrinsic;}/**- * Gets the value (index) of the property.- * @return The index value of the property.+ * Gets the {@link Hfa} kind.+ * @return The {@link Hfa} kind.*/- public int getHfaVal() {- return hfaVal;+ public Hfa getHfa() {+ return hfa;}/**- * Gets the value (index) of the property.- * @return The index value of the property.+ * Gets the {@link Mocom} kind.+ * @return The {@link Mocom} kind.*/- public int getMocomVal() {- return mocomVal;+ public Mocom getMocom() {+ return mocom;}@Override@@ -216,9 +250,9 @@ public class MsProperty extends AbstractParsableItem {builder.append(ds.out(scopedDefinition, SCOPED_STRING));builder.append(ds.out(hasUniqueName, HAS_UNIQUE_NAME_STRING));builder.append(ds.out(sealed, SEALED_STRING));- builder.append(ds.out((hfaVal != 0), HFA_STRING[hfaVal]));+ builder.append(ds.out((hfa != Hfa.NONE), hfa));builder.append(ds.out(isIntrinsic, INTRINSIC_STRING));- builder.append(ds.out((mocomVal != 0), MOCOM_STRING[mocomVal]));+ builder.append(ds.out((mocom != Mocom.NONE), mocom));}private void processProperties(int properties) {@@ -245,13 +279,13 @@ public class MsProperty extends AbstractParsableItem {sealed = ((properties & 0x0001) == 0x0001);properties >>= 1;- hfaVal = (properties & 0x0003);+ hfa = Hfa.fromValue(properties & 0x0003);properties >>= 2;isIntrinsic = ((properties & 0x0001) == 0x0001);properties >>= 1;- mocomVal = (properties & 0x0003);+ mocom = Mocom.fromValue(properties & 0x0003);}}diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/Pointer16MsType.java b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/Pointer16MsType.javaindex b8b13d532a..73a7439661 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/Pointer16MsType.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/Pointer16MsType.java@@ -56,9 +56,10 @@ public class Pointer16MsType extends AbstractPointerMsType {protected void parseAttributes(PdbByteReader reader) throws PdbException {int attributes1 = reader.parseUnsignedByteVal();int attributes2 = reader.parseUnsignedByteVal();- pointerTypeAttribute = attributes1 & 0x001f;+ pointerType = PointerType.fromValue(attributes1 & 0x001f);attributes1 >>= 5;- pointerModeAttribute = attributes1 & 0x0007;+ pointerMode = PointerMode.fromValue(attributes1 & 0x0007);+ //pointerMode = attributes1 & 0x0007;isFlat = ((attributes2 & 0x0001) == 0x0001);attributes2 >>= 1;diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/PointerMsType.java b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/PointerMsType.javaindex 7ca20a83b4..bf32b678be 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/PointerMsType.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/PointerMsType.java@@ -50,40 +50,40 @@ public class PointerMsType extends AbstractPointerMsType {}/**- * Tells whether the property is true.- * @return Truth about the property.+ * Tells whether it has the restrict attribute.+ * @return True if it has the restrict attribute.*/public boolean isRestrict() {return isRestrict;}/**- * Tells whether the property is true.- * @return Truth about the property.+ * Tells whether it is Mocom.+ * @return True if it is Mocoem.*/public boolean isMocom() {return isMocom;}/**- * Tells whether the property is true.- * @return Truth about the property.+ * Tells whether it is a left reference.+ * @return True if it is a left reference.*/public boolean isLeftReference() {return isLRef;}/**- * Tells whether the property is true.- * @return Truth about the property.+ * Tells whether if is a right reference.+ * @return True if it is a right reference.*/public boolean isRightReference() {return isRRef;}/**- * Tells whether the property is true.- * @return Truth about the property.+ * Tells whether the attribute is unknown.+ * @return True if the attribute is unknown.*/public boolean isUnknownAttributes() {return unk;@@ -111,9 +111,10 @@ public class PointerMsType extends AbstractPointerMsType {@Overrideprotected void parseAttributes(PdbByteReader reader) throws PdbException {long attributes = reader.parseUnsignedIntVal();- pointerTypeAttribute = (int) (attributes & 0x001f);+ pointerType = PointerType.fromValue((int) (attributes & 0x001f));attributes >>= 5;- pointerModeAttribute = (int) (attributes & 0x0007);+ pointerMode = PointerMode.fromValue((int) (attributes & 0x0007));+ //pointerMode = (int) (attributes & 0x0007);attributes >>= 3;isFlat = ((attributes & 0x0001) == 0x0001);diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/VtShapeDescriptorMsProperty.java b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/VtShapeDescriptorMsProperty.javaindex 22411c449b..a1379cc306 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/VtShapeDescriptorMsProperty.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/VtShapeDescriptorMsProperty.java@@ -48,10 +48,7 @@ public enum VtShapeDescriptorMsProperty {}public static VtShapeDescriptorMsProperty fromValue(int val) {- if (val < 0 || val >= 7) {- val = 7;- }- return BY_VALUE.get(val);+ return BY_VALUE.getOrDefault(val, UNUSED);}private VtShapeDescriptorMsProperty(String label, int value) {diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/VtShapeMsType.java b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/VtShapeMsType.javaindex 1fe2451272..f166110691 100644--- a/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/VtShapeMsType.java+++ b/Ghidra/Features/PDB/src/main/java/ghidra/pdb/pdbreader/type/VtShapeMsType.java@@ -61,13 +61,22 @@ public class VtShapeMsType extends AbstractMsType {return PDB_ID;}+ /**+ * Tells whether the the {@link VtShapeDescriptorMsProperty} is present.+ * @param descriptor the {@link VtShapeDescriptorMsProperty} to check.+ * @return True if the {@link VtShapeDescriptorMsProperty} is present.+ */+ public boolean hasDescriptor(VtShapeDescriptorMsProperty descriptor) {+ return descriptorList.contains(descriptor);+ }+@Overridepublic void emit(StringBuilder builder, Bind bind) {// No documented API for output.DelimiterState ds = new DelimiterState("", ",");builder.append("vtshape: {");for (VtShapeDescriptorMsProperty descriptor : descriptorList) {- builder.append(ds.out(true, descriptor.toString()));+ builder.append(ds.out(true, descriptor));}builder.append(")");}diff --git a/Ghidra/Features/PDB/src/test/java/ghidra/pdb/pdbreader/DummyPdb700.java b/Ghidra/Features/PDB/src/test/java/ghidra/pdb/pdbreader/DummyPdb700.javaindex e1ac046d2f..3f5186bfc0 100644--- a/Ghidra/Features/PDB/src/test/java/ghidra/pdb/pdbreader/DummyPdb700.java+++ b/Ghidra/Features/PDB/src/test/java/ghidra/pdb/pdbreader/DummyPdb700.java@@ -33,10 +33,14 @@ public class DummyPdb700 extends Pdb700 {/*** IMPORTANT: This method is for testing only. It allows us to set a basic object.* Note: not all values are initialized. Constructor for a dummy PDB used for testing.- * @param tpiIndexMin int. The IndexMin to set/use for the TypeProgramInterface.- * @param tpiIndexMaxExclusive int. MaxIndex+1 to set/use for the TypeProgramInterface.- * @param ipiIndexMin int. The IndexMin to set/use for the ItemProgramInterface.- * @param ipiIndexMaxExclusive int. MaxIndex+1 to set/use for the ItemProgramInterface.+ * @param tpiIndexMin int. The IndexMin to set/use for the+ * {@link AbstractTypeProgramInterface}.+ * @param tpiIndexMaxExclusive int. MaxIndex+1 to set/use for the+ * {@link AbstractTypeProgramInterface}.+ * @param ipiIndexMin int. The IndexMin to set/use for the+ * {@link AbstractTypeProgramInterface}.+ * @param ipiIndexMaxExclusive int. MaxIndex+1 to set/use for the+ * {@link AbstractTypeProgramInterface}.* @throws IOException Upon file IO seek/read issues.* @throws PdbException Upon unknown value for configuration or error in processing components.*/