Advertisement
HabKaffee

Untitled

Mar 26th, 2020
534
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CODE_SEG SEGMENT
  2. ASSUME CS:CODE_SEG,DS:code_seg
  3.  
  4. ORG 100H
  5.  
  6. START:
  7. JMP BEGIN
  8. ;================================== data ====================================
  9. int_2Fh_vector DD ?
  10. old_09h DD ?
  11.  
  12. flag        DB  0
  13. ; window's coords
  14. high_Y      DB  01  
  15. left_X      DB  01  
  16. low_Y       DB  15  
  17. right_X     DB  30  
  18. ;
  19. page_num    DB  0
  20. ;message's coords in window
  21. coord_Y     DB  4  
  22. coord_X     DB  15
  23.  
  24. buffer      DB  ?
  25. tail        DW 0
  26. count       DB 0
  27. ;=============================================================================
  28. new_09h proc far
  29.     push AX
  30.     push ES
  31.    
  32.     mov AX,40h
  33.     mov ES,AX
  34.     mov AX,ES:[1Ch]
  35.     mov CS:tail,AX
  36.    
  37.     pop ES
  38.     pop AX
  39.    
  40.     pushf
  41.     call CS:old_09h
  42.    
  43.     push AX
  44.     push BX
  45.     push ES
  46.    
  47.     mov AX,40h
  48.     mov ES,AX
  49.     mov BX,CS:tail
  50.     cmp BX,ES:[1Ch]
  51.     je exit1
  52.     jmp cont
  53. exit1:
  54.     pop ES
  55.     pop BX
  56.     pop AX
  57.     iret
  58. cont:
  59.     pushf
  60.     push    AX
  61.     in      AL,60h    ; enter scan-code
  62.     cmp     AL,58h      ; scan-code <F12>
  63.     je      hotkey      ; Yes
  64.     inc CS:count
  65.     pop     AX    ; No. Restore AX
  66.     popf
  67.     jmp     dword ptr CS:[old_09h]
  68. hotkey:
  69.     sti                
  70.     in      AL,61h      ; Enter B port's content
  71.     or      AL,80h      ; Set elder bit
  72.     out     61h,AL      ; return to content to B port.
  73.     and     AL,7Fh      ; Enable keyboard,
  74.     out     61h,AL      ; Reset older bit from B port .
  75. ;
  76. ;-------------------- Window output by BIOS ---------------------------
  77. ;
  78.     ;save used registers            
  79.             push    BX  
  80.             push    CX  
  81.             push    DX  
  82.             push    DS  
  83.     ;set our register to ds
  84.             push    CS  ;
  85.             pop     DS  ;
  86. ;----------------------------------------------------------------------------
  87.         mov     AX, 0600h      ; Set window
  88.         mov     BH, 70h        ; attribute Black on write
  89.         ;window's coordinates
  90.         mov     CH, high_Y    
  91.         mov     CL, left_X  
  92.         mov     DH, low_Y  
  93.         mov     DL, right_X
  94.         int 10h
  95. ; ------------------------ Set cursors's position -----------------------------
  96.         mov     AH,02h       ; Set position func
  97.         mov     BH,page_num  ; Video
  98.         mov     DH,coord_Y   ; string
  99.         mov     DL,coord_X   ; row
  100.         int 10h
  101.        
  102.     mov ah, 2
  103.     mov dl, count
  104.     int 21h
  105. ;return cursor
  106. ;        mov     AH,02h          ; Set position func
  107. ;        mov     BH,0;
  108. ;        mov     DH,24  ; string
  109. ;        mov     DL,12  ; row
  110. ;        int 10h
  111.  
  112.             pop     DS  ; Reset registers
  113.             pop     DX
  114.             pop     CX
  115.             pop     BX
  116. ;---------------------------------------------------------------------------
  117.     cli
  118.     ;end of interrupt
  119.     mov     AL, 20h      
  120.     out     20h,AL    
  121. ;
  122.     pop     AX
  123.     popf
  124.    
  125. ;============================
  126. exit:
  127. pop ES
  128. pop BX
  129. pop AX
  130. iret
  131. new_09h endp
  132. ;=============================================================================
  133. ;
  134. ;=============================================================================
  135. int_2Fh proc far
  136.     cmp     AH,0C7h         ; Is it our num?
  137.     jne     Pass_2Fh        ; go exit
  138.     cmp     AL,00h          ; Already installed?
  139.     je      inst            ;
  140.     cmp     AL,01h          ; Unload?
  141.     je      unins           ; Yes, go to unload
  142.     jmp     Pass_2Fh        ; Unknown command
  143. inst:
  144.     mov     AL,0FFh         ; Already installed
  145.     iret
  146. Pass_2Fh:
  147.     jmp dword PTR CS:[int_2Fh_vector]
  148. ;
  149. ; -------------- Is unload possible ? ------
  150. unins:
  151.     push    BX
  152.     push    CX
  153.     push    DX
  154.     push    ES
  155. ;
  156.     mov     CX,CS   ; for compairing
  157.     mov     AX,3509h    ; check 09h
  158.     int     21h ; Return vector in ES:BX
  159. ;
  160.     mov     DX,ES
  161.     cmp     CX,DX
  162.     jne     Not_remove
  163. ;
  164.     cmp     BX, offset CS:new_09h
  165.     jne     Not_remove
  166. ;
  167.     mov     AX,352Fh    ; Check vector 2Fh
  168.     int     21h
  169. ;
  170.     mov     DX,ES
  171.     cmp     CX,DX
  172.     jne     Not_remove
  173. ;
  174.     cmp     BX, offset CS:int_2Fh
  175.     jne     Not_remove
  176.     ; ---------------------- Unload from memory ---------------------
  177. ;
  178.     push    DS
  179. ;
  180.     lds     DX, CS:old_09h  
  181.     mov     AX,2509h        ; Fill vector by old content
  182.     int     21h
  183. ;
  184.     lds     DX, CS:int_2Fh_vector  
  185.     mov     AX,252Fh
  186.     int     21h
  187. ;
  188.     pop     DS
  189. ;
  190.     mov     ES,CS:2Ch       ; ES -> enviroment
  191.     mov     AH, 49h         ; Free memory function
  192.     int     21h
  193. ;
  194.     mov     AX, CS
  195.     mov     ES, AX          ; ES -> PSP unload programm
  196.     mov     AH, 49h         ; Free memory function
  197.     int     21h
  198. ;
  199.     mov     AL,0Fh          ; Successful uninstall
  200.     jmp     pop_ret
  201. Not_remove:
  202.     mov     AL,0F0h          ; Can't unload
  203. pop_ret:
  204.     pop     ES
  205.     pop     DX
  206.     pop     CX
  207.     pop     BX
  208. ;
  209.     iret
  210. int_2Fh endp
  211. ;=============================================================================
  212. begin:
  213. mov AX,0C700h
  214. int 2Fh
  215. cmp AL, 0
  216. jz not_installed
  217. lea DX,msg
  218. call print
  219. int 20h
  220. msg DB 'Already installed',13,10,'$'
  221. not_installed:
  222. mov AX,352Fh
  223. int 21h
  224. mov word ptr int_2Fh_vector,BX
  225. mov word ptr int_2Fh_vector+2,ES
  226. mov DX,offset int_2Fh
  227. mov AX,252Fh
  228. int 21h
  229. mov AX,3509h
  230. int 21h
  231. mov word ptr old_09h,BX
  232. mov word ptr old_09h+2,ES
  233. mov DX,offset new_09h
  234. mov AX,2509h
  235. int 21h
  236. ;------------------------------------------------------------------------------
  237. mov DX,offset begin
  238. int 27h
  239. ;=============================================================================
  240. PRINT PROC NEAR
  241. MOV AH,09H
  242. INT 21H
  243. RET
  244. PRINT ENDP
  245. ;=============================================================================
  246. CODE_SEG ENDS
  247. END START
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement