DispatchSystemControl Routine of a Battery Miniclass Driver
Battery miniclass drivers must support Windows Management Instrumentation (WMI) by providing a DispatchSystemControl routine to handle the IRP_MJ_SYSTEM_CONTROL IRP. WMI offers a consistent way for drivers to expose measurement and instrumentation data.
To perform initial processing, battery miniclass drivers use the BatteryClassSystemControl routine, which takes a WmiLibContext parameter specifying a dispatch table of functions. The routine uses the MinorFunction member of IRP_MJ_SYSTEM_CONTROL to determine the dispatch function it calls.
All drivers for battery devices must handle certain WMI queries. Battery miniclass drivers forward these WMI queries to the battery class driver instead of directly supporting them. To handle WMI queries, the miniclass driver provides a pointer to a DpWmiQueryDataBlock routine in the QueryWmiDataBlock member of WMILIB_CONTEXT. The miniclass driver is not required to handle any other type of WMI request and can set the other members of WMILIB_CONTEXT to zero if it doesn't.
In its DpWmiQueryDataBlock routine, the miniclass driver calls the BatteryClassQueryWmiDataBlock routine, allowing the battery class driver to handle the WMI query request if possible. If the battery class driver handles the WMI class GUID, it completes the IRP. Otherwise, BatteryClassQueryWmiDataBlock returns a value of STATUS_WMI_GUID_NOT_FOUND. The miniclass driver can then perform driver-specific processing and use WmiCompleteRequest to complete the request.
Battery miniclass drivers only need to call BatteryClassQueryWmiDataBlock for WMI IRP processing. In a minimal WMI handling implementation for a battery miniclass driver, if BatteryClassQueryWmiDataBlock returns STATUS_WMI_GUID_NOT_FOUND, the miniclass driver simply calls WmiCompleteRequest with a status value of STATUS_WMI_GUID_NOT_FOUND.