Upvote Upvoted 16 Downvote Downvoted
Writing a Windows Driver
posted in Hardware
1
#1
0 Frags +

So, recently I bought an IBM terminal keyboard. Knowing that the general consensus is that these cannot be made to work with Windows (barring a microcontroller), I thought this would be a fun project.

So far, I have cleaned the board up, made an adapter from the proprietary 240-degree 5-pin DIN adapter to PS/2, and successfully gotten characters to print out under Windows. Many of the scancodes sent by the keyboard did not map correctly to their keycaps (or in some cases the functions on the keycaps did not exist anymore!), so I used a registry entry documented here as well as information on the scancodes sent by the keyboard here (second diagram), and a list of actual scancodes found here. This has so far resulted in this registry entry (the <>, and grey block above the arrow keys have yet to be remapped).

So far, so good. However, at this point I noticed some oddities with respect to the function of the numlock and scroll lock keys (but not capslock), as well as numerous issues with attempting to use the keyboard in any games. Using this program, I deduced that the keyboard is not sending keyup scancodes. This thread states that a filter driver is needed to call IOCTL_INTERNAL_I8042_KEYBOARD_WRITE_BUFFER to send commands to the keyboard, which can be used to make the keyboard send keydown and keyup scancodes (possibly without repeating, but that may not be an issue).

I, however, have absolutely no clue where to begin with writing a driver. If anyone could offer some expertise on the matter, I would be quite grateful.

tl;dr, does anyone know how to write a Windows 7 filter driver?

So, recently I bought an [url=http://www.ebay.com/itm/171532623187?_trksid=p2060778.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT]IBM terminal keyboard[/url]. Knowing that the general consensus is that these cannot be made to work with Windows (barring a microcontroller), I thought this would be a fun project.

So far, I have cleaned the board up, made an adapter from the proprietary 240-degree 5-pin DIN adapter to PS/2, and successfully gotten characters to print out under Windows. Many of the scancodes sent by the keyboard did not map correctly to their keycaps (or in some cases the functions on the keycaps did not exist anymore!), so I used a registry entry documented [url=https://msdn.microsoft.com/en-us/library/windows/hardware/jj128267%28v=vs.85%29.aspx]here[/url] as well as information on the scancodes sent by the keyboard [url=http://www.seasip.info/VintagePC/ibm_1390876.html]here[/url] (second diagram), and a list of actual scancodes found [url=https://msdn.microsoft.com/en-us/library/aa299374%28v=vs.60%29.aspx]here[/url]. This has so far resulted in [url=http://puu.sh/f3aLZ/b2f7a9b390.txt]this registry entry[/url] (the <>, and grey block above the arrow keys have yet to be remapped).

So far, so good. However, at this point I noticed some oddities with respect to the function of the numlock and scroll lock keys (but not capslock), as well as numerous issues with attempting to use the keyboard in any games. Using [url=http://www.delphiforfun.org/programs/utilities/KeyCodes.htm]this program[/url], I deduced that the keyboard is not sending keyup scancodes. [url=https://geekhack.org/index.php?topic=6770.45;wap2]This[/url] thread states that a [url=https://msdn.microsoft.com/en-us/library/windows/hardware/ff545890%28v=vs.85%29.aspx]filter driver[/url] is needed to call IOCTL_INTERNAL_I8042_KEYBOARD_WRITE_BUFFER to send commands to the keyboard, which can be used to make the keyboard send keydown and keyup scancodes (possibly without repeating, but that may not be an issue).

I, however, have absolutely no clue where to begin with writing a driver. If anyone could offer some expertise on the matter, I would be quite grateful.

tl;dr, does anyone know how to write a Windows 7 filter driver?
2
#2
3 Frags +

Writing a driver seems a tad out of the scope of this forum. You will probably have more luck over at MSDN.

Writing a driver seems a tad out of the scope of this forum. You will probably have more luck over at [url=https://social.msdn.microsoft.com/Forums/en-US/home]MSDN[/url].
3
#3
1 Frags +

Good point, I had tried asking on a few StackExchange sites though. I entirely forgot about the MSDN forums.

Good point, I had tried asking on a few StackExchange sites though. I entirely forgot about the MSDN forums.
4
#4
4 Frags +

No idea. Cool project though 8)

No idea. Cool project though 8)
5
#5
7 Frags +
AdmirableNo idea. Cool project though 8)

+1
keep us updated

[quote=Admirable]No idea. Cool project though 8)[/quote]

+1
keep us updated
6
#6
4 Frags +

The QL Accel filter driver I made is based on some example code from MSDN (moufiltr). There is a similar piece of example code for keyboards called kbdfiltr (located here). I'm not sure if theres anything I can offer regarding specifics from this point on. Keep in mind if you are using 64-bit, you will need to enable test signing, create/import your own certificate and self-sign your driver or it will not load.

The QL Accel filter driver I made is based on some example code from MSDN (moufiltr). There is a similar piece of example code for keyboards called kbdfiltr (located [url=https://code.msdn.microsoft.com/windowshardware/Kbfiltr-WDF-Version-685ff5c4]here[/url]). I'm not sure if theres anything I can offer regarding specifics from this point on. Keep in mind if you are using 64-bit, you will need to enable test signing, create/import your own certificate and self-sign your driver or it will not load.
7
#7
1 Frags +

I had entirely forgotten about signing drivers, thanks. This thread, however, confirms my belief that I need to modify i8042prt, rather than writing a new filter driver. Sadly, all of the links to prebuilt drivers are down, and the diff file from here doesn't actually correspond to the source for i8042prt that I found.

I had entirely forgotten about signing drivers, thanks. [url=https://geekhack.org/index.php?topic=8046.0]This[/url] thread, however, confirms my belief that I need to modify i8042prt, rather than writing a new filter driver. Sadly, all of the links to prebuilt drivers are down, and the diff file from [url=http://www.seasip.info/VintagePC/ibm_1390876.html]here[/url] doesn't actually correspond to the source for i8042prt that I found.
8
#8
1 Frags +
povohatThe QL Accel filter driver I made is based on some example code from MSDN (moufiltr). There is a similar piece of example code for keyboards called kbdfiltr (located here). I'm not sure if theres anything I can offer regarding specifics from this point on. Keep in mind if you are using 64-bit, you will need to enable test signing, create/import your own certificate and self-sign your driver or it will not load.

You made a filter driver? Iv been doing some asm in my EE courses and I have wanted to write some drivers for old tech I have. Do you have any source code to your driver?

[quote=povohat]The QL Accel filter driver I made is based on some example code from MSDN (moufiltr). There is a similar piece of example code for keyboards called kbdfiltr (located [url=https://code.msdn.microsoft.com/windowshardware/Kbfiltr-WDF-Version-685ff5c4]here[/url]). I'm not sure if theres anything I can offer regarding specifics from this point on. Keep in mind if you are using 64-bit, you will need to enable test signing, create/import your own certificate and self-sign your driver or it will not load.[/quote]

You made a filter driver? Iv been doing some asm in my EE courses and I have wanted to write some drivers for old tech I have. Do you have any source code to your driver?
9
#9
2 Frags +
DarkTechNoYou made a filter driver? Iv been doing some asm in my EE courses and I have wanted to write some drivers for old tech I have. Do you have any source code to your driver?

I didn't really 'write' a driver. I took the moufiltr example code which has all the important stuff already written. I just added some code that reads some registry values and manipulates each packet of mouse data that has movement information in it. The source for the previous version is up on the site.

I should mention that I'm not a legit programmer and don't really know much about drivers or C or anything like that. I sorta fumbled my way through using the internet and bouncing some ideas off other ppl in irc.

[quote=DarkTechNo]You made a filter driver? Iv been doing some asm in my EE courses and I have wanted to write some drivers for old tech I have. Do you have any source code to your driver?[/quote]

I didn't really 'write' a driver. I took the moufiltr example code which has all the important stuff already written. I just added some code that reads some registry values and manipulates each packet of mouse data that has movement information in it. The source for the previous version is up [url=http://accel.drok-radnik.com]on the site[/url].

I should mention that I'm not a legit programmer and don't really know much about drivers or C or anything like that. I sorta fumbled my way through using the internet and bouncing some ideas off other ppl in irc.
10
#10
0 Frags +

Gotcha, well lifes hitting me really hard right now, maybe ill look into it in the future.

Gotcha, well lifes hitting me really hard right now, maybe ill look into it in the future.
Please sign in through STEAM to post a comment.