HID mini or USB function driver?

A

Alexander Grau

Hello,

I have some USB HID devices (presenters/laserpointers with buttons) that
I need to read the buttons in a specific application only (to map the
buttons to specific actions defined in that application).

The problem is that some devices pretend to be an HID keyboard (which is
good to use them without drivers) but not really useful in my special
case ...

| my devices
------------------------------------------------------------
mouse keyboard|laserpointer irpresenter
usage page 0x01 0x01 |0x01 0x0c
usage 0x02 0x06 |0x06 0x01

Windows loads kbdhid.sys for them, exclusively opens them and then I
cannot open the device in user mode (CreateFile) to read any Input
Reports from the user application.

Now I have these ideas:

1) Writing a keyboard class filter driver would not work I think, as I
need to filter out the keystrokes for some specific devices and not all
keyboards in general.

2) Reading the irpresenter (see table) in user mode works works, I think
because it has usage page 0x0c (application specific). If I could change
the usage page from 0x01 (keyboard) to 0x0c in the HID Descriptor for
the other devices, I'm sure kbdhid.sys would not exclusively open the
device. What is the easiest to implement this? Replacing the hidusb.sys
minidriver by a custom one?

3) Writing a USB function driver for a specific device might work. The
disadvantage is that I would have to implement all the HID logic there...


Can someone give some recommendations or even support me with a sample
driver that could help me further?

Thank you!
Alexander
 
A

Alexander Grau

I solved my problem with an USB device lower filter:

1. Registered my "usbfilgr.sys" as LowerFilters for the device (Enum/USB).
In "DispatchInternalIOCTL" the driver watches for
URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE and
pDescriptorRequest->DescriptorType == 0x22 (Get Report Descriptor) and
in "InternalIOCTLCompletion" it "fixes" the report descriptor like this
to change usage page to "Application specific" (0x0c):

if ((buf[0] == 0x05) && (buf[1] == 0x01) && (buf[2] == 0x09)
&& ((buf[3] == 0x06) || (buf[3] == 0x02)) ){
KdPrint(("fixing...\n"));
buf[0] = 0x05;
buf[1] = 0x0c;
buf[2] = 0x09;
//buf[3] = 0x01;
}

2. Removed corresponding Collection entries for the device (Enum/HID).
After plugging in the device it is no longer recognized as HID keyboard
or mouse.

3. I can use user space functions (CreateFile, ReadFile) to read
InputReports and thereby read the button values.

The solution might not be the most elegant, but it "corrects" the
problem that my devices did behave like HID keyboards/mices...

Cheers,
Alexander
 
Joined
Oct 31, 2011
Messages
1
Reaction score
0
Hello, Alexander
I have the same problem
Can you send yuor source code of filter driver to my e-mail? ((e-mail address removed))
or more simply explained by

You change descriptor of you device?

thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top