home *** CD-ROM | disk | FTP | other *** search
- /************************************************
- * norb.c - Prevent Control-Alt-Delete reboots *
- * *
- * 891105 MCMason - originally coded *
- ************************************************/
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <dos.h>
- #include <conio.h>
- #include <signal.h>
-
- #define TRUE (1==1) /* BOOLEAN TRUE */
- #define ksDELCODE 0x53 /* DEL scan code*/
- static char far *_RB_keystat; /*Kbd status ptr*/
-
- /* Storage for old keyboard interrupt handler */
- static void (interrupt far *OldInt09H)(void);
-
- /************************************************
- * RBinstall - install new kbd handler, install *
- * func RBremove in ^Break handler. *
- * *
- * OUT: _RB_keystat - points to kbd status byte *
- * OldInt09H - points to old kbd intr hdlr *
- ************************************************/
- void RBinstall(void)
- {
- OldInt09H = getvect(0x09); /* Get old hdlr */
- setvect(0x09,NewInt09H); /* Put new hdlr */
- signal(SIGINT,RBremove); /* Trap ^Break */
- /* point to keyboard status byte */
- _RB_keystat = (char far *)0x00400017;
- }
-
- /************************************************
- * RBremove - remove new kbd handler *
- ************************************************/
- void RBremove(void)
- {
- puts("Program terminated...");
- setvect(0x09,OldInt09H);
- exit(TRUE);
- }
-
- /************************************************
- * NewInt09H - New keyboard interrupt handler. *
- * Detect (and prevent) Ctrl-Alt-Del reboots *
- ************************************************/
- void interrupt far NewInt09H(void)
- {
- int i,j;
- i=inp(0x60); /* Get scan code */
- if (((i&0x7f)==ksDELCODE) && /*DELete? */
- ((*_RB_keystat&0x0c)==0x0c)) /*CTL+ALT?*/
- {
- j = inp(0x61); /* Save kbd status */
- outp(0x61,j|0x80); /* Reset kbd intrpt */
- outp(0x61,j&0x7f);
- outp(0x20,0x20);
- }
- else
- (*OldInt09H)(); /* Process key */
- }
-