Leaked source code of windows server 2003
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.

348 lines
7.0 KiB

  1. name faxdrv
  2. title 'FAX16 - Stub driver for Application based intercept under NT'
  3. ;
  4. ; fax16.asm: This is a very simple DOS stub device driver for NTVDM.
  5. ; It shows how to use application based intercept services
  6. ; provided by NTVDM. FAX32.dll is its DLL which will be loaded
  7. ; in the NTVDM process by this stub device driver.
  8. ;
  9. ; This driver only has meaningful code for init,read and write.
  10. ; Rest all command codes always succeed. We are assuming here
  11. ; that the 16 bit fax application for this stub device driver
  12. ; opens this device and just make read and write calls. The
  13. ; meaning of read is to get a fax message and write means
  14. ; send a message
  15. _TEXT segment byte public 'CODE'
  16. assume cs:_TEXT,ds:_TEXT,es:NOTHING
  17. org 0
  18. include isvbop.inc
  19. MaxCmd equ 24 ; Maximum allowed command
  20. ; VDD Command codes
  21. OpGet equ 1 ; Read a FAX
  22. OpSend equ 2 ; Send a FAX
  23. Header: ; Fax Device Header
  24. DD -1
  25. DW 0c840h
  26. DW FaxStrat
  27. DW FaxIntr
  28. DB 'FAXDRV00'
  29. RHPtr DD ? ; Pointer to Request Header
  30. Dispatch: ; Interrupt routine command code
  31. DW Init
  32. DW MediaChk
  33. DW BuildBPB
  34. DW IoctlRd
  35. DW Read
  36. DW NdRead
  37. DW InpStat
  38. DW InpFlush
  39. DW Write
  40. DW WriteVfy
  41. DW OutStat
  42. DW OutFlush
  43. DW IoctlWt
  44. DW DevOpen
  45. DW DevClose
  46. DW RemMedia
  47. DW OutBusy
  48. DW Error
  49. DW Error
  50. DW GenIOCTL
  51. DW Error
  52. DW Error
  53. DW Error
  54. DW GetLogDev
  55. DW SetLogDev
  56. DllName DB "FAX32.DLL",0
  57. InitFunc DB "FAXVDDRegisterInit",0
  58. DispFunc DB "FAXVDDDispatch",0
  59. F32Mes DB "We are called from 32 staff", 10, 13, "$"
  60. hVDD DW ?
  61. FaxStrat proc far ; Strategy Routine
  62. mov word ptr cs:[RhPtr],bx
  63. mov word ptr cs:[RhPtr+2],es
  64. ret
  65. FaxStrat endp
  66. FaxIntr proc far ; INterrupt routine
  67. push ax ; Save registers
  68. push bx
  69. push cx
  70. push dx
  71. push ds
  72. push es
  73. push di
  74. push si
  75. push bp
  76. push cs
  77. pop ds ; DS = CS
  78. les di,[RHPtr] ; ES:DI = request header
  79. mov bl,es:[di+2]
  80. xor bh,bh ; BX = command code
  81. cmp bx,MaxCmd
  82. jle FIntr1
  83. call Error ; Unknown command
  84. jmp FIntr2
  85. FIntr1:
  86. shl bx,1
  87. call word ptr [bx+Dispatch] ; call command routine
  88. les di,[RhPtr] ; ES:DI = request header
  89. FIntr2:
  90. or ax,0100h ; Set Done bit in the status
  91. mov es:[di+3],ax ; Store the status
  92. pop bp ; restore registers
  93. pop si
  94. pop di
  95. pop es
  96. pop ds
  97. pop dx
  98. pop cx
  99. pop bx
  100. pop ax
  101. ret
  102. MediaChk proc near
  103. xor ax,ax
  104. ret
  105. MediaChk endp
  106. BuildBPB proc near
  107. xor ax,ax
  108. ret
  109. BuildBPB endp
  110. IoctlRd proc near
  111. xor ax,ax
  112. ret
  113. IoctlRd endp
  114. Read proc near
  115. push es
  116. push di ; Save Request Header add
  117. mov bx,word ptr es:[di+14] ; buffer offset
  118. mov ax,word ptr es:[di+16] ; buffer segment
  119. mov cx,word ptr es:[di+18] ; buffer length
  120. mov es,ax ; es:bx is the buffer where
  121. ; fax has to be read from
  122. ; the NT device driver
  123. mov ax,word ptr cs:[hVDD] ; VDD handle returned by
  124. ; register module
  125. mov dx,OpGet ; Read the fax command
  126. DispatchCall
  127. pop di
  128. pop es
  129. jnc rOK ; NC -> Success and CX has
  130. ; the count read.
  131. call Error ; Operation Failed
  132. ret
  133. rOK:
  134. mov word ptr es:[di+12],cx ; return in header how much
  135. ; was read
  136. xor ax,ax
  137. ret
  138. Read endp
  139. NdRead proc near
  140. xor ax,ax
  141. ret
  142. NdRead endp
  143. InpStat proc near
  144. xor ax,ax
  145. ret
  146. InpStat endp
  147. InpFlush proc near
  148. xor ax,ax
  149. ret
  150. InpFlush endp
  151. Write proc near
  152. push es
  153. push di ; Save Request Header add
  154. mov bx,word ptr es:[di+14] ; buffer offset
  155. mov ax,word ptr es:[di+16] ; buffer segment
  156. mov cx,word ptr es:[di+18] ; buffer length
  157. mov es,ax ; es:bx is the FAX message where
  158. ; to be send by NT device
  159. ; driver
  160. mov ax,word ptr cs:[hVDD] ; VDD handle returned by
  161. ; register module
  162. mov dx,OpSend ; Send the fax command
  163. DispatchCall
  164. pop di
  165. pop es
  166. jnc wOK ; NC -> Success and CX has
  167. ; the count read.
  168. call Error ; Operation Failed
  169. ret
  170. wOK:
  171. mov word ptr es:[di+12],cx ; return in header how much
  172. ; was actually written
  173. xor ax,ax
  174. ret
  175. Write endp
  176. WriteVfy proc near
  177. xor ax,ax
  178. ret
  179. WriteVfy endp
  180. OutStat proc near
  181. xor ax,ax
  182. ret
  183. OutStat endp
  184. OutFlush proc near
  185. xor ax,ax
  186. ret
  187. OutFlush endp
  188. IoctlWt proc near
  189. xor ax,ax
  190. ret
  191. IoctlWt endp
  192. DevOpen proc near
  193. xor ax,ax
  194. ret
  195. DevOpen endp
  196. DevClose proc near
  197. xor ax,ax
  198. ret
  199. DevClose endp
  200. RemMedia proc near
  201. xor ax,ax
  202. ret
  203. RemMedia endp
  204. OutBusy proc near
  205. xor ax,ax
  206. ret
  207. OutBusy endp
  208. GenIOCTL proc near
  209. xor ax,ax
  210. ret
  211. GenIOCTL endp
  212. GetLogDev proc near
  213. xor ax,ax
  214. ret
  215. GetLogDev endp
  216. SetLogDev proc near
  217. xor ax,ax
  218. ret
  219. SetLogDev endp
  220. Error proc near
  221. mov ax,8003h ; Bad Command Code
  222. ret
  223. Error endp
  224. ;
  225. ;
  226. ; This function is a sample sub that calling from 32-bits part of VDD
  227. ;
  228. From32Sub proc near
  229. push cs
  230. pop ds
  231. mov dx, offset F32mes
  232. mov ah, 09h
  233. int 21h
  234. VDDUnSimulate16
  235. ret
  236. From32Sub endp
  237. Init proc near
  238. push es
  239. push di ; Save Request Header add
  240. push ds
  241. pop es
  242. ; Load fax32.dll
  243. mov si, offset DllName ; ds:si = fax32.dll
  244. mov di, offset InitFunc ; es:di = init routine
  245. mov bx, offset DispFunc ; ds:bx = dispatch routine
  246. mov ax, offset From32Sub ; ds:ax = From32Sub
  247. RegisterModule
  248. jnc saveHVDD ; NC -> Success
  249. call Error ; Indicate failure
  250. pop di
  251. pop es
  252. mov byte ptr es:[di+13],0 ; unit supported 0
  253. mov word ptr es:[di+14],offset Header ; Unload this device
  254. mov word ptr es:[di+16],cs
  255. mov si, offset Header
  256. and [si+4],8FFFh ; clear bit 15 for failure
  257. ret
  258. saveHVDD:
  259. mov [hVDD],ax
  260. pop di
  261. pop es
  262. mov word ptr es:[di+14],offset Init ; Free Memory address
  263. mov word ptr es:[di+16],cs
  264. xor ax,ax ; return success
  265. ret
  266. Init endp
  267. FaxIntr endp
  268. _TEXT ends
  269. end