GP-0 - PDB rename MS PointerMode

This commit is contained in:
ghizard 2024-02-26 17:24:11 -05:00
parent a348f2d5df
commit 774d6058bb
4 changed files with 23 additions and 23 deletions

View File

@ -73,7 +73,7 @@ public abstract class AbstractPointerMsType extends AbstractMsType {
} }
public enum PointerMode { public enum MsPointerMode {
INVALID("", -1), // Our default INVALID("", -1), // Our default
POINTER("*", 0), // Normal POINTER("*", 0), // Normal
@ -83,9 +83,9 @@ public abstract class AbstractPointerMsType extends AbstractMsType {
RVALUE_REFERENCE("&&", 4), RVALUE_REFERENCE("&&", 4),
RESERVED("", 5); RESERVED("", 5);
private static final Map<Integer, PointerMode> BY_VALUE = new HashMap<>(); private static final Map<Integer, MsPointerMode> BY_VALUE = new HashMap<>();
static { static {
for (PointerMode val : values()) { for (MsPointerMode val : values()) {
BY_VALUE.put(val.value, val); BY_VALUE.put(val.value, val);
} }
} }
@ -106,11 +106,11 @@ public abstract class AbstractPointerMsType extends AbstractMsType {
return label; return label;
} }
public static PointerMode fromValue(int val) { public static MsPointerMode fromValue(int val) {
return BY_VALUE.getOrDefault(val, INVALID); return BY_VALUE.getOrDefault(val, INVALID);
} }
private PointerMode(String label, int value) { private MsPointerMode(String label, int value) {
this.label = label; this.label = label;
this.value = value; this.value = value;
} }
@ -164,7 +164,7 @@ public abstract class AbstractPointerMsType extends AbstractMsType {
//============================================================================================== //==============================================================================================
protected RecordNumber underlyingRecordNumber; protected RecordNumber underlyingRecordNumber;
protected PointerType pointerType; protected PointerType pointerType;
protected PointerMode pointerMode; protected MsPointerMode pointerMode;
protected boolean isFlat; // 0:32 pointer protected boolean isFlat; // 0:32 pointer
protected boolean isVolatile; protected boolean isVolatile;
protected boolean isConst; protected boolean isConst;
@ -191,8 +191,8 @@ public abstract class AbstractPointerMsType extends AbstractMsType {
public void parseExtendedPointerInfo(PdbByteReader reader, int intSize, public void parseExtendedPointerInfo(PdbByteReader reader, int intSize,
StringParseType stringType) throws PdbException { StringParseType stringType) throws PdbException {
if (pointerMode == PointerMode.MEMBER_DATA_POINTER || if (pointerMode == MsPointerMode.MEMBER_DATA_POINTER ||
pointerMode == PointerMode.MEMBER_FUNCTION_POINTER) { pointerMode == MsPointerMode.MEMBER_FUNCTION_POINTER) {
memberPointerContainingClassRecordNumber = memberPointerContainingClassRecordNumber =
RecordNumber.parse(pdb, reader, RecordCategory.TYPE, intSize); RecordNumber.parse(pdb, reader, RecordCategory.TYPE, intSize);
memberPointerType = MemberPointerType.fromValue(reader.parseUnsignedShortVal()); memberPointerType = MemberPointerType.fromValue(reader.parseUnsignedShortVal());
@ -265,10 +265,10 @@ public abstract class AbstractPointerMsType extends AbstractMsType {
} }
/** /**
* Returns {@link PointerMode} attribute. * Returns {@link MsPointerMode} attribute.
* @return {@link PointerMode} attribute. * @return {@link MsPointerMode} attribute.
*/ */
public PointerMode getPointerMode() { public MsPointerMode getPointerMode() {
return pointerMode; return pointerMode;
} }

View File

@ -51,7 +51,7 @@ public class Pointer16MsType extends AbstractPointerMsType {
int attributes2 = reader.parseUnsignedByteVal(); int attributes2 = reader.parseUnsignedByteVal();
pointerType = PointerType.fromValue(attributes1 & 0x001f); pointerType = PointerType.fromValue(attributes1 & 0x001f);
attributes1 >>= 5; attributes1 >>= 5;
pointerMode = PointerMode.fromValue(attributes1 & 0x0007); pointerMode = MsPointerMode.fromValue(attributes1 & 0x0007);
isFlat = ((attributes2 & 0x0001) == 0x0001); isFlat = ((attributes2 & 0x0001) == 0x0001);
attributes2 >>= 1; attributes2 >>= 1;

View File

@ -101,7 +101,7 @@ public class PointerMsType extends AbstractPointerMsType {
long attributes = reader.parseUnsignedIntVal(); long attributes = reader.parseUnsignedIntVal();
pointerType = PointerType.fromValue((int) (attributes & 0x001f)); pointerType = PointerType.fromValue((int) (attributes & 0x001f));
attributes >>= 5; attributes >>= 5;
pointerMode = PointerMode.fromValue((int) (attributes & 0x0007)); pointerMode = MsPointerMode.fromValue((int) (attributes & 0x0007));
attributes >>= 3; attributes >>= 3;
isFlat = ((attributes & 0x0001) == 0x0001); isFlat = ((attributes & 0x0001) == 0x0001);

View File

@ -19,7 +19,7 @@ import ghidra.app.util.SymbolPath;
import ghidra.app.util.bin.format.pdb2.pdbreader.PdbException; import ghidra.app.util.bin.format.pdb2.pdbreader.PdbException;
import ghidra.app.util.bin.format.pdb2.pdbreader.RecordNumber; import ghidra.app.util.bin.format.pdb2.pdbreader.RecordNumber;
import ghidra.app.util.bin.format.pdb2.pdbreader.type.*; import ghidra.app.util.bin.format.pdb2.pdbreader.type.*;
import ghidra.app.util.bin.format.pdb2.pdbreader.type.AbstractPointerMsType.PointerMode; import ghidra.app.util.bin.format.pdb2.pdbreader.type.AbstractPointerMsType.MsPointerMode;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.exception.CancelledException; import ghidra.util.exception.CancelledException;
@ -52,8 +52,8 @@ public class PointerTypeApplier extends MsTypeApplier {
*/ */
String getPointerCommentField(AbstractPointerMsType type, FixupContext fixupContext) String getPointerCommentField(AbstractPointerMsType type, FixupContext fixupContext)
throws CancelledException, PdbException { throws CancelledException, PdbException {
AbstractPointerMsType.PointerMode pointerMode = type.getPointerMode(); AbstractPointerMsType.MsPointerMode pointerMode = type.getPointerMode();
if (pointerMode == AbstractPointerMsType.PointerMode.MEMBER_FUNCTION_POINTER) { if (pointerMode == AbstractPointerMsType.MsPointerMode.MEMBER_FUNCTION_POINTER) {
// We are no longer able to get underlying type in time due to cycle breaks unless // We are no longer able to get underlying type in time due to cycle breaks unless
// we start doing fixups on pmf/pdm pointers. // we start doing fixups on pmf/pdm pointers.
// TODO: consider fixups on these later... maybe after we understand contents of // TODO: consider fixups on these later... maybe after we understand contents of
@ -63,7 +63,7 @@ public class PointerTypeApplier extends MsTypeApplier {
//return "\"::*\" (pmf) to type: " + underlyingType; //return "\"::*\" (pmf) to type: " + underlyingType;
return "\"::*\" (pmf)"; return "\"::*\" (pmf)";
} }
else if (pointerMode == AbstractPointerMsType.PointerMode.MEMBER_DATA_POINTER) { else if (pointerMode == AbstractPointerMsType.MsPointerMode.MEMBER_DATA_POINTER) {
// We are no longer able to get underlying type in time due to cycle breaks unless // We are no longer able to get underlying type in time due to cycle breaks unless
// we start doing fixups on pmf/pdm pointers. // we start doing fixups on pmf/pdm pointers.
// TODO: consider fixups on these later... maybe after we understand contents of // TODO: consider fixups on these later... maybe after we understand contents of
@ -109,9 +109,9 @@ public class PointerTypeApplier extends MsTypeApplier {
private DataType applyAbstractPointerMsType(AbstractPointerMsType type, private DataType applyAbstractPointerMsType(AbstractPointerMsType type,
FixupContext fixupContext) throws CancelledException, PdbException { FixupContext fixupContext) throws CancelledException, PdbException {
AbstractPointerMsType.PointerMode pointerMode = type.getPointerMode(); AbstractPointerMsType.MsPointerMode pointerMode = type.getPointerMode();
if (pointerMode == AbstractPointerMsType.PointerMode.MEMBER_DATA_POINTER || if (pointerMode == AbstractPointerMsType.MsPointerMode.MEMBER_DATA_POINTER ||
pointerMode == AbstractPointerMsType.PointerMode.MEMBER_FUNCTION_POINTER) { pointerMode == AbstractPointerMsType.MsPointerMode.MEMBER_FUNCTION_POINTER) {
return processMemberPointer(type, fixupContext); return processMemberPointer(type, fixupContext);
} }
return processPointer(type, fixupContext); return processPointer(type, fixupContext);
@ -125,8 +125,8 @@ public class PointerTypeApplier extends MsTypeApplier {
int size = type.getSize().intValueExact(); int size = type.getSize().intValueExact();
String name; String name;
AbstractPointerMsType.PointerMode pointerMode = type.getPointerMode(); AbstractPointerMsType.MsPointerMode pointerMode = type.getPointerMode();
if (pointerMode == AbstractPointerMsType.PointerMode.MEMBER_FUNCTION_POINTER) { if (pointerMode == AbstractPointerMsType.MsPointerMode.MEMBER_FUNCTION_POINTER) {
name = String.format("pmf_%08x", type.toString().hashCode()); name = String.format("pmf_%08x", type.toString().hashCode());
} }
else { else {
@ -175,7 +175,7 @@ public class PointerTypeApplier extends MsTypeApplier {
int size = type.getSize().intValueExact(); int size = type.getSize().intValueExact();
AbstractMsType under = applicator.getPdb().getTypeRecord(type.getUnderlyingRecordNumber()); AbstractMsType under = applicator.getPdb().getTypeRecord(type.getUnderlyingRecordNumber());
CategoryPath categoryPath = applicator.getAnonymousTypesCategory(); CategoryPath categoryPath = applicator.getAnonymousTypesCategory();
PointerMode mode = type.getPointerMode(); MsPointerMode mode = type.getPointerMode();
AbstractPointerMsType.PointerType pt = type.getPointerType(); AbstractPointerMsType.PointerType pt = type.getPointerType();
String name = String name =
String.format("StubPtr%d_%s%s_To_%s", 8 * size, pt.toString(), mode.toString(), String.format("StubPtr%d_%s%s_To_%s", 8 * size, pt.toString(), mode.toString(),