mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
parent
55ef384277
commit
2945389edc
4 changed files with 23 additions and 24 deletions
29
src/format.c
29
src/format.c
|
@ -54,6 +54,7 @@ static int task_number = 0;
|
|||
extern const int nb_steps[FS_MAX];
|
||||
static int fs_index = 0;
|
||||
BOOL force_large_fat32 = FALSE;
|
||||
static BOOL WritePBR(HANDLE hLogicalDrive);
|
||||
|
||||
/*
|
||||
* FormatEx callback. Return FALSE to halt operations
|
||||
|
@ -572,6 +573,13 @@ static BOOL FormatFAT32(DWORD DriveIndex)
|
|||
write_sectors(hLogicalVolume, BytesPerSect, SectorStart, 1, pFirstSectOfFat);
|
||||
}
|
||||
|
||||
// Must do it here, as have issues when trying to write the PBR after a remount
|
||||
PrintStatus(0, TRUE, "Writing partition boot record...");
|
||||
if (!WritePBR(hLogicalVolume)) {
|
||||
// Non fatal error, but the drive probably won't boot
|
||||
uprintf("Could not write partition boot record - drive may not boot...\n");
|
||||
}
|
||||
|
||||
// Set the FAT32 volume label
|
||||
GetWindowTextW(hLabel, wLabel, ARRAYSIZE(wLabel));
|
||||
ToValidLabel(wLabel, TRUE);
|
||||
|
@ -778,7 +786,9 @@ static BOOL ClearMBRGPT(HANDLE hPhysicalDrive, LONGLONG DiskSize, DWORD SectorSi
|
|||
// http://en.wikipedia.org/wiki/GUID_Partition_Table tells us we should clear 34 sectors at the
|
||||
// beginning and 33 at the end. We bump these values to MAX_SECTORS_TO_CLEAR each end to help
|
||||
// with reluctant access to large drive.
|
||||
for (i=0; i<MAX_SECTORS_TO_CLEAR; i++) {
|
||||
|
||||
// Must clear at least 1MB + the PBR for large FAT32 format to work on a large drive
|
||||
for (i=0; i<(2048+MAX_SECTORS_TO_CLEAR); i++) {
|
||||
if ((IS_ERROR(FormatStatus)) || (write_sectors(hPhysicalDrive, SectorSize, i, 1, pBuf) != SectorSize)) {
|
||||
goto out;
|
||||
}
|
||||
|
@ -788,13 +798,6 @@ static BOOL ClearMBRGPT(HANDLE hPhysicalDrive, LONGLONG DiskSize, DWORD SectorSi
|
|||
goto out;
|
||||
}
|
||||
}
|
||||
// Also attempt to clear the PBR, usually located at the 1 MB mark
|
||||
for (i=1024*1024/SectorSize; i<MAX_SECTORS_TO_CLEAR; i++) {
|
||||
if ((IS_ERROR(FormatStatus)) || (write_sectors(hPhysicalDrive, SectorSize, i, 1, pBuf) != SectorSize)) {
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
r = TRUE;
|
||||
|
||||
out:
|
||||
|
@ -1155,7 +1158,7 @@ DWORD WINAPI CloseFormatPromptThread(LPVOID param) {
|
|||
DWORD WINAPI FormatThread(LPVOID param)
|
||||
{
|
||||
int r, pt, bt, fs, dt;
|
||||
BOOL ret;
|
||||
BOOL ret, use_large_fat32;
|
||||
DWORD DriveIndex = (DWORD)(uintptr_t)param;
|
||||
HANDLE hPhysicalDrive = INVALID_HANDLE_VALUE;
|
||||
HANDLE hLogicalVolume = INVALID_HANDLE_VALUE;
|
||||
|
@ -1172,6 +1175,7 @@ DWORD WINAPI FormatThread(LPVOID param)
|
|||
dt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType));
|
||||
pt = GETPARTTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)));
|
||||
bt = GETBIOSTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)));
|
||||
use_large_fat32 = (fs == FS_FAT32) && ((SelectedDrive.DiskSize > LARGE_FAT32_SIZE) || (force_large_fat32));
|
||||
|
||||
PrintStatus(0, TRUE, "Requesting disk access...\n");
|
||||
hPhysicalDrive = GetPhysicalHandle(DriveIndex, TRUE, TRUE);
|
||||
|
@ -1323,8 +1327,7 @@ DWORD WINAPI FormatThread(LPVOID param)
|
|||
|
||||
// If FAT32 is requested and we have a large drive (>32 GB) use
|
||||
// large FAT32 format, else use MS's FormatEx.
|
||||
ret = ((fs == FS_FAT32) && ((SelectedDrive.DiskSize > LARGE_FAT32_SIZE) || (force_large_fat32)))?
|
||||
FormatFAT32(DriveIndex):FormatDrive(DriveIndex);
|
||||
ret = use_large_fat32?FormatFAT32(DriveIndex):FormatDrive(DriveIndex);
|
||||
if (!ret) {
|
||||
// Error will be set by FormatDrive() in FormatStatus
|
||||
uprintf("Format error: %s\n", StrError(FormatStatus));
|
||||
|
@ -1369,7 +1372,7 @@ 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) || ((dt == DT_ISO) && (fs == FS_NTFS))) {
|
||||
} else if ((((dt == DT_WINME) || (dt == DT_FREEDOS)) && (!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);
|
||||
|
@ -1426,7 +1429,7 @@ DWORD WINAPI FormatThread(LPVOID param)
|
|||
goto out;
|
||||
}
|
||||
if ((bt == BT_UEFI) && (!iso_report.has_efi) && (iso_report.has_win7_efi)) {
|
||||
// TODO: (v1.3.4) check ISO with EFI only
|
||||
// TODO: (v1.4.0) check ISO with EFI only
|
||||
PrintStatus(0, TRUE, "Win7 EFI boot setup (this may take a while)...");
|
||||
wim_image[0] = drive_name[0];
|
||||
efi_dst[0] = drive_name[0];
|
||||
|
|
|
@ -213,11 +213,7 @@ static BOOL DefineClusterSizes(void)
|
|||
// > 32GB FAT32 is not supported by MS and FormatEx but is achieved using fat32format
|
||||
// See: http://www.ridgecrop.demon.co.uk/index.htm?fat32format.htm
|
||||
// < 32 MB FAT32 is not allowed by FormatEx, so we don't bother
|
||||
// We also found issues with > 1TB drives, so we use our own max threshold (can be disabled with Alt-S)
|
||||
if ((size_check) && (1.0f*SelectedDrive.DiskSize >= 1.0f*MAX_FAT32_SIZE*TB))
|
||||
uprintf("FAT32 support is disabled for this device, as it is larger than %.1f TB\n", 1.0f*MAX_FAT32_SIZE);
|
||||
|
||||
if ((SelectedDrive.DiskSize >= 32*MB) && ((!size_check) || (1.0f*SelectedDrive.DiskSize < 1.0f*MAX_FAT32_SIZE*TB))) {
|
||||
if ((SelectedDrive.DiskSize >= 32*MB) && (1.0f*SelectedDrive.DiskSize < 1.0f*MAX_FAT32_SIZE*TB)) {
|
||||
SelectedDrive.ClusterSize[FS_FAT32].Allowed = 0x000001F8;
|
||||
for (i=32; i<=(32*1024); i<<=1) { // 32 MB -> 32 GB
|
||||
if (SelectedDrive.DiskSize < i*MB) {
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
#define PROPOSEDLABEL_TOLERANCE 0.10
|
||||
#define FS_DEFAULT FS_FAT32
|
||||
#define LARGE_FAT32_SIZE (32*1073741824LL) // Size at which we need to use fat32format
|
||||
#define MAX_FAT32_SIZE 1.0f // Threshold above which we disable FAT32 formatting (in TB)
|
||||
#define MAX_FAT32_SIZE 2.0f // Threshold above which we disable FAT32 formatting (in TB)
|
||||
#define WHITE RGB(255,255,255)
|
||||
#define SEPARATOR_GREY RGB(223,223,223)
|
||||
#define RUFUS_URL "http://rufus.akeo.ie"
|
||||
|
|
10
src/rufus.rc
10
src/rufus.rc
|
@ -30,7 +30,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.3.4.276"
|
||||
CAPTION "Rufus v1.3.4.277"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
|
||||
|
@ -278,8 +278,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,3,4,276
|
||||
PRODUCTVERSION 1,3,4,276
|
||||
FILEVERSION 1,3,4,277
|
||||
PRODUCTVERSION 1,3,4,277
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -296,13 +296,13 @@ BEGIN
|
|||
BEGIN
|
||||
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "1.3.4.276"
|
||||
VALUE "FileVersion", "1.3.4.277"
|
||||
VALUE "InternalName", "Rufus"
|
||||
VALUE "LegalCopyright", "© 2011-2013 Pete Batard (GPL v3)"
|
||||
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
|
||||
VALUE "OriginalFilename", "rufus.exe"
|
||||
VALUE "ProductName", "Rufus"
|
||||
VALUE "ProductVersion", "1.3.4.276"
|
||||
VALUE "ProductVersion", "1.3.4.277"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
Loading…
Reference in a new issue