diff --git a/src/bled/decompress_gunzip.c b/src/bled/decompress_gunzip.c index 69aeaabf..59f088e9 100644 --- a/src/bled/decompress_gunzip.c +++ b/src/bled/decompress_gunzip.c @@ -1214,13 +1214,18 @@ unpack_gz_stream(transformer_state_t *xstate) total = 0; ALLOC_STATE; - if (state == NULL) + if (state == NULL) { + bb_error_msg("alloc error"); return -1; + } to_read = -1; // bytebuffer_max = 0x8000; bytebuffer = xmalloc(bytebuffer_max); - if (bytebuffer == NULL) - return -1; + if (bytebuffer == NULL) { + bb_error_msg("alloc error"); + total = -1; + goto ret; + } gunzip_src_fd = xstate->src_fd; again: diff --git a/src/drive.c b/src/drive.c index ddcf2f9c..b390dbf0 100644 --- a/src/drive.c +++ b/src/drive.c @@ -1099,7 +1099,6 @@ UINT GetDriveTypeFromIndex(DWORD DriveIndex) return drive_type; } - // Removes all drive letters associated with the specific drive, and return // either the first or last letter that was removed, according to bReturnLast. char RemoveDriveLetters(DWORD DriveIndex, BOOL bReturnLast, BOOL bSilent) diff --git a/src/format.c b/src/format.c index b6642d06..b9711760 100644 --- a/src/format.c +++ b/src/format.c @@ -1746,6 +1746,23 @@ DWORD WINAPI FormatThread(void* param) goto out; } RefreshDriveLayout(hPhysicalDrive); + + // If we write an image that contains an ESP, Windows forcibly reassigns/removes the target + // drive, which causes a write error. To work around this, we must lock the logical drive. + if ((boot_type == BT_IMAGE) && write_as_image) { + // ...and get a lock to the logical drive so that we can actually write something + hLogicalVolume = GetLogicalHandle(DriveIndex, 0, TRUE, FALSE, !actual_lock_drive); + if (hLogicalVolume == INVALID_HANDLE_VALUE) { + uprintf("Could not lock volume"); + FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_OPEN_FAILED; + goto out; + } else if (hLogicalVolume == NULL) { + // NULL is returned for cases where the drive is not yet partitioned + uprintf("Drive does not appear to be partitioned"); + } else if (!UnmountVolume(hLogicalVolume)) { + uprintf("Trying to continue regardless..."); + } + } CHECK_FOR_USER_CANCEL; if (!zero_drive && !write_as_image) { diff --git a/src/rufus.rc b/src/rufus.rc index c076f7c5..44c74f0c 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.13.1716" +CAPTION "Rufus 3.13.1717" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -395,8 +395,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,13,1716,0 - PRODUCTVERSION 3,13,1716,0 + FILEVERSION 3,13,1717,0 + PRODUCTVERSION 3,13,1717,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -414,13 +414,13 @@ BEGIN VALUE "Comments", "https://rufus.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "3.13.1716" + VALUE "FileVersion", "3.13.1717" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2020 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "OriginalFilename", "rufus-3.13.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "3.13.1716" + VALUE "ProductVersion", "3.13.1717" END END BLOCK "VarFileInfo"