0

我编写了一个示例 KMDF 驱动程序。我不知道我是否做对了所有事情,但在 DebugView 实用程序中看到 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***
4

2 回答 2

0

WDK 中有很多相关的示例。例如,看看KMDF Echo 示例

于 2013-02-23T08:38:42.803 回答
0

首先,您需要命名您的对象。其次,您至少需要执行以下操作之一:

  1. 在 \GLOBAL??\ 中创建符号链接
  2. 注册设备接口。

选项 1 将让您做简单的事

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

选项 2,您将需要使用 Setup DI Api 例程来找到您的设备以将其打开。

于 2014-09-27T05:18:51.470 回答