本文整理汇总了C#中Microsoft.Cci.UtilityDataStructures.MemoryReader.ReadUInt16方法的典型用法代码示例。如果您正苦于以下问题:C# MemoryReader.ReadUInt16方法的具体用法?C# MemoryReader.ReadUInt16怎么用?C# MemoryReader.ReadUInt16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Cci.UtilityDataStructures.MemoryReader
的用法示例。
在下文中一共展示了MemoryReader.ReadUInt16方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMethodIL
internal MethodIL/*?*/ GetMethodIL(
uint methodDefRowId
) {
MethodRow methodRow = this.MethodTable[methodDefRowId];
if (
(methodRow.ImplFlags & MethodImplFlags.CodeTypeMask) != MethodImplFlags.ILCodeType
|| methodRow.RVA == 0
) {
return null;
}
MemoryBlock memBlock = this.RVAToMemoryBlock(methodRow.RVA);
// Error need to check if the Memory Block is empty. This is calse for all the calls...
MemoryReader memReader = new MemoryReader(memBlock);
byte headByte = memReader.ReadByte();
if ((headByte & CILMethodFlags.ILFormatMask) == CILMethodFlags.ILTinyFormat) {
int size = headByte >> CILMethodFlags.ILTinyFormatSizeShift;
return new MethodIL(
true,
8,
0x00000000,
memReader.GetMemoryBlockAt(0, size),
null
);
} else if ((headByte & CILMethodFlags.ILFormatMask) != CILMethodFlags.ILFatFormat) {
// PEFileFormat Error...
return null;
}
// FatILFormat
byte headByte2 = memReader.ReadByte();
if ((headByte2 >> CILMethodFlags.ILFatFormatHeaderSizeShift) != CILMethodFlags.ILFatFormatHeaderSize) {
// PEFile Format Error...
return null;
}
bool localVarInited = (headByte & CILMethodFlags.ILInitLocals) == CILMethodFlags.ILInitLocals;
bool moreSectsPresent = (headByte & CILMethodFlags.ILMoreSects) == CILMethodFlags.ILMoreSects;
ushort maxStack = memReader.ReadUInt16();
int codeSize = memReader.ReadInt32();
uint localSignatureToken = memReader.ReadUInt32();
MemoryBlock ilCodeMemBlock = memReader.GetMemoryBlockAt(0, codeSize);
SEHTableEntry[]/*?*/ sehTableEntries = null;
if (moreSectsPresent) {
memReader.SkipBytes(codeSize);
memReader.Align(4);
byte sectHeader = memReader.ReadByte();
if ((sectHeader & CILMethodFlags.SectEHTable) != CILMethodFlags.SectEHTable) {
// PEFile Format Error...
return null;
}
bool sectFatFormat = (sectHeader & CILMethodFlags.SectFatFormat) == CILMethodFlags.SectFatFormat;
int dataSize = memReader.ReadByte();
if (sectFatFormat) {
dataSize += (int)memReader.ReadUInt16() << 8;
sehTableEntries = PEFileReader.GetFatSEHEntries(memReader, dataSize / 24);
} else {
memReader.SkipBytes(2); //skip over reserved field
sehTableEntries = PEFileReader.GetSmallSEHEntries(memReader, dataSize / 12);
}
}
return new MethodIL(
localVarInited,
maxStack,
localSignatureToken,
ilCodeMemBlock,
sehTableEntries
);
}
示例2: PopulateCilInstructions
//.........这里部分代码省略.........
case OperationCode.Ckfinite:
break;
case OperationCode.Mkrefany:
value = this.GetType(memReader.ReadUInt32());
break;
case OperationCode.Ldtoken:
value = this.GetRuntimeHandleFromToken(memReader.ReadUInt32());
break;
case OperationCode.Conv_U2:
case OperationCode.Conv_U1:
case OperationCode.Conv_I:
case OperationCode.Conv_Ovf_I:
case OperationCode.Conv_Ovf_U:
case OperationCode.Add_Ovf:
case OperationCode.Add_Ovf_Un:
case OperationCode.Mul_Ovf:
case OperationCode.Mul_Ovf_Un:
case OperationCode.Sub_Ovf:
case OperationCode.Sub_Ovf_Un:
case OperationCode.Endfinally:
break;
case OperationCode.Leave: {
uint leaveOffset = (uint)(memReader.Offset + 4 + memReader.ReadInt32());
if (leaveOffset >= this.EndOfMethodOffset) {
// Error...
}
value = leaveOffset;
}
break;
case OperationCode.Leave_S: {
uint leaveOffset = (uint)(memReader.Offset + 1 + memReader.ReadSByte());
if (leaveOffset >= this.EndOfMethodOffset) {
// Error...
}
value = leaveOffset;
}
break;
case OperationCode.Stind_I:
case OperationCode.Conv_U:
case OperationCode.Arglist:
case OperationCode.Ceq:
case OperationCode.Cgt:
case OperationCode.Cgt_Un:
case OperationCode.Clt:
case OperationCode.Clt_Un:
break;
case OperationCode.Ldftn:
case OperationCode.Ldvirtftn:
value = this.GetMethod(memReader.ReadUInt32());
break;
case OperationCode.Ldarg:
case OperationCode.Ldarga:
case OperationCode.Starg:
value = this.GetParameter(memReader.ReadUInt16());
break;
case OperationCode.Ldloc:
case OperationCode.Ldloca:
case OperationCode.Stloc:
value = this.GetLocal(memReader.ReadUInt16());
break;
case OperationCode.Localloc:
value = PointerType.GetPointerType(this.PEFileToObjectModel.PlatformType.SystemVoid, this.PEFileToObjectModel.InternFactory);
break;
case OperationCode.Endfilter:
break;
case OperationCode.Unaligned_:
value = memReader.ReadByte();
break;
case OperationCode.Volatile_:
case OperationCode.Tail_:
break;
case OperationCode.Initobj:
value = this.GetType(memReader.ReadUInt32());
break;
case OperationCode.Constrained_:
value = this.GetType(memReader.ReadUInt32());
break;
case OperationCode.Cpblk:
case OperationCode.Initblk:
break;
case OperationCode.No_:
value = (OperationCheckFlags)memReader.ReadByte();
break;
case OperationCode.Rethrow:
break;
case OperationCode.Sizeof:
value = this.GetType(memReader.ReadUInt32());
break;
case OperationCode.Refanytype:
case OperationCode.Readonly_:
break;
default:
this.PEFileToObjectModel.PEFileReader.ErrorContainer.AddILError(this.MethodDefinition, offset, MetadataReaderErrorKind.UnknownILInstruction);
break;
}
instrList[instructionNumber++] = new CilInstruction(cilOpCode, document, offset, value);
}
this.MethodBody.SetCilInstructions(instrList);
return true;
}
示例3: ReadStorageHeader
bool ReadStorageHeader(
ref MemoryReader memReader
)
//^ requires this.ReaderState >= ReaderState.PEFile;
{
if (memReader.RemainingBytes < COR20Constants.SizeofStorageHeader) {
this.ErrorContainer.AddDirectoryError(Directories.Cor20HeaderMetaData, memReader.Offset, MetadataReaderErrorKind.StorageHeaderTooSmall);
return false;
}
this.StorageHeader.Flags = memReader.ReadUInt16();
this.StorageHeader.NumberOfStreams = memReader.ReadInt16();
return true;
}
示例4: GetSmallSEHEntries
internal static SEHTableEntry[] GetSmallSEHEntries(
MemoryReader memReader,
int numEntries
) {
SEHTableEntry[] retSEHEntries = new SEHTableEntry[numEntries];
for (int i = 0; i < numEntries; ++i) {
SEHFlags sehFlags = (SEHFlags)memReader.ReadUInt16();
uint tryOffset = memReader.ReadUInt16();
uint tryLength = memReader.ReadByte();
uint handlerOffset = memReader.ReadUInt16();
uint handlerLength = memReader.ReadByte();
uint classTokenOrFilterOffset = memReader.ReadUInt32();
retSEHEntries[i] = new SEHTableEntry(sehFlags, tryOffset, tryLength, handlerOffset, handlerLength, classTokenOrFilterOffset);
}
return retSEHEntries;
}
示例5: ReadCOR20Header
bool ReadCOR20Header()
//^ requires this.ReaderState >= ReaderState.PEFile;
{
MemoryBlock memBlock = this.DirectoryToMemoryBlock(this.OptionalHeaderDirectoryEntries.COR20HeaderTableDirectory);
if (memBlock.Length < this.OptionalHeaderDirectoryEntries.COR20HeaderTableDirectory.Size) {
this.ErrorContainer.AddDirectoryError(Directories.COR20Header, 0, MetadataReaderErrorKind.NotEnoughSpaceForCOR20HeaderTableDirectory);
return false;
}
MemoryReader memReader = new MemoryReader(memBlock);
if (memReader.RemainingBytes < COR20Constants.SizeOfCOR20Header) {
this.ErrorContainer.AddDirectoryError(Directories.COR20Header, 0, MetadataReaderErrorKind.COR20HeaderTooSmall);
return false;
}
this.COR20Header.CountBytes = memReader.ReadInt32();
this.COR20Header.MajorRuntimeVersion = memReader.ReadUInt16();
this.COR20Header.MinorRuntimeVersion = memReader.ReadUInt16();
this.COR20Header.MetaDataDirectory.RelativeVirtualAddress = memReader.ReadInt32();
this.COR20Header.MetaDataDirectory.Size = memReader.ReadUInt32();
this.COR20Header.COR20Flags = (COR20Flags)memReader.ReadUInt32();
this.COR20Header.EntryPointTokenOrRVA = memReader.ReadUInt32();
this.COR20Header.ResourcesDirectory.RelativeVirtualAddress = memReader.ReadInt32();
this.COR20Header.ResourcesDirectory.Size = memReader.ReadUInt32();
this.COR20Header.StrongNameSignatureDirectory.RelativeVirtualAddress = memReader.ReadInt32();
this.COR20Header.StrongNameSignatureDirectory.Size = memReader.ReadUInt32();
this.COR20Header.CodeManagerTableDirectory.RelativeVirtualAddress = memReader.ReadInt32();
this.COR20Header.CodeManagerTableDirectory.Size = memReader.ReadUInt32();
this.COR20Header.VtableFixupsDirectory.RelativeVirtualAddress = memReader.ReadInt32();
this.COR20Header.ExportAddressTableJumpsDirectory.Size = memReader.ReadUInt32();
this.COR20Header.ExportAddressTableJumpsDirectory.RelativeVirtualAddress = memReader.ReadInt32();
this.COR20Header.ExportAddressTableJumpsDirectory.Size = memReader.ReadUInt32();
this.COR20Header.ManagedNativeHeaderDirectory.RelativeVirtualAddress = memReader.ReadInt32();
this.COR20Header.ManagedNativeHeaderDirectory.Size = memReader.ReadUInt32();
return true;
}
示例6: ReadMetadataHeader
bool ReadMetadataHeader(
ref MemoryReader memReader
)
//^ requires this.ReaderState >= ReaderState.PEFile;
{
if (memReader.RemainingBytes < COR20Constants.MinimumSizeofMetadataHeader) {
this.ErrorContainer.AddDirectoryError(Directories.Cor20HeaderMetaData, 0, MetadataReaderErrorKind.MetadataHeaderTooSmall);
return false;
}
this.MetadataHeader.Signature = memReader.ReadUInt32();
if (this.MetadataHeader.Signature != COR20Constants.COR20MetadataSignature) {
this.ErrorContainer.AddDirectoryError(Directories.Cor20HeaderMetaData, memReader.Offset - sizeof(uint), MetadataReaderErrorKind.MetadataSignature);
return false;
}
this.MetadataHeader.MajorVersion = memReader.ReadUInt16();
this.MetadataHeader.MinorVersion = memReader.ReadUInt16();
this.MetadataHeader.ExtraData = memReader.ReadUInt32();
this.MetadataHeader.VersionStringSize = memReader.ReadInt32();
if (memReader.RemainingBytes < this.MetadataHeader.VersionStringSize) {
this.ErrorContainer.AddDirectoryError(Directories.Cor20HeaderMetaData, memReader.Offset, MetadataReaderErrorKind.NotEnoughSpaceForVersionString);
return false;
}
int numberOfBytesRead;
this.MetadataHeader.VersionString = memReader.PeekUTF8NullTerminated(0, out numberOfBytesRead);
memReader.SkipBytes(this.MetadataHeader.VersionStringSize);
return true;
}
示例7: ReadOptionalHeaderNTAdditionalFields64
bool ReadOptionalHeaderNTAdditionalFields64(
ref MemoryReader memReader
)
//^ requires this.ReaderState >= ReaderState.Initialized;
{
if (memReader.RemainingBytes < PEFileConstants.SizeofOptionalHeaderNTAdditionalFields64) {
this.ErrorContainer.AddBinaryError(memReader.Offset, MetadataReaderErrorKind.OptionalHeaderNTAdditionalFields64TooSmall);
return false;
}
this.OptionalHeaderNTAdditionalFields.ImageBase = memReader.ReadUInt64();
this.OptionalHeaderNTAdditionalFields.SectionAlignment = memReader.ReadInt32();
this.OptionalHeaderNTAdditionalFields.FileAlignment = memReader.ReadUInt32();
this.OptionalHeaderNTAdditionalFields.MajorOperatingSystemVersion = memReader.ReadUInt16();
this.OptionalHeaderNTAdditionalFields.MinorOperatingSystemVersion = memReader.ReadUInt16();
this.OptionalHeaderNTAdditionalFields.MajorImageVersion = memReader.ReadUInt16();
this.OptionalHeaderNTAdditionalFields.MinorImageVersion = memReader.ReadUInt16();
this.OptionalHeaderNTAdditionalFields.MajorSubsystemVersion = memReader.ReadUInt16();
this.OptionalHeaderNTAdditionalFields.MinorSubsystemVersion = memReader.ReadUInt16();
this.OptionalHeaderNTAdditionalFields.Win32VersionValue = memReader.ReadUInt32();
this.OptionalHeaderNTAdditionalFields.SizeOfImage = memReader.ReadInt32();
this.OptionalHeaderNTAdditionalFields.SizeOfHeaders = memReader.ReadInt32();
this.OptionalHeaderNTAdditionalFields.CheckSum = memReader.ReadUInt32();
this.OptionalHeaderNTAdditionalFields.Subsystem = (Subsystem)memReader.ReadUInt16();
this.OptionalHeaderNTAdditionalFields.DllCharacteristics = (DllCharacteristics)memReader.ReadUInt16();
this.OptionalHeaderNTAdditionalFields.SizeOfStackReserve = memReader.ReadUInt64();
this.OptionalHeaderNTAdditionalFields.SizeOfStackCommit = memReader.ReadUInt64();
this.OptionalHeaderNTAdditionalFields.SizeOfHeapReserve = memReader.ReadUInt64();
this.OptionalHeaderNTAdditionalFields.SizeOfHeapCommit = memReader.ReadUInt64();
this.OptionalHeaderNTAdditionalFields.LoaderFlags = memReader.ReadUInt32();
this.OptionalHeaderNTAdditionalFields.NumberOfRvaAndSizes = memReader.ReadInt32();
return true;
}
示例8: ReadSectionHeaders
bool ReadSectionHeaders(
ref MemoryReader memReader
)
//^ requires this.ReaderState >= ReaderState.Initialized;
{
int numberOfSections = this.COFFFileHeader.NumberOfSections;
if (memReader.RemainingBytes < numberOfSections * PEFileConstants.SizeofSectionHeader) {
this.ErrorContainer.AddBinaryError(memReader.Offset, MetadataReaderErrorKind.SectionHeadersTooSmall);
return false;
}
this.SectionHeaders = new SectionHeader[numberOfSections];
SectionHeader[] sectionHeaderArray = this.SectionHeaders;
for (int i = 0; i < numberOfSections; ++i) {
sectionHeaderArray[i].Name = memReader.ReadASCIIWithSize(PEFileConstants.SizeofSectionName);
sectionHeaderArray[i].VirtualSize = memReader.ReadInt32();
sectionHeaderArray[i].VirtualAddress = memReader.ReadInt32();
sectionHeaderArray[i].SizeOfRawData = memReader.ReadInt32();
sectionHeaderArray[i].OffsetToRawData = memReader.ReadInt32();
sectionHeaderArray[i].RVAToRelocations = memReader.ReadInt32();
sectionHeaderArray[i].PointerToLineNumbers = memReader.ReadInt32();
sectionHeaderArray[i].NumberOfRelocations = memReader.ReadUInt16();
sectionHeaderArray[i].NumberOfLineNumbers = memReader.ReadUInt16();
sectionHeaderArray[i].SectionCharacteristics = (SectionCharacteristics)memReader.ReadUInt32();
}
return true;
}
示例9: ReadOptionalHeaderStandardFields64
bool ReadOptionalHeaderStandardFields64(
ref MemoryReader memReader
)
//^ requires this.ReaderState >= ReaderState.Initialized;
{
if (memReader.RemainingBytes < PEFileConstants.SizeofOptionalHeaderStandardFields64) {
this.ErrorContainer.AddBinaryError(memReader.Offset, MetadataReaderErrorKind.OptionalHeaderStandardFields64TooSmall);
return false;
}
this.OptionalHeaderStandardFields.PEMagic = (PEMagic)memReader.ReadUInt16();
this.OptionalHeaderStandardFields.MajorLinkerVersion = memReader.ReadByte();
this.OptionalHeaderStandardFields.MinorLinkerVersion = memReader.ReadByte();
this.OptionalHeaderStandardFields.SizeOfCode = memReader.ReadInt32();
this.OptionalHeaderStandardFields.SizeOfInitializedData = memReader.ReadInt32();
this.OptionalHeaderStandardFields.SizeOfUninitializedData = memReader.ReadInt32();
this.OptionalHeaderStandardFields.RVAOfEntryPoint = memReader.ReadInt32();
this.OptionalHeaderStandardFields.BaseOfCode = memReader.ReadInt32();
return true;
}
示例10: ReadCOFFFileHeader
bool ReadCOFFFileHeader(
ref MemoryReader memReader
)
//^ requires this.ReaderState >= ReaderState.Initialized;
{
if (memReader.RemainingBytes < PEFileConstants.SizeofCOFFFileHeader) {
this.ErrorContainer.AddBinaryError(memReader.Offset, MetadataReaderErrorKind.COFFHeaderTooSmall);
return false;
}
this.COFFFileHeader.Machine = (Machine)memReader.ReadUInt16();
this.COFFFileHeader.NumberOfSections = memReader.ReadInt16();
this.COFFFileHeader.TimeDateStamp = memReader.ReadInt32();
this.COFFFileHeader.PointerToSymbolTable = memReader.ReadInt32();
this.COFFFileHeader.NumberOfSymbols = memReader.ReadInt32();
this.COFFFileHeader.SizeOfOptionalHeader = memReader.ReadInt16();
this.COFFFileHeader.Characteristics = (Characteristics)memReader.ReadUInt16();
return true;
}
示例11: ReadDebugInformationLocationFromDebugTableDirectoryData
private string ReadDebugInformationLocationFromDebugTableDirectoryData() {
if (this.OptionalHeaderDirectoryEntries.DebugTableDirectory.Size != 0x1c) return string.Empty;
var debugDirectoryReader = new MemoryReader(this.DirectoryToMemoryBlock(this.OptionalHeaderDirectoryEntries.DebugTableDirectory));
PeDebugDirectory debugDir = new PeDebugDirectory();
debugDir.Characteristics = debugDirectoryReader.ReadUInt32();
debugDir.TimeDateStamp = debugDirectoryReader.ReadUInt32();
debugDir.MajorVersion = debugDirectoryReader.ReadUInt16();
debugDir.MinorVersion = debugDirectoryReader.ReadUInt16();
debugDir.Type = debugDirectoryReader.ReadUInt32();
debugDir.SizeOfData = debugDirectoryReader.ReadUInt32();
debugDir.AddressOfRawData = debugDirectoryReader.ReadUInt32();
debugDir.PointerToRawData = debugDirectoryReader.ReadUInt32();
if (debugDir.SizeOfData == 0 ) return string.Empty;
var dataBlock = new MemoryBlock(this.BinaryDocumentMemoryBlock.Pointer + debugDir.PointerToRawData, debugDir.SizeOfData);
var ptrToDebugInfo = this.BinaryDocumentMemoryBlock.Pointer + debugDir.PointerToRawData;
var ptrToDebugInfoEnd = this.BinaryDocumentMemoryBlock.Pointer + debugDir.PointerToRawData + debugDir.SizeOfData;
if (ptrToDebugInfo >= this.BinaryDocumentMemoryBlock.Pointer + this.BinaryDocumentMemoryBlock.Length - 28) {
//TODO: error
return string.Empty;
}
if (ptrToDebugInfoEnd > this.BinaryDocumentMemoryBlock.Pointer + this.BinaryDocumentMemoryBlock.Length) {
//TODO: error
return string.Empty;
}
var debugDataReader = new MemoryReader(dataBlock);
var magic = debugDataReader.ReadUInt32();
if (magic != 0x53445352) { //RSDS in little endian format
//TODO: error
return string.Empty;
}
var unknown1 = debugDataReader.ReadUInt32();
var unknown2 = debugDataReader.ReadUInt32();
var unknown3 = debugDataReader.ReadUInt32();
var unknown4 = debugDataReader.ReadUInt32();
var unknown5 = debugDataReader.ReadUInt32();
return debugDataReader.ReadASCIINullTerminated();
}
示例12: GetDefaultValue
internal IMetadataConstant GetDefaultValue(
MetadataObject metadataObject
) {
uint constRowId = this.PEFileReader.ConstantTable.GetConstantRowId(metadataObject.TokenValue);
if (constRowId == 0)
return Dummy.Constant;
ConstantRow constRow = this.PEFileReader.ConstantTable[constRowId];
MemoryBlock constValueMemoryBlock = this.PEFileReader.BlobStream.GetMemoryBlockAt(constRow.Value);
MemoryReader memoryReader = new MemoryReader(constValueMemoryBlock);
switch (constRow.Type) {
case ElementType.Boolean: {
byte val = memoryReader.ReadByte();
return new ConstantExpression(this.PlatformType.SystemBoolean, val != 0);
}
case ElementType.Char:
return new ConstantExpression(this.PlatformType.SystemChar, memoryReader.ReadChar());
case ElementType.Int8:
return new ConstantExpression(this.PlatformType.SystemInt8, memoryReader.ReadSByte());
case ElementType.Int16:
return new ConstantExpression(this.PlatformType.SystemInt16, memoryReader.ReadInt16());
case ElementType.Int32:
return new ConstantExpression(this.PlatformType.SystemInt32, memoryReader.ReadInt32());
case ElementType.Int64:
return new ConstantExpression(this.PlatformType.SystemInt64, memoryReader.ReadInt64());
case ElementType.UInt8:
return new ConstantExpression(this.PlatformType.SystemUInt8, memoryReader.ReadByte());
case ElementType.UInt16:
return new ConstantExpression(this.PlatformType.SystemUInt16, memoryReader.ReadUInt16());
case ElementType.UInt32:
return new ConstantExpression(this.PlatformType.SystemUInt32, memoryReader.ReadUInt32());
case ElementType.UInt64:
return new ConstantExpression(this.PlatformType.SystemUInt64, memoryReader.ReadUInt64());
case ElementType.Single:
return new ConstantExpression(this.PlatformType.SystemFloat32, memoryReader.ReadSingle());
case ElementType.Double:
return new ConstantExpression(this.PlatformType.SystemFloat64, memoryReader.ReadDouble());
case ElementType.String: {
int byteLen = memoryReader.Length;
string/*?*/ value;
if (byteLen == -1) {
value = null;
} else if (byteLen == 0) {
value = string.Empty;
} else {
value = memoryReader.ReadUTF16WithSize(byteLen);
}
return new ConstantExpression(this.PlatformType.SystemString, value);
}
case ElementType.Class:
return new ConstantExpression(this.PlatformType.SystemObject, null);
}
// MDError...
return Dummy.Constant;
}
示例13: ReadDebugInformationLocationFromDebugTableDirectoryData
private PEFileDebugInformation ReadDebugInformationLocationFromDebugTableDirectoryData() {
if (this.OptionalHeaderDirectoryEntries.DebugTableDirectory.Size != 0x1c) return new PEFileDebugInformation();
var debugDirectoryReader = new MemoryReader(this.DirectoryToMemoryBlock(this.OptionalHeaderDirectoryEntries.DebugTableDirectory));
PeDebugDirectory debugDir = new PeDebugDirectory();
debugDir.Characteristics = debugDirectoryReader.ReadUInt32();
debugDir.TimeDateStamp = debugDirectoryReader.ReadUInt32();
debugDir.MajorVersion = debugDirectoryReader.ReadUInt16();
debugDir.MinorVersion = debugDirectoryReader.ReadUInt16();
debugDir.Type = debugDirectoryReader.ReadUInt32();
debugDir.SizeOfData = debugDirectoryReader.ReadUInt32();
debugDir.AddressOfRawData = debugDirectoryReader.ReadUInt32();
debugDir.PointerToRawData = debugDirectoryReader.ReadUInt32();
if (debugDir.SizeOfData == 0) return new PEFileDebugInformation();
var dataBlock = new MemoryBlock(this.BinaryDocumentMemoryBlock.Pointer + debugDir.PointerToRawData, debugDir.SizeOfData);
var ptrToDebugInfo = this.BinaryDocumentMemoryBlock.Pointer + debugDir.PointerToRawData;
var ptrToDebugInfoEnd = this.BinaryDocumentMemoryBlock.Pointer + debugDir.PointerToRawData + debugDir.SizeOfData;
if (ptrToDebugInfo >= this.BinaryDocumentMemoryBlock.Pointer + this.BinaryDocumentMemoryBlock.Length - 28) {
//TODO: error
return new PEFileDebugInformation();
}
if (ptrToDebugInfoEnd > this.BinaryDocumentMemoryBlock.Pointer + this.BinaryDocumentMemoryBlock.Length) {
//TODO: error
return new PEFileDebugInformation();
}
var debugDataReader = new MemoryReader(dataBlock);
var magic = debugDataReader.ReadUInt32();
if (magic != 0x53445352) { //RSDS in little endian format
//TODO: error
return new PEFileDebugInformation();
}
var guid = debugDataReader.PeekGuid(0);
debugDataReader.SkipBytes(16);
UInt32 age = debugDataReader.ReadUInt32();
string fileName = debugDataReader.ReadASCIINullTerminated();
var guidHex = guid.ToString("N");
string ageHex = age.ToString("X");
string version = guidHex + ageHex;
PEFileDebugInformation information = new PEFileDebugInformation();
information.Signature = guid;
information.Age = age;
information.PdbVersion = version;
information.PdbFileName = fileName;
return information;
}