From: Jon on
Hello all, I am interested in converting the "kbfiltr" example in the
Windows DDK from an upper keyboard filter driver i.e attaching to the
i8042 port driver to another upperfilter driver (?) attaching above
the keyboard class driver ( kbdclass.sys ).

I was wondering if there would be a lot of work involved? It seems
pretty easy. As of now, the kbfiltr filter driver attaches to the
device stack by doing something like:

IoAttachDeviceToDeviceStack(device, PDO);

but I was thinking that I could easily attach it to the keyboard class
driver by doing something like:

CCHAR ntNameBuffer[64] = "\\Device\\KeyboardClass0";
STRING ntNameString;
UNICODE_STRING uKeyboardDeviceName;
RtlInitAnsiString( &ntNameString, ntNameBuffer );
RtlAnsiStringToUnicodeString( &uKeyboardDeviceName, &ntNameString, TRUE
);
IoAttachDevice(pKeyboardDeviceObject,&uKeyboardDeviceName,&devExt->pKeyboardDevice);

But once I attach to the device stack, I could easily continue
intercepting keystrokes from the keyboard in the ServiceCallback
routine correct?

Thanks ahead of time for any comments

:)

From: anton bassov on
Jon,

> But once I attach to the device stack, I could easily continue
> intercepting keystrokes from the keyboard in the ServiceCallback
> routine correct?
>

Callback is used for communications between i8042prt and kbdclass. Once
kbdfilter is in between these two on the stack, it may make use of it.
However, callback has nothing to do with communications between
kbdclass and the system. Therefore, once a filter above kbdclass is
meant to monitor communications between kbdclass and the system, it
cannot make any use of a callback

Anton Bassov

Jon wrote:
> Hello all, I am interested in converting the "kbfiltr" example in the
> Windows DDK from an upper keyboard filter driver i.e attaching to the
> i8042 port driver to another upperfilter driver (?) attaching above
> the keyboard class driver ( kbdclass.sys ).
>
> I was wondering if there would be a lot of work involved? It seems
> pretty easy. As of now, the kbfiltr filter driver attaches to the
> device stack by doing something like:
>
> IoAttachDeviceToDeviceStack(device, PDO);
>
> but I was thinking that I could easily attach it to the keyboard class
> driver by doing something like:
>
> CCHAR ntNameBuffer[64] = "\\Device\\KeyboardClass0";
> STRING ntNameString;
> UNICODE_STRING uKeyboardDeviceName;
> RtlInitAnsiString( &ntNameString, ntNameBuffer );
> RtlAnsiStringToUnicodeString( &uKeyboardDeviceName, &ntNameString, TRUE
> );
> IoAttachDevice(pKeyboardDeviceObject,&uKeyboardDeviceName,&devExt->pKeyboardDevice);
>
> But once I attach to the device stack, I could easily continue
> intercepting keystrokes from the keyboard in the ServiceCallback
> routine correct?
>
> Thanks ahead of time for any comments
>
> :)

From: Jon on
Thanks Anton. I will look for other means than to intercept key
strokes.

From: Jon on
Thanks Anton. I will look for other means than to intercept key
strokes.

From: Maxim S. Shatskih on
> but I was thinking that I could easily attach it to the keyboard class
> driver by doing something like:
>
> CCHAR ntNameBuffer[64] = "\\Device\\KeyboardClass0";
> STRING ntNameString;
> UNICODE_STRING uKeyboardDeviceName;
> RtlInitAnsiString( &ntNameString, ntNameBuffer );
> RtlAnsiStringToUnicodeString( &uKeyboardDeviceName, &ntNameString,
>TRUE
> );
> IoAttachDevice(pKeyboardDeviceObject,&uKeyboardDeviceName,&devExt-
>pKeyboardDevice);

No you cannot. Use PnP instead and UpperFilters registration, forget
IoAttachDevice for PnP stacks.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim(a)storagecraft.com
http://www.storagecraft.com