From d8a2c29a679bde1981cad9f88bba5b762c93888e Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Sun, 17 Oct 2021 13:28:03 +0100 Subject: [PATCH] [core] fix MBR cleanup regression * Commit 9dc045a7017cfd3ac503ced89a3a1c6604dd5d67 introduced a regression on account that we didn't set the file pointer to 0 before clearing the disk. * This leads to the MBR not being properly cleared, with the result that Windows may in turn produce errors when trying to repartition the disk. * Fix this by making sure we do invoke SetFilePointerEx() before calling WriteFileWithRetry(). * Also set rufus-next to 3.17 * Also fix a MinGW warning --- configure | 20 ++++++++++---------- configure.ac | 2 +- res/appstore/Package.appxmanifest | 2 +- res/appstore/packme.cmd | 2 +- src/format.c | 7 +++++-- src/rufus.rc | 12 ++++++------ src/stdfn.c | 2 +- 7 files changed, 25 insertions(+), 22 deletions(-) diff --git a/configure b/configure index 72959b7b..f1a1b5f4 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.71 for rufus 3.16. +# Generated by GNU Autoconf 2.71 for rufus 3.17. # # Report bugs to . # @@ -611,8 +611,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='rufus' PACKAGE_TARNAME='rufus' -PACKAGE_VERSION='3.16' -PACKAGE_STRING='rufus 3.16' +PACKAGE_VERSION='3.17' +PACKAGE_STRING='rufus 3.17' PACKAGE_BUGREPORT='https://github.com/pbatard/rufus/issues' PACKAGE_URL='https://rufus.ie' @@ -1268,7 +1268,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures rufus 3.16 to adapt to many kinds of systems. +\`configure' configures rufus 3.17 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1335,7 +1335,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of rufus 3.16:";; + short | recursive ) echo "Configuration of rufus 3.17:";; esac cat <<\_ACEOF @@ -1427,7 +1427,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -rufus configure 3.16 +rufus configure 3.17 generated by GNU Autoconf 2.71 Copyright (C) 2021 Free Software Foundation, Inc. @@ -1503,7 +1503,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by rufus $as_me 3.16, which was +It was created by rufus $as_me 3.17, which was generated by GNU Autoconf 2.71. Invocation command line was $ $0$ac_configure_args_raw @@ -2767,7 +2767,7 @@ fi # Define the identity of the package. PACKAGE='rufus' - VERSION='3.16' + VERSION='3.17' printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h @@ -5205,7 +5205,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by rufus $as_me 3.16, which was +This file was extended by rufus $as_me 3.17, which was generated by GNU Autoconf 2.71. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -5261,7 +5261,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -rufus config.status 3.16 +rufus config.status 3.17 configured by $0, generated by GNU Autoconf 2.71, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index ad15b4de..fa305d55 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([rufus], [3.16], [https://github.com/pbatard/rufus/issues], [rufus], [https://rufus.ie]) +AC_INIT([rufus], [3.17], [https://github.com/pbatard/rufus/issues], [rufus], [https://rufus.ie]) AM_INIT_AUTOMAKE([-Wno-portability foreign no-dist no-dependencies]) AC_CONFIG_SRCDIR([src/rufus.c]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/res/appstore/Package.appxmanifest b/res/appstore/Package.appxmanifest index dd955567..50b7e92e 100644 --- a/res/appstore/Package.appxmanifest +++ b/res/appstore/Package.appxmanifest @@ -11,7 +11,7 @@ + Version="3.17.1838.0" /> Rufus diff --git a/res/appstore/packme.cmd b/res/appstore/packme.cmd index c9696100..11aab563 100644 --- a/res/appstore/packme.cmd +++ b/res/appstore/packme.cmd @@ -1,6 +1,6 @@ @echo off setlocal EnableExtensions DisableDelayedExpansion -set VERSION=3.16 +set VERSION=3.17 del /q *.appx >NUL 2>&1 del /q *.appxbundle >NUL 2>&1 diff --git a/src/format.c b/src/format.c index 4a9f53ae..322752b3 100644 --- a/src/format.c +++ b/src/format.c @@ -739,6 +739,9 @@ static BOOL ClearMBRGPT(HANDLE hPhysicalDrive, LONGLONG DiskSize, DWORD SectorSi FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_NOT_ENOUGH_MEMORY; goto out; } + liFilePointer.QuadPart = 0ULL; + if (!SetFilePointerEx(hPhysicalDrive, liFilePointer, &liFilePointer, FILE_BEGIN) || (liFilePointer.QuadPart != 0ULL)) + uprintf("Warning: Could not reset disk position"); if (!WriteFileWithRetry(hPhysicalDrive, pZeroBuf, (DWORD)(SectorSize * num_sectors_to_clear), NULL, WRITE_RETRIES)) goto out; CHECK_FOR_USER_CANCEL; @@ -1852,8 +1855,8 @@ DWORD WINAPI FormatThread(void* param) { int r; BOOL ret, use_large_fat32, windows_to_go, actual_lock_drive = lock_drive; - // Windows 11 and VDS (which I suspect is what fmifs.dll's FormatEx() is now calling behind the - // scenes) require us to unlock the physical drive to format the drive, else access denied is re + // Windows 11 and VDS (which I suspect is what fmifs.dll's FormatEx() is now calling behind the scenes) + // require us to unlock the physical drive to format the drive, else access denied is returned. BOOL need_logical = FALSE, must_unlock_physical = (use_vds || nWindowsVersion >= WINDOWS_11); DWORD cr, DriveIndex = (DWORD)(uintptr_t)param, ClusterSize, Flags; HANDLE hPhysicalDrive = INVALID_HANDLE_VALUE; diff --git a/src/rufus.rc b/src/rufus.rc index 7606d3b7..fa93318a 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.16.1837" +CAPTION "Rufus 3.17.1838" 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,16,1837,0 - PRODUCTVERSION 3,16,1837,0 + FILEVERSION 3,17,1838,0 + PRODUCTVERSION 3,17,1838,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.16.1837" + VALUE "FileVersion", "3.17.1838" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2021 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" - VALUE "OriginalFilename", "rufus-3.16.exe" + VALUE "OriginalFilename", "rufus-3.17.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "3.16.1837" + VALUE "ProductVersion", "3.17.1838" END END BLOCK "VarFileInfo" diff --git a/src/stdfn.c b/src/stdfn.c index 6dd0caf3..836e9dfd 100644 --- a/src/stdfn.c +++ b/src/stdfn.c @@ -310,7 +310,7 @@ static const char* GetEdition(DWORD ProductType) case 0x000000BD: return "Lite"; case 0xABCDABCD: return "(Unlicensed)"; default: - static_sprintf(unknown_edition_str, "(Unknown Edition 0x%02X)", ProductType); + static_sprintf(unknown_edition_str, "(Unknown Edition 0x%02X)", (uint32_t)ProductType); return unknown_edition_str; } }