VirtualBox

Changeset 83718 in vbox for trunk/src/VBox/Additions/common


Ignore:
Timestamp:
Apr 16, 2020 3:20:01 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
137229
Message:

VBoxServiceAutoMount: Try address incomplete handling of GetVolumeInformationW failures in vbsvcAutomounterQueryMountPoint.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp

    r83708 r83718  
    11931193            if (rc != ERROR_PATH_NOT_FOUND || g_cVerbosity >= 4)
    11941194                VGSvcVerbose(3, "vbsvcAutomounterQueryMountPoint: GetVolumeInformationW('%ls',,,,) failed: %u\n", pwszMountPoint, rc);
    1195             rc = VWRN_NOT_FOUND;
     1195            if (rc == ERROR_PATH_NOT_FOUND)
     1196                rc = VWRN_NOT_FOUND;
     1197            else if (   RT_C_IS_ALPHA(pszMountPoint[0])
     1198                     && pszMountPoint[1] == ':'
     1199                     && (   pszMountPoint[2] == '\0'
     1200                         || (RTPATH_IS_SLASH(pszMountPoint[2]) && pszMountPoint[3] == '\0')))
     1201            {
     1202                /* See whether QueryDosDeviceW thinks its a malfunctioning shared folder or
     1203                   something else (it doesn't access the file system).  We've seen
     1204                   VERR_NET_HOST_NOT_FOUND here for shared folders that was removed on the
     1205                   host side.
     1206
     1207                   Note! This duplicates code from vbsvcAutomounterPopulateTable. */
     1208                rc = VERR_ACCESS_DENIED;
     1209                static const char s_szDevicePath[] = "\\Device\\VBoxMiniRdr\\;";
     1210                wszFileSystem[0] = pwszMountPoint[0];
     1211                wszFileSystem[1] = pwszMountPoint[1];
     1212                wszFileSystem[2] = '\0';
     1213                DWORD const cwcResult = QueryDosDeviceW(wszFileSystem, wszLabel, RT_ELEMENTS(wszLabel));
     1214                if (   cwcResult > sizeof(s_szDevicePath)
     1215                    && RTUtf16NICmpAscii(wszLabel, RT_STR_TUPLE(s_szDevicePath)) == 0)
     1216                {
     1217                    PCRTUTF16 pwsz = &wszLabel[RT_ELEMENTS(s_szDevicePath) - 1];
     1218                    Assert(pwsz[-1] == ';');
     1219                    if (   (pwsz[0] & ~(RTUTF16)0x20) == (wszFileSystem[0] & ~(RTUTF16)0x20)
     1220                        && pwsz[1] == ':'
     1221                        && pwsz[2] == '\\')
     1222                    {
     1223                        if (RTUtf16NICmpAscii(&pwsz[3], RT_STR_TUPLE("VBoxSvr\\")) == 0)
     1224                        {
     1225                            pwsz += 3 + 8;
     1226                            char *pszMountedName = NULL;
     1227                            rc = RTUtf16ToUtf8(pwsz, &pszMountedName);
     1228                            if (RT_SUCCESS(rc))
     1229                            {
     1230                                if (RTStrICmp(pszMountedName, pszName) == 0)
     1231                                {
     1232                                    rc = VINF_SUCCESS;
     1233                                    VGSvcVerbose(2, "vbsvcAutomounterQueryMountPoint: Found shared folder '%s' at '%s' (using QueryDosDeviceW).\n",
     1234                                                 pszName, pszMountPoint);
     1235                                }
     1236                                else
     1237                                {
     1238                                    VGSvcVerbose(2, "vbsvcAutomounterQueryMountPoint: Found shared folder '%s' at '%s' (using QueryDosDeviceW), not '%s'...\n",
     1239                                                 pszMountedName, pszMountPoint, pszName);
     1240                                    rc = VERR_RESOURCE_BUSY;
     1241                                }
     1242                                RTStrFree(pszMountedName);
     1243                            }
     1244                            else
     1245                            {
     1246                                VGSvcVerbose(2, "vbsvcAutomounterQueryMountPoint: RTUtf16ToUtf8 failed: %Rrc\n", rc);
     1247                                AssertRC(rc);
     1248                                rc = VERR_RESOURCE_BUSY;
     1249                            }
     1250                        }
     1251                    }
     1252                }
     1253            }
     1254            else
     1255                rc = VERR_ACCESS_DENIED;
    11961256        }
    11971257        RTUtf16Free(pwszMountPoint);
Note: See TracChangeset for help on using the changeset viewer.

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