[ms-sys] update ms-sys to current

* NB: This includes an updated Syslinux MBR
This commit is contained in:
Pete Batard 2016-01-07 15:49:58 +00:00
parent cc65d0494d
commit b77561bb9b
15 changed files with 312 additions and 120 deletions

View File

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Drive access function calls
* Copyright © 2011-2015 Pete Batard <pete@akeo.ie>
* Copyright © 2011-2016 Pete Batard <pete@akeo.ie>
*
* 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
@ -576,10 +576,10 @@ const struct {int (*fn)(FILE *fp); char* str;} known_mbr[] = {
{ is_rufus_mbr, "Rufus" },
{ is_syslinux_mbr, "Syslinux" },
{ is_reactos_mbr, "ReactOS" },
{ is_kolibri_mbr, "KolibriOS" },
{ is_grub_mbr, "Grub4DOS" },
{ is_kolibrios_mbr, "KolibriOS" },
{ is_grub4dos_mbr, "Grub4DOS" },
{ is_grub2_mbr, "Grub 2.0" },
{ is_zero_mbr, "Zeroed" },
{ is_zero_mbr_not_including_disk_signature_or_copy_protect, "Zeroed" },
};
// Returns TRUE if the drive seems bootable, FALSE otherwise
@ -591,10 +591,7 @@ BOOL AnalyzeMBR(HANDLE hPhysicalDrive, const char* TargetName)
int i;
fake_fd._handle = (char*)hPhysicalDrive;
fake_fd._sector_size = SelectedDrive.Geometry.BytesPerSector;
// Might need correction, as we use this method for images and we may not have a target UFD yet
if (fake_fd._sector_size < 512)
fake_fd._sector_size = 512;
set_bytes_per_sector(SelectedDrive.Geometry.BytesPerSector);
if (!is_br(fp)) {
uprintf("%s does not have an x86 %s\n", TargetName, mbr_name);
@ -630,7 +627,7 @@ BOOL AnalyzePBR(HANDLE hLogicalVolume)
int i;
fake_fd._handle = (char*)hLogicalVolume;
fake_fd._sector_size = SelectedDrive.Geometry.BytesPerSector;
set_bytes_per_sector(SelectedDrive.Geometry.BytesPerSector);
if (!is_br(fp)) {
uprintf("Volume does not have an x86 %s\n", pbr_name);

View File

@ -2,7 +2,7 @@
* Rufus: The Reliable USB Formatting Utility
* Formatting function calls
* Copyright © 2007-2009 Tom Thornhill/Ridgecrop
* Copyright © 2011-2015 Pete Batard <pete@akeo.ie>
* Copyright © 2011-2016 Pete Batard <pete@akeo.ie>
*
* 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
@ -913,7 +913,7 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive)
}
fake_fd._handle = (char*)hPhysicalDrive;
fake_fd._sector_size = SelectedDrive.Geometry.BytesPerSector;
set_bytes_per_sector(SelectedDrive.Geometry.BytesPerSector);
// What follows is really a case statement with complex conditions listed
// by order of preference
@ -945,7 +945,7 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive)
// Grub4DOS
if ( ((bt == BT_ISO) && (img_report.has_grub4dos)) || (bt == BT_GRUB4DOS) ) {
uprintf(using_msg, "Grub4DOS");
r = write_grub_mbr(fp);
r = write_grub4dos_mbr(fp);
goto notify;
}
@ -959,7 +959,7 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive)
// KolibriOS
if ( (bt == BT_ISO) && (img_report.has_kolibrios) && (IS_FAT(fs))) {
uprintf(using_msg, "KolibriOS");
r = write_kolibri_mbr(fp);
r = write_kolibrios_mbr(fp);
goto notify;
}
@ -996,7 +996,7 @@ static BOOL WriteSBR(HANDLE hPhysicalDrive)
FILE* fp = (FILE*)&fake_fd;
fake_fd._handle = (char*)hPhysicalDrive;
fake_fd._sector_size = SelectedDrive.Geometry.BytesPerSector;
set_bytes_per_sector(SelectedDrive.Geometry.BytesPerSector);
// Ensure that we have sufficient space for the SBR
max_size = IsChecked(IDC_EXTRA_PARTITION) ?
(DWORD)(SelectedDrive.Geometry.BytesPerSector * SelectedDrive.Geometry.SectorsPerTrack) : 1024 * 1024;
@ -1068,7 +1068,7 @@ static BOOL WritePBR(HANDLE hLogicalVolume)
const char* using_msg = "Using %s %s partition boot record\n";
fake_fd._handle = (char*)hLogicalVolume;
fake_fd._sector_size = SelectedDrive.Geometry.BytesPerSector;
set_bytes_per_sector(SelectedDrive.Geometry.BytesPerSector);
switch (ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem))) {
case FS_FAT16:

View File

@ -1,5 +1,5 @@
/******************************************************************
Copyright (C) 2009 Henrik Carlqvist
Copyright (C) 2009-2015 Henrik Carlqvist
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
@ -20,13 +20,35 @@
#include "file.h"
#include "br.h"
unsigned long ulBytesPerSector = 512;
void set_bytes_per_sector(unsigned long ulValue)
{
ulBytesPerSector = ulValue;
if ((ulBytesPerSector < 512) || (ulBytesPerSector > 65536))
ulBytesPerSector = 512;
} /* set_bytes_per_sector */
uint32_t read_windows_disk_signature(FILE *fp)
{
uint32_t tWDS;
if(!read_data(fp, 0x1b8, &tWDS, 4))
return 0;
return tWDS;
} /* read_windows_disk_signature */
int write_windows_disk_signature(FILE *fp, uint32_t tWDS)
{
return write_data(fp, 0x1b8, &tWDS, 4);
} /* write_windows_disk_signature */
int is_br(FILE *fp)
{
/* A "file" is probably some kind of boot record if it contains the magic
chars 0x55, 0xAA at position 0x1FE */
unsigned char aucRef[] = {0x55, 0xAA};
return contains_data(fp, 0x1FE, aucRef, sizeof(aucRef));
return contains_data(fp, 0x1FE, aucRef, sizeof(aucRef));
} /* is_br */
int is_lilo_br(FILE *fp)
@ -36,130 +58,128 @@ int is_lilo_br(FILE *fp)
unsigned char aucRef[] = {'L','I','L','O'};
return ( contains_data(fp, 0x6, aucRef, sizeof(aucRef)) ||
contains_data(fp, 0x2, aucRef, sizeof(aucRef)) );
contains_data(fp, 0x2, aucRef, sizeof(aucRef)) );
} /* is_lilo_br */
int is_dos_mbr(FILE *fp)
{
#include "mbr_dos.h"
unsigned char aucRef[] = {0x55, 0xAA};
return
contains_data(fp, 0x0, mbr_dos_0x0, sizeof(mbr_dos_0x0)) &&
contains_data(fp, 0x1FE, aucRef, sizeof(aucRef));
is_br(fp);
} /* is_dos_mbr */
int is_dos_f2_mbr(FILE *fp)
{
#include "mbr_dos_f2.h"
unsigned char aucRef[] = {0x55, 0xAA};
return
contains_data(fp, 0x0, mbr_dos_f2_0x0, sizeof(mbr_dos_f2_0x0)) &&
contains_data(fp, 0x1FE, aucRef, sizeof(aucRef));
is_br(fp);
} /* is_dos_f2_mbr */
int is_95b_mbr(FILE *fp)
{
#include "mbr_95b.h"
unsigned char aucRef[] = {0x55, 0xAA};
return
contains_data(fp, 0x0, mbr_95b_0x0, sizeof(mbr_95b_0x0)) &&
contains_data(fp, 0x0e0, mbr_95b_0x0e0, sizeof(mbr_95b_0x0e0)) &&
contains_data(fp, 0x1FE, aucRef, sizeof(aucRef));
is_br(fp);
} /* is_95b_mbr */
int is_2000_mbr(FILE *fp)
{
#include "mbr_2000.h"
unsigned char aucRef[] = {0x55, 0xAA};
return
contains_data(fp, 0x0, mbr_2000_0x0, sizeof(mbr_2000_0x0)) &&
contains_data(fp, 0x1FE, aucRef, sizeof(aucRef));
is_br(fp);
} /* is_2000_mbr */
int is_vista_mbr(FILE *fp)
{
#include "mbr_vista.h"
unsigned char aucRef[] = {0x55, 0xAA};
return
contains_data(fp, 0x0, mbr_vista_0x0, sizeof(mbr_vista_0x0)) &&
contains_data(fp, 0x1FE, aucRef, sizeof(aucRef));
is_br(fp);
} /* is_vista_mbr */
int is_win7_mbr(FILE *fp)
{
#include "mbr_win7.h"
unsigned char aucRef[] = {0x55, 0xAA};
return
contains_data(fp, 0x0, mbr_win7_0x0, sizeof(mbr_win7_0x0)) &&
contains_data(fp, 0x1FE, aucRef, sizeof(aucRef));
is_br(fp);
} /* 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_br(fp);
} /* 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_br(fp);
} /* is_reactos_mbr */
int is_grub_mbr(FILE *fp)
int is_grub4dos_mbr(FILE *fp)
{
#include "mbr_grub.h"
unsigned char aucRef[] = {0x55, 0xAA};
return
contains_data(fp, 0x0, mbr_grub_0x0, sizeof(mbr_grub_0x0)) &&
contains_data(fp, 0x1FE, aucRef, sizeof(aucRef));
is_br(fp);
} /* is_grub_mbr */
int is_grub2_mbr(FILE *fp)
{
#include "mbr_grub2.h"
unsigned char aucRef[] = {0x55, 0xAA};
return
contains_data(fp, 0x0, mbr_grub2_0x0, sizeof(mbr_grub2_0x0)) &&
contains_data(fp, 0x1FE, aucRef, sizeof(aucRef));
is_br(fp);
} /* is_grub2_mbr */
int is_kolibri_mbr(FILE *fp)
int is_kolibrios_mbr(FILE *fp)
{
#include "mbr_kolibri.h"
unsigned char aucRef[] = {0x55, 0xAA};
return
contains_data(fp, 0x0, mbr_kolibri_0x0, sizeof(mbr_kolibri_0x0)) &&
contains_data(fp, 0x1FE, aucRef, sizeof(aucRef));
is_br(fp);
} /* is_kolibri_mbr */
int is_syslinux_mbr(FILE *fp)
{
#include "mbr_syslinux.h"
unsigned char aucRef[] = {0x55, 0xAA};
return
contains_data(fp, 0x0, mbr_syslinux_0x0, sizeof(mbr_syslinux_0x0)) &&
contains_data(fp, 0x1FE, aucRef, sizeof(aucRef));
is_br(fp);
} /* is_syslinux_mbr */
int is_syslinux_gpt_mbr(FILE *fp)
{
#include "mbr_gpt_syslinux.h"
return
contains_data(fp, 0x0, mbr_gpt_syslinux_0x0,
sizeof(mbr_gpt_syslinux_0x0)) &&
is_br(fp);
} /* is_syslinux_gpt_mbr */
int is_zero_mbr(FILE *fp)
{
#include "mbr_zero.h"
@ -169,19 +189,37 @@ int is_zero_mbr(FILE *fp)
/* Don't bother to check 55AA signature */
} /* is_zero_mbr */
int is_zero_mbr_with_other_windows_disk_signature(FILE *fp)
{
#include "mbr_zero.h"
return
(!contains_data(fp, 0x0, mbr_zero_0x0, sizeof(mbr_zero_0x0))) &&
contains_data(fp, 0x0, mbr_zero_0x0, 0x1b8);
contains_data(fp, 0x1bc, mbr_zero_0x0, 2);
/* Don't bother to check 55AA signature */
} /* is_zero_mbr_with_other_windows_disk_signature */
int is_zero_mbr_not_including_disk_signature_or_copy_protect(FILE *fp)
{
#include "mbr_zero.h"
return
contains_data(fp, 0x0, mbr_zero_0x0, 0x1b8);
} /* is_zero_mbr_not_including_disk_signature_or_copy_protect */
/* Handle nonstandard sector sizes (such as 4K) by writing
the boot marker at every 512-2 bytes location */
static int write_bootmark(FILE *fp)
{
unsigned char aucRef[] = {0x55, 0xAA};
uint32_t pos = 0x1FE;
FAKE_FD* fd = (FAKE_FD*)fp;
unsigned char aucRef[] = {0x55, 0xAA};
unsigned long pos = 0x1FE;
for (pos = 0x1FE; pos < fd->_sector_size; pos += 0x200) {
if (!write_data(fp, pos, aucRef, sizeof(aucRef)))
return 0;
}
return 1;
for (pos = 0x1FE; pos < ulBytesPerSector; pos += 0x200) {
if (!write_data(fp, pos, aucRef, sizeof(aucRef)))
return 0;
}
return 1;
}
int write_dos_mbr(FILE *fp)
@ -248,7 +286,7 @@ int write_reactos_mbr(FILE *fp)
write_bootmark(fp);
} /* write_reactos_mbr */
int write_kolibri_mbr(FILE *fp)
int write_kolibrios_mbr(FILE *fp)
{
#include "mbr_kolibri.h"
@ -266,7 +304,16 @@ int write_syslinux_mbr(FILE *fp)
write_bootmark(fp);
} /* write_syslinux_mbr */
int write_grub_mbr(FILE *fp)
int write_syslinux_gpt_mbr(FILE *fp)
{
#include "mbr_gpt_syslinux.h"
return
write_data(fp, 0x0, mbr_gpt_syslinux_0x0, sizeof(mbr_gpt_syslinux_0x0)) &&
write_bootmark(fp);
} /* write_syslinux_gpt_mbr */
int write_grub4dos_mbr(FILE *fp)
{
#include "mbr_grub.h"
@ -289,6 +336,6 @@ int write_zero_mbr(FILE *fp)
#include "mbr_zero.h"
return
write_data(fp, 0x0, mbr_zero_0x0, sizeof(mbr_zero_0x0)) &&
write_data(fp, 0x0, mbr_zero_0x0, sizeof(mbr_zero_0x0)) &&
write_bootmark(fp);
} /* write_zero_mbr */

View File

@ -129,5 +129,5 @@ int write_fat_16_ros_br(FILE *fp, int bKeepLabel)
( 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_data(fp, 0x3e, br_fat16_0x3e, sizeof(br_fat16_0x3e)) );
} /* write_fat_16_ros_br */

View File

@ -172,6 +172,57 @@ int write_fat_32_nt_br(FILE *fp, int bKeepLabel)
);
} /* write_fat_32_nt_br */
/* Not used by Rufus */
#if 0
int entire_fat_32_pe_br_matches(FILE *fp)
{
#include "br_fat32_0x0.h"
#include "br_fat32pe_0x52.h"
#include "br_fat32pe_0x3f0.h"
#include "br_fat32pe_0x1800.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_fat32pe_0x52, sizeof(br_fat32pe_0x52)) &&
/* Cluster information might differ between systems */
contains_data(fp, 0x3f0, br_fat32pe_0x3f0, sizeof(br_fat32pe_0x3f0)) &&
contains_data(fp, 0x1800, br_fat32pe_0x1800, sizeof(br_fat32pe_0x1800))
);
} /* entire_fat_32_nt_br_matches */
int write_fat_32_pe_br(FILE *fp, int bKeepLabel)
{
#include "label_11_char.h"
#include "br_fat32_0x0.h"
#include "br_fat32pe_0x52.h"
#include "br_fat32pe_0x3f0.h"
#include "br_fat32pe_0x1800.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_fat32pe_0x52, sizeof(br_fat32pe_0x52)) &&
/* Cluster information is not overwritten, however, it would bo OK
to write 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff here. */
write_data(fp, 0x3f0, br_fat32pe_0x3f0, sizeof(br_fat32pe_0x3f0)) &&
write_data(fp, 0x1800, br_fat32pe_0x1800, sizeof(br_fat32pe_0x1800))
);
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_fat32pe_0x52, sizeof(br_fat32pe_0x52)) &&
/* Cluster information is not overwritten, however, it would bo OK
to write 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff here. */
write_data(fp, 0x3f0, br_fat32pe_0x3f0, sizeof(br_fat32pe_0x3f0)) &&
write_data(fp, 0x1800, br_fat32pe_0x1800, sizeof(br_fat32pe_0x1800))
);
} /* write_fat_32_pe_br */
#endif
int entire_fat_32_ros_br_matches(FILE *fp)
{
#include "br_fat32_0x0.h"

View File

@ -1,6 +1,6 @@
/******************************************************************
Copyright (C) 2009 Henrik Carlqvist
Modified for Rufus/Windows (C) 2011-2015 Pete Batard
Modified for Rufus/Windows (C) 2011-2016 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
@ -23,6 +23,8 @@
#include "../rufus.h"
#include "file.h"
extern unsigned long ulBytesPerSector;
/* Returns the number of bytes written or -1 on error */
int64_t write_sectors(HANDLE hDrive, uint64_t SectorSize,
uint64_t StartSector, uint64_t nSectors,
@ -89,26 +91,37 @@ int64_t read_sectors(HANDLE hDrive, uint64_t SectorSize,
}
/*
* The following calls use a hijacked fp on Windows that contains:
* fp->_handle: a Windows handle
* fp->_sector_size: the sector size
* fp->_offset: a file offset
*/
* The following calls use a hijacked fp on Windows that contains:
* fp->_handle: a Windows handle
* fp->_offset: a file offset
*/
int contains_data(FILE *fp, uint64_t Position,
const void *pData, uint64_t Len)
const void *pData, uint64_t Len)
{
unsigned char aucBuf[MAX_DATA_LEN];
if (!read_data(fp, Position, aucBuf, Len))
return 0;
if (memcmp(pData, aucBuf, (size_t)Len))
return 0;
return 1;
} /* contains_data */
int read_data(FILE *fp, uint64_t Position,
void *pData, uint64_t Len)
{
unsigned char aucBuf[MAX_DATA_LEN];
FAKE_FD* fd = (FAKE_FD*)fp;
HANDLE hDrive = (HANDLE)fd->_handle;
uint64_t SectorSize = (uint64_t)fd->_sector_size;
uint64_t StartSector, EndSector, NumSectors;
Position += fd->_offset;
StartSector = Position/SectorSize;
EndSector = (Position+Len+SectorSize-1)/SectorSize;
StartSector = Position/ulBytesPerSector;
EndSector = (Position+Len+ulBytesPerSector -1)/ulBytesPerSector;
NumSectors = (size_t)(EndSector - StartSector);
if((NumSectors*SectorSize) > MAX_DATA_LEN)
if((NumSectors*ulBytesPerSector) > MAX_DATA_LEN)
{
uprintf("contains_data: please increase MAX_DATA_LEN in file.h\n");
return 0;
@ -120,14 +133,13 @@ int contains_data(FILE *fp, uint64_t Position,
return 0;
}
if(read_sectors(hDrive, SectorSize, StartSector,
if(read_sectors(hDrive, ulBytesPerSector, StartSector,
NumSectors, aucBuf) <= 0)
return 0;
if(memcmp(pData, &aucBuf[Position - StartSector*SectorSize], (size_t)Len))
return 0;
memcpy(pData, &aucBuf[Position - StartSector*ulBytesPerSector], (size_t)Len);
return 1;
} /* contains_data */
} /* read_data */
/* May read/write the same sector many times, but compatible with existing ms-sys */
int write_data(FILE *fp, uint64_t Position,
@ -136,15 +148,14 @@ int write_data(FILE *fp, uint64_t Position,
unsigned char aucBuf[MAX_DATA_LEN];
FAKE_FD* fd = (FAKE_FD*)fp;
HANDLE hDrive = (HANDLE)fd->_handle;
uint64_t SectorSize = (uint64_t)fd->_sector_size;
uint64_t StartSector, EndSector, NumSectors;
Position += fd->_offset;
StartSector = Position/SectorSize;
EndSector = (Position+Len+SectorSize-1)/SectorSize;
StartSector = Position/ulBytesPerSector;
EndSector = (Position+Len+ulBytesPerSector-1)/ulBytesPerSector;
NumSectors = EndSector - StartSector;
if((NumSectors*SectorSize) > MAX_DATA_LEN)
if((NumSectors*ulBytesPerSector) > MAX_DATA_LEN)
{
uprintf("Please increase MAX_DATA_LEN in file.h\n");
return 0;
@ -157,14 +168,14 @@ int write_data(FILE *fp, uint64_t Position,
}
/* Data to write may not be aligned on a sector boundary => read into a sector buffer first */
if(read_sectors(hDrive, SectorSize, StartSector,
if(read_sectors(hDrive, ulBytesPerSector, StartSector,
NumSectors, aucBuf) <= 0)
return 0;
if(!memcpy(&aucBuf[Position - StartSector*SectorSize], pData, (size_t)Len))
if(!memcpy(&aucBuf[Position - StartSector*ulBytesPerSector], pData, (size_t)Len))
return 0;
if(write_sectors(hDrive, SectorSize, StartSector,
if(write_sectors(hDrive, ulBytesPerSector, StartSector,
NumSectors, aucBuf) <= 0)
return 0;
return 1;

View File

@ -2,6 +2,16 @@
#define BR_H
#include <stdio.h>
#include <stdint.h>
/* Sets custom number of bytes per sector, default value is 512 */
void set_bytes_per_sector(unsigned long ulValue);
/* Gets Windows Disk Signature from MBR */
uint32_t read_windows_disk_signature(FILE *fp);
/* Sets a new Windows Disk Signature to MBR */
int write_windows_disk_signature(FILE *fp, uint32_t tWDS);
/* returns TRUE if the file has a boot record, otherwise FALSE.
The file position will change when this function is called! */
@ -46,7 +56,7 @@ int is_reactos_mbr(FILE *fp);
/* returns TRUE if the file has a Grub4DOS master boot record, otherwise
FALSE.The file position will change when this function is called! */
int is_grub_mbr(FILE *fp);
int is_grub4dos_mbr(FILE *fp);
/* returns TRUE if the file has a Grub 2.0 master boot record, otherwise
FALSE.The file position will change when this function is called! */
@ -54,15 +64,21 @@ int is_grub2_mbr(FILE *fp);
/* returns TRUE if the file has a KolibriOS master boot record, otherwise
FALSE.The file position will change when this function is called! */
int is_kolibri_mbr(FILE *fp);
int is_kolibrios_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);
/* returns TRUE if the file has a syslinux GPT master boot record, otherwise
FALSE.The file position will change when this function is called! */
int is_syslinux_gpt_mbr(FILE *fp);
/* returns TRUE if the file has a zeroed master boot record, otherwise
FALSE.The file position will change when this function is called! */
int is_zero_mbr(FILE *fp);
int is_zero_mbr_with_other_windows_disk_signature(FILE *fp);
int is_zero_mbr_not_including_disk_signature_or_copy_protect(FILE *fp);
/* Writes a dos master boot record to a file, returns TRUE on success, otherwise
FALSE */
@ -94,7 +110,7 @@ int write_reactos_mbr(FILE *fp);
/* Writes a Grub4DOS master boot record to a file, returns TRUE on success, otherwise
FALSE */
int write_grub_mbr(FILE *fp);
int write_grub4dos_mbr(FILE *fp);
/* Writes a Grub 2.0 master boot record to a file, returns TRUE on success, otherwise
FALSE */
@ -102,12 +118,16 @@ int write_grub2_mbr(FILE *fp);
/* Writes a KolibriOS master boot record to a file, returns TRUE on success, otherwise
FALSE */
int write_kolibri_mbr(FILE *fp);
int write_kolibrios_mbr(FILE *fp);
/* Writes a syslinux master boot record to a file, returns TRUE on success, otherwise
FALSE */
int write_syslinux_mbr(FILE *fp);
/* Writes a syslinux GPT master boot record to a file, returns TRUE on success, otherwise
FALSE */
int write_syslinux_gpt_mbr(FILE *fp);
/* Writes an empty (zeroed) master boot record to a file, returns TRUE on success, otherwise
FALSE */
int write_zero_mbr(FILE *fp);

View File

@ -38,6 +38,15 @@ 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 NT, otherwise FALSE.
The file position will change when this function is called! */
int entire_fat_32_pe_br_matches(FILE *fp);
/* Writes a FAT32 NT boot record to a file, returns TRUE on success, otherwise
FALSE */
int write_fat_32_pe_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! */

View File

@ -10,7 +10,6 @@
typedef struct {
void *_handle;
uint64_t _offset;
uint32_t _sector_size;
} FAKE_FD;
/* Checks if a file contains a data pattern of length Len at position
@ -18,6 +17,11 @@ typedef struct {
int contains_data(FILE *fp, uint64_t Position,
const void *pData, uint64_t Len);
/* Reads data of length Len at position Position.
The file pointer will change when calling this function! */
int read_data(FILE *fp, uint64_t Position,
void *pData, uint64_t uiLen);
/* Writes a data pattern of length Len at position Position.
The file pointer will change when calling this function! */
int write_data(FILE *fp, uint64_t Position,

View File

@ -0,0 +1,40 @@
/* This version is from gptmbr.bin from syslinux 6.02 */
unsigned char mbr_gpt_syslinux_0x0[] = {
0x33, 0xc0, 0xfa, 0x8e, 0xd8, 0x8e, 0xd0, 0xbc, 0x00, 0x7c, 0x89, 0xe6,
0x06, 0x57, 0x8e, 0xc0, 0xfb, 0xfc, 0xbf, 0x00, 0x06, 0xb9, 0x00, 0x01,
0xf3, 0xa5, 0xea, 0x1f, 0x06, 0x00, 0x00, 0x52, 0x89, 0xe5, 0x83, 0xec,
0x1c, 0x6a, 0x1e, 0xc7, 0x46, 0xfa, 0x00, 0x02, 0x52, 0xb4, 0x41, 0xbb,
0xaa, 0x55, 0x31, 0xc9, 0x30, 0xf6, 0xf9, 0xcd, 0x13, 0x5a, 0xb4, 0x08,
0x72, 0x17, 0x81, 0xfb, 0x55, 0xaa, 0x75, 0x11, 0xd1, 0xe9, 0x73, 0x0d,
0x66, 0xc7, 0x06, 0x59, 0x07, 0xb4, 0x42, 0xeb, 0x13, 0xb4, 0x48, 0x89,
0xe6, 0xcd, 0x13, 0x83, 0xe1, 0x3f, 0x51, 0x0f, 0xb6, 0xc6, 0x40, 0xf7,
0xe1, 0x52, 0x50, 0x66, 0x31, 0xc0, 0x66, 0x99, 0x40, 0xe8, 0xdc, 0x00,
0x8b, 0x4e, 0x56, 0x8b, 0x46, 0x5a, 0x50, 0x51, 0xf7, 0xe1, 0xf7, 0x76,
0xfa, 0x91, 0x41, 0x66, 0x8b, 0x46, 0x4e, 0x66, 0x8b, 0x56, 0x52, 0x53,
0xe8, 0xc4, 0x00, 0xe2, 0xfb, 0x31, 0xf6, 0x5f, 0x59, 0x58, 0x66, 0x8b,
0x15, 0x66, 0x0b, 0x55, 0x04, 0x66, 0x0b, 0x55, 0x08, 0x66, 0x0b, 0x55,
0x0c, 0x74, 0x0c, 0xf6, 0x45, 0x30, 0x04, 0x74, 0x06, 0x21, 0xf6, 0x75,
0x19, 0x89, 0xfe, 0x01, 0xc7, 0xe2, 0xdf, 0x21, 0xf6, 0x75, 0x2e, 0xe8,
0xe1, 0x00, 0x4d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x4f, 0x53,
0x0d, 0x0a, 0xe8, 0xd2, 0x00, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c,
0x65, 0x20, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x20, 0x70, 0x61, 0x72,
0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x0d, 0x0a, 0x91, 0xbf, 0xbe,
0x07, 0x57, 0x66, 0x31, 0xc0, 0xb0, 0x80, 0x66, 0xab, 0xb0, 0xed, 0x66,
0xab, 0x66, 0x8b, 0x44, 0x20, 0x66, 0x8b, 0x54, 0x24, 0xe8, 0x40, 0x00,
0x66, 0x8b, 0x44, 0x28, 0x66, 0x8b, 0x54, 0x2c, 0x66, 0x2b, 0x44, 0x20,
0x66, 0x1b, 0x54, 0x24, 0xe8, 0x70, 0x00, 0xe8, 0x2a, 0x00, 0x66, 0x0f,
0xb7, 0xc1, 0x66, 0xab, 0xf3, 0xa4, 0x5e, 0x66, 0x8b, 0x44, 0x34, 0x66,
0x8b, 0x54, 0x38, 0xe8, 0x22, 0x00, 0x81, 0x3e, 0xfe, 0x7d, 0x55, 0xaa,
0x75, 0x85, 0x89, 0xec, 0x5a, 0x5f, 0x07, 0x66, 0xb8, 0x21, 0x47, 0x50,
0x54, 0xfa, 0xff, 0xe4, 0x66, 0x21, 0xd2, 0x74, 0x04, 0x66, 0x83, 0xc8,
0xff, 0x66, 0xab, 0xc3, 0xbb, 0x00, 0x7c, 0x66, 0x60, 0x66, 0x52, 0x66,
0x50, 0x06, 0x53, 0x6a, 0x01, 0x6a, 0x10, 0x89, 0xe6, 0x66, 0xf7, 0x76,
0xdc, 0xc0, 0xe4, 0x06, 0x88, 0xe1, 0x88, 0xc5, 0x92, 0xf6, 0x76, 0xe0,
0x88, 0xc6, 0x08, 0xe1, 0x41, 0xb8, 0x01, 0x02, 0x8a, 0x56, 0x00, 0xcd,
0x13, 0x8d, 0x64, 0x10, 0x66, 0x61, 0x72, 0x0c, 0x02, 0x7e, 0xfb, 0x66,
0x83, 0xc0, 0x01, 0x66, 0x83, 0xd2, 0x00, 0xc3, 0xe8, 0x0c, 0x00, 0x44,
0x69, 0x73, 0x6b, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x0d, 0x0a, 0x5e,
0xac, 0xb4, 0x0e, 0x8a, 0x3e, 0x62, 0x04, 0xb3, 0x07, 0xcd, 0x10, 0x3c,
0x0a, 0x75, 0xf1, 0xcd, 0x18, 0xf4, 0xeb, 0xfd, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

View File

@ -1,29 +1,40 @@
/* Public domain MBR by H. Peter Anvin supplied with Syslinux */
/* This version from mbr.asm,v 1.6 2--2/10/03 10:02:50 */
/* This version is from mbr.bin from syslinux 6.02 */
unsigned char mbr_syslinux_0x0[] = {
0xfa, 0x31, 0xc0, 0x8e, 0xd8, 0x8e, 0xc0, 0x8e, 0xd0, 0xbc, 0x00, 0x7c,
0xfb, 0xfc, 0x89, 0xe6, 0xbf, 0x00, 0x06, 0xb9, 0x00, 0x01, 0xf3, 0xa5,
0xea, 0x1d, 0x06, 0x00, 0x00, 0x88, 0x16, 0x00, 0x08, 0xb4, 0x08, 0xcd,
0x13, 0x31, 0xc0, 0x88, 0xf0, 0x40, 0xa3, 0xec, 0x06, 0x80, 0xe1, 0x3f,
0x88, 0x0e, 0xee, 0x06, 0xbe, 0xbe, 0x07, 0x31, 0xc0, 0xb9, 0x04, 0x00,
0xf6, 0x04, 0x80, 0x74, 0x03, 0x40, 0x89, 0xf7, 0x83, 0xc6, 0x10, 0xe2,
0xf3, 0x83, 0xf8, 0x01, 0x75, 0x73, 0x8a, 0x16, 0x00, 0x08, 0xb8, 0x00,
0x41, 0xbb, 0xaa, 0x55, 0x31, 0xc9, 0x30, 0xf6, 0xf9, 0xcd, 0x13, 0x72,
0x23, 0x81, 0xfb, 0x55, 0xaa, 0x75, 0x1d, 0xf6, 0xc1, 0x01, 0x74, 0x18,
0x57, 0xbe, 0xdc, 0x06, 0x8b, 0x5d, 0x08, 0x89, 0x5c, 0x08, 0x8b, 0x5d,
0x0a, 0x89, 0x5c, 0x0a, 0x8a, 0x16, 0x00, 0x08, 0xb4, 0x42, 0xeb, 0x2a,
0x57, 0x8b, 0x45, 0x08, 0x8b, 0x55, 0x0a, 0xf7, 0x36, 0xee, 0x06, 0x42,
0x89, 0xd1, 0x31, 0xd2, 0xf7, 0x36, 0xec, 0x06, 0x88, 0xc5, 0xd1, 0xe8,
0xd1, 0xe8, 0x24, 0xc0, 0x08, 0xc1, 0x88, 0xd6, 0x8a, 0x16, 0x00, 0x08,
0xbb, 0x00, 0x7c, 0xb8, 0x01, 0x02, 0xcd, 0x13, 0x72, 0x16, 0x5e, 0x81,
0x3e, 0xfe, 0x7d, 0x55, 0xaa, 0x75, 0x08, 0xfa, 0xea, 0x00, 0x7c, 0x00,
0x00, 0x77, 0x05, 0xbe, 0xf0, 0x06, 0xeb, 0x03, 0xbe, 0x0b, 0x07, 0xac,
0x30, 0xc0, 0x74, 0x09, 0xb4, 0x0e, 0xbb, 0x07, 0x00, 0xcd, 0x10, 0xeb,
0xf2, 0xeb, 0xfe, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x7c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x4d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x6f, 0x70, 0x65, 0x72,
0x61, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d,
0x0d, 0x0a, 0x00, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6e, 0x67,
0x20, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x6c, 0x6f, 0x61, 0x64,
0x69, 0x6e, 0x67, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x0d, 0x0a, 0x00
0x33, 0xc0, 0xfa, 0x8e, 0xd8, 0x8e, 0xd0, 0xbc, 0x00, 0x7c, 0x89, 0xe6,
0x06, 0x57, 0x8e, 0xc0, 0xfb, 0xfc, 0xbf, 0x00, 0x06, 0xb9, 0x00, 0x01,
0xf3, 0xa5, 0xea, 0x1f, 0x06, 0x00, 0x00, 0x52, 0x52, 0xb4, 0x41, 0xbb,
0xaa, 0x55, 0x31, 0xc9, 0x30, 0xf6, 0xf9, 0xcd, 0x13, 0x72, 0x13, 0x81,
0xfb, 0x55, 0xaa, 0x75, 0x0d, 0xd1, 0xe9, 0x73, 0x09, 0x66, 0xc7, 0x06,
0x8d, 0x06, 0xb4, 0x42, 0xeb, 0x15, 0x5a, 0xb4, 0x08, 0xcd, 0x13, 0x83,
0xe1, 0x3f, 0x51, 0x0f, 0xb6, 0xc6, 0x40, 0xf7, 0xe1, 0x52, 0x50, 0x66,
0x31, 0xc0, 0x66, 0x99, 0xe8, 0x66, 0x00, 0xe8, 0x35, 0x01, 0x4d, 0x69,
0x73, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74,
0x69, 0x6e, 0x67, 0x20, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x0d,
0x0a, 0x66, 0x60, 0x66, 0x31, 0xd2, 0xbb, 0x00, 0x7c, 0x66, 0x52, 0x66,
0x50, 0x06, 0x53, 0x6a, 0x01, 0x6a, 0x10, 0x89, 0xe6, 0x66, 0xf7, 0x36,
0xf4, 0x7b, 0xc0, 0xe4, 0x06, 0x88, 0xe1, 0x88, 0xc5, 0x92, 0xf6, 0x36,
0xf8, 0x7b, 0x88, 0xc6, 0x08, 0xe1, 0x41, 0xb8, 0x01, 0x02, 0x8a, 0x16,
0xfa, 0x7b, 0xcd, 0x13, 0x8d, 0x64, 0x10, 0x66, 0x61, 0xc3, 0xe8, 0xc4,
0xff, 0xbe, 0xbe, 0x7d, 0xbf, 0xbe, 0x07, 0xb9, 0x20, 0x00, 0xf3, 0xa5,
0xc3, 0x66, 0x60, 0x89, 0xe5, 0xbb, 0xbe, 0x07, 0xb9, 0x04, 0x00, 0x31,
0xc0, 0x53, 0x51, 0xf6, 0x07, 0x80, 0x74, 0x03, 0x40, 0x89, 0xde, 0x83,
0xc3, 0x10, 0xe2, 0xf3, 0x48, 0x74, 0x5b, 0x79, 0x39, 0x59, 0x5b, 0x8a,
0x47, 0x04, 0x3c, 0x0f, 0x74, 0x06, 0x24, 0x7f, 0x3c, 0x05, 0x75, 0x22,
0x66, 0x8b, 0x47, 0x08, 0x66, 0x8b, 0x56, 0x14, 0x66, 0x01, 0xd0, 0x66,
0x21, 0xd2, 0x75, 0x03, 0x66, 0x89, 0xc2, 0xe8, 0xac, 0xff, 0x72, 0x03,
0xe8, 0xb6, 0xff, 0x66, 0x8b, 0x46, 0x1c, 0xe8, 0xa0, 0xff, 0x83, 0xc3,
0x10, 0xe2, 0xcc, 0x66, 0x61, 0xc3, 0xe8, 0x76, 0x00, 0x4d, 0x75, 0x6c,
0x74, 0x69, 0x70, 0x6c, 0x65, 0x20, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65,
0x20, 0x70, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e,
0x0d, 0x0a, 0x66, 0x8b, 0x44, 0x08, 0x66, 0x03, 0x46, 0x1c, 0x66, 0x89,
0x44, 0x08, 0xe8, 0x30, 0xff, 0x72, 0x27, 0x66, 0x81, 0x3e, 0x00, 0x7c,
0x58, 0x46, 0x53, 0x42, 0x75, 0x09, 0x66, 0x83, 0xc0, 0x04, 0xe8, 0x1c,
0xff, 0x72, 0x13, 0x81, 0x3e, 0xfe, 0x7d, 0x55, 0xaa, 0x0f, 0x85, 0xf2,
0xfe, 0xbc, 0xfa, 0x7b, 0x5a, 0x5f, 0x07, 0xfa, 0xff, 0xe4, 0xe8, 0x1e,
0x00, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x73,
0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x20, 0x65,
0x72, 0x72, 0x6f, 0x72, 0x2e, 0x0d, 0x0a, 0x5e, 0xac, 0xb4, 0x0e, 0x8a,
0x3e, 0x62, 0x04, 0xb3, 0x07, 0xcd, 0x10, 0x3c, 0x0a, 0x75, 0xf1, 0xcd,
0x18, 0xf4, 0xeb, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

View File

@ -1,4 +1,4 @@
/* First 440 bytes of a zeroed MBR (disk signature is excluded) */
/* First 446 bytes of a zeroed MBR*/
unsigned char mbr_zero_0x0[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ -36,4 +36,6 @@ unsigned char mbr_zero_0x0[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00
};

View File

@ -10,7 +10,7 @@ int write_partition_number_of_heads(FILE *fp, int iHeads);
int write_partition_start_sector_number(FILE *fp, int iStartSector);
/* Writes a physical disk drive id of 0x80 (for C:) to a partition */
int write_partition_physical_disk_drive_id_fat16(FILE *fp);
int write_partition_physical_disk_drive_id_fat32(FILE *fp);
int write_partition_physical_disk_drive_id_fat16(FILE *fp);
#endif

View File

@ -55,13 +55,13 @@ int write_partition_start_sector_number(FILE *fp, int iStartSector)
int write_partition_physical_disk_drive_id_fat32(FILE *fp)
{
unsigned char ucId = 0x80; /* C: */
return write_data(fp, 0x40, &ucId, 1);
} /* write_partition_physical_disk_drive_id_fat32 */
int write_partition_physical_disk_drive_id_fat16(FILE *fp)
{
unsigned char ucId = 0x80; /* C: */
return write_data(fp, 0x24, &ucId, 1);
} /* write_partition_physical_disk_drive_id_fat16 */

View File

@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 242, 376
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Rufus 2.7.823"
CAPTION "Rufus 2.7.824"
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
@ -319,8 +319,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,7,823,0
PRODUCTVERSION 2,7,823,0
FILEVERSION 2,7,824,0
PRODUCTVERSION 2,7,824,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -337,13 +337,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "2.7.823"
VALUE "FileVersion", "2.7.824"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "2.7.823"
VALUE "ProductVersion", "2.7.824"
END
END
BLOCK "VarFileInfo"