1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[ui] add cheat mode (Alt-M) to ignore Boot Marker

This commit is contained in:
Pete Batard 2020-11-12 17:38:20 +00:00
parent 77b0d1d366
commit 35b0ab2470
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
8 changed files with 38 additions and 21 deletions

View file

@ -23,6 +23,7 @@ o v3.*
- *NEW* MSG_317 "Disk ID"
// The following can be tested with <Alt>-<+> and <Alt>-<->
- *NEW* MSG_318 "Default thread priority: %d"
- *NEW* MSG_319 "Ignore Boot Marker"
o v3.5 (2019.03.12)
The following 3 messages can be tested by creating a UEFI:NTFS drive in Rufus ('Show advanced drive properties' must be enabled

View file

@ -578,6 +578,7 @@ t MSG_315 "Multiple buttons"
t MSG_316 "Number of passes"
t MSG_317 "Disk ID"
t MSG_318 "Default thread priority: %d"
t MSG_319 "Ignore Boot Marker"
#########################################################################
l "ar-SA" "Arabic (العربية)" 0x0401, 0x0801, 0x0c01, 0x1001, 0x1401, 0x1801, 0x1c01, 0x2001, 0x2401, 0x2801, 0x2c01, 0x3001, 0x3401, 0x3801, 0x3c01, 0x4001

View file

@ -1293,7 +1293,6 @@ const struct {int (*fn)(FILE *fp); char* str;} known_mbr[] = {
// Returns TRUE if the drive seems bootable, FALSE otherwise
BOOL AnalyzeMBR(HANDLE hPhysicalDrive, const char* TargetName, BOOL bSilent)
{
const char* mbr_name = "Master Boot Record";
FAKE_FD fake_fd = { 0 };
FILE* fp = (FILE*)&fake_fd;
int i;
@ -1302,17 +1301,17 @@ BOOL AnalyzeMBR(HANDLE hPhysicalDrive, const char* TargetName, BOOL bSilent)
set_bytes_per_sector(SelectedDrive.SectorSize);
if (!is_br(fp)) {
suprintf("%s does not have an x86 %s", TargetName, mbr_name);
suprintf("%s does not have a Boot Marker", TargetName);
return FALSE;
}
for (i=0; i<ARRAYSIZE(known_mbr); i++) {
if (known_mbr[i].fn(fp)) {
suprintf("%s has a %s %s", TargetName, known_mbr[i].str, mbr_name);
suprintf("%s has a %s Master Boot Record", TargetName, known_mbr[i].str);
return TRUE;
}
}
suprintf("%s has an unknown %s", TargetName, mbr_name);
suprintf("%s has an unknown Master Boot Record", TargetName);
return TRUE;
}

View file

@ -119,7 +119,7 @@ BOOL enable_HDDs = FALSE, enable_VHDs = TRUE, enable_ntfs_compression = FALSE, n
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;
BOOL write_as_image = FALSE, write_as_esp = FALSE, installed_uefi_ntfs = FALSE, use_vds = FALSE;
BOOL write_as_image = FALSE, write_as_esp = FALSE, installed_uefi_ntfs = FALSE, use_vds = FALSE, ignore_boot_marker = FALSE;
BOOL windows_to_go_selected = FALSE;
float fScale = 1.0f;
int dialog_showing = 0, selection_default = BT_IMAGE, persistence_unit_selection = -1;
@ -1209,7 +1209,7 @@ DWORD WINAPI ImageScanThread(LPVOID param)
EnableControls(FALSE, FALSE);
memset(&img_report, 0, sizeof(img_report));
img_report.is_iso = (BOOLEAN)ExtractISO(image_path, "", TRUE);
img_report.is_bootable_img = (BOOLEAN)IsBootableImage(image_path);
img_report.is_bootable_img = IsBootableImage(image_path);
ComboBox_ResetContent(hImageOption);
if ((FormatStatus == (ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_CANCELLED)) ||
@ -1224,6 +1224,7 @@ DWORD WINAPI ImageScanThread(LPVOID param)
PrintInfoDebug(0, MSG_203);
PrintStatus(0, MSG_203);
EnableControls(TRUE, FALSE);
MessageBoxExU(hMainDialog, lmprintf(MSG_082), lmprintf(MSG_081), MB_OK | MB_ICONINFORMATION | MB_IS_RTL, selected_langid);
goto out;
}
@ -1247,8 +1248,11 @@ DWORD WINAPI ImageScanThread(LPVOID param)
}
uprintf(" Image is %sa UEFI bootable Windows installation image", img_report.has_efi ? "" : "NOT ");
} else if (img_report.is_bootable_img) {
uprintf(" Image is a %sbootable %s image",
(img_report.compression_type != BLED_COMPRESSION_NONE) ? "compressed " : "", img_report.is_vhd ? "VHD" : "disk");
if (img_report.is_bootable_img == 2)
uprintf(" Image is a FORCED non-bootable image");
else
uprintf(" Image is a %sbootable %s image",
(img_report.compression_type != BLED_COMPRESSION_NONE) ? "compressed " : "", img_report.is_vhd ? "VHD" : "disk");
selection_default = BT_IMAGE;
}
@ -3295,6 +3299,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
enable_file_indexing = ReadSettingBool(SETTING_ENABLE_FILE_INDEXING);
enable_VHDs = !ReadSettingBool(SETTING_DISABLE_VHDS);
enable_extra_hashes = ReadSettingBool(SETTING_ENABLE_EXTRA_HASHES);
ignore_boot_marker = ReadSettingBool(SETTING_IGNORE_BOOT_MARKER);
// We want above normal priority by default, so we offset the value.
default_thread_priority = ReadSetting32(SETTING_DEFAULT_THREAD_PRIORITY) + THREAD_PRIORITY_ABOVE_NORMAL;
@ -3464,7 +3469,7 @@ relaunch:
while(GetMessage(&msg, NULL, 0, 0)) {
static BOOL ctrl_without_focus = FALSE;
BOOL no_focus = (msg.message == WM_SYSKEYDOWN) && !(msg.lParam & 0x20000000);
// ** *********** ***************
// ** ***************************
// .,ABCDEFGHIJKLMNOPQRSTUVWXYZ+-
// Sigh... The things one need to do to detect standalone use of the 'Alt' key.
@ -3645,6 +3650,14 @@ relaunch:
GetDevices(0);
continue;
}
// Alt-M => Toggle the check for the 0x55 0xAA boot marker at offset 0x1fe.
// This means that Rufus treats anything selected as a writeable DD image.
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'M')) {
ignore_boot_marker = !ignore_boot_marker;
WriteSettingBool(SETTING_IGNORE_BOOT_MARKER, ignore_boot_marker);
PrintStatusTimeout(lmprintf(MSG_319), ignore_boot_marker);
continue;
}
// Alt N => Enable NTFS compression
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'N')) {
enable_ntfs_compression = !enable_ntfs_compression;

View file

@ -343,7 +343,7 @@ typedef struct {
int64_t mismatch_size;
uint32_t wininst_version;
BOOLEAN is_iso;
BOOLEAN is_bootable_img;
uint8_t is_bootable_img;
BOOLEAN is_vhd;
BOOLEAN is_windows_img;
BOOLEAN disable_iso;
@ -567,7 +567,7 @@ extern BOOL WimExtractFile(const char* wim_image, int index, const char* src, co
extern BOOL WimExtractFile_API(const char* image, int index, const char* src, const char* dst, BOOL bSilent);
extern BOOL WimExtractFile_7z(const char* image, int index, const char* src, const char* dst, BOOL bSilent);
extern BOOL WimApplyImage(const char* image, int index, const char* dst);
extern BOOL IsBootableImage(const char* path);
extern uint8_t IsBootableImage(const char* path);
extern BOOL AppendVHDFooter(const char* vhd_path);
extern int SetWinToGoIndex(void);
extern int IsHDD(DWORD DriveIndex, uint16_t vid, uint16_t pid, const char* strid);

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.13.1723"
CAPTION "Rufus 3.13.1724"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -395,8 +395,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,13,1723,0
PRODUCTVERSION 3,13,1723,0
FILEVERSION 3,13,1724,0
PRODUCTVERSION 3,13,1724,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -414,13 +414,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.13.1723"
VALUE "FileVersion", "3.13.1724"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2020 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-3.13.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.13.1723"
VALUE "ProductVersion", "3.13.1724"
END
END
BLOCK "VarFileInfo"

View file

@ -42,6 +42,7 @@ extern char* ini_file;
#define SETTING_ENABLE_VMDK_DETECTION "EnableVmdkDetection"
#define SETTING_ENABLE_WIN_DUAL_EFI_BIOS "EnableWindowsDualUefiBiosMode"
#define SETTING_FORCE_LARGE_FAT32_FORMAT "ForceLargeFat32Formatting"
#define SETTING_IGNORE_BOOT_MARKER "IgnoreBootMarker"
#define SETTING_INCLUDE_BETAS "CheckForBetas"
#define SETTING_LAST_UPDATE "LastUpdateCheck"
#define SETTING_LOCALE "Locale"

View file

@ -111,6 +111,7 @@ PF_TYPE_DECL(RPC_ENTRY, RPC_STATUS, UuidCreate, (UUID __RPC_FAR*));
uint32_t wim_nb_files, wim_proc_files, wim_extra_files;
HANDLE apply_wim_thread = NULL;
extern int default_thread_priority;
extern BOOL ignore_boot_marker;
static uint8_t wim_flags = 0;
static wchar_t wmount_path[MAX_PATH] = { 0 };
@ -277,7 +278,8 @@ BOOL IsCompressedBootableImage(const char* path)
return FALSE;
}
BOOL IsBootableImage(const char* path)
// 0: non-bootable, 1: bootable, 2: forced bootable
uint8_t IsBootableImage(const char* path)
{
HANDLE handle = INVALID_HANDLE_VALUE;
LARGE_INTEGER liImageSize;
@ -287,7 +289,7 @@ BOOL IsBootableImage(const char* path)
uint32_t checksum, old_checksum;
uint64_t wim_magic = 0;
LARGE_INTEGER ptr = { 0 };
BOOL is_bootable_img = FALSE;
uint8_t is_bootable_img = 0;
uprintf("Disk image analysis:");
handle = CreateFileU(path, GENERIC_READ, FILE_SHARE_READ, NULL,
@ -297,9 +299,9 @@ BOOL IsBootableImage(const char* path)
goto out;
}
is_bootable_img = (BOOLEAN)IsCompressedBootableImage(path);
is_bootable_img = IsCompressedBootableImage(path) ? 1 : 0;
if (img_report.compression_type == BLED_COMPRESSION_NONE)
is_bootable_img = (BOOLEAN)AnalyzeMBR(handle, " Image", FALSE);
is_bootable_img = AnalyzeMBR(handle, " Image", FALSE) ? 1 : (ignore_boot_marker ? 2 : 0);
if (!GetFileSizeEx(handle, &liImageSize)) {
uprintf(" Could not get image size: %s", WindowsErrorString());
@ -326,7 +328,7 @@ BOOL IsBootableImage(const char* path)
if ( (bswap_uint32(footer->file_format_version) != VHD_FOOTER_FILE_FORMAT_V1_0)
|| (bswap_uint32(footer->disk_type) != VHD_FOOTER_TYPE_FIXED_HARD_DISK)) {
uprintf(" Unsupported type of VHD image");
is_bootable_img = FALSE;
is_bootable_img = 0;
goto out;
}
// Might as well validate the checksum while we're at it