Chapter6.Kernel PlugIn User-Mode Functions

This chapter describes the user-mode functions that initiate the Kernel PlugIn operations and activate its callbacks. For a description of the high-level WDC user-mode Kernel PlugIn APIs, which can be used instead of the low-level APIs described in this chapter, and for a description of the KernelPlugIn structures and kernel-mode APIs, refer to the WinDriver PCI Manual.

6.1.WD_KernelPlugInOpen()

Purpose

Obtain a valid handle to the Kernel PlugIn.

Prototype
DWORD WD_KernelPlugInOpen(
    HANDLE hWD,
    WD_KERNEL_PLUGIN *pKernelPlugIn);
Parameters
NameTypeInput/Output
hWDHANDLEOutput
pKernelPlugInWD_KERNEL_PLUGIN*
hKernelPlugInDWORDOutput
pcDriverNamePCHARInput
pcDriverPathPCHARInput
pOpenDataPVOIDInput
Description
NameDescription
hWDHandle to WinDriver
pKernelPlugInPointer to Kernel PlugIn information structure:
hKernelPlugInReturns the handle to the Kernel PlugIn
pcDriverNameName of Kernel PlugIn to load, up to 8 characters
pcDriverPath This field should be set to NULL. WinDriver will search for the driver in the operating system's drivers/modules directory.
pOpenData Pointer to data that will be passed to the KP_Open callback in the Kernel PlugIn
Return Value

Returns WD_STATUS_SUCCESS (0) on success, or an appropriate error code otherwise[A].

Example
WD_KERNEL_PLUGIN kernelPlugIn;
BZERO(kernelPlugIn);

/* Tells WinDriver which driver to open */
kernelPlugIn.pcDriverName = "KPDriver";

HANDLE hWD = WD_Open(); /* Validate handle here */

dwStatus = WD_KernelPlugInOpen(hWD, &kernelPlugIn);
if (dwStatus)
{
    printf ("Failed opening a handle to the Kernel PlugIn. Error: 0x%x (%s)\n",
            dwStatus, Stat2Str(dwStatus));
}
else
{
   printf("Opened a handle to the Kernel PlugIn (0x%x)\n",
           kernelPlugIn.hKernelPlugIn);
}