public PeHeader(Stream stream) { Reader = new PeReader(stream); Reader.SetPosition(0); DosHeader = Reader.ReadDosHeader(); if (!DosHeader.IsValid) { return; } Reader.SetPosition(DosHeader.HeaderAddress); CoffHeader = Reader.ReadCoffFileHeader(); OptionalHeader = Reader.ReadOptionalHeader(); HeaderFormat = OptionalHeader?.Magic switch { CoffHeader.Magic.Pe32 => Format.PE32, CoffHeader.Magic.Pe32Plus => Format.PE32_PLUS, _ => Format.UNKNOWN }; Reader.SetPosition(CoffHeader.Location + CoffHeader.Size + CoffHeader.SizeOfOptionalHeader); Sections = Reader.ReadSectionTable(CoffHeader.NumberOfSections); }