Index: trunk/src/VBox/HostDrivers/VBoxUSB/win/lib/VBoxUsbLib-win.cpp
===================================================================
--- trunk/src/VBox/HostDrivers/VBoxUSB/win/lib/VBoxUsbLib-win.cpp	(revision 81024)
+++ trunk/src/VBox/HostDrivers/VBoxUSB/win/lib/VBoxUsbLib-win.cpp	(revision 81058)
@@ -125,6 +125,6 @@
     {
         dwErr = GetLastError();
-        AssertMsgFailed(("CreateFile FAILED to open %s, dwErr (%d)\n", pVuDev->szName, dwErr));
-        LogRelFunc(("Failed to open `%s' (dwErr=%d)!\n", pVuDev->szName, dwErr));
+        AssertMsgFailed(("CreateFile FAILED to open %s, dwErr=%u\n", pVuDev->szName, dwErr));
+        LogRelFunc(("Failed to open `%s' (dwErr=%u)!\n", pVuDev->szName, dwErr));
         return VERR_GENERAL_FAILURE;
     }
@@ -140,5 +140,5 @@
             dwErr = GetLastError();
             AssertMsgFailed(("DeviceIoControl SUPUSB_IOCTL_GET_VERSION failed with LastError=%Rwa\n", dwErr));
-            LogRelFunc(("SUPUSB_IOCTL_GET_VERSION failed on `%s' (dwErr=%d)!\n", pVuDev->szName, dwErr));
+            LogRelFunc(("SUPUSB_IOCTL_GET_VERSION failed on `%s' (dwErr=%u)!\n", pVuDev->szName, dwErr));
             break;
         }
@@ -159,5 +159,5 @@
             dwErr = GetLastError();
             AssertMsgFailed(("DeviceIoControl SUPUSB_IOCTL_IS_OPERATIONAL failed with LastError=%Rwa\n", dwErr));
-            LogRelFunc(("SUPUSB_IOCTL_IS_OPERATIONAL failed on `%s' (dwErr=%d)!\n", pVuDev->szName, dwErr));
+            LogRelFunc(("SUPUSB_IOCTL_IS_OPERATIONAL failed on `%s' (dwErr=%u)!\n", pVuDev->szName, dwErr));
             break;
         }
@@ -255,5 +255,5 @@
     {
         DWORD dwErr = GetLastError(); NOREF(dwErr);
-        AssertMsgFailed(("SetupDiGetClassDevs, dwErr (%d)\n", dwErr));
+        AssertMsgFailed(("SetupDiGetClassDevs, dwErr (%u)\n", dwErr));
         return VERR_GENERAL_FAILURE;
     }
@@ -273,5 +273,5 @@
                 break;
 
-            AssertMsgFailed(("SetupDiEnumDeviceInterfaces, dwErr (%d), resuming\n", dwErr));
+            AssertMsgFailed(("SetupDiEnumDeviceInterfaces, dwErr (%u), resuming\n", dwErr));
             continue;
         }
@@ -397,5 +397,5 @@
     {
 #ifdef VBOX_WITH_ANNOYING_USB_ASSERTIONS
-        AssertMsgFailed(("DeviceIoControl 1 fail dwErr (%d)\n", GetLastError()));
+        AssertMsgFailed(("DeviceIoControl 1 fail dwErr (%u)\n", GetLastError()));
 #endif
         return VERR_GENERAL_FAILURE;
@@ -427,5 +427,5 @@
     {
         DWORD dwErr = GetLastError(); NOREF(dwErr);
-        AssertMsgFailed(("DeviceIoControl 2 fail dwErr (%d)\n", dwErr));
+        AssertMsgFailed(("DeviceIoControl 2 fail dwErr (%u)\n", dwErr));
         rc = VERR_GENERAL_FAILURE;
     }
@@ -526,5 +526,5 @@
     {
         DWORD dwErr = GetLastError();
-        LogRelFunc(("IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION #1 failed (dwErr=%d) on hub %s port %d\n", dwErr, lpcszHubName, iPort));
+        LogRelFunc(("IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION #1 failed (dwErr=%u) on hub %s port %d\n", dwErr, lpcszHubName, iPort));
 #ifdef VBOX_WITH_ANNOYING_USB_ASSERTIONS
         AssertFailed();
@@ -563,5 +563,5 @@
         {
             DWORD dwErr = GetLastError();
-            LogRelFunc(("IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION #2 failed (dwErr=%d) on hub %s port %d\n", dwErr, lpcszHubName, iPort));
+            LogRelFunc(("IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION #2 failed (dwErr=%u) on hub %s port %d\n", dwErr, lpcszHubName, iPort));
 #ifdef VBOX_WITH_ANNOYING_USB_ASSERTIONS
             AssertFailed();
@@ -617,5 +617,5 @@
     {
         DWORD dwErr = GetLastError();
-        LogRel(("Getting USB descriptor (id %u) failed with error %ld on hub %s port %d\n", iDr, dwErr, lpcszHubName, iPort));
+        LogRel(("Getting USB descriptor (id %u) failed (dwErr=%u) on hub %s port %d\n", iDr, dwErr, lpcszHubName, iPort));
         return RTErrConvertFromWin32(dwErr);
     }
@@ -777,6 +777,6 @@
     {
         DWORD dwErr = GetLastError(); NOREF(dwErr);
-        LogRel(("Getting USB connection information failed with error %ld on hub %s\n", dwErr, lpcszHubName));
-        AssertMsg(dwErr == ERROR_DEVICE_NOT_CONNECTED, (__FUNCTION__": DeviceIoControl failed dwErr (%d)\n", dwErr));
+        LogRel(("Getting USB connection information failed (dwErr=%u) on hub %s\n", dwErr, lpcszHubName));
+        AssertMsg(dwErr == ERROR_DEVICE_NOT_CONNECTED, (__FUNCTION__": DeviceIoControl failed (dwErr=%u)\n", dwErr));
         return VERR_GENERAL_FAILURE;
     }
@@ -887,5 +887,5 @@
                             &cbReturned, NULL))
         {
-            LogRel(("Getting USB node information failed with error %ld on hub %s\n", GetLastError(), lpszName));
+            LogRel(("Getting USB node information failed (dwErr=%u) on hub %s\n", GetLastError(), lpszName));
             AssertFailed();
             break;
@@ -1091,5 +1091,5 @@
     if (HubDevice == INVALID_HANDLE_VALUE)
     {
-        LogRelFunc(("Failed to open hub `%s' (dwErr=%d)\n", lpcszHubFile, GetLastError()));
+        LogRelFunc(("Failed to open hub `%s' (dwErr=%u)\n", lpcszHubFile, GetLastError()));
         return VERR_FILE_NOT_FOUND;
     }
@@ -1110,6 +1110,6 @@
     {
         DWORD dwErr = GetLastError(); NOREF(dwErr);
-        LogRel(("IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX failed with error %ld on hub %s, port %d\n", dwErr, lpcszHubFile, iPort));
-        AssertMsg(dwErr == ERROR_DEVICE_NOT_CONNECTED, (__FUNCTION__": DeviceIoControl failed dwErr (%d)\n", dwErr));
+        LogRel(("IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX failed (dwErr=%u) on hub %s, port %d\n", dwErr, lpcszHubFile, iPort));
+        AssertMsg(dwErr == ERROR_DEVICE_NOT_CONNECTED, (__FUNCTION__": DeviceIoControl failed dwErr (%u)\n", dwErr));
         CloseHandle(HubDevice);
         return VERR_GENERAL_FAILURE;
@@ -1328,10 +1328,10 @@
                 DWORD dwErr = GetLastError();
 #ifdef VBOX_WITH_ANNOYING_USB_ASSERTIONS
-                 /* ERROR_DEVICE_NOT_CONNECTED -> device was removed just now */
-                 AssertMsg(dwErr == ERROR_DEVICE_NOT_CONNECTED, (__FUNCTION__": DeviceIoControl failed dwErr (%d)\n", dwErr));
+                /* ERROR_DEVICE_NOT_CONNECTED -> device was removed just now */
+                AssertMsg(dwErr == ERROR_DEVICE_NOT_CONNECTED, (__FUNCTION__": DeviceIoControl failed dwErr (%u)\n", dwErr));
 #endif
                 LogRelFunc(("SUPUSB_IOCTL_GET_DEVICE failed on '%s' (dwErr=%u)!\n", pDevInfos->szName, dwErr));
-                 CloseHandle(hDev);
-                 break;
+                CloseHandle(hDev);
+                break;
             }
 
@@ -1343,10 +1343,10 @@
             if (!DeviceIoControl(pGlobal->hMonitor, SUPUSBFLT_IOCTL_GET_DEVICE, &hDevice, sizeof (hDevice), &MonInfo, sizeof (MonInfo), &cbReturned, NULL))
             {
-                 DWORD dwErr = GetLastError();
-                 /* ERROR_DEVICE_NOT_CONNECTED -> device was removed just now */
-                 AssertMsgFailed(("Monitor DeviceIoControl failed dwErr (%d)\n", dwErr));
+                DWORD dwErr = GetLastError();
+                /* ERROR_DEVICE_NOT_CONNECTED -> device was removed just now */
+                AssertMsgFailed(("Monitor DeviceIoControl failed dwErr (%u)\n", dwErr));
                 LogRelFunc(("SUPUSBFLT_IOCTL_GET_DEVICE failed for '%s' (hDevice=%p, dwErr=%u)!\n", pDevInfos->szName, hDevice, dwErr));
-                 CloseHandle(hDev);
-                 break;
+                CloseHandle(hDev);
+                break;
             }
 
@@ -1431,5 +1431,5 @@
         {
             DWORD dwErr = GetLastError(); NOREF(dwErr);
-            AssertMsgFailed(("WaitForMultipleObjects failed, dwErr (%d)\n", dwErr));
+            AssertMsgFailed(("WaitForMultipleObjects failed, dwErr (%u)\n", dwErr));
             return VERR_GENERAL_FAILURE;
         }
@@ -1450,5 +1450,5 @@
     {
         DWORD dwErr = GetLastError(); NOREF(dwErr);
-        AssertMsgFailed(("SetEvent failed, dwErr (%d)\n", dwErr));
+        AssertMsgFailed(("SetEvent failed, dwErr (%u)\n", dwErr));
         return VERR_GENERAL_FAILURE;
     }
@@ -1498,6 +1498,7 @@
                 &cbReturned, NULL))
     {
-        DWORD dwErr = GetLastError(); NOREF(dwErr);
-        AssertMsgFailed(("DeviceIoControl failed with dwErr (%d(\n", dwErr));
+        DWORD dwErr = GetLastError();
+        AssertMsgFailed(("DeviceIoControl failed with dwErr (%u)\n", dwErr));
+        LogRelFunc(("SUPUSBFLT_IOCTL_ADD_FILTER failed (dwErr=%u)!\n", dwErr));
         return NULL;
     }
@@ -1506,6 +1507,15 @@
     {
         AssertMsgFailed(("Adding filter failed with %d\n", FltAddRc.rc));
+        LogRelFunc(("Adding a USB filter failed with rc=%d!\n", FltAddRc.rc));
         return NULL;
     }
+
+    LogRel(("Added USB filter (ID=%u, type=%d) for device %04X:%04X rev %04X, c/s/p %02X/%02X/%02X, Manufacturer=`%s' Product=`%s' Serial=`%s'\n", FltAddRc.uId, USBFilterGetFilterType(pFilter),
+            USBFilterGetNum(pFilter, USBFILTERIDX_VENDOR_ID), USBFilterGetNum(pFilter, USBFILTERIDX_PRODUCT_ID), USBFilterGetNum(pFilter, USBFILTERIDX_DEVICE_REV),
+            USBFilterGetNum(pFilter, USBFILTERIDX_DEVICE_CLASS), USBFilterGetNum(pFilter, USBFILTERIDX_DEVICE_SUB_CLASS), USBFilterGetNum(pFilter, USBFILTERIDX_DEVICE_PROTOCOL),
+            USBFilterGetString(pFilter, USBFILTERIDX_MANUFACTURER_STR)  ? USBFilterGetString(pFilter, USBFILTERIDX_MANUFACTURER_STR)  : "<null>",
+            USBFilterGetString(pFilter, USBFILTERIDX_PRODUCT_STR)       ? USBFilterGetString(pFilter, USBFILTERIDX_PRODUCT_STR)       : "<null>",
+         USBFilterGetString(pFilter, USBFILTERIDX_SERIAL_NUMBER_STR) ? USBFilterGetString(pFilter, USBFILTERIDX_SERIAL_NUMBER_STR) : "<null>"));
+
     return (void *)FltAddRc.uId;
 }
@@ -1529,5 +1539,11 @@
     uId = (uintptr_t)pvId;
     if (!DeviceIoControl(g_VBoxUsbGlobal.hMonitor, SUPUSBFLT_IOCTL_REMOVE_FILTER, &uId, sizeof(uId),  NULL, 0,&cbReturned, NULL))
-        AssertMsgFailed(("DeviceIoControl failed with LastError=%Rwa\n", GetLastError()));
+    {
+        DWORD dwErr = GetLastError();
+        AssertMsgFailed(("DeviceIoControl failed with LastError=%Rwa\n", dwErr));
+        LogRelFunc(("SUPUSBFLT_IOCTL_REMOVE_FILTER failed (dwErr=%u)!\n", dwErr));
+    }
+    else
+        LogRel(("Removed USB filter ID=%u\n", uId));
 }
 
@@ -1544,5 +1560,6 @@
     {
         DWORD dwErr = GetLastError();
-        AssertMsgFailed(("DeviceIoControl failed with dwErr (%d(\n", dwErr));
+        AssertMsgFailed(("DeviceIoControl failed with dwErr (%u)\n", dwErr));
+        LogRelFunc(("SUPUSBFLT_IOCTL_RUN_FILTERS failed (dwErr=%u)!\n", dwErr));
         return RTErrConvertFromWin32(dwErr);
     }
@@ -1571,5 +1588,5 @@
         {
             DWORD dwErr = GetLastError(); NOREF(dwErr);
-            AssertMsg(dwErr == ERROR_IO_PENDING, ("DeleteTimerQueueTimer failed, dwErr (%d)\n", dwErr));
+            AssertMsg(dwErr == ERROR_IO_PENDING, ("DeleteTimerQueueTimer failed, dwErr (%u)\n", dwErr));
         }
     }
@@ -1583,5 +1600,5 @@
     {
         DWORD dwErr = GetLastError(); NOREF(dwErr);
-        AssertMsgFailed(("CreateTimerQueueTimer failed, dwErr (%d)\n", dwErr));
+        AssertMsgFailed(("CreateTimerQueueTimer failed, dwErr (%u)\n", dwErr));
 
         /* call it directly */
@@ -1738,5 +1755,5 @@
                     {
                         DWORD dwErr = GetLastError();
-                        LogRelFunc(("CreateFile failed (dwErr=%d) for `%s'\n", dwErr, USBMON_DEVICE_NAME));
+                        LogRelFunc(("CreateFile failed (dwErr=%u) for `%s'\n", dwErr, USBMON_DEVICE_NAME));
                         rc = VERR_FILE_NOT_FOUND;
                     }
@@ -1810,5 +1827,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=%u)\n", dwErr));
                                 g_VBoxUsbGlobal.hThread = INVALID_HANDLE_VALUE;
                             }
@@ -1816,5 +1833,5 @@
                             {
                                 DWORD dwErr = GetLastError(); NOREF(dwErr);
-                                AssertMsgFailed(("CreateThread failed, dwErr (%d)\n", dwErr));
+                                AssertMsgFailed(("CreateThread failed, (dwErr=%u)\n", dwErr));
                                 rc = VERR_GENERAL_FAILURE;
                             }
@@ -1826,5 +1843,5 @@
                         {
                             DWORD dwErr = GetLastError(); NOREF(dwErr);
-                            AssertMsgFailed(("CreateTimerQueue failed (dwErr=%d)\n", dwErr));
+                            AssertMsgFailed(("CreateTimerQueue failed (dwErr=%u)\n", dwErr));
                         }
                     }
@@ -1842,5 +1859,5 @@
                 {
                     DWORD dwErr = GetLastError(); NOREF(dwErr);
-                    LogRelFunc(("SUPUSBFLT_IOCTL_GET_VERSION failed (dwErr=%d)\n", dwErr));
+                    LogRelFunc(("SUPUSBFLT_IOCTL_GET_VERSION failed (dwErr=%u)\n", dwErr));
                     AssertFailed();
                     rc = VERR_VERSION_MISMATCH;
@@ -1864,6 +1881,5 @@
         else
         {
-            DWORD dwErr = GetLastError(); NOREF(dwErr);
-            AssertMsgFailed(("CreateEvent for InterruptEvent failed (dwErr=%d)\n", dwErr));
+            AssertMsgFailed(("CreateEvent for InterruptEvent failed (dwErr=%u)\n", GetLastError()));
             rc = VERR_GENERAL_FAILURE;
         }
@@ -1874,6 +1890,5 @@
     else
     {
-        DWORD dwErr = GetLastError(); NOREF(dwErr);
-        AssertMsgFailed(("CreateEvent for NotifyEvent failed (dwErr=%d)\n", dwErr));
+        AssertMsgFailed(("CreateEvent for NotifyEvent failed (dwErr=%u)\n", GetLastError()));
         rc = VERR_GENERAL_FAILURE;
     }
@@ -1903,5 +1918,5 @@
     BOOL fRc;
     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=%u)\n", GetLastError()));
 
     if (g_VBoxUsbGlobal.hThread != NULL)
@@ -1910,5 +1925,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=%u)\n", GetLastError()));
     }
 
@@ -1917,5 +1932,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=%u)\n", GetLastError()));
     }
 
@@ -1924,17 +1939,17 @@
         fRc = DeleteTimerQueueEx(g_VBoxUsbGlobal.hTimerQueue,
                                  INVALID_HANDLE_VALUE); /* <-- to block until all timers are completed */
-        AssertMsg(fRc, ("DeleteTimerQueueEx failed (dwErr=%d)\n", GetLastError()));
+        AssertMsg(fRc, ("DeleteTimerQueueEx failed (dwErr=%u)\n", GetLastError()));
     }
 
     fRc = CloseHandle(g_VBoxUsbGlobal.hMonitor);
-    AssertMsg(fRc, ("CloseHandle for hMonitor failed (dwErr=%d)\n", GetLastError()));
+    AssertMsg(fRc, ("CloseHandle for hMonitor failed (dwErr=%u)\n", GetLastError()));
     g_VBoxUsbGlobal.hMonitor = INVALID_HANDLE_VALUE;
 
     fRc = CloseHandle(g_VBoxUsbGlobal.hInterruptEvent);
-    AssertMsg(fRc, ("CloseHandle for hInterruptEvent failed lasterr=%u\n", GetLastError()));
+    AssertMsg(fRc, ("CloseHandle for hInterruptEvent failed (dwErr=%u)\n", GetLastError()));
     g_VBoxUsbGlobal.hInterruptEvent = NULL;
 
     fRc = CloseHandle(g_VBoxUsbGlobal.hNotifyEvent);
-    AssertMsg(fRc, ("CloseHandle for hNotifyEvent failed (dwErr=%d)\n", GetLastError()));
+    AssertMsg(fRc, ("CloseHandle for hNotifyEvent failed (dwErr=%u)\n", GetLastError()));
     g_VBoxUsbGlobal.hNotifyEvent = NULL;
 
