Initializing WMI Support in Your Driver
[Applies to KMDF only]
To support WMI data blocks, a framework-based driver:
Registers the managed object format (MOF) resource names of any customized WMI data providers that are not defined in Wmicore.mof.
Creates one or more WMI instance objects to represent the data blocks it can read or write.
Optionally implements one or more event callback functions to supply the WMI data that the driver provides.
Register each WMI instance object to make it available to WMI clients.
A driver that provides a MOF file to support customized WMI data providers must call the WdfDeviceAssignMofResourceName method to register a MOF resource name before the driver creates WMI provider objects that represent the data provider.
Initialize a WMI provider configuration structure and optionally create a WMI provider object (WDFWMIPROVIDER).
- Initialize a WMI instance configuration structure and create a WMI instance object (WDFWMIINSTANCE).
The framework creates a WMI provider by default when a KMDF driver creates its first WMI instance. Therefore, if the driver requires only one WMI provider, it is not required to call the provider-creation method (WdfWmiProviderCreate). However, the driver must fill in the provider configuration structure because this structure supplies information about the provider that the framework uses when it creates the instance.
If your driver creates a single instance of each WMI data block that it supports, the driver calls WdfWmiInstanceCreate, passing both a WDF_WMI_PROVIDER_CONFIG structure and a WDF_WMI_INSTANCE_CONFIG structure. This single call both configures the single framework-provided WMI provider object and creates a WMI instance object.
Registering Provider Instances
Before WMI clients can access your driver's WMI data blocks, the driver must register its provider instances with the system's WMI service. The driver can use either of the following techniques to register a provider instance:
Set the Register member of the provider instance's WDF_WMI_INSTANCE_CONFIG structure to TRUE.
If your driver sets Register to TRUE, the framework automatically registers the instance the first time that the device enters its working (D0) state.
Call the WdfWmiInstanceRegister method.
The framework automatically deregisters each provider instance when the instance's device is removed (and before it calls the EvtDeviceSelfManagedIoCleanup event callback function). For information about the order in which the framework calls a driver's callback functions, see PnP and Power Management Scenarios.
Your driver can deregister an instance at any time by calling WdfWmiInstanceDeregister.