带USB控制器集线器的HID键盘鼠标
2024-10-21
103
2
以往开发的虚拟USB键盘鼠标HID设备都是直接通过虚拟USB总线虚拟出设备,其在设备管理器中如下:
其具体实现可详见:https://www.usbzh.com/article/detail-1182.html
但在某些情况下,关于HID键盘鼠标的检测会更加深入,比如需要检测其所在的集线器端口,根据USB集线器相关的接口获取相关的USB-HID设备信息进行二次检测。在这种情况下,类于UVKM这种直接虚拟的设备就会被检测到。
那有没有可以过二次检测的虚拟USB-HID键盘鼠标设备呢?当然有了,那就是直接从根节点虚拟。先虚拟出USB控制器,再USB集线器,再在USB集线器上虚拟出USB-HID键盘鼠标。这样就算通过USB集线器接口的特定接口进行二次检测,那也是可行的。
其于USB控制器集线器的HID键盘鼠标其在功能上和UVKM功能上可以完全保持一致,在在USB树下,其设备关系如下:
对于这种设备,我们通过USBTREEVIEWER等第三方工具也可以看到如下的设备树:
这种在其工具的右端也可以显示完整的设备其它信息,如:设备描述符、配置描述符、设备连接信息等。
如我们对于上面的USB鼠标信息如下:
=========================== USB Port1 ===========================
Connection Status : 0x01 (Device is connected)
Port Chain : 3-1
Properties : 0x00
IsUserConnectable : no
PortIsDebugCapable : no
PortHasMultiCompanions : no
PortConnectorIsTypeC : no
ConnectionIndex : 0x01 (Port 1)
========================== Summary =========================
Vendor ID : 0x1000 (Speedtech Corp.)
Product ID : 0x0002
Manufacturer String : Speedtech
Product String : USB2.0 HID
Serial : 20240411
USB Version : 2.0
Port maximum Speed : High-Speed
Device maximum Speed : SuperSpeed
Device Connection Speed : SuperSpeed
Self powered : no
Demanded Current : 400 mA
Used Endpoints : 2
======================== USB Device ========================
+++++++++++++++++ Device Information ++++++++++++++++++
Device Description : USB 输入设备
Device Path : \\?\USB#VID_1000&PID_0002&REV_0100#3&286900ca&0&0001#{a5dcbf10-6530-11d2-901f-00c04fb951ed} (GUID_DEVINTERFACE_USB_DEVICE)
Kernel Name : \Device\00000202
Device ID : USB\VID_1000&PID_0002&REV_0100\3&286900CA&0&0001
Hardware IDs : USB\VID_1000&PID_0002&REV_0100
Driver KeyName : {745a17a0-74d3-11d0-b6fe-00a0c90f57da}\0052 (GUID_DEVCLASS_HIDCLASS)
Driver : \SystemRoot\System32\drivers\hidusb.sys (Version: 10.0.18362.175 Date: 2019-12-27 Company: Microsoft Corporation)
Driver Inf : C:\Windows\inf\input.inf
Legacy BusType : PNPBus
Class : HIDClass
Class GUID : {745a17a0-74d3-11d0-b6fe-00a0c90f57da} (GUID_DEVCLASS_HIDCLASS)
Service : HidUsb
Enumerator : USB
Location Info : USB Device Loaction-2
Address : 1
Container ID : {11fe7194-8f75-11ef-9a64-00e04b3be8a5}
Manufacturer Info : (标准系统设备)
Capabilities : 0x84 (Removable, SurpriseRemovalOK)
Status : 0x0180600A (DN_DRIVER_LOADED, DN_STARTED, DN_DISABLEABLE, DN_REMOVABLE, DN_NT_ENUMERATOR, DN_NT_DRIVER)
Problem Code : 0
SelectiveSuspendEnabled : 0
EnhancedPowerMgmtEnabled : 1
Power State : D0 (supported: D0, D3, wake from D0)
---------------- Connection Information ---------------
Connection Index : 0x01 (Port 1)
Connection Status : 0x01 (DeviceConnected)
Current Config Value : 0x01 (Configuration 1)
Device Address : 0x01 (1)
Is Hub : 0x00 (no)
Device Bus Speed : 0x03 (SuperSpeed)
Number of open Pipes : 0x01 (1 pipe to data endpoints)
Pipe[0] : EndpointID=1 Direction=IN ScheduleOffset=0 Type=Interrupt wMaxPacketSize=0x4 bInterval=10
Data (HexDump) : 01 00 00 00 12 01 00 02 03 01 02 40 00 10 02 00 ...........@....
00 01 01 02 03 01 01 03 00 01 00 01 00 00 00 01 ................
00 00 00 07 05 81 03 04 00 0A 00 00 00 00 ..............
--------------- Connection Information V2 -------------
Connection Index : 0x01 (1)
Length : 0x10 (16 bytes)
SupportedUsbProtocols : 0x03
Usb110 : 1 (yes, port supports USB 1.1)
Usb200 : 1 (yes, port supports USB 2.0)
Usb300 : 0 (no, port not supports USB 3.0)
ReservedMBZ : 0x00
Flags : 0x00
DevIsOpAtSsOrHigher : 0 (Device is not operating at SuperSpeed or higher)
DevIsSsCapOrHigher : 0 (Device is not SuperSpeed capable or higher)
DevIsOpAtSsPlusOrHigher : 0 (Device is not operating at SuperSpeedPlus or higher)
DevIsSsPlusCapOrHigher : 0 (Device is not SuperSpeedPlus capable or higher)
ReservedMBZ : 0x00
Data (HexDump) : 01 00 00 00 10 00 00 00 03 00 00 00 00 00 00 00 ................
---------------------- Device Descriptor ----------------------
bLength : 0x12 (18 bytes)
bDescriptorType : 0x01 (Device Descriptor)
bcdUSB : 0x200 (USB Version 2.0)
bDeviceClass : 0x03 (HID - Human Interface Device)
bDeviceSubClass : 0x01
bDeviceProtocol : 0x02 (Mouse)
bMaxPacketSize0 : 0x40 (64 bytes)
idVendor : 0x1000 (Speedtech Corp.)
idProduct : 0x0002
bcdDevice : 0x0100
iManufacturer : 0x01 (String Descriptor 1)
Language 0x0409 : "USBZH"
iProduct : 0x02 (String Descriptor 2)
Language 0x0409 : "USB2.0 HID"
iSerialNumber : 0x03 (String Descriptor 3)
Language 0x0409 : "20240411"
bNumConfigurations : 0x01 (1 Configuration)
Data (HexDump) : 12 01 00 02 03 01 02 40 00 10 02 00 00 01 01 02 .......@........
03 01 ..
------------------ Configuration Descriptor -------------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x02 (Configuration Descriptor)
wTotalLength : 0x0022 (34 bytes)
bNumInterfaces : 0x01 (1 Interface)
bConfigurationValue : 0x01 (Configuration 1)
iConfiguration : 0x00 (No String Descriptor)
bmAttributes : 0x80
D7: Reserved, set 1 : 0x01
D6: Self Powered : 0x00 (no)
D5: Remote Wakeup : 0x00 (no)
D4..0: Reserved, set 0 : 0x00
MaxPower : 0x32 (400 mA)
Data (HexDump) : 09 02 22 00 01 01 00 80 32 09 04 00 00 01 03 01 ..".....2.......
02 00 09 21 11 01 00 01 22 2E 00 07 05 81 03 04 ...!....".......
00 0A ..
---------------- Interface Descriptor -----------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x04 (Interface Descriptor)
bInterfaceNumber : 0x00 (Interface 0)
bAlternateSetting : 0x00
bNumEndpoints : 0x01 (1 Endpoint)
bInterfaceClass : 0x03 (HID - Human Interface Device)
bInterfaceSubClass : 0x01 (Boot Interface)
bInterfaceProtocol : 0x02 (Mouse)
iInterface : 0x00 (No String Descriptor)
Data (HexDump) : 09 04 00 00 01 03 01 02 00 .........
------------------- HID Descriptor --------------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x21 (HID Descriptor)
bcdHID : 0x0111 (HID Version 1.11)
bCountryCode : 0x00 (00 = not localized)
bNumDescriptors : 0x01
Data (HexDump) : 09 21 11 01 00 01 22 2E 00 .!...."..
Descriptor 1:
bDescriptorType : 0x22 (Class=Report)
wDescriptorLength : 0x002E (46 bytes)
05 01 Usage Page (Generic Desktop Controls)
09 02 Usage (Mouse)
A1 01 Collection (Application)
09 01 Usage (Pointer)
A1 00 Collection (Physical)
05 09 Usage Page (Buttons)
19 01 Usage Minimum (1)
29 03 Usage Maximum (3)
15 00 Logical Minimum (0)
25 01 Logical Maximum (1)
95 08 Report Count (8)
75 01 Report Size (1)
81 02 Input (Var)
05 01 Usage Page (Generic Desktop Controls)
09 30 Usage (Direction-X)
09 31 Usage (Direction-Y)
09 38 Usage (Wheel)
15 81 Logical Minimum (-127)
25 7F Logical Maximum (127)
75 08 Report Size (8)
95 03 Report Count (3)
81 06 Input (Var, Rel)
C0 End Collection
C0 End Collection
Data (HexDump) : 05 01 09 02 A1 01 09 01 A1 00 05 09 19 01 29 03 ..............).
15 00 25 01 95 08 75 01 81 02 05 01 09 30 09 31 ..%...u......0.1
09 38 15 81 25 7F 75 08 95 03 81 06 C0 C0 .8..%.u.......
----------------- Endpoint Descriptor -----------------
bLength : 0x07 (7 bytes)
bDescriptorType : 0x05 (Endpoint Descriptor)
bEndpointAddress : 0x81 (Direction=IN EndpointID=1)
bmAttributes : 0x03 (TransferType=InterruptPeriodic)
*!*ERROR Endpoint Companion Descriptor missing
wMaxPacketSize : 0x0004
bInterval : 0x0A (512 microframes -> 64 ms)
Data (HexDump) : 07 05 81 03 04 00 0A .......
----------------- Device Qualifier Descriptor -----------------
Error : ERROR_INVALID_PARAMETER (because the device is SuperSpeed only)
-------------------- String Descriptors -------------------
------ String Descriptor 0 ------
bLength : 0x04 (4 bytes)
bDescriptorType : 0x03 (String Descriptor)
Language ID[0] : 0x0409 (English - United States)
Data (HexDump) : 04 03 09 04 ....
------ String Descriptor 1 ------
bLength : 0x0C (12 bytes)
bDescriptorType : 0x03 (String Descriptor)
Language 0x0409 : "USBZH"
Data (HexDump) : 0C 03 55 00 53 00 42 00 5A 00 48 00 ..U.S.B.Z.H.
------ String Descriptor 2 ------
bLength : 0x16 (22 bytes)
bDescriptorType : 0x03 (String Descriptor)
Language 0x0409 : "USB2.0 HID"
Data (HexDump) : 16 03 55 00 53 00 42 00 32 00 2E 00 30 00 20 00 ..U.S.B.2...0. .
48 00 49 00 44 00 H.I.D.
------ String Descriptor 3 ------
bLength : 0x12 (18 bytes)
bDescriptorType : 0x03 (String Descriptor)
Language 0x0409 : "20240411"
Data (HexDump) : 12 03 32 00 30 00 32 00 34 00 30 00 34 00 31 00 ..2.0.2.4.0.4.1.
31 00 1.
HID人机交互QQ群:564808376
UAC音频QQ群:218581009
UVC相机QQ群:331552032
BOT&UASP大容量存储QQ群:258159197
STC-USB单片机QQ群:315457461
USB技术交流QQ群2:580684376
USB技术交流QQ群:952873936