| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | namespace System.Reflection.PortableExecutable |
| | | 5 | | { |
| | | 6 | | public sealed class CoffHeader |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// The type of target machine. |
| | | 10 | | /// </summary> |
| | 0 | 11 | | public Machine Machine { get; } |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// The number of sections. This indicates the size of the section table, which immediately follows the headers. |
| | | 15 | | /// </summary> |
| | 0 | 16 | | public short NumberOfSections { get; } |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// The low 32 bits of the number of seconds since 00:00 January 1, 1970, that indicates when the file was creat |
| | | 20 | | /// </summary> |
| | 0 | 21 | | public int TimeDateStamp { get; } |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// The file pointer to the COFF symbol table, or zero if no COFF symbol table is present. |
| | | 25 | | /// This value should be zero for a PE image. |
| | | 26 | | /// </summary> |
| | 0 | 27 | | public int PointerToSymbolTable { get; } |
| | | 28 | | |
| | | 29 | | /// <summary> |
| | | 30 | | /// The number of entries in the symbol table. This data can be used to locate the string table, |
| | | 31 | | /// which immediately follows the symbol table. This value should be zero for a PE image. |
| | | 32 | | /// </summary> |
| | 0 | 33 | | public int NumberOfSymbols { get; } |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// The size of the optional header, which is required for executable files but not for object files. |
| | | 37 | | /// This value should be zero for an object file. |
| | | 38 | | /// </summary> |
| | 0 | 39 | | public short SizeOfOptionalHeader { get; } |
| | | 40 | | |
| | | 41 | | /// <summary> |
| | | 42 | | /// The flags that indicate the attributes of the file. |
| | | 43 | | /// </summary> |
| | 0 | 44 | | public Characteristics Characteristics { get; } |
| | | 45 | | |
| | | 46 | | internal const int Size = |
| | | 47 | | sizeof(short) + // Machine |
| | | 48 | | sizeof(short) + // NumberOfSections |
| | | 49 | | sizeof(int) + // TimeDateStamp: |
| | | 50 | | sizeof(int) + // PointerToSymbolTable |
| | | 51 | | sizeof(int) + // NumberOfSymbols |
| | | 52 | | sizeof(short) + // SizeOfOptionalHeader: |
| | | 53 | | sizeof(ushort); // Characteristics |
| | | 54 | | |
| | 0 | 55 | | internal CoffHeader(ref PEBinaryReader reader) |
| | 0 | 56 | | { |
| | 0 | 57 | | Machine = (Machine)reader.ReadUInt16(); |
| | 0 | 58 | | NumberOfSections = reader.ReadInt16(); |
| | 0 | 59 | | TimeDateStamp = reader.ReadInt32(); |
| | 0 | 60 | | PointerToSymbolTable = reader.ReadInt32(); |
| | 0 | 61 | | NumberOfSymbols = reader.ReadInt32(); |
| | 0 | 62 | | SizeOfOptionalHeader = reader.ReadInt16(); |
| | 0 | 63 | | Characteristics = (Characteristics)reader.ReadUInt16(); |
| | 0 | 64 | | } |
| | | 65 | | } |
| | | 66 | | } |
| | | 67 | | |