Can I install UMDF upper filter Driver for UVC Video Driver

Is it possible to add UMDF upper filter driver for the UVC Video driver (usbvideo.sys)?
Please let me know what INF file Service install section should have.
Also, should I mention USB VID/PID in the UMDF Inf file?

No. The kernel streaming IRPs that are handed to usbvideo.sys use METHOD_NEITHER, which cannot be handled in UMDF.

Thanks.
In general, what are the steps for installing the UMDF filter driver.
Should we create a service using the "sc create type= kernel start= demand binpath= system32/drivers/UMDF/yourfilename.dll" command?
And add registry entry for Upper/lower Filter driver to the function driver for which we want to attach as filter driver?

No, that clearly won't work, since yourfilename.dll is NOT of type=kernel.

The way UMDF works is that there IS a kernel stub driver that marshals all the requests to your UMDF driver process, then blocks until your UMDF driver replies. So, the UpperFilters key has to mention WUDFRd. There are them special UMDF keys that tell WUDFRd where to marshal the requests.

Start here:

Hi Tim,
Thanks for sharing the information.
I looked at the link and created an INF file for the UMDF driver which acts as filter driver for a USB Camera Device VID\PID. By default, the camera device uses windows inbox USBVideo Driver.
Using the "%DeviceName% = MyDevice_Install, USB\VID" of the USB device in the UMDF INF file do not allow the UMDF filter driver to install.
What should MyDevice_Install should be pointing to in the UMDF inf?

Without seeing the INF, I don't know how much we can say. It used to be that, to install a device filter, you had to write an INF that completely replaced the original one, I understand it's now possible to have a "filter-only" INF, but I've never written one.

;
; UMDFUpperFilter.inf
;

[Version]
Signature   = "$Windows NT$"
Class       = USB ; TODO: specify appropriate Class
ClassGuid   = {36FC9E60-C465-11CF-8056-444553540000} ; TODO: specify appropriate ClassGuid
Provider    = %ManufacturerName%
CatalogFile = UMDFUpperFilter.cat
DriverVer   = ; TODO: set DriverVer in stampinf property pages
PnpLockdown = 1

[Manufacturer]
; This driver package is only installable on Win11+
%ManufacturerName% = Standard,NT$ARCH$.10.0...22000 ; wudfrd.inf introduced in build 22000

[Standard.NT$ARCH$.10.0...22000]
%DeviceName% = MyDevice_Install, Root\UMDFUpperFilter ; TODO: edit hw-id
;%DeviceName% = MyDevice_Install, USB\VID_XXXX&PID_XXXX&REV_0010&MI_00 ; TODO: edit hw-id

[SourceDisksFiles]
UMDFUpperFilter.dll = 1

[SourceDisksNames]
1 = %DiskName%

; =================== UMDF Device ==================================

[MyDevice_Install.NT]
Include = WUDFRD.inf
Needs = WUDFRD.NT
AddReg = UsbVideo_AddReg

[MyDevice_Install.NT.hw]
Include = WUDFRD.inf
Needs = WUDFRD.NT.HW

[MyDevice_Install.NT.Services]
Include = WUDFRD.inf
Needs = WUDFRD.NT.Services
Needs = USBVideo.Install


[MyDevice_Install.NT.Wdf]
;Include = usbvideo.inf
;Needs = USBVideo.NT.Services
KmdfService = USBVideo, USBVideo_Install
UmdfService = UMDFUpperFilter,UMDFUpperFilter_Install
UmdfServiceOrder = UMDFUpperFilter
UmdfKernelModeClientPolicy = AllowKernelModeClients
UmdfImpersonationLevel = Impersonation

[MyDevice_Install.NT.Filters]
Include = WUDFRD.inf
Needs = WUDFRD_UpperFilter.NT.Filters
AddFilter=UMDFUpperFilter,0,filter-install-section

[UMDFUpperFilter_Install]
UmdfLibraryVersion = $UMDFVERSION$ 
StartType = 3
ErrorControl = 1
ServiceBinary = %12%\UMDF\UMDFUpperFilter.dll

[USBVideo_Install]
KmdfLibraryVersion = 1.27
ServiceBinary  = %10%\System32\Drivers\usbvideo.sys
AddReg=UsbVideo_AddReg
LoadOrderGroup = Base

[UsbVideo_AddReg]
HKR,,\"UpperFilters\",0x00010008,\"WUDFRd\" ; REG_MULTI_STRING

[DestinationDirs]
UMDriverCopy = 12

[filter-install-section]
FilterPosition = Upper

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

[Strings]
ManufacturerName = "<Your manufacturer name>" ;TODO: Replace with your manufacturer name
DiskName = "UMDFUpperFilter Installation Disk"
DeviceName ="UMDFUpperFilter Device"

This is the INF file I'm using to install the UMDF filter driver, The INF is not verified fully. Still working.

This INF does not change the USB device at all. This creates a brand-new dummy device, then loads your UMDF driver as the driver for that dummy device. No hardware involved. Did you notice the part where it says "TODO edit hw-id"? You need to match this to your device's hardware ID.

I would also point out that it's not going to find "USBVIDEO.Install" within "WUDFRD.inf". You need another Include line.

The USB Device was disabled in INF for testing.
Below is the INF file with the USB VID/PID Enabled.
Also added Include usbvideo.inf to the Install.Nt.Wdf
The missing link in the INF is how the UMDF filter driver is layered over the usbvideo.sys
With the below changed INF I still don't get the UMDF filter driver added as upper filter driver for the usbvideo driver.

; UMDFUpperFilter.inf
;

[Version]
Signature   = "$Windows NT$"
Class       = Camera ; TODO: specify appropriate Class
ClassGuid   = {ca3e7ab9-b4c3-4ae6-8251-579ef933890f} ; TODO: specify appropriate ClassGuid
Provider    = %ManufacturerName%
CatalogFile = UMDFUpperFilter.cat
DriverVer   = ; TODO: set DriverVer in stampinf property pages
PnpLockdown = 1

[Manufacturer]
; This driver package is only installable on Win11+
%ManufacturerName% = Standard,NT$ARCH$.10.0...22000 ; wudfrd.inf introduced in build 22000

[Standard.NT$ARCH$.10.0...22000]
;%DeviceName% = MyDevice_Install, Root\UMDFUpperFilter ; TODO: edit hw-id
%DeviceName% = MyDevice_Install, USB\VID_ABCD&PID_FD00&REV_0010&MI_00 ; TODO: edit hw-id

[SourceDisksFiles]
UMDFUpperFilter.dll = 1

[SourceDisksNames]
1 = %DiskName%

; =================== UMDF Device ==================================

[MyDevice_Install.NT]
Include = WUDFRD.inf
Needs = WUDFRD.NT
Include = usbvideo.inf
Needs = USBVideo.NT
AddReg = UsbVideo_AddReg

[MyDevice_Install.NT.hw]
Include = WUDFRD.inf
Needs = WUDFRD.NT.HW
Needs = USBVideo.NT.HW

[MyDevice_Install.NT.Services]
Include = WUDFRD.inf
Needs = WUDFRD.NT.Services
Include = usbvideo.inf
Needs = USBVideo.NT.Services


[MyDevice_Install.NT.Wdf]
Include = usbvideo.inf
Needs = USBVideo.NT.Wdf
KmdfService = USBVideo, USBVideo_Install
UmdfService = UMDFUpperFilter,UMDFUpperFilter_Install
UmdfServiceOrder = UMDFUpperFilter
UmdfKernelModeClientPolicy = AllowKernelModeClients
UmdfImpersonationLevel = Impersonation

[MyDevice_Install.NT.Filters]
Include = WUDFRD.inf
Needs = WUDFRD_UpperFilter.NT.Filters
AddFilter=UMDFUpperFilter,0,filter-install-section

[UMDFUpperFilter_Install]
UmdfLibraryVersion = $UMDFVERSION$ 
StartType = 3
ErrorControl = 1
ServiceBinary = %12%\UMDF\UMDFUpperFilter.dll

[USBVideo_Install]
KmdfLibraryVersion = 1.27
ServiceBinary  = %10%\System32\Drivers\usbvideo.sys
AddReg=UsbVideo_AddReg
LoadOrderGroup = Base

[UsbVideo_AddReg]
HKR,,\"UpperFilters\",0x00010008,\"WUDFRd\" ; REG_MULTI_STRING

[DestinationDirs]
UMDriverCopy = 12

[filter-install-section]
FilterPosition = Upper

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

[Strings]
ManufacturerName = "<Your manufacturer name>" ;TODO: Replace with your manufacturer name
DiskName = "UMDFUpperFilter Installation Disk"
DeviceName ="UMDFUpperFilter Device"

This is a very complicate inf file. It is really too bad that none of the github samples provide an example to work from.

the strings should not be escaped. (replace \" with "). This may or may not have anything to do with your problem.

[UsbVideo_AddReg]
HKR,,"UpperFilters",0x00010008,"WUDFRd" ; REG_MULTI_STRING

I think this will add the "UpperFilters" String to the USBVideo driver registry. Installing the UMDF Filter driver with the INF file is not updating the registry of the In-Box USBVideo Driver.