[core] clean up the RUFUS_DRIVE_INFO struct

* Remove the duplication of DISK_GEOMETRY to keep only the variables we actually use
* Also set rufus-next to 2.10
This commit is contained in:
Pete Batard 2016-05-23 12:19:11 +01:00
parent 258a4f7ca0
commit 81673ade26
8 changed files with 75 additions and 72 deletions

20
configure vendored
View file

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for rufus 2.9. # Generated by GNU Autoconf 2.69 for rufus 2.10.
# #
# Report bugs to <https://github.com/pbatard/rufus/issues>. # Report bugs to <https://github.com/pbatard/rufus/issues>.
# #
@ -580,8 +580,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='rufus' PACKAGE_NAME='rufus'
PACKAGE_TARNAME='rufus' PACKAGE_TARNAME='rufus'
PACKAGE_VERSION='2.9' PACKAGE_VERSION='2.10'
PACKAGE_STRING='rufus 2.9' PACKAGE_STRING='rufus 2.10'
PACKAGE_BUGREPORT='https://github.com/pbatard/rufus/issues' PACKAGE_BUGREPORT='https://github.com/pbatard/rufus/issues'
PACKAGE_URL='http://rufus.akeo.ie' PACKAGE_URL='http://rufus.akeo.ie'
@ -1228,7 +1228,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures rufus 2.9 to adapt to many kinds of systems. \`configure' configures rufus 2.10 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1294,7 +1294,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of rufus 2.9:";; short | recursive ) echo "Configuration of rufus 2.10:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
@ -1385,7 +1385,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
rufus configure 2.9 rufus configure 2.10
generated by GNU Autoconf 2.69 generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc. Copyright (C) 2012 Free Software Foundation, Inc.
@ -1440,7 +1440,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by rufus $as_me 2.9, which was It was created by rufus $as_me 2.10, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@ $ $0 $@
@ -2303,7 +2303,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE='rufus' PACKAGE='rufus'
VERSION='2.9' VERSION='2.10'
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
@ -4482,7 +4482,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by rufus $as_me 2.9, which was This file was extended by rufus $as_me 2.10, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@ -4536,7 +4536,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ ac_cs_version="\\
rufus config.status 2.9 rufus config.status 2.10
configured by $0, generated by GNU Autoconf 2.69, configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"

View file

@ -1,4 +1,4 @@
AC_INIT([rufus], [2.9], [https://github.com/pbatard/rufus/issues], [rufus], [http://rufus.akeo.ie]) AC_INIT([rufus], [2.10], [https://github.com/pbatard/rufus/issues], [rufus], [http://rufus.akeo.ie])
AM_INIT_AUTOMAKE([-Wno-portability foreign no-dist no-dependencies]) AM_INIT_AUTOMAKE([-Wno-portability foreign no-dist no-dependencies])
AC_CONFIG_SRCDIR([src/rufus.c]) AC_CONFIG_SRCDIR([src/rufus.c])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])

View file

@ -592,7 +592,7 @@ BOOL AnalyzeMBR(HANDLE hPhysicalDrive, const char* TargetName)
int i; int i;
fake_fd._handle = (char*)hPhysicalDrive; fake_fd._handle = (char*)hPhysicalDrive;
set_bytes_per_sector(SelectedDrive.Geometry.BytesPerSector); set_bytes_per_sector(SelectedDrive.SectorSize);
if (!is_br(fp)) { if (!is_br(fp)) {
uprintf("%s does not have an x86 %s\n", TargetName, mbr_name); uprintf("%s does not have an x86 %s\n", TargetName, mbr_name);
@ -628,7 +628,7 @@ BOOL AnalyzePBR(HANDLE hLogicalVolume)
int i; int i;
fake_fd._handle = (char*)hLogicalVolume; fake_fd._handle = (char*)hLogicalVolume;
set_bytes_per_sector(SelectedDrive.Geometry.BytesPerSector); set_bytes_per_sector(SelectedDrive.SectorSize);
if (!is_br(fp)) { if (!is_br(fp)) {
uprintf("Volume does not have an x86 %s\n", pbr_name); uprintf("Volume does not have an x86 %s\n", pbr_name);
@ -690,15 +690,18 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys
safe_closehandle(hPhysical); safe_closehandle(hPhysical);
return 0; return 0;
} }
if (DiskGeometry->Geometry.BytesPerSector < 512) {
suprintf("Warning: Drive 0x%02x reports a sector size of %d - Correcting to 512 bytes.\n",
DriveIndex, DiskGeometry->Geometry.BytesPerSector);
DiskGeometry->Geometry.BytesPerSector = 512;
}
SelectedDrive.DiskSize = DiskGeometry->DiskSize.QuadPart; SelectedDrive.DiskSize = DiskGeometry->DiskSize.QuadPart;
memcpy(&SelectedDrive.Geometry, &DiskGeometry->Geometry, sizeof(DISK_GEOMETRY)); SelectedDrive.SectorSize = DiskGeometry->Geometry.BytesPerSector;
suprintf("Disk type: %s, Sector Size: %d bytes\n", (DiskGeometry->Geometry.MediaType == FixedMedia)?"Fixed":"Removable", if (SelectedDrive.SectorSize < 512) {
DiskGeometry->Geometry.BytesPerSector); suprintf("Warning: Drive 0x%02x reports a sector size of %d - Correcting to 512 bytes.\n",
DriveIndex, SelectedDrive.SectorSize);
SelectedDrive.SectorSize = 512;
}
SelectedDrive.SectorsPerTrack = DiskGeometry->Geometry.SectorsPerTrack;
SelectedDrive.MediaType = DiskGeometry->Geometry.MediaType;
suprintf("Disk type: %s, Sector Size: %d bytes\n", (SelectedDrive.MediaType == FixedMedia)?"Fixed":"Removable",
SelectedDrive.SectorSize);
suprintf("Cylinders: %" PRIi64 ", TracksPerCylinder: %d, SectorsPerTrack: %d\n", suprintf("Cylinders: %" PRIi64 ", TracksPerCylinder: %d, SectorsPerTrack: %d\n",
DiskGeometry->Geometry.Cylinders, DiskGeometry->Geometry.TracksPerCylinder, DiskGeometry->Geometry.SectorsPerTrack); DiskGeometry->Geometry.Cylinders, DiskGeometry->Geometry.TracksPerCylinder, DiskGeometry->Geometry.SectorsPerTrack);
@ -1031,7 +1034,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
BOOL r; BOOL r;
DWORD i, size, bufsize, pn = 0; DWORD i, size, bufsize, pn = 0;
LONGLONG main_part_size_in_sectors, extra_part_size_in_tracks = 0, ms_efi_size; LONGLONG main_part_size_in_sectors, extra_part_size_in_tracks = 0, ms_efi_size;
const LONGLONG bytes_per_track = ((LONGLONG)SelectedDrive.Geometry.SectorsPerTrack) * SelectedDrive.Geometry.BytesPerSector; const LONGLONG bytes_per_track = ((LONGLONG)SelectedDrive.SectorsPerTrack) * SelectedDrive.SectorSize;
PrintInfoDebug(0, MSG_238, PartitionTypeName[partition_style]); PrintInfoDebug(0, MSG_238, PartitionTypeName[partition_style]);
@ -1078,7 +1081,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
// Set our main data partition // Set our main data partition
main_part_size_in_sectors = (SelectedDrive.DiskSize - DriveLayoutEx.PartitionEntry[pn].StartingOffset.QuadPart) / main_part_size_in_sectors = (SelectedDrive.DiskSize - DriveLayoutEx.PartitionEntry[pn].StartingOffset.QuadPart) /
// Need 33 sectors at the end for secondary GPT // Need 33 sectors at the end for secondary GPT
SelectedDrive.Geometry.BytesPerSector - ((partition_style == PARTITION_STYLE_GPT)?33:0); SelectedDrive.SectorSize - ((partition_style == PARTITION_STYLE_GPT)?33:0);
if (main_part_size_in_sectors <= 0) if (main_part_size_in_sectors <= 0)
return FALSE; return FALSE;
@ -1088,9 +1091,9 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
if (extra_partitions & XP_EFI) { if (extra_partitions & XP_EFI) {
// The size of the EFI partition depends on the minimum size we're able to format in FAT32, // The size of the EFI partition depends on the minimum size we're able to format in FAT32,
// which in turn depends on the cluster size used, which in turn depends on the disk sector size. // which in turn depends on the cluster size used, which in turn depends on the disk sector size.
if (SelectedDrive.Geometry.BytesPerSector <= 1024) if (SelectedDrive.SectorSize <= 1024)
ms_efi_size = 100*MB; ms_efi_size = 100*MB;
else if (SelectedDrive.Geometry.BytesPerSector <= 4096) else if (SelectedDrive.SectorSize <= 4096)
ms_efi_size = 300*MB; ms_efi_size = 300*MB;
else else
ms_efi_size = 1200*MB; // That'll teach you to have a nonstandard disk! ms_efi_size = 1200*MB; // That'll teach you to have a nonstandard disk!
@ -1101,12 +1104,12 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
extra_part_size_in_tracks = 1; // One track for the extra partition extra_part_size_in_tracks = 1; // One track for the extra partition
uprintf("Reserved %" PRIi64" tracks (%s) for extra partition", extra_part_size_in_tracks, uprintf("Reserved %" PRIi64" tracks (%s) for extra partition", extra_part_size_in_tracks,
SizeToHumanReadable(extra_part_size_in_tracks * bytes_per_track, TRUE, FALSE)); SizeToHumanReadable(extra_part_size_in_tracks * bytes_per_track, TRUE, FALSE));
main_part_size_in_sectors = ((main_part_size_in_sectors / SelectedDrive.Geometry.SectorsPerTrack) - main_part_size_in_sectors = ((main_part_size_in_sectors / SelectedDrive.SectorsPerTrack) -
extra_part_size_in_tracks) * SelectedDrive.Geometry.SectorsPerTrack; extra_part_size_in_tracks) * SelectedDrive.SectorsPerTrack;
if (main_part_size_in_sectors <= 0) if (main_part_size_in_sectors <= 0)
return FALSE; return FALSE;
} }
DriveLayoutEx.PartitionEntry[pn].PartitionLength.QuadPart = main_part_size_in_sectors * SelectedDrive.Geometry.BytesPerSector; DriveLayoutEx.PartitionEntry[pn].PartitionLength.QuadPart = main_part_size_in_sectors * SelectedDrive.SectorSize;
if (partition_style == PARTITION_STYLE_MBR) { if (partition_style == PARTITION_STYLE_MBR) {
DriveLayoutEx.PartitionEntry[pn].Mbr.BootIndicator = IsChecked(IDC_BOOT); DriveLayoutEx.PartitionEntry[pn].Mbr.BootIndicator = IsChecked(IDC_BOOT);
switch (file_system) { switch (file_system) {
@ -1139,7 +1142,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
DriveLayoutEx.PartitionEntry[pn].StartingOffset.QuadPart = DriveLayoutEx.PartitionEntry[pn-1].StartingOffset.QuadPart + DriveLayoutEx.PartitionEntry[pn].StartingOffset.QuadPart = DriveLayoutEx.PartitionEntry[pn-1].StartingOffset.QuadPart +
DriveLayoutEx.PartitionEntry[pn-1].PartitionLength.QuadPart; DriveLayoutEx.PartitionEntry[pn-1].PartitionLength.QuadPart;
DriveLayoutEx.PartitionEntry[pn].PartitionLength.QuadPart = (extra_partitions & XP_UEFI_NTFS)?uefi_ntfs_size: DriveLayoutEx.PartitionEntry[pn].PartitionLength.QuadPart = (extra_partitions & XP_UEFI_NTFS)?uefi_ntfs_size:
extra_part_size_in_tracks * SelectedDrive.Geometry.SectorsPerTrack * SelectedDrive.Geometry.BytesPerSector; extra_part_size_in_tracks * SelectedDrive.SectorsPerTrack * SelectedDrive.SectorSize;
if (partition_style == PARTITION_STYLE_GPT) { if (partition_style == PARTITION_STYLE_GPT) {
DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionType = (extra_partitions & XP_UEFI_NTFS)? DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionType = (extra_partitions & XP_UEFI_NTFS)?
PARTITION_BASIC_DATA_GUID:PARTITION_SYSTEM_GUID; PARTITION_BASIC_DATA_GUID:PARTITION_SYSTEM_GUID;
@ -1149,7 +1152,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
DriveLayoutEx.PartitionEntry[pn].Mbr.PartitionType = (extra_partitions & XP_UEFI_NTFS)?0xef:RUFUS_EXTRA_PARTITION_TYPE; DriveLayoutEx.PartitionEntry[pn].Mbr.PartitionType = (extra_partitions & XP_UEFI_NTFS)?0xef:RUFUS_EXTRA_PARTITION_TYPE;
if (extra_partitions & XP_COMPAT) if (extra_partitions & XP_COMPAT)
// Set the one track compatibility partition to be all hidden sectors // Set the one track compatibility partition to be all hidden sectors
DriveLayoutEx.PartitionEntry[pn].Mbr.HiddenSectors = SelectedDrive.Geometry.SectorsPerTrack; DriveLayoutEx.PartitionEntry[pn].Mbr.HiddenSectors = SelectedDrive.SectorsPerTrack;
} }
// We need to write the UEFI:NTFS partition before we refresh the disk // We need to write the UEFI:NTFS partition before we refresh the disk
@ -1207,8 +1210,8 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
DriveLayoutEx.PartitionStyle = PARTITION_STYLE_GPT; DriveLayoutEx.PartitionStyle = PARTITION_STYLE_GPT;
DriveLayoutEx.PartitionCount = pn; DriveLayoutEx.PartitionCount = pn;
// At the very least, a GPT disk has 34 reserved sectors at the beginning and 33 at the end. // At the very least, a GPT disk has 34 reserved sectors at the beginning and 33 at the end.
DriveLayoutEx.Type.Gpt.StartingUsableOffset.QuadPart = 34 * SelectedDrive.Geometry.BytesPerSector; DriveLayoutEx.Type.Gpt.StartingUsableOffset.QuadPart = 34 * SelectedDrive.SectorSize;
DriveLayoutEx.Type.Gpt.UsableLength.QuadPart = SelectedDrive.DiskSize - (34+33) * SelectedDrive.Geometry.BytesPerSector; DriveLayoutEx.Type.Gpt.UsableLength.QuadPart = SelectedDrive.DiskSize - (34+33) * SelectedDrive.SectorSize;
DriveLayoutEx.Type.Gpt.MaxPartitionCount = MAX_GPT_PARTITIONS; DriveLayoutEx.Type.Gpt.MaxPartitionCount = MAX_GPT_PARTITIONS;
DriveLayoutEx.Type.Gpt.DiskId = CreateDisk.Gpt.DiskId; DriveLayoutEx.Type.Gpt.DiskId = CreateDisk.Gpt.DiskId;
break; break;

View file

@ -57,14 +57,16 @@ static __inline BOOL UnlockDrive(HANDLE hDrive) {
/* Current drive info */ /* Current drive info */
typedef struct { typedef struct {
DWORD DeviceNumber;
LONGLONG DiskSize; LONGLONG DiskSize;
DISK_GEOMETRY Geometry; DWORD DeviceNumber;
DWORD SectorsPerTrack;
DWORD SectorSize;
DWORD FirstSector; DWORD FirstSector;
char proposed_label[16]; MEDIA_TYPE MediaType;
int PartitionType; int PartitionType;
int nPartitions; // number of partitions we actually care about int nPartitions; // number of partitions we actually care about
int FSType; int FSType;
char proposed_label[16];
BOOL has_protective_mbr; BOOL has_protective_mbr;
BOOL has_mbr_uefi_marker; BOOL has_mbr_uefi_marker;
struct { struct {

View file

@ -747,7 +747,7 @@ static BOOL FormatDrive(DWORD DriveIndex)
fs_index = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); fs_index = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
uprintf("%s format was selected\n", IsChecked(IDC_QUICKFORMAT)?"Quick":"Slow"); uprintf("%s format was selected\n", IsChecked(IDC_QUICKFORMAT)?"Quick":"Slow");
pfFormatEx(wVolumeName, SelectedDrive.Geometry.MediaType, wFSType, wLabel, pfFormatEx(wVolumeName, SelectedDrive.MediaType, wFSType, wLabel,
IsChecked(IDC_QUICKFORMAT), ulClusterSize, FormatExCallback); IsChecked(IDC_QUICKFORMAT), ulClusterSize, FormatExCallback);
if ((fs == FS_NTFS) && (enable_ntfs_compression) && (pfEnableVolumeCompression != NULL)) { if ((fs == FS_NTFS) && (enable_ntfs_compression) && (pfEnableVolumeCompression != NULL)) {
@ -859,14 +859,14 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive)
// FormatEx rewrites the MBR and removes the LBA attribute of FAT16 // FormatEx rewrites the MBR and removes the LBA attribute of FAT16
// and FAT32 partitions - we need to correct this in the MBR // and FAT32 partitions - we need to correct this in the MBR
buf = (unsigned char*)malloc(SelectedDrive.Geometry.BytesPerSector); buf = (unsigned char*)malloc(SelectedDrive.SectorSize);
if (buf == NULL) { if (buf == NULL) {
uprintf("Could not allocate memory for MBR"); uprintf("Could not allocate memory for MBR");
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_NOT_ENOUGH_MEMORY; FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_NOT_ENOUGH_MEMORY;
goto out; goto out;
} }
if (!read_sectors(hPhysicalDrive, SelectedDrive.Geometry.BytesPerSector, 0, 1, buf)) { if (!read_sectors(hPhysicalDrive, SelectedDrive.SectorSize, 0, 1, buf)) {
uprintf("Could not read MBR\n"); uprintf("Could not read MBR\n");
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_READ_FAULT; FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_READ_FAULT;
goto out; goto out;
@ -897,14 +897,14 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive)
uprintf("Set bootable USB partition as 0x%02X\n", buf[0x1be]); uprintf("Set bootable USB partition as 0x%02X\n", buf[0x1be]);
} }
if (!write_sectors(hPhysicalDrive, SelectedDrive.Geometry.BytesPerSector, 0, 1, buf)) { if (!write_sectors(hPhysicalDrive, SelectedDrive.SectorSize, 0, 1, buf)) {
uprintf("Could not write MBR\n"); uprintf("Could not write MBR\n");
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_FAULT; FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_FAULT;
goto out; goto out;
} }
fake_fd._handle = (char*)hPhysicalDrive; fake_fd._handle = (char*)hPhysicalDrive;
set_bytes_per_sector(SelectedDrive.Geometry.BytesPerSector); set_bytes_per_sector(SelectedDrive.SectorSize);
// What follows is really a case statement with complex conditions listed // What follows is really a case statement with complex conditions listed
// by order of preference // by order of preference
@ -987,10 +987,10 @@ static BOOL WriteSBR(HANDLE hPhysicalDrive)
FILE* fp = (FILE*)&fake_fd; FILE* fp = (FILE*)&fake_fd;
fake_fd._handle = (char*)hPhysicalDrive; fake_fd._handle = (char*)hPhysicalDrive;
set_bytes_per_sector(SelectedDrive.Geometry.BytesPerSector); set_bytes_per_sector(SelectedDrive.SectorSize);
// Ensure that we have sufficient space for the SBR // Ensure that we have sufficient space for the SBR
max_size = IsChecked(IDC_EXTRA_PARTITION) ? max_size = IsChecked(IDC_EXTRA_PARTITION) ?
(DWORD)(SelectedDrive.Geometry.BytesPerSector * SelectedDrive.Geometry.SectorsPerTrack) : 1*MB; (DWORD)(SelectedDrive.SectorsPerTrack * SelectedDrive.SectorSize) : 1*MB;
max_size -= mbr_size; max_size -= mbr_size;
// Syslinux has precedence over Grub // Syslinux has precedence over Grub
if ((bt == BT_ISO) && (!HAS_SYSLINUX(img_report))) { if ((bt == BT_ISO) && (!HAS_SYSLINUX(img_report))) {
@ -1059,7 +1059,7 @@ static BOOL WritePBR(HANDLE hLogicalVolume)
const char* using_msg = "Using %s %s partition boot record\n"; const char* using_msg = "Using %s %s partition boot record\n";
fake_fd._handle = (char*)hLogicalVolume; fake_fd._handle = (char*)hLogicalVolume;
set_bytes_per_sector(SelectedDrive.Geometry.BytesPerSector); set_bytes_per_sector(SelectedDrive.SectorSize);
switch (ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem))) { switch (ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem))) {
case FS_FAT16: case FS_FAT16:
@ -1103,7 +1103,7 @@ static BOOL WritePBR(HANDLE hLogicalVolume)
// Disk Drive ID needs to be corrected on XP // Disk Drive ID needs to be corrected on XP
if (!write_partition_physical_disk_drive_id_fat32(fp)) if (!write_partition_physical_disk_drive_id_fat32(fp))
break; break;
fake_fd._offset += 6 * SelectedDrive.Geometry.BytesPerSector; fake_fd._offset += 6 * SelectedDrive.SectorSize;
} }
return TRUE; return TRUE;
case FS_NTFS: case FS_NTFS:
@ -1281,7 +1281,7 @@ static BOOL SetupWinToGo(const char* drive_name, BOOL use_ms_efi)
uprintf("Windows To Go mode selected"); uprintf("Windows To Go mode selected");
// Additional sanity checks // Additional sanity checks
if ( ((use_ms_efi) && (SelectedDrive.Geometry.MediaType != FixedMedia)) || if ( ((use_ms_efi) && (SelectedDrive.MediaType != FixedMedia)) ||
((nWindowsVersion < WINDOWS_8) || ((WimExtractCheck() & 4) == 0)) ) { ((nWindowsVersion < WINDOWS_8) || ((WimExtractCheck() & 4) == 0)) ) {
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_NOT_SUPPORTED; FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_NOT_SUPPORTED;
return FALSE; return FALSE;
@ -1324,18 +1324,18 @@ static BOOL SetupWinToGo(const char* drive_name, BOOL use_ms_efi)
// According to Ubuntu (https://bugs.launchpad.net/ubuntu/+source/partman-efi/+bug/811485) you want to use FAT32. // According to Ubuntu (https://bugs.launchpad.net/ubuntu/+source/partman-efi/+bug/811485) you want to use FAT32.
// However, you have to be careful that the cluster size needs to be greater or equal to the sector size, which // However, you have to be careful that the cluster size needs to be greater or equal to the sector size, which
// in turn has an impact on the minimum EFI partition size we can create (see ms_efi_size_MB in drive.c) // in turn has an impact on the minimum EFI partition size we can create (see ms_efi_size_MB in drive.c)
if (SelectedDrive.Geometry.BytesPerSector <= 1024) if (SelectedDrive.SectorSize <= 1024)
cluster_size = 1024; cluster_size = 1024;
else if (SelectedDrive.Geometry.BytesPerSector <= 4096) else if (SelectedDrive.SectorSize <= 4096)
cluster_size = 4096; cluster_size = 4096;
else // Go for broke else // Go for broke
cluster_size = (ULONG)SelectedDrive.Geometry.BytesPerSector; cluster_size = (ULONG)SelectedDrive.SectorSize;
fs_index = 1; // FAT32 fs_index = 1; // FAT32
task_number = 0; task_number = 0;
wVolumeName[0] = ms_efi[0]; wVolumeName[0] = ms_efi[0];
// Boy do you *NOT* want to specify a label here, and spend HOURS figuring out why your EFI partition cannot boot... // Boy do you *NOT* want to specify a label here, and spend HOURS figuring out why your EFI partition cannot boot...
pfFormatEx(wVolumeName, SelectedDrive.Geometry.MediaType, L"FAT32", L"", TRUE, cluster_size, FormatExCallback); pfFormatEx(wVolumeName, SelectedDrive.MediaType, L"FAT32", L"", TRUE, cluster_size, FormatExCallback);
if (IS_ERROR(FormatStatus)) { if (IS_ERROR(FormatStatus)) {
uprintf("Failed to format EFI partition"); uprintf("Failed to format EFI partition");
AltUnmountVolume(ms_efi); AltUnmountVolume(ms_efi);
@ -1460,7 +1460,6 @@ static void update_progress(const uint64_t processed_bytes)
/* Write an image file or zero a drive */ /* Write an image file or zero a drive */
static BOOL WriteDrive(HANDLE hPhysicalDrive, HANDLE hSourceImage) static BOOL WriteDrive(HANDLE hPhysicalDrive, HANDLE hSourceImage)
{ {
const DWORD SectorSize = SelectedDrive.Geometry.BytesPerSector;
BOOL s, ret = FALSE; BOOL s, ret = FALSE;
LARGE_INTEGER li; LARGE_INTEGER li;
DWORD rSize, wSize, BufSize; DWORD rSize, wSize, BufSize;
@ -1482,15 +1481,15 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, HANDLE hSourceImage)
} else { } else {
uprintf(hSourceImage?"Writing Image...":"Zeroing drive..."); uprintf(hSourceImage?"Writing Image...":"Zeroing drive...");
// Our buffer size must be a multiple of the sector size // Our buffer size must be a multiple of the sector size
BufSize = ((DD_BUFFER_SIZE + SectorSize - 1) / SectorSize) * SectorSize; BufSize = ((DD_BUFFER_SIZE + SelectedDrive.SectorSize - 1) / SelectedDrive.SectorSize) * SelectedDrive.SectorSize;
buffer = (uint8_t*)calloc(BufSize + SectorSize, 1); // +1 sector for align buffer = (uint8_t*)calloc(BufSize + SelectedDrive.SectorSize, 1); // +1 sector for align
if (buffer == NULL) { if (buffer == NULL) {
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_NOT_ENOUGH_MEMORY; FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_NOT_ENOUGH_MEMORY;
uprintf("could not allocate disk write buffer"); uprintf("could not allocate disk write buffer");
goto out; goto out;
} }
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa365747.aspx does buffer sector alignment // http://msdn.microsoft.com/en-us/library/windows/desktop/aa365747.aspx does buffer sector alignment
aligned_buffer = ((void *)((((uintptr_t)(buffer)) + (SectorSize)-1) & (~(((uintptr_t)(SectorSize)) - 1)))); aligned_buffer = ((void *)((((uintptr_t)(buffer)) + (SelectedDrive.SectorSize)-1) & (~(((uintptr_t)(SelectedDrive.SectorSize)) - 1))));
// Don't bother trying for something clever, using double buffering overlapped and whatnot: // Don't bother trying for something clever, using double buffering overlapped and whatnot:
// With Windows' default optimizations, sync read + sync write for sequential operations // With Windows' default optimizations, sync read + sync write for sequential operations
@ -1520,8 +1519,8 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, HANDLE hSourceImage)
} }
// WriteFile fails unless the size is a multiple of sector size // WriteFile fails unless the size is a multiple of sector size
if (rSize % SectorSize != 0) if (rSize % SelectedDrive.SectorSize != 0)
rSize = ((rSize + SectorSize - 1) / SectorSize) * SectorSize; rSize = ((rSize + SelectedDrive.SectorSize - 1) / SelectedDrive.SectorSize) * SelectedDrive.SectorSize;
for (i = 0; i < WRITE_RETRIES; i++) { for (i = 0; i < WRITE_RETRIES; i++) {
CHECK_FOR_USER_CANCEL; CHECK_FOR_USER_CANCEL;
s = WriteFile(hPhysicalDrive, aligned_buffer, rSize, &wSize, NULL); s = WriteFile(hPhysicalDrive, aligned_buffer, rSize, &wSize, NULL);
@ -1565,7 +1564,6 @@ DWORD WINAPI FormatThread(void* param)
{ {
int i, r, pt, tt, fs, bt; int i, r, pt, tt, fs, bt;
BOOL ret, use_large_fat32, windows_to_go; BOOL ret, use_large_fat32, windows_to_go;
const DWORD SectorSize = SelectedDrive.Geometry.BytesPerSector;
DWORD DriveIndex = (DWORD)(uintptr_t)param; DWORD DriveIndex = (DWORD)(uintptr_t)param;
HANDLE hPhysicalDrive = INVALID_HANDLE_VALUE; HANDLE hPhysicalDrive = INVALID_HANDLE_VALUE;
HANDLE hLogicalVolume = INVALID_HANDLE_VALUE; HANDLE hLogicalVolume = INVALID_HANDLE_VALUE;
@ -1677,7 +1675,7 @@ DWORD WINAPI FormatThread(void* param)
// Note, Microsoft's way of cleaning partitions (IOCTL_DISK_CREATE_DISK, which is what we apply // Note, Microsoft's way of cleaning partitions (IOCTL_DISK_CREATE_DISK, which is what we apply
// in InitializeDisk) is *NOT ENOUGH* to reset a disk and can render it inoperable for partitioning // in InitializeDisk) is *NOT ENOUGH* to reset a disk and can render it inoperable for partitioning
// or formatting under Windows. See https://github.com/pbatard/rufus/issues/759 for details. // or formatting under Windows. See https://github.com/pbatard/rufus/issues/759 for details.
if ((!ClearMBRGPT(hPhysicalDrive, SelectedDrive.DiskSize, SectorSize, FALSE)) || (!InitializeDisk(hPhysicalDrive)) ) { if ((!ClearMBRGPT(hPhysicalDrive, SelectedDrive.DiskSize, SelectedDrive.SectorSize, FALSE)) || (!InitializeDisk(hPhysicalDrive)) ) {
uprintf("Could not reset partitions\n"); uprintf("Could not reset partitions\n");
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_PARTITION_FAILURE; FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_PARTITION_FAILURE;
goto out; goto out;
@ -1704,12 +1702,12 @@ DWORD WINAPI FormatThread(void* param)
fflush(log_fd); fflush(log_fd);
} }
if (!BadBlocks(hPhysicalDrive, SelectedDrive.DiskSize, SectorSize, if (!BadBlocks(hPhysicalDrive, SelectedDrive.DiskSize, SelectedDrive.SectorSize,
ComboBox_GetCurSel(hNBPasses)+1, &report, log_fd)) { ComboBox_GetCurSel(hNBPasses)+1, &report, log_fd)) {
uprintf("Bad blocks: Check failed.\n"); uprintf("Bad blocks: Check failed.\n");
if (!IS_ERROR(FormatStatus)) if (!IS_ERROR(FormatStatus))
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_BADBLOCKS_FAILURE); FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_BADBLOCKS_FAILURE);
ClearMBRGPT(hPhysicalDrive, SelectedDrive.DiskSize, SectorSize, FALSE); ClearMBRGPT(hPhysicalDrive, SelectedDrive.DiskSize, SelectedDrive.SectorSize, FALSE);
fclose(log_fd); fclose(log_fd);
_unlink(logfile); _unlink(logfile);
goto out; goto out;
@ -1741,7 +1739,7 @@ DWORD WINAPI FormatThread(void* param)
// Especially after destructive badblocks test, you must zero the MBR/GPT completely // Especially after destructive badblocks test, you must zero the MBR/GPT completely
// before repartitioning. Else, all kind of bad things happen. // before repartitioning. Else, all kind of bad things happen.
if (!ClearMBRGPT(hPhysicalDrive, SelectedDrive.DiskSize, SectorSize, use_large_fat32)) { if (!ClearMBRGPT(hPhysicalDrive, SelectedDrive.DiskSize, SelectedDrive.SectorSize, use_large_fat32)) {
uprintf("unable to zero MBR/GPT\n"); uprintf("unable to zero MBR/GPT\n");
if (!IS_ERROR(FormatStatus)) if (!IS_ERROR(FormatStatus))
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_FAULT; FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_FAULT;

View file

@ -283,7 +283,7 @@ static BOOL DefineClusterSizes(void)
// ReFS (only supported for Windows 8.1 and later and for fixed disks) // ReFS (only supported for Windows 8.1 and later and for fixed disks)
if (SelectedDrive.DiskSize >= 512*MB) { if (SelectedDrive.DiskSize >= 512*MB) {
if ((nWindowsVersion >= WINDOWS_8_1) && (SelectedDrive.Geometry.MediaType == FixedMedia)) { if ((nWindowsVersion >= WINDOWS_8_1) && (SelectedDrive.MediaType == FixedMedia)) {
SelectedDrive.ClusterSize[FS_REFS].Allowed = SINGLE_CLUSTERSIZE_DEFAULT; SelectedDrive.ClusterSize[FS_REFS].Allowed = SINGLE_CLUSTERSIZE_DEFAULT;
SelectedDrive.ClusterSize[FS_REFS].Default = 1; SelectedDrive.ClusterSize[FS_REFS].Default = 1;
} }
@ -294,7 +294,7 @@ static BOOL DefineClusterSizes(void)
for (fs=0; fs<FS_MAX; fs++) { for (fs=0; fs<FS_MAX; fs++) {
// Remove all cluster sizes that are below the sector size // Remove all cluster sizes that are below the sector size
if (SelectedDrive.ClusterSize[fs].Allowed != SINGLE_CLUSTERSIZE_DEFAULT) { if (SelectedDrive.ClusterSize[fs].Allowed != SINGLE_CLUSTERSIZE_DEFAULT) {
SelectedDrive.ClusterSize[fs].Allowed &= ~(SelectedDrive.Geometry.BytesPerSector - 1); SelectedDrive.ClusterSize[fs].Allowed &= ~(SelectedDrive.SectorSize - 1);
if ((SelectedDrive.ClusterSize[fs].Default & SelectedDrive.ClusterSize[fs].Allowed) == 0) if ((SelectedDrive.ClusterSize[fs].Default & SelectedDrive.ClusterSize[fs].Allowed) == 0)
// We lost our default => Use rightmost bit to select the new one // We lost our default => Use rightmost bit to select the new one
SelectedDrive.ClusterSize[fs].Default = SelectedDrive.ClusterSize[fs].Default =
@ -1284,7 +1284,7 @@ static BOOL BootCheck(void)
// Windows To Go only works for NTFS // Windows To Go only works for NTFS
MessageBoxExU(hMainDialog, lmprintf(MSG_097, "Windows To Go"), lmprintf(MSG_092), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); MessageBoxExU(hMainDialog, lmprintf(MSG_097, "Windows To Go"), lmprintf(MSG_092), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid);
return FALSE; return FALSE;
} else if (SelectedDrive.Geometry.MediaType != FixedMedia) { } else if (SelectedDrive.MediaType != FixedMedia) {
if ((tt == TT_UEFI) && (pt == PARTITION_STYLE_GPT)) { if ((tt == TT_UEFI) && (pt == PARTITION_STYLE_GPT)) {
// We're screwed since we need access to 2 partitions at the same time to set this, which // We're screwed since we need access to 2 partitions at the same time to set this, which
// Windows can't do. Cue in Arthur's Theme: "♫ I know it's stupid... but it's true. ♫" // Windows can't do. Cue in Arthur's Theme: "♫ I know it's stupid... but it's true. ♫"
@ -2498,8 +2498,8 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
zero_drive = FALSE; zero_drive = FALSE;
break; break;
} }
if ((!zero_drive) && (IsChecked(IDC_BOOT)) && (SelectedDrive.Geometry.BytesPerSector != 512) && if ((!zero_drive) && (IsChecked(IDC_BOOT)) && (SelectedDrive.SectorSize != 512) &&
(MessageBoxExU(hMainDialog, lmprintf(MSG_196, SelectedDrive.Geometry.BytesPerSector), (MessageBoxExU(hMainDialog, lmprintf(MSG_196, SelectedDrive.SectorSize),
lmprintf(MSG_197), MB_OKCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDCANCEL)) { lmprintf(MSG_197), MB_OKCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDCANCEL)) {
format_op_in_progress = FALSE; format_op_in_progress = FALSE;
break; break;

View file

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

View file

@ -113,10 +113,10 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int fs_type)
// 4K sector size workaround // 4K sector size workaround
SECTOR_SHIFT = 0; SECTOR_SHIFT = 0;
SECTOR_SIZE = SelectedDrive.Geometry.BytesPerSector; SECTOR_SIZE = SelectedDrive.SectorSize;
while (SECTOR_SIZE>>=1) while (SECTOR_SIZE>>=1)
SECTOR_SHIFT++; SECTOR_SHIFT++;
SECTOR_SIZE = SelectedDrive.Geometry.BytesPerSector; SECTOR_SIZE = SelectedDrive.SectorSize;
LIBFAT_SECTOR_SHIFT = SECTOR_SHIFT; LIBFAT_SECTOR_SHIFT = SECTOR_SHIFT;
LIBFAT_SECTOR_SIZE = SECTOR_SIZE; LIBFAT_SECTOR_SIZE = SECTOR_SIZE;
LIBFAT_SECTOR_MASK = SECTOR_SIZE - 1; LIBFAT_SECTOR_MASK = SECTOR_SIZE - 1;