VirtualBox

Ignore:
Timestamp:
Sep 27, 2019 2:07:15 PM (5 years ago)
Author:
vboxsync
Message:

USB/win: Additional logging, format specifier fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxUSB/win/lib/VBoxUsbLib-win.cpp

    r80964 r81058  
    125125    {
    126126        dwErr = GetLastError();
    127         AssertMsgFailed(("CreateFile FAILED to open %s, dwErr (%d)\n", pVuDev->szName, dwErr));
    128         LogRelFunc(("Failed to open `%s' (dwErr=%d)!\n", pVuDev->szName, dwErr));
     127        AssertMsgFailed(("CreateFile FAILED to open %s, dwErr=%u\n", pVuDev->szName, dwErr));
     128        LogRelFunc(("Failed to open `%s' (dwErr=%u)!\n", pVuDev->szName, dwErr));
    129129        return VERR_GENERAL_FAILURE;
    130130    }
     
    140140            dwErr = GetLastError();
    141141            AssertMsgFailed(("DeviceIoControl SUPUSB_IOCTL_GET_VERSION failed with LastError=%Rwa\n", dwErr));
    142             LogRelFunc(("SUPUSB_IOCTL_GET_VERSION failed on `%s' (dwErr=%d)!\n", pVuDev->szName, dwErr));
     142            LogRelFunc(("SUPUSB_IOCTL_GET_VERSION failed on `%s' (dwErr=%u)!\n", pVuDev->szName, dwErr));
    143143            break;
    144144        }
     
    159159            dwErr = GetLastError();
    160160            AssertMsgFailed(("DeviceIoControl SUPUSB_IOCTL_IS_OPERATIONAL failed with LastError=%Rwa\n", dwErr));
    161             LogRelFunc(("SUPUSB_IOCTL_IS_OPERATIONAL failed on `%s' (dwErr=%d)!\n", pVuDev->szName, dwErr));
     161            LogRelFunc(("SUPUSB_IOCTL_IS_OPERATIONAL failed on `%s' (dwErr=%u)!\n", pVuDev->szName, dwErr));
    162162            break;
    163163        }
     
    255255    {
    256256        DWORD dwErr = GetLastError(); NOREF(dwErr);
    257         AssertMsgFailed(("SetupDiGetClassDevs, dwErr (%d)\n", dwErr));
     257        AssertMsgFailed(("SetupDiGetClassDevs, dwErr (%u)\n", dwErr));
    258258        return VERR_GENERAL_FAILURE;
    259259    }
     
    273273                break;
    274274
    275             AssertMsgFailed(("SetupDiEnumDeviceInterfaces, dwErr (%d), resuming\n", dwErr));
     275            AssertMsgFailed(("SetupDiEnumDeviceInterfaces, dwErr (%u), resuming\n", dwErr));
    276276            continue;
    277277        }
     
    397397    {
    398398#ifdef VBOX_WITH_ANNOYING_USB_ASSERTIONS
    399         AssertMsgFailed(("DeviceIoControl 1 fail dwErr (%d)\n", GetLastError()));
     399        AssertMsgFailed(("DeviceIoControl 1 fail dwErr (%u)\n", GetLastError()));
    400400#endif
    401401        return VERR_GENERAL_FAILURE;
     
    427427    {
    428428        DWORD dwErr = GetLastError(); NOREF(dwErr);
    429         AssertMsgFailed(("DeviceIoControl 2 fail dwErr (%d)\n", dwErr));
     429        AssertMsgFailed(("DeviceIoControl 2 fail dwErr (%u)\n", dwErr));
    430430        rc = VERR_GENERAL_FAILURE;
    431431    }
     
    526526    {
    527527        DWORD dwErr = GetLastError();
    528         LogRelFunc(("IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION #1 failed (dwErr=%d) on hub %s port %d\n", dwErr, lpcszHubName, iPort));
     528        LogRelFunc(("IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION #1 failed (dwErr=%u) on hub %s port %d\n", dwErr, lpcszHubName, iPort));
    529529#ifdef VBOX_WITH_ANNOYING_USB_ASSERTIONS
    530530        AssertFailed();
     
    563563        {
    564564            DWORD dwErr = GetLastError();
    565             LogRelFunc(("IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION #2 failed (dwErr=%d) on hub %s port %d\n", dwErr, lpcszHubName, iPort));
     565            LogRelFunc(("IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION #2 failed (dwErr=%u) on hub %s port %d\n", dwErr, lpcszHubName, iPort));
    566566#ifdef VBOX_WITH_ANNOYING_USB_ASSERTIONS
    567567            AssertFailed();
     
    617617    {
    618618        DWORD dwErr = GetLastError();
    619         LogRel(("Getting USB descriptor (id %u) failed with error %ld on hub %s port %d\n", iDr, dwErr, lpcszHubName, iPort));
     619        LogRel(("Getting USB descriptor (id %u) failed (dwErr=%u) on hub %s port %d\n", iDr, dwErr, lpcszHubName, iPort));
    620620        return RTErrConvertFromWin32(dwErr);
    621621    }
     
    777777    {
    778778        DWORD dwErr = GetLastError(); NOREF(dwErr);
    779         LogRel(("Getting USB connection information failed with error %ld on hub %s\n", dwErr, lpcszHubName));
    780         AssertMsg(dwErr == ERROR_DEVICE_NOT_CONNECTED, (__FUNCTION__": DeviceIoControl failed dwErr (%d)\n", dwErr));
     779        LogRel(("Getting USB connection information failed (dwErr=%u) on hub %s\n", dwErr, lpcszHubName));
     780        AssertMsg(dwErr == ERROR_DEVICE_NOT_CONNECTED, (__FUNCTION__": DeviceIoControl failed (dwErr=%u)\n", dwErr));
    781781        return VERR_GENERAL_FAILURE;
    782782    }
     
    887887                            &cbReturned, NULL))
    888888        {
    889             LogRel(("Getting USB node information failed with error %ld on hub %s\n", GetLastError(), lpszName));
     889            LogRel(("Getting USB node information failed (dwErr=%u) on hub %s\n", GetLastError(), lpszName));
    890890            AssertFailed();
    891891            break;
     
    10911091    if (HubDevice == INVALID_HANDLE_VALUE)
    10921092    {
    1093         LogRelFunc(("Failed to open hub `%s' (dwErr=%d)\n", lpcszHubFile, GetLastError()));
     1093        LogRelFunc(("Failed to open hub `%s' (dwErr=%u)\n", lpcszHubFile, GetLastError()));
    10941094        return VERR_FILE_NOT_FOUND;
    10951095    }
     
    11101110    {
    11111111        DWORD dwErr = GetLastError(); NOREF(dwErr);
    1112         LogRel(("IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX failed with error %ld on hub %s, port %d\n", dwErr, lpcszHubFile, iPort));
    1113         AssertMsg(dwErr == ERROR_DEVICE_NOT_CONNECTED, (__FUNCTION__": DeviceIoControl failed dwErr (%d)\n", dwErr));
     1112        LogRel(("IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX failed (dwErr=%u) on hub %s, port %d\n", dwErr, lpcszHubFile, iPort));
     1113        AssertMsg(dwErr == ERROR_DEVICE_NOT_CONNECTED, (__FUNCTION__": DeviceIoControl failed dwErr (%u)\n", dwErr));
    11141114        CloseHandle(HubDevice);
    11151115        return VERR_GENERAL_FAILURE;
     
    13281328                DWORD dwErr = GetLastError();
    13291329#ifdef VBOX_WITH_ANNOYING_USB_ASSERTIONS
    1330                  /* ERROR_DEVICE_NOT_CONNECTED -> device was removed just now */
    1331                  AssertMsg(dwErr == ERROR_DEVICE_NOT_CONNECTED, (__FUNCTION__": DeviceIoControl failed dwErr (%d)\n", dwErr));
     1330                /* ERROR_DEVICE_NOT_CONNECTED -> device was removed just now */
     1331                AssertMsg(dwErr == ERROR_DEVICE_NOT_CONNECTED, (__FUNCTION__": DeviceIoControl failed dwErr (%u)\n", dwErr));
    13321332#endif
    13331333                LogRelFunc(("SUPUSB_IOCTL_GET_DEVICE failed on '%s' (dwErr=%u)!\n", pDevInfos->szName, dwErr));
    1334                  CloseHandle(hDev);
    1335                  break;
     1334                CloseHandle(hDev);
     1335                break;
    13361336            }
    13371337
     
    13431343            if (!DeviceIoControl(pGlobal->hMonitor, SUPUSBFLT_IOCTL_GET_DEVICE, &hDevice, sizeof (hDevice), &MonInfo, sizeof (MonInfo), &cbReturned, NULL))
    13441344            {
    1345                  DWORD dwErr = GetLastError();
    1346                  /* ERROR_DEVICE_NOT_CONNECTED -> device was removed just now */
    1347                  AssertMsgFailed(("Monitor DeviceIoControl failed dwErr (%d)\n", dwErr));
     1345                DWORD dwErr = GetLastError();
     1346                /* ERROR_DEVICE_NOT_CONNECTED -> device was removed just now */
     1347                AssertMsgFailed(("Monitor DeviceIoControl failed dwErr (%u)\n", dwErr));
    13481348                LogRelFunc(("SUPUSBFLT_IOCTL_GET_DEVICE failed for '%s' (hDevice=%p, dwErr=%u)!\n", pDevInfos->szName, hDevice, dwErr));
    1349                  CloseHandle(hDev);
    1350                  break;
     1349                CloseHandle(hDev);
     1350                break;
    13511351            }
    13521352
     
    14311431        {
    14321432            DWORD dwErr = GetLastError(); NOREF(dwErr);
    1433             AssertMsgFailed(("WaitForMultipleObjects failed, dwErr (%d)\n", dwErr));
     1433            AssertMsgFailed(("WaitForMultipleObjects failed, dwErr (%u)\n", dwErr));
    14341434            return VERR_GENERAL_FAILURE;
    14351435        }
     
    14501450    {
    14511451        DWORD dwErr = GetLastError(); NOREF(dwErr);
    1452         AssertMsgFailed(("SetEvent failed, dwErr (%d)\n", dwErr));
     1452        AssertMsgFailed(("SetEvent failed, dwErr (%u)\n", dwErr));
    14531453        return VERR_GENERAL_FAILURE;
    14541454    }
     
    14981498                &cbReturned, NULL))
    14991499    {
    1500         DWORD dwErr = GetLastError(); NOREF(dwErr);
    1501         AssertMsgFailed(("DeviceIoControl failed with dwErr (%d(\n", dwErr));
     1500        DWORD dwErr = GetLastError();
     1501        AssertMsgFailed(("DeviceIoControl failed with dwErr (%u)\n", dwErr));
     1502        LogRelFunc(("SUPUSBFLT_IOCTL_ADD_FILTER failed (dwErr=%u)!\n", dwErr));
    15021503        return NULL;
    15031504    }
     
    15061507    {
    15071508        AssertMsgFailed(("Adding filter failed with %d\n", FltAddRc.rc));
     1509        LogRelFunc(("Adding a USB filter failed with rc=%d!\n", FltAddRc.rc));
    15081510        return NULL;
    15091511    }
     1512
     1513    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),
     1514            USBFilterGetNum(pFilter, USBFILTERIDX_VENDOR_ID), USBFilterGetNum(pFilter, USBFILTERIDX_PRODUCT_ID), USBFilterGetNum(pFilter, USBFILTERIDX_DEVICE_REV),
     1515            USBFilterGetNum(pFilter, USBFILTERIDX_DEVICE_CLASS), USBFilterGetNum(pFilter, USBFILTERIDX_DEVICE_SUB_CLASS), USBFilterGetNum(pFilter, USBFILTERIDX_DEVICE_PROTOCOL),
     1516            USBFilterGetString(pFilter, USBFILTERIDX_MANUFACTURER_STR)  ? USBFilterGetString(pFilter, USBFILTERIDX_MANUFACTURER_STR)  : "<null>",
     1517            USBFilterGetString(pFilter, USBFILTERIDX_PRODUCT_STR)       ? USBFilterGetString(pFilter, USBFILTERIDX_PRODUCT_STR)       : "<null>",
     1518         USBFilterGetString(pFilter, USBFILTERIDX_SERIAL_NUMBER_STR) ? USBFilterGetString(pFilter, USBFILTERIDX_SERIAL_NUMBER_STR) : "<null>"));
     1519
    15101520    return (void *)FltAddRc.uId;
    15111521}
     
    15291539    uId = (uintptr_t)pvId;
    15301540    if (!DeviceIoControl(g_VBoxUsbGlobal.hMonitor, SUPUSBFLT_IOCTL_REMOVE_FILTER, &uId, sizeof(uId),  NULL, 0,&cbReturned, NULL))
    1531         AssertMsgFailed(("DeviceIoControl failed with LastError=%Rwa\n", GetLastError()));
     1541    {
     1542        DWORD dwErr = GetLastError();
     1543        AssertMsgFailed(("DeviceIoControl failed with LastError=%Rwa\n", dwErr));
     1544        LogRelFunc(("SUPUSBFLT_IOCTL_REMOVE_FILTER failed (dwErr=%u)!\n", dwErr));
     1545    }
     1546    else
     1547        LogRel(("Removed USB filter ID=%u\n", uId));
    15321548}
    15331549
     
    15441560    {
    15451561        DWORD dwErr = GetLastError();
    1546         AssertMsgFailed(("DeviceIoControl failed with dwErr (%d(\n", dwErr));
     1562        AssertMsgFailed(("DeviceIoControl failed with dwErr (%u)\n", dwErr));
     1563        LogRelFunc(("SUPUSBFLT_IOCTL_RUN_FILTERS failed (dwErr=%u)!\n", dwErr));
    15471564        return RTErrConvertFromWin32(dwErr);
    15481565    }
     
    15711588        {
    15721589            DWORD dwErr = GetLastError(); NOREF(dwErr);
    1573             AssertMsg(dwErr == ERROR_IO_PENDING, ("DeleteTimerQueueTimer failed, dwErr (%d)\n", dwErr));
     1590            AssertMsg(dwErr == ERROR_IO_PENDING, ("DeleteTimerQueueTimer failed, dwErr (%u)\n", dwErr));
    15741591        }
    15751592    }
     
    15831600    {
    15841601        DWORD dwErr = GetLastError(); NOREF(dwErr);
    1585         AssertMsgFailed(("CreateTimerQueueTimer failed, dwErr (%d)\n", dwErr));
     1602        AssertMsgFailed(("CreateTimerQueueTimer failed, dwErr (%u)\n", dwErr));
    15861603
    15871604        /* call it directly */
     
    17381755                    {
    17391756                        DWORD dwErr = GetLastError();
    1740                         LogRelFunc(("CreateFile failed (dwErr=%d) for `%s'\n", dwErr, USBMON_DEVICE_NAME));
     1757                        LogRelFunc(("CreateFile failed (dwErr=%u) for `%s'\n", dwErr, USBMON_DEVICE_NAME));
    17411758                        rc = VERR_FILE_NOT_FOUND;
    17421759                    }
     
    18101827                                BOOL fRc = CloseHandle(g_VBoxUsbGlobal.hThread); NOREF(fRc);
    18111828                                DWORD dwErr = GetLastError(); NOREF(dwErr);
    1812                                 AssertMsg(fRc, ("CloseHandle for hThread failed (dwErr=%d)\n", dwErr));
     1829                                AssertMsg(fRc, ("CloseHandle for hThread failed (dwErr=%u)\n", dwErr));
    18131830                                g_VBoxUsbGlobal.hThread = INVALID_HANDLE_VALUE;
    18141831                            }
     
    18161833                            {
    18171834                                DWORD dwErr = GetLastError(); NOREF(dwErr);
    1818                                 AssertMsgFailed(("CreateThread failed, dwErr (%d)\n", dwErr));
     1835                                AssertMsgFailed(("CreateThread failed, (dwErr=%u)\n", dwErr));
    18191836                                rc = VERR_GENERAL_FAILURE;
    18201837                            }
     
    18261843                        {
    18271844                            DWORD dwErr = GetLastError(); NOREF(dwErr);
    1828                             AssertMsgFailed(("CreateTimerQueue failed (dwErr=%d)\n", dwErr));
     1845                            AssertMsgFailed(("CreateTimerQueue failed (dwErr=%u)\n", dwErr));
    18291846                        }
    18301847                    }
     
    18421859                {
    18431860                    DWORD dwErr = GetLastError(); NOREF(dwErr);
    1844                     LogRelFunc(("SUPUSBFLT_IOCTL_GET_VERSION failed (dwErr=%d)\n", dwErr));
     1861                    LogRelFunc(("SUPUSBFLT_IOCTL_GET_VERSION failed (dwErr=%u)\n", dwErr));
    18451862                    AssertFailed();
    18461863                    rc = VERR_VERSION_MISMATCH;
     
    18641881        else
    18651882        {
    1866             DWORD dwErr = GetLastError(); NOREF(dwErr);
    1867             AssertMsgFailed(("CreateEvent for InterruptEvent failed (dwErr=%d)\n", dwErr));
     1883            AssertMsgFailed(("CreateEvent for InterruptEvent failed (dwErr=%u)\n", GetLastError()));
    18681884            rc = VERR_GENERAL_FAILURE;
    18691885        }
     
    18741890    else
    18751891    {
    1876         DWORD dwErr = GetLastError(); NOREF(dwErr);
    1877         AssertMsgFailed(("CreateEvent for NotifyEvent failed (dwErr=%d)\n", dwErr));
     1892        AssertMsgFailed(("CreateEvent for NotifyEvent failed (dwErr=%u)\n", GetLastError()));
    18781893        rc = VERR_GENERAL_FAILURE;
    18791894    }
     
    19031918    BOOL fRc;
    19041919    fRc = PostMessage(g_VBoxUsbGlobal.hWnd, WM_CLOSE, 0, 0);
    1905     AssertMsg(fRc, ("PostMessage for hWnd failed (dwErr=%d)\n", GetLastError()));
     1920    AssertMsg(fRc, ("PostMessage for hWnd failed (dwErr=%u)\n", GetLastError()));
    19061921
    19071922    if (g_VBoxUsbGlobal.hThread != NULL)
     
    19101925        Assert(dwResult == WAIT_OBJECT_0); NOREF(dwResult);
    19111926        fRc = CloseHandle(g_VBoxUsbGlobal.hThread);
    1912         AssertMsg(fRc, ("CloseHandle for hThread failed (dwErr=%d)\n", GetLastError()));
     1927        AssertMsg(fRc, ("CloseHandle for hThread failed (dwErr=%u)\n", GetLastError()));
    19131928    }
    19141929
     
    19171932        fRc = DeleteTimerQueueTimer(g_VBoxUsbGlobal.hTimerQueue, g_VBoxUsbGlobal.hTimer,
    19181933                                    INVALID_HANDLE_VALUE); /* <-- to block until the timer is completed */
    1919         AssertMsg(fRc, ("DeleteTimerQueueTimer failed (dwErr=%d)\n", GetLastError()));
     1934        AssertMsg(fRc, ("DeleteTimerQueueTimer failed (dwErr=%u)\n", GetLastError()));
    19201935    }
    19211936
     
    19241939        fRc = DeleteTimerQueueEx(g_VBoxUsbGlobal.hTimerQueue,
    19251940                                 INVALID_HANDLE_VALUE); /* <-- to block until all timers are completed */
    1926         AssertMsg(fRc, ("DeleteTimerQueueEx failed (dwErr=%d)\n", GetLastError()));
     1941        AssertMsg(fRc, ("DeleteTimerQueueEx failed (dwErr=%u)\n", GetLastError()));
    19271942    }
    19281943
    19291944    fRc = CloseHandle(g_VBoxUsbGlobal.hMonitor);
    1930     AssertMsg(fRc, ("CloseHandle for hMonitor failed (dwErr=%d)\n", GetLastError()));
     1945    AssertMsg(fRc, ("CloseHandle for hMonitor failed (dwErr=%u)\n", GetLastError()));
    19311946    g_VBoxUsbGlobal.hMonitor = INVALID_HANDLE_VALUE;
    19321947
    19331948    fRc = CloseHandle(g_VBoxUsbGlobal.hInterruptEvent);
    1934     AssertMsg(fRc, ("CloseHandle for hInterruptEvent failed lasterr=%u\n", GetLastError()));
     1949    AssertMsg(fRc, ("CloseHandle for hInterruptEvent failed (dwErr=%u)\n", GetLastError()));
    19351950    g_VBoxUsbGlobal.hInterruptEvent = NULL;
    19361951
    19371952    fRc = CloseHandle(g_VBoxUsbGlobal.hNotifyEvent);
    1938     AssertMsg(fRc, ("CloseHandle for hNotifyEvent failed (dwErr=%d)\n", GetLastError()));
     1953    AssertMsg(fRc, ("CloseHandle for hNotifyEvent failed (dwErr=%u)\n", GetLastError()));
    19391954    g_VBoxUsbGlobal.hNotifyEvent = NULL;
    19401955
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette