VirtualBox

Ignore:
Timestamp:
Apr 26, 2019 1:19:49 AM (6 years ago)
Author:
vboxsync
Message:

winnt/vboxsf: Use g_SfClient everywhere to avoid having dangling pointers (MRX_VBOX_NETROOT_EXTENSION::phgcmClient) and copies (MRX_VBOX_DEVICE_EXTENSION::hgcmClient). This also reduces the stack space usage. ASSUMES that the module can only be instantiated once (already an assumption of the g_SfClient variable and related code in VBoxGuestLibSharedFoldersInline.h). Renamed all sources to .cpp (except the w2k hacks). bugref:9172

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/net.cpp

    r78303 r78304  
    7979    PMRX_V_NET_ROOT pVNetRoot = (PMRX_V_NET_ROOT)pCreateNetRootContext->pVNetRoot;
    8080
    81     PMRX_VBOX_DEVICE_EXTENSION pDeviceExtension = VBoxMRxGetDeviceExtension(pCreateNetRootContext->RxContext);
    8281    PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension = VBoxMRxGetNetRootExtension(pVNetRoot->pNetRoot);
    8382
     
    158157     * pNetRootExtension is actually the pNetRoot->Context and it is not NULL.
    159158     */
    160     fInitializeNetRoot = (pNetRootExtension->phgcmClient == NULL);
    161 
    162159    Status = STATUS_SUCCESS;
    163160
    164     if (fInitializeNetRoot)
     161    if (!pNetRootExtension->fInitialized)
    165162    {
    166163        PWCHAR pRootName;
     
    172169
    173170        pNetRoot->MRxNetRootState = MRX_NET_ROOT_STATE_GOOD;
     171        pNetRootExtension->map.root = SHFL_ROOT_NIL;
    174172
    175173        RootNameLength = pNetRoot->pNetRootName->Length - pSrvCall->pSrvCallName->Length;
     
    193191            RootNameLength -= sizeof(WCHAR);
    194192
    195         if (!pNetRootExtension->phgcmClient)
     193        if (!pNetRootExtension->fInitialized)
    196194        {
    197195            Log(("VBOXSF: MRxCreateVNetRoot: Initialize netroot length = %d, name = %.*ls\n",
     
    204202            }
    205203
    206             vrc = VbglR0SfMapFolder(&pDeviceExtension->hgcmClient, ParsedPath, &pNetRootExtension->map);
     204            vrc = VbglR0SfMapFolder(&g_SfClient, ParsedPath, &pNetRootExtension->map);
    207205            vbsfFreeNonPagedMem(ParsedPath);
    208             if (vrc != VINF_SUCCESS)
     206            if (RT_SUCCESS(vrc))
    209207            {
    210                 Log(("VBOXSF: MRxCreateVNetRoot: VbglR0SfMapFolder failed with %d\n", vrc));
    211                 Status = STATUS_BAD_NETWORK_NAME;
     208                pNetRootExtension->fInitialized = true;
     209                Status = STATUS_SUCCESS;
    212210            }
    213211            else
    214212            {
    215                 Status = STATUS_SUCCESS;
    216                 pNetRootExtension->phgcmClient = &pDeviceExtension->hgcmClient;
     213                Log(("VBOXSF: MRxCreateVNetRoot: VbglR0SfMapFolder failed with %d\n", vrc));
     214                pNetRootExtension->map.root = SHFL_ROOT_NIL;
     215                Status = STATUS_BAD_NETWORK_NAME;
    217216            }
    218217        }
     
    259258    Log(("VBOXSF: MRxFinalizeNetRoot: NET_ROOT %p\n", pNetRoot));
    260259
    261     if (pNetRootExtension->phgcmClient)
    262     {
    263         int vrc = VbglR0SfUnmapFolder(pNetRootExtension->phgcmClient, &pNetRootExtension->map);
     260    if (   pNetRootExtension->fInitialized
     261        && g_SfClient.handle != NULL)
     262    {
     263        int vrc = VbglR0SfUnmapFolder(&g_SfClient, &pNetRootExtension->map);
    264264        if (vrc != VINF_SUCCESS)
    265265            Log(("VBOXSF: MRxFinalizeVNetRoot: VbglR0SfUnmapFolder failed with %d\n",
    266266                 vrc));
    267         pNetRootExtension->phgcmClient = NULL;
     267        pNetRootExtension->map.root = SHFL_ROOT_NIL;
     268        pNetRootExtension->fInitialized = false;
    268269    }
    269270
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette