[vhd] fix VHD detection on Windows 7

* Revert to using strstr
* Also fix a potential issue with GetTextExtentPoint
This commit is contained in:
Pete Batard 2014-12-03 18:44:00 +00:00
parent 8e8a2bc827
commit efd22d1fe3
4 changed files with 20 additions and 21 deletions

View File

@ -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);

View File

@ -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"

View File

@ -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;
}

View File

@ -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;
}