in host/common/win32/portablehelpersmajor.cpp [4962:5036]
void mountBootableVolumesIfRequried()
{
static bool isVolFilter = false;
static bool isDiskFilter = false;
LocalConfigurator localConfigurator;
if (!isDiskFilter && !isVolFilter && localConfigurator.IsFilterDriverAvailable())
{
DeviceStream::Ptr pDeviceStream(new DeviceStream(INMAGE_DISK_FILTER_DOS_DEVICE_NAME));
if (SV_SUCCESS == pDeviceStream->Open(DeviceStream::Mode_Open | DeviceStream::Mode_Read | DeviceStream::Mode_ShareRW))
{
isDiskFilter = true;
}
else
{
pDeviceStream.reset(new DeviceStream(INMAGE_FILTER_DEVICE_NAME));
if (SV_SUCCESS == pDeviceStream->Open(DeviceStream::Mode_Open | DeviceStream::Mode_Read | DeviceStream::Mode_ShareRW))
{
isVolFilter = true;
}
}
}
/* GetVolumePathNamesForVolumeName is not supported in win2k */
#ifndef SCOUT_WIN2K_SUPPORT
char volGuid[256] = { 0 }; // buffer to hold GUID of a volume.
HANDLE pHandle = NULL;
pHandle = FindFirstVolume(volGuid, sizeof(volGuid) - 1);
if (pHandle != INVALID_HANDLE_VALUE)
{
do
{
LPTSTR VolumePathName = NULL;
DWORD rlen = 0;
GetVolumePathNamesForVolumeName(volGuid, VolumePathName, 0, &rlen);
if (GetLastError() == ERROR_MORE_DATA)
{
size_t pathnamelen;
INM_SAFE_ARITHMETIC(pathnamelen = InmSafeInt<DWORD>::Type(rlen) * 2, INMAGE_EX(rlen))
VolumePathName = (LPTSTR)malloc(pathnamelen);
memset(VolumePathName, 0, rlen * 2);
if (VolumePathName != NULL && GetVolumePathNamesForVolumeName(volGuid, VolumePathName, rlen * 2, &rlen))
{
if (VolumePathName[0] == '\0')
{
// This volume does not have drive letter.
//check whether it is SRV or not.
if (isVolFilter && isBootableVolume(volGuid))
{
mountVolume(volGuid);
}
}
else
{
if (isDiskFilter && (0 == strcmp(VolumePathName, INM_BOOT_VOLUME_MOUNTPOINT)) && isBootableVolume(volGuid))
{
boost::filesystem::exists(std::string(INM_BOOT_VOLUME_MOUNTPOINT)) &&
DeleteVolumeMountPoint(INM_BOOT_VOLUME_MOUNTPOINT) &&
boost::filesystem::remove(std::string(INM_BOOT_VOLUME_MOUNTPOINT));
}
}
}
if (VolumePathName != NULL)
{
free(VolumePathName);
VolumePathName = NULL;
}
}
} while (FindNextVolume(pHandle, volGuid, sizeof(volGuid) - 1));
FindVolumeClose(pHandle);
}
else
{
DebugPrintf(SV_LOG_ERROR, "FindFirstVolume() Failed. \n");
}
#endif
}