mirror of
https://github.com/pbatard/rufus.git
synced 2025-06-02 15:49:52 -04:00
[img] add a retry for DD Images
* Also try to ignore autorun.inf issues from idiotic antivirus solutions, when writing ISOs * Also remove the columns in the English labels (improves high DPI display) * Also update additional ISO related messages to make them more generic
This commit is contained in:
parent
89a7a3deb1
commit
cd4dd3cc47
7 changed files with 66 additions and 51 deletions
32
src/format.c
32
src/format.c
|
@ -1172,7 +1172,6 @@ DWORD WINAPI CloseFormatPromptThread(LPVOID param) {
|
|||
* Close the volume handle.
|
||||
*/
|
||||
#define CHECK_FOR_USER_CANCEL if (IS_ERROR(FormatStatus)) goto out
|
||||
#define BSIZE 65536 // TODO: dual buffer and overlapped when writing an image
|
||||
DWORD WINAPI FormatThread(void* param)
|
||||
{
|
||||
int i, r, pt, bt, fs, dt;
|
||||
|
@ -1185,7 +1184,7 @@ DWORD WINAPI FormatThread(void* param)
|
|||
FILE* log_fd;
|
||||
LARGE_INTEGER li;
|
||||
uint64_t wb;
|
||||
uint8_t buffer[BSIZE];
|
||||
uint8_t buffer[65536];
|
||||
char *bb_msg, *guid_volume = NULL;
|
||||
char drive_name[] = "?:\\";
|
||||
char drive_letters[27];
|
||||
|
@ -1327,7 +1326,7 @@ DWORD WINAPI FormatThread(void* param)
|
|||
// We poked the MBR, so we need to rewind
|
||||
li.QuadPart = 0;
|
||||
SetFilePointerEx(hPhysicalDrive, li, NULL, FILE_BEGIN);
|
||||
hSourceImage = CreateFileU(iso_path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
||||
hSourceImage = CreateFileU(iso_path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
||||
if (hSourceImage == INVALID_HANDLE_VALUE) {
|
||||
uprintf("Could not open image '%s': %s", iso_path, WindowsErrorString());
|
||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_OPEN_FAILED;
|
||||
|
@ -1335,11 +1334,15 @@ DWORD WINAPI FormatThread(void* param)
|
|||
}
|
||||
|
||||
uprintf("Writing Image...");
|
||||
// Don't bother trying for something clever, using double buffering overlapped and whatnot:
|
||||
// With Windows' default optimizations, sync read + sync write for sequential operations
|
||||
// will be as fast, if not faster, than whatever async scheme you can come up with.
|
||||
for (wb = 0; ; wb += wSize) {
|
||||
s = ReadFile(hSourceImage, buffer, BSIZE, &rSize, NULL);
|
||||
s = ReadFile(hSourceImage, buffer, sizeof(buffer), &rSize, NULL);
|
||||
if (!s) {
|
||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_READ_FAULT;
|
||||
uprintf("read error: %s", WindowsErrorString());
|
||||
goto out;
|
||||
}
|
||||
if (rSize == 0)
|
||||
break;
|
||||
|
@ -1350,16 +1353,24 @@ DWORD WINAPI FormatThread(void* param)
|
|||
UpdateProgress(OP_FORMAT, format_percent);
|
||||
}
|
||||
CHECK_FOR_USER_CANCEL;
|
||||
// TODO: add a retry on write?
|
||||
s = WriteFile(hPhysicalDrive, buffer, rSize, &wSize, NULL);
|
||||
if (!s || wSize != rSize) {
|
||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_FAULT;
|
||||
for (i=0; i<WRITE_RETRIES; i++) {
|
||||
s = WriteFile(hPhysicalDrive, buffer, rSize, &wSize, NULL);
|
||||
if ((s) && (wSize == rSize))
|
||||
break;
|
||||
if (s)
|
||||
uprintf("write error: Wrote %d bytes, expected %d bytes\n", wSize, rSize);
|
||||
else
|
||||
uprintf("write error: %s", WindowsErrorString());
|
||||
goto out;
|
||||
}
|
||||
if (i < WRITE_RETRIES-1) {
|
||||
li.QuadPart = wb;
|
||||
SetFilePointerEx(hPhysicalDrive, li, NULL, FILE_BEGIN);
|
||||
uprintf(" RETRYING...\n");
|
||||
} else {
|
||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_FAULT;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
if (i >= WRITE_RETRIES) goto out;
|
||||
}
|
||||
uprintf("Done");
|
||||
goto out;
|
||||
|
@ -1551,6 +1562,7 @@ DWORD WINAPI FormatThread(void* param)
|
|||
out:
|
||||
safe_free(guid_volume);
|
||||
SendMessage(hISOProgressDlg, UM_ISO_EXIT, 0, 0);
|
||||
safe_closehandle(hSourceImage);
|
||||
safe_unlockclose(hLogicalVolume);
|
||||
safe_unlockclose(hPhysicalDrive); // This can take a while
|
||||
if (IS_ERROR(FormatStatus)) {
|
||||
|
|
28
src/iso.c
28
src/iso.c
|
@ -47,7 +47,6 @@
|
|||
// the progress bar for every block will bring extraction to a crawl
|
||||
#define PROGRESS_THRESHOLD 128
|
||||
#define FOUR_GIGABYTES 4294967296LL
|
||||
#define WRITE_RETRIES 3
|
||||
|
||||
// Needed for UDF ISO access
|
||||
CdIo_t* cdio_open (const char* psz_source, driver_id_t driver_id) {return NULL;}
|
||||
|
@ -69,6 +68,9 @@ static const char* pe_dirname[] = { "/i386", "/minint" };
|
|||
static const char* pe_file[] = { "ntdetect.com", "setupldr.bin", "txtsetup.sif" };
|
||||
static const char* reactos_name = "setupldr.sys"; // TODO: freeldr.sys doesn't seem to work
|
||||
static const char* autorun_name = "autorun.inf";
|
||||
static const char* stupid_antivirus = " NOTE: This is usually caused by a poorly designed security solution. "
|
||||
"See http://rufus.akeo.ie/compatibility.\r\n This file will be skipped for now, but you should really "
|
||||
"look into using a *SMARTER* antivirus solution.";
|
||||
const char* old_c32_name[NB_OLD_C32] = OLD_C32_NAMES;
|
||||
static const int64_t old_c32_threshold[NB_OLD_C32] = OLD_C32_THRESHOLD;
|
||||
static uint8_t i_joliet_level = 0;
|
||||
|
@ -283,13 +285,11 @@ static int udf_extract_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const cha
|
|||
if (file_handle == INVALID_HANDLE_VALUE) {
|
||||
err = GetLastError();
|
||||
uprintf(" Unable to create file: %s\n", WindowsErrorString());
|
||||
if ((err == ERROR_ACCESS_DENIED) && (safe_strcmp(&psz_fullpath[3], autorun_name) == 0)) {
|
||||
uprintf(" NOTE: This may be caused by a poorly designed security solution. "
|
||||
"See http://rufus.akeo.ie/compatibility.");
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
while (i_file_length > 0) {
|
||||
if ((err == ERROR_ACCESS_DENIED) && (safe_strcmp(&psz_fullpath[3], autorun_name) == 0))
|
||||
uprintf(stupid_antivirus);
|
||||
else
|
||||
goto out;
|
||||
} else while (i_file_length > 0) {
|
||||
if (FormatStatus) goto out;
|
||||
memset(buf, 0, UDF_BLOCKSIZE);
|
||||
i_read = udf_read_block(p_udf_dirent, buf, 1);
|
||||
|
@ -424,13 +424,11 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path)
|
|||
if (file_handle == INVALID_HANDLE_VALUE) {
|
||||
err = GetLastError();
|
||||
uprintf(" Unable to create file: %s\n", WindowsErrorString());
|
||||
if ((err == ERROR_ACCESS_DENIED) && (safe_strcmp(&psz_fullpath[3], autorun_name) == 0)) {
|
||||
uprintf(" NOTE: This may be caused by a poorly designed security solution. "
|
||||
"See http://rufus.akeo.ie/compatibility.");
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
for (i=0; i_file_length>0; i++) {
|
||||
if ((err == ERROR_ACCESS_DENIED) && (safe_strcmp(&psz_fullpath[3], autorun_name) == 0))
|
||||
uprintf(stupid_antivirus);
|
||||
else
|
||||
goto out;
|
||||
} else for (i=0; i_file_length>0; i++) {
|
||||
if (FormatStatus) goto out;
|
||||
memset(buf, 0, ISO_BLOCKSIZE);
|
||||
lsn = p_statbuf->lsn + (lsn_t)i;
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#define MAX_SECTORS_TO_CLEAR 128 // nb sectors to zap when clearing the MBR/GPT (must be >34)
|
||||
#define MBR_UEFI_MARKER 0x49464555 // 'U', 'E', 'F', 'I', as a 32 bit little endian longword
|
||||
#define PROPOSEDLABEL_TOLERANCE 0.10
|
||||
#define WRITE_RETRIES 3
|
||||
#define FS_DEFAULT FS_FAT32
|
||||
#define BADBLOCK_PATTERNS {0xaa, 0x55, 0xff, 0x00}
|
||||
#define LARGE_FAT32_SIZE (32*1073741824LL) // Size at which we need to use fat32format
|
||||
|
|
24
src/rufus.rc
24
src/rufus.rc
|
@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
|||
|
||||
IDD_DIALOG DIALOGEX 12, 12, 206, 329
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Rufus 1.4.4.405"
|
||||
CAPTION "Rufus 1.4.4.406"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
|
||||
|
@ -51,16 +51,16 @@ BEGIN
|
|||
GROUPBOX "Format Options ",IDS_FORMAT_OPTIONS_GRP,7,149,192,66
|
||||
LTEXT "New volume label",IDS_LABEL_TXT,9,121,186,10
|
||||
EDITTEXT IDC_LABEL,7,131,190,13,ES_AUTOHSCROLL
|
||||
CONTROL "Check device for bad blocks:",IDC_BADBLOCKS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,161,101,10
|
||||
CONTROL "Check device for bad blocks",IDC_BADBLOCKS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,161,101,10
|
||||
CONTROL "Quick format",IDC_QUICKFORMAT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,173,106,10
|
||||
CONTROL "Create a bootable disk using:",IDC_BOOT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,185,104,10
|
||||
CONTROL "Create a bootable disk using",IDC_BOOT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,185,104,10
|
||||
CONTROL "Create extended label and icon files",IDC_SET_ICON,
|
||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,198,181,10
|
||||
CONTROL "",IDC_PROGRESS,"msctls_progress32",PBS_SMOOTH | WS_BORDER,8,272,189,9
|
||||
COMBOBOX IDC_NBPASSES,119,159,49,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_BOOTTYPE,119,183,49,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
PUSHBUTTON "...",IDC_SELECT_ISO,171,182,22,14,BS_ICON
|
||||
CONTROL "Use Rufus MBR with BIOS ID:",IDC_RUFUS_MBR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,248,106,10
|
||||
CONTROL "Use Rufus MBR with BIOS ID",IDC_RUFUS_MBR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,248,106,10
|
||||
PUSHBUTTON "",IDC_ADVANCED,63,148,14,10,BS_TOP | BS_FLAT
|
||||
GROUPBOX "Advanced Options",IDS_ADVANCED_OPTIONS_GRP,7,210,192,54
|
||||
COMBOBOX IDC_DISK_ID,119,246,73,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
|
@ -165,7 +165,7 @@ END
|
|||
RTL_IDD_DIALOG DIALOGEX 12, 12, 206, 329
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_RTLREADING | WS_EX_APPWINDOW | WS_EX_LAYOUTRTL
|
||||
CAPTION "Rufus 1.4.4.405"
|
||||
CAPTION "Rufus 1.4.4.406"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
|
||||
|
@ -184,16 +184,16 @@ BEGIN
|
|||
GROUPBOX "Format Options ",IDS_FORMAT_OPTIONS_GRP,7,149,192,66
|
||||
LTEXT "New volume label",IDS_LABEL_TXT,9,121,186,10
|
||||
EDITTEXT IDC_LABEL,7,131,190,13,ES_AUTOHSCROLL
|
||||
CONTROL "Check device for bad blocks:",IDC_BADBLOCKS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,161,101,10
|
||||
CONTROL "Check device for bad blocks",IDC_BADBLOCKS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,161,101,10
|
||||
CONTROL "Quick format",IDC_QUICKFORMAT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,173,106,10
|
||||
CONTROL "Create a bootable disk using:",IDC_BOOT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,185,104,10
|
||||
CONTROL "Create a bootable disk using",IDC_BOOT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,185,104,10
|
||||
CONTROL "Create extended label and icon files",IDC_SET_ICON,
|
||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,198,181,10
|
||||
CONTROL "",IDC_PROGRESS,"msctls_progress32",PBS_SMOOTH | WS_BORDER,8,272,189,9
|
||||
COMBOBOX IDC_NBPASSES,119,159,49,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_BOOTTYPE,119,183,49,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
PUSHBUTTON "...",IDC_SELECT_ISO,171,182,22,14,BS_ICON
|
||||
CONTROL "Use Rufus MBR with BIOS ID:",IDC_RUFUS_MBR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,248,106,10
|
||||
CONTROL "Use Rufus MBR with BIOS ID",IDC_RUFUS_MBR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,248,106,10
|
||||
PUSHBUTTON "",IDC_ADVANCED,63,148,14,10,BS_TOP | BS_FLAT
|
||||
GROUPBOX "Advanced Options",IDS_ADVANCED_OPTIONS_GRP,7,210,192,54
|
||||
COMBOBOX IDC_DISK_ID,119,246,73,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
|
@ -427,8 +427,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,4,4,405
|
||||
PRODUCTVERSION 1,4,4,405
|
||||
FILEVERSION 1,4,4,406
|
||||
PRODUCTVERSION 1,4,4,406
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -445,13 +445,13 @@ BEGIN
|
|||
BEGIN
|
||||
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "1.4.4.405"
|
||||
VALUE "FileVersion", "1.4.4.406"
|
||||
VALUE "InternalName", "Rufus"
|
||||
VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)"
|
||||
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
|
||||
VALUE "OriginalFilename", "rufus.exe"
|
||||
VALUE "ProductName", "Rufus"
|
||||
VALUE "ProductVersion", "1.4.4.405"
|
||||
VALUE "ProductVersion", "1.4.4.406"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue