今天也是努力学习的一天 2022-08-18 15:07 采纳率: 60%
浏览 38
已结题

如何编写正确的过滤驱动 inf文件

如何编写正确的过滤驱动 inf文件
我希望能写一个过滤驱动过滤摄像头的数据并进行显示,之前使用Minifilter,但是安装之后在设备管理器中发现自己写的驱动没有被启动,

img

别问什么这是在UBS下面,我试过安装在Camera设备类的lowerFilter下也没有用
inf文件如下

;;;
;;; UVCFilter
;;;

[Version]
Signature   = "$Windows NT$"
; TODO - Change the Class and ClassGuid to match the Load Order Group value, see https://msdn.microsoft.com/en-us/windows/hardware/gg462963
ClassGuid={ca3e7ab9-b4c3-4ae6-8251-579ef933890f}      ; chkinf compat &!
Class=Camera                                          ; inf2cat compat &!
;Class = "_TODO_Change_Class_appropriately_"
;ClassGuid = {_TODO_Change_ClassGuid_appropriately_}
Provider    = %ManufacturerName%
DriverVer   = 08/18/2022,1.0.0.0
CatalogFile = UVCFilter.cat
PnpLockDown=1
DriverPackageType   = ClassFilter                     ; DIFx identifier
[DestinationDirs]
DefaultDestDir          = 12
UVCFilter.DriverFiles  = 12            ;%windir%\system32\drivers

;;
;; Default install sections
;;

[DefaultInstall]
OptionDesc          = %ServiceDescription%
CopyFiles           = UVCFilter.DriverFiles

[DefaultInstall.Services]
AddService          = %ServiceName%,,UVCFilter.Service

;;
;; Default uninstall sections
;;

[DefaultUninstall]
DelFiles   = UVCFilter.DriverFiles

[DefaultUninstall.Services]
DelService = %ServiceName%,0x200      ;Ensure service is stopped before deleting

;
; Services Section
;

[UVCFilter.Service]
DisplayName      = %ServiceName%
Description      = %ServiceDescription%
ServiceBinary    = %12%\%DriverName%.sys        ;%windir%\system32\drivers\
Dependencies     = "FltMgr"
ServiceType    = 1                                    ; SERVICE_KERNEL_DRIVER
StartType      = 0                                    ; SERVICE_BOOT_START
ErrorControl   = 0                                    ; SERVICE_ERROR_IGNORE
; TODO - Change the Load Order Group value
; LoadOrderGroup = "FSFilter Activity Monitor"
;LoadOrderGroup = "System Bus Extender"
AddReg           = UVCFilter.AddRegistry

;
; Registry Modifications
;

[UVCFilter.AddRegistry]
HKLM, System\CurrentControlSet\Control\Class\{ca3e7ab9-b4c3-4ae6-8251-579ef933890f}, LowerFilters, 0x00010008, UVCFilter ; firewire

;
; Copy Files
;

[UVCFilter.DriverFiles]
%DriverName%.sys

[SourceDisksFiles]
UVCFilter.sys = 1,,

[SourceDisksNames]
1 = %DiskId1%,,,

;;
;; String Section
;;

[Strings]
; TODO - Add your manufacturer
ManufacturerName        = "XChip"
ServiceDescription      = "UVCFilter Mini-Filter Driver"
ServiceName             = "UVCFilter"
DriverName              = "UVCFilter"
DiskId1                 = "UVCFilter Device Installation Disk"

;Instances specific information.
DefaultInstance         = "UVCFilter Instance"
Instance1.Name          = "UVCFilter Instance"
; TODO - Change the altitude value, see https://msdn.microsoft.com/en-us/windows/hardware/drivers/ifs/load-order-groups-and-altitudes-for-minifilter-drivers
Instance1.Altitude       = "_TODO_Change_Altitude_appropriately_"
Instance1.Flags         = 0x0              ; Allow all attachments



然后我试图使用标准的KMDF框架编写驱动,但是这次连驱动都安装不上,
inf文件如下

;
; KMDFFilter.inf
;

[Version]
Signature="$WINDOWS NT$"
Class=Camera ; TODO: edit Class
ClassGuid={ca3e7ab9-b4c3-4ae6-8251-579ef933890f} ; TODO: edit ClassGuid
Provider=%ManufacturerName%
CatalogFile=KMDFFilter.cat
DriverVer= ; TODO: set DriverVer in stampinf property pages

[DestinationDirs]
DefaultDestDir = 12
KMDFFilter_Device_CoInstaller_CopyFiles = 12

; ================= Class section =====================

;[ClassInstall32]
;Addreg=SampleClassReg

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

[SourceDisksNames]
1 = %DiskName%,,,""

[SourceDisksFiles]
KMDFFilter.sys  = 1,,
WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll=1 ; make sure the number matches with SourceDisksNames

;*****************************************
; Install Section
;*****************************************

[Manufacturer]
%ManufacturerName%=Standard,NT$ARCH$

[Standard.NT$ARCH$]
%KMDFFilter.DeviceDesc%=KMDFFilter_Device, Root\KMDFFilter ; TODO: edit hw-id

[KMDFFilter_Device.NT]
CopyFiles=Drivers_Dir

[Drivers_Dir]
KMDFFilter.sys

;-------------- Service installation
[KMDFFilter_Device.NT.Services]
AddService = KMDFFilter,%SPSVCINST_ASSOCSERVICE%, KMDFFilter_Service_Inst

; -------------- KMDFFilter driver install sections
[KMDFFilter_Service_Inst]
DisplayName    = %KMDFFilter.SVCDESC%
ServiceType    = 1               ; SERVICE_KERNEL_DRIVER
StartType      = 3               ; SERVICE_DEMAND_START
ErrorControl   = 1               ; SERVICE_ERROR_NORMAL
ServiceBinary  = %12%\KMDFFilter.sys

;
;--- KMDFFilter_Device Coinstaller installation ------
;

[KMDFFilter_Device.NT.CoInstallers]
AddReg=KMDFFilter_Device_CoInstaller_AddReg
CopyFiles=KMDFFilter_Device_CoInstaller_CopyFiles

[KMDFFilter_Device_CoInstaller_AddReg]
HKR,,CoInstallers32,0x00010000, "WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll,WdfCoInstaller"
HKLM, System\CurrentControlSet\Control\Class\{ca3e7ab9-b4c3-4ae6-8251-579ef933890f}, LowerFilters, 0x00010008, KMDFFilter ; usb
[KMDFFilter_Device_CoInstaller_CopyFiles]
WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll

[KMDFFilter_Device.NT.Wdf]
KmdfService =  KMDFFilter, KMDFFilter_wdfsect
[KMDFFilter_wdfsect]
KmdfLibraryVersion = $KMDFVERSION$

[Strings]
SPSVCINST_ASSOCSERVICE= 0x00000002
ManufacturerName="<XChip>" ;TODO: Replace with your manufacturer name
ClassName="Camera" ; TODO: edit ClassName
DiskName = "KMDFFilter Installation Disk"
KMDFFilter.DeviceDesc = "KMDFFilter Device"
KMDFFilter.SVCDESC = "KMDFFilter Service"


驱动的.c文件就不需要放出来了,这些文件是VS的框架自动生成的我没有任何修改,但是就是启动不了驱动,
请不要用模糊的语言回答这个问题,我已经看了很多模拟两可的答复了,能正确启动驱动才会结题

  • 写回答

1条回答 默认 最新

  • 王大师王文峰 企业官方账号 2022-08-19 10:42
    关注

    步骤是这样的
    为驱动程序包 编写 INF文件时,应遵循以下准则:

    INF 文件必须使用有效的结构和语法在安装过程开始时通过驱动程序包验证检查。

    使用 INFVerif 工具验证 INF 文件的结构和语法。

    INF 文件必须包含有效的 INF SourceDisksFiles 和SourceDisksNames 节。 从 Windows Vista 开始,操作系统不会将驱动程序包复制到驱动程序存储中,除非这些部分存在并正确填写。

    有时有必要在设备安装期间复制 INF 文件,以便Windows查找这些文件,而无需重复显示用户提示。 例如,多功能设备的基本 INF 文件可能会复制设备各个功能的 INF 文件,以便 Windows 可以在不提示用户每次安装设备功能之一时查找这些 INF 文件。

    从 Windows XP 开始,如果要在由 INF 文件驱动的安装期间阶段其他 INF 文件,请使用 INF CopyINF 指令。

    注意 请勿使用 INF CopyFiles 指令 复制 INF 文件。

    驱动程序包的组件不得直接将 INF 文件直接复制或删除到系统的 %SystemRoot%/Inf 目录中。 这会导致驱动程序的数字签名失效,导致驱动程序无法成功加载。

    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 8月19日
  • 赞助了问题酬金20元 8月18日
  • 创建了问题 8月18日

悬赏问题

  • ¥15 我的数据无法存进链表里
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端