internal void Load(Stream s) { s.AssumeArgNotNull("s"); HeaderSize = s.ReadUIntLE(); MajorRuntimeVersion = s.ReadUShortLE(); MinorRuntimeVersion = s.ReadUShortLE(); MetaDataPointer.Load(s); Flags = (ClrHeaderFlags) s.ReadUIntLE(); EntryPointToken = s.ReadUIntLE(); Resources.Load(s); StrongNameSignature.Load(s); CodeManagerTable.Load(s); VTableFixups.Load(s); ExportAddressTableJumps.Load(s); ManagedNativeHeader.Load(s); }
internal void Load(Stream s) { Name = Encoding.ASCII.GetString(s.ReadBytes(8)).TrimEnd('\0'); VirtualSize = s.ReadUIntLE(); SectionRVA = s.ReadUIntLE(); SizeOfRawData = s.ReadUIntLE(); PointerToRawData = s.ReadUIntLE(); PointerToRelocations = s.ReadUIntLE(); PointerToLineNumbers = s.ReadUIntLE(); NumberOfRelocations = s.ReadUShortLE(); NumberOfLineNumbers = s.ReadUShortLE(); SectionFlags = (SectionFlags)s.ReadUIntLE(); }
internal void Load(Stream s) { s.AssumeArgNotNull("s"); MachineType = ((MachineType)s.ReadUShortLE()).AssumeDefined(); NumberOfSections = s.ReadUShortLE().AssumeGt(0, "Empty section table detected. All valid PE files should contain at least one section."); TimeDateStamp = s.ReadUIntLE(); PointerToSymbolTable = s.ReadUIntLE().AssumeEquals(0u); NumberOfSymbols = s.ReadUIntLE().AssumeEquals(0u); SizeOfOptionalHeader = s.ReadUShortLE(); Characteristics = (FileCharacteristics)s.ReadUShortLE(); Util.Assume(SizeOfOptionalHeader >= 92, "Unexpected optional header size"); var optHeaderStart = s.Position; ImageType = ((ImageType)s.ReadUShortLE()).AssumeDefined(); if (ImageType == ImageType.PE32PlusFile) { Util.Assume(SizeOfOptionalHeader >= 108, "Unexpected optional header size"); } MajorLinkerVersion = s.ReadByteOrThrow(); MinorLinkerVersion = s.ReadByteOrThrow(); SizeOfCode = s.ReadUIntLE(); SizeOfInitializedData = s.ReadUIntLE(); SizeOfUnInitializedData = s.ReadUIntLE(); EntryPointRVA = s.ReadUIntLE(); BaseOfCode = s.ReadUIntLE(); if (ImageType == ImageType.PEFile) { BaseOfData = s.ReadUIntLE(); ImageBase = s.ReadUIntLE(); } else { ImageBase = s.ReadULongLE(); } SectionAlignment = s.ReadUIntLE(); FileAlignment = s.ReadUIntLE(); MajorOSVersion = s.ReadUShortLE(); MinorOSVersion = s.ReadUShortLE(); MajorImageVersion = s.ReadUShortLE(); MinorImageVersion = s.ReadUShortLE(); MajorSubsystemVersion = s.ReadUShortLE(); MinorSubsystemVersion = s.ReadUShortLE(); Win32VersionValue = s.ReadUIntLE(); SizeOfImage = s.ReadUIntLE(); SizeOfHeaders = s.ReadUIntLE(); CheckSum = s.ReadUIntLE(); Subsystem = ((WindowsSubsystem) s.ReadUShortLE()).AssumeDefined(); DllCharacteristics = (DllCharacteristics) s.ReadUShortLE(); if (ImageType == ImageType.PEFile) { SizeOfStackReserve = s.ReadUIntLE(); SizeOfStackCommit = s.ReadUIntLE(); SizeOfHeapReserve = s.ReadUIntLE(); SizeOfHeapCommit = s.ReadUIntLE(); } else { SizeOfStackReserve = s.ReadULongLE(); SizeOfStackCommit = s.ReadULongLE(); SizeOfHeapReserve = s.ReadULongLE(); SizeOfHeapCommit = s.ReadULongLE(); } LoaderFlags = s.ReadUIntLE(); var dataDirCount = s.ReadUIntLE(); Util.Assume(dataDirCount * 8 <= SizeOfOptionalHeader - (s.Position - optHeaderStart), "Inconsistent header fields"); if (dataDirCount != 0) { var dirs = new BlockReference[dataDirCount]; for (int i = 0; i < dirs.Length; ++i) { dirs[i] = new BlockReference(s); } DataDirectories = new ReadOnlyCollection<BlockReference>(dirs); } }