12.4. Create a New Kernel PlugIn Project

As indicated above [12], you can use DriverWizard to generate a new Kernel PlugIn project (and a corresponding user-mode project) for your device (recommended), or use one of the WinDriver Kernel PlugIn samples as the basis for your development.

To successfully build a Kernel PlugIn project using MS Visual Studio, the path to the project directory must not contain any spaces.

If you select to start your development with the KP_PCI sample, follow these steps:

  1. Make a copy of the WinDriver/samples/pci_diag/kp_pci directory. For example, to create a new Kernel PlugIn project called KP_MyDrv, copy WinDriver/samples/pci_diag/kp_pci to WinDriver/samples/mydrv.
  2. Change all instances of "KP_PCI" and "kp_pci", in all the Kernel PlugIn files in your new directory, to "KP_MyDrv" and "kp_mydrv" (respectively).
    The names of the KP_PCI_xxx() functions in the kp_pci.c files do not have to be changed, but the code will be clearer if you use your selected driver name in the function names.
  3. Change all occurrences of "KP_PCI" in file names to "kp_mydrv".
  4. To use the shared pci_lib library API from your Kernel PlugIn driver and user-mode application, copy the pci_lib.h and pci_lib.c files from the WinDriver/samples/pci_diag directory to your new mydrv directory. You can change the names of the library functions to use your driver's name (MyDrv) instead of "PCI", but note that in this case you will also need to modify the names in all calls to these functions from your Kernel PlugIn project and user-mode application. If you do not copy the shared library to your new project, you will need to modify the sample Kernel PlugIn code and replace all references to the PCI_xxx library APIs with alternative code.
  5. Modify the files and directory paths in the project and make files, and the #include paths in the source files, as needed (depending on the location in which you selected to save your new project directory).
  6. To use the pci_diag user-mode application, copy WinDriver/samples/pci_diag/pci_diag.c and the relevant pci_diag project, solution, or make files to your mydrv directory, rename the files (if you wish), and replace all "pci_diag" references in the files with your preferred user-mode application name. To use the solution files, also replace the references to "KP_PCI" in the files with your new Kernel PlugIn driver, e.g., "KP_MyDrv". Then modify the sample code to implement your desired driver functionality.

For a general description of the sample and generated Kernel PlugIn code and its structure, see Sections 11.6.3 and 11.6.4 (respectively).