[misc] address various TODOs and improve UI

* display comprehensive partition information
* improve tooltips
* remove TODOs that are no longer relevant
This commit is contained in:
Pete Batard 2012-05-29 17:47:24 +01:00
parent af80c80917
commit 372b89ba3a
6 changed files with 57 additions and 41 deletions

View File

@ -937,7 +937,7 @@ BOOL SetDOSLocale(const char* path, BOOL bFreeDOS)
kbdrv = bFreeDOS?fd_get_kbdrv(kb):ms_get_kbdrv(kb);
if (kbdrv == NULL) {
uprintf("Keyboard id '%s' is not supported - falling back to 'us'\n", kb);
kb = "us"; // TODO: smarter fallback?
kb = "us";
kbdrv = bFreeDOS?fd_get_kbdrv(kb):ms_get_kbdrv(kb); // Always succeeds
}
uprintf("Will use DOS keyboard '%s' [%s]\n", kb, kb_to_hr(kb));
@ -1018,4 +1018,3 @@ BOOL SetDOSLocale(const char* path, BOOL bFreeDOS)
return TRUE;
}

View File

@ -102,8 +102,8 @@ HANDLE GetDriveHandle(DWORD DriveIndex, char* DriveLetter, BOOL bWriteAccess, BO
value there => Use GetDriveType() to filter out unwanted devices.
See https://github.com/pbatard/rufus/issues/32 for details. */
drive_type = GetDriveTypeA(drive);
// NB: the HP utility allows drive_type == DRIVE_FIXED, which we don't really really want for now
// TODO: allow fixed drives after partitioning/preserving of existing partitions has been sorted out
// NB: the HP utility allows drive_type == DRIVE_FIXED, which we don't allow by default
// Using Alt-F in Rufus does enable listing, but this mode is unsupported.
if ((drive_type != DRIVE_REMOVABLE) && ((!enable_fixed_disks) || (drive_type != DRIVE_FIXED)))
continue;

View File

@ -415,7 +415,7 @@ BOOL WriteRufusMBR(FILE *fp)
unsigned char aucRef[] = {0x55, 0xAA};
unsigned char* rufus_mbr;
// TODO: will we need to edit the disk ID according to UI sel in the MBR as well?
// TODO: Will we need to edit the disk ID according to UI selection in the MBR as well?
res = FindResource(hMainInstance, MAKEINTRESOURCE(IDR_BR_MBR_BIN), RT_RCDATA);
if (res == NULL) {
uprintf("Unable to locate mbr.bin resource: %s\n", WindowsErrorString());
@ -449,7 +449,7 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive)
// FormatEx rewrites the MBR and removes the LBA attribute of FAT16
// and FAT32 partitions - we need to correct this in the MBR
// TODO: something else for bootable GPT
// TODO: Something else for bootable GPT
buf = (unsigned char*)malloc(SecSize * nSecs);
if (buf == NULL) {
uprintf("Could not allocate memory for MBR");
@ -526,7 +526,6 @@ static BOOL WritePBR(HANDLE hLogicalVolume)
fake_fd._ptr = (char*)hLogicalVolume;
fake_fd._bufsiz = SelectedDrive.Geometry.BytesPerSector;
// TODO: call write_partition_number_of_heads() and write_partition_start_sector_number()?
switch (ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem))) {
case FS_FAT16:
if (!is_fat_16_fs(&fake_fd)) {
@ -582,7 +581,6 @@ static BOOL WritePBR(HANDLE hLogicalVolume)
/*
* Setup WinPE for bootable USB
*/
// TODO: set FormatError
static BOOL SetupWinPE(char drive_letter)
{
char src[64], dst[32];
@ -609,8 +607,9 @@ static BOOL SetupWinPE(char drive_letter)
// Create a copy of txtsetup.sif, as we want to keep the i386 files unmodified
safe_sprintf(src, sizeof(src), "%c:\\%s\\txtsetup.sif", drive_letter, basedir[index]);
safe_sprintf(dst, sizeof(dst), "%c:\\txtsetup.sif", drive_letter);
// TODO: detect if overwrite?
CopyFileA(src, dst, TRUE);
if (!CopyFileA(src, dst, TRUE)) {
uprintf("Did not copy %s as %s: %s\n", src, dst, WindowsErrorString());
}
if (insert_section_data(dst, "[SetupData]", setupsrcdev, FALSE) == NULL) {
uprintf("Failed to add SetupSourceDevice in %s\n", dst);
goto out;
@ -620,8 +619,9 @@ static BOOL SetupWinPE(char drive_letter)
safe_sprintf(src, sizeof(src), "%c:\\%s\\setupldr.bin", drive_letter, basedir[index]);
safe_sprintf(dst, sizeof(dst), "%c:\\BOOTMGR", drive_letter);
// TODO: detect if overwrite?
CopyFileA(src, dst, TRUE);
if (!CopyFileA(src, dst, TRUE)) {
uprintf("Did not copy %s as %s: %s\n", src, dst, WindowsErrorString());
}
// \minint with /minint option doesn't require further processing => return true
// \minint and no \i386 without /minint is unclear => return error
@ -659,7 +659,6 @@ static BOOL SetupWinPE(char drive_letter)
uprintf("Patching file %s\n", dst);
// Remove CRC check for 32 bit part of setupldr.bin from Win2k3
if ((size > 0x2061) && (buf[0x2060] == 0x74) && (buf[0x2061] == 0x03)) {
// TODO: amend this if not all Win2k3 setupldr.bin's use the same header
buf[0x2060] = 0xeb;
buf[0x2061] = 0x1a;
uprintf(" 0x00002060: 0x74 0x03 -> 0xEB 0x1A (disable Win2k3 CRC check)\n");
@ -678,7 +677,7 @@ static BOOL SetupWinPE(char drive_letter)
// Additional setupldr.bin/bootmgr patching
for (i=0; i<size-32; i++) {
// rdisk(0) -> rdisk(#) disk masquerading
// TODO: only the first one seems to be needed
// NB: only the first one seems to be needed
if (safe_strnicmp(&buf[i], rdisk_zero, strlen(rdisk_zero)-1) == 0) {
buf[i+6] = 0x20 + ComboBox_GetCurSel(hDiskID);
uprintf(" 0x%08X: '%s' -> 'rdisk(%c)'\n", i, rdisk_zero, buf[i+6]);

View File

@ -311,6 +311,25 @@ static BOOL SetClusterSizes(int FSType)
return TRUE;
}
// Convert a file size to human readable
static __inline char* size_to_hr(LARGE_INTEGER size)
{
int suffix = 0;
static char str_size[24];
const char* sizes[] = { "", "KB", "MB", "GB", "TB" };
double hr_size = (double)size.QuadPart;
while ((suffix < ARRAYSIZE(sizes)) && (hr_size >= 1024.0)) {
hr_size /= 1024.0;
suffix++;
}
if (suffix == 0) {
safe_sprintf(str_size, sizeof(str_size), "%d bytes", (int)hr_size);
} else {
safe_sprintf(str_size, sizeof(str_size), "%0.1f %s", hr_size, sizes[suffix]);
}
return str_size;
}
/*
* Fill the drive properties (size, FS, etc)
*/
@ -319,13 +338,14 @@ static BOOL GetDriveInfo(void)
BOOL r;
HANDLE hDrive;
DWORD size;
BYTE geometry[128], layout[1024];
BYTE geometry[128], layout[1024], part_type;
void* disk_geometry = (void*)geometry;
void* drive_layout = (void*)layout;
PDISK_GEOMETRY_EX DiskGeometry = (PDISK_GEOMETRY_EX)disk_geometry;
PDRIVE_LAYOUT_INFORMATION_EX DriveLayout = (PDRIVE_LAYOUT_INFORMATION_EX)drive_layout;
char DrivePath[] = "#:\\", tmp[128], fs_type[32];
char DrivePath[] = "#:\\", tmp[512], fs_type[32];
DWORD i, nb_partitions = 0;
int tmp_pos;
SelectedDrive.DiskSize = 0;
@ -354,26 +374,23 @@ static BOOL GetDriveInfo(void)
r = FALSE;
switch (DriveLayout->PartitionStyle) {
case PARTITION_STYLE_MBR:
for (i=0; i<DriveLayout->PartitionCount; i++) {
for (tmp_pos=0, i=0; (i<DriveLayout->PartitionCount)&&(tmp_pos>=0); i++) {
if (DriveLayout->PartitionEntry[i].Mbr.PartitionType != PARTITION_ENTRY_UNUSED) {
uprintf("Partition #%d:\n", ++nb_partitions);
if (!r) {
// TODO: provide all partitions FS on tooltip, not just the one
safe_sprintf(tmp, sizeof(tmp), "Current file system: %s (0x%02x)",
GetPartitionType(DriveLayout->PartitionEntry[i].Mbr.PartitionType),
DriveLayout->PartitionEntry[i].Mbr.PartitionType);
CreateTooltip(hFileSystem, tmp, -1);
r = TRUE;
}
uprintf(" Type: %s (0x%02x)\n Boot: %s\n Recognized: %s\n Hidden Sectors: %d\n",
GetPartitionType(DriveLayout->PartitionEntry[i].Mbr.PartitionType),
DriveLayout->PartitionEntry[i].Mbr.PartitionType,
nb_partitions++;
uprintf("Partition %d:\n", i+1);
part_type = DriveLayout->PartitionEntry[i].Mbr.PartitionType;
uprintf(" Type: %s (0x%02x)\n Size: %s\n Boot: %s\n Recognized: %s\n Hidden Sectors: %d\n",
GetPartitionType(part_type), part_type, size_to_hr(DriveLayout->PartitionEntry[i].PartitionLength),
DriveLayout->PartitionEntry[i].Mbr.BootIndicator?"Yes":"No",
DriveLayout->PartitionEntry[i].Mbr.RecognizedPartition?"Yes":"No",
DriveLayout->PartitionEntry[i].Mbr.HiddenSectors);
tmp_pos = safe_sprintf(&tmp[tmp_pos], sizeof(tmp)-tmp_pos, "Partition %d: %s (%s)\n",
i+1, GetPartitionType(part_type), size_to_hr(DriveLayout->PartitionEntry[i].PartitionLength));
}
}
uprintf("Partition type: MBR, NB Partitions: %d\n", nb_partitions);
tmp[sizeof(tmp)-1] = 0;
CreateTooltip(hCapacity, tmp, -1);
break;
case PARTITION_STYLE_GPT:
uprintf("Partition type: GPT, NB Partitions: %d\n", DriveLayout->PartitionCount);
@ -587,6 +604,8 @@ BOOL CreatePartition(HANDLE hDrive)
DriveLayoutEx.PartitionEntry[0].PartitionStyle = PARTITION_STYLE_MBR;
// TODO: CHS fixup (32 sectors/track) through a cheat mode, if requested
// NB: disk geometry is computed by BIOS & co. by finding a match between LBA and CHS value of first partition
// ms-sys's write_partition_number_of_heads() and write_partition_start_sector_number() can be used if needed
DriveLayoutEx.PartitionEntry[0].StartingOffset.QuadPart =
SelectedDrive.Geometry.BytesPerSector * SelectedDrive.Geometry.SectorsPerTrack;
sector_size = (SelectedDrive.DiskSize - DriveLayoutEx.PartitionEntry[0].StartingOffset.QuadPart) / SelectedDrive.Geometry.BytesPerSector;
@ -1374,23 +1393,23 @@ void InitDialog(HWND hDlg)
SendMessage(GetDlgItem(hDlg, IDC_ADVANCED), BCM_SETIMAGELIST, 0, (LPARAM)&bi_down);
// Set the various tooltips
CreateTooltip(hCapacity, "Size of the current USB drive", -1);
CreateTooltip(hClusterSize, "Minimum size that each data block will occupy", -1);
CreateTooltip(hFileSystem, "Sets the target filesystem", -1);
CreateTooltip(hClusterSize, "Minimum size that each data block occupies", -1);
CreateTooltip(hLabel, "Use this field to set the drive label\nInternational characters are accepted", -1);
CreateTooltip(GetDlgItem(hDlg, IDC_ADVANCED), "Toggle advanced options", -1);
CreateTooltip(GetDlgItem(hDlg, IDC_BADBLOCKS), "Test the device for bad blocks using a set byte pattern", -1);
CreateTooltip(GetDlgItem(hDlg, IDC_QUICKFORMAT), "Unchek this box to use the \"slow\" format method", -1);
CreateTooltip(hDOS, "Check this box to make the USB drive bootable", -1);
CreateTooltip(hDOSType, "Type of boot", -1);
CreateTooltip(hDOSType, "Boot method", -1);
CreateTooltip(hSelectISO, "Click to select an ISO...", -1);
CreateTooltip(GetDlgItem(hDlg, IDC_SET_ICON), "Check this box to allow the display of international labels "
"as well as set a device icon (through autorun.inf)", 10000);
"and set a device icon (creates an autorun.inf)", 10000);
CreateTooltip(GetDlgItem(hDlg, IDC_RUFUS_MBR), "Install an MBR that allows boot selection and can masquerade the BIOS USB drive ID", 10000);
CreateTooltip(hDiskID, "Try to masquerade first bootable USB drive (usually 0x80) as a different disk.\n"
"This should only be necessary for XP installation" , 10000);
CreateTooltip(GetDlgItem(hDlg, IDC_EXTRA_PARTITION), "Create an extra hidden partition and try to align partitions boundaries.\n"
"This can improve boot detection for older BIOSes", -1);
CreateTooltip(GetDlgItem(hDlg, IDC_START), "Format the drive. This will DESTROY any data on it", -1);
CreateTooltip(GetDlgItem(hDlg, IDC_START), "Start the formatting operation.\nThis will DESTROY any data on the target!", -1);
CreateTooltip(GetDlgItem(hDlg, IDC_ABOUT), "Licensing information and credits", -1);
ToggleAdvanced(); // We start in advanced mode => go to basic mode

View File

@ -30,7 +30,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 316
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "Rufus v1.2.0.177"
CAPTION "Rufus v1.2.0.178"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,278,50,14
@ -76,7 +76,7 @@ BEGIN
DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP
CONTROL "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL,
"SysLink",WS_TABSTOP,46,47,114,9
LTEXT "Version 1.2.0 (Build 177)",IDC_STATIC,46,19,78,8
LTEXT "Version 1.2.0 (Build 178)",IDC_STATIC,46,19,78,8
PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP
EDITTEXT IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL
LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8
@ -221,8 +221,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,2,0,177
PRODUCTVERSION 1,2,0,177
FILEVERSION 1,2,0,178
PRODUCTVERSION 1,2,0,178
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -239,13 +239,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "akeo.ie"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.2.0.177"
VALUE "FileVersion", "1.2.0.178"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "1.2.0.177"
VALUE "ProductVersion", "1.2.0.178"
END
END
BLOCK "VarFileInfo"

View File

@ -55,7 +55,6 @@ int libfat_readfile(intptr_t pp, void *buf, size_t secsize,
!ReadFile((HANDLE) pp, buf, (DWORD)secsize, &bytes_read, NULL) ||
bytes_read != secsize) {
uprintf("Cannot read sector %u\n", sector);
// TODO -1?
return 0;
}