mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-05-06 20:43:44 +00:00
Add PE resource classes
This commit is contained in:
@@ -56,7 +56,7 @@ namespace BurnOutSharp.Models.PortableExecutable
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
38
BurnOutSharp.Models/PortableExecutable/ResourceDataEntry.cs
Normal file
38
BurnOutSharp.Models/PortableExecutable/ResourceDataEntry.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace BurnOutSharp.Models.PortableExecutable
|
||||
{
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <see href="https://learn.microsoft.com/en-us/windows/win32/debug/pe-format"/>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class ResourceDataEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// The address of a unit of resource data in the Resource Data area.
|
||||
/// </summary>
|
||||
public uint DataRVA;
|
||||
|
||||
/// <summary>
|
||||
/// The size, in bytes, of the resource data that is pointed to by the
|
||||
/// Data RVA field.
|
||||
/// </summary>
|
||||
public uint Size;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public uint Codepage;
|
||||
|
||||
/// <summary>
|
||||
/// Reserved, must be 0.
|
||||
/// </summary>
|
||||
public uint Reserved;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace BurnOutSharp.Models.PortableExecutable
|
||||
{
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <see href="https://learn.microsoft.com/en-us/windows/win32/debug/pe-format"/>
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public class ResourceDirectoryEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// The offset of a string that gives the Type, Name, or Language ID entry,
|
||||
/// depending on level of table.
|
||||
/// </summary>
|
||||
[FieldOffset(0)] public uint NameOffset;
|
||||
|
||||
/// <summary>
|
||||
/// A 32-bit integer that identifies the Type, Name, or Language ID entry.
|
||||
/// </summary>
|
||||
[FieldOffset(0)] public uint IntegerID;
|
||||
|
||||
/// <summary>
|
||||
/// High bit 0. Address of a Resource Data entry (a leaf).
|
||||
/// </summary>
|
||||
[FieldOffset(4)] public uint DataEntryOffset;
|
||||
|
||||
/// <summary>
|
||||
/// High bit 1. The lower 31 bits are the address of another resource
|
||||
/// directory table (the next level down).
|
||||
/// </summary>
|
||||
[FieldOffset(4)] public uint SubdirectoryOffset;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace BurnOutSharp.Models.PortableExecutable
|
||||
{
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <see href="https://learn.microsoft.com/en-us/windows/win32/debug/pe-format"/>
|
||||
public class ResourceDirectoryString
|
||||
{
|
||||
/// <summary>
|
||||
/// The size of the string, not including length field itself.
|
||||
/// </summary>
|
||||
public ushort Length;
|
||||
|
||||
/// <summary>
|
||||
/// The variable-length Unicode string data, word-aligned.
|
||||
/// </summary>
|
||||
public byte[] UnicodeString;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace BurnOutSharp.Models.PortableExecutable
|
||||
{
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <see href="https://learn.microsoft.com/en-us/windows/win32/debug/pe-format"/>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class ResourceDirectoryTable
|
||||
{
|
||||
/// <summary>
|
||||
/// Resource flags. This field is reserved for future use. It is currently
|
||||
/// set to zero.
|
||||
/// </summary>
|
||||
public uint Characteristics;
|
||||
|
||||
/// <summary>
|
||||
/// The time that the resource data was created by the resource compiler.
|
||||
/// </summary>
|
||||
public uint TimeDateStamp;
|
||||
|
||||
/// <summary>
|
||||
/// The major version number, set by the user.
|
||||
/// </summary>
|
||||
public ushort MajorVersion;
|
||||
|
||||
/// <summary>
|
||||
/// The minor version number, set by the user.
|
||||
/// </summary>
|
||||
public ushort MinorVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 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).
|
||||
/// </summary>
|
||||
public ushort NumberOfNameEntries;
|
||||
|
||||
/// <summary>
|
||||
/// The number of directory entries immediately following the Name entries that
|
||||
/// use numeric IDs for Type, Name, or Language entries.
|
||||
/// </summary>
|
||||
public ushort NumberOfIDEntries;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user