From 24e73c5e10481f63fc12fee2494cf8a1dc3fcc53 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Sun, 22 Dec 2013 20:48:57 +0000 Subject: [PATCH] [efi] set UEFI mode when a pure EFI ISO is selected * Closes #168 * Also fix various VS Code Analysis warnings --- src/iso.c | 2 +- src/localization.c | 5 +++-- src/parser.c | 4 ++++ src/registry.h | 2 +- src/rufus.c | 34 ++++++++++++++++++++++------------ src/rufus.h | 4 ++-- src/rufus.rc | 10 +++++----- 7 files changed, 38 insertions(+), 23 deletions(-) diff --git a/src/iso.c b/src/iso.c index 3e38fdf2..6a2e2ba9 100644 --- a/src/iso.c +++ b/src/iso.c @@ -126,7 +126,7 @@ static void log_handler (cdio_log_level_t level, const char *message) * Scan and set ISO properties * Returns true if the the current file does not need to be processed further */ -static __inline BOOL check_iso_props(const char* psz_dirname, BOOL* is_syslinux_cfg, BOOL* is_old_c32, +static BOOL check_iso_props(const char* psz_dirname, BOOL* is_syslinux_cfg, BOOL* is_old_c32, int64_t i_file_length, const char* psz_basename, const char* psz_fullpath) { size_t i, j; diff --git a/src/localization.c b/src/localization.c index 01e15573..ba335f9a 100644 --- a/src/localization.c +++ b/src/localization.c @@ -380,12 +380,13 @@ BOOL dispatch_loc_cmd(loc_cmd* lcmd) if (lcmd->command <= LC_TEXT) { // Any command up to LC_TEXT takes a control ID in text[0] if (safe_strncmp(lcmd->txt[0], msg_prefix, 4) == 0) { - if (lcmd->command != LC_TEXT) { + // The unneeded NULL check is to silence a VS warning + if ((lcmd->txt[0] == NULL) || (lcmd->command != LC_TEXT)) { luprint("only the [t]ext command can be applied to a message (MSG_###)\n"); goto err; } // Try to convert the numeric part of a MSG_#### to a numeric - lcmd->ctrl_id = MSG_000 + atoi(&lcmd->txt[0][4]); + lcmd->ctrl_id = MSG_000 + atoi(&(lcmd->txt[0][4])); if (lcmd->ctrl_id == MSG_000) { // Conversion could not be performed luprintf("failed to convert the numeric value in '%'\n", lcmd->txt[0]); diff --git a/src/parser.c b/src/parser.c index 6ee28ab6..ea35b2cb 100644 --- a/src/parser.c +++ b/src/parser.c @@ -404,6 +404,10 @@ BOOL get_loc_data_file(const char* filename, loc_cmd* lcmd) old_loc_line_nr = loc_line_nr; } + if (lcmd == NULL) { + uprintf("Spock gone crazy error!\n"); + goto out; + } offset = (long)lcmd->num[0]; end_offset = (long)lcmd->num[1]; start_line = lcmd->line_nr; diff --git a/src/registry.h b/src/registry.h index d467eef9..28887349 100644 --- a/src/registry.h +++ b/src/registry.h @@ -165,7 +165,7 @@ static __inline BOOL WriteRegistryKey32(HKEY root, const char* key, int32_t val) /* Helpers for String registry operations */ #define GetRegistryKeyStr(root, key, str, len) _GetRegistryKey(root, key, REG_SZ, (LPBYTE)str, (DWORD)len) -#define SetRegistryKeyStr(root, key, str) _SetRegistryKey(root, key, REG_SZ, (LPBYTE)str, safe_strlen(str)) +#define SetRegistryKeyStr(root, key, str) _SetRegistryKey(root, key, REG_SZ, (LPBYTE)str, (DWORD)safe_strlen(str)) // Use a static buffer - don't allocate static __inline char* ReadRegistryKeyStr(HKEY root, const char* key) { static char str[512]; diff --git a/src/rufus.c b/src/rufus.c index 11d68ece..4fc02091 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -522,6 +522,22 @@ static void SetPartitionSchemeTooltip(void) } } +static void SetTargetSystem(void) +{ + int ts; + + if (SelectedDrive.PartitionType == PARTITION_STYLE_GPT) { + ts = 2; // GPT/UEFI + } else if (SelectedDrive.has_protective_mbr || SelectedDrive.has_mbr_uefi_marker || (IS_EFI(iso_report) && + (!iso_report.has_isolinux) && (!iso_report.has_bootmgr) && (!IS_WINPE(iso_report.winpe))) ) { + ts = 1; // MBR/UEFI + } else { + ts = 0; // MBR/BIOS|UEFI + } + IGNORE_RETVAL(ComboBox_SetCurSel(hPartitionScheme, ts)); + SetPartitionSchemeTooltip(); +} + /* * Populate the UI properties */ @@ -544,8 +560,6 @@ static BOOL PopulateProperties(int ComboIndex) if (!GetDriveInfo(ComboIndex)) // This also populates FS return FALSE; - SetFSFromISO(); - EnableBootOptions(TRUE); HumanReadableSize = (double)SelectedDrive.DiskSize; for (i=1; i= MAX_SIZE_SUFFIXES) uprintf("Could not populate partition scheme data\n"); - if (SelectedDrive.PartitionType == PARTITION_STYLE_GPT) { - j = 2; - } else if (SelectedDrive.has_protective_mbr || SelectedDrive.has_mbr_uefi_marker) { - j = 1; - } else { - j = 0; - } - IGNORE_RETVAL(ComboBox_SetCurSel(hPartitionScheme, j)); - SetPartitionSchemeTooltip(); + + SetTargetSystem(); + SetFSFromISO(); + EnableBootOptions(TRUE); device_tooltip = (char*) malloc(safe_strlen(DriveID.Table[ComboIndex]) + 16); // Set a proposed label according to the size (eg: "256MB", "8GB") @@ -1176,8 +1185,9 @@ DWORD WINAPI ISOScanThread(LPVOID param) } } - // Enable DOS, set DOS Type to ISO (last item) and set FS accordingly + // Enable bootable and set Target System and FS accordingly CheckDlgButton(hMainDialog, IDC_BOOT, BST_CHECKED); + SetTargetSystem(); SetFSFromISO(); SetMBRProps(); for (i=(int)safe_strlen(iso_path); (i>0)&&(iso_path[i]!='\\'); i--); diff --git a/src/rufus.h b/src/rufus.h index 1592b542..7b6fb168 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -180,8 +180,8 @@ enum bios_type { BT_MAX }; // For the partition types we'll use Microsoft's PARTITION_STYLE_### constants -#define GETBIOSTYPE(x) (((x) >> 16) & 0xFFFF) -#define GETPARTTYPE(x) ((x) & 0xFFFF); +#define GETBIOSTYPE(x) (((x)>0)?(((x) >> 16) & 0xFFFF):0) +#define GETPARTTYPE(x) (((x)>0)?((x) & 0xFFFF):0); /* Current drive info */ typedef struct { diff --git a/src/rufus.rc b/src/rufus.rc index f7b5fbce..0a8ca9d4 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 206, 329 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW -CAPTION "Rufus v1.4.2.361" +CAPTION "Rufus v1.4.2.362" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,94,291,50,14 @@ -288,8 +288,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,4,2,361 - PRODUCTVERSION 1,4,2,361 + FILEVERSION 1,4,2,362 + PRODUCTVERSION 1,4,2,362 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -306,13 +306,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "1.4.2.361" + VALUE "FileVersion", "1.4.2.362" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2013 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "1.4.2.361" + VALUE "ProductVersion", "1.4.2.362" END END BLOCK "VarFileInfo"