2

我正在尝试为 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"`
4

1 回答 1

1

@ore​​n671:您应该能够在 MTP 堆栈上安装 UMDF 过滤器驱动程序作为上层过滤器。我尝试使用上面共享的相同 inf,发现 inf 中定义的 WpdMtpDriver_Install 部分导致错误,因为它已包含在 wpdmtp.inf 'WPD.MTP.Wdf' 部分中(请参阅 DDInstall.Wdf 下的包含/需要)。

在 %SystemDrive%\Windows\setupact.log 中发现错误:“...错误读取部分 [WpdMtpDriver_Install] 键 UmdfLibraryVersion - 发现重复键...”请检查 SystemDrive%\Windows\Inf\setupapi.dev.log 和 %SystemDrive %\Windows\setupact.log 用于失败。

从上面的 inf 中删除“WpdMtpDriver_Install”部分,我能够在 MTP 堆栈上安装 UMDF 过滤器。

我已经修改了示例inf 以使用 MTP Setup inf Directions链接。带有 USB 传输的 MTP 使用 WPD(即 UMDF)和 WINUSB,因此在您的过滤器 inf 中包括来自 wpdmtp.inf 的相关部分(DDInstall、DDInstall.hw、DDInstall.Services、DDInstall.CoInstallers、DDInstall.Wdf)应该消除需要复制它们。

;
; WUDFOsrUsbFilterOnMTPDriver.inf - Install a UM Filter driver on an MTP device'
;

[Version]
Signature="$Windows NT$"
Class=WPD
ClassGuid={EEC5AD98-8080-425f-922A-DABF3DE3F69A}
Provider=%MSFTUMDF%
DriverVer=02/03/2014,18.8.52.851
CatalogFile=wudf.cat

[Manufacturer]
%MSFTUMDF%=Microsoft,NTamd64

[Microsoft.NTamd64]
%OsrUsbDeviceName%=OsrUsb_Install, USB\VID_04E8&PID_6860&MI_00
%OsrUsbDeviceName%=OsrUsb_Install, USB\VID_04E8&PID_6860

[SourceDisksFiles]
WudfOsrUsbFilter.dll=1

[SourceDisksNames]
1 = %MediaDescription%

; =================== UMDF OSR Filter Driver ==================================

[OsrUsb_Install.NT]
CopyFiles=UMDriverCopy
Include = wpdmtp.inf, WINUSB.INF
Needs   = WPD.MTP, WINUSB.NT

[OsrUsb_Install.NT.hw]
Include = wpdmtp.inf
Needs   = WPD.MTP.Registration

[OsrUsb_Install.NT.Services]
Include = wpdmtp.inf
Needs   = WPD.MTP.Services

[OsrUsb_Install.NT.Wdf]
Include = wpdmtp.inf
Needs = WPD.MTP.Wdf
UmdfService=WudfOsrUsbFilter, WudfOsrUsbFilter_Install
UmdfServiceOrder=WpdMtpDriver, WUDFOsrUsbFilter

[OsrUsb_Install.NT.CoInstallers]
Include = wpdmtp.inf
Needs = WPD.MTP.CoInstallers

[WudfOsrUsbFilter_Install]
UmdfLibraryVersion=1.11.0
DriverCLSID = "{422d8dbc-520d-4d7e-8f53-920e5c867e6c}"
ServiceBinary = "%12%\UMDF\WUDFOsrUsbFilter.dll"

[DestinationDirs]
UMDriverCopy=12,UMDF        ; copy to drivers\umdf

[UMDriverCopy]
WudfOsrUsbFilter.dll

; =================== Generic ==================================

[Strings]
MSFTUMDF="Microsoft Internal (WDF:UMDF)"
MediaDescription="Microsoft UMDF OSR USB Sample Device Installation Media"
OsrUsbDeviceName="Microsoft UMDF OSR Usb Sample Device With Filter on User-mode Driver"
于 2014-03-19T06:41:15.067 回答