Simple Keyboard filtering driver

Hello,

First of all: I’m new when it goes to driver development. I went through tutorial(s) and I read a lot about drivers and how it should work but since I don’t have knowledge I’m experiencing issues from the very begining… But let me explain my “simple task”

  • I need to write a keyboard filter - HID keyboard.
  • I understand that it needs to be in the Kernel space - KMDF - WDF
  • I took a solution in VS 2015 for Kernel drivers and I adopted it based on OSR WDF Filtering driver tutorial
  • The driver inf file is based on firefly example from MS (mouse filtering). More/less the same idea. I’ve narrowed it to a single specific keyboard

====
Current state:
The driver installs on my remote machine without issues. I’m able to deploy it and I see it in the Device Manager. It is shown as a “Upper Filter” in the Device Manager. I was able to get Kernel Debug logs (via DbgPrint) and the driver is created without issues - all statuses were ok. I set my driver as filter, created device, created queue and “subscribed” my own callbacks for read/write enents.

And the last thing (read/write) callbacks are not called at all.

Driver files visible in Device Manager:
IngacoFltr.sys (mine)
kdbclass.sys
kbdhid.sys
SynTP.sys (this is laptop specific)

Upper Filter: IngacoFltr

Device stack:
\Driver\kdbclass
\Driver\SynTP
\Driver\IngacoFltr
\Driver\kbdhid
\Driver\HidUsb

Any comments apprieciated ;).

What do you want the filter to do? The kbdfiltr sample is a better starting point as it has all of the relevant pieces wired in. For drivers below kbdclass you will not see reads/writes. Instead you hook the keyboard service callback chain and use it to inspect, inject, and/or reject input

Bent from my phone


From: xxxxx@lists.osr.com on behalf of xxxxx@interia.pl
Sent: Friday, April 21, 2017 5:32:00 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Simple Keyboard filtering driver

Hello,

First of all: I’m new when it goes to driver development. I went through tutorial(s) and I read a lot about drivers and how it should work but since I don’t have knowledge I’m experiencing issues from the very begining… But let me explain my “simple task”

- I need to write a keyboard filter - HID keyboard.
- I understand that it needs to be in the Kernel space - KMDF - WDF
- I took a solution in VS 2015 for Kernel drivers and I adopted it based on OSR WDF Filtering driver tutorial
- The driver inf file is based on firefly example from MS (mouse filtering). More/less the same idea. I’ve narrowed it to a single specific keyboard

====
Current state:
The driver installs on my remote machine without issues. I’m able to deploy it and I see it in the Device Manager. It is shown as a “Upper Filter” in the Device Manager. I was able to get Kernel Debug logs (via DbgPrint) and the driver is created without issues - all statuses were ok. I set my driver as filter, created device, created queue and “subscribed” my own callbacks for read/write enents.

And the last thing (read/write) callbacks are not called at all.

Driver files visible in Device Manager:
IngacoFltr.sys (mine)
kdbclass.sys
kbdhid.sys
SynTP.sys (this is laptop specific)

Upper Filter: IngacoFltr

Device stack:
\Driver\kdbclass
\Driver\SynTP
\Driver\IngacoFltr
\Driver\kbdhid
\Driver\HidUsb

Any comments apprieciated ;).


NTDEV is sponsored by OSR

Visit the list online at: https:

MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
Details at https:

To unsubscribe, visit the List Server section of OSR Online at https:</https:></https:></https:>

Thank you for your response. Indeed, I should write what is all about more precisely.

I would like to change some key mappings (it should be configurable by user) - more/less like it is for a normal keyboard. You press “Z” and you receive “Y” for example (that needs to be done only for a specific keyboard - and the mapping should be customizable - a few buttons can result as a single letter as an example).

The kbdfiltr itself is quite big thing - specially that a lot of the code there seems to be PS/2 keyboard specific (correct me if I’m wrong). But I’m open for any suggestions.

It is a much better sample to start with for what you want to do. The ps2 stuff will be harmless as is or you can remove it (anything with 8042). How are you going to communicate the mappings? You can’t open a direct handle to the filter (kbdclass blocks it) which is why kbdfiltr shows you how to create a raw pdo for that communication channel

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@interia.pl
Sent: Friday, April 21, 2017 7:37 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Simple Keyboard filtering driver

Thank you for your response. Indeed, I should write what is all about more precisely.

I would like to change some key mappings (it should be configurable by user) - more/less like it is for a normal keyboard. You press “Z” and you receive “Y” for example (that needs to be done only for a specific keyboard - and the mapping should be customizable - a few buttons can result as a single letter as an example).

The kbdfiltr itself is quite big thing - specially that a lot of the code there seems to be PS/2 keyboard specific (correct me if I’m wrong). But I’m open for any suggestions.


NTDEV is sponsored by OSR

Visit the list online at: https:

MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
Details at https:

To unsubscribe, visit the List Server section of OSR Online at https:</https:></https:></https:>