  CAD_INT9.PAS
  ------------
  Pascal source code to prevent Control-Alt-Delete from reaching
  the replaced Keyboard Interrupt Service Routine

  Copyright
  ---------
  Copyright Joseph Kevin Robertson, April 1995

  Contact
  -------
  Electronic Mail : MCSCS3JKR@ZIPPY.DCT.AC.UK

  Disclaimer
  ----------

  Mr. J. K. Robertson, MCSCS3JKR@ZIPPY.DCT.AC.UK, hereby disclaims
  all warranties relating to the use of the software herein - namely
  CAD_INT9.

  Mr. J. K. Robertson will not be liable for any incidental,
  consequential, special, indirect, or similar damages due to
  loss of data or any other reason.

  The user using this example application assumes all responsibility
  for its use, its quality, and performance.

  Description
  -----------

  Assuming control of the Interrupt 9 Service Routine allows control
  over the specific key presses that are passed to the Old Keyboard
  Interrupt Service Routine (OKISR).

  In this application the keypress of Control-Alt-Delete has been
  captured, with ALL other keypresses being passed to the OKISR.

  This prevents Control-Alt-Delete from reseting (warm booting) the system,
  thus your application can deal with critical tasks such as storing data
  onto secondary storage, where a Non-Maskable Interrupt such as
  Control-Alt-Delete could corrupt data.

  Once the application is terminated successfuly, or should the application
  be terminated via a Control-Break keypress, then the OKISR is restored.

  How does it work?
  -----------------

  When you turn your P.C. on the BIOS chip initialises the vector table.
  Ms-Dos resets the Keyboard Interrupt Service Routine ($9) to code of its
  own thus 'creating' a keyboard handler. Once Ms-Dos has been loaded,
  pressing a key upon the keyboard (one that generates a scan code) will
  cause execution of the Ms-Dos KISR.

  What this application does is place a new KISR before the current KISR.

  So what does that mean? Basically, the memory location of the current
  KISR is stored, to allow us to restore its location when we exit the
  application, and the address of our new KISR is placed into the Interrupt
  Vector table.

  Now any keypress that generates a scan code will call the new KISR.

  When the new KISR is executed it compares the value of the Keyboard Flag
  byte located at memory location $0040:$0017 to see if bits 2 and 3 have
  set to logic '1'. If both of these bits have been set then that indicates
  Control-Alt has been pressed.

       Byte value at memory location $0040$0017

           Most                           Least
           Significant Bit ... 76543210 ... Significant Bit
                                   ..
                                   ....... CTRL key depressed
                                   ....... ALT key depressed

  If Control-Alt has NOT been depressed, or Control-Alt has been depressed
  but the generated scan code is NOT that of the delete key then control is
  passed to the replaced KISR.

  This method of interception allows use of Control-Alt-Something keypresses
  within an application, with the advantage that the Delete key is still
  available as a standard keypress.

  Further Information
  -------------------

  It should be noted that if another Int 9H interrupt is installed alongside
  this one then there is no guarantee that this application will still
  prevent a warm boot. Further Int 9H Interrupt Routines may force a
  warm boot upon capture of the Control-Alt-Delete keypress.
