Changeset 82443 in vbox for trunk/src/VBox/HostDrivers/VBoxUSB/win/lib
- Timestamp:
- Dec 6, 2019 7:26:34 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxUSB/win/lib/VBoxUsbLib-win.cpp
r81664 r82443 405 405 406 406 /* The location is used as a unique identifier for cross-referencing the two lists. */ 407 Location = (LPCSTR)usbLibGetRegistryProperty(InfoSet, &DeviceData, SPDRP_ LOCATION_INFORMATION);407 Location = (LPCSTR)usbLibGetRegistryProperty(InfoSet, &DeviceData, SPDRP_DRIVER); 408 408 if (Location) 409 409 { … … 521 521 } 522 522 523 static bool usbLibParseLocation(LPCSTR LocStr, uint16_t *pBus, uint16_t *pPort)524 {525 #define PORT_PREFIX "Port_#"526 #define BUS_PREFIX ".Hub_#"527 528 *pBus = *pPort = 0xFFFF;529 530 /* The Location Information is in the format Port_#xxxx.Hub_#xxxx, with 'xxxx'531 * being 16-bit hexadecimal numbers. It should be reliable on Windows Vista and532 * later. Note that while the port corresponds to the port number aka address,533 * the hub nomber has no discernible relationship to how Windows enumerates hubs.534 */535 536 if (strncmp(LocStr, PORT_PREFIX, strlen(PORT_PREFIX)))537 return false;538 539 /* Point to the start of the port number and parse it. */540 LocStr += strlen(PORT_PREFIX);541 *pPort = usbLibParseHexNumU16(&LocStr);542 543 if (strncmp(LocStr, BUS_PREFIX, strlen(BUS_PREFIX)))544 return false;545 546 /* Point to the start of the hub/bus number and parse it. */547 LocStr += strlen(BUS_PREFIX);548 *pBus = usbLibParseHexNumU16(&LocStr);549 550 return true;551 #undef PORT_PREFIX552 #undef BUS_PREFIX553 }554 555 523 static int usbLibDevPopulate(PUSBDEVICE pDev, PUSB_NODE_CONNECTION_INFORMATION_EX pConInfo, ULONG iPort, LPCSTR lpszLocation, LPCSTR lpszDrvKeyName, LPCSTR lpszHubName, PVBOXUSB_STRING_DR_ENTRY pDrList) 556 524 { 557 uint16_t uPort;558 uint16_t uBus;559 560 525 pDev->bcdUSB = pConInfo->DeviceDescriptor.bcdUSB; 561 526 pDev->bDeviceClass = pConInfo->DeviceDescriptor.bDeviceClass; … … 565 530 pDev->idProduct = pConInfo->DeviceDescriptor.idProduct; 566 531 pDev->bcdDevice = pConInfo->DeviceDescriptor.bcdDevice; 567 568 /* Parse the bus (hub) and port out of the location. */ 569 if (usbLibParseLocation(lpszLocation, &uBus, &uPort)) 570 { 571 Assert(uPort == iPort); 572 pDev->bBus = uBus; 573 pDev->bPort = uPort; 574 } 575 else 576 { 577 /* Shouldn't happen but fall back to semi-sane values. */ 578 pDev->bBus = 0; 579 pDev->bPort = iPort; 580 } 581 582 /** @todo check which devices are used for primary input (keyboard & mouse) */ 532 pDev->bBus = 0; /* The hub numbering is not very useful on Windows. Skip it. */ 533 pDev->bPort = iPort; 534 535 /* The port path/location uniquely identifies the port. */ 536 pDev->pszPortPath = RTStrDup(lpszLocation); 537 if (!pDev->pszPortPath) 538 return VERR_NO_STR_MEMORY; 539 540 /* If there is no DriverKey, the device is unused because there's no driver. */ 583 541 if (!lpszDrvKeyName || *lpszDrvKeyName == 0) 584 542 pDev->enmState = USBDEVICESTATE_UNUSED; … … 602 560 pDev->enmSpeed = USBDEVICESPEED_SUPER; 603 561 604 pDev->pszAddress = RTStrDup(lpszLocation); 605 if (!pDev->pszAddress) 606 return VERR_NO_STR_MEMORY; 562 /* If there's no DriverKey, jam in an empty string to avoid NULL pointers. */ 563 if (!lpszDrvKeyName) 564 pDev->pszAddress = RTStrDup(""); 565 else 566 pDev->pszAddress = RTStrDup(lpszDrvKeyName); 567 607 568 pDev->pszBackend = RTStrDup("host"); 608 569 if (!pDev->pszBackend) … … 1503 1464 { 1504 1465 /* The location information uniquely identifies the USB device, (hub/port). */ 1505 Location = (LPCSTR)usbLibGetRegistryProperty(InfoSet, &DeviceData, SPDRP_LOCATION_ INFORMATION);1466 Location = (LPCSTR)usbLibGetRegistryProperty(InfoSet, &DeviceData, SPDRP_LOCATION_PATHS); 1506 1467 1507 1468 /* The software key aka DriverKey. This will be NULL for devices with no driver
Note:
See TracChangeset
for help on using the changeset viewer.