diff --git a/src/drive.c b/src/drive.c index 18c46154..d99a0fa3 100644 --- a/src/drive.c +++ b/src/drive.c @@ -120,6 +120,7 @@ BOOL GetAutoMount(BOOL* enabled) static HANDLE GetHandle(char* Path, BOOL bLockDrive, BOOL bWriteAccess, BOOL bWriteShare) { int i; + BOOL bSearchProcess = FALSE; DWORD size; HANDLE hDrive = INVALID_HANDLE_VALUE; char DevPath[MAX_PATH]; @@ -145,22 +146,24 @@ static HANDLE GetHandle(char* Path, BOOL bLockDrive, BOOL bWriteAccess, BOOL bWr if ((GetLastError() != ERROR_SHARING_VIOLATION) && (GetLastError() != ERROR_ACCESS_DENIED)) break; if (i == 0) { - uprintf("Waiting for access..."); + uprintf("Waiting for access on %s [%s]...", Path, DevPath); } else if (!bWriteShare && (i > DRIVE_ACCESS_RETRIES/3)) { - // If we can't seem to get a hold of the drive for some time, - // try to enable FILE_SHARE_WRITE... + // If we can't seem to get a hold of the drive for some time, try to enable FILE_SHARE_WRITE... uprintf("Warning: Could not obtain exclusive rights. Retrying with write sharing enabled..."); bWriteShare = TRUE; + // Try to report the process that is locking the drive + SearchProcess(DevPath, TRUE, TRUE); + bSearchProcess = TRUE; } Sleep(DRIVE_ACCESS_TIMEOUT / DRIVE_ACCESS_RETRIES); } if (hDrive == INVALID_HANDLE_VALUE) { - uprintf("Could not open %s [%s]: %s\n", Path, DevPath, WindowsErrorString()); + uprintf("Could not open %s: %s\n", Path, WindowsErrorString()); goto out; } if (bWriteAccess) { - uprintf("Opened %s [%s] for write access", Path, DevPath); + uprintf("Opened %s for %s write access", Path, bWriteShare?"shared":"exclusive"); } if (bLockDrive) { @@ -168,6 +171,7 @@ static HANDLE GetHandle(char* Path, BOOL bLockDrive, BOOL bWriteAccess, BOOL bWr uprintf("I/O boundary checks disabled\n"); } + uprintf("Requesting lock..."); for (i = 0; i < DRIVE_ACCESS_RETRIES; i++) { if (DeviceIoControl(hDrive, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, &size, NULL)) goto out; @@ -176,9 +180,9 @@ static HANDLE GetHandle(char* Path, BOOL bLockDrive, BOOL bWriteAccess, BOOL bWr Sleep(DRIVE_ACCESS_TIMEOUT/DRIVE_ACCESS_RETRIES); } // If we reached this section, either we didn't manage to get a lock or the user cancelled - uprintf("Could not get exclusive access to %s: %s", Path, WindowsErrorString()); + uprintf("Could not lock access to %s: %s", Path, WindowsErrorString()); // See if we can tell the user what processes are accessing the drive - if (!IS_ERROR(FormatStatus)) + if (!IS_ERROR(FormatStatus) && !bSearchProcess) SearchProcess(DevPath, TRUE, TRUE); safe_closehandle(hDrive); } @@ -1036,15 +1040,15 @@ BOOL RemountVolume(char* drive_name) if (DeleteVolumeMountPointA(drive_name)) { Sleep(200); if (MountVolume(drive_name, drive_guid)) { - uprintf("Successfully remounted %s on %s\n", &drive_guid[4], drive_name); + uprintf("Successfully remounted %s on %C:", drive_guid, drive_name[0]); } else { - uprintf("Failed to remount %s on %s\n", &drive_guid[4], drive_name); + uprintf("Failed to remount %s on %C:", drive_guid, drive_name[0]); // This will leave the drive inaccessible and must be flagged as an error FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_CANT_REMOUNT_VOLUME); return FALSE; } } else { - uprintf("Could not remount %s %s\n", drive_name, WindowsErrorString()); + uprintf("Could not remount %C: %s", drive_name[0], WindowsErrorString()); // Try to continue regardless } } diff --git a/src/format.c b/src/format.c index 1d01293f..a18072cb 100644 --- a/src/format.c +++ b/src/format.c @@ -1663,13 +1663,13 @@ DWORD WINAPI FormatThread(void* param) extra_partitions = XP_COMPAT; PrintInfoDebug(0, MSG_225); - hPhysicalDrive = GetPhysicalHandle(DriveIndex, lock_drive, TRUE, FALSE); + hPhysicalDrive = GetPhysicalHandle(DriveIndex, lock_drive, TRUE, !lock_drive); if (hPhysicalDrive == INVALID_HANDLE_VALUE) { FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_OPEN_FAILED; goto out; } - // At this stage with have both a handle and a lock to the physical drive... + // At this stage we should have both a handle and a lock to the physical drive... if (!GetDriveLetters(DriveIndex, drive_letters)) { uprintf("Failed to get a drive letter\n"); FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_CANT_ASSIGN_LETTER); @@ -1705,7 +1705,7 @@ DWORD WINAPI FormatThread(void* param) uprintf("Will use '%c:' as volume mountpoint\n", drive_name[0]); // ...but we need a lock to the logical drive to be able to write anything to it - hLogicalVolume = GetLogicalHandle(DriveIndex, TRUE, FALSE, FALSE); + hLogicalVolume = GetLogicalHandle(DriveIndex, TRUE, FALSE, !lock_drive); if (hLogicalVolume == INVALID_HANDLE_VALUE) { uprintf("Could not lock volume\n"); FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_OPEN_FAILED; diff --git a/src/process.c b/src/process.c index 1bdb4552..310b7a8a 100644 --- a/src/process.c +++ b/src/process.c @@ -433,7 +433,7 @@ BOOL SearchProcess(char* HandleName, BOOL bPartialMatch, BOOL bIgnoreSelf) // If we're switching process and found a match, print it if (bFound) { - uprintf("o '%s' (pid: %ld, access: %s)", exe_path, pid[cur_pid], access_rights_str[access_rights & 0x3]); + uprintf("‣ '%s' (pid: %ld, access: %s)", exe_path, pid[cur_pid], access_rights_str[access_rights & 0x3]); bFound = FALSE; access_rights = 0; } @@ -533,7 +533,7 @@ BOOL SearchProcess(char* HandleName, BOOL bPartialMatch, BOOL bIgnoreSelf) // If this is the very first process we find, print a header if (exe_path[0] == 0) - uprintf("\r\nNOTE: The following process(es) or service(s) are accessing %s:", HandleName); + uprintf("NOTE: The following process(es) or service(s) are accessing %s:", HandleName); if (!GetModuleFileNameExU(processHandle, 0, exe_path, MAX_PATH - 1)) safe_sprintf(exe_path, MAX_PATH, "Unknown_Process_%" PRIu64, @@ -544,7 +544,7 @@ out: if (exe_path[0] != 0) uprintf("You should try to close these applications before attempting to reformat the drive."); else - uprintf(APPLICATION_NAME " was unable to identify the process(es) or service(s) preventing access to %s", HandleName); + uprintf("NOTE: Could not identify the process(es) or service(s) accessing %s", HandleName); free(wHandleName); PhFree(buffer); diff --git a/src/rufus.rc b/src/rufus.rc index acc97947..79da32be 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 242, 376 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 2.15.1105" +CAPTION "Rufus 2.15.1106" FONT 8, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 @@ -334,8 +334,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,15,1105,0 - PRODUCTVERSION 2,15,1105,0 + FILEVERSION 2,15,1106,0 + PRODUCTVERSION 2,15,1106,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -352,13 +352,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "2.15.1105" + VALUE "FileVersion", "2.15.1106" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2017 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "2.15.1105" + VALUE "ProductVersion", "2.15.1106" END END BLOCK "VarFileInfo"