diff --git a/src/drive.c b/src/drive.c index 23ebc761..10ec2fd4 100644 --- a/src/drive.c +++ b/src/drive.c @@ -757,7 +757,7 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys #endif switch (DriveLayout->PartitionStyle) { case PARTITION_STYLE_MBR: - SelectedDrive.PartitionType = PARTITION_STYLE_MBR; + SelectedDrive.PartitionStyle = PARTITION_STYLE_MBR; for (i=0; iPartitionCount; i++) { if (DriveLayout->PartitionEntry[i].Mbr.PartitionType != PARTITION_ENTRY_UNUSED) { SelectedDrive.nPartitions++; @@ -804,7 +804,7 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys } break; case PARTITION_STYLE_GPT: - SelectedDrive.PartitionType = PARTITION_STYLE_GPT; + SelectedDrive.PartitionStyle = PARTITION_STYLE_GPT; suprintf("Partition type: GPT, NB Partitions: %d", DriveLayout->PartitionCount); suprintf("Disk GUID: %s", GuidToString(&DriveLayout->Gpt.DiskId)); suprintf("Max parts: %d, Start Offset: %" PRIi64 ", Usable = %" PRIi64 " bytes", @@ -833,7 +833,7 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys } break; default: - SelectedDrive.PartitionType = PARTITION_STYLE_MBR; + SelectedDrive.PartitionStyle = PARTITION_STYLE_MBR; suprintf("Partition type: RAW"); break; } diff --git a/src/drive.h b/src/drive.h index 88110601..d41b624e 100644 --- a/src/drive.h +++ b/src/drive.h @@ -63,7 +63,7 @@ typedef struct { DWORD SectorSize; DWORD FirstDataSector; MEDIA_TYPE MediaType; - int PartitionType; + int PartitionStyle; int nPartitions; // number of partitions we actually care about int FSType; char proposed_label[16]; diff --git a/src/format.c b/src/format.c index 5fe0dadd..72e2a98f 100644 --- a/src/format.c +++ b/src/format.c @@ -1662,7 +1662,7 @@ DWORD WINAPI FormatThread(void* param) if (large_drive) uprintf("Notice: Large drive detected (may produce short writes)"); // Find out if we need to add any extra partitions - if ((windows_to_go) && (tt == TT_UEFI) && (pt == PARTITION_STYLE_GPT)) + if ((windows_to_go) && (tt == TT_UEFI) && (ps == PARTITION_STYLE_GPT)) // According to Microsoft, every GPT disk (we RUN Windows from) must have an MSR due to not having hidden sectors // http://msdn.microsoft.com/en-us/library/windows/hardware/dn640535.aspx#gpt_faq_what_disk_require_msr extra_partitions = XP_MSR | XP_EFI; @@ -1848,7 +1848,7 @@ DWORD WINAPI FormatThread(void* param) UpdateProgress(OP_ZERO_MBR, -1.0f); CHECK_FOR_USER_CANCEL; - if (!CreatePartition(hPhysicalDrive, pt, fs, (pt==PARTITION_STYLE_MBR) && (tt==TT_UEFI), extra_partitions)) { + if (!CreatePartition(hPhysicalDrive, ps, fs, (ps==PARTITION_STYLE_MBR) && (tt==TT_UEFI), extra_partitions)) { FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_PARTITION_FAILURE; goto out; } @@ -1882,7 +1882,7 @@ DWORD WINAPI FormatThread(void* param) } // Thanks to Microsoft, we must fix the MBR AFTER the drive has been formatted - if (pt == PARTITION_STYLE_MBR) { + if (ps == PARTITION_STYLE_MBR) { PrintInfoDebug(0, MSG_228); // "Writing master boot record..." if ((!WriteMBR(hPhysicalDrive)) || (!WriteSBR(hPhysicalDrive))) { if (!IS_ERROR(FormatStatus)) diff --git a/src/rufus.c b/src/rufus.c index fae03235..56e2722c 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -101,7 +101,7 @@ BUTTON_IMAGELIST bi_iso = { 0 }, bi_up = { 0 }, bi_down = { 0 }, bi_save = { 0 } char szFolderPath[MAX_PATH], app_dir[MAX_PATH], system_dir[MAX_PATH], temp_dir[MAX_PATH], sysnative_dir[MAX_PATH]; char *image_path = NULL, *short_image_path; float fScale = 1.0f; -int default_fs, fs, bt, pt, tt; +int default_fs, fs, bt, ps, tt; int cbw, ddw, ddbh = 0, bh = 0; // (empty) check box width, (empty) drop down width, button height (for and without dropdown match) uint32_t dur_mins, dur_secs; loc_cmd* selected_locale = NULL; @@ -310,6 +310,8 @@ static void SetPartitionSchemeAndTargetSystem(BOOL only_target) } if (!only_target) { + // Try to reselect the current drive's partition scheme + int preferred_ps = SelectedDrive.PartitionStyle; if (allowed_partition_scheme[PARTITION_STYLE_MBR]) IGNORE_RETVAL(ComboBox_SetItemData(hPartitionScheme, ComboBox_AddStringU(hPartitionScheme, "MBR"), PARTITION_STYLE_MBR)); @@ -319,20 +321,31 @@ static void SetPartitionSchemeAndTargetSystem(BOOL only_target) if (allowed_partition_scheme[PARTITION_STYLE_SFD]) IGNORE_RETVAL(ComboBox_SetItemData(hPartitionScheme, ComboBox_AddStringU(hPartitionScheme, sfd_name), PARTITION_STYLE_SFD)); - SetComboEntry(hPartitionScheme, PARTITION_STYLE_GPT); - pt = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)); + // Override the partition scheme according to the current + if (bt == BT_NON_BOOTABLE) + preferred_ps = PARTITION_STYLE_MBR; + else if (bt == BT_UEFI_NTFS) + preferred_ps = PARTITION_STYLE_GPT; + else if ((bt == BT_IMAGE) && (image_path != NULL) && (img_report.is_iso)) { + if (HAS_WINDOWS(img_report) && img_report.has_efi) + preferred_ps = allow_dual_uefi_bios? PARTITION_STYLE_MBR : PARTITION_STYLE_GPT; + if (img_report.is_bootable_img) + preferred_ps = PARTITION_STYLE_MBR; + } + SetComboEntry(hPartitionScheme, preferred_ps); + ps = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)); } has_uefi_csm = FALSE; - if (allowed_target_system[0] && (pt != PARTITION_STYLE_GPT)) { + if (allowed_target_system[0] && (ps != PARTITION_STYLE_GPT)) { IGNORE_RETVAL(ComboBox_SetItemData(hTargetSystem, ComboBox_AddStringU(hTargetSystem, lmprintf(MSG_031)), TT_BIOS)); has_uefi_csm = TRUE; } - if (allowed_target_system[1] && !((pt == PARTITION_STYLE_MBR) && IS_BIOS_BOOTABLE(img_report) && IS_EFI_BOOTABLE(img_report)) ) + if (allowed_target_system[1] && !((ps == PARTITION_STYLE_MBR) && IS_BIOS_BOOTABLE(img_report) && IS_EFI_BOOTABLE(img_report)) ) IGNORE_RETVAL(ComboBox_SetItemData(hTargetSystem, ComboBox_AddStringU(hTargetSystem, lmprintf(MSG_032)), TT_UEFI)); - if (allowed_target_system[2] && ((pt != PARTITION_STYLE_GPT) || (bt == BT_NON_BOOTABLE))) + if (allowed_target_system[2] && ((ps != PARTITION_STYLE_GPT) || (bt == BT_NON_BOOTABLE))) IGNORE_RETVAL(ComboBox_SetItemData(hTargetSystem, ComboBox_AddStringU(hTargetSystem, lmprintf(MSG_033)), TT_BIOS)); IGNORE_RETVAL(ComboBox_SetCurSel(hTargetSystem, 0)); @@ -633,7 +646,7 @@ static void EnableMBRBootOptions(BOOL enable, BOOL remove_checkboxes) BOOL actual_enable_fix = enable; static UINT uXPartChecked = BST_UNCHECKED; - if ((pt != PARTITION_STYLE_MBR) || (tt != TT_BIOS) || ((bt == BT_IMAGE) && !IS_BIOS_BOOTABLE(img_report))) { + if ((ps != PARTITION_STYLE_MBR) || (tt != TT_BIOS) || ((bt == BT_IMAGE) && !IS_BIOS_BOOTABLE(img_report))) { // These options cannot apply if we aren't using MBR+BIOS, or are using an image that isn't BIOS bootable actual_enable_mbr = FALSE; actual_enable_fix = FALSE; @@ -1430,7 +1443,7 @@ static BOOL BootCheck(void) return FALSE; } if (SelectedDrive.MediaType != FixedMedia) { - if ((tt == TT_UEFI) && (pt == PARTITION_STYLE_GPT) && (nWindowsBuildNumber < 15000)) { + if ((tt == TT_UEFI) && (ps == PARTITION_STYLE_GPT) && (nWindowsBuildNumber < 15000)) { // Up to Windows 10 Creators Update, we were screwed, since we need access to 2 partitions at the same time. // Thankfully, the newer Windows allow mounting multiple partitions on the same REMOVABLE drive. MessageBoxExU(hMainDialog, lmprintf(MSG_198), lmprintf(MSG_190), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); @@ -1737,13 +1750,13 @@ static INT_PTR CALLBACK ProgressCallback(HWND hCtrl, UINT message, WPARAM wParam { HDC hDC; RECT rect; - PAINTSTRUCT ps; + PAINTSTRUCT paint_struct; wchar_t winfo[128] = L"Copying ISO files..."; switch (message) { case WM_PAINT: - hDC = BeginPaint(hCtrl, &ps); + hDC = BeginPaint(hCtrl, &paint_struct); CallWindowProc(progress_original_proc, hCtrl, message, (WPARAM)hDC, lParam); GetWindowTextW(hProgress, winfo, ARRAYSIZE(winfo)); SetBkMode(hDC, TRANSPARENT); @@ -1754,7 +1767,7 @@ static INT_PTR CALLBACK ProgressCallback(HWND hCtrl, UINT message, WPARAM wParam ExtTextOutW(hDC, rect.right / 2, rect.bottom / 2 + (int)(4.0f * fScale), ETO_CLIPPED | ETO_NUMERICSLOCAL | (right_to_left_mode ? ETO_RTLREADING : 0), &rect, winfo, (int)wcslen(winfo), NULL); - EndPaint(hCtrl, &ps); + EndPaint(hCtrl, &paint_struct); return (INT_PTR)TRUE; } @@ -2785,7 +2798,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA RECT rc, DialogRect, DesktopRect; LONG progress_style; HDC hDC; - PAINTSTRUCT ps; + PAINTSTRUCT paint_struct; int nDeviceIndex, i, nWidth, nHeight, nb_devices, selected_language, offset; char tmp[128]; wchar_t* wbuffer = NULL; @@ -2954,7 +2967,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA case IDC_PARTITION_TYPE: if (HIWORD(wParam) != CBN_SELCHANGE) break; - pt = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)); + ps = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)); SetPartitionSchemeAndTargetSystem(TRUE); SetFileSystemAndClusterSize(NULL); EnableMBRBootOptions(TRUE, FALSE); @@ -3002,7 +3015,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA SetProposedLabel(ComboBox_GetCurSel(hDeviceList)); EnableControls(TRUE); tt = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)); - pt = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem)); + ps = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem)); return (INT_PTR)TRUE; case IDC_SELECT: if (iso_provided) { @@ -3051,7 +3064,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA // Just in case bt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)); tt = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)); - pt = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem)); + ps = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem)); fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); write_as_image = FALSE; // Disable all controls except Cancel @@ -3310,9 +3323,9 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA break; case WM_PAINT: - hDC = BeginPaint(hDlg, &ps); + hDC = BeginPaint(hDlg, &paint_struct); OnPaint(hDC); - EndPaint(hDlg, &ps); + EndPaint(hDlg, &paint_struct); break; case WM_CTLCOLORSTATIC: diff --git a/src/rufus.h b/src/rufus.h index 3b2d2c8a..0dd70e66 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -399,7 +399,7 @@ extern int64_t iso_blocking_status; extern uint16_t rufus_version[3], embedded_sl_version[2]; extern int nWindowsVersion; extern int nWindowsBuildNumber; -extern int fs, bt, pt, tt; +extern int fs, bt, ps, tt; extern char WindowsVersionStr[128]; extern size_t ubuffer_pos; extern char ubuffer[UBUFFER_SIZE]; diff --git a/src/rufus.rc b/src/rufus.rc index 549fe614..f2963145 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 232, 326 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 3.0.1223" +CAPTION "Rufus 3.0.1224" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -371,8 +371,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,18,1223,0 - PRODUCTVERSION 2,18,1223,0 + FILEVERSION 2,18,1224,0 + PRODUCTVERSION 2,18,1224,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -389,13 +389,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "2.18.1223" + VALUE "FileVersion", "2.18.1224" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2018 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "2.18.1223" + VALUE "ProductVersion", "2.18.1224" END END BLOCK "VarFileInfo" diff --git a/src/stdfn.c b/src/stdfn.c index 34611f20..6f0890b6 100644 --- a/src/stdfn.c +++ b/src/stdfn.c @@ -457,7 +457,7 @@ static PSID GetSID(void) { */ BOOL FileIO(BOOL save, char* path, char** buffer, DWORD* size) { - SECURITY_ATTRIBUTES s_attr, *ps = NULL; + SECURITY_ATTRIBUTES s_attr, *sa = NULL; SECURITY_DESCRIPTOR s_desc; PSID sid = NULL; HANDLE handle; @@ -472,7 +472,7 @@ BOOL FileIO(BOOL save, char* path, char** buffer, DWORD* size) s_attr.nLength = sizeof(SECURITY_ATTRIBUTES); s_attr.bInheritHandle = FALSE; s_attr.lpSecurityDescriptor = &s_desc; - ps = &s_attr; + sa = &s_attr; } else { uprintf("Could not set security descriptor: %s\n", WindowsErrorString()); } @@ -481,7 +481,7 @@ BOOL FileIO(BOOL save, char* path, char** buffer, DWORD* size) *buffer = NULL; } handle = CreateFileU(path, save?GENERIC_WRITE:GENERIC_READ, FILE_SHARE_READ, - ps, save?CREATE_ALWAYS:OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + sa, save?CREATE_ALWAYS:OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (handle == INVALID_HANDLE_VALUE) { uprintf("Could not %s file '%s'\n", save?"create":"open", path);