[ui] display a notice about Secure Boot when UEFI:NTFS is applied

This commit is contained in:
Pete Batard 2018-11-20 12:28:20 +00:00
parent 2ba62fa891
commit 15806de646
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
9 changed files with 98 additions and 37 deletions

View file

@ -61,6 +61,7 @@ PF_TYPE_DECL(NTAPI, NTSTATUS, NtQueryVolumeInformationFile, (HANDLE, PIO_STATUS_
* Globals
*/
RUFUS_DRIVE_INFO SelectedDrive;
BOOL installed_uefi_ntfs;
const char* sfd_name = "Super Floppy Disk";
/*
@ -1250,6 +1251,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
uprintf("Write error: %s", WindowsErrorString());
return FALSE;
}
installed_uefi_ntfs = TRUE;
}
pn++;
}

View file

@ -108,7 +108,7 @@
#define IDC_EXTENDED_LABEL 1015
#define IDC_RUFUS_MBR 1016
#define IDC_TARGET_SYSTEM 1017
#define IDC_PERSISTENCE_SIZE 1118
#define IDC_PERSISTENCE_SIZE 1018
#define IDC_PERSISTENCE_UNITS 1019
#define IDC_DISK_ID 1020
#define IDC_OLD_BIOS_FIXES 1021
@ -140,6 +140,7 @@
#define IDC_LOG_EDIT 1055
#define IDC_LOG_SAVE 1056
#define IDC_LOG_CLEAR 1057
#define IDC_DONT_DISPLAY_AGAIN 1059
#define IDC_MORE_INFO 1060
#define IDC_POLICY 1061
#define IDC_UPDATE_FREQUENCY 1062

View file

@ -104,7 +104,8 @@ BOOL iso_op_in_progress = FALSE, format_op_in_progress = FALSE, right_to_left_mo
BOOL enable_HDDs = FALSE, force_update = FALSE, enable_ntfs_compression = FALSE, no_confirmation_on_cancel = FALSE, lock_drive = TRUE;
BOOL advanced_mode_device, advanced_mode_format, allow_dual_uefi_bios, detect_fakes, enable_vmdk, force_large_fat32, usb_debug;
BOOL use_fake_units, preserve_timestamps = FALSE, fast_zeroing = FALSE, app_changed_size = FALSE;
BOOL zero_drive = FALSE, list_non_usb_removable_drives = FALSE, enable_file_indexing, large_drive = FALSE, write_as_image = FALSE;
BOOL zero_drive = FALSE, list_non_usb_removable_drives = FALSE, enable_file_indexing, large_drive = FALSE;
BOOL write_as_image = FALSE, installed_uefi_ntfs;
uint64_t persistence_size = 0;
float fScale = 1.0f;
int dialog_showing = 0, selection_default = BT_IMAGE, windows_to_go_selection = 0, persistence_unit_selection = -1;
@ -1839,7 +1840,7 @@ static BOOL CheckDriveAccess(DWORD dwTimeOut)
message = GetMuiString("shell32.dll", 28701); // "This drive is in use (...) Do you want to format it anyway?"
if (message != NULL) {
ComboBox_GetTextU(hDeviceList, title, sizeof(title));
proceed = Notification(MSG_WARNING_QUESTION, NULL, title, message);
proceed = Notification(MSG_WARNING_QUESTION, NULL, NULL, title, message);
free(message);
}
}
@ -1884,7 +1885,10 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
case WM_COMMAND:
#ifdef RUFUS_TEST
if (LOWORD(wParam) == IDC_TEST) {
uprintf("CPU ARCH: %d", GetCpuArch());
notification_info more_info;
more_info.id = MORE_INFO_URL;
more_info.url = SECURE_BOOT_MORE_INFO_URL;
Notification(MSG_INFO, SETTING_DISABLE_SECURE_BOOT_NOTICE, &more_info, lmprintf(MSG_128), lmprintf(MSG_129));
break;
}
#endif
@ -2206,6 +2210,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
tt = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem));
fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
write_as_image = FALSE;
installed_uefi_ntfs = FALSE;
// Disable all controls except Cancel
EnableControls(FALSE);
FormatStatus = 0;
@ -2512,7 +2517,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
break;
case UM_NO_UPDATE:
Notification(MSG_INFO, NULL, lmprintf(MSG_243), lmprintf(MSG_247));
Notification(MSG_INFO, NULL, NULL, lmprintf(MSG_243), lmprintf(MSG_247));
// Need to manually set focus back to "Check Now" for tabbing to work
SendMessage(hUpdatesDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hUpdatesDlg, IDC_CHECK_NOW), TRUE);
break;
@ -2617,11 +2622,17 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
PrintInfo(0, MSG_210);
MessageBeep(MB_OK);
FlashTaskbar(dialog_handle);
if (installed_uefi_ntfs && (!ReadSettingBool(SETTING_DISABLE_SECURE_BOOT_NOTICE))) {
notification_info more_info;
more_info.id = MORE_INFO_URL;
more_info.url = SECURE_BOOT_MORE_INFO_URL;
Notification(MSG_INFO, SETTING_DISABLE_SECURE_BOOT_NOTICE, &more_info, lmprintf(MSG_128), lmprintf(MSG_129));
}
} else if (SCODE_CODE(FormatStatus) == ERROR_CANCELLED) {
SendMessage(hProgress, PBM_SETSTATE, (WPARAM)PBST_PAUSED, 0);
SetTaskbarProgressState(TASKBAR_PAUSED);
PrintInfo(0, MSG_211);
Notification(MSG_INFO, NULL, lmprintf(MSG_211), lmprintf(MSG_041));
Notification(MSG_INFO, NULL, NULL, lmprintf(MSG_211), lmprintf(MSG_041));
} else {
SendMessage(hProgress, PBM_SETSTATE, (WPARAM)PBST_ERROR, 0);
SetTaskbarProgressState(TASKBAR_ERROR);
@ -2660,7 +2671,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
break;
}
}
Notification(MSG_ERROR, NULL, lmprintf(MSG_042), lmprintf(MSG_043, StrError(FormatStatus, FALSE)));
Notification(MSG_ERROR, NULL, NULL, lmprintf(MSG_042), lmprintf(MSG_043, StrError(FormatStatus, FALSE)));
}
}
FormatStatus = 0;

View file

@ -72,6 +72,7 @@
#define MAX_GPT_PARTITIONS 128
#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 MORE_INFO_URL 0xFFFF
#define STATUS_MSG_TIMEOUT 3500 // How long should cheat mode messages appear for on the status bar
#define WRITE_RETRIES 4
#define WRITE_TIMEOUT 5000 // How long we should wait between write retries
@ -100,6 +101,7 @@
#endif
#define DOWNLOAD_URL RUFUS_URL "/downloads"
#define FILES_URL RUFUS_URL "/files"
#define SECURE_BOOT_MORE_INFO_URL "https://github.com/pbatard/rufus/wiki/FAQ#Why_do_I_need_to_disable_Secure_Boot_to_use_UEFINTFS"
#define SEVENZIP_URL "https://www.7-zip.org"
#define FILES_DIR "rufus_files"
#define IGNORE_RETVAL(expr) do { (void)(expr); } while(0)
@ -197,7 +199,10 @@ enum notification_type {
typedef INT_PTR (CALLBACK *Callback_t)(HWND, UINT, WPARAM, LPARAM);
typedef struct {
WORD id;
Callback_t callback;
union {
Callback_t callback;
char* url;
};
} notification_info; // To provide a "More info..." on notifications
/* Status Bar sections */
@ -481,7 +486,7 @@ extern INT_PTR CreateAboutBox(void);
extern BOOL CreateTooltip(HWND hControl, const char* message, int duration);
extern void DestroyTooltip(HWND hWnd);
extern void DestroyAllTooltips(void);
extern BOOL Notification(int type, const notification_info* more_info, char* title, char* format, ...);
extern BOOL Notification(int type, const char* dont_display_setting, const notification_info* more_info, char* title, char* format, ...);
extern int SelectionDialog(char* title, char* message, char** choices, int size);
extern void ListDialog(char* title, char* message, char** items, int size);
extern SIZE GetTextSize(HWND hCtrl, char* txt);

View file

@ -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.4.1423"
CAPTION "Rufus 3.4.1424"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -129,7 +129,7 @@ BEGIN
DEFPUSHBUTTON "Close",IDCANCEL,306,305,50,12
END
IDD_NOTIFICATION DIALOGEX 0, 0, 263, 59
IDD_NOTIFICATION DIALOGEX 0, 0, 263, 73
STYLE DS_SETFONT | DS_NOFAILCREATE | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_THICKFRAME
CAPTION "Rufus"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
@ -138,9 +138,11 @@ BEGIN
LTEXT "",IDC_STATIC,0,0,263,34
ICON OCR_UP,IDC_NOTIFICATION_ICON,6,6,20,20
LTEXT "Message",IDC_NOTIFICATION_TEXT,35,6,219,20
DEFPUSHBUTTON "No",IDNO,206,40,50,14
PUSHBUTTON "More information",IDC_MORE_INFO,8,40,76,14,NOT WS_VISIBLE
PUSHBUTTON "Yes",IDYES,149,40,50,14,NOT WS_VISIBLE
DEFPUSHBUTTON "No",IDNO,205,53,50,14
PUSHBUTTON "More information",IDC_MORE_INFO,8,53,76,14,NOT WS_VISIBLE
PUSHBUTTON "Yes",IDYES,148,53,50,14,NOT WS_VISIBLE
CONTROL "Do not show this message again",IDC_DONT_DISPLAY_AGAIN,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,39,248,10,WS_EX_TRANSPARENT
END
IDD_SELECTION DIALOGEX 0, 0, 312, 71
@ -392,8 +394,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,4,1423,0
PRODUCTVERSION 3,4,1423,0
FILEVERSION 3,4,1424,0
PRODUCTVERSION 3,4,1424,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -411,13 +413,13 @@ BEGIN
VALUE "Comments", "https://akeo.ie"
VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.4.1423"
VALUE "FileVersion", "3.4.1424"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2018 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus-3.4.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.4.1423"
VALUE "ProductVersion", "3.4.1424"
END
END
BLOCK "VarFileInfo"

View file

@ -34,6 +34,7 @@ extern char* ini_file;
#define SETTING_COMM_CHECK "CommCheck64"
#define SETTING_LOCALE "Locale"
#define SETTING_DISABLE_LGP "DisableLGP"
#define SETTING_DISABLE_SECURE_BOOT_NOTICE "DisableSecureBootNotice"
#define SETTING_ADVANCED_MODE "AdvancedMode"
#define SETTING_ADVANCED_MODE_DEVICE "ShowAdvancedDriveProperties"

View file

@ -31,6 +31,8 @@
#include <shlobj.h>
#include <commdlg.h>
#include <richedit.h>
#undef NDEBUG
#include <assert.h>
#include "rufus.h"
#include "missing.h"
@ -55,6 +57,7 @@ static WNDPROC pOrgBrowseWndproc;
static const SETTEXTEX friggin_microsoft_unicode_amateurs = {ST_DEFAULT, CP_UTF8};
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 char *fp_title_str = "Microsoft Windows", *fp_button_str = "Format disk";
@ -659,11 +662,11 @@ INT_PTR CreateAboutBox(void)
INT_PTR CALLBACK NotificationCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
LRESULT loc;
int i, dh;
int i, dh, cbh = 0;
// Prevent resizing
static LRESULT disabled[9] = { HTLEFT, HTRIGHT, HTTOP, HTBOTTOM, HTSIZE,
HTTOPLEFT, HTTOPRIGHT, HTBOTTOMLEFT, HTBOTTOMRIGHT };
static HBRUSH background_brush, separator_brush;
static HBRUSH background_brush, separator_brush, buttonface_brush;
// To use the system message font
NONCLIENTMETRICS ncm;
HFONT hDlgFont;
@ -677,9 +680,9 @@ INT_PTR CALLBACK NotificationCallback(HWND hDlg, UINT message, WPARAM wParam, LP
ncm.cbSize = sizeof(ncm);
// If we're compiling with the Vista SDK or later, the NONCLIENTMETRICS struct
// will be the wrong size for previous versions, so we need to adjust it.
#if defined(_MSC_VER) && (_MSC_VER >= 1500) && (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
#if defined(_MSC_VER) && (_MSC_VER >= 1500) && (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
ncm.cbSize -= sizeof(ncm.iPaddedBorderWidth);
#endif
#endif
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
hDlgFont = CreateFontIndirect(&(ncm.lfMessageFont));
// Set the dialog to use the system message box font
@ -697,6 +700,7 @@ INT_PTR CALLBACK NotificationCallback(HWND hDlg, UINT message, WPARAM wParam, LP
apply_localization(IDD_NOTIFICATION, hDlg);
background_brush = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
separator_brush = CreateSolidBrush(GetSysColor(COLOR_3DLIGHT));
buttonface_brush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
SetTitleBarIcon(hDlg);
CenterDialog(hDlg);
// Change the default icon
@ -713,6 +717,16 @@ INT_PTR CALLBACK NotificationCallback(HWND hDlg, UINT message, WPARAM wParam, LP
} else {
ShowWindow(GetDlgItem(hDlg, IDYES), SW_SHOW);
}
hCtrl = GetDlgItem(hDlg, IDC_DONT_DISPLAY_AGAIN);
if (notification_dont_display_setting != NULL) {
SetWindowTextU(hCtrl, lmprintf(MSG_127));
} else {
// Remove the "Don't display again" checkbox
ShowWindow(hCtrl, SW_HIDE);
GetWindowRect(hCtrl, &rc);
MapWindowPoints(NULL, hDlg, (POINT*)&rc, 2);
cbh = rc.bottom - rc.top;
}
if ((notification_more_info != NULL) && (notification_more_info->callback != NULL)) {
hCtrl = GetDlgItem(hDlg, IDC_MORE_INFO);
// Resize the 'More information' button
@ -731,17 +745,16 @@ INT_PTR CALLBACK NotificationCallback(HWND hDlg, UINT message, WPARAM wParam, LP
GetWindowRect(hCtrl, &rc);
dh = rc.bottom - rc.top;
DrawTextU(hDC, szMessageText, -1, &rc, DT_CALCRECT | DT_WORDBREAK);
dh = rc.bottom - rc.top - dh + (int)(8.0f * fScale);
dh = max(rc.bottom - rc.top - dh + (int)(8.0f * fScale), 0);
safe_release_dc(hCtrl, hDC);
if (dh > 0) {
ResizeMoveCtrl(hDlg, hCtrl, 0, 0, 0, dh, 1.0f);
ResizeMoveCtrl(hDlg, hDlg, 0, 0, 0, dh, 1.0f);
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, -1), 0, 0, 0, dh, 1.0f); // IDC_STATIC = -1
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_SELECTION_LINE), 0, dh, 0, 0, 1.0f);
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_MORE_INFO), 0, dh, 0, 0, 1.0f);
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDYES), 0, dh, 0, 0, 1.0f);
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDNO), 0, dh, 0, 0, 1.0f);
}
ResizeMoveCtrl(hDlg, hCtrl, 0, 0, 0, dh, 1.0f);
ResizeMoveCtrl(hDlg, hDlg, 0, 0, 0, dh - cbh, 1.0f);
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, -1), 0, 0, 0, dh, 1.0f); // IDC_STATIC = -1
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_SELECTION_LINE), 0, dh, 0, 0, 1.0f);
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_DONT_DISPLAY_AGAIN), 0, dh, 0, 0, 1.0f);
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_MORE_INFO), 0, dh - cbh, 0, 0, 1.0f);
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDYES), 0, dh -cbh, 0, 0, 1.0f);
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDNO), 0, dh -cbh, 0, 0, 1.0f);
}
return (INT_PTR)TRUE;
case WM_CTLCOLORSTATIC:
@ -750,6 +763,9 @@ INT_PTR CALLBACK NotificationCallback(HWND hDlg, UINT message, WPARAM wParam, LP
if ((HWND)lParam == GetDlgItem(hDlg, IDC_NOTIFICATION_LINE)) {
return (INT_PTR)separator_brush;
}
if ((HWND)lParam == GetDlgItem(hDlg, IDC_DONT_DISPLAY_AGAIN)) {
return (INT_PTR)buttonface_brush;
}
return (INT_PTR)background_brush;
case WM_NCHITTEST:
// Check coordinates to prevent resize actions
@ -766,11 +782,20 @@ INT_PTR CALLBACK NotificationCallback(HWND hDlg, UINT message, WPARAM wParam, LP
case IDCANCEL:
case IDYES:
case IDNO:
if (IsDlgButtonChecked(hDlg, IDC_DONT_DISPLAY_AGAIN) == BST_CHECKED) {
WriteSettingBool(SETTING_DISABLE_SECURE_BOOT_NOTICE, TRUE);
}
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
case IDC_MORE_INFO:
if (notification_more_info != NULL)
MyDialogBox(hMainInstance, notification_more_info->id, hDlg, notification_more_info->callback);
assert(notification_more_info->callback != NULL);
if (notification_more_info != NULL) {
if (notification_more_info->id == MORE_INFO_URL) {
ShellExecuteA(hDlg, "open", notification_more_info->url, NULL, NULL, SW_SHOWNORMAL);
} else {
MyDialogBox(hMainInstance, notification_more_info->id, hDlg, notification_more_info->callback);
}
}
break;
}
break;
@ -781,7 +806,7 @@ INT_PTR CALLBACK NotificationCallback(HWND hDlg, UINT message, WPARAM wParam, LP
/*
* Display a custom notification
*/
BOOL Notification(int type, const notification_info* more_info, char* title, char* format, ...)
BOOL Notification(int type, const char* dont_display_setting, const notification_info* more_info, char* title, char* format, ...)
{
BOOL ret;
va_list args;
@ -800,6 +825,7 @@ BOOL Notification(int type, const notification_info* more_info, char* title, cha
szMessageText[max_msg_size -1] = 0;
notification_more_info = more_info;
notification_is_question = FALSE;
notification_dont_display_setting = dont_display_setting;
switch(type) {
case MSG_WARNING_QUESTION:
@ -1478,7 +1504,6 @@ BOOL SetUpdateCheck(void)
{
BOOL enable_updates;
uint64_t commcheck = GetTickCount64();
notification_info more_info = { IDD_UPDATE_POLICY, UpdateCallback };
char filename[MAX_PATH] = "", exename[] = APPLICATION_NAME ".exe";
size_t fn_len, exe_len;
@ -1489,6 +1514,7 @@ BOOL SetUpdateCheck(void)
// If the update interval is not set, this is the first time we run so prompt the user
if (ReadSetting32(SETTING_UPDATE_INTERVAL) == 0) {
notification_info more_info;
// Add a hack for people who'd prefer the app not to prompt about update settings on first run.
// If the executable is called "rufus.exe", without version, we disable the prompt
@ -1501,7 +1527,9 @@ BOOL SetUpdateCheck(void)
enable_updates = TRUE;
} else {
#endif
enable_updates = Notification(MSG_QUESTION, &more_info, lmprintf(MSG_004), lmprintf(MSG_005));
more_info.id = IDD_UPDATE_POLICY;
more_info.callback = UpdateCallback;
enable_updates = Notification(MSG_QUESTION, NULL, &more_info, lmprintf(MSG_004), lmprintf(MSG_005));
#if !defined(_DEBUG)
}
#endif