Properly installing keyboard and mouse filter drivers

I’m currently in the process of writing the installers for our latest
product. It contains a keyboard and mouse filter driver, both based on the
kbfiltr and moufiltr WDF samples.

Both samples’ Readme files talk about adding the filters directly to an
existing device through Device Manager. However, I’m interested in filtering
all keyboard and mouse input instead of targeting a specific device, which
is why I’m targeting the UpperFilters registry value in the
{4D36E96B-E325-11CE-BFC1-08002BE10318} and
{4D36E96F-E325-11CE-BFC1-08002BE10318} classes, respectively.

I do need to install each driver, of course, and my question is how to best
do this. The INF files for the two samples specifically install the
kbdclass/mouclass and port drivers and I’m not sure if that’s what I want. I
really just want the driver Services to be installed and then add the
drivers to the UpperFilters key.

/ Soren

Hack the registry manually from your own code and request a reboot.

For PS/2, reboot is absolutely mandatory.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

“Soren Dreijer” wrote in message news:xxxxx@ntdev…
I’m currently in the process of writing the installers for our latest product. It contains a keyboard and mouse filter driver, both based on the kbfiltr and moufiltr WDF samples.

Both samples’ Readme files talk about adding the filters directly to an existing device through Device Manager. However, I’m interested in filtering all keyboard and mouse input instead of targeting a specific device, which is why I’m targeting the UpperFilters registry value in the {4D36E96B-E325-11CE-BFC1-08002BE10318} and {4D36E96F-E325-11CE-BFC1-08002BE10318} classes, respectively.

I do need to install each driver, of course, and my question is how to best do this. The INF files for the two samples specifically install the kbdclass/mouclass and port drivers and I’m not sure if that’s what I want. I really just want the driver Services to be installed and then add the drivers to the UpperFilters key.

/ Soren

As in adding the Services entry myself and then updating the UpperFilters
key? I was hoping I could use the “normal” install approach with an .inf
file to have the driver services created automatically on the target OS (in
case there were slight differences) and then manually modifying the
UpperFilters key afterwards.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
Sent: Thursday, July 01, 2010 3:13 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Properly installing keyboard and mouse filter drivers

Hack the registry manually from your own code and request a reboot.

For PS/2, reboot is absolutely mandatory.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

“Soren Dreijer” wrote in message news:xxxxx@ntdev…
I’m currently in the process of writing the installers for our latest
product. It contains a keyboard and mouse filter driver, both based on the
kbfiltr and moufiltr WDF samples.

Both samples’ Readme files talk about adding the filters directly to an
existing device through Device Manager. However, I’m interested in filtering
all keyboard and mouse input instead of targeting a specific device, which
is why I’m targeting the UpperFilters registry value in the
{4D36E96B-E325-11CE-BFC1-08002BE10318} and
{4D36E96F-E325-11CE-BFC1-08002BE10318} classes, respectively.

I do need to install each driver, of course, and my question is how to best
do this. The INF files for the two samples specifically install the
kbdclass/mouclass and port drivers and I’m not sure if that’s what I want. I
really just want the driver Services to be installed and then add the
drivers to the UpperFilters key.

/ Soren


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

I would avoid the INF whenever possible. The INF gives you a) signing issues b) putting the driver to the Driver Store, which hardens uninstall.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

“Soren Dreijer” wrote in message news:xxxxx@ntdev…
> As in adding the Services entry myself and then updating the UpperFilters
> key? I was hoping I could use the “normal” install approach with an .inf
> file to have the driver services created automatically on the target OS (in
> case there were slight differences) and then manually modifying the
> UpperFilters key afterwards.
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
> Sent: Thursday, July 01, 2010 3:13 PM
> To: Windows System Software Devs Interest List
> Subject: Re:[ntdev] Properly installing keyboard and mouse filter drivers
>
> Hack the registry manually from your own code and request a reboot.
>
> For PS/2, reboot is absolutely mandatory.
>
> –
> Maxim S. Shatskih
> Windows DDK MVP
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
> “Soren Dreijer” wrote in message news:xxxxx@ntdev…
> I’m currently in the process of writing the installers for our latest
> product. It contains a keyboard and mouse filter driver, both based on the
> kbfiltr and moufiltr WDF samples.
>
> Both samples’ Readme files talk about adding the filters directly to an
> existing device through Device Manager. However, I’m interested in filtering
> all keyboard and mouse input instead of targeting a specific device, which
> is why I’m targeting the UpperFilters registry value in the
> {4D36E96B-E325-11CE-BFC1-08002BE10318} and
> {4D36E96F-E325-11CE-BFC1-08002BE10318} classes, respectively.
>
> I do need to install each driver, of course, and my question is how to best
> do this. The INF files for the two samples specifically install the
> kbdclass/mouclass and port drivers and I’m not sure if that’s what I want. I
> really just want the driver Services to be installed and then add the
> drivers to the UpperFilters key.
>
> / Soren
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
>

A few questions then:

* Signing issues?

* Could you help me identify exactly which keys I need to manually modify
in the registry then? I know I have to create my service under the
Services<driver_name> key, of course, but having previously installed with
an INF I see my driver registered several other places as well, such as
“Control\Wdf\Kmdf\KmdfLibrary\Versions\1\DriverServices”, “Enum\HID.…”
(which is the actual keyboard), and “Enum\Root\SYSTEM\0001” (which is the
class I used in the INF file with my custom hardware ID)

Cheers,
Soren

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
Sent: Thursday, July 01, 2010 3:36 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Properly installing keyboard and mouse filter drivers

I would avoid the INF whenever possible. The INF gives you a) signing
issues b) putting the driver to the Driver Store, which hardens uninstall.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

“Soren Dreijer” wrote in message news:xxxxx@ntdev…
> As in adding the Services entry myself and then updating the
> UpperFilters key? I was hoping I could use the “normal” install
> approach with an .inf file to have the driver services created
> automatically on the target OS (in case there were slight differences)
> and then manually modifying the UpperFilters key afterwards.
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S.
> Shatskih
> Sent: Thursday, July 01, 2010 3:13 PM
> To: Windows System Software Devs Interest List
> Subject: Re:[ntdev] Properly installing keyboard and mouse filter
> drivers
>
> Hack the registry manually from your own code and request a reboot.
>
> For PS/2, reboot is absolutely mandatory.
>
> –
> Maxim S. Shatskih
> Windows DDK MVP
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
> “Soren Dreijer” wrote in message
news:xxxxx@ntdev…
> I’m currently in the process of writing the installers for our latest
> product. It contains a keyboard and mouse filter driver, both based on
> the kbfiltr and moufiltr WDF samples.
>
> Both samples’ Readme files talk about adding the filters directly to
> an existing device through Device Manager. However, I’m interested in
> filtering all keyboard and mouse input instead of targeting a specific
> device, which is why I’m targeting the UpperFilters registry value in
> the {4D36E96B-E325-11CE-BFC1-08002BE10318} and
> {4D36E96F-E325-11CE-BFC1-08002BE10318} classes, respectively.
>
> I do need to install each driver, of course, and my question is how to
> best do this. The INF files for the two samples specifically install
> the kbdclass/mouclass and port drivers and I’m not sure if that’s what
> I want. I really just want the driver Services to be installed and
> then add the drivers to the UpperFilters key.
>
> / Soren
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
>


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer</driver_name>

Do not create the service keys under Services yourself. At the very least use the SCM to install the driver.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Soren Dreijer
Sent: Thursday, July 01, 2010 1:58 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Properly installing keyboard and mouse filter drivers

A few questions then:

* Signing issues?

* Could you help me identify exactly which keys I need to manually modify in the registry then? I know I have to create my service under the Services<driver_name> key, of course, but having previously installed with an INF I see my driver registered several other places as well, such as “Control\Wdf\Kmdf\KmdfLibrary\Versions\1\DriverServices”, “Enum\HID.…”
(which is the actual keyboard), and “Enum\Root\SYSTEM\0001” (which is the class I used in the INF file with my custom hardware ID)

Cheers,
Soren

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
Sent: Thursday, July 01, 2010 3:36 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Properly installing keyboard and mouse filter drivers

I would avoid the INF whenever possible. The INF gives you a) signing issues b) putting the driver to the Driver Store, which hardens uninstall.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

“Soren Dreijer” wrote in message news:xxxxx@ntdev…
> As in adding the Services entry myself and then updating the
> UpperFilters key? I was hoping I could use the “normal” install
> approach with an .inf file to have the driver services created
> automatically on the target OS (in case there were slight differences)
> and then manually modifying the UpperFilters key afterwards.
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S.
> Shatskih
> Sent: Thursday, July 01, 2010 3:13 PM
> To: Windows System Software Devs Interest List
> Subject: Re:[ntdev] Properly installing keyboard and mouse filter
> drivers
>
> Hack the registry manually from your own code and request a reboot.
>
> For PS/2, reboot is absolutely mandatory.
>
> –
> Maxim S. Shatskih
> Windows DDK MVP
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
> “Soren Dreijer” wrote in message
news:xxxxx@ntdev…
> I’m currently in the process of writing the installers for our latest
> product. It contains a keyboard and mouse filter driver, both based on
> the kbfiltr and moufiltr WDF samples.
>
> Both samples’ Readme files talk about adding the filters directly to
> an existing device through Device Manager. However, I’m interested in
> filtering all keyboard and mouse input instead of targeting a specific
> device, which is why I’m targeting the UpperFilters registry value in
> the {4D36E96B-E325-11CE-BFC1-08002BE10318} and
> {4D36E96F-E325-11CE-BFC1-08002BE10318} classes, respectively.
>
> I do need to install each driver, of course, and my question is how to
> best do this. The INF files for the two samples specifically install
> the kbdclass/mouclass and port drivers and I’m not sure if that’s what
> I want. I really just want the driver Services to be installed and
> then add the drivers to the UpperFilters key.
>
> / Soren
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
>


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</driver_name>

Also, I found this earlier post on NTDEV where the guy talks about doing it
semi-manually as well (scroll to the bottom):
http://www.osronline.com/showthread.cfm?link=119885

Is that a recommended approach?

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
Sent: Thursday, July 01, 2010 3:36 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Properly installing keyboard and mouse filter drivers

I would avoid the INF whenever possible. The INF gives you a) signing
issues b) putting the driver to the Driver Store, which hardens uninstall.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

“Soren Dreijer” wrote in message news:xxxxx@ntdev…
> As in adding the Services entry myself and then updating the
> UpperFilters key? I was hoping I could use the “normal” install
> approach with an .inf file to have the driver services created
> automatically on the target OS (in case there were slight differences)
> and then manually modifying the UpperFilters key afterwards.
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S.
> Shatskih
> Sent: Thursday, July 01, 2010 3:13 PM
> To: Windows System Software Devs Interest List
> Subject: Re:[ntdev] Properly installing keyboard and mouse filter
> drivers
>
> Hack the registry manually from your own code and request a reboot.
>
> For PS/2, reboot is absolutely mandatory.
>
> –
> Maxim S. Shatskih
> Windows DDK MVP
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
> “Soren Dreijer” wrote in message
news:xxxxx@ntdev…
> I’m currently in the process of writing the installers for our latest
> product. It contains a keyboard and mouse filter driver, both based on
> the kbfiltr and moufiltr WDF samples.
>
> Both samples’ Readme files talk about adding the filters directly to
> an existing device through Device Manager. However, I’m interested in
> filtering all keyboard and mouse input instead of targeting a specific
> device, which is why I’m targeting the UpperFilters registry value in
> the {4D36E96B-E325-11CE-BFC1-08002BE10318} and
> {4D36E96F-E325-11CE-BFC1-08002BE10318} classes, respectively.
>
> I do need to install each driver, of course, and my question is how to
> best do this. The INF files for the two samples specifically install
> the kbdclass/mouclass and port drivers and I’m not sure if that’s what
> I want. I really just want the driver Services to be installed and
> then add the drivers to the UpperFilters key.
>
> / Soren
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
>


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

> Services<driver_name> key

SC database (you can call CreateService as Doron suggested, this also can save you a reboot in some cases), and also the UpperFilters value for Control\Class{guid}

The class filter is not a device driver, it is a Windows kernel add-on which alters its functionality.

It is not tied to the particular hardware, for instance.

And all those INFs are for the drivers tied to particular piece of hardware, not for kernel add-ons.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com</driver_name>

> The class filter is not a device driver, it is a Windows kernel add-on
which alters its functionality.

It is not tied to the particular hardware, for instance.

Gotcha. After Doron’s reply yesterday I successfully added the new service
using the SC command-line tool and manually added the driver to the
UpperFilters key and everything worked fine.

What LoadOrderGroup should I choose? Will “Boot Bus Extender” be fine?

And then a quick follow-up question: I know a reboot is required if I want
to filter a PS/2 keyboard stack, but what if a USB keyboard is currently
being used? How do I force the drivers to be reloaded without a reboot?

Thanks,
Soren

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
Sent: Friday, July 02, 2010 6:47 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Properly installing keyboard and mouse filter drivers

Services<driver_name> key

SC database (you can call CreateService as Doron suggested, this also can
save you a reboot in some cases), and also the UpperFilters value for
Control\Class{guid}

The class filter is not a device driver, it is a Windows kernel add-on
which alters its functionality.

It is not tied to the particular hardware, for instance.

And all those INFs are for the drivers tied to particular piece of hardware,
not for kernel add-ons.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer</driver_name>

> What LoadOrderGroup should I choose? Will “Boot Bus Extender” be fine?

I think they are ignored for PnP. PnP drivers are inited earlier then these groups.

And then a quick follow-up question: I know a reboot is required if I want
to filter a PS/2 keyboard stack, but what if a USB keyboard is currently
being used? How do I force the drivers to be reloaded without a reboot?

  1. set SC entry by CreateService
  2. set UpperFilters value
  3. restart all keyboards in the system using the same sequence of calls as “devcon” uses.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

Load order group does not matter all for non boot start pnp drivers (and for boot start, it just matters enough if you have dependencies on other boot start drivers)

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Soren Dreijer
Sent: Friday, July 02, 2010 8:13 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Properly installing keyboard and mouse filter drivers

The class filter is not a device driver, it is a Windows kernel add-on
which alters its functionality.
It is not tied to the particular hardware, for instance.

Gotcha. After Doron’s reply yesterday I successfully added the new service
using the SC command-line tool and manually added the driver to the
UpperFilters key and everything worked fine.

What LoadOrderGroup should I choose? Will “Boot Bus Extender” be fine?

And then a quick follow-up question: I know a reboot is required if I want
to filter a PS/2 keyboard stack, but what if a USB keyboard is currently
being used? How do I force the drivers to be reloaded without a reboot?

Thanks,
Soren

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
Sent: Friday, July 02, 2010 6:47 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Properly installing keyboard and mouse filter drivers

Services<driver_name> key

SC database (you can call CreateService as Doron suggested, this also can
save you a reboot in some cases), and also the UpperFilters value for
Control\Class{guid}

The class filter is not a device driver, it is a Windows kernel add-on
which alters its functionality.

It is not tied to the particular hardware, for instance.

And all those INFs are for the drivers tied to particular piece of hardware,
not for kernel add-ons.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</driver_name>

Soren Dreijer wrote:

Gotcha. After Doron’s reply yesterday I successfully added the new service
using the SC command-line tool and manually added the driver to the
UpperFilters key and everything worked fine.

What LoadOrderGroup should I choose? Will “Boot Bus Extender” be fine?

Omit it. That option has no meaning for filter drivers. Your driver
will be loaded when the device you are filtering is loaded.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.