diff --git a/src/.msvc/rufus.vcxproj b/src/.msvc/rufus.vcxproj
index 3d52a6e5..c451b956 100644
--- a/src/.msvc/rufus.vcxproj
+++ b/src/.msvc/rufus.vcxproj
@@ -198,6 +198,7 @@
+
diff --git a/src/.msvc/rufus.vcxproj.filters b/src/.msvc/rufus.vcxproj.filters
index ee6895d6..e5ced23c 100644
--- a/src/.msvc/rufus.vcxproj.filters
+++ b/src/.msvc/rufus.vcxproj.filters
@@ -119,6 +119,9 @@
Header Files
+
+ Header Files
+
diff --git a/src/drive.c b/src/drive.c
index 871e1cdd..b3548b94 100644
--- a/src/drive.c
+++ b/src/drive.c
@@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Drive access function calls
- * Copyright © 2011-2013 Pete Batard
+ * Copyright © 2011-2014 Pete Batard
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -28,8 +28,13 @@
#include "msapi_utf8.h"
#include "rufus.h"
+#include "drive.h"
#include "resource.h"
#include "sys_types.h"
+#include "br.h"
+#include "fat16.h"
+#include "fat32.h"
+#include "ntfs.h"
#include "localization.h"
/*
@@ -467,6 +472,81 @@ BOOL IsMediaPresent(DWORD DriveIndex)
return r;
}
+// TODO: use an (fn,str) table and simplify this whole thing
+BOOL AnalyzeMBR(HANDLE hPhysicalDrive)
+{
+ FILE fake_fd = { 0 };
+
+ fake_fd._ptr = (char*)hPhysicalDrive;
+ fake_fd._bufsiz = SelectedDrive.Geometry.BytesPerSector;
+
+ if (!is_br(&fake_fd)) {
+ uprintf("Drive does not have an x86 master boot record\n");
+ return FALSE;
+ }
+ if (is_dos_mbr(&fake_fd)) {
+ uprintf("Drive has a DOS/NT/95A master boot record\n");
+ } else if (is_dos_f2_mbr(&fake_fd)) {
+ uprintf("Drive has a DOS/NT/95A master boot record "
+ "with the undocumented F2 instruction\n");
+ } else if (is_95b_mbr(&fake_fd)) {
+ uprintf("Drive has a Windows 95B/98/98SE/ME master boot record\n");
+ } else if (is_2000_mbr(&fake_fd)) {
+ uprintf("Drive has a Windows 2000/XP/2003 master boot record\n");
+ } else if (is_vista_mbr(&fake_fd)) {
+ uprintf("Drive has a Windows Vista master boot record\n");
+ } else if (is_win7_mbr(&fake_fd)) {
+ uprintf("Drive has a Windows 7 master boot record\n");
+ } else if (is_rufus_mbr(&fake_fd)) {
+ uprintf("Drive has a Rufus master boot record\n");
+ } else if (is_syslinux_mbr(&fake_fd)) {
+ uprintf("Drive has a Syslinux master boot record\n");
+ } else if (is_reactos_mbr(&fake_fd)) {
+ uprintf("Drive has a ReactOS master boot record\n");
+ } else if (is_zero_mbr(&fake_fd)) {
+ uprintf("Drive has a zeroed non-bootable master boot record\n");
+ } else {
+ uprintf("Drive has an unknown master boot record\n");
+ }
+ return TRUE;
+}
+
+// TODO: use an (fn,str) table and simplify this whole thing
+BOOL AnalyzePBR(HANDLE hLogicalVolume)
+{
+ FILE fake_fd = { 0 };
+
+ fake_fd._ptr = (char*)hLogicalVolume;
+ fake_fd._bufsiz = SelectedDrive.Geometry.BytesPerSector;
+
+ if (!is_br(&fake_fd)) {
+ uprintf("Volume does not have an x86 partition boot record\n");
+ return FALSE;
+ }
+ if (is_fat_16_br(&fake_fd) || is_fat_32_br(&fake_fd)) {
+ if (entire_fat_16_br_matches(&fake_fd)) {
+ uprintf("Drive has a FAT16 DOS partition boot record\n");
+ } else if (entire_fat_16_fd_br_matches(&fake_fd)) {
+ uprintf("Drive has a FAT16 FreeDOS partition boot record\n");
+ } else if (entire_fat_16_ros_br_matches(&fake_fd)) {
+ uprintf("Drive has a FAT16 ReactOS partition boot record\n");
+ } else if (entire_fat_32_br_matches(&fake_fd)) {
+ uprintf("Drive has a FAT32 DOS partition boot record\n");
+ } else if (entire_fat_32_nt_br_matches(&fake_fd)) {
+ uprintf("Drive has a FAT32 NT partition boot record\n");
+ } else if (entire_fat_32_fd_br_matches(&fake_fd)) {
+ uprintf("Drive has a FAT32 FreeDOS partition boot record\n");
+ } else if (entire_fat_32_ros_br_matches(&fake_fd)) {
+ uprintf("Drive has a FAT32 ReactOS partition boot record\n");
+ } else {
+ uprintf("Drive has an unknown FAT16 or FAT32 partition boot record\n");
+ }
+ } else {
+ uprintf("Drive has an unknown partition boot record\n");
+ }
+ return TRUE;
+}
+
/*
* Fill the drive properties (size, FS, etc)
*/
@@ -527,6 +607,7 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys
uprintf("Partition type: MBR, NB Partitions: %d\n", nb_partitions);
SelectedDrive.has_mbr_uefi_marker = (DriveLayout->Mbr.Signature == MBR_UEFI_MARKER);
uprintf("Disk ID: 0x%08X %s\n", DriveLayout->Mbr.Signature, SelectedDrive.has_mbr_uefi_marker?"(UEFI target)":"");
+ AnalyzeMBR(hPhysical);
for (i=0; iPartitionCount; i++) {
if (DriveLayout->PartitionEntry[i].Mbr.PartitionType != PARTITION_ENTRY_UNUSED) {
uprintf("Partition %d:\n", DriveLayout->PartitionEntry[i].PartitionNumber);
diff --git a/src/drive.h b/src/drive.h
new file mode 100644
index 00000000..98651545
--- /dev/null
+++ b/src/drive.h
@@ -0,0 +1,44 @@
+/*
+ * Rufus: The Reliable USB Formatting Utility
+ * Drive access function calls
+ * Copyright © 2011-2014 Pete Batard
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include
+#include
+
+#pragma once
+
+char* GetPhysicalName(DWORD DriveIndex);
+HANDLE GetPhysicalHandle(DWORD DriveIndex, BOOL bWriteAccess, BOOL bLockDrive);
+char* GetLogicalName(DWORD DriveIndex, BOOL bKeepTrailingBackslash, BOOL bSilent);
+BOOL WaitForLogical(DWORD DriveIndex);
+HANDLE GetLogicalHandle(DWORD DriveIndex, BOOL bWriteAccess, BOOL bLockDrive);
+BOOL GetDriveLetter(DWORD DriveIndex, char* drive_letter);
+UINT GetDriveTypeFromIndex(DWORD DriveIndex);
+char GetUnusedDriveLetter(void);
+BOOL GetDriveLabel(DWORD DriveIndex, char* letter, char** label);
+uint64_t GetDriveSize(DWORD DriveIndex);
+BOOL IsMediaPresent(DWORD DriveIndex);
+BOOL AnalyzeMBR(HANDLE hPhysicalDrive);
+BOOL AnalyzePBR(HANDLE hLogicalVolume);
+BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSystemNameSize);
+BOOL UnmountVolume(HANDLE hDrive);
+BOOL MountVolume(char* drive_name, char *drive_guid);
+BOOL RemountVolume(char* drive_name);
+BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL mbr_uefi_marker);
+BOOL DeletePartitions(HANDLE hDrive);
+const char* GetPartitionType(BYTE Type);
diff --git a/src/format.c b/src/format.c
index 160372f0..ab556ae8 100644
--- a/src/format.c
+++ b/src/format.c
@@ -2,7 +2,7 @@
* Rufus: The Reliable USB Formatting Utility
* Formatting function calls
* Copyright © 2007-2009 Tom Thornhill/Ridgecrop
- * Copyright © 2011-2013 Pete Batard
+ * Copyright © 2011-2014 Pete Batard
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -41,6 +41,7 @@
#include "ntfs.h"
#include "partition_info.h"
#include "file.h"
+#include "drive.h"
#include "format.h"
#include "badblocks.h"
#include "localization.h"
@@ -767,69 +768,6 @@ out:
return r;
}
-static BOOL AnalyzeMBR(HANDLE hPhysicalDrive)
-{
- FILE fake_fd = { 0 };
-
- fake_fd._ptr = (char*)hPhysicalDrive;
- fake_fd._bufsiz = SelectedDrive.Geometry.BytesPerSector;
-
- if (!is_br(&fake_fd)) {
- uprintf("Drive does not have an x86 master boot record\n");
- return FALSE;
- }
- if (is_dos_mbr(&fake_fd)) {
- uprintf("Drive has a DOS/NT/95A master boot record\n");
- } else if (is_dos_f2_mbr(&fake_fd)) {
- uprintf("Drive has a DOS/NT/95A master boot record "
- "with the undocumented F2 instruction\n");
- } else if (is_95b_mbr(&fake_fd)) {
- uprintf("Drive has a Windows 95B/98/98SE/ME master boot record\n");
- } else if (is_2000_mbr(&fake_fd)) {
- uprintf("Drive has a Windows 2000/XP/2003 master boot record\n");
- } else if (is_vista_mbr(&fake_fd)) {
- uprintf("Drive has a Windows Vista master boot record\n");
- } else if (is_win7_mbr(&fake_fd)) {
- uprintf("Drive has a Windows 7 master boot record\n");
- } else if (is_zero_mbr(&fake_fd)) {
- uprintf("Drive has a zeroed non-bootable master boot record\n");
- } else {
- uprintf("Drive has an unknown master boot record\n");
- }
- return TRUE;
-}
-
-static BOOL AnalyzePBR(HANDLE hLogicalVolume)
-{
- FILE fake_fd = { 0 };
-
- fake_fd._ptr = (char*)hLogicalVolume;
- fake_fd._bufsiz = SelectedDrive.Geometry.BytesPerSector;
-
- if (!is_br(&fake_fd)) {
- uprintf("Volume does not have an x86 partition boot record\n");
- return FALSE;
- }
- if (is_fat_16_br(&fake_fd) || is_fat_32_br(&fake_fd)) {
- if (entire_fat_16_br_matches(&fake_fd)) {
- uprintf("Drive has a FAT16 DOS partition boot record\n");
- } else if (entire_fat_16_fd_br_matches(&fake_fd)) {
- uprintf("Drive has a FAT16 FreeDOS partition boot record\n");
- } else if (entire_fat_32_br_matches(&fake_fd)) {
- uprintf("Drive has a FAT32 DOS partition boot record\n");
- } else if (entire_fat_32_nt_br_matches(&fake_fd)) {
- uprintf("Drive has a FAT32 NT partition boot record\n");
- } else if (entire_fat_32_fd_br_matches(&fake_fd)) {
- uprintf("Drive has a FAT32 FreeDOS partition boot record\n");
- } else {
- uprintf("Drive has an unknown FAT16 or FAT32 partition boot record\n");
- }
- } else {
- uprintf("Drive has an unknown partition boot record\n");
- }
- return TRUE;
-}
-
static BOOL ClearMBRGPT(HANDLE hPhysicalDrive, LONGLONG DiskSize, DWORD SectorSize, BOOL add1MB)
{
BOOL r = FALSE;
@@ -865,23 +803,6 @@ out:
return r;
}
-/*
- * Our own MBR, not in ms-sys
- */
-BOOL WriteRufusMBR(FILE *fp)
-{
- DWORD size;
- unsigned char aucRef[] = {0x55, 0xAA};
- unsigned char* rufus_mbr;
-
- // TODO: Will we need to edit the disk ID according to UI selection in the MBR as well?
- rufus_mbr = GetResource(hMainInstance, MAKEINTRESOURCEA(IDR_BR_MBR_BIN), _RT_RCDATA, "mbr.bin", &size, FALSE);
-
- return
- write_data(fp, 0x0, rufus_mbr, 0x1b8) &&
- write_data(fp, 0x1fe, aucRef, sizeof(aucRef));
-}
-
/*
* Process the Master Boot Record
*/
@@ -894,6 +815,7 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive)
size_t SecSize = SelectedDrive.Geometry.BytesPerSector;
size_t nSecs = (0x200 + SecSize -1) / SecSize;
FILE fake_fd = { 0 };
+ const char* using_msg = "Using %s MBR\n";
if (!AnalyzeMBR(hPhysicalDrive)) return FALSE;
@@ -947,13 +869,17 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive)
fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
dt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType));
if ( (dt == DT_SYSLINUX_V4) || (dt == DT_SYSLINUX_V5) || ((dt == DT_ISO) && ((fs == FS_FAT16) || (fs == FS_FAT32))) ) {
+ uprintf(using_msg, "Syslinux");
r = write_syslinux_mbr(&fake_fd);
+ } else if (dt == DT_REACTOS) {
+ uprintf(using_msg, "ReactOS");
+ r = write_reactos_mbr(&fake_fd);
} else {
if ((IS_WINPE(iso_report.winpe) && !iso_report.uses_minint) || (IsChecked(IDC_RUFUS_MBR))) {
- uprintf("Using " APPLICATION_NAME " bootable USB selection MBR\n");
- r = WriteRufusMBR(&fake_fd);
+ uprintf(using_msg, APPLICATION_NAME);
+ r = write_rufus_mbr(&fake_fd);
} else {
- uprintf("Using Windows 7 MBR\n");
+ uprintf(using_msg, "Windows 7");
r = write_win7_mbr(&fake_fd);
}
}
@@ -969,24 +895,35 @@ out:
/*
* Process the Partition Boot Record
*/
+static __inline const char* dt_to_name(int dt) {
+ switch (dt) {
+ case DT_FREEDOS: return "FreeDOS";
+ case DT_REACTOS: return "ReactOS";
+ default: return "Standard";
+ }
+}
static BOOL WritePBR(HANDLE hLogicalVolume)
{
int i;
FILE fake_fd = { 0 };
- BOOL bFreeDOS = (ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)) == DT_FREEDOS);
+ int dt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType));
+ const char* using_msg = "Using %s %s partition boot record\n";
fake_fd._ptr = (char*)hLogicalVolume;
fake_fd._bufsiz = SelectedDrive.Geometry.BytesPerSector;
switch (ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem))) {
case FS_FAT16:
+ uprintf(using_msg, dt_to_name(dt), "FAT16");
if (!is_fat_16_fs(&fake_fd)) {
- uprintf("New volume does not have a FAT16 boot sector\n");
+ uprintf("New volume does not have a FAT16 boot sector - aborting\n");
break;
}
uprintf("Confirmed new volume has a FAT16 boot sector\n");
- if (bFreeDOS) {
+ if (dt == DT_FREEDOS) {
if (!write_fat_16_fd_br(&fake_fd, 0)) break;
+ } else if (dt == DT_REACTOS) {
+ if (!write_fat_16_ros_br(&fake_fd, 0)) break;
} else {
if (!write_fat_16_br(&fake_fd, 0)) break;
}
@@ -995,16 +932,21 @@ static BOOL WritePBR(HANDLE hLogicalVolume)
break;
return TRUE;
case FS_FAT32:
+ uprintf(using_msg, dt_to_name(dt), "FAT32");
for (i=0; i<2; i++) {
if (!is_fat_32_fs(&fake_fd)) {
- uprintf("New volume does not have a %s FAT32 boot sector\n", i?"secondary":"primary");
+ uprintf("New volume does not have a %s FAT32 boot sector - aborting\n", i?"secondary":"primary");
break;
}
uprintf("Confirmed new volume has a %s FAT32 boot sector\n", i?"secondary":"primary");
- uprintf("Setting %s FAT32 boot sector for DOS boot...\n", i?"secondary":"primary");
- if (bFreeDOS) {
+ uprintf("Setting %s FAT32 boot sector for boot...\n", i?"secondary":"primary");
+ if (dt == DT_FREEDOS) {
if (!write_fat_32_fd_br(&fake_fd, 0)) break;
- } else if (!write_fat_32_br(&fake_fd, 0)) break;
+ } else if (dt == DT_REACTOS) {
+ if (!write_fat_32_ros_br(&fake_fd, 0)) break;
+ } else {
+ if (!write_fat_32_br(&fake_fd, 0)) break;
+ }
// Disk Drive ID needs to be corrected on XP
if (!write_partition_physical_disk_drive_id_fat32(&fake_fd))
break;
@@ -1012,8 +954,9 @@ static BOOL WritePBR(HANDLE hLogicalVolume)
}
return TRUE;
case FS_NTFS:
+ uprintf(using_msg, dt_to_name(dt), "NTFS");
if (!is_ntfs_fs(&fake_fd)) {
- uprintf("New volume does not have an NTFS boot sector\n");
+ uprintf("New volume does not have an NTFS boot sector - aborting\n");
break;
}
uprintf("Confirmed new volume has an NTFS boot sector\n");
@@ -1023,7 +966,7 @@ static BOOL WritePBR(HANDLE hLogicalVolume)
// But with NTFS, if you don't remount, you don't boot!
return TRUE;
default:
- uprintf("unsupported FS for FS BR processing\n");
+ uprintf("Unsupported FS for FS BR processing - aborting\n");
break;
}
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_FAULT;
@@ -1399,7 +1342,7 @@ DWORD WINAPI FormatThread(LPVOID param)
// Thanks to Microsoft, we must fix the MBR AFTER the drive has been formatted
if (pt == PARTITION_STYLE_MBR) {
- PrintStatus(0, TRUE, MSG_228);
+ PrintStatus(0, TRUE, MSG_228); // "Writing master boot record..."
if (!WriteMBR(hPhysicalDrive)) {
if (!IS_ERROR(FormatStatus))
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_FAULT;
@@ -1435,7 +1378,8 @@ DWORD WINAPI FormatThread(LPVOID param)
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_INSTALL_FAILURE;
goto out;
}
- } else if ((((dt == DT_WINME) || (dt == DT_FREEDOS)) && (!use_large_fat32)) || ((dt == DT_ISO) && (fs == FS_NTFS))) {
+ } else if ((((dt == DT_WINME) || (dt == DT_FREEDOS) || (dt == DT_REACTOS)) &&
+ (!use_large_fat32)) || ((dt == DT_ISO) && (fs == FS_NTFS))) {
// We still have a lock, which we need to modify the volume boot record
// => no need to reacquire the lock...
hLogicalVolume = GetLogicalHandle(DriveIndex, TRUE, FALSE);
diff --git a/src/ms-sys/.msvc/ms-sys.vcxproj b/src/ms-sys/.msvc/ms-sys.vcxproj
index 4b708620..6f2b20e7 100644
--- a/src/ms-sys/.msvc/ms-sys.vcxproj
+++ b/src/ms-sys/.msvc/ms-sys.vcxproj
@@ -23,14 +23,18 @@
+
+
-
+
+
+
@@ -45,6 +49,8 @@
+
+
diff --git a/src/ms-sys/.msvc/ms-sys.vcxproj.filters b/src/ms-sys/.msvc/ms-sys.vcxproj.filters
index 3dd1e24c..fcb101ce 100644
--- a/src/ms-sys/.msvc/ms-sys.vcxproj.filters
+++ b/src/ms-sys/.msvc/ms-sys.vcxproj.filters
@@ -47,9 +47,6 @@
Header Files
-
- Header Files
-
Header Files
@@ -107,6 +104,27 @@
Header Files
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
diff --git a/src/ms-sys/br.c b/src/ms-sys/br.c
index df5b352a..7f232622 100644
--- a/src/ms-sys/br.c
+++ b/src/ms-sys/br.c
@@ -100,6 +100,26 @@ int is_win7_mbr(FILE *fp)
contains_data(fp, 0x1FE, aucRef, sizeof(aucRef));
} /* is_win7_mbr */
+int is_rufus_mbr(FILE *fp)
+{
+ #include "mbr_rufus.h"
+ unsigned char aucRef[] = {0x55, 0xAA};
+
+ return
+ contains_data(fp, 0x0, mbr_rufus_0x0, sizeof(mbr_rufus_0x0)) &&
+ contains_data(fp, 0x1FE, aucRef, sizeof(aucRef));
+} /* is_rufus_mbr */
+
+int is_reactos_mbr(FILE *fp)
+{
+ #include "mbr_reactos.h"
+ unsigned char aucRef[] = {0x55, 0xAA};
+
+ return
+ contains_data(fp, 0x0, mbr_reactos_0x0, sizeof(mbr_reactos_0x0)) &&
+ contains_data(fp, 0x1FE, aucRef, sizeof(aucRef));
+} /* is_reactos_mbr */
+
int is_syslinux_mbr(FILE *fp)
{
#include "mbr_syslinux.h"
@@ -170,6 +190,26 @@ int write_win7_mbr(FILE *fp)
write_data(fp, 0x1FE, aucRef, sizeof(aucRef));
} /* write_win7_mbr */
+int write_rufus_mbr(FILE *fp)
+{
+ #include "mbr_rufus.h"
+ unsigned char aucRef[] = {0x55, 0xAA};
+
+ return
+ write_data(fp, 0x0, mbr_rufus_0x0, sizeof(mbr_rufus_0x0)) &&
+ write_data(fp, 0x1FE, aucRef, sizeof(aucRef));
+} /* write_rufus_mbr */
+
+int write_reactos_mbr(FILE *fp)
+{
+ #include "mbr_reactos.h"
+ unsigned char aucRef[] = {0x55, 0xAA};
+
+ return
+ write_data(fp, 0x0, mbr_reactos_0x0, sizeof(mbr_reactos_0x0)) &&
+ write_data(fp, 0x1FE, aucRef, sizeof(aucRef));
+} /* write_reactos_mbr */
+
int write_syslinux_mbr(FILE *fp)
{
#include "mbr_syslinux.h"
diff --git a/src/ms-sys/fat16.c b/src/ms-sys/fat16.c
index 46f0a9e1..9d375910 100644
--- a/src/ms-sys/fat16.c
+++ b/src/ms-sys/fat16.c
@@ -101,3 +101,33 @@ int write_fat_16_fd_br(FILE *fp, int bKeepLabel)
write_data(fp, 0x2b, label_11_char, sizeof(label_11_char)) &&
write_data(fp, 0x3e, br_fat16_0x3e, sizeof(br_fat16_0x3e)) );
} /* write_fat_16_fd_br */
+
+int entire_fat_16_ros_br_matches(FILE *fp)
+{
+ #include "br_fat16ros_0x0.h"
+ #include "br_fat16ros_0x3e.h"
+
+ return
+ ( contains_data(fp, 0x0, br_fat16_0x0, sizeof(br_fat16_0x0)) &&
+ /* BIOS Parameter Block might differ between systems */
+ contains_data(fp, 0x3e, br_fat16_0x3e, sizeof(br_fat16_0x3e)) );
+} /* entire_fat_16_ros_br_matches */
+
+int write_fat_16_ros_br(FILE *fp, int bKeepLabel)
+{
+ #include "label_11_char.h"
+ #include "br_fat16ros_0x0.h"
+ #include "br_fat16ros_0x3e.h"
+
+ if(bKeepLabel)
+ return
+ ( write_data(fp, 0x0, br_fat16_0x0, sizeof(br_fat16_0x0)) &&
+ /* BIOS Parameter Block should not be overwritten */
+ write_data(fp, 0x3e, br_fat16_0x3e, sizeof(br_fat16_0x3e)) );
+ else
+ return
+ ( write_data(fp, 0x0, br_fat16_0x0, sizeof(br_fat16_0x0)) &&
+ /* BIOS Parameter Block should not be overwritten */
+ write_data(fp, 0x2b, label_11_char, sizeof(label_11_char)) &&
+ write_data(fp, 0x3e, br_fat16_0x3e, sizeof(br_fat16_0x3e)) );
+} /* write_fat_16_ros_br */
diff --git a/src/ms-sys/fat32.c b/src/ms-sys/fat32.c
index 8b785b5d..b2b398b0 100644
--- a/src/ms-sys/fat32.c
+++ b/src/ms-sys/fat32.c
@@ -70,7 +70,7 @@ int write_fat_32_br(FILE *fp, int bKeepLabel)
( write_data(fp, 0x0, br_fat32_0x0, sizeof(br_fat32_0x0)) &&
/* BIOS Parameter Block should not be overwritten */
write_data(fp, 0x52, br_fat32_0x52, sizeof(br_fat32_0x52)) &&
- /* Cluster information is not overwritten, however, it would bo OK
+ /* Cluster information is not overwritten, however, it would be OK
to write 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff here. */
write_data(fp, 0x3f0, br_fat32_0x3f0, sizeof(br_fat32_0x3f0)) );
else
@@ -79,7 +79,7 @@ int write_fat_32_br(FILE *fp, int bKeepLabel)
/* BIOS Parameter Block should not be overwritten */
write_data(fp, 0x47, label_11_char, sizeof(label_11_char)) &&
write_data(fp, 0x52, br_fat32_0x52, sizeof(br_fat32_0x52)) &&
- /* Cluster information is not overwritten, however, it would bo OK
+ /* Cluster information is not overwritten, however, it would be OK
to write 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff here. */
write_data(fp, 0x3f0, br_fat32_0x3f0, sizeof(br_fat32_0x3f0)) );
} /* write_fat_32_br */
@@ -110,7 +110,7 @@ int write_fat_32_fd_br(FILE *fp, int bKeepLabel)
( write_data(fp, 0x0, br_fat32_0x0, sizeof(br_fat32_0x0)) &&
/* BIOS Parameter Block should not be overwritten */
write_data(fp, 0x52, br_fat32_0x52, sizeof(br_fat32_0x52)) &&
- /* Cluster information is not overwritten, however, it would bo OK
+ /* Cluster information is not overwritten, however, it would be OK
to write 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff here. */
write_data(fp, 0x3f0, br_fat32_0x3f0, sizeof(br_fat32_0x3f0)) );
else
@@ -119,20 +119,20 @@ int write_fat_32_fd_br(FILE *fp, int bKeepLabel)
/* BIOS Parameter Block should not be overwritten */
write_data(fp, 0x47, label_11_char, sizeof(label_11_char)) &&
write_data(fp, 0x52, br_fat32_0x52, sizeof(br_fat32_0x52)) &&
- /* Cluster information is not overwritten, however, it would bo OK
+ /* Cluster information is not overwritten, however, it would be OK
to write 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff here. */
write_data(fp, 0x3f0, br_fat32_0x3f0, sizeof(br_fat32_0x3f0)) );
-} /* write_fat_32_nt_br */
+} /* write_fat_32_fd_br */
int entire_fat_32_nt_br_matches(FILE *fp)
{
- #include "br_fat32nt_0x0.h"
+ #include "br_fat32_0x0.h"
#include "br_fat32nt_0x52.h"
#include "br_fat32nt_0x3f0.h"
#include "br_fat32nt_0x1800.h"
return
- ( contains_data(fp, 0x0, br_fat32nt_0x0, sizeof(br_fat32nt_0x0)) &&
+ ( contains_data(fp, 0x0, br_fat32_0x0, sizeof(br_fat32_0x0)) &&
/* BIOS Parameter Block might differ between systems */
contains_data(fp, 0x52, br_fat32nt_0x52, sizeof(br_fat32nt_0x52)) &&
/* Cluster information might differ between systems */
@@ -144,30 +144,79 @@ int entire_fat_32_nt_br_matches(FILE *fp)
int write_fat_32_nt_br(FILE *fp, int bKeepLabel)
{
#include "label_11_char.h"
- #include "br_fat32nt_0x0.h"
+ #include "br_fat32_0x0.h"
#include "br_fat32nt_0x52.h"
#include "br_fat32nt_0x3f0.h"
#include "br_fat32nt_0x1800.h"
if(bKeepLabel)
return
- ( write_data(fp, 0x0, br_fat32nt_0x0, sizeof(br_fat32nt_0x0)) &&
+ ( write_data(fp, 0x0, br_fat32_0x0, sizeof(br_fat32_0x0)) &&
/* BIOS Parameter Block should not be overwritten */
write_data(fp, 0x52, br_fat32nt_0x52, sizeof(br_fat32nt_0x52)) &&
- /* Cluster information is not overwritten, however, it would bo OK
+ /* Cluster information is not overwritten, however, it would be OK
to write 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff here. */
write_data(fp, 0x3f0, br_fat32nt_0x3f0, sizeof(br_fat32nt_0x3f0)) &&
write_data(fp, 0x1800, br_fat32nt_0x1800, sizeof(br_fat32nt_0x1800))
);
else
return
- ( write_data(fp, 0x0, br_fat32nt_0x0, sizeof(br_fat32nt_0x0)) &&
+ ( write_data(fp, 0x0, br_fat32_0x0, sizeof(br_fat32_0x0)) &&
/* BIOS Parameter Block should not be overwritten */
write_data(fp, 0x47, label_11_char, sizeof(label_11_char)) &&
write_data(fp, 0x52, br_fat32nt_0x52, sizeof(br_fat32nt_0x52)) &&
- /* Cluster information is not overwritten, however, it would bo OK
+ /* Cluster information is not overwritten, however, it would be OK
to write 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff here. */
write_data(fp, 0x3f0, br_fat32nt_0x3f0, sizeof(br_fat32nt_0x3f0)) &&
write_data(fp, 0x1800, br_fat32nt_0x1800, sizeof(br_fat32nt_0x1800))
);
} /* write_fat_32_nt_br */
+
+int entire_fat_32_ros_br_matches(FILE *fp)
+{
+ #include "br_fat32_0x0.h"
+ #include "br_fat32ros_0x52.h"
+ #include "br_fat32ros_0x3f0.h"
+ #include "br_fat32ros_0x1c00.h"
+
+ return
+ ( contains_data(fp, 0x0, br_fat32_0x0, sizeof(br_fat32_0x0)) &&
+ /* BIOS Parameter Block might differ between systems */
+ contains_data(fp, 0x52, br_fat32ros_0x52, sizeof(br_fat32ros_0x52)) &&
+ /* Cluster information might differ between systems */
+ contains_data(fp, 0x3f0, br_fat32ros_0x3f0, sizeof(br_fat32ros_0x3f0)) &&
+ contains_data(fp, 0x1c00, br_fat32ros_0x1c00, sizeof(br_fat32ros_0x1c00))
+ );
+} /* entire_fat_32_ros_br_matches */
+
+/* See http://doxygen.reactos.org/dc/d83/bootsup_8c_source.html#l01596 */
+int write_fat_32_ros_br(FILE *fp, int bKeepLabel)
+{
+ #include "label_11_char.h"
+ #include "br_fat32_0x0.h"
+ #include "br_fat32ros_0x52.h"
+ #include "br_fat32ros_0x3f0.h"
+ #include "br_fat32ros_0x1c00.h"
+
+ if(bKeepLabel)
+ return
+ ( write_data(fp, 0x0, br_fat32_0x0, sizeof(br_fat32_0x0)) &&
+ /* BIOS Parameter Block should not be overwritten */
+ write_data(fp, 0x52, br_fat32ros_0x52, sizeof(br_fat32ros_0x52)) &&
+ /* Cluster information is not overwritten, however, it would be OK
+ to write 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff here. */
+ write_data(fp, 0x3f0, br_fat32ros_0x3f0, sizeof(br_fat32ros_0x3f0)) &&
+ write_data(fp, 0x1c00, br_fat32ros_0x1c00, sizeof(br_fat32ros_0x1c00))
+ );
+ else
+ return
+ ( write_data(fp, 0x0, br_fat32_0x0, sizeof(br_fat32_0x0)) &&
+ /* BIOS Parameter Block should not be overwritten */
+ write_data(fp, 0x47, label_11_char, sizeof(label_11_char)) &&
+ write_data(fp, 0x52, br_fat32ros_0x52, sizeof(br_fat32ros_0x52)) &&
+ /* Cluster information is not overwritten, however, it would be OK
+ to write 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff here. */
+ write_data(fp, 0x3f0, br_fat32ros_0x3f0, sizeof(br_fat32ros_0x3f0)) &&
+ write_data(fp, 0x1c00, br_fat32ros_0x1c00, sizeof(br_fat32ros_0x1c00))
+ );
+} /* write_fat_32_ros_br */
diff --git a/src/ms-sys/inc/br.h b/src/ms-sys/inc/br.h
index c4f0e467..fb42a2fd 100644
--- a/src/ms-sys/inc/br.h
+++ b/src/ms-sys/inc/br.h
@@ -40,6 +40,10 @@ int is_win7_mbr(FILE *fp);
FALSE.The file position will change when this function is called! */
int is_rufus_mbr(FILE *fp);
+/* returns TRUE if the file has a ReactOS master boot record, otherwise
+ FALSE.The file position will change when this function is called! */
+int is_reactos_mbr(FILE *fp);
+
/* returns TRUE if the file has a syslinux master boot record, otherwise
FALSE.The file position will change when this function is called! */
int is_syslinux_mbr(FILE *fp);
@@ -64,7 +68,7 @@ int write_2000_mbr(FILE *fp);
FALSE */
int write_vista_mbr(FILE *fp);
-/* Writes a 7 master boot record to a file, returns TRUE on success, otherwise
+/* Writes a Windows 7 master boot record to a file, returns TRUE on success, otherwise
FALSE */
int write_win7_mbr(FILE *fp);
@@ -72,6 +76,10 @@ int write_win7_mbr(FILE *fp);
FALSE */
int write_rufus_mbr(FILE *fp);
+/* Writes a ReactOS master boot record to a file, returns TRUE on success, otherwise
+ FALSE */
+int write_reactos_mbr(FILE *fp);
+
/* Writes a syslinux master boot record to a file, returns TRUE on success, otherwise
FALSE */
int write_syslinux_mbr(FILE *fp);
diff --git a/src/ms-sys/inc/br_fat16ros_0x0.h b/src/ms-sys/inc/br_fat16ros_0x0.h
new file mode 100644
index 00000000..1e1d4be8
--- /dev/null
+++ b/src/ms-sys/inc/br_fat16ros_0x0.h
@@ -0,0 +1,3 @@
+unsigned char br_fat16_0x0[] = {
+ 0xeb, 0x71, 0x90, 0x46, 0x72, 0x4c, 0x64, 0x72, 0x31, 0x2e, 0x30
+};
diff --git a/src/ms-sys/inc/br_fat16ros_0x3e.h b/src/ms-sys/inc/br_fat16ros_0x3e.h
new file mode 100644
index 00000000..388adbab
--- /dev/null
+++ b/src/ms-sys/inc/br_fat16ros_0x3e.h
@@ -0,0 +1,40 @@
+unsigned char br_fat16_0x3e[] = {
+ 0x46, 0x52, 0x45, 0x45, 0x4c, 0x44, 0x52, 0x20, 0x53, 0x59, 0x53, 0x4c,
+ 0x6f, 0x61, 0x64, 0x20, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x21, 0x0d,
+ 0x0a, 0x00, 0x50, 0x72, 0x65, 0x73, 0x73, 0x20, 0x61, 0x6e, 0x79, 0x20,
+ 0x6b, 0x65, 0x79, 0x20, 0x74, 0x6f, 0x20, 0x72, 0x65, 0x62, 0x6f, 0x6f,
+ 0x74, 0x2e, 0x2e, 0x2e, 0x00, 0x31, 0xc0, 0x8e, 0xd8, 0x8e, 0xd0, 0xbc,
+ 0xe0, 0x7b, 0x89, 0xe5, 0xa0, 0x24, 0x7c, 0x3c, 0xff, 0x74, 0x02, 0x88,
+ 0xc2, 0x88, 0x16, 0x24, 0x7c, 0x31, 0xff, 0xb4, 0x08, 0xcd, 0x13, 0x0f,
+ 0x82, 0xb8, 0x00, 0x66, 0x0f, 0xb6, 0xdd, 0x88, 0xcf, 0xc0, 0xef, 0x06,
+ 0x80, 0xe1, 0x3f, 0x66, 0x0f, 0xb6, 0xc9, 0x66, 0x0f, 0xb6, 0xc6, 0x66,
+ 0x40, 0x66, 0x43, 0x66, 0xf7, 0xe1, 0x66, 0xf7, 0xe3, 0x66, 0x89, 0x46,
+ 0x08, 0x66, 0x0f, 0xb7, 0x86, 0x2e, 0x00, 0x66, 0x03, 0x86, 0x3c, 0x00,
+ 0x66, 0x0f, 0xb7, 0x8e, 0x36, 0x00, 0x66, 0x60, 0xbb, 0x00, 0x80, 0x8e,
+ 0xc3, 0x31, 0xff, 0xe8, 0xb9, 0x00, 0x66, 0x61, 0x66, 0x89, 0xc3, 0x66,
+ 0x0f, 0xb6, 0x86, 0x30, 0x00, 0x66, 0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 0x76, 0x03, 0xbb, 0x40, 0x00, 0x66,
+ 0x60, 0x66, 0x6a, 0x00, 0x66, 0x50, 0x06, 0x57, 0x53, 0x6a, 0x10, 0x89,
+ 0xe6, 0x8a, 0x16, 0x24, 0x7c, 0xb4, 0x42, 0xcd, 0x13, 0x72, 0x9c, 0x83,
+ 0xc4, 0x10, 0xc1, 0xe3, 0x05, 0x8c, 0xc0, 0x01, 0xd8, 0x8e, 0xc0, 0x66,
+ 0x61, 0x66, 0x01, 0xd8, 0x29, 0xd9, 0x75, 0xc7, 0xc3, 0xb4, 0x0e, 0xbb,
+ 0x07, 0x00, 0xcd, 0x10, 0xac, 0x08, 0xc0, 0x75, 0xf4, 0xc3, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa
+};
diff --git a/src/ms-sys/inc/br_fat32nt_0x0.h b/src/ms-sys/inc/br_fat32nt_0x0.h
deleted file mode 100644
index 1bceae2b..00000000
--- a/src/ms-sys/inc/br_fat32nt_0x0.h
+++ /dev/null
@@ -1,3 +0,0 @@
-unsigned char br_fat32nt_0x0[] = {
- 0xeb, 0x58, 0x90, 0x4d, 0x53, 0x57, 0x49, 0x4e, 0x34, 0x2e, 0x31
-};
diff --git a/src/ms-sys/inc/br_fat32ros_0x1c00.h b/src/ms-sys/inc/br_fat32ros_0x1c00.h
new file mode 100644
index 00000000..26bbf0e9
--- /dev/null
+++ b/src/ms-sys/inc/br_fat32ros_0x1c00.h
@@ -0,0 +1,45 @@
+unsigned char br_fat32ros_0x1c00[] = {
+ 0x66, 0x8b, 0x86, 0x2c, 0x00, 0x66, 0x3d, 0x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0x66, 0x01, 0xd8, 0x31, 0xdb, 0x0f,
+ 0xb6, 0x8e, 0x0d, 0x00, 0xe8, 0x60, 0xfd, 0xc3, 0xbe, 0x8b, 0x7f, 0xe8,
+ 0x23, 0xfe, 0xbe, 0xd9, 0x7d, 0xe8, 0x1d, 0xfe, 0xe9, 0x0e, 0xfe, 0x66,
+ 0x72, 0x65, 0x65, 0x6c, 0x64, 0x72, 0x2e, 0x73, 0x79, 0x73, 0x20, 0x6e,
+ 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x0d, 0x0a, 0x00, 0x46,
+ 0x52, 0x45, 0x45, 0x4c, 0x44, 0x52, 0x20, 0x53, 0x59, 0x53, 0x4c, 0x6f,
+ 0x61, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x46, 0x72, 0x65, 0x65, 0x4c, 0x6f,
+ 0x61, 0x64, 0x65, 0x72, 0x2e, 0x2e, 0x2e, 0x0d, 0x0a, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa
+};
diff --git a/src/ms-sys/inc/br_fat32ros_0x3f0.h b/src/ms-sys/inc/br_fat32ros_0x3f0.h
new file mode 100644
index 00000000..018c0a44
--- /dev/null
+++ b/src/ms-sys/inc/br_fat32ros_0x3f0.h
@@ -0,0 +1,4 @@
+unsigned char br_fat32ros_0x3f0[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x55, 0xaa
+};
diff --git a/src/ms-sys/inc/br_fat32ros_0x52.h b/src/ms-sys/inc/br_fat32ros_0x52.h
new file mode 100644
index 00000000..82c8ac41
--- /dev/null
+++ b/src/ms-sys/inc/br_fat32ros_0x52.h
@@ -0,0 +1,79 @@
+unsigned char br_fat32ros_0x52[] = {
+ 0x46, 0x41, 0x54, 0x33, 0x32, 0x20, 0x20, 0x20, 0x31, 0xc0, 0x8e, 0xd8,
+ 0x8e, 0xc0, 0x8e, 0xd0, 0xbd, 0x00, 0x7c, 0xbc, 0x00, 0x7c, 0x80, 0xbe,
+ 0x40, 0x00, 0xff, 0x75, 0x04, 0x88, 0x96, 0x40, 0x00, 0x83, 0xbe, 0x16,
+ 0x00, 0x00, 0x75, 0x0f, 0x66, 0x83, 0xbe, 0x11, 0x00, 0x00, 0x75, 0x07,
+ 0x83, 0xbe, 0x2a, 0x00, 0x00, 0x76, 0x03, 0xe9, 0x07, 0x01, 0xb8, 0x00,
+ 0x08, 0x8a, 0x96, 0x40, 0x00, 0xcd, 0x13, 0x73, 0x05, 0xb9, 0xff, 0xff,
+ 0x88, 0xce, 0x88, 0xeb, 0x88, 0xcf, 0xc0, 0xef, 0x06, 0x80, 0xe1, 0x3f,
+ 0x66, 0x0f, 0xb6, 0xc6, 0x66, 0x0f, 0xb7, 0xdb, 0x66, 0x0f, 0xb6, 0xc9,
+ 0x66, 0x40, 0x66, 0x43, 0x66, 0xf7, 0xe1, 0x66, 0xf7, 0xe3, 0x66, 0xa3,
+ 0xb4, 0x7d, 0x66, 0xb8, 0x0e, 0x00, 0x00, 0x00, 0x66, 0x03, 0x86, 0x1c,
+ 0x00, 0xb9, 0x01, 0x00, 0x31, 0xdb, 0x8e, 0xc3, 0xbb, 0x00, 0x7e, 0xe8,
+ 0x03, 0x00, 0xe9, 0x25, 0x01, 0x06, 0x66, 0x3b, 0x06, 0xb4, 0x7d, 0x73,
+ 0x1c, 0x66, 0x60, 0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 0xbe, 0xd9, 0x7d, 0xe8, 0x06, 0x00, 0x31, 0xc0, 0xcd,
+ 0x16, 0xcd, 0x19, 0xac, 0x08, 0xc0, 0x74, 0x09, 0xb4, 0x0e, 0xbb, 0x07,
+ 0x00, 0xcd, 0x10, 0xeb, 0xf2, 0xc3, 0x00, 0x00, 0x00, 0x00, 0x44, 0x69,
+ 0x73, 0x6b, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x0d, 0x0a, 0x00, 0x46,
+ 0x69, 0x6c, 0x65, 0x20, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x65,
+ 0x72, 0x72, 0x6f, 0x72, 0x0d, 0x0a, 0x00, 0x50, 0x72, 0x65, 0x73, 0x73,
+ 0x20, 0x61, 0x6e, 0x79, 0x20, 0x6b, 0x65, 0x79, 0x20, 0x74, 0x6f, 0x20,
+ 0x72, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x0d, 0x0a, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa, 0x52, 0x52,
+ 0x61, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x72, 0x72, 0x41, 0x61
+};
diff --git a/src/ms-sys/inc/fat16.h b/src/ms-sys/inc/fat16.h
index 96f4c336..ce4f8dd7 100644
--- a/src/ms-sys/inc/fat16.h
+++ b/src/ms-sys/inc/fat16.h
@@ -29,4 +29,13 @@ int entire_fat_16_fd_br_matches(FILE *fp);
otherwise FALSE */
int write_fat_16_fd_br(FILE *fp, int bKeepLabel);
+/* returns TRUE if the file has an exact match of the FAT16 boot record this
+ program would create for ReactOS, otherwise FALSE.
+ The file position will change when this function is called! */
+int entire_fat_16_ros_br_matches(FILE *fp);
+
+/* Writes a FAT16 ReactOS boot record to a file, returns TRUE on success,
+ otherwise FALSE */
+int write_fat_16_ros_br(FILE *fp, int bKeepLabel);
+
#endif
diff --git a/src/ms-sys/inc/fat32.h b/src/ms-sys/inc/fat32.h
index b3b1b6e8..7738b8ba 100644
--- a/src/ms-sys/inc/fat32.h
+++ b/src/ms-sys/inc/fat32.h
@@ -38,4 +38,13 @@ int entire_fat_32_nt_br_matches(FILE *fp);
FALSE */
int write_fat_32_nt_br(FILE *fp, int bKeepLabel);
+/* returns TRUE if the file has an exact match of the FAT32 boot record this
+ program would create for ReactOS, otherwise FALSE.
+ The file position will change when this function is called! */
+int entire_fat_32_ros_br_matches(FILE *fp);
+
+/* Writes a FAT32 ReactOS boot record to a file, returns TRUE on success, otherwise
+ FALSE */
+int write_fat_32_ros_br(FILE *fp, int bKeepLabel);
+
#endif
diff --git a/src/ms-sys/inc/mbr_reactos.h b/src/ms-sys/inc/mbr_reactos.h
new file mode 100644
index 00000000..2f716c5c
--- /dev/null
+++ b/src/ms-sys/inc/mbr_reactos.h
@@ -0,0 +1,26 @@
+/* First 267 bytes of MBR from ReactOS */
+unsigned char mbr_reactos_0x0[] = {
+ 0xfa, 0xfc, 0x31, 0xc0, 0x8e, 0xd0, 0x8e, 0xd8, 0xbd, 0x00, 0x7c, 0x8d,
+ 0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6, 0xc1, 0x01, 0x74, 0x27, 0xeb, 0x10, 0x10, 0x00, 0x04,
+ 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x8b, 0x45, 0x08, 0xa3, 0xd1, 0x7c, 0x8b, 0x45, 0x0a, 0xa3, 0xd3,
+ 0x7c, 0xb8, 0x00, 0x42, 0xbe, 0xc9, 0x7c, 0xcd, 0x13, 0xc3, 0xb8, 0x04,
+ 0x02, 0xbb, 0x00, 0x7c, 0x8b, 0x4d, 0x02, 0x8a, 0x75, 0x01, 0xcd, 0x13,
+ 0xc3, 0x31, 0xdb, 0xb4, 0x0e, 0xcd, 0x10, 0x5e, 0xac, 0x56, 0x3c, 0x00,
+ 0x75, 0xf3, 0xc3
+};
diff --git a/src/ms-sys/inc/mbr_rufus.h b/src/ms-sys/inc/mbr_rufus.h
new file mode 100644
index 00000000..770fe9d1
--- /dev/null
+++ b/src/ms-sys/inc/mbr_rufus.h
@@ -0,0 +1,44 @@
+/*
+ * First 440 bytes of Rufus MBR
+ * https://github.com/pbatard/rufus/tree/master/res/mbr
+ * Copyright © 2012-2014 Pete Batard
+ */
+unsigned char mbr_rufus_0x0[] = {
+ 0x41, 0x4b, 0x45, 0x4f, 0xfc, 0x31, 0xc0, 0xfa, 0x8e, 0xd0, 0xbc, 0x00,
+ 0x7c, 0xfb, 0x89, 0xe6, 0x89, 0xe7, 0x1e, 0x06, 0x8e, 0xd8, 0xbb, 0x13,
+ 0x04, 0x8b, 0x07, 0x48, 0x89, 0x07, 0xc1, 0xe0, 0x06, 0x2d, 0xc0, 0x07,
+ 0x8e, 0xc0, 0xb9, 0x00, 0x02, 0xf3, 0xa4, 0x50, 0x68, 0x30, 0x7c, 0xcb,
+ 0x8e, 0xd8, 0x66, 0x31, 0xdb, 0x8e, 0xc3, 0x41, 0xba, 0x81, 0x00, 0xe8,
+ 0x89, 0x00, 0x72, 0x6d, 0xbb, 0xbe, 0x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6f, 0x6f, 0x74, 0x20, 0x66, 0x72, 0x6f, 0x6d,
+ 0x20, 0x55, 0x53, 0x42, 0x2e, 0x00, 0x00, 0x00
+};
diff --git a/src/resource.h b/src/resource.h
index 327f560b..6ec24796 100644
--- a/src/resource.h
+++ b/src/resource.h
@@ -13,7 +13,6 @@
#define IDI_ICON 110
#define IDI_UP 111
#define IDI_DOWN 112
-#define IDR_BR_MBR_BIN 200
#define IDR_FD_COMMAND_COM 300
#define IDR_FD_KERNEL_SYS 301
#define IDR_FD_DISPLAY_EXE 302
diff --git a/src/rufus.c b/src/rufus.c
index 9cb2f090..7ff80130 100644
--- a/src/rufus.c
+++ b/src/rufus.c
@@ -40,6 +40,7 @@
#include "msapi_utf8.h"
#include "resource.h"
#include "rufus.h"
+#include "drive.h"
#include "registry.h"
#include "localization.h"
@@ -444,7 +445,7 @@ static void SetFSFromISO(void)
}
// Syslinux and EFI have precedence over bootmgr (unless the user selected BIOS as target type)
- if ((iso_report.has_isolinux) || ( (IS_EFI(iso_report)) && (bt == BT_UEFI))) {
+ if ((iso_report.has_isolinux) || (IS_REACTOS(iso_report)) || ( (IS_EFI(iso_report)) && (bt == BT_UEFI))) {
if (fs_mask & (1<= DT_SYSLINUX_V4)) {
selection_default = DT_FREEDOS;
CheckDlgButton(hDlg, IDC_DISK_ID, BST_UNCHECKED);
}
@@ -1842,7 +1844,11 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
if (HIWORD(wParam) != CBN_SELCHANGE)
break;
selection_default = (int) ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType));
- if (ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)) == DT_ISO) {
+ // The Rufus MBR can't apply for Syslinux or ReactOS
+ // TODO: we should also disable this for isolinux based ISOs
+ EnableWindow(GetDlgItem(hMainDialog, IDC_RUFUS_MBR), selection_default < DT_SYSLINUX_V4);
+ EnableWindow(hDiskID, selection_default < DT_SYSLINUX_V4);
+ if (selection_default == DT_ISO) {
if ((iso_path == NULL) || (iso_report.label[0] == 0)) {
// Set focus to the Select ISO button
SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)FALSE, 0);
@@ -2064,11 +2070,12 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
#endif
{
const char* old_wait_option = "/W";
+ const char* rufus_loc = "rufus.loc";
int i, opt, option_index = 0, argc = 0, si = 0, lcid = GetUserDefaultUILanguage();
BOOL attached_console = FALSE, external_loc_file = FALSE, lgp_set = FALSE;
BYTE* loc_data;
DWORD loc_size, Size;
- char tmp_path[MAX_PATH], loc_file[MAX_PATH] = "", *tmp, *locale_name = NULL;
+ char tmp_path[MAX_PATH] = "", loc_file[MAX_PATH] = "", *tmp, *locale_name = NULL;
char** argv = NULL;
wchar_t **wenv, **wargv;
PF_DECL(__wgetmainargs);
@@ -2154,24 +2161,28 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
// Init localization
init_localization();
// Seek for a loc file in the current directory
- if (GetFileAttributesU("rufus.loc") == INVALID_FILE_ATTRIBUTES) {
+ if (GetFileAttributesU(rufus_loc) == INVALID_FILE_ATTRIBUTES) {
uprintf("loc file not found in current directory - embedded one will be used");
loc_data = (BYTE*)GetResource(hMainInstance, MAKEINTRESOURCEA(IDR_LC_RUFUS_LOC), _RT_RCDATA, "embedded.loc", &loc_size, FALSE);
- GetTempPathU(sizeof(tmp_path), tmp_path);
- GetTempFileNameU(tmp_path, APPLICATION_NAME, 0, loc_file);
+ if ( (GetTempPathU(sizeof(tmp_path), tmp_path) == 0)
+ || (GetTempFileNameU(tmp_path, APPLICATION_NAME, 0, loc_file) == 0)
+ || (loc_file[0] == 0) ) {
+ // Last ditch effort to get a loc file - just extract it to the current directory
+ safe_strcpy(loc_file, sizeof(loc_file), rufus_loc);
+ }
hFile = CreateFileU(loc_file, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, CREATE_ALWAYS, 0, 0);
- if ((hFile == INVALID_HANDLE_VALUE)|| (!WriteFile(hFile, loc_data, loc_size, &Size, 0)) || (loc_size != Size)) {
- safe_closehandle(hFile);
+ if ((hFile == INVALID_HANDLE_VALUE) || (!WriteFile(hFile, loc_data, loc_size, &Size, 0)) || (loc_size != Size)) {
uprintf("localization: unable to extract '%s': %s.\n", loc_file, WindowsErrorString());
- } else {
safe_closehandle(hFile);
- uprintf("localization: extracted data to '%s'\n", loc_file);
+ goto out;
}
+ uprintf("localization: extracted data to '%s'\n", loc_file);
+ safe_closehandle(hFile);
} else {
- safe_sprintf(loc_file, sizeof(loc_file), "%s\\rufus.loc", app_dir);
+ safe_sprintf(loc_file, sizeof(loc_file), "%s\\%s", app_dir, rufus_loc);
external_loc_file = TRUE;
uprintf("using external loc file '%s'", loc_file);
}
diff --git a/src/rufus.h b/src/rufus.h
index 461878c7..c36eaf2c 100644
--- a/src/rufus.h
+++ b/src/rufus.h
@@ -169,8 +169,9 @@ enum dos_type {
DT_WINME = 0,
DT_FREEDOS,
DT_ISO,
- DT_SYSLINUX_V4,
+ DT_SYSLINUX_V4, // Start of indexes that only display in advanced mode
DT_SYSLINUX_V5,
+ DT_REACTOS,
DT_MAX
};
@@ -318,24 +319,6 @@ extern BOOL ExtractISO(const char* src_iso, const char* dest_dir, BOOL scan);
extern BOOL ExtractISOFile(const char* iso, const char* iso_file, const char* dest_file);
extern BOOL InstallSyslinux(DWORD drive_index, char drive_letter);
DWORD WINAPI FormatThread(void* param);
-extern char* GetPhysicalName(DWORD DriveIndex);
-extern HANDLE GetPhysicalHandle(DWORD DriveIndex, BOOL bWriteAccess, BOOL bLockDrive);
-extern BOOL WaitForLogical(DWORD DriveIndex);
-extern char* GetLogicalName(DWORD DriveIndex, BOOL bKeepTrailingBackslash, BOOL bSilent);
-extern HANDLE GetLogicalHandle(DWORD DriveIndex, BOOL bWriteAccess, BOOL bLockDrive);
-extern BOOL GetDriveLetter(DWORD DriveIndex, char* drive_letter);
-extern UINT GetDriveTypeFromIndex(DWORD DriveIndex);
-extern uint64_t GetDriveSize(DWORD DriveIndex);
-extern char GetUnusedDriveLetter(void);
-extern BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL mbr_uefi_marker);
-extern BOOL DeletePartitions(HANDLE hDrive);
-extern const char* GetPartitionType(BYTE Type);
-extern BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSystemNameSize);
-extern BOOL GetDriveLabel(DWORD DriveIndex, char* letter, char** label);
-extern BOOL IsMediaPresent(DWORD DriveIndex);
-extern BOOL MountVolume(char* drive_name, char *drive_guid);
-extern BOOL UnmountVolume(HANDLE hDrive);
-extern BOOL RemountVolume(char* drive_name);
extern BOOL CreateProgress(void);
extern BOOL SetAutorun(const char* path);
extern char* FileDialog(BOOL save, char* path, char* filename, char* ext, char* ext_desc);
diff --git a/src/rufus.rc b/src/rufus.rc
index 24fd875f..34b508aa 100644
--- a/src/rufus.rc
+++ b/src/rufus.rc
@@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 329
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
-CAPTION "Rufus v1.4.2.370"
+CAPTION "Rufus v1.4.2.371"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
@@ -200,7 +200,6 @@ BEGIN
"IDR_SL_LDLINUX_V5_BSS RCDATA ""../res/syslinux/ldlinux_v5.bss""\r\n"
"IDR_SL_LDLINUX_V5_SYS RCDATA ""../res/syslinux/ldlinux_v5.sys""\r\n"
"IDR_SL_MBOOT_C32 RCDATA ""../res/syslinux/mboot.c32""\r\n"
- "IDR_BR_MBR_BIN RCDATA ""../res/mbr/mbr.bin""\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"
@@ -289,8 +288,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,4,2,370
- PRODUCTVERSION 1,4,2,370
+ FILEVERSION 1,4,2,371
+ PRODUCTVERSION 1,4,2,371
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -307,13 +306,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
- VALUE "FileVersion", "1.4.2.370"
+ VALUE "FileVersion", "1.4.2.371"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
- VALUE "ProductVersion", "1.4.2.370"
+ VALUE "ProductVersion", "1.4.2.371"
END
END
BLOCK "VarFileInfo"
@@ -354,7 +353,6 @@ IDR_SL_LDLINUX_V4_SYS RCDATA "../res/syslinux/ldlinux_v4.sys"
IDR_SL_LDLINUX_V5_BSS RCDATA "../res/syslinux/ldlinux_v5.bss"
IDR_SL_LDLINUX_V5_SYS RCDATA "../res/syslinux/ldlinux_v5.sys"
IDR_SL_MBOOT_C32 RCDATA "../res/syslinux/mboot.c32"
-IDR_BR_MBR_BIN RCDATA "../res/mbr/mbr.bin"
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/smart.c b/src/smart.c
index 01dcaa9c..d6d4b507 100644
--- a/src/smart.c
+++ b/src/smart.c
@@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* SMART HDD vs Flash detection (using ATA over USB, S.M.A.R.T., etc.)
- * Copyright © 2013 Pete Batard
+ * Copyright © 2014 Pete Batard
*
* Based in part on scsiata.cpp from Smartmontools: http://smartmontools.sourceforge.net
* Copyright © 2006-12 Douglas Gilbert
@@ -33,6 +33,7 @@
#include "msapi_utf8.h"
#include "rufus.h"
+#include "drive.h"
#include "smart.h"
#include "hdd_vs_ufd.h"
diff --git a/src/syslinux.c b/src/syslinux.c
index ae0a0902..a6f9ed4e 100644
--- a/src/syslinux.c
+++ b/src/syslinux.c
@@ -27,6 +27,7 @@
#include
#include "rufus.h"
+#include "drive.h"
#include "resource.h"
#include "localization.h"