I am trying to write a filter driver for MTP devices on Windows 7 for the purpose of logging file operations and block certain file operations. I found that the driver that handles MTP in windows is a UMDF driver named WpdMtpDr.dll and I wrote a UMDF filter driver for it according to this example (Sample UMDF Filter Driver above UMDF Function Driver) as I treated WpdMtpDr.dll
as the function driver. I also used this as a reference to determine if the driver is installed as an upper or lower filter. I installed the driver using dpinst.exe . Below is my INF file.
The installation had no errors, but when plugging in an MTP device (Samsung Galaxy S3), the filter driver was not in its drivers list (seen through device manager) and its DllMain was never called.
I tried to switch between lower and upper filter and it didn't help either.
What am I doing wrong?
;
; 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"`