From 108e63a0993528c726586b1e124f473f731e12d6 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 23 Apr 2024 13:36:24 -0400 Subject: [PATCH] Add some null-terminated type flags --- AACS/CopyrightRecord.cs | 6 +++++- PortableExecutable/MenuItemExtended.cs | 19 +++++++++++++------ PortableExecutable/NB10ProgramDatabase.cs | 16 ++++++++++------ 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/AACS/CopyrightRecord.cs b/AACS/CopyrightRecord.cs index 221a4d8..7a223d5 100644 --- a/AACS/CopyrightRecord.cs +++ b/AACS/CopyrightRecord.cs @@ -1,13 +1,17 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.AACS { /// /// This record type is undocumented but found in real media key blocks /// + [StructLayout(LayoutKind.Sequential)] public sealed class CopyrightRecord : Record { /// /// Null-terminated ASCII string representing the copyright /// - public string? Copyright { get; set; } + [MarshalAs(UnmanagedType.LPStr)] + public string? Copyright; } } \ No newline at end of file diff --git a/PortableExecutable/MenuItemExtended.cs b/PortableExecutable/MenuItemExtended.cs index 771fedc..4b4a36c 100644 --- a/PortableExecutable/MenuItemExtended.cs +++ b/PortableExecutable/MenuItemExtended.cs @@ -1,37 +1,44 @@ -namespace SabreTools.Models.PortableExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.PortableExecutable { /// /// Defines a menu item in an extended menu template. This structure definition is for /// explanation only; it is not present in any standard header file. /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class MenuItemExtended { /// /// Describes the menu item. /// - public MenuFlags ItemType { get; set; } + [MarshalAs(UnmanagedType.U4)] + public MenuFlags ItemType; /// /// Describes the menu item. /// - public MenuFlags State { get; set; } + [MarshalAs(UnmanagedType.U4)] + public MenuFlags State; /// /// A numeric expression that identifies the menu item that is passed in the /// WM_COMMAND message. /// - public uint ID { get; set; } + public uint ID; /// /// A set of bit flags that specify the type of menu item. /// - public MenuFlags Flags { get; set; } + [MarshalAs(UnmanagedType.U4)] + public MenuFlags Flags; /// /// A null-terminated Unicode string that contains the text for this menu item. /// There is no fixed limit on the size of this string. /// - public string? MenuText { get; set; } + [MarshalAs(UnmanagedType.LPWStr)] + public string? MenuText; } } diff --git a/PortableExecutable/NB10ProgramDatabase.cs b/PortableExecutable/NB10ProgramDatabase.cs index 591ad33..70ac2ea 100644 --- a/PortableExecutable/NB10ProgramDatabase.cs +++ b/PortableExecutable/NB10ProgramDatabase.cs @@ -1,39 +1,43 @@ -namespace SabreTools.Models.PortableExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.PortableExecutable { /// /// PDB 2.0 files /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class NB10ProgramDatabase { /// /// "CodeView signature, equal to “NB10” /// - public uint Signature { get; set; } + public uint Signature; /// /// CodeView offset. Set to 0, because debug information /// is stored in a separate file. /// - public uint Offset { get; set; } + public uint Offset; /// /// The time when debug information was created (in seconds /// since 01.01.1970) /// - public uint Timestamp { get; set; } + public uint Timestamp; /// /// Ever-incrementing value, which is initially set to 1 and /// incremented every time when a part of the PDB file is updated /// without rewriting the whole file. /// - public uint Age { get; set; } + public uint Age; /// /// Null-terminated name of the PDB file. It can also contain full /// or partial path to the file. /// - public string? PdbFileName { get; set; } + [MarshalAs(UnmanagedType.LPStr)] + public string? PdbFileName; } }