2.3. lf.win.objects — Common Microsoft Windows objects and converters

2.3.1. Converters

These classes convert from a lf.win.ctypes object to an object from the Python standard library.

class lf.win.objects.GUIDToUUID

Converts a GUID to a UUID.

classmethod from_stream(stream, offset=None, byte_order=LITTLE_ENDIAN)

Creates a UUID object from a stream.

Parameters:
  • stream (IStream) – A stream that contains the GUID structure.
  • offset (int or None) – The start of the GUID structure in the stream.
  • byte_order (constant) – The byte order to use (from lf.dtypes)
Return type:

UUID

Returns:

The corresponding UUID object.

classmethod from_ctype(ctype)

Creates a UUID object from a ctype.

Parameter:ctype (guid_le or guid_be) – A GUID object.
Return type:UUID
Returns:The corresponding UUID object.
classmethod from_guid(data1, data2, data3, data4)

Creates a UUID object from individual GUID fields.

Parameters:
  • data1 (int) – The first 8 hexadecimal digits (32 bits).
  • data2 (int) – The first group of 4 hexadecimal digits (16 bits).
  • data3 (int) – The second group of 4 hexadecimal digits (16 bits).
  • data4 (bytes or bytearray) – The last 8 bytes.
Return type:

UUID

Returns:

The corresponding UUID object.

class lf.win.objects.CLSIDToUUID

Converts a CLSID to a UUID.

classmethod from_stream(stream, offset=None, byte_order=LITTLE_ENDIAN)

Creates a UUID object from a stream.

Parameters:
  • stream (IStream) – A stream that contains the CLSID structure.
  • offset (int or None) – The start of the CLSID structure in the stream.
  • byte_order (constant) – The byte order to use (from lf.dtypes)
Return type:

UUID

Returns:

The corresponding UUID object.

classmethod from_ctype(ctype)

Creates a UUID object from a ctype.

Parameter:ctype (clsid_le or clsid_be) – A CLSID object.
Return type:UUID
Returns:The corresponding UUID object.
class lf.win.objects.DECIMALToDecimal

Converts a DECIMAL to a Decimal.

classmethod from_stream(stream, offset=None, byte_order=LITTLE_ENDIAN)

Creates a Decimal object from a stream.

Parameters:
  • stream (IStream) – A stream that contains the DECIMAL structure.
  • offset (int or None) – The start of the DECIMAL structure in the stream.
  • byte_order (constant) – The byte order to use (from lf.dtypes)
Return type:

Decimal

Returns:

The corresponding Decimal object.

classmethod from_ctype(ctype)

Creates a Decimal object from a ctype.

Parameter:ctype (decimal_le or decimal_be) – A DECIMAL object.
Raises ValueError:
 If the DECIMAL object is invalid.
Return type:Decmial
Returns:The corresponding Decimal object.
class lf.win.objects.CURRENCYToDecimal

Converts a CURRENCY data type to a Decimal.

classmethod from_stream(stream, offset=None, byte_order=LITTLE_ENDIAN)

Creates a Decimal object from a stream.

Parameters:
  • stream (IStream) – A stream that contains the CURRENCY structure.
  • offset (int or None) – The start of the CURRENCY structure in the stream.
  • byte_order (constant) – The byte order to use (from lf.dtypes)
Return type:

Decimal

Returns:

The corresponding Decmial object.

classmethod from_int(integer)

Creates a Decimal object from an int.

Parameter:integer (int) – The value of the CURRENCY object.
Return type:Decimal
Returns:The corresponding Decimal object.

2.3.2. Value Objects

The following classes subclass lf.dtypes.ActiveStructuple to provide a Python data type not found in the standard library.

class lf.win.objects.LCID

Represents a Locale ID data type.

rsvd
The reserved field.
sort_id
The sort ID field.
lang_id
The language ID field.
classmethod from_stream(stream, offset=None, byte_order=LITTLE_ENDIAN)

Creates a LCID object from a stream.

Parameters:
  • stream (IStream) – A stream that contains the LCID structure.
  • offset (int or None) – The start of the LCID structure in the stream.
  • byte_order (constant) – The byte order to use (from lf.dtypes)
Return type:

LCID

Returns:

The extracted LCID object.

classmethod from_ctype(ctype)

Creates a LCID object from a ctype.

Parameter:ctype (lcid_le or lcid_be) – An instance of an lcid ctype.
Return type:LCID
Returns:The corresponding LCID object.
class lf.win.objects.HRESULT

Represents and HRESULT data type.

s
The severity bit.
r
The reserved bit.
c
The customer bit.
n
The NTSTATUS bit.
x
The x field.
facility
Indicates the source of the error.
code
The remaining part of the error code.
classmethod from_stream(stream, offset=None, byte_order=LITTLE_ENDIAN)

Creates a HRESULT object from a stream.

Parameters:
  • stream (IStream) – A stream that contains the HRESULT structure.
  • offset (int or None) – The start of the HRESULT structure in the stream.
  • byte_order (constant) – The byte order to use (from lf.dtypes)
Return type:

HRESULT

Returns:

The extracted HRESULT object.

classmethod from_ctype(ctype)

Creates a HRESULT object from a ctype.

Parameter:ctype (hresult_le or hresult_be) – A hresult object.
Return type:HRESULT
Returns:The corresponding HRESULT object.
classmethod from_int(hresult)

Creates a HRESULT object from an int.

Parameter:hresult (int) – The value of the HRESULT.
Return type:HRESULT
Returns:The corresponding HRESULT object.