Changeset 36998 in vbox for trunk/src/VBox/HostDrivers/VBoxUSB
- Timestamp:
- May 7, 2011 8:19:55 PM (14 years ago)
- Location:
- trunk/src/VBox/HostDrivers/VBoxUSB/win
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxUSB/win/dev/VBoxUsbDev.h
r36968 r36998 27 27 28 28 extern VBOXUSB_GLOBALS g_VBoxUsbGlobals; 29 30 typedef struct VBOXUSB_IOSTATE31 {32 volatile uint32_t cRefs;33 } VBOXUSB_IOSTATE, *PVBOXUSB_IOSTATE;34 29 35 30 /* pnp state decls */ -
trunk/src/VBox/HostDrivers/VBoxUSB/win/lib/VBoxUsbLib-win.cpp
r36968 r36998 354 354 if (!DeviceIoControl(hHub, IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME, &Name, sizeof (Name), &Name, sizeof (Name), &cbReturned, NULL)) 355 355 { 356 #ifdef DEBUG_misha 356 357 DWORD winEr = GetLastError(); 357 358 AssertMsgFailed((__FUNCTION__": DeviceIoControl 1 fail winEr (%d)\n", winEr)); 359 #endif 358 360 return VERR_GENERAL_FAILURE; 359 361 } … … 761 763 if (RT_FAILURE(rc)) 762 764 { 763 AssertMsgFailed((__FUNCTION__": usbLibDevStrDriverKeyGet failed\n"));764 765 return rc; 765 766 } … … 889 890 static int usbLibMonDevicesUpdate(PVBOXUSBGLOBALSTATE pGlobal, PUSBDEVICE pDevs, uint32_t cDevs, PVBOXUSB_DEV pDevInfos, uint32_t cDevInfos) 890 891 { 892 PUSBDEVICE pDevsHead = pDevs; 891 893 for (; pDevInfos; pDevInfos = pDevInfos->pNext) 892 894 { 893 for ( ; pDevs; pDevs = pDevs->pNext)895 for (pDevs = pDevsHead; pDevs; pDevs = pDevs->pNext) 894 896 { 895 897 if (usbLibMonDevicesCmp(pDevs, pDevInfos)) -
trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbFlt.cpp
r36968 r36998 459 459 } 460 460 461 static bool vboxUsbFltDevCheckReplugLocked(PVBOXUSBFLT_DEVICE pDevice) 462 { 461 static bool vboxUsbFltDevCheckReplugLocked(PVBOXUSBFLT_DEVICE pDevice, PVBOXUSBFLTCTX pContext) 462 { 463 Assert(pContext); 464 465 /* check if device is already replugging */ 463 466 if (pDevice->enmState <= VBOXUSBFLT_DEVSTATE_ADDED) 464 467 { 468 /* it is, do nothing */ 465 469 Assert(pDevice->enmState == VBOXUSBFLT_DEVSTATE_REPLUGGING); 470 return false; 471 } 472 473 if (pDevice->pOwner && pContext != pDevice->pOwner) 474 { 475 /* this device is owned by another context, we're not allowed to do anything */ 466 476 return false; 467 477 } … … 474 484 false, /* do not remove a one-shot filter */ 475 485 &fFilter, &fIsOneShot); 476 if (pDevice->pOwner && p Device->uFltId && pNewOwner != pDevice->pOwner)477 { 478 /* the device is owned by another context by a valid filter*/486 if (pDevice->pOwner && pNewOwner && pDevice->pOwner != pNewOwner) 487 { 488 /* the device is owned by another owner, we can not change the owner here */ 479 489 return false; 480 490 } … … 488 498 if (fIsOneShot) 489 499 { 500 Assert(pNewOwner); 490 501 /* remove a one-shot filter and keep the original filter data */ 491 502 int tmpRc = VBoxUSBFilterRemove(pNewOwner, uId); 492 503 AssertRC(tmpRc); 504 if (!pDevice->pOwner) 505 { 506 /* update owner for one-shot if the owner is changed (i.e. assigned) */ 507 vboxUsbFltDevOwnerUpdateLocked(pDevice, pNewOwner, uId, true); 508 } 493 509 } 494 510 else 495 511 { 496 vboxUsbFltDevOwnerUpdateLocked(pDevice, pNewOwner, uId, false); 512 if (pNewOwner) 513 { 514 vboxUsbFltDevOwnerUpdateLocked(pDevice, pNewOwner, uId, false); 515 } 497 516 } 498 517 } 499 518 else 500 519 { 501 /* the device is currently filtered, while it should not, replug needed */ 502 bNeedReplug = true; 520 /* the device is currently filtered, we should release it only if it is NOT grabbed by a one-shot filter */ 521 if (!pDevice->pOwner || !pDevice->fIsFilterOneShot) 522 { 523 bNeedReplug = true; 524 } 503 525 } 504 526 } 505 527 else 506 528 { 507 /* the device should NOTbe filtered, check the current state */529 /* the device should be filtered, check the current state */ 508 530 Assert(uId); 509 531 Assert(pNewOwner); … … 527 549 else 528 550 { 551 Assert(!pDevice->pOwner); 529 552 /* the device needs to be filtered, but the owner changes, replug needed */ 530 553 bNeedReplug = true; … … 533 556 else 534 557 { 535 /* the device is currently NOT filtered, while it should, replug needed */ 536 bNeedReplug = true; 558 /* the device is currently NOT filtered, we should replug it only if it is NOT grabbed by a one-shot filter */ 559 if (!pDevice->pOwner || !pDevice->fIsFilterOneShot) 560 { 561 bNeedReplug = true; 562 } 537 563 } 538 564 } … … 564 590 } 565 591 566 NTSTATUS VBoxUsbFltFilterCheck( )592 NTSTATUS VBoxUsbFltFilterCheck(PVBOXUSBFLTCTX pContext) 567 593 { 568 594 NTSTATUS Status; … … 635 661 if (pDevice) 636 662 { 637 bool bReplug = vboxUsbFltDevCheckReplugLocked(pDevice );663 bool bReplug = vboxUsbFltDevCheckReplugLocked(pDevice, pContext); 638 664 if (bReplug) 639 665 { … … 757 783 vboxUsbFltDevOwnerClearLocked(pDevice); 758 784 759 if (vboxUsbFltDevCheckReplugLocked(pDevice ))785 if (vboxUsbFltDevCheckReplugLocked(pDevice, pContext)) 760 786 { 761 787 InsertHeadList(&ReplugDevList, &pDevice->RepluggingLe); … … 856 882 continue; 857 883 858 Assert(pDevice->pOwner); 884 Assert(pDevice->pOwner == pContext); 885 if (pDevice->pOwner != pContext) 886 continue; 887 859 888 Assert(!pDevice->fIsFilterOneShot); 860 889 pDevice->uFltId = 0; 890 /* clear the fIsFilterOneShot flag to ensure the device is replugged on the next VBoxUsbFltFilterCheck call */ 891 pDevice->fIsFilterOneShot = false; 861 892 } 862 893 VBOXUSBFLT_LOCK_RELEASE(); -
trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbFlt.h
r36968 r36998 38 38 int VBoxUsbFltRemove(PVBOXUSBFLTCTX pContext, uintptr_t uId); 39 39 NTSTATUS VBoxUsbFltSetNotifyEvent(PVBOXUSBFLTCTX pContext, HANDLE hEvent); 40 NTSTATUS VBoxUsbFltFilterCheck( );40 NTSTATUS VBoxUsbFltFilterCheck(PVBOXUSBFLTCTX pContext); 41 41 42 42 NTSTATUS VBoxUsbFltGetDevice(PVBOXUSBFLTCTX pContext, HVBOXUSBDEVUSR hDevice, PUSBSUP_GETDEV_MON pInfo); -
trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.cpp
r36968 r36998 862 862 static NTSTATUS VBoxUsbMonRunFilters(PVBOXUSBMONCTX pContext) 863 863 { 864 NTSTATUS Status = VBoxUsbFltFilterCheck( );864 NTSTATUS Status = VBoxUsbFltFilterCheck(&pContext->FltCtx); 865 865 return Status; 866 866 }
Note:
See TracChangeset
for help on using the changeset viewer.