diff --git a/src/drive.c b/src/drive.c index 2384b62b..24c6e7d6 100644 --- a/src/drive.c +++ b/src/drive.c @@ -66,7 +66,7 @@ static HANDLE GetHandle(char* Path, BOOL bWriteAccess, BOOL bLockDrive) if (Path == NULL) goto out; hDrive = CreateFileA(Path, GENERIC_READ|(bWriteAccess?GENERIC_WRITE:0), - FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0); + FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (hDrive == INVALID_HANDLE_VALUE) { uprintf("Could not open drive %s: %s\n", Path, WindowsErrorString()); goto out; @@ -77,6 +77,10 @@ static HANDLE GetHandle(char* Path, BOOL bWriteAccess, BOOL bLockDrive) } if (bLockDrive) { + if (DeviceIoControl(hDrive, FSCTL_ALLOW_EXTENDED_DASD_IO, NULL, 0, NULL, 0, &size, NULL)) { + uprintf("I/O boundary checks disabled\n"); + } + for (i = 0; i < DRIVE_ACCESS_RETRIES; i++) { if (DeviceIoControl(hDrive, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, &size, NULL)) goto out; @@ -186,7 +190,7 @@ char* GetLogicalName(DWORD DriveIndex, BOOL bKeepTrailingBackslash, BOOL bSilent } // If we can't have FILE_SHARE_WRITE, forget it - hDrive = CreateFileA(volume_name, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0); + hDrive = CreateFileA(volume_name, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (hDrive == INVALID_HANDLE_VALUE) { suprintf("Could not open GUID volume '%s': %s\n", volume_name, WindowsErrorString()); continue; @@ -302,7 +306,7 @@ static BOOL _GetDriveLetterAndType(DWORD DriveIndex, char* drive_letter, UINT* d continue; safe_sprintf(logical_drive, sizeof(logical_drive), "\\\\.\\%c:", drive[0]); - hDrive = CreateFileA(logical_drive, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0); + hDrive = CreateFileA(logical_drive, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (hDrive == INVALID_HANDLE_VALUE) { uprintf("Warning: could not open drive %c: %s\n", drive[0], WindowsErrorString()); continue; @@ -560,7 +564,7 @@ static BOOL FlushDrive(char drive_letter) logical_drive[4] = drive_letter; hDrive = CreateFileA(logical_drive, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, - NULL, OPEN_EXISTING, 0, 0); + NULL, OPEN_EXISTING, 0, NULL); if (hDrive == INVALID_HANDLE_VALUE) { uprintf("Failed to open %c: for flushing: %s\n", drive_letter, WindowsErrorString()); goto out; diff --git a/src/format.c b/src/format.c index d2ac1e7f..bc79119f 100644 --- a/src/format.c +++ b/src/format.c @@ -338,6 +338,7 @@ static BOOL FormatFAT32(DWORD DriveIndex) DWORD cbRet; DISK_GEOMETRY dgDrive; PARTITION_INFORMATION piDrive; + PARTITION_INFORMATION_EX xpiDrive; // Recommended values DWORD ReservedSectCount = 32; DWORD NumFATs = 2; @@ -387,7 +388,15 @@ static BOOL FormatFAT32(DWORD DriveIndex) if (IS_ERROR(FormatStatus)) goto out; if (!DeviceIoControl (hLogicalVolume, IOCTL_DISK_GET_PARTITION_INFO, NULL, 0, &piDrive, sizeof(piDrive), &cbRet, NULL)) { - die("Failed to get partition info\n", ERROR_NOT_SUPPORTED); + if (!DeviceIoControl (hLogicalVolume, IOCTL_DISK_GET_PARTITION_INFO_EX, NULL, 0, &xpiDrive, + sizeof(xpiDrive), &cbRet, NULL)) { + die("Failed to get partition info (both regular and _ex)", ERROR_NOT_SUPPORTED); + } + + memset (&piDrive, 0, sizeof(piDrive)); + piDrive.StartingOffset.QuadPart = xpiDrive.StartingOffset.QuadPart; + piDrive.PartitionLength.QuadPart = xpiDrive.PartitionLength.QuadPart; + piDrive.HiddenSectors = (DWORD) (xpiDrive.StartingOffset.QuadPart / dgDrive.BytesPerSector); } BytesPerSect = dgDrive.BytesPerSector; @@ -419,7 +428,7 @@ static BOOL FormatFAT32(DWORD DriveIndex) // fill out the boot sector and fs info pFAT32BootSect->sJmpBoot[0]=0xEB; - pFAT32BootSect->sJmpBoot[1]=0x5A; + pFAT32BootSect->sJmpBoot[1]=0x58; // jmp.s $+0x5a is 0xeb 0x58, not 0xeb 0x5a. Thanks Marco! pFAT32BootSect->sJmpBoot[2]=0x90; strncpy((char*)pFAT32BootSect->sOEMName, "MSWIN4.1", 8); pFAT32BootSect->wBytsPerSec = (WORD) BytesPerSect; diff --git a/src/rufus.rc b/src/rufus.rc index 0cd5ff16..a08fa82f 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.0.328" +CAPTION "Rufus v1.4.0.329" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,94,291,50,14 @@ -288,8 +288,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,4,0,328 - PRODUCTVERSION 1,4,0,328 + FILEVERSION 1,4,0,329 + PRODUCTVERSION 1,4,0,329 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -306,13 +306,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "1.4.0.328" + VALUE "FileVersion", "1.4.0.329" 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.4.0.328" + VALUE "ProductVersion", "1.4.0.329" END END BLOCK "VarFileInfo"