home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / TECLADO / KILBREAK.ZIP / KILL-2.ASM next >
Encoding:
Assembly Source File  |  1988-07-24  |  3.2 KB  |  140 lines

  1. ;CC-KILL.ASM 7-24-88
  2.  
  3. ;memory resident INT 9 routine
  4. ;occupies 512 bytes of RAM memory.
  5. ;
  6. ;PURPOSE:
  7. ;to defeat any CNTRL-C keypresses
  8. ;and CNTRL-BREAK
  9. ;
  10. ;7-24-88 modification:
  11. ;Allow key combination ALT 7 to
  12. ;perform the Control C function.
  13.  
  14. cseg segment para public 'code'
  15. org 100h
  16.  
  17. CCDEFEAT proc far
  18. assume cs:cseg, ds:cseg
  19. jmp  install
  20. oldint9 dd 0
  21. int9loc equ 9h*4
  22. kb_flag equ 417h
  23. ctrl equ 04
  24. alt equ 08
  25. noctrl equ 0ffh-ctrl
  26. ckey equ 46 ;C key keybd scan code
  27. seven equ 8 ;key scan code for 7 key
  28.             ;routine can be modified for
  29.             ;any ALT - ? combination if
  30.             ;key scan code is put here
  31.             ;for replacement of key 7
  32.  
  33. newint9:
  34.   sti
  35.   push es
  36.   push di
  37.   push ax
  38.   push cx
  39.   pushf
  40.   mov ax,0
  41.   mov es,ax
  42.   mov di,kb_flag
  43.   mov ah,es:[di]
  44.   test ah,ctrl ;control key down?
  45.   jz checkalt  ;if not then check alt key
  46.   in al,60h    ;get second key scan code
  47.   cmp al,ckey  ;was it the C key ?
  48.   jne return
  49.   and ah,noctrl      ;turn off ctrl flag
  50.   mov es:[di],ah     ;& put back KB_flag
  51.   jmp return
  52. checkalt:
  53.   test ah,alt  ;was ALT key pressed?
  54.   jz return    ;no, exit
  55.   in al,60h    ;get second key scan code
  56.   cmp al,seven ;was it the 7 key ?
  57.   jne return
  58. ;at this point ALT 7 has been pressed so
  59. ;           1. set keyb buffer head
  60. ;              to start of buffer
  61. ;           2. set keyb buffer tail
  62. ;              to start + 2 bytes
  63. ;           3. put CNTRL-C codes into first
  64. ;              word of buffer  03 2E
  65.   mov di,0480h    ;adr of keyb buff begin ptr
  66.                   ;just in case the software
  67.                   ;running has relocated the
  68.                   ;keyboard buffer, as some
  69.                   ;of mine does.
  70.   mov ax,es:[di]  ;get pointer value into ax
  71.   add ax,0400h    ;add 400 hex
  72.   push ax
  73.   pop di          ;put ax into di
  74.   mov cx,2E03h    ;Cntrl-C codes / backwards
  75.                   ;looks like 03 2E in buffer
  76.   mov es:[di],cx  ;install them in keyb buffer
  77.   sub ax,0400h
  78.   mov di,041Ah
  79.   mov es:[di],ax  ;set buffer head pointer
  80.                   ;to first byte of buffer.
  81.   add ax,0002h    ;bump buffer pointer
  82.   inc di
  83.   inc di
  84.   mov es:[di],ax  ;set tail word past the head
  85.                   ;telling DOS something waits
  86.                   ;in the buffer.
  87. return:
  88.   popf
  89.   pop cx
  90.   pop ax
  91.   pop di
  92.   pop es
  93.   jmp cs:[oldint9]
  94. ;
  95. install:
  96.   mov ax,0
  97.   mov es,ax
  98.   mov di,int9loc
  99.   mov ax,es:[di]
  100.   mov bx,es:[di+2]
  101.   mov si,offset oldint9
  102.   mov [si],ax
  103.   mov [si+2],bx
  104.   mov ax,0
  105.   mov es,ax
  106.   mov bx,ds
  107.   cli         ;disable interrupts
  108.   mov di,int9loc
  109.   mov ax,offset newint9
  110.   mov es:[di],ax
  111.   mov es:[di+2],bx
  112. ;
  113. ;now defeat the CNTRL/BREAK keys
  114. ;by changing INT 1Bh so that it
  115. ;points to an IRET instruction
  116. ;in ROM.
  117.   push ds
  118.   xor ax,ax
  119.   mov ds,ax
  120.   mov ax,0F000h ;CS
  121.   mov ds:[006Eh],ax
  122.   mov ax,0FF53h ;IP
  123.   mov ds:[006Ch],ax
  124.   pop ds
  125. ;
  126.   sti          ;enable interrupts
  127.   mov dx,offset install   ;put offset
  128.                           ;of end of
  129.                           ;resident
  130.                           ;program in
  131.                           ;DX reg.
  132.   int 27h ;terminate stay resident
  133. CCDEFEAT endp
  134.  
  135. cseg ends
  136. end CCDEFEAT
  137.  
  138.  
  139.  
  140.