Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

230 lines
5.7 KiB

  1. name mscdexnt
  2. ;
  3. ; MSCDEXNT
  4. ;
  5. ; Author: Neil Sandlin (neilsa)
  6. ;
  7. ; Description:
  8. ;
  9. ; This TSR implements the v86 mode portion of MSCDEX support under
  10. ; NT. Basically, all this piece does is hook INT2F and watch for
  11. ; MSCDEX calls. When the first one occurs, it tries to load VCDEX.DLL.
  12. ; If that succeeds, it passes the call (and all subsequent calls)
  13. ; to VCDEX for processing.
  14. ;
  15. include isvbop.inc
  16. include mscdexnt.inc
  17. _TEXT segment word public 'CODE'
  18. assume cs:_TEXT,ds:_TEXT,es:_TEXT
  19. ;*----------------------- TSR Code --------------------------*
  20. DrvStrat proc far ; Strategy Routine
  21. ret
  22. DrvStrat endp
  23. DrvIntr proc far ; INterrupt routine
  24. ret
  25. DrvIntr endp
  26. ;******************************************************************************
  27. ;
  28. ; Int2FHook
  29. ;
  30. ;
  31. ;******************************************************************************
  32. Int2FHook proc near
  33. cmp ah, MSCDEX_ID ;MSCDEX?
  34. jnz int2fchain ;no
  35. cmp al, MAX_MSCDEX_CMD ;command too high?
  36. ja int2fchain ;yes
  37. cmp word ptr cs:[hVDD], 0 ;zero is an invalid module handle
  38. jnz callvdd ;registered ok
  39. cmp byte ptr cs:[fVDDChecked],1
  40. jz vddfailed
  41. call RegisterVDD
  42. jc vddfailed ;didn't get it
  43. callvdd:
  44. push ax ;put ax on stack
  45. mov ax, word ptr cs:[hVDD]
  46. DispatchCall
  47. add sp, 2 ;vdd has set ax accordingly
  48. iret ;svc handled, return to caller
  49. vddfailed:
  50. or al,al
  51. jnz try_0b
  52. xor bx,bx
  53. jmp short int2f_done
  54. try_0b:
  55. cmp al,0bh
  56. jne int2f_done
  57. ;; williamh - June 1 1993 - if unable to load VDD, we should tell
  58. ;; the caller that the drive is NOT a cd rom.
  59. xor ax, ax
  60. mov bx,0adadh
  61. int2f_done:
  62. iret
  63. int2fchain:
  64. jmp dword ptr cs:[oldint]
  65. Int2FHook endp
  66. ;****************************************************************************
  67. ;
  68. ; RegisterVDD
  69. ;
  70. ;****************************************************************************
  71. RegisterVDD proc near
  72. push ax
  73. push bx
  74. push cx
  75. push dx
  76. push si
  77. push di
  78. push ds
  79. push es
  80. mov ax, cs
  81. mov ds, ax
  82. mov es, ax
  83. ; Load vcdex.dll
  84. mov si, offset DllName ; ds:si = dll name
  85. mov di, offset InitFunc ; es:di = init routine
  86. mov bx, offset DispFunc ; ds:bx = dispatch routine
  87. push cs ; pass far pointer to headers
  88. pop cx ; in cx:dx
  89. mov dx, offset drive_header
  90. RegisterModule
  91. jc errorexit ; jif error
  92. mov cs:[hVDD],ax ; save handle
  93. errorexit:
  94. mov byte ptr cs:[fVDDChecked],1
  95. pop es
  96. pop ds
  97. pop di
  98. pop si
  99. pop dx
  100. pop cx
  101. pop bx
  102. pop ax
  103. ret
  104. RegisterVDD endp
  105. ;*----------------------- TSR Data Area ---------------------*
  106. oldint dd 0
  107. hVDD DW 0
  108. fVDDChecked DB 0 ; 0 - VDD never called. 1 - VDD once called.
  109. DllName DB "VCDEX.DLL",0
  110. InitFunc DB "VDDRegisterInit",0
  111. DispFunc DB "VDDDispatch",0
  112. ALIGN 16
  113. drive_header:
  114. DrvHd 'MSCDEX00'
  115. ALIGN 16
  116. Init_Fence:
  117. ;*-------------------------- Initialization Code ----------------------*
  118. mscdexnt proc far
  119. ; at this point es,ds -> PSP
  120. ; SS:SP points to stack
  121. ; first check that we are running under NT
  122. mov ax, GET_NT_VERSION
  123. int 21h
  124. cmp bl, NT_MAJOR_VERSION
  125. je cdx_chk_more
  126. jmp cdx_exit
  127. cdx_chk_more:
  128. cmp bh, NT_MINOR_VERSION
  129. je cdx_ver_ok
  130. jmp cdx_exit
  131. cdx_ver_ok:
  132. ; Now check that this TSR is'nt already installed
  133. mov ah,MSCDEX_ID
  134. mov al,0bh ; call function 0b
  135. int MPX_INT ; int 2f
  136. cmp bx,0adadh
  137. jne cdx_chks_done
  138. jmp cdx_exit
  139. cdx_chks_done:
  140. ; free the env segment
  141. push es
  142. push ds
  143. mov es, es:[2ch]
  144. mov ah, 49h
  145. int 21h
  146. mov ah, DOS_GET_VECTOR
  147. mov al, MPX_INT ; 2f
  148. int 21h ; get old vector
  149. mov WORD PTR cs:oldint,bx ; save old vector here
  150. mov WORD PTR cs:oldint+2,es
  151. mov dx, offset Int2FHook
  152. push cs ; get current code segment
  153. pop ds
  154. mov ah, DOS_SET_VECTOR
  155. mov al, MPX_INT ; vector to hook
  156. int 21h ; hook that vector
  157. ;
  158. ; Compute size of TSR area
  159. ;
  160. pop ds
  161. pop es
  162. mov dx, offset Init_Fence ; end of fixed TSR code
  163. mov cl, 4 ; divide by 16
  164. shr dx, cl
  165. add dx, 16 ; add in PSP
  166. ;
  167. ; Terminate and stay resident
  168. ;
  169. mov ah, DOS_TSR ; TSR
  170. mov al, 0
  171. int 21h ; TSR
  172. cdx_exit:
  173. mov ax,4c00h ; Exit
  174. int 21h
  175. mscdexnt endp
  176. _TEXT ends
  177. InitStack segment para stack 'STACK'
  178. dw 256 dup (?)
  179. top_of_stack equ $
  180. InitStack ends
  181. end mscdexnt
  182.