コード例 #1
0
 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;
 }