Create a hardware notification client driver

This section provides general guidance on the development of a hardware notification client driver that utilizes the KMDF class extension provided by Microsoft.

  1. Create a file for your client driver implementation that links to Mshwnclxstub.lib and includes the headers hwn.h and hwnclx.h.

  2. Define instances of the required KMDF and hardware notification class extension callback functions. Specifically, you must implement and register these callback functions as shown in the following example code.

    DRIVER_INITIALIZE DriverEntry;
    EVT_WDF_DRIVER_DEVICE_ADD HwnClientEvtDeviceAdd;
    HWN_CLIENT_INITIALIZE_DEVICE HwnClientInitializeDevice;
    HWN_CLIENT_UNINITIALIZE_DEVICE HwnClientUnInitializeDevice;
    HWN_CLIENT_QUERY_DEVICE_INFORMATION HwnClientQueryDeviceInformation;
    HWN_CLIENT_START_DEVICE HwnClientStartDevice;
    HWN_CLIENT_STOP_DEVICE HwnClientStopDevice;
    HWN_CLIENT_SET_STATE HwnClientSetState;
    HWN_CLIENT_GET_STATE HwnClientGetState;
    
  3. Implement the DriverEntry routine, which is the client driver entry point and responsible for initialization. For the hardware notification client driver, this function should handle the following:

  4. Implement the EVT_WDF_DRIVER_DEVICE_ADD function, which is responsible for performing device initialization operations when the PnP manager reports the existence of a device. For the hardware notification client driver, this function should handle the following:

  5. Implement the defined HWN_CLIENT_INITIALIZE_DEVICE function, which is called by the class extension to prepare the hardware notification controller for use.

  6. Implement the defined HWN_CLIENT_UNINITIALIZE_DEVICE function, which is called by the class extension to uninitialize the hardware notification controller.

  7. Implement the defined HWN_CLIENT_QUERY_DEVICE_INFORMATION function, which is called by the class extension. This function is responsible for retrieving the attributes of a hardware notification component.

  8. Implement the defined HWN_CLIENT_START_DEVICE function, which is called by the class extension. This function is responsible for starting the hardware notification controller and for allocating ACPI resources for the client driver.

  9. Implement the defined HWN_CLIENT_STOP_DEVICE function, which is called by the class extension. This function is responsible for stopping the hardware notification controller and for releasing ACPI resources used by the client driver.

  10. Implement the defined HWN_CLIENT_SET_STATE, which is called by the class extension. This function is responsible for setting hardware notification component states.

  11. Implement the defined HWN_CLIENT_GET_STATE, which is called by the class extension. This function is responsible for getting the current values of the hardware notification components. When the input buffer is NULL, meaning the user did not specify the specific hardware notification state, this function should return state information for all hardware notification components.

Hardware notifications