home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / pascal / 7558 < prev    next >
Encoding:
Internet Message Format  |  1992-12-20  |  2.2 KB

  1. From: Phil.Hodges@f601.n105.z1.fidonet.org (Phil Hodges)
  2. Sender: postmaster@therose.pdx.com
  3. Path: sparky!uunet!psgrain!qiclab!therose!postmaster
  4. Newsgroups: comp.lang.pascal
  5. Subject: Disable Crtl-Break and C
  6. Message-ID: <724545516.AA00000@therose.pdx.com>
  7. Date: Mon, 14 Dec 1992 03:49:06 -0700
  8. Lines: 93
  9.  
  10. SL>From: sl9dm@cc.usu.edu
  11.   >Newsgroups: comp.lang.pascal
  12.  
  13.   >> What sort of code do I need to include in a pascal program (writen in
  14.   >> Borland Pascal 6.0) to disable CTRL-BREAK and CTRL-C?
  15.  
  16. SL>> How about CTR-ALT-DEL?
  17.   >>
  18.   >Not possible because the computer catches the CTL-ALT-DEL and reboots
  19. before
  20.   >the program sees it.
  21.  
  22.     NOT true! Ever hear of interrupt vectors?!!?!?!?!?!?!?!?! Try this unit.
  23. All you need to do is put Uses CAD, and it will disable C-A-D in your
  24. programs.
  25. You have to call RestoreCAD before leaving the program.
  26.  
  27. UNIT CAD;
  28.  
  29. INTERFACE
  30.  
  31. USES Dos;
  32.  
  33. VAR
  34.   Int9Handler  : POINTER;
  35.  
  36. PROCEDURE InterceptCtrlAltDel;
  37. PROCEDURE RestoreCAD;
  38.  
  39.   IMPLEMENTATION
  40.  
  41. PROCEDURE InterceptCtrlAltDel; Assembler;
  42.  
  43. CONST
  44.   Ctrl         = 4;
  45.   Alt          = 8;
  46.   Del          = $53;
  47.   KbdPort      = $60;                  { Keyboard port }
  48.   KbdCtrlPort  = $61;                  { Keyboard control port }
  49.   PIC          = $20;                  { 8259 Interrupt controller }
  50.   EOI          = $20;                  { End-of-interrupt }
  51.  
  52.   ASM
  53.  
  54.   PUSH   AX
  55.   PUSH   DS
  56.   MOV    AX, SEG @Data
  57.   MOV    DS, AX
  58.   STI
  59.   IN     AL, KbdPort
  60.   AND    AL, 01111111b
  61.   CMP    AL, Del
  62.   JNE    @2
  63.  
  64.   @1 :     MOV    AH, 2               { BIOS Get keyboard flags service }
  65.   INT    16h
  66.   TEST   AL, Ctrl + Alt
  67.   JNZ    @3
  68.  
  69.   @2 :     PUSHF
  70.   CALL   [Int9Handler]
  71.   JMP    @4
  72.  
  73.   @3 :     IN     AL, KbdCtrlPort
  74.   MOV    AH, AL
  75.   OR     AL, 10000000b
  76.   OUT    KbdCtrlPort, AL
  77.   XCHG   AH, AL
  78.   OUT    KbdCtrlPort, AL
  79.   CLI
  80.  
  81.   MOV    AL, EOI
  82.   OUT    PIC, AL
  83.   @4 :     POP    DS
  84.   POP    AX
  85.   IRET                       { make sure we return correctly }
  86. END;  { InterceptCtrlAltDel }
  87.  
  88. PROCEDURE RestoreCAD;
  89.  
  90. BEGIN
  91.   SETINTVEC (9, Int9Handler);
  92. END;  { RestoreCAD }
  93.  
  94.  
  95. BEGIN
  96.   GETINTVEC (9, Int9Handler);
  97.   SETINTVEC (9, @InterceptCtrlAltDel);
  98. END. {Unit CAD}
  99.  
  100.  
  101.  * SLMR 2.1a * COBOL programmers understand why women hate periods.
  102.  
  103.