Index: /trunk/src/VBox/HostDrivers/VBoxUSB/win/dev/VBoxUsbDev.h
===================================================================
--- /trunk/src/VBox/HostDrivers/VBoxUSB/win/dev/VBoxUsbDev.h	(revision 36997)
+++ /trunk/src/VBox/HostDrivers/VBoxUSB/win/dev/VBoxUsbDev.h	(revision 36998)
@@ -27,9 +27,4 @@
 
 extern VBOXUSB_GLOBALS g_VBoxUsbGlobals;
-
-typedef struct VBOXUSB_IOSTATE
-{
-    volatile uint32_t cRefs;
-} VBOXUSB_IOSTATE, *PVBOXUSB_IOSTATE;
 
 /* pnp state decls */
Index: /trunk/src/VBox/HostDrivers/VBoxUSB/win/lib/VBoxUsbLib-win.cpp
===================================================================
--- /trunk/src/VBox/HostDrivers/VBoxUSB/win/lib/VBoxUsbLib-win.cpp	(revision 36997)
+++ /trunk/src/VBox/HostDrivers/VBoxUSB/win/lib/VBoxUsbLib-win.cpp	(revision 36998)
@@ -354,6 +354,8 @@
     if (!DeviceIoControl(hHub, IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME, &Name, sizeof (Name), &Name, sizeof (Name), &cbReturned, NULL))
     {
+#ifdef DEBUG_misha
         DWORD winEr = GetLastError();
         AssertMsgFailed((__FUNCTION__": DeviceIoControl 1 fail winEr (%d)\n", winEr));
+#endif
         return VERR_GENERAL_FAILURE;
     }
@@ -761,5 +763,4 @@
     if (RT_FAILURE(rc))
     {
-        AssertMsgFailed((__FUNCTION__": usbLibDevStrDriverKeyGet failed\n"));
         return rc;
     }
@@ -889,7 +890,8 @@
 static int usbLibMonDevicesUpdate(PVBOXUSBGLOBALSTATE pGlobal, PUSBDEVICE pDevs, uint32_t cDevs, PVBOXUSB_DEV pDevInfos, uint32_t cDevInfos)
 {
+    PUSBDEVICE pDevsHead = pDevs;
     for (; pDevInfos; pDevInfos = pDevInfos->pNext)
     {
-        for (; pDevs; pDevs = pDevs->pNext)
+        for (pDevs = pDevsHead; pDevs; pDevs = pDevs->pNext)
         {
             if (usbLibMonDevicesCmp(pDevs, pDevInfos))
Index: /trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbFlt.cpp
===================================================================
--- /trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbFlt.cpp	(revision 36997)
+++ /trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbFlt.cpp	(revision 36998)
@@ -459,9 +459,19 @@
 }
 
-static bool vboxUsbFltDevCheckReplugLocked(PVBOXUSBFLT_DEVICE pDevice)
-{
+static bool vboxUsbFltDevCheckReplugLocked(PVBOXUSBFLT_DEVICE pDevice, PVBOXUSBFLTCTX pContext)
+{
+    Assert(pContext);
+
+    /* check if device is already replugging */
     if (pDevice->enmState <= VBOXUSBFLT_DEVSTATE_ADDED)
     {
+        /* it is, do nothing */
         Assert(pDevice->enmState == VBOXUSBFLT_DEVSTATE_REPLUGGING);
+        return false;
+    }
+
+    if (pDevice->pOwner && pContext != pDevice->pOwner)
+    {
+        /* this device is owned by another context, we're not allowed to do anything */
         return false;
     }
@@ -474,7 +484,7 @@
             false, /* do not remove a one-shot filter */
             &fFilter, &fIsOneShot);
-    if (pDevice->pOwner && pDevice->uFltId && pNewOwner != pDevice->pOwner)
-    {
-        /* the device is owned by another context by a valid filter */
+    if (pDevice->pOwner && pNewOwner && pDevice->pOwner != pNewOwner)
+    {
+        /* the device is owned by another owner, we can not change the owner here */
         return false;
     }
@@ -488,22 +498,34 @@
             if (fIsOneShot)
             {
+                Assert(pNewOwner);
                 /* remove a one-shot filter and keep the original filter data */
                 int tmpRc = VBoxUSBFilterRemove(pNewOwner, uId);
                 AssertRC(tmpRc);
+                if (!pDevice->pOwner)
+                {
+                    /* update owner for one-shot if the owner is changed (i.e. assigned) */
+                    vboxUsbFltDevOwnerUpdateLocked(pDevice, pNewOwner, uId, true);
+                }
             }
             else
             {
-                vboxUsbFltDevOwnerUpdateLocked(pDevice, pNewOwner, uId, false);
+                if (pNewOwner)
+                {
+                    vboxUsbFltDevOwnerUpdateLocked(pDevice, pNewOwner, uId, false);
+                }
             }
         }
         else
         {
-            /* the device is currently filtered, while it should not, replug needed */
-            bNeedReplug = true;
+            /* the device is currently filtered, we should release it only if it is NOT grabbed by a one-shot filter */
+            if (!pDevice->pOwner || !pDevice->fIsFilterOneShot)
+            {
+                bNeedReplug = true;
+            }
         }
     }
     else
     {
-        /* the device should NOT be filtered, check the current state  */
+        /* the device should be filtered, check the current state  */
         Assert(uId);
         Assert(pNewOwner);
@@ -527,4 +549,5 @@
             else
             {
+                Assert(!pDevice->pOwner);
                 /* the device needs to be filtered, but the owner changes, replug needed */
                 bNeedReplug = true;
@@ -533,6 +556,9 @@
         else
         {
-            /* the device is currently NOT filtered, while it should, replug needed */
-            bNeedReplug = true;
+            /* the device is currently NOT filtered, we should replug it only if it is NOT grabbed by a one-shot filter */
+            if (!pDevice->pOwner || !pDevice->fIsFilterOneShot)
+            {
+                bNeedReplug = true;
+            }
         }
     }
@@ -564,5 +590,5 @@
 }
 
-NTSTATUS VBoxUsbFltFilterCheck()
+NTSTATUS VBoxUsbFltFilterCheck(PVBOXUSBFLTCTX pContext)
 {
     NTSTATUS Status;
@@ -635,5 +661,5 @@
                                 if (pDevice)
                                 {
-                                    bool bReplug = vboxUsbFltDevCheckReplugLocked(pDevice);
+                                    bool bReplug = vboxUsbFltDevCheckReplugLocked(pDevice, pContext);
                                     if (bReplug)
                                     {
@@ -757,5 +783,5 @@
         vboxUsbFltDevOwnerClearLocked(pDevice);
 
-        if (vboxUsbFltDevCheckReplugLocked(pDevice))
+        if (vboxUsbFltDevCheckReplugLocked(pDevice, pContext))
         {
             InsertHeadList(&ReplugDevList, &pDevice->RepluggingLe);
@@ -856,7 +882,12 @@
             continue;
 
-        Assert(pDevice->pOwner);
+        Assert(pDevice->pOwner == pContext);
+        if (pDevice->pOwner != pContext)
+            continue;
+
         Assert(!pDevice->fIsFilterOneShot);
         pDevice->uFltId = 0;
+        /* clear the fIsFilterOneShot flag to ensure the device is replugged on the next VBoxUsbFltFilterCheck call */
+        pDevice->fIsFilterOneShot = false;
     }
     VBOXUSBFLT_LOCK_RELEASE();
Index: /trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbFlt.h
===================================================================
--- /trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbFlt.h	(revision 36997)
+++ /trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbFlt.h	(revision 36998)
@@ -38,5 +38,5 @@
 int VBoxUsbFltRemove(PVBOXUSBFLTCTX pContext, uintptr_t uId);
 NTSTATUS VBoxUsbFltSetNotifyEvent(PVBOXUSBFLTCTX pContext, HANDLE hEvent);
-NTSTATUS VBoxUsbFltFilterCheck();
+NTSTATUS VBoxUsbFltFilterCheck(PVBOXUSBFLTCTX pContext);
 
 NTSTATUS VBoxUsbFltGetDevice(PVBOXUSBFLTCTX pContext, HVBOXUSBDEVUSR hDevice, PUSBSUP_GETDEV_MON pInfo);
Index: /trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.cpp
===================================================================
--- /trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.cpp	(revision 36997)
+++ /trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.cpp	(revision 36998)
@@ -862,5 +862,5 @@
 static NTSTATUS VBoxUsbMonRunFilters(PVBOXUSBMONCTX pContext)
 {
-    NTSTATUS Status = VBoxUsbFltFilterCheck();
+    NTSTATUS Status = VBoxUsbFltFilterCheck(&pContext->FltCtx);
     return Status;
 }
