From efd22d1fe36954e7c5488f65aa8f230e0e242f34 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Wed, 3 Dec 2014 18:44:00 +0000 Subject: [PATCH] [vhd] fix VHD detection on Windows 7 * Revert to using strstr * Also fix a potential issue with GetTextExtentPoint --- src/msapi_utf8.h | 4 +++- src/rufus.rc | 16 ++++++++-------- src/stdlg.c | 8 ++------ src/usb.c | 13 +++++++------ 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/msapi_utf8.h b/src/msapi_utf8.h index 04acb4e7..aec92faa 100644 --- a/src/msapi_utf8.h +++ b/src/msapi_utf8.h @@ -383,7 +383,9 @@ static __inline BOOL GetTextExtentPointU(HDC hdc, const char* lpString, LPSIZE l BOOL ret = FALSE; DWORD err = ERROR_INVALID_DATA; wconvert(lpString); - ret = GetTextExtentPointW(hdc, wlpString, (int)wcslen(wlpString)+1, lpSize); + if (wlpString == NULL) + return FALSE; + ret = GetTextExtentPoint32W(hdc, wlpString, (int)wcslen(wlpString), lpSize); err = GetLastError(); wfree(lpString); SetLastError(err); diff --git a/src/rufus.rc b/src/rufus.rc index 6bf2d52f..15394b11 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 242, 329 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Rufus 1.5.0.552" +CAPTION "Rufus 1.5.0.553" FONT 8, "Segoe UI", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,127,291,50,14 @@ -164,7 +164,7 @@ END IDD_DIALOG_XP DIALOGEX 12, 12, 242, 329 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Rufus 1.5.0.552" +CAPTION "Rufus 1.5.0.553" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,127,291,50,14 @@ -297,7 +297,7 @@ END IDD_DIALOG_RTL DIALOGEX 12, 12, 242, 329 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_RTLREADING | WS_EX_APPWINDOW | WS_EX_LAYOUTRTL -CAPTION "Rufus 1.5.0.552" +CAPTION "Rufus 1.5.0.553" FONT 8, "Segoe UI", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,127,291,50,14 @@ -437,7 +437,7 @@ END IDD_DIALOG_RTL_XP DIALOGEX 12, 12, 242, 329 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_RTLREADING | WS_EX_APPWINDOW | WS_EX_LAYOUTRTL -CAPTION "Rufus 1.5.0.552" +CAPTION "Rufus 1.5.0.553" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,127,291,50,14 @@ -702,8 +702,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,5,0,552 - PRODUCTVERSION 1,5,0,552 + FILEVERSION 1,5,0,553 + PRODUCTVERSION 1,5,0,553 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -720,13 +720,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "1.5.0.552" + VALUE "FileVersion", "1.5.0.553" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "1.5.0.552" + VALUE "ProductVersion", "1.5.0.553" END END BLOCK "VarFileInfo" diff --git a/src/stdlg.c b/src/stdlg.c index 1218e2ba..dafb254f 100644 --- a/src/stdlg.c +++ b/src/stdlg.c @@ -867,23 +867,19 @@ LONG GetEntryWidth(HWND hDropDown, const char *entry) HDC hDC; HFONT hFont, hDefFont = NULL; SIZE size; - WCHAR* wentry = NULL; - int len; hDC = GetDC(hDropDown); hFont = (HFONT)SendMessage(hDropDown, WM_GETFONT, 0, 0); if (hFont != NULL) hDefFont = (HFONT)SelectObject(hDC, hFont); - wentry = utf8_to_wchar(entry); - len = (int)wcslen(wentry)+1; - GetTextExtentPoint32W(hDC, wentry, len, &size); + if (!GetTextExtentPointU(hDC, entry, &size)) + size.cx = 0; if (hFont != NULL) SelectObject(hDC, hDefFont); ReleaseDC(hDropDown, hDC); - free(wentry); return size.cx; } diff --git a/src/usb.c b/src/usb.c index ffccb4cb..7cc917f3 100644 --- a/src/usb.c +++ b/src/usb.c @@ -109,15 +109,16 @@ static __inline BOOL IsVHD(const char* buffer) int i; // List of the Friendly Names of the VHD devices we know const char* vhd_name[] = { - "Arsenal Virtual SCSI Disk Device", - "Kernsafe Virtual SCSI Disk Device", - "Microsoft Virtual Disk", - "MS Virtual Server SCSI Disk Device", - "Msft Virtual Disk" + "Arsenal Virtual", + "Kernsafe Virtual", + "Microsoft Virtual", + "MS Virtual", + "Msft Virtual", +// "VMware Virtual" // Would list primary disks on VMWare instances, so we avoid it }; for (i = 0; i < ARRAYSIZE(vhd_name); i++) - if (safe_stricmp(buffer, vhd_name[i]) == 0) + if (safe_strstr(buffer, vhd_name[i]) != NULL) return TRUE; return FALSE; }