本文整理汇总了C#中Microsoft.Cci.UtilityDataStructures.MemoryReader.PeekInt32方法的典型用法代码示例。如果您正苦于以下问题:C# MemoryReader.PeekInt32方法的具体用法?C# MemoryReader.PeekInt32怎么用?C# MemoryReader.PeekInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Cci.UtilityDataStructures.MemoryReader
的用法示例。
在下文中一共展示了MemoryReader.PeekInt32方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadPEFileLevelData
bool ReadPEFileLevelData()
//^ requires this.ReaderState >= ReaderState.Initialized;
{
MemoryReader memReader = new MemoryReader(this.BinaryDocumentMemoryBlock.Pointer, this.BinaryDocumentMemoryBlock.Length);
if (memReader.RemainingBytes < PEFileConstants.BasicPEHeaderSize) {
this.ErrorContainer.AddBinaryError(0, MetadataReaderErrorKind.FileSizeTooSmall);
return false;
}
// Look for DOS Signature "MZ"
ushort dosSig = memReader.PeekUInt16(0);
if (dosSig != PEFileConstants.DosSignature) {
this.ErrorContainer.AddBinaryError(0, MetadataReaderErrorKind.DosHeader);
return false;
}
// Skip the DOS Header
int ntHeaderOffset = memReader.PeekInt32(PEFileConstants.PESignatureOffsetLocation);
if (!memReader.SeekOffset(ntHeaderOffset)) {
this.ErrorContainer.AddBinaryError(memReader.Offset, MetadataReaderErrorKind.FileSizeTooSmall);
return false;
}
// Look for PESignature "PE\0\0"
uint NTSignature = memReader.ReadUInt32();
if (NTSignature != PEFileConstants.PESignature) {
this.ErrorContainer.AddBinaryError(memReader.Offset - sizeof(uint), MetadataReaderErrorKind.PESignature);
return false;
}
// Read the COFF Header
if (!this.ReadCOFFFileHeader(ref memReader)) {
return false;
}
// Read the magic to determine if its PE or PE+
PEMagic magic = (PEMagic)memReader.PeekUInt16(0);
switch (magic) {
case PEMagic.PEMagic32:
if (
!this.ReadOptionalHeaderStandardFields32(ref memReader)
|| !this.ReadOptionalHeaderNTAdditionalFields32(ref memReader)
) {
return false;
}
break;
case PEMagic.PEMagic64:
if (
!this.ReadOptionalHeaderStandardFields64(ref memReader)
|| !this.ReadOptionalHeaderNTAdditionalFields64(ref memReader)
) {
return false;
}
break;
default:
this.ErrorContainer.AddBinaryError(memReader.Offset, MetadataReaderErrorKind.UnknownPEMagic);
return false;
}
if (!this.ReadOptionalHeaderDirectoryEntries(ref memReader)) {
return false;
}
if (!this.ReadSectionHeaders(ref memReader)) {
return false;
}
this.ReaderState = ReaderState.PEFile;
this.Win32ResourceMemoryReader = new MemoryReader(this.DirectoryToMemoryBlock(this.OptionalHeaderDirectoryEntries.ResourceTableDirectory));
return true;
}