mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[efi] fix incorrect offset for UEFI:TOGO partition
* Also remove the use of hardcoded value for the size of the UEFI:TOGO partition and fix a WDK warning.
This commit is contained in:
parent
a4e12f5c12
commit
3f0e71f3ba
3 changed files with 23 additions and 18 deletions
22
src/drive.c
22
src/drive.c
|
@ -46,6 +46,7 @@ const GUID PARTITION_BASIC_DATA_GUID =
|
|||
* Globals
|
||||
*/
|
||||
RUFUS_DRIVE_INFO SelectedDrive;
|
||||
size_t uefi_togo_size = 0;
|
||||
|
||||
/*
|
||||
* The following methods get or set the AutoMount setting (which is different from AutoRun)
|
||||
|
@ -668,6 +669,9 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys
|
|||
if (hPhysical == INVALID_HANDLE_VALUE)
|
||||
return 0;
|
||||
|
||||
if (uefi_togo_size == 0)
|
||||
uefi_togo_size = GetResourceSize(hMainInstance, MAKEINTRESOURCEA(IDR_UEFI_TOGO), _RT_RCDATA, "uefi-togo.img");
|
||||
|
||||
r = DeviceIoControl(hPhysical, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX,
|
||||
NULL, 0, geometry, sizeof(geometry), &size, NULL);
|
||||
if (!r || size <= 0) {
|
||||
|
@ -715,7 +719,7 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys
|
|||
if (DriveLayout->PartitionEntry[i].Mbr.PartitionType != PARTITION_ENTRY_UNUSED) {
|
||||
part_type = DriveLayout->PartitionEntry[i].Mbr.PartitionType;
|
||||
isUefiTogo = (i == 1) && (part_type == 0x01) &&
|
||||
(DriveLayout->PartitionEntry[i].PartitionLength.QuadPart == 131072);
|
||||
(DriveLayout->PartitionEntry[i].PartitionLength.QuadPart == uefi_togo_size);
|
||||
suprintf("Partition %d%s:\n", i+1, isUefiTogo?" (UEFI:TOGO)":"");
|
||||
for (j=0; j<ARRAYSIZE(mbr_mountable); j++) {
|
||||
if (part_type == mbr_mountable[j]) {
|
||||
|
@ -753,7 +757,7 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys
|
|||
GuidToString(&DriveLayout->PartitionEntry[i].Gpt.PartitionId), SizeToHumanReadable(DriveLayout->PartitionEntry[i].PartitionLength.QuadPart, TRUE, FALSE),
|
||||
DriveLayout->PartitionEntry[i].PartitionLength, DriveLayout->PartitionEntry[i].StartingOffset.QuadPart / DiskGeometry->Geometry.BytesPerSector,
|
||||
DriveLayout->PartitionEntry[i].Gpt.Attributes);
|
||||
if (safe_strcmp(tmp, "UEFI:TOGO") == 0)
|
||||
if (strcmp(tmp, "UEFI:TOGO") == 0)
|
||||
hasRufusExtra = TRUE;
|
||||
if ( (memcmp(&PARTITION_BASIC_DATA_GUID, &DriveLayout->PartitionEntry[i].Gpt.PartitionType, sizeof(GUID)) == 0) &&
|
||||
(nWindowsVersion >= WINDOWS_VISTA) )
|
||||
|
@ -912,6 +916,8 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
|
|||
LONGLONG size_in_sectors, extra_size_in_tracks = 1;
|
||||
|
||||
PrintStatus(0, TRUE, MSG_238, PartitionTypeName[partition_style]);
|
||||
if (uefi_togo_size == 0)
|
||||
uefi_togo_size = GetResourceSize(hMainInstance, MAKEINTRESOURCEA(IDR_UEFI_TOGO), _RT_RCDATA, "uefi-togo.img");
|
||||
|
||||
if ((partition_style == PARTITION_STYLE_GPT) || (!IsChecked(IDC_EXTRA_PARTITION))) {
|
||||
// Go with the MS 1 MB wastage at the beginning...
|
||||
|
@ -923,7 +929,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
|
|||
}
|
||||
size_in_sectors = (SelectedDrive.DiskSize - DriveLayoutEx.PartitionEntry[0].StartingOffset.QuadPart) / SelectedDrive.Geometry.BytesPerSector;
|
||||
// Align on track boundary if the extra part option is checked
|
||||
if ((partition_style == PARTITION_STYLE_MBR) && ((IsChecked(IDC_EXTRA_PARTITION)) || (add_uefi_togo))) {
|
||||
if ((add_uefi_togo) || ((partition_style == PARTITION_STYLE_MBR) && (IsChecked(IDC_EXTRA_PARTITION)))) {
|
||||
if (add_uefi_togo) // Already set to 1 track in non To_Go mode
|
||||
extra_size_in_tracks = (MIN_EXTRA_PART_SIZE + SelectedDrive.Geometry.SectorsPerTrack - 1) /
|
||||
SelectedDrive.Geometry.SectorsPerTrack;
|
||||
|
@ -1007,8 +1013,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
|
|||
DriveLayoutEx.PartitionEntry[1].StartingOffset.QuadPart = DriveLayoutEx.PartitionEntry[0].StartingOffset.QuadPart +
|
||||
DriveLayoutEx.PartitionEntry[0].PartitionLength.QuadPart;
|
||||
if (add_uefi_togo) {
|
||||
DriveLayoutEx.PartitionEntry[1].PartitionLength.QuadPart =
|
||||
GetResourceSize(hMainInstance, MAKEINTRESOURCEA(IDR_UEFI_TOGO), _RT_RCDATA, "uefi-togo.img");
|
||||
DriveLayoutEx.PartitionEntry[1].PartitionLength.QuadPart = uefi_togo_size;
|
||||
} else {
|
||||
DriveLayoutEx.PartitionEntry[1].PartitionLength.QuadPart = extra_size_in_tracks *
|
||||
SelectedDrive.Geometry.SectorsPerTrack * SelectedDrive.Geometry.BytesPerSector;
|
||||
|
@ -1024,19 +1029,18 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
|
|||
break;
|
||||
case PARTITION_STYLE_GPT:
|
||||
DriveLayoutEx.PartitionEntry[0].Gpt.PartitionType = PARTITION_BASIC_DATA_GUID;
|
||||
IGNORE_RETVAL(CoCreateGuid(&DriveLayoutEx.PartitionEntry[0].Gpt.PartitionId));
|
||||
wcscpy(DriveLayoutEx.PartitionEntry[0].Gpt.Name, L"Microsoft Basic Data");
|
||||
if (add_uefi_togo) {
|
||||
DriveLayoutEx.PartitionEntry[1].Gpt.PartitionType = PARTITION_BASIC_DATA_GUID;
|
||||
IGNORE_RETVAL(CoCreateGuid(&DriveLayoutEx.PartitionEntry[1].Gpt.PartitionId));
|
||||
wcscpy(DriveLayoutEx.PartitionEntry[1].Gpt.Name, L"UEFI:TOGO");
|
||||
DriveLayoutEx.PartitionEntry[1].PartitionNumber = 2;
|
||||
DriveLayoutEx.PartitionEntry[1].RewritePartition = TRUE;
|
||||
DriveLayoutEx.PartitionEntry[1].StartingOffset.QuadPart = DriveLayoutEx.PartitionEntry[0].StartingOffset.QuadPart +
|
||||
DriveLayoutEx.PartitionEntry[0].PartitionLength.QuadPart;
|
||||
DriveLayoutEx.PartitionEntry[1].PartitionLength.QuadPart =
|
||||
GetResourceSize(hMainInstance, MAKEINTRESOURCEA(IDR_UEFI_TOGO), _RT_RCDATA, "uefi-togo.img");
|
||||
DriveLayoutEx.PartitionEntry[1].PartitionLength.QuadPart = uefi_togo_size;
|
||||
}
|
||||
IGNORE_RETVAL(CoCreateGuid(&DriveLayoutEx.PartitionEntry[0].Gpt.PartitionId));
|
||||
IGNORE_RETVAL(CoCreateGuid(&DriveLayoutEx.PartitionEntry[1].Gpt.PartitionId));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -1552,7 +1552,8 @@ DWORD WINAPI FormatThread(void* param)
|
|||
// Wait for the logical drive we just created to appear
|
||||
uprintf("Waiting for logical drive to reappear...\n");
|
||||
Sleep(200);
|
||||
WaitForLogical(DriveIndex); // We try to continue even if this fails, just in case
|
||||
if (!WaitForLogical(DriveIndex))
|
||||
uprintf("Logical drive was not found!"); // We try to continue even if this fails, just in case
|
||||
CHECK_FOR_USER_CANCEL;
|
||||
|
||||
// If FAT32 is requested and we have a large drive (>32 GB) use
|
||||
|
|
16
src/rufus.rc
16
src/rufus.rc
|
@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
|||
|
||||
IDD_DIALOG DIALOGEX 12, 12, 242, 329
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Rufus 1.5.0.561"
|
||||
CAPTION "Rufus 1.5.0.562"
|
||||
FONT 8, "Segoe UI", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Start",IDC_START,127,291,50,14
|
||||
|
@ -164,7 +164,7 @@ END
|
|||
|
||||
IDD_DIALOG_XP DIALOGEX 12, 12, 242, 329
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Rufus 1.5.0.561"
|
||||
CAPTION "Rufus 1.5.0.562"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Start",IDC_START,127,291,50,14
|
||||
|
@ -297,7 +297,7 @@ END
|
|||
IDD_DIALOG_RTL DIALOGEX 12, 12, 242, 329
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_RTLREADING | WS_EX_APPWINDOW | WS_EX_LAYOUTRTL
|
||||
CAPTION "Rufus 1.5.0.561"
|
||||
CAPTION "Rufus 1.5.0.562"
|
||||
FONT 8, "Segoe UI", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Start",IDC_START,127,291,50,14
|
||||
|
@ -437,7 +437,7 @@ END
|
|||
IDD_DIALOG_RTL_XP DIALOGEX 12, 12, 242, 329
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_RTLREADING | WS_EX_APPWINDOW | WS_EX_LAYOUTRTL
|
||||
CAPTION "Rufus 1.5.0.561"
|
||||
CAPTION "Rufus 1.5.0.562"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Start",IDC_START,127,291,50,14
|
||||
|
@ -703,8 +703,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,5,0,561
|
||||
PRODUCTVERSION 1,5,0,561
|
||||
FILEVERSION 1,5,0,562
|
||||
PRODUCTVERSION 1,5,0,562
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -721,13 +721,13 @@ BEGIN
|
|||
BEGIN
|
||||
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "1.5.0.561"
|
||||
VALUE "FileVersion", "1.5.0.562"
|
||||
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.5.0.561"
|
||||
VALUE "ProductVersion", "1.5.0.562"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
Loading…
Reference in a new issue