Index: trunk/src/VBox/HostDrivers/VBoxUSB/win/lib/VBoxUsbLib-win.cpp
===================================================================
--- trunk/src/VBox/HostDrivers/VBoxUSB/win/lib/VBoxUsbLib-win.cpp	(revision 80796)
+++ trunk/src/VBox/HostDrivers/VBoxUSB/win/lib/VBoxUsbLib-win.cpp	(revision 80877)
@@ -51,13 +51,8 @@
 #include <usbdi.h>
 #include <hidsdi.h>
+#include <Dbt.h>
 
 /* Defined in Windows 8 DDK (through usbdi.h) but we use Windows 7 DDK to build. */
 #define UsbSuperSpeed   3
-
-#define VBOX_USB_USE_DEVICE_NOTIFICATION
-
-#ifdef VBOX_USB_USE_DEVICE_NOTIFICATION
-# include <Dbt.h>
-#endif
 
 #ifdef VBOX_WITH_NEW_USB_ENUM
@@ -88,10 +83,8 @@
     HANDLE hNotifyEvent;
     HANDLE hInterruptEvent;
-#ifdef VBOX_USB_USE_DEVICE_NOTIFICATION
     HANDLE hThread;
     HWND   hWnd;
     HANDLE hTimerQueue;
     HANDLE hTimer;
-#endif
 } VBOXUSBGLOBALSTATE, *PVBOXUSBGLOBALSTATE;
 
@@ -525,5 +518,5 @@
     {
         DWORD dwErr = GetLastError();
-        LogRelFunc(("DeviceIoControl 1 fail dwErr (%d) on hub %s port %d\n", dwErr, lpcszHubName, iPort));
+        LogRelFunc(("IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION #1 failed (dwErr=%d) on hub %s port %d\n", dwErr, lpcszHubName, iPort));
 #ifdef VBOX_WITH_ANNOYING_USB_ASSERTIONS
         AssertFailed();
@@ -562,5 +555,5 @@
         {
             DWORD dwErr = GetLastError();
-            LogRelFunc(("DeviceIoControl 2 fail dwErr (%d) on hub %s port %d\n", dwErr, lpcszHubName, iPort));
+            LogRelFunc(("IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION #2 failed (dwErr=%d) on hub %s port %d\n", dwErr, lpcszHubName, iPort));
 #ifdef VBOX_WITH_ANNOYING_USB_ASSERTIONS
             AssertFailed();
@@ -810,5 +803,5 @@
     if (!lpszName)
     {
-        LogRelFunc(("warning: no DriverKey on hub %s port %d\n", lpcszHubName, iPort));
+        LogRelFunc(("No DriverKey on hub %s port %d\n", lpcszHubName, iPort));
         lpszName = &nameEmptyBuf;
         fFreeNameBuf = false;
@@ -1043,5 +1036,5 @@
     if (cr != CR_SUCCESS)
     {
-        LogRelFunc(("Failed to get device ID size, error %ld\n", GetLastError()));
+        LogRelFunc(("Failed to get device ID size (DevInst=%X), error %ld\n", DevInst, GetLastError()));
         return NULL;
     }
@@ -1056,5 +1049,5 @@
     if (cr != CR_SUCCESS)
     {
-        LogRelFunc(("Failed to get device ID, error %ld\n", GetLastError()));
+        LogRelFunc(("Failed to get device ID (DevInst=%X), error %ld\n", DevInst, GetLastError()));
         RTMemFree(InstanceID);
         return NULL;
@@ -1090,5 +1083,5 @@
     if (HubDevice == INVALID_HANDLE_VALUE)
     {
-        LogRelFunc(("Failed to open hub `%s', dwErr(%d)\n", lpcszHubFile, GetLastError()));
+        LogRelFunc(("Failed to open hub `%s' (dwErr=%d)\n", lpcszHubFile, GetLastError()));
         return VERR_FILE_NOT_FOUND;
     }
@@ -1389,4 +1382,5 @@
     *pcDevs = 0;
 
+    LogRelFunc(("Starting USB device enumeration\n"));
     int rc = usbLibDevGetDevices(ppDevs, pcDevs);
     AssertRC(rc);
@@ -1404,4 +1398,5 @@
         }
 
+        LogRelFunc(("Found %u USB devices, %u captured\n", *pcDevs, cDevInfos));
         return VINF_SUCCESS;
     }
@@ -1548,6 +1543,4 @@
 }
 
-
-#ifdef VBOX_USB_USE_DEVICE_NOTIFICATION
 
 static VOID CALLBACK usbLibTimerCallback(__in PVOID lpParameter, __in BOOLEAN TimerOrWaitFired)
@@ -1681,5 +1674,4 @@
 }
 
-#endif /* VBOX_USB_USE_DEVICE_NOTIFICATION */
 
 /**
@@ -1702,9 +1694,5 @@
     g_VBoxUsbGlobal.hNotifyEvent = CreateEvent(NULL,  /* LPSECURITY_ATTRIBUTES lpEventAttributes */
                                                FALSE, /* BOOL bManualReset */
-#ifndef VBOX_USB_USE_DEVICE_NOTIFICATION
-                                               TRUE,  /* BOOL bInitialState */
-#else
                                                FALSE, /* set to false since it will be initially used for notification thread startup sync */
-#endif
                                                NULL   /* LPCTSTR lpName */);
     if (g_VBoxUsbGlobal.hNotifyEvent)
@@ -1742,5 +1730,5 @@
                     {
                         DWORD dwErr = GetLastError();
-                        LogRelFunc(("CreateFile failed dwErr(%d)\n", dwErr));
+                        LogRelFunc(("CreateFile failed (dwErr=%d) for `%s'\n", dwErr, USBMON_DEVICE_NAME));
                         rc = VERR_FILE_NOT_FOUND;
                     }
@@ -1772,35 +1760,4 @@
                         )
                     {
-#ifndef VBOX_USB_USE_DEVICE_NOTIFICATION
-                        /*
-                         * Tell the monitor driver which event object to use
-                         * for notifications.
-                         */
-                        USBSUP_SET_NOTIFY_EVENT SetEvent = {0};
-                        Assert(g_VBoxUsbGlobal.hNotifyEvent);
-                        SetEvent.u.hEvent = g_VBoxUsbGlobal.hNotifyEvent;
-                        if (DeviceIoControl(g_VBoxUsbGlobal.hMonitor, SUPUSBFLT_IOCTL_SET_NOTIFY_EVENT,
-                                            &SetEvent, sizeof(SetEvent),
-                                            &SetEvent, sizeof(SetEvent),
-                                            &cbReturned, NULL))
-                        {
-                            rc = SetEvent.u.rc;
-                            if (RT_SUCCESS(rc))
-                            {
-                                /*
-                                 * We're DONE!
-                                 */
-                                return VINF_SUCCESS;
-                            }
-
-                            AssertMsgFailed(("SetEvent failed, %Rrc (%d)\n", rc, rc));
-                        }
-                        else
-                        {
-                            DWORD dwErr = GetLastError();
-                            AssertMsgFailed(("SetEvent Ioctl failed, dwErr (%d)\n", dwErr));
-                            rc = VERR_VERSION_MISMATCH;
-                        }
-#else
                         /*
                          * We can not use USB Mon for reliable device add/remove tracking
@@ -1845,5 +1802,5 @@
                                 BOOL fRc = CloseHandle(g_VBoxUsbGlobal.hThread); NOREF(fRc);
                                 DWORD dwErr = GetLastError(); NOREF(dwErr);
-                                AssertMsg(fRc, ("CloseHandle for hThread failed dwErr(%d)\n", dwErr));
+                                AssertMsg(fRc, ("CloseHandle for hThread failed (dwErr=%d)\n", dwErr));
                                 g_VBoxUsbGlobal.hThread = INVALID_HANDLE_VALUE;
                             }
@@ -1861,7 +1818,6 @@
                         {
                             DWORD dwErr = GetLastError(); NOREF(dwErr);
-                            AssertMsgFailed(("CreateTimerQueue failed dwErr(%d)\n", dwErr));
+                            AssertMsgFailed(("CreateTimerQueue failed (dwErr=%d)\n", dwErr));
                         }
-#endif
                     }
                     else
@@ -1878,5 +1834,6 @@
                 {
                     DWORD dwErr = GetLastError(); NOREF(dwErr);
-                    AssertMsgFailed(("DeviceIoControl failed dwErr(%d)\n", dwErr));
+                    LogRelFunc(("SUPUSBFLT_IOCTL_GET_VERSION failed (dwErr=%d)\n", dwErr));
+                    AssertFailed();
                     rc = VERR_VERSION_MISMATCH;
                 }
@@ -1900,5 +1857,5 @@
         {
             DWORD dwErr = GetLastError(); NOREF(dwErr);
-            AssertMsgFailed(("CreateEvent for InterruptEvent failed dwErr(%d)\n", dwErr));
+            AssertMsgFailed(("CreateEvent for InterruptEvent failed (dwErr=%d)\n", dwErr));
             rc = VERR_GENERAL_FAILURE;
         }
@@ -1910,5 +1867,5 @@
     {
         DWORD dwErr = GetLastError(); NOREF(dwErr);
-        AssertMsgFailed(("CreateEvent for NotifyEvent failed dwErr(%d)\n", dwErr));
+        AssertMsgFailed(("CreateEvent for NotifyEvent failed (dwErr=%d)\n", dwErr));
         rc = VERR_GENERAL_FAILURE;
     }
@@ -1937,7 +1894,6 @@
 
     BOOL fRc;
-#ifdef VBOX_USB_USE_DEVICE_NOTIFICATION
     fRc = PostMessage(g_VBoxUsbGlobal.hWnd, WM_CLOSE, 0, 0);
-    AssertMsg(fRc, ("PostMessage for hWnd failed dwErr(%d)\n", GetLastError()));
+    AssertMsg(fRc, ("PostMessage for hWnd failed (dwErr=%d)\n", GetLastError()));
 
     if (g_VBoxUsbGlobal.hThread != NULL)
@@ -1946,5 +1902,5 @@
         Assert(dwResult == WAIT_OBJECT_0); NOREF(dwResult);
         fRc = CloseHandle(g_VBoxUsbGlobal.hThread);
-        AssertMsg(fRc, ("CloseHandle for hThread failed dwErr(%d)\n", GetLastError()));
+        AssertMsg(fRc, ("CloseHandle for hThread failed (dwErr=%d)\n", GetLastError()));
     }
 
@@ -1953,5 +1909,5 @@
         fRc = DeleteTimerQueueTimer(g_VBoxUsbGlobal.hTimerQueue, g_VBoxUsbGlobal.hTimer,
                                     INVALID_HANDLE_VALUE); /* <-- to block until the timer is completed */
-        AssertMsg(fRc, ("DeleteTimerQueueTimer failed dwErr(%d)\n", GetLastError()));
+        AssertMsg(fRc, ("DeleteTimerQueueTimer failed (dwErr=%d)\n", GetLastError()));
     }
 
@@ -1960,10 +1916,9 @@
         fRc = DeleteTimerQueueEx(g_VBoxUsbGlobal.hTimerQueue,
                                  INVALID_HANDLE_VALUE); /* <-- to block until all timers are completed */
-        AssertMsg(fRc, ("DeleteTimerQueueEx failed dwErr(%d)\n", GetLastError()));
-    }
-#endif /* VBOX_USB_USE_DEVICE_NOTIFICATION */
+        AssertMsg(fRc, ("DeleteTimerQueueEx failed (dwErr=%d)\n", GetLastError()));
+    }
 
     fRc = CloseHandle(g_VBoxUsbGlobal.hMonitor);
-    AssertMsg(fRc, ("CloseHandle for hMonitor failed dwErr(%d)\n", GetLastError()));
+    AssertMsg(fRc, ("CloseHandle for hMonitor failed (dwErr=%d)\n", GetLastError()));
     g_VBoxUsbGlobal.hMonitor = INVALID_HANDLE_VALUE;
 
@@ -1973,5 +1928,5 @@
 
     fRc = CloseHandle(g_VBoxUsbGlobal.hNotifyEvent);
-    AssertMsg(fRc, ("CloseHandle for hNotifyEvent failed dwErr(%d)\n", GetLastError()));
+    AssertMsg(fRc, ("CloseHandle for hNotifyEvent failed (dwErr=%d)\n", GetLastError()));
     g_VBoxUsbGlobal.hNotifyEvent = NULL;
 
Index: trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbFlt.cpp
===================================================================
--- trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbFlt.cpp	(revision 80796)
+++ trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbFlt.cpp	(revision 80877)
@@ -677,22 +677,4 @@
 }
 
-static void vboxUsbFltSignalChangeLocked()
-{
-    for (PLIST_ENTRY pEntry = g_VBoxUsbFltGlobals.ContextList.Flink;
-            pEntry != &g_VBoxUsbFltGlobals.ContextList;
-            pEntry = pEntry->Flink)
-    {
-        PVBOXUSBFLTCTX pCtx = PVBOXUSBFLTCTX_FROM_LE(pEntry);
-        /* the removed context can not be in a list */
-        Assert(!pCtx->bRemoved);
-        if (pCtx->pChangeEvent)
-        {
-            KeSetEvent(pCtx->pChangeEvent,
-                    0, /* increment*/
-                    FALSE /* wait */);
-        }
-    }
-}
-
 static bool vboxUsbFltDevCheckReplugLocked(PVBOXUSBFLT_DEVICE pDevice, PVBOXUSBFLTCTX pContext)
 {
@@ -1038,15 +1020,4 @@
 
     pContext->bRemoved = TRUE;
-    if (pContext->pChangeEvent)
-    {
-        LOG(("seting & closing change event (0x%p)", pContext->pChangeEvent));
-        KeSetEvent(pContext->pChangeEvent,
-                0, /* increment*/
-                FALSE /* wait */);
-        ObDereferenceObject(pContext->pChangeEvent);
-        pContext->pChangeEvent = NULL;
-    }
-    else
-        LOG(("no change event"));
     RemoveEntryList(&pContext->ListEntry);
 
@@ -1210,34 +1181,4 @@
 }
 
-NTSTATUS VBoxUsbFltSetNotifyEvent(PVBOXUSBFLTCTX pContext, HANDLE hEvent)
-{
-    NTSTATUS Status = STATUS_SUCCESS;
-    PKEVENT pEvent = NULL;
-    PKEVENT pOldEvent = NULL;
-    if (hEvent)
-    {
-        Status = ObReferenceObjectByHandle(hEvent,
-                    EVENT_MODIFY_STATE,
-                    *ExEventObjectType, UserMode,
-                    (PVOID*)&pEvent,
-                    NULL);
-        Assert(Status == STATUS_SUCCESS);
-        if (!NT_SUCCESS(Status))
-            return Status;
-    }
-
-    VBOXUSBFLT_LOCK_ACQUIRE();
-    pOldEvent = pContext->pChangeEvent;
-    pContext->pChangeEvent = pEvent;
-    VBOXUSBFLT_LOCK_RELEASE();
-
-    if (pOldEvent)
-    {
-        ObDereferenceObject(pOldEvent);
-    }
-
-    return STATUS_SUCCESS;
-}
-
 static USBDEVICESTATE vboxUsbDevGetUserState(PVBOXUSBFLTCTX pContext, PVBOXUSBFLT_DEVICE pDevice)
 {
@@ -1399,13 +1340,4 @@
 }
 
-NTSTATUS VBoxUsbFltPdoAddCompleted(PDEVICE_OBJECT pPdo)
-{
-    RT_NOREF1(pPdo);
-    VBOXUSBFLT_LOCK_ACQUIRE();
-    vboxUsbFltSignalChangeLocked();
-    VBOXUSBFLT_LOCK_RELEASE();
-    return STATUS_SUCCESS;
-}
-
 BOOLEAN VBoxUsbFltPdoIsFiltered(PDEVICE_OBJECT pPdo)
 {
@@ -1434,16 +1366,4 @@
         enmOldState = pDevice->enmState;
         pDevice->enmState = VBOXUSBFLT_DEVSTATE_REMOVED;
-        if (enmOldState != VBOXUSBFLT_DEVSTATE_REPLUGGING)
-        {
-            vboxUsbFltSignalChangeLocked();
-        }
-        else
-        {
-            /* the device *should* reappear, do signlling on re-appear only
-             * to avoid extra signaling. still there might be a situation
-             * when the device will not re-appear if it gets physically removed
-             * before it re-appears
-             * @todo: set a timer callback to do a notification from it */
-        }
     }
     VBOXUSBFLT_LOCK_RELEASE();
@@ -1471,5 +1391,4 @@
         LOG(("The proxy notified proxy start for the captured device 0x%x", pDevice));
         vboxUsbFltDevRetain(pDevice);
-        vboxUsbFltSignalChangeLocked();
     }
     else
@@ -1501,5 +1420,4 @@
         LOG(("The proxy notified proxy stop for the captured device 0x%x, current state %d", pDevice, pDevice->enmState));
         pDevice->enmState = VBOXUSBFLT_DEVSTATE_CAPTURING;
-        vboxUsbFltSignalChangeLocked();
     }
     else
Index: trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbFlt.h
===================================================================
--- trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbFlt.h	(revision 80796)
+++ trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbFlt.h	(revision 80877)
@@ -39,8 +39,7 @@
 {
     LIST_ENTRY ListEntry;
-    PKEVENT pChangeEvent;
-    RTPROCESS Process;
+    RTPROCESS Process;          // Purely informational, no function?
     uint32_t cActiveFilters;
-    BOOLEAN bRemoved;
+    BOOLEAN bRemoved;           // For debugging only?
 } VBOXUSBFLTCTX, *PVBOXUSBFLTCTX;
 
@@ -51,5 +50,4 @@
 int VBoxUsbFltAdd(PVBOXUSBFLTCTX pContext, PUSBFILTER pFilter, uintptr_t *pId);
 int VBoxUsbFltRemove(PVBOXUSBFLTCTX pContext, uintptr_t uId);
-NTSTATUS VBoxUsbFltSetNotifyEvent(PVBOXUSBFLTCTX pContext, HANDLE hEvent);
 NTSTATUS VBoxUsbFltFilterCheck(PVBOXUSBFLTCTX pContext);
 
@@ -61,5 +59,4 @@
 
 NTSTATUS VBoxUsbFltPdoAdd(PDEVICE_OBJECT pPdo, BOOLEAN *pbFiltered);
-NTSTATUS VBoxUsbFltPdoAddCompleted(PDEVICE_OBJECT pPdo);
 NTSTATUS VBoxUsbFltPdoRemove(PDEVICE_OBJECT pPdo);
 BOOLEAN VBoxUsbFltPdoIsFiltered(PDEVICE_OBJECT pPdo);
Index: trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.cpp
===================================================================
--- trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.cpp	(revision 80796)
+++ trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.cpp	(revision 80877)
@@ -633,13 +633,5 @@
         case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
         case IRP_MN_QUERY_RESOURCES:
-            if (NT_SUCCESS(pIrp->IoStatus.Status) || pIrp->IoStatus.Status == STATUS_NOT_SUPPORTED)
-            {
-                VBoxUsbFltPdoAddCompleted(pRealDevObj);
-            }
-            else
-            {
-                AssertFailed();
-            }
-            break;
+            /* There used to be code to support SUPUSBFLT_IOCTL_SET_NOTIFY_EVENT but it was not reliable. */
 
         default:
@@ -1105,10 +1097,4 @@
 }
 
-static int VBoxUsbMonSetNotifyEvent(PVBOXUSBMONCTX pContext, HANDLE hEvent)
-{
-    int rc = VBoxUsbFltSetNotifyEvent(&pContext->FltCtx, hEvent);
-    return rc;
-}
-
 static int VBoxUsbMonFltAdd(PVBOXUSBMONCTX pContext, PUSBFILTER pFilter, uintptr_t *pId)
 {
@@ -1256,21 +1242,4 @@
                 WARN(("VBoxUsbMonGetDevice fail 0x%x", Status));
             }
-            break;
-        }
-
-        case SUPUSBFLT_IOCTL_SET_NOTIFY_EVENT:
-        {
-            PUSBSUP_SET_NOTIFY_EVENT pSne = (PUSBSUP_SET_NOTIFY_EVENT)pvBuffer;
-            if (!pvBuffer || cbInBuffer != sizeof (*pSne) || cbOutBuffer != sizeof (*pSne))
-            {
-                WARN(("SUPUSBFLT_IOCTL_SET_NOTIFY_EVENT: Invalid input/output sizes. cbIn=%d expected %d. cbOut=%d expected %d.",
-                        cbInBuffer, sizeof (*pSne), cbOutBuffer, sizeof (*pSne)));
-                Status = STATUS_INVALID_PARAMETER;
-                break;
-            }
-
-            pSne->u.rc = VBoxUsbMonSetNotifyEvent(pContext, pSne->u.hEvent);
-            Info = sizeof (*pSne);
-            ASSERT_WARN(Status == STATUS_SUCCESS, ("unexpected status, 0x%x", Status));
             break;
         }
