【发布时间】:2020-07-03 14:40:55
【问题描述】:
我正在尝试打开设备驱动程序以向其发送 ioctl。在 SO 和其他地方有很多例子,但几乎所有地址都打开 "\\.\PhysicalDrive0" 等。但我正在尝试打开一个非磁盘驱动程序,该驱动程序是从 GitHub 上的 Microsoft 示例代码“Windows-driver-samples”编译而来,即“simgpio”。它似乎已正确安装,但我不知道要使用什么“\\.\name”。我没有高兴地尝试了 "\\.\simgpio"。有什么建议吗?
作为参考,我在下面包含了驱动程序的 .INF 文件。
;/*++
;
;Copyright (c) Microsoft Corporation. All rights reserved.
;
;Module Name:
;
; SIMGPIO.INF
;
;Abstract:
; INF file for installing Simulated GPIO Client Driver.
;
;--*/
[Version]
Signature="$WINDOWS NT$"
Class=System
ClassGuid={4d36e97d-e325-11ce-bfc1-08002be10318}
Provider=%ProviderName%
DriverVer = 06/30/2020,15.29.58.35
CatalogFile=gpiosamples.cat
[SourceDisksNames]
3426=windows cd
[SourceDisksFiles]
simgpio.sys = 3426
[DestinationDirs]
DefaultDestDir = 12
[ControlFlags]
BasicDriverOk = *
ExcludeFromSelect = *
;******************************************
; SIMGPIO Client driver Install Section
;******************************************
[Manufacturer]
%ManufacturerName%=Standard,NTx86
[Standard.NTx86]
%GPIO.DeviceDesc% = GPIO_Inst,ACPI\TEST0001
[GPIO_Inst.NT]
Copyfiles = GPIOCopyFiles
[GPIOCopyFiles]
simgpio.sys,,,0x100
[GPIO_Inst.NT.Services]
AddService = simgpio,%SPSVCINST_ASSOCSERVICE%,GPIO_Service_Inst
[GPIO_Service_Inst]
DisplayName = %GPIO.SvcDesc%
ServiceType = %SERVICE_KERNEL_DRIVER%
StartType = %SERVICE_DEMAND_START%
ErrorControl = %SERVICE_ERROR_NORMAL%
ServiceBinary = %12%\simgpio.sys
[strings]
; localizable strings
ProviderName = "TODO-Set-Provider"
ManufacturerName = "TODO-Set-Manufacturer"
GPIO.DeviceDesc = "Simulated GPIO Client Driver"
GPIO.SvcDesc = "Simulated GPIO Client Driver"
; non-localizable strings
SPSVCINST_TAGTOFRONT = 0x00000003
SPSVCINST_ASSOCSERVICE = 0x00000002
SERVICE_KERNEL_DRIVER = 1
SERVICE_BOOT_START = 0
SERVICE_SYSTEM_START = 1
SERVICE_DEMAND_START = 3
SERVICE_ERROR_NORMAL = 1
SERVICE_ERROR_IGNORE = 0
SERVICE_ERROR_CRITICAL = 3
REG_EXPAND_SZ = 0x00020000
REG_DWORD = 0x00010001
REG_SZ = 0x00000000
【问题讨论】:
-
几十年前,人们认为让司机随意命名设备太混乱了。您需要在系统标头中为您正在实现的接口类找到设备接口类 GUID,我想在您的情况下是在“km/i2cgpio.h”中定义的
GUID_GPIO_INTERFACE。通过SetupDiGetClassDevsW为接口类建立设备信息集;通过SetupDiEnumDeviceInterfaces枚举设备;并通过SetupDiGetDeviceInterfaceDetailW获取每个设备的打开路径。 -
谢谢。那行得通。
标签: windows device-driver createfile