Changeset 81023 in vbox for trunk/src/VBox/HostDrivers/VBoxUSB
- Timestamp:
- Sep 26, 2019 2:52:01 PM (5 years ago)
- Location:
- trunk/src/VBox/HostDrivers/VBoxUSB/win
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxUSB/win/Makefile.kmk
r76553 r81023 138 138 # 139 139 USBTest_TEMPLATE = VBOXR3EXE 140 USBTest_DEFS = IN_RT_R3 140 USBTest_DEFS = IN_RT_R3 IN_USBLIB 141 141 USBTest_SDKS = ReorderCompilerIncs $(VBOX_WINPSDK) $(VBOX_WINDDK) VBOX_NTDLL 142 142 USBTest_CXXFLAGS = -Gz 143 143 USBTest_CFLAGS = -Gz 144 144 USBTest_SOURCES = \ 145 testcase/USBTest.cpp 145 testcase/USBTest.cpp \ 146 ../USBFilter.cpp 146 147 USBTest_LIBS = \ 147 148 $(PATH_SDK_$(VBOX_WINDDK)_LIB)/newdev.lib \ -
trunk/src/VBox/HostDrivers/VBoxUSB/win/testcase/USBTest.cpp
r76553 r81023 157 157 * 158 158 * @returns VBox status code. 159 * @param pszVendor Vendor filter string160 * @param pszProduct Product filter string161 * @param pszRevision Revision filter string159 * @param usVendorId Vendor id 160 * @param usProductId Product id 161 * @param usRevision Revision 162 162 * @param ppID Pointer to filter id 163 163 */ 164 int usbMonInsertFilter( const char *pszVendor, const char *pszProduct, const char *pszRevision, void **ppID)164 int usbMonInsertFilter(USHORT usVendorId, USHORT usProductId, USHORT usRevision, void **ppID) 165 165 { 166 166 USBFILTER filter; … … 170 170 Assert(g_hUSBMonitor); 171 171 172 printf("usblibInsertFilter %s %s %s\n", pszVendor, pszProduct, pszRevision); 173 174 // strncpy(filter.szVendor, pszVendor, sizeof(filter.szVendor)); 175 // strncpy(filter.szProduct, pszProduct, sizeof(filter.szProduct)); 176 // strncpy(filter.szRevision, pszRevision, sizeof(filter.szRevision)); 177 172 printf("usblibInsertFilter %04X %04X %04X\n", usVendorId, usProductId, usRevision); 173 174 USBFilterInit(&filter, USBFILTERTYPE_CAPTURE); 175 USBFilterSetNumExact(&filter, USBFILTERIDX_VENDOR_ID, usVendorId, true); 176 USBFilterSetNumExact(&filter, USBFILTERIDX_PRODUCT_ID, usProductId, true); 177 USBFilterSetNumExact(&filter, USBFILTERIDX_DEVICE_REV, usRevision, true); 178 178 179 if (!DeviceIoControl(g_hUSBMonitor, SUPUSBFLT_IOCTL_ADD_FILTER, &filter, sizeof(filter), &flt_add, sizeof(flt_add), &cbReturned, NULL)) 179 180 { … … 182 183 } 183 184 *ppID = (void *)flt_add.uId; 185 return VINF_SUCCESS; 186 } 187 188 /** 189 * Applies existing filters to currently plugged-in USB devices 190 * 191 * @returns VBox status code. 192 */ 193 int usbMonRunFilters(void) 194 { 195 DWORD cbReturned = 0; 196 197 Assert(g_hUSBMonitor); 198 199 if (!DeviceIoControl(g_hUSBMonitor, SUPUSBFLT_IOCTL_RUN_FILTERS, NULL, 0, NULL, 0, &cbReturned, NULL)) 200 { 201 AssertMsgFailed(("DeviceIoControl failed with %d\n", GetLastError())); 202 return RTErrConvertFromWin32(GetLastError()); 203 } 184 204 return VINF_SUCCESS; 185 205 } … … 317 337 { 318 338 int rc; 339 int c; 319 340 RT_NOREF2(argc, argv); 320 341 … … 324 345 AssertRC(rc); 325 346 326 void *pId1, *pId2; 327 328 usbMonInsertFilter("0529", "0514", "0100", &pId1); 329 usbMonInsertFilter("0A16", "2499", "0100", &pId2); 330 331 printf("Waiting to capture device\n"); 332 getchar(); 347 void *pId1, *pId2, *pId3; 348 349 usbMonInsertFilter(0x0529, 0x0514, 0x0100, &pId1); 350 usbMonInsertFilter(0x0A16, 0x2499, 0x0100, &pId2); 351 usbMonInsertFilter(0x80EE, 0x0030, 0x0110, &pId3); 352 353 printf("Waiting to capture devices... enter 'r' to run filters\n"); 354 c = getchar(); 355 if (c == 'r') 356 { 357 usbMonRunFilters(); 358 printf("Waiting to capture devices...\n"); 359 getchar(); /* eat the '\n' */ 360 getchar(); /* wait for more input */ 361 } 333 362 334 363 printf("Releasing device\n"); … … 337 366 usbMonRemoveFilter(pId1); 338 367 usbMonRemoveFilter(pId2); 368 usbMonRemoveFilter(pId3); 339 369 340 370 rc = usbMonitorTerm();
Note:
See TracChangeset
for help on using the changeset viewer.