How to Prevent a Warm Boot in Real ModeID: Q81887
|
The simultaneous pressing of the CTRL, ALT, and DEL keys (CTRL+ALT+DEL) causes the computer to restart. This article demonstrates one method of preventing this from occurring.
Every time a key is pressed, the following sequence of events take
place:
/* Compile options needed: None
*/
#include <dos.h>
#include <conio.h>
#include <stdio.h>
#define LOBYTE(x) ((unsigned char)((unsigned) x & 0x00FF) )
#define HIBYTE(x) ((unsigned char)(((unsigned) x & 0xFF00) >> 8 ))
#define BITSET(x, n) ((((unsigned char) x >> n) & 1) == 1 ? 1 : 0)
#define ESC 0x1B /* scan code for ESC */
#define DEL 0x53 /* scan code for DEL */
#define INT15 0x15 /* Interrupt to intercept */
#define KBD_INT_BIT 4 /* Int 15H Service 4FH support bit */
#define ESB_OFFSET 5 /* Environment status byte offset */
#define KBD_STATUS_PTR 0x00400017 /* Address of shift-state byte */
#define KEYBRD_INTERCEPT 0x4F /* Keyboard intercept subfunction */
/* NewInt15 will point to the new interrupt 15H handler */
void (_interrupt _far _cdecl *NewInt15)(
unsigned _es, unsigned _ds, unsigned _di,
unsigned _si, unsigned _bp, unsigned _sp,
unsigned _bx, unsigned _dx, unsigned _cx,
unsigned _ax, unsigned _ip, unsigned _cs,
unsigned _flags );
/* OldInt15 will point to the original interrupt 15H handler */
void (_interrupt _far _cdecl *OldInt15)(void);
/****************************************************************
void _interrupt _far _cdecl Int15(unsigned _es,unsigned ds,...)
This function hooks service 4FH, and checks for the
CTRL+ALT+DEL key combination. If detected, the system
reboot is prevented by consuming the DEL and exiting the
interrupt handler. Otherwise, call the default handler.
****************************************************************/
void _interrupt _far _cdecl Int15(unsigned _es,unsigned _ds,
unsigned _di,unsigned _si, unsigned _bp,
unsigned _sp,unsigned _bx, unsigned _dx,
unsigned _cx,unsigned _ax, unsigned _ip,
unsigned _cs,unsigned _flags )
{
unsigned char far *ptr=(unsigned char far *) KBD_STATUS_PTR;
if(HIBYTE(_ax)==KEYBRD_INTERCEPT) /* Was this a call to us? */
{
if(LOBYTE(_ax)==DEL) /* Was DEL key pressed? */
{
if(BITSET(*ptr,2)&&BITSET(*ptr,3)) /* CTRL and ALT pressed? */
{
_flags ^= 1; /* Consume DEL */
}
}
else
{
_chain_intr( OldInt15 ); /* Call default handler */
}
}
else
{
_chain_intr( OldInt15 ); /* Call default handler */
}
}
/************************************************************
int Supports_Int154F(void)
Detects whether the ROM BIOS keyboard intercept function
is supported.
RETURNS: TRUE if interrupt 15H service 4FH is supported,
FALSE if not.
**************************************************************/
int Supports_Int154F(void)
{
union REGS inregs,outregs;
struct SREGS segregs;
unsigned char far *config_flags;
/* Set up to get system environment information */
inregs.h.ah = 0xC0; /* Get system environment function */
/* Execute interrupt */
int86x( INT15, &inregs, &outregs, &segregs );
/* Get the configuration flags */
config_flags = (unsigned char far *) (((long)segregs.es << 16) |
((long) outregs.x.bx+ESB_OFFSET) );
/* Does this system support keyboard intercept function? */
return ( BITSET(*config_flags, KBD_INT_BIT) );
}
/***************************************
***************************************
**** MAIN PROGRAM BEGINS HERE ****
***************************************
***************************************/
void main(void)
{
unsigned ch;
if(Supports_Int154F()) /* program must support int 15 service */
{
OldInt15 = _dos_getvect( INT15 ); /* Save original handler */
NewInt15 = Int15; /* Get pointer to new handler */
_dos_setvect( INT15, NewInt15 ); /* Hook interrupt 15H */
printf("** WARM BOOT now disabled..."
"press Escape Key to Exit **\n");
ch = getch(); /* Initialize character buffer */
/**********************************
** LOOP UNTIL ESCAPE IS PRESSED **
**********************************/
while ( LOBYTE(ch) != ESC )
{
ch = getch();
}
_dos_setvect(INT15,OldInt15); /* Restore original handler */
}
else
{
printf("This machine does not support interrupt "
"15H service 4FH\n");
}
}
Additional query words: kbinf trap reset 6.00 6.00a 6.00ax 7.00 1.00 1.50
Keywords : kb16bitonly
Version :
Platform :
Issue type :
Last Reviewed: August 3, 1999