diff --git a/resource.h b/resource.h index 0297b009..6d4a4f4d 100644 --- a/resource.h +++ b/resource.h @@ -13,18 +13,22 @@ #define IDC_CLOSE 1004 #define IDC_CAPACITY 1005 #define IDC_ALLOCSIZE 1006 -#define IDC_ABOUT_ICON 1007 -#define IDC_RUFUS_BOLD 1008 #define IDC_STATUS 1009 #define IDC_ABOUT 1010 +#define IDC_LABEL 1011 +#define IDC_QUICKFORMAT 1012 +#define IDC_DOSSTARTUP 1013 +#define IDC_PROGRESS 1014 #define IDC_ABOUT_LICENSE 1030 -#define IDC_ABOUT_COPYRIGHTS 1031 -#define IDC_ABOUT_RUFUS_URL 1032 -#define IDC_ABOUT_BUG_URL 1033 +#define IDC_ABOUT_ICON 1031 +#define IDC_RUFUS_BOLD 1032 +#define IDC_ABOUT_COPYRIGHTS 1033 +#define IDC_ABOUT_RUFUS_URL 1034 +#define IDC_ABOUT_BUG_URL 1035 +#define IDC_LICENSE_TEXT 1036 #define IDC_NOTIFICATION_ICON 1040 #define IDC_NOTIFICATION_TEXT 1041 #define IDC_NOTIFICATION_LINE 1042 -#define IDC_LICENSE_TEXT 1050 // Next default values for new objects // @@ -33,7 +37,7 @@ #define _APS_NO_MFC 1 #define _APS_NEXT_RESOURCE_VALUE 106 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1051 +#define _APS_NEXT_CONTROL_VALUE 1043 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/rufus.c b/rufus.c index 0bc16d81..c39336a1 100644 --- a/rufus.c +++ b/rufus.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -60,8 +61,19 @@ char szFolderPath[MAX_PATH]; HWND hStatus; float fScale = 1.0f; -static HWND hDeviceList, hCapacity, hFileSystem, hDeviceToolTip = NULL; -static StrArray DriveID; +BOOL bBootable; +BOOL bQuickFormat; + +struct { + DWORD DeviceNumber; + LONGLONG DiskSize; + LONGLONG PartitionSize; + DWORD FirstSector; + char FSType[32]; +} SelectedDrive; + +static HWND hDeviceList, hCapacity, hFileSystem, hLabel, hDeviceToolTip = NULL; +static StrArray DriveID, DriveLabel; #ifdef RUFUS_DEBUG void _uprintf(const char *format, ...) @@ -270,15 +282,15 @@ static BOOL GetDriveHandle(DWORD DriveIndex, HANDLE* hDrive, char* DriveLetter, /* * Return the drive letter and volume label */ -static BOOL GetDriveLabel(DWORD num, char* letter, char** label) +static BOOL GetDriveLabel(DWORD DriveIndex, char* letter, char** label) { HANDLE hDrive; char DrivePath[] = "#:\\"; - char volume_label[MAX_PATH+1]; + static char volume_label[MAX_PATH+1]; - *label = "NO_LABEL"; + *label = STR_NO_LABEL; - if (!GetDriveHandle(num, &hDrive, DrivePath, FALSE)) + if (!GetDriveHandle(DriveIndex, &hDrive, DrivePath, FALSE)) return FALSE; safe_closehandle(hDrive); *letter = DrivePath[0]; @@ -291,9 +303,9 @@ static BOOL GetDriveLabel(DWORD num, char* letter, char** label) } /* - * Returns the drive properties (size, FS) + * Fill the drive properties (size, FS, etc) */ -static BOOL GetDriveInfo(DWORD num, LONGLONG* DriveSize, char* FSType, DWORD FSTypeSize) +static BOOL GetDriveInfo(void) { BOOL r; HANDLE hDrive; @@ -306,9 +318,9 @@ static BOOL GetDriveInfo(DWORD num, LONGLONG* DriveSize, char* FSType, DWORD FST char DrivePath[] = "#:\\"; DWORD i, nb_partitions = 0; - *DriveSize = 0; + SelectedDrive.DiskSize = 0; - if (!GetDriveHandle(num, &hDrive, DrivePath, FALSE)) + if (!GetDriveHandle(SelectedDrive.DeviceNumber, &hDrive, DrivePath, FALSE)) return FALSE; r = DeviceIoControl(hDrive, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, @@ -318,7 +330,7 @@ static BOOL GetDriveInfo(DWORD num, LONGLONG* DriveSize, char* FSType, DWORD FST safe_closehandle(hDrive); return FALSE; } - *DriveSize = DiskGeometry->DiskSize.QuadPart; + SelectedDrive.DiskSize = DiskGeometry->DiskSize.QuadPart; uprintf("Cylinders: %lld, TracksPerCylinder: %d, SectorsPerTrack: %d, BytesPerSector: %d\n", DiskGeometry->Geometry.Cylinders, DiskGeometry->Geometry.TracksPerCylinder, DiskGeometry->Geometry.SectorsPerTrack, DiskGeometry->Geometry.BytesPerSector); @@ -354,9 +366,9 @@ static BOOL GetDriveInfo(DWORD num, LONGLONG* DriveSize, char* FSType, DWORD FST safe_closehandle(hDrive); - if (!GetVolumeInformationA(DrivePath, NULL, 0, NULL, NULL, NULL, FSType, FSTypeSize)) { - safe_sprintf(FSType, FSTypeSize, "Non Windows (Please Select)"); -// uprintf("GetVolumeInformation (Properties) failed: %s\n", WindowsErrorString()); + if (!GetVolumeInformationA(DrivePath, NULL, 0, NULL, NULL, NULL, + SelectedDrive.FSType, sizeof(SelectedDrive.FSType))) { + safe_sprintf(SelectedDrive.FSType, sizeof(SelectedDrive.FSType), "Non Windows (Please Select)"); } return TRUE; @@ -365,26 +377,30 @@ static BOOL GetDriveInfo(DWORD num, LONGLONG* DriveSize, char* FSType, DWORD FST /* * Populate the UI properties */ -static BOOL PopulateProperties(int index) +static BOOL PopulateProperties(int ComboIndex) { double HumanReadableSize; - LONGLONG DiskSize; - DWORD DeviceNumber; - char capacity[64], FSType[32]; - char* suffix[] = { "KB", "MB", "GB", "TB", "PB"}; + char capacity[64]; + char *suffix[] = { "KB", "MB", "GB", "TB", "PB"}; + char proposed_label[16], no_label[] = STR_NO_LABEL; int i; IGNORE_RETVAL(ComboBox_ResetContent(hCapacity)); IGNORE_RETVAL(ComboBox_ResetContent(hFileSystem)); - if (index < 0) { + SetWindowTextA(hLabel, ""); + DestroyTooltip(hDeviceToolTip); + hDeviceToolTip = NULL; + memset(&SelectedDrive, 0, sizeof(SelectedDrive)); + + if (ComboIndex < 0) { return TRUE; } - DeviceNumber = (DWORD)ComboBox_GetItemData(hDeviceList, index); - if (!GetDriveInfo(DeviceNumber, &DiskSize, FSType, sizeof(FSType))) + SelectedDrive.DeviceNumber = (DWORD)ComboBox_GetItemData(hDeviceList, ComboIndex); + if (!GetDriveInfo()) return FALSE; - HumanReadableSize = (double)DiskSize; + HumanReadableSize = (double)SelectedDrive.DiskSize; for (i=0; i