void MoveTo(DataDirectory directory) { BaseStream.Position = image.ResolveVirtualAddress(directory.VirtualAddress); }
public void WriteDataDirectory(DataDirectory directory) { Write(directory.VirtualAddress); Write(directory.Size); }
void ReadOptionalHeaders(out ushort subsystem, out ushort dll_characteristics) { // - PEOptionalHeader // - StandardFieldsHeader // Magic 2 bool pe64 = ReadUInt16() == 0x20b; // pe32 || pe64 image.LinkerVersion = ReadUInt16(); // CodeSize 4 // InitializedDataSize 4 // UninitializedDataSize4 // EntryPointRVA 4 // BaseOfCode 4 // BaseOfData 4 || 0 // - NTSpecificFieldsHeader // ImageBase 4 || 8 // SectionAlignment 4 // FileAlignement 4 // OSMajor 2 // OSMinor 2 // UserMajor 2 // UserMinor 2 // SubSysMajor 2 // SubSysMinor 2 Advance(44); image.SubSystemMajor = ReadUInt16(); image.SubSystemMinor = ReadUInt16(); // Reserved 4 // ImageSize 4 // HeaderSize 4 // FileChecksum 4 Advance(16); // SubSystem 2 subsystem = ReadUInt16(); // DLLFlags 2 dll_characteristics = ReadUInt16(); // StackReserveSize 4 || 8 // StackCommitSize 4 || 8 // HeapReserveSize 4 || 8 // HeapCommitSize 4 || 8 // LoaderFlags 4 // NumberOfDataDir 4 // - DataDirectoriesHeader // ExportTable 8 // ImportTable 8 Advance(pe64 ? 56 : 40); // ResourceTable 8 image.Win32Resources = ReadDataDirectory(); // ExceptionTable 8 // CertificateTable 8 // BaseRelocationTable 8 Advance(24); // Debug 8 image.Debug = ReadDataDirectory(); // Copyright 8 // GlobalPtr 8 // TLSTable 8 // LoadConfigTable 8 // BoundImport 8 // IAT 8 // DelayImportDescriptor8 Advance(56); // CLIHeader 8 cli = ReadDataDirectory(); if (cli.IsZero) { throw new BadImageFormatException(); } // Reserved 8 Advance(8); }