使用C++在Windows上捕获鼠标HID数据包?

huangapple go评论66阅读模式
英文:

Capture mouse HID packets on windows using C++?

问题

我想摒弃Razer Synapse,因为它占用了高达600MB的内存,却毫无用处。我只想使用我的宏来控制我Razer Deathadder上的两个额外按键。我已经成功地使用C++ HID API捕获了我的Corsair K95键盘的HID数据包,并执行了我的宏,最终能够告别iCUE。但我无法将鼠标作为HID设备打开。一切都应该配置正确,包括VID/PID、UsagePage和Usage。但有趣的是,Wireshark可以捕获鼠标,但对我来说却不能,即使我尝试以管理员权限打开它也不行。有人有任何想法我应该怎么做吗?

我尝试过HIDAPI C++库的hidapitester应用程序,它会自动关闭设备并不接收任何数据。如果不能以这种方式解决,我应该采取哪种方法来捕获数据包呢?

谢谢。

英文:

I want to ditch Razer Synapse because it eats up to 600MB of RAM for nothing. I just want to use my macros for two additional keys found on my Razer Deathadder. I've sucessfully captured the HID packets for my Corsair K95 keyboard with C++ HID API and executed my macros, finally was able to say bye bye to iCUE. But I'm not able to open mouse as HID device. Everything should be configured properly, VID/PID, UsagePage and Usage too. But the interesting thing is that wireshark is able to capture the mouse, for me it doesn't for even when I try to open it with admin priveliges. Does somebody have any idea what I should do?

I've tried hidapitester application which is part of HIDAPI C++ library, it automatically closes the device and doesn't receive anything. If it's not possible to solve it in this way, which approach I should use to be able to capture the packets?

Thank you.

答案1

得分: 1

你不能打开键盘和鼠标 HID 设备句柄,出于安全原因(这样你就无法编写键盘记录器等)。这是 Windows 的设计之一。

官方解决方法是编写键盘/鼠标过滤驱动程序。

英文:

You cannot open keyboard and mouse hid device handles for a security reasons (so you can’t write a keylogger etc). It by design in Windows.

https://learn.microsoft.com/en-us/windows-hardware/drivers/hid/top-level-collections-opened-by-windows-for-system-use

Official workaround is to write a keyboard/mouse filter driver.
https://learn.microsoft.com/en-us/samples/microsoft/windows-driver-samples/mouse-input-wdf-filter-driver-moufiltr/

huangapple
  • 本文由 发表于 2023年2月18日 17:33:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/75492411.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定