4

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?

JavaMan
  • 4,954
  • 4
  • 41
  • 69
  • Sounds like I need to provide my own INF file and choose HAVE DISK in the update driver wizard to use my own INF file. – JavaMan Apr 24 '11 at 12:28

2 Answers2

6

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.

Ilya
  • 5,533
  • 2
  • 29
  • 57
  • How do I add UpperFilters to a device class through an INF? Or, I should better say how to MODIFY the UpperFilters of the mouseclass as it already got a upper filter mouclass.sys. Is there any sample INF available for download? – JavaMan May 05 '11 at 08:53
  • Would it be some INF section that looks like: [VBoxMouse_AddReg] HKLM, System\CurrentControlSet\Control\Class\{4D36E96F-E325-11CE-BFC1-08002BE10318}, UpperFilters, 0x00010000, "VBoxMouse", "mouclass" . (this is the one I found VirtualBox is using to modify the mouse class upper filter of the guest win install on top of its virtual machine) – JavaMan May 05 '11 at 09:48
  • VBoxMouse's INF looks like a good example. Use 0x00010008 flags so that your filter would be appended to the list, rather than replace it. – Ilya May 06 '11 at 12:46
0

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

m4n0
  • 29,823
  • 27
  • 76
  • 89