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 ad开发者_StackOverflow社区d 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?
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.
This driver filters input for a particular keyboard on the system. If you want to filter keyboard inputs from all the keyboards plugged into the system, you can install this driver as a class filter below the KbdClass filter driver by adding the service name of this filter driver before the KbdClass filter in the registry at:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E96B-E325-11CE-BFC1-08002BE10318}\UpperFilters
See this page: https://github.com/microsoft/Windows-driver-samples/blob/1fe4cc42bedfccb97a5b2cc169f9e5306d41d0de/input/kbfiltr/README.md
精彩评论