Driver-Defined WMI Data Items

A data item in a class definition of WMI data or event block can be one of the following:

  • A basic data type such as a string or an unsigned integer.

  • An embedded class. An embedded class is used only as a data item in another class definition and is not exposed as a data block or event block.

  • A fixed-length or variable-length array of a basic data type or embedded class.

When sending a data block to WMI, a driver must align the start of the block on an 8-byte boundary. All subsequent data items in the block must be aligned on the corresponding alignment for the data type. A boolean or uint8 should be aligned on a 1-byte boundary. A sint16, uint16, or string item should be aligned on a 2-byte boundary, and so on. Arrays should be aligned based upon the base type of the array. An array of bytes should be aligned on a byte boundary, an array of uint64 should be aligned on an 8-byte boundary, and so on. An embedded class should be aligned based upon the natural alignment of the embedded class which is defined to be the largest element within the embedded class. For example, if an embedded class has a uint64, the class should be aligned on an 8-byte boundary. WMI data item alignment follows the same conventions as the /Zp8 switch on the Microsoft C compiler.

A driver writer does not necessarily have to define data items in a block other than the required items InstanceName and Active. For example, an empty event block can serve as notification that an event occurred, without additional data. Or a data block might simply enumerate instance names in response to an IRP_MN_QUERY_ALL_DATA request.

The following table lists the MOF data types that can be used to define items in a WMI data or event block. For more information about MOF data types, see the Microsoft Windows SDK.

Data type Data format Alignment (in bytes)

string

A USHORT specifying the string length in bytes, followed by the Unicode string data. The string data may optionally include a terminating 0 followed by padding. If so, the string length must include the terminating 0 and padding. Drivers can use the MaxLen qualifier to specify the maximum length in characters of the string. Drivers that specify a maximum string length can use a fixed size buffer to hold the string. If the string is strictly smaller than the size of the buffer, then the driver can pad the rest of the string with zeros.

2

boolean

A one-byte value where 0 is FALSE and any nonzero value is TRUE

1

sint8

Signed 8-bit integer

1

uint8

Unsigned 8-bit integer

1

sint16

Signed 16-bit integer

2

uint16

Unsigned 16-bit integer

2

sint32

Signed 32-bit integer

4

uint32

Unsigned 32-bit integer

4

sint64

Signed 64-bit integer

8

uint64

Unsigned 64-bit integer

8

datetime

A fixed-length 25-character Unicode string that specifies an absolute date or time interval. A datetime value has the following format:

yyyymmddhhmmss.mmmmmmsutc

where:

yyyy is the 4-digit year

mm is the 2-digit month

dd is the 2-digit day of the month

hh is the hour according to a 24-hour clock

mm is the minute

ss is the seconds

mmmmmm is the number of microseconds

s is a plus sign (+) or minus sign (-), indicating whether utc is a positive or negative offset from Universal Time Coordinates; or a colon (:), indicating that the datetime value is an interval.

utc is the offset in minutes from Universal Time Coordinates. If utc is zero (000), the datetime value is an interval.

Values must be zero-padded. Fields that are not significant can be filled with asterisks (*).

2