Changeset 83803 in vbox for trunk/src/VBox/HostDrivers/VBoxUSB/win/mon
- Timestamp:
- Apr 18, 2020 6:20:34 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxUSB/win/mon/VBoxUsbMon.cpp
r82968 r83803 109 109 * Defined Constants And Macros * 110 110 *********************************************************************************************************************************/ 111 #define VBOXUSBMON_MEMTAG 'MUBV' 112 113 114 /********************************************************************************************************************************* 115 * Structures and Typedefs * 116 *********************************************************************************************************************************/ 117 typedef struct VBOXUSBMONINS 118 { 119 void * pvDummy; 120 } VBOXUSBMONINS, *PVBOXUSBMONINS; 121 122 typedef struct VBOXUSBMONCTX 123 { 124 VBOXUSBFLTCTX FltCtx; 125 } VBOXUSBMONCTX, *PVBOXUSBMONCTX; 126 127 typedef struct VBOXUSBHUB_PNPHOOK 128 { 129 VBOXUSBHOOK_ENTRY Hook; 130 bool fUninitFailed; 131 } VBOXUSBHUB_PNPHOOK, *PVBOXUSBHUB_PNPHOOK; 132 133 typedef struct VBOXUSBHUB_PNPHOOK_COMPLETION 134 { 135 VBOXUSBHOOK_REQUEST Rq; 136 } VBOXUSBHUB_PNPHOOK_COMPLETION, *PVBOXUSBHUB_PNPHOOK_COMPLETION; 137 138 #define VBOXUSBMON_MAXDRIVERS 5 139 typedef struct VBOXUSB_PNPDRIVER 140 { 141 PDRIVER_OBJECT DriverObject; 142 VBOXUSBHUB_PNPHOOK UsbHubPnPHook; 143 PDRIVER_DISPATCH pfnHookStub; 144 } VBOXUSB_PNPDRIVER, *PVBOXUSB_PNPDRIVER; 145 146 typedef struct VBOXUSBMONGLOBALS 147 { 148 PDEVICE_OBJECT pDevObj; 149 VBOXUSB_PNPDRIVER pDrivers[VBOXUSBMON_MAXDRIVERS]; 150 KEVENT OpenSynchEvent; 151 IO_REMOVE_LOCK RmLock; 152 uint32_t cOpens; 153 volatile LONG ulPreventUnloadOn; 154 PFILE_OBJECT pPreventUnloadFileObj; 155 } VBOXUSBMONGLOBALS, *PVBOXUSBMONGLOBALS; 156 157 158 /********************************************************************************************************************************* 159 * Global Variables * 160 *********************************************************************************************************************************/ 161 static VBOXUSBMONGLOBALS g_VBoxUsbMonGlobals; 162 111 163 /* 112 164 * Note: Must match the VID & PID in the USB driver .inf file!! … … 122 174 */ 123 175 124 #define szBusQueryDeviceId L"USB\\Vid_80EE&Pid_CAFE" 125 #define szBusQueryHardwareIDs L"USB\\Vid_80EE&Pid_CAFE&Rev_0100\0USB\\Vid_80EE&Pid_CAFE\0\0" 126 #define szBusQueryCompatibleIDs L"USB\\Class_ff&SubClass_00&Prot_00\0USB\\Class_ff&SubClass_00\0USB\\Class_ff\0\0" 127 128 #define szDeviceTextDescription L"VirtualBox USB" 129 130 131 #define VBOXUSBMON_MEMTAG 'MUBV' 132 133 134 /********************************************************************************************************************************* 135 * Structures and Typedefs * 136 *********************************************************************************************************************************/ 137 typedef struct VBOXUSBMONINS 138 { 139 void * pvDummy; 140 } VBOXUSBMONINS, *PVBOXUSBMONINS; 141 142 typedef struct VBOXUSBMONCTX 143 { 144 VBOXUSBFLTCTX FltCtx; 145 } VBOXUSBMONCTX, *PVBOXUSBMONCTX; 146 147 typedef struct VBOXUSBHUB_PNPHOOK 148 { 149 VBOXUSBHOOK_ENTRY Hook; 150 bool fUninitFailed; 151 } VBOXUSBHUB_PNPHOOK, *PVBOXUSBHUB_PNPHOOK; 152 153 typedef struct VBOXUSBHUB_PNPHOOK_COMPLETION 154 { 155 VBOXUSBHOOK_REQUEST Rq; 156 } VBOXUSBHUB_PNPHOOK_COMPLETION, *PVBOXUSBHUB_PNPHOOK_COMPLETION; 157 158 #define VBOXUSBMON_MAXDRIVERS 5 159 typedef struct VBOXUSB_PNPDRIVER 160 { 161 PDRIVER_OBJECT DriverObject; 162 VBOXUSBHUB_PNPHOOK UsbHubPnPHook; 163 PDRIVER_DISPATCH pfnHookStub; 164 } VBOXUSB_PNPDRIVER, *PVBOXUSB_PNPDRIVER; 165 166 typedef struct VBOXUSBMONGLOBALS 167 { 168 PDEVICE_OBJECT pDevObj; 169 VBOXUSB_PNPDRIVER pDrivers[VBOXUSBMON_MAXDRIVERS]; 170 KEVENT OpenSynchEvent; 171 IO_REMOVE_LOCK RmLock; 172 uint32_t cOpens; 173 volatile LONG ulPreventUnloadOn; 174 PFILE_OBJECT pPreventUnloadFileObj; 175 } VBOXUSBMONGLOBALS, *PVBOXUSBMONGLOBALS; 176 177 178 /********************************************************************************************************************************* 179 * Global Variables * 180 *********************************************************************************************************************************/ 181 static VBOXUSBMONGLOBALS g_VBoxUsbMonGlobals; 176 static WCHAR const g_szBusQueryDeviceId[] = L"USB\\Vid_80EE&Pid_CAFE"; 177 static WCHAR const g_szBusQueryHardwareIDs[] = L"USB\\Vid_80EE&Pid_CAFE&Rev_0100\0USB\\Vid_80EE&Pid_CAFE\0\0"; 178 static WCHAR const g_szBusQueryCompatibleIDs[] = L"USB\\Class_ff&SubClass_00&Prot_00\0USB\\Class_ff&SubClass_00\0USB\\Class_ff\0\0"; 179 static WCHAR const g_szDeviceTextDescription[] = L"VirtualBox USB"; 182 180 183 181 … … 377 375 /* IRQL should be always passive here */ 378 376 ASSERT_WARN(Iqrl == PASSIVE_LEVEL, ("irql is not PASSIVE")); 379 switch (pSl->Parameters.QueryDeviceText.DeviceTextType)377 switch (pSl->Parameters.QueryDeviceText.DeviceTextType) 380 378 { 381 379 case DeviceTextLocationInformation: … … 390 388 { 391 389 LOG(("PDO (0x%p) is filtered", pDevObj)); 392 WCHAR *pId = (WCHAR *)ExAllocatePool(PagedPool, sizeof(szDeviceTextDescription)); 393 if (!pId) 394 { 395 AssertFailed(); 396 break; 397 } 398 memcpy(pId, szDeviceTextDescription, sizeof(szDeviceTextDescription)); 390 WCHAR *pId2 = (WCHAR *)ExAllocatePool(PagedPool, sizeof(g_szDeviceTextDescription)); 391 AssertBreak(pId2); 392 memcpy(pId2, g_szDeviceTextDescription, sizeof(g_szDeviceTextDescription)); 399 393 LOG(("NEW szDeviceTextDescription")); 400 LOG_STRW(pId );394 LOG_STRW(pId2); 401 395 ExFreePool((PVOID)pIoStatus->Information); 402 pIoStatus->Information = (ULONG_PTR)pId ;396 pIoStatus->Information = (ULONG_PTR)pId2; 403 397 } 404 398 else … … 443 437 { 444 438 LOG(("BusQueryDeviceID")); 445 pId = (WCHAR *)ExAllocatePool(PagedPool, sizeof( szBusQueryDeviceId));439 pId = (WCHAR *)ExAllocatePool(PagedPool, sizeof(g_szBusQueryDeviceId)); 446 440 if (!pId) 447 441 { … … 468 462 LOG(("PDO (0x%p) is filtered", pDevObj)); 469 463 ExFreePool((PVOID)pIoStatus->Information); 470 memcpy(pId, szBusQueryDeviceId, sizeof(szBusQueryDeviceId));464 memcpy(pId, g_szBusQueryDeviceId, sizeof(g_szBusQueryDeviceId)); 471 465 pIoStatus->Information = (ULONG_PTR)pId; 472 466 break; … … 483 477 } 484 478 #endif 485 pId = (WCHAR *)ExAllocatePool(PagedPool, sizeof( szBusQueryHardwareIDs));479 pId = (WCHAR *)ExAllocatePool(PagedPool, sizeof(g_szBusQueryHardwareIDs)); 486 480 if (!pId) 487 481 { … … 508 502 LOG(("PDO (0x%p) is filtered", pDevObj)); 509 503 510 memcpy(pId, szBusQueryHardwareIDs, sizeof(szBusQueryHardwareIDs));504 memcpy(pId, g_szBusQueryHardwareIDs, sizeof(g_szBusQueryHardwareIDs)); 511 505 #ifdef VBOX_USB_WITH_VERBOSE_LOGGING 512 506 LOG(("NEW BusQueryHardwareIDs")); … … 537 531 { 538 532 LOG(("PDO (0x%p) is filtered", pDevObj)); 539 pId = (WCHAR *)ExAllocatePool(PagedPool, sizeof( szBusQueryCompatibleIDs));533 pId = (WCHAR *)ExAllocatePool(PagedPool, sizeof(g_szBusQueryCompatibleIDs)); 540 534 if (!pId) 541 535 { … … 543 537 break; 544 538 } 545 memcpy(pId, szBusQueryCompatibleIDs, sizeof(szBusQueryCompatibleIDs));539 memcpy(pId, g_szBusQueryCompatibleIDs, sizeof(g_szBusQueryCompatibleIDs)); 546 540 #ifdef VBOX_USB_WITH_VERBOSE_LOGGING 547 541 LOG(("NEW BusQueryCompatibleIDs"));
Note:
See TracChangeset
for help on using the changeset viewer.