diff --git a/res/loc/rufus.loc b/res/loc/rufus.loc index ba8eae8f..70f7ad28 100644 --- a/res/loc/rufus.loc +++ b/res/loc/rufus.loc @@ -343,7 +343,7 @@ t MSG_136 "Release" t MSG_137 "Edition" t MSG_138 "Language" t MSG_139 "Architecture" -t MSG_140 "Confirm" +t MSG_140 "Continue" t MSG_141 "Back" t MSG_142 "Please wait..." t MSG_143 "Download ISO Image" @@ -4285,7 +4285,7 @@ t MSG_133 "Rufus a détecté que vous êtes en train de créer un média 'Window t MSG_134 "Parce que MBR a été sélectionné pour le schéma de partition, Rufus peut seulement créer une partition sur ce média occupant jusqu’à 2 To, ce qui laissera %s d’espace disque non-disponible.\n\nEtes-vous sûr de vouloir continuer ?" t MSG_137 "Édition" t MSG_138 "Langue de produit" -t MSG_140 "Confirmer" +t MSG_140 "Continuer" t MSG_141 "Retour" t MSG_142 "Veuillez patienter..." t MSG_143 "Télécharger une image ISO" diff --git a/src/net.c b/src/net.c index 608b2584..38eae5fe 100644 --- a/src/net.c +++ b/src/net.c @@ -49,7 +49,7 @@ BYTE* fido_script = NULL; extern loc_cmd* selected_locale; extern HANDLE dialog_handle; -extern BOOL force_update, is_x86_32; +extern BOOL force_update, is_x86_32, close_fido_cookie_prompts; static DWORD error_code, fido_len = 0; static BOOL update_check_in_progress = FALSE; static BOOL force_update_check = FALSE; @@ -385,7 +385,7 @@ static uint64_t DownloadToFileOrBuffer(const char* url, const char* file, BYTE** uprintf("No buffer pointer provided for download"); goto out; } - *buffer = malloc(total_size); + *buffer = malloc((size_t)total_size); if (*buffer == NULL) { uprintf("Could not allocate buffer for download"); goto out; @@ -897,9 +897,12 @@ static DWORD WINAPI DownloadISOThread(LPVOID param) } static_sprintf(cmdline, "%s -NonInteractive -NoProfile –ExecutionPolicy Bypass " - "-File %s -PipeName %s -LocData \"%s\" -Icon %s -AppTitle \"%s\" -ShowBrowserOption", + "-File %s -PipeName %s -LocData \"%s\" -Icon %s -AppTitle \"%s\"", powershell_path, script_path, &pipe[9], locale_str, icon_path, lmprintf(MSG_143)); + // Signal our Windows alerts hook that it should close the IE cookie prompts from Fido + close_fido_cookie_prompts = TRUE; FormatStatus = RunCommand(cmdline, app_dir, TRUE); + close_fido_cookie_prompts = FALSE; if ((FormatStatus == 0) && PeekNamedPipe(hPipe, NULL, dwPipeSize, NULL, &dwAvail, NULL) && (dwAvail != 0)) { url = malloc(dwAvail + 1); if ((url != NULL) && ReadFile(hPipe, url, dwAvail, &dwSize, NULL) && (dwSize > 4)) { diff --git a/src/rufus.c b/src/rufus.c index ea62fc99..1e0cf62b 100755 --- a/src/rufus.c +++ b/src/rufus.c @@ -3152,7 +3152,7 @@ relaunch: ChangeWindowMessageFilter(WM_COPYGLOBALDATA, MSGFLT_ADD); // Set the hook to automatically close Windows' "You need to format the disk in drive..." prompt - if (!SetFormatPromptHook()) + if (!SetAlertPromptHook()) uprintf("Warning: Could not set 'Format Disk' prompt auto-close"); ShowWindow(hDlg, SW_SHOWNORMAL); @@ -3402,7 +3402,7 @@ out: if ((!external_loc_file) && (loc_file[0] != 0)) DeleteFileU(loc_file); DestroyAllTooltips(); - ClrFormatPromptHook(); + ClrAlertPromptHook(); exit_localization(); safe_free(image_path); safe_free(locale_name); diff --git a/src/rufus.h b/src/rufus.h index 4fce017b..88348b0f 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -567,8 +567,8 @@ extern BOOL IsBufferInDB(const unsigned char* buf, const size_t len); extern char* _printbits(size_t const size, void const * const ptr, int leading_zeroes); extern BOOL IsCurrentProcessElevated(void); extern char* GetCurrentMUI(void); -extern BOOL SetFormatPromptHook(void); -extern void ClrFormatPromptHook(void); +extern BOOL SetAlertPromptHook(void); +extern void ClrAlertPromptHook(void); extern BYTE SearchProcess(char* HandleName, DWORD dwTimeout, BOOL bPartialMatch, BOOL bIgnoreSelf, BOOL bQuiet); extern BOOL EnablePrivileges(void); extern void FlashTaskbar(HANDLE handle); diff --git a/src/rufus.rc b/src/rufus.rc index 2f46dc8e..1f29be16 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.5.1451" +CAPTION "Rufus 3.5.1452" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -394,8 +394,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,5,1451,0 - PRODUCTVERSION 3,5,1451,0 + FILEVERSION 3,5,1452,0 + PRODUCTVERSION 3,5,1452,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -413,13 +413,13 @@ BEGIN VALUE "Comments", "https://akeo.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "3.5.1451" + VALUE "FileVersion", "3.5.1452" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2019 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus-3.5.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "3.5.1451" + VALUE "ProductVersion", "3.5.1452" END END BLOCK "VarFileInfo" diff --git a/src/stdlg.c b/src/stdlg.c index 6ecf9d08..3a10c99e 100644 --- a/src/stdlg.c +++ b/src/stdlg.c @@ -59,8 +59,10 @@ static BOOL notification_is_question; static const notification_info* notification_more_info; static const char* notification_dont_display_setting; static WNDPROC update_original_proc = NULL; -static HWINEVENTHOOK fp_weh = NULL; +static HWINEVENTHOOK ap_weh = NULL; static char *fp_title_str = "Microsoft Windows", *fp_button_str = "Format disk"; +static char *cp_title_str = "Windows Security Warning"; +BOOL close_fido_cookie_prompts = FALSE; static int update_settings_reposition_ids[] = { IDC_POLICY, @@ -1929,17 +1931,18 @@ INT_PTR MyDialogBox(HINSTANCE hInstance, int Dialog_ID, HWND hWndParent, DLGPROC /* * The following function calls are used to automatically detect and close the native - * Windows format prompt "You must format the disk in drive X:". To do that, we use an - * event hook that gets triggered whenever a window is placed in the foreground. + * Windows format prompt "You must format the disk in drive X:" as well as the cookies + * alert being popped by Windows when running our Download script. To do that, we use + * an event hook that gets triggered whenever a window is placed in the foreground. * In that hook, we look for a dialog that has style WS_POPUPWINDOW and has the relevant - * title. However, because the title in itself is too generic (the expectation is that - * it will be "Microsoft Windows") we also enumerate all the child controls from that - * prompt, using another callback, until we find one that contains the text we expect - * for the "Format disk" button. + * title. However, in case of the Format prompt, because the title in itself is too + * generic (the expectation is that it will be "Microsoft Windows") we also enumerate + * all the child controls from that prompt, using another callback, until we find one + * that contains the text we expect for the "Format disk" button. * Oh, and since all of these strings are localized, we must first pick them up from - * the relevant mui (something like "C:\Windows\System32\en-GB\shell32.dll.mui") + * the relevant mui's. */ -static BOOL CALLBACK FormatPromptCallback(HWND hWnd, LPARAM lParam) +static BOOL CALLBACK AlertPromptCallback(HWND hWnd, LPARAM lParam) { char str[128]; BOOL *found = (BOOL*)lParam; @@ -1951,7 +1954,7 @@ static BOOL CALLBACK FormatPromptCallback(HWND hWnd, LPARAM lParam) return TRUE; } -static void CALLBACK FormatPromptHook(HWINEVENTHOOK hWinEventHook, DWORD Event, HWND hWnd, LONG idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime) +static void CALLBACK AlertPromptHook(HWINEVENTHOOK hWinEventHook, DWORD Event, HWND hWnd, LONG idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime) { char str[128]; BOOL found; @@ -1960,25 +1963,27 @@ static void CALLBACK FormatPromptHook(HWINEVENTHOOK hWinEventHook, DWORD Event, if (GetWindowLongPtr(hWnd, GWL_STYLE) & WS_POPUPWINDOW) { str[0] = 0; GetWindowTextU(hWnd, str, sizeof(str)); - if (safe_strcmp(str, fp_title_str) == 0) { + if (strcmp(str, fp_title_str) == 0) { found = FALSE; - EnumChildWindows(hWnd, FormatPromptCallback, (LPARAM)&found); + EnumChildWindows(hWnd, AlertPromptCallback, (LPARAM)&found); if (found) { SendMessage(hWnd, WM_COMMAND, (WPARAM)IDCANCEL, (LPARAM)0); uprintf("Closed Windows format prompt"); } + } else if (close_fido_cookie_prompts && strcmp(str, cp_title_str) == 0) { + SendMessage(hWnd, WM_COMMAND, (WPARAM)IDCANCEL, (LPARAM)0); } } } } -BOOL SetFormatPromptHook(void) +BOOL SetAlertPromptHook(void) { HMODULE mui_lib; char mui_path[MAX_PATH]; - static char title_str[128], button_str[128]; + static char title_str[2][128], button_str[128]; - if (fp_weh != NULL) + if (ap_weh != NULL) return TRUE; // No need to set again if active // Fetch the localized strings in the relevant MUI @@ -1988,8 +1993,8 @@ BOOL SetFormatPromptHook(void) // 4097 = "You need to format the disk in drive %c: before you can use it." (dialog text) // 4125 = "Microsoft Windows" (dialog title) // 4126 = "Format disk" (button) - if (LoadStringU(mui_lib, 4125, title_str, sizeof(title_str)) > 0) - fp_title_str = title_str; + if (LoadStringU(mui_lib, 4125, title_str[0], sizeof(title_str[0])) > 0) + fp_title_str = title_str[0]; else uprintf("Warning: Could not locate localized format prompt title string in '%s': %s", mui_path, WindowsErrorString()); if (LoadStringU(mui_lib, 4126, button_str, sizeof(button_str)) > 0) @@ -1998,15 +2003,25 @@ BOOL SetFormatPromptHook(void) uprintf("Warning: Could not locate localized format prompt button string in '%s': %s", mui_path, WindowsErrorString()); FreeLibrary(mui_lib); } + static_sprintf(mui_path, "%s\\%s\\urlmon.dll.mui", system_dir, GetCurrentMUI()); + mui_lib = LoadLibraryU(mui_path); + if (mui_lib != NULL) { + // 2070 = "Windows Security Warning" (yes, that's what MS uses for a stupid cookie!) + if (LoadStringU(mui_lib, 2070, title_str[1], sizeof(title_str[1])) > 0) + cp_title_str = title_str[1]; + else + uprintf("Warning: Could not locate localized cookie prompt title string in '%s': %s", mui_path, WindowsErrorString()); + FreeLibrary(mui_lib); + } - fp_weh = SetWinEventHook(EVENT_SYSTEM_FOREGROUND, EVENT_SYSTEM_FOREGROUND, NULL, - FormatPromptHook, 0, 0, WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS); - return (fp_weh != NULL); + ap_weh = SetWinEventHook(EVENT_SYSTEM_FOREGROUND, EVENT_SYSTEM_FOREGROUND, NULL, + AlertPromptHook, 0, 0, WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS); + return (ap_weh != NULL); } -void ClrFormatPromptHook(void) { - UnhookWinEvent(fp_weh); - fp_weh = NULL; +void ClrAlertPromptHook(void) { + UnhookWinEvent(ap_weh); + ap_weh = NULL; } void FlashTaskbar(HANDLE handle)