diff --git a/ChangeLog.txt b/ChangeLog.txt index 56405764..723c7dca 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -3,6 +3,7 @@ o Version 2.11 (2016.09.??) Improve support for Arch Linux derivatives Add a cheat mode to disable drive indexing (Alt-Q) on format Fix handling of 'Super Floppy Disk' formatted drives + Fix handling of misleading short write reports for drives larger than 1 TB Fix an issue that enabled FAT32 file system selection on some Windows images Fix broken UI font for XP users Fix sanitizing of exFAT labels diff --git a/src/format.c b/src/format.c index f36fca61..c1cfb92e 100644 --- a/src/format.c +++ b/src/format.c @@ -1557,6 +1557,9 @@ DWORD WINAPI FormatThread(void* param) tt = GETTARGETTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme))); use_large_fat32 = (fs == FS_FAT32) && ((SelectedDrive.DiskSize > LARGE_FAT32_SIZE) || (force_large_fat32)); windows_to_go = (togo_mode) && HAS_TOGO(img_report) && (Button_GetCheck(GetDlgItem(hMainDialog, IDC_WINDOWS_TO_GO)) == BST_CHECKED); + large_drive = (SelectedDrive.DiskSize > (1*TB)); + if (large_drive) + uprintf("Notice: Large drive detected (may produce short writes)"); // Find out if we need to add any extra partitions if ((windows_to_go) && (tt == TT_UEFI) && (pt == PARTITION_STYLE_GPT)) // According to Microsoft, every GPT disk (we RUN Windows from) must have an MSR due to not having hidden sectors diff --git a/src/ms-sys/file.c b/src/ms-sys/file.c index 906b1239..50aa0991 100644 --- a/src/ms-sys/file.c +++ b/src/ms-sys/file.c @@ -47,12 +47,23 @@ int64_t write_sectors(HANDLE hDrive, uint64_t SectorSize, return -1; } - if((!WriteFile(hDrive, pBuf, Size, &Size, NULL)) || (Size != nSectors*SectorSize)) + if(!WriteFile(hDrive, pBuf, Size, &Size, NULL)) { - uprintf("write_sectors: Write error %s\n", (GetLastError()!=ERROR_SUCCESS)?WindowsErrorString():""); - uprintf(" Wrote: %d, Expected: %" PRIu64 "\n", Size, nSectors*SectorSize); + uprintf("write_sectors: Write error %s\n", WindowsErrorString()); uprintf(" StartSector: 0x%08" PRIx64 ", nSectors: 0x%" PRIx64 ", SectorSize: 0x%" PRIx64 "\n", StartSector, nSectors, SectorSize); - return Size; + return -1; + } + if (Size != nSectors*SectorSize) + { + /* Some large drives return 0, even though all the data was written - See github #787 */ + if (large_drive && Size == 0) { + uprintf("Warning: Possible short write\n"); + return 0; + } + uprintf("write_sectors:write error\n"); + uprintf(" Wrote: %d, Expected: %" PRIu64 "\n", Size, nSectors*SectorSize); + uprintf(" StartSector: 0x%08" PRIx64 ", nSectors: 0x%" PRIx64 ", SectorSize: 0x%" PRIx64 "\n", StartSector, nSectors, SectorSize); + return -1; } return (int64_t)Size; diff --git a/src/rufus.c b/src/rufus.c index 579aa477..a9dd86a8 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -109,7 +109,7 @@ BOOL use_own_c32[NB_OLD_C32] = {FALSE, FALSE}, mbr_selected_by_user = FALSE, tog BOOL iso_op_in_progress = FALSE, format_op_in_progress = FALSE, right_to_left_mode = FALSE; BOOL enable_HDDs = FALSE, force_update = FALSE, enable_ntfs_compression = FALSE, no_confirmation_on_cancel = FALSE, lock_drive = TRUE; BOOL advanced_mode, allow_dual_uefi_bios, detect_fakes, enable_vmdk, force_large_fat32, usb_debug, use_fake_units, preserve_timestamps; -BOOL zero_drive = FALSE, list_non_usb_removable_drives = FALSE, disable_file_indexing; +BOOL zero_drive = FALSE, list_non_usb_removable_drives = FALSE, disable_file_indexing, large_drive = FALSE; int dialog_showing = 0, lang_button_id = 0; uint16_t rufus_version[3], embedded_sl_version[2]; char embedded_sl_version_str[2][12] = { "?.??", "?.??" }; diff --git a/src/rufus.h b/src/rufus.h index 8dcd279a..66ce2736 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -372,7 +372,7 @@ extern BOOL PromptOnError; extern unsigned long syslinux_ldlinux_len[2]; extern const int nb_steps[FS_MAX]; extern BOOL use_own_c32[NB_OLD_C32], detect_fakes, iso_op_in_progress, format_op_in_progress, right_to_left_mode; -extern BOOL allow_dual_uefi_bios, togo_mode; +extern BOOL allow_dual_uefi_bios, togo_mode, large_drive; extern RUFUS_IMG_REPORT img_report; extern int64_t iso_blocking_status; extern uint16_t rufus_version[3], embedded_sl_version[2]; diff --git a/src/rufus.rc b/src/rufus.rc index 4e01fe6f..4c26d07d 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.11.993" +CAPTION "Rufus 2.11.994" FONT 8, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 @@ -320,8 +320,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,11,993,0 - PRODUCTVERSION 2,11,993,0 + FILEVERSION 2,11,994,0 + PRODUCTVERSION 2,11,994,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -338,13 +338,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "2.11.993" + VALUE "FileVersion", "2.11.994" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "2.11.993" + VALUE "ProductVersion", "2.11.994" END END BLOCK "VarFileInfo" diff --git a/src/stdio.c b/src/stdio.c index b732f579..b8bf4318 100644 --- a/src/stdio.c +++ b/src/stdio.c @@ -336,10 +336,14 @@ BOOL WriteFileWithRetry(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWr if (WriteFile(hFile, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, NULL)) { if (nNumberOfBytesToWrite == *lpNumberOfBytesWritten) return TRUE; + // Some large drives return 0, even though all the data was written - See github #787 */ + if (large_drive && (*lpNumberOfBytesWritten == 0)) { + uprintf("Warning: Possible short write"); + return TRUE; + } uprintf(" Wrote %d bytes but requested %d%s", *lpNumberOfBytesWritten, nNumberOfBytesToWrite, nTry < nNumRetries ? retry_msg : ""); - } - else { + } else { uprintf(" Write error [0x%08X]%s", GetLastError(), nTry < nNumRetries ? retry_msg : ""); } // If we can't reposition for the next run, just abort