Changeset 62690 in vbox for trunk/src/VBox/HostDrivers/VBoxUSB/win/lib
- Timestamp:
- Jul 29, 2016 1:44:32 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxUSB/win/lib/VBoxUsbLib-win.cpp
r62686 r62690 114 114 if (hOut == INVALID_HANDLE_VALUE) 115 115 { 116 DWORD winEr = GetLastError();117 AssertMsgFailed(("CreateFile FAILED to open %s, winEr (%d)\n", pVuDev->szName, winEr));116 DWORD dwErr = GetLastError(); NOREF(dwErr); 117 AssertMsgFailed(("CreateFile FAILED to open %s, dwErr (%d)\n", pVuDev->szName, dwErr)); 118 118 return VERR_GENERAL_FAILURE; 119 119 } … … 132 132 133 133 if ( version.u32Major != USBDRV_MAJOR_VERSION 134 || version.u32Minor < USBDRV_MINOR_VERSION) 134 #if USBDRV_MINOR_VERSION != 0 135 || version.u32Minor < USBDRV_MINOR_VERSION 136 #endif 137 ) 135 138 { 136 139 AssertMsgFailed(("Invalid version %d:%d vs %d:%d\n", version.u32Major, version.u32Minor, USBDRV_MAJOR_VERSION, USBDRV_MINOR_VERSION)); … … 184 187 &DevInfoData)) 185 188 { 186 DWORD winEr = GetLastError();187 AssertMsgFailed(("SetupDiGetDeviceInterfaceDetail, cbRequired (%d), was (%d), winEr (%d)\n", cbDbgRequired, cbIfDetailData, winEr));189 DWORD dwErr = GetLastError(); NOREF(dwErr); 190 AssertMsgFailed(("SetupDiGetDeviceInterfaceDetail, cbRequired (%d), was (%d), dwErr (%d)\n", cbDbgRequired, cbIfDetailData, dwErr)); 188 191 rc = VERR_GENERAL_FAILURE; 189 192 break; … … 198 201 &cbDbgRequired)) 199 202 { 200 DWORD winEr = GetLastError();201 AssertMsgFailed(("SetupDiGetDeviceRegistryPropertyA, cbRequired (%d), was (%d), winEr (%d)\n", cbDbgRequired, sizeof (pVuDev->szDriverRegName), winEr));203 DWORD dwErr = GetLastError(); NOREF(dwErr); 204 AssertMsgFailed(("SetupDiGetDeviceRegistryPropertyA, cbRequired (%d), was (%d), dwErr (%d)\n", cbDbgRequired, sizeof (pVuDev->szDriverRegName), dwErr)); 202 205 rc = VERR_GENERAL_FAILURE; 203 206 break; … … 234 237 if (hDevInfo == INVALID_HANDLE_VALUE) 235 238 { 236 DWORD winEr = GetLastError();237 AssertMsgFailed(("SetupDiGetClassDevs, winEr (%d)\n", winEr));239 DWORD dwErr = GetLastError(); NOREF(dwErr); 240 AssertMsgFailed(("SetupDiGetClassDevs, dwErr (%d)\n", dwErr)); 238 241 return VERR_GENERAL_FAILURE; 239 242 } … … 249 252 &IfData)) 250 253 { 251 DWORD winEr = GetLastError();252 if ( winEr == ERROR_NO_MORE_ITEMS)254 DWORD dwErr = GetLastError(); 255 if (dwErr == ERROR_NO_MORE_ITEMS) 253 256 break; 254 257 255 AssertMsgFailed(("SetupDiEnumDeviceInterfaces, winEr (%d), resuming\n", winEr));258 AssertMsgFailed(("SetupDiEnumDeviceInterfaces, dwErr (%d), resuming\n", dwErr)); 256 259 continue; 257 260 } … … 360 363 { 361 364 #ifdef VBOX_WITH_ANNOYING_USB_ASSERTIONS 362 DWORD winEr = GetLastError();363 AssertMsgFailed(("DeviceIoControl 1 fail winEr (%d)\n", winEr));365 DWORD dwErr = GetLastError(); 366 AssertMsgFailed(("DeviceIoControl 1 fail dwErr (%d)\n", dwErr)); 364 367 #endif 365 368 return VERR_GENERAL_FAILURE; … … 390 393 else 391 394 { 392 DWORD winEr = GetLastError();393 AssertMsgFailed(("DeviceIoControl 2 fail winEr (%d)\n", winEr));395 DWORD dwErr = GetLastError(); NOREF(dwErr); 396 AssertMsgFailed(("DeviceIoControl 2 fail dwErr (%d)\n", dwErr)); 394 397 rc = VERR_GENERAL_FAILURE; 395 398 } … … 488 491 &cbReturned, NULL)) 489 492 { 490 DWORD winEr = GetLastError();491 LogRelFunc(("DeviceIoControl 1 fail winEr (%d)\n", winEr));493 DWORD dwErr = GetLastError(); 494 LogRelFunc(("DeviceIoControl 1 fail dwErr (%d)\n", dwErr)); 492 495 #ifdef VBOX_WITH_ANNOYING_USB_ASSERTIONS 493 496 AssertFailed(); … … 525 528 &cbReturned, NULL)) 526 529 { 527 DWORD winEr = GetLastError();528 LogRelFunc(("DeviceIoControl 2 fail winEr (%d)\n", winEr));530 DWORD dwErr = GetLastError(); 531 LogRelFunc(("DeviceIoControl 2 fail dwErr (%d)\n", dwErr)); 529 532 #ifdef VBOX_WITH_ANNOYING_USB_ASSERTIONS 530 533 AssertFailed(); … … 729 732 char Buf[sizeof (USB_NODE_CONNECTION_INFORMATION_EX) + (sizeof (USB_PIPE_INFO) * 20)]; 730 733 PUSB_NODE_CONNECTION_INFORMATION_EX pConInfo = (PUSB_NODE_CONNECTION_INFORMATION_EX)Buf; 731 PUSB_PIPE_INFO paPipeInfo = (PUSB_PIPE_INFO)(Buf + sizeof (PUSB_NODE_CONNECTION_INFORMATION_EX));734 //PUSB_PIPE_INFO paPipeInfo = (PUSB_PIPE_INFO)(Buf + sizeof (PUSB_NODE_CONNECTION_INFORMATION_EX)); 732 735 DWORD cbReturned = 0; 733 736 memset(&Buf, 0, sizeof (Buf)); … … 738 741 &cbReturned, NULL)) 739 742 { 740 DWORD winEr = GetLastError();741 AssertMsg( winEr == ERROR_DEVICE_NOT_CONNECTED, (__FUNCTION__": DeviceIoControl failed winEr (%d)\n", winEr));743 DWORD dwErr = GetLastError(); NOREF(dwErr); 744 AssertMsg(dwErr == ERROR_DEVICE_NOT_CONNECTED, (__FUNCTION__": DeviceIoControl failed dwErr (%d)\n", dwErr)); 742 745 return VERR_GENERAL_FAILURE; 743 746 } … … 894 897 } 895 898 899 #if 0 /* unused */ 896 900 static PUSBSUP_GET_DEVICES usbLibMonGetDevRqAlloc(uint32_t cDevs, PDWORD pcbRq) 897 901 { … … 905 909 return pRq; 906 910 } 911 #endif 907 912 908 913 static int usbLibMonDevicesCmp(PUSBDEVICE pDev, PVBOXUSB_DEV pDevInfo) … … 913 918 } 914 919 915 static int usbLibMonDevicesUpdate(PVBOXUSBGLOBALSTATE pGlobal, PUSBDEVICE pDevs, uint32_t cDevs, PVBOXUSB_DEV pDevInfos, uint32_t cDevInfos) 916 { 920 static int usbLibMonDevicesUpdate(PVBOXUSBGLOBALSTATE pGlobal, PUSBDEVICE pDevs, PVBOXUSB_DEV pDevInfos) 921 { 922 917 923 PUSBDEVICE pDevsHead = pDevs; 918 924 for (; pDevInfos; pDevInfos = pDevInfos->pNext) … … 941 947 if (!DeviceIoControl(hDev, SUPUSB_IOCTL_GET_DEVICE, &Dev, sizeof (Dev), &Dev, sizeof (Dev), &cbReturned, NULL)) 942 948 { 943 DWORD winEr = GetLastError(); 949 #ifdef VBOX_WITH_ANNOYING_USB_ASSERTIONS 950 DWORD dwErr = GetLastError(); NOREF(dwErr); 944 951 /* ERROR_DEVICE_NOT_CONNECTED -> device was removed just now */ 945 #ifdef VBOX_WITH_ANNOYING_USB_ASSERTIONS 946 AssertMsg(winEr == ERROR_DEVICE_NOT_CONNECTED, (__FUNCTION__": DeviceIoControl failed winEr (%d)\n", winEr)); 952 AssertMsg(dwErr == ERROR_DEVICE_NOT_CONNECTED, (__FUNCTION__": DeviceIoControl failed dwErr (%d)\n", dwErr)); 947 953 #endif 948 954 Log(("SUPUSB_IOCTL_GET_DEVICE: DeviceIoControl no longer connected\n")); … … 958 964 if (!DeviceIoControl(pGlobal->hMonitor, SUPUSBFLT_IOCTL_GET_DEVICE, &hDevice, sizeof (hDevice), &MonInfo, sizeof (MonInfo), &cbReturned, NULL)) 959 965 { 960 DWORD winEr = GetLastError();966 DWORD dwErr = GetLastError(); NOREF(dwErr); 961 967 /* ERROR_DEVICE_NOT_CONNECTED -> device was removed just now */ 962 AssertMsgFailed(("Monitor DeviceIoControl failed winEr (%d)\n", winEr));968 AssertMsgFailed(("Monitor DeviceIoControl failed dwErr (%d)\n", dwErr)); 963 969 Log(("SUPUSBFLT_IOCTL_GET_DEVICE: DeviceIoControl no longer connected\n")); 964 970 CloseHandle(hDev); … … 1021 1027 if (RT_SUCCESS(rc)) 1022 1028 { 1023 rc = usbLibMonDevicesUpdate(pGlobal, *ppDevs, *pcDevs, pDevInfos, cDevInfos);1029 rc = usbLibMonDevicesUpdate(pGlobal, *ppDevs, pDevInfos); 1024 1030 AssertRC(rc); 1025 1031 usbLibVuFreeDevices(pDevInfos); … … 1049 1055 default: 1050 1056 { 1051 DWORD winEr = GetLastError();1052 AssertMsgFailed(("WaitForMultipleObjects failed, winEr (%d)\n", winEr));1057 DWORD dwErr = GetLastError(); NOREF(dwErr); 1058 AssertMsgFailed(("WaitForMultipleObjects failed, dwErr (%d)\n", dwErr)); 1053 1059 return VERR_GENERAL_FAILURE; 1054 1060 } … … 1065 1071 static int usbLibInterruptWaitChange(PVBOXUSBGLOBALSTATE pGlobal) 1066 1072 { 1067 BOOL bRc = SetEvent(pGlobal->hInterruptEvent);1068 if (! bRc)1069 { 1070 DWORD winEr = GetLastError();1071 AssertMsgFailed(("SetEvent failed, winEr (%d)\n", winEr));1073 BOOL fRc = SetEvent(pGlobal->hInterruptEvent); 1074 if (!fRc) 1075 { 1076 DWORD dwErr = GetLastError(); NOREF(dwErr); 1077 AssertMsgFailed(("SetEvent failed, dwErr (%d)\n", dwErr)); 1072 1078 return VERR_GENERAL_FAILURE; 1073 1079 } … … 1117 1123 &cbReturned, NULL)) 1118 1124 { 1119 DWORD winEr = GetLastError();1120 AssertMsgFailed(("DeviceIoControl failed with winEr (%d(\n", winEr));1125 DWORD dwErr = GetLastError(); NOREF(dwErr); 1126 AssertMsgFailed(("DeviceIoControl failed with dwErr (%d(\n", dwErr)); 1121 1127 return NULL; 1122 1128 } … … 1162 1168 &cbReturned, NULL)) 1163 1169 { 1164 DWORD winEr = GetLastError();1165 AssertMsgFailed(("DeviceIoControl failed with winEr (%d(\n", winEr));1166 return RTErrConvertFromWin32( winEr);1170 DWORD dwErr = GetLastError(); 1171 AssertMsgFailed(("DeviceIoControl failed with dwErr (%d(\n", dwErr)); 1172 return RTErrConvertFromWin32(dwErr); 1167 1173 } 1168 1174 … … 1175 1181 static VOID CALLBACK usbLibTimerCallback(__in PVOID lpParameter, __in BOOLEAN TimerOrWaitFired) 1176 1182 { 1183 RT_NOREF2(lpParameter, TimerOrWaitFired); 1177 1184 SetEvent(g_VBoxUsbGlobal.hNotifyEvent); 1178 1185 } … … 1190 1197 if (!DeleteTimerQueueTimer(g_VBoxUsbGlobal.hTimerQueue, g_VBoxUsbGlobal.hTimer, NULL)) 1191 1198 { 1192 DWORD winEr = GetLastError();1193 AssertMsg( winEr == ERROR_IO_PENDING, ("DeleteTimerQueueTimer failed, winEr (%d)\n", winEr));1199 DWORD dwErr = GetLastError(); NOREF(dwErr); 1200 AssertMsg(dwErr == ERROR_IO_PENDING, ("DeleteTimerQueueTimer failed, dwErr (%d)\n", dwErr)); 1194 1201 } 1195 1202 } … … 1202 1209 WT_EXECUTEONLYONCE)) 1203 1210 { 1204 DWORD winEr = GetLastError();1205 AssertMsgFailed(("CreateTimerQueueTimer failed, winEr (%d)\n", winEr));1211 DWORD dwErr = GetLastError(); NOREF(dwErr); 1212 AssertMsgFailed(("CreateTimerQueueTimer failed, dwErr (%d)\n", dwErr)); 1206 1213 1207 1214 /* call it directly */ … … 1243 1250 static LPCSTR s_szVBoxUsbWndClassName = "VBoxUsbLibClass"; 1244 1251 const HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL); 1252 RT_NOREF1(lpParameter); 1245 1253 1246 1254 Assert(g_VBoxUsbGlobal.hWnd == NULL); … … 1361 1369 if (g_VBoxUsbGlobal.hMonitor == INVALID_HANDLE_VALUE) 1362 1370 { 1363 DWORD winEr = GetLastError();1364 LogRelFunc(("CreateFile failed winEr(%d)\n", winEr));1371 DWORD dwErr = GetLastError(); 1372 LogRelFunc(("CreateFile failed dwErr(%d)\n", dwErr)); 1365 1373 rc = VERR_FILE_NOT_FOUND; 1366 1374 } … … 1387 1395 { 1388 1396 if ( Version.u32Major == USBMON_MAJOR_VERSION 1389 && Version.u32Minor >= USBMON_MINOR_VERSION) 1397 #if USBMON_MINOR_VERSION != 0 1398 && Version.u32Minor >= USBMON_MINOR_VERSION 1399 #endif 1400 ) 1390 1401 { 1391 1402 #ifndef VBOX_USB_USE_DEVICE_NOTIFICATION … … 1415 1426 else 1416 1427 { 1417 DWORD winEr = GetLastError();1418 AssertMsgFailed(("SetEvent Ioctl failed, winEr (%d)\n", winEr));1428 DWORD dwErr = GetLastError(); 1429 AssertMsgFailed(("SetEvent Ioctl failed, dwErr (%d)\n", dwErr)); 1419 1430 rc = VERR_VERSION_MISMATCH; 1420 1431 } … … 1460 1471 dwResult = WaitForSingleObject(g_VBoxUsbGlobal.hThread, INFINITE); 1461 1472 Assert(dwResult == WAIT_OBJECT_0); 1462 BOOL bRc = CloseHandle(g_VBoxUsbGlobal.hThread); 1463 AssertMsg(bRc, ("CloseHandle for hThread failed winEr(%d)\n", GetLastError())); 1473 BOOL fRc = CloseHandle(g_VBoxUsbGlobal.hThread); NOREF(fRc); 1474 DWORD dwErr = GetLastError(); NOREF(dwErr); 1475 AssertMsg(fRc, ("CloseHandle for hThread failed dwErr(%d)\n", dwErr)); 1464 1476 g_VBoxUsbGlobal.hThread = INVALID_HANDLE_VALUE; 1465 1477 } 1466 1478 else 1467 1479 { 1468 DWORD winEr = GetLastError();1469 AssertMsgFailed(("CreateThread failed, winEr (%d)\n", winEr));1480 DWORD dwErr = GetLastError(); NOREF(dwErr); 1481 AssertMsgFailed(("CreateThread failed, dwErr (%d)\n", dwErr)); 1470 1482 rc = VERR_GENERAL_FAILURE; 1471 1483 } … … 1476 1488 else 1477 1489 { 1478 DWORD winEr = GetLastError();1479 AssertMsgFailed(("CreateTimerQueue failed winEr(%d)\n", winEr));1490 DWORD dwErr = GetLastError(); NOREF(dwErr); 1491 AssertMsgFailed(("CreateTimerQueue failed dwErr(%d)\n", dwErr)); 1480 1492 } 1481 1493 #endif … … 1493 1505 else 1494 1506 { 1495 DWORD winEr = GetLastError();1496 AssertMsgFailed(("DeviceIoControl failed winEr(%d)\n", winEr));1507 DWORD dwErr = GetLastError(); NOREF(dwErr); 1508 AssertMsgFailed(("DeviceIoControl failed dwErr(%d)\n", dwErr)); 1497 1509 rc = VERR_VERSION_MISMATCH; 1498 1510 } … … 1515 1527 else 1516 1528 { 1517 DWORD winEr = GetLastError();1518 AssertMsgFailed(("CreateEvent for InterruptEvent failed winEr(%d)\n", winEr));1529 DWORD dwErr = GetLastError(); NOREF(dwErr); 1530 AssertMsgFailed(("CreateEvent for InterruptEvent failed dwErr(%d)\n", dwErr)); 1519 1531 rc = VERR_GENERAL_FAILURE; 1520 1532 } … … 1525 1537 else 1526 1538 { 1527 DWORD winEr = GetLastError();1528 AssertMsgFailed(("CreateEvent for NotifyEvent failed winEr(%d)\n", winEr));1539 DWORD dwErr = GetLastError(); NOREF(dwErr); 1540 AssertMsgFailed(("CreateEvent for NotifyEvent failed dwErr(%d)\n", dwErr)); 1529 1541 rc = VERR_GENERAL_FAILURE; 1530 1542 } … … 1552 1564 } 1553 1565 1554 BOOL bRc;1566 BOOL fRc; 1555 1567 #ifdef VBOX_USB_USE_DEVICE_NOTIFICATION 1556 bRc = PostMessage(g_VBoxUsbGlobal.hWnd, WM_CLOSE, 0, 0);1557 AssertMsg( bRc, ("PostMessage for hWnd failed winEr(%d)\n", GetLastError()));1568 fRc = PostMessage(g_VBoxUsbGlobal.hWnd, WM_CLOSE, 0, 0); 1569 AssertMsg(fRc, ("PostMessage for hWnd failed dwErr(%d)\n", GetLastError())); 1558 1570 1559 1571 if (g_VBoxUsbGlobal.hThread != NULL) 1560 1572 { 1561 1573 DWORD dwResult = WaitForSingleObject(g_VBoxUsbGlobal.hThread, INFINITE); 1562 Assert(dwResult == WAIT_OBJECT_0); 1563 bRc = CloseHandle(g_VBoxUsbGlobal.hThread);1564 AssertMsg( bRc, ("CloseHandle for hThread failed winEr(%d)\n", GetLastError()));1574 Assert(dwResult == WAIT_OBJECT_0); NOREF(dwResult); 1575 fRc = CloseHandle(g_VBoxUsbGlobal.hThread); 1576 AssertMsg(fRc, ("CloseHandle for hThread failed dwErr(%d)\n", GetLastError())); 1565 1577 } 1566 1578 1567 1579 if (g_VBoxUsbGlobal.hTimer) 1568 1580 { 1569 bRc = DeleteTimerQueueTimer(g_VBoxUsbGlobal.hTimerQueue, g_VBoxUsbGlobal.hTimer,1581 fRc = DeleteTimerQueueTimer(g_VBoxUsbGlobal.hTimerQueue, g_VBoxUsbGlobal.hTimer, 1570 1582 INVALID_HANDLE_VALUE); /* <-- to block until the timer is completed */ 1571 AssertMsg( bRc, ("DeleteTimerQueueTimer failed winEr(%d)\n", GetLastError()));1583 AssertMsg(fRc, ("DeleteTimerQueueTimer failed dwErr(%d)\n", GetLastError())); 1572 1584 } 1573 1585 1574 1586 if (g_VBoxUsbGlobal.hTimerQueue) 1575 1587 { 1576 bRc = DeleteTimerQueueEx(g_VBoxUsbGlobal.hTimerQueue,1588 fRc = DeleteTimerQueueEx(g_VBoxUsbGlobal.hTimerQueue, 1577 1589 INVALID_HANDLE_VALUE); /* <-- to block until all timers are completed */ 1578 AssertMsg( bRc, ("DeleteTimerQueueEx failed winEr(%d)\n", GetLastError()));1590 AssertMsg(fRc, ("DeleteTimerQueueEx failed dwErr(%d)\n", GetLastError())); 1579 1591 } 1580 1592 #endif /* VBOX_USB_USE_DEVICE_NOTIFICATION */ 1581 1593 1582 bRc = CloseHandle(g_VBoxUsbGlobal.hMonitor);1583 AssertMsg( bRc, ("CloseHandle for hMonitor failed winEr(%d)\n", GetLastError()));1594 fRc = CloseHandle(g_VBoxUsbGlobal.hMonitor); 1595 AssertMsg(fRc, ("CloseHandle for hMonitor failed dwErr(%d)\n", GetLastError())); 1584 1596 g_VBoxUsbGlobal.hMonitor = INVALID_HANDLE_VALUE; 1585 1597 1586 bRc = CloseHandle(g_VBoxUsbGlobal.hInterruptEvent);1587 AssertMsg( bRc, ("CloseHandle for hInterruptEvent failed lasterr=%u\n", GetLastError()));1598 fRc = CloseHandle(g_VBoxUsbGlobal.hInterruptEvent); 1599 AssertMsg(fRc, ("CloseHandle for hInterruptEvent failed lasterr=%u\n", GetLastError())); 1588 1600 g_VBoxUsbGlobal.hInterruptEvent = NULL; 1589 1601 1590 bRc = CloseHandle(g_VBoxUsbGlobal.hNotifyEvent);1591 AssertMsg( bRc, ("CloseHandle for hNotifyEvent failed winEr(%d)\n", GetLastError()));1602 fRc = CloseHandle(g_VBoxUsbGlobal.hNotifyEvent); 1603 AssertMsg(fRc, ("CloseHandle for hNotifyEvent failed dwErr(%d)\n", GetLastError())); 1592 1604 g_VBoxUsbGlobal.hNotifyEvent = NULL; 1593 1605
Note:
See TracChangeset
for help on using the changeset viewer.