diff --git a/BurnOutSharp.Models/PortableExecutable/Executable.cs b/BurnOutSharp.Models/PortableExecutable/Executable.cs index a4797960..da83ee1a 100644 --- a/BurnOutSharp.Models/PortableExecutable/Executable.cs +++ b/BurnOutSharp.Models/PortableExecutable/Executable.cs @@ -56,7 +56,7 @@ namespace BurnOutSharp.Models.PortableExecutable /// public DelayLoadDirectoryTableEntry[] DelayLoadDirectoryTable { get; set; } - // TODO: Left off at "The .rsrc Section" + // TODO: Left off at "The .cormeta Section (Object Only)" // TODO: Implement and/or document the following non-modeled parts: // - Grouped Sections (Object Only) @@ -81,5 +81,6 @@ namespace BurnOutSharp.Models.PortableExecutable // - Import Address Table // - The .pdata Section [Multiple formats per entry] // - TLS Callback Functions + // - The .rsrc Section } } diff --git a/BurnOutSharp.Models/PortableExecutable/ResourceDataEntry.cs b/BurnOutSharp.Models/PortableExecutable/ResourceDataEntry.cs new file mode 100644 index 00000000..789b3c86 --- /dev/null +++ b/BurnOutSharp.Models/PortableExecutable/ResourceDataEntry.cs @@ -0,0 +1,38 @@ +using System.Runtime.InteropServices; + +namespace BurnOutSharp.Models.PortableExecutable +{ + /// + /// The resource directory string area consists of Unicode strings, which + /// are word-aligned. These strings are stored together after the last + /// Resource Directory entry and before the first Resource Data entry. + /// This minimizes the impact of these variable-length strings on the + /// alignment of the fixed-size directory entries. + /// + /// + [StructLayout(LayoutKind.Sequential)] + public class ResourceDataEntry + { + /// + /// The address of a unit of resource data in the Resource Data area. + /// + public uint DataRVA; + + /// + /// The size, in bytes, of the resource data that is pointed to by the + /// Data RVA field. + /// + public uint Size; + + /// + /// The code page that is used to decode code point values within the + /// resource data. Typically, the code page would be the Unicode code page. + /// + public uint Codepage; + + /// + /// Reserved, must be 0. + /// + public uint Reserved; + } +} diff --git a/BurnOutSharp.Models/PortableExecutable/ResourceDirectoryEntry.cs b/BurnOutSharp.Models/PortableExecutable/ResourceDirectoryEntry.cs new file mode 100644 index 00000000..7d2e27c8 --- /dev/null +++ b/BurnOutSharp.Models/PortableExecutable/ResourceDirectoryEntry.cs @@ -0,0 +1,47 @@ +using System.Runtime.InteropServices; + +namespace BurnOutSharp.Models.PortableExecutable +{ + /// + /// A leaf's Type, Name, and Language IDs are determined by the path that is + /// taken through directory tables to reach the leaf. The first table + /// determines Type ID, the second table (pointed to by the directory entry + /// in the first table) determines Name ID, and the third table determines + /// Language ID. + /// + /// The directory entries make up the rows of a table. Each resource directory + /// entry has the following format. Whether the entry is a Name or ID entry + /// is indicated by the resource directory table, which indicates how many + /// Name and ID entries follow it (remember that all the Name entries precede + /// all the ID entries for the table). All entries for the table are sorted + /// in ascending order: the Name entries by case-sensitive string and the ID + /// entries by numeric value. Offsets are relative to the address in the + /// IMAGE_DIRECTORY_ENTRY_RESOURCE DataDirectory. + /// + /// + [StructLayout(LayoutKind.Explicit)] + public class ResourceDirectoryEntry + { + /// + /// The offset of a string that gives the Type, Name, or Language ID entry, + /// depending on level of table. + /// + [FieldOffset(0)] public uint NameOffset; + + /// + /// A 32-bit integer that identifies the Type, Name, or Language ID entry. + /// + [FieldOffset(0)] public uint IntegerID; + + /// + /// High bit 0. Address of a Resource Data entry (a leaf). + /// + [FieldOffset(4)] public uint DataEntryOffset; + + /// + /// High bit 1. The lower 31 bits are the address of another resource + /// directory table (the next level down). + /// + [FieldOffset(4)] public uint SubdirectoryOffset; + } +} diff --git a/BurnOutSharp.Models/PortableExecutable/ResourceDirectoryString.cs b/BurnOutSharp.Models/PortableExecutable/ResourceDirectoryString.cs new file mode 100644 index 00000000..cc0dc1b3 --- /dev/null +++ b/BurnOutSharp.Models/PortableExecutable/ResourceDirectoryString.cs @@ -0,0 +1,23 @@ +namespace BurnOutSharp.Models.PortableExecutable +{ + /// + /// The resource directory string area consists of Unicode strings, which + /// are word-aligned. These strings are stored together after the last + /// Resource Directory entry and before the first Resource Data entry. + /// This minimizes the impact of these variable-length strings on the + /// alignment of the fixed-size directory entries. + /// + /// + public class ResourceDirectoryString + { + /// + /// The size of the string, not including length field itself. + /// + public ushort Length; + + /// + /// The variable-length Unicode string data, word-aligned. + /// + public byte[] UnicodeString; + } +} diff --git a/BurnOutSharp.Models/PortableExecutable/ResourceDirectoryTable.cs b/BurnOutSharp.Models/PortableExecutable/ResourceDirectoryTable.cs new file mode 100644 index 00000000..d1351636 --- /dev/null +++ b/BurnOutSharp.Models/PortableExecutable/ResourceDirectoryTable.cs @@ -0,0 +1,55 @@ +using System.Runtime.InteropServices; + +namespace BurnOutSharp.Models.PortableExecutable +{ + /// + /// Each directory table is followed by a series of directory entries that + /// give the name or identifier (ID) for that level (Type, Name, or Language + /// level) and an address of either a data description or another directory + /// table. If the address points to a data description, then the data is a + /// leaf in the tree. If the address points to another directory table, + /// then that table lists directory entries at the next level down. + /// + /// Each resource directory table has the following format. This data + /// structure should be considered the heading of a table because the table + /// actually consists of directory entries. + /// + /// + [StructLayout(LayoutKind.Sequential)] + public class ResourceDirectoryTable + { + /// + /// Resource flags. This field is reserved for future use. It is currently + /// set to zero. + /// + public uint Characteristics; + + /// + /// The time that the resource data was created by the resource compiler. + /// + public uint TimeDateStamp; + + /// + /// The major version number, set by the user. + /// + public ushort MajorVersion; + + /// + /// The minor version number, set by the user. + /// + public ushort MinorVersion; + + /// + /// The number of directory entries immediately following the table that use + /// strings to identify Type, Name, or Language entries (depending on the + /// level of the table). + /// + public ushort NumberOfNameEntries; + + /// + /// The number of directory entries immediately following the Name entries that + /// use numeric IDs for Type, Name, or Language entries. + /// + public ushort NumberOfIDEntries; + } +}