我正在尝试为 Windows 7 上的 MTP 设备编写过滤器驱动程序,以记录文件操作并阻止某些文件操作。我发现在 Windows 中处理 MTP 的驱动程序是一个名为 WpdMtpDr.dll 的 UMDF 驱动程序,我根据这个示例(UMDF 函数驱动程序之上的示例 UMDF 过滤器驱动程序)为它编写了一个 UMDF 过滤器驱动程序,因为我将WpdMtpDr.dll
其视为功能驱动程序。我还以此作为参考来确定驱动程序是作为上过滤器还是下过滤器安装的。我使用 dpinst.exe 安装了驱动程序。下面是我的 INF 文件。
安装没有错误,但在插入 MTP 设备(三星 Galaxy S3)时,过滤器驱动程序不在其驱动程序列表中(通过设备管理器查看),并且从未调用其 DllMain。
我试图在上下过滤器之间切换,它也没有帮助。
我究竟做错了什么?
;
; umdffilter.inf
;
[Version]
Signature="$Windows NT$"
Class=WPD
ClassGuid={EEC5AD98-8080-425f-922A-DABF3DE3F69A}
Provider=%ManufacturerName%
CatalogFile=umdffilter.cat
DriverVer=01/02/2013,18.8.52.851`
[Manufacturer]
%ManufacturerName%=Standard,NTamd64
[Standard.NTamd64]
%DeviceName%=MyDevice_Install, usb\vid_04e8&pid_6860
[SourceDisksFiles]
umdffilter.dll=1
WudfUpdate_01011.dll=1
WdfCoInstaller01011.dll=1
WinUsbCoinstaller2.dll=1
[SourceDisksNames]
1 = %DiskName%
; =================== UMDF Filter Driver ==================================
[MyDevice_Install.NT]
CopyFiles=UMDriverCopy
Include=wpdmtp.inf, WINUSB.INF ; Import sections from wpdmtp.inf and WINUSB.INF
Needs=WPD.MTP, WINUSB.NT ; Run the CopyFiles & AddReg directives for wpdmtp.inf and WINUSB.INF
[MyDevice_Install.NT.hw]
Include = wpdmtp.inf
Needs = WPD.MTP.Registration
AddReg = MyDevice_AddReg
[MyDevice_Install.NT.Services]
AddService=WUDFRd,0x000001fa,WUDFRD_ServiceInstall ; flag 0x2 sets this as the service for the device
AddService=WinUsb,0x000001f8,WinUsb_ServiceInstall ; this service is installed because its a filter.
[MyDevice_Install.NT.CoInstallers]
CopyFiles=CoInstallers_CopyFiles
AddReg=CoInstallers_AddReg
[MyDevice_Install.NT.Wdf]
Include = wpdmtp.inf
Needs = WPD.MTP.Wdf
KmdfService=WINUSB, WinUsb_Install
UmdfService=umdffilter,umdffilter_Install
UmdfServiceOrder=umdffilter,WpdMtpDriver ; upper filter
[WinUsb_Install]
KmdfLibraryVersion=1.11
[WpdMtpDriver_Install]
UmdfLibraryVersion=1.11.0
[umdffilter_Install]
UmdfLibraryVersion=1.11.0
ServiceBinary=%12%\UMDF\umdffilter.dll
DriverCLSID={8cec927c-219a-4777-baea-8626d6a0ce50}
[MyDevice_AddReg]
HKR,,"LowerFilters",0x00010008,"WinUsb" ; FLG_ADDREG_TYPE_MULTI_SZ | FLG_ADDREG_APPEND
[WUDFRD_ServiceInstall]
DisplayName = %WudfRdDisplayName%
ServiceType = 1
StartType = 3
ErrorControl = 1
ServiceBinary = %12%\WUDFRd.sys
LoadOrderGroup = Base
[WinUsb_ServiceInstall]
DisplayName = %WinUsb_SvcDesc%
ServiceType = 1
StartType = 3
ErrorControl = 1
ServiceBinary = %12%\WinUSB.sys
[CoInstallers_CopyFiles]
WdfCoInstaller01011.dll
WudfUpdate_01011.dll
WinUsbCoinstaller2.dll
[CoInstallers_AddReg]
HKR,,CoInstallers32,0x00010000,"WudfUpdate_01011.dll", "WinUsbCoinstaller2.dll", "WdfCoInstaller01011.dll,WdfCoInstaller"
[DestinationDirs]
UMDriverCopy=12,UMDF ; copy to drivers\umdf
CoInstallers_CopyFiles=11 ; copy to system32
[UMDriverCopy]
umdffilter.dll
; =================== Generic ==================================
[Strings]
ManufacturerName="Me"
ClassName="Samples" ; TODO: edit ClassName
DiskName = "umdffilter Installation Disk"
WinUsb_SvcDesc="WinUSB Driver"
WudfRdDisplayName="Windows Driver Foundation - User-mode Driver Framework Reflector"
DeviceName="umdffilter Device"`