2013-01-19 109 views
0

我已經寫了一個示例KMDF驅動程序。我不知道我是否做了正確的事情,但在DebugView實用程序中看到KMDF驅動程序打印調試消息 - 當我將此驅動程序添加爲新硬件時。它也顯示爲設備管理器下的「Sample Device」。如何從客戶端應用程序訪問KMDF驅動程序

現在我想寫一個示例客戶端,可以調用此驅動程序 - 所以我可以建立驅動程序和客戶端之間的連接。我讀過,我們需要使用'CreateFile'和'DEviceIOControl'等,但我無法從中獲得啓動。

你能指導我創建示例客戶端來訪問示例KMDF驅動程序嗎?驅動程序

我的INF文件看起來像這樣: -

***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*** 

回答

0

首先,您需要爲您的對象命名。 其次,你需要做以下的至少一個:

  1. 創建在\ GLOBAL ?? \
  2. 符號鏈接註冊設備接口。

選項1將讓你做簡單的

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

選項2,您需要使用安裝DI API例程找到你的設備將其打開。

相關問題