diff --git a/SabreTools.Models/OLE/ArrayDimension.cs b/SabreTools.Models/OLE/ArrayDimension.cs new file mode 100644 index 0000000..591ee2f --- /dev/null +++ b/SabreTools.Models/OLE/ArrayDimension.cs @@ -0,0 +1,23 @@ +namespace SabreTools.Models.OLE +{ + /// + /// The ArrayDimension packet represents the size and index offset of a dimension of an array + /// property type. + /// + /// + public class ArrayDimension + { + /// + /// An unsigned integer representing the size of the dimension. + /// + public uint Size { get; set; } + + /// + /// A signed integer representing the index offset of the dimension. For + /// example, an array dimension that is to be accessed with a 0-based index would have the value + /// zero, whereas an array dimension that is to be accessed with a 1-based index would have the + /// value 0x00000001. + /// + public int Value { get; set; } + } +} diff --git a/SabreTools.Models/OLE/ArrayHeader.cs b/SabreTools.Models/OLE/ArrayHeader.cs new file mode 100644 index 0000000..caed60b --- /dev/null +++ b/SabreTools.Models/OLE/ArrayHeader.cs @@ -0,0 +1,29 @@ +namespace SabreTools.Models.OLE +{ + /// + /// The ArrayHeader packet represents the type and dimensions of an array property type. + /// + /// + public class ArrayHeader + { + /// + /// MUST be set to the value obtained by clearing the VT_ARRAY (0x2000) bit of + /// this array property's PropertyType value. + /// + public PropertyType Type { get; set; } + + /// + /// An unsigned integer representing the number of dimensions in the array + /// property. MUST be at least 1 and at most 31. + /// + public uint NumDimensions { get; set; } + + /// + /// MUST be a sequence of ArrayDimension packets + /// + /// The number of scalar values in an array property can be calculated from the ArrayHeader packet + /// as the product of the Size fields of each of the ArrayDimension packets. + /// + public ArrayDimension[]? Dimensions { get; set; } + } +} diff --git a/SabreTools.Models/OLE/BLOB.cs b/SabreTools.Models/OLE/BLOB.cs new file mode 100644 index 0000000..70bbc39 --- /dev/null +++ b/SabreTools.Models/OLE/BLOB.cs @@ -0,0 +1,19 @@ +namespace SabreTools.Models.OLE +{ + /// + /// The BLOB packet represents binary data + /// + /// + public class BLOB + { + /// + /// The size in bytes of the field, not including padding (if any) + /// + public uint Size { get; set; } + + /// + /// MUST be an array of bytes, followed by zero padding to a multiple of 4 bytes. + /// + public byte[]? Bytes { get; set; } + } +} diff --git a/SabreTools.Models/OLE/CURRENCY.cs b/SabreTools.Models/OLE/CURRENCY.cs new file mode 100644 index 0000000..3f1a975 --- /dev/null +++ b/SabreTools.Models/OLE/CURRENCY.cs @@ -0,0 +1,15 @@ +namespace SabreTools.Models.OLE +{ + /// + /// The CURRENCY (Packet Version) packet represents a CURRENCY as specified in [MS-OAUT] + /// section 2.2.24. + /// + /// + public class CURRENCY + { + /// + /// The value of the int64 field specified in [MS-OAUT] section 2.2.24. + /// + public ulong Value { get; set; } + } +} diff --git a/SabreTools.Models/OLE/ClipboardData.cs b/SabreTools.Models/OLE/ClipboardData.cs new file mode 100644 index 0000000..aa239ca --- /dev/null +++ b/SabreTools.Models/OLE/ClipboardData.cs @@ -0,0 +1,26 @@ +namespace SabreTools.Models.OLE +{ + /// + /// The ClipboardData packet represents clipboard data + /// + /// + public class ClipboardData + { + /// + /// The total size in bytes of the and fields, + /// not including padding (if any). + /// + public uint Size { get; set; } + + /// + /// An application-specific identifier for the format of the data in the + /// field. + /// + public uint Format { get; set; } + + /// + /// MUST be an array of bytes, followed by zero padding to a multiple of 4 bytes + /// + public byte[]? Data { get; set; } + } +} diff --git a/SabreTools.Models/OLE/CodePageString.cs b/SabreTools.Models/OLE/CodePageString.cs new file mode 100644 index 0000000..8730089 --- /dev/null +++ b/SabreTools.Models/OLE/CodePageString.cs @@ -0,0 +1,33 @@ +namespace SabreTools.Models.OLE +{ + /// + /// The CodePageString packet represents a string whose encoding depends on the + /// value of the property set's CodePage property. + /// + /// + public class CodePageString + { + /// + /// The size in bytes of the field, including the null terminator, + /// but not including padding (if any). If the property set's CodePage property + /// has the value CP_WINUNICODE (0x04B0), then the value MUST be a multiple of 2 + /// + public uint Size { get; set; } + + /// + /// If is zero, this field MUST be zero bytes in length. If + /// is nonzero and the CodePage property set's CodePage property has the value CP_WINUNICODE (0x04B0), + /// then the value MUST be a null-terminated array of 16-bit Unicode characters, followed by zero + /// padding to a multiple of 4 bytes. If is nonzero and the property set's CodePage + /// property has any other value, it MUST be a null-terminated array of 8-bit characters from the code + /// page identified by the CodePage property, followed by zero padding to a multiple of 4 bytes. The + /// string represented by this field MAY contain embedded or additional trailing null characters and + /// an OLEPS implementation MUST be able to handle such strings. However, the manner in which + /// strings with embedded or additional trailing null characters are presented by the implementation + /// to an application is implementation-specific. For maximum interoperability, an OLEPS + /// implementation SHOULD NOT write strings with embedded or trailing null characters unless + /// specifically requested to do so by an application. + /// + public string? Characters { get; set; } + } +} diff --git a/SabreTools.Models/OLE/Constants.cs b/SabreTools.Models/OLE/Constants.cs new file mode 100644 index 0000000..6743352 --- /dev/null +++ b/SabreTools.Models/OLE/Constants.cs @@ -0,0 +1,90 @@ +namespace SabreTools.Models.OLE +{ + public static class Constants + { + #region Format IDs + + public const string SummaryInformationFMTIDString = "F29F85E0-4FF9-1068-AB91-08002B27B3D9"; + public static readonly GUID SummaryInformationFMTIDGUID = new() + { + Data1 = 0xF29F85E0, + Data2 = 0x4FF9, + Data3 = 0x1068, + Data4 = [0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9], + }; + + public const string DocSummaryInformationFMTIDString = "D5CDD502-2E9C-101B-9397-08002B2CF9AE"; + public static readonly GUID DocSummaryInformationFMTIDGUID = new() + { + Data1 = 0xD5CDD502, + Data2 = 0x2E9C, + Data3 = 0x101B, + Data4 = [0x93, 0x97, 0x08, 0x00, 0x2B, 0x2C, 0xF9, 0xAE], + }; + + public const string UserDefinedPropertiesFMTIDString = "D5CDD502-2E9C-101B-9397-08002B2CF9AE"; + public static readonly GUID UserDefinedPropertiesFMTIDGUID = new() + { + Data1 = 0xD5CDD502, + Data2 = 0x2E9C, + Data3 = 0x101B, + Data4 = [0x93, 0x97, 0x08, 0x00, 0x2B, 0x2C, 0xF9, 0xAE], + }; + + public const string GlobalInfoFMTIDString = "56616F00-C154-11CE-8553-00AA00A1F95B"; + public static readonly GUID GlobalInfoFMTIDGUID = new() + { + Data1 = 0x56616F00, + Data2 = 0xC154, + Data3 = 0x11CE, + Data4 = [0x85, 0x53, 0x00, 0xAA, 0x00, 0xA1, 0xF9, 0x5B], + }; + + public const string ImageContentsFMTIDString = "556616400-C154-11CE-8553-00AA00A1F95B"; + public static readonly GUID ImageContentsFMTIDGUID = new() + { + Data1 = 0x56616F00, + Data2 = 0xC154, + Data3 = 0x11CE, + Data4 = [0x85, 0x53, 0x00, 0xAA, 0x00, 0xA1, 0xF9, 0x5B], + }; + + public const string ImageInfoFMTIDString = "556616400-C154-11CE-8553-00AA00A1F95B"; + public static readonly GUID ImageInfoFMTIDGUID = new() + { + Data1 = 0x56616F00, + Data2 = 0xC154, + Data3 = 0x11CE, + Data4 = [0x85, 0x53, 0x00, 0xAA, 0x00, 0xA1, 0xF9, 0x5B], + }; + + public const string PropertyBagFMTIDString = "20001801-5DE6-11D1-8E38-00C04FB9386D"; + public static readonly GUID PropertyBagFMTIDGUID = new() + { + Data1 = 0x20001801, + Data2 = 0x5DE6, + Data3 = 0x11D1, + Data4 = [0x8E, 0x38, 0x00, 0xC0, 0x4F, 0xB9, 0x38, 0x6D], + }; + + #endregion + + #region Stream or Storage Names + + public static readonly string SummaryInformationName = (byte)0x05 + "SummaryInformation"; + + public static readonly string DocSummaryInformationName = (byte)0x05 + "DocumentSummaryInformation"; + + public static readonly string UserDefinedPropertiesName = (byte)0x05 + "DocumentSummaryInformation"; + + public static readonly string GlobalInfoName = (byte)0x05 + "GlobalInfo"; + + public static readonly string ImageContentsName = (byte)0x05 + "ImageContents"; + + public static readonly string ImageInfoName = (byte)0x05 + "ImageInfo"; + + public const string ControlStreamName = "{4c8cc155-6c1e-11d1-8e41-00c04fb9386d}"; + + #endregion + } +} \ No newline at end of file diff --git a/SabreTools.Models/OLE/ControlStream.cs b/SabreTools.Models/OLE/ControlStream.cs new file mode 100644 index 0000000..a16f091 --- /dev/null +++ b/SabreTools.Models/OLE/ControlStream.cs @@ -0,0 +1,35 @@ +namespace SabreTools.Models.OLE +{ + /// + /// A file that has one or more property sets associated with it through the alternate + /// stream binding MUST have a control stream, which is an alternate stream with the name + /// "{4c8cc155-6c1e-11d1-8e41-00c04fb9386d}". This stream MUST contain the following packet. + /// + /// + public class ControlStream + { + /// + /// MUST be set to zero, and nonzero values MUST be rejected. + /// + public ushort Reserved1 { get; set; } + + /// + /// MUST be set to zero, and MUST be ignored. + /// + public ushort Reserved2 { get; set; } + + /// + /// An application-provided value that MUST NOT be interpreted by the + /// OLEPS implementation. If the application did not provide a value, + /// it SHOULD be set to zero. + /// + public uint ApplicationState { get; set; } + + /// + /// An application-provided value that MUST NOT be interpreted by the + /// OLEPS implementation. If the application did not provide a value, + /// it SHOULD be absent. + /// + public GUID? CLSID { get; set; } + } +} diff --git a/SabreTools.Models/OLE/DATE.cs b/SabreTools.Models/OLE/DATE.cs new file mode 100644 index 0000000..4fc7ed4 --- /dev/null +++ b/SabreTools.Models/OLE/DATE.cs @@ -0,0 +1,16 @@ +namespace SabreTools.Models.OLE +{ + /// + /// The DATE (Packet Version) packet represents a DATE as specified in [MS-OAUT] + /// section 2.2.25 + /// + /// + public class DATE + { + /// + /// The value of the DATE is an 8-byte IEEE floating-point number, as specified in + /// [MS-OAUT] section 2.2.25. + /// + public ulong Value { get; set; } + } +} diff --git a/SabreTools.Models/OLE/DECIMAL.cs b/SabreTools.Models/OLE/DECIMAL.cs new file mode 100644 index 0000000..c8b6541 --- /dev/null +++ b/SabreTools.Models/OLE/DECIMAL.cs @@ -0,0 +1,35 @@ +namespace SabreTools.Models.OLE +{ + /// + /// The DECIMAL (Packet Version) packet represents a DECIMAL as specified in [MS-OAUT] section + /// 2.2.26 + /// + /// + public class DECIMAL + { + /// + /// MUST be set to zero and MUST be ignored + /// + public ushort Reserved { get; set; } + + /// + /// The value of the scale field specified in [MS-OAUT] section 2.2.26 + /// + public byte Scale { get; set; } + + /// + /// The value of the sign field specified in [MS-OAUT] section 2.2.26 + /// + public byte Sign { get; set; } + + /// + /// The value of the Hi32 field specified in [MS-OAUT] section 2.2.26 + /// + public uint Hi32 { get; set; } + + /// + /// The value of the Lo64 field specified in [MS-OAUT] section 2.2.26 + /// + public ulong Lo64 { get; set; } + } +} diff --git a/SabreTools.Models/OLE/Dictionary.cs b/SabreTools.Models/OLE/Dictionary.cs new file mode 100644 index 0000000..6480443 --- /dev/null +++ b/SabreTools.Models/OLE/Dictionary.cs @@ -0,0 +1,24 @@ +namespace SabreTools.Models.OLE +{ + /// + /// The Dictionary packet represents all mappings between property identifiers and + /// property names in a property set + /// + /// + public class Dictionary + { + /// + /// n unsigned integer representing the number of entries in the Dictionary + /// + public uint NumEntries { get; set; } + + /// + /// All Entry fields MUST be a sequence of DictionaryEntry packets. Entries are + /// not required to appear in any particular order. + /// + public DictionaryEntry[]? Entries { get; set; } + + // Padding (variable): Padding, if necessary, to a total length that is a multiple of 4 bytes. + // Padding would be after each dictionary entry + } +} diff --git a/SabreTools.Models/OLE/DictionaryEntry.cs b/SabreTools.Models/OLE/DictionaryEntry.cs new file mode 100644 index 0000000..149c2e4 --- /dev/null +++ b/SabreTools.Models/OLE/DictionaryEntry.cs @@ -0,0 +1,35 @@ +namespace SabreTools.Models.OLE +{ + /// + /// The DictionaryEntry packet represents a mapping between a property identifier and a + /// property name + /// + /// + public class DictionaryEntry + { + /// + /// An unsigned integer representing a property identifier. MUST be a valid + /// PropertyIdentifier value in the range 0x00000002 to 0x7FFFFFFF, inclusive + /// (this specifically excludes the property identifiers for any of the special + /// properties specified in section 2.18). + /// + public PropertyIdentifier PropertyIdentifier { get; set; } + + /// + /// If the property set's CodePage property has the value CP_WINUNICODE (0x04B0), + /// MUST be the length of the Name field in 16-bit Unicode characters, including + /// the null terminator but not including padding (if any). Otherwise, MUST be the + /// length of the Name field in 8-bit characters, including the null terminator. + /// + public uint Length { get; set; } + + /// + /// If the property set's CodePage property has the value CP_WINUNICODE (0x04B0), + /// MUST be a null-terminated array of 16-bit Unicode characters, followed by zero + /// padding to a multiple of 4 bytes. Otherwise, MUST be a null-terminated array of + /// 8-bit characters from the code page identified by the CodePage property and MUST + /// NOT be padded. + /// + public string? Name { get; set; } + } +} diff --git a/SabreTools.Models/OLE/Enums.cs b/SabreTools.Models/OLE/Enums.cs new file mode 100644 index 0000000..c4dae7f --- /dev/null +++ b/SabreTools.Models/OLE/Enums.cs @@ -0,0 +1,503 @@ +namespace SabreTools.Models.OLE +{ + /// + /// The PropertyIdentifier data type represents the property identifier of a property in a property set + /// + /// + /// The SummaryInformation property set format, identified by FMTID_SummaryInformation + /// ({F29F85E0-4FF9-1068-AB91-08002B27B3D9}), represents generic properties of a document. The properties + /// specific to the SummaryInformation property set are specified in the following table. Except where + /// otherwise stated, a SummaryInformation property set SHOULD have all of these properties, and SHOULD + /// NOT have any other properties, except for the special properties specified in section 2.18. + /// + /// + public enum PropertyIdentifier : uint + { + /// + /// Property identifier for the Dictionary property + /// + DICTIONARY_PROPERTY_IDENTIFIER = 0x00000000, + + /// + /// Property identifier for the CodePage property + /// + CODEPAGE_PROPERTY_IDENTIFIER = 0x00000001, + + /// + /// Property identifier for the Locale property + /// + LOCALE_PROPERTY_IDENTIFIER = 0x80000000, + + /// + /// Property identifier for the Behavior property + /// + BEHAVIOR_PROPERTY_IDENTIFIER = 0x80000003, + + #region SummaryInformation + + /// + /// The title of the document. + /// + /// VT_LPSTR + PIDSI_TITLE = 0x00000002, + + /// + /// The subject of the document. + /// + /// VT_LPSTR + PIDSI_SUBJECT = 0x00000003, + + /// + /// The author of the document. + /// + /// VT_LPSTR + PIDSI_AUTHOR = 0x00000004, + + /// + /// Keywords related to the document. + /// + /// VT_LPSTR + PIDSI_KEYWORDS = 0x00000005, + + /// + /// Comments related the document. + /// + /// VT_LPSTR + PIDSI_COMMENTS = 0x00000006, + + /// + /// The application-specific template from which the document was created. + /// + /// VT_LPSTR + PIDSI_TEMPLATE = 0x00000007, + + /// + /// The last author of the document. + /// + /// VT_LPSTR + PIDSI_LASTAUTHOR = 0x00000008, + + /// + /// An application-specific revision number for this version of the document. + /// + /// VT_LPSTR + PIDSI_REVNUMBER = 0x00000009, + + /// + /// A 64-bit unsigned integer indicating the total amount of time that + /// has been spent editing the document in 100-nanosecond + /// increments. MUST be encoded as a FILETIME by setting the + /// dwLowDataTime field to the low 32-bits and the dwHighDateTime + /// field to the high 32-bits. + /// + /// VT_FILETIME + PIDSI_EDITTIME = 0x0000000A, + + /// + /// The most recent time that the document was printed. + /// + /// VT_FILETIME + PIDSI_LASTPRINTED = 0x0000000B, + + /// + /// The time that the document was created. + /// + /// VT_FILETIME + PIDSI_CREATE_DTM = 0x0000000C, + + /// + /// The most recent time that the document was saved. + /// + /// VT_FILETIME + PIDSI_LASTSAVE_DTM = 0x0000000D, + + /// + /// The total number of pages in the document. + /// + /// VT_I4 + PIDSI_PAGECOUNT = 0x0000000E, + + /// + /// The total number of words in the document. + /// + /// VT_I4 + PIDSI_WORDCOUNT = 0x0000000F, + + /// + /// The total number of characters in the document. + /// + /// VT_I4 + PIDSI_CHARCOUNT = 0x00000010, + + /// + /// Application-specific clipboard data containing a thumbnail + /// representing the document's contents. MAY be absent. + /// + /// VT_CF + PIDSI_THUMBNAIL = 0x00000011, + + /// + /// The name of the application that was used to create the document. + /// + /// VT_LPSTR + PIDSI_APPNAME = 0x00000012, + + /// + /// A 32-bit signed integer representing a set of application-suggested + /// access control flags with the following values: + /// - 0x00000001: Password protected + /// - 0x00000002: Read-only recommended + /// - 0x00000004: Read-only enforced + /// - 0x00000008: Locked for annotations + /// + /// VT_I4 + PIDSI_DOC_SECURITY = 0x00000013, + + #endregion + } + + /// + /// The PropertyType enumeration represents the type of a property in a property set. The set of types + /// supported depends on the version of the property set, which is indicated by the Version field of the + /// PropertySetStream packet. In addition, the property types not supported in simple property sets + /// are specified as such. PropertyType is an enumeration, which MUST be one of the following values + /// + /// + public enum PropertyType : ushort + { + /// + /// Type is undefined, and the minimum property set version is 0 + /// + VT_EMPTY = 0x0000, + + /// + /// Type is null, and the minimum property set version is 0 + /// + VT_NULL = 0x0001, + + /// + /// Type is 16-bit signed integer, and the minimum property set version is 0 + /// + VT_I2 = 0x0002, + + /// + /// Type is 32-bit signed integer, and the minimum property set version is 0. + /// + VT_I4 = 0x0003, + + /// + /// Type is 4-byte (single-precision) IEEE floating-point number, and the + /// minimum property set version is 0. + /// + VT_R4 = 0x0004, + + /// + /// Type is 8-byte (double-precision) IEEE floating-point number, and the + /// minimum property set version is 0. + /// + VT_R8 = 0x0005, + + /// + /// Type is CURRENCY, and the minimum property set version is 0. + /// + VT_CY = 0x0006, + + /// + /// Type is DATE, and the minimum property set version is 0. + /// + VT_DATE = 0x0007, + + /// + /// Type is CodePageString, and the minimum property set version is 0. + /// + VT_BSTR = 0x0008, + + /// + /// Type is HRESULT, and the minimum property set version is 0. + /// + VT_ERROR = 0x000A, + + /// + /// Type is VARIANT_BOOL, and the minimum property set version is 0. + /// + VT_BOOL = 0x000B, + + /// + /// Type is DECIMAL, and the minimum property set version is 0. + /// + VT_DECIMAL = 0x000E, + + /// + /// Type is 1-byte signed integer, and the minimum property set version + /// is 1. + /// + VT_I1 = 0x0010, + + /// + /// Type is 1-byte unsigned integer, and the minimum property set version + /// is 0. + /// + VT_UI1 = 0x0011, + + /// + /// Type is 2-byte unsigned integer, and the minimum property set version + /// is 0. + /// + VT_UI2 = 0x0012, + + /// + /// Type is 4-byte unsigned integer, and the minimum property set version + /// is 0. + /// + VT_UI4 = 0x0013, + + /// + /// Type is 8-byte signed integer, and the minimum property set version + /// is 0. + /// + VT_I8 = 0x0014, + + /// + /// Type is 8-byte unsigned integer, and the minimum property set version + /// is 0. + /// + VT_UI8 = 0x0015, + + /// + /// Type is 4-byte signed integer, and the minimum property set version + /// is 1. + /// + VT_INT = 0x0016, + + /// + /// Type is 4-byte unsigned integer, and the minimum property set version + /// is 1. + /// + VT_UINT = 0x0017, + + /// + /// Type is CodePageString, and the minimum property set version is 0. + /// + VT_LPSTR = 0x001E, + + /// + /// Type is UnicodeString, and the minimum property set version is 0. + /// + VT_LPWSTR = 0x001F, + + /// + /// Type is FILETIME, and the minimum property set version is 0. + /// + VT_FILETIME = 0x0040, + + /// + /// Type is binary large object (BLOB), and the minimum property set + /// version is 0. + /// + VT_BLOB = 0x0041, + + /// + /// Type is Stream, and the minimum property set version is 0. VT_STREAM + /// is not allowed in a simple property set. + /// + VT_STREAM = 0x0042, + + /// + /// Type is Storage, and the minimum property set version is 0. VT_STORAGE + /// is not allowed in a simple property set. + /// + VT_STORAGE = 0x0043, + + /// + /// Type is Stream representing an Object in an application-specific manner, + /// and the minimum property set version is 0. VT_STREAMED_Object is not + /// allowed in a simple property set. + /// + VT_STREAMED_Object = 0x0044, + + /// + /// Type is Storage representing an Object in an application-specific manner, + /// and the minimum property set version is 0. VT_STORED_Object is not + /// allowed in a simple property set. + /// + VT_STORED_Object = 0x0045, + + /// + /// Type is BLOB representing an object in an application-specific manner. + /// The minimum property set version is 0. + /// + VT_BLOB_Object = 0x0046, + + /// + /// Type is PropertyIdentifier, and the minimum property set version is 0. + /// + VT_CF = 0x0047, + + /// + /// Type is CLSID, and the minimum property set version is 0. + /// + VT_CLSID = 0x0048, + + /// + /// Type is Stream with application-specific version GUID (VersionedStream). + /// The minimum property set version is 0. VT_VERSIONED_STREAM is not allowed + /// in a simple property set. + /// + VT_VERSIONED_STREAM = 0x0049, + + /// + /// Type is Vector, and the minimum property set version is 0 + /// + VT_VECTOR = 0x1000, + + /// + /// Type is Vector of 1-byte unsigned integers, and the minimum property set version + /// is 0. + /// + VT_VECTOR_UI1 = 0x1011, + + /// + /// Type is Vector of 2-byte unsigned integers, and the minimum property set version + /// is 0. + /// + VT_VECTOR_UI2 = 0x1012, + + /// + /// Type is Vector of 4-byte unsigned integers, and the minimum property set version + /// is 0. + /// + VT_VECTOR_UI4 = 0x1013, + + /// + /// Type is Vector of 8-byte signed integers, and the minimum property set version + /// is 0. + /// + VT_VECTOR_I8 = 0x1014, + + /// + /// Type is Vector of 8-byte unsigned integers and the minimum property set version + /// is 0. + /// + VT_VECTOR_UI8 = 0x1015, + + /// + /// Type is Vector of CodePageString, and the minimum property set version is 0. + /// + VT_VECTOR_LPSTR = 0x101E, + + /// + /// Type is Vector of UnicodeString, and the minimum property set version is 0. + /// + VT_VECTOR_LPWSTR = 0x101F, + + /// + /// Type is Vector of FILETIME, and the minimum property set version is 0. + /// + VT_VECTOR_FILETIME = 0x1040, + + /// + /// Type is Vector of PropertyIdentifier, and the minimum property set version is 0. + /// + VT_VECTOR_CF = 0x1047, + + /// + /// Type is Vector of CLSID, and the minimum property set version is 0. + /// + VT_VECTOR_CLSID = 0x1048, + + /// + /// Type is Array of 16-bit signed integers, and the minimum property set version + /// is 1. + /// + VT_ARRAY_I2 = 0x2002, + + /// + /// Type is Array of 32-bit signed integers, and the minimum property set version + /// is 1. + /// + VT_ARRAY_I4 = 0x2003, + + /// + /// Type is Array of 4-byte (single-precision) IEEE floating-point numbers, and the + /// minimum property set version is 1. + /// + VT_ARRAY_R4 = 0x2004, + + /// + /// Type is IEEE floating-point numbers, and the minimum property set version is 1. + /// + VT_ARRAY_R8 = 0x2005, + + /// + /// Type is Array of CURRENCY, and the minimum property set version is 1. + /// + VT_ARRAY_CY = 0x2006, + + /// + /// Type is Array of DATE, and the minimum property set version is 1. + /// + VT_ARRAY_DATE = 0x2007, + + /// + /// Type is Array of CodePageString, and the minimum property set version is 1. + /// + VT_ARRAY_BSTR = 0x2008, + + /// + /// Type is Array of HRESULT, and the minimum property set version is 1. + /// + VT_ARRAY_ERROR = 0x200A, + + /// + /// Type is Array of VARIANT_BOOL, and the minimum property set version is 1. + /// + VT_ARRAY_BOOL = 0x200B, + + /// + /// Type is Array of variable-typed properties, and the minimum property set + /// version is 1 + /// + VT_ARRAY_VARIANT = 0x200C, + + /// + /// Type is Array of DECIMAL, and the minimum property set version is 1 + /// + VT_ARRAY_DECIMAL = 0x200E, + + /// + /// Type is Array of 1-byte signed integers, and the minimum property set + /// version is 1 + /// + VT_ARRAY_I1 = 0x2010, + + /// + /// Type is Array of 1-byte unsigned integers, and the minimum property set + /// version is 1 + /// + VT_ARRAY_UI1 = 0x2011, + + /// + /// Type is Array of 2-byte unsigned integers, and the minimum property set + /// version is 1. + /// + VT_ARRAY_UI2 = 0x2012, + + /// + /// Type is Array of 4-byte unsigned integers, and the minimum property set + /// version is 1. + /// + VT_ARRAY_UI4 = 0x2013, + + /// + /// Type is Array of 4-byte signed integers, and the minimum property set version + /// is 1. + /// + VT_ARRAY_INT = 0x2016, + + /// + /// Type is Array of 4-byte unsigned integers, and the minimum property set version + /// is 1. + /// + VT_ARRAY_UINT = 0x2017, + } +} diff --git a/SabreTools.Models/OLE/FILETIME.cs b/SabreTools.Models/OLE/FILETIME.cs new file mode 100644 index 0000000..ab4663c --- /dev/null +++ b/SabreTools.Models/OLE/FILETIME.cs @@ -0,0 +1,19 @@ +namespace SabreTools.Models.OLE +{ + /// + /// The FILETIME (Packet Version) packet represents a FILETIME structure ([MS-DTYP] section 2.3.3 + /// + /// + public class FILETIME + { + /// + /// The value of the dwLowDateTime field specified in [MS-DTYP] section 2.3.3. + /// + public uint LowDateTime { get; set; } + + /// + /// The value of the dwHighDateTime field specified in [MS-DTYP] section 2.3.3. + /// + public uint HighDateTime { get; set; } + } +} diff --git a/SabreTools.Models/OLE/GUID.cs b/SabreTools.Models/OLE/GUID.cs new file mode 100644 index 0000000..dbf219d --- /dev/null +++ b/SabreTools.Models/OLE/GUID.cs @@ -0,0 +1,29 @@ +namespace SabreTools.Models.OLE +{ + /// + /// The GUID (Packet Version) packet represents a GUID + /// + /// + public class GUID + { + /// + /// The value of the Data1 field specified in [MS-DTYP] section 2.3.4 + /// + public uint Data1 { get; set; } + + /// + /// The value of the Data2 field specified in [MS-DTYP] section 2.3.4 + /// + public ushort Data2 { get; set; } + + /// + /// The value of the Data3 field specified in [MS-DTYP] section 2.3.4 + /// + public ushort Data3 { get; set; } + + /// + /// The value of the Data4 field specified in [MS-DTYP] section 2.3.4 + /// + public byte[]? Data4 { get; set; } + } +} diff --git a/SabreTools.Models/OLE/IndirectPropertyName.cs b/SabreTools.Models/OLE/IndirectPropertyName.cs new file mode 100644 index 0000000..c7f1689 --- /dev/null +++ b/SabreTools.Models/OLE/IndirectPropertyName.cs @@ -0,0 +1,19 @@ +namespace SabreTools.Models.OLE +{ + /// + /// The IndirectPropertyName packet represents the name of a stream or storage as used in the + /// representation of the following property types in a non-simple property set: VT_STREAM (0x0042), + /// VT_STORAGE (0x0043), VT_STREAMED_OBJECT (0x0044), VT_STORED_OBJECT (0x0044), and + /// VT_VERSIONED_STREAM (0x0049). It MUST be represented as a CodePageString, and its value MUST + /// be derived from the property identifier of the property represented according to the following + /// Augmented Backus–Naur Form (ABNF) [RFC4234] syntax. + /// + /// Indirectproperty = "prop" propertyIdentifier + /// + /// Where PropertyIdentifier is the decimal string representation of the property identifier. This property + /// identifier MUST be a valid PropertyIdentifier value and MUST NOT be the property identifier for any of + /// the special properties specified in section 2.18. + /// + /// + public class IndirectPropertyName : CodePageString { } +} diff --git a/SabreTools.Models/OLE/PropertyIdentifierAndOffset.cs b/SabreTools.Models/OLE/PropertyIdentifierAndOffset.cs new file mode 100644 index 0000000..91a93ab --- /dev/null +++ b/SabreTools.Models/OLE/PropertyIdentifierAndOffset.cs @@ -0,0 +1,23 @@ +namespace SabreTools.Models.OLE +{ + /// + /// The PropertyIdentifierAndOffset packet is used in the PropertySet packet to represent a + /// property identifier and the byte offset of the property in the PropertySet packet + /// + /// + public class PropertyIdentifierAndOffset + { + /// + /// An unsigned integer representing the property identifier of a property + /// in the property set. MUST be a valid PropertyIdentifier value. + /// + public PropertyIdentifier PropertyIdentifier { get; set; } + + /// + /// An unsigned integer representing the offset in bytes from the beginning + /// of the PropertySet packet to the beginning of the Property field for the + /// property represented. MUST be a multiple of 4 bytes. + /// + public uint Offset { get; set; } + } +} diff --git a/SabreTools.Models/OLE/PropertySet.cs b/SabreTools.Models/OLE/PropertySet.cs new file mode 100644 index 0000000..3056fbb --- /dev/null +++ b/SabreTools.Models/OLE/PropertySet.cs @@ -0,0 +1,36 @@ +namespace SabreTools.Models.OLE +{ + /// + /// The PropertySet packet represents a property set. + /// + /// + public class PropertySet + { + /// + /// MUST be the total size in bytes of the PropertySet packet + /// + public uint Size { get; set; } + + /// + /// An unsigned integer representing the number of properties in the + /// property set. + /// + public uint NumProperties { get; set; } + + /// + /// All PropertyIdentifierAndOffset fields MUST be a sequence of + /// PropertyIdentifierAndOffset packets. The sequence MUST be in order of + /// increasing value of the Offset field. Packets are not required to be + /// in any particular order with regard to the value of the PropertyIdentifier + /// field. + /// + public PropertyIdentifierAndOffset[]? PropertyIdentifierAndOffsets { get; set; } + + /// + /// Each Property field is a sequence of property values, each of which MUST + /// be represented by a TypedPropertyValue packet or a Dictionary packet in + /// the special case of the Dictionary property. + /// + public object[]? Properties { get; set; } + } +} diff --git a/SabreTools.Models/OLE/PropertySetStream.cs b/SabreTools.Models/OLE/PropertySetStream.cs new file mode 100644 index 0000000..19e44ac --- /dev/null +++ b/SabreTools.Models/OLE/PropertySetStream.cs @@ -0,0 +1,106 @@ +namespace SabreTools.Models.OLE +{ + /// + /// The PropertySetStream packet specifies the stream format for simple property + /// sets and the stream format for the CONTENTS stream in the Non-Simple Property + /// Set Storage Format. A simple property set MUST be represented by a stream + /// containing a PropertySetStream packet. + /// + /// The PropertySetStream packet usually represents exactly one property set, but + /// for historical reasons, the DocumentSummaryInfo and UserDefinedProperties + /// property sets are represented in the same stream.In this special case, a + /// PropertySetStream might represent two property sets. + /// + /// An implementation SHOULD enforce a limit on the total size of a PropertySetStream + /// packet. This limit MUST be at least 262,144 bytes, and for maximum interoperability + /// SHOULD be 2,097,152 bytes. + /// + /// + public class PropertySetStream + { + /// + /// MUST be set to 0xFFFE + /// + public ushort ByteOrder { get; set; } + + /// + /// An unsigned integer indicating the version number of the property set (or + /// property sets). MUST be 0x0000 or 0x0001. An OLEPS implementation MUST + /// accept version 0 property sets and SHOULD<5> also accept version 1 property + /// sets. This field MUST be set to 0x0001 if the property set or property sets + /// use any of the following features not supported by version 0 property sets: + /// - Property types not supported for version 0 property sets, as specified in + /// the PropertyType enumeration. + /// - The Behavior property. + /// + /// If the property set does not use any of these features, this field SHOULD be + /// set to 0x0000 for maximum interoperability. + /// + public ushort Version { get; set; } + + /// + /// An implementation-specific value that SHOULD be ignored, except possibly to + /// report this value to applications. It SHOULD NOT be interpreted by the + /// OLEPS implementation. + /// + public uint SystemIdentifier { get; set; } + + /// + /// MUST be a GUID (Packet Version) packet representing the associated CLSID of + /// the property set (or property sets). If no CLSID is provided by the + /// application, it SHOULD be set to GUID_NULL by default. + /// + public GUID? CLSID { get; set; } + + /// + /// An unsigned integer indicating the number of property sets represented by + /// this PropertySetStream structure. MUST be either 0x00000001 or 0x00000002. + /// + /// - 0x00000001: This structure contains one property set + /// - 0x00000002: This structure contains two property sets. + /// The optional fields for PropertySet 1 are present. + /// + public uint NumPropertySets { get; set; } + + /// + /// A GUID that MUST be set to the FMTID of the property set represented by the + /// field PropertySet 0. If NumPropertySets has the value 0x00000002, then this + /// GUID MUST be set to FMTID_DocSummaryInformation + /// ({D5CDD502-2E9C-101B-9397-08002B2CF9AE}). + /// + public GUID? FMTID0 { get; set; } + + /// + /// An unsigned integer that MUST be set to the offset in bytes from the beginning + /// of this PropertySetStream structure to the beginning of the field PropertySet 0. + /// + public uint Offset0 { get; set; } + + /// + /// If NumPropertySets has the value 0x00000002, it MUST be set to FMTID_UserDefinedProperties + /// ({D5CDD505-2E9C-101B-9397-08002B2CF9AE}). Otherwise, it MUST be absent. + /// + public GUID? FMTID1 { get; set; } + + /// + /// If NumPropertySets has the value 0x00000002, it MUST be set to the offset in bytes + /// from the beginning of this PropertySetStream structure to the beginning of the + /// field PropertySet 1. Otherwise, it MUST be absent. + /// + public uint? Offset1 { get; set; } + + /// + /// MUST be a PropertySet packet + /// + public PropertySet? PropertySet0 { get; set; } + + /// + /// If NumPropertySets has the value 0x00000002, it MUST be a PropertySet packet. + /// Otherwise, it MUST be absent. + /// + public PropertySet? PropertySet1 { get; set; } + + // Padding (variable): Contains additional padding added by the implementation. + // If present, padding MUST be zeroes and MUST be ignored. + } +} diff --git a/SabreTools.Models/OLE/TypedPropertyValue.cs b/SabreTools.Models/OLE/TypedPropertyValue.cs new file mode 100644 index 0000000..ebb993a --- /dev/null +++ b/SabreTools.Models/OLE/TypedPropertyValue.cs @@ -0,0 +1,27 @@ +namespace SabreTools.Models.OLE +{ + /// + /// The TypedPropertyValue structure represents the typed value of a property in a property set + /// + /// + public class TypedPropertyValue + { + /// + /// MUST be a value from the PropertyType enumeration, indicating the type of + /// property represented. + /// + public PropertyType Type { get; set; } + + /// + /// MUST be set to zero, and any nonzero value SHOULD be rejected + /// + public ushort Padding { get; set; } + + /// + /// MUST be the value of the property represented and serialized according to + /// the value of Type as follows. + /// + /// See documentation for required lengths + public byte[]? Value { get; set; } + } +} diff --git a/SabreTools.Models/OLE/UnicodeString.cs b/SabreTools.Models/OLE/UnicodeString.cs new file mode 100644 index 0000000..3779dfa --- /dev/null +++ b/SabreTools.Models/OLE/UnicodeString.cs @@ -0,0 +1,23 @@ +namespace SabreTools.Models.OLE +{ + /// + /// The UnicodeString packet represents a Unicode string. + /// + /// + public class UnicodeString + { + /// + /// The length in 16-bit Unicode characters of the field, including the null + /// terminator, but not including padding (if any). + /// + public uint Length { get; set; } + + /// + /// If is zero, this field MUST be zero bytes in length. If is + /// nonzero, this field MUST be a null-terminated array of 16-bit Unicode characters, followed by zero + /// padding to a multiple of 4 bytes. The string represented by this field SHOULD NOT contain + /// embedded or additional trailing null characters. + /// + public string? Characters { get; set; } + } +} diff --git a/SabreTools.Models/OLE/VectorHeader.cs b/SabreTools.Models/OLE/VectorHeader.cs new file mode 100644 index 0000000..1f35db9 --- /dev/null +++ b/SabreTools.Models/OLE/VectorHeader.cs @@ -0,0 +1,14 @@ +namespace SabreTools.Models.OLE +{ + /// + /// The VectorHeader packet represents the number of scalar values in a vector property type. + /// + /// + public class VectorHeader + { + /// + /// An unsigned integer indicating the number of scalar values following the header. + /// + public uint Length { get; set; } + } +} diff --git a/SabreTools.Models/OLE/VersionedStream.cs b/SabreTools.Models/OLE/VersionedStream.cs new file mode 100644 index 0000000..da8f73d --- /dev/null +++ b/SabreTools.Models/OLE/VersionedStream.cs @@ -0,0 +1,19 @@ +namespace SabreTools.Models.OLE +{ + /// + /// The VersionedStream packet represents a stream with an application-specific version GUID. + /// + /// + public class VersionedStream + { + /// + /// MUST be a GUID (Packet Version). + /// + public GUID? VersionGuid { get; set; } + + /// + /// MUST be an IndirectPropertyName. + /// + public IndirectPropertyName? StreamName { get; set; } + } +}