diff --git a/.gitignore b/.gitignore index 3a7a7568..f06bebc1 100644 --- a/.gitignore +++ b/.gitignore @@ -36,8 +36,8 @@ Makefile arm arm64 -x86_32 -x86_64 +x64 +x86 autom4te.cache config.guess ./config.h diff --git a/_coverity.cmd b/_coverity.cmd deleted file mode 100644 index 80c2c6fa..00000000 --- a/_coverity.cmd +++ /dev/null @@ -1,26 +0,0 @@ -@rem *** Internal developer script to run Coverity *** -@echo off -call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" -set COV_DIR=D:\cov-analysis-win64-2017.07 -set PATH=%PATH%;%COV_DIR%\bin -set PWD=%~dp0 -set TARGET=x86_32 -rmdir cov-int /s /q >NUL 2>NUL -rmdir %TARGET% /s /q >NUL 2>NUL -del cov-int.zip >NUL 2>NUL -mkdir cov-int -cov-build --dir cov-int msbuild rufus.sln /p:Configuration=Release,Platform=%TARGET% /maxcpucount -rem *** for when/if Coverity manage to clean their act -rem cov-build --dir cov-int C:\msys64\usr\bin\bash -cl "export PATH=/mingw32/bin:$PATH; cd /c/rufus; ./configure --build=i686-w64-mingw32 --host=i686-w64-mingw32 --disable-debug; make -j4" -rem *** zip script by Peter Mortensen - http://superuser.com/a/111266/286681 -echo Set objArgs = WScript.Arguments> zip.vbs -echo InputFolder = objArgs(0)>> zip.vbs -echo ZipFile = objArgs(1)>> zip.vbs -echo CreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" ^& Chr(5) ^& Chr(6) ^& String(18, vbNullChar)>> zip.vbs -echo Set objShell = CreateObject("Shell.Application")>> zip.vbs -echo Set source = objShell.NameSpace(InputFolder)>> zip.vbs -echo objShell.NameSpace(ZipFile).CopyHere(source)>> zip.vbs -echo wScript.Sleep 8000>> zip.vbs -CScript zip.vbs %PWD%cov-int %PWD%cov-int.zip -del zip.vbs -pause diff --git a/src/Makefile.am b/src/Makefile.am index f7610a42..ceb6b841 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -12,7 +12,7 @@ AM_V_WINDRES = $(AM_V_WINDRES_$(V)) rufus_SOURCES = badblocks.c checksum.c dev.c dos.c dos_locale.c drive.c format.c icon.c iso.c localization.c \ net.c parser.c pki.c process.c rufus.c smart.c stdfn.c stdio.c stdlg.c syslinux.c ui.c vhd.c -rufus_CFLAGS = -I./ms-sys/inc -I./syslinux/libfat -I./syslinux/libinstaller -I./syslinux/win -I./libcdio $(AM_CFLAGS) -DEXT2_FLAT_INCLUDES=0 -Wno-shadow +rufus_CFLAGS = -I./ms-sys/inc -I./syslinux/libfat -I./syslinux/libinstaller -I./syslinux/win -I./libcdio $(AM_CFLAGS) -DEXT2_FLAT_INCLUDES=0 rufus_LDFLAGS = $(AM_LDFLAGS) -mwindows rufus_LDADD = rufus_rc.o bled/libbled.a ext2fs/libext2fs.a ms-sys/libmssys.a syslinux/libfat/libfat.a syslinux/libinstaller/libinstaller.a syslinux/win/libwin.a \ libcdio/iso9660/libiso9660.a libcdio/udf/libudf.a libcdio/driver/libdriver.a -lsetupapi -lole32 -lgdi32 -lshlwapi -lcrypt32 -lwintrust -lcomdlg32 -lcomctl32 -luuid -lpsapi diff --git a/src/Makefile.in b/src/Makefile.in index ef014d36..53a49ccb 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -275,7 +275,7 @@ AM_V_WINDRES = $(AM_V_WINDRES_$(V)) rufus_SOURCES = badblocks.c checksum.c dev.c dos.c dos_locale.c drive.c format.c icon.c iso.c localization.c \ net.c parser.c pki.c process.c rufus.c smart.c stdfn.c stdio.c stdlg.c syslinux.c ui.c vhd.c -rufus_CFLAGS = -I./ms-sys/inc -I./syslinux/libfat -I./syslinux/libinstaller -I./syslinux/win -I./libcdio $(AM_CFLAGS) -DEXT2_FLAT_INCLUDES=0 -Wno-shadow +rufus_CFLAGS = -I./ms-sys/inc -I./syslinux/libfat -I./syslinux/libinstaller -I./syslinux/win -I./libcdio $(AM_CFLAGS) -DEXT2_FLAT_INCLUDES=0 rufus_LDFLAGS = $(AM_LDFLAGS) -mwindows rufus_LDADD = rufus_rc.o bled/libbled.a ext2fs/libext2fs.a ms-sys/libmssys.a syslinux/libfat/libfat.a syslinux/libinstaller/libinstaller.a syslinux/win/libwin.a \ libcdio/iso9660/libiso9660.a libcdio/udf/libudf.a libcdio/driver/libdriver.a -lsetupapi -lole32 -lgdi32 -lshlwapi -lcrypt32 -lwintrust -lcomdlg32 -lcomctl32 -luuid -lpsapi diff --git a/src/drive.c b/src/drive.c index f723fda6..103750ae 100644 --- a/src/drive.c +++ b/src/drive.c @@ -1415,7 +1415,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m } DriveLayoutEx.PartitionEntry[pn].PartitionLength.QuadPart = main_part_size_in_sectors * SelectedDrive.SectorSize; if (partition_style == PARTITION_STYLE_MBR) { - DriveLayoutEx.PartitionEntry[pn].Mbr.BootIndicator = (bt != BT_NON_BOOTABLE); + DriveLayoutEx.PartitionEntry[pn].Mbr.BootIndicator = (boot_type != BT_NON_BOOTABLE); switch (file_system) { case FS_FAT16: DriveLayoutEx.PartitionEntry[pn].Mbr.PartitionType = 0x0e; // FAT16 LBA diff --git a/src/format.c b/src/format.c index edf51da1..c7d1b078 100644 --- a/src/format.c +++ b/src/format.c @@ -809,7 +809,7 @@ static BOOL FormatDrive(DWORD DriveIndex) break; } } - if ((fs == FS_UDF) && !((dur_mins == 0) && (dur_secs == 0))) { + if ((fs_type == FS_UDF) && !((dur_mins == 0) && (dur_secs == 0))) { PrintInfoDebug(0, MSG_220, &FSType[index], dur_mins, dur_secs); } else { PrintInfoDebug(0, MSG_222, &FSType[index]); @@ -855,7 +855,7 @@ static BOOL FormatDrive(DWORD DriveIndex) } GetWindowTextW(hLabel, wLabel, ARRAYSIZE(wLabel)); // Make sure the label is valid - ToValidLabel(wLabel, (fs == FS_FAT16) || (fs == FS_FAT32) || (fs == FS_EXFAT)); + ToValidLabel(wLabel, (fs_type == FS_FAT16) || (fs_type == FS_FAT32) || (fs_type == FS_EXFAT)); ulClusterSize = (ULONG)ComboBox_GetItemData(hClusterSize, ComboBox_GetCurSel(hClusterSize)); if (ulClusterSize < 0x200) { // 0 is FormatEx's value for default, which we need to use for UDF @@ -872,7 +872,7 @@ static BOOL FormatDrive(DWORD DriveIndex) pfFormatEx(wVolumeName, SelectedDrive.MediaType, &wFSType[index], wLabel, IsChecked(IDC_QUICK_FORMAT), ulClusterSize, FormatExCallback); - if ((fs == FS_NTFS) && (enable_ntfs_compression) && (pfEnableVolumeCompression != NULL)) { + if ((fs_type == FS_NTFS) && (enable_ntfs_compression) && (pfEnableVolumeCompression != NULL)) { wVolumeName[wcslen(wVolumeName)] = '\\'; // Add trailing backslash back again if (pfEnableVolumeCompression(wVolumeName, FPF_COMPRESSED)) { uprintf("Enabled NTFS compression\n"); @@ -1011,7 +1011,7 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive) if (SelectedDrive.SectorSize < 512) goto out; - if (pt == PARTITION_STYLE_GPT) { + if (partition_type == PARTITION_STYLE_GPT) { // Add a notice in the protective MBR fake_fd._handle = (char*)hPhysicalDrive; set_bytes_per_sector(SelectedDrive.SectorSize); @@ -1053,7 +1053,7 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive) buffer[0x1c2] = 0x0c; break; } - if ((bt != BT_NON_BOOTABLE) && (tt == TT_BIOS)) { + if ((boot_type != BT_NON_BOOTABLE) && (target_type == TT_BIOS)) { // Set first partition bootable - masquerade as per the DiskID selected buffer[0x1be] = IsChecked(IDC_RUFUS_MBR) ? (BYTE)ComboBox_GetItemData(hDiskID, ComboBox_GetCurSel(hDiskID)):0x80; @@ -1071,47 +1071,47 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive) // What follows is really a case statement with complex conditions listed // by order of preference - if (HAS_WINDOWS(img_report) && (allow_dual_uefi_bios) && (tt == TT_BIOS)) + if (HAS_WINDOWS(img_report) && (allow_dual_uefi_bios) && (target_type == TT_BIOS)) goto windows_mbr; // Forced UEFI (by zeroing the MBR) - if (tt == TT_UEFI) { + if (target_type == TT_UEFI) { uprintf(using_msg, "zeroed"); r = write_zero_mbr(fp); goto notify; } // Syslinux - if ( (bt == BT_SYSLINUX_V4) || (bt == BT_SYSLINUX_V6) || - ((bt == BT_IMAGE) && HAS_SYSLINUX(img_report)) ) { + if ( (boot_type == BT_SYSLINUX_V4) || (boot_type == BT_SYSLINUX_V6) || + ((boot_type == BT_IMAGE) && HAS_SYSLINUX(img_report)) ) { uprintf(using_msg, "Syslinux"); r = write_syslinux_mbr(fp); goto notify; } // Grub 2.0 - if ( ((bt == BT_IMAGE) && (img_report.has_grub2)) || (bt == BT_GRUB2) ) { + if ( ((boot_type == BT_IMAGE) && (img_report.has_grub2)) || (boot_type == BT_GRUB2) ) { uprintf(using_msg, "Grub 2.0"); r = write_grub2_mbr(fp); goto notify; } // Grub4DOS - if ( ((bt == BT_IMAGE) && (img_report.has_grub4dos)) || (bt == BT_GRUB4DOS) ) { + if ( ((boot_type == BT_IMAGE) && (img_report.has_grub4dos)) || (boot_type == BT_GRUB4DOS) ) { uprintf(using_msg, "Grub4DOS"); r = write_grub4dos_mbr(fp); goto notify; } // ReactOS - if (bt == BT_REACTOS) { + if (boot_type == BT_REACTOS) { uprintf(using_msg, "ReactOS"); r = write_reactos_mbr(fp); goto notify; } // KolibriOS - if ( (bt == BT_IMAGE) && HAS_KOLIBRIOS(img_report) && (IS_FAT(fs))) { + if ( (boot_type == BT_IMAGE) && HAS_KOLIBRIOS(img_report) && (IS_FAT(fs_type))) { uprintf(using_msg, "KolibriOS"); r = write_kolibrios_mbr(fp); goto notify; @@ -1144,12 +1144,12 @@ static BOOL WriteSBR(HANDLE hPhysicalDrive) { // TODO: Do we need anything special for 4K sectors? DWORD size, max_size, mbr_size = 0x200; - int r, sub_type = bt; + int r, sub_type = boot_type; unsigned char* buf = NULL; FAKE_FD fake_fd = { 0 }; FILE* fp = (FILE*)&fake_fd; - if (pt == PARTITION_STYLE_GPT) + if (partition_type == PARTITION_STYLE_GPT) return TRUE; fake_fd._handle = (char*)hPhysicalDrive; @@ -1159,7 +1159,7 @@ static BOOL WriteSBR(HANDLE hPhysicalDrive) (DWORD)(SelectedDrive.SectorsPerTrack * SelectedDrive.SectorSize) : 1*MB; max_size -= mbr_size; // Syslinux has precedence over Grub - if ((bt == BT_IMAGE) && (!HAS_SYSLINUX(img_report))) { + if ((boot_type == BT_IMAGE) && (!HAS_SYSLINUX(img_report))) { if (img_report.has_grub4dos) sub_type = BT_GRUB4DOS; if (img_report.has_grub2) @@ -1210,11 +1210,11 @@ static BOOL WriteSBR(HANDLE hPhysicalDrive) * Process the Partition Boot Record */ static __inline const char* bt_to_name(void) { - switch (bt) { + switch (boot_type) { case BT_FREEDOS: return "FreeDOS"; case BT_REACTOS: return "ReactOS"; default: - return ((bt==BT_IMAGE) && HAS_KOLIBRIOS(img_report)) ? "KolibriOS" : "Standard"; + return ((boot_type == BT_IMAGE) && HAS_KOLIBRIOS(img_report)) ? "KolibriOS" : "Standard"; } } static BOOL WritePBR(HANDLE hLogicalVolume) @@ -1235,11 +1235,11 @@ static BOOL WritePBR(HANDLE hLogicalVolume) break; } uprintf("Confirmed new volume has a FAT16 boot sector\n"); - if (bt == BT_FREEDOS) { + if (boot_type == BT_FREEDOS) { if (!write_fat_16_fd_br(fp, 0)) break; - } else if (bt == BT_REACTOS) { + } else if (boot_type == BT_REACTOS) { if (!write_fat_16_ros_br(fp, 0)) break; - } else if ((bt == BT_IMAGE) && HAS_KOLIBRIOS(img_report)) { + } else if ((boot_type == BT_IMAGE) && HAS_KOLIBRIOS(img_report)) { uprintf("FAT16 is not supported for KolibriOS\n"); break; } else { if (!write_fat_16_br(fp, 0)) break; @@ -1257,15 +1257,15 @@ static BOOL WritePBR(HANDLE hLogicalVolume) } uprintf("Confirmed new volume has a %s FAT32 boot sector\n", i?"secondary":"primary"); uprintf("Setting %s FAT32 boot sector for boot...\n", i?"secondary":"primary"); - if (bt == BT_FREEDOS) { + if (boot_type == BT_FREEDOS) { if (!write_fat_32_fd_br(fp, 0)) break; - } else if (bt == BT_REACTOS) { + } else if (boot_type == BT_REACTOS) { if (!write_fat_32_ros_br(fp, 0)) break; - } else if ((bt == BT_IMAGE) && HAS_KOLIBRIOS(img_report)) { + } else if ((boot_type == BT_IMAGE) && HAS_KOLIBRIOS(img_report)) { if (!write_fat_32_kos_br(fp, 0)) break; - } else if ((bt == BT_IMAGE) && HAS_BOOTMGR(img_report)) { + } else if ((boot_type == BT_IMAGE) && HAS_BOOTMGR(img_report)) { if (!write_fat_32_pe_br(fp, 0)) break; - } else if ((bt == BT_IMAGE) && HAS_WINPE(img_report)) { + } else if ((boot_type == BT_IMAGE) && HAS_WINPE(img_report)) { if (!write_fat_32_nt_br(fp, 0)) break; } else { if (!write_fat_32_br(fp, 0)) break; @@ -1887,25 +1887,25 @@ DWORD WINAPI FormatThread(void* param) uint8_t *buffer = NULL, extra_partitions = 0; char *bb_msg, *guid_volume = NULL; char drive_name[] = "?:\\"; - char drive_letters[27], fs_type[32]; + char drive_letters[27], fs_name[32]; char logfile[MAX_PATH], *userdir; char efi_dst[] = "?:\\efi\\boot\\bootx64.efi"; char kolibri_dst[] = "?:\\MTLD_F32"; char grub4dos_dst[] = "?:\\grldr"; - use_large_fat32 = (fs == FS_FAT32) && ((SelectedDrive.DiskSize > LARGE_FAT32_SIZE) || (force_large_fat32)); - windows_to_go = (image_options & IMOP_WINTOGO) && (bt == BT_IMAGE) && HAS_WINTOGO(img_report) && + use_large_fat32 = (fs_type == FS_FAT32) && ((SelectedDrive.DiskSize > LARGE_FAT32_SIZE) || (force_large_fat32)); + windows_to_go = (image_options & IMOP_WINTOGO) && (boot_type == BT_IMAGE) && HAS_WINTOGO(img_report) && (ComboBox_GetCurSel(GetDlgItem(hMainDialog, IDC_IMAGE_OPTION)) == 1); large_drive = (SelectedDrive.DiskSize > (1*TB)); 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) && (target_type == TT_UEFI) && (partition_type == 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; - else if ( (fs == FS_NTFS) && ((bt == BT_UEFI_NTFS) || - ((bt == BT_IMAGE) && IS_EFI_BOOTABLE(img_report) && ((tt == TT_UEFI) || (windows_to_go) || (allow_dual_uefi_bios)))) ) + else if ( (fs_type == FS_NTFS) && ((boot_type == BT_UEFI_NTFS) || + ((boot_type == BT_IMAGE) && IS_EFI_BOOTABLE(img_report) && ((target_type == TT_UEFI) || (windows_to_go) || (allow_dual_uefi_bios)))) ) extra_partitions = XP_UEFI_NTFS; else if (IsChecked(IDC_OLD_BIOS_FIXES)) extra_partitions = XP_COMPAT; @@ -1936,7 +1936,7 @@ DWORD WINAPI FormatThread(void* param) // Do it in reverse so that we always end on the first volume letter for (i = (int)safe_strlen(drive_letters); i > 0; i--) { drive_name[0] = drive_letters[i-1]; - if (bt == BT_IMAGE) { + if (boot_type == BT_IMAGE) { // If we are using an image, check that it isn't located on the drive we are trying to format if ((PathGetDriveNumberU(image_path) + 'A') == drive_letters[i-1]) { uprintf("ABORTED: Cannot use an image that is located on the target drive!"); @@ -1994,7 +1994,7 @@ DWORD WINAPI FormatThread(void* param) // 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 // or formatting under Windows. See https://github.com/pbatard/rufus/issues/759 for details. - if ((bt != BT_IMAGE) || (img_report.is_iso && !write_as_image)) { + if ((boot_type != BT_IMAGE) || (img_report.is_iso && !write_as_image)) { if ((!ClearMBRGPT(hPhysicalDrive, SelectedDrive.DiskSize, SelectedDrive.SectorSize, use_large_fat32)) || (!InitializeDisk(hPhysicalDrive))) { uprintf("Could not reset partitions"); @@ -2070,7 +2070,7 @@ DWORD WINAPI FormatThread(void* param) } // Write an image file - if ((bt == BT_IMAGE) && write_as_image) { + if ((boot_type == BT_IMAGE) && write_as_image) { hSourceImage = CreateFileU(image_path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL); if (hSourceImage == INVALID_HANDLE_VALUE) { @@ -2086,7 +2086,7 @@ DWORD WINAPI FormatThread(void* param) safe_unlockclose(hLogicalVolume); Sleep(200); WaitForLogical(DriveIndex); - if (GetDrivePartitionData(SelectedDrive.DeviceNumber, fs_type, sizeof(fs_type), TRUE)) { + if (GetDrivePartitionData(SelectedDrive.DeviceNumber, fs_name, sizeof(fs_name), TRUE)) { guid_volume = GetLogicalName(DriveIndex, TRUE, TRUE); if ((guid_volume != NULL) && (MountVolume(drive_name, guid_volume))) uprintf("Remounted %s as %C:", guid_volume, drive_name[0]); @@ -2097,7 +2097,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, partition_type, fs_type, (partition_type==PARTITION_STYLE_MBR) && (target_type==TT_UEFI), extra_partitions)) { FormatStatus = (LastWriteError != 0) ? LastWriteError : (ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_PARTITION_FAILURE); goto out; } @@ -2131,7 +2131,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) || ((bt != BT_NON_BOOTABLE) && (pt == PARTITION_STYLE_GPT))) { + if ((partition_type == PARTITION_STYLE_MBR) || ((boot_type != BT_NON_BOOTABLE) && (partition_type == PARTITION_STYLE_GPT))) { PrintInfoDebug(0, MSG_228); // "Writing master boot record..." if ((!WriteMBR(hPhysicalDrive)) || (!WriteSBR(hPhysicalDrive))) { if (!IS_ERROR(FormatStatus)) @@ -2161,7 +2161,7 @@ DWORD WINAPI FormatThread(void* param) CHECK_FOR_USER_CANCEL; // Disable file indexing, unless it was force-enabled by the user - if ((!enable_file_indexing) && ((fs == FS_NTFS) || (fs == FS_UDF) || (fs == FS_REFS))) { + if ((!enable_file_indexing) && ((fs_type == FS_NTFS) || (fs_type == FS_UDF) || (fs_type == FS_REFS))) { uprintf("Disabling file indexing..."); if (!SetFileAttributesA(guid_volume, FILE_ATTRIBUTE_NOT_CONTENT_INDEXED)) uprintf("Could not disable file indexing: %s", WindowsErrorString()); @@ -2174,20 +2174,20 @@ DWORD WINAPI FormatThread(void* param) uprintf("Warning: Failed to refresh label: %s", WindowsErrorString()); } - if (bt != BT_NON_BOOTABLE) { - if (bt == BT_UEFI_NTFS) { + if (boot_type != BT_NON_BOOTABLE) { + if (boot_type == BT_UEFI_NTFS) { // All good - } else if (tt == TT_UEFI) { + } else if (target_type == TT_UEFI) { // For once, no need to do anything - just check our sanity - assert((bt == BT_IMAGE) && IS_EFI_BOOTABLE(img_report) && (fs <= FS_NTFS)); - if ( (bt != BT_IMAGE) || !IS_EFI_BOOTABLE(img_report) || (fs > FS_NTFS) ) { + assert((boot_type == BT_IMAGE) && IS_EFI_BOOTABLE(img_report) && (fs_type <= FS_NTFS)); + if ( (boot_type != BT_IMAGE) || !IS_EFI_BOOTABLE(img_report) || (fs_type > FS_NTFS) ) { FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_INSTALL_FAILURE; goto out; } - } else if ( (bt == BT_SYSLINUX_V4) || (bt == BT_SYSLINUX_V6) || - ((bt == BT_IMAGE) && (HAS_SYSLINUX(img_report) || HAS_REACTOS(img_report)) && + } else if ( (boot_type == BT_SYSLINUX_V4) || (boot_type == BT_SYSLINUX_V6) || + ((boot_type == BT_IMAGE) && (HAS_SYSLINUX(img_report) || HAS_REACTOS(img_report)) && (!HAS_WINDOWS(img_report) || !allow_dual_uefi_bios)) ) { - if (!InstallSyslinux(DriveIndex, drive_name[0], fs)) { + if (!InstallSyslinux(DriveIndex, drive_name[0], fs_type)) { FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_INSTALL_FAILURE; goto out; } @@ -2224,8 +2224,8 @@ DWORD WINAPI FormatThread(void* param) goto out; CHECK_FOR_USER_CANCEL; - if (bt != BT_NON_BOOTABLE) { - if ((bt == BT_MSDOS) || (bt == BT_FREEDOS)) { + if (boot_type != BT_NON_BOOTABLE) { + if ((boot_type == BT_MSDOS) || (boot_type == BT_FREEDOS)) { UpdateProgress(OP_DOS, -1.0f); PrintInfoDebug(0, MSG_230); if (!ExtractDOS(drive_name)) { @@ -2233,14 +2233,14 @@ DWORD WINAPI FormatThread(void* param) FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_CANNOT_COPY; goto out; } - } else if (bt == BT_GRUB4DOS) { + } else if (boot_type == BT_GRUB4DOS) { grub4dos_dst[0] = drive_name[0]; IGNORE_RETVAL(_chdirU(app_dir)); uprintf("Installing: %s (Grub4DOS loader) %s", grub4dos_dst, IsFileInDB(FILES_DIR "\\grub4dos-" GRUB4DOS_VERSION "\\grldr")?"✓":"✗"); if (!CopyFileU(FILES_DIR "\\grub4dos-" GRUB4DOS_VERSION "\\grldr", grub4dos_dst, FALSE)) uprintf("Failed to copy file: %s", WindowsErrorString()); - } else if ((bt == BT_IMAGE) && (image_path != NULL) && (img_report.is_iso)) { + } else if ((boot_type == BT_IMAGE) && (image_path != NULL) && (img_report.is_iso)) { UpdateProgress(OP_DOS, 0.0f); drive_name[2] = 0; // Ensure our drive is something like 'D:' if (windows_to_go) { @@ -2266,7 +2266,7 @@ DWORD WINAPI FormatThread(void* param) } } // EFI mode selected, with no 'boot###.efi' but Windows 7 x64's 'bootmgr.efi' (bit #0) - if (((tt == TT_UEFI) || allow_dual_uefi_bios) && HAS_WIN7_EFI(img_report)) { + if (((target_type == TT_UEFI) || allow_dual_uefi_bios) && HAS_WIN7_EFI(img_report)) { PrintInfoDebug(0, MSG_232); img_report.wininst_path[0][0] = drive_name[0]; efi_dst[0] = drive_name[0]; @@ -2282,7 +2282,7 @@ DWORD WINAPI FormatThread(void* param) } } } - if ( (tt == TT_BIOS) && HAS_WINPE(img_report) ) { + if ( (target_type == TT_BIOS) && HAS_WINPE(img_report) ) { // Apply WinPe fixup if (!SetupWinPE(drive_name[0])) FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_CANT_PATCH); @@ -2296,7 +2296,7 @@ DWORD WINAPI FormatThread(void* param) // Issue another complete remount before we exit, to ensure we're clean RemountVolume(drive_name); // NTFS fixup (WinPE/AIK images don't seem to boot without an extra checkdisk) - if ((bt == BT_IMAGE) && (img_report.is_iso) && (fs == FS_NTFS)) { + if ((boot_type == BT_IMAGE) && (img_report.is_iso) && (fs_type == FS_NTFS)) { // Try to ensure that all messages from Checkdisk will be in English if (PRIMARYLANGID(GetThreadUILanguage()) != LANG_ENGLISH) { SetThreadUILanguage(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); diff --git a/src/rufus.c b/src/rufus.c index 0587c93a..80b12454 100755 --- a/src/rufus.c +++ b/src/rufus.c @@ -112,7 +112,7 @@ BOOL write_as_image = FALSE, installed_uefi_ntfs = FALSE, enable_fido = FALSE; uint64_t persistence_size = 0; float fScale = 1.0f; int dialog_showing = 0, selection_default = BT_IMAGE, windows_to_go_selection = 0, persistence_unit_selection = -1; -int default_fs, fs, bt, pt, tt; // file system, boot type, partition type, target type +int default_fs, fs_type, boot_type, partition_type, target_type; // file system, boot type, partition type, target type int force_update = 0; char szFolderPath[MAX_PATH], app_dir[MAX_PATH], system_dir[MAX_PATH], temp_dir[MAX_PATH], sysnative_dir[MAX_PATH]; char embedded_sl_version_str[2][12] = { "?.??", "?.??" }; @@ -165,7 +165,7 @@ static void SetAllowedFileSystems(void) // Don't allow anything besides NTFS if the image has a >4GB file if ((image_path != NULL) && (img_report.has_4GB_file)) break; - if (!HAS_WINDOWS(img_report) || (tt != TT_BIOS) || allow_dual_uefi_bios) { + if (!HAS_WINDOWS(img_report) || (target_type != TT_BIOS) || allow_dual_uefi_bios) { if (!HAS_WINTOGO(img_report) || (ComboBox_GetCurSel(GetDlgItem(hMainDialog, IDC_IMAGE_OPTION)) != 1)) { allowed_filesystem[FS_FAT16] = TRUE; allowed_filesystem[FS_FAT32] = TRUE; @@ -238,13 +238,13 @@ static void SetPartitionSchemeAndTargetSystem(BOOL only_target) IGNORE_RETVAL(ComboBox_ResetContent(hPartitionScheme)); IGNORE_RETVAL(ComboBox_ResetContent(hTargetSystem)); - bt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)); - is_windows_to_go_selected = (bt == BT_IMAGE) && (image_path != NULL) && HAS_WINTOGO(img_report) && + boot_type = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)); + is_windows_to_go_selected = (boot_type == BT_IMAGE) && (image_path != NULL) && HAS_WINTOGO(img_report) && (ComboBox_GetCurSel(GetDlgItem(hMainDialog, IDC_IMAGE_OPTION)) == 1); // If no device is selected, don't populate anything if (ComboBox_GetCurSel(hDeviceList) < 0) return; - switch (bt) { + switch (boot_type) { case BT_NON_BOOTABLE: allowed_partition_scheme[PARTITION_STYLE_SFD] = TRUE; allowed_target_system[0] = FALSE; @@ -302,11 +302,11 @@ static void SetPartitionSchemeAndTargetSystem(BOOL only_target) IGNORE_RETVAL(ComboBox_SetItemData(hPartitionScheme, ComboBox_AddStringU(hPartitionScheme, sfd_name), PARTITION_STYLE_SFD)); // Override the partition scheme according to the current - if (bt == BT_NON_BOOTABLE) + if (boot_type == BT_NON_BOOTABLE) preferred_pt = (selected_pt >= 0) ? selected_pt : PARTITION_STYLE_MBR; - else if (bt == BT_UEFI_NTFS) + else if (boot_type == BT_UEFI_NTFS) preferred_pt = (selected_pt >= 0) ? selected_pt : PARTITION_STYLE_GPT; - else if ((bt == BT_IMAGE) && (image_path != NULL) && (img_report.is_iso)) { + else if ((boot_type == BT_IMAGE) && (image_path != NULL) && (img_report.is_iso)) { if (HAS_WINDOWS(img_report) && img_report.has_efi) preferred_pt = allow_dual_uefi_bios? PARTITION_STYLE_MBR : ((selected_pt >= 0) ? selected_pt : PARTITION_STYLE_GPT); @@ -314,23 +314,23 @@ static void SetPartitionSchemeAndTargetSystem(BOOL only_target) preferred_pt = (selected_pt >= 0) ? selected_pt : PARTITION_STYLE_MBR; } SetComboEntry(hPartitionScheme, preferred_pt); - pt = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)); + partition_type = (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] && (partition_type != 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) && (bt == BT_IMAGE) && IS_BIOS_BOOTABLE(img_report) && IS_EFI_BOOTABLE(img_report)) ) + if (allowed_target_system[1] && !((partition_type == PARTITION_STYLE_MBR) && (boot_type == BT_IMAGE) && 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] && ((partition_type != PARTITION_STYLE_GPT) || (boot_type == BT_NON_BOOTABLE))) IGNORE_RETVAL(ComboBox_SetItemData(hTargetSystem, ComboBox_AddStringU(hTargetSystem, lmprintf(MSG_033)), TT_BIOS)); IGNORE_RETVAL(ComboBox_SetCurSel(hTargetSystem, 0)); - tt = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem)); + target_type = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem)); // Can't update a tooltip from a thread, so we send a message instead SendMessage(hMainDialog, UM_UPDATE_CSM_TOOLTIP, 0, 0); } @@ -371,7 +371,7 @@ static BOOL SetClusterSizes(int FSType) } // Populate the File System and Cluster Size dropdowns -static BOOL SetFileSystemAndClusterSize(char* fs_type) +static BOOL SetFileSystemAndClusterSize(char* fs_name) { int fs_index; LONGLONG i; @@ -525,9 +525,9 @@ static BOOL SetFileSystemAndClusterSize(char* fs_type) // re-select existing FS if it's one we know SelectedDrive.FSType = FS_UNKNOWN; - if (safe_strlen(fs_type) != 0) { + if (safe_strlen(fs_name) != 0) { for (SelectedDrive.FSType = FS_MAX - 1; SelectedDrive.FSType >= 0; SelectedDrive.FSType--) { - if (safe_strcmp(fs_type, FileSystemLabel[SelectedDrive.FSType]) == 0) { + if (safe_strcmp(fs_name, FileSystemLabel[SelectedDrive.FSType]) == 0) { break; } } @@ -555,7 +555,7 @@ static void SetFSFromISO(void) { int i, fs_tmp, preferred_fs = FS_UNKNOWN; uint32_t fs_mask = FS_FAT32 | FS_NTFS; - BOOL windows_to_go = (image_options & IMOP_WINTOGO) && (bt == BT_IMAGE) && HAS_WINTOGO(img_report) && + BOOL windows_to_go = (image_options & IMOP_WINTOGO) && (boot_type == BT_IMAGE) && HAS_WINTOGO(img_report) && (ComboBox_GetCurSel(GetDlgItem(hMainDialog, IDC_IMAGE_OPTION)) == 1); if (image_path == NULL) @@ -577,7 +577,7 @@ static void SetFSFromISO(void) if (preferred_fs == FS_UNKNOWN) { // Syslinux and EFI have precedence over bootmgr (unless the user selected BIOS as target type) if ((HAS_SYSLINUX(img_report)) || (HAS_REACTOS(img_report)) || HAS_KOLIBRIOS(img_report) || - (IS_EFI_BOOTABLE(img_report) && (tt == TT_UEFI) && (!windows_to_go))) { + (IS_EFI_BOOTABLE(img_report) && (target_type == TT_UEFI) && (!windows_to_go))) { if (fs_mask & (1 << FS_FAT32)) { preferred_fs = FS_FAT32; } else if ((fs_mask & (1 << FS_FAT16)) && !HAS_KOLIBRIOS(img_report)) { @@ -614,7 +614,7 @@ static void SetMBRProps(void) { BOOL needs_masquerading = HAS_WINPE(img_report) && (!img_report.uses_minint); - if ((!mbr_selected_by_user) && ((image_path == NULL) || (bt != BT_IMAGE) || (fs != FS_NTFS) || HAS_GRUB(img_report) || + if ((!mbr_selected_by_user) && ((image_path == NULL) || (boot_type != BT_IMAGE) || (fs_type != FS_NTFS) || HAS_GRUB(img_report) || ((image_options & IMOP_WINTOGO) && (ComboBox_GetCurSel(GetDlgItem(hMainDialog, IDC_IMAGE_OPTION)) == 1)) )) { CheckDlgButton(hMainDialog, IDC_RUFUS_MBR, BST_UNCHECKED); IGNORE_RETVAL(ComboBox_SetCurSel(hDiskID, 0)); @@ -634,7 +634,7 @@ static void SetProposedLabel(int ComboIndex) app_changed_label = TRUE; // If bootable ISO creation is selected, and we have an ISO selected with a valid name, use that // Also some distros (eg. Arch) require the USB to have the same label as the ISO - if ((bt == BT_IMAGE) && (image_path != NULL) && (img_report.label[0] != 0)) { + if ((boot_type == BT_IMAGE) && (image_path != NULL) && (img_report.label[0] != 0)) { SetWindowTextU(hLabel, img_report.label); // If we force the ISO label, we need to reset the user_changed_label flag user_changed_label = FALSE; @@ -665,21 +665,21 @@ static void SetProposedLabel(int ComboIndex) // This handles the enabling/disabling of the "Add fixes for old BIOSes" and "Use Rufus MBR" controls static void EnableMBRBootOptions(BOOL enable, BOOL remove_checkboxes) { - BOOL actual_enable_mbr = (bt > BT_IMAGE) ? FALSE: enable; + BOOL actual_enable_mbr = (boot_type > BT_IMAGE) ? FALSE: enable; 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 ((partition_type != PARTITION_STYLE_MBR) || (target_type != TT_BIOS) || ((boot_type == 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; } else { // If we are using an image, the Rufus MBR only applies if it's for Windows - if ((bt == BT_IMAGE) && !HAS_WINPE(img_report) && !HAS_BOOTMGR(img_report)) { + if ((boot_type == BT_IMAGE) && !HAS_WINPE(img_report) && !HAS_BOOTMGR(img_report)) { actual_enable_mbr = FALSE; mbr_selected_by_user = FALSE; } - if (bt == BT_NON_BOOTABLE) { + if (boot_type == BT_NON_BOOTABLE) { actual_enable_fix = FALSE; } } @@ -712,7 +712,7 @@ static void EnableQuickFormat(BOOL enable) } // Disable/restore the quick format control depending on large FAT32 or ReFS - if (((fs == FS_FAT32) && ((SelectedDrive.DiskSize > LARGE_FAT32_SIZE) || (force_large_fat32))) || (fs == FS_REFS)) { + if (((fs_type == FS_FAT32) && ((SelectedDrive.DiskSize > LARGE_FAT32_SIZE) || (force_large_fat32))) || (fs_type == FS_REFS)) { enable = FALSE; CheckDlgButton(hMainDialog, IDC_QUICK_FORMAT, BST_CHECKED); } @@ -734,11 +734,11 @@ static void EnableBootOptions(BOOL enable, BOOL remove_checkboxes) if (ComboBox_GetCurSel(hDeviceList) < 0) actual_enable = FALSE; // If boot selection is set to image, but no image is currently selected, don't enable anything - if ((bt == BT_IMAGE) && (image_path == NULL)) + if ((boot_type == BT_IMAGE) && (image_path == NULL)) actual_enable = FALSE; actual_enable_bb = actual_enable; // If we are dealing with a pure DD image, remove all options except Bad Blocks check - if ((bt == BT_IMAGE) && (img_report.is_bootable_img) && (!img_report.is_iso)) + if ((boot_type == BT_IMAGE) && (img_report.is_bootable_img) && (!img_report.is_iso)) actual_enable = FALSE; EnableWindow(GetDlgItem(hMainDialog, IDC_IMAGE_OPTION), actual_enable); @@ -773,7 +773,7 @@ static void EnableControls(BOOL bEnable) SendMessage(hMultiToolbar, TB_ENABLEBUTTON, (WPARAM)IDC_SETTINGS, (LPARAM)bEnable); // Checksum button is enabled if an image has been selected - EnableWindow(hHashToolbar, bEnable && (bt == BT_IMAGE) && (image_path != NULL)); + EnableWindow(hHashToolbar, bEnable && (boot_type == BT_IMAGE) && (image_path != NULL)); // Toggle CLOSE/CANCEL SetDlgItemTextU(hMainDialog, IDCANCEL, bEnable ? uppercase_close : uppercase_cancel); @@ -784,12 +784,12 @@ static void EnableControls(BOOL bEnable) EnableWindow(hSaveToolbar, bEnable); // Enable or disable the Start button and the other boot options - bEnable = ((bt == BT_IMAGE) && (image_path == NULL)) ? FALSE : bEnable; + bEnable = ((boot_type == BT_IMAGE) && (image_path == NULL)) ? FALSE : bEnable; EnableWindow(hStart, bEnable); EnableBootOptions(bEnable, FALSE); // Finally, only enable the half-size dropdowns if we aren't dealing with a pure DD image - bEnable = ((bt == BT_IMAGE) && (image_path != NULL) && (!img_report.is_iso)) ? FALSE : bEnable; + bEnable = ((boot_type == BT_IMAGE) && (image_path != NULL) && (!img_report.is_iso)) ? FALSE : bEnable; EnableWindow(hPartitionScheme, bEnable); EnableWindow(hTargetSystem, bEnable); EnableWindow(GetDlgItem(hMainDialog, IDS_CSM_HELP_TXT), bEnable); @@ -803,7 +803,7 @@ static BOOL PopulateProperties(void) { char* device_tooltip; int device_index = ComboBox_GetCurSel(hDeviceList); - char fs_type[32]; + char fs_name[32]; memset(&SelectedDrive, 0, sizeof(SelectedDrive)); EnableWindow(hStart, FALSE); @@ -815,10 +815,10 @@ static BOOL PopulateProperties(void) // Get data from the currently selected drive SelectedDrive.DeviceNumber = (DWORD)ComboBox_GetItemData(hDeviceList, device_index); // This fills the SelectedDrive properties - GetDrivePartitionData(SelectedDrive.DeviceNumber, fs_type, sizeof(fs_type), FALSE); + GetDrivePartitionData(SelectedDrive.DeviceNumber, fs_name, sizeof(fs_name), FALSE); SetPartitionSchemeAndTargetSystem(FALSE); // Attempt to reselect the last file system explicitly set by the user - if (!SetFileSystemAndClusterSize((selected_fs == FS_UNKNOWN) ? fs_type : NULL)) { + if (!SetFileSystemAndClusterSize((selected_fs == FS_UNKNOWN) ? fs_name : NULL)) { SetProposedLabel(-1); uprintf("No file system is selectable for this drive\n"); return FALSE; @@ -1032,7 +1032,7 @@ static void UpdateImage(void) (image_path == NULL) ? lmprintf(MSG_281, lmprintf(MSG_280)) : short_image_path); ComboBox_SetItemData(hBootType, image_index, BT_IMAGE); IGNORE_RETVAL(ComboBox_SetCurSel(hBootType, image_index)); - bt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)); + boot_type = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)); SetBootTypeDropdownWidth(); } @@ -1152,13 +1152,13 @@ static DWORD WINAPI BootCheckThread(LPVOID param) if (ComboBox_GetCurSel(hDeviceList) == CB_ERR) goto out; - if ((zero_drive) || (bt == BT_NON_BOOTABLE)) { + if ((zero_drive) || (boot_type == BT_NON_BOOTABLE)) { // Nothing to check ret = 0; goto out; } - if (bt == BT_IMAGE) { + if (boot_type == BT_IMAGE) { assert(image_path != NULL); if (image_path == NULL) goto out; @@ -1173,13 +1173,13 @@ static DWORD WINAPI BootCheckThread(LPVOID param) goto out; } if ((image_options & IMOP_WINTOGO) && (ComboBox_GetCurSel(GetDlgItem(hMainDialog, IDC_IMAGE_OPTION)) == 1)) { - if (fs != FS_NTFS) { + if (fs_type != FS_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); goto out; } if (SelectedDrive.MediaType != FixedMedia) { - if ((tt == TT_UEFI) && (pt == PARTITION_STYLE_GPT) && (nWindowsBuildNumber < 15000)) { + if ((target_type == TT_UEFI) && (partition_type == 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); @@ -1196,7 +1196,7 @@ static DWORD WINAPI BootCheckThread(LPVOID param) default: break; } - } else if (tt == TT_UEFI) { + } else if (target_type == TT_UEFI) { if (!IS_EFI_BOOTABLE(img_report)) { // Unsupported ISO MessageBoxExU(hMainDialog, lmprintf(MSG_091), lmprintf(MSG_090), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); @@ -1208,30 +1208,30 @@ static DWORD WINAPI BootCheckThread(LPVOID param) ShellExecuteA(hMainDialog, "open", SEVENZIP_URL, NULL, NULL, SW_SHOWNORMAL); goto out; } - } else if ( ((fs == FS_NTFS) && !HAS_WINDOWS(img_report) && !HAS_GRUB(img_report) && + } else if ( ((fs_type == FS_NTFS) && !HAS_WINDOWS(img_report) && !HAS_GRUB(img_report) && (!HAS_SYSLINUX(img_report) || (SL_MAJOR(img_report.sl_version) <= 5))) - || ((IS_FAT(fs)) && (!HAS_SYSLINUX(img_report)) && (!allow_dual_uefi_bios) && !IS_EFI_BOOTABLE(img_report) && + || ((IS_FAT(fs_type)) && (!HAS_SYSLINUX(img_report)) && (!allow_dual_uefi_bios) && !IS_EFI_BOOTABLE(img_report) && (!HAS_REACTOS(img_report)) && !HAS_KOLIBRIOS(img_report) && (!HAS_GRUB(img_report))) - || ((IS_FAT(fs)) && (HAS_WINDOWS(img_report) || HAS_WININST(img_report)) && (!allow_dual_uefi_bios)) ) { + || ((IS_FAT(fs_type)) && (HAS_WINDOWS(img_report) || HAS_WININST(img_report)) && (!allow_dual_uefi_bios)) ) { // Incompatible FS and ISO MessageBoxExU(hMainDialog, lmprintf(MSG_096), lmprintf(MSG_092), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); goto out; - } else if ((fs == FS_FAT16) && HAS_KOLIBRIOS(img_report)) { + } else if ((fs_type == FS_FAT16) && HAS_KOLIBRIOS(img_report)) { // KolibriOS doesn't support FAT16 MessageBoxExU(hMainDialog, lmprintf(MSG_189), lmprintf(MSG_099), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); goto out; } - if ((IS_FAT(fs)) && (img_report.has_4GB_file)) { + if ((IS_FAT(fs_type)) && (img_report.has_4GB_file)) { // This ISO image contains a file larger than 4GB file (FAT32) MessageBoxExU(hMainDialog, lmprintf(MSG_100), lmprintf(MSG_099), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); goto out; } // If the selected target doesn't include include BIOS, skip file downloads for GRUB/Syslinux - if (tt != TT_BIOS) + if (target_type != TT_BIOS) goto uefi_target; - if ((pt == PARTITION_STYLE_MBR) && (img_report.has_grub2) && (img_report.grub2_version[0] != 0) && + if ((partition_type == PARTITION_STYLE_MBR) && (img_report.has_grub2) && (img_report.grub2_version[0] != 0) && (strcmp(img_report.grub2_version, GRUB2_PACKAGE_VERSION) != 0)) { // We may have to download a different Grub2 version if we can find one IGNORE_RETVAL(_chdirU(app_dir)); @@ -1295,7 +1295,7 @@ static DWORD WINAPI BootCheckThread(LPVOID param) } } - if ((pt == PARTITION_STYLE_MBR) && HAS_SYSLINUX(img_report)) { + if ((partition_type == PARTITION_STYLE_MBR) && HAS_SYSLINUX(img_report)) { if (SL_MAJOR(img_report.sl_version) < 5) { IGNORE_RETVAL(_chdirU(app_dir)); for (i=0; i= 65536)) { // MS-DOS cannot boot from a drive using a 64 kilobytes Cluster size MessageBoxExU(hMainDialog, lmprintf(MSG_110), lmprintf(MSG_111), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); goto out; } - } else if (bt == BT_GRUB4DOS) { + } else if (boot_type == BT_GRUB4DOS) { IGNORE_RETVAL(_chdirU(app_dir)); IGNORE_RETVAL(_mkdir(FILES_DIR)); IGNORE_RETVAL(_chdir(FILES_DIR)); @@ -1454,9 +1454,9 @@ static DWORD WINAPI BootCheckThread(LPVOID param) } uefi_target: - if (bt == BT_UEFI_NTFS) { - fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); - if (fs != FS_NTFS) { + if (boot_type == BT_UEFI_NTFS) { + fs_type = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); + if (fs_type != FS_NTFS) { MessageBoxExU(hMainDialog, lmprintf(MSG_097, "UEFI:NTFS"), lmprintf(MSG_092), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); goto out; } @@ -2020,7 +2020,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA WriteSettingBool(SETTING_ADVANCED_MODE_DEVICE, advanced_mode_device); ToggleAdvancedDeviceOptions(advanced_mode_device); SetBootOptions(); - bt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)); + boot_type = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)); EnableControls(TRUE); SetFileSystemAndClusterSize(NULL); SendMessage(hMainDialog, WM_COMMAND, (CBN_SELCHANGE_INTERNAL<<16) | IDC_FILE_SYSTEM, @@ -2111,18 +2111,18 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA case IDC_TARGET_SYSTEM: if (HIWORD(wParam) != CBN_SELCHANGE) break; - tt = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem)); + target_type = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem)); SendMessage(hMainDialog, UM_UPDATE_CSM_TOOLTIP, 0, 0); SetFileSystemAndClusterSize(NULL); break; case IDC_PARTITION_TYPE: if (HIWORD(wParam) != CBN_SELCHANGE) break; - pt = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)); + partition_type = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)); SetPartitionSchemeAndTargetSystem(TRUE); SetFileSystemAndClusterSize(NULL); EnableMBRBootOptions(TRUE, FALSE); - selected_pt = pt; + selected_pt = partition_type; break; case IDC_FILE_SYSTEM: if ((HIWORD(wParam) != CBN_SELCHANGE) && (HIWORD(wParam) != CBN_SELCHANGE_INTERNAL)) @@ -2130,20 +2130,20 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA if (IsWindowEnabled(hFileSystem)) EnableQuickFormat(TRUE); set_selected_fs = (HIWORD(wParam) == CBN_SELCHANGE); - fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); - SetClusterSizes(fs); - if (set_selected_fs && (fs > 0)) - selected_fs = fs; + fs_type = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); + SetClusterSizes(fs_type); + if (set_selected_fs && (fs_type > 0)) + selected_fs = fs_type; EnableMBRBootOptions(TRUE, FALSE); SetMBRProps(); break; case IDC_BOOT_SELECTION: if (HIWORD(wParam) != CBN_SELCHANGE) break; - bt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)); - if ((HIWORD(wParam) != CBN_SELCHANGE) || (bt == selection_default)) + boot_type = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)); + if ((HIWORD(wParam) != CBN_SELCHANGE) || (boot_type == selection_default)) break; - selection_default = bt; + selection_default = boot_type; SetPartitionSchemeAndTargetSystem(FALSE); // Try to reselect current FS from the drive for non-bootable tmp[0] = 0; @@ -2153,8 +2153,8 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA ToggleImageOptions(); SetProposedLabel(ComboBox_GetCurSel(hDeviceList)); EnableControls(TRUE); - tt = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)); - pt = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem)); + target_type = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)); + partition_type = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem)); return (INT_PTR)TRUE; case IDC_SELECT: if (select_index == 1) { @@ -2206,10 +2206,10 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA if (format_thid != NULL) return (INT_PTR)TRUE; // Just in case - bt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)); - pt = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)); - tt = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem)); - fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); + boot_type = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)); + partition_type = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)); + target_type = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem)); + fs_type = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); write_as_image = FALSE; installed_uefi_ntfs = FALSE; // Disable all controls except Cancel @@ -2275,8 +2275,8 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA return (INT_PTR)TRUE; case UM_UPDATE_CSM_TOOLTIP: - ShowWindow(GetDlgItem(hMainDialog, IDS_CSM_HELP_TXT), ((tt == TT_UEFI) || has_uefi_csm) ? SW_SHOW : SW_HIDE); - CreateTooltip(GetDlgItem(hMainDialog, IDS_CSM_HELP_TXT), lmprintf((tt == TT_UEFI) ? MSG_152 : MSG_151), 30000); + ShowWindow(GetDlgItem(hMainDialog, IDS_CSM_HELP_TXT), ((target_type == TT_UEFI) || has_uefi_csm) ? SW_SHOW : SW_HIDE); + CreateTooltip(GetDlgItem(hMainDialog, IDS_CSM_HELP_TXT), lmprintf((target_type == TT_UEFI) ? MSG_152 : MSG_151), 30000); break; case UM_ENABLE_CONTROLS: KillTimer(hMainDialog, TID_APP_TIMER); @@ -2574,7 +2574,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA if (wParam != 0) goto aborted_start; - if ((pt == PARTITION_STYLE_MBR) && (SelectedDrive.DiskSize > 2 * TB)) { + if ((partition_type == PARTITION_STYLE_MBR) && (SelectedDrive.DiskSize > 2 * TB)) { if (MessageBoxExU(hMainDialog, lmprintf(MSG_134, SizeToHumanReadable(SelectedDrive.DiskSize - 2 * TB, FALSE, FALSE)), lmprintf(MSG_128, "MBR"), MB_YESNO | MB_ICONWARNING | MB_IS_RTL, selected_langid) != IDYES) goto aborted_start; @@ -2582,7 +2582,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA if (!zero_drive) { // Display a warning about UDF formatting times - if (fs == FS_UDF) { + if (fs_type == FS_UDF) { dur_secs = (uint32_t)(((double)SelectedDrive.DiskSize) / 1073741824.0f / UDF_FORMAT_SPEED); if (dur_secs > UDF_FORMAT_WARN) { dur_mins = dur_secs / 60; @@ -2595,7 +2595,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA } } - if ((bt == BT_IMAGE) && IS_DD_BOOTABLE(img_report)) { + if ((boot_type == BT_IMAGE) && IS_DD_BOOTABLE(img_report)) { if (img_report.is_iso) { // Ask users how they want to write ISOHybrid images char* iso_image = lmprintf(MSG_036); @@ -2623,7 +2623,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA if ((SelectedDrive.nPartitions > 1) && (MessageBoxExU(hMainDialog, lmprintf(MSG_093), lmprintf(MSG_094), MB_OKCANCEL | MB_ICONWARNING | MB_IS_RTL, selected_langid) == IDCANCEL)) goto aborted_start; - if ((!zero_drive) && (bt != BT_NON_BOOTABLE) && (SelectedDrive.SectorSize != 512) && + if ((!zero_drive) && (boot_type != BT_NON_BOOTABLE) && (SelectedDrive.SectorSize != 512) && (MessageBoxExU(hMainDialog, lmprintf(MSG_196, SelectedDrive.SectorSize), lmprintf(MSG_197), MB_OKCANCEL | MB_ICONWARNING | MB_IS_RTL, selected_langid) == IDCANCEL)) goto aborted_start; diff --git a/src/rufus.h b/src/rufus.h index b6d6a466..7bb781a6 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -314,7 +314,7 @@ enum checksum_type { #define IS_BIOS_BOOTABLE(r) (HAS_BOOTMGR(r) || HAS_SYSLINUX(r) || HAS_WINPE(r) || HAS_GRUB(r) || HAS_REACTOS(r) || HAS_KOLIBRIOS(r)) #define HAS_WINTOGO(r) (HAS_BOOTMGR(r) && IS_EFI_BOOTABLE(r) && HAS_WININST(r)) #define HAS_PERSISTENCE(r) (r.has_casper) -#define IS_FAT(fs) ((fs == FS_FAT16) || (fs == FS_FAT32)) +#define IS_FAT(fs) ((fs_type == FS_FAT16) || (fs_type == FS_FAT32)) typedef struct { char label[192]; // 3*64 to account for UTF-8 @@ -456,7 +456,7 @@ extern size_t ubuffer_pos; extern const int nb_steps[FS_MAX]; extern float fScale; extern int nWindowsVersion, nWindowsBuildNumber, dialog_showing, force_update; -extern int fs, bt, pt, tt; +extern int fs_type, boot_type, partition_type, target_type; extern unsigned long syslinux_ldlinux_len[2]; extern char WindowsVersionStr[128], ubuffer[UBUFFER_SIZE], embedded_sl_version_str[2][12]; extern char szFolderPath[MAX_PATH], app_dir[MAX_PATH], temp_dir[MAX_PATH], system_dir[MAX_PATH], sysnative_dir[MAX_PATH]; diff --git a/src/rufus.rc b/src/rufus.rc index e373ba9d..e24e813d 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.6.1519" +CAPTION "Rufus 3.6.1520" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -394,8 +394,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,6,1519,0 - PRODUCTVERSION 3,6,1519,0 + FILEVERSION 3,6,1520,0 + PRODUCTVERSION 3,6,1520,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -413,13 +413,13 @@ BEGIN VALUE "Comments", "https://akeo.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "3.6.1519" + VALUE "FileVersion", "3.6.1520" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2019 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus-3.6.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "3.6.1519" + VALUE "ProductVersion", "3.6.1520" END END BLOCK "VarFileInfo" diff --git a/src/syslinux.c b/src/syslinux.c index 47c8bd34..924c5316 100644 --- a/src/syslinux.c +++ b/src/syslinux.c @@ -83,7 +83,7 @@ int libfat_readfile(intptr_t pp, void *buf, size_t secsize, libfat_sector_t sect * Extract the ldlinux.sys and ldlinux.bss from resources, * then patch and install them */ -BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int fs_type) +BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int file_system) { const LARGE_INTEGER liZero = { {0, 0} }; HANDLE f_handle = INVALID_HANDLE_VALUE; @@ -112,9 +112,9 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int fs_type) int ldlinux_sectors; uint32_t ldlinux_cluster; int i, nsectors, sl_fs_stype; - BOOL use_v5 = (bt == BT_SYSLINUX_V6) || ((bt == BT_IMAGE) && (SL_MAJOR(img_report.sl_version) >= 5)); + BOOL use_v5 = (boot_type == BT_SYSLINUX_V6) || ((boot_type == BT_IMAGE) && (SL_MAJOR(img_report.sl_version) >= 5)); - PrintInfoDebug(0, MSG_234, (bt == BT_IMAGE)?img_report.sl_version_str:embedded_sl_version_str[use_v5?1:0]); + PrintInfoDebug(0, MSG_234, (boot_type == BT_IMAGE)?img_report.sl_version_str:embedded_sl_version_str[use_v5?1:0]); /* 4K sector size workaround */ SECTOR_SHIFT = 0; @@ -218,7 +218,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int fs_type) } uprintf("Successfully wrote '%s'", &path[3]); - if (bt != BT_IMAGE) + if (boot_type != BT_IMAGE) UpdateProgress(OP_DOS, -1.0f); /* Now flush the media */ @@ -233,7 +233,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int fs_type) if (sectors == NULL) goto out; - switch (fs_type) { + switch (file_system) { case FS_NTFS: static_sprintf(tmp, "%C:\\", drive_letter); vol_info.Handle = d_handle; @@ -317,7 +317,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int fs_type) } /* Make the syslinux boot sector */ - syslinux_make_bootsect(sectbuf, (fs_type == FS_NTFS)?NTFS:VFAT); + syslinux_make_bootsect(sectbuf, (file_system == FS_NTFS)?NTFS:VFAT); /* Write boot sector back */ if (!SetFilePointerEx(d_handle, liZero, NULL, FILE_BEGIN) || @@ -328,7 +328,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int fs_type) } uprintf("Successfully wrote Syslinux boot record"); - if (bt == BT_SYSLINUX_V6) { + if (boot_type == BT_SYSLINUX_V6) { IGNORE_RETVAL(_chdirU(app_dir)); static_sprintf(path, "%s/%s-%s", FILES_DIR, syslinux, embedded_sl_version_str[1]); IGNORE_RETVAL(_chdir(path)); @@ -379,7 +379,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int fs_type) fclose(fd); } - if (bt != BT_IMAGE) + if (boot_type != BT_IMAGE) UpdateProgress(OP_DOS, -1.0f); r = TRUE; diff --git a/src/ui.c b/src/ui.c index 13bf7b87..5844f443 100644 --- a/src/ui.c +++ b/src/ui.c @@ -755,8 +755,8 @@ void ToggleImageOptions(void) uint8_t entry_image_options = image_options; int i, shift = rh; - has_wintogo = ((bt == BT_IMAGE) && (image_path != NULL) && (img_report.is_iso) && (nWindowsVersion >= WINDOWS_8) && (HAS_WINTOGO(img_report))); - has_persistence = ((bt == BT_IMAGE) && (image_path != NULL) && (img_report.is_iso) && (HAS_PERSISTENCE(img_report))); + has_wintogo = ((boot_type == BT_IMAGE) && (image_path != NULL) && (img_report.is_iso) && (nWindowsVersion >= WINDOWS_8) && (HAS_WINTOGO(img_report))); + has_persistence = ((boot_type == BT_IMAGE) && (image_path != NULL) && (img_report.is_iso) && (HAS_PERSISTENCE(img_report))); assert(popcnt8(image_options) <= 1); @@ -1145,7 +1145,7 @@ void InitProgress(BOOL bOnlyFormat) if (IsChecked(IDC_BAD_BLOCKS)) { nb_slots[OP_BADBLOCKS] = -1; } - if (bt != BT_NON_BOOTABLE) { + if (boot_type != BT_NON_BOOTABLE) { // 1 extra slot for PBR writing switch (selection_default) { case BT_MSDOS: @@ -1171,10 +1171,10 @@ void InitProgress(BOOL bOnlyFormat) nb_slots[OP_CREATE_FS] = nb_steps[ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem))]; if ((!IsChecked(IDC_QUICK_FORMAT)) - || ((fs == FS_FAT32) && ((SelectedDrive.DiskSize >= LARGE_FAT32_SIZE) || (force_large_fat32)))) { + || ((fs_type == FS_FAT32) && ((SelectedDrive.DiskSize >= LARGE_FAT32_SIZE) || (force_large_fat32)))) { nb_slots[OP_FORMAT] = -1; } - nb_slots[OP_FINALIZE] = ((selection_default == BT_IMAGE) && (fs == FS_NTFS)) ? 3 : 2; + nb_slots[OP_FINALIZE] = ((selection_default == BT_IMAGE) && (fs_type == FS_NTFS)) ? 3 : 2; } }