diff --git a/AACS/DriveRevocationListEntry.cs b/AACS/DriveRevocationListEntry.cs index 0db9d7e..79b6ecc 100644 --- a/AACS/DriveRevocationListEntry.cs +++ b/AACS/DriveRevocationListEntry.cs @@ -1,6 +1,9 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.AACS { /// + [StructLayout(LayoutKind.Sequential)] public sealed class DriveRevocationListEntry { /// @@ -9,13 +12,14 @@ namespace SabreTools.Models.AACS /// field indicates that only one ID is being revoked, a value of one /// in the Range field indicates two ID’s are being revoked, and so on. /// - public ushort Range { get; set; } + public ushort Range; /// /// A 6-byte Drive ID value identifying the Licensed Drive being revoked /// (or the first in a range of Licensed Drives being revoked, in the /// case of a non-zero Range value). /// - public byte[]? DriveID { get; set; } + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] + public byte[]? DriveID; } } \ No newline at end of file diff --git a/AACS/HostRevocationListEntry.cs b/AACS/HostRevocationListEntry.cs index 0fb1812..eda3ae3 100644 --- a/AACS/HostRevocationListEntry.cs +++ b/AACS/HostRevocationListEntry.cs @@ -1,6 +1,9 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.AACS { /// + [StructLayout(LayoutKind.Sequential)] public sealed class HostRevocationListEntry { /// @@ -9,13 +12,14 @@ namespace SabreTools.Models.AACS /// field indicates that only one ID is being revoked, a value of one /// in the Range field indicates two ID’s are being revoked, and so on. /// - public ushort Range { get; set; } + public ushort Range; /// /// A 6-byte Host ID value identifying the host being revoked (or the /// first in a range of hosts being revoked, in the case of a non-zero /// Range value). /// - public byte[]? HostID { get; set; } + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] + public byte[]? HostID; } } \ No newline at end of file diff --git a/AACS/SubsetDifference.cs b/AACS/SubsetDifference.cs index 32636d8..9ea8ac5 100644 --- a/AACS/SubsetDifference.cs +++ b/AACS/SubsetDifference.cs @@ -1,6 +1,9 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.AACS { /// + [StructLayout(LayoutKind.Sequential)] public sealed class SubsetDifference { /// @@ -9,12 +12,12 @@ namespace SabreTools.Models.AACS /// the mask. For example, the value 0x01 denotes a mask of /// 0xFFFFFFFE; value 0x0A denotes a mask of 0xFFFFFC00. /// - public byte Mask { get; set; } + public byte Mask; /// /// The last 4 bytes are the uv number, most significant /// byte first. /// - public uint Number { get; set; } + public uint Number; } } \ No newline at end of file diff --git a/BFPK/Header.cs b/BFPK/Header.cs index 3c792ff..0874794 100644 --- a/BFPK/Header.cs +++ b/BFPK/Header.cs @@ -1,24 +1,28 @@ -namespace SabreTools.Models.BFPK +using System.Runtime.InteropServices; + +namespace SabreTools.Models.BFPK { /// /// Header /// /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public sealed class Header { /// /// "BFPK" /// - public string? Magic { get; set; } + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)] + public string? Magic; /// /// Version /// - public int Version { get; set; } + public int Version; /// /// Files /// - public int Files { get; set; } + public int Files; } } diff --git a/BMP/BITMAPFILEHEADER.cs b/BMP/BITMAPFILEHEADER.cs index 1a58440..361651b 100644 --- a/BMP/BITMAPFILEHEADER.cs +++ b/BMP/BITMAPFILEHEADER.cs @@ -1,3 +1,5 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.BMP { /// @@ -5,31 +7,32 @@ namespace SabreTools.Models.BMP /// and layout of a file that contains a DIB. /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class BITMAPFILEHEADER { /// /// The file type; must be BM. /// - public ushort Type { get; set; } + public ushort Type; /// /// The size, in bytes, of the bitmap file. /// - public uint Size { get; set; } + public uint Size; /// /// Reserved; must be zero. /// - public ushort Reserved1 { get; set; } + public ushort Reserved1; /// /// Reserved; must be zero. /// - public ushort Reserved2 { get; set; } + public ushort Reserved2; /// /// The offset, in bytes, from the beginning of the BITMAPFILEHEADER structure to the bitmap bits. /// - public uint OffBits { get; set; } + public uint OffBits; } } diff --git a/BMP/BITMAPINFOHEADER.cs b/BMP/BITMAPINFOHEADER.cs index 67f0bf1..4d776f4 100644 --- a/BMP/BITMAPINFOHEADER.cs +++ b/BMP/BITMAPINFOHEADER.cs @@ -1,9 +1,12 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.BMP { /// /// The BITMAPINFOHEADER structure contains information about the dimensions and /// color format of a device-independent bitmap (DIB). /// + [StructLayout(LayoutKind.Sequential)] public sealed class BITMAPINFOHEADER { /// @@ -11,12 +14,12 @@ namespace SabreTools.Models.BMP /// not include the size of the color table or the size of the color masks, /// if they are appended to the end of structure. /// - public uint Size { get; set; } + public uint Size; /// /// Specifies the width of the bitmap, in pixels. /// - public int Width { get; set; } + public int Width; /// /// Specifies the height of the bitmap, in pixels. @@ -30,19 +33,19 @@ namespace SabreTools.Models.BMP /// or negative biHeight. /// - For compressed formats, biHeight must be positive, regardless of image orientation. /// - public int Height { get; set; } + public int Height; /// /// Specifies the number of planes for the target device. This value must be set to 1. /// - public ushort Planes { get; set; } + public ushort Planes; /// /// Specifies the number of bits per pixel (bpp). For uncompressed formats, this value /// is the average number of bits per pixel. For compressed formats, this value is the /// implied bit depth of the uncompressed image, after the image has been decoded. /// - public ushort BitCount { get; set; } + public ushort BitCount; /// /// For compressed video and YUV formats, this member is a FOURCC code, specified as a @@ -59,36 +62,36 @@ namespace SabreTools.Models.BMP /// If biCompression equals BI_BITFIELDS, the format is either RGB 555 or RGB 565. Use /// the subtype GUID in the AM_MEDIA_TYPE structure to determine the specific RGB type. /// - public uint Compression { get; set; } + public uint Compression; /// /// Specifies the size, in bytes, of the image. This can be set to 0 for uncompressed /// RGB bitmaps. /// - public uint SizeImage { get; set; } + public uint SizeImage; /// /// Specifies the horizontal resolution, in pixels per meter, of the target device for /// the bitmap. /// - public int XPelsPerMeter { get; set; } + public int XPelsPerMeter; /// /// Specifies the vertical resolution, in pixels per meter, of the target device for /// the bitmap. /// - public int YPelsPerMeter { get; set; } + public int YPelsPerMeter; /// /// Specifies the number of color indices in the color table that are actually used by /// the bitmap. /// - public uint ClrUsed { get; set; } + public uint ClrUsed; /// /// Specifies the number of color indices that are considered important for displaying /// the bitmap. If this value is zero, all colors are important. /// - public uint ClrImportant { get; set; } + public uint ClrImportant; } } diff --git a/BSP/Header.cs b/BSP/Header.cs index a88ee91..ddab40b 100644 --- a/BSP/Header.cs +++ b/BSP/Header.cs @@ -1,11 +1,14 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.BSP { /// + [StructLayout(LayoutKind.Sequential)] public sealed class Header { /// /// Version /// - public uint Version { get; set; } + public uint Version; } } \ No newline at end of file diff --git a/BSP/Lump.cs b/BSP/Lump.cs index bcdf627..253e253 100644 --- a/BSP/Lump.cs +++ b/BSP/Lump.cs @@ -1,16 +1,19 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.BSP { /// + [StructLayout(LayoutKind.Sequential)] public sealed class Lump { /// /// Offset /// - public uint Offset { get; set; } + public uint Offset; /// /// Length /// - public uint Length { get; set; } + public uint Length; } } \ No newline at end of file diff --git a/Compression/LZ/FileHeader.cs b/Compression/LZ/FileHeader.cs index 3637b56..045ddcf 100644 --- a/Compression/LZ/FileHeader.cs +++ b/Compression/LZ/FileHeader.cs @@ -1,17 +1,22 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.Compression.LZ { /// /// Format of first 14 byte of LZ compressed file /// /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public sealed class FileHeaader { - public string? Magic { get; set; } + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 8)] + public string? Magic; - public byte CompressionType { get; set; } + public byte CompressionType; - public char LastChar { get; set; } + [MarshalAs(UnmanagedType.U1)] + public char LastChar; - public uint RealLength { get; set; } + public uint RealLength; } } \ No newline at end of file diff --git a/DVD/CellAddressTableEntry.cs b/DVD/CellAddressTableEntry.cs index da76e38..834071e 100644 --- a/DVD/CellAddressTableEntry.cs +++ b/DVD/CellAddressTableEntry.cs @@ -1,31 +1,34 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.DVD { /// + [StructLayout(LayoutKind.Sequential)] public sealed class CellAddressTableEntry { /// /// VOBidn /// - public ushort VOBIdentity { get; set; } + public ushort VOBIdentity; /// /// CELLidn /// - public byte CellIdentity { get; set; } + public byte CellIdentity; /// /// Reserved /// - public byte Reserved { get; set; } + public byte Reserved; /// /// Starting sector within VOB /// - public uint StartingSectorWithinVOB { get; set; } + public uint StartingSectorWithinVOB; /// /// Ending sector within VOB /// - public uint EndingSectorWithinVOB { get; set; } + public uint EndingSectorWithinVOB; } } \ No newline at end of file diff --git a/DVD/LanguageUnitTableEntry.cs b/DVD/LanguageUnitTableEntry.cs index dba3ee0..c52aa25 100644 --- a/DVD/LanguageUnitTableEntry.cs +++ b/DVD/LanguageUnitTableEntry.cs @@ -1,26 +1,29 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.DVD { /// + [StructLayout(LayoutKind.Sequential)] public sealed class LanguageUnitTableEntry { /// /// ISO639 language code /// - public ushort ISO639LanguageCode { get; set; } + public ushort ISO639LanguageCode; /// /// Reserved for language code extension /// - public byte Reserved { get; set; } + public byte Reserved; /// /// Menu existence flag [80 = title] /// - public byte MenuExistenceFlag { get; set; } + public byte MenuExistenceFlag; /// /// Offset to VMGM_LU, relative to VMGM_PGCI_UT /// - public uint LanguageUnitOffset { get; set; } + public uint LanguageUnitOffset; } } \ No newline at end of file diff --git a/DVD/ParentalManagementMasksTableEntry.cs b/DVD/ParentalManagementMasksTableEntry.cs index cf94d5d..3fc9927 100644 --- a/DVD/ParentalManagementMasksTableEntry.cs +++ b/DVD/ParentalManagementMasksTableEntry.cs @@ -1,21 +1,24 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.DVD { /// + [StructLayout(LayoutKind.Sequential)] public sealed class ParentalManagementMasksTableEntry { /// /// Country code /// - public ushort CountryCode { get; set; } + public ushort CountryCode; /// /// Reserved /// - public byte[]? Reserved { get; set; } + public ushort Reserved; /// /// Offset to PTL_MAIT /// - public uint Offset { get; set; } + public uint Offset; } } \ No newline at end of file diff --git a/DVD/ProgramChainTable.cs b/DVD/ProgramChainTable.cs index 8277475..4a017e3 100644 --- a/DVD/ProgramChainTable.cs +++ b/DVD/ProgramChainTable.cs @@ -11,7 +11,7 @@ namespace SabreTools.Models.DVD /// /// Reserved /// - public byte[]? Reserved { get; set; } + public ushort Reserved { get; set; } /// /// End address (last byte of last PGC in this LU) diff --git a/DVD/ProgramChainTableEntry.cs b/DVD/ProgramChainTableEntry.cs index 0f0145e..f30a0e3 100644 --- a/DVD/ProgramChainTableEntry.cs +++ b/DVD/ProgramChainTableEntry.cs @@ -1,26 +1,30 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.DVD { /// + [StructLayout(LayoutKind.Sequential)] public sealed class ProgramChainTableEntry { /// /// PGC category /// - public ProgramChainCategory Category { get; set; } + [MarshalAs(UnmanagedType.U1)] + public ProgramChainCategory Category; /// /// Unknown /// - public byte Unknown { get; set; } + public byte Unknown; /// /// Parental management mask /// - public ushort ParentalManagementMask { get; set; } + public ushort ParentalManagementMask; /// /// Offset to VMGM_PGC, relative to VMGM_LU /// - public uint Offset { get; set; } + public uint Offset; } } \ No newline at end of file diff --git a/DVD/TitlesTable.cs b/DVD/TitlesTable.cs index 51820a8..213fbe7 100644 --- a/DVD/TitlesTable.cs +++ b/DVD/TitlesTable.cs @@ -11,7 +11,7 @@ namespace SabreTools.Models.DVD /// /// Reserved /// - public byte[]? Reserved { get; set; } + public ushort Reserved { get; set; } /// /// End address (last byte of last entry) diff --git a/DVD/TitlesTableEntry.cs b/DVD/TitlesTableEntry.cs index 2566838..46480a6 100644 --- a/DVD/TitlesTableEntry.cs +++ b/DVD/TitlesTableEntry.cs @@ -1,42 +1,46 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.DVD { /// + [StructLayout(LayoutKind.Sequential)] public sealed class TitlesTableEntry { /// /// Title type /// - public TitleType TitleType { get; set; } + [MarshalAs(UnmanagedType.U1)] + public TitleType TitleType; /// /// Number of angles /// - public byte NumberOfAngles { get; set; } + public byte NumberOfAngles; /// /// Number of chapters (PTTs) /// - public ushort NumberOfChapters { get; set; } + public ushort NumberOfChapters; /// /// Parental management mask /// - public ushort ParentalManagementMask { get; set; } + public ushort ParentalManagementMask; /// /// Video Title Set number (VTSN) /// - public byte VideoTitleSetNumber { get; set; } + public byte VideoTitleSetNumber; /// /// Title number within VTS (VTS_TTN) /// - public byte TitleNumberWithinVTS { get; set; } + public byte TitleNumberWithinVTS; /// /// Start sector for VTS, referenced to whole disk /// (video_ts.ifo starts at sector 00000000) /// - public uint VTSStartSector { get; set; } + public uint VTSStartSector; } } \ No newline at end of file diff --git a/DVD/VideoManagerIFO.cs b/DVD/VideoManagerIFO.cs index e1096b3..e5e1ae0 100644 --- a/DVD/VideoManagerIFO.cs +++ b/DVD/VideoManagerIFO.cs @@ -1,22 +1,27 @@ +using System.Drawing; +using System.Runtime.InteropServices; + namespace SabreTools.Models.DVD { /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public sealed class VideoManagerIFO { /// /// "DVDVIDEO-VMG" /// - public string? Signature { get; set; } + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 12)] + public string? Signature; /// /// Last sector of VMG set (last sector of BUP) /// - public uint LastVMGSetSector { get; set; } + public uint LastVMGSetSector; /// /// Last sector of IFO /// - public uint LastIFOSector { get; set; } + public uint LastIFOSector; /// /// Version number @@ -24,127 +29,132 @@ namespace SabreTools.Models.DVD /// - Byte 1, Bits 7-4 - Major version number /// - Byte 1, Bits 3-0 - Minor version number /// - public ushort VersionNumber { get; set; } + public ushort VersionNumber; /// /// VMG category /// /// byte1=prohibited region mask - public uint VMGCategory { get; set; } + public uint VMGCategory; /// /// Number of volumes /// - public ushort NumberOfVolumes { get; set; } + public ushort NumberOfVolumes; /// /// Volume number /// - public ushort VolumeNumber { get; set; } + public ushort VolumeNumber; /// /// Side ID /// - public byte SideID { get; set; } + public byte SideID; /// /// Number of title sets /// - public ushort NumberOfTitleSets { get; set; } + public ushort NumberOfTitleSets; /// /// Provider ID /// - public byte[]? ProviderID { get; set; } + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public byte[]? ProviderID; /// /// VMG POS /// - public ulong VMGPOS { get; set; } + public ulong VMGPOS; /// /// End byte address of VMGI_MAT /// - public uint InformationManagementTableEndByteAddress { get; set; } + public uint InformationManagementTableEndByteAddress; /// /// Start address of FP_PGC (First Play program chain) /// - public uint FirstPlayProgramChainStartAddress { get; set; } + public uint FirstPlayProgramChainStartAddress; /// /// Start sector of Menu VOB /// - public uint MenuVOBStartSector { get; set; } + public uint MenuVOBStartSector; /// /// Sector pointer to TT_SRPT (table of titles) /// - public uint TableOfTitlesSectorPointer { get; set; } + public uint TableOfTitlesSectorPointer; /// /// Sector pointer to VMGM_PGCI_UT (Menu Program Chain table) /// - public uint MenuProgramChainTableSectorPointer { get; set; } + public uint MenuProgramChainTableSectorPointer; /// /// Sector pointer to VMG_PTL_MAIT (Parental Management masks) /// - public uint ParentalManagementMasksSectorPointer { get; set; } + public uint ParentalManagementMasksSectorPointer; /// /// Sector pointer to VMG_VTS_ATRT (copies of VTS audio/sub-picture attributes) /// - public uint AudioSubPictureAttributesSectorPointer { get; set; } + public uint AudioSubPictureAttributesSectorPointer; /// /// Sector pointer to VMG_TXTDT_MG (text data) /// - public uint TextDataSectorPointer { get; set; } + public uint TextDataSectorPointer; /// /// Sector pointer to VMGM_C_ADT (menu cell address table) /// - public uint MenuCellAddressTableSectorPointer { get; set; } + public uint MenuCellAddressTableSectorPointer; /// /// Sector pointer to VMGM_VOBU_ADMAP (menu VOBU address map) /// - public uint MenuVOBUAddressMapSectorPointer { get; set; } + public uint MenuVOBUAddressMapSectorPointer; /// /// Video attributes of VMGM_VOBS /// - public byte[]? VideoAttributes { get; set; } + public ushort VideoAttributes; /// /// Number of audio streams in VMGM_VOBS /// - public ushort NumberOfAudioStreams { get; set; } + public ushort NumberOfAudioStreams; /// /// Audio attributes of VMGM_VOBS /// - public byte[][]? AudioAttributes { get; set; } + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public ulong[]? AudioAttributes; /// /// Unknown /// - public byte[]? Unknown { get; set; } + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public byte[]? Unknown; /// /// Number of subpicture streams in VMGM_VOBS (0 or 1) /// - public ushort NumberOfSubpictureStreams { get; set; } + public ushort NumberOfSubpictureStreams; /// /// Subpicture attributes of VMGM_VOBS /// - public byte[]? SubpictureAttributes { get; set; } + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] + public byte[]? SubpictureAttributes; /// /// Reserved /// - public byte[]? Reserved { get; set; } + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 164)] + public byte[]? Reserved; } } \ No newline at end of file diff --git a/DVD/VideoTitleSetIFO.cs b/DVD/VideoTitleSetIFO.cs index ae27508..b1653b4 100644 --- a/DVD/VideoTitleSetIFO.cs +++ b/DVD/VideoTitleSetIFO.cs @@ -1,22 +1,26 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.DVD { /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public sealed class VideoTitleSetIFO { /// /// "DVDVIDEO-VTS" /// - public string? Signature { get; set; } + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 12)] + public string? Signature; /// /// Last sector of title set (last sector of BUP) /// - public uint LastTitleSetSector { get; set; } + public uint LastTitleSetSector; /// /// Last sector of IFO /// - public uint LastIFOSector { get; set; } + public uint LastIFOSector; /// /// Version number @@ -24,137 +28,142 @@ namespace SabreTools.Models.DVD /// - Byte 1, Bits 7-4 - Major version number /// - Byte 1, Bits 3-0 - Minor version number /// - public ushort VersionNumber { get; set; } + public ushort VersionNumber; /// /// VTS category /// /// 0=unspecified, 1=Karaoke - public uint VMGCategory { get; set; } + public uint VMGCategory; /// /// Number of volumes /// - public ushort NumberOfVolumes { get; set; } + public ushort NumberOfVolumes; /// /// Volume number /// - public ushort VolumeNumber { get; set; } + public ushort VolumeNumber; /// /// Side ID /// - public byte SideID { get; set; } + public byte SideID; /// /// Number of title sets /// - public ushort NumberOfTitleSets { get; set; } + public ushort NumberOfTitleSets; /// /// Provider ID /// - public byte[]? ProviderID { get; set; } + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public byte[]? ProviderID; /// /// VMG POS /// - public ulong VMGPOS { get; set; } + public ulong VMGPOS; /// /// End byte address of VTS_MAT /// - public uint InformationManagementTableEndByteAddress { get; set; } + public uint InformationManagementTableEndByteAddress; /// /// Start address of FP_PGC (First Play program chain) /// - public uint FirstPlayProgramChainStartAddress { get; set; } + public uint FirstPlayProgramChainStartAddress; /// /// Start sector of Menu VOB /// - public uint MenuVOBStartSector { get; set; } + public uint MenuVOBStartSector; /// /// Start sector of Title VOB /// - public uint TitleVOBStartSector { get; set; } + public uint TitleVOBStartSector; /// /// Sector pointer to VTS_PTT_SRPT (table of Titles and Chapters) /// - public uint TableOfTitlesAndChaptersSectorPointer { get; set; } + public uint TableOfTitlesAndChaptersSectorPointer; /// /// Sector pointer to VTS_PGCI (Title Program Chain table) /// - public uint TitleProgramChainTableSectorPointer { get; set; } + public uint TitleProgramChainTableSectorPointer; /// /// Sector pointer to VTSM_PGCI_UT (Menu Program Chain table) /// - public uint MenuProgramChainTableSectorPointer { get; set; } + public uint MenuProgramChainTableSectorPointer; /// /// Sector pointer to VTS_TMAPTI (time map) /// - public uint TimeMapSectorPointer { get; set; } + public uint TimeMapSectorPointer; /// /// Sector pointer to VTSM_C_ADT (menu cell address table) /// - public uint MenuCellAddressTableSectorPointer { get; set; } + public uint MenuCellAddressTableSectorPointer; /// /// Sector pointer to VTSM_VOBU_ADMAP (menu VOBU address map) /// - public uint MenuVOBUAddressMapSectorPointer { get; set; } + public uint MenuVOBUAddressMapSectorPointer; /// /// Sector pointer to VTS_C_ADT (title set cell address table) /// - public uint TitleSetCellAddressTableSectorPointer { get; set; } + public uint TitleSetCellAddressTableSectorPointer; /// /// Sector pointer to VTS_VOBU_ADMAP (title set VOBU address map) /// - public uint TitleSetVOBUAddressMapSectorPointer { get; set; } + public uint TitleSetVOBUAddressMapSectorPointer; /// /// Video attributes of VTSM_VOBS /// - public byte[]? VideoAttributes { get; set; } + public ushort VideoAttributes; /// /// Number of audio streams in VTSM_VOBS /// - public ushort NumberOfAudioStreams { get; set; } + public ushort NumberOfAudioStreams; /// /// Audio attributes of VTSM_VOBS /// - public byte[][]? AudioAttributes { get; set; } + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public ulong[]? AudioAttributes; /// /// Unknown /// - public byte[]? Unknown { get; set; } + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public byte[]? Unknown; /// /// Number of subpicture streams in VTSM_VOBS (0 or 1) /// - public ushort NumberOfSubpictureStreams { get; set; } + public ushort NumberOfSubpictureStreams; /// /// Subpicture attributes of VTSM_VOBS /// - public byte[]? SubpictureAttributes { get; set; } + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] + public byte[]? SubpictureAttributes; /// /// Reserved /// - public byte[]? Reserved { get; set; } + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 164)] + public byte[]? Reserved; } } \ No newline at end of file diff --git a/Delphi/PackageUnitEntry.cs b/Delphi/PackageUnitEntry.cs index 76e6f4f..62f76bd 100644 --- a/Delphi/PackageUnitEntry.cs +++ b/Delphi/PackageUnitEntry.cs @@ -1,18 +1,21 @@ +using System.Runtime.InteropServices; + /// /// Information sourced from https://docwiki.embarcadero.com/Libraries/Alexandria/en/System.PackageUnitEntry /// namespace SabreTools.Models.Delphi { + [StructLayout(LayoutKind.Sequential)] public class PackageUnitEntry { /// /// System-dependent pointer type, assumed to be encoded for x86 /// - public uint Init { get; set; } + public uint Init; /// /// System-dependent pointer type, assumed to be encoded for x86 /// - public uint FInit { get; set; } + public uint FInit; } } \ No newline at end of file diff --git a/GCF/BlockEntry.cs b/GCF/BlockEntry.cs index f029237..2e026dd 100644 --- a/GCF/BlockEntry.cs +++ b/GCF/BlockEntry.cs @@ -1,41 +1,44 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.GCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class BlockEntry { /// /// Flags for the block entry. 0x200F0000 == Not used. /// - public uint EntryFlags { get; set; } + public uint EntryFlags; /// /// The offset for the data contained in this block entry in the file. /// - public uint FileDataOffset { get; set; } + public uint FileDataOffset; /// /// The length of the data in this block entry. /// - public uint FileDataSize { get; set; } + public uint FileDataSize; /// /// The offset to the first data block of this block entry's data. /// - public uint FirstDataBlockIndex { get; set; } + public uint FirstDataBlockIndex; /// /// The next block entry in the series. (N/A if == BlockCount.) /// - public uint NextBlockEntryIndex { get; set; } + public uint NextBlockEntryIndex; /// /// The previous block entry in the series. (N/A if == BlockCount.) /// - public uint PreviousBlockEntryIndex { get; set; } + public uint PreviousBlockEntryIndex; /// /// The offset of the block entry in the directory. /// - public uint DirectoryIndex { get; set; } + public uint DirectoryIndex; } } \ No newline at end of file diff --git a/GCF/BlockEntryHeader.cs b/GCF/BlockEntryHeader.cs index 136da4c..1aeb3b5 100644 --- a/GCF/BlockEntryHeader.cs +++ b/GCF/BlockEntryHeader.cs @@ -1,46 +1,49 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.GCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class BlockEntryHeader { /// /// Number of data blocks. /// - public uint BlockCount { get; set; } + public uint BlockCount; /// /// Number of data blocks that point to data. /// - public uint BlocksUsed { get; set; } + public uint BlocksUsed; /// /// Reserved /// - public uint Dummy0 { get; set; } + public uint Dummy0; /// /// Reserved /// - public uint Dummy1 { get; set; } + public uint Dummy1; /// /// Reserved /// - public uint Dummy2 { get; set; } + public uint Dummy2; /// /// Reserved /// - public uint Dummy3 { get; set; } + public uint Dummy3; /// /// Reserved /// - public uint Dummy4 { get; set; } + public uint Dummy4; /// /// Header checksum. /// - public uint Checksum { get; set; } + public uint Checksum; } } \ No newline at end of file diff --git a/GCF/BlockEntryMap.cs b/GCF/BlockEntryMap.cs index edeaea0..7ef1b60 100644 --- a/GCF/BlockEntryMap.cs +++ b/GCF/BlockEntryMap.cs @@ -1,19 +1,22 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.GCF { /// /// Part of version 5 but not version 6. /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class BlockEntryMap { /// /// The previous block entry. (N/A if == BlockCount.) /// - public uint PreviousBlockEntryIndex { get; set; } + public uint PreviousBlockEntryIndex; /// /// The next block entry. (N/A if == BlockCount.) /// - public uint NextBlockEntryIndex { get; set; } + public uint NextBlockEntryIndex; } } \ No newline at end of file diff --git a/GCF/BlockEntryMapHeader.cs b/GCF/BlockEntryMapHeader.cs index 6397c47..d11de02 100644 --- a/GCF/BlockEntryMapHeader.cs +++ b/GCF/BlockEntryMapHeader.cs @@ -1,34 +1,37 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.GCF { /// /// Part of version 5 but not version 6. /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class BlockEntryMapHeader { /// /// Number of data blocks. /// - public uint BlockCount { get; set; } + public uint BlockCount; /// /// Index of the first block entry. /// - public uint FirstBlockEntryIndex { get; set; } + public uint FirstBlockEntryIndex; /// /// Index of the last block entry. /// - public uint LastBlockEntryIndex { get; set; } + public uint LastBlockEntryIndex; /// /// Reserved /// - public uint Dummy0 { get; set; } + public uint Dummy0; /// /// Header checksum. /// - public uint Checksum { get; set; } + public uint Checksum; } } \ No newline at end of file diff --git a/GCF/ChecksumEntry.cs b/GCF/ChecksumEntry.cs index 567c86f..ff61526 100644 --- a/GCF/ChecksumEntry.cs +++ b/GCF/ChecksumEntry.cs @@ -1,11 +1,14 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.GCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class ChecksumEntry { /// /// Checksum. /// - public uint Checksum { get; set; } + public uint Checksum; } } \ No newline at end of file diff --git a/GCF/ChecksumHeader.cs b/GCF/ChecksumHeader.cs index f30d664..e39c421 100644 --- a/GCF/ChecksumHeader.cs +++ b/GCF/ChecksumHeader.cs @@ -1,16 +1,19 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.GCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class ChecksumHeader { /// /// Always 0x00000001 /// - public uint Dummy0 { get; set; } + public uint Dummy0; /// /// Size of LPGCFCHECKSUMHEADER & LPGCFCHECKSUMMAPHEADER & in bytes. /// - public uint ChecksumSize { get; set; } + public uint ChecksumSize; } } \ No newline at end of file diff --git a/GCF/ChecksumMapEntry.cs b/GCF/ChecksumMapEntry.cs index 72a6049..543a8f7 100644 --- a/GCF/ChecksumMapEntry.cs +++ b/GCF/ChecksumMapEntry.cs @@ -1,16 +1,19 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.GCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class ChecksumMapEntry { /// /// Number of checksums. /// - public uint ChecksumCount { get; set; } + public uint ChecksumCount; /// /// Index of first checksum. /// - public uint FirstChecksumIndex { get; set; } + public uint FirstChecksumIndex; } } \ No newline at end of file diff --git a/GCF/ChecksumMapHeader.cs b/GCF/ChecksumMapHeader.cs index 355ace8..863d4c4 100644 --- a/GCF/ChecksumMapHeader.cs +++ b/GCF/ChecksumMapHeader.cs @@ -1,26 +1,29 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.GCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class ChecksumMapHeader { /// /// Always 0x14893721 /// - public uint Dummy0 { get; set; } + public uint Dummy0; /// /// Always 0x00000001 /// - public uint Dummy1 { get; set; } + public uint Dummy1; /// /// Number of items. /// - public uint ItemCount { get; set; } + public uint ItemCount; /// /// Number of checksums. /// - public uint ChecksumCount { get; set; } + public uint ChecksumCount; } } \ No newline at end of file diff --git a/GCF/DataBlockHeader.cs b/GCF/DataBlockHeader.cs index 8014b5f..bacf288 100644 --- a/GCF/DataBlockHeader.cs +++ b/GCF/DataBlockHeader.cs @@ -1,36 +1,39 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.GCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class DataBlockHeader { /// /// GCF file version. This field is not part of all file versions. /// - public uint LastVersionPlayed { get; set; } + public uint LastVersionPlayed; /// /// Number of data blocks. /// - public uint BlockCount { get; set; } + public uint BlockCount; /// /// Size of each data block in bytes. /// - public uint BlockSize { get; set; } + public uint BlockSize; /// /// Offset to first data block. /// - public uint FirstBlockOffset { get; set; } + public uint FirstBlockOffset; /// /// Number of data blocks that contain data. /// - public uint BlocksUsed { get; set; } + public uint BlocksUsed; /// /// Header checksum. /// - public uint Checksum { get; set; } + public uint Checksum; } } \ No newline at end of file diff --git a/GCF/DirectoryCopyEntry.cs b/GCF/DirectoryCopyEntry.cs index b85349e..2d57801 100644 --- a/GCF/DirectoryCopyEntry.cs +++ b/GCF/DirectoryCopyEntry.cs @@ -1,11 +1,14 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.GCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class DirectoryCopyEntry { /// /// Index of the directory item. /// - public uint DirectoryIndex { get; set; } + public uint DirectoryIndex; } } \ No newline at end of file diff --git a/GCF/DirectoryHeader.cs b/GCF/DirectoryHeader.cs index 26b9db8..038254d 100644 --- a/GCF/DirectoryHeader.cs +++ b/GCF/DirectoryHeader.cs @@ -1,76 +1,79 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.GCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class DirectoryHeader { /// /// Always 0x00000004 /// - public uint Dummy0 { get; set; } + public uint Dummy0; /// /// Cache ID. /// - public uint CacheID { get; set; } + public uint CacheID; /// /// GCF file version. /// - public uint LastVersionPlayed { get; set; } + public uint LastVersionPlayed; /// /// Number of items in the directory. /// - public uint ItemCount { get; set; } + public uint ItemCount; /// /// Number of files in the directory. /// - public uint FileCount { get; set; } + public uint FileCount; /// /// Always 0x00008000. Data per checksum? /// - public uint Dummy1 { get; set; } + public uint Dummy1; /// /// Size of lpGCFDirectoryEntries & lpGCFDirectoryNames & lpGCFDirectoryInfo1Entries & lpGCFDirectoryInfo2Entries & lpGCFDirectoryCopyEntries & lpGCFDirectoryLocalEntries in bytes. /// - public uint DirectorySize { get; set; } + public uint DirectorySize; /// /// Size of the directory names in bytes. /// - public uint NameSize { get; set; } + public uint NameSize; /// /// Number of Info1 entires. /// - public uint Info1Count { get; set; } + public uint Info1Count; /// /// Number of files to copy. /// - public uint CopyCount { get; set; } + public uint CopyCount; /// /// Number of files to keep local. /// - public uint LocalCount { get; set; } + public uint LocalCount; /// /// Reserved /// - public uint Dummy2 { get; set; } + public uint Dummy2; /// /// Reserved /// - public uint Dummy3 { get; set; } + public uint Dummy3; /// /// Header checksum. /// - public uint Checksum { get; set; } + public uint Checksum; } } \ No newline at end of file diff --git a/GCF/DirectoryInfo1Entry.cs b/GCF/DirectoryInfo1Entry.cs index cd71778..b5af4c4 100644 --- a/GCF/DirectoryInfo1Entry.cs +++ b/GCF/DirectoryInfo1Entry.cs @@ -1,11 +1,14 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.GCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class DirectoryInfo1Entry { /// /// Reserved /// - public uint Dummy0 { get; set; } + public uint Dummy0; } } \ No newline at end of file diff --git a/GCF/DirectoryInfo2Entry.cs b/GCF/DirectoryInfo2Entry.cs index 1e5a1f6..f255fe1 100644 --- a/GCF/DirectoryInfo2Entry.cs +++ b/GCF/DirectoryInfo2Entry.cs @@ -1,11 +1,14 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.GCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class DirectoryInfo2Entry { /// /// Reserved /// - public uint Dummy0 { get; set; } + public uint Dummy0; } } \ No newline at end of file diff --git a/GCF/DirectoryLocalEntry.cs b/GCF/DirectoryLocalEntry.cs index 6defe47..b6ba093 100644 --- a/GCF/DirectoryLocalEntry.cs +++ b/GCF/DirectoryLocalEntry.cs @@ -1,11 +1,14 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.GCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class DirectoryLocalEntry { /// /// Index of the directory item. /// - public uint DirectoryIndex { get; set; } + public uint DirectoryIndex; } } \ No newline at end of file diff --git a/GCF/DirectoryMapEntry.cs b/GCF/DirectoryMapEntry.cs index 609c607..0517da1 100644 --- a/GCF/DirectoryMapEntry.cs +++ b/GCF/DirectoryMapEntry.cs @@ -1,11 +1,14 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.GCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class DirectoryMapEntry { /// /// Index of the first data block. (N/A if == BlockCount.) /// - public uint FirstBlockIndex { get; set; } + public uint FirstBlockIndex; } } \ No newline at end of file diff --git a/GCF/DirectoryMapHeader.cs b/GCF/DirectoryMapHeader.cs index a3a0173..e3f39e2 100644 --- a/GCF/DirectoryMapHeader.cs +++ b/GCF/DirectoryMapHeader.cs @@ -1,19 +1,22 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.GCF { /// /// Added in version 4 or version 5. /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class DirectoryMapHeader { /// /// Always 0x00000001 /// - public uint Dummy0 { get; set; } + public uint Dummy0; /// /// Always 0x00000000 /// - public uint Dummy1 { get; set; } + public uint Dummy1; } } \ No newline at end of file diff --git a/GCF/FragmentationMap.cs b/GCF/FragmentationMap.cs index e761b41..661358e 100644 --- a/GCF/FragmentationMap.cs +++ b/GCF/FragmentationMap.cs @@ -1,11 +1,14 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.GCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class FragmentationMap { /// /// The index of the next data block. /// - public uint NextDataBlockIndex { get; set; } + public uint NextDataBlockIndex; } } \ No newline at end of file diff --git a/GCF/FragmentationMapHeader.cs b/GCF/FragmentationMapHeader.cs index c639a0a..822ddd9 100644 --- a/GCF/FragmentationMapHeader.cs +++ b/GCF/FragmentationMapHeader.cs @@ -1,26 +1,29 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.GCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class FragmentationMapHeader { /// /// Number of data blocks. /// - public uint BlockCount { get; set; } + public uint BlockCount; /// /// The index of the first unused fragmentation map entry. /// - public uint FirstUnusedEntry { get; set; } + public uint FirstUnusedEntry; /// /// The block entry terminator; 0 = 0x0000ffff or 1 = 0xffffffff. /// - public uint Terminator { get; set; } + public uint Terminator; /// /// Header checksum. /// - public uint Checksum { get; set; } + public uint Checksum; } } \ No newline at end of file diff --git a/GCF/Header.cs b/GCF/Header.cs index 553f9f9..5c402e0 100644 --- a/GCF/Header.cs +++ b/GCF/Header.cs @@ -1,61 +1,64 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.GCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class Header { /// /// Always 0x00000001 /// - public uint Dummy0 { get; set; } + public uint Dummy0; /// /// Always 0x00000001 /// - public uint MajorVersion { get; set; } + public uint MajorVersion; /// /// GCF version number. /// - public uint MinorVersion { get; set; } + public uint MinorVersion; /// /// Cache ID /// - public uint CacheID { get; set; } + public uint CacheID; /// /// Last version played /// - public uint LastVersionPlayed { get; set; } + public uint LastVersionPlayed; /// /// Reserved /// - public uint Dummy1 { get; set; } + public uint Dummy1; /// /// Reserved /// - public uint Dummy2 { get; set; } + public uint Dummy2; /// /// Total size of GCF file in bytes. /// - public uint FileSize { get; set; } + public uint FileSize; /// /// Size of each data block in bytes. /// - public uint BlockSize { get; set; } + public uint BlockSize; /// /// Number of data blocks. /// - public uint BlockCount { get; set; } + public uint BlockCount; /// /// Reserved /// - public uint Dummy3 { get; set; } + public uint Dummy3; } } \ No newline at end of file diff --git a/InstallShieldArchiveV3/Directory.cs b/InstallShieldArchiveV3/Directory.cs index fbf4306..1fb7ae0 100644 --- a/InstallShieldArchiveV3/Directory.cs +++ b/InstallShieldArchiveV3/Directory.cs @@ -1,10 +1,14 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.InstallShieldArchiveV3 { /// + [StructLayout(LayoutKind.Sequential)] public class Directory { - public string? Name { get; set; } + [MarshalAs(UnmanagedType.BStr)] + public string? Name; - public ushort FileCount { get; set; } + public ushort FileCount; } } \ No newline at end of file diff --git a/InstallShieldArchiveV3/File.cs b/InstallShieldArchiveV3/File.cs index 1c024d2..5b2779e 100644 --- a/InstallShieldArchiveV3/File.cs +++ b/InstallShieldArchiveV3/File.cs @@ -1,32 +1,37 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.InstallShieldArchiveV3 { /// + [StructLayout(LayoutKind.Sequential)] public class File { - public byte VolumeEnd { get; set; } + public byte VolumeEnd; - public ushort Index { get; set; } + public ushort Index; - public uint UncompressedSize { get; set; } + public uint UncompressedSize; - public uint CompressedSize { get; set; } + public uint CompressedSize; - public uint Offset { get; set; } + public uint Offset; - public uint DateTime { get; set; } + public uint DateTime; - public uint Reserved0 { get; set; } + public uint Reserved0; - public ushort ChunkSize { get; set; } + public ushort ChunkSize; - public Attributes Attrib { get; set; } + [MarshalAs(UnmanagedType.U1)] + public Attributes Attrib; - public byte IsSplit { get; set; } + public byte IsSplit; - public byte Reserved1 { get; set; } + public byte Reserved1; - public byte VolumeStart { get; set; } + public byte VolumeStart; - public string? Name { get; set; } + [MarshalAs(UnmanagedType.AnsiBStr)] + public string? Name; } } \ No newline at end of file diff --git a/InstallShieldArchiveV3/Header.cs b/InstallShieldArchiveV3/Header.cs index f6c4157..e5f9730 100644 --- a/InstallShieldArchiveV3/Header.cs +++ b/InstallShieldArchiveV3/Header.cs @@ -1,50 +1,53 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.InstallShieldArchiveV3 { /// + [StructLayout(LayoutKind.Sequential)] public class Header { - public uint Signature1 { get; set; } + public uint Signature1; - public uint Signature2 { get; set; } + public uint Signature2; - public ushort Reserved0 { get; set; } + public ushort Reserved0; - public ushort IsMultivolume { get; set; } + public ushort IsMultivolume; - public ushort FileCount { get; set; } + public ushort FileCount; - public uint DateTime { get; set; } + public uint DateTime; - public uint CompressedSize { get; set; } + public uint CompressedSize; - public uint UncompressedSize { get; set; } + public uint UncompressedSize; - public uint Reserved1 { get; set; } + public uint Reserved1; /// /// Set in first vol only, zero in subsequent vols /// - public byte VolumeTotal { get; set; } + public byte VolumeTotal; /// /// [1...n] /// - public byte VolumeNumber { get; set; } + public byte VolumeNumber; - public byte Reserved2 { get; set; } + public byte Reserved2; - public uint SplitBeginAddress { get; set; } + public uint SplitBeginAddress; - public uint SplitEndAddress { get; set; } + public uint SplitEndAddress; - public uint TocAddress { get; set; } + public uint TocAddress; - public uint Reserved3 { get; set; } + public uint Reserved3; - public ushort DirCount { get; set; } + public ushort DirCount; - public uint Reserved4 { get; set; } + public uint Reserved4; - public uint Reserved5 { get; set; } + public uint Reserved5; } } \ No newline at end of file diff --git a/InstallShieldCabinet/CommonHeader.cs b/InstallShieldCabinet/CommonHeader.cs index 58a494e..12835f8 100644 --- a/InstallShieldCabinet/CommonHeader.cs +++ b/InstallShieldCabinet/CommonHeader.cs @@ -1,31 +1,35 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.InstallShieldCabinet { /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public sealed class CommonHeader { /// /// "ISc(" /// - public string? Signature { get; set; } + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)] + public string? Signature; /// /// Encoded version /// - public uint Version { get; set; } + public uint Version; /// /// Volume information /// - public uint VolumeInfo { get; set; } + public uint VolumeInfo; /// /// Offset to cabinet descriptor /// - public uint DescriptorOffset { get; set; } + public uint DescriptorOffset; /// /// Cabinet descriptor size /// - public uint DescriptorSize { get; set; } + public uint DescriptorSize; } } \ No newline at end of file diff --git a/InstallShieldCabinet/Component.cs b/InstallShieldCabinet/Component.cs index a93116a..d0e2ca2 100644 --- a/InstallShieldCabinet/Component.cs +++ b/InstallShieldCabinet/Component.cs @@ -33,7 +33,7 @@ namespace SabreTools.Models.InstallShieldCabinet /// /// Reserved /// - public byte[]? Reserved0 { get; set; } + public ushort Reserved0 { get; set; } /// /// Reserved offset @@ -78,6 +78,7 @@ namespace SabreTools.Models.InstallShieldCabinet /// /// Reserved /// + /// 32 bytes public byte[]? Reserved1 { get; set; } /// @@ -93,11 +94,13 @@ namespace SabreTools.Models.InstallShieldCabinet /// /// Reserved /// + /// 28 bytes public byte[]? Reserved2 { get; set; } /// /// Reserved /// + /// 2 bytes (<= v5), 1 byte (> v5) public byte[]? Reserved3 { get; set; } /// diff --git a/InstallShieldCabinet/Descriptor.cs b/InstallShieldCabinet/Descriptor.cs index ef4d51f..88229dd 100644 --- a/InstallShieldCabinet/Descriptor.cs +++ b/InstallShieldCabinet/Descriptor.cs @@ -1,3 +1,5 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.InstallShieldCabinet { /// @@ -6,116 +8,118 @@ namespace SabreTools.Models.InstallShieldCabinet /// /// Offset to the descriptor strings /// - public uint StringsOffset { get; set; } + public uint StringsOffset; /// /// Reserved /// - public byte[]? Reserved0 { get; set; } + public uint Reserved0; /// /// Offset to the component list /// - public uint ComponentListOffset { get; set; } + public uint ComponentListOffset; /// /// Offset to the file table /// - public uint FileTableOffset { get; set; } + public uint FileTableOffset; /// /// Reserved /// - public byte[]? Reserved1 { get; set; } + public uint Reserved1; /// /// Size of the file table /// - public uint FileTableSize { get; set; } + public uint FileTableSize; /// /// Redundant size of the file table /// - public uint FileTableSize2 { get; set; } + public uint FileTableSize2; /// /// Number of directories /// - public ushort DirectoryCount { get; set; } + public ushort DirectoryCount; /// /// Reserved /// - public byte[]? Reserved2 { get; set; } + public uint Reserved2; /// /// Reserved /// - public byte[]? Reserved3 { get; set; } + public ushort Reserved3; /// /// Reserved /// - public byte[]? Reserved4 { get; set; } + public uint Reserved4; /// /// Number of files /// - public uint FileCount { get; set; } + public uint FileCount; /// /// Redundant offset to the file table /// - public uint FileTableOffset2 { get; set; } + public uint FileTableOffset2; /// /// Number of component table infos /// - public ushort ComponentTableInfoCount { get; set; } + public ushort ComponentTableInfoCount; /// /// Offset to the component table /// - public uint ComponentTableOffset { get; set; } + public uint ComponentTableOffset; /// /// Reserved /// - public byte[]? Reserved5 { get; set; } + public uint Reserved5; /// /// Reserved /// - public byte[]? Reserved6 { get; set; } + public uint Reserved6; /// /// Offsets to the file groups /// - public uint[]? FileGroupOffsets { get; set; } + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 71)] + public uint[]? FileGroupOffsets; /// /// Offsets to the components /// - public uint[]? ComponentOffsets { get; set; } + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 71)] + public uint[]? ComponentOffsets; /// /// Offset to the setup types /// - public uint SetupTypesOffset { get; set; } + public uint SetupTypesOffset; /// /// Offset to the setup table /// - public uint SetupTableOffset { get; set; } + public uint SetupTableOffset; /// /// Reserved /// - public byte[]? Reserved7 { get; set; } + public uint Reserved7; /// /// Reserved /// - public byte[]? Reserved8 { get; set; } + public uint Reserved8; } } \ No newline at end of file diff --git a/LinearExecutable/FixupPageTableEntry.cs b/LinearExecutable/FixupPageTableEntry.cs index e386d1c..b224fee 100644 --- a/LinearExecutable/FixupPageTableEntry.cs +++ b/LinearExecutable/FixupPageTableEntry.cs @@ -1,4 +1,6 @@ -namespace SabreTools.Models.LinearExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.LinearExecutable { /// /// The Fixup Page Table provides a simple mapping of a logical page number @@ -15,6 +17,7 @@ /// /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class FixupPageTableEntry { /// @@ -28,6 +31,6 @@ /// This field specifies the offset following the last fixup record in the /// fixup record table. This is the last entry in the fixup page table. (n + 1) /// - public uint Offset { get; set; } + public uint Offset; } } diff --git a/LinearExecutable/InformationBlock.cs b/LinearExecutable/InformationBlock.cs index b294ff8..bb53b38 100644 --- a/LinearExecutable/InformationBlock.cs +++ b/LinearExecutable/InformationBlock.cs @@ -1,4 +1,6 @@ -namespace SabreTools.Models.LinearExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.LinearExecutable { /// /// The `information block` in the LE header contains the linker version number, @@ -10,6 +12,7 @@ /// /// /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public sealed class InformationBlock { /// @@ -21,7 +24,8 @@ /// The signature word is used by the loader to identify the EXE /// file as a valid 32-bit Linear Executable Module Format. /// - public string? Signature { get; set; } + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)] + public string? Signature; /// /// Byte Ordering. @@ -29,7 +33,8 @@ /// /// This byte specifies the byte ordering for the linear EXE format. /// - public ByteOrder ByteOrder { get; set; } + [MarshalAs(UnmanagedType.U1)] + public ByteOrder ByteOrder; /// /// Word Ordering. @@ -37,7 +42,8 @@ /// /// This byte specifies the Word ordering for the linear EXE format. /// - public WordOrder WordOrder { get; set; } + [MarshalAs(UnmanagedType.U1)] + public WordOrder WordOrder; /// /// Linear EXE Format Level. @@ -49,7 +55,7 @@ /// future EXE file versions so that an appropriate error message may be /// displayed if an attempt is made to load them. /// - public uint ExecutableFormatLevel { get; set; } + public uint ExecutableFormatLevel; /// /// Module CPU Type. @@ -57,7 +63,8 @@ /// /// This field specifies the type of CPU required by this module to run. /// - public CPUType CPUType { get; set; } + [MarshalAs(UnmanagedType.U2)] + public CPUType CPUType; /// /// Module OS Type. @@ -65,7 +72,8 @@ /// /// This field specifies the type of Operating system required to run this module. /// - public OperatingSystem ModuleOS { get; set; } + [MarshalAs(UnmanagedType.U2)] + public OperatingSystem ModuleOS; /// /// Module version @@ -74,12 +82,13 @@ /// This is useful for differentiating between revisions of dynamic linked modules. /// This value is specified at link time by the user. /// - public uint ModuleVersion { get; set; } + public uint ModuleVersion; /// /// Module type flags /// - public ModuleFlags ModuleTypeFlags { get; set; } + [MarshalAs(UnmanagedType.U4)] + public ModuleFlags ModuleTypeFlags; /// /// Number of pages in module. @@ -94,7 +103,7 @@ /// EXE module. This is used to determine the size of the page information tables /// in the linear EXE module. /// - public uint ModuleNumberPages { get; set; } + public uint ModuleNumberPages; /// /// The Object number to which the Entry Address is relative. @@ -109,7 +118,7 @@ /// is set, then the object to which this field refers must be a 32-bit object (i.e., /// the Big/Default bit must be set in the object flags; see below). /// - public uint InitialObjectCS { get; set; } + public uint InitialObjectCS; /// /// Entry Address of module. @@ -118,7 +127,7 @@ /// The Entry Address is the starting address for program modules and the library /// initialization and Library termination address for library modules. /// - public uint InitialEIP { get; set; } + public uint InitialEIP; /// /// The Object number to which the ESP is relative. @@ -128,7 +137,7 @@ /// nonzero value for a program module to be correctly loaded. This field is ignored /// for a library module. /// - public uint InitialObjectSS { get; set; } + public uint InitialObjectSS; /// /// Starting stack address of module. @@ -138,7 +147,7 @@ /// value in this field indicates that the stack pointer is to be initialized to the /// highest address/offset in the object. This field is ignored for a library module. /// - public uint InitialESP { get; set; } + public uint InitialESP; /// /// The size of one page for this system. @@ -148,7 +157,7 @@ /// For the initial version of this linear EXE format the page size is 4Kbytes. /// (The 4K page size is specified by a value of 4096 in this field.) /// - public uint MemoryPageSize { get; set; } + public uint MemoryPageSize; /// /// The shift left bits for page offsets. @@ -162,7 +171,7 @@ /// 512 byte (disk sector) basis. The default value for this field is 12 (decimal), /// which give a 4096 byte alignment. All other offsets are byte aligned. /// - public uint BytesOnLastPage { get; set; } + public uint BytesOnLastPage; /// /// Total size of the fixup information in bytes. @@ -174,7 +183,7 @@ /// - Import Module name Table /// - Import Procedure Name Table /// - public uint FixupSectionSize { get; set; } + public uint FixupSectionSize; /// /// Checksum for fixup information. @@ -185,7 +194,7 @@ /// not always loaded into main memory with the 'loader section'. If the checksum /// feature is not implemented, then the linker will set these fields to zero. /// - public uint FixupSectionChecksum { get; set; } + public uint FixupSectionChecksum; /// /// Size of memory resident tables. @@ -195,7 +204,7 @@ /// for the module, while the module is in use. This total size includes all /// tables from the Object Table down to and including the Per-Page Checksum Table. /// - public uint LoaderSectionSize { get; set; } + public uint LoaderSectionSize; /// /// Checksum for loader section. @@ -205,7 +214,7 @@ /// If the checksum feature is not implemented, then the linker will set these fields /// to zero. /// - public uint LoaderSectionChecksum { get; set; } + public uint LoaderSectionChecksum; /// /// Object Table offset. @@ -213,7 +222,7 @@ /// /// This offset is relative to the beginning of the linear EXE header. /// - public uint ObjectTableOffset { get; set; } + public uint ObjectTableOffset; /// /// Object Table Count. @@ -221,7 +230,7 @@ /// /// This defines the number of entries in Object Table. /// - public uint ObjectTableCount { get; set; } + public uint ObjectTableCount; /// /// Object Page Table offset @@ -229,7 +238,7 @@ /// /// This offset is relative to the beginning of the linear EXE header. /// - public uint ObjectPageMapOffset { get; set; } + public uint ObjectPageMapOffset; /// /// Object Iterated Pages offset. @@ -237,7 +246,7 @@ /// /// This offset is relative to the beginning of the linear EXE header. /// - public uint ObjectIterateDataMapOffset { get; set; } + public uint ObjectIterateDataMapOffset; /// /// Resource Table offset @@ -245,12 +254,12 @@ /// /// This offset is relative to the beginning of the linear EXE header. /// - public uint ResourceTableOffset { get; set; } + public uint ResourceTableOffset; /// /// Number of entries in Resource Table. /// - public uint ResourceTableCount { get; set; } + public uint ResourceTableCount; /// /// Resident Name Table offset. @@ -258,7 +267,7 @@ /// /// This offset is relative to the beginning of the linear EXE header. /// - public uint ResidentNamesTableOffset { get; set; } + public uint ResidentNamesTableOffset; /// /// Entry Table offset. @@ -266,7 +275,7 @@ /// /// This offset is relative to the beginning of the linear EXE header. /// - public uint EntryTableOffset { get; set; } + public uint EntryTableOffset; /// /// Module Format Directives Table offset. @@ -274,7 +283,7 @@ /// /// This offset is relative to the beginning of the linear EXE header. /// - public uint ModuleDirectivesTableOffset { get; set; } + public uint ModuleDirectivesTableOffset; /// /// Number of Module Format Directives in the Table. @@ -283,7 +292,7 @@ /// This field specifies the number of entries in the /// Module Format Directives Table. /// - public uint ModuleDirectivesCount { get; set; } + public uint ModuleDirectivesCount; /// /// Fixup Page Table offset. @@ -291,7 +300,7 @@ /// /// This offset is relative to the beginning of the linear EXE header. /// - public uint FixupPageTableOffset { get; set; } + public uint FixupPageTableOffset; /// /// Fixup Record Table offset. @@ -299,7 +308,7 @@ /// /// This offset is relative to the beginning of the linear EXE header. /// - public uint FixupRecordTableOffset { get; set; } + public uint FixupRecordTableOffset; /// /// Import Module Name Table offset. @@ -307,12 +316,12 @@ /// /// This offset is relative to the beginning of the linear EXE header. /// - public uint ImportedModulesNameTableOffset { get; set; } + public uint ImportedModulesNameTableOffset; /// /// The number of entries in the Import Module Name Table. /// - public uint ImportedModulesCount { get; set; } + public uint ImportedModulesCount; /// /// Import Procedure Name Table offset. @@ -320,7 +329,7 @@ /// /// This offset is relative to the beginning of the linear EXE header. /// - public uint ImportProcedureNameTableOffset { get; set; } + public uint ImportProcedureNameTableOffset; /// /// Per-page Checksum Table offset. @@ -328,7 +337,7 @@ /// /// This offset is relative to the beginning of the linear EXE header. /// - public uint PerPageChecksumTableOffset { get; set; } + public uint PerPageChecksumTableOffset; /// /// Data Pages Offset. @@ -336,7 +345,7 @@ /// /// This offset is relative to the beginning of the EXE file. /// - public uint DataPagesOffset { get; set; } + public uint DataPagesOffset; /// /// Number of Preload pages for this module. @@ -345,7 +354,7 @@ /// Note that OS/2 2.0 does not respect the preload of pages as specified /// in the executable file for performance reasons. /// - public uint PreloadPageCount { get; set; } + public uint PreloadPageCount; /// /// Non-Resident Name Table offset. @@ -353,12 +362,12 @@ /// /// This offset is relative to the beginning of the EXE file. /// - public uint NonResidentNamesTableOffset { get; set; } + public uint NonResidentNamesTableOffset; /// /// Number of bytes in the Non-resident name table. /// - public uint NonResidentNamesTableLength { get; set; } + public uint NonResidentNamesTableLength; /// /// Non-Resident Name Table Checksum. @@ -366,7 +375,7 @@ /// /// This is a cryptographic checksum of the Non-Resident Name Table. /// - public uint NonResidentNamesTableChecksum { get; set; } + public uint NonResidentNamesTableChecksum; /// /// The Auto Data Segment Object number. @@ -376,7 +385,7 @@ /// This field is supported for 16-bit compatibility only and is not used by /// 32-bit modules. /// - public uint AutomaticDataObject { get; set; } + public uint AutomaticDataObject; /// /// Debug Information offset. @@ -384,7 +393,7 @@ /// /// This offset is relative to the beginning of the linear EXE header. /// - public uint DebugInformationOffset { get; set; } + public uint DebugInformationOffset; /// /// Debug Information length. @@ -392,7 +401,7 @@ /// /// The length of the debug information in bytes. /// - public uint DebugInformationLength { get; set; } + public uint DebugInformationLength; /// /// Instance pages in preload section. @@ -400,7 +409,7 @@ /// /// The number of instance data pages found in the preload section. /// - public uint PreloadInstancePagesNumber { get; set; } + public uint PreloadInstancePagesNumber; /// /// Instance pages in demand section. @@ -408,7 +417,7 @@ /// /// The number of instance data pages found in the demand section. /// - public uint DemandInstancePagesNumber { get; set; } + public uint DemandInstancePagesNumber; /// /// Heap size added to the Auto DS Object. @@ -418,6 +427,6 @@ /// by the loader. This field is supported for 16-bit compatibility only and /// is not used by 32-bit modules. /// - public uint ExtraHeapAllocation { get; set; } + public uint ExtraHeapAllocation; } } diff --git a/LinearExecutable/ModuleFormatDirectivesTableEntry.cs b/LinearExecutable/ModuleFormatDirectivesTableEntry.cs index 41aafcb..b998066 100644 --- a/LinearExecutable/ModuleFormatDirectivesTableEntry.cs +++ b/LinearExecutable/ModuleFormatDirectivesTableEntry.cs @@ -1,4 +1,6 @@ -namespace SabreTools.Models.LinearExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.LinearExecutable { /// /// The Module Format Directives Table is an optional table that allows additional @@ -13,6 +15,7 @@ /// /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class ModuleFormatDirectivesTableEntry { /// @@ -22,7 +25,8 @@ /// The directive number specifies the type of directive defined. This can be /// used to determine the format of the information in the directive data. /// - public DirectiveNumber DirectiveNumber { get; set; } + [MarshalAs(UnmanagedType.U2)] + public DirectiveNumber DirectiveNumber; /// /// Directive data length. @@ -30,7 +34,7 @@ /// /// This specifies the length in byte of the directive data for this directive number. /// - public ushort DirectiveDataLength { get; set; } + public ushort DirectiveDataLength; /// /// Directive data offset. @@ -40,6 +44,6 @@ /// to beginning of linear EXE header for a resident table, and relative to the /// beginning of the EXE file for non-resident tables. /// - public uint DirectiveDataOffset { get; set; } + public uint DirectiveDataOffset; } } diff --git a/LinearExecutable/ObjectPageMapEntry.cs b/LinearExecutable/ObjectPageMapEntry.cs index 29dd268..1451526 100644 --- a/LinearExecutable/ObjectPageMapEntry.cs +++ b/LinearExecutable/ObjectPageMapEntry.cs @@ -1,4 +1,6 @@ -namespace SabreTools.Models.LinearExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.LinearExecutable { /// /// The Object page table provides information about a logical page in an object. @@ -13,6 +15,7 @@ /// /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class ObjectPageMapEntry { /// @@ -35,7 +38,7 @@ /// The logical page number (Object Page Table index), is used to index the Fixup /// Page Table to find any fixups associated with the logical page. /// - public uint PageDataOffset { get; set; } + public uint PageDataOffset; /// /// Number of bytes of data for this page. @@ -47,11 +50,12 @@ /// bytes are to be filled with zeros. If the FLAGS field indicates an Iterated Data /// Page, the iterated data records will completely fill out the remainder. /// - public ushort DataSize { get; set; } + public ushort DataSize; /// /// Attributes specifying characteristics of this logical page. /// - public ObjectPageFlags Flags { get; set; } + [MarshalAs(UnmanagedType.U2)] + public ObjectPageFlags Flags; } } diff --git a/LinearExecutable/ObjectTableEntry.cs b/LinearExecutable/ObjectTableEntry.cs index e851e41..dfb3ff9 100644 --- a/LinearExecutable/ObjectTableEntry.cs +++ b/LinearExecutable/ObjectTableEntry.cs @@ -1,4 +1,6 @@ -namespace SabreTools.Models.LinearExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.LinearExecutable { /// /// The object table contains information that describes each segment in @@ -12,6 +14,7 @@ /// /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class ObjectTableEntry { /// @@ -24,7 +27,7 @@ /// file for the object. This memory size must also be large enough to /// contain all of the iterated data and uninitialized data in the EXE file. /// - public uint VirtualSegmentSize { get; set; } + public uint VirtualSegmentSize; /// /// Relocation Base Address. @@ -34,12 +37,13 @@ /// internal relocation fixups for the module have been removed, this is the /// address the object will be allocated at by the loader. /// - public uint RelocationBaseAddress { get; set; } + public uint RelocationBaseAddress; /// /// Flag bits for the object. /// - public ObjectFlags ObjectFlags { get; set; } + [MarshalAs(UnmanagedType.U2)] + public ObjectFlags ObjectFlags; /// /// Object Page Table Index. @@ -53,7 +57,7 @@ /// other words the object table entries are sorted based on the object page table /// index value. /// - public uint PageTableIndex { get; set; } + public uint PageTableIndex; /// /// # of object page table entries for this object. @@ -69,11 +73,11 @@ /// was neither a zero filled or invalid page, then the additional pages are treated /// as zero filled pages. /// - public uint PageTableEntries { get; set; } + public uint PageTableEntries; /// /// Reserved for future use. Must be set to zero. /// - public uint Reserved { get; set; } + public uint Reserved; } } diff --git a/LinearExecutable/PerPageChecksumTableEntry.cs b/LinearExecutable/PerPageChecksumTableEntry.cs index 9ede004..5691007 100644 --- a/LinearExecutable/PerPageChecksumTableEntry.cs +++ b/LinearExecutable/PerPageChecksumTableEntry.cs @@ -1,4 +1,6 @@ -namespace SabreTools.Models.LinearExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.LinearExecutable { /// /// The Per-Page Checksum table provides space for a cryptographic checksum for @@ -11,11 +13,12 @@ /// /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class PerPageChecksumTableEntry { /// /// Cryptographic checksum. /// - public uint Checksum { get; set; } + public uint Checksum; } } diff --git a/LinearExecutable/ResourceTableEntry.cs b/LinearExecutable/ResourceTableEntry.cs index bd991ef..8d9a095 100644 --- a/LinearExecutable/ResourceTableEntry.cs +++ b/LinearExecutable/ResourceTableEntry.cs @@ -1,4 +1,6 @@ -namespace SabreTools.Models.LinearExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.LinearExecutable { /// /// The resource table is an array of resource table entries. Each resource table @@ -13,31 +15,33 @@ /// /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class ResourceTableEntry { /// /// Resource type ID. /// - public ResourceTableEntryType TypeID { get; set; } + [MarshalAs(UnmanagedType.U4)] + public ResourceTableEntryType TypeID; /// /// An ID used as a name for the resource when referred to. /// - public ushort NameID { get; set; } + public ushort NameID; /// /// The number of bytes the resource consists of. /// - public uint ResourceSize { get; set; } + public uint ResourceSize; /// /// The number of the object which contains the resource. /// - public ushort ObjectNumber { get; set; } + public ushort ObjectNumber; /// /// The offset within the specified object where the resource begins. /// - public uint Offset { get; set; } + public uint Offset; } } diff --git a/LinearExecutable/VerifyRecordDirectiveTableEntry.cs b/LinearExecutable/VerifyRecordDirectiveTableEntry.cs index 115892e..4c0c729 100644 --- a/LinearExecutable/VerifyRecordDirectiveTableEntry.cs +++ b/LinearExecutable/VerifyRecordDirectiveTableEntry.cs @@ -1,4 +1,6 @@ -namespace SabreTools.Models.LinearExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.LinearExecutable { /// /// The Verify Record Directive Table is an optional table. It maintains a record @@ -9,6 +11,7 @@ /// /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class VerifyRecordDirectiveTableEntry { /// @@ -19,7 +22,7 @@ /// directive table. This is equal to the number of modules referenced by /// this module. /// - public ushort EntryCount { get; set; } + public ushort EntryCount; /// /// Ordinal index into the Import Module Name Table. @@ -28,7 +31,7 @@ /// This value is an ordered index in to the Import Module Name Table for /// the referenced module. /// - public ushort OrdinalIndex { get; set; } + public ushort OrdinalIndex; /// /// Module Version. @@ -41,7 +44,7 @@ /// number in a module to be incremented anytime the entry point offsets /// change. /// - public ushort Version { get; set; } + public ushort Version; /// /// Module # of Object Entries. @@ -50,7 +53,7 @@ /// This field is used to identify the number of object verify entries /// that follow for the referenced module. /// - public ushort ObjectEntriesCount { get; set; } + public ushort ObjectEntriesCount; /// /// Object # in Module. @@ -59,7 +62,7 @@ /// This field specifies the object number in the referenced module that /// is being verified. /// - public ushort ObjectNumberInModule { get; set; } + public ushort ObjectNumberInModule; /// /// Object load base address. @@ -68,7 +71,7 @@ /// This is the address that the object was loaded at when the fixups were /// performed. /// - public ushort ObjectLoadBaseAddress { get; set; } + public ushort ObjectLoadBaseAddress; /// /// Object virtual address size. @@ -77,6 +80,6 @@ /// This field specifies the total amount of virtual memory required for /// this object. /// - public ushort ObjectVirtualAddressSize { get; set; } + public ushort ObjectVirtualAddressSize; } } diff --git a/MSDOS/RelocationEntry.cs b/MSDOS/RelocationEntry.cs index 53cf736..98be6b6 100644 --- a/MSDOS/RelocationEntry.cs +++ b/MSDOS/RelocationEntry.cs @@ -1,19 +1,22 @@ -namespace SabreTools.Models.MSDOS +using System.Runtime.InteropServices; + +namespace SabreTools.Models.MSDOS { /// /// Each pointer in the relocation table looks as such /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class RelocationEntry { /// /// Offset of the relocation within provided segment. /// - public ushort Offset { get; set; } + public ushort Offset; /// /// Segment of the relocation, relative to the load segment address. /// - public ushort Segment { get; set; } + public ushort Segment; } } diff --git a/MoPaQ/BlockEntry.cs b/MoPaQ/BlockEntry.cs index 48b6904..09d6644 100644 --- a/MoPaQ/BlockEntry.cs +++ b/MoPaQ/BlockEntry.cs @@ -1,4 +1,6 @@ -namespace SabreTools.Models.MoPaQ +using System.Runtime.InteropServices; + +namespace SabreTools.Models.MoPaQ { /// /// Block table contains informations about file sizes and way of their storage within @@ -6,26 +8,28 @@ /// of block table entry is (like hash table entry). The block table is also encrypted. /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class BlockEntry { /// /// Offset of the beginning of the file data, relative to the beginning of the archive. /// - public uint FilePosition { get; set; } + public uint FilePosition; /// /// Compressed file size /// - public uint CompressedSize { get; set; } + public uint CompressedSize; /// /// Size of uncompressed file /// - public uint UncompressedSize { get; set; } + public uint UncompressedSize; /// /// Flags for the file. /// - public FileFlags Flags { get; set; } + [MarshalAs(UnmanagedType.U4)] + public FileFlags Flags; } } diff --git a/MoPaQ/HashEntry.cs b/MoPaQ/HashEntry.cs index 67ccb91..6f47265 100644 --- a/MoPaQ/HashEntry.cs +++ b/MoPaQ/HashEntry.cs @@ -1,4 +1,6 @@ -namespace SabreTools.Models.MoPaQ +using System.Runtime.InteropServices; + +namespace SabreTools.Models.MoPaQ { /// /// Hash table is used for searching files by name. The file name is converted to @@ -8,29 +10,31 @@ /// table is 16 bytes. /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class HashEntry { /// /// The hash of the full file name (part A) /// - public uint NameHashPartA { get; set; } + public uint NameHashPartA; /// /// The hash of the full file name (part B) /// - public uint NameHashPartB { get; set; } + public uint NameHashPartB; /// /// The language of the file. This is a Windows LANGID data type, and uses the same values. /// 0 indicates the default language (American English), or that the file is language-neutral. /// - public Locale Locale { get; set; } + [MarshalAs(UnmanagedType.I2)] + public Locale Locale; /// /// The platform the file is used for. 0 indicates the default platform. /// No other values have been observed. /// - public ushort Platform { get; set; } + public ushort Platform; /// /// If the hash table entry is valid, this is the index into the block table of the file. @@ -40,6 +44,6 @@ /// - FFFFFFFEh: Hash table entry is empty, but was valid at some point (a deleted file). /// Does not terminate searches for a given file. /// - public uint BlockIndex { get; set; } + public uint BlockIndex; } } diff --git a/NCF/ChecksumEntry.cs b/NCF/ChecksumEntry.cs index d75ac17..31af673 100644 --- a/NCF/ChecksumEntry.cs +++ b/NCF/ChecksumEntry.cs @@ -1,11 +1,14 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.NCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class ChecksumEntry { /// /// Checksum. /// - public uint Checksum { get; set; } + public uint Checksum; } } diff --git a/NCF/ChecksumHeader.cs b/NCF/ChecksumHeader.cs index 2f1ba03..6a760ca 100644 --- a/NCF/ChecksumHeader.cs +++ b/NCF/ChecksumHeader.cs @@ -1,16 +1,19 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.NCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class ChecksumHeader { /// /// Always 0x00000001 /// - public uint Dummy0 { get; set; } + public uint Dummy0; /// /// Size of LPNCFCHECKSUMHEADER & LPNCFCHECKSUMMAPHEADER & in bytes. /// - public uint ChecksumSize { get; set; } + public uint ChecksumSize; } } diff --git a/NCF/ChecksumMapEntry.cs b/NCF/ChecksumMapEntry.cs index 7ece4ab..31f650f 100644 --- a/NCF/ChecksumMapEntry.cs +++ b/NCF/ChecksumMapEntry.cs @@ -1,16 +1,19 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.NCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class ChecksumMapEntry { /// /// Number of checksums. /// - public uint ChecksumCount { get; set; } + public uint ChecksumCount; /// /// Index of first checksum. /// - public uint FirstChecksumIndex { get; set; } + public uint FirstChecksumIndex; } } diff --git a/NCF/ChecksumMapHeader.cs b/NCF/ChecksumMapHeader.cs index 2b112c2..86b24c2 100644 --- a/NCF/ChecksumMapHeader.cs +++ b/NCF/ChecksumMapHeader.cs @@ -1,26 +1,29 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.NCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class ChecksumMapHeader { /// /// Always 0x14893721 /// - public uint Dummy0 { get; set; } + public uint Dummy0; /// /// Always 0x00000001 /// - public uint Dummy1 { get; set; } + public uint Dummy1; /// /// Number of items. /// - public uint ItemCount { get; set; } + public uint ItemCount; /// /// Number of checksums. /// - public uint ChecksumCount { get; set; } + public uint ChecksumCount; } } diff --git a/NCF/DirectoryCopyEntry.cs b/NCF/DirectoryCopyEntry.cs index 5a55449..93cd927 100644 --- a/NCF/DirectoryCopyEntry.cs +++ b/NCF/DirectoryCopyEntry.cs @@ -1,11 +1,14 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.NCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class DirectoryCopyEntry { /// /// Index of the directory item. /// - public uint DirectoryIndex { get; set; } + public uint DirectoryIndex; } } diff --git a/NCF/DirectoryHeader.cs b/NCF/DirectoryHeader.cs index b61d27d..a329a78 100644 --- a/NCF/DirectoryHeader.cs +++ b/NCF/DirectoryHeader.cs @@ -1,76 +1,79 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.NCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class DirectoryHeader { /// /// Always 0x00000004 /// - public uint Dummy0 { get; set; } + public uint Dummy0; /// /// Cache ID. /// - public uint CacheID { get; set; } + public uint CacheID; /// /// NCF file version. /// - public uint LastVersionPlayed { get; set; } + public uint LastVersionPlayed; /// /// Number of items in the directory. /// - public uint ItemCount { get; set; } + public uint ItemCount; /// /// Number of files in the directory. /// - public uint FileCount { get; set; } + public uint FileCount; /// /// Always 0x00008000. Data per checksum? /// - public uint ChecksumDataLength { get; set; } + public uint ChecksumDataLength; /// /// Size of lpNCFDirectoryEntries & lpNCFDirectoryNames & lpNCFDirectoryInfo1Entries & lpNCFDirectoryInfo2Entries & lpNCFDirectoryCopyEntries & lpNCFDirectoryLocalEntries in bytes. /// - public uint DirectorySize { get; set; } + public uint DirectorySize; /// /// Size of the directory names in bytes. /// - public uint NameSize { get; set; } + public uint NameSize; /// /// Number of Info1 entires. /// - public uint Info1Count { get; set; } + public uint Info1Count; /// /// Number of files to copy. /// - public uint CopyCount { get; set; } + public uint CopyCount; /// /// Number of files to keep local. /// - public uint LocalCount { get; set; } + public uint LocalCount; /// /// Reserved /// - public uint Dummy1 { get; set; } + public uint Dummy1; /// /// Reserved /// - public uint Dummy2 { get; set; } + public uint Dummy2; /// /// Header checksum. /// - public uint Checksum { get; set; } + public uint Checksum; } } diff --git a/NCF/DirectoryInfo1Entry.cs b/NCF/DirectoryInfo1Entry.cs index 3e65147..3d6331f 100644 --- a/NCF/DirectoryInfo1Entry.cs +++ b/NCF/DirectoryInfo1Entry.cs @@ -1,11 +1,14 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.NCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class DirectoryInfo1Entry { /// /// Reserved /// - public uint Dummy0 { get; set; } + public uint Dummy0; } } diff --git a/NCF/DirectoryInfo2Entry.cs b/NCF/DirectoryInfo2Entry.cs index 3916fdb..eeacd92 100644 --- a/NCF/DirectoryInfo2Entry.cs +++ b/NCF/DirectoryInfo2Entry.cs @@ -1,11 +1,14 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.NCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class DirectoryInfo2Entry { /// /// Reserved /// - public uint Dummy0 { get; set; } + public uint Dummy0; } } diff --git a/NCF/DirectoryLocalEntry.cs b/NCF/DirectoryLocalEntry.cs index de47a67..233f212 100644 --- a/NCF/DirectoryLocalEntry.cs +++ b/NCF/DirectoryLocalEntry.cs @@ -1,11 +1,14 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.NCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class DirectoryLocalEntry { /// /// Index of the directory item. /// - public uint DirectoryIndex { get; set; } + public uint DirectoryIndex; } } diff --git a/NCF/Header.cs b/NCF/Header.cs index 8a38953..fe4f808 100644 --- a/NCF/Header.cs +++ b/NCF/Header.cs @@ -1,61 +1,64 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.NCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class Header { /// /// Always 0x00000001 /// - public uint Dummy0 { get; set; } + public uint Dummy0; /// /// Always 0x00000002 /// - public uint MajorVersion { get; set; } + public uint MajorVersion; /// /// NCF version number. /// - public uint MinorVersion { get; set; } + public uint MinorVersion; /// /// Cache ID /// - public uint CacheID { get; set; } + public uint CacheID; /// /// Last version played /// - public uint LastVersionPlayed { get; set; } + public uint LastVersionPlayed; /// /// Reserved /// - public uint Dummy1 { get; set; } + public uint Dummy1; /// /// Reserved /// - public uint Dummy2 { get; set; } + public uint Dummy2; /// /// Total size of NCF file in bytes. /// - public uint FileSize { get; set; } + public uint FileSize; /// /// Size of each data block in bytes. /// - public uint BlockSize { get; set; } + public uint BlockSize; /// /// Number of data blocks. /// - public uint BlockCount { get; set; } + public uint BlockCount; /// /// Reserved /// - public uint Dummy3 { get; set; } + public uint Dummy3; } } diff --git a/NCF/UnknownEntry.cs b/NCF/UnknownEntry.cs index 5e5b1c2..4fbd44c 100644 --- a/NCF/UnknownEntry.cs +++ b/NCF/UnknownEntry.cs @@ -1,11 +1,14 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.NCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class UnknownEntry { /// /// Reserved /// - public uint Dummy0 { get; set; } + public uint Dummy0; } } diff --git a/NCF/UnknownHeader.cs b/NCF/UnknownHeader.cs index 6bc1890..878bc0d 100644 --- a/NCF/UnknownHeader.cs +++ b/NCF/UnknownHeader.cs @@ -1,16 +1,19 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.NCF { /// + [StructLayout(LayoutKind.Sequential)] public sealed class UnknownHeader { /// /// Always 0x00000001 /// - public uint Dummy0 { get; set; } + public uint Dummy0; /// /// Always 0x00000000 /// - public uint Dummy1 { get; set; } + public uint Dummy1; } } diff --git a/NewExecutable/ExecutableHeader.cs b/NewExecutable/ExecutableHeader.cs index 52f522d..2ce2202 100644 --- a/NewExecutable/ExecutableHeader.cs +++ b/NewExecutable/ExecutableHeader.cs @@ -1,3 +1,5 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.NewExecutable { /// @@ -6,6 +8,7 @@ namespace SabreTools.Models.NewExecutable /// /// /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public sealed class ExecutableHeader { /// @@ -13,38 +16,40 @@ namespace SabreTools.Models.NewExecutable /// "N" is low-order byte. /// "E" is high-order byte. /// + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)] public string? Magic; /// /// Version number of the linker. /// - public byte LinkerVersion { get; set; } + public byte LinkerVersion; /// /// Revision number of the linker. /// - public byte LinkerRevision { get; set; } + public byte LinkerRevision; /// /// Entry Table file offset, relative to the beginning of the segmented EXE header. /// - public ushort EntryTableOffset { get; set; } + public ushort EntryTableOffset; /// /// Number of bytes in the entry table. /// - public ushort EntryTableSize { get; set; } + public ushort EntryTableSize; /// /// 32-bit CRC of entire contents of file. /// /// These words are taken as 00 during the calculation. - public uint CrcChecksum { get; set; } + public uint CrcChecksum; /// /// Flag word /// - public HeaderFlag FlagWord { get; set; } + [MarshalAs(UnmanagedType.U2)] + public HeaderFlag FlagWord; /// /// Segment number of automatic data segment. @@ -57,26 +62,26 @@ namespace SabreTools.Models.NewExecutable /// table. The first entry in the segment table is segment /// number 1. /// - public ushort AutomaticDataSegmentNumber { get; set; } + public ushort AutomaticDataSegmentNumber; /// /// Initial size, in bytes, of dynamic heap added to the /// data segment. This value is zero if no initial local /// heap is allocated. /// - public ushort InitialHeapAlloc { get; set; } + public ushort InitialHeapAlloc; /// /// Initial size, in bytes, of stack added to the data /// segment. This value is zero to indicate no initial /// stack allocation, or when SS is not equal to DS. /// - public ushort InitialStackAlloc { get; set; } + public ushort InitialStackAlloc; /// /// Segment number:offset of CS:IP. /// - public uint InitialCSIPSetting { get; set; } + public uint InitialCSIPSetting; /// /// Segment number:offset of SS:SP. @@ -87,108 +92,110 @@ namespace SabreTools.Models.NewExecutable /// automatic data segment just below the additional heap /// area. /// - public uint InitialSSSPSetting { get; set; } + public uint InitialSSSPSetting; /// /// Number of entries in the Segment Table. /// - public ushort FileSegmentCount { get; set; } + public ushort FileSegmentCount; /// /// Number of entries in the Module Reference Table. /// - public ushort ModuleReferenceTableSize { get; set; } + public ushort ModuleReferenceTableSize; /// /// Number of bytes in the Non-Resident Name Table. /// - public ushort NonResidentNameTableSize { get; set; } + public ushort NonResidentNameTableSize; /// /// Segment Table file offset, relative to the beginning /// of the segmented EXE header. /// - public ushort SegmentTableOffset { get; set; } + public ushort SegmentTableOffset; /// /// Resource Table file offset, relative to the beginning /// of the segmented EXE header. /// - public ushort ResourceTableOffset { get; set; } + public ushort ResourceTableOffset; /// /// Resident Name Table file offset, relative to the /// beginning of the segmented EXE header. /// - public ushort ResidentNameTableOffset { get; set; } + public ushort ResidentNameTableOffset; /// /// Module Reference Table file offset, relative to the /// beginning of the segmented EXE header. /// - public ushort ModuleReferenceTableOffset { get; set; } + public ushort ModuleReferenceTableOffset; /// /// Imported Names Table file offset, relative to the /// beginning of the segmented EXE header. /// - public ushort ImportedNamesTableOffset { get; set; } + public ushort ImportedNamesTableOffset; /// /// Non-Resident Name Table offset, relative to the /// beginning of the file. /// - public uint NonResidentNamesTableOffset { get; set; } + public uint NonResidentNamesTableOffset; /// /// Number of movable entries in the Entry Table. /// - public ushort MovableEntriesCount { get; set; } + public ushort MovableEntriesCount; /// /// Logical sector alignment shift count, log(base 2) of /// the segment sector size (default 9). /// - public ushort SegmentAlignmentShiftCount { get; set; } + public ushort SegmentAlignmentShiftCount; /// /// Number of resource entries. /// - public ushort ResourceEntriesCount { get; set; } + public ushort ResourceEntriesCount; /// /// Executable type, used by loader. /// - public OperatingSystem TargetOperatingSystem { get; set; } + [MarshalAs(UnmanagedType.U1)] + public OperatingSystem TargetOperatingSystem; /// /// Other OS/2 flags /// - public OS2Flag AdditionalFlags { get; set; } + [MarshalAs(UnmanagedType.U1)] + public OS2Flag AdditionalFlags; /// /// Offset to return thunks or start of gangload area /// - public ushort ReturnThunkOffset { get; set; } + public ushort ReturnThunkOffset; /// /// Offset to segment reference thunks or size of gangload area /// - public ushort SegmentReferenceThunkOffset { get; set; } + public ushort SegmentReferenceThunkOffset; /// /// Minimum code swap area size /// - public ushort MinCodeSwapAreaSize { get; set; } + public ushort MinCodeSwapAreaSize; /// /// Windows SDK revison number /// - public byte WindowsSDKRevision { get; set; } + public byte WindowsSDKRevision; /// /// Windows SDK version number /// - public byte WindowsSDKVersion { get; set; } + public byte WindowsSDKVersion; } } diff --git a/NewExecutable/ImportNameRelocationRecord.cs b/NewExecutable/ImportNameRelocationRecord.cs index a71bd3d..5b00812 100644 --- a/NewExecutable/ImportNameRelocationRecord.cs +++ b/NewExecutable/ImportNameRelocationRecord.cs @@ -1,16 +1,19 @@ -namespace SabreTools.Models.NewExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.NewExecutable { /// + [StructLayout(LayoutKind.Sequential)] public sealed class ImportNameRelocationRecord { /// /// Index into module reference table for the imported module. /// - public ushort Index { get; set; } + public ushort Index; /// /// Offset within Imported Names Table to procedure name string. /// - public ushort Offset { get; set; } + public ushort Offset; } } diff --git a/NewExecutable/ImportOrdinalRelocationRecord.cs b/NewExecutable/ImportOrdinalRelocationRecord.cs index 0d357b0..949303d 100644 --- a/NewExecutable/ImportOrdinalRelocationRecord.cs +++ b/NewExecutable/ImportOrdinalRelocationRecord.cs @@ -1,16 +1,19 @@ -namespace SabreTools.Models.NewExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.NewExecutable { /// + [StructLayout(LayoutKind.Sequential)] public sealed class ImportOrdinalRelocationRecord { /// /// Index into module reference table for the imported module. /// - public ushort Index { get; set; } + public ushort Index; /// /// Procedure ordinal number. /// - public ushort Ordinal { get; set; } + public ushort Ordinal; } } diff --git a/NewExecutable/InternalRefRelocationRecord.cs b/NewExecutable/InternalRefRelocationRecord.cs index 4a6b38c..931b1bf 100644 --- a/NewExecutable/InternalRefRelocationRecord.cs +++ b/NewExecutable/InternalRefRelocationRecord.cs @@ -1,23 +1,26 @@ -namespace SabreTools.Models.NewExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.NewExecutable { /// + [StructLayout(LayoutKind.Sequential)] public sealed class InternalRefRelocationRecord { /// /// Segment number for a fixed segment, or 0FFh for a /// movable segment. /// - public byte SegmentNumber { get; set; } + public byte SegmentNumber; /// /// 0 /// - public byte Reserved { get; set; } + public byte Reserved; /// /// Offset into segment if fixed segment, or ordinal /// number index into Entry Table if movable segment. /// - public ushort Offset { get; set; } + public ushort Offset; } } diff --git a/NewExecutable/ModuleReferenceTableEntry.cs b/NewExecutable/ModuleReferenceTableEntry.cs index 2b1b23a..8869626 100644 --- a/NewExecutable/ModuleReferenceTableEntry.cs +++ b/NewExecutable/ModuleReferenceTableEntry.cs @@ -1,4 +1,6 @@ -namespace SabreTools.Models.NewExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.NewExecutable { /// /// The module-reference table follows the resident-name table. Each entry @@ -6,11 +8,12 @@ /// names table; each entry is 2 bytes long. /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class ModuleReferenceTableEntry { /// /// Offset within Imported Names Table to referenced module name string. /// - public ushort Offset { get; set; } + public ushort Offset; } } diff --git a/NewExecutable/OSFixupRelocationRecord.cs b/NewExecutable/OSFixupRelocationRecord.cs index b7a79b3..b357217 100644 --- a/NewExecutable/OSFixupRelocationRecord.cs +++ b/NewExecutable/OSFixupRelocationRecord.cs @@ -1,17 +1,21 @@ -namespace SabreTools.Models.NewExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.NewExecutable { /// + [StructLayout(LayoutKind.Sequential)] public sealed class OSFixupRelocationRecord { /// /// Operating system fixup type. /// Floating-point fixups. /// - public OSFixupType FixupType { get; set; } + [MarshalAs(UnmanagedType.U2)] + public OSFixupType FixupType; /// /// 0 /// - public ushort Reserved { get; set; } + public ushort Reserved; } } diff --git a/NewExecutable/ResourceTypeResourceEntry.cs b/NewExecutable/ResourceTypeResourceEntry.cs index de25421..dbc3db5 100644 --- a/NewExecutable/ResourceTypeResourceEntry.cs +++ b/NewExecutable/ResourceTypeResourceEntry.cs @@ -1,10 +1,13 @@ -namespace SabreTools.Models.NewExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.NewExecutable { /// /// A table of resources for this type follows. The following is /// the format of each resource (8 bytes each): /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class ResourceTypeResourceEntry { /// @@ -13,17 +16,18 @@ /// of the alignment shift count value specified at /// beginning of the resource table. /// - public ushort Offset { get; set; } + public ushort Offset; /// /// Length of the resource in the file (in bytes). /// - public ushort Length { get; set; } + public ushort Length; /// /// Flag word. /// - public ResourceTypeResourceFlag FlagWord { get; set; } + [MarshalAs(UnmanagedType.U2)] + public ResourceTypeResourceFlag FlagWord; /// /// Resource ID. This is an integer type if the high-order @@ -31,11 +35,11 @@ /// resource string, the offset is relative to the /// beginning of the resource table. /// - public ushort ResourceID { get; set; } + public ushort ResourceID; /// /// Reserved. /// - public uint Reserved { get; set; } + public uint Reserved; } } diff --git a/NewExecutable/SegmentTableEntry.cs b/NewExecutable/SegmentTableEntry.cs index 5d947a9..4cf7b08 100644 --- a/NewExecutable/SegmentTableEntry.cs +++ b/NewExecutable/SegmentTableEntry.cs @@ -1,4 +1,6 @@ -namespace SabreTools.Models.NewExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.NewExecutable { /// /// The segment table contains an entry for each segment in the executable @@ -7,6 +9,7 @@ /// The following is the structure of a segment table entry. /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class SegmentTableEntry { /// @@ -14,22 +17,23 @@ /// data, relative to the beginning of the file. Zero means no /// file data. /// - public ushort Offset { get; set; } + public ushort Offset; /// /// Length of the segment in the file, in bytes. Zero means 64K. /// - public ushort Length { get; set; } + public ushort Length; /// /// Flag word. /// - public SegmentTableEntryFlag FlagWord { get; set; } + [MarshalAs(UnmanagedType.U2)] + public SegmentTableEntryFlag FlagWord; /// /// Minimum allocation size of the segment, in bytes. Total size /// of the segment. Zero means 64K. /// - public ushort MinimumAllocationSize { get; set; } + public ushort MinimumAllocationSize; } } diff --git a/PAK/DirectoryItem.cs b/PAK/DirectoryItem.cs index 196c376..6b718ef 100644 --- a/PAK/DirectoryItem.cs +++ b/PAK/DirectoryItem.cs @@ -1,21 +1,25 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.PAK { /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public sealed class DirectoryItem { /// /// Item Name /// - public string? ItemName { get; set; } + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 56)] + public string? ItemName; /// /// Item Offset /// - public uint ItemOffset { get; set; } + public uint ItemOffset; /// /// Item Length /// - public uint ItemLength { get; set; } + public uint ItemLength; } } diff --git a/PAK/Header.cs b/PAK/Header.cs index 34e765c..4db3047 100644 --- a/PAK/Header.cs +++ b/PAK/Header.cs @@ -1,21 +1,25 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.PAK { /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public sealed class Header { /// /// Signature /// - public string? Signature { get; set; } + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)] + public string? Signature; /// /// Directory Offset /// - public uint DirectoryOffset { get; set; } + public uint DirectoryOffset; /// /// Directory Length /// - public uint DirectoryLength { get; set; } + public uint DirectoryLength; } } diff --git a/PFF/Footer.cs b/PFF/Footer.cs index 0670930..3c17880 100644 --- a/PFF/Footer.cs +++ b/PFF/Footer.cs @@ -1,24 +1,28 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.PFF { /// /// PFF file footer /// /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public sealed class Footer { /// /// Current system IP /// - public uint SystemIP { get; set; } + public uint SystemIP; /// /// Reserved /// - public uint Reserved { get; set; } + public uint Reserved; /// /// King tag /// - public string? KingTag { get; set; } + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)] + public string? KingTag; } } \ No newline at end of file diff --git a/PFF/Header.cs b/PFF/Header.cs index 9f09f60..eef49b2 100644 --- a/PFF/Header.cs +++ b/PFF/Header.cs @@ -1,3 +1,5 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.PFF { /// @@ -5,32 +7,34 @@ namespace SabreTools.Models.PFF /// /// Versions 2, 3, and 4 supported /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public sealed class Header { /// /// Size of the following header /// - public uint HeaderSize { get; set; } + public uint HeaderSize; /// /// Signature /// /// Versions 2 and 3 share the same signature but different header sizes - public string? Signature { get; set; } + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)] + public string? Signature; /// /// Number of files /// - public uint NumberOfFiles { get; set; } + public uint NumberOfFiles; /// /// File segment size /// - public uint FileSegmentSize { get; set; } + public uint FileSegmentSize; /// /// File list offset /// - public uint FileListOffset { get; set; } + public uint FileListOffset; } } \ No newline at end of file diff --git a/PIC/DiscInformationUnitBody.cs b/PIC/DiscInformationUnitBody.cs index a2fce4d..7f4cc30 100644 --- a/PIC/DiscInformationUnitBody.cs +++ b/PIC/DiscInformationUnitBody.cs @@ -7,10 +7,6 @@ namespace SabreTools.Models.PIC { /// /// Disc Type Identifier - /// = "BDO" for BD-ROM - /// = "BDU" for BD-ROM Ultra - /// = "BDW" for BD-RE - /// = "BDR" for BD-R /// public string? DiscTypeIdentifier { get; set; } diff --git a/PIC/DiscInformationUnitHeader.cs b/PIC/DiscInformationUnitHeader.cs index ed93195..1176508 100644 --- a/PIC/DiscInformationUnitHeader.cs +++ b/PIC/DiscInformationUnitHeader.cs @@ -1,43 +1,47 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.PIC { /// /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public class DiscInformationUnitHeader { /// /// Disc Information Identifier "DI" /// Emergency Brake Identifier "EB" /// - public string? DiscInformationIdentifier { get; set; } + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)] + public string? DiscInformationIdentifier; /// /// Disc Information Format /// - public byte DiscInformationFormat { get; set; } + public byte DiscInformationFormat; /// /// Number of DI units in each DI block /// - public byte NumberOfUnitsInBlock { get; set; } + public byte NumberOfUnitsInBlock; /// /// Should be 0x00 /// - public byte Reserved0 { get; set; } + public byte Reserved0; /// /// DI unit Sequence Number /// - public byte SequenceNumber { get; set; } + public byte SequenceNumber; /// /// Number of bytes in use in this DI unit /// - public byte BytesInUse { get; set; } + public byte BytesInUse; /// /// Should be 0x00 /// - public byte Reserved1 { get; set; } + public byte Reserved1; } } diff --git a/PIC/DiscInformationUnitTrailer.cs b/PIC/DiscInformationUnitTrailer.cs index fe22f11..bfa81d0 100644 --- a/PIC/DiscInformationUnitTrailer.cs +++ b/PIC/DiscInformationUnitTrailer.cs @@ -1,3 +1,5 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.PIC { /// @@ -5,28 +7,31 @@ namespace SabreTools.Models.PIC /// /// /// + [StructLayout(LayoutKind.Sequential)] public class DiscInformationUnitTrailer { /// /// Disc Manufacturer ID /// /// 6 bytes - public byte[]? DiscManufacturerID { get; set; } = new byte[6]; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] + public byte[]? DiscManufacturerID; /// /// Media Type ID /// /// 3 bytes - public byte[]? MediaTypeID { get; set; } = new byte[3]; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public byte[]? MediaTypeID; /// /// Time Stamp /// - public ushort TimeStamp { get; set; } + public ushort TimeStamp; /// /// Product Revision Number /// - public byte ProductRevisionNumber { get; set; } + public byte ProductRevisionNumber; } } diff --git a/PKZIP/EndOfCentralDirectoryLocator64.cs b/PKZIP/EndOfCentralDirectoryLocator64.cs index 377e062..07ffbe1 100644 --- a/PKZIP/EndOfCentralDirectoryLocator64.cs +++ b/PKZIP/EndOfCentralDirectoryLocator64.cs @@ -1,29 +1,32 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.PKZIP { /// /// Zip64 end of central directory locator /// /// + [StructLayout(LayoutKind.Sequential)] public class EndOfCentralDirectoryLocator64 { /// /// ZIP64 end of central directory locator signature (0x07064B50) /// - public uint Signature { get; set; } + public uint Signature; /// /// Number of the disk with the start of the end of central directory /// - public uint StartDiskNumber { get; set; } + public uint StartDiskNumber; /// /// Relative offset of start of central directory record /// - public ulong CentralDirectoryOffset { get; set; } + public ulong CentralDirectoryOffset; /// /// Total number of disks /// - public uint TotalDisks { get; set; } + public uint TotalDisks; } } \ No newline at end of file diff --git a/PlayStation3/SFB.cs b/PlayStation3/SFB.cs index 11bb858..445b1b7 100644 --- a/PlayStation3/SFB.cs +++ b/PlayStation3/SFB.cs @@ -1,96 +1,110 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.PlayStation3 { /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public class SFB { /// /// ".SFB" /// - public byte[]? Magic { get; set; } + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] + public byte[]? Magic; /// /// File version(?) /// - public uint FileVersion { get; set; } + public uint FileVersion; /// /// Unknown (zeroes) /// /// 0x18 bytes - public byte[]? Reserved1 { get; set; } + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x18)] + public byte[]? Reserved1; /// /// "HYBRID_FLAG" (Flags type) /// /// 0x10 bytes - public string? FlagsType { get; set; } + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x10)] + public string? FlagsType; /// /// Disc Content Data Offset /// - public uint DiscContentDataOffset { get; set; } + public uint DiscContentDataOffset; /// /// Disc Content Data Length /// - public uint DiscContentDataLength { get; set; } + public uint DiscContentDataLength; /// /// Unknown (zeroes) /// /// 0x08 bytes - public byte[]? Reserved2 { get; set; } + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x08)] + public byte[]? Reserved2; /// /// "TITLE_ID" (Disc Title Name) /// /// 0x08 bytes - public string? DiscTitleName { get; set; } + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x08)] + public string? DiscTitleName; /// /// Unknown (zeroes) /// /// 0x08 bytes - public byte[]? Reserved3 { get; set; } + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x08)] + public byte[]? Reserved3; /// /// Disc Version Data Offset /// - public uint DiscVersionDataOffset { get; set; } + public uint DiscVersionDataOffset; /// /// Disc Version Data Length /// - public uint DiscVersionDataLength { get; set; } + public uint DiscVersionDataLength; /// /// Unknown (zeroes) /// /// 0x188 bytes - public byte[]? Reserved4 { get; set; } + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x188)] + public byte[]? Reserved4; /// /// Disc Content (Hybrid Flags) /// /// 0x20 bytes - public string? DiscContent { get; set; } + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)] + public string? DiscContent; /// /// Disc Title /// /// 0x10 bytes - public string? DiscTitle { get; set; } + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x10)] + public string? DiscTitle; /// /// Disc Version /// /// 0x10 bytes - public string? DiscVersion { get; set; } + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x10)] + public string? DiscVersion; /// /// Unknown (zeroes) /// /// 0x3C0 bytes - public byte[]? Reserved5 { get; set; } + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x3C0)] + public byte[]? Reserved5; } } diff --git a/PlayStation3/SFOHeader.cs b/PlayStation3/SFOHeader.cs index 1e8a314..054111f 100644 --- a/PlayStation3/SFOHeader.cs +++ b/PlayStation3/SFOHeader.cs @@ -1,31 +1,35 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.PlayStation3 { /// + [StructLayout(LayoutKind.Sequential)] public class SFOHeader { /// /// "\0PSF" /// - public byte[]? Magic { get; set; } + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] + public byte[]? Magic; /// /// Version /// - public uint Version { get; set; } + public uint Version; /// /// Absolute start offset of key_table /// - public uint KeyTableStart { get; set; } + public uint KeyTableStart; /// /// Absolute start offset of data_table /// - public uint DataTableStart { get; set; } + public uint DataTableStart; /// /// Number of entries in index_table, key_table, and data_table /// - public uint TablesEntries { get; set; } + public uint TablesEntries; } } diff --git a/PlayStation3/SFOIndexTableEntry.cs b/PlayStation3/SFOIndexTableEntry.cs index f4b6e9d..71a0794 100644 --- a/PlayStation3/SFOIndexTableEntry.cs +++ b/PlayStation3/SFOIndexTableEntry.cs @@ -1,33 +1,37 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.PlayStation3 { /// + [StructLayout(LayoutKind.Sequential)] public class SFOIndexTableEntry { /// /// Key relative offset. /// (Absolute start offset of key) - (Absolute start offset of key_table) /// - public ushort KeyOffset { get; set; } + public ushort KeyOffset; /// /// Data type /// - public DataFormat DataFormat { get; set; } + [MarshalAs(UnmanagedType.U2)] + public DataFormat DataFormat; /// /// Data used length /// - public uint DataLength { get; set; } + public uint DataLength; /// /// Data total length. TITLE_ID is always = 16 bytes /// - public uint DataMaxLength { get; set; } + public uint DataMaxLength; /// /// Data relative offset. /// (Absolute start offset of data_1) - (Absolute start offset of data_table) /// - public uint DataOffset { get; set; } + public uint DataOffset; } } diff --git a/PortableExecutable/AcceleratorTableEntry.cs b/PortableExecutable/AcceleratorTableEntry.cs index 23f8571..2824417 100644 --- a/PortableExecutable/AcceleratorTableEntry.cs +++ b/PortableExecutable/AcceleratorTableEntry.cs @@ -1,31 +1,35 @@ -namespace SabreTools.Models.PortableExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.PortableExecutable { /// /// Describes the data in an individual accelerator table resource. The structure definition /// provided here is for explanation only; it is not present in any standard header file. /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class AcceleratorTableEntry { /// /// Describes keyboard accelerator characteristics. /// - public AcceleratorTableFlags Flags { get; set; } + [MarshalAs(UnmanagedType.U2)] + public AcceleratorTableFlags Flags; /// /// An ANSI character value or a virtual-key code that identifies the accelerator key. /// - public ushort Ansi { get; set; } + public ushort Ansi; /// /// An identifier for the keyboard accelerator. This is the value passed to the window /// procedure when the user presses the specified key. /// - public ushort Id { get; set; } + public ushort Id; /// /// The number of bytes inserted to ensure that the structure is aligned on a DWORD boundary. /// - public ushort Padding { get; set; } + public ushort Padding; } } diff --git a/PortableExecutable/BaseRelocationTypeOffsetFieldEntry.cs b/PortableExecutable/BaseRelocationTypeOffsetFieldEntry.cs index eef727e..95a940f 100644 --- a/PortableExecutable/BaseRelocationTypeOffsetFieldEntry.cs +++ b/PortableExecutable/BaseRelocationTypeOffsetFieldEntry.cs @@ -1,9 +1,12 @@ -namespace SabreTools.Models.PortableExecutable +using System.Runtime.InteropServices; + +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/COFFFileHeader.cs b/PortableExecutable/COFFFileHeader.cs index a283763..972a860 100644 --- a/PortableExecutable/COFFFileHeader.cs +++ b/PortableExecutable/COFFFileHeader.cs @@ -1,4 +1,6 @@ -namespace SabreTools.Models.PortableExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.PortableExecutable { /// /// At the beginning of an object file, or immediately after the signature @@ -6,48 +8,51 @@ /// Note that the Windows loader limits the number of sections to 96. /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class COFFFileHeader { /// /// The number that identifies the type of target machine. /// - public MachineType Machine { get; set; } + [MarshalAs(UnmanagedType.U2)] + public MachineType Machine; /// /// The number of sections. This indicates the size of the section table, /// which immediately follows the headers. /// - public ushort NumberOfSections { get; set; } + public ushort NumberOfSections; /// /// The low 32 bits of the number of seconds since 00:00 January 1, 1970 /// (a C run-time time_t value), which indicates when the file was created. /// - public uint TimeDateStamp { get; set; } + public uint TimeDateStamp; /// /// The file offset of the COFF symbol table, or zero if no COFF symbol table /// is present. This value should be zero for an image because COFF debugging /// information is deprecated. /// - public uint PointerToSymbolTable { get; set; } + public uint PointerToSymbolTable; /// /// The number of entries in the symbol table. This data can be used to locate /// the string table, which immediately follows the symbol table. This value /// should be zero for an image because COFF debugging information is deprecated. /// - public uint NumberOfSymbols { get; set; } + public uint NumberOfSymbols; /// /// The size of the optional header, which is required for executable files but /// not for object files. This value should be zero for an object file. /// - public ushort SizeOfOptionalHeader { get; set; } + public ushort SizeOfOptionalHeader; /// /// The flags that indicate the attributes of the file. /// - public Characteristics Characteristics { get; set; } + [MarshalAs(UnmanagedType.U2)] + public Characteristics Characteristics; } } diff --git a/PortableExecutable/COFFRelocation.cs b/PortableExecutable/COFFRelocation.cs index b7fb2eb..da1116c 100644 --- a/PortableExecutable/COFFRelocation.cs +++ b/PortableExecutable/COFFRelocation.cs @@ -1,4 +1,6 @@ -namespace SabreTools.Models.PortableExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.PortableExecutable { /// /// Object files contain COFF relocations, which specify how the section data @@ -15,6 +17,7 @@ /// specified in the section header. /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class COFFRelocation { /// @@ -24,7 +27,7 @@ /// For example, if the first byte of the section has an address of 0x10, /// the third byte has an address of 0x12. /// - public uint VirtualAddress { get; set; } + public uint VirtualAddress; /// /// A zero-based index into the symbol table. This symbol gives the address @@ -32,12 +35,13 @@ /// storage class, then the symbol's address is the address with the first /// section of the same name. /// - public uint SymbolTableIndex { get; set; } + public uint SymbolTableIndex; /// /// A value that indicates the kind of relocation that should be performed. /// Valid relocation types depend on machine type. /// - public RelocationType TypeIndicator { get; set; } + [MarshalAs(UnmanagedType.U2)] + public RelocationType TypeIndicator; } } diff --git a/PortableExecutable/DataDirectory.cs b/PortableExecutable/DataDirectory.cs index 4bf4701..db03c86 100644 --- a/PortableExecutable/DataDirectory.cs +++ b/PortableExecutable/DataDirectory.cs @@ -1,4 +1,6 @@ -namespace SabreTools.Models.PortableExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.PortableExecutable { /// /// Each data directory gives the address and size of a table or string that Windows uses. @@ -9,6 +11,7 @@ /// that the sections that contain specific tables have specific names. /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class DataDirectory { /// @@ -16,11 +19,11 @@ /// is the address of the table relative to the base address of the image when /// the table is loaded. /// - public uint VirtualAddress { get; set; } + public uint VirtualAddress; /// /// The second field gives the size in bytes. /// - public uint Size { get; set; } + public uint Size; } } diff --git a/PortableExecutable/DebugDirectoryEntry.cs b/PortableExecutable/DebugDirectoryEntry.cs index e96dced..b36cc33 100644 --- a/PortableExecutable/DebugDirectoryEntry.cs +++ b/PortableExecutable/DebugDirectoryEntry.cs @@ -1,4 +1,6 @@ -namespace SabreTools.Models.PortableExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.PortableExecutable { /// /// Image files contain an optional debug directory that indicates what form @@ -17,47 +19,49 @@ /// RVA is its address. /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class DebugDirectoryEntry { /// /// Reserved, must be zero. /// - public uint Characteristics { get; set; } + public uint Characteristics; /// /// The time and date that the debug data was created. /// - public uint TimeDateStamp { get; set; } + public uint TimeDateStamp; /// /// The major version number of the debug data format. /// - public ushort MajorVersion { get; set; } + public ushort MajorVersion; /// /// The minor version number of the debug data format. /// - public ushort MinorVersion { get; set; } + public ushort MinorVersion; /// /// The format of debugging information. This field enables support /// of multiple debuggers. /// - public DebugType DebugType { get; set; } + [MarshalAs(UnmanagedType.U4)] + public DebugType DebugType; /// /// The size of the debug data (not including the debug directory itself). /// - public uint SizeOfData { get; set; } + public uint SizeOfData; /// /// The address of the debug data when loaded, relative to the image base. /// - public uint AddressOfRawData { get; set; } + public uint AddressOfRawData; /// /// The file pointer to the debug data. /// - public uint PointerToRawData { get; set; } + public uint PointerToRawData; } } diff --git a/PortableExecutable/DelayLoadDirectoryTable.cs b/PortableExecutable/DelayLoadDirectoryTable.cs index 08b295a..2a28fa6 100644 --- a/PortableExecutable/DelayLoadDirectoryTable.cs +++ b/PortableExecutable/DelayLoadDirectoryTable.cs @@ -1,4 +1,6 @@ -namespace SabreTools.Models.PortableExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.PortableExecutable { /// /// The delay-load directory table is the counterpart to the import directory @@ -6,6 +8,7 @@ /// the optional header data directories list (offset 200). /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class DelayLoadDirectoryTable { /// @@ -17,7 +20,7 @@ /// indicating the presence of new fields, or it can be used to indicate /// behaviors to the delay or unload helper functions. /// - public uint Attributes { get; set; } + public uint Attributes; /// /// The RVA of the name of the DLL to be loaded. The name resides in the @@ -27,7 +30,7 @@ /// The name of the DLL to be delay-loaded resides in the read-only data /// section of the image. It is referenced through the szName field. /// - public uint Name { get; set; } + public uint Name; /// /// The RVA of the module handle (in the data section of the image) of the DLL @@ -39,7 +42,7 @@ /// The phmod field points to the handle. The supplied delay-load helper uses /// this location to store the handle to the loaded DLL. /// - public uint ModuleHandle { get; set; } + public uint ModuleHandle; /// /// The RVA of the delay-load import address table. @@ -51,7 +54,7 @@ /// the calling loop. The function pointers are accessed by using the expression /// pINT->u1.Function. /// - public uint DelayImportAddressTable { get; set; } + public uint DelayImportAddressTable; /// /// The RVA of the delay-load name table, which contains the names of the imports @@ -63,7 +66,7 @@ /// in the IAT. They consist of the same structures as the standard INT and are /// accessed by using the expression pINT->u1.AddressOfData->Name[0]. /// - public uint DelayImportNameTable { get; set; } + public uint DelayImportNameTable; /// /// The RVA of the bound delay-load address table, if it exists. @@ -73,7 +76,7 @@ /// IMAGE_THUNK_DATA items that is used along with the timestamp field of the /// delay-load directory table by a post-process binding phase. /// - public uint BoundDelayImportTable { get; set; } + public uint BoundDelayImportTable; /// /// The RVA of the unload delay-load address table, if it exists. This is an exact @@ -89,7 +92,7 @@ /// On the unload request, the library can be freed, the *phmod cleared, and the /// UIAT written over the IAT to restore everything to its preload state. /// - public uint UnloadDelayImportTable { get; set; } + public uint UnloadDelayImportTable; /// /// The timestamp of the DLL to which this image has been bound. @@ -99,6 +102,6 @@ /// IMAGE_THUNK_DATA items that is used along with the timestamp field of the /// delay-load directory table by a post-process binding phase. /// - public uint TimeStamp { get; set; } + public uint TimeStamp; } } diff --git a/PortableExecutable/Enums.cs b/PortableExecutable/Enums.cs index 80e4aa9..ad27019 100644 --- a/PortableExecutable/Enums.cs +++ b/PortableExecutable/Enums.cs @@ -42,7 +42,7 @@ namespace SabreTools.Models.PortableExecutable LastEntry = 0x80, } - public enum BaseRelocationTypes : uint + public enum BaseRelocationTypes : ushort { /// /// The base relocation is skipped. This type can be used to pad a block. diff --git a/PortableExecutable/FixedFileInfo.cs b/PortableExecutable/FixedFileInfo.cs index 663cb18..ef51ad6 100644 --- a/PortableExecutable/FixedFileInfo.cs +++ b/PortableExecutable/FixedFileInfo.cs @@ -1,85 +1,92 @@ -namespace SabreTools.Models.PortableExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.PortableExecutable { /// /// Contains version information for a file. This information is language and /// code page independent. /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class FixedFileInfo { /// /// Contains the value 0xFEEF04BD. This is used with the szKey member of the VS_VERSIONINFO /// structure when searching a file for the FixedFileInfo structure. /// - public uint Signature { get; set; } + public uint Signature; /// /// The binary version number of this structure. The high-order word of this member contains /// the major version number, and the low-order word contains the minor version number. /// - public uint StrucVersion { get; set; } + public uint StrucVersion; /// /// The most significant 32 bits of the file's binary version number. This member is used with /// FileVersionLS to form a 64-bit value used for numeric comparisons. /// - public uint FileVersionMS { get; set; } + public uint FileVersionMS; /// /// The least significant 32 bits of the file's binary version number. This member is used with /// FileVersionMS to form a 64-bit value used for numeric comparisons. /// - public uint FileVersionLS { get; set; } + public uint FileVersionLS; /// /// The most significant 32 bits of the binary version number of the product with which this file /// was distributed. This member is used with ProductVersionLS to form a 64-bit value used for /// numeric comparisons. /// - public uint ProductVersionMS { get; set; } + public uint ProductVersionMS; /// /// The least significant 32 bits of the binary version number of the product with which this file /// was distributed. This member is used with ProductVersionMS to form a 64-bit value used for /// numeric comparisons. /// - public uint ProductVersionLS { get; set; } + public uint ProductVersionLS; /// /// Contains a bitmask that specifies the valid bits in FileFlags. A bit is valid only if it was /// defined when the file was created. /// - public uint FileFlagsMask { get; set; } + public uint FileFlagsMask; /// /// Contains a bitmask that specifies the Boolean attributes of the file. /// - public FixedFileInfoFlags FileFlags { get; set; } + [MarshalAs(UnmanagedType.U4)] + public FixedFileInfoFlags FileFlags; /// /// The operating system for which this file was designed. /// - public FixedFileInfoOS FileOS { get; set; } + [MarshalAs(UnmanagedType.U4)] + public FixedFileInfoOS FileOS; /// /// The general type of file. /// - public FixedFileInfoFileType FileType { get; set; } + [MarshalAs(UnmanagedType.U4)] + public FixedFileInfoFileType FileType; /// /// The function of the file. The possible values depend on the value of FileType. For all values /// of FileType not described in the following list, FileSubtype is zero. /// - public FixedFileInfoFileSubtype FileSubtype { get; set; } + [MarshalAs(UnmanagedType.U4)] + public FixedFileInfoFileSubtype FileSubtype; /// /// The most significant 32 bits of the file's 64-bit binary creation date and time stamp. /// - public uint FileDateMS { get; set; } + public uint FileDateMS; /// /// The least significant 32 bits of the file's 64-bit binary creation date and time stamp. /// - public uint FileDateLS { get; set; } + public uint FileDateLS; } } diff --git a/PortableExecutable/MenuHeader.cs b/PortableExecutable/MenuHeader.cs index 4a2f1f1..9a7b7fb 100644 --- a/PortableExecutable/MenuHeader.cs +++ b/PortableExecutable/MenuHeader.cs @@ -1,22 +1,25 @@ -namespace SabreTools.Models.PortableExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.PortableExecutable { /// /// Contains version information for the menu resource. The structure definition provided /// here is for explanation only; it is not present in any standard header file. /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class MenuHeader { /// /// The version number of the menu template. This member must be equal to zero to indicate /// that this is an RT_MENU created with a standard menu template. /// - public ushort Version { get; set; } + public ushort Version; /// /// The size of the menu template header. This value is zero for menus you create with a /// standard menu template. /// - public ushort HeaderSize { get; set; } + public ushort HeaderSize; } } diff --git a/PortableExecutable/MenuHeaderExtended.cs b/PortableExecutable/MenuHeaderExtended.cs index df3601d..9fbdc25 100644 --- a/PortableExecutable/MenuHeaderExtended.cs +++ b/PortableExecutable/MenuHeaderExtended.cs @@ -1,27 +1,30 @@ -namespace SabreTools.Models.PortableExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.PortableExecutable { /// /// Defines the header for 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 MenuHeaderExtended { /// /// The template version number. This member must be 1 for extended menu templates. /// - public ushort Version { get; set; } + public ushort Version; /// /// The offset to the first MENUEX_TEMPLATE_ITEM structure, relative to the end of /// this structure member. If the first item definition immediately follows the /// dwHelpId member, this member should be 4. /// - public ushort Offset { get; set; } + public ushort Offset; /// /// The help identifier of menu bar. /// - public uint HelpID { get; set; } + public uint HelpID; } } diff --git a/PortableExecutable/MessageResourceBlock.cs b/PortableExecutable/MessageResourceBlock.cs index 17d9794..94987d1 100644 --- a/PortableExecutable/MessageResourceBlock.cs +++ b/PortableExecutable/MessageResourceBlock.cs @@ -1,27 +1,30 @@ -namespace SabreTools.Models.PortableExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.PortableExecutable { /// /// Contains information about message strings with identifiers in the range indicated /// by the LowId and HighId members. /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class MessageResourceBlock { /// /// The lowest message identifier contained within this structure. /// - public uint LowId { get; set; } + public uint LowId; /// /// The highest message identifier contained within this structure. /// - public uint HighId { get; set; } + public uint HighId; /// /// The offset, in bytes, from the beginning of the MESSAGE_RESOURCE_DATA structure to the /// MESSAGE_RESOURCE_ENTRY structures in this MESSAGE_RESOURCE_BLOCK. The MESSAGE_RESOURCE_ENTRY /// structures contain the message strings. /// - public uint OffsetToEntries { get; set; } + public uint OffsetToEntries; } } diff --git a/PortableExecutable/NewHeader.cs b/PortableExecutable/NewHeader.cs index de0d522..161fae3 100644 --- a/PortableExecutable/NewHeader.cs +++ b/PortableExecutable/NewHeader.cs @@ -1,4 +1,6 @@ -namespace SabreTools.Models.PortableExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.PortableExecutable { /// /// Contains the number of icon or cursor components in a resource group. The @@ -6,23 +8,24 @@ /// in any standard header file. /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class NewHeader { /// /// Reserved; must be zero. /// - public ushort Reserved { get; set; } + public ushort Reserved; /// /// The resource type. This member must have one of the following values. /// - RES_ICON (1): Icon resource type. /// - RES_CURSOR (2): Cursor resource type. /// - public ushort ResType { get; set; } + public ushort ResType; /// /// The number of icon or cursor components in the resource group. /// - public ushort ResCount { get; set; } + public ushort ResCount; } } diff --git a/PortableExecutable/ResourceHeader.cs b/PortableExecutable/ResourceHeader.cs index 1f20f10..fc4e676 100644 --- a/PortableExecutable/ResourceHeader.cs +++ b/PortableExecutable/ResourceHeader.cs @@ -1,4 +1,6 @@ -namespace SabreTools.Models.PortableExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.PortableExecutable { /// /// Contains information about the resource header itself and the data specific to @@ -7,6 +9,7 @@ /// explanation only; it is not present in any standard header file. /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class ResourceHeader { /// @@ -14,12 +17,12 @@ /// particular resource. It does not include any file padding between this /// resource and any resource that follows it in the resource file. /// - public uint DataSize { get; set; } + public uint DataSize; /// /// The size, in bytes, of the resource header data that follows. /// - public uint HeaderSize { get; set; } + public uint HeaderSize; /// /// The resource type. The TYPE member can either be a numeric value or a @@ -32,7 +35,8 @@ /// /// Values less than 256 are reserved for system use. /// - public ResourceType ResourceType { get; set; } + [MarshalAs(UnmanagedType.U4)] + public ResourceType ResourceType; /// /// A name that identifies the particular resource. The NAME member, like the TYPE @@ -44,13 +48,13 @@ /// members because they contain WORD data. However, you may need to add a WORD of /// padding after the NAME member to align the rest of the header on DWORD boundaries. /// - public uint Name { get; set; } + public uint Name; /// /// A predefined resource data version. This will determine which version of the /// resource data the application should use. /// - public uint DataVersion { get; set; } + public uint DataVersion; /// /// A set of attribute flags that can describe the state of the resource. Modifiers @@ -62,7 +66,8 @@ /// ignored. Resources are loaded when the corresponding module is loaded, and are /// freed when the module is unloaded. /// - public MemoryFlags MemoryFlags { get; set; } + [MarshalAs(UnmanagedType.U2)] + public MemoryFlags MemoryFlags; /// /// The language for the resource or set of resources. Set the value for this member @@ -75,20 +80,20 @@ /// the strings within the resources, you will need to specify a LanguageId for each /// one. /// - public ushort LanguageId { get; set; } + public ushort LanguageId; /// /// A user-defined version number for the resource data that tools can use to read and /// write resource files. Set this value with the optional VERSION resource definition /// statement. /// - public uint Version { get; set; } + public uint Version; /// /// Specifies user-defined information about the resource that tools can use to read and /// write resource files. Set this value with the optional CHARACTERISTICS resource /// definition statement. /// - public uint Characteristics { get; set; } + public uint Characteristics; } } diff --git a/PortableExecutable/SecuROMAddDEntry.cs b/PortableExecutable/SecuROMAddDEntry.cs index 7b24556..e6e6f67 100644 --- a/PortableExecutable/SecuROMAddDEntry.cs +++ b/PortableExecutable/SecuROMAddDEntry.cs @@ -1,4 +1,6 @@ -namespace SabreTools.Models.PortableExecutable +using System.Runtime.InteropServices; + +namespace SabreTools.Models.PortableExecutable { /// /// Overlay data associated with SecuROM executables @@ -8,60 +10,62 @@ /// environment by using sample from legally obtained software that /// is protected by SecuROM. /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public sealed class SecuROMAddDEntry { /// /// Physical offset of the embedded file /// - public uint PhysicalOffset { get; set; } + public uint PhysicalOffset; /// /// Length of the embedded file /// /// The last entry seems to be 4 bytes short in 4.47.00.0039 - public uint Length { get; set; } + public uint Length; /// /// Unknown (0x08) /// /// 3149224 [3496, 48] in the sample (all 3 entries) in 4.47.00.0039 - public uint Unknown08h { get; set; } + public uint Unknown08h; /// /// Unknown (0x0C) /// /// 3147176 [1448, 48] in the sample (all 3 entries) in 4.47.00.0039 - public uint Unknown0Ch { get; set; } + public uint Unknown0Ch; /// /// Unknown (0x10) /// /// 3149224 [3496, 48] in the sample (all 3 entries) in 4.47.00.0039 - public uint Unknown10h { get; set; } + public uint Unknown10h; /// /// Unknown (0x14) /// /// 1245044 [65396, 18] in the sample (all 3 entries) in 4.47.00.0039 - public uint Unknown14h { get; set; } + public uint Unknown14h; /// /// Unknown (0x18) /// /// 4214725 [20421, 64] in the sample (all 3 entries) in 4.47.00.0039 - public uint Unknown18h { get; set; } + public uint Unknown18h; /// /// Unknown (0x1C) /// /// 2 [2, 0] in the sample (all 3 entries) in 4.47.00.0039 - public uint Unknown1Ch { get; set; } + public uint Unknown1Ch; /// /// Entry file name (null-terminated) /// /// 12 bytes long in the sample (all 3 entries) in 4.47.00.0039 - public string? FileName { get; set; } + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 12)] + public string? FileName; /// /// Unknown (0x2C) @@ -70,6 +74,6 @@ /// Offset based on consistent-sized filenames (12 bytes) in 4.47.00.0039 /// 132 [132, 0] in the sample (all 3 entries) in 4.47.00.0039 /// - public uint Unknown2Ch { get; set; } + public uint Unknown2Ch; } } diff --git a/Quantum/Header.cs b/Quantum/Header.cs index d8ce48a..14b0c4f 100644 --- a/Quantum/Header.cs +++ b/Quantum/Header.cs @@ -1,39 +1,43 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.Quantum { /// /// Quantum archive file header /// /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public class Header { /// /// Quantum signature: 0x44 0x53 /// - public string? Signature { get; set; } + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)] + public string? Signature; /// /// Quantum major version number /// - public byte MajorVersion { get; set; } + public byte MajorVersion; /// /// Quantum minor version number /// - public byte MinorVersion { get; set; } + public byte MinorVersion; /// /// Number of files within this archive /// - public ushort FileCount { get; set; } + public ushort FileCount; /// /// Table size required for decompression /// - public byte TableSize { get; set; } + public byte TableSize; /// /// Compression flags /// - public byte CompressionFlags { get; set; } + public byte CompressionFlags; } } \ No newline at end of file diff --git a/SFFS/FileEntry.cs b/SFFS/FileEntry.cs index e99dbc5..848901a 100644 --- a/SFFS/FileEntry.cs +++ b/SFFS/FileEntry.cs @@ -1,17 +1,21 @@ -namespace SabreTools.Models.SFFS +using System.Runtime.InteropServices; + +namespace SabreTools.Models.SFFS { /// + [StructLayout(LayoutKind.Sequential)] public sealed class FileEntry { /// /// MD5 hash of filename (not encrypted,) /// /// 0x10 bytes - public byte[]? FilenameMD5Hash { get; set; } + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x10)] + public byte[]? FilenameMD5Hash; /// /// Index of fileheader (encrypted with filename) /// - public ulong FileHeaderIndex { get; set; } + public ulong FileHeaderIndex; } } diff --git a/SFFS/Header.cs b/SFFS/Header.cs index 1204cd7..4675ffe 100644 --- a/SFFS/Header.cs +++ b/SFFS/Header.cs @@ -1,26 +1,29 @@ -namespace SabreTools.Models.SFFS +using System.Runtime.InteropServices; + +namespace SabreTools.Models.SFFS { /// /// Header /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class Header { /// /// "SFFS" /// - public uint Magic { get; set; } + public uint Magic; /// /// Version (0x00000001) /// - public uint Version { get; set; } + public uint Version; /// /// Number of files in the container (encrypted with application key). /// Minimal number here is usually 65h, so its not real file count /// in some cases, more like index size /// - public ulong FileCount { get; set; } + public ulong FileCount; } } diff --git a/SafeDisc/EncryptedFileEntry.cs b/SafeDisc/EncryptedFileEntry.cs index 3a7fa29..1bbc5f9 100644 --- a/SafeDisc/EncryptedFileEntry.cs +++ b/SafeDisc/EncryptedFileEntry.cs @@ -1,31 +1,33 @@ -namespace SabreTools.Models.SafeDisc +using System.Runtime.InteropServices; + +namespace SabreTools.Models.SafeDisc { /// + [StructLayout(LayoutKind.Sequential)] public class EncryptedFileEntry { /// /// 0xA8726B03 /// - public uint Signature1 { get; set; } + public uint Signature1; /// /// 0xEF01996C /// - public uint Signature2 { get; set; } + public uint Signature2; - public uint FileNumber { get; set; } + public uint FileNumber; - public uint Offset1 { get; set; } + public uint Offset1; - public uint Offset2 { get; set; } + public uint Offset2; - public uint Unknown1 { get; set; } + public uint Unknown1; - public uint Unknown2 { get; set; } + public uint Unknown2; - /// - /// 0x0D bytes - /// - public byte[]? Name { get; set; } + /// 0x0D bytes + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x0D)] + public byte[]? Name; } } diff --git a/VBSP/Lump.cs b/VBSP/Lump.cs index 745fa95..f3f51cb 100644 --- a/VBSP/Lump.cs +++ b/VBSP/Lump.cs @@ -1,20 +1,24 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.VBSP { /// + [StructLayout(LayoutKind.Sequential)] public sealed class Lump { - public uint Offset { get; set; } + public uint Offset; - public uint Length { get; set; } + public uint Length; /// /// Default to zero. /// - public uint Version { get; set; } + public uint Version; /// /// Default to (char)0, (char)0, (char)0, (char)0. /// - public char[]? FourCC { get; set; } + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] + public char[]? FourCC; } } diff --git a/VBSP/LumpHeader.cs b/VBSP/LumpHeader.cs index b235e33..a42c0ba 100644 --- a/VBSP/LumpHeader.cs +++ b/VBSP/LumpHeader.cs @@ -1,16 +1,19 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.VBSP { /// + [StructLayout(LayoutKind.Sequential)] public sealed class LumpHeader { - public int LumpOffset { get; set; } + public int LumpOffset; - public int LumpID { get; set; } + public int LumpID; - public int LumpVersion { get; set; } + public int LumpVersion; - public int LumpLength { get; set; } + public int LumpLength; - public int MapRevision { get; set; } + public int MapRevision; } } diff --git a/VPK/DirectoryEntry.cs b/VPK/DirectoryEntry.cs index f2b9949..0412469 100644 --- a/VPK/DirectoryEntry.cs +++ b/VPK/DirectoryEntry.cs @@ -1,21 +1,24 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.VPK { /// + [StructLayout(LayoutKind.Sequential)] public sealed class DirectoryEntry { - public uint CRC { get; set; } + public uint CRC; - public ushort PreloadBytes { get; set; } + public ushort PreloadBytes; - public ushort ArchiveIndex { get; set; } + public ushort ArchiveIndex; - public uint EntryOffset { get; set; } + public uint EntryOffset; - public uint EntryLength { get; set; } + public uint EntryLength; /// /// Always 0xffff. /// - public ushort Dummy0 { get; set; } + public ushort Dummy0; } } diff --git a/VPK/ExtendedHeader.cs b/VPK/ExtendedHeader.cs index 4590d44..f4f8e58 100644 --- a/VPK/ExtendedHeader.cs +++ b/VPK/ExtendedHeader.cs @@ -1,29 +1,32 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.VPK { /// /// Added in version 2. /// /// + [StructLayout(LayoutKind.Sequential)] public sealed class ExtendedHeader { /// /// Reserved /// - public uint Dummy0 { get; set; } + public uint Dummy0; /// /// Archive hash length /// - public uint ArchiveHashLength { get; set; } + public uint ArchiveHashLength; /// /// Looks like some more MD5 hashes. /// - public uint ExtraLength { get; set; } + public uint ExtraLength; /// /// Reserved /// - public uint Dummy1 { get; set; } + public uint Dummy1; } } diff --git a/VPK/Header.cs b/VPK/Header.cs index f166e0e..ccaa7ff 100644 --- a/VPK/Header.cs +++ b/VPK/Header.cs @@ -1,15 +1,18 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.VPK { /// + [StructLayout(LayoutKind.Sequential)] public sealed class Header { /// /// Always 0x55aa1234. /// - public uint Signature { get; set; } + public uint Signature; - public uint Version { get; set; } + public uint Version; - public uint DirectoryLength { get; set; } + public uint DirectoryLength; } } diff --git a/XZP/DirectoryEntry.cs b/XZP/DirectoryEntry.cs index 4066a36..3107a5d 100644 --- a/XZP/DirectoryEntry.cs +++ b/XZP/DirectoryEntry.cs @@ -1,12 +1,15 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.XZP { /// + [StructLayout(LayoutKind.Sequential)] public sealed class DirectoryEntry { - public uint FileNameCRC { get; set; } + public uint FileNameCRC; - public uint EntryLength { get; set; } + public uint EntryLength; - public uint EntryOffset { get; set; } + public uint EntryOffset; } } diff --git a/XZP/DirectoryMapping.cs b/XZP/DirectoryMapping.cs index d4657f9..93bac36 100644 --- a/XZP/DirectoryMapping.cs +++ b/XZP/DirectoryMapping.cs @@ -1,8 +1,11 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.XZP { /// + [StructLayout(LayoutKind.Sequential)] public sealed class DirectoryMapping { - public ushort PreloadDirectoryEntryIndex { get; set; } + public ushort PreloadDirectoryEntryIndex; } }