mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[core] work around Windows 10 CU potentially selecting the UEFI:NTFS partition for formatting
* Should only happen with Windows 10 Creator Update (1703) * Closes #931 * Also silence the flow of bcdboot benign errors on WinToGo creation (unless USB Debug is enabled) * Also ensure WaitForLogical() will not actually spends 15 seconds max before giving up
This commit is contained in:
parent
42e8d714e8
commit
caa9b06426
4 changed files with 24 additions and 12 deletions
|
@ -306,10 +306,13 @@ out:
|
|||
/* Wait for a logical drive to reappear - Used when a drive has just been repartitioned */
|
||||
BOOL WaitForLogical(DWORD DriveIndex)
|
||||
{
|
||||
DWORD i;
|
||||
DWORD EndTime;
|
||||
char* LogicalPath = NULL;
|
||||
|
||||
for (i = 0; i < DRIVE_ACCESS_RETRIES; i++) {
|
||||
// GetLogicalName() calls may be slow, so use the system time to
|
||||
// make sure we don't spend more than DRIVE_ACCESS_TIMEOUT in wait.
|
||||
EndTime = GetTickCount() + DRIVE_ACCESS_TIMEOUT;
|
||||
do {
|
||||
LogicalPath = GetLogicalName(DriveIndex, FALSE, TRUE);
|
||||
if (LogicalPath != NULL) {
|
||||
free(LogicalPath);
|
||||
|
@ -318,7 +321,7 @@ BOOL WaitForLogical(DWORD DriveIndex)
|
|||
if (IS_ERROR(FormatStatus)) // User cancel
|
||||
return FALSE;
|
||||
Sleep(DRIVE_ACCESS_TIMEOUT/DRIVE_ACCESS_RETRIES);
|
||||
}
|
||||
} while (GetTickCount() < EndTime);
|
||||
uprintf("Timeout while waiting for logical drive\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
|
16
src/format.c
16
src/format.c
|
@ -61,7 +61,7 @@ static int task_number = 0;
|
|||
extern const int nb_steps[FS_MAX];
|
||||
extern uint32_t dur_mins, dur_secs;
|
||||
static int fs_index = 0, wintogo_index = -1;
|
||||
extern BOOL force_large_fat32, enable_ntfs_compression, lock_drive, zero_drive, disable_file_indexing;
|
||||
extern BOOL force_large_fat32, enable_ntfs_compression, lock_drive, zero_drive, disable_file_indexing, usb_debug;
|
||||
uint8_t *grub2_buf = NULL;
|
||||
long grub2_len;
|
||||
static BOOL WritePBR(HANDLE hLogicalDrive);
|
||||
|
@ -681,7 +681,7 @@ static BOOL FormatDrive(DWORD DriveIndex)
|
|||
BOOL r = FALSE;
|
||||
PF_DECL(FormatEx);
|
||||
PF_DECL(EnableVolumeCompression);
|
||||
char FSType[32];
|
||||
char FSType[32], path[MAX_PATH];
|
||||
char *locale, *VolumeName = NULL;
|
||||
WCHAR* wVolumeName = NULL;
|
||||
WCHAR wFSType[64];
|
||||
|
@ -715,6 +715,16 @@ static BOOL FormatDrive(DWORD DriveIndex)
|
|||
// a trailing backslash, but EnableCompression() fails without...
|
||||
wVolumeName[wcslen(wVolumeName)-1] = 0; // Remove trailing backslash
|
||||
|
||||
// Check if Windows picked the UEFI:NTFS partition
|
||||
// NB: No need to do this for Large FAT32, as this only applies to NTFS
|
||||
safe_strcpy(path, MAX_PATH, VolumeName);
|
||||
safe_strcat(path, MAX_PATH, "EFI\\Rufus\\ntfs_x64.efi");
|
||||
if (PathFileExistsA(path)) {
|
||||
uprintf("Windows selected the UEFI:NTFS partition for formatting - Retry needed", VolumeName);
|
||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_RETRY;
|
||||
goto out;
|
||||
}
|
||||
|
||||
// LoadLibrary("fmifs.dll") appears to changes the locale, which can lead to
|
||||
// problems with tolower(). Make sure we restore the locale. For more details,
|
||||
// see http://comments.gmane.org/gmane.comp.gnu.mingw.user/39300
|
||||
|
@ -1423,7 +1433,7 @@ static BOOL SetupWinToGo(const char* drive_name, BOOL use_ms_efi)
|
|||
uprintf("Enabling boot...");
|
||||
static_sprintf(cmd, "%s\\bcdboot.exe %s\\Windows /v /f ALL /s %s", sysnative_dir,
|
||||
drive_name, (use_ms_efi)?ms_efi:drive_name);
|
||||
if (RunCommand(cmd, sysnative_dir, TRUE) != 0) {
|
||||
if (RunCommand(cmd, sysnative_dir, usb_debug) != 0) {
|
||||
// Try to continue... but report a failure
|
||||
uprintf("Failed to enable boot using command '%s'", cmd);
|
||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_ISO_EXTRACT);
|
||||
|
|
10
src/rufus.rc
10
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.14.1086"
|
||||
CAPTION "Rufus 2.14.1087"
|
||||
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,14,1086,0
|
||||
PRODUCTVERSION 2,14,1086,0
|
||||
FILEVERSION 2,14,1087,0
|
||||
PRODUCTVERSION 2,14,1087,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.14.1086"
|
||||
VALUE "FileVersion", "2.14.1087"
|
||||
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.14.1086"
|
||||
VALUE "ProductVersion", "2.14.1087"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
|
@ -294,7 +294,6 @@ const char* _StrError(DWORD error_code)
|
|||
case ERROR_NOT_READY:
|
||||
return lmprintf(MSG_079);
|
||||
default:
|
||||
uprintf("Unknown error: %08X\n", error_code);
|
||||
SetLastError(error_code);
|
||||
return WindowsErrorString();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue