mirror of
https://github.com/pbatard/rufus.git
synced 2025-05-24 19:54:25 -04:00
[misc] fix conversion of windows error codes
* Commit f453dc272b
improved on error message reporting, but went a bit
too far in trying to let Windows facilities sort their messages out.
* Add a retry that clears the facility, so that, for one thing, we get wininet
messages properly processed, regardless of the official facility assigned.
This commit is contained in:
parent
4d42b7a73a
commit
eb282642ff
2 changed files with 18 additions and 12 deletions
10
src/rufus.rc
10
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 4.6.2205"
|
||||
CAPTION "Rufus 4.6.2206"
|
||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
||||
|
@ -399,8 +399,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 4,6,2205,0
|
||||
PRODUCTVERSION 4,6,2205,0
|
||||
FILEVERSION 4,6,2206,0
|
||||
PRODUCTVERSION 4,6,2206,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -418,13 +418,13 @@ BEGIN
|
|||
VALUE "Comments", "https://rufus.ie"
|
||||
VALUE "CompanyName", "Akeo Consulting"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "4.6.2205"
|
||||
VALUE "FileVersion", "4.6.2206"
|
||||
VALUE "InternalName", "Rufus"
|
||||
VALUE "LegalCopyright", "© 2011-2024 Pete Batard (GPL v3)"
|
||||
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
||||
VALUE "OriginalFilename", "rufus-4.6.exe"
|
||||
VALUE "ProductName", "Rufus"
|
||||
VALUE "ProductVersion", "4.6.2205"
|
||||
VALUE "ProductVersion", "4.6.2206"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
20
src/stdio.c
20
src/stdio.c
|
@ -233,16 +233,18 @@ const char *WindowsErrorString(void)
|
|||
static char err_string[256] = { 0 };
|
||||
|
||||
DWORD size, presize;
|
||||
DWORD error_code, format_error;
|
||||
DWORD error_code, _error_code, format_error;
|
||||
HANDLE hModule = NULL;
|
||||
|
||||
error_code = GetLastError();
|
||||
_error_code = error_code;
|
||||
retry:
|
||||
// Check for specific facility error codes
|
||||
switch (HRESULT_FACILITY(error_code)) {
|
||||
switch (HRESULT_FACILITY(_error_code)) {
|
||||
case FACILITY_NULL:
|
||||
// Special case for internet related errors, that don't actually have a facility
|
||||
// set but still require a hModule into wininet to display the messages.
|
||||
if ((error_code >= INTERNET_ERROR_BASE) && (error_code <= INTERNET_ERROR_LAST))
|
||||
if ((_error_code >= INTERNET_ERROR_BASE) && (_error_code <= INTERNET_ERROR_LAST))
|
||||
hModule = GetModuleHandleA("wininet.dll");
|
||||
break;
|
||||
case FACILITY_ITF:
|
||||
|
@ -260,22 +262,26 @@ const char *WindowsErrorString(void)
|
|||
// coverity[var_deref_model]
|
||||
size = FormatMessageU(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS |
|
||||
((hModule != NULL) ? FORMAT_MESSAGE_FROM_HMODULE : 0), hModule,
|
||||
error_code, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
|
||||
_error_code, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
|
||||
&err_string[presize], (DWORD)(sizeof(err_string) - strlen(err_string)), NULL);
|
||||
if (size == 0) {
|
||||
format_error = GetLastError();
|
||||
switch (format_error) {
|
||||
case ERROR_SUCCESS:
|
||||
static_sprintf(err_string, "[0x%08lX] (No Windows Error String)", error_code);
|
||||
static_sprintf(err_string, "[0x%08lX] (No Windows Error String)", _error_code);
|
||||
break;
|
||||
case ERROR_MR_MID_NOT_FOUND:
|
||||
case ERROR_MUI_FILE_NOT_FOUND:
|
||||
case ERROR_MUI_FILE_NOT_LOADED:
|
||||
// We might be trying with the wrong facility. Remove it and try again.
|
||||
if (HRESULT_FACILITY(_error_code) != FACILITY_NULL) {
|
||||
_error_code = HRESULT_CODE(_error_code);
|
||||
goto retry;
|
||||
}
|
||||
static_sprintf(err_string, "[0x%08lX] (NB: This system was unable to provide an English error message)", error_code);
|
||||
break;
|
||||
default:
|
||||
static_sprintf(err_string, "[0x%08lX] (FormatMessage error code 0x%08lX)",
|
||||
error_code, format_error);
|
||||
static_sprintf(err_string, "[0x%08lX] (FormatMessage error code 0x%08lX)", error_code, format_error);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue