13 Commits
1.4.4 ... 1.4.7

Author SHA1 Message Date
Matt Nadareski
149a45d871 Bump version 2024-05-15 14:00:54 -04:00
Matt Nadareski
e18d8d7543 Fix menu header parsing/serialization 2024-05-15 14:00:30 -04:00
Matt Nadareski
38f0d4aef5 Bump version 2024-05-13 13:18:47 -04:00
Matt Nadareski
3959993255 Fix XMID/XeMID comments 2024-05-09 21:40:43 -04:00
Matt Nadareski
00df5bdd6e UTF-8 treated like ASCII for old .NET 2024-05-07 05:28:46 -04:00
Matt Nadareski
00c087d8e0 Add third-party expansion fields for PKZIP 2024-04-28 02:30:46 -04:00
Matt Nadareski
6bc948784a Add PKZIP appendix A and B 2024-04-28 02:02:58 -04:00
Matt Nadareski
c4f14854c2 Add extensible data field definitions 2024-04-28 01:11:27 -04:00
Matt Nadareski
adaac68898 Bump version 2024-04-24 10:04:06 -04:00
Matt Nadareski
a9bc4a2bfe Fix getopts 2024-04-24 01:35:59 -04:00
Matt Nadareski
262b91de65 32 unicode characters, 64 bytes 2024-04-24 01:25:30 -04:00
Matt Nadareski
62bd6a4bde Add a couple of constants from UnshieldSharp 2024-04-24 00:36:41 -04:00
Matt Nadareski
7f14f0c5b0 Fix encoding for DirectoryEntry 2024-04-23 21:43:17 -04:00
41 changed files with 2064 additions and 47 deletions

View File

@@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
namespace SabreTools.Models.CFB
{
/// <see href="https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-CFB/%5bMS-CFB%5d.pdf"/>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public sealed class DirectoryEntry
{
/// <summary>
@@ -19,7 +19,7 @@ namespace SabreTools.Models.CFB
/// name: '/', '\', ':', '!'.
/// </summary>
/// <remarks>64 bytes</remarks>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string? Name;
/// <summary>

View File

@@ -8,10 +8,14 @@ namespace SabreTools.Models.InstallShieldCabinet
public const uint SignatureUInt32 = 0x28635349;
public const string HEADER_SUFFIX = "hdr";
public const string CABINET_SUFFIX = "cab";
public const int COMMON_HEADER_SIZE = 20;
public const int VOLUME_HEADER_SIZE_V5 = 40;
public const int VOLUME_HEADER_SIZE_V6 = 64;
// TODO: Determine how the value "71" was chosen here

View File

@@ -0,0 +1,26 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// AS/400 Extra Field (0x0065) Attribute [APPENDIX A]
/// </summary>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class AS400ExtraFieldAttribute : ExtensibleDataField
{
/// <summary>
/// Field length including length
/// </summary>
/// <remarks>Big-endian</remarks>
public ushort FieldLength { get; set; }
/// <summary>
/// Field code
/// </summary>
public AS400ExtraFieldAttributeFieldCode FieldCode { get; set; }
/// <summary>
/// Data
/// </summary>
/// <remarks>Variable byte length based on field code</remarks>
public byte[]? Data { get; set; }
}
}

View File

@@ -0,0 +1,34 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// (per Zbynek Vyskovsky) Defines alignment of data stream of this
/// entry within the zip archive. Additionally, indicates whether the
/// compression method should be kept when re-compressing the zip file.
///
/// The purpose of this extra field is to align specific resources to
/// word or page boundaries so they can be easily mapped into memory.
///
/// The alignment field (lower 15 bits) defines the minimal alignment
/// required by the data stream. Bit 15 of alignment field indicates
/// whether the compression method of this entry can be changed when
/// recompressing the zip file. The value 0 means the compression method
/// should not be changed. The value 1 indicates the compression method
/// may be changed. The padding field contains padding to ensure the correct
/// alignment. It can be changed at any time when the offset or required
/// alignment changes. (see https://issues.apache.org/jira/browse/COMPRESS-391)
/// </summary>
/// <remarks>Header ID = 0xa11e</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class DataStreamAlignment : ExtensibleDataField
{
/// <summary>
/// Required alignment and indicator
/// </summary>
public ushort Alignment { get; set; }
/// <summary>
/// 0x00-padding
/// </summary>
public byte[]? Padding { get; set; }
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,22 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// In order to allow different programs and different types
/// of information to be stored in the 'extra' field in .ZIP
/// files, the following structure MUST be used for all
/// programs storing data in this field
/// </summary>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public abstract class ExtensibleDataField
{
/// <summary>
/// Header ID
/// </summary>
public HeaderID HeaderID { get; set; }
/// <summary>
/// Data Size
/// </summary>
public ushort DataSize { get; set; }
}
}

View File

@@ -0,0 +1,39 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// The FWKCS Contents_Signature System, used in
/// automatically identifying files independent of file name,
/// optionally adds and uses an extra field to support the
/// rapid creation of an enhanced contents_signature.
///
/// When FWKCS revises a .ZIP file central directory to add
/// this extra field for a file, it also replaces the
/// central directory entry for that file's uncompressed
/// file length with a measured value.
///
/// FWKCS provides an option to strip this extra field, if
/// present, from a .ZIP file central directory. In adding
/// this extra field, FWKCS preserves .ZIP file Authenticity
/// Verification; if stripping this extra field, FWKCS
/// preserves all versions of AV through PKZIP version 2.04g.
///
/// FWKCS, and FWKCS Contents_Signature System, are
/// trademarks of Frederick W. Kantor.
/// </summary>
/// <remarks>Header ID = 0x4b46</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class FWKCSMD5ExtraField : ExtensibleDataField
{
/// <summary>
/// "MD5"
/// </summary>
/// <remarks>3 bytes</remarks>
public byte[]? Preface { get; set; }
/// <summary>
/// Uncompressed file's MD5 hash, low byte first
/// </summary>
/// <remarks>16 bytes</remarks>
public byte[]? MD5 { get; set; }
}
}

View File

@@ -0,0 +1,54 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// Stores the UTF-8 version of the file comment as stored in the
/// central directory header. (Last Revision 20070912)
///
/// Currently Version is set to the number 1. If there is a need
/// to change this field, the version will be incremented. Changes
/// MAY NOT be backward compatible so this extra field SHOULD NOT be
/// used if the version is not recognized.
///
/// The ComCRC32 is the standard zip CRC32 checksum of the File Comment
/// field in the central directory header. This is used to verify that
/// the comment field has not changed since the Unicode Comment extra field
/// was created. This can happen if a utility changes the File Comment
/// field but does not update the UTF-8 Comment extra field. If the CRC
/// check fails, this Unicode Comment extra field SHOULD be ignored and
/// the File Comment field in the header SHOULD be used instead.
///
/// The UnicodeCom field is the UTF-8 version of the File Comment field
/// in the header. As UnicodeCom is defined to be UTF-8, no UTF-8 byte
/// order mark (BOM) is used. The length of this field is determined by
/// subtracting the size of the previous fields from TSize. If both the
/// File Name and Comment fields are UTF-8, the new General Purpose Bit
/// Flag, bit 11 (Language encoding flag (EFS)), can be used to indicate
/// both the header File Name and Comment fields are UTF-8 and, in this
/// case, the Unicode Path and Unicode Comment extra fields are not
/// needed and SHOULD NOT be created. Note that, for backward
/// compatibility, bit 11 SHOULD only be used if the native character set
/// of the paths and comments being zipped up are already in UTF-8. It is
/// expected that the same file comment storage method, either general
/// purpose bit 11 or extra fields, be used in both the Local and Central
/// Directory Header for a file.
/// </summary>
/// <remarks>Header ID = 0x6375</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class InfoZIPUnicodeCommentExtraField : ExtensibleDataField
{
/// <summary>
/// Version of this extra field, currently 1
/// </summary>
public byte Version { get; set; }
/// <summary>
/// Comment Field CRC32 Checksum
/// </summary>
public uint ComCRC32 { get; set; }
/// <summary>
/// UTF-8 version of the entry comment
/// </summary>
public string? UnicodeCom { get; set; }
}
}

View File

@@ -0,0 +1,54 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// Stores the UTF-8 version of the file name field as stored in the
/// local header and central directory header. (Last Revision 20070912)
///
/// Currently Version is set to the number 1. If there is a need
/// to change this field, the version will be incremented. Changes
/// MAY NOT be backward compatible so this extra field SHOULD NOT be
/// used if the version is not recognized.
///
/// The NameCRC32 is the standard zip CRC32 checksum of the File Name
/// field in the header. This is used to verify that the header
/// File Name field has not changed since the Unicode Path extra field
/// was created. This can happen if a utility renames the File Name but
/// does not update the UTF-8 path extra field. If the CRC check fails,
/// this UTF-8 Path Extra Field SHOULD be ignored and the File Name field
/// in the header SHOULD be used instead.
///
/// The UnicodeName is the UTF-8 version of the contents of the File Name
/// field in the header. As UnicodeName is defined to be UTF-8, no UTF-8
/// byte order mark (BOM) is used. The length of this field is determined
/// by subtracting the size of the previous fields from TSize. If both
/// the File Name and Comment fields are UTF-8, the new General Purpose
/// Bit Flag, bit 11 (Language encoding flag (EFS)), can be used to
/// indicate that both the header File Name and Comment fields are UTF-8
/// and, in this case, the Unicode Path and Unicode Comment extra fields
/// are not needed and SHOULD NOT be created. Note that, for backward
/// compatibility, bit 11 SHOULD only be used if the native character set
/// of the paths and comments being zipped up are already in UTF-8. It is
/// expected that the same file name storage method, either general
/// purpose bit 11 or extra fields, be used in both the Local and Central
/// Directory Header for a file.
/// </summary>
/// <remarks>Header ID = 0x7075</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class InfoZIPUnicodePathExtraField : ExtensibleDataField
{
/// <summary>
/// Version of this extra field, currently 1
/// </summary>
public byte Version { get; set; }
/// <summary>
/// File Name Field CRC32 Checksum
/// </summary>
public uint NameCRC32 { get; set; }
/// <summary>
/// UTF-8 version of the entry File Name
/// </summary>
public string? UnicodeName { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// The following is the layout of the Key Provider "extra" block.
/// TData is a variable length, variable content field. It holds
/// information about encryptions and/or encryption key sources.
/// Contact PKWARE for information on current TData structures.
/// Information in this "extra" block may aternatively be placed
/// within comment fields. Refer to the section in this document
/// entitled "Incorporating PKWARE Proprietary Technology into Your
/// Product" for more information.
/// </summary>
/// <remarks>Header ID = 0x0022</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class KeyProviderRecordExtraField : ExtensibleDataField
{
/// <summary>
/// Data about the key
/// </summary>
public byte[]? TData { get; set; }
}
}

21
PKZIP/MVSExtraField.cs Normal file
View File

@@ -0,0 +1,21 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// The following is the layout of the MVS "extra" block.
/// </summary>
/// <remarks>Header ID = 0x0065</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class MVSExtraField : ExtensibleDataField
{
/// <summary>
/// EBCDIC "Z390" 0xE9F3F9F0
/// or "T4MV" for TargetFour
/// </summary>
public uint ID { get; set; }
/// <summary>
/// Attribute data (see APPENDIX B)
/// </summary>
public byte[]? Var { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
namespace SabreTools.Models.PKZIP
{
/// <remarks>Header ID = 0xa220</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class MicrosoftOpenPackagingGrowthHint : ExtensibleDataField
{
/// <summary>
/// Verification signature (A028)
/// </summary>
public ushort Sig { get; set; }
/// <summary>
/// Initial padding value
/// </summary>
public ushort PadVal { get; set; }
/// <summary>
/// Filled with NULL characters
/// </summary>
public byte[]? Padding { get; set; }
}
}

36
PKZIP/NTFSExtraField.cs Normal file
View File

@@ -0,0 +1,36 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// The following is the layout of the NTFS attributes
/// "extra" block. (Note: At this time the Mtime, Atime
/// and Ctime values MAY be used on any WIN32 system.)
/// </summary>
/// <remarks>Header ID = 0x000A</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class NTFSExtraField : ExtensibleDataField
{
/// <summary>
/// Reserved for future use
/// </summary>
public uint Reserved { get; set; }
#region Tags, Interleaved
/// <summary>
/// NTFS attribute tag values
/// </summary>
public ushort[]? Tags { get; set; }
/// <summary>
/// Size of attributes, in bytes
/// </summary>
public ushort[]? Size { get; set; }
/// <summary>
/// Attribute data
/// </summary>
public byte[]? Vars { get; set; }
#endregion
}
}

36
PKZIP/OS2ExtraField.cs Normal file
View File

@@ -0,0 +1,36 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// The following is the layout of the OS/2 attributes "extra"
/// block. (Last Revision 09/05/95)
///
/// The OS/2 extended attribute structure (FEA2LIST) is
/// compressed and then stored in its entirety within this
/// structure. There will only ever be one "block" of data in
/// VarFields[].
/// </summary>
/// <remarks>Header ID = 0x0009</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class OS2ExtraField : ExtensibleDataField
{
/// <summary>
/// Uncompressed Block Size
/// </summary>
public uint BSize { get; set; }
/// <summary>
/// Compression type
/// </summary>
public ushort CType { get; set; }
/// <summary>
/// CRC value for uncompress block
/// </summary>
public uint EACRC { get; set; }
/// <summary>
/// Compressed block
/// </summary>
public byte[]? Var { get; set; }
}
}

21
PKZIP/OS400ExtraField.cs Normal file
View File

@@ -0,0 +1,21 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// The following is the layout of the OS/400 "extra" block.
/// </summary>
/// <remarks>Header ID = 0x0065</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class OS400ExtraField : ExtensibleDataField
{
/// <summary>
/// EBCDIC "Z390" 0xE9F3F9F0
/// or "T4MV" for TargetFour
/// </summary>
public uint ID { get; set; }
/// <summary>
/// Attribute data (see APPENDIX A)
/// </summary>
public byte[]? Var { get; set; }
}
}

View File

@@ -0,0 +1,50 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// The following is the layout of the OpenVMS attributes
/// "extra" block.
///
/// OpenVMS Extra Field Rules:
///
/// - There will be one or more attributes present, which
/// will each be preceded by the above TagX & SizeX values.
/// These values are identical to the ATR$C_XXXX and ATR$S_XXXX
/// constants which are defined in ATR.H under OpenVMS C. Neither
/// of these values will ever be zero.
///
/// - No word alignment or padding is performed.
///
/// - A well-behaved PKZIP/OpenVMS program SHOULD NOT produce
/// more than one sub-block with the same TagX value. Also, there MUST
/// NOT be more than one "extra" block of type 0x000c in a particular
/// directory record.
/// </summary>
/// <remarks>Header ID = 0x000C</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class OpenVMSExtraField : ExtensibleDataField
{
/// <summary>
/// 32-bit CRC for remainder of the block
/// </summary>
public uint CRC { get; set; }
#region Tags, Interleaved
/// <summary>
/// OpenVMS attribute tag values
/// </summary>
public ushort[]? Tags { get; set; }
/// <summary>
/// Size of attributes, in bytes
/// </summary>
public ushort[]? Size { get; set; }
/// <summary>
/// Attribute data
/// </summary>
public byte[]? Vars { get; set; }
#endregion
}
}

View File

@@ -0,0 +1,31 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// This field MAY contain information about each of the certificates
/// used in encryption processing and it can be used to identify who is
/// allowed to decrypt encrypted files. This field SHOULD only appear
/// in the archive extra data record. This field is not required and
/// serves only to aid archive modifications by preserving public
/// encryption key data. Individual security requirements may dictate
/// that this data be omitted to deter information exposure.
///
/// See the section describing the Strong Encryption Specification
/// for details. Refer to the section in this document entitled
/// "Incorporating PKWARE Proprietary Technology into Your Product"
/// for more information.
/// </summary>
/// <remarks>Header ID = 0x0019</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class PKCS7EncryptionRecipientCertificateList : ExtensibleDataField
{
/// <summary>
/// Format version number - MUST be 0x0001 at this time
/// </summary>
public ushort Version { get; set; }
/// <summary>
/// PKCS#7 data blob
/// </summary>
public byte[]? CStore { get; set; }
}
}

20
PKZIP/PKCS7Store.cs Normal file
View File

@@ -0,0 +1,20 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// This field MUST contain information about each of the certificates
/// files MAY be signed with. When the Central Directory Encryption
/// feature is enabled for a ZIP file, this record will appear in
/// the Archive Extra Data Record, otherwise it will appear in the
/// first central directory record and will be ignored in any
/// other record.
/// </summary>
/// <remarks>Header ID = 0x0014</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class PKCS7Store : ExtensibleDataField
{
/// <summary>
/// Data about the store
/// </summary>
public byte[]? TData { get; set; }
}
}

View File

@@ -0,0 +1,50 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// The following is the layout of the Patch Descriptor
/// "extra" block.
///
/// Patch support is provided by PKPatchMaker(tm) technology
/// and is covered under U.S. Patents and Patents Pending. The use or
/// implementation in a product of certain technological aspects set
/// forth in the current APPNOTE, including those with regard to
/// strong encryption or patching requires a license from PKWARE.
/// Refer to the section in this document entitled "Incorporating
/// PKWARE Proprietary Technology into Your Product" for more
/// information.
/// </summary>
/// <remarks>Header ID = 0x000F</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class PatchDescriptorExtraField : ExtensibleDataField
{
/// <summary>
/// Version of the descriptor
/// </summary>
public ushort Version { get; set; }
/// <summary>
/// Actions and reactions
/// </summary>
public ActionsReactions Flags { get; set; }
/// <summary>
/// Size of the file about to be patched
/// </summary>
public uint OldSize { get; set; }
/// <summary>
/// 32-bit CRC of the file to be patched
/// </summary>
public uint OldCRC { get; set; }
/// <summary>
/// Size of the resulting file
/// </summary>
public uint NewSize { get; set; }
/// <summary>
/// 32-bit CRC of the resulting file
/// </summary>
public uint NewCRC { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// The following is the layout of the Policy Decryption Key "extra" block.
/// TData is a variable length, variable content field. It holds
/// information about encryptions and/or encryption key sources.
/// Contact PKWARE for information on current TData structures.
/// Information in this "extra" block may aternatively be placed
/// within comment fields. Refer to the section in this document
/// entitled "Incorporating PKWARE Proprietary Technology into Your
/// Product" for more information.
/// </summary>
/// <remarks>Header ID = 0x0021</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class PolicyDecryptionKeyRecordExtraField : ExtensibleDataField
{
/// <summary>
/// Data about the key
/// </summary>
public byte[]? TData { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// The following is the layout of the Policy Key Data "extra" block.
/// TData is a variable length, variable content field. It holds
/// information about encryptions and/or encryption key sources.
/// Contact PKWARE for information on current TData structures.
/// Information in this "extra" block may aternatively be placed
/// within comment fields. Refer to the section in this document
/// entitled "Incorporating PKWARE Proprietary Technology into Your
/// Product" for more information.
/// </summary>
/// <remarks>Header ID = 0x0023</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class PolicyKeyDataRecordRecordExtraField : ExtensibleDataField
{
/// <summary>
/// Data about the key
/// </summary>
public byte[]? TData { get; set; }
}
}

View File

@@ -0,0 +1,26 @@
namespace SabreTools.Models.PKZIP
{
/// <remarks>Header ID = 0x0018</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class RecordManagementControls : ExtensibleDataField
{
#region Tags, Interleaved
/// <summary>
/// NTFS attribute tag values
/// </summary>
public ushort[]? Tags { get; set; }
/// <summary>
/// Size of attributes, in bytes
/// </summary>
public ushort[]? Size { get; set; }
/// <summary>
/// Attribute data
/// </summary>
public byte[]? Vars { get; set; }
#endregion
}
}

View File

@@ -0,0 +1,44 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// See the section describing the Strong Encryption Specification
/// for details. Refer to the section in this document entitled
/// "Incorporating PKWARE Proprietary Technology into Your Product"
/// for more information.
/// </summary>
/// <remarks>Header ID = 0x0017</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class StrongEncryptionHeader : ExtensibleDataField
{
/// <summary>
/// Format definition for this record
/// </summary>
public ushort Format { get; set; }
/// <summary>
/// Encryption algorithm identifier
/// </summary>
public ushort AlgID { get; set; }
/// <summary>
/// Bit length of encryption key
/// </summary>
public ushort Bitlen { get; set; }
/// <summary>
/// Processing flags
/// </summary>
public ushort Flags { get; set; }
/// <summary>
/// Certificate decryption extra field data
/// </summary>
/// <remarks>
/// Refer to the explanation for CertData
/// in the section describing the
/// Certificate Processing Method under
/// the Strong Encryption Specification
/// </remarks>
public byte[]? CertData { get; set; }
}
}

49
PKZIP/UnixExtraField.cs Normal file
View File

@@ -0,0 +1,49 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// The following is the layout of the UNIX "extra" block.
///
/// The variable length data field will contain file type
/// specific data. Currently the only values allowed are
/// the original "linked to" file names for hard or symbolic
/// links, and the major and minor device node numbers for
/// character and block device nodes. Since device nodes
/// cannot be either symbolic or hard links, only one set of
/// variable length data is stored. Link files will have the
/// name of the original file stored. This name is NOT NULL
/// terminated. Its size can be determined by checking TSize -
/// 12. Device entries will have eight bytes stored as two 4
/// byte entries (in little endian format). The first entry
/// will be the major device number, and the second the minor
/// device number.
/// </summary>
/// <remarks>Header ID = 0x000D</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class UnixExtraField : ExtensibleDataField
{
/// <summary>
/// File last access time
/// </summary>
public uint Atime { get; set; }
/// <summary>
/// File last modification time
/// </summary>
public uint Mtime { get; set; }
/// <summary>
/// File user ID
/// </summary>
public ushort Uid { get; set; }
/// <summary>
/// File group ID
/// </summary>
public ushort Gid { get; set; }
/// <summary>
/// Variable length data field
/// </summary>
public byte[]? Var { get; set; }
}
}

View File

@@ -0,0 +1,19 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// This field contains the information about which certificate in
/// the PKCS#7 store was used to sign the central directory structure.
/// When the Central Directory Encryption feature is enabled for a
/// ZIP file, this record will appear in the Archive Extra Data Record,
/// otherwise it will appear in the first central directory record.
/// </summary>
/// <remarks>Header ID = 0x0016</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class X509CentralDirectory : ExtensibleDataField
{
/// <summary>
/// Data
/// </summary>
public byte[]? TData { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// This field contains the information about which certificate in
/// the PKCS#7 store was used to sign a particular file. It also
/// contains the signature data. This field can appear multiple
/// times, but can only appear once per certificate.
/// </summary>
/// <remarks>Header ID = 0x0015</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class X509IndividualFile : ExtensibleDataField
{
/// <summary>
/// Signature Data
/// </summary>
public byte[]? TData { get; set; }
}
}

View File

@@ -0,0 +1,26 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// z/OS Extra Field (0x0065) Attribute [APPENDIX B]
/// </summary>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class ZOSExtraFieldAttribute : ExtensibleDataField
{
/// <summary>
/// Field length including length
/// </summary>
/// <remarks>Big-endian</remarks>
public ushort FieldLength { get; set; }
/// <summary>
/// Field code
/// </summary>
public ZOSExtraFieldAttributeFieldCode FieldCode { get; set; }
/// <summary>
/// Data
/// </summary>
/// <remarks>Variable byte length based on field code</remarks>
public byte[]? Data { get; set; }
}
}

View File

@@ -0,0 +1,48 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// The following is the layout of the zip64 extended
/// information "extra" block. If one of the size or
/// offset fields in the Local or Central directory
/// record is too small to hold the required data,
/// a Zip64 extended information record is created.
/// The order of the fields in the zip64 extended
/// information record is fixed, but the fields MUST
/// only appear if the corresponding Local or Central
/// directory record field is set to 0xFFFF or 0xFFFFFFFF.
///
/// This entry in the Local header MUST include BOTH original
/// and compressed file size fields. If encrypting the
/// central directory and bit 13 of the general purpose bit
/// flag is set indicating masking, the value stored in the
/// Local Header for the original file size will be zero.
/// </summary>
/// <remarks>Header ID = 0x0001</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class Zip64ExtendedInformationExtraField : ExtensibleDataField
{
/// <summary>
/// Original uncompressed file size
/// </summary>
/// <remarks>Only exists if parent entry corresponding value is max</remarks>
public ulong? OriginalSize { get; set; }
/// <summary>
/// Size of compressed data
/// </summary>
/// <remarks>Only exists if parent entry corresponding value is max</remarks>
public ulong? CompressedSize { get; set; }
/// <summary>
/// Offset of local header record
/// </summary>
/// <remarks>Only exists if parent entry corresponding value is max</remarks>
public ulong? RelativeHeaderOffset { get; set; }
/// <summary>
/// Number of the disk on which this file starts
/// </summary>
/// <remarks>Only exists if parent entry corresponding value is max</remarks>
public uint? DiskStartNumber { get; set; }
}
}

View File

@@ -0,0 +1,41 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// The following is the layout of the ZipIt extra block
/// for Macintosh. The local-header and central-header versions
/// are identical. This block MUST be present if the file is
/// stored MacBinary-encoded and it SHOULD NOT be used if the file
/// is not stored MacBinary-encoded.
/// </summary>
/// <remarks>Header ID = 0x2605</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class ZipItMacintoshExtraField : ExtensibleDataField
{
/// <summary>
/// "ZPIT" - extra-field signature
/// </summary>
public uint ExtraFieldSignature { get; set; }
/// <summary>
/// Length of FileName
/// </summary>
public byte FnLen { get; set; }
/// <summary>
/// Full Macintosh filename
/// </summary>
public string? FileName { get; set; }
/// <summary>
/// Four-byte Mac file type string
/// </summary>
/// <remarks>4 bytes</remarks>
public byte[]? FileType { get; set; }
/// <summary>
/// Four-byte Mac creator string
/// </summary>
/// <remarks>4 bytes</remarks>
public byte[]? Creator { get; set; }
}
}

View File

@@ -0,0 +1,29 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// The following is the layout of a shortened variant of the
/// ZipIt extra block for Macintosh used only for directory
/// entries. This variant is used by ZipIt 1.3.5 and newer to
/// save some optional Mac-specific information about directories.
/// The local-header and central-header versions are identical.
/// </summary>
/// <remarks>Header ID = 0x2805</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class ZipItMacintoshShortDirectoryExtraField : ExtensibleDataField
{
/// <summary>
/// "ZPIT" - extra-field signature
/// </summary>
public uint ExtraFieldSignature { get; set; }
/// <summary>
/// attributes from DInfo.frFlags, MAY be omitted
/// </summary>
public ushort? FrFlags { get; set; }
/// <summary>
/// ZipIt view flag, MAY be omitted
/// </summary>
public ZipItInternalSettings? View { get; set; }
}
}

View File

@@ -0,0 +1,41 @@
namespace SabreTools.Models.PKZIP
{
/// <summary>
/// The following is the layout of a shortened variant of the
/// ZipIt extra block for Macintosh (without "full name" entry).
/// This variant is used by ZipIt 1.3.5 and newer for entries of
/// files (not directories) that do not have a MacBinary encoded
/// file. The local-header and central-header versions are identical.
/// </summary>
/// <remarks>Header ID = 0x2705</remarks>
/// <see href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT"/>
public class ZipItMacintoshShortFileExtraField : ExtensibleDataField
{
/// <summary>
/// "ZPIT" - extra-field signature
/// </summary>
public uint ExtraFieldSignature { get; set; }
/// <summary>
/// Four-byte Mac file type string
/// </summary>
/// <remarks>4 bytes</remarks>
public byte[]? FileType { get; set; }
/// <summary>
/// Four-byte Mac creator string
/// </summary>
/// <remarks>4 bytes</remarks>
public byte[]? Creator { get; set; }
/// <summary>
/// Attributes from FInfo.frFlags, MAY be omitted
/// </summary>
public ushort? FdFlags { get; set; }
/// <summary>
/// Reserved, MAY be omitted
/// </summary>
public ushort? Reserved { get; set; }
}
}

View File

@@ -3,23 +3,10 @@
namespace SabreTools.Models.PortableExecutable
{
/// <summary>
/// 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.
/// Common base class for menu item types
/// </summary>
/// <see href="https://learn.microsoft.com/en-us/windows/win32/menurc/menuheader"/>
/// <see href="https://learn.microsoft.com/en-us/windows/win32/menurc/menuex-template-header"/>
[StructLayout(LayoutKind.Sequential)]
public sealed class MenuHeader
{
/// <summary>
/// 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.
/// </summary>
public ushort Version;
/// <summary>
/// The size of the menu template header. This value is zero for menus you create with a
/// standard menu template.
/// </summary>
public ushort HeaderSize;
}
public abstract class MenuHeader { }
}

View File

@@ -8,7 +8,7 @@ namespace SabreTools.Models.PortableExecutable
/// </summary>
/// <see href="https://learn.microsoft.com/en-us/windows/win32/menurc/menuex-template-header"/>
[StructLayout(LayoutKind.Sequential)]
public sealed class MenuHeaderExtended
public sealed class MenuHeaderExtended : MenuHeader
{
/// <summary>
/// The template version number. This member must be 1 for extended menu templates.

View File

@@ -1,9 +1,12 @@
namespace SabreTools.Models.PortableExecutable
using System.Runtime.InteropServices;
namespace SabreTools.Models.PortableExecutable
{
/// <summary>
/// Common base class for menu item types
/// </summary>
/// <see href="https://learn.microsoft.com/en-us/windows/win32/menurc/normalmenuitem"/>
/// <see href="https://learn.microsoft.com/en-us/windows/win32/menurc/popupmenuitem"/>
[StructLayout(LayoutKind.Sequential)]
public abstract class MenuItem { }
}

View File

@@ -9,32 +9,14 @@
/// <see href="https://learn.microsoft.com/en-us/windows/win32/menurc/resource-file-formats"/>
public sealed class MenuResource
{
#region Menu header
/// <summary>
/// Menu header structure
/// </summary>
public MenuHeader? MenuHeader { get; set; }
/// <summary>
/// Menu extended header structure
/// </summary>
public MenuHeaderExtended? ExtendedMenuHeader { get; set; }
#endregion
#region Menu items
/// <summary>
/// Menu items
/// </summary>
public MenuItem?[]? MenuItems { get; set; }
/// <summary>
/// Extended menu items
/// </summary>
public MenuItemExtended?[]? ExtendedMenuItems { get; set; }
#endregion
}
}

View File

@@ -0,0 +1,25 @@
using System.Runtime.InteropServices;
namespace SabreTools.Models.PortableExecutable
{
/// <summary>
/// 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.
/// </summary>
/// <see href="https://learn.microsoft.com/en-us/windows/win32/menurc/menuheader"/>
[StructLayout(LayoutKind.Sequential)]
public sealed class NormalMenuHeader: MenuHeader
{
/// <summary>
/// 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.
/// </summary>
public ushort Version;
/// <summary>
/// The size of the menu template header. This value is zero for menus you create with a
/// standard menu template.
/// </summary>
public ushort HeaderSize;
}
}

View File

@@ -31,7 +31,11 @@ namespace SabreTools.Models.PortableExecutable
/// <summary>
/// zero terminated UTF8 path and file name
/// </summary>
[MarshalAs(UnmanagedType.LPWStr)]
#if NET472_OR_GREATER || NETCOREAPP
[MarshalAs(UnmanagedType.LPUTF8Str)]
#else
[MarshalAs(UnmanagedType.LPStr)]
#endif
public string? PathAndFileName;
}
}

View File

@@ -7,7 +7,7 @@
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Version>1.4.4</Version>
<Version>1.4.7</Version>
<WarningsNotAsErrors>CS0618</WarningsNotAsErrors>
<!-- Package Properties -->

View File

@@ -7,10 +7,10 @@ namespace SabreTools.Models.Xbox
/// XGD1 XMID Format Information:
///
/// AABBBCCD
/// - AA => The two-ASCII-character publisher identifier (see GetPublisher for details)
/// - AA => The two-ASCII-character publisher identifier (see Constants.Publishers for details)
/// - BBB => Game ID
/// - CC => Version number
/// - D => Region identifier (see GetRegion for details)
/// - D => Region identifier (see Constants.Regions for details)
/// </remarks>
public class XMID
{

View File

@@ -7,13 +7,13 @@ namespace SabreTools.Models.Xbox
/// XGD2/3 XeMID Format Information:
///
/// AABCCCDDEFFGHH(IIIIIIII)
/// - AA => The two-ASCII-character publisher identifier (see GetPublisher for details)
/// - AA => The two-ASCII-character publisher identifier (see Constants.Publishers for details)
/// - B => Platform identifier; 2 indicates Xbox 360.
/// - CCC => Game ID
/// - DD => SKU number (unique per SKU of a title)
/// - E => Region identifier (see GetRegion for details)
/// - E => Region identifier (see Constants.Regions for details)
/// - FF => Base version; usually starts at 01 (can be 1 or 2 characters)
/// - G => Media type identifier (see GetMediaSubtype for details)
/// - G => Media type identifier (see Constants.MediaSubtypes for details)
/// - HH => Disc number stored in [disc number][total discs] format
/// - IIIIIIII => 8-hex-digit certification submission identifier; usually on test discs only
/// </remarks>

View File

@@ -8,7 +8,7 @@
# Optional parameters
NO_BUILD=false
while getopts "uba" OPTION
while getopts "b" OPTION
do
case $OPTION in
b)