From e899fc0e61d8b66ccd54f59b79e0d84e67139457 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Tue, 10 Dec 2013 19:30:12 +0000 Subject: [PATCH] [core] fix a conflict with Windows automount drive letter assignation * Closes #239 --- src/drive.c | 12 ++++++++++++ src/rufus.rc | 10 +++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/drive.c b/src/drive.c index 2e259a80..030838f8 100644 --- a/src/drive.c +++ b/src/drive.c @@ -598,6 +598,18 @@ BOOL UnmountVolume(HANDLE hDrive) BOOL MountVolume(char* drive_name, char *drive_guid) { char mounted_guid[52]; // You need at least 51 characters on XP + char mounted_letter[16] = {0}; + DWORD size; + + // For fixed disks, Windows may already have remounted the volume, but with a different letter + // than the one we want. If that's the case, we need to unmount first. + if ( (GetVolumePathNamesForVolumeNameA(drive_guid, mounted_letter, sizeof(mounted_letter), &size)) + && (size > 2) && (safe_strcmp(mounted_letter, drive_name) != 0) ) { + uprintf("Volume is already mounted, but as %s instead of %s - Unmounting...\n", mounted_letter, drive_name); + if (!DeleteVolumeMountPointA(mounted_letter)) + uprintf("Failed to unmount volume: %s", WindowsErrorString()); + Sleep(200); + } if (!SetVolumeMountPointA(drive_name, drive_guid)) { // If the OS was faster than us at remounting the drive, this operation can fail diff --git a/src/rufus.rc b/src/rufus.rc index dd8b4728..a11d0cf7 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 206, 329 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW -CAPTION "Rufus v1.4.1.350" +CAPTION "Rufus v1.4.1.351" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,94,291,50,14 @@ -288,8 +288,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,4,1,350 - PRODUCTVERSION 1,4,1,350 + FILEVERSION 1,4,1,351 + PRODUCTVERSION 1,4,1,351 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -306,13 +306,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "1.4.1.350" + VALUE "FileVersion", "1.4.1.351" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2013 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "1.4.1.350" + VALUE "ProductVersion", "1.4.1.351" END END BLOCK "VarFileInfo"