hid usb通信
(You need Visual Studio.)
(您需要Visual Studio。)
警告 (Warning)
This USB sniffer, because of its user mode method access to hardware, cannot read HID packets with RID at 0, it's due to Windows protection level to prevent keyloggers/spying software.
此USB嗅探器由于其用户模式方法可访问硬件,因此无法读取RID为0的HID数据包,这是由于Windows的保护级别所致,以防止键盘记录器/间谍软件。
Example of use:
使用示例:
DEVICE_VID = 1A2C;
DEVICE_PID = 0001;
USAGE_PAGE = FF00;
USAGE = 0000;
REPORT_ID = FF;
Do not add 0x, else the application will crash (I haven't added 0x prefix support)
不要添加0x,否则应用程序将崩溃(我还没有添加0x前缀支持)
Unfortunately, the write
function can only send 1 byte (+ Report ID byte), it's because I was too lazy to add a fully functional text parse function ^^.
不幸的是, write
函数只能发送1个字节(+报告ID字节),这是因为我懒得添加一个功能齐全的文本解析函数^^。
But it's working, the most important thing, you can verify it via any USB sniffer (use your own values for that).
但这是有效的,最重要的是,您可以通过任何USB嗅探器对其进行验证(为此使用您自己的值)。
介绍 (Introduction)
This article shows you how to using the USB/HID protocol under Windows to be able to send/receive USB packets from any USB devices connected to the PC.
本文向您展示如何在Windows下使用USB / HID协议,以便能够从连接到PC的任何USB设备发送/接收USB数据包。
And without using DLL, just an application is needed.
而且,无需使用DLL,仅需要一个应用程序即可。
背景 (Background)
This article was possible with this WDK sample:
使用此WDK示例可以实现本文:
Basically, it's just a rewrite of this sample, but in a simple form.
基本上,这只是对该示例的重写,但是形式很简单。
使用代码 (Using the Code)
Declaration of variables, WinAPI functions and using: https://pastebin.com/MSRAYJ5b
变量声明,WinAPI函数和使用: https : //pastebin.com/MSRAYJ5b
All that you need is those functions:
您所需要做的就是这些功能:
HidD_Get