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.

1154 lines
32 KiB

  1. page ,132
  2. if 0
  3. /*++
  4. Copyright (c) 1991 Microsoft Corporation
  5. Module Name:
  6. resident.asm
  7. Abstract:
  8. This module contains the resident code part of the stub redir TSR for NT
  9. VDM net support. The routines contained herein are the 2f handler and the
  10. API support routines:
  11. MultHandler
  12. ReturnMode
  13. SetMode
  14. GetAssignList
  15. DefineMacro
  16. BreakMacro
  17. GetRedirVersion
  18. NetGetUserName
  19. DefaultServiceError
  20. NetGetEnumInfo
  21. NetSpoolStuff
  22. Author:
  23. Richard L Firth (rfirth) 05-Sep-1991
  24. Environment:
  25. Dos mode only
  26. Revision History:
  27. 05-Sep-1991 rfirth
  28. Created
  29. --*/
  30. endif
  31. .xlist ; don't list these include files
  32. .xcref ; turn off cross-reference listing
  33. include dosmac.inc ; Break macro etc (for following include files only)
  34. include dossym.inc ; User_<Reg> defines
  35. include mult.inc ; MultNET
  36. include error.inc ; DOS errors - ERROR_INVALID_FUNCTION
  37. include syscall.inc ; DOS system call numbers
  38. include rdrint2f.inc ; redirector Int 2f numbers
  39. include segorder.inc ; segments
  40. include enumapis.inc ; dispatch codes
  41. include debugmac.inc ; DbgPrint macro
  42. include localmac.inc ; DbgPrint macro
  43. include asmmacro.inc ; language extensions
  44. include rdrsvc.inc ; BOP and SVC macros/dispatch codes
  45. include rdrmisc.inc ; miscellaneous definitions
  46. include sf.inc ; SFT definitions/structure
  47. include vrdefld.inc ; VDM_LOAD_INFO
  48. .cref ; switch cross-reference back on
  49. .list ; switch listing back on
  50. subttl ; kill subtitling started in include file
  51. .286 ; all code in this module 286 compatible
  52. ResidentDataStart
  53. public LanRootLength, LanRoot
  54. LanRootLength dw ? ; can't be >81 bytes anyhow
  55. LanRoot db (64+3+1+13) dup (?)
  56. ResidentDataEnd
  57. ResidentCodeStart
  58. extrn DosQnmPipeInfo: near
  59. extrn DosQNmpHandState: near
  60. extrn DosSetNmpHandState: near
  61. extrn DosPeekNmPipe: near
  62. extrn DosTransactNmPipe: near
  63. extrn DosCallNmPipe: near
  64. extrn DosWaitNmPipe: near
  65. extrn NetTransactAPI: near
  66. extrn NetIRemoteAPI: near
  67. extrn NetUseAdd: near
  68. extrn NetUseDel: near
  69. extrn NetUseEnum: near
  70. extrn NetUseGetInfo: near
  71. extrn NetServerEnum: near
  72. extrn DosMakeMailslot: near
  73. extrn DosDeleteMailslot: near
  74. extrn DosMailslotInfo: near
  75. extrn DosReadMailslot: near
  76. extrn DosPeekMailslot: near
  77. extrn DosWriteMailslot: near
  78. extrn NetNullTransactAPI: near
  79. extrn NetServerEnum2: near
  80. extrn NetServiceControl: near
  81. extrn NetWkstaGetInfo: near
  82. extrn NetWkstaSetInfo: near
  83. extrn NetMessageBufferSend: near
  84. extrn NetHandleGetInfo: near
  85. extrn NetHandleSetInfo: near
  86. extrn DosReadAsyncNmPipe: near
  87. extrn DosWriteAsyncNmPipe: near
  88. extrn DosReadAsyncNmPipe2: near
  89. extrn DosWriteAsyncNmPipe2: near
  90. extrn MessengerDispatch: near
  91. ;
  92. ; IMPORTANT: This structure MUST be the first thing in the resident code segment
  93. ;
  94. extrn dwPostRoutineAddress: dword
  95. VdmWindowAddr VDM_LOAD_INFO <dwPostRoutineAddress, 0>
  96. align 4
  97. ;
  98. ; Address of previous handler to chain if int 2f not for us
  99. ;
  100. public OldMultHandler
  101. OldMultHandler dd ?
  102. ;
  103. ; OldFunctionTable is a table of near pointers to handlers for the old 5f
  104. ; functions 5f00 through 5f05
  105. ;
  106. OldFunctionTable label word
  107. dw ReturnMode ; 5f00
  108. dw SetMode ; 5f01
  109. dw GetAssignList ; 5f02
  110. dw DefineMacro ; 5f03
  111. dw BreakMacro ; 5f04
  112. dw GetAssignList2 ; 5f05
  113. ;
  114. ; May as well keep this jump table in the code segment - no point in loading
  115. ; ds just to get a jump offset
  116. ;
  117. MultDispatchTable label word
  118. dw GetRedirVersion ; 5f30
  119. dw DefaultServiceError ; 5f31 - NetWkstaSetUID
  120. dw DosQnmPipeInfo ; 5f32
  121. dw DosQNmpHandState ; 5f33
  122. dw DosSetNmpHandState ; 5f34
  123. dw DosPeekNmPipe ; 5f35
  124. dw DosTransactNmPipe ; 5f36
  125. dw DosCallNmPipe ; 5f37
  126. dw DosWaitNmPipe ; 5f38
  127. dw DefaultServiceError ; 5f39 - DosRawReadNmPipe
  128. dw DefaultServiceError ; 5f3a - DosRawWriteNmPipe
  129. dw NetHandleSetInfo ; 5f3b
  130. dw NetHandleGetInfo ; 5f3c
  131. dw NetTransactAPI ; 5f3d
  132. dw DefaultServiceError ; 5f3e - NetSpecialSMB
  133. dw NetIRemoteAPI ; 5f3f
  134. dw NetMessageBufferSend ; 5f40
  135. dw DefaultServiceError ; 5f41 - NetServiceEnum
  136. dw NetServiceControl ; 5f42
  137. dw DefaultServiceError ; 5f43 - DosPrintJobGetID
  138. dw NetWkstaGetInfo ; 5f44
  139. dw NetWkstaSetInfo ; 5f45
  140. dw NetUseEnum ; 5f46
  141. dw NetUseAdd ; 5f47
  142. dw NetUseDel ; 5f48
  143. dw NetUseGetInfo ; 5f49
  144. dw DefaultServiceError ; 5f4a - NetRemoteCopy
  145. dw DefaultServiceError ; 5f4b - NetRemoteMove
  146. dw NetServerEnum ; 5f4c
  147. dw DosMakeMailslot ; 5f4d
  148. dw DosDeleteMailslot ; 5f4e
  149. dw DosMailslotInfo ; 5f4f
  150. dw DosReadMailslot ; 5f50
  151. dw DosPeekMailslot ; 5f51
  152. dw DosWriteMailslot ; 5f52
  153. dw NetServerEnum2 ; 5f53
  154. dw NetNullTransactAPI ; 5f54 - NullTransaction entrypoint.
  155. MAX_TABLE_ENTRIES = (($-MultDispatchTable)/type MultDispatchTable)-1
  156. ;
  157. ; this next table dispatches the functions that come in through a direct call
  158. ; to int 2f, ah=11, al=function code
  159. ;
  160. ServiceDispatchTable label word
  161. dw NetGetUserName ; 80h - NetGetUserName o
  162. dw DefaultServiceError ; 81h - NetSetUserName x
  163. dw DefaultServiceError ; 82h - NetServiceNotify x
  164. dw DefaultServiceError ; 83h - NetPrintNameEnum x
  165. dw NetGetEnumInfo ; 84h - NetGetEnumInfo o
  166. dw DefaultServiceError ; 85h - TestDBCSLB x
  167. dw DosReadAsyncNmPipe ; 86h - DosReadAsyncNmPipe x
  168. dw DefaultServiceError ; 87h - DosUnusedFunction1 x
  169. dw DefaultServiceError ; 88h - DosUnusedFunction2 x
  170. dw DefaultServiceError ; 89h - NetCalloutNCB x
  171. dw DefaultServiceError ; 8Ah - EncrPasswd x
  172. dw DefaultServiceError ; 8Bh - NetGetLogonServer o
  173. dw DefaultServiceError ; 8Ch - NetSetLogonServer o
  174. dw DefaultServiceError ; 8Dh - NetGetDomain o
  175. dw DefaultServiceError ; 8Eh - NetSetDomain o
  176. dw DosWriteAsyncNmPipe ; 8FH - DosWriteAsyncNmPipe x
  177. dw DosReadAsyncNmPipe2 ; 90H - DosReadAsyncNmPipe2 x
  178. dw DosWriteAsyncNmPipe2 ; 91H - DosWriteAsyncNmPipe2 x
  179. MAX_SERVICE_ENTRIES = (($-ServiceDispatchTable)/type ServiceDispatchTable)-1
  180. page
  181. ; *** MultHandler
  182. ; *
  183. ; * Whenever an INT 2F call is made, sooner or later this function will
  184. ; * get control. If the call is actually for the redir, AH will be set
  185. ; * to 11h (MultNET). If it is any other value then we just chain it
  186. ; * along. Note that since there is no MINSES loaded in the NT DOS network
  187. ; * stack, then we need also to fake calls to MINSES. These are made through
  188. ; * INT 2F, with ah = 0xB8. We trap calls AX=B800 (network presence test)
  189. ; * and AX=B809 (network/redir installation test)
  190. ; *
  191. ; * ENTRY ax = (MultNET << 8) | net operation code
  192. ; * Net operation code can be:
  193. ; * Install check 0
  194. ; * Assign operation 30
  195. ; * Anything else is DOS/NET specific. We should raise a gorbachev
  196. ; * or rather an error if we receive something else
  197. ; *
  198. ; * Stack: IP \
  199. ; * CS > From Int 2f
  200. ; * Flags /
  201. ; * Caller's AX From call to Int 21/ah=5f
  202. ; *
  203. ; * We need the caller's AX to dispatch the NetAssOper calls, nothing
  204. ; * more
  205. ; *
  206. ; * All the rest of the registers are as per the caller
  207. ; *
  208. ; * EXIT CF = 0
  209. ; * success
  210. ; * CF = 1
  211. ; * AX = error
  212. ; *
  213. ; * USES all regs
  214. ; *
  215. ; * ASSUMES Earth is flat
  216. ; *
  217. ; ***
  218. if DEBUG
  219. OriginalAx dw ?
  220. OriginalBx dw ?
  221. endif
  222. public MultHandler
  223. MultHandler proc far
  224. assume cs:ResidentCode
  225. assume ds:nothing
  226. assume es:nothing
  227. assume ss:nothing
  228. if DEBUG
  229. mov OriginalAx,ax
  230. mov OriginalBx,bx
  231. endif
  232. cmp ah,MultNET ; 11h
  233. je @f
  234. ;
  235. ; test for AH=B8 and return network presence indicators if it is. Here we are
  236. ; faking calls to MINSES (minimum session layer) and intercept calls AX=B800
  237. ; and AX=B809. Any other AH=B8 call must be for a different TSR/driver
  238. ;
  239. cmp ah,0b8h
  240. jne check_messenger
  241. or al,al
  242. jnz try_9
  243. ;
  244. ; AX=B800. This is the MinSes installation check. Return the magic numbers
  245. ; AL=1 and BX=8 (see doslan\minses\int2f.inc in LANMAN project)
  246. ;
  247. inc al
  248. mov bx,8
  249. do_iret:iret
  250. try_9:
  251. cmp al,9
  252. jne chain_previous_handler ; AL not 0 or 9, AH=B8 for somebody else
  253. ;
  254. ; AX=B809 is a network installation test. Return the magic numbers AL=1, AH=2
  255. ; for PC Network version 1.2 (this is what minses does, don't complain to me
  256. ; about PC networks, etc, etc)
  257. ;
  258. mov ax,0201h
  259. jmp short do_iret
  260. ;
  261. ; MESSENGER TSR uses AH=42h
  262. ;
  263. check_messenger:
  264. cmp ah,42h ; multMESSAGE
  265. jne chain_previous_handler
  266. call MessengerDispatch
  267. retf 2 ; return state in flags
  268. chain_previous_handler:
  269. jmp OldMultHandler ; not for us; pass it along
  270. ;
  271. ; the 2f call is for us. If it is the installation check, return al == -1 else
  272. ; dispatch the byte code at sp+6
  273. ;
  274. @@: sti ; re-enable interrupts
  275. or al,al
  276. jnz @f
  277. or al,-1 ; installation check just returns 0xff
  278. ret 2 ; 'or' clears carry
  279. @@: cld ; auto-increment string operations
  280. ;
  281. ; this call is something other than an installation check. I really hope that
  282. ; its the AssignOper request, because I don't know what to do if it isn't...
  283. ;
  284. cmp al,_2F_NET_ASSOPER
  285. jmpe is_net_request ; yes - we can do something
  286. ;
  287. ; if its the ResetEnvironment request then we have to kill any net state info
  288. ; like mailslot info. Return via iret
  289. ;
  290. cmp al,_2F_NetResetEnvironment
  291. jmpne check_service_call
  292. ;
  293. ; deferred loading: don't load VDMREDIR.DLL for VrTerminateDosProcess if no NET
  294. ; calls have been made
  295. ;
  296. cmp VdmWindowAddr.VrInitialized,1
  297. je @f
  298. iret
  299. if 0
  300. DbgPrintString "NetResetEnvironment received. PDB="
  301. push ax ; int 21/51 uses ax,bx
  302. push bx
  303. endif
  304. @@: mov ah,51h
  305. int 21h ; get current PDB
  306. if 0
  307. DbgPrintHexWord bx ; bx contains PSP of current process
  308. pop bx
  309. pop ax
  310. DbgCrLf
  311. endif
  312. mov ax,bx
  313. SVC SVC_RDRTERMINATE
  314. iret
  315. ;
  316. ; if this is a net service call (ah=11h, al=function code 80h through 91h) then
  317. ; dispatch through the service table
  318. ;
  319. check_service_call:
  320. cmp al,_2F_NetSpoolOper ; 25h
  321. jne @f
  322. call NetSpoolStuff
  323. jmp short return_to_dos
  324. @@: cmp al,_2F_NetGetUserName ; 80h
  325. jmpb trap_it
  326. cmp al,_2F_DosWriteAsyncNmPipe2 ; 91h
  327. jmpa trap_it
  328. if 0
  329. DbgPrintString "Received Service Request: "
  330. DbgPrintHexWord ax
  331. DbgCrLf
  332. endif
  333. sub ax,(MultNET shl 8) + _2F_NetGetUserName
  334. xchg ax,bx
  335. shl bx,1
  336. mov bx,ServiceDispatchTable[bx]
  337. xchg ax,bx
  338. call ax
  339. ;
  340. ; all calls that come through here are expected to have originated in DOS
  341. ;
  342. return_to_dos:
  343. ret 2 ; with interrupts enabled
  344. ;
  345. ; if we get anything else, either from DOS, or some - as yet - unknown source,
  346. ; then just pass it along to the next handler. In the debug version, we alert
  347. ; someone to the fact that we've got an unrecognized call
  348. ;
  349. trap_it:
  350. DbgPrintString "Received unrecognized Service Request: "
  351. DbgPrintHexWord ax
  352. DbgCrLf
  353. DbgBreakPoint
  354. jmp OldMultHandler ; pass it down the chain
  355. ;
  356. ; get the original dispatch code back off the stack. We no longer require the
  357. ; current contents of ax
  358. ;
  359. is_net_request:
  360. push bp
  361. mov bp,sp
  362. mov ax,[bp + 8] ; ax <- original code (5fxx)
  363. pop bp
  364. if DEBUG
  365. mov OriginalAx,ax
  366. endif
  367. ;
  368. ; quick sanity check to make sure that we're processing the right call. If we
  369. ; were called with ax != 5fxx, assume that somebody else is also using the
  370. ; same 2F function call, and chain the next handler. Note: this wouldn't be
  371. ; a very smart thing to do
  372. ;
  373. sub ah,AssignOper ; ah => 0 it is AssignOper
  374. jz @f
  375. DbgBreakPoint
  376. mov ax,(MultNET shl 8) + _2F_NET_ASSOPER ; restore ax
  377. jmps chain_previous_handler
  378. @@: cmp al,5 ; is it 5f00 - 5f05?
  379. jnbe @f
  380. ;
  381. ; if the function is in the range 0 - 5 then its an old function - dispatch
  382. ; through the old function table
  383. ;
  384. shl al,1
  385. xchg ax,bx
  386. mov bx,OldFunctionTable[bx]
  387. xchg ax,bx
  388. call ax
  389. ret 2
  390. @@: sub al,Local_API_RedirGetVersion
  391. jz @f ; function is GetRedirVersion
  392. cmp al,MAX_TABLE_ENTRIES
  393. jbe @f ; UNSIGNED comparison!!!
  394. ;
  395. ; get 32-bit support code to dump registers to debug terminal
  396. ;
  397. if DEBUG
  398. mov ax,OriginalAx
  399. DbgUnsupported
  400. endif
  401. mov ax,ERROR_NOT_SUPPORTED
  402. stc ; set error indication
  403. jmp short set_ax_exit
  404. ;
  405. ; the function is within range. Dispatch it. Copy the offset from the dispatch
  406. ; table into ax then call through ax. ax was only required to get us this far
  407. ; and contains no useful information
  408. ;
  409. @@: xchg ax,bx ; need base register, ax not good enough in 286
  410. shl bx,1 ; bx is now offset in dispatch table
  411. mov bx,MultDispatchTable[bx]; bx is offset of handler routine
  412. xchg ax,bx ; restore caller's bx
  413. call ax ; go handle it
  414. ret 2 ; return without reinstating flags
  415. ;
  416. ; Return an error in the caller's ax register. To do this we have to ask DOS to
  417. ; please give us the address of its copy of the user's registers, which it will
  418. ; pass back in DS:SI. We then futz with the copy of the user's reg. Dos will
  419. ; restore this before returning control to the user code. Since we know we have
  420. ; an error situation set the carry flag
  421. ;
  422. set_ax_exit:
  423. pushf ; error indicator
  424. push ax ; return code
  425. DosCallBack GET_USER_STACK ; get pointer to caller's context
  426. assume ds:nothing ; nuked - actually in DOS somewhere (stack)
  427. pop [si].User_Ax ; copy saved return code into user's copy
  428. popf ; restore error indicator
  429. ret 2 ; clear caller's flags from int 2f call
  430. MultHandler endp
  431. page
  432. ; *** ReturnMode
  433. ; *
  434. ; * Returns the disk or print redirection flag. Flag is 0 if redirection
  435. ; * is paused, else 1
  436. ; *
  437. ; * ENTRY BL = 3
  438. ; * Return print redirection
  439. ; *
  440. ; * BL = 4
  441. ; * Return drive redirection
  442. ; *
  443. ; * EXIT CF = 0
  444. ; * BX = redirection flag: 0 or 1
  445. ; *
  446. ; * CF = 1
  447. ; * error
  448. ; *
  449. ; * USES bx
  450. ; *
  451. ; * ASSUMES nothing
  452. ; *
  453. ; ***
  454. PrintRedirection db 0
  455. DriveRedirection db 0
  456. ReturnMode proc near
  457. assume cs:ResidentCode
  458. assume ds:nothing
  459. DbgPrintString <"5f00 called",13,10>
  460. DbgUnsupported
  461. cmp bl,3
  462. jne @f
  463. mov bh,PrintRedirection
  464. jmp short set_info
  465. @@: cmp bl,4
  466. stc
  467. jnz @f
  468. mov bh,DriveRedirection
  469. set_info:
  470. and bh,1
  471. DosCallBack GET_USER_STACK
  472. mov [si].User_Bx,bx
  473. clc
  474. @@: ret
  475. ReturnMode endp
  476. page
  477. ; *** SetMode
  478. ; *
  479. ; * Pauses or continues drive or printer redirection. Note that we don't
  480. ; * support drive/print pause/continuation from DOS
  481. ; *
  482. ; * ENTRY BL = printer (3) or drive (4) redirection
  483. ; * BH = pause (0) or continue (1)
  484. ; *
  485. ; * EXIT CF = 0
  486. ; * success
  487. ; * CF = 1
  488. ; * ax = ERROR_INVALID_PARAMETER
  489. ; *
  490. ; * USES ax, bx
  491. ; *
  492. ; * ASSUMES nothing
  493. ; *
  494. ; ***
  495. SetMode proc near
  496. assume cs:ResidentCode
  497. assume ds:nothing
  498. DbgPrintString <"5f01 called",13,10>
  499. DbgUnsupported
  500. cmp bh,1
  501. jnbe bad_parm_exit
  502. dec bh ; convert 0 => ff, 1 => 0
  503. not bh ; convert ff => 0, 0 => ff
  504. sub bl,3
  505. jnz try_drive
  506. mov PrintRedirection,bh
  507. jmp short ok_exit
  508. try_drive:
  509. dec bl
  510. jnz bad_parm_exit
  511. mov DriveRedirection,bh
  512. ok_exit:clc
  513. ret
  514. bad_parm_exit:
  515. mov ax,ERROR_INVALID_PARAMETER
  516. stc
  517. ret
  518. SetMode endp
  519. page
  520. ; *** GetAssignList
  521. ; *
  522. ; * Returns information on enumerated redirections. Old version of
  523. ; * NetUseGetInfo
  524. ; *
  525. ; * ENTRY BX = which item to return (starts @ 0)
  526. ; * DS:SI points to local redirection name
  527. ; * ES:DI points to remote redirection name
  528. ; * AL != 0 means return LSN in BP (GetAssignList2)? ** UNSUPPORTED **
  529. ; *
  530. ; * EXIT CF = 0
  531. ; * BL = macro type (3 = printer, 4 = drive)
  532. ; * BH = 'interesting' bits: 00 = valid, 01 = invalid
  533. ; * CX = user word
  534. ; * DS:SI has device type
  535. ; * ES:DI has net path
  536. ; * CF = 1
  537. ; * AX = ERROR_NO_MORE_FILES
  538. ; *
  539. ; * USES
  540. ; *
  541. ; * ASSUMES nothing
  542. ; *
  543. ; ***
  544. GetAssignList proc near
  545. assume cs:ResidentCode
  546. assume ds:nothing
  547. xor al,al
  548. jmp short @f
  549. GetAssignList2:
  550. or al,-1
  551. @@: SVC SVC_RDRGET_ASG_LIST
  552. jc @f
  553. push bx
  554. push cx
  555. DosCallBack GET_USER_STACK
  556. pop [si].User_Cx
  557. pop [si].User_Bx
  558. clc
  559. @@: ret
  560. GetAssignList endp
  561. page
  562. ; *** DefineMacro
  563. ; *
  564. ; * Old version of NetUseAdd
  565. ; *
  566. ; * ENTRY BL = device type
  567. ; * 3 = printer
  568. ; * 4 = drive
  569. ; * bit 7 on means use the wksta password when connecting
  570. ; * CX = user word
  571. ; * DS:SI = local device
  572. ; * Can be NUL device name, indicating UNC use
  573. ; * ES:DI = remote name
  574. ; *
  575. ; * EXIT CF = 0
  576. ; * success
  577. ; *
  578. ; * CF = 1
  579. ; * AX = ERROR_INVALID_PARAMETER (87)
  580. ; * ERROR_INVALID_PASSWORD (86)
  581. ; * ERROR_INVALID_DRIVE (15)
  582. ; * ERROR_ALREADY_ASSIGNED (85)
  583. ; * ERROR_PATH_NOT_FOUND (3)
  584. ; * ERROR_ACCESS_DENIED (5)
  585. ; * ERROR_NOT_ENOUGH_MEMORY (8)
  586. ; * ERROR_NO_MORE_FILES (18)
  587. ; * ERROR_REDIR_PAUSED (72)
  588. ; *
  589. ; * USES
  590. ; *
  591. ; * ASSUMES nothing
  592. ; *
  593. ; ***
  594. DefineMacro proc near
  595. assume cs:ResidentCode
  596. assume ds:nothing
  597. SVC SVC_RDRDEFINE_MACRO
  598. ret
  599. DefineMacro endp
  600. page
  601. ; *** BreakMacro
  602. ; *
  603. ; * Old version of NetUseDel
  604. ; *
  605. ; * ENTRY DS:SI = buffer containing device name of redirection to break
  606. ; *
  607. ; * EXIT
  608. ; *
  609. ; * USES
  610. ; *
  611. ; * ASSUMES nothing
  612. ; *
  613. ; ***
  614. BreakMacro proc near
  615. assume cs:ResidentCode
  616. assume ds:nothing
  617. SVC SVC_RDRBREAK_MACRO
  618. ret
  619. BreakMacro endp
  620. page
  621. ; *** GetRedirVersion
  622. ; *
  623. ; * Returns the version number of this redir in ax
  624. ; *
  625. ; * ENTRY none
  626. ; *
  627. ; * EXIT ax = version #
  628. ; *
  629. ; * USES ax, flags
  630. ; *
  631. ; * ASSUMES nothing
  632. ; *
  633. ; ***
  634. GetRedirVersion proc near
  635. assume cs:ResidentCode
  636. assume ds:nothing
  637. mov ax,300
  638. clc
  639. ret
  640. GetRedirVersion endp
  641. page
  642. ; *** NetGetUserName
  643. ; *
  644. ; * Returns the current logged on user name (if any)
  645. ; *
  646. ; * ENTRY CX = buffer length
  647. ; * ES:DI = buffer
  648. ; *
  649. ; * EXIT CF = 1
  650. ; * AX = Error code
  651. ; * NERR_BufTooSmall
  652. ; * Buffer not large enough for user name
  653. ; *
  654. ; * CF = 0
  655. ; * CX:BX = UID (ignored)
  656. ; * ES:DI = user name
  657. ; *
  658. ; * USES ax, flags
  659. ; *
  660. ; * ASSUMES nothing
  661. ; *
  662. ; ***
  663. NetGetUserName proc near
  664. assume cs:ResidentCode
  665. assume ds:nothing
  666. mov bx,1 ; bx == 1: check name length against cx
  667. call NetGetUserNameSvcCall
  668. DbgBreakPoint
  669. jc @f ; error
  670. ;
  671. ; no error: the user name was copied into ES:DI. Set the caller's cx and bx to
  672. ; return a UID. We could leave this as a random number since it is not used,
  673. ; but we set it to a known value
  674. ;
  675. DosCallBack GET_USER_STACK
  676. xor ax,ax ; clears carry again
  677. mov [si].User_Cx,ax
  678. inc ax
  679. mov [si].User_Bx,ax ; UID = 0x00000001
  680. @@: ret
  681. NetGetUserName endp
  682. page
  683. ; *** DefaultServiceError
  684. ; *
  685. ; * Default error routine - returns ERROR_INVALID_FUNCTION for any API
  686. ; * function which we don't support. Reached exclusively through dispatch
  687. ; * table
  688. ; *
  689. ; * ENTRY none
  690. ; *
  691. ; * EXIT CF = 1
  692. ; * AX = ERROR_INVALID_FUNCTION
  693. ; *
  694. ; * USES ax, flags
  695. ; *
  696. ; * ASSUMES nothing
  697. ; *
  698. ; ***
  699. DefaultServiceError proc near
  700. assume cs:ResidentCode
  701. assume ds:nothing
  702. ; DbgPrintString <"DefaultServiceError Ax="
  703. ; DbgPrintHexWord OriginalAx
  704. ; DbgPrintString <" Bx=">,NOBANNER
  705. ; DbgPrintHexWord OriginalBx
  706. ; DbgCrLf
  707. ;
  708. ; cause debug output to go to debug port: making invalid BOP will dump registers
  709. ;
  710. if DEBUG
  711. mov ax,OriginalAx
  712. mov bx,OriginalBx
  713. DbgUnsupported
  714. endif
  715. mov ax,ERROR_INVALID_FUNCTION
  716. stc
  717. ret
  718. DefaultServiceError endp
  719. page
  720. ; *** NetGetEnumInfo
  721. ; *
  722. ; * Routine which returns various internal redir variables based on an
  723. ; * index
  724. ; *
  725. ; * ENTRY BL = index
  726. ; * 0 = CDNames
  727. ; * 1 = Comment (not supported)
  728. ; * 2 = LanRoot
  729. ; * 3 = ComputerName
  730. ; * 4 = UserName
  731. ; * 5 = Primary Domain
  732. ; * 6 = Logon Server
  733. ; * 7 = Mailslots Yes/No
  734. ; * 8 = RIPL Yes/No
  735. ; * 9 = Get RIPL UNC
  736. ; * 10 = Get RIPL drive
  737. ; * 11 = Start marking CON_RIPL
  738. ; * 12 = Stop marking CON_RIPL
  739. ; * 13 = exchange int17 handlers
  740. ; * 14 = primary WrkNet
  741. ; *
  742. ; * es:di = buffer for returned info
  743. ; *
  744. ; * EXIT CF = 0
  745. ; * success
  746. ; * CF = 1
  747. ; * AX = ERROR_INVALID_FUNCTION
  748. ; *
  749. ; * USES ax, flags
  750. ; *
  751. ; * ASSUMES nothing
  752. ; *
  753. ; ***
  754. NetGetEnumInfo proc near
  755. or bl,bl
  756. jnz @f
  757. ;
  758. ; CDNames (Computer and Domain Names)
  759. ;
  760. ; DbgPrintString <"NetGetEnumInfo: return CDNames", 13, 10>
  761. SVC SVC_RDRGETCDNAMES
  762. ret
  763. ;
  764. ; Comment - nothing returned by this or the original redir (ax = invalid
  765. ; function, but carry clear?)
  766. ;
  767. @@: dec bl
  768. jnz @f
  769. DbgPrintString <"NetGetEnumInfo: return Comment", 13, 10>
  770. mov ax,ERROR_INVALID_FUNCTION
  771. ret
  772. ;
  773. ; LanRoot
  774. ;
  775. @@: dec bl
  776. jnz check_computername
  777. DbgPrintString <"NetGetEnumInfo: return LanRoot", 13, 10>
  778. pusha ; save user gp regs
  779. push es ; save user seg regs
  780. push ds
  781. mov si,ResidentData
  782. mov ds,si
  783. assume ds:ResidentData
  784. mov si,offset LanRoot
  785. mov cx,LanRootLength
  786. shr cx,1 ; cx = number of words to copy, cf=lsb
  787. cld
  788. rep movsw ; copy words
  789. jnc @f ; if not odd number of bytes skip
  790. movsb ; copy single byte
  791. @@: pop ds ; restore user seg regs
  792. pop es
  793. popa ; restore user gp regs
  794. ret
  795. ;
  796. ; ComputerName
  797. ;
  798. check_computername:
  799. dec bl
  800. jnz @f
  801. DbgPrintString <"NetGetEnumInfo: return ComputerName", 13, 10>
  802. SVC SVC_RDRGETCOMPUTERNAME
  803. ret
  804. ;
  805. ; Username
  806. ;
  807. @@: dec bl
  808. jnz @f
  809. DbgPrintString <"NetGetEnumInfo: return UserName", 13, 10>
  810. ;
  811. ; This is also the entry point for NetGetUserName, which return some info in
  812. ; cx:bx (the (ignored) UID). We could leave this random, but we set it to a
  813. ; known value, just in case
  814. ;
  815. NetGetUserNameSvcCall:
  816. SVC SVC_RDRGETUSERNAME ; either 0 if for NetGetEnumInfo or 1 if NetGetUserName
  817. ret
  818. ;
  819. ; Primary domain name
  820. ;
  821. @@: dec bl
  822. jnz @f
  823. DbgPrintString <"NetGetEnumInfo: return DomainName", 13, 10>
  824. SVC SVC_RDRGETDOMAINNAME
  825. ret
  826. ;
  827. ; Logon server name
  828. ;
  829. @@: dec bl
  830. jnz @f
  831. DbgPrintString <"NetGetEnumInfo: return LogonServerName", 13, 10>
  832. SVC SVC_RDRGETLOGONSERVER
  833. ret
  834. ;
  835. ; Mailslots YN
  836. ;
  837. ; Mailslots are always enabled with this redir, so return yes (TRUE, 1)
  838. ;
  839. @@: dec bl
  840. jnz @f
  841. DbgPrintString <"NetGetEnumInfo: Mailslot check", 13, 10>
  842. mov ax,1
  843. ret
  844. ;
  845. ; RIPL YN
  846. ;
  847. ; This redir doesn't know anything about RPL, so return no (FALSE, 0)
  848. ;
  849. @@: dec bl
  850. jnz @f
  851. DbgPrintString <"NetGetEnumInfo: RIPL check", 13, 10>
  852. xor ax,ax
  853. ret
  854. ;
  855. ; RIPL UNC
  856. ;
  857. @@: dec bl
  858. jnz @f
  859. DbgPrintString <"NetGetEnumInfo: return RIPL UNC", 13, 10>
  860. jmps DefaultServiceError
  861. ;
  862. ; RIPL drive
  863. ;
  864. @@: dec bl
  865. jnz @f
  866. DbgPrintString <"NetGetEnumInfo: return RIPL drive", 13, 10>
  867. jmps DefaultServiceError
  868. ;
  869. ; Start marking CON_RIPL
  870. ;
  871. @@: dec bl
  872. jnz @f
  873. DbgPrintString <"NetGetEnumInfo: Start marking CON_RIPL", 13, 10>
  874. jmps DefaultServiceError
  875. ;
  876. ; Stop marking CON_RIPL
  877. ;
  878. @@: dec bl
  879. jnz @f
  880. DbgPrintString <"NetGetEnumInfo: Stop marking CON_RIPL", 13, 10>
  881. jmps DefaultServiceError
  882. ;
  883. ; exchange int 17 handlers
  884. ;
  885. ; We don't support this so return error
  886. ;
  887. @@: dec bl
  888. jnz @f
  889. DbgPrintString <"NetGetEnumInfo: exchange int 17 handlers", 13, 10>
  890. jmps DefaultServiceError
  891. ;
  892. ; primary WrkNet
  893. ;
  894. ; This is transport-specific so we don't return anything except error
  895. ;
  896. @@: dec bl
  897. jnz @f
  898. DbgPrintString <"NetGetEnumInfo: return primary WrkNet", 13, 10>
  899. jmps DefaultServiceError
  900. ;
  901. ; anything else - return an error
  902. ;
  903. @@: DbgPrintString "NetGetEnumInfo: unknown request: "
  904. DbgPrintHexWord bx
  905. DbgCrLf
  906. jmps DefaultServiceError
  907. NetGetEnumInfo endp
  908. page
  909. ; *** NetSpoolStuff
  910. ; *
  911. ; * Gets control from INT 2f/ax=1125h. This really has no use in NTVDM,
  912. ; * but we supply it because DOS has started making 1125 calls. Spooling
  913. ; * in NTVDM has nothing to do with the Redir TSR. Historically, printing
  914. ; * over the net was handled by the redir & this call was used (amongst
  915. ; * other things) to flush & close all spool files when an app terminated
  916. ; *
  917. ; * ENTRY AL = 7 Return truncate flag in DL (DH destroyed)
  918. ; * AL = 8 Set truncate flag from DL (must be 0 or 1)
  919. ; * AL = 9 Close all spool files
  920. ; *
  921. ; * EXIT CF = 1
  922. ; * AX = ERROR_INVALID_FUNCTION
  923. ; *
  924. ; * USES ax, dx, si, ds, flags
  925. ; *
  926. ; * ASSUMES nothing
  927. ; *
  928. ; ***
  929. PrintTruncate db 0
  930. NetSpoolStuff proc near
  931. sub al,9 ; most common case first
  932. jnz @f
  933. net_spool_stuff_good_exit:
  934. xor ax,ax ; nothing to do for CloseAllSpool!
  935. ret
  936. @@: inc al
  937. jnz @f ; must be get, or invalid
  938. mov ax,ERROR_INVALID_PARAMETER
  939. cmp dl,1 ; must be 0 or 1
  940. ja net_spool_stuff_error_exit
  941. mov PrintTruncate,dl
  942. jmp short net_spool_stuff_good_exit
  943. @@: inc al
  944. mov ax,ERROR_INVALID_FUNCTION
  945. jnz net_spool_stuff_error_exit
  946. ;
  947. ; return PrintTruncate flag to caller (app)
  948. ;
  949. DosCallBack GET_USER_STACK
  950. mov dl,PrintTruncate
  951. xor dh,dh
  952. mov [si].User_Dx,dx
  953. ret
  954. net_spool_stuff_error_exit:
  955. stc
  956. ret
  957. NetSpoolStuff endp
  958. page
  959. if DEBUG
  960. even
  961. public Old21Handler
  962. Old21Handler dd ?
  963. public CheckInt21Function5e
  964. CheckInt21Function5e proc far
  965. assume cs:ResidentCode
  966. assume ds:nothing
  967. assume es:nothing
  968. assume ss:nothing
  969. ; cmp ah,5eh
  970. ; jnz @f
  971. ; DbgUnsupported
  972. @@: jmp Old21Handler ; let DOS handle it. DOS returns to caller
  973. CheckInt21Function5e endp
  974. endif
  975. ResidentCodeEnd
  976. end