mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[misc] improve size based constants
* Make them more explicit by ensuring that they use a size suffix. * Also improve whitespace consistency. * Also make sure that we display the search for conflicting process message in the status on a search operation that may timeout.
This commit is contained in:
parent
180a61736c
commit
d0bc05077a
5 changed files with 50 additions and 48 deletions
|
@ -890,8 +890,8 @@ BOOL GetDevices(DWORD devnum)
|
|||
break;
|
||||
}
|
||||
drive_size = GetDriveSize(drive_index);
|
||||
if (drive_size < (MIN_DRIVE_SIZE * MB)) {
|
||||
uprintf("Device eliminated because it is smaller than %d MB", MIN_DRIVE_SIZE);
|
||||
if (drive_size < MIN_DRIVE_SIZE) {
|
||||
uprintf("Device eliminated because it is smaller than %s", SizeToHumanReadable(MIN_DRIVE_SIZE, FALSE, FALSE));
|
||||
safe_free(devint_detail_data);
|
||||
break;
|
||||
}
|
||||
|
@ -927,8 +927,9 @@ BOOL GetDevices(DWORD devnum)
|
|||
uprintf("NOTE: You can enable the listing of Hard Drives under 'advanced drive properties'");
|
||||
safe_free(devint_detail_data);
|
||||
break;
|
||||
} else if ((!enable_HDDs) && (props.is_CARD) && (drive_size > MAX_DEFAULT_LIST_CARD_SIZE * GB)) {
|
||||
uprintf("Device eliminated because it was detected as a card larger than %d GB", MAX_DEFAULT_LIST_CARD_SIZE);
|
||||
} else if ((!enable_HDDs) && (props.is_CARD) && (drive_size > MAX_DEFAULT_LIST_CARD_SIZE)) {
|
||||
uprintf("Device eliminated because it was detected as a card larger than %s",
|
||||
SizeToHumanReadable(MAX_DEFAULT_LIST_CARD_SIZE, FALSE, FALSE));
|
||||
uprintf("To use such a card, check 'List USB Hard Drives' under 'advanced drive properties'");
|
||||
safe_free(devint_detail_data);
|
||||
break;
|
||||
|
|
|
@ -21,12 +21,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
/* Convenient to have around */
|
||||
#define KB 1024LL
|
||||
#define MB 1048576LL
|
||||
#define GB 1073741824LL
|
||||
#define TB 1099511627776LL
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
|
49
src/rufus.c
49
src/rufus.c
|
@ -378,7 +378,7 @@ static BOOL SetClusterSizes(int FSType)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
for (i = 0, j = 0x100, k = 0; j<0x10000000; i++, j <<= 1) {
|
||||
for (i = 0, j = 0x100, k = 0; j < 0x10000000; i++, j <<= 1) {
|
||||
if (j & SelectedDrive.ClusterSize[FSType].Allowed) {
|
||||
if (j == SelectedDrive.ClusterSize[FSType].Default) {
|
||||
szClustSize = lmprintf(MSG_030, ClusterSizeLabel[i]);
|
||||
|
@ -476,11 +476,11 @@ static BOOL SetFileSystemAndClusterSize(char* fs_name)
|
|||
*/
|
||||
|
||||
// FAT 16
|
||||
if (SelectedDrive.DiskSize < 4*GB) {
|
||||
if (SelectedDrive.DiskSize < 4 * GB) {
|
||||
SelectedDrive.ClusterSize[FS_FAT16].Allowed = 0x00001E00;
|
||||
for (i = 32; i <= 4096; i <<= 1) { // 8 MB -> 4 GB
|
||||
if (SelectedDrive.DiskSize < i*MB) {
|
||||
SelectedDrive.ClusterSize[FS_FAT16].Default = 16*(ULONG)i;
|
||||
if (SelectedDrive.DiskSize < i * MB) {
|
||||
SelectedDrive.ClusterSize[FS_FAT16].Default = 16 * (ULONG)i;
|
||||
break;
|
||||
}
|
||||
SelectedDrive.ClusterSize[FS_FAT16].Allowed <<= 1;
|
||||
|
@ -490,12 +490,12 @@ static BOOL SetFileSystemAndClusterSize(char* fs_name)
|
|||
|
||||
// FAT 32
|
||||
// > 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
|
||||
// See: http://ridgecrop.co.uk/index.htm?fat32format.htm
|
||||
// < 32 MB FAT32 is not allowed by FormatEx, so we don't bother
|
||||
if ((SelectedDrive.DiskSize >= 32*MB) && (1.0f*SelectedDrive.DiskSize < 1.0f*MAX_FAT32_SIZE*TB)) {
|
||||
if ((SelectedDrive.DiskSize >= 32 * MB) && (SelectedDrive.DiskSize < MAX_FAT32_SIZE)) {
|
||||
SelectedDrive.ClusterSize[FS_FAT32].Allowed = 0x000001F8;
|
||||
for (i=32; i<=(32*1024); i<<=1) { // 32 MB -> 32 GB
|
||||
if (SelectedDrive.DiskSize*1.0f < i*MB*FAT32_CLUSTER_THRESHOLD) { // MS
|
||||
for (i = 32; i <= (32 * 1024); i <<= 1) { // 32 MB -> 32 GB
|
||||
if (SelectedDrive.DiskSize*1.0f < i * MB * FAT32_CLUSTER_THRESHOLD) { // MS
|
||||
SelectedDrive.ClusterSize[FS_FAT32].Default = 8*(ULONG)i;
|
||||
break;
|
||||
}
|
||||
|
@ -504,39 +504,39 @@ static BOOL SetFileSystemAndClusterSize(char* fs_name)
|
|||
SelectedDrive.ClusterSize[FS_FAT32].Allowed &= 0x0001FE00;
|
||||
|
||||
// Default cluster sizes in the 256MB to 32 GB range do not follow the rule above
|
||||
if ((SelectedDrive.DiskSize >= 256*MB) && (SelectedDrive.DiskSize < 32*GB)) {
|
||||
for (i=8; i<=32; i<<=1) { // 256 MB -> 32 GB
|
||||
if (SelectedDrive.DiskSize*1.0f < i*GB*FAT32_CLUSTER_THRESHOLD) {
|
||||
SelectedDrive.ClusterSize[FS_FAT32].Default = ((ULONG)i/2)*KB;
|
||||
if ((SelectedDrive.DiskSize >= 256 * MB) && (SelectedDrive.DiskSize < 32 * GB)) {
|
||||
for (i = 8; i <= 32; i <<= 1) { // 256 MB -> 32 GB
|
||||
if (SelectedDrive.DiskSize * 1.0f < i * GB * FAT32_CLUSTER_THRESHOLD) {
|
||||
SelectedDrive.ClusterSize[FS_FAT32].Default = ((ULONG)i / 2) * KB;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// More adjustments for large drives
|
||||
if (SelectedDrive.DiskSize >= 32*GB) {
|
||||
if (SelectedDrive.DiskSize >= 32 * GB) {
|
||||
SelectedDrive.ClusterSize[FS_FAT32].Allowed &= 0x0001C000;
|
||||
SelectedDrive.ClusterSize[FS_FAT32].Default = 0x00008000;
|
||||
}
|
||||
}
|
||||
|
||||
if (SelectedDrive.DiskSize < 256*TB) {
|
||||
if (SelectedDrive.DiskSize < 256 * TB) {
|
||||
// NTFS
|
||||
SelectedDrive.ClusterSize[FS_NTFS].Allowed = 0x0001FE00;
|
||||
for (i=16; i<=256; i<<=1) { // 7 MB -> 256 TB
|
||||
if (SelectedDrive.DiskSize < i*TB) {
|
||||
SelectedDrive.ClusterSize[FS_NTFS].Default = ((ULONG)i/4)*KB;
|
||||
for (i = 16; i <= 256; i <<= 1) { // 7 MB -> 256 TB
|
||||
if (SelectedDrive.DiskSize < i * TB) {
|
||||
SelectedDrive.ClusterSize[FS_NTFS].Default = ((ULONG)i / 4) * KB;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// exFAT
|
||||
SelectedDrive.ClusterSize[FS_EXFAT].Allowed = 0x03FFFE00;
|
||||
if (SelectedDrive.DiskSize < 256*MB) // < 256 MB
|
||||
SelectedDrive.ClusterSize[FS_EXFAT].Default = 4*KB;
|
||||
else if (SelectedDrive.DiskSize < 32*GB) // < 32 GB
|
||||
SelectedDrive.ClusterSize[FS_EXFAT].Default = 32*KB;
|
||||
if (SelectedDrive.DiskSize < 256 * MB) // < 256 MB
|
||||
SelectedDrive.ClusterSize[FS_EXFAT].Default = 4 * KB;
|
||||
else if (SelectedDrive.DiskSize < 32 * GB) // < 32 GB
|
||||
SelectedDrive.ClusterSize[FS_EXFAT].Default = 32 * KB;
|
||||
else
|
||||
SelectedDrive.ClusterSize[FS_EXFAT].Default = 128*KB;
|
||||
SelectedDrive.ClusterSize[FS_EXFAT].Default = 128 * KB;
|
||||
|
||||
// UDF
|
||||
SelectedDrive.ClusterSize[FS_UDF].Allowed = SINGLE_CLUSTERSIZE_DEFAULT;
|
||||
|
@ -1447,7 +1447,7 @@ static DWORD WINAPI BootCheckThread(LPVOID param)
|
|||
char* iso_image = lmprintf(MSG_036);
|
||||
char* dd_image = lmprintf(MSG_095);
|
||||
// If the ISO is small enough to be written as an ESP and we are using GPT add the ISO → ESP option
|
||||
if ((img_report.projected_size < MAX_ISO_TO_ESP_SIZE * MB) && HAS_REGULAR_EFI(img_report) &&
|
||||
if ((img_report.projected_size < MAX_ISO_TO_ESP_SIZE) && HAS_REGULAR_EFI(img_report) &&
|
||||
(partition_type == PARTITION_STYLE_GPT) && IS_FAT(fs_type)) {
|
||||
char* choices[3] = { lmprintf(MSG_276, iso_image), lmprintf(MSG_277, "ISO → ESP"), lmprintf(MSG_277, dd_image) };
|
||||
i = SelectionDialog(lmprintf(MSG_274, "ISOHybrid"), lmprintf(MSG_275, iso_image, dd_image, iso_image, dd_image), choices, 3);
|
||||
|
@ -1630,7 +1630,7 @@ static DWORD WINAPI BootCheckThread(LPVOID param)
|
|||
}
|
||||
}
|
||||
|
||||
if ((img_report.projected_size < MAX_ISO_TO_ESP_SIZE * MB) && HAS_REGULAR_EFI(img_report) &&
|
||||
if ((img_report.projected_size < MAX_ISO_TO_ESP_SIZE) && HAS_REGULAR_EFI(img_report) &&
|
||||
(partition_type == PARTITION_STYLE_GPT) && IS_FAT(fs_type) && !esp_already_asked) {
|
||||
// The ISO is small enough to be written as an ESP and we are using GPT
|
||||
// so ask the users if they want to write it as an ESP.
|
||||
|
@ -2954,6 +2954,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
|||
// Detect processes that have write (0x2) or exec (0x4) permissions against our drive.
|
||||
// Ideally, exec should be no big deal, but Windows complains on USB ejection if a
|
||||
// process such as cmd.exe holds exec rights, so we follow suit.
|
||||
PrintStatus(0, MSG_278);
|
||||
if (GetProcessSearch(SEARCH_PROCESS_TIMEOUT, 0x06, TRUE)) {
|
||||
char title[128];
|
||||
ComboBox_GetTextU(hDeviceList, title, sizeof(title));
|
||||
|
|
24
src/rufus.h
24
src/rufus.h
|
@ -31,6 +31,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
/* Convenient to have around */
|
||||
#define KB 1024LL
|
||||
#define MB 1048576LL
|
||||
#define GB 1073741824LL
|
||||
#define TB 1099511627776LL
|
||||
|
||||
/*
|
||||
* Features not ready for prime time and that may *DESTROY* your data - USE AT YOUR OWN RISKS!
|
||||
*/
|
||||
|
@ -62,9 +68,9 @@
|
|||
#define DRIVE_ACCESS_RETRIES 150 // How many times we should retry
|
||||
#define DRIVE_INDEX_MIN 0x00000080
|
||||
#define DRIVE_INDEX_MAX 0x000000C0
|
||||
#define MIN_DRIVE_SIZE 8 // Minimum size a drive must have, to be formattable (in MB)
|
||||
#define MIN_EXTRA_PART_SIZE (1024*1024) // Minimum size of the extra partition, in bytes
|
||||
#define MIN_EXT_SIZE (256*1024*1024) // Minimum size we allow for ext formatting
|
||||
#define MIN_DRIVE_SIZE (8 * MB) // Minimum size a drive must have, to be formattable
|
||||
#define MIN_EXTRA_PART_SIZE (1 * MB) // Minimum size of the extra partition, in bytes
|
||||
#define MIN_EXT_SIZE (256 * MB) // Minimum size we allow for ext formatting
|
||||
#define MAX_DRIVES (DRIVE_INDEX_MAX - DRIVE_INDEX_MIN)
|
||||
#define MAX_TOOLTIPS 128
|
||||
#define MAX_SIZE_SUFFIXES 6 // bytes, KB, MB, GB, TB, PB
|
||||
|
@ -78,8 +84,8 @@
|
|||
#define MAX_PARTITIONS 16 // Maximum number of partitions we handle
|
||||
#define MAX_ESP_TOGGLE 8 // Maximum number of entries we record to toggle GPT ESP back and forth
|
||||
#define MAX_IGNORE_USB 8 // Maximum number of USB drives we want to ignore
|
||||
#define MAX_ISO_TO_ESP_SIZE 1024 // Maximum size we allow for the ISO → ESP option (in MB)
|
||||
#define MAX_DEFAULT_LIST_CARD_SIZE 200 // Size above which we don't list a card without enable HDD or Alt-F (in GB)
|
||||
#define MAX_ISO_TO_ESP_SIZE (1 * GB) // Maximum size we allow for the ISO → ESP option
|
||||
#define MAX_DEFAULT_LIST_CARD_SIZE (500 * GB) // Size above which we don't list a card without enable HDD or Alt-F
|
||||
#define MAX_SECTORS_TO_CLEAR 128 // nb sectors to zap when clearing the MBR/GPT (must be >34)
|
||||
#define MAX_USERNAME_LENGTH 128 // Maximum size we'll accept for a WUE specified username
|
||||
#define MAX_WININST 4 // Max number of install[.wim|.esd] we can handle on an image
|
||||
|
@ -100,13 +106,13 @@
|
|||
#define BADBLOCK_PATTERN_SLC {0x00, 0xff, 0x55, 0xaa}
|
||||
#define BADCLOCK_PATTERN_MLC {0x00, 0xff, 0x33, 0xcc}
|
||||
#define BADBLOCK_PATTERN_TLC {0x00, 0xff, 0x1c71c7, 0xe38e38}
|
||||
#define BADBLOCK_BLOCK_SIZE (512 * 1024)
|
||||
#define LARGE_FAT32_SIZE (32 * 1073741824LL) // Size at which we need to use fat32format
|
||||
#define BADBLOCK_BLOCK_SIZE (512 * KB)
|
||||
#define LARGE_FAT32_SIZE (32 * GB) // Size at which we need to use fat32format
|
||||
#define UDF_FORMAT_SPEED 3.1f // Speed estimate at which we expect UDF drives to be formatted (GB/s)
|
||||
#define UDF_FORMAT_WARN 20 // Duration (in seconds) above which we warn about long UDF formatting times
|
||||
#define MAX_FAT32_SIZE 2.0f // Threshold above which we disable FAT32 formatting (in TB)
|
||||
#define MAX_FAT32_SIZE (2 * TB) // Threshold above which we disable FAT32 formatting
|
||||
#define FAT32_CLUSTER_THRESHOLD 1.011f // For FAT32, cluster size changes don't occur at power of 2 boundaries but slightly above
|
||||
#define DD_BUFFER_SIZE (32 * 1024 * 1024) // Minimum size of buffer to use for DD operations
|
||||
#define DD_BUFFER_SIZE (32 * MB) // Minimum size of buffer to use for DD operations
|
||||
#define UBUFFER_SIZE 4096
|
||||
#define ISO_BUFFER_SIZE (64 * KB) // Buffer size used for ISO data extraction
|
||||
#define RSA_SIGNATURE_SIZE 256
|
||||
|
|
10
src/rufus.rc
10
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 4.5.2158"
|
||||
CAPTION "Rufus 4.5.2159"
|
||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
||||
|
@ -397,8 +397,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 4,5,2158,0
|
||||
PRODUCTVERSION 4,5,2158,0
|
||||
FILEVERSION 4,5,2159,0
|
||||
PRODUCTVERSION 4,5,2159,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -416,13 +416,13 @@ BEGIN
|
|||
VALUE "Comments", "https://rufus.ie"
|
||||
VALUE "CompanyName", "Akeo Consulting"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "4.5.2158"
|
||||
VALUE "FileVersion", "4.5.2159"
|
||||
VALUE "InternalName", "Rufus"
|
||||
VALUE "LegalCopyright", "<22> 2011-2024 Pete Batard (GPL v3)"
|
||||
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
||||
VALUE "OriginalFilename", "rufus-4.5.exe"
|
||||
VALUE "ProductName", "Rufus"
|
||||
VALUE "ProductVersion", "4.5.2158"
|
||||
VALUE "ProductVersion", "4.5.2159"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
Loading…
Reference in a new issue