Hi all,
I am new to device driver development and am currently writing an upper
filter driver for a USB keyboard. My first step I am trying is to
obtain the LED information from the keyboard from a user-mode
application. I have followed the Windows example (toaster filter)
regarding creating a control device object in the upper filter driver
and am able to obtain a handle to this control device object in the
user-mode application. However, I then attempt to obtain the LED
information as follows in the application:
USBHandle = CreateFile("\\\\.\\KeyboardUSB", GENERIC_READ |
GENERIC_WRITE, NULL, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (USBHandle != INVALID_HANDLE_VALUE) {
status = DeviceIoControl(USBHandle,
IOCTL_KEYBOARD_QUERY_INDICATORS, NULL, 0, &kbdParam, sizeof(kbdParam),
&outLength, NULL);
}
In the filter driver, I receive the correct IRP (as below in my
DispatchIO routine), but am unsure how to obtain and return the correct
data. Below shows what I am currently attempting to do.
irpStack = IoGetCurrentIrpStackLocation(Irp);
switch (irpStack->MajorFunction) {
case IRP_MJ_DEVICE_CONTROL:
#ifdef DEBUG
WriteLogFile("DispatchIo: IRP_MJ_DEVICE_CONTROL\r\n", 35);
#endif
switch (irpStack->Parameters.DeviceIoControl.IoControlCode) {
case IOCTL_KEYBOARD_QUERY_INDICATORS:
#ifdef DEBUG
WriteLogFile("DispatchIo:
IOCTL_KEYBOARD_QUERY_INDICATORS\r\n", 45);
#endif
return FilterPass(MainDeviceObject, Irp);
break;
default:
break;
}
default:
break;
}
Therefore, my main question is how to execute the IRPs correctly that
are created from my application using DeviceIoControl. Do I need to
use completion routines and if so, how should these be used?
Thanks in advance,
Kyzer