Code:
#include <stdio.h>
#include <dos.h>
#include <conio.h>
#define INTR 0X09 /*The interrupt number for keyboard*/
/*These r scan codes of non-displayable keys*/
#define NIL -1
#define ESC 27
#define CTRL 29
#define SHFT 42
#define ALT 56
#define CAPS 58
#define F1 59
#define F2 60
#define F3 61
#define F4 62
#define F5 63
#define F6 64
#define F7 65
#define F8 66
#define F9 67
#define F10 68
#define NUM 69
#define SCRL 70
#define HOME 71
#define UP 72
#define PGUP 73
#define LEFT 75
#define FIVE 76
#define RGHT 77
#define END 79
#define DOWN 80
#define PGDN 81
#define INS 82
#define DEL 83
#define F11 87
#define F12 88
#define WIN 91
#define RTCK 93
#define POWR 94
#define SLEP 95
#define WAKE 99
/*The scancode-to-ASCII table*/
char ascii[]= {
NIL, ESC, '1', '2', '3', '4', '5', '6', '7', '8',
'9', '0', '-', '=', '\b', '\t', 'q', 'w', 'e', 'r',
't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', CTRL,
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';',
'\'', '`', SHFT, '\\', 'z', 'x', 'c', 'v', 'b', 'n',
'm', ',', '.', '/', SHFT, '*', ALT, ' ', CAPS, F1,
F2, F3, F4, F5, F6, F7, F8, F9, F10, NUM,
SCRL,HOME, UP, PGUP, '-', LEFT, FIVE, RGHT, '+', END,
DOWN, PGDN, INS, DEL, NIL, NIL, NIL, F11, F12, NIL,
NIL, WIN, WIN, RTCK, POWR, SLEP, NIL, NIL, NIL, WAKE
};
/*function pointer to save the old interrupt handler*/
void interrupt ( *oldhandler)(...);
/*our new interrupt handler. When u press a key, this function gets called*/
void interrupt handler(...)
{
unsigned char scan_code = inportb(0x60); /*read scancode byte from port 0x60*/
/* when the key is pressed,the MSB is cleared so check for this condition*/
if(!(scan_code & 0x80))
printf("%c",ascii[scan_code]);
outportb(0x20,0x20); /*acknowledge PIC that we have received interrupt*/
oldhandler(); /*call the old handler to do its work*/
}
void main()
{
/*save the old interrupt vector*/
oldhandler = getvect(INTR);
/*install the new interrupt handler*/
setvect(INTR, handler);
/*A delay of 10 seconds. What ever u type in this period,will be displayed by our new interrupt handler*/
delay(10000);
/*reset the old interrupt handler*/
setvect(INTR, oldhandler);
}
Alright, now I understand all the code, and I use Dev-C++. Do I just open it and hit "Compile"...and rename the EXE to VXD? I'd have to write an INF to install it..but is there anything else to it....would it work in Windows?