To send keyboard strokes in the kernel

Hi,

I have a special keyboard which connects to an industrial PC by dual-port
RAM. The industrial PC will have no other keyboard. I want to write a
kernel-mode dirver with the full functionality of a normal keyboard. I have
a driver to handle the dual-port RAM. At the present I send keyboard strokes
from user-mode by SendInput API function, but SendInput can not synthesize
Ctrl-Alt-Del.

How can I send keyboard strokes in the kernel? I have got some instruction
from Mr. Holan:

“To send keyboard strokes in the kernel, you must interface with kbdclass
directly; there is no equivalent of SendInput. You need to have a pnp
device stack whose device class is the keyboard class (this is set by
the INF) and report keyboard strokes accordingly. There is the i8042prt
(I think it is called pnpi8042 actually) example in the DDK which shows
a keyboard port driver and kbdfiltr which shows a keyboard filter
driver, but is much simpler then i8042prt”.

A “keyboard driver” is required, not a “keyboard filter driver”, isn’t it?

I have not found examples in the DDK and in the web how to develop a custom
keyboard driver. I study the DDK documentation, but I have no idea how to
implement Mr. Holan’s instructions. There is an example for PS/2 (i8042prt)
and an other example for a filter driver (kbfiltr), but I have not found in
it how to “interface with kbdclass dircetly”. I need some more help.

Pleeeeeeease help!!

Regards,

Ferenc Deak

Hi,

The “i8042prt” lies between the keyboard class-driver ( kbdclass ) and the
hardware. The
“kbdfilter” driver lies on top of the “kbdclass” driver. Probably, you need
both. You will
need a “i8042prt” like driver if your hardware reacts different from the
existing supported
keyboards. You will need a filter driver if you have to manipulate
keystrokes, generated by
your HW ( and i8042prt-like driver ). You may find an example of a
filter-driver that manipulates
keystrokes at

http://galileo.spaceports.com/~qualsoft/OPOSKeyboard/OPOSKeyboard.asp

To start, just look at the OKBDHook.c out of the driver directory ( "
OPOSKeyboard\OKBDHook\SYS ").
The driver is based on “crtl2cap” of Mark Russinovich (
www.sysinternals.com ).

Have success,

Christiaan

----- Original Message -----
From: “De?k Ferenc”
To: “NT Developers Interest List”
Cc:
Sent: Tuesday, November 12, 2002 2:03 PM
Subject: [ntdev] To send keyboard strokes in the kernel

> Hi,
>
> I have a special keyboard which connects to an industrial PC by dual-port
> RAM. The industrial PC will have no other keyboard. I want to write a
> kernel-mode dirver with the full functionality of a normal keyboard. I
have
> a driver to handle the dual-port RAM. At the present I send keyboard
strokes
> from user-mode by SendInput API function, but SendInput can not synthesize
> Ctrl-Alt-Del.
>
> How can I send keyboard strokes in the kernel? I have got some instruction
> from Mr. Holan:
>
> “To send keyboard strokes in the kernel, you must interface with kbdclass
> directly; there is no equivalent of SendInput. You need to have a pnp
> device stack whose device class is the keyboard class (this is set by
> the INF) and report keyboard strokes accordingly. There is the i8042prt
> (I think it is called pnpi8042 actually) example in the DDK which shows
> a keyboard port driver and kbdfiltr which shows a keyboard filter
> driver, but is much simpler then i8042prt”.
>
> A “keyboard driver” is required, not a “keyboard filter driver”, isn’t it?
>
> I have not found examples in the DDK and in the web how to develop a
custom
> keyboard driver. I study the DDK documentation, but I have no idea how to
> implement Mr. Holan’s instructions. There is an example for PS/2
(i8042prt)
> and an other example for a filter driver (kbfiltr), but I have not found
in
> it how to “interface with kbdclass dircetly”. I need some more help.
>
> Pleeeeeeease help!!
>
> Regards,
>
> Ferenc Deak
>
>
>
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@Compaqnet.be
> To unsubscribe send a blank email to %%email.unsub%%
>

Close, but not quite. Kbdfiltr sits in between kbdclass and the port driver, not on top of kbdclass. Since Deak is writing his own keyboard port driver, there is no need for a 2nd filter driver.

Deak, read the DDK section on input (*). The direct interface to kbdclass is the IOCTL IOCTL_INTERNAL_KEYBOARD_CONNECT and the service callback function that it provides; install your device under the keyboard device class in your INF and kbdclass will be automatically loaded in your device stack.

(*) the section is
Interactive Input Devices
Non HIDClass keyboard and mouse devices
Operation of Non hidclass keyboard and mouse drivers

And then specifically, the topic titled “Connect a Class Service Callback and a filter service callback to a device”. Ignore the points made about filters since you are writing the port driver yourself.

d

-----Original Message-----
From: Christiaan Ghijselinck [mailto:xxxxx@CompaqNet.be]
Sent: Tuesday, November 12, 2002 6:14 AM
To: NT Developers Interest List
Cc: xxxxx@nct.hu
Subject: [ntdev] Re: To send keyboard strokes in the kernel

Hi,

The “i8042prt” lies between the keyboard class-driver ( kbdclass ) and the
hardware. The
“kbdfilter” driver lies on top of the “kbdclass” driver. Probably, you need
both. You will
need a “i8042prt” like driver if your hardware reacts different from the
existing supported
keyboards. You will need a filter driver if you have to manipulate
keystrokes, generated by
your HW ( and i8042prt-like driver ). You may find an example of a
filter-driver that manipulates
keystrokes at

http://galileo.spaceports.com/~qualsoft/OPOSKeyboard/OPOSKeyboard.asp

To start, just look at the OKBDHook.c out of the driver directory ( "
OPOSKeyboard\OKBDHook\SYS ").
The driver is based on “crtl2cap” of Mark Russinovich (
www.sysinternals.com ).

Have success,

Christiaan

----- Original Message -----
From: “De?k Ferenc”
To: “NT Developers Interest List”
Cc:
Sent: Tuesday, November 12, 2002 2:03 PM
Subject: [ntdev] To send keyboard strokes in the kernel

> Hi,
>
> I have a special keyboard which connects to an industrial PC by dual-port
> RAM. The industrial PC will have no other keyboard. I want to write a
> kernel-mode dirver with the full functionality of a normal keyboard. I
have
> a driver to handle the dual-port RAM. At the present I send keyboard
strokes
> from user-mode by SendInput API function, but SendInput can not synthesize
> Ctrl-Alt-Del.
>
> How can I send keyboard strokes in the kernel? I have got some instruction
> from Mr. Holan:
>
> “To send keyboard strokes in the kernel, you must interface with kbdclass
> directly; there is no equivalent of SendInput. You need to have a pnp
> device stack whose device class is the keyboard class (this is set by
> the INF) and report keyboard strokes accordingly. There is the i8042prt
> (I think it is called pnpi8042 actually) example in the DDK which shows
> a keyboard port driver and kbdfiltr which shows a keyboard filter
> driver, but is much simpler then i8042prt”.
>
> A “keyboard driver” is required, not a “keyboard filter driver”, isn’t it?
>
> I have not found examples in the DDK and in the web how to develop a
custom
> keyboard driver. I study the DDK documentation, but I have no idea how to
> implement Mr. Holan’s instructions. There is an example for PS/2
(i8042prt)
> and an other example for a filter driver (kbfiltr), but I have not found
in
> it how to “interface with kbdclass dircetly”. I need some more help.
>
> Pleeeeeeease help!!
>
> Regards,
>
> Ferenc Deak
>
>
>
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@Compaqnet.be
> To unsubscribe send a blank email to %%email.unsub%%
>


You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to %%email.unsub%%

----- Original Message -----
From: “Doron Holan”

> The direct interface to kbdclass is the IOCTL_INTERNAL_KEYBOARD_CONNECT
> and the service callback function that it provides; install your device
under the
> keyboard device class in your INF and kbdclass will be automatically
loaded in your device stack.

OK. I (already) understand it. But what about PnP?

If I want to attach my device to the device stack of keyboard class then an
AddDevice function is needed, isn’t it?
IoCreateDevice and IoAttachDeviceToDeviceStack can be called in this
function.

But AddDevice is called by the PnP manager when a new device is detected. My
keyboard connects to the PC by a dual-port RAM mapped into the memory space.
Three bytes signes keystrokes and nothing else. No interrupt () and no PnP.
How will be it detected by the PnP manager? How will be my AddDevice called?

(
) I want to manage it by CustomTimerDpc

Regards,

Ferenc

How is your driver being loaded right now? As an NT4 style driver (ie, no power and pnp)? If so, you need to create a pnp style driver. You will need to create a root enumerated device node for your device, this will give you a pnp stack. (Root enumerated device’s are essentially pnp devices for which there is no way of detecting). You can look at the devcon application & example in the XP DDK to see how to manually install a device.

d

-----Original Message-----
From: Ferenc De?k [mailto:xxxxx@nct.hu]
Sent: Friday, December 06, 2002 2:49 AM
To: NT Developers Interest List
Cc: Doron Holan
Subject: [ntdev] Re: To send keyboard strokes in the kernel

----- Original Message -----
From: “Doron Holan”

> The direct interface to kbdclass is the IOCTL_INTERNAL_KEYBOARD_CONNECT
> and the service callback function that it provides; install your device
under the
> keyboard device class in your INF and kbdclass will be automatically
loaded in your device stack.

OK. I (already) understand it. But what about PnP?

If I want to attach my device to the device stack of keyboard class then an
AddDevice function is needed, isn’t it?
IoCreateDevice and IoAttachDeviceToDeviceStack can be called in this
function.

But AddDevice is called by the PnP manager when a new device is detected. My
keyboard connects to the PC by a dual-port RAM mapped into the memory space.
Three bytes signes keystrokes and nothing else. No interrupt () and no PnP.
How will be it detected by the PnP manager? How will be my AddDevice called?

(
) I want to manage it by CustomTimerDpc

Regards,

Ferenc


You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to %%email.unsub%%

I have found a sample program for installing root-enumerated driver in
ntddk\src\general\setup\install. What is “PnP HardwareID of device”?

Thank you for the answers.

Regards,
Ferenc

int __cdecl _tmain(int argc, _TCHAR **argv, _TCHAR **envp)
/*++
Routine Discription:

Entry point to install.exe.
Parse the command line, call subroutines.

Arguments:

Standard console ‘c’ application arguments.

argv[1] - Full path of INF file.
argv[2] - PnP HardwareID of device.

Return Value:

Standard Console ERRORLEVEL values:

0 - Install Successfull, no reboot required.
1 - Install Successfull, reboot required.
2 - Install Failure.

–*/

----- Original Message -----
From: “Doron Holan”
To: “NT Developers Interest List”
Sent: Friday, December 06, 2002 6:13 PM
Subject: [ntdev] Re: To send keyboard strokes in the kernel

How is your driver being loaded right now? As an NT4 style driver (ie, no
power and pnp)? If so, you need to create a pnp style driver. You will
need to create a root enumerated device node for your device, this will give
you a pnp stack. (Root enumerated device’s are essentially pnp devices for
which there is no way of detecting). You can look at the devcon application
& example in the XP DDK to see how to manually install a device.

d

The HardwareID for root-enumerated driver is the value that you have inside
the [DeviceList] section in your inf file
it should be something like *PNP303 (this Id is a keyboard ID).

Gil.

-----Original Message-----
From: xxxxx@nct.hu [mailto:xxxxx@nct.hu]
Sent: Monday, December 09, 2002 11:24 AM
To: NT Developers Interest List
Cc: xxxxx@windows.microsoft.com
Subject: [ntdev] Re: To send keyboard strokes in the kernel

I have found a sample program for installing root-enumerated driver in
ntddk\src\general\setup\install. What is “PnP HardwareID of device”?

Thank you for the answers.

Regards,
Ferenc

int __cdecl _tmain(int argc, _TCHAR **argv, _TCHAR **envp)
/*++
Routine Discription:

Entry point to install.exe.
Parse the command line, call subroutines.

Arguments:

Standard console ‘c’ application arguments.

argv[1] - Full path of INF file.
argv[2] - PnP HardwareID of device.

Return Value:

Standard Console ERRORLEVEL values:

0 - Install Successfull, no reboot required.
1 - Install Successfull, reboot required.
2 - Install Failure.

–*/

----- Original Message -----
From: “Doron Holan”
To: “NT Developers Interest List”
Sent: Friday, December 06, 2002 6:13 PM
Subject: [ntdev] Re: To send keyboard strokes in the kernel

How is your driver being loaded right now? As an NT4 style driver (ie, no
power and pnp)? If so, you need to create a pnp style driver. You will
need to create a root enumerated device node for your device, this will give
you a pnp stack. (Root enumerated device’s are essentially pnp devices for
which there is no way of detecting). You can look at the devcon application
& example in the XP DDK to see how to manually install a device.

d


You are currently subscribed to ntdev as: xxxxx@gntsteps.com
To unsubscribe send a blank email to %%email.unsub%%

OK, but how can I determine or declare a hardware ID for a new keyboard
class / root enumerated driver? (The HW is also new.)

[Version]
Signature=“$Windows NT$”
Provider=%NCT%
ClassGUID={4D36E96B-E325-11CE-BFC1-08002BE10318} <- this is the hardware ID
for install.exe?

----- Original Message -----
From: “Gil Mizrahi”
To: “NT Developers Interest List”
Cc:
Sent: Monday, December 09, 2002 10:32 AM
Subject: [ntdev] Re: To send keyboard strokes in the kernel

> The HardwareID for root-enumerated driver is the value that you have
inside
> the [DeviceList] section in your inf file
> it should be something like PNP303 (this Id is a keyboard ID).
>
> Gil.
>
> -----Original Message-----
> From: xxxxx@nct.hu [mailto:xxxxx@nct.hu]
> Sent: Monday, December 09, 2002 11:24 AM
> To: NT Developers Interest List
> Cc: xxxxx@windows.microsoft.com
> Subject: [ntdev] Re: To send keyboard strokes in the kernel
>
>
> I have found a sample program for installing root-enumerated driver in
> ntddk\src\general\setup\install. What is “PnP HardwareID of device”?
>
> Thank you for the answers.
>
> Regards,
> Ferenc
>
>
> int __cdecl _tmain(int argc, _TCHAR argv, _TCHAR envp)
> /
++
> Routine Discription:
>
> Entry point to install.exe.
> Parse the command line, call subroutines.
>
> Arguments:
>
> Standard console ‘c’ application arguments.
>
> argv[1] - Full path of INF file.
> argv[2] - PnP HardwareID of device.
>
> Return Value:
>
> Standard Console ERRORLEVEL values:
>
> 0 - Install Successfull, no reboot required.
> 1 - Install Successfull, reboot required.
> 2 - Install Failure.
>
> --*/
>
>
> ----- Original Message -----
> From: “Doron Holan”
> To: “NT Developers Interest List”
> Sent: Friday, December 06, 2002 6:13 PM
> Subject: [ntdev] Re: To send keyboard strokes in the kernel
>
>
> How is your driver being loaded right now? As an NT4 style driver (ie, no
> power and pnp)? If so, you need to create a pnp style driver. You will
> need to create a root enumerated device node for your device, this will
give
> you a pnp stack. (Root enumerated device’s are essentially pnp devices
for
> which there is no way of detecting). You can look at the devcon
application
> & example in the XP DDK to see how to manually install a device.
>
> d
>
>
>
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@gntsteps.com
> To unsubscribe send a blank email to %%email.unsub%%
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@nct.hu
> To unsubscribe send a blank email to %%email.unsub%%
>
>

No, and *pnpxxx ID is reserved for actually found hardware on the
motherboard. Please do *not* use that. Besides, it will install the
ps2 driver on your device which you do not want.

You can create your own hardware ID, if you want to be truly unique,
create a GUID and use the string representation of it, like
“root{3893d2ab-3870-46b9-b34e-b6c9f373eee1}” or create something on
your own like “ROOT\MY_OWN_SPECIAL_HARDWARE_ID”

d

-----Original Message-----
From: Gil Mizrahi [mailto:xxxxx@Gntsteps.com]
Sent: Monday, December 09, 2002 1:33 AM
To: NT Developers Interest List
Cc: Doron Holan
Subject: [ntdev] Re: To send keyboard strokes in the kernel

The HardwareID for root-enumerated driver is the value that you have
inside
the [DeviceList] section in your inf file
it should be something like *PNP303 (this Id is a keyboard ID).

Gil.

-----Original Message-----
From: xxxxx@nct.hu [mailto:xxxxx@nct.hu]
Sent: Monday, December 09, 2002 11:24 AM
To: NT Developers Interest List
Cc: xxxxx@windows.microsoft.com
Subject: [ntdev] Re: To send keyboard strokes in the kernel

I have found a sample program for installing root-enumerated driver in
ntddk\src\general\setup\install. What is “PnP HardwareID of device”?

Thank you for the answers.

Regards,
Ferenc

int __cdecl _tmain(int argc, _TCHAR **argv, _TCHAR **envp)
/*++
Routine Discription:

Entry point to install.exe.
Parse the command line, call subroutines.

Arguments:

Standard console ‘c’ application arguments.

argv[1] - Full path of INF file.
argv[2] - PnP HardwareID of device.

Return Value:

Standard Console ERRORLEVEL values:

0 - Install Successfull, no reboot required.
1 - Install Successfull, reboot required.
2 - Install Failure.

–*/

----- Original Message -----
From: “Doron Holan”
To: “NT Developers Interest List”
Sent: Friday, December 06, 2002 6:13 PM
Subject: [ntdev] Re: To send keyboard strokes in the kernel

How is your driver being loaded right now? As an NT4 style driver (ie,
no
power and pnp)? If so, you need to create a pnp style driver. You will
need to create a root enumerated device node for your device, this will
give
you a pnp stack. (Root enumerated device’s are essentially pnp devices
for
which there is no way of detecting). You can look at the devcon
application
& example in the XP DDK to see how to manually install a device.

d


You are currently subscribed to ntdev as: xxxxx@gntsteps.com
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to %%email.unsub%%