summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rbutil/rbutilqt/base/system.cpp24
1 files changed, 8 insertions, 16 deletions
diff --git a/rbutil/rbutilqt/base/system.cpp b/rbutil/rbutilqt/base/system.cpp
index 61a5b95cde..229becc40c 100644
--- a/rbutil/rbutilqt/base/system.cpp
+++ b/rbutil/rbutilqt/base/system.cpp
@@ -336,20 +336,7 @@ QMap<uint32_t, QString> System::listUsbDevices(void)
336 // get device desriptor first 336 // get device desriptor first
337 // for some reason not doing so results in bad things (tm) 337 // for some reason not doing so results in bad things (tm)
338 while(!SetupDiGetDeviceRegistryProperty(deviceInfo, &infoData, 338 while(!SetupDiGetDeviceRegistryProperty(deviceInfo, &infoData,
339 SPDRP_DEVICEDESC,&data, (PBYTE)buffer, buffersize, &buffersize)) { 339 SPDRP_DEVICEDESC, &data, (PBYTE)buffer, buffersize, &buffersize)) {
340 if(GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
341 if(buffer) free(buffer);
342 // double buffer size to avoid problems as per KB888609
343 buffer = (LPTSTR)malloc(buffersize * 2);
344 }
345 else {
346 break;
347 }
348 }
349
350 // now get the hardware id, which contains PID and VID.
351 while(!SetupDiGetDeviceRegistryProperty(deviceInfo, &infoData,
352 SPDRP_LOCATION_INFORMATION,&data, (PBYTE)buffer, buffersize, &buffersize)) {
353 if(GetLastError() == ERROR_INSUFFICIENT_BUFFER) { 340 if(GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
354 if(buffer) free(buffer); 341 if(buffer) free(buffer);
355 // double buffer size to avoid problems as per KB888609 342 // double buffer size to avoid problems as per KB888609
@@ -361,8 +348,9 @@ QMap<uint32_t, QString> System::listUsbDevices(void)
361 } 348 }
362 description = QString::fromWCharArray(buffer); 349 description = QString::fromWCharArray(buffer);
363 350
351 // now get the hardware id, which contains PID and VID.
364 while(!SetupDiGetDeviceRegistryProperty(deviceInfo, &infoData, 352 while(!SetupDiGetDeviceRegistryProperty(deviceInfo, &infoData,
365 SPDRP_HARDWAREID,&data, (PBYTE)buffer, buffersize, &buffersize)) { 353 SPDRP_HARDWAREID, &data, (PBYTE)buffer, buffersize, &buffersize)) {
366 if(GetLastError() == ERROR_INSUFFICIENT_BUFFER) { 354 if(GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
367 if(buffer) free(buffer); 355 if(buffer) free(buffer);
368 // double buffer size to avoid problems as per KB888609 356 // double buffer size to avoid problems as per KB888609
@@ -374,7 +362,11 @@ QMap<uint32_t, QString> System::listUsbDevices(void)
374 } 362 }
375 363
376 unsigned int vid, pid; 364 unsigned int vid, pid;
377 if(_stscanf(buffer, _TEXT("USB\\Vid_%x&Pid_%x"), &vid, &pid) == 2) { 365 // convert buffer text to upper case to avoid depending on the case of
366 // the keys (W7 uses different casing than XP at least).
367 int len = _tcslen(buffer);
368 while(len--) buffer[len] = _totupper(buffer[len]);
369 if(_stscanf(buffer, _TEXT("USB\\VID_%x&PID_%x"), &vid, &pid) == 2) {
378 uint32_t id; 370 uint32_t id;
379 id = vid << 16 | pid; 371 id = vid << 16 | pid;
380 usbids.insert(id, description); 372 usbids.insert(id, description);