1

Is there any way to DIRECTLY read keyboard input?

By directly, I mean WITHOUT using Win API functions, or any pre written procedure. Just my plain assembly.

For example, my dad showed me his disassembly of a ZX-81 OS. We have found a procedure named 'INKEY$' which directly goes to the memory, copies the values of the keyboard buffer, and does whatever needs to be done with them. I know ZX-81 is historic, but I wanted to know if there is ANY way to read directly from the buffer.

I have disassembled 'user32.dll' and looked up for GetAsyncKeyState and GetKeyboardState. Heres a piece of code from GetAsyncKeyState which seems to be doing the 'reading from buffer' and deciding what to do if the key is pressed or not (Even though in both cases they jump to the same address...)

mov edx, [ebp+vKey]
cmp edx, 2
jz loc_7DC73234
cmp edx, 1
jz loc_7DC73234

My dad said it might be impossible to be done now because keyboards are connected with USB and they have drivers and stuff to do these low level actions. But then you can still read directly from wherever the keyboard drivers saves the keypresses.

So, can you still go to the memory and with a plain 'mov' instruction copy a value saying a key is pressed or not? Thanks.

Jong
  • 9,045
  • 3
  • 34
  • 66
  • Have you checked the "Related" questions, eg: http://stackoverflow.com/questions/219120/x86-assembly-protected-mode-keyboard-access – Kevin Stricker Aug 18 '11 at 18:15
  • I have checked some, not this one in particular but most of them didnt have the answer I want. Ill read this one now. – Jong Aug 18 '11 at 18:16
  • This question had some outdated info (i8042 - I think it IS different from core i7, isnt it?) and I couldnt figure out a straight answer from there. I DON'T want a method, I just want to know if it is possible. If it is, Ill keep studying it. If not... well, I won't. – Jong Aug 18 '11 at 18:26
  • 4
    Modern operating systems do not expose raw hardware buffers to applications. You could write a keyboard filter driver, but that's probably far more than you bargained for. – Raymond Chen Sep 05 '11 at 16:44
  • 1
    The i8042 is the chip that handles keyboards connected to the PS/2 port. No actual i8042 is present on modern motherboards but emulated by a super i/o chip. So this approch is still possible as long as the keyboard is connected to a PS/2 port (or emulated to be somehow), otherwise it's a comletely different story. Is your goal to come up with something that will function under windows or to learn how keyboard related hardware works? – Fabel Jul 29 '12 at 17:26

0 Answers0