Author Topic: Character input and TSR  (Read 6920 times)

Offline Spectre

  • Jr. Member
  • *
  • Posts: 2
Character input and TSR
« on: October 31, 2012, 12:54:57 AM »
Hello. I'm trying to make a keylogger that logs characters that user inputs in any program in DOS.I have two interrupt routines:

1. INT 60h - At the moment I read characters using BIOS call int 16h. I save characters in a buffer.
2. INT 1Ch - every 20 iterations ( ~1sec ) I check if any characters have been input and save them to a previously opened file, if needed.

It works as long as program is running (as long as I'm running the first routine as "main" - looping it). But when I attempt to actually modify the vector table on int60 and leave using int 27h, it stops working because (I guess) the read "function" is a blocking call. By stops working I mean the program returns to DOS and stops responding to user input while the underscore is blinking. I'm pretty sure my code is good, since I tested it several times, but I can still post it if needed.

The question is if its somehow possible to read input in a non blocking call? I tried using int 21h and checking stdin input status, but the problem remains. I think I'm missing the big picture here. When should my read character interrupt routine be called? And by who? I can't call it from my timer routine since it's not reentrant.

Btw. yes this is a school project and I'm not asking for any code, just a tip or two.

Thanks in advance,


Offline avcaballero

  • Full Member
  • **
  • Posts: 132
  • Country: es
    • Abre los Ojos al Ensamblador
Re: Character input and TSR
« Reply #1 on: October 31, 2012, 01:03:30 PM »
When you make a TSR you should save records well, including segments, otherwise you can get errors.

If you intercept an INT, at the end of your new ISR you have to call the original routine to keep it running.

Try the DOS Int 21h instead of 16h of the BIOS. Some time ago I created a program to count keystrokes.

Maybe it is not much, sorry.


Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2658
  • Country: us
Re: Character input and TSR
« Reply #2 on: October 31, 2012, 09:40:06 PM »
My thought on this would be to ignore any keyboard interrupts and monitor Bios Data Area. Hook timer interrupt just to know "when", and see if there's anything available by comparing "head pointer" and "tail pointer". If so, you might be able to write file straight from the keyboard buffer (if that interrupt works in these circumstances). Closing the file when you're done might be a problem... maybe need to make an uninstaller for your TSR that closes file? Dunno. TSRs are trickey, as you know. Might be able to help more when mains power is back on - running off  car battery now and time is limited...


Offline Spectre

  • Jr. Member
  • *
  • Posts: 2
Re: Character input and TSR
« Reply #3 on: October 31, 2012, 11:54:50 PM »
Good idea about comparing head and tail pointer, I will definitely try that.