12.4. Open a Handle to the Kernel PlugIn

To open a handle to a Kernel PlugIn driver, WD_KernelPlugIn() (see the WinDriver PCI Low-Level API Reference) needs to be called from the user mode. This low-level function is called from WDC_KernelPlugInOpen() [B.3.15] — when it is called with the name of a Kernel PlugIn driver.

When using the high-level WDC API [B.2] you should use the following method to open a Kernel PlugIn handle:

[Tip]
To ensure that your code works correctly in all the supported configurations, use the first method described above.

The generated DriverWizard and the sample pci_diag shared library (xxx_lib.c / pci_lib.c) demonstrate how to open a handle to the Kernel PlugIn — see the generated/sample XXX_DeviceOpen()/PCI_DeviceOpen() library function (which is called from the generated/sample xxx_diag/pci_diag user-mode application).

The handle to the Kernel PlugIn driver is closed when the WD_KernelPlugInClose() function (see the WinDriver PCI Low-Level API Reference) is called from the user mode. When using the low-level WinDriver API, this function is called directly from the user-mode application. When using the high-level WDC API [B.2], the function is called automatically when calling WDC_xxxDeviceClose() (PCI [B.3.12] / ISA [B.3.13]) with a device handle that contains an open Kernel PlugIn handle. The function is also called by WinDriver as part of the application cleanup, for any identified open Kernel PlugIn handles.