private void WriteCoffHeader(BlobBuilder builder, ImmutableArray <SerializedSection> sections, out Blob stampFixup) { // Machine builder.WriteUInt16((ushort)(Header.Machine == 0 ? Machine.I386 : Header.Machine)); // NumberOfSections builder.WriteUInt16((ushort)sections.Length); // TimeDateStamp: stampFixup = builder.ReserveBytes(sizeof(uint)); // PointerToSymbolTable (TODO: not supported): // The file pointer to the COFF symbol table, or zero if no COFF symbol table is present. // This value should be zero for a PE image. builder.WriteUInt32(0); // NumberOfSymbols (TODO: not supported): // The number of entries in the symbol table. This data can be used to locate the string table, // which immediately follows the symbol table. This value should be zero for a PE image. builder.WriteUInt32(0); // SizeOfOptionalHeader: // The size of the optional header, which is required for executable files but not for object files. // This value should be zero for an object file (TODO). builder.WriteUInt16((ushort)PEHeader.Size(Header.Is32Bit)); // Characteristics builder.WriteUInt16((ushort)Header.ImageCharacteristics); }
internal int ComputeSizeOfPEHeaders(int sectionCount) => PEBuilder.DosHeaderSize + PEHeaders.PESignatureSize + CoffHeader.Size + PEHeader.Size(Is32Bit) + SectionHeader.Size * sectionCount;