4.6. lf.win.ole.ps — OLE property sets
This package provides support to work with OLE property sets. Microsoft OLE
property sets are a generic format for persisting metadata. They are commonly
used with OLE structured storage (e.g. lf.win.ole.cfb)
Several of the classes take a decoder parameter. This parameter is
used to decode (interpret) embedded strings.
Additionally, some of the classes truncate strings at the first NULL byte. Any
class that does truncate a string can only do so if a valid decoder is
available.
4.6.1. Inheritance Diagrams
4.6.1.1. Base classes
4.6.1.2. Common OLE data types
4.6.1.3. Typed Property Value (TPV) classes
4.6.2. Base Classes
-
class lf.win.ole.ps.Packet
- Base class for packet types.
-
class lf.win.ole.ps.ActivePacket
- Base class for a packet type that can read from streams/ctypes.
-
class lf.win.ole.ps.PropertyPacket
Base class for packet types associated with a property.
-
size
- The total number of bytes in the packet, including any header, value,
and padding fields.
-
value
- The represented value.
-
class lf.win.ole.ps.ValuePacket
Base class for packet types associated with the value of a property.
-
size
- The total number of bytes in the packet, including any header, value,
and padding fields.
-
value
- The represented value.
4.6.4. Special Properties
-
class lf.win.ole.ps.Dictionary
Represents a Dictionary property.
-
property_count
- A count of the number of properties in the mapping. This is a field in
the data type (i.e. not len(mapping)).
-
mapping
- A dictionary of property identifiers (keys) and names (values).
-
value
- An alias for the mapping attribute.
-
classmethod from_stream(stream, offset=None, code_page=None, decoder=None)
Creates a Dictionary object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the Dictionary property.
- offset (int) – The start of the property in stream.
- code_page (int) – The value of the CodePage property.
- decoder (codecs.codec) – An optional codec to decode the names.
|
Return type: | Dictionary
|
Returns: | The corresponding Dictionary object.
|
-
class lf.win.ole.ps.DictionaryEntry
Represents a DictionaryEntry structure (packet).
-
pid
- The property identifier
-
name
- The name associated with the property identifier.
-
value
- An alias for the name attribute.
-
classmethod from_stream(stream, offset=None, code_page=None, decoder=None)
Creates a DictionaryEntry object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the DictionaryEntry property.
- offset (int) – The start of the property in stream.
- code_page (int) – The value of the CodePage property.
- decoder (codecs.codec) – An optional codec to decode the names.
|
Return type: | DictionaryEntry
|
Returns: | The corresponding DictionaryEntry object.
|
4.6.5. Common OLE data types
-
class lf.win.ole.ps.CURRENCY
Represents a CURRENCY structure (packet).
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a CURRENCY object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the CURRENCY structure.
- offset (int) – The start of the structure in stream.
- decoder (None) – This parameter is not used.
|
Return type: | CURRENCY
|
Returns: | The corresponding CURRENCY object.
|
-
class lf.win.ole.ps.DATE
Represents a DATE structure (packet).
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a DATE object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the DATE structure.
- offset (int) – The start of the structure in stream.
- decoder (None) – This parameter is not used.
|
Return type: | DATE
|
Returns: | The corresponding DATE object.
|
-
class lf.win.ole.ps.CodePageString
Represents a CodePageString structure (packet).
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a CodePageString object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the CodePageString structure.
- offset (int) – The start of the structure in stream.
- decoder (codecs.codec) – An optional codec to decode the string.
|
Return type: | CodePageString
|
Returns: | The corresponding CodePageString object.
|
-
class lf.win.ole.ps.DECIMAL
Represents a DECIMAL structure (packet).
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a DECIMAL object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the DECIMAL structure.
- offset (int) – The start of the structure in stream.
- decoder (None) – This parameter is not used.
|
Return type: | DECIMAL
|
Returns: | The corresponding DECIMAL object.
|
-
class lf.win.ole.ps.UnicodeString
Represents a UnicodeString structure (packet).
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a UnicodeString object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the UnicodeString structure.
- offset (int) – The start of the structure in stream.
- decoder (codecs.codec) – An optional codec to decode the string.
|
Return type: | UnicodeString
|
Returns: | The corresponding UnicodeString object.
|
-
class lf.win.ole.ps.FILETIME
Represents a FILETIME structure (packet).
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a FILETIME object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the FILETIME structure.
- offset (int) – The start of the structure in stream.
- decoder (None) – This parameter is not used.
|
Return type: | FILETIME
|
Returns: | The corresponding FILETIME object.
|
-
class lf.win.ole.ps.BLOB
Represents a BLOB structure (packet).
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a BLOB object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the BLOB structure.
- offset (int) – The start of the structure in stream.
- decoder (None) – This parameter is not used.
|
Return type: | BLOB
|
Returns: | The corresponding BLOB object.
|
-
class lf.win.ole.ps.IndirectPropertyName
- Represents an IndirectPropertyName structure (packet).
-
class lf.win.ole.ps.ClipboardData
Represents a ClipboardData structure (packet).
-
format
- The format field.
-
data
- The data field.
-
value
- An alias for the data attribute.
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a ClipboardData object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the ClipboardData structure.
- offset (int) – The start of the structure in stream.
- decoder (None) – This parameter is not used.
|
Return type: | ClipboardData
|
Returns: | The corresponding ClipboardData object.
|
-
class lf.win.ole.ps.GUID
Represents a GUID structure (packet).
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a GUID object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the GUID structure.
- offset (int) – The start of the structure in stream.
- decoder (None) – This parameter is not used.
|
Return type: | GUID
|
Returns: | The corresponding GUID object.
|
-
class lf.win.ole.ps.VersionedStream
Represents a VersionedStream structure (packet).
-
version_guid
- The VersionGuid field.
-
stream_name
- The StreamName field.
-
value
- An alias for the stream_name attribute.
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a VersionedStream object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the VersionedStream structure.
- offset (int) – The start of the structure in stream.
- decoder (codecs.codec) – An optional codec to decode the stream name.
|
Return type: | VersionedStream
|
Returns: | The corresponding VersionedStream object.
|
-
class lf.win.ole.ps.HRESULT
Represents an HRESULT structure (packet).
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a HRESULT object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the HRESULT structure.
- offset (int) – The start of the structure in stream.
- decoder (None) – This parameter is not used.
|
Return type: | HRESULT
|
Returns: | The corresponding HRESULT object.
|
-
classmethod from_ctype(ctype)
Creates a HRESULT object from a ctype.
-
class lf.win.ole.ps.Array
Represents the value from a VT_ARRAY property.
-
scalar_type
- The property type contained in the array. This is an extracted value.
-
dimension_count
- The number of dimensions in the array.
-
dimensions
- A list of the (size, index_offset) attributes for each dimension.
-
value
- A flattened list of the values.
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates an Array object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the Array structure.
- offset (int) – The start of the structure in stream.
- decoder (codecs.codec) – An optional codec to decode the string properties.
|
Raises ValueError: |
| If the extracted scalar type is an invalid property
type.
|
Return type: | Array
|
Returns: | The corresponding Array object.
|
-
class lf.win.ole.ps.Vector
Represents the value from a VT_VECTOR packet.
-
scalar_count
- The number of elements in the vector.
-
value
- A list of elements in the vector.
-
classmethod from_stream(stream, scalar_type, offset=None, decoder=None)
Creates a Vector object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the Vector structure.
- scalar_type (lf.win.ole.ps.consts.PropertyType) – The type of the properties in the Vector structure.
- offset (int) – The start of the structure in stream.
- decoder (codecs.codec) – An optional codec to decode the string properties.
|
Raises ValueError: |
| If scalar_type is an invalid property type.
|
Return type: | Vector
|
Returns: | The corresponding Vector object.
|
-
class lf.win.ole.ps.Sequence
A ValuePacket that is composed of a sequence of values.
The value attribute is a list of (possibly more lists of)
the values in the sequence.
Note
This is used internally by the Array and Vector
classes to extract the individual elements.
-
classmethod from_stream(stream, ptype, count, offset=None, decoder=None)
Creates a sequence of various properties from a stream.
Note
This method will round the size up to the nearest multiple of 4.
Parameters: |
- stream (IStream) – A stream that contains the sequence.
- ptype (lf.win.ole.ps.consts.PropertyType) – The property type of the elements in the Sequence.
- count (int) – The number of elements in the sequence.
- offset (int) – The start of the structure in stream.
- decoder (codecs.codec) – An optional codec to decode string properties.
|
Raises ValueError: |
| If ptype is an invalid property type.
|
Return type: | Sequence
|
Returns: | The corresponding Sequence object.
|
-
classmethod from_factory(stream, factory, count, offset=None, decoder=None)
Creates a sequence of various properties, given a factory.
Note
It is up to the calling function to round the size up to the
nearest multiple of 4 (if necessary).
Parameters: |
- stream (IStream) – A stream that contains the sequence.
- factory (function) – A factory function to create the properties. This
function must accept the same arguments as
TypedPropertyValue.from_stream().
- count (int) – The number of elements in the sequence.
- offset (int) – The start of the structure in stream.
- decoder (codecs.codec) – An optional codec to decode string properties.
|
Return type: | Sequence
|
Returns: | The corresponding Sequence object.
|
4.6.6. Typed Property Value (TPV) classes
The following classes represent typed values of a property.
-
class lf.win.ole.ps.TypedPropertyValue
Base class for TypedPropertyValue packets.
-
type
- The property type.
-
_ctype
- A ctypes ctype used to extract the various properties.
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a TypedPropertyValue object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the structure.
- offset (int) – The start of the structure in stream.
- decoder (codecs.codec) – An optional codec, used only if the property requires a
decoder.
|
Return type: | TypedPropertyValue
|
Returns: | The corresponding TypedPropertyValue object.
|
-
class lf.win.ole.ps.VT_EMPTY
- Typed value VT_EMPTY.
-
class lf.win.ole.ps.VT_NULL
- Typed value VT_NULL.
-
class lf.win.ole.ps.VT_I2
- Typed value VT_I2.
-
class lf.win.ole.ps.VT_I4
- Typed value VT_I4.
-
class lf.win.ole.ps.VT_R4
- Typed value VT_R4.
-
class lf.win.ole.ps.VT_R8
- Typed value VT_R8.
-
class lf.win.ole.ps.VT_CY
Typed value VT_CY.
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a VT_CY object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the structure.
- offset (int) – The start of the structure in stream.
- decoder (codecs.codec) – An optional codec, used only if the property requires a
decoder.
|
Return type: | VT_CY
|
Returns: | The corresponding VT_CY object.
|
-
class lf.win.ole.ps.VT_DATE
Typed value VT_DATE.
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a VT_DATE object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the structure.
- offset (int) – The start of the structure in stream.
- decoder (codecs.codec) – An optional codec, used only if the property requires a
decoder.
|
Return type: | VT_DATE
|
Returns: | The corresponding VT_DATE object.
|
-
class lf.win.ole.ps.VT_LPSTR
Typed value VT_LPSTR.
Note
The value attribute is the value attribute from a
CodePageString object.
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a VT_LPSTR object from a stream.
Note
If a decoder is specified, then the string will be decoded and
trimmed to the first null terminator (if found).
Parameters: |
- stream (IStream) – A stream that contains the structure.
- offset (int) – The start of the structure in stream.
- decoder (codecs.codec) – An optional codec, used only if the property requires a
decoder.
|
Return type: | VT_LPSTR
|
Returns: | The corresponding VT_LPSTR object.
|
-
class lf.win.ole.ps.VT_ERROR
Typed value VT_ERROR.
Note
The value attribute is an instance of an
HRESULT class.
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a VT_ERROR object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the structure.
- offset (int) – The start of the structure in stream.
- decoder (None) – This parameter is not used.
|
Return type: | VT_ERROR
|
Returns: | The corresponding VT_ERROR object.
|
-
class lf.win.ole.ps.VT_BOOL
- Typed value VT_BOOL.
-
class lf.win.ole.ps.VT_DECIMAL
Typed value VT_DECIMAL.
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a VT_DECIMAL object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the structure.
- offset (int) – The start of the structure in stream.
- decoder (codecs.codec) – An optional codec, used only if the property requires a
decoder.
|
Return type: | VT_DECIMAL
|
Returns: | The corresponding VT_DECIMAL object.
|
-
class lf.win.ole.ps.VT_I1
- Typed value VT_I1.
-
class lf.win.ole.ps.VT_UI1
- Typed value VT_UI1.
-
class lf.win.ole.ps.VT_UI2
- Typed value VT_UI2.
-
class lf.win.ole.ps.VT_UI4
- Typed value VT_UI4.
-
class lf.win.ole.ps.VT_I8
- Typed value VT_I8.
-
class lf.win.ole.ps.VT_UI8
- Typed value VT_UI8.
-
class lf.win.ole.ps.VT_INT
- Typed value VT_INT.
-
class lf.win.ole.ps.VT_UINT
- Typed value VT_UINT.
-
class lf.win.ole.ps.VT_BSTR
Typed value VT_BSTR.
Note
The value attribute is the value attribute from a
CodePageString.
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a VT_BSTR object from a stream.
Note
If a decoder is specified, then the string will be decoded. Unlike
VT_LPSTR classes, the string is not trimmed, since it
may contain embedded NULLs.
Parameters: |
- stream (IStream) – A stream that contains the structure.
- offset (int) – The start of the structure in stream.
- decoder (codecs.codec) – An optional codec, used only if the property requires a
decoder.
|
Return type: | VT_BSTR
|
Returns: | The corresponding VT_BSTR object.
|
-
class lf.win.ole.ps.VT_LPWSTR
Typed value VT_LPWSTR.
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a VT_LPWSTR object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the structure.
- offset (int) – The start of the structure in stream.
- decoder (codecs.codec) – An optional codec, used only if the property requires a
decoder.
|
Return type: | VT_LPWSTR
|
Returns: | The corresponding VT_LPWSTR object.
|
-
class lf.win.ole.ps.VT_FILETIME
Typed value VT_FILETIME.
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a VT_FILETIME object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the structure.
- offset (int) – The start of the structure in stream.
- decoder (None) – This parameter is not used.
|
Return type: | VT_FILETIME
|
Returns: | The corresponding VT_FILETIME object.
|
-
class lf.win.ole.ps.VT_BLOB
Typed value VT_BLOB.
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a VT_BLOB object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the structure.
- offset (int) – The start of the structure in stream.
- decoder (None) – This parameter is not used.
|
Return type: | VT_BLOB
|
Returns: | The corresponding VT_BLOB object.
|
-
class lf.win.ole.ps.VT_STREAM
- Typed value VT_STREAM.
-
class lf.win.ole.ps.VT_STORAGE
- Typed value VT_STORAGE.
-
class lf.win.ole.ps.VT_STREAMED_OBJECT
- Typed value VT_STREAMED_OBJECT.
-
class lf.win.ole.ps.VT_STORED_OBJECT
- Type value
-
class lf.win.ole.ps.VT_BLOB_OBJECT
- Typed value VT_BLOB_OBJECT.
-
class lf.win.ole.ps.VT_CF
Typed value VT_CF.
-
value
- An instance of ClipboardData.
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a VT_CF object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the structure.
- offset (int) – The start of the structure in stream.
- decoder (None) – This parameter is not used.
|
Return type: | VT_CF
|
Returns: | The corresponding VT_CF object.
|
-
class lf.win.ole.ps.VT_CLSID
Typed value VT_CLSID.
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a VT_CLSID object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the structure.
- offset (int) – The start of the structure in stream.
- decoder (None) – This parameter is not used.
|
Return type: | VT_CLSID
|
Returns: | The corresponding VT_CLSID object.
|
-
class lf.win.ole.ps.VT_VERSIONED_STREAM
Typed value VT_VERSIONED_STREAM.
-
value
- An instance of a VersionedStream object.
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a VT_VERSIONED_STREAM object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the structure.
- offset (int) – The start of the structure in stream.
- decoder (codecs.codec) – An optional codec to decode string properties.
|
Return type: | VT_VERSIONED_STREAM
|
Returns: | The corresponding VT_VERSIONED_STREAM object.
|
-
class lf.win.ole.ps.VT_ARRAY
Typed value VT_ARRAY.
-
value
- An instance of an Array object.
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a VT_ARRAY object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the structure.
- offset (int) – The start of the structure in stream.
- decoder (codecs.codec) – An optional codec to decode string properties.
|
Return type: | VT_ARRAY
|
Returns: | The corresponding VT_ARRAY object.
|
-
class lf.win.ole.ps.VT_VECTOR
Typed value VT_VECTOR.
-
value
- An instance of a Vector object.
-
classmethod from_stream(stream, offset=None, decoder=None)
Creates a VT_VECTOR object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the structure.
- offset (int) – The start of the structure in stream.
- decoder (codecs.codec) – An optional codec to decode string properties.
|
Return type: | VT_VECTOR
|
Returns: | The corresponding VT_VECTOR object.
|
4.6.7. Building properties
These classes are used to build properties and property sets.
-
class lf.win.ole.ps.PropertyFactory
A class that makes properties.
-
classmethod make(stream, offset=None, decoder=None)
Makes a property object from a stream.
Parameters: |
- stream (IStream) – A stream that contains the property structure.
- offset (int) – The start of the structure in stream.
- decoder (codecs.codec) – An optional codec to decode string properties.
|
Return type: | PropertyPacket
|
Returns: | The corresponding PropertyPacket (or subclass)
object.
|
-
class lf.win.ole.ps.PropertySet
Represents a PropertySet structure (packet).
-
size
- The size in bytes of the PropertySetHeader structure.
-
pair_count
- The number of pid/offset pairs.
-
pids_offsets
- A dictionary of property identifiers and the offsets of the
corresponding properties.
-
properties
- A dictionary of property identifiers and the corresponding properties.
-
class lf.win.ole.ps.PropertySetStream
Represents a PropertySetStream structure (packet).
-
byte_order
- The byte order field.
-
version
- The version of the OLE property set.
-
sys_id
- The system identifier field.
-
clsid
- The CLSID of the associated property set(s).
-
property_set_count
- The number of property sets in the stream.
-
fmtid0
- A GUID that identifies the property set format of the first property
set. If there are no property sets, this should be None.
-
offset0
- The offset of the first property set, relative to the start of the
PropertySetStreamHeader structure. If there are no property
sets, this should be None.
-
fmtid1
- A GUID that idientifies the property set format of the second property
set. If there is only one property set, this should be None.
-
offset1
- The offset of the second property set, relative to the start of the
PropertySetStreamHeader structure. If there is only one
property set, this should be None.
-
property_set_0
- An instance of PropertySet that represents the first property
set. If there are no property sets, this should be None.
-
property_set_1
- An instance of PropertySet that represents the second property
set. If there are no property sets, this should be None.
-
class lf.win.ole.ps.Builder
Builds property set streams.
-
classmethod build(stream, offset=None, decoder=None)
Builds property set streams from a stream.
Parameters: |
- stream (IStream) – A stream that contains the property (and related)
structures.
- offset (int) – The start of the structures in stream.
- decoder (codecs.codec) – An optional codec to decode string properties. If this
value is None, one is guessed by using the CodePage
property.
|
Return type: | PropertySetStream
|
Returns: | The corresponding PropertySetStream object.
|
Builds a PropertySetStreamHeader object.
Builds a PropertySetHeader object.
Parameters: |
- stream (IStream) – A stream that contains the property set header
structure.
- offset (int) – The start of the structure in stream.
- fmtid (UUID) – The FMTID of the property set.
|
Return type: | PropertySetHeader
|
Returns: | The corresponding PropertySetHeader object.
|
-
classmethod build_properties(stream, property_set, offset=None, fmtid=None, decoder=None)
Builds a dictionary of PropertyPacket objects.
Parameters: |
- stream (IStream) – A stream that contains the property structures.
- property_set (PropertySetHeader) – A PropertySetHeader object that describes
the properties in the property set.
- offset (int) – The start of the structures in stream.
- fmtid (UUID) – The FMTID of the property set.
- decoder (codecs.codec) – A codec to decode string properties.
|
Return type: | dict
|
Returns: | A dictionary of property identifiers (keys) and the
corresponding PropertyPacket objects (values).
|