From f95aa94c57a6aec7816523151f8bc9b078d101fc Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Mon, 15 Jul 2019 12:35:22 +0100 Subject: [PATCH] [core] prevent the enumeration of Windows 10 19H1 sandbox VHDs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * The new 19H1 Windows Sandbox feature relies on VHDs labelled 'PortableBaseLayer' → Don't list those --- ChangeLog.txt | 1 + README.md | 5 +++-- src/dev.c | 8 ++++++++ src/drive.c | 11 ++++++++++- src/rufus.rc | 10 +++++----- 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 7b582237..706f51fa 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,7 @@ o Version 3.6 (2019.07.??) Fix progress bar report for screen readers (Accessibility issue) Fix a regression where Windows format prompts would not be suppressed Improve(?) Windows To Go support by following Microsoft's recommended partition order + Don't enumerate Windows Sandbox VHDs Disable ISO mode when Manjaro ISOHybrids are being used Update embedded GRUB to version 2.04 diff --git a/README.md b/README.md index 3bdd9801..86f87275 100644 --- a/README.md +++ b/README.md @@ -11,17 +11,18 @@ Rufus: The Reliable USB Formatting Utility Features -------- -* Format USB, flash card and virtual drives to FAT/FAT32/NTFS/UDF/exFAT/ReFS +* Format USB, flash card and virtual drives to FAT/FAT32/NTFS/UDF/exFAT/ReFS/ext2/ext3 * Create DOS bootable USB drives, using [FreeDOS](http://www.freedos.org) or MS-DOS (Windows 8.1 or earlier) * Create BIOS or UEFI bootable drives, including [UEFI bootable NTFS](https://github.com/pbatard/uefi-ntfs) * Create bootable drives from bootable ISOs (Windows, Linux, etc.) * Create bootable drives from bootable disk images, including compressed ones * Create [Windows To Go](https://en.wikipedia.org/wiki/Windows_To_Go) drives +* Create persistent Linux partitions * Download official Microsoft Windows 8 or Windows 10 retail ISOs * Compute MD5, SHA-1 and SHA-256 checksums of the selected image * Twice as fast as Microsoft's USB/DVD tool or UNetbootin, on ISO -> USB creation (1) * Perform bad blocks checks, including detection of "fake" flash drives -* Modern and familiar UI, with [39 languages natively supported](https://github.com/pbatard/rufus/wiki/FAQ#What_languages_are_natively_supported_by_Rufus) +* Modern and familiar UI, with [38 languages natively supported](https://github.com/pbatard/rufus/wiki/FAQ#What_languages_are_natively_supported_by_Rufus) * Small footprint. No installation required. * Portable * 100% [Free Software](https://www.gnu.org/philosophy/free-sw) ([GPL v3](https://www.gnu.org/licenses/gpl-3.0)) diff --git a/src/dev.c b/src/dev.c index e3bd7c17..8d2476be 100644 --- a/src/dev.c +++ b/src/dev.c @@ -453,6 +453,7 @@ BOOL GetDevices(DWORD devnum) "_SD_", "_SDHC_", "_MMC_", "_MS_", "_MSPro_", "_xDPicture_", "_O2Media_" }; const char* usb_speed_name[USB_SPEED_MAX] = { "USB", "USB 1.0", "USB 1.1", "USB 2.0", "USB 3.0" }; + const char* windows_sandbox_vhd_label = "PortableBaseLayer"; // Hash table and String Array used to match a Device ID with the parent hub's Device Interface Path htab_table htab_devid = HTAB_EMPTY; StrArray dev_if_path; @@ -883,6 +884,13 @@ BOOL GetDevices(DWORD devnum) safe_free(devint_detail_data); break; } + // Windows 10 19H1 mounts a 'PortableBaseLayer' for its Windows Sandbox feature => unlist those + if (safe_strcmp(label, windows_sandbox_vhd_label) == 0) { + uprintf("Device eliminated because it's a Windows Sandbox VHD"); + safe_closehandle(hDrive); + safe_free(devint_detail_data); + break; + } // The empty string is returned for drives that don't have any volumes assigned if (drive_letters[0] == 0) { diff --git a/src/drive.c b/src/drive.c index 9328a6dc..8766e074 100644 --- a/src/drive.c +++ b/src/drive.c @@ -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; } diff --git a/src/rufus.rc b/src/rufus.rc index 2ec12d3a..1f55cd7c 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 232, 326 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 3.6.1549" +CAPTION "Rufus 3.6.1550" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -394,8 +394,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,6,1549,0 - PRODUCTVERSION 3,6,1549,0 + FILEVERSION 3,6,1550,0 + PRODUCTVERSION 3,6,1550,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -413,13 +413,13 @@ BEGIN VALUE "Comments", "https://akeo.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "3.6.1549" + VALUE "FileVersion", "3.6.1550" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2019 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus-3.6.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "3.6.1549" + VALUE "ProductVersion", "3.6.1550" END END BLOCK "VarFileInfo"