public PEFile(string fileName) { using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { fs.Seek(0x3C, SeekOrigin.Begin); fileHeaderOffset = Utils.ReadInt(fs); fs.Seek(fileHeaderOffset, SeekOrigin.Begin); FileHeader = new PEFileHeader(fileHeaderOffset, fs); OptionalHeader = new PEOptionalHeader(fs); // read the sections Sections = new List<PESection>(); for (int i = 0; i < FileHeader.NumSections; i++) Sections.Add(new PESection(fs)); // Find .text section and load the data PESection textSection = Sections.FirstOrDefault(s => s.SectionName.StartsWith(".text")); textSection.LoadData(fs); CLRDirectory = new CLRDirectory(fs, this); } }
public PEFile(string fileName) { using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { fs.Seek(0x3C, SeekOrigin.Begin); fileHeaderOffset = Utils.ReadInt(fs); fs.Seek(fileHeaderOffset, SeekOrigin.Begin); FileHeader = new PEFileHeader(fileHeaderOffset, fs); OptionalHeader = new PEOptionalHeader(fs); // read the sections Sections = new List <PESection>(); for (int i = 0; i < FileHeader.NumSections; i++) { Sections.Add(new PESection(fs)); } // Find .text section and load the data PESection textSection = Sections.FirstOrDefault(s => s.SectionName.StartsWith(".text")); textSection.LoadData(fs); CLRDirectory = new CLRDirectory(fs, this); } }