diff --git a/PortableExecutable/BaseRelocationTypeOffsetFieldEntry.cs b/PortableExecutable/BaseRelocationTypeOffsetFieldEntry.cs
index 95a940f..eef727e 100644
--- a/PortableExecutable/BaseRelocationTypeOffsetFieldEntry.cs
+++ b/PortableExecutable/BaseRelocationTypeOffsetFieldEntry.cs
@@ -1,12 +1,9 @@
-using System.Runtime.InteropServices;
-
-namespace SabreTools.Models.PortableExecutable
+namespace SabreTools.Models.PortableExecutable
{
///
/// Type or Offset field entry is a WORD (2 bytes).
///
///
- [StructLayout(LayoutKind.Sequential)]
public sealed class BaseRelocationTypeOffsetFieldEntry
{
///
diff --git a/PortableExecutable/HintNameTableEntry.cs b/PortableExecutable/HintNameTableEntry.cs
index 2ced00c..250afd7 100644
--- a/PortableExecutable/HintNameTableEntry.cs
+++ b/PortableExecutable/HintNameTableEntry.cs
@@ -1,9 +1,12 @@
-namespace SabreTools.Models.PortableExecutable
+using System.Runtime.InteropServices;
+
+namespace SabreTools.Models.PortableExecutable
{
///
/// One hint/name table suffices for the entire import section.
///
///
+ [StructLayout(LayoutKind.Sequential)]
public sealed class HintNameTableEntry
{
///
@@ -11,13 +14,14 @@
/// with this value. If it fails, a binary search is performed on the DLL's
/// export name pointer table.
///
- public ushort Hint { get; set; }
+ public ushort Hint;
///
/// An ASCII string that contains the name to import. This is the string that
/// must be matched to the public name in the DLL. This string is case sensitive
/// and terminated by a null byte.
///
- public string? Name { get; set; }
+ [MarshalAs(UnmanagedType.LPStr)]
+ public string? Name;
}
}
diff --git a/PortableExecutable/MenuItem.cs b/PortableExecutable/MenuItem.cs
index 8920688..847d5a5 100644
--- a/PortableExecutable/MenuItem.cs
+++ b/PortableExecutable/MenuItem.cs
@@ -1,62 +1,9 @@
namespace SabreTools.Models.PortableExecutable
{
///
- /// Contains information about each item in a menu resource that does not open a menu
- /// or a submenu. The structure definition provided here is for explanation only; it
- /// is not present in any standard header file.
- ///
- /// Contains information about the menu items in a menu resource that open a menu
- /// or a submenu. The structure definition provided here is for explanation only;
- /// it is not present in any standard header file.
+ /// Common base class for menu item types
///
///
///
- public sealed class MenuItem
- {
- #region NORMALMENUITEM
-
- ///
- /// The type of menu item.
- ///
- public MenuFlags NormalResInfo { get; set; }
-
- ///
- /// 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? NormalMenuText { get; set; }
-
- #endregion
-
- #region POPUPMENUITEM
-
- ///
- /// Describes the menu item.
- ///
- public MenuFlags PopupItemType { get; set; }
-
- ///
- /// Describes the menu item.
- ///
- public MenuFlags PopupState { get; set; }
-
- ///
- /// A numeric expression that identifies the menu item that is passed in the
- /// WM_COMMAND message.
- ///
- public uint PopupID { get; set; }
-
- ///
- /// A set of bit flags that specify the type of menu item.
- ///
- public MenuFlags PopupResInfo { get; set; }
-
- ///
- /// 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? PopupMenuText { get; set; }
-
- #endregion
- }
+ public abstract class MenuItem { }
}
diff --git a/PortableExecutable/NB10ProgramDatabase.cs b/PortableExecutable/NB10ProgramDatabase.cs
index 70ac2ea..2d1cdf5 100644
--- a/PortableExecutable/NB10ProgramDatabase.cs
+++ b/PortableExecutable/NB10ProgramDatabase.cs
@@ -35,8 +35,9 @@ namespace SabreTools.Models.PortableExecutable
///
/// Null-terminated name of the PDB file. It can also contain full
- /// or partial path to the file.
+ /// or partial path to the file.
///
+ /// Is this Unicode?
[MarshalAs(UnmanagedType.LPStr)]
public string? PdbFileName;
}
diff --git a/PortableExecutable/NormalMenuItem.cs b/PortableExecutable/NormalMenuItem.cs
new file mode 100644
index 0000000..8176c0e
--- /dev/null
+++ b/PortableExecutable/NormalMenuItem.cs
@@ -0,0 +1,27 @@
+using System.Runtime.InteropServices;
+
+namespace SabreTools.Models.PortableExecutable
+{
+ ///
+ /// Contains information about each item in a menu resource that does not open a menu
+ /// or a submenu. The structure definition provided here is for explanation only; it
+ /// is not present in any standard header file.
+ ///
+ ///
+ [StructLayout(LayoutKind.Sequential)]
+ public sealed class NormalMenuItem : MenuItem
+ {
+ ///
+ /// The type of menu item.
+ ///
+ [MarshalAs(UnmanagedType.U2)]
+ public MenuFlags NormalResInfo;
+
+ ///
+ /// A null-terminated Unicode string that contains the text for this menu item.
+ /// There is no fixed limit on the size of this string.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string? NormalMenuText;
+ }
+}
diff --git a/PortableExecutable/PopupMenuItem.cs b/PortableExecutable/PopupMenuItem.cs
new file mode 100644
index 0000000..5b6ab76
--- /dev/null
+++ b/PortableExecutable/PopupMenuItem.cs
@@ -0,0 +1,45 @@
+using System.Runtime.InteropServices;
+
+namespace SabreTools.Models.PortableExecutable
+{
+ ///
+ /// Contains information about the menu items in a menu resource that open a menu
+ /// or a submenu. The structure definition provided here is for explanation only;
+ /// it is not present in any standard header file.
+ ///
+ ///
+ [StructLayout(LayoutKind.Sequential)]
+ public sealed class PopupMenuItem : MenuItem
+ {
+ ///
+ /// Describes the menu item.
+ ///
+ [MarshalAs(UnmanagedType.U4)]
+ public MenuFlags PopupItemType;
+
+ ///
+ /// Describes the menu item.
+ ///
+ [MarshalAs(UnmanagedType.U4)]
+ public MenuFlags PopupState;
+
+ ///
+ /// A numeric expression that identifies the menu item that is passed in the
+ /// WM_COMMAND message.
+ ///
+ public uint PopupID;
+
+ ///
+ /// A set of bit flags that specify the type of menu item.
+ ///
+ [MarshalAs(UnmanagedType.U4)]
+ public MenuFlags PopupResInfo;
+
+ ///
+ /// A null-terminated Unicode string that contains the text for this menu item.
+ /// There is no fixed limit on the size of this string.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string? PopupMenuText;
+ }
+}
diff --git a/PortableExecutable/RSDSProgramDatabase.cs b/PortableExecutable/RSDSProgramDatabase.cs
index 3c6a992..d7ef7d8 100644
--- a/PortableExecutable/RSDSProgramDatabase.cs
+++ b/PortableExecutable/RSDSProgramDatabase.cs
@@ -1,4 +1,5 @@
using System;
+using System.Runtime.InteropServices;
namespace SabreTools.Models.PortableExecutable
{
@@ -7,28 +8,30 @@ namespace SabreTools.Models.PortableExecutable
/// or "DS" type which are emitted by Miscrosoft's link.exe from version 7 and above.
///
///
+ [StructLayout(LayoutKind.Sequential)]
public sealed class RSDSProgramDatabase
{
///
/// "RSDS" signature
///
- public uint Signature { get; set; }
+ public uint Signature;
///
/// 16-byte Globally Unique Identifier
///
- public Guid GUID { get; set; }
+ public Guid GUID;
///
/// 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;
///
/// zero terminated UTF8 path and file name
///
- public string? PathAndFileName { get; set; }
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string? PathAndFileName;
}
}
diff --git a/PortableExecutable/SecuROMAddD.cs b/PortableExecutable/SecuROMAddD.cs
index 6311cf0..844aa6f 100644
--- a/PortableExecutable/SecuROMAddD.cs
+++ b/PortableExecutable/SecuROMAddD.cs
@@ -1,4 +1,6 @@
-namespace SabreTools.Models.PortableExecutable
+using System.Runtime.InteropServices;
+
+namespace SabreTools.Models.PortableExecutable
{
///
/// Overlay data associated with SecuROM executables
@@ -15,7 +17,7 @@
///
public uint Signature { get; set; }
- ///
+ /// s
/// Unknown (Entry count?)
///
///
@@ -27,12 +29,14 @@
///
/// Version, always 8 bytes?
///
- public string? Version { get; set; }
+ [MarshalAs(UnmanagedType.LPStr)]
+ public string? Version;
///
/// Unknown (Build? Formatted as a string)
///
- public char[]? Build { get; set; }
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
+ public char[]? Build;
///
/// Unknown (0x14h), Variable number of bytes before entry table
diff --git a/PortableExecutable/SecuROMAddDEntry.cs b/PortableExecutable/SecuROMAddDEntry.cs
index e6e6f67..63c9828 100644
--- a/PortableExecutable/SecuROMAddDEntry.cs
+++ b/PortableExecutable/SecuROMAddDEntry.cs
@@ -64,7 +64,7 @@ namespace SabreTools.Models.PortableExecutable
/// Entry file name (null-terminated)
///
/// 12 bytes long in the sample (all 3 entries) in 4.47.00.0039
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 12)]
+ [MarshalAs(UnmanagedType.LPStr)]
public string? FileName;
///