home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / PCACHSRC.ZIP / TSR9.ASM < prev    next >
Assembly Source File  |  1995-01-01  |  3KB  |  90 lines

  1. ;ISR9.ASM --- Skeleton TSR, hooks IVT-9...
  2. ;assemble and link like a normal .EXE program.
  3. .286
  4. .MODEL SMALL
  5. .STACK
  6. .DATA
  7. psp_size = 10h        ;in paragraphs (100h/16)
  8.  
  9. ;..................................................
  10. .CODE
  11. start:  
  12.     jmp     installhooks          ;go to install portion
  13.  
  14.     oldoffivt9  DW      0
  15.     oldsegivt9  Dw      0
  16.     oldoffivt28 DW      0
  17.     oldsegivt28 DW      0
  18.     bypass      DB      0      ;fix reentrancy problems.
  19.     killkeyboard DB     1      ;=1 disable keyboard.
  20.  
  21. ;....................................................
  22. runtime9:                      ;resident ISR.
  23.     push    es              ;save all registers.
  24.     push    ds              ;   /
  25.     pusha                   ;   /
  26.  
  27.     pushf
  28.     call    DWORD PTR cs:oldoffivt9     ;call old vector
  29.  
  30.     mov     ax,40h        ;keybuffer in BIOS data-area.
  31.     mov     es,ax
  32.     mov     bx,1Ah
  33.         mov     ax,es:[bx+2]    ;get tail pointer
  34.         mov     cx,es:[bx]      ;get head pointer
  35.  
  36.         cmp     ax,cx
  37.         je      getout          ;buffer is empty
  38.         mov     si,cx
  39.         mov     dx,es:[si]      ;get ascii/scancode out of buffer.
  40.         cmp     dx,2C00h        ;test for <ALT-Z> hotkey.
  41.         jne     nothot          ;not the hotkey.
  42.         xor     cs:killkeyboard,1       ;toggle keyboard enable/disable.
  43.  
  44. killit:
  45.     mov     es:[bx],ax    ;clr key buffer
  46.         jmp     SHORT getout
  47.  
  48. nothot:
  49.         cmp     cs:killkeyboard,1
  50.         je      killit
  51.  
  52. getout:
  53.     popa
  54.     pop     ds
  55.     pop     es
  56.     iret
  57.  
  58. ;......................................................
  59.     DB      17      DUP(0)
  60. dumpme:
  61. ;......................................................
  62. installhooks:
  63.     push    cs
  64.     pop     ds  ;note cs: overrides thus not really reqd.
  65.  
  66. ;hook int-9....
  67.     mov     ax,3509h                ;get old vector.
  68.     int     21h                     ;IVT-->es:bx
  69.     mov     oldoffivt9,bx
  70.     mov     oldsegivt9,es
  71.     mov     ax,2509h                ;set vector.
  72.     lea     dx,runtime9             ;ds:dx-->IVT
  73.     int     21h
  74.  
  75. ;terminate, leave resident....
  76.     lea     dx,dumpme       ;point past all resident code.
  77.     shr     dx,4            ;compute # paragraphs to keep.
  78.     add     dx,psp_size     ;       /
  79.     mov     ax,3100h        ;terminate and stay resident.
  80.     int     21h             ;       /
  81.  
  82. ;......................................................
  83.     END     start
  84.  
  85. Note that it is not necessary to use CLI to disable hardware interrupts
  86. at the beginning of RUNTIME9:, as ISRs are always entered with the IF
  87. clear.
  88. Nor will we put STI inside RUNTIME9:, to allows hardware interrupts,
  89. as that creates an interrupt nesting problem... potentially.
  90.