[core] prevent the enumeration of Windows 10 19H1 sandbox VHDs

* The new 19H1 Windows Sandbox feature relies on VHDs labelled 'PortableBaseLayer' → Don't list those
This commit is contained in:
Pete Batard 2019-07-15 12:35:22 +01:00
parent 5b1ae09df4
commit f95aa94c57
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
5 changed files with 27 additions and 8 deletions

View file

@ -954,14 +954,23 @@ BOOL GetDriveLabel(DWORD DriveIndex, char* letters, char** label)
{
HANDLE hPhysical;
DWORD size, error;
static char VolumeLabel[MAX_PATH + 1];
static char VolumeLabel[MAX_PATH + 1] = { 0 };
char DrivePath[] = "#:\\", AutorunPath[] = "#:\\autorun.inf", *AutorunLabel = NULL;
WCHAR VolumeName[MAX_PATH + 1] = { 0 }, FileSystemName[64];
DWORD VolumeSerialNumber, MaximumComponentLength, FileSystemFlags;
*label = STR_NO_LABEL;
if (!GetDriveLetters(DriveIndex, letters))
return FALSE;
if (letters[0] == 0) {
// Even if we don't have a letter, try to obtain the label of the first partition
HANDLE h = GetLogicalHandle(DriveIndex, 0, FALSE, FALSE, FALSE);
if (GetVolumeInformationByHandleW(h, VolumeName, 64, &VolumeSerialNumber,
&MaximumComponentLength, &FileSystemFlags, FileSystemName, 64)) {
wchar_to_utf8_no_alloc(VolumeName, VolumeLabel, sizeof(VolumeLabel));
*label = VolumeLabel;
}
// Drive without volume assigned - always enabled
return TRUE;
}