2013-01-16 132 views
2

我正在尝试为Windows 7上的MTP设备编写筛选器驱动程序,以便记录文件操作并阻止某些文件操作。我发现,处理MTP在Windows驱动程序名为WpdMtpDr.dll一个UMDF驱动程序,我根据这个example(样品UMDF过滤驱动上述UMDF功能驱动程序),因为我对待WpdMtpDr.dll作为功能驱动程序写了UMDF过滤器驱动程序。我还使用this作为参考,以确定驱动程序是安装为上限还是下限过滤器。我使用dpinst.exe安装了驱动程序。以下是我的INF文件。用于MTP设备的UMDF筛选器驱动程序

安装没有错误,但是当插入MTP设备(Samsung 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"` 
+0

显然UMDF过滤器不能作为第三方驱动程序安装。它意味着作为供应商软件包的一部分进行安装。特别是在Samsung Galaxy S3上,它导致设备无法启动(代码10)。 – oren671

回答

1

@ oren671:您应该能够在MTP堆栈上安装UMDF过滤器驱动程序作为上层过滤器。我试图使用相同的INF上述共享和发现在您的INF中定义的WpdMtpDriver_Install部分导致错误,因为它已经从在wpdmtp.inf“WPD.MTP.Wdf”部分包括(见包含/需求DDInstall.Wdf下)。在的%SystemDrive%\的Windows \ setupact.log发现

错误: “...错误读取部分[WpdMtpDriver_Install]键UmdfLibraryVersion - 重复键找到......” 请检查系统驱动器%\ Windows \ Inf文件\ SETUPAPI。 dev.log &%SystemDrive%\ Windows \ setupact.log失败。

卸下从上述INF的“WpdMtpDriver_Install”部分,我能够在MTP堆栈上安装UMDF滤波器。

我修改了sample inf以使用MTP设置inf指令link。使用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"