[enum] use Unicode when retrieving the device friendly name

* This should fix the improper display of some localized strings such as
  "Microsoft Virtual Disk"
This commit is contained in:
Pete Batard 2016-06-05 20:21:16 +01:00
parent de386329e4
commit 66534640a4
3 changed files with 26 additions and 6 deletions

View File

@ -376,7 +376,7 @@ BOOL GetDevices(DWORD devnum)
&datatype, (LPBYTE)buffer, sizeof(buffer), &size) && IsRemovable(buffer);
memset(buffer, 0, sizeof(buffer));
if (!SetupDiGetDeviceRegistryPropertyA(dev_info, &dev_info_data, SPDRP_FRIENDLYNAME,
if (!SetupDiGetDeviceRegistryPropertyU(dev_info, &dev_info_data, SPDRP_FRIENDLYNAME,
&datatype, (LPBYTE)buffer, sizeof(buffer), &size)) {
uprintf("SetupDiGetDeviceRegistryProperty (Friendly Name) failed: %s\n", WindowsErrorString());
// We can afford a failure on this call - just replace the name with "USB Storage Device (Generic)"

View File

@ -863,6 +863,26 @@ static __inline int _mkdirU(const char* dirname)
return ret;
}
// The following expects PropertyBuffer to contain a single Unicode string
static __inline BOOL SetupDiGetDeviceRegistryPropertyU(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData,
DWORD Property, PDWORD PropertyRegDataType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize)
{
DWORD ret = FALSE, err = ERROR_INVALID_DATA;
walloc(PropertyBuffer, PropertyBufferSize);
ret = SetupDiGetDeviceRegistryPropertyW(DeviceInfoSet, DeviceInfoData, Property,
PropertyRegDataType, (PBYTE)wPropertyBuffer, PropertyBufferSize, RequiredSize);
err = GetLastError();
if ((ret != 0) && (wchar_to_utf8_no_alloc(wPropertyBuffer,
(char*)(uintptr_t)PropertyBuffer, PropertyBufferSize) == 0)) {
err = GetLastError();
ret = FALSE;
}
wfree(PropertyBuffer);
SetLastError(err);
return ret;
}
#ifdef __cplusplus
}
#endif

View File

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 242, 376
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 2.10.951"
CAPTION "Rufus 2.10.952"
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
@ -320,8 +320,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,10,951,0
PRODUCTVERSION 2,10,951,0
FILEVERSION 2,10,952,0
PRODUCTVERSION 2,10,952,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -338,13 +338,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "2.10.951"
VALUE "FileVersion", "2.10.952"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "2.10.951"
VALUE "ProductVersion", "2.10.952"
END
END
BLOCK "VarFileInfo"