home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / keyboard / break / breaknow.pas next >
Encoding:
Pascal/Delphi Source File  |  1989-07-13  |  1.6 KB  |  55 lines

  1.  
  2. Unit BreakNow;
  3. {
  4.  This Unit will intercept hardware interrupt $9 and check for a Ctrl-Break.
  5.  If the interrupt does not contain a Ctrl-Break the preceding Int9 is called.
  6.  If Ctrl-Break was pressed we call Turbo's int23 handler to stop execution
  7.  of the program, while still executing the ExitProcs.
  8. }
  9. interface
  10.  
  11. Uses DOS,CRT;
  12.  
  13.   { No interface }
  14.  
  15. implementation
  16.  
  17. Var
  18.   Int23,
  19.   OldExit,
  20.   OldKBD : pointer;
  21.  
  22. { This procedure will jump from an ISR to the ISR vector passed }
  23.  
  24. procedure JmpOldISR(OldISR: pointer);
  25.   inline($5B/$58/$87/$5E/$0E/$87/$46/$10/$89/
  26.          $EC/$5D/$07/$1F/$5F/$5E/$5A/$59/$CB);
  27.  
  28. {$F+}
  29. procedure Key_ISR( Flags,CS,IP,AX,BX,CX,DX,SI,DI,DS,ES,BP:word );
  30. interrupt;
  31. Begin
  32.   if CheckBreak and ((Mem[0000:$0417] and 4) = 4) and (Port[$60] = 70) then
  33.      Begin
  34.        inline($E4/$61/$8A/$E0/$0C/$80/$E6/$61/   { Clean up as the    }
  35.               $86/$E0/$E6/$61/$B0/$20/$E6/$20);  { Bios would         }
  36.        JmpOldISR( Int23 );   {Jump to current Int23 handler (turbo's) }
  37.      end;
  38.   JmpOldISR( OldKBD );       {Jump to Old Keyboard handler }
  39. End;
  40.  
  41. Procedure Exitit;
  42. Begin
  43.   ExitProc := OldExit;       { Restore Old ExitProc pointer }
  44.   SetIntVec( 9, OldKBD );    { Restore Old Int9 Handler     }
  45. end;
  46. {$F-}
  47.  
  48. Begin
  49.   OldExit := ExitProc;       { Save old ExitProc pointer }
  50.   ExitProc := @Exitit;       { Set new ExitProc pointer  }
  51.   GetIntVec( $23, Int23 );   { Get Current Int23 Vector  }
  52.   GetIntVec( 9, OldKBD );    { Get Current Int9  Vector  }
  53.   SetIntVec( 9, @Key_ISR );  { Set Int9 to our routine   }
  54. end.
  55.