Hi All,
I need to write a simple filter driver which would allow or block audio or video devices based on their VID/PID. I took generic WDF filter sample from the latest WDK (Windows-driver-samples\general\toaster\toastDrv\kmdf\filter\generic), built and installed the service myfilter as a lower filter to the media class by adding a LowerFilter entry to HKLM\SYSTEM\CurrentControlSet\Control\Class{4d36e96c-e325-11ce-bfc1-08002be10318} and plugged in my USB speaker.
The USB speaker gets enumerated properly. But either adjusting the volume through tray volume control or playing sound simply breaks the entire USB sub-system so badly that the hub(s) it is connected to go into reset cycles and things go crazy from that point. Entire PnP process becomes excruciatingly slow (unplug re-plug of other USB devices would take several minutes), some USB devices just won’t get enumerated at all, or enumeration - re-enumeration cycle would repeat for hours. The only way to recover is to unplug the USB speaker, and unplug and re-plug the external hub(s) to which the USB speaker was plugged into, and wait for them to enumerate properly - typically 10+ minutes. In few occasions, computer was frozen, it needed a reboot. Classic WDM filter from WDK 7.x produces the outcome as well.
My setup is: Dell laptop → USB xHCI Host Controller → Powered USB-C external hub (with HDMI video) → Powered USB 3.0 external hub → USB speaker (+ mouse, keyboard etc). Windows 10 x64 22H2 19045. Installation is fairly clean, only the chipset driver from dell and the drivers installed by Windows update are present and nothing more.
I am assuming that this is something to do with the fact that I am installing standard filter on the audio KS streaming stack. I arrived at this conclusion because, the filter when installed as lower filter to audio device causes problem, but not when installed as an upper filter to its usbccgp composite parent. This led me into the world of KS streaming, which apparently is very special and complex for my purposes so I didn’t get much further to be to understand its nuances. Also noticed that MSDN has references to WDM streaming filters, it made me naively think that any standard pass-through filter should work on KS stack, apparently it is not the case. The question is what the special rule about KS driver stack where a standard pass through would cause issues? Why passing everything through is insufficient? Why would it kill the entire USB subsystem? I can replicate this with other computers running standard Windows 10 x64 22H2 19045 as well, but NOT all computers.
Lower filter to Media class which causes issues:
0: kd> !devstack 0xFFFFC18D6034C2E0
!DevObj !DrvObj !DevExt ObjectName
ffffc18d61d9e280 \Driver\ksthunk ffffc18d61d9e3d0 000000fc
ffffc18d4d87ca50 \Driver\usbaudio ffffc18d4d87cbc0
ffffc18d6034c2e0 \Driver\myfilter ffffc18d6034c430
ffffc18d633d77f0 \Driver\usbccgp ffffc18d633d7940 000000fa
!DevNode ffffc18d5fe58cc0 :
DeviceInst is “USB\VID_0B0E&PID_0410&MI_00\7&10769164&0&0000”
ServiceName is “usbaudio”
Upper filter to usb (ccgp) where there is no issue:
0: kd> !devstack 0xFFFFC18D659AC080
!DevObj !DrvObj !DevExt ObjectName
ffffc18d659ac080 \Driver\myfilter ffffc18d659ac1d0
ffffc18d5eacf290 \Driver\usbccgp ffffc18d5eacf3e0 00000102
ffffc18d5f2f3060 \Driver\USBHUB3 ffffc18d60f047b0 USBPDO-4
!DevNode ffffc18d64ddf5d0 :
DeviceInst is “USB\VID_0B0E&PID_0410\70BF9213A8FAx011200”
ServiceName is “usbccgp”
Thank you!