reading keyboard input without "consuming" it in x86 assembly

Posted by Bob on Stack Overflow See other posts from Stack Overflow or by Bob
Published on 2011-11-12T09:23:57Z Indexed on 2011/11/12 9:50 UTC
Read the original article Hit count: 132

Filed under:
|
|
|
|

Ok so here the deal:

I have an assignment regarding DOS and interrupts: I need to write a sort of key-logger function that can be called from C code. what it means is a c program would call an assembly function called startlog that would indicate to start logging the keys pressed until a function called endlog is called. the logging should work like this: write the ascii value of any key pressed without disturbing the C code between startlog and endlog, meaning that if the C code also needs to read the input (let's say by scanf, it would work ok).

I managed to write the logger by changing the interrupt vector 9th entry (interrupt for keyboard press) to a function I wrote that writes the values to a file, and it works fine. however the C code does not get the input. Basically what i did is read the key pressed using int 21h, however after reading the ascii value it is "consumed" so I need a way to either simulate the key press again or read the value without "consuming" it so next time a key is read it reads the same key. (I described the code in english because it is long and clumsy assembly code)

© Stack Overflow or respective owner

Related posts about c

    Related posts about assembly