Files
SabreTools.Serialization/SabreTools.Data.Models/PortableExecutable/Resource/DirectoryEntry.cs

77 lines
3.2 KiB
C#
Raw Normal View History

2025-09-26 13:06:18 -04:00
namespace SabreTools.Data.Models.PortableExecutable.Resource
2025-09-26 12:09:34 -04:00
{
/// <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.
2025-10-30 23:29:24 -04:00
///
2025-09-26 12:09:34 -04:00
/// 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"/>
2026-02-12 12:27:36 -05:00
/// <see href="https://learn.microsoft.com/en-us/previous-versions/ms809762(v=msdn.10)#pe-file-resources"/>
2025-09-26 12:09:34 -04:00
public sealed class DirectoryEntry
{
#region Offset 0x00
/// <summary>
/// The offset of a string that gives the Type, Name, or Language ID entry,
/// depending on level of table.
/// </summary>
2026-02-12 12:52:52 -05:00
/// <remarks>Must be unset if <see cref="IntegerID"/> is set</remarks>
2025-09-26 12:09:34 -04:00
public uint NameOffset { get; set; }
/// <summary>
/// A string that gives the Type, Name, or Language ID entry, depending on
/// level of table.
/// </summary>
2026-02-12 12:52:52 -05:00
/// <remarks>Only has a value if <see cref="NameOffset"/> is set</remarks>
2025-09-26 12:09:34 -04:00
public DirectoryString? Name { get; set; }
/// <summary>
/// A 32-bit integer that identifies the Type, Name, or Language ID entry.
/// </summary>
2026-02-12 12:52:52 -05:00
/// <remarks>Must be unset if <see cref="NameOffset"/> is set</remarks>
2025-09-26 12:09:34 -04:00
public uint IntegerID { get; set; }
#endregion
#region Offset 0x04
/// <summary>
/// High bit 0. Address of a Resource Data entry (a leaf).
/// </summary>
2026-02-12 12:52:52 -05:00
/// <remarks>Must be unset if <see cref="SubdirectoryOffset"/> is set</remarks>
2025-09-26 12:09:34 -04:00
public uint DataEntryOffset { get; set; }
/// <summary>
/// High bit 1. The lower 31 bits are the address of another resource
/// directory table (the next level down).
/// </summary>
2026-02-12 12:52:52 -05:00
/// <remarks>Must be unset if <see cref="DataEntryOffset"/> is set</remarks>
2025-09-26 12:09:34 -04:00
public uint SubdirectoryOffset { get; set; }
2026-02-12 12:52:52 -05:00
#endregion
/// <summary>
/// Resource data entry (a leaf).
/// </summary>
/// <remarks>Must be null if <see cref="Subdirectory"/> is set</remarks>
public DataEntry? DataEntry { get; set; }
2025-09-26 12:09:34 -04:00
/// <summary>
/// Another resource directory table (the next level down).
/// </summary>
2026-02-12 12:52:52 -05:00
/// <remarks>Must be null if <see cref="DataEntry"/> is set</remarks>
2025-09-26 12:09:34 -04:00
public DirectoryTable? Subdirectory { get; set; }
}
}