0

I have written a sample KMDF driver. I dont know if I did every thing right but have seen KMDF driver printing Debug message in DebugView utility - when I added this driver as new hardware. It also showed up as "Sample Device" under device manager.

Now I want to write a sample client that could call this Driver - so I can establish a connection between driver and client. I read that we need to use 'CreateFile' and 'DEviceIOControl' etc. But I am not able to get a start on it.

Can you please guide me around creating sample client to access the sample KMDF driver ?

My INF file for the driver looks like this :-

    ***My INF FILE****
; myshelldriver.INF
; Windows installation file for installing the myshelldriver driver
; Copyright (c) Microsoft Corporation All rights Reserved
;
; Installation Notes:
;
;     Using Devcon: Type "devcon install myshelldriver.inf myshelldriver" to install
;

[Version]
Signature="$WINDOWS NT$"
Class=Sample
ClassGuid={78A1C341-4539-11d3-B88D-00C04FAD5171}
Provider=%MSFT%
DriverVer=09/24/2012,1.0
CatalogFile=myshell.cat

[DestinationDirs]
DefaultDestDir = 12

[ClassInstall32]
Addreg=SampleClassReg

[SampleClassReg]
HKR,,,0,%ClassName%
HKR,,Icon,,-5

[DiskCopyfiles]
wdfmyshelldriver.sys

[SourceDisksNames]
1=%InstDisk%,

[SourceDisksFiles]
Wdfmyshelldriver.sys=1

[Manufacturer]
%MSFT% = DiskDevice,NTAMD64

; For Win2K
[DiskDevice]
%DiskDevDesc% = DiskInstall, wdfmyshelldriver

; For XP and later
[DiskDevice.NTAMD64]
%DiskDevDesc% = DiskInstall, wdfmyshelldriver

[DiskInstall.NT]
CopyFiles = DiskCopyfiles


;;specify that this is the installation
;;for nt based systems.
[DriverInstall.ntx86]
DriverVer=09/24/2012,1.0
CopyFiles=DriverCopyFiles


[DiskInstall.NT.Services]
AddService = wdfmyshelldriver, %SPSVCINST_ASSOCSERVICE%, DiskServiceInst

[DiskServiceInst]
ServiceType   = %SERVICE_KERNEL_DRIVER%
StartType     = %SERVICE_DEMAND_START%
ErrorControl  = %SERVICE_ERROR_NORMAL%
DisplayName   = %DiskServiceDesc%
ServiceBinary = %12%\Wdfmyshelldriver.sys
AddReg        = DiskAddReg

[DiskAddReg]
HKR, "Parameters", "BreakOnEntry",      %REG_DWORD%, 0x00000000
HKR, "Parameters", "DiskSize",          %REG_DWORD%, 0x00100000
HKR, "Parameters", "DriveLetter",       %REG_SZ%,    "R:"
HKR, "Parameters", "RootDirEntries",    %REG_DWORD%, 0x00000200
HKR, "Parameters", "SectorsPerCluster", %REG_DWORD%, 0x00000002




[Strings]
MSFT            = "Microsoft"
ClassName       = "My Shell Device"
DiskDevDesc     = "WDF My Shell Driver"
DiskServiceDesc = "myshelldriver Driver"
InstDisk        = "myshelldriver Install Disk"
;*******************************************
;Handy macro substitutions (non-localizable)
SPSVCINST_ASSOCSERVICE = 0x00000002
SERVICE_KERNEL_DRIVER  = 1
SERVICE_DEMAND_START   = 3
SERVICE_ERROR_NORMAL   = 1
REG_DWORD              = 0x00010001
REG_SZ                 = 0x00000000


**** END OF INF FILE***

2 Answers2

1

There are many relevant samples in the WDK. For example, take a look at KMDF Echo sample.

SomeWittyUsername
  • 18,025
  • 3
  • 42
  • 85
0

First you will need to name your object. Second you will need to do at least one of the following:

  1. Create a Symbolic link in the \GLOBAL??\
  2. Register a Device Interface.

Option 1 will let you do the simple

CreateFile("\\\\.\\<device_name>, ...);

Option 2 and you will need to use the Setup DI Api routines to find your device to open it.

roscoe_casita
  • 175
  • 14