Installing kbfiltr as upper keyboard class filter driver

I am currently modifying kbfiltr form the WDK samples. The filter installs by default as device filter driver for PS/2 keyboards but help file says that it is possible to install it as a class filter driver below the kbdclass filter "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”.

The problem is that I have almost zero experience in driver development and do not undestand what exactly I need to do to install the driver as upper class filter driver.

WDK seems to insist on using INF files. For example http://msdn.microsoft.com/en-us/library/ff547595(v=vs.85).aspx uses INF file in combination with SetupInstallxxx functions. At the same time SetupInstallServicesFromInfSection description says that this API may be not available in future OS versions (Should I use something instead?).

Some posts on this forum suggests to use CreateService function instead and edit UpperFilters redistry entry.

I am completely lost. Which method or API should I use? Which method is suitable for production? For installing on x64 machines on Vista and higher? The driver will be installed as a part of our installation package not when some hardware is detected. Please help me out.

> Some posts on this forum suggests to use CreateService function instead and edit UpperFilters redistry entry.

Since you need a reboot anyway (PS/2 stack cannot be stopped and restarted), probably there is no need in CreateService.

Just register the driver in CurrentControlSet\Services (Start/Type/ErrorControl/Group values) and then add the key name from Services to UpperFilters.


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

Thanks, Maxim for your help! I thought CreateService will create all necessary Service entries. Are there some disadvantages of this call that require directly modifying the registry settings? Also will it work for KMDF-based drivers (need to use coinstallers etc.)? And do i need to cop? driver to system folder or it can be executed from program installation folder? Not sure why but kbdclass.sys starts at system boot (to support non-PnP drivers?). Do I need to make my driver system-booted too?

xxxxx@yandex.ru wrote:

Thanks, Maxim for your help! I thought CreateService will create all necessary Service entries. Are there some disadvantages of this call that require directly modifying the registry settings? Also will it work for KMDF-based drivers (need to use coinstallers etc.)? And do i need to cop? driver to system folder or it can be executed from program installation folder?

CreateService creates the Services registry entry. That’s what maps
your service name to a driver file. You still have to modify the
registry key for the class to tell it which services will be used as
filters.

The path in the Services entry can point to an arbitrary location. The
system32\drivers folder is the traditional location, and it’s a nice
spot because it is protected from manhandling by dumb users, but it’s
not required.

Not sure why but kbdclass.sys starts at system boot (to support non-PnP drivers?). Do I need to make my driver system-booted too?

Kbdclass starts at boot because keyboards have to be alive and working
during boot. Your filter driver should be declared as “load on
demand”. It just so happens that the demand will occur during boot, but
since your driver is never loaded on its own, that’s not important.


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

> Thanks, Maxim for your help! I thought CreateService will create all necessary Service entries. Are there some

disadvantages of this call that require directly modifying the registry settings?

No. Just sometimes it is more convinient, but CreateService is better.

Also will it work for KMDF-based drivers (need to use coinstallers etc.)?

No, they should be installed via INF.


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

> Kbdclass starts at boot because keyboards have to be alive and working

during boot.

It starts as System :slight_smile:


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

kbfilter driver sample is KMDF-based. So based on my current understanding I need change the INF file. Installation programm will need to call SetupCopyOEMInf for the INF file and then use SetupDixxx functions to place the kbfilter driver service before the kbdclass in UpperFilters entry for the keyboard class devices. Am I correct? Do I need to use any driver install fremework for this?

What os version are you going to install on? If win7, the coinstaller is optional , if lower, it is required.

d

debt from my phone

-----Original Message-----
From: xxxxx@yandex.ru
Sent: Monday, September 19, 2011 10:49 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Installing kbfiltr as upper keyboard class filter driver

kbfilter driver sample is KMDF-based. So based on my current understanding I need change the INF file. Installation programm will need to call SetupCopyOEMInf for the INF file and then use SetupDixxx functions to place the kbfilter driver service before the kbdclass in UpperFilters entry for the keyboard class devices. Am I correct? Do I need to use any driver install fremework for this?


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

We are going to install it on Vista and higher.

Hey Yuri,

I’m also working on the same work. Have you already figured out the way to install the kbdfltr as the class upper filter driver?

In addition, I have another question that the order of the value of registry key “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class{4D36E96B-E325-11CE-BF
C1-08002BE10318}\UpperFilters” does matter. For example, is there any difference between

kbdclass kbdfltr

and

kbdfltr kbdclass

Yes, there is a difference. kbfilter relies on being between kbdslass and port driver in the device stack. So if should be placed before kbdclass in UpperFilters.