Changeset 81452 in vbox for trunk/src/VBox/HostDrivers/VBoxUSB
- Timestamp:
- Oct 22, 2019 2:05:33 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 134170
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxUSB/win/lib/VBoxUsbLib-win.cpp
r81058 r81452 211 211 strncpy(pVuDev->szName, pIfDetailData->DevicePath, sizeof (pVuDev->szName)); 212 212 213 #ifdef VBOX_WITH_NEW_USB_ENUM 214 if (!SetupDiGetDeviceRegistryPropertyA(hDevInfo, &DevInfoData, SPDRP_LOCATION_INFORMATION, 215 #else 213 216 if (!SetupDiGetDeviceRegistryPropertyA(hDevInfo, &DevInfoData, SPDRP_DRIVER, 217 #endif 214 218 NULL, /* OUT PDWORD PropertyRegDataType */ 215 219 (PBYTE)pVuDev->szDriverRegName, … … 302 306 } 303 307 308 #ifndef VBOX_WITH_NEW_USB_ENUM 304 309 static int usbLibDevPopulate(PUSBDEVICE pDev, PUSB_NODE_CONNECTION_INFORMATION_EX pConInfo, ULONG iPort, LPCSTR lpszDrvKeyName, LPCSTR lpszHubName, PVBOXUSB_STRING_DR_ENTRY pDrList) 305 310 { … … 381 386 return VINF_SUCCESS; 382 387 } 388 #else 389 static int usbLibDevPopulate(PUSBDEVICE pDev, PUSB_NODE_CONNECTION_INFORMATION_EX pConInfo, ULONG iPort, LPCSTR lpszLocation, LPCSTR lpszDrvKeyName, LPCSTR lpszHubName, PVBOXUSB_STRING_DR_ENTRY pDrList) 390 { 391 pDev->bcdUSB = pConInfo->DeviceDescriptor.bcdUSB; 392 pDev->bDeviceClass = pConInfo->DeviceDescriptor.bDeviceClass; 393 pDev->bDeviceSubClass = pConInfo->DeviceDescriptor.bDeviceSubClass; 394 pDev->bDeviceProtocol = pConInfo->DeviceDescriptor.bDeviceProtocol; 395 pDev->idVendor = pConInfo->DeviceDescriptor.idVendor; 396 pDev->idProduct = pConInfo->DeviceDescriptor.idProduct; 397 pDev->bcdDevice = pConInfo->DeviceDescriptor.bcdDevice; 398 pDev->bBus = 0; /** @todo figure out bBus on windows... */ 399 pDev->bPort = iPort; 400 /** @todo check which devices are used for primary input (keyboard & mouse) */ 401 if (!lpszDrvKeyName || *lpszDrvKeyName == 0) 402 pDev->enmState = USBDEVICESTATE_UNUSED; 403 else 404 pDev->enmState = USBDEVICESTATE_USED_BY_HOST_CAPTURABLE; 405 406 /* Determine the speed the device is operating at. */ 407 switch (pConInfo->Speed) 408 { 409 case UsbLowSpeed: pDev->enmSpeed = USBDEVICESPEED_LOW; break; 410 case UsbFullSpeed: pDev->enmSpeed = USBDEVICESPEED_FULL; break; 411 case UsbHighSpeed: pDev->enmSpeed = USBDEVICESPEED_HIGH; break; 412 default: /* If we don't know, most likely it's something new. */ 413 case UsbSuperSpeed: pDev->enmSpeed = USBDEVICESPEED_SUPER; break; 414 } 415 /* Unfortunately USB_NODE_CONNECTION_INFORMATION_EX will not report UsbSuperSpeed, and 416 * it's not even defined in the Win7 DDK we use. So we go by the USB version, and 417 * luckily we know that USB3 must mean SuperSpeed. The USB3 spec guarantees this (9.6.1). 418 */ 419 if (pDev->bcdUSB >= 0x0300) 420 pDev->enmSpeed = USBDEVICESPEED_SUPER; 421 422 pDev->pszAddress = RTStrDup(lpszLocation); 423 if (!pDev->pszAddress) 424 return VERR_NO_STR_MEMORY; 425 pDev->pszBackend = RTStrDup("host"); 426 if (!pDev->pszBackend) 427 { 428 RTStrFree((char *)pDev->pszAddress); 429 return VERR_NO_STR_MEMORY; 430 } 431 pDev->pszHubName = RTStrDup(lpszHubName); 432 pDev->bNumConfigurations = 0; 433 pDev->u64SerialHash = 0; 434 435 for (; pDrList; pDrList = pDrList->pNext) 436 { 437 char **ppszString = NULL; 438 if ( pConInfo->DeviceDescriptor.iManufacturer 439 && pDrList->iDr == pConInfo->DeviceDescriptor.iManufacturer) 440 ppszString = (char **)&pDev->pszManufacturer; 441 else if ( pConInfo->DeviceDescriptor.iProduct 442 && pDrList->iDr == pConInfo->DeviceDescriptor.iProduct) 443 ppszString = (char **)&pDev->pszProduct; 444 else if ( pConInfo->DeviceDescriptor.iSerialNumber 445 && pDrList->iDr == pConInfo->DeviceDescriptor.iSerialNumber) 446 ppszString = (char **)&pDev->pszSerialNumber; 447 if (ppszString) 448 { 449 int rc = RTUtf16ToUtf8((PCRTUTF16)pDrList->StrDr.bString, ppszString); 450 if (RT_SUCCESS(rc)) 451 { 452 Assert(*ppszString); 453 USBLibPurgeEncoding(*ppszString); 454 455 if (pDrList->iDr == pConInfo->DeviceDescriptor.iSerialNumber) 456 pDev->u64SerialHash = USBLibHashSerial(*ppszString); 457 } 458 else 459 { 460 AssertMsgFailed(("RTUtf16ToUtf8 failed, rc (%d), resuming\n", rc)); 461 *ppszString = NULL; 462 } 463 } 464 } 465 466 return VINF_SUCCESS; 467 } 468 #endif 383 469 384 470 static void usbLibDevStrFree(LPSTR lpszName) … … 1066 1152 1067 1153 /* Process a single USB device that's being enumerated and grab its hub-specific data. */ 1068 static int usbLibDevGetDevice(LPCSTR lpcszHubFile, ULONG iPort, LPCSTR Location, PUSBDEVICE *ppDevs, uint32_t *pcDevs)1154 static int usbLibDevGetDevice(LPCSTR lpcszHubFile, ULONG iPort, LPCSTR lpcszLocation, LPCSTR lpcszDriverKey, PUSBDEVICE *ppDevs, uint32_t *pcDevs) 1069 1155 { 1070 1156 HANDLE HubDevice; … … 1083 1169 { 1084 1170 LogRelFunc(("Hub path is NULL!\n")); 1171 return VERR_INVALID_PARAMETER; 1172 } 1173 if (!lpcszLocation) 1174 { 1175 LogRelFunc(("Location NULL!\n")); 1085 1176 return VERR_INVALID_PARAMETER; 1086 1177 } … … 1149 1240 if (RT_LIKELY(pDev)) 1150 1241 { 1151 rc = usbLibDevPopulate(pDev, pConInfo, iPort, Location, lpcszHubFile, pList);1242 rc = usbLibDevPopulate(pDev, pConInfo, iPort, lpcszLocation, lpcszDriverKey, lpcszHubFile, pList); 1152 1243 if (RT_SUCCESS(rc)) 1153 1244 { … … 1196 1287 * USB IOCTL and PnP Manager data. 1197 1288 */ 1198 static int usbLib DevGetDevices(PUSBDEVICE *ppDevs, uint32_t *pcDevs)1289 static int usbLibEnumDevices(PUSBDEVICE *ppDevs, uint32_t *pcDevs) 1199 1290 { 1200 1291 HDEVINFO InfoSet; … … 1205 1296 LPCSTR HubPath = NULL; 1206 1297 LPCSTR Location; 1298 LPCSTR DriverKey; 1207 1299 1208 1300 /* Ask for the USB PnP enumerator for all it has. */ … … 1231 1323 Location = (LPCSTR)usbLibGetRegistryProperty(InfoSet, &DeviceData, SPDRP_LOCATION_INFORMATION); 1232 1324 1325 /* The software key aka DriverKey. This will be NULL for devices with no driver 1326 * and allows us to distinguish between 'busy' (driver installed) and 'available' 1327 * (no driver) devices. 1328 */ 1329 DriverKey = (LPCSTR)usbLibGetRegistryProperty(InfoSet, &DeviceData, SPDRP_DRIVER); 1330 1233 1331 /* The device's PnP Manager "address" is the port number on the parent hub. */ 1234 1332 Address = (LPDWORD)usbLibGetRegistryProperty(InfoSet, &DeviceData, SPDRP_ADDRESS); 1235 if (Address && Location) 1333 if (Address && Location) /* NB: DriverKey may be NULL! */ 1236 1334 { 1237 usbLibDevGetDevice(HubPath, *Address, Location, ppDevs, pcDevs);1335 usbLibDevGetDevice(HubPath, *Address, Location, DriverKey, ppDevs, pcDevs); 1238 1336 } 1239 1337 RTMemFree((void *)HubPath); … … 1241 1339 if (Location) 1242 1340 RTMemFree((void *)Location); 1341 if (DriverKey) 1342 RTMemFree((void *)DriverKey); 1243 1343 if (Address) 1244 1344 RTMemFree((void *)Address); … … 1391 1491 1392 1492 LogRelFunc(("Starting USB device enumeration\n")); 1493 #ifdef VBOX_WITH_NEW_USB_ENUM 1494 int rc = usbLibEnumDevices(ppDevs, pcDevs); 1495 #else 1393 1496 int rc = usbLibDevGetDevices(ppDevs, pcDevs); 1497 #endif 1394 1498 AssertRC(rc); 1395 1499 if (RT_SUCCESS(rc))
Note:
See TracChangeset
for help on using the changeset viewer.