Log in

View Full Version : Hacking a keyboard driver...


squidge
April 20th, 2003, 15:38
I've gone and purchased a Logitech Navigator keyboard. Mainly because it was black and suited the rest of my setup.

It comes with several special added function keys along the top, labeled with things like "Email", "Messenger", "Webcam", "Shopping", etc, and also contains some multi media type buttons in the middle for volume control, volume mute/etc.

I figured I could use some of these buttons for something of more use, like frequently accessed webpages and programs. This is fine as the keyboard comes with a configuration program that allows you to redefine these keys.

However, the response to these keys is very sluggish, and the program itself also turns my function keys into annoying "enhanced keys" by giving them commands like "My Documents folder", "My Pictures Folder". This I hate.

So my first idea was to write a keyboard hook routine that would give me the scan codes of these keys so I can modify them in the hook to do what I want and get rid of the utility program. One small snag with this is that even with the WH_KEYBOARD_LL (lowlevel) keyboard hooks, no scan codes are reported for these keys.

I'm now thinking that these keys must either be filtered off by the driver and passed to the utility program in some other method (perhaps windows messages or events). So my best cause of action would be to hack up the driver to add scan codes for these keys so my keyboard hook routine can parse them.

Now, I've never hacked a keyboard driver before, so just wondering if anyone has any clues as to how they work, or possibly any URL's of websites that may help?

disavowed
April 20th, 2003, 18:31
Quote:
Originally posted by squidge
I'm now thinking that these keys must either be filtered off by the driver...

why not try disabling the driver, rebooting, and then trying your keyboard hook w/o the driver running?

squidge
April 21st, 2003, 04:12
Tried that, but then I don't get any codes whatsoever. Considering it's a USB keyboard I decided on a different approach. I connected the USB->PS2 converter, and then rebooted, and since it's no more USB it's not plug&play, so told Windows it was a standard 103 key keyboard.

Now a lot of the keys don't work anymore, but I do get the scan codes of these keys in my keyboard hook, so can change them to whatever I want. It's also a LOT faster than it was.

How come Logitech always make great hardware products and really crap drivers ? It's the same with there mice - the MX700 for example.

disavowed
April 21st, 2003, 08:15
i had to reformat a few years ago after logitech's mouse drivers rendered my keyboard useless (yes, keyboard) under win2k

/me no longer buys logitech products

Dedec0
April 27th, 2003, 20:38
disavowed, I am very curious to know how a program fucked up a piece of hardware... would you give us some details?

squidge, I am a beginner at this, so I can't tell you much anyway, but should get you started (if you didn't by now).
To directly control anyhardware from Windoze, you need a "ring0" program (aka VXD, and some others, I think). Normal EXEs are NOT alowed to direct access any hardware what so ever. So you may try searching for these things on google, win32asm, etc...

I am curious about reversing my mouse/ keyboard/ etc. specialy because I have some extra hardware (circuits, cables, etc.) that are no in use because some shitty mechanical plastic parts that were broken... most for a thing so stupid... Reusing that would be cool: imagine you have 2 mice, 1 normal and another one you use for "special tasks", with slight modification... or something. hehe...


Regards,

fuzzy_seacow
April 27th, 2003, 21:39
I've also been thinking of hacking the usb-keyboard driver (or writing a new one). I would like to use two usb-keyboards, one for ordinary typing and the other as programmable hotkeys. Sofar I've not found any program or driver that lets me do this. Have anyone else found a driver/util that lets you do this in 2000/XP?

tgodd
April 27th, 2003, 21:58
Sorry do not have a driver for you....

If you are interested in having a look at the usb, then
you should have a look at this:

hxxp://sourceforge.net/projects/usbsnoop/

and as usual xx must be changed to tt.

Hope that this helps.

Regards,

tgodd

fuzzy_seacow
April 27th, 2003, 22:17
Thanks for the hint about the sf project. Looks like a great starting point. Shouldn't be to hard to modify it for my needs. Wouldn't it be great to use one of thoose numeric usb-keyboards as a programmable hotkey board?

/seacow

UrgeOverKill
May 3rd, 2003, 22:10
Hey Squidge,

take a look at 'C:Windows\Inf\Keyboard.inf' and I think you might find what you are looking for there. If your good at decrypting....... the other file is "C:Windows\Inf\Keyboard.PNF'

squidge
May 4th, 2003, 05:55
Thanks UrgeOverKill, however my keyboard hook is working very well - lets me intercept all the special keys and seems to be quite reliable (certainly better than Logitech's offering anyway).

Source attached for anyone interested (18kb).

Note that this only works whilst in the PS2 port (USB is too laggy anyway).

kfw
May 7th, 2003, 12:16
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwui/html/wm_appcmd.asp