Search code examples
windowsfilterdriverdevicewdk

Installing Filter Drivers To An Existing Device


I am learning how to write a filter driver and is trying to install one on top an existing HID driver (mouse or keyboard) for practising. From what I understand, I should at least add an UpperFilters key to the hardware registry key. Is there anything else I should do?

When I use regedit to manually add an UpperFilters key to my target USB mouse device, regedit says It cannot create the key. I am suspecting regedit disallows modification to Windows provided device driver stack registry. Is there any other methods to install my filter driver to an existing device stack?


Solution

  • Windows 7 by default disallows modifications under the HKLM\SYSTEM\CurrentControlSet\Enum hierarchy for anyone but the SYSTEM account (i.e. not even the Administrators), so adding an UpperFilters key to a particular device manually isn't easy. However, from within an INF it should be easy.

    However, if you want to filter all mice, you should add the UpperFilters key to the Mouse device class -- i.e. to HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E96F-E325-11CE-BFC1-08002BE10318}. This should be unhindered even on Windows 7, but normally you do this through an INF as well.

    When writing the INF, you can add the FLG_ADDREG_APPEND (0x00000008) flag in the AddReg section so that your filter will be added to any other filters on the Mouse device class.