diff --git a/.vs/ms-sys.vcxproj b/.vs/ms-sys.vcxproj
index 23c3d70f..eeb5fc36 100644
--- a/.vs/ms-sys.vcxproj
+++ b/.vs/ms-sys.vcxproj
@@ -70,11 +70,11 @@
-
+
diff --git a/.vs/ms-sys.vcxproj.filters b/.vs/ms-sys.vcxproj.filters
index c714b2af..d8dc4d00 100644
--- a/.vs/ms-sys.vcxproj.filters
+++ b/.vs/ms-sys.vcxproj.filters
@@ -152,10 +152,10 @@
Header Files
-
+
Header Files
-
+
Header Files
diff --git a/src/format.c b/src/format.c
index 3ac72469..ca845f11 100644
--- a/src/format.c
+++ b/src/format.c
@@ -764,17 +764,15 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive)
FILE* fp = (FILE*)&fake_fd;
const char* using_msg = "Using %s MBR";
-// AnalyzeMBR(hPhysicalDrive, "Drive", FALSE);
-
if (SelectedDrive.SectorSize < 512)
goto out;
if (partition_type == PARTITION_STYLE_GPT) {
- // Add a notice in the protective MBR
+ // Add a notice with a protective MBR
fake_fd._handle = (char*)hPhysicalDrive;
set_bytes_per_sector(SelectedDrive.SectorSize);
uprintf(using_msg, "Rufus protective");
- r = write_rufus_gpt_mbr(fp);
+ r = write_rufus_msg_mbr(fp);
goto notify;
}
@@ -907,14 +905,11 @@ static BOOL WriteSBR(HANDLE hPhysicalDrive)
FAKE_FD fake_fd = { 0 };
FILE* fp = (FILE*)&fake_fd;
- if (partition_type == PARTITION_STYLE_GPT)
- return TRUE;
-
fake_fd._handle = (char*)hPhysicalDrive;
set_bytes_per_sector(SelectedDrive.SectorSize);
// Ensure that we have sufficient space for the SBR
max_size = IsChecked(IDC_OLD_BIOS_FIXES) ?
- (DWORD)(SelectedDrive.SectorsPerTrack * SelectedDrive.SectorSize) : 1*MB;
+ (DWORD)(SelectedDrive.SectorsPerTrack * SelectedDrive.SectorSize) : 1 * MB;
max_size -= mbr_size;
// Syslinux has precedence over Grub
if ((boot_type == BT_IMAGE) && (!HAS_SYSLINUX(img_report))) {
@@ -922,6 +917,8 @@ static BOOL WriteSBR(HANDLE hPhysicalDrive)
sub_type = BT_GRUB4DOS;
if (img_report.has_grub2)
sub_type = BT_GRUB2;
+ } else if (partition_type == PARTITION_STYLE_GPT) {
+ sub_type = BT_NON_BOOTABLE;
}
switch (sub_type) {
@@ -950,6 +947,15 @@ static BOOL WriteSBR(HANDLE hPhysicalDrive)
}
}
break;
+ case BT_NON_BOOTABLE:
+ uprintf("Writing protective message SBR");
+ size = 4 * KB;
+ buf = GetResource(hMainInstance, MAKEINTRESOURCEA(IDR_SBR_MSG), _RT_RCDATA, "msg.txt", &size, TRUE);
+ if (buf == NULL) {
+ uprintf("Could not access message");
+ return FALSE;
+ }
+ break;
default:
// No need to write secondary block
return TRUE;
@@ -961,6 +967,8 @@ static BOOL WriteSBR(HANDLE hPhysicalDrive)
}
r = write_data(fp, mbr_size, buf, (uint64_t)size);
safe_free(grub2_buf);
+ if (sub_type == BT_NON_BOOTABLE)
+ safe_free(buf);
return (r != 0);
}
@@ -1009,7 +1017,7 @@ BOOL WritePBR(HANDLE hLogicalVolume)
return TRUE;
case FS_FAT32:
uprintf(using_msg, bt_to_name(), "FAT32");
- for (i=0; i<2; i++) {
+ for (i = 0; i < 2; i++) {
if (!is_fat_32_fs(fp)) {
uprintf("New volume does not have a %s FAT32 boot sector - aborting\n", i?"secondary":"primary");
break;
diff --git a/src/ms-sys/br.c b/src/ms-sys/br.c
index ef7ed8bb..c432e422 100644
--- a/src/ms-sys/br.c
+++ b/src/ms-sys/br.c
@@ -148,14 +148,14 @@ int is_rufus_mbr(FILE *fp)
is_br(fp);
} /* is_rufus_mbr */
-int is_rufus_gpt_mbr(FILE *fp)
+int is_rufus_msg_mbr(FILE *fp)
{
-#include "mbr_gpt_rufus.h"
+#include "mbr_msg_rufus.h"
return
- contains_data(fp, 0x0, mbr_gpt_rufus_0x0, sizeof(mbr_gpt_rufus_0x0)) &&
+ contains_data(fp, 0x0, mbr_msg_rufus_0x0, sizeof(mbr_msg_rufus_0x0)) &&
is_br(fp);
-} /* is_rufus_gpt_mbr */
+} /* is_rufus_msg_mbr */
int is_reactos_mbr(FILE *fp)
{
@@ -298,14 +298,14 @@ int write_rufus_mbr(FILE *fp)
write_bootmark(fp);
} /* write_rufus_mbr */
-int write_rufus_gpt_mbr(FILE *fp)
+int write_rufus_msg_mbr(FILE *fp)
{
-#include "mbr_gpt_rufus.h"
+#include "mbr_msg_rufus.h"
return
- write_data(fp, 0x0, mbr_gpt_rufus_0x0, sizeof(mbr_gpt_rufus_0x0)) &&
+ write_data(fp, 0x0, mbr_msg_rufus_0x0, sizeof(mbr_msg_rufus_0x0)) &&
write_bootmark(fp);
-} /* write_rufus_gpt_mbr */
+} /* write_rufus_msg_mbr */
int write_reactos_mbr(FILE *fp)
{
diff --git a/src/ms-sys/inc/br.h b/src/ms-sys/inc/br.h
index a4e3e9d1..98cc3826 100644
--- a/src/ms-sys/inc/br.h
+++ b/src/ms-sys/inc/br.h
@@ -111,9 +111,9 @@ int write_win7_mbr(FILE *fp);
FALSE */
int write_rufus_mbr(FILE *fp);
-/* Writes a Rufus GPT master boot record to a file, returns TRUE on success, otherwise
+/* Writes a Rufus MSG master boot record to a file, returns TRUE on success, otherwise
FALSE */
-int write_rufus_gpt_mbr(FILE *fp);
+int write_rufus_msg_mbr(FILE *fp);
/* Writes a ReactOS master boot record to a file, returns TRUE on success, otherwise
FALSE */
diff --git a/src/ms-sys/inc/mbr_gpt_rufus.h b/src/ms-sys/inc/mbr_gpt_rufus.h
deleted file mode 100644
index 2893d263..00000000
--- a/src/ms-sys/inc/mbr_gpt_rufus.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Rufus Protective MBR for GPT systems
- * https://github.com/pbatard/rufus/tree/master/res/mbr
- * Copyright © 2019 Pete Batard
- */
-
-unsigned char mbr_gpt_rufus_0x0[] = {
- 0x41, 0x4B, 0x45, 0x4F, 0xFC, 0x31, 0xC0, 0x8E, 0xD8, 0xBE, 0x31, 0x7C,
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x74,
- 0x20, 0x69, 0x6E, 0x20, 0x42, 0x49, 0x4F, 0x53, 0x2F, 0x4C, 0x65, 0x67,
- 0x61, 0x63, 0x79, 0x20, 0x6D, 0x6F, 0x64, 0x65, 0x2E, 0x0D, 0x0A, 0x0D,
- 0x0A, 0x49, 0x66, 0x20, 0x79, 0x6F, 0x75, 0x20, 0x77, 0x61, 0x6E, 0x74,
- 0x20, 0x74, 0x6F, 0x20, 0x62, 0x6F, 0x6F, 0x74, 0x20, 0x74, 0x68, 0x69,
- 0x73, 0x20, 0x64, 0x72, 0x69, 0x76, 0x65, 0x20, 0x69, 0x6E, 0x20, 0x42,
- 0x49, 0x4F, 0x53, 0x2F, 0x4C, 0x65, 0x67, 0x61, 0x63, 0x79, 0x20, 0x6D,
- 0x6F, 0x64, 0x65, 0x2C, 0x20, 0x79, 0x6F, 0x75, 0x0D, 0x0A, 0x73, 0x68,
- 0x6F, 0x75, 0x6C, 0x64, 0x20, 0x72, 0x65, 0x63, 0x72, 0x65, 0x61, 0x74,
- 0x65, 0x20, 0x69, 0x74, 0x20, 0x69, 0x6E, 0x20, 0x52, 0x75, 0x66, 0x75,
- 0x73, 0x20, 0x75, 0x73, 0x69, 0x6E, 0x67, 0x20, 0x74, 0x68, 0x65, 0x20,
- 0x66, 0x6F, 0x6C, 0x6C, 0x6F, 0x77, 0x69, 0x6E, 0x67, 0x20, 0x73, 0x65,
- 0x74, 0x74, 0x69, 0x6E, 0x67, 0x73, 0x3A, 0x0D, 0x0A, 0x2A, 0x20, 0x50,
- 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x73, 0x63, 0x68,
- 0x65, 0x6D, 0x65, 0x20, 0x2D, 0x3E, 0x20, 0x4D, 0x42, 0x52, 0x0D, 0x0A,
- 0x2A, 0x20, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x20, 0x73, 0x79, 0x73,
- 0x74, 0x65, 0x6D, 0x20, 0x2D, 0x3E, 0x20, 0x42, 0x49, 0x4F, 0x53, 0x2E,
- 0x2E, 0x2E, 0x0D, 0x0A, 0x00
-};
diff --git a/src/ms-sys/inc/mbr_msg_rufus.h b/src/ms-sys/inc/mbr_msg_rufus.h
new file mode 100644
index 00000000..3c5948cd
--- /dev/null
+++ b/src/ms-sys/inc/mbr_msg_rufus.h
@@ -0,0 +1,46 @@
+/*
+ * Rufus message MBR - Displays an ASCII text message contained in the
+ * next 4 KB of sectors that follow.
+ * See https://github.com/pbatard/rufus/tree/master/res/mbr
+ * Copyright © 2019-2020 Pete Batard
+ */
+
+unsigned char mbr_msg_rufus_0x0[] = {
+ 0x41, 0x4B, 0x45, 0x4F, 0xFC, 0x31, 0xC0, 0xFA, 0x8E, 0xD0, 0xBC, 0x00,
+ 0x7C, 0xFB, 0x8E, 0xD8, 0xBB, 0x13, 0x04, 0x8B, 0x07, 0x83, 0xE8, 0x04,
+ 0x89, 0x07, 0xC1, 0xE0, 0x06, 0x8E, 0xC0, 0xB7, 0x07, 0xB8, 0x7F, 0x00,
+ 0xCD, 0x10, 0x31, 0xDB, 0x31, 0xC9, 0xBA, 0x4F, 0x18, 0xB8, 0x00, 0x06,
+ 0xCD, 0x10, 0x31, 0xD2, 0xB4, 0x02, 0xCD, 0x10, 0xB4, 0x41, 0xBB, 0xAA,
+ 0x55, 0xCD, 0x13, 0x72, 0x29, 0x81, 0xFB, 0x55, 0xAA, 0x75, 0x23, 0xF7,
+ 0xC1, 0x01, 0x00, 0x74, 0x1D, 0x66, 0x31, 0xC0, 0x66, 0x50, 0x66, 0x40,
+ 0x66, 0x50, 0x06, 0x6A, 0x00, 0x6A, 0x08, 0x6A, 0x10, 0x89, 0xE6, 0xB4,
+ 0x42, 0xCD, 0x13, 0x9F, 0x83, 0xC4, 0x10, 0x9E, 0xEB, 0x0D, 0xB8, 0x08,
+ 0x02, 0xB9, 0x02, 0x00, 0xBA, 0x80, 0x00, 0x31, 0xDB, 0xCD, 0x13, 0xBB,
+ 0x07, 0x00, 0x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2A,
+ 0x2A, 0x2A, 0x20, 0x45, 0x52, 0x52, 0x4F, 0x52, 0x3A, 0x20, 0x54, 0x48,
+ 0x49, 0x53, 0x20, 0x4D, 0x45, 0x44, 0x49, 0x41, 0x20, 0x43, 0x41, 0x4E,
+ 0x4E, 0x4F, 0x54, 0x20, 0x42, 0x4F, 0x4F, 0x54, 0x20, 0x49, 0x4E, 0x20,
+ 0x4C, 0x45, 0x47, 0x41, 0x43, 0x59, 0x20, 0x4D, 0x4F, 0x44, 0x45, 0x20,
+ 0x2A, 0x2A, 0x2A, 0x5C, 0x30, 0x37, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x0D,
+ 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x5C, 0x37, 0x30, 0x50, 0x6C, 0x65, 0x61, 0x73, 0x65, 0x20,
+ 0x72, 0x65, 0x6D, 0x6F, 0x76, 0x65, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20,
+ 0x6D, 0x65, 0x64, 0x69, 0x61, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x70, 0x72,
+ 0x65, 0x73, 0x73, 0x20, 0x61, 0x6E, 0x79, 0x20, 0x6B, 0x65, 0x79, 0x20,
+ 0x74, 0x6F, 0x20, 0x72, 0x65, 0x62, 0x6F, 0x6F, 0x74, 0x5C, 0x30, 0x37,
+ 0x00,
+};
diff --git a/src/resource.h b/src/resource.h
index b67f5c5e..8d13c0ed 100644
--- a/src/resource.h
+++ b/src/resource.h
@@ -86,6 +86,7 @@
#define IDR_SL_MBOOT_C32 404
#define IDR_GR_GRUB_GRLDR_MBR 450
#define IDR_GR_GRUB2_CORE_IMG 451
+#define IDR_SBR_MSG 452
#define IDR_LC_RUFUS_LOC 500
#define IDR_XT_HOGGER 501
#define IDR_UEFI_NTFS 502
diff --git a/src/rufus.rc b/src/rufus.rc
index 99c6763b..8fc4a7f4 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.9.1619"
+CAPTION "Rufus 3.9.1620"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@@ -276,6 +276,7 @@ BEGIN
"IDR_SL_MBOOT_C32 RCDATA ""../res/syslinux/mboot.c32""\r\n"
"IDR_GR_GRUB_GRLDR_MBR RCDATA ""../res/grub/grldr.mbr""\r\n"
"IDR_GR_GRUB2_CORE_IMG RCDATA ""../res/grub2/core.img""\r\n"
+ "IDR_SBR_MSG RCDATA ""../res/mbr/msg.txt""\r\n"
"IDR_FD_COMMAND_COM RCDATA ""../res/freedos/COMMAND.COM""\r\n"
"IDR_FD_KERNEL_SYS RCDATA ""../res/freedos/KERNEL.SYS""\r\n"
"IDR_FD_DISPLAY_EXE RCDATA ""../res/freedos/DISPLAY.EXE""\r\n"
@@ -394,8 +395,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 3,9,1619,0
- PRODUCTVERSION 3,9,1619,0
+ FILEVERSION 3,9,1620,0
+ PRODUCTVERSION 3,9,1620,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -413,13 +414,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus"
- VALUE "FileVersion", "3.9.1619"
+ VALUE "FileVersion", "3.9.1620"
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.9.exe"
VALUE "ProductName", "Rufus"
- VALUE "ProductVersion", "3.9.1619"
+ VALUE "ProductVersion", "3.9.1620"
END
END
BLOCK "VarFileInfo"
@@ -461,6 +462,7 @@ IDR_SL_LDLINUX_V6_SYS RCDATA "../res/syslinux/ldlinux_v6.sys"
IDR_SL_MBOOT_C32 RCDATA "../res/syslinux/mboot.c32"
IDR_GR_GRUB_GRLDR_MBR RCDATA "../res/grub/grldr.mbr"
IDR_GR_GRUB2_CORE_IMG RCDATA "../res/grub2/core.img"
+IDR_SBR_MSG RCDATA "../res/mbr/msg.txt"
IDR_FD_COMMAND_COM RCDATA "../res/freedos/COMMAND.COM"
IDR_FD_KERNEL_SYS RCDATA "../res/freedos/KERNEL.SYS"
IDR_FD_DISPLAY_EXE RCDATA "../res/freedos/DISPLAY.EXE"
diff --git a/src/stdfn.c b/src/stdfn.c
index dad6da86..11b89eee 100644
--- a/src/stdfn.c
+++ b/src/stdfn.c
@@ -582,9 +582,9 @@ unsigned char* GetResource(HMODULE module, char* name, char* type, const char* d
uprintf("Could not allocate resource '%s'\n", desc);
goto out;
}
- memcpy(p, LockResource(res_handle), res_len);
- if (res_len < *len)
- uprintf("Warning: Resource '%s' was truncated by %d bytes!\n", desc, *len - res_len);
+ memcpy(p, LockResource(res_handle), min(res_len, *len));
+ if (res_len > *len)
+ uprintf("WARNING: Resource '%s' was truncated by %d bytes!\n", desc, res_len - *len);
} else {
p = (unsigned char*)LockResource(res_handle);
}