What data can a HID device receive?

旧巷老猫 提交于 2019-12-22 04:58:16

问题


I am designing a USB keyboard with special capabilities. What information can such a HID device receive from the host?

Can I via USB:

  • Read data from a form on the screen?
  • Find out what OS the user is on?
  • Find out if there's been an error message?
  • Even 'know' what's going on visually on the screen, i.e. what program is selected or whether the program is windowed or fullscreen?

Thank you!


回答1:


The device can't get any of this information from a standard driver that the operating system supplies because that would be a security issue. It can receive any information that your own driver or application sends it. There are many ways to communicate with it - your device could present multiple interfaces (which will appear as separate devices), multiple endpoints, or use the control channel. You will definitely need to study the spec, and I also found this tutorial helpful.

I have done something similar and used the control channel to exchange feature data with a Windows application (over the standard Windows driver). On Windows, the API calls are HidD_SetFeature() and HidD_GetFeature().

On the device side, my hardware ran embedded Linux and I used the GadgetFS library to create a user-mode driver - much easier to debug than a kernel driver.




回答2:


As others have said, you'll run into issues if you try this with a normal HID. However, there is a project called the USB Rubber Ducky. From their description:

The USB Rubber Ducky isn't your ordinary HID (Human Interface Device). 
Coupled with a powerful 60 MHz 32-bit processor and a simple scripting language

The USB Rubber Ducky looks like a usb-device and is recognized as a HID, but is programmable. You can make a small script that will be typed onto the screen which will allow you to performs the queries you seek.

With the USB Rubber Ducky you can:

  • Read data from a form on the screen? Yes

  • Find out what OS the user is on? Yes

  • Find out if there's been an error message? Yes

  • Even 'know' what's going on visually on the screen, i.e. what program is selected or whether the program is windowed or fullscreen? Yes

    If you aren't hoping to buy this device, at least their firmware is on github so it can provide you a starting point



来源:https://stackoverflow.com/questions/30208215/what-data-can-a-hid-device-receive

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!