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.

368 lines
9.2 KiB

  1. page ,132
  2. if 0
  3. /*++
  4. Copyright (c) 1993 Microsoft Corporation
  5. Module Name:
  6. ints.asm
  7. Abstract:
  8. Contains handler for Windows protect-mode NetwareRequest function, exported
  9. by NETWARE.DRV. Code in this file access real mode memory via an LDT descriptor
  10. created especially for this purpose. This selector gives us access to all
  11. code and data contained in the Nw16 TSR
  12. Author:
  13. Richard L Firth 22-Jan-1994
  14. Environment:
  15. Windows protect mode only
  16. Revision History:
  17. 22-Jan-1994 rfirth
  18. Created
  19. --*/
  20. endif
  21. include nwdos.inc ; NWDOSTABLE_ASM structure
  22. include isvbop.inc ; DispatchCall
  23. .286
  24. .model medium,pascal
  25. _DATA segment word public 'DATA'
  26. OldInt21Handler dd ?
  27. RMSegment dw ?
  28. RMBase dw ? ; MUST be in this order - loaded
  29. RMSelector dw ? ; via lds dx,word ptr RMBase
  30. .errnz (RMSelector - (RMBase + 2))
  31. _DATA ends
  32. ;
  33. ; code segment ordering
  34. ;
  35. INIT_TEXT segment byte public 'CODE'
  36. INIT_TEXT ends
  37. _TEXT segment byte public 'CODE'
  38. _TEXT ends
  39. ;
  40. ; macros
  41. ;
  42. LOAD_DS macro
  43. push _DATA
  44. pop ds
  45. assume ds:_DATA
  46. endm
  47. SET_DS macro
  48. push ds
  49. LOAD_DS
  50. endm
  51. RESTORE_DS macro
  52. pop ds
  53. assume ds:nothing
  54. endm
  55. LOAD_RM_DS_BX macro
  56. LOAD_DS
  57. lds bx,dword ptr RMBase
  58. assume ds:nothing
  59. endm
  60. RESTORE_DS_BX macro
  61. RESTORE_DS
  62. pop bx
  63. endm
  64. INIT_TEXT segment byte public 'CODE'
  65. assume cs:INIT_TEXT
  66. public GetLowRedirInfo
  67. GetLowRedirInfo proc far
  68. mov ax,9f00h
  69. int 21h ; get the RM data segment in BX
  70. jc @f
  71. SET_DS
  72. mov RMSegment,bx
  73. mov RMBase,dx
  74. mov ax,2
  75. int 31h
  76. jc @f ; can't create selector
  77. mov RMSelector,ax
  78. ;
  79. ; now that we have the selector, we write the selector value into the low
  80. ; memory area. The 32-bit DLL will use this value when setting output DS or ES
  81. ; register values if the call originated in Protect Mode
  82. ;
  83. lds bx,dword ptr RMBase
  84. mov [bx]._PmSelector,ax
  85. ;
  86. ; we now hook int 21
  87. ;
  88. LOAD_DS
  89. push es
  90. mov ax,3521h
  91. int 21h
  92. mov word ptr OldInt21Handler,bx
  93. mov word ptr OldInt21Handler[2],es
  94. mov cx,_TEXT
  95. mov dx,offset _TEXT:NewInt21Handler
  96. mov ax,205h
  97. mov bl,21h
  98. int 31h
  99. pop es
  100. RESTORE_DS
  101. xor ax,ax ; success: return TRUE
  102. inc ax
  103. ret
  104. @@: xor ax,ax ; failure: return FALSE
  105. ret
  106. GetLowRedirInfo endp
  107. INIT_TEXT ends
  108. _TEXT segment byte public 'CODE'
  109. assume cs:_TEXT
  110. public NewInt21Handler
  111. NewInt21Handler proc far
  112. sti
  113. cmp ah,0e3h
  114. jb @f
  115. call far ptr NetwareRequest
  116. retf 2
  117. @@: sub sp,4
  118. push bp
  119. mov bp,sp
  120. push es
  121. push bx
  122. SET_DS
  123. les bx,OldInt21Handler
  124. mov [bp+2],bx
  125. mov [bp+4],es
  126. RESTORE_DS
  127. pop bx
  128. pop es
  129. pop bp
  130. retf
  131. NewInt21Handler endp
  132. public NetwareRequest
  133. NetwareRequest proc far
  134. push bx
  135. push ds
  136. LOAD_RM_DS_BX
  137. cmp ah,0f0h
  138. jne for_dll
  139. ;
  140. ; these are the 0xF000, 0xF001, 0xF002, 0xF004, 0xF005 calls that we can handle
  141. ; here without having to BOP. All we need do is access the table in the shared
  142. ; real-mode/protect-mode (low) memory
  143. ;
  144. .errnz (_PrimaryServer - (_PreferredServer + 1))
  145. ;
  146. ; point bx at PreferredServer in the low memory area. If the request is a
  147. ; PrimaryServer request (0xF004, 0xF005) then point bx at PrimaryServer
  148. ;
  149. lea bx,[bx]._PreferredServer; bx = offset of PreferredServer
  150. cmp al,3
  151. cmc
  152. adc bx,0 ; bx = &PrimaryServer if F004 or F005
  153. or al,al ; f000 = set preferred server
  154. jz set_server
  155. cmp al,4 ; f004 = set primary server
  156. jnz try_01
  157. ;
  158. ; 0xF000 or 0xF004: set Preferred or Primary Server to value contained in DL.
  159. ; If DL > 8, set respective server index to 0
  160. ;
  161. set_server:
  162. xor al,al
  163. cmp dl,8
  164. ja @f
  165. mov al,dl
  166. @@: mov [bx],al
  167. jmp short exit_f0
  168. ;
  169. ; 0xF001 or 0xF005: get Preferred or Primary Server
  170. ;
  171. try_01: cmp al,1 ; f001 = get preferred server
  172. jz get_server
  173. cmp al,5
  174. jnz try_02
  175. get_server:
  176. mov al,[bx]
  177. jmp short exit_f0
  178. try_02: cmp al,2 ; f002 = get default server
  179. jnz for_dll ; try to handle on 32-bit side
  180. mov al,[bx] ; al = PreferredServer
  181. or al,al
  182. jnz exit_f0
  183. mov al,[bx+1] ; al = PrimaryServer
  184. exit_f0:RESTORE_DS_BX
  185. ret
  186. ;
  187. ; if we're here then the call must go through to the 32-bit DLL. Save any relevant
  188. ; info in the low memory area, load the handle and BOP (DispatchCall)
  189. ;
  190. for_dll:mov [bx]._SavedAx,ax ; save AX value for DLL
  191. push word ptr [bx]._hVdd ; put VDD handle on top of stack
  192. cmp ah,0BCh ; bc, bd, be need handle mapping
  193. jb @f
  194. cmp ah,0BEh
  195. ja @f
  196. pop ax ; ax = hVdd
  197. RESTORE_DS_BX ; ds, bx = user ds, bx
  198. call MapNtHandle
  199. jmp dispatchola
  200. @@: push bp
  201. cmp ah, 0E3h ; Is it new or old Create Job request?
  202. je lookupcode
  203. cmp ax, 0F217h
  204. jne check_f3
  205. lookupcode:
  206. mov bp,sp
  207. mov ds,[bp+4]
  208. cmp byte ptr [si+2],68h
  209. je createjob
  210. cmp byte ptr [si+2],79h
  211. je createjob
  212. jmp short outtahere
  213. createjob:
  214. LOAD_RM_DS_BX
  215. mov [bx]._SavedAx,9f02h
  216. push ax ; Open \\Server\queue for NCP
  217. mov ax,[bp+2] ; ax = hVdd
  218. mov ds,[bp+4] ; ds = users ds
  219. push ds
  220. push dx ; users dx
  221. DispatchCall ; Set DeNovellBuffer to \\Server\queue
  222. ; and registers ready for DOS OpenFile
  223. int 21h ; Open \\server\queue
  224. LOAD_RM_DS_BX
  225. jc openfailed
  226. mov [bx]._JobHandle, al
  227. mov [bx]._CreatedJob, 1 ; Flag JobHandle is valid
  228. push bx
  229. mov bx, ax ; JobHandle
  230. call MapNtHandle ; take bx and find the Nt handle
  231. pop bx
  232. openfailed:
  233. pop dx
  234. pop ds ; Proceed and send the NCP
  235. pop ax
  236. push ds
  237. push bx
  238. LOAD_RM_DS_BX
  239. mov [bx]._SavedAx, ax
  240. pop bx
  241. pop ds ; users DS
  242. jmp short outtahere
  243. check_f3:
  244. cmp ah, 0F3h
  245. jne outtahere
  246. ; FileServerCopy, change both
  247. ; handles in the structure es:di
  248. push bx
  249. mov bx,word ptr es:[di] ; Map Source Handle
  250. call MapNtHandle
  251. pop bx
  252. mov ax,[bx]._NtHandleHi
  253. mov [bx]._NtHandleSrcHi,ax
  254. mov ax,[bx]._NtHandleLow
  255. mov [bx]._NtHandleSrcLow,ax
  256. mov bx,word ptr es:[di+2] ; Map Destination Handle
  257. call MapNtHandle
  258. outtahere:
  259. pop bp
  260. pop ax ; ax = hVdd
  261. RESTORE_DS_BX ; ds, bx = user ds, bx
  262. dispatchola:
  263. DispatchCall ; BOP: DLL performs action
  264. ret ; return to the application
  265. ;
  266. ; if the request was not recognized by the DLL, it modifies IP so that control
  267. ; will resume at the next int 21. We just fill the intervening space with NOPs
  268. ; (space that makes up a retf <n> instruction in the RM TSR)
  269. ;
  270. nop
  271. nop
  272. int 21h
  273. ret
  274. NetwareRequest endp
  275. ; *** MapNtHandle
  276. ; *
  277. ; * Given a handle in BX, map it to a 32-bit Nt handle in NtHandle[Hi|Low]
  278. ; *
  279. ; * ENTRY bx = handle to map
  280. ; *
  281. ; * EXIT Success - NtHandle set to 32-bit Nt handle from SFT
  282. ; *
  283. ; * USES ax, bx, flags
  284. ; *
  285. ; * ASSUMES nothing
  286. ; *
  287. ; ***
  288. MapNtHandle proc near
  289. push ax
  290. mov ax,9f01h ; call MapNtHandle on (BX) in RM
  291. int 21h ; update NtHandleHi, NtHandleLow
  292. pop ax
  293. @@: ret
  294. MapNtHandle endp
  295. _TEXT ends
  296. end