home *** CD-ROM | disk | FTP | other *** search
/ Software Collection (I) / TOOLS.iso / b04 / 22.img / LDOSNET / DOSNET.AS_ / DOSNET.AS
Encoding:
Text File  |  1992-01-04  |  32.9 KB  |  1,289 lines

  1. PAGE 58,132
  2. ;******************************************************************************
  3. TITLE DOSNET.ASM
  4. ;******************************************************************************
  5. ;
  6. ;   (C) Copyright MICROSOFT Corp., 1988-1990
  7. ;
  8. ;   Title:    DOSNET.ASM - DOS NETWORK INT 21 Call manager device
  9. ;
  10. ;   Version:    2.01
  11. ;
  12. ;   Date:    09-Jun-1989
  13. ;
  14. ;   Author:    ARR
  15. ;
  16. ;------------------------------------------------------------------------------
  17. ;
  18. ;   Change log:
  19. ;
  20. ;      DATE    REV            DESCRIPTION
  21. ;   ----------- --- -----------------------------------------------------------
  22. ;   09-Jun-1989 ARR Move stuff from DOSMGR device
  23. ;
  24. ;==============================================================================
  25.  
  26.     .386p
  27.  
  28. ;******************************************************************************
  29. ;
  30. ;  What this device does is manage DOS network drive connections in such a way
  31. ;    as to prevent the DOS internal drive state information structures
  32. ;    from containing corrupt (stale) information. It also prevents the
  33. ;    data structure state in the REDIRector from getting similarly corrupted.
  34. ;
  35. ;
  36. ;      o CONNECTIONS in effect when WIN386 starts are GLOBAL connections which
  37. ;        cannot be broken while WIN386 is running.
  38. ;
  39. ;          The DOS CDS structures are part of the "instance snapshot" which
  40. ;          is restored ehrn WIN386 exits. If we allowed GLOBAL network
  41. ;          connections to be broken or changed under WIN386 we would
  42. ;          "restore" a connection which no longer exists (or is different)
  43. ;          and corrupt the CDS structures.
  44. ;
  45. ;      o CONNECTIONS in effect in the SYSTEM VM when a new VM is created
  46. ;        are INHERITED by the new VM. INHERITED connections cannot be
  47. ;        broken in any VM including the SYS VM.
  48. ;
  49. ;          When VMs are created, the SHELL device calls the
  50. ;          DOSMGR_Copy_VM_Drive_State service so that new VMs have the same
  51. ;          drive state as the current SYS VM drive state.
  52. ;
  53. ;          The DOS REDIRector is driven by reference counts on its
  54. ;          internal "connection" structures. These reference counts are
  55. ;          not updated when VMs are created and destroyed. In order to
  56. ;          prevent "corruption" of the REDIRector data structures,
  57. ;          trying to delete one of these INHERITED connections is prevented.
  58. ;
  59. ;      o CONNECTIONS made by a particular VM are LOCAL to that VM because
  60. ;        the DOS CDS structures, where the connection is indicated, are
  61. ;        LOCAL to each VM.
  62. ;
  63. ;          The DOS REDIRector is a GLOBAL object however. In order to
  64. ;          prevent corrupting the REDIRectors data structures when a VM
  65. ;          terminates the DOSNET device "net use /d"s any LOCAL uses
  66. ;          that the VM has performed.
  67. ;
  68. ;      o Windows version 3 has a message called WM_FILESYSCHANGE which is
  69. ;        sent when the filesystem is changed, this includes changes made
  70. ;        in VMs other than the SYS VM. We do not want to send
  71. ;        WM_FILESYSCHANGE messages on LOCAL network drives because Windows
  72. ;        doesn't know anything about these drives.
  73. ;
  74. ;      o UNC uses (drive resource uses which are not associated with any
  75. ;        drive) do not need to be managed by DOSNET. They behave GLOBALY.
  76. ;
  77. ;      o Printer uses do not need to be managed by DOSNET. They behave GLOBALY.
  78. ;
  79. ;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  80. ;
  81. ; This DOSNET device DOES NOT HAVE one of these pieces. This is because it
  82. ;    doesn't need one. The interaction of applications with DOS REDIR networks
  83. ;    is via the standard DOS INT 21H calls (5Fh) and the mapping of them for
  84. ;    Protected Mode applications is handled by the DOSMGR device. In the case
  85. ;    of a network that has made extensions to the DOS INT 21H, or other API,
  86. ;    interfaces (such as the NOVELL network) this piece would be needed and
  87. ;    the DOSNET device is a logical place to put it (although it could be in
  88. ;    a separate device instead).
  89. ;
  90. ;      o API mapper to map APIs specific to this network from Protected Mode
  91. ;        applications. Consult V86MMGR documentation and the VNETBIOS device
  92. ;        sources.
  93. ;
  94. ;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  95. ;
  96. ;******************************************************************************
  97.  
  98. ;******************************************************************************
  99. ;                  I N C L U D E S
  100. ;******************************************************************************
  101.  
  102.     INCLUDE VMM.Inc
  103.     INCLUDE Debug.Inc
  104.     INCLUDE DNLocal.Inc
  105.     INCLUDE shell.inc
  106.  
  107.     Create_DOSNET_Service_Table EQU TRUE
  108.  
  109.     INCLUDE DOSNET.Inc
  110.  
  111. ;******************************************************************************
  112.  
  113. Declare_Virtual_Device DOSNET, 1, 0, DOSNET_Sys_Control, DOSNET_Device_ID, \
  114.                DOSNET_Init_Order
  115.  
  116. ;******************************************************************************
  117. ;                 E X T E R N A L S
  118. ;******************************************************************************
  119.  
  120.  
  121. ;
  122. VxD_CODE_SEG
  123.  
  124. VxD_CODE_ENDS
  125.  
  126. VxD_ICODE_SEG
  127.  
  128. VxD_ICODE_ENDS
  129.  
  130.  
  131. VxD_DATA_SEG
  132.  
  133. Extrn    DNNetUseGlobalMsg:byte
  134. Extrn    DNNetUseGlobalMsgDrive:byte
  135. Extrn    DNNetUseInherMsg:byte
  136. Extrn    DNNetUseInherMsgDrive:byte
  137. Extrn    DNNetUseParentMsg:byte
  138. Extrn    DNNetUseParentMsgDrive:byte
  139. Extrn    DNDontDestroyMsg:byte
  140. Extrn    DNDontDestroyMsgDrive:byte
  141.  
  142. ALIGN 4
  143.  
  144. ;
  145. ; Control block offset of DOSNET section
  146. ;
  147.     public DN_CB_Offset
  148. DN_CB_Offset        dd    ?
  149.  
  150. ;
  151. ; Flag that indicates that the origin of this "NET USE /D" call is the DOSNET
  152. ;    device itself.
  153. ;
  154. NetUseCleanUpFlg    db    0
  155.  
  156. VxD_DATA_ENDS
  157.  
  158.  
  159. VxD_IDATA_SEG
  160.  
  161. VxD_IDATA_ENDS
  162.  
  163.  
  164. VxD_ICODE_SEG
  165.  
  166. ;******************************************************************************
  167. ;
  168. ;   NAME:
  169. ;    DOSNET_Sys_Critical_Init
  170. ;
  171. ;   DESCRIPTION:
  172. ;    Allocate the control block buffer
  173. ;
  174. ;   ENTRY:
  175. ;    EBX = VM1 handle
  176. ;
  177. ;   EXIT:
  178. ;       CF set if error
  179. ;
  180. ;   USES:
  181. ;    EAX,ECX,EDX,Flags
  182. ;
  183. ;------------------------------------------------------------------------------
  184.  
  185. BeginProc DOSNET_Sys_Critical_Init
  186.  
  187.     VMMCall _Allocate_Device_CB_Area, <<SIZE DN_Control_Blk_Struc>, 0>
  188.     test    eax, eax
  189.     jnz    SHORT DN_CB_OK
  190.     Debug_Out "DOSNET ERROR:  Could not alloc control block data area space"
  191.     VMMcall Fatal_Memory_Error
  192.  
  193. DN_CB_OK:
  194.     mov    [DN_CB_Offset], eax
  195.     clc
  196.     ret
  197.  
  198. EndProc DOSNET_Sys_Critical_Init
  199.  
  200.  
  201.  
  202. ;******************************************************************************
  203. ;
  204. ;   DOSNET_Device_Init
  205. ;
  206. ;   DESCRIPTION:
  207. ;    Now we can simulate interrupts into the system VM. We will set
  208. ;    up the GLOBAL uses information and set up the INT 21 hook.
  209. ;
  210. ;   ENTRY:
  211. ;    EBX = SYS_VM_Handle
  212. ;
  213. ;   EXIT:
  214. ;    Carry set if problem
  215. ;
  216. ;   USES:
  217. ;    EAX,ECX,EDX,ESI,EDI,Flags
  218. ;
  219. ;==============================================================================
  220.  
  221. BeginProc DOSNET_Device_Init
  222.  
  223.     ;
  224.     ; Install the DOS system call hook.
  225.     ;
  226.     ; NOTE: We only need to hook the V86 call. This indirectly hooks the
  227.     ;        Protected Mode call as well because after the API mapping of
  228.     ;        the INT 21 is performed, the INT 21 is reflected into V86
  229.     ;        mode which will trip this hook. One might tend to think:
  230.     ;        "Wouldn't it be more efficient to hook the PM INT 21 as well?"
  231.     ;        But there are some subtle interactions that would be harder to
  232.     ;        handle if it was done this way:
  233.     ;
  234.     ;          The PM hook would get tripped, then the V86 hook would get
  235.     ;        tripped. The V86 hook would have to "interact and exclude"
  236.     ;        with the PM hook to prevent them from interfereing with each
  237.     ;        other (hooking the same call twice, once in PM and once in
  238.     ;        V86).
  239.     ;
  240.     ;          The error simulation on failure of NET USE /D is done by actually
  241.     ;        reflecting the call into DOS (in V86 mode) after "adjusting"
  242.     ;        the parameters to cause an error. The PM hook would have to
  243.     ;        reflect into V86 mode anyway to get this behavior.
  244.     ;
  245.     mov    eax, 21h
  246.     mov    esi, offset32 DOSNET_Int_21
  247.     VMMcall Hook_V86_Int_Chain
  248.     ;
  249.     ; Init the global Net Use list in the SYS VM
  250.     ;
  251.     VMMCall _Allocate_Temp_V86_Data_Area,<256,0>
  252.  
  253.     or    eax,eax
  254. IFDEF DEBUG
  255.     jnz    short DDID20
  256.     debug_out "_Allocate_Temp_V86_Data_Area failed DOSNET_Device_Init"
  257. DDID20:
  258. ENDIF
  259.     jz    DDIDone
  260.     mov    esi,eax
  261.     mov    edi,eax
  262.     shr    edi,4            ; EDI = segment
  263.  
  264.     VMMCall Get_SYS_VM_Handle
  265.  
  266.     mov    edx,ebx
  267.     add    edx,[DN_CB_Offset]
  268.  
  269.     Push_Client_State
  270.  
  271.     VMMCall Begin_Nest_Exec
  272.  
  273.     mov    ebp, [ebx.CB_Client_Pointer]
  274.     mov    [ebp.Client_DS], di
  275.     mov    [ebp.Client_ES], di
  276.     mov    [ebp.Client_SI], 0
  277.     mov    [ebp.Client_DI], 128
  278.     xor    ecx,ecx
  279. DDIGetRedirLp:
  280.     mov    [ebp.Client_BX], cx
  281.     mov    [ebp.Client_AX], 5F02h
  282.     mov    eax, 21h
  283.  
  284.     VMMCall Exec_Int
  285.  
  286.     test    [ebp.Client_EFLAGS],CF_Mask
  287.     jnz    short DDIGetRedirDone
  288.     cmp    [ebp.Client_BL], 4
  289.     jnz    short DDISkipUse    ; Ignore non-drive uses
  290.     mov    eax,dword ptr [esi]
  291.     or    al,al
  292.     jz    short DDISkipUse    ; Ignore UNC uses
  293.     cmp    ah,':'
  294.     jnz    short DDISkipUse    ; Ignore non-drive uses
  295.     or    al,20h
  296.     sub    al,'a'
  297.     jc    short DDISkipUse    ; Ignore non-drive uses
  298.     cmp    al,26
  299.     jae    short DDISkipUse    ; Ignore non-drive uses
  300.     movzx    eax,al
  301.     mov    [edx.DN_VM_LocalNetUseFlgs][eax],DN_LocUse_F_Global + DN_LocUse_F_InUse
  302. DDISkipUse:
  303.     inc    ecx
  304.     jmp    short DDIGetRedirLp
  305.  
  306. DDIGetRedirDone:
  307.  
  308.     VMMCall End_Nest_Exec
  309.  
  310.     Pop_Client_State
  311.  
  312.     VMMCall _Free_Temp_V86_Data_Area
  313.  
  314. DDIDone:
  315.     clc
  316.     ret
  317.  
  318. EndProc DOSNET_Device_Init
  319.  
  320. VxD_ICODE_ENDS
  321.  
  322.  
  323. VxD_CODE_SEG
  324.  
  325. BeginDoc
  326. ;******************************************************************************
  327. ;
  328. ;   DOSNET_Get_Version
  329. ;
  330. ;   DESCRIPTION:
  331. ;    Return DOSNET device version
  332. ;
  333. ;   ENTRY:
  334. ;    None
  335. ;
  336. ;   EXIT:
  337. ;    EAX = Version, Major in AH, Minor in AL
  338. ;    Carry clear
  339. ;
  340. ;   USES:
  341. ;    Flags,EAX
  342. ;
  343. ;==============================================================================
  344. EndDoc
  345.  
  346. BeginProc DOSNET_Get_Version, SERVICE
  347.  
  348.     mov    eax,0300h
  349.     clc
  350.     ret
  351.  
  352. EndProc DOSNET_Get_Version
  353.  
  354. BeginDoc
  355. ;******************************************************************************
  356. ;
  357. ;   DOSNET_Do_PSP_Adjust
  358. ;
  359. ;   DESCRIPTION:
  360. ;    This service allows the DOSMGR device to ask whether it should perform
  361. ;    adjustments to try and initially give each VM in the system a different
  362. ;    starting DOS PSP address. This needs to be done on networks (such as
  363. ;    MSNET) that use the PSP address as part of an ID to uniquely identify
  364. ;    different processes talking to the SERVER (this effects the behavior
  365. ;    of DOS SHARE on the SERVER end). On a network which uses DOS PSP
  366. ;    addresses as part of an ID, WIN386 can cause the ID to be non-unique
  367. ;    since thare are now multiple VMs which all can have an app in them
  368. ;    which has the same PSP address. If the PSP adjust is enabled by this
  369. ;    service, the DOSMGR device causes each VM to start at a different
  370. ;    paragraph address (VMID is the basis of the adjustment value) and
  371. ;    thus have a different PSP address. This has the cost of wasting some
  372. ;    memory with the benifit of making the PSP addresses different in all
  373. ;    the VMs.
  374. ;
  375. ;    For a network which does not use DOS PSP addresses for anything, or
  376. ;    one which is WIN386 aware and uses the Get VMID INT 2F service of
  377. ;    WIN386 to deal with this problem, a return of Carry SET, EAX !=0
  378. ;    is appropriate.
  379. ;
  380. ;    NOTE: That the uniqueness of PSPs is NOT GUARANTEED by this. It will
  381. ;          deal with the case on most configurations, but on some it will
  382. ;          not. The only absolutely correct solution is to make the network
  383. ;          software WIN386 aware and work the VMID into the network ID,
  384. ;          in addition to the PSP address, by using the Get VMID INT 2F
  385. ;          service of WIN386.
  386. ;
  387. ;   ENTRY:
  388. ;    None
  389. ;
  390. ;   EXIT:
  391. ;    Carry Set
  392. ;        DO NOT do PSP adjustment
  393. ;        EAX == 0 if SYSTEM.INI override of this is allowed
  394. ;        EAX != 0 if SYSTEM.INI override of this is NOT allowed
  395. ;    Carry Clear
  396. ;        DO PSP adjustment
  397. ;        EAX == 0 if SYSTEM.INI override of this is allowed
  398. ;        EAX != 0 if SYSTEM.INI override of this is NOT allowed
  399. ;
  400. ;   NOTE: The behavior of DOSMGR if the DOSNET device is not loaded is a
  401. ;      return of carry SET, EAX = 0.
  402. ;
  403. ;   USES:
  404. ;    Flags,EAX
  405. ;
  406. ;==============================================================================
  407. EndDoc
  408.  
  409. BeginProc DOSNET_Do_PSP_Adjust, SERVICE
  410.  
  411.     xor    eax,eax     ; SYSTEM.INI override allowed (also clears carry)
  412. ;;;       clc                ; DO PSP adjust
  413.     ret
  414.  
  415. EndProc DOSNET_Do_PSP_Adjust
  416.  
  417. BeginDoc
  418. ;******************************************************************************
  419. ;
  420. ;   DOSNET_Send_FILESYSCHANGE
  421. ;
  422. ;   DESCRIPTION:
  423. ;    It is incorrect to send the WM_FILESYSCHANGE message to the Windows
  424. ;    shell on drives which Windows knows nothing about. This routine
  425. ;    tells the caller whether this is a "local to this VM" drive or
  426. ;    not. The WM_FILESYSCHANGE message allows Windows applications
  427. ;    to be told when a change is made to the file volume name space so
  428. ;    that they can update portions of their display which may be showing
  429. ;    that part of the file volume.
  430. ;
  431. ;    Sending a WM_FILESYSCHANGE on a drive incorrectly can result in
  432. ;    all sorts of misbehavior. If the indicated drive letter is invalid
  433. ;    in the SYS VM, the Windows app may get an error it is not expecting.
  434. ;    If the indicated drive letter actually mapps a different file system
  435. ;    volume in the SYS VM, all sorts of other unexpected errors may occur.
  436. ;
  437. ;   NOTE: This is a DOSNET device service and cannot be implemented directly
  438. ;      in another device. Another device that also wishes to effect the
  439. ;      WM_FILESYSCHANGE behavior must hook this service. Note also that
  440. ;      the DOSNET device does not install if there is no REDIR, so a device
  441. ;      which wants to hook this service must ship with a modified DOSNET
  442. ;      device which ALWAYS loads (real mode init code removed).
  443. ;
  444. ;   ENTRY:
  445. ;    EAX (AL) = Drive number (0 = A)
  446. ;    EBX is VM Handle of VM involved
  447. ;
  448. ;   EXIT:
  449. ;    Carry Set
  450. ;        WM_FILESYSCHANGE should NOT be sent on this drive
  451. ;    Carry Clear
  452. ;        WM_FILESYSCHANGE SHOULD be sent on this drive
  453. ;
  454. ;   USES:
  455. ;    FLAGS
  456. ;
  457. ;==============================================================================
  458. EndDoc
  459.  
  460. BeginProc DOSNET_Send_FILESYSCHANGE, SERVICE
  461.  
  462.     push    ebx
  463.  
  464.     Assert_VM_Handle ebx
  465.  
  466.     VMMCall Test_SYS_VM_Handle
  467.  
  468.     clc
  469.     je    short DNSFSCDone    ; Always should on SYS VM
  470.     cmp    al,26
  471.     jae    short DNSFSCDone    ; Carry clear if jump
  472.     add    ebx,[DN_CB_Offset]
  473.     test    [ebx.DN_VM_LocalNetUseFlgs][eax],DN_LocUse_F_InUse
  474.     jz    short DNSFSCDone    ; Carry clear if jump
  475.     test    [ebx.DN_VM_LocalNetUseFlgs][eax],DN_LocUse_F_Global + DN_LocUse_F_Inherit
  476.     jnz    short DNSFSCDone    ; Carry clear if jump
  477.     stc                ; Drive is a local use drive
  478. DNSFSCDone:
  479.     pop    ebx
  480.     ret
  481.  
  482. EndProc DOSNET_Send_FILESYSCHANGE
  483.  
  484.  
  485. ;******************************************************************************
  486. ;
  487. ;   DOSNET_Sys_Control
  488. ;
  489. ;   DESCRIPTION:
  490. ;    Dispatch routine for the sys control calls
  491. ;
  492. ;   ENTRY:
  493. ;    Call specific
  494. ;
  495. ;   EXIT:
  496. ;    Call specific
  497. ;
  498. ;   USES:
  499. ;    Call specific
  500. ;
  501. ;==============================================================================
  502.  
  503. Begin_Control_Dispatch DOSNET_Sys
  504.  
  505.     Control_Dispatch Sys_Critical_Init, DOSNET_Sys_Critical_Init
  506.     Control_Dispatch Device_Init,        DOSNET_Device_Init
  507.     Control_Dispatch Destroy_VM,        DOSNET_Destroy_VM
  508.     Control_Dispatch VM_Terminate,        DOSNET_VM_Terminate
  509.     Control_Dispatch Sys_VM_Terminate,  DOSNET_VM_Terminate
  510.     Control_Dispatch Create_VM,        DOSNET_Create_VM
  511.     Control_Dispatch Query_Destroy,     DOSNET_Query_Destroy
  512. IFDEF DEBUG
  513.     Control_Dispatch Debug_Query,        DOSNET_Dump_Debug_Info
  514. ENDIF
  515.  
  516. End_Control_Dispatch DOSNET_Sys
  517.  
  518.  
  519. ;******************************************************************************
  520. ;
  521. ;   DOSNET_Query_Destroy
  522. ;
  523. ;   DESCRIPTION:
  524. ;    OK to destroy running VM? Answer NO if any local uses outstanding.
  525. ;
  526. ;   ENTRY:
  527. ;    EBX = VM Handle
  528. ;
  529. ;   EXIT:
  530. ;    Carry Set if not OK (outstanding net uses)
  531. ;
  532. ;   USES:
  533. ;    FLAGS,EAX,EDX,ECX
  534. ;
  535. ;==============================================================================
  536.  
  537. BeginProc DOSNET_Query_Destroy
  538.  
  539.     mov    edx,ebx
  540.     add    edx,[DN_CB_Offset]
  541.     mov    ecx,25
  542. DNQDChkLp:
  543.     test    [edx.DN_VM_LocalNetUseFlgs][ecx],DN_LocUse_F_InUse
  544.     jz    short DNQDChkSkip    ; Not net
  545.     test    [edx.DN_VM_LocalNetUseFlgs][ecx],DN_LocUse_F_Global
  546.     jnz    short DNQDChkSkip    ; Is global, OK
  547.     test    [edx.DN_VM_LocalNetUseFlgs][ecx],DN_LocUse_F_Inherit
  548.     jnz    short DNQDChkSkip    ; Is Inherit, OK
  549.     ;
  550.     ; ECX drive is a local use.
  551.     ;
  552.     mov    al,cl
  553.     add    al,'A'
  554.     mov    ecx,offset32 DNDontDestroyMsg
  555.     mov    [DNDontDestroyMsgDrive],al
  556.     xor    edi,edi         ; Standard caption
  557.     xor    esi,esi         ; No call back
  558.     mov    eax,MB_OK + MB_ICONEXCLAMATION + MB_SYSTEMMODAL
  559.  
  560.     VMMCall Test_SYS_VM_Handle
  561.  
  562.     jz    short DNQD_Modal
  563.  
  564.     VxdCall SHELL_Message
  565.  
  566.     jmp    short DNQD_MsgDone
  567.  
  568. DNQD_Modal:
  569.     debug_out "Odd case DOSNET_Query_Destroy on SYS VM????"
  570.  
  571.     VxdCall SHELL_SYSMODAL_Message
  572.  
  573. DNQD_MsgDone:
  574.  
  575.     stc
  576.     jmp    short DNQDDone
  577.  
  578. DNQDChkSkip:
  579.     jecxz    DNQDDoneOK
  580.     dec    ecx
  581.     jmp    DEBFAR DNQDChkLp
  582.  
  583. DNQDDoneOK:
  584.     clc
  585. DNQDDone:
  586.     ret
  587.  
  588. EndProc DOSNET_Query_Destroy
  589.  
  590. ;******************************************************************************
  591. ;
  592. ;   DOSNET_Destroy_VM
  593. ;
  594. ;   DESCRIPTION:
  595. ;    Clean up any outstanding net use inheritance counts.
  596. ;    We need this here because a VM which crashes or is destroyed
  597. ;    will not go through a normal termination sequence.
  598. ;
  599. ;   ENTRY:
  600. ;    EBX = VM Handle
  601. ;
  602. ;   EXIT:
  603. ;    Carry clear
  604. ;
  605. ;   USES:
  606. ;    FLAGS,EAX,EDX
  607. ;
  608. ;==============================================================================
  609.  
  610. BeginProc DOSNET_Destroy_VM
  611.  
  612.     mov    edx,ebx
  613.     add    edx,[DN_CB_Offset]
  614.     mov    ecx,25
  615. DDVMUndoLp:
  616.     test    [edx.DN_VM_LocalNetUseFlgs][ecx],DN_LocUse_F_InUse
  617.     jz    DEBFAR DDVMUndoSkip
  618.     test    [edx.DN_VM_LocalNetUseFlgs][ecx],DN_LocUse_F_Global
  619.     jnz    DEBFAR DDVMUndoSkip
  620.     test    [edx.DN_VM_LocalNetUseFlgs][ecx],DN_LocUse_F_Inherit
  621. IFDEF DEBUG
  622.     jnz    short DDVMD20
  623.     debug_out "Stranded local use drive #CL DOSNET_Destroy_VM"
  624. DDVMD20:
  625. ENDIF
  626.     jz    short DDVMUndoSkip
  627.     push    ebx
  628.  
  629.     VMMCall Get_SYS_VM_Handle
  630.  
  631.     mov    eax,ebx
  632.     add    eax,[DN_CB_Offset]
  633.     pop    ebx
  634. IFDEF DEBUG
  635.     test    [eax.DN_VM_LocalNetUseFlgs][ecx],DN_LocUse_F_InUse
  636.     jnz    short DDVMD05
  637.     debug_out "Inher net use back link to SYS VM invalid 1 DOSNET_Destroy_VM"
  638. DDVMD05:
  639.     test    [eax.DN_VM_LocalNetUseFlgs][ecx],DN_LocUse_F_Inherit + DN_LocUse_F_Global
  640.     jz    short DDVMD07
  641.     debug_out "Inher net use back link to SYS VM invalid 2 DOSNET_Destroy_VM"
  642. DDVMD07:
  643. ENDIF
  644.     cmp    [eax.DN_VM_LocalNetInhRefCnt][ecx],0
  645. IFDEF DEBUG
  646.     jnz    short DDVMD10
  647.     debug_out "Attempt to dec drive #CL inherit count through 0 DOSNET_Destroy_VM"
  648. DDVMD10:
  649. ENDIF
  650.     jz    short DDVMUndoSkip
  651.     dec    [eax.DN_VM_LocalNetInhRefCnt][ecx]
  652. DDVMUndoSkip:
  653.     jecxz    DDVMDone
  654.     dec    ecx
  655.     jmp    DEBFAR DDVMUndoLp
  656.  
  657. DDVMDone:
  658.     clc
  659.     ret
  660.  
  661. EndProc DOSNET_Destroy_VM
  662.  
  663.  
  664. ;******************************************************************************
  665. ;
  666. ;   DOSNET_VM_Terminate
  667. ;
  668. ;   DESCRIPTION:
  669. ;    Clean up any outstanding local net uses and un-inherit inherited drives
  670. ;
  671. ;   ENTRY:
  672. ;    EBX = VM Handle
  673. ;
  674. ;   EXIT:
  675. ;    Carry clear
  676. ;
  677. ;   USES:
  678. ;    FLAGS,EAX,EDX
  679. ;
  680. ;==============================================================================
  681.  
  682. BeginProc DOSNET_VM_Terminate
  683.  
  684.     mov    edx,ebx
  685.     add    edx,[DN_CB_Offset]
  686.     mov    ecx,25
  687. DVMTUndoLp:
  688.     test    [edx.DN_VM_LocalNetUseFlgs][ecx],DN_LocUse_F_InUse
  689.     jz    DEBFAR DVMTUndoSkip    ; Not net, ignore
  690.     test    [edx.DN_VM_LocalNetUseFlgs][ecx],DN_LocUse_F_Global
  691.     jnz    DEBFAR DVMTUndoSkip    ; Global, ignore
  692.     test    [edx.DN_VM_LocalNetUseFlgs][ecx],DN_LocUse_F_Inherit
  693.     jz    DEBFAR DVMTUndoUse    ; Local use, go undo it
  694.     ;
  695.     ; ECX drive is an inherited drive from SYS VM
  696.     ;
  697.     push    ebx
  698.  
  699.     VMMCall Get_SYS_VM_Handle
  700.  
  701.     mov    eax,ebx
  702.     add    eax,[DN_CB_Offset]
  703.     pop    ebx
  704.     cmp    eax,edx
  705. IFDEF DEBUG
  706.     jne    short DNVTD03
  707.     debug_out "Inher set in SYS VM DOSNET_VM_Terminate"
  708. DNVTD03:
  709. ENDIF
  710.     je    short DVMTUndoSkipZap
  711. IFDEF DEBUG
  712.     test    [eax.DN_VM_LocalNetUseFlgs][ecx],DN_LocUse_F_InUse
  713.     jnz    short DNVTD05
  714.     debug_out "Inher net use back link to SYS VM invalid 1 DOSNET_VM_Terminate"
  715. DNVTD05:
  716.     test    [eax.DN_VM_LocalNetUseFlgs][ecx],DN_LocUse_F_Inherit + DN_LocUse_F_Global
  717.     jz    short DNVTD07
  718.     debug_out "Inher net use back link to SYS VM invalid 2 DOSNET_VM_Terminate"
  719. DNVTD07:
  720. ENDIF
  721.     cmp    [eax.DN_VM_LocalNetInhRefCnt][ecx],0
  722. IFDEF DEBUG
  723.     jnz    short DVMTD10
  724.     debug_out "Attempt to dec drive #CL inherit count through 0 DOSNET_VM_Terminate"
  725. DVMTD10:
  726. ENDIF
  727.     jz    short DVMTUndoSkipZap
  728.     dec    [eax.DN_VM_LocalNetInhRefCnt][ecx]
  729. DVMTUndoSkipZap:
  730.     mov    [edx.DN_VM_LocalNetUseFlgs][ecx],0
  731. DVMTUndoSkip:
  732.     jecxz    DVMTDone
  733.     dec    ecx
  734.     jmp    DEBFAR DVMTUndoLp
  735.  
  736. DVMTUndoUse:
  737.     inc    [NetUseCleanUpFlg]    ; Flag that this use /d is from DOSNET
  738.     mov    eax,ecx
  739.     add    al,'A'
  740.     mov    ah,':'
  741.     push    eax
  742.     mov    esi,esp
  743.     mov    eax,5F04h        ; "net use /d" call
  744.  
  745.     VxDInt    21h
  746.  
  747. IFDEF DEBUG
  748.     jnc    short DVMTD40
  749.     debug_out "Net UnUse clean up attempt failed error #EAX drv @esp"
  750. DVMTD40:
  751. ENDIF
  752.     mov    [NetUseCleanUpFlg],0    ; Clear "from DOSNET" flag
  753.     pop    eax
  754.     jmp    short DVMTUndoSkipZap
  755.  
  756. DVMTDone:
  757.     clc
  758.     ret
  759.  
  760. EndProc DOSNET_VM_Terminate
  761.  
  762.  
  763. ;******************************************************************************
  764. ;
  765. ;   DOSNET_Create_VM
  766. ;
  767. ;   DESCRIPTION:
  768. ;    Initialize the use arrays setting up the GLOBAL and INHERITed drives
  769. ;    for the new VM
  770. ;
  771. ;   ENTRY:
  772. ;    EBX = VM Handle
  773. ;
  774. ;   EXIT:
  775. ;    Carry clear
  776. ;
  777. ;   USES:
  778. ;    All but segs, EBP
  779. ;
  780. ;==============================================================================
  781.  
  782. BeginProc DOSNET_Create_VM
  783.  
  784.     push    ebx
  785.  
  786.     VMMCall Get_SYS_VM_Handle
  787.  
  788.     mov    esi,ebx
  789.     pop    edi
  790.     cmp    esi,edi
  791.     je    short DCVMDone        ; Skip SYS VM
  792.     add    esi,[DN_CB_Offset]
  793.     add    edi,[DN_CB_Offset]
  794.     mov    ecx,25
  795. DCVMSetupLp:
  796.     test    [esi.DN_VM_LocalNetUseFlgs][ecx],DN_LocUse_F_InUse
  797.     jz    short DCVMSetupSkip    ; Not a net drive
  798. IFDEF DEBUG
  799.     test    [esi.DN_VM_LocalNetUseFlgs][ecx],DN_LocUse_F_Inherit
  800.     jz    short DCVMD30
  801.     debug_out "DN_LocUse_F_Inherit set in SYS VM drive #CL DOSNET_Create_VM"
  802. DCVMD30:
  803.     mov    al,[esi.DN_VM_LocalNetUseFlgs][ecx]
  804.     and    al,DN_LocUse_F_Inherit + DN_LocUse_F_Global
  805.     cmp    al,DN_LocUse_F_Inherit + DN_LocUse_F_Global
  806.     jne    short DCVMD40
  807.     debug_out "DN_LocUse_F_Inherit + Global set in SYS VM drive #CL DOSNET_Create_VM"
  808. DCVMD40:
  809. ENDIF
  810.     test    [esi.DN_VM_LocalNetUseFlgs][ecx],DN_LocUse_F_Global
  811.     jnz    short DCVMSetGlobal
  812.     mov    [edi.DN_VM_LocalNetUseFlgs][ecx],DN_LocUse_F_InUse + DN_LocUse_F_Inherit
  813.     inc    [esi.DN_VM_LocalNetInhRefCnt][ecx]
  814. DCVMSetupSkip:
  815.     jecxz    DCVMDone
  816.     dec    ecx
  817.     jmp    short DCVMSetupLp
  818.  
  819. DCVMDone:
  820.     clc
  821.     ret
  822.  
  823. DCVMSetGlobal:
  824.     mov    [edi.DN_VM_LocalNetUseFlgs][ecx],DN_LocUse_F_InUse + DN_LocUse_F_Global
  825.     jmp    short DCVMSetupSkip
  826.  
  827. EndProc DOSNET_Create_VM
  828.  
  829.  
  830. ;******************************************************************************
  831. ;
  832. ;   DOSNET_Int_21
  833. ;
  834. ;   DESCRIPTION:
  835. ;    This procedure handles the processing of NET USE and NET USE /d
  836. ;
  837. ;   ENTRY:
  838. ;    EBX = VM Handle making INT 21h call
  839. ;
  840. ;   EXIT:
  841. ;    None
  842. ;
  843. ;   USES:
  844. ;    All but segs, EBP
  845. ;
  846. ;==============================================================================
  847.  
  848. ;
  849. ; This structure is allocated and associated with a specific NET USE
  850. ;   call. It indicates what the call is doing.
  851. ;
  852. DN_I21_TailStruc STRUC
  853.  
  854. NDrive        dd    ?    ; 0 = A drive number
  855. DriveAddr    dd    ?    ; V86 address of NET USE string
  856. OrigDrive    db    ?    ; Original byte at DriveAddr
  857. RETFlag     db    0    ;  3 is NETUSE ret
  858.                 ;  4 is NETUNUSE ret
  859. DN_I21_TailStruc ENDS
  860.  
  861.  
  862. BeginProc DOSNET_Int_21, High_Freq
  863.  
  864.     cmp    [ebp.Client_AH],5Fh    ; NET USE call?
  865.     jne    DN_I21_Reflect        ; No, ignore
  866. DN_I21_NETUSE:
  867.     cmp    [ebp.Client_AL],04h    ; Cancel Redirection?
  868.     je    DEBFAR NetUseBreak    ; Yes
  869.     cmp    [ebp.Client_AL],03h    ; Make Redirection?
  870.     jne    DN_I21_Reflect        ; No, ignore
  871. NetUseMake:
  872.     cmp    [ebp.Client_BL],04h    ; File device make?
  873.     jne    DN_I21_Reflect        ; No, ignore
  874.     movzx    esi,[ebp.Client_DS]    ; Get pointer to drive
  875.     shl    esi,4
  876.     movzx    eax,[ebp.Client_SI]
  877.     add    esi,eax
  878.     add    esi,[ebx.CB_High_Linear]
  879.     cmp    byte ptr [esi],0    ; UNC use?
  880.     je    DN_I21_Reflect        ; Yes, Ignore UNC
  881.     cmp    word ptr [esi+1],":"    ; Valid Drive use?
  882.     jne    DN_I21_Reflect        ; No, Ignore random drivel
  883.     movzx    eax,byte ptr [esi]    ; Get drive letter
  884.     or    al,20h            ; Make lower case
  885.     sub    al,'a'            ; Convert to number
  886.     jc    DN_I21_Reflect        ; Ignore, invalid drive
  887.     cmp    al,26
  888.     jae    DN_I21_Reflect        ; Ignore, invalid drive
  889.     push    eax            ; Save drive #
  890.     call    DOSNET_AllocInfoStruc    ; Allocate DN_I21_TailStruc for call
  891.     pop    eax            ; drive #
  892. IFDEF DEBUG
  893.     jnc    short NUD10
  894.     debug_out "DOSNET_AllocInfoStruc failed on 5F03h call, can't track drive #AL"
  895. NUD10:
  896. ENDIF
  897.     jc    DN_I21_Reflect
  898.     mov    [edx.NDrive],eax
  899.     mov    [edx.RETFlag],3     ; NET USE make type
  900.     jmp    DN_I21_SetCB
  901.  
  902. NetUseBreak:
  903.     cmp    [NetUseCleanUpFlg],0    ; From DOSNET device?
  904.     jne    DN_I21_Reflect        ; Yes, let it through
  905.     movzx    esi,[ebp.Client_DS]
  906.     shl    esi,4
  907.     movzx    eax,[ebp.Client_SI]
  908.     add    esi,eax
  909.     add    esi,[ebx.CB_High_Linear]
  910.     cmp    word ptr [esi],"//"    ; UNC?
  911.     je    DN_I21_Reflect        ; Yes, Ignore UNC
  912.     cmp    word ptr [esi],"\\"    ; UNC?
  913.     je    DN_I21_Reflect        ; Yes, Ignore UNC
  914.     cmp    word ptr [esi],"\/"    ; UNC?
  915.     je    DN_I21_Reflect        ; Yes, Ignore UNC
  916.     cmp    word ptr [esi],"/\"     ; UNC?
  917.     je    DN_I21_Reflect        ; Yes, Ignore UNC
  918.     cmp    word ptr [esi+1],":"    ; Drive type?
  919.     jne    DN_I21_Reflect        ; No, Ignore char dev type
  920.     movzx    eax,byte ptr [esi]    ; Get drive letter
  921.     or    al,20h            ; To lower case
  922.     sub    al,'a'            ; To number
  923.     jc    DN_I21_Reflect        ; Ignore, invalid drive
  924.     cmp    al,26
  925.     jae    DN_I21_Reflect        ; Ignore, invalid drive
  926.     mov    ecx,ebx
  927.     add    ecx,[DN_CB_Offset]
  928.     test    [ecx.DN_VM_LocalNetUseFlgs][eax],DN_LocUse_F_InUse
  929.     jz    DN_I21_Reflect        ; Ignore, uninteresting drives
  930.     test    [ecx.DN_VM_LocalNetUseFlgs][eax],DN_LocUse_F_Global
  931.     jnz    short DN_I21_FailBreakGlobal
  932.     test    [ecx.DN_VM_LocalNetUseFlgs][eax],DN_LocUse_F_Inherit
  933.     jnz    short DN_I21_FailBreakInherit
  934.     cmp    [ecx.DN_VM_LocalNetInhRefCnt][eax],0
  935.     jnz    short DN_I21_FailBreakParent
  936.     push    eax            ; Save drive
  937.     push    ecx            ; and CB pointer
  938.     call    DOSNET_AllocInfoStruc    ; Allocate DN_I21_TailStruc for call
  939.     pop    ecx
  940.     pop    eax
  941.     jc    short BrkBlast
  942.     mov    [edx.NDrive],eax
  943.     mov    [edx.RETFlag],4     ; Net use /D type
  944.     jmp    DN_I21_SetCB
  945.  
  946. BrkBlast:
  947.     debug_out "DOSNET_AllocInfoStruc failed on 5F04h call, freeing drive #AL"
  948.     mov    [ecx.DN_VM_LocalNetUseFlgs][eax],0
  949.     jmp    DN_I21_Reflect
  950.  
  951.  
  952. ;
  953. ; Can't NET USE /D GLOBAL drives
  954. ;
  955. DN_I21_FailBreakGlobal:
  956.     mov    ecx,offset32 DNNetUseGlobalMsg
  957.     mov    edi,offset32 DNNetUseGlobalMsgDrive
  958.     jmp    short DN_I21_FailBreak
  959.  
  960. ;
  961. ; Can't NET USE /D drives inherited from SYS VM
  962. ;
  963. DN_I21_FailBreakInherit:
  964.     mov    ecx,offset32 DNNetUseInherMsg
  965.     mov    edi,offset32 DNNetUseInherMsgDrive
  966.     jmp    short DN_I21_FailBreak
  967.  
  968. ;
  969. ; Can't NET USE /D drives passed to other VMs
  970. ;
  971. DN_I21_FailBreakParent:
  972.     mov    ecx,offset32 DNNetUseParentMsg
  973.     mov    edi,offset32 DNNetUseParentMsgDrive
  974. DN_I21_FailBreak:
  975.     mov    al,byte ptr [esi]    ; Drive letter
  976.     and    al,NOT 20h        ; To upper case
  977.     mov    byte ptr [edi],al    ; Set drive letter in message
  978.     push    esi
  979.     xor    edi,edi         ; Standard caption
  980.     xor    esi,esi         ; No call back
  981.     mov    eax,MB_OK + MB_ICONEXCLAMATION + MB_SYSTEMMODAL
  982.  
  983.     VMMCall Test_SYS_VM_Handle
  984.  
  985.     jz    short DN_I21_Modal
  986.  
  987.     VxdCall SHELL_Message
  988.  
  989.     jmp    short DN_I21_MsgDone
  990.  
  991. DN_I21_Modal:
  992.  
  993.     VxdCall SHELL_SYSMODAL_Message
  994.  
  995. DN_I21_MsgDone:
  996.     call    DOSNET_AllocInfoStruc
  997.     pop    esi
  998.     jc    short FailBrkAsIs
  999.     mov    al,byte ptr [esi]    ; Get drive letter
  1000.     mov    byte ptr [esi],'['    ; Change to invalid drive to simulate
  1001.                     ;   correct DOS error
  1002.     mov    [edx.NDrive],0FFFFFFFFh ; Flag that we are failing this
  1003.     mov    [edx.DriveAddr],esi    ; Save user address
  1004.     mov    [edx.OrigDrive],al    ; And original byte
  1005.     mov    [edx.RETFlag],4     ; NET USE /D type
  1006.     jmp    short DN_I21_SetCB
  1007.  
  1008.  
  1009. FailBrkAsIs:
  1010.     mov    [ebp.Client_AX],15    ; Error Invalid Drive
  1011.     or    [ebp.Client_EFLAGS],CF_Mask
  1012.     clc
  1013.     ret
  1014.  
  1015. ;
  1016. ; Set the call back to catch when the INT 21H is complete
  1017. ;
  1018. DN_I21_SetCB:
  1019.     mov    eax,10000        ; 10 second time out
  1020.     mov    esi,offset32 DN_I21_CallBack
  1021.  
  1022.     VMMCall Call_When_VM_Returns
  1023.  
  1024. DN_I21_Reflect:
  1025.     stc
  1026.     ret
  1027.  
  1028. DN_I21_FreeReflect:
  1029.  
  1030.     VMMCall _HeapFree,<edx,0>
  1031.  
  1032.     jmp    short DN_I21_Reflect
  1033.  
  1034.  
  1035. EndProc DOSNET_Int_21
  1036.  
  1037. ;**
  1038. ;
  1039. ; DOSNET_AllocInfoStruc - Allocate DN_I21_TailStruc
  1040. ;
  1041. ; ENTRY:
  1042. ;    None
  1043. ;
  1044. ; EXIT:
  1045. ;    Carry Set
  1046. ;        Failed
  1047. ;    Carry Clear
  1048. ;        EDX -> DN_I21_TailStruc
  1049. ;
  1050. ; USES:
  1051. ;    EAX,ECX,EDX,FLAGS
  1052. ;
  1053. BeginProc DOSNET_AllocInfoStruc
  1054.  
  1055.     VMMCall _HeapAllocate,<<(SIZE DN_I21_TailStruc)>,HeapZeroInit>
  1056.  
  1057.     or    eax,eax
  1058. IFDEF DEBUG
  1059.     jnz    short DN_I21D30
  1060.     trace_out "HeapAllocate Failed DOSNET_Int_21"
  1061. DN_I21D30:
  1062. ENDIF
  1063.     stc
  1064.     jz    short DN_AIFDone
  1065.     mov    edx,eax
  1066.     clc
  1067. DN_AIFDone:
  1068.     ret
  1069.  
  1070. EndProc DOSNET_AllocInfoStruc
  1071.  
  1072.  
  1073. ;**
  1074. ;
  1075. ; DN_I21_CallBack - Perform back end processing of INT 21 call
  1076. ;
  1077. ; ENTRY:
  1078. ;    EBX = VM Handle
  1079. ;    EDX -> DN_I21_TailStruc for call
  1080. ;
  1081. ; EXIT:
  1082. ;    None
  1083. ;
  1084. ; USES:
  1085. ;    EAX,ECX,EDX,FLAGS
  1086. ;
  1087. BeginProc DN_I21_CallBack
  1088.  
  1089. IFDEF DEBUG
  1090.     jnc    short DN_I21D10
  1091.     trace_out "Int 21 timed out DN_I21_CallBack"
  1092. DN_I21D10:
  1093. ENDIF
  1094.     jc    short DN_I21_CallBackFree
  1095.     cmp    [edx.RETFlag],4         ; NET USE /D?
  1096.     je    short SetNetUnUseRet        ; Yes
  1097.     test    [ebp.Client_EFLAGS], CF_Mask    ; Call worked?
  1098.     jnz    short DN_I21_CallBackFree    ; No, done
  1099.     cmp    [edx.RETFlag],3         ; NET USE?
  1100.     je    short SetNetUseRet        ; Yes
  1101.     debug_out "DN_I21_CallBack odd RETFlag value"
  1102. DN_I21_CallWorked:
  1103. DN_I21_CallBackFree:
  1104.  
  1105.     VMMCall _HeapFree,<edx,0>
  1106.  
  1107.     ret
  1108.  
  1109. SetNetUnUseRet:
  1110.     mov    eax,[edx.NDrive]
  1111.     inc    eax                ; Special "Set a Failure" case?
  1112.     jz    short NetUnUseRetMyFail     ; Yes, go fix back up
  1113.     dec    eax
  1114.     test    [ebp.Client_EFLAGS], CF_Mask    ; Worked?
  1115.     jnz    short DN_I21_CallBackFree    ; No, done
  1116.     ;
  1117.     ; NET USE /D Worked
  1118.     ;    Clear the flags, no longer a net drive
  1119.     ;
  1120.     mov    ecx,ebx
  1121.     add    ecx,[DN_CB_Offset]
  1122.     mov    [ecx.DN_VM_LocalNetUseFlgs][eax],0
  1123.     jmp    short DN_I21_CallBackFree
  1124.  
  1125. NetUnUseRetMyFail:
  1126.     mov    esi,[edx.DriveAddr]
  1127.     mov    al,[edx.OrigDrive]
  1128.     mov    byte ptr [esi],al        ; Restore proper user drive
  1129.     jmp    short DN_I21_CallBackFree
  1130.  
  1131. SetNetUseRet:
  1132.     mov    eax,[edx.NDrive]
  1133.     mov    ecx,ebx
  1134.     add    ecx,[DN_CB_Offset]
  1135. IFDEF DEBUG
  1136.     cmp    [ecx.DN_VM_LocalNetUseFlgs][eax],0
  1137.     je    short NUD20
  1138.     debug_out "5F03 call worked, but DN_VM_LocalNetUseFlgs != 0"
  1139. NUD20:
  1140. ENDIF
  1141.     mov    [ecx.DN_VM_LocalNetUseFlgs][eax],DN_LocUse_F_InUse
  1142.     mov    [ecx.DN_VM_LocalNetInhRefCnt][eax],0
  1143.     jmp    DN_I21_CallBackFree
  1144.  
  1145. EndProc DN_I21_CallBack
  1146.  
  1147. ;****************************************************************************
  1148. ;
  1149. ; Querry Debug code
  1150. ;
  1151.  
  1152. IFDEF DEBUG
  1153.  
  1154. BeginProc DOSNET_Dump_Debug_Info
  1155.  
  1156.     pushad
  1157.     mov    al,[NetUseCleanUpFlg]
  1158.     trace_out "NetUseCleanUpFlg = #AL"
  1159.     mov    edi,[DN_CB_Offset]
  1160.     VMMcall Get_Cur_VM_Handle
  1161. Dump_Next_VM:
  1162.     call    DOSNET_Dump_VM
  1163.     VMMcall Get_Next_VM_Handle
  1164.     VMMcall Test_Cur_VM_Handle
  1165.     je    SHORT DOSNET_DDI_Exit
  1166.     Trace_Out "[ESC] to exit, any other key for next VM: ", NO_EOL
  1167.     VMMcall In_Debug_Chr
  1168.     Trace_Out " "
  1169.     jnz    Dump_Next_VM
  1170.  
  1171. DOSNET_DDI_Exit:
  1172.     popad
  1173.     clc
  1174.     ret
  1175.  
  1176. EndProc DOSNET_Dump_Debug_Info
  1177.  
  1178. _DATA SEGMENT
  1179.  
  1180. Drive_Strng    db    "    Drive "
  1181. ThisDrv     db    "A:, Inher Ref count #DL, FLAGS - ",0
  1182.  
  1183. _DATA ENDS
  1184.  
  1185. BeginProc DOSNET_Dump_VM
  1186.  
  1187.     trace_out "VM #EBX"
  1188.     push    ebx
  1189.     add    ebx,edi
  1190.     xor    eax,eax
  1191.     mov    [ThisDrv],'A'
  1192.     mov    ecx,26
  1193. ShowDrvs:
  1194.     mov    dl,[ebx.DN_VM_LocalNetInhRefCnt][eax]
  1195.     pushfd
  1196.     pushad
  1197.     mov    esi, OFFSET32 Drive_Strng
  1198.     VMMcall Out_Debug_String
  1199.     popad
  1200.     popfd
  1201.     test    [ebx.DN_VM_LocalNetUseFlgs][eax],DN_LocUse_F_InUse
  1202.     jz    short ChkInh
  1203.     trace_out "INUSE ",NO_EOL
  1204. ChkInh:
  1205.     test    [ebx.DN_VM_LocalNetUseFlgs][eax],DN_LocUse_F_Inherit
  1206.     jz    short ChkGlb
  1207.     trace_out "INHERIT ",NO_EOL
  1208. ChkGlb:
  1209.     test    [ebx.DN_VM_LocalNetUseFlgs][eax],DN_LocUse_F_Global
  1210.     jz    short FlgsDn
  1211.     trace_out "GLOBAL ",NO_EOL
  1212. FlgsDn:
  1213.     trace_out " "
  1214.     inc    [ThisDrv]
  1215.     inc    eax
  1216.     loop    ShowDrvs
  1217.     pop    ebx
  1218.     ret
  1219.  
  1220. EndProc DOSNET_Dump_VM
  1221.  
  1222. ENDIF
  1223. ;
  1224. ;****************************************************************************
  1225.  
  1226. VxD_CODE_ENDS
  1227.  
  1228. ;******************************************************************************
  1229. ;******************************************************************************
  1230. ;
  1231. ; Real mode initialization code
  1232. ;
  1233. ; DOSNET does not install if not in REDIR configuration.
  1234. ;
  1235. ;******************************************************************************
  1236.  
  1237. VxD_REAL_INIT_SEG
  1238.  
  1239. ;
  1240. ; Don't load if DOS is not in the REDIRector configuration
  1241. ;
  1242. BeginProc DOSNET_init
  1243.  
  1244.     mov    ax,3000h        ; Get version
  1245.     int    21h
  1246.     xchg    ah,al
  1247.     cmp    ax,030Ah        ; At least 3.10?
  1248.     jb    short DOSNET_DontLoad    ; No, no network stuff
  1249.     ;
  1250.     ; If the Get Redirection list entry DOS call returns an invalid
  1251.     ;    function error, the DOS REDIR is not loaded.
  1252.     ;
  1253.     mov    ax,5F02H        ; Get Redirection list entry
  1254.     xor    bx,bx            ; Index 0, Also Clears carry
  1255.     push    cs
  1256.     pop    ds
  1257.     push    cs
  1258.     pop    es
  1259.     mov    si,offset RMbuffer    ; Point at a buffer (don't really care
  1260.     mov    di,offset RMbuffer    ;   about its contents)
  1261.     int    21h
  1262.     jnc    short DOSNET_Load    ; Call worked, REDIR is loaded
  1263.     ;
  1264.     ; We got an error. Invalid function is the interesting one. Any other error
  1265.     ;    (probably "no more files" (no redirections)) indicates the REDIR is
  1266.     ;    around.
  1267.     ;
  1268.     cmp    ax,1            ; Invalid function?
  1269.     je    short DOSNET_DontLoad    ; Yes, network not started
  1270. DOSNET_Load:
  1271.     mov    ax, Device_Load_Ok
  1272. DOSNET_LdDone:
  1273.     xor    bx, bx
  1274.     xor    edx, edx
  1275.     xor    si, si
  1276.     ret
  1277.  
  1278. DOSNET_DontLoad:
  1279.     mov    ax, Abort_Device_Load + No_Fail_Message
  1280.     jmp    short DOSNET_LdDone
  1281.  
  1282. RMbuffer db    128 dup (0)
  1283.  
  1284. EndProc DOSNET_init
  1285.  
  1286. VxD_REAL_INIT_ENDS
  1287.  
  1288.     END    DOSNET_Init
  1289.