From a16d35698fa486a81af0876bf3422cf62d367576 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Mon, 4 Feb 2013 23:15:11 +0000 Subject: [PATCH] [misc] various fixes and improvements * add commandline usage guide * use -w 150 instead of /W for updated app launch * fix enabling/disabling of advanced options for UEFI/exFAT * test for >4GB files for UEFI * fix warning with freopen --- src/rufus.c | 79 ++++++++++++++++++++++++++++++---------------------- src/rufus.rc | 10 +++---- src/stdlg.c | 2 +- 3 files changed, 52 insertions(+), 39 deletions(-) diff --git a/src/rufus.c b/src/rufus.c index 3e2a0a3e..836cf5d0 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -410,7 +410,7 @@ static void SetFSFromISO(void) ComboBox_GetCurSel(hFileSystem)); } -void SetMBRProps(void) +static void SetMBRProps(void) { int fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); int dt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)); @@ -427,13 +427,27 @@ void SetMBRProps(void) IGNORE_RETVAL(ComboBox_SetCurSel(hDiskID, needs_masquerading?1:0)); } -void EnableBootOptions(BOOL enable) +static void EnableAdvancedBootOptions(BOOL enable) { - EnableWindow(hBoot, enable); - EnableWindow(hBootType, enable); - EnableWindow(hSelectISO, enable); - EnableWindow(GetDlgItem(hMainDialog, IDC_RUFUS_MBR), enable); - EnableWindow(hDiskID, enable); + BOOL actual_enable; + int bt = GETBIOSTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme))); + actual_enable = (bt==BT_UEFI)?FALSE:enable; + + EnableWindow(GetDlgItem(hMainDialog, IDC_RUFUS_MBR), actual_enable); + EnableWindow(GetDlgItem(hMainDialog, IDC_EXTRA_PARTITION), actual_enable); + EnableWindow(hDiskID, actual_enable); +} + +static void EnableBootOptions(BOOL enable) +{ + BOOL actual_enable; + int fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); + actual_enable = ((fs != FS_FAT16) && (fs != FS_FAT32) && (fs != FS_NTFS))?FALSE:enable; + + EnableWindow(hBoot, actual_enable); + EnableWindow(hBootType, actual_enable); + EnableWindow(hSelectISO, actual_enable); + EnableAdvancedBootOptions(actual_enable); } static void SetPartitionSchemeTooltip(void) @@ -464,7 +478,7 @@ static BOOL PopulateProperties(int ComboIndex) char capacity[64]; static char* suffix[] = { "B", "KB", "MB", "GB", "TB", "PB"}; char no_label[] = STR_NO_LABEL; - int i, j, pt, bt, fs; + int i, j, pt, bt; IGNORE_RETVAL(ComboBox_ResetContent(hPartitionScheme)); IGNORE_RETVAL(ComboBox_ResetContent(hFileSystem)); @@ -479,8 +493,7 @@ static BOOL PopulateProperties(int ComboIndex) if (!GetDriveInfo(ComboIndex)) // This also populates FS return FALSE; SetFSFromISO(); - fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); - EnableBootOptions((fs == FS_FAT16) || (fs == FS_FAT32) || (fs == FS_NTFS)); + EnableBootOptions(TRUE); HumanReadableSize = (double)SelectedDrive.DiskSize; for (i=1; i]\n", fname); + printf("\nUsage: %s [-h] [-i PATH] [-w TIMEOUT]\n", fname); + printf(" -i PATH, --iso=PATH\n"); + printf(" Select the ISO image pointed by PATH to be used on startup\n"); + printf(" -w TIMEOUT, --wait=TIMEOUT\n"); + printf(" Wait TIMEOUT tens of a second for the global application mutex to be released.\n"); + printf(" Used when launching a newer version of " APPLICATION_NAME " from a running application.\n"); + printf(" -h, --help\n"); + printf(" This usage guide.\n"); } /* There's a massive annoyance when taking over the console in a win32 app @@ -1763,21 +1776,21 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine // Reattach the console, if we were started from commandline if (AttachConsole(ATTACH_PARENT_PROCESS) != 0) { attached_console = TRUE; - freopen("CONIN$", "r", stdin); - freopen("CONOUT$", "w", stdout); - freopen("CONOUT$", "w", stderr); + IGNORE_RETVAL(freopen("CONIN$", "r", stdin)); + IGNORE_RETVAL(freopen("CONOUT$", "w", stdout)); + IGNORE_RETVAL(freopen("CONOUT$", "w", stderr)); _flushall(); printf("\n"); } + // We have to process the arguments before we acquire the lock PF_INIT(__wgetmainargs, msvcrt); if (pf__wgetmainargs != NULL) { pf__wgetmainargs(&argc, &wargv, &wenv, 1, &si); argv = (char**)calloc(argc, sizeof(char*)); for (i=0; i0)&&(filepath[i]!='\\'); i--); safe_strcpy(tmp, sizeof(tmp), &filepath[i+1]); - safe_strcat(tmp, sizeof(tmp), " /W"); + safe_strcat(tmp, sizeof(tmp), " -w 150"); // add 15 seconds delay to wait for lock release filepath[i] = 0; memset(&si, 0, sizeof(si)); memset(&pi, 0, sizeof(pi));