Jungo WinDriver  
Official Documentation

◆ KP_PCI_Open()

BOOL __cdecl KP_PCI_Open ( KP_OPEN_CALL kpOpenCall,
HANDLE  hWD,
PVOID  pOpenData,
PVOID *  ppDrvContext 
)

Kernel PlugIn open function.

This function sets the rest of the Kernel PlugIn callback functions (KP_Call, KP_IntEnable, etc.) and performs any other desired initialization (such as allocating memory for the driver context and filling it with data passed from the user mode). The returned driver context (*ppDrvContext) will be passed to rest of the Kernel PlugIn callback functions.

The KP_Open callback is called when the WD_KernelPlugInOpen() function (see the WinDriver PCI Low-\Level API Reference) is called from the user mode — either directly (when using the low-level WinDriver API), or via a call to a high-level WDC function. WD_KernelPlugInOpen() is called from the WDC_KernelPlugInOpen(), and from the WDC_PciDeviceOpen() / WDC_IsaDeviceOpen() functions when they are called with the name of a valid Kernel PlugIn driver (set in the pcKPDriverName parameter).

[Note] The WDC_xxxDeviceOpen() functions cannot be used to open a handle to a 64-bit Kernel PlugIn function from a 32-bit application. For this purpose, use WDC_KernelPlugInOpen() (or the low-level WD_KernelPlugInOpen() function). The Kernel PlugIn driver can implement two types of KP_Open() callback functions — A "standard" Kernel PlugIn open function, which is used whenever a user-mode application opens a handle to a Kernel PlugIn driver, except when a 32-bit applications opens a handle to a 64-bit driver. This callback function is set in the funcOpen field of the KP_INIT structure that is passed as a parameter to KP_Init(). A function that will be used when a 32-bit user-mode application opens a handle to a 64-bit Kernel PlugIn driver. This callback function is set in the funcOpen_32_64 field of the KP_INIT structure that is passed as a parameter to KP_Init. A Kernel PlugIn driver can provide either one or both of these KP_Open() callbacks, depending on the target configuration(s).

[Note] The KP_PCI sample (WinDriver/samples/pci_diag/kp_pci/kp_pci.c) implements both types of KP_Open callbacks — KP_PCI_Open() (standard) and KP_PCI_Open_32_64() (for opening a handle to a 64-bit Kernel PlugIn from a 32-bit application). The generated DriverWizard Kernel PlugIn code always implements a standard Kernel PlugIn open function — KP_XXX_Open(). When selecting the 32-bit application for a 64-bit Kernel PlugIn DriverWizard code-generation option, the wizard also implements a KP_XXX_Open_32_64() function, for opening a handle to a 64-bit Kernel PlugIn driver from a 32-bit application.

Parameters
[in]kpOpenCallStructure to fill in the addresses of the KP_xxx callback functions
[in]hWDThe WinDriver handle that WD_KernelPlugInOpen() was called with
[in]pOpenDataPointer to data passed from user mode
[out]ppDrvContextPointer to driver context data with which the KP_Close(), KP_Call(), KP_IntEnable() and KP_Event() functions will be called. Use this to keep driver-specific information that will be shared among these callbacks.
Returns
TRUE if successful. If FALSE, the call to WD_KernelPlugInOpen() from the user mode will fail

Definition at line 154 of file kp_pci.c.