mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[ui] improve error reporting for download issues
* This is part of #1444
This commit is contained in:
parent
b8b22ee890
commit
87a7228d38
5 changed files with 38 additions and 16 deletions
|
@ -2982,7 +2982,6 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
zero_drive = FALSE;
|
|
||||||
safe_free(volume_name);
|
safe_free(volume_name);
|
||||||
safe_free(buffer);
|
safe_free(buffer);
|
||||||
safe_closehandle(hSourceImage);
|
safe_closehandle(hSourceImage);
|
||||||
|
|
38
src/rufus.c
38
src/rufus.c
|
@ -50,6 +50,13 @@
|
||||||
#include "../res/grub/grub_version.h"
|
#include "../res/grub/grub_version.h"
|
||||||
#include "../res/grub2/grub2_version.h"
|
#include "../res/grub2/grub2_version.h"
|
||||||
|
|
||||||
|
enum bootcheck_return {
|
||||||
|
BOOTCHECK_PROCEED = 0,
|
||||||
|
BOOTCHECK_CANCEL = -1,
|
||||||
|
BOOTCHECK_DOWNLOAD_ERROR = -2,
|
||||||
|
BOOTCHECK_GENERAL_ERROR = -3,
|
||||||
|
};
|
||||||
|
|
||||||
static const char* cmdline_hogger = "rufus.com";
|
static const char* cmdline_hogger = "rufus.com";
|
||||||
static const char* ep_reg = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer";
|
static const char* ep_reg = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer";
|
||||||
static const char* vs_reg = "Software\\Microsoft\\VisualStudio";
|
static const char* vs_reg = "Software\\Microsoft\\VisualStudio";
|
||||||
|
@ -1185,7 +1192,7 @@ static DWORD WINAPI BootCheckThread(LPVOID param)
|
||||||
int i, r;
|
int i, r;
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
DWORD len;
|
DWORD len;
|
||||||
WPARAM ret = -1;
|
WPARAM ret = BOOTCHECK_CANCEL;
|
||||||
BOOL in_files_dir = FALSE;
|
BOOL in_files_dir = FALSE;
|
||||||
const char* grub = "grub";
|
const char* grub = "grub";
|
||||||
const char* core_img = "core.img";
|
const char* core_img = "core.img";
|
||||||
|
@ -1202,7 +1209,7 @@ static DWORD WINAPI BootCheckThread(LPVOID param)
|
||||||
|
|
||||||
if ((zero_drive) || (boot_type == BT_NON_BOOTABLE)) {
|
if ((zero_drive) || (boot_type == BT_NON_BOOTABLE)) {
|
||||||
// Nothing to check
|
// Nothing to check
|
||||||
ret = 0;
|
ret = BOOTCHECK_PROCEED;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1217,7 +1224,7 @@ static DWORD WINAPI BootCheckThread(LPVOID param)
|
||||||
}
|
}
|
||||||
if (IS_DD_BOOTABLE(img_report) && !img_report.is_iso) {
|
if (IS_DD_BOOTABLE(img_report) && !img_report.is_iso) {
|
||||||
// Pure DD images are fine at this stage
|
// Pure DD images are fine at this stage
|
||||||
ret = 0;
|
ret = BOOTCHECK_PROCEED;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if ((image_options & IMOP_WINTOGO) && (ComboBox_GetCurSel(GetDlgItem(hMainDialog, IDC_IMAGE_OPTION)) == 1)) {
|
if ((image_options & IMOP_WINTOGO) && (ComboBox_GetCurSel(GetDlgItem(hMainDialog, IDC_IMAGE_OPTION)) == 1)) {
|
||||||
|
@ -1375,6 +1382,7 @@ static DWORD WINAPI BootCheckThread(LPVOID param)
|
||||||
len = DownloadSignedFile(tmp, &tmp[sizeof(FILES_URL)], hMainDialog, TRUE);
|
len = DownloadSignedFile(tmp, &tmp[sizeof(FILES_URL)], hMainDialog, TRUE);
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
uprintf("Could not download file - cancelling");
|
uprintf("Could not download file - cancelling");
|
||||||
|
ret = BOOTCHECK_DOWNLOAD_ERROR;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
use_own_c32[i] = TRUE;
|
use_own_c32[i] = TRUE;
|
||||||
|
@ -1442,6 +1450,7 @@ static DWORD WINAPI BootCheckThread(LPVOID param)
|
||||||
uprintf("Could not download the file - will try to use embedded %s version instead", img_report.sl_version_str);
|
uprintf("Could not download the file - will try to use embedded %s version instead", img_report.sl_version_str);
|
||||||
} else {
|
} else {
|
||||||
uprintf("Could not download the file - cancelling");
|
uprintf("Could not download the file - cancelling");
|
||||||
|
ret = BOOTCHECK_DOWNLOAD_ERROR;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1470,10 +1479,12 @@ static DWORD WINAPI BootCheckThread(LPVOID param)
|
||||||
static_sprintf(tmp, "%s-%s", syslinux, embedded_sl_version_str[1]);
|
static_sprintf(tmp, "%s-%s", syslinux, embedded_sl_version_str[1]);
|
||||||
IGNORE_RETVAL(_mkdir(tmp));
|
IGNORE_RETVAL(_mkdir(tmp));
|
||||||
static_sprintf(tmp, "%s/%s-%s/%s.%s", FILES_URL, syslinux, embedded_sl_version_str[1], ldlinux, ldlinux_ext[2]);
|
static_sprintf(tmp, "%s/%s-%s/%s.%s", FILES_URL, syslinux, embedded_sl_version_str[1], ldlinux, ldlinux_ext[2]);
|
||||||
if (DownloadSignedFile(tmp, &tmp[sizeof(FILES_URL)], hMainDialog, TRUE) == 0)
|
if (DownloadSignedFile(tmp, &tmp[sizeof(FILES_URL)], hMainDialog, TRUE) == 0) {
|
||||||
|
ret = BOOTCHECK_DOWNLOAD_ERROR;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (boot_type == BT_MSDOS) {
|
} else if (boot_type == BT_MSDOS) {
|
||||||
if ((size_check) && (ComboBox_GetItemData(hClusterSize, ComboBox_GetCurSel(hClusterSize)) >= 65536)) {
|
if ((size_check) && (ComboBox_GetItemData(hClusterSize, ComboBox_GetCurSel(hClusterSize)) >= 65536)) {
|
||||||
// MS-DOS cannot boot from a drive using a 64 kilobytes Cluster size
|
// MS-DOS cannot boot from a drive using a 64 kilobytes Cluster size
|
||||||
|
@ -1500,11 +1511,13 @@ static DWORD WINAPI BootCheckThread(LPVOID param)
|
||||||
static_sprintf(tmp, "grub4dos-%s", GRUB4DOS_VERSION);
|
static_sprintf(tmp, "grub4dos-%s", GRUB4DOS_VERSION);
|
||||||
IGNORE_RETVAL(_mkdir(tmp));
|
IGNORE_RETVAL(_mkdir(tmp));
|
||||||
static_sprintf(tmp, "%s/grub4dos-%s/grldr", FILES_URL, GRUB4DOS_VERSION);
|
static_sprintf(tmp, "%s/grub4dos-%s/grldr", FILES_URL, GRUB4DOS_VERSION);
|
||||||
if (DownloadSignedFile(tmp, &tmp[sizeof(FILES_URL)], hMainDialog, TRUE) == 0)
|
if (DownloadSignedFile(tmp, &tmp[sizeof(FILES_URL)], hMainDialog, TRUE) == 0) {
|
||||||
|
ret = BOOTCHECK_DOWNLOAD_ERROR;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uefi_target:
|
uefi_target:
|
||||||
if (boot_type == BT_UEFI_NTFS) {
|
if (boot_type == BT_UEFI_NTFS) {
|
||||||
|
@ -1514,7 +1527,7 @@ uefi_target:
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret = 0;
|
ret = BOOTCHECK_PROCEED;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
PostMessage(hMainDialog, UM_FORMAT_START, ret, 0);
|
PostMessage(hMainDialog, UM_FORMAT_START, ret, 0);
|
||||||
|
@ -2622,8 +2635,10 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UM_FORMAT_START:
|
case UM_FORMAT_START:
|
||||||
if (wParam != 0)
|
if (wParam != BOOTCHECK_PROCEED)
|
||||||
goto aborted_start;
|
goto aborted_start;
|
||||||
|
// All subsequent aborts below translate to a user cancellation
|
||||||
|
wParam = BOOTCHECK_CANCEL;
|
||||||
|
|
||||||
if ((partition_type == PARTITION_STYLE_MBR) && (SelectedDrive.DiskSize > 2 * TB)) {
|
if ((partition_type == PARTITION_STYLE_MBR) && (SelectedDrive.DiskSize > 2 * TB)) {
|
||||||
if (MessageBoxExU(hMainDialog, lmprintf(MSG_134, SizeToHumanReadable(SelectedDrive.DiskSize - 2 * TB, FALSE, FALSE)),
|
if (MessageBoxExU(hMainDialog, lmprintf(MSG_134, SizeToHumanReadable(SelectedDrive.DiskSize - 2 * TB, FALSE, FALSE)),
|
||||||
|
@ -2699,14 +2714,19 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
if (format_thid != NULL)
|
if (format_thid != NULL)
|
||||||
break;
|
break;
|
||||||
aborted_start:
|
aborted_start:
|
||||||
EnableControls(TRUE, FALSE);
|
|
||||||
zero_drive = FALSE;
|
zero_drive = FALSE;
|
||||||
if (queued_hotplug_event)
|
if (queued_hotplug_event)
|
||||||
SendMessage(hDlg, UM_MEDIA_CHANGE, 0, 0);
|
SendMessage(hDlg, UM_MEDIA_CHANGE, 0, 0);
|
||||||
EnableWindow(GetDlgItem(hDlg, IDCANCEL), TRUE);
|
if (wParam == BOOTCHECK_CANCEL) {
|
||||||
|
EnableControls(TRUE, FALSE);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) |
|
||||||
|
((wParam == BOOTCHECK_DOWNLOAD_ERROR) ? APPERR(ERROR_CANT_DOWNLOAD) : ERROR_GEN_FAILURE);
|
||||||
|
// Fall through
|
||||||
|
|
||||||
case UM_FORMAT_COMPLETED:
|
case UM_FORMAT_COMPLETED:
|
||||||
|
zero_drive = FALSE;
|
||||||
format_thid = NULL;
|
format_thid = NULL;
|
||||||
// Stop the timer
|
// Stop the timer
|
||||||
KillTimer(hMainDialog, TID_APP_TIMER);
|
KillTimer(hMainDialog, TID_APP_TIMER);
|
||||||
|
|
|
@ -663,3 +663,4 @@ static __inline HMODULE GetLibraryHandle(char* szLibraryName) {
|
||||||
#define ERROR_CANT_ASSIGN_LETTER 0x120B
|
#define ERROR_CANT_ASSIGN_LETTER 0x120B
|
||||||
#define ERROR_CANT_MOUNT_VOLUME 0x120C
|
#define ERROR_CANT_MOUNT_VOLUME 0x120C
|
||||||
#define ERROR_BAD_SIGNATURE 0x120D
|
#define ERROR_BAD_SIGNATURE 0x120D
|
||||||
|
#define ERROR_CANT_DOWNLOAD 0x120E
|
||||||
|
|
10
src/rufus.rc
10
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||||
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
EXSTYLE WS_EX_ACCEPTFILES
|
EXSTYLE WS_EX_ACCEPTFILES
|
||||||
CAPTION "Rufus 3.9.1596"
|
CAPTION "Rufus 3.9.1597"
|
||||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||||
BEGIN
|
BEGIN
|
||||||
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
||||||
|
@ -394,8 +394,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 3,9,1596,0
|
FILEVERSION 3,9,1597,0
|
||||||
PRODUCTVERSION 3,9,1596,0
|
PRODUCTVERSION 3,9,1597,0
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -413,13 +413,13 @@ BEGIN
|
||||||
VALUE "Comments", "https://rufus.ie"
|
VALUE "Comments", "https://rufus.ie"
|
||||||
VALUE "CompanyName", "Akeo Consulting"
|
VALUE "CompanyName", "Akeo Consulting"
|
||||||
VALUE "FileDescription", "Rufus"
|
VALUE "FileDescription", "Rufus"
|
||||||
VALUE "FileVersion", "3.9.1596"
|
VALUE "FileVersion", "3.9.1597"
|
||||||
VALUE "InternalName", "Rufus"
|
VALUE "InternalName", "Rufus"
|
||||||
VALUE "LegalCopyright", "© 2011-2020 Pete Batard (GPL v3)"
|
VALUE "LegalCopyright", "© 2011-2020 Pete Batard (GPL v3)"
|
||||||
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
||||||
VALUE "OriginalFilename", "rufus-3.9.exe"
|
VALUE "OriginalFilename", "rufus-3.9.exe"
|
||||||
VALUE "ProductName", "Rufus"
|
VALUE "ProductName", "Rufus"
|
||||||
VALUE "ProductVersion", "3.9.1596"
|
VALUE "ProductVersion", "3.9.1597"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
|
@ -766,6 +766,8 @@ const char* _StrError(DWORD error_code)
|
||||||
return lmprintf(MSG_079);
|
return lmprintf(MSG_079);
|
||||||
case ERROR_BAD_SIGNATURE:
|
case ERROR_BAD_SIGNATURE:
|
||||||
return lmprintf(MSG_172);
|
return lmprintf(MSG_172);
|
||||||
|
case ERROR_CANT_DOWNLOAD:
|
||||||
|
return lmprintf(MSG_242);
|
||||||
default:
|
default:
|
||||||
SetLastError(error_code);
|
SetLastError(error_code);
|
||||||
return WindowsErrorString();
|
return WindowsErrorString();
|
||||||
|
|
Loading…
Reference in a new issue