Changeset 38488 in vbox for trunk/src/VBox/HostDrivers/VBoxUSB/win/mon
- Timestamp:
- Aug 18, 2011 10:26:06 AM (13 years ago)
- Location:
- trunk/src/VBox/HostDrivers/VBoxUSB/win/mon
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbFlt.cpp
r38436 r38488 403 403 if (pDevDr == NULL) 404 404 { 405 WARN(("Failed to alloc mem for urb \n"));405 WARN(("Failed to alloc mem for urb")); 406 406 return STATUS_INSUFFICIENT_RESOURCES; 407 407 } … … 412 412 if (!NT_SUCCESS(Status)) 413 413 { 414 WARN(("getting device descriptor failed, Status (0x%x) \n", Status));414 WARN(("getting device descriptor failed, Status (0x%x)", Status)); 415 415 break; 416 416 } … … 418 418 if (vboxUsbFltBlDevMatchLocked(pDevDr->idVendor, pDevDr->idProduct, pDevDr->bcdDevice)) 419 419 { 420 WARN(("found a known black list device, vid(0x%x), pid(0x%x), rev(0x%x) \n", pDevDr->idVendor, pDevDr->idProduct, pDevDr->bcdDevice));420 WARN(("found a known black list device, vid(0x%x), pid(0x%x), rev(0x%x)", pDevDr->idVendor, pDevDr->idProduct, pDevDr->bcdDevice)); 421 421 Status = STATUS_UNSUCCESSFUL; 422 422 break; 423 423 } 424 424 425 LOG(("Device pid=%x vid=%x rev=%x \n", pDevDr->idVendor, pDevDr->idProduct, pDevDr->bcdDevice));425 LOG(("Device pid=%x vid=%x rev=%x", pDevDr->idVendor, pDevDr->idProduct, pDevDr->bcdDevice)); 426 426 pDevice->idVendor = pDevDr->idVendor; 427 427 pDevice->idProduct = pDevDr->idProduct; … … 442 442 if (!NT_SUCCESS(Status)) 443 443 { 444 WARN(("reading language ID failed \n"));444 WARN(("reading language ID failed")); 445 445 if (Status == STATUS_CANCELLED) 446 446 { 447 WARN(("found a new black list device, vid(0x%x), pid(0x%x), rev(0x%x) \n", pDevDr->idVendor, pDevDr->idProduct, pDevDr->bcdDevice));447 WARN(("found a new black list device, vid(0x%x), pid(0x%x), rev(0x%x)", pDevDr->idVendor, pDevDr->idProduct, pDevDr->bcdDevice)); 448 448 vboxUsbFltBlDevAddLocked(pDevDr->idVendor, pDevDr->idProduct, pDevDr->bcdDevice); 449 449 Status = STATUS_UNSUCCESSFUL; … … 457 457 if (!NT_SUCCESS(Status)) 458 458 { 459 WARN(("reading serial number failed \n"));459 WARN(("reading serial number failed")); 460 460 ASSERT_WARN(pDevice->szSerial[0] == '\0', ("serial is not zero!!")); 461 461 if (Status == STATUS_CANCELLED) 462 462 { 463 WARN(("found a new black list device, vid(0x%x), pid(0x%x), rev(0x%x) \n", pDevDr->idVendor, pDevDr->idProduct, pDevDr->bcdDevice));463 WARN(("found a new black list device, vid(0x%x), pid(0x%x), rev(0x%x)", pDevDr->idVendor, pDevDr->idProduct, pDevDr->bcdDevice)); 464 464 vboxUsbFltBlDevAddLocked(pDevDr->idVendor, pDevDr->idProduct, pDevDr->bcdDevice); 465 465 Status = STATUS_UNSUCCESSFUL; … … 476 476 if (!NT_SUCCESS(Status)) 477 477 { 478 WARN(("reading manufacturer name failed \n"));478 WARN(("reading manufacturer name failed")); 479 479 ASSERT_WARN(pDevice->szMfgName[0] == '\0', ("szMfgName is not zero!!")); 480 480 if (Status == STATUS_CANCELLED) 481 481 { 482 WARN(("found a new black list device, vid(0x%x), pid(0x%x), rev(0x%x) \n", pDevDr->idVendor, pDevDr->idProduct, pDevDr->bcdDevice));482 WARN(("found a new black list device, vid(0x%x), pid(0x%x), rev(0x%x)", pDevDr->idVendor, pDevDr->idProduct, pDevDr->bcdDevice)); 483 483 vboxUsbFltBlDevAddLocked(pDevDr->idVendor, pDevDr->idProduct, pDevDr->bcdDevice); 484 484 Status = STATUS_UNSUCCESSFUL; … … 495 495 if (!NT_SUCCESS(Status)) 496 496 { 497 WARN(("reading product name failed \n"));497 WARN(("reading product name failed")); 498 498 ASSERT_WARN(pDevice->szProduct[0] == '\0', ("szProduct is not zero!!")); 499 499 if (Status == STATUS_CANCELLED) 500 500 { 501 WARN(("found a new black list device, vid(0x%x), pid(0x%x), rev(0x%x) \n", pDevDr->idVendor, pDevDr->idProduct, pDevDr->bcdDevice));501 WARN(("found a new black list device, vid(0x%x), pid(0x%x), rev(0x%x)", pDevDr->idVendor, pDevDr->idProduct, pDevDr->bcdDevice)); 502 502 vboxUsbFltBlDevAddLocked(pDevDr->idVendor, pDevDr->idProduct, pDevDr->bcdDevice); 503 503 Status = STATUS_UNSUCCESSFUL; … … 521 521 if (!NT_SUCCESS(Status)) 522 522 { 523 AssertMsgFailed((__FUNCTION__": IoGetDeviceProperty failed Status (0x%x) \n", Status));523 AssertMsgFailed((__FUNCTION__": IoGetDeviceProperty failed Status (0x%x)", Status)); 524 524 break; 525 525 } … … 535 535 if (!NT_SUCCESS(Status)) 536 536 { 537 AssertMsgFailed((__FUNCTION__": RtlUnicodeStringToAnsiString failed Status (0x%x) \n", Status));537 AssertMsgFailed((__FUNCTION__": RtlUnicodeStringToAnsiString failed Status (0x%x)", Status)); 538 538 break; 539 539 } … … 543 543 if (!NT_SUCCESS(Status)) 544 544 { 545 AssertMsgFailed((__FUNCTION__": VBoxUsbToolGetDeviceSpeed failed Status (0x%x) \n", Status));545 AssertMsgFailed((__FUNCTION__": VBoxUsbToolGetDeviceSpeed failed Status (0x%x)", Status)); 546 546 break; 547 547 } 548 548 } 549 549 #endif 550 LOG((": strings: '%s':'%s':'%s' (lang ID %x) \n",550 LOG((": strings: '%s':'%s':'%s' (lang ID %x)", 551 551 pDevice->szMfgName, pDevice->szProduct, pDevice->szSerial, langId)); 552 552 } … … 754 754 } 755 755 756 typedef struct VBOXUSBFLTCHECKWALKER 757 { 758 PVBOXUSBFLTCTX pContext; 759 } VBOXUSBFLTCHECKWALKER, *PVBOXUSBFLTCHECKWALKER; 760 761 static DECLCALLBACK(BOOLEAN) vboxUsbFltFilterCheckWalker(PFILE_OBJECT pFile, PDEVICE_OBJECT pTopDo, PDEVICE_OBJECT pHubDo, PVOID pvContext) 762 { 763 PVBOXUSBFLTCHECKWALKER pData = (PVBOXUSBFLTCHECKWALKER)pvContext; 764 PVBOXUSBFLTCTX pContext = pData->pContext; 765 766 LOG(("Visiting pFile(0x%p), pTopDo(0x%p), pHubDo(0x%p), oContext(0x%p)", pFile, pTopDo, pHubDo, pContext)); 767 KIRQL Irql = KeGetCurrentIrql(); 768 ASSERT_WARN(Irql == PASSIVE_LEVEL, ("unexpected IRQL (%d)", Irql)); 769 770 771 772 PDEVICE_RELATIONS pDevRelations = NULL; 773 774 NTSTATUS Status = VBoxUsbMonQueryBusRelations(pTopDo, pFile, &pDevRelations); 775 if (Status == STATUS_SUCCESS && pDevRelations) 776 { 777 ULONG cReplugPdos = pDevRelations->Count; 778 LIST_ENTRY ReplugDevList; 779 InitializeListHead(&ReplugDevList); 780 for (ULONG k = 0; k < pDevRelations->Count; ++k) 781 { 782 PDEVICE_OBJECT pDevObj = pDevRelations->Objects[k]; 783 784 LOG(("Found existing USB PDO 0x%p", pDevObj)); 785 VBOXUSBFLT_LOCK_ACQUIRE(); 786 PVBOXUSBFLT_DEVICE pDevice = vboxUsbFltDevGetLocked(pDevObj); 787 if (pDevice) 788 { 789 LOG(("Found existing device info (0x%p) for PDO 0x%p", pDevice, pDevObj)); 790 bool bReplug = vboxUsbFltDevCheckReplugLocked(pDevice, pContext); 791 if (bReplug) 792 { 793 LOG(("Replug needed for device (0x%p)", pDevice)); 794 InsertHeadList(&ReplugDevList, &pDevice->RepluggingLe); 795 vboxUsbFltDevRetain(pDevice); 796 /* do not dereference object since we will use it later */ 797 } 798 else 799 { 800 LOG(("Replug NOT needed for device (0x%p)", pDevice)); 801 ObDereferenceObject(pDevObj); 802 } 803 804 VBOXUSBFLT_LOCK_RELEASE(); 805 806 pDevRelations->Objects[k] = NULL; 807 --cReplugPdos; 808 ASSERT_WARN((uint32_t)cReplugPdos < UINT32_MAX/2, ("cReplugPdos(%d) state broken", cReplugPdos)); 809 continue; 810 } 811 VBOXUSBFLT_LOCK_RELEASE(); 812 813 LOG(("NO device info found for PDO 0x%p", pDevObj)); 814 VBOXUSBFLT_DEVICE Device; 815 Status = vboxUsbFltDevPopulate(&Device, pDevObj /*, FALSE /* only need filter properties */); 816 if (NT_SUCCESS(Status)) 817 { 818 uintptr_t uId = 0; 819 bool fFilter = false; 820 bool fIsOneShot = false; 821 VBOXUSBFLT_LOCK_ACQUIRE(); 822 PVBOXUSBFLTCTX pCtx = vboxUsbFltDevMatchLocked(&Device, &uId, 823 false, /* do not remove a one-shot filter */ 824 &fFilter, &fIsOneShot); 825 VBOXUSBFLT_LOCK_RELEASE(); 826 LOG(("Matching Info: Filter (0x%p), pCtx(0x%p), fFilter(%d), fIsOneShot(%d)", uId, pCtx, (int)fFilter, (int)fIsOneShot)); 827 if (fFilter) 828 { 829 LOG(("Matching: This device SHOULD be filtered")); 830 /* this device needs to be filtered, but it's not, 831 * leave the PDO in array to issue a replug request for it 832 * later on */ 833 continue; 834 } 835 } 836 else 837 { 838 WARN(("vboxUsbFltDevPopulate for PDO 0x%p failed with Status 0x%x", pDevObj, Status)); 839 } 840 841 LOG(("Matching: This device should NOT be filtered")); 842 /* this device should not be filtered, and it's not */ 843 ObDereferenceObject(pDevObj); 844 pDevRelations->Objects[k] = NULL; 845 --cReplugPdos; 846 ASSERT_WARN((uint32_t)cReplugPdos < UINT32_MAX/2, ("cReplugPdos is %d", cReplugPdos)); 847 } 848 849 LOG(("(%d) non-matched PDOs to be replugged", cReplugPdos)); 850 851 if (cReplugPdos) 852 { 853 for (ULONG k = 0; k < pDevRelations->Count; ++k) 854 { 855 if (!pDevRelations->Objects[k]) 856 continue; 857 858 Status = vboxUsbFltPdoReplug(pDevRelations->Objects[k]); 859 ASSERT_WARN(Status == STATUS_SUCCESS, ("vboxUsbFltPdoReplug ailed Status(0x%x)", Status)); 860 ObDereferenceObject(pDevRelations->Objects[k]); 861 if (!--cReplugPdos) 862 break; 863 } 864 865 ASSERT_WARN(!cReplugPdos, ("cReplugPdosreached zero!")); 866 } 867 868 vboxUsbFltReplugList(&ReplugDevList); 869 870 ExFreePool(pDevRelations); 871 } 872 else 873 { 874 WARN(("VBoxUsbMonQueryBusRelations failed for DO(0x%p), Status(0x%x), pDevRelations(0x%p)", 875 pTopDo, Status, pDevRelations)); 876 } 877 878 LOG(("Done Visiting pFile(0x%p), pTopDo(0x%p), pHubDo(0x%p), oContext(0x%p)", pFile, pTopDo, pHubDo, pContext)); 879 880 return TRUE; 881 } 882 756 883 NTSTATUS VBoxUsbFltFilterCheck(PVBOXUSBFLTCTX pContext) 757 884 { 758 NTSTATUS Status;759 UNICODE_STRING szStandardControllerName[RT_ELEMENTS(lpszStandardControllerName)];760 885 KIRQL Irql = KeGetCurrentIrql(); 761 A ssert(Irql == PASSIVE_LEVEL);886 ASSERT_WARN(Irql == PASSIVE_LEVEL, ("unexpected IRQL (%d)", Irql)); 762 887 763 888 LOG(("Running filters, Context (0x%p)..", pContext)); 764 889 765 for (int i=0;i<RT_ELEMENTS(lpszStandardControllerName);i++) 766 { 767 szStandardControllerName[i].Length = 0; 768 szStandardControllerName[i].MaximumLength = 0; 769 szStandardControllerName[i].Buffer = 0; 770 771 RtlInitUnicodeString(&szStandardControllerName[i], lpszStandardControllerName[i]); 772 } 773 774 for (int i = 0; i < 16; i++) 775 { 776 char szHubName[32]; 777 WCHAR szwHubName[32]; 778 UNICODE_STRING UnicodeName; 779 ANSI_STRING AnsiName; 780 PDEVICE_OBJECT pHubDevObj; 781 PFILE_OBJECT pHubFileObj; 782 783 sprintf(szHubName, "\\Device\\USBPDO-%d", i); 784 785 UnicodeName.Length = 0; 786 UnicodeName.MaximumLength = sizeof (szwHubName); 787 UnicodeName.Buffer = szwHubName; 788 789 RtlInitAnsiString(&AnsiName, szHubName); 790 RtlAnsiStringToUnicodeString(&UnicodeName, &AnsiName, FALSE); 791 792 Status = IoGetDeviceObjectPointer(&UnicodeName, FILE_READ_DATA, &pHubFileObj, &pHubDevObj); 793 if (Status == STATUS_SUCCESS) 794 { 795 LOG(("IoGetDeviceObjectPointer for %s returned %p %p\n", szHubName, pHubDevObj, pHubFileObj)); 796 797 if (pHubDevObj->DriverObject 798 && pHubDevObj->DriverObject->DriverName.Buffer 799 && pHubDevObj->DriverObject->DriverName.Length 800 ) 801 { 802 for (int j = 0; j < RT_ELEMENTS(lpszStandardControllerName); ++j) 803 { 804 if (!RtlCompareUnicodeString(&szStandardControllerName[j], &pHubDevObj->DriverObject->DriverName, TRUE /* case insensitive */)) 805 { 806 PDEVICE_RELATIONS pDevRelations = NULL; 807 808 LOG(("Flt Associated driver ")); 809 LOG_USTR(&pHubDevObj->DriverObject->DriverName); 810 LOG((" -> related dev obj=0x%p", pHubDevObj)); 811 812 Status = VBoxUsbMonQueryBusRelations(pHubDevObj, pHubFileObj, &pDevRelations); 813 if (Status == STATUS_SUCCESS && pDevRelations) 814 { 815 ULONG cReplugPdos = pDevRelations->Count; 816 LIST_ENTRY ReplugDevList; 817 InitializeListHead(&ReplugDevList); 818 for (ULONG k = 0; k < pDevRelations->Count; ++k) 819 { 820 PDEVICE_OBJECT pDevObj = pDevRelations->Objects[k]; 821 822 LOG(("Found existing USB PDO 0x%p", pDevObj)); 823 VBOXUSBFLT_LOCK_ACQUIRE(); 824 PVBOXUSBFLT_DEVICE pDevice = vboxUsbFltDevGetLocked(pDevObj); 825 if (pDevice) 826 { 827 LOG(("Found existing device info (0x%p) for PDO 0x%p", pDevice, pDevObj)); 828 bool bReplug = vboxUsbFltDevCheckReplugLocked(pDevice, pContext); 829 if (bReplug) 830 { 831 LOG(("Replug needed for device (0x%p)", pDevice)); 832 InsertHeadList(&ReplugDevList, &pDevice->RepluggingLe); 833 vboxUsbFltDevRetain(pDevice); 834 /* do not dereference object since we will use it later */ 835 } 836 else 837 { 838 LOG(("Replug NOT needed for device (0x%p)", pDevice)); 839 ObDereferenceObject(pDevObj); 840 } 841 842 VBOXUSBFLT_LOCK_RELEASE(); 843 844 pDevRelations->Objects[k] = NULL; 845 --cReplugPdos; 846 ASSERT_WARN((uint32_t)cReplugPdos < UINT32_MAX/2, ("cReplugPdos(%d) state broken", cReplugPdos)); 847 continue; 848 } 849 VBOXUSBFLT_LOCK_RELEASE(); 850 851 LOG(("NO device info found for PDO 0x%p", pDevObj)); 852 VBOXUSBFLT_DEVICE Device; 853 Status = vboxUsbFltDevPopulate(&Device, pDevObj /*, FALSE /* only need filter properties */); 854 if (NT_SUCCESS(Status)) 855 { 856 uintptr_t uId = 0; 857 bool fFilter = false; 858 bool fIsOneShot = false; 859 VBOXUSBFLT_LOCK_ACQUIRE(); 860 PVBOXUSBFLTCTX pCtx = vboxUsbFltDevMatchLocked(&Device, &uId, 861 false, /* do not remove a one-shot filter */ 862 &fFilter, &fIsOneShot); 863 VBOXUSBFLT_LOCK_RELEASE(); 864 LOG(("Matching Info: Filter (0x%p), pCtx(0x%p), fFilter(%d), fIsOneShot(%d)", uId, pCtx, (int)fFilter, (int)fIsOneShot)); 865 if (fFilter) 866 { 867 LOG(("Matching: This device SHOULD be filtered")); 868 /* this device needs to be filtered, but it's not, 869 * leave the PDO in array to issue a replug request for it 870 * later on */ 871 continue; 872 } 873 } 874 else 875 { 876 WARN(("vboxUsbFltDevPopulate for PDO 0x%p failed with Status 0x%x", pDevObj, Status)); 877 } 878 879 LOG(("Matching: This device should NOT be filtered")); 880 /* this device should not be filtered, and it's not */ 881 ObDereferenceObject(pDevObj); 882 pDevRelations->Objects[k] = NULL; 883 --cReplugPdos; 884 ASSERT_WARN((uint32_t)cReplugPdos < UINT32_MAX/2, ("cReplugPdos is %d", cReplugPdos)); 885 } 886 887 LOG(("(%d) non-matched PDOs to be replugged", cReplugPdos)); 888 889 if (cReplugPdos) 890 { 891 for (ULONG k = 0; k < pDevRelations->Count; ++k) 892 { 893 if (!pDevRelations->Objects[k]) 894 continue; 895 896 Status = vboxUsbFltPdoReplug(pDevRelations->Objects[k]); 897 ASSERT_WARN(Status == STATUS_SUCCESS, ("vboxUsbFltPdoReplug ailed Status(0x%x)", Status)); 898 ObDereferenceObject(pDevRelations->Objects[k]); 899 if (!--cReplugPdos) 900 break; 901 } 902 903 ASSERT_WARN(!cReplugPdos, ("cReplugPdosreached zero!")); 904 } 905 906 vboxUsbFltReplugList(&ReplugDevList); 907 908 ExFreePool(pDevRelations); 909 } 910 else 911 { 912 WARN(("VBoxUsbMonQueryBusRelations failed for DO(0x%p), Status(0x%x), pDevRelations(0x%p)", 913 pHubDevObj, Status, pDevRelations)); 914 } 915 } 916 else 917 { 918 LOG(("driver name not match, was:")); 919 LOG_USTR(&pHubDevObj->DriverObject->DriverName); 920 LOG(("but expected:")); 921 LOG_USTR(&szStandardControllerName[j]); 922 } 923 } 924 } 925 else 926 { 927 LOG(("null driver object (0x%p) or name buffer (0x%p), length(%d)", pHubDevObj->DriverObject, 928 pHubDevObj->DriverObject ? pHubDevObj->DriverObject->DriverName.Buffer : NULL, 929 pHubDevObj->DriverObject ? pHubDevObj->DriverObject->DriverName.Length : 0)); 930 } 931 ObDereferenceObject(pHubFileObj); 932 } 933 } 890 VBOXUSBFLTCHECKWALKER Data; 891 Data.pContext = pContext; 892 vboxUsbMonHubDevWalk(vboxUsbFltFilterCheckWalker, &Data, VBOXUSBMONHUBWALK_F_FDO); 934 893 935 894 LOG(("DONE Running filters, Context (0x%p)", pContext)); … … 1029 988 *pId = 0; 1030 989 /* LOG the filter details. */ 1031 LOG((__FUNCTION__": %s %s %s \n",990 LOG((__FUNCTION__": %s %s %s", 1032 991 USBFilterGetString(pFilter, USBFILTERIDX_MANUFACTURER_STR) ? USBFilterGetString(pFilter, USBFILTERIDX_MANUFACTURER_STR) : "<null>", 1033 992 USBFilterGetString(pFilter, USBFILTERIDX_PRODUCT_STR) ? USBFilterGetString(pFilter, USBFILTERIDX_PRODUCT_STR) : "<null>", 1034 993 USBFilterGetString(pFilter, USBFILTERIDX_SERIAL_NUMBER_STR) ? USBFilterGetString(pFilter, USBFILTERIDX_SERIAL_NUMBER_STR) : "<null>")); 1035 994 #ifdef VBOX_USB_WITH_VERBOSE_LOGGING 1036 LOG(("VBoxUSBClient::addFilter: idVendor=%#x idProduct=%#x bcdDevice=%#x bDeviceClass=%#x bDeviceSubClass=%#x bDeviceProtocol=%#x bBus=%#x bPort=%#x Type%#x \n",995 LOG(("VBoxUSBClient::addFilter: idVendor=%#x idProduct=%#x bcdDevice=%#x bDeviceClass=%#x bDeviceSubClass=%#x bDeviceProtocol=%#x bBus=%#x bPort=%#x Type%#x", 1037 996 USBFilterGetNum(pFilter, USBFILTERIDX_VENDOR_ID), 1038 997 USBFilterGetNum(pFilter, USBFILTERIDX_PRODUCT_ID), … … 1394 1353 { 1395 1354 pDevice->enmState = VBOXUSBFLT_DEVSTATE_CAPTURED; 1396 LOG(("The proxy notified proxy start for the captured device 0x%x \n", pDevice));1355 LOG(("The proxy notified proxy start for the captured device 0x%x", pDevice)); 1397 1356 vboxUsbFltDevRetain(pDevice); 1398 1357 vboxUsbFltSignalChangeLocked(); … … 1415 1374 { 1416 1375 /* this is due to devie was physically removed */ 1417 LOG(("The proxy notified proxy stop for the captured device 0x%x, current state %d \n", pDevice, pDevice->enmState));1376 LOG(("The proxy notified proxy stop for the captured device 0x%x, current state %d", pDevice, pDevice->enmState)); 1418 1377 pDevice->enmState = VBOXUSBFLT_DEVSTATE_CAPTURING; 1419 1378 vboxUsbFltSignalChangeLocked(); -
trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.cpp
r38425 r38488 102 102 case _t: return #_t 103 103 #define VBOXUSBDBG_STRCASE_UNKNOWN(_v) \ 104 default: LOG((__FUNCTION__": Unknown Value (0n%d), (0x%x) \n", _v, _v)); return "Unknown"104 default: LOG((__FUNCTION__": Unknown Value (0n%d), (0x%x)", _v, _v)); return "Unknown" 105 105 106 106 static const char* vboxUsbDbgStrPnPMn(UCHAR uMn) … … 168 168 if (!pIrp) 169 169 { 170 WARN(("IoBuildDeviceIoControlRequest failed!! \n"));170 WARN(("IoBuildDeviceIoControlRequest failed!!")); 171 171 return STATUS_INSUFFICIENT_RESOURCES; 172 172 } … … 182 182 if (Status == STATUS_PENDING) 183 183 { 184 LOG(("IoCallDriver returned STATUS_PENDING!! \n"));184 LOG(("IoCallDriver returned STATUS_PENDING!!")); 185 185 KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); 186 186 Status = IoStatus.Status; … … 190 190 { 191 191 PDEVICE_RELATIONS pRel = (PDEVICE_RELATIONS)IoStatus.Information; 192 LOG(("pRel = %p \n", pRel));192 LOG(("pRel = %p", pRel)); 193 193 if (VALID_PTR(pRel)) 194 194 { … … 197 197 else 198 198 { 199 WARN(("Invalid pointer %p \n", pRel));199 WARN(("Invalid pointer %p", pRel)); 200 200 } 201 201 } 202 202 else 203 203 { 204 WARN(("IRP_MN_QUERY_DEVICE_RELATIONS failed Status(0x%x) \n", Status));205 } 206 207 LOG(("IoCallDriver returned %x \n", Status));204 WARN(("IRP_MN_QUERY_DEVICE_RELATIONS failed Status(0x%x)", Status)); 205 } 206 207 LOG(("IoCallDriver returned %x", Status)); 208 208 return Status; 209 209 } 210 210 211 static PDRIVER_OBJECT vboxUsbMonHookFindHubDrvObj() 211 RT_C_DECLS_BEGIN 212 /* these two come from IFS Kit, which is not included in 2K DDK we use, 213 * although they are documented and exported in ntoskrnl, 214 * and both should be present for >= XP according to MSDN */ 215 NTKERNELAPI 216 NTSTATUS 217 ObQueryNameString( 218 __in PVOID Object, 219 __out_bcount_opt(Length) POBJECT_NAME_INFORMATION ObjectNameInfo, 220 __in ULONG Length, 221 __out PULONG ReturnLength 222 ); 223 224 NTKERNELAPI 225 PDEVICE_OBJECT 226 IoGetLowerDeviceObject( 227 __in PDEVICE_OBJECT DeviceObject 228 ); 229 230 RT_C_DECLS_END 231 232 typedef DECLCALLBACK(VOID) FNVBOXUSBDEVNAMEMATCHER(PDEVICE_OBJECT pDo, PUNICODE_STRING pName, PVOID pvMatcher); 233 typedef FNVBOXUSBDEVNAMEMATCHER *PFNVBOXUSBDEVNAMEMATCHER; 234 235 static NTSTATUS vboxUsbObjCheckName(PDEVICE_OBJECT pDo, PFNVBOXUSBDEVNAMEMATCHER pfnMatcher, PVOID pvMatcher) 236 { 237 union 238 { 239 OBJECT_NAME_INFORMATION Info; 240 char buf[1024]; 241 } buf; 242 ULONG cbLength = 0; 243 244 POBJECT_NAME_INFORMATION pInfo = &buf.Info; 245 NTSTATUS Status = ObQueryNameString(pDo, &buf.Info, sizeof (buf), &cbLength); 246 if (!NT_SUCCESS(Status)) 247 { 248 if (STATUS_INFO_LENGTH_MISMATCH != Status) 249 { 250 WARN(("ObQueryNameString failed 0x%x", Status)); 251 return Status; 252 } 253 254 LOG(("ObQueryNameString returned STATUS_INFO_LENGTH_MISMATCH, required size %d", cbLength)); 255 256 pInfo = (POBJECT_NAME_INFORMATION)VBoxUsbMonMemAlloc(cbLength); 257 if (!pInfo) 258 { 259 WARN(("VBoxUsbMonMemAlloc failed")); 260 return STATUS_NO_MEMORY; 261 } 262 Status = ObQueryNameString(pDo, pInfo, cbLength, &cbLength); 263 if (!NT_SUCCESS(Status)) 264 { 265 WARN(("ObQueryNameString second try failed 0x%x", Status)); 266 VBoxUsbMonMemFree(pInfo); 267 return Status; 268 } 269 } 270 271 /* we've got the name! */ 272 LOG(("got the name:")); 273 LOG_USTR(&pInfo->Name); 274 pfnMatcher(pDo, &pInfo->Name, pvMatcher); 275 276 if (&buf.Info != pInfo) 277 { 278 LOG(("freeing allocated pInfo(0x%p)", pInfo)); 279 VBoxUsbMonMemFree(pInfo); 280 } 281 else 282 { 283 LOG(("no freeing info needed")); 284 } 285 286 return STATUS_SUCCESS; 287 } 288 289 290 typedef DECLCALLBACK(BOOLEAN) FNVBOXUSBDEVSTACKWALKER(PDEVICE_OBJECT pTopDo, PDEVICE_OBJECT pCurDo, PVOID pvContext); 291 typedef FNVBOXUSBDEVSTACKWALKER *PFNVBOXUSBDEVSTACKWALKER; 292 293 VOID vboxUsbObjDevStackWalk(PDEVICE_OBJECT pDo, PFNVBOXUSBDEVSTACKWALKER pfnWalker, PVOID pvWalker) 294 { 295 LOG(("==>tree walk for Do 0x%p", pDo)); 296 PDEVICE_OBJECT pCurDo = pDo; 297 ObReferenceObject(pCurDo); /* <- to make sure the dereferencing logic below works correctly */ 298 do 299 { 300 LOG(("==Do 0x%p", pCurDo)); 301 #ifdef VBOX_USB_WITH_VERBOSE_LOGGING 302 { 303 union 304 { 305 OBJECT_NAME_INFORMATION Info; 306 char buf[1024]; 307 } buf; 308 ULONG cbLength = 0; 309 310 NTSTATUS tmpStatus = ObQueryNameString(pCurDo, &buf.Info, sizeof (buf), &cbLength); 311 if (NT_SUCCESS(tmpStatus)) 312 { 313 LOG((" Obj name:")); 314 LOG_USTR(&buf.Info.Name); 315 } 316 else 317 { 318 if (STATUS_INFO_LENGTH_MISMATCH != tmpStatus) 319 { 320 WARN(("ObQueryNameString failed 0x%x", tmpStatus)); 321 } 322 else 323 { 324 WARN(("ObQueryNameString STATUS_INFO_LENGTH_MISMATCH, required %d", cbLength)); 325 } 326 } 327 328 if (pCurDo->DriverObject 329 && pCurDo->DriverObject->DriverName.Buffer 330 && pCurDo->DriverObject->DriverName.Length) 331 { 332 LOG((" Drv Obj(0x%p), name:", pCurDo->DriverObject)); 333 LOG_USTR(&pCurDo->DriverObject->DriverName); 334 } 335 else 336 { 337 LOG((" No Drv Name, Drv Obj(0x%p)", pCurDo->DriverObject)); 338 if (pCurDo->DriverObject) 339 { 340 LOG((" driver name is zero, Length(%d), Buffer(0x%p)", 341 pCurDo->DriverObject->DriverName.Length, pCurDo->DriverObject->DriverName.Buffer)); 342 } 343 else 344 { 345 LOG((" driver object is NULL")); 346 } 347 } 348 } 349 #endif 350 if (!pfnWalker(pDo, pCurDo, pvWalker)) 351 { 352 LOG(("the walker said to stop")); 353 ObDereferenceObject(pCurDo); 354 break; 355 } 356 357 PDEVICE_OBJECT pLowerDo = IoGetLowerDeviceObject(pCurDo); 358 ObDereferenceObject(pCurDo); 359 if (!pLowerDo) 360 { 361 LOG(("IoGetLowerDeviceObject returnned NULL, stop")); 362 break; 363 } 364 pCurDo = pLowerDo; 365 } while (1); 366 367 LOG(("<==tree walk")); 368 } 369 370 static DECLCALLBACK(BOOLEAN) vboxUsbObjNamePrefixMatch(PUNICODE_STRING pName, PUNICODE_STRING pNamePrefix, BOOLEAN fCaseInSensitive) 371 { 372 LOG(("Matching prefix:")); 373 LOG_USTR(pNamePrefix); 374 if (pNamePrefix->Length > pName->Length) 375 { 376 LOG(("Pregix Length(%d) > Name Length(%d)", pNamePrefix->Length, pName->Length)); 377 return FALSE; 378 } 379 380 LOG(("Pregix Length(%d) <= Name Length(%d)", pNamePrefix->Length, pName->Length)); 381 382 UNICODE_STRING NamePrefix = *pName; 383 NamePrefix.Length = pNamePrefix->Length; 384 LONG rc = RtlCompareUnicodeString(&NamePrefix, pNamePrefix, fCaseInSensitive); 385 386 if (!rc) 387 { 388 LOG(("prefix MATCHED!")); 389 return TRUE; 390 } 391 392 LOG(("prefix NOT matched!")); 393 return FALSE; 394 } 395 396 typedef struct VBOXUSBOBJNAMEPREFIXMATCHER 397 { 398 PUNICODE_STRING pNamePrefix; 399 BOOLEAN fMatched; 400 } VBOXUSBOBJNAMEPREFIXMATCHER, *PVBOXUSBOBJNAMEPREFIXMATCHER; 401 402 static DECLCALLBACK(VOID) vboxUsbObjDevNamePrefixMatcher(PDEVICE_OBJECT pDo, PUNICODE_STRING pName, PVOID pvMatcher) 403 { 404 PVBOXUSBOBJNAMEPREFIXMATCHER pData = (PVBOXUSBOBJNAMEPREFIXMATCHER)pvMatcher; 405 PUNICODE_STRING pNamePrefix = pData->pNamePrefix; 406 ASSERT_WARN(!pData->fMatched, ("match flag already set!")); 407 pData->fMatched = vboxUsbObjNamePrefixMatch(pName, pNamePrefix, TRUE /* fCaseInSensitive */); 408 LOG(("match result (%d)", (int)pData->fMatched)); 409 } 410 411 typedef struct VBOXUSBOBJDRVOBJSEARCHER 412 { 413 PDEVICE_OBJECT pDevObj; 414 PUNICODE_STRING pDrvName; 415 PUNICODE_STRING pPdoNamePrefix; 416 ULONG fFlags; 417 } VBOXUSBOBJDRVOBJSEARCHER, *PVBOXUSBOBJDRVOBJSEARCHER; 418 419 static DECLCALLBACK(BOOLEAN) vboxUsbObjDevObjSearcherWalker(PDEVICE_OBJECT pTopDo, PDEVICE_OBJECT pCurDo, PVOID pvContext) 420 { 421 PVBOXUSBOBJDRVOBJSEARCHER pData = (PVBOXUSBOBJDRVOBJSEARCHER)pvContext; 422 ASSERT_WARN(!pData->pDevObj, ("non-null dev object (0x%p) on enter", pData->pDevObj)); 423 pData->pDevObj = NULL; 424 if (pCurDo->DriverObject 425 && pCurDo->DriverObject->DriverName.Buffer 426 && pCurDo->DriverObject->DriverName.Length 427 && !RtlCompareUnicodeString(pData->pDrvName, &pCurDo->DriverObject->DriverName, TRUE /* case insensitive */)) 428 { 429 LOG(("MATCHED driver:")); 430 LOG_USTR(&pCurDo->DriverObject->DriverName); 431 if ((pData->fFlags & VBOXUSBMONHUBWALK_F_ALL) != VBOXUSBMONHUBWALK_F_ALL) 432 { 433 VBOXUSBOBJNAMEPREFIXMATCHER Data = {0}; 434 Data.pNamePrefix = pData->pPdoNamePrefix; 435 NTSTATUS Status = vboxUsbObjCheckName(pCurDo, vboxUsbObjDevNamePrefixMatcher, &Data); 436 if (!NT_SUCCESS(Status)) 437 { 438 WARN(("vboxUsbObjCheckName failed Status (0x%x)", Status)); 439 return TRUE; 440 } 441 442 443 LOG(("prefix match result (%d)", Data.fMatched)); 444 if ((pData->fFlags & VBOXUSBMONHUBWALK_F_FDO) == VBOXUSBMONHUBWALK_F_FDO) 445 { 446 LOG(("VBOXUSBMONHUBWALK_F_FDO")); 447 if (Data.fMatched) 448 { 449 LOG(("this is a PDO object, skip it and stop search")); 450 /* stop search as we will not find FDO here */ 451 return FALSE; 452 } 453 454 LOG(("this is a FDO object, MATCHED!!")); 455 } 456 else if ((pData->fFlags & VBOXUSBMONHUBWALK_F_PDO) == VBOXUSBMONHUBWALK_F_PDO) 457 { 458 LOG(("VBOXUSBMONHUBWALK_F_PDO")); 459 if (!Data.fMatched) 460 { 461 LOG(("this is a FDO object, skip it and continue search")); 462 /* continue seach since since this could be a nested hub that would have a usbhub-originated PDO */ 463 return TRUE; 464 } 465 466 LOG(("this is a PDO object, MATCHED!!")); 467 } 468 469 } 470 else 471 { 472 LOG(("VBOXUSBMONHUBWALK_F_ALL")); 473 LOG(("either PDO or FDO, MATCHED!!")); 474 } 475 476 /* ensure the dev object is not destroyed */ 477 ObReferenceObject(pCurDo); 478 pData->pDevObj = pCurDo; 479 /* we are done */ 480 return FALSE; 481 } 482 else 483 { 484 LOG(("driver object (0x%p) no match", pCurDo->DriverObject)); 485 if (pCurDo->DriverObject) 486 { 487 if ( pCurDo->DriverObject->DriverName.Buffer 488 && pCurDo->DriverObject->DriverName.Length) 489 { 490 LOG(("driver name not match, was:")); 491 LOG_USTR(&pCurDo->DriverObject->DriverName); 492 LOG(("but expected:")); 493 LOG_USTR(pData->pDrvName); 494 } 495 else 496 { 497 LOG(("driver name is zero, Length(%d), Buffer(0x%p)", 498 pCurDo->DriverObject->DriverName.Length, pCurDo->DriverObject->DriverName.Buffer)); 499 } 500 } 501 else 502 { 503 LOG(("driver object is NULL")); 504 } 505 } 506 return TRUE; 507 } 508 509 VOID vboxUsbMonHubDevWalk(PFNVBOXUSBMONDEVWALKER pfnWalker, PVOID pvWalker, ULONG fFlags) 212 510 { 213 511 NTSTATUS Status = STATUS_UNSUCCESSFUL; … … 218 516 szStandardHubName.Buffer = 0; 219 517 RtlInitUnicodeString(&szStandardHubName, L"\\Driver\\usbhub"); 220 221 LOG(("Search USB hub\n")); 518 UNICODE_STRING szStandardHubPdoNamePrefix; 519 szStandardHubPdoNamePrefix.Length = 0; 520 szStandardHubPdoNamePrefix.MaximumLength = 0; 521 szStandardHubPdoNamePrefix.Buffer = 0; 522 RtlInitUnicodeString(&szStandardHubPdoNamePrefix, L"\\Device\\USBPDO-"); 523 222 524 for (int i = 0; i < 16; i++) 223 525 { 224 WCHAR szwHubName[32] = { };225 char szHubName[32] = { };526 WCHAR szwHubName[32] = {0}; 527 char szHubName[32] = {0}; 226 528 ANSI_STRING AnsiName; 227 529 UNICODE_STRING UnicodeName; … … 244 546 if (Status == STATUS_SUCCESS) 245 547 { 246 LOG(("IoGetDeviceObjectPointer for %S returned %p %p\n", szwHubName, pHubDevObj, pHubFileObj)); 247 248 if (pHubDevObj->DriverObject 249 && pHubDevObj->DriverObject->DriverName.Buffer 250 && pHubDevObj->DriverObject->DriverName.Length 251 && !RtlCompareUnicodeString(&szStandardHubName, &pHubDevObj->DriverObject->DriverName, TRUE /* case insensitive */)) 548 LOG(("IoGetDeviceObjectPointer for %S returned %p %p", szwHubName, pHubDevObj, pHubFileObj)); 549 550 VBOXUSBOBJDRVOBJSEARCHER Data = {0}; 551 Data.pDrvName = &szStandardHubName; 552 Data.pPdoNamePrefix = &szStandardHubPdoNamePrefix; 553 Data.fFlags = fFlags; 554 555 vboxUsbObjDevStackWalk(pHubDevObj, vboxUsbObjDevObjSearcherWalker, &Data); 556 if (Data.pDevObj) 252 557 { 253 LOG(("Associated driver")); 254 LOG_USTR(&pHubDevObj->DriverObject->DriverName); 255 LOG(("pnp handler %p\n", pHubDevObj->DriverObject->MajorFunction[IRP_MJ_PNP])); 256 257 pDrvObj = pHubDevObj->DriverObject; 258 /* ensure the driver object is not destroyed */ 259 ObReferenceObject(pDrvObj); 260 /* release the file object which will releade the dev objectas well, 261 * as we do not need those anymore */ 262 ObDereferenceObject(pHubFileObj); 263 break; 558 LOG(("found hub dev obj (0x%p)", Data.pDevObj)); 559 if (!pfnWalker(pHubFileObj, pHubDevObj, Data.pDevObj, pvWalker)) 560 { 561 LOG(("the walker said to stop")); 562 ObDereferenceObject(Data.pDevObj); 563 break; 564 } 565 566 LOG(("going forward..")); 567 ObDereferenceObject(Data.pDevObj); 264 568 } 265 569 else 266 570 { 267 LOG(("driver object (0x%p) no match", pHubDevObj->DriverObject)); 268 if (pHubDevObj->DriverObject) 269 { 270 if ( pHubDevObj->DriverObject->DriverName.Buffer 271 && pHubDevObj->DriverObject->DriverName.Length) 272 { 273 LOG(("driver name not match, was:")); 274 LOG_USTR(&pHubDevObj->DriverObject->DriverName); 275 LOG(("but expected:")); 276 LOG_USTR(&szStandardHubName); 277 } 278 else 279 { 280 LOG(("driver name is zero, Length(%d), Buffer(0x%p)", 281 pHubDevObj->DriverObject->DriverName.Length, pHubDevObj->DriverObject->DriverName.Buffer)); 282 } 283 } 284 else 285 { 286 LOG(("driver object is NULL")); 287 } 571 LOG(("no hub driver obj found")); 572 ASSERT_WARN(!Data.pDevObj, ("non-null dev obj poiter returned (0x%p)", Data.pDevObj)); 288 573 } 574 575 /* this will dereference both file and dev obj */ 289 576 ObDereferenceObject(pHubFileObj); 290 577 } 291 578 else 292 579 { 293 WARN(("IoGetDeviceObjectPointer returned Status (0x%x) for (%S)", Status, szwHubName));580 LOG(("IoGetDeviceObjectPointer returned Status (0x%x) for (%S)", Status, szwHubName)); 294 581 } 295 582 } … … 299 586 } 300 587 } 301 302 return pDrvObj; 588 } 589 590 typedef struct VBOXUSBMONFINDHUBWALKER 591 { 592 PDRIVER_OBJECT pDrvObj; 593 } VBOXUSBMONFINDHUBWALKER, *PVBOXUSBMONFINDHUBWALKER; 594 595 static DECLCALLBACK(BOOLEAN) vboxUsbMonFindHubDrvObjWalker(PFILE_OBJECT pFile, PDEVICE_OBJECT pTopDo, PDEVICE_OBJECT pHubDo, PVOID pvContext) 596 { 597 PVBOXUSBMONFINDHUBWALKER pData = (PVBOXUSBMONFINDHUBWALKER)pvContext; 598 PDRIVER_OBJECT pDrvObj = pHubDo->DriverObject; 599 600 ASSERT_WARN(!pData->pDrvObj, ("pDrvObj expected null on enter, but was(0x%p)", pData->pDrvObj)); 601 if(pDrvObj) 602 { 603 LOG(("found driver object 0x%p", pDrvObj)); 604 ObReferenceObject(pDrvObj); 605 pData->pDrvObj = pDrvObj; 606 return FALSE; 607 } 608 609 WARN(("null pDrvObj!")); 610 return TRUE; 611 } 612 613 static PDRIVER_OBJECT vboxUsbMonHookFindHubDrvObj() 614 { 615 NTSTATUS Status = STATUS_UNSUCCESSFUL; 616 UNICODE_STRING szStandardHubName; 617 PDRIVER_OBJECT pDrvObj = NULL; 618 szStandardHubName.Length = 0; 619 szStandardHubName.MaximumLength = 0; 620 szStandardHubName.Buffer = 0; 621 RtlInitUnicodeString(&szStandardHubName, L"\\Driver\\usbhub"); 622 623 LOG(("Search USB hub")); 624 VBOXUSBMONFINDHUBWALKER Data = {0}; 625 vboxUsbMonHubDevWalk(vboxUsbMonFindHubDrvObjWalker, &Data, VBOXUSBMONHUBWALK_F_ALL); 626 if (Data.pDrvObj) 627 { 628 LOG(("returning driver object 0x%p", Data.pDrvObj)); 629 } 630 else 631 { 632 WARN(("no hub driver object found!")); 633 } 634 return Data.pDrvObj; 303 635 } 304 636 … … 308 640 static NTSTATUS vboxUsbMonHandlePnPIoctl(PDEVICE_OBJECT pDevObj, PIO_STACK_LOCATION pSl, PIO_STATUS_BLOCK pIoStatus) 309 641 { 310 LOG(("IRQL = %d \n", KeGetCurrentIrql()));642 LOG(("IRQL = %d", KeGetCurrentIrql())); 311 643 switch(pSl->MinorFunction) 312 644 { 313 645 case IRP_MN_QUERY_DEVICE_TEXT: 314 646 { 315 LOG(("IRP_MN_QUERY_DEVICE_TEXT: pIoStatus->Status = %x \n", pIoStatus->Status));647 LOG(("IRP_MN_QUERY_DEVICE_TEXT: pIoStatus->Status = %x", pIoStatus->Status)); 316 648 if (pIoStatus->Status == STATUS_SUCCESS) 317 649 { … … 358 690 } 359 691 else 360 LOG(("Invalid pointer %p \n", pId));692 LOG(("Invalid pointer %p", pId)); 361 693 } 362 694 break; … … 365 697 case IRP_MN_QUERY_ID: 366 698 { 367 LOG(("IRP_MN_QUERY_ID: Irp->pIoStatus->Status = %x \n", pIoStatus->Status));699 LOG(("IRP_MN_QUERY_ID: Irp->pIoStatus->Status = %x", pIoStatus->Status)); 368 700 if (pIoStatus->Status == STATUS_SUCCESS && pDevObj) 369 701 { … … 511 843 else 512 844 { 513 LOG(("Invalid pointer %p \n", pId));845 LOG(("Invalid pointer %p", pId)); 514 846 } 515 847 } … … 524 856 case BusRelations: 525 857 { 526 LOG(("BusRelations \n"));858 LOG(("BusRelations")); 527 859 528 860 if (pIoStatus->Status == STATUS_SUCCESS) 529 861 { 530 862 PDEVICE_RELATIONS pRel = (PDEVICE_RELATIONS)pIoStatus->Information; 531 LOG(("pRel = %p \n", pRel));863 LOG(("pRel = %p", pRel)); 532 864 if (VALID_PTR(pRel)) 533 865 { … … 535 867 { 536 868 if (VBoxUsbFltPdoIsFiltered(pDevObj)) 537 LOG(("New PDO %p \n", pRel->Objects[i]));869 LOG(("New PDO %p", pRel->Objects[i])); 538 870 } 539 871 } 540 872 else 541 LOG(("Invalid pointer %p \n", pRel));873 LOG(("Invalid pointer %p", pRel)); 542 874 } 543 875 break; 544 876 } 545 877 case TargetDeviceRelation: 546 LOG(("TargetDeviceRelation \n"));878 LOG(("TargetDeviceRelation")); 547 879 break; 548 880 case RemovalRelations: 549 LOG(("RemovalRelations \n"));881 LOG(("RemovalRelations")); 550 882 break; 551 883 case EjectionRelations: 552 LOG(("EjectionRelations \n"));884 LOG(("EjectionRelations")); 553 885 break; 554 886 } … … 558 890 case IRP_MN_QUERY_CAPABILITIES: 559 891 { 560 LOG(("IRP_MN_QUERY_CAPABILITIES: pIoStatus->Status = %x \n", pIoStatus->Status));892 LOG(("IRP_MN_QUERY_CAPABILITIES: pIoStatus->Status = %x", pIoStatus->Status)); 561 893 if (pIoStatus->Status == STATUS_SUCCESS) 562 894 { … … 564 896 if (VALID_PTR(pCaps)) 565 897 { 566 LOG(("Caps.SilentInstall = %d \n", pCaps->SilentInstall));567 LOG(("Caps.UniqueID = %d \n", pCaps->UniqueID ));568 LOG(("Caps.Address = %d \n", pCaps->Address ));569 LOG(("Caps.UINumber = %d \n", pCaps->UINumber ));898 LOG(("Caps.SilentInstall = %d", pCaps->SilentInstall)); 899 LOG(("Caps.UniqueID = %d", pCaps->UniqueID )); 900 LOG(("Caps.Address = %d", pCaps->Address )); 901 LOG(("Caps.UINumber = %d", pCaps->UINumber )); 570 902 } 571 903 else 572 LOG(("Invalid pointer %p \n", pCaps));904 LOG(("Invalid pointer %p", pCaps)); 573 905 } 574 906 break; … … 580 912 } /*switch */ 581 913 582 LOG(("Done returns %x (IRQL = %d) \n", pIoStatus->Status, KeGetCurrentIrql()));914 LOG(("Done returns %x (IRQL = %d)", pIoStatus->Status, KeGetCurrentIrql())); 583 915 return pIoStatus->Status; 584 916 } … … 586 918 NTSTATUS _stdcall VBoxUsbPnPCompletion(DEVICE_OBJECT *pDevObj, IRP *pIrp, void *pvContext) 587 919 { 588 LOG(("Completion PDO(0x%p), IRP(0x%p), Status(0x%x) \n", pDevObj, pIrp, pIrp->IoStatus.Status));920 LOG(("Completion PDO(0x%p), IRP(0x%p), Status(0x%x)", pDevObj, pIrp, pIrp->IoStatus.Status)); 589 921 ASSERT_WARN(pvContext, ("zero context")); 590 922 … … 657 989 } 658 990 659 LOG(("<==PnP: Mn(%s), PDO(0x%p), IRP(0x%p), Status(0x%x), Sl PDO(0x%p), Compl PDO(0x%p) \n",991 LOG(("<==PnP: Mn(%s), PDO(0x%p), IRP(0x%p), Status(0x%x), Sl PDO(0x%p), Compl PDO(0x%p)", 660 992 vboxUsbDbgStrPnPMn(pSl->MinorFunction), 661 993 pRealDevObj, pIrp, pIrp->IoStatus.Status, … … 684 1016 NTSTATUS _stdcall VBoxUsbMonPnPHook(IN PDEVICE_OBJECT pDevObj, IN PIRP pIrp) 685 1017 { 686 LOG(("==>PnP: Mn(%s), PDO(0x%p), IRP(0x%p), Status(0x%x) \n", vboxUsbDbgStrPnPMn(IoGetCurrentIrpStackLocation(pIrp)->MinorFunction), pDevObj, pIrp, pIrp->IoStatus.Status));1018 LOG(("==>PnP: Mn(%s), PDO(0x%p), IRP(0x%p), Status(0x%x)", vboxUsbDbgStrPnPMn(IoGetCurrentIrpStackLocation(pIrp)->MinorFunction), pDevObj, pIrp, pIrp->IoStatus.Status)); 687 1019 688 1020 if(!VBoxUsbHookRetain(&g_VBoxUsbMonGlobals.UsbHubPnPHook.Hook)) … … 761 1093 if (!NT_SUCCESS(Status)) 762 1094 { 763 AssertMsgFailed(("usbhub pnp unhook failed, setting the fUninitFailed flag, the current value of fUninitFailed (%d) \n", g_VBoxUsbMonGlobals.UsbHubPnPHook.fUninitFailed));1095 AssertMsgFailed(("usbhub pnp unhook failed, setting the fUninitFailed flag, the current value of fUninitFailed (%d)", g_VBoxUsbMonGlobals.UsbHubPnPHook.fUninitFailed)); 764 1096 g_VBoxUsbMonGlobals.UsbHubPnPHook.fUninitFailed = true; 765 1097 } … … 924 1256 if (!InterlockedExchange(&g_VBoxUsbMonGlobals.ulPreventUnloadOn, 1)) 925 1257 { 926 LOGREL(("ulPreventUnloadOn not set, preventing unload \n"));1258 LOGREL(("ulPreventUnloadOn not set, preventing unload")); 927 1259 UNICODE_STRING UniName; 928 1260 PDEVICE_OBJECT pTmpDevObj; … … 1034 1366 PUSBSUP_VERSION pOut = (PUSBSUP_VERSION)pvBuffer; 1035 1367 1036 LOG(("SUPUSBFLT_IOCTL_GET_VERSION \n"));1368 LOG(("SUPUSBFLT_IOCTL_GET_VERSION")); 1037 1369 if (!pvBuffer || cbOutBuffer != sizeof(*pOut) || cbInBuffer != 0) 1038 1370 { 1039 WARN(("SUPUSBFLT_IOCTL_GET_VERSION: Invalid input/output sizes. cbIn=%d expected %d. cbOut=%d expected %d. \n",1371 WARN(("SUPUSBFLT_IOCTL_GET_VERSION: Invalid input/output sizes. cbIn=%d expected %d. cbOut=%d expected %d.", 1040 1372 cbInBuffer, 0, cbOutBuffer, sizeof (*pOut))); 1041 1373 Status = STATUS_INVALID_PARAMETER; … … 1057 1389 if (RT_UNLIKELY(!pvBuffer || cbInBuffer != sizeof (*pFilter) || cbOutBuffer != sizeof (*pOut))) 1058 1390 { 1059 WARN(("SUPUSBFLT_IOCTL_ADD_FILTER: Invalid input/output sizes. cbIn=%d expected %d. cbOut=%d expected %d. \n",1391 WARN(("SUPUSBFLT_IOCTL_ADD_FILTER: Invalid input/output sizes. cbIn=%d expected %d. cbOut=%d expected %d.", 1060 1392 cbInBuffer, sizeof (*pFilter), cbOutBuffer, sizeof (*pOut))); 1061 1393 Status = STATUS_INVALID_PARAMETER; … … 1078 1410 if (!pvBuffer || cbInBuffer != sizeof (*pIn) || (cbOutBuffer && cbOutBuffer != sizeof (*pRc))) 1079 1411 { 1080 WARN(("SUPUSBFLT_IOCTL_REMOVE_FILTER: Invalid input/output sizes. cbIn=%d expected %d. cbOut=%d expected %d. \n",1412 WARN(("SUPUSBFLT_IOCTL_REMOVE_FILTER: Invalid input/output sizes. cbIn=%d expected %d. cbOut=%d expected %d.", 1081 1413 cbInBuffer, sizeof (*pIn), cbOutBuffer, 0)); 1082 1414 Status = STATUS_INVALID_PARAMETER; 1083 1415 break; 1084 1416 } 1085 LOG(("SUPUSBFLT_IOCTL_REMOVE_FILTER %x \n", *pIn));1417 LOG(("SUPUSBFLT_IOCTL_REMOVE_FILTER %x", *pIn)); 1086 1418 int rc = VBoxUsbMonFltRemove(pContext, *pIn); 1087 1419 if (cbOutBuffer) … … 1100 1432 if (pvBuffer || cbInBuffer || cbOutBuffer) 1101 1433 { 1102 WARN(("SUPUSBFLT_IOCTL_RUN_FILTERS: Invalid input/output sizes. cbIn=%d expected %d. cbOut=%d expected %d. \n",1434 WARN(("SUPUSBFLT_IOCTL_RUN_FILTERS: Invalid input/output sizes. cbIn=%d expected %d. cbOut=%d expected %d.", 1103 1435 cbInBuffer, 0, cbOutBuffer, 0)); 1104 1436 Status = STATUS_INVALID_PARAMETER; 1105 1437 break; 1106 1438 } 1107 LOG(("SUPUSBFLT_IOCTL_RUN_FILTERS \n"));1439 LOG(("SUPUSBFLT_IOCTL_RUN_FILTERS ")); 1108 1440 Status = VBoxUsbMonRunFilters(pContext); 1109 1441 ASSERT_WARN(Status != STATUS_PENDING, ("status pending!")); … … 1117 1449 if (!pvBuffer || cbInBuffer != sizeof (hDevice) || cbOutBuffer < sizeof (*pOut)) 1118 1450 { 1119 WARN(("SUPUSBFLT_IOCTL_GET_DEVICE: Invalid input/output sizes. cbIn=%d expected %d. cbOut=%d expected >= %d. \n",1451 WARN(("SUPUSBFLT_IOCTL_GET_DEVICE: Invalid input/output sizes. cbIn=%d expected %d. cbOut=%d expected >= %d.", 1120 1452 cbInBuffer, sizeof (hDevice), cbOutBuffer, sizeof (*pOut))); 1121 1453 Status = STATUS_INVALID_PARAMETER; … … 1141 1473 if (!pvBuffer || cbInBuffer != sizeof (*pSne) || cbOutBuffer != sizeof (*pSne)) 1142 1474 { 1143 WARN(("SUPUSBFLT_IOCTL_SET_NOTIFY_EVENT: Invalid input/output sizes. cbIn=%d expected %d. cbOut=%d expected %d. \n",1475 WARN(("SUPUSBFLT_IOCTL_SET_NOTIFY_EVENT: Invalid input/output sizes. cbIn=%d expected %d. cbOut=%d expected %d.", 1144 1476 cbInBuffer, sizeof (*pSne), cbOutBuffer, sizeof (*pSne))); 1145 1477 Status = STATUS_INVALID_PARAMETER; … … 1208 1540 PVBOXUSBIDC_VERSION pOut = (PVBOXUSBIDC_VERSION)pvBuffer; 1209 1541 1210 LOG(("VBOXUSBIDC_INTERNAL_IOCTL_GET_VERSION \n"));1542 LOG(("VBOXUSBIDC_INTERNAL_IOCTL_GET_VERSION")); 1211 1543 if (!pvBuffer) 1212 1544 { 1213 WARN(("VBOXUSBIDC_INTERNAL_IOCTL_GET_VERSION: Buffer is NULL \n"));1545 WARN(("VBOXUSBIDC_INTERNAL_IOCTL_GET_VERSION: Buffer is NULL")); 1214 1546 Status = STATUS_INVALID_PARAMETER; 1215 1547 break; … … 1225 1557 PVBOXUSBIDC_PROXY_STARTUP pOut = (PVBOXUSBIDC_PROXY_STARTUP)pvBuffer; 1226 1558 1227 LOG(("VBOXUSBIDC_INTERNAL_IOCTL_PROXY_STARTUP \n"));1559 LOG(("VBOXUSBIDC_INTERNAL_IOCTL_PROXY_STARTUP")); 1228 1560 if (!pvBuffer) 1229 1561 { 1230 WARN(("VBOXUSBIDC_INTERNAL_IOCTL_PROXY_STARTUP: Buffer is NULL \n"));1562 WARN(("VBOXUSBIDC_INTERNAL_IOCTL_PROXY_STARTUP: Buffer is NULL")); 1231 1563 Status = STATUS_INVALID_PARAMETER; 1232 1564 break; … … 1243 1575 PVBOXUSBIDC_PROXY_TEARDOWN pOut = (PVBOXUSBIDC_PROXY_TEARDOWN)pvBuffer; 1244 1576 1245 LOG(("VBOXUSBIDC_INTERNAL_IOCTL_PROXY_TEARDOWN \n"));1577 LOG(("VBOXUSBIDC_INTERNAL_IOCTL_PROXY_TEARDOWN")); 1246 1578 if (!pvBuffer) 1247 1579 { 1248 WARN(("VBOXUSBIDC_INTERNAL_IOCTL_PROXY_TEARDOWN: Buffer is NULL \n"));1580 WARN(("VBOXUSBIDC_INTERNAL_IOCTL_PROXY_TEARDOWN: Buffer is NULL")); 1249 1581 Status = STATUS_INVALID_PARAMETER; 1250 1582 break; … … 1296 1628 static void _stdcall VBoxUsbMonUnload(PDRIVER_OBJECT pDrvObj) 1297 1629 { 1298 LOG(("VBoxUSBMonUnload pDrvObj (0x%p) \n", pDrvObj));1630 LOG(("VBoxUSBMonUnload pDrvObj (0x%p)", pDrvObj)); 1299 1631 1300 1632 IoReleaseRemoveLockAndWait(&g_VBoxUsbMonGlobals.RmLock, &g_VBoxUsbMonGlobals); … … 1369 1701 1370 1702 g_VBoxUsbMonGlobals.pDevObj = pDevObj; 1371 LOG(("VBoxUSBMon::DriverEntry returning STATUS_SUCCESS \n"));1703 LOG(("VBoxUSBMon::DriverEntry returning STATUS_SUCCESS")); 1372 1704 return STATUS_SUCCESS; 1373 1705 } -
trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.h
r38356 r38488 47 47 void vboxUsbDbgPrintUnicodeString(PUNICODE_STRING pUnicodeString); 48 48 49 /* visit usbhub-originated device PDOs */ 50 #define VBOXUSBMONHUBWALK_F_PDO 0x00000001 51 /* visit usbhub device FDOs */ 52 #define VBOXUSBMONHUBWALK_F_FDO 0x00000002 53 /* visit all usbhub-originated device objects */ 54 #define VBOXUSBMONHUBWALK_F_ALL (VBOXUSBMONHUBWALK_F_FDO | VBOXUSBMONHUBWALK_F_PDO) 55 56 typedef DECLCALLBACK(BOOLEAN) FNVBOXUSBMONDEVWALKER(PFILE_OBJECT pFile, PDEVICE_OBJECT pTopDo, PDEVICE_OBJECT pHubDo, PVOID pvContext); 57 typedef FNVBOXUSBMONDEVWALKER *PFNVBOXUSBMONDEVWALKER; 58 59 VOID vboxUsbMonHubDevWalk(PFNVBOXUSBMONDEVWALKER pfnWalker, PVOID pvWalker, ULONG fFlags); 60 49 61 #endif /* #ifndef ___VBoxUsbMon_h___ */
Note:
See TracChangeset
for help on using the changeset viewer.