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

  1. Xref: sparky comp.lang.pascal:7746 alt.lang.asm:520
  2. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!gatech!swrinde!network.ucsd.edu!munnari.oz.au!ariel.ucs.unimelb.EDU.AU!ucsvc.ucs.unimelb.edu.au!lugb!lux!cscmd
  3. Newsgroups: comp.lang.pascal,alt.lang.asm
  4. Subject: Re: Disable Crtl-Break and C
  5. Message-ID: <1992Dec30.153520.10692@lugb.latrobe.edu.au>
  6. From: cscmd@lux.latrobe.edu.au (Mitch Davis)
  7. Date: Wed, 30 Dec 1992 15:35:20 GMT
  8. Sender: news@lugb.latrobe.edu.au (USENET News System)
  9. References: <724545516.AA00000@therose.pdx.com>
  10. Organization: La Trobe University
  11. Lines: 209
  12.  
  13. In article <724545516.AA00000@therose.pdx.com> Phil.Hodges@f601.n105.z1.fidonet.org (Phil Hodges) writes:
  14. >SL>From: sl9dm@cc.usu.edu
  15. >  >Newsgroups: comp.lang.pascal
  16. >
  17. >SL>> How about CTR-ALT-DEL?
  18. >  >Not possible because the computer catches the CTL-ALT-DEL and reboots before
  19. >  >the program sees it.
  20. >
  21. >    NOT true! Ever hear of interrupt vectors?!!?!?!?!?!?!?!?! Try this unit.
  22. >
  23. >UNIT CAD;
  24.  
  25. Two ideas:
  26.  
  27.   o First, put RemoveCAD into the unit exit procedure so the application
  28.     automatically restores the CAD status upon leaving, and
  29.   o Making it an ASM TSR for size, etc.  Try this:
  30.  
  31. ; Uses TASM.  Author:  Mitch Davis 30-Dec-92
  32. .model tiny
  33. .code
  34.   org 0100h
  35.  
  36.   shifters equ 0417h
  37.   OurShift equ 0Ch    ;0Ch for Ctrl-Alt, 06h for Ctrl-Shift, 0Ah for Shift-Alt.
  38.  
  39. entry:
  40.   jmp main
  41.  
  42. MyInt09:
  43.   pushf
  44.   push ax ds
  45.   xor  ax, ax
  46.   mov  ds, ax
  47.   mov  al, ds:[Shifters]
  48.   and  al, 0Fh
  49.   cmp  al, OurShift
  50.   jne  Nope
  51.   in   al, 60H ;Read port to see what happened.
  52.   and  al, 7Fh     ;Make BREAK code equal to MAKE code.
  53.   cmp  al, 053h
  54.   je   Abort
  55.  
  56. Nope:
  57.   pop  ds ax
  58.   popf
  59.   jmp dword ptr cs:[OldInt09h]
  60.  
  61. Abort:
  62.   ; Reset keyboard
  63.   sti
  64.   in   al, 61H
  65.   mov  ah, al
  66.   or   al, 80h
  67.   out  61h, al
  68.   xchg ah, al
  69.   out  61h, al
  70.   ; Clear PIC
  71.   mov  al, 20h
  72.   out  20H, al
  73.   cli
  74.   pop  ax ds
  75.   popf
  76.   iret
  77.  
  78. OldInt09h: dd ?
  79.  
  80. NonTSR:
  81.  
  82. Cbreak:
  83.  
  84. ; Acts as a temporary ^Break handler - stops user pressing Break before
  85. ; program goes TSR!
  86.  
  87.   pushf
  88.   push ax dx
  89.   mov  dx, offset MESS02
  90.   call prmess
  91.   pop  dx ax
  92.   popf
  93.   clc
  94.   retf 2
  95.  
  96. prmess:
  97.   push ds
  98.   push cs
  99.   pop  ds
  100.   mov  ah, 09
  101.   int  21h
  102.   pop  ds
  103.   ret
  104.  
  105. getintvec:
  106.   push es
  107.   push bx
  108.   mov  ah, 35h
  109.   int  21h
  110.   mov  ax, bx
  111.   pop  bx
  112.   mov  [bx], ax
  113.   inc  bx
  114.   inc  bx
  115.   mov  [bx], es
  116.   pop  es
  117.   ret
  118.  
  119. setintvec:
  120.   push dx ds
  121.   mov  dx, [bx]
  122.   inc  bx
  123.   inc  bx
  124.   mov  ds, [bx]
  125.   mov  ah, 25h
  126.   int  21h
  127.   pop  ds dx
  128.   ret
  129.  
  130. main:
  131.   push cs
  132.   pop  ds
  133.  
  134.   mov  dx, offset heading
  135.   call prmess
  136.  
  137.   ; Install the Ctrl-Break interrupt handler:
  138.  
  139.   mov  bx, offset OldInt23
  140.   mov  al, 23h
  141.   call GetIntVec
  142.   mov  dx, offset CBreak
  143.   mov  ax, 2523h
  144.   int  21h
  145.  
  146.   ; Install the new key handler
  147.  
  148.   mov  bx, offset OldInt09h
  149.   mov  al, 9h
  150.   call GetIntVec
  151.  
  152.   mov  dx, offset MyInt09
  153.   mov  ax, 2509h
  154.   int  21h
  155.  
  156.   ; release environment
  157.  
  158.   mov  ax, word ptr ds:[002Ch] ; environment segment
  159.   mov  es, ax
  160.   mov  ah, 49h
  161.   int  21h
  162.  
  163.   ; display exit message
  164.  
  165.   mov  dx, offset MESS01
  166.   call prmess
  167.  
  168.   ; Restore old Ctrl-Break handler
  169.  
  170.   mov  bx, offset OldInt23
  171.   mov  al, 23h
  172.   call SetIntVec
  173.  
  174.   ; Go TSR
  175.   mov  ax, 3100h
  176.   mov  dx, offset NonTSR
  177.   mov  cl, 04
  178.   shr  dx, cl
  179.   inc  dx
  180.   int  21h
  181.  
  182. OldInt23: dd ?
  183. heading:  db 13,10,'No Ctrl-Alt-Del version 1.0, by Mitch
  184. Davis.',13,10,10,'$'
  185. MESS01:   db 'NoCAD has been installed.',13,10,'$'
  186. MESS02:   db '[Ctrl-Break Ignored] $'
  187. END entry
  188.  
  189. Or for those of you without TASM:
  190.  
  191. --8<--------------------------------------------------- 
  192.  N NOCAD.COM
  193.  E 0100 EB 73 9C 50 1E 33 C0 8E D8 A0 17 04 24 0F 3C 0C
  194.  E 0110 75 08 E4 60 24 7F 3C 53 74 08 1F 58 9D 2E FF 2E
  195.  E 0120 38 01 FB E4 61 8A E0 0C 80 E6 61 86 E0 E6 61 B0
  196.  E 0130 20 E6 20 FA 58 1F 9D CF 00 00 00 00 9C 50 52 BA
  197.  E 0140 13 02 E8 07 00 5A 58 9D F8 CA 02 00 1E 0E 1F B4
  198.  E 0150 09 CD 21 1F C3 06 53 B4 35 CD 21 8B C3 5B 89 07
  199.  E 0160 43 43 8C 07 07 C3 52 1E 8B 17 43 43 8E 1F B4 25
  200.  E 0170 CD 21 1F 5A C3 0E 1F BA C5 01 E8 CF FF BB C1 01
  201.  E 0180 B0 23 E8 D0 FF BA 3C 01 B8 23 25 CD 21 BB 38 01
  202.  E 0190 B0 09 E8 C0 FF BA 02 01 B8 09 25 CD 21 A1 2C 00
  203.  E 01A0 8E C0 B4 49 CD 21 BA F7 01 E8 A0 FF BB C1 01 B0
  204.  E 01B0 23 E8 B2 FF B8 00 31 BA 3C 01 B1 04 D3 EA 42 CD
  205.  E 01C0 21 00 00 00 00 0D 0A 4E 6F 20 43 74 72 6C 2D 41
  206.  E 01D0 6C 74 2D 44 65 6C 20 76 65 72 73 69 6F 6E 20 31
  207.  E 01E0 2E 30 2C 20 62 79 20 4D 69 74 63 68 20 44 61 76
  208.  E 01F0 69 73 2E 0D 0A 0A 24 4E 6F 43 41 44 20 68 61 73
  209.  E 0200 20 62 65 65 6E 20 69 6E 73 74 61 6C 6C 65 64 2E
  210.  E 0210 0D 0A 24 5B 43 74 72 6C 2D 42 72 65 61 6B 20 49
  211.  E 0220 67 6E 6F 72 65 64 5D 20 24
  212.  RCX
  213.  0129
  214.  W
  215.  Q
  216. --8<--------------------------------------------------- 
  217.  
  218. Extract between the scissors, and pipe it into DOS's DEBUG.
  219.  
  220. Mitch.
  221. [Did someone say this was comp.lang.pascal?  Sorry.]
  222.