首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MTP设备的UMDF筛选器驱动程序

MTP设备的UMDF筛选器驱动程序
EN

Stack Overflow用户
提问于 2013-01-16 21:45:37
回答 1查看 4.2K关注 0票数 2

我正在尝试为Windows 7上的MTP设备编写筛选器驱动程序,以便记录文件操作并阻止某些文件操作。我发现windows中处理MTP的驱动是一个名为WpdMtpDr.dll的UMDF驱动程序,我把WpdMtpDr.dll当作函数驱动程序一样,根据这个example (在UMDF函数驱动之上的示例UMDF filter driver )为它写了一个UMDF过滤驱动程序。我还使用了this作为参考,以确定驱动程序是作为上层过滤器还是下层过滤器安装的。我使用dpinst.exe安装了驱动程序。下面是我的INF文件。

安装没有错误,但当插入MTP设备(三星Galaxy S3)时,过滤器驱动程序不在其驱动程序列表中(可通过设备管理器查看),并且其DllMain从未被调用。

我试着在下层过滤器和上层过滤器之间切换,但也没有帮助。

我做错了什么?

代码语言:javascript
复制
;
; 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"`
EN

回答 1

Stack Overflow用户

发布于 2014-03-19 14:41:15

@oren671:您应该能够在MTP堆栈上安装UMDF筛选器驱动程序作为上层筛选器。我尝试使用上面分享的相同的inf,发现inf中定义的Include部分导致错误,因为它已经包含在wpdmtp.inf 'WPD.MTP.Wdf‘部分中(参见DDInstall.Wdf下的Include/ WpdMtpDriver_Install )。

在%SystemDrive%\Windows\setupact.log中发现错误:"...Error正在读取部分WpdMtpDriver_Install密钥UmdfLibraryVersion -找到重复的密钥...“请检查SystemDrive%\Windows\Inf\setupapi.dev.log和%SystemDrive%\Windows\setupact.log中的故障。

从上面的inf中删除'WpdMtpDriver_Install‘部分,我就能够在MTP栈上安装UMDF过滤器了。

我已经修改了MTP inf以使用sample设置inf方向link。使用USB传输的MTP同时使用WPD (即UMDF)和WINUSB,因此在您的filter inf中包含来自wpdmtp.inf的相关部分(DDInstall,DDInstall.hw,DDInstall.Services,DDInstall.CoInstallers,DDInstall.Wdf)应该会消除复制它们的需要。

代码语言:javascript
复制
;
; 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"
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14359871

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档