Edit

Using the SCSI Port WMI Library

Storage miniport drivers that function as WMI providers can use the SCSI Port WMI library to simplify the task of processing SCSI request blocks (SRBs) that contain WMI commands. The miniport driver's start I/O routine, HwScsiStartIo, passes relevant information in the WMI SRB to the SCSI Port WMI library for processing by a call to the ScsiPortWmiDispatchFunction library's dispatch routine. The miniport driver will pass the following data to the dispatch routine:

  • In the WmiLibInfo parameter: a SCSI_WMILIB_CONTEXT structure with pointers to the miniport driver's callback routines.

  • In the WMISubFunction parameter: the value in the WMISubFunction member of the SRB.

  • In the DeviceContext parameter: a pointer to the device extension.

  • In the RequestContext parameter: a request context structure of type SCSIWMI_REQUEST_CONTEXT that the SCSI Port WMI library uses to record information, such as status and the size of the data returned.

  • In the DataPath parameter: the value in the DataPath member of the SRB.

  • In the BufferSize parameter: the value in the DataTransferLength member of the SRB.

  • In the Buffer parameter: the value in the DataBuffer member of the SRB.

When the miniport driver is initialized, it must fill a SCSI_WMILIB_CONTEXT structure with pointers to the required miniport driver callback routines, and then store the structure in a miniport driver-specific storage area, such as the driver extension. Each miniport driver callback routine corresponds to a minor IRP number, as explained in How the Port Driver Processes WMI Requests. For information about how to design miniport driver callback routines, see Designing WMI Miniport Driver Callback Routines

The GuidList member of the SCSI_WMILIB_CONTEXT structure must point to an array of elements of type SCSIWMIGUIDREGINFO that contain information about the GUIDs that uniquely identify the supported WMI classes defined in the MOF file. The following code snippet illustrates the definition of an array of such elements:

SCSIWMIGUIDREGINFO GuidList[] = 
{
  {
    &HBAStatisticsGUID,  // Guid
    3,  // number of instances of this class
    0  // flags
  },
  {
    &HBAAttributesGUID, // guid
    1,  // number of instances of this class
    0  // flags
  }
};

The array contains information about the GUIDs of two WMI classes, HBAStatistics and HBAAttributes. The symbolic constants for the GUIDs were taken from a header file that was generated by compiling the MOF file that defines the two classes with the WMI tool suite (the mofcomp and wmimofck tools). For more information about how to use these tools, see Compiling a Driver's MOF File and Using wmimofck.exe.

The WMI tool suite generates the name of the symbolic constant for the GUID by concatenating a suffix of "GUID" to the name of the WMI class. For instance, for the class HBAStatistics, the tool will create a symbolic constant called HBAStatisticsGUID that represents the GUID for that class.