在你的罗技鼠标中存储2字节的数据
Storing 2 bytes of data in your Logitech mouse

原始链接: https://www.timwehrle.de/blog/what-if-i-stored-data-in-my-mouse/

这个项目始于好奇:Logitech MX Vertical鼠标的内部闪存是否可以用于数据存储?该鼠标使用Logitech的HID++协议进行通信,提供33个功能,其中一些已记录,一些是逆向工程得到的。作者旨在利用一个非易失性存储功能,最终确定DPI寄存器是唯一可行的选择。 尝试写入其他寄存器,例如设备名称或专用存储槽,被macOS的IOHIDManager阻止,或者直接被鼠标忽略。然而,DPI寄存器接受任何16位值,无需验证,允许在计算机之间传输2字节的持久数据。 虽然客观上毫无用处——2字节的存储空间微乎其微——但该项目的价值在于调查本身。作者深入了解了HID++功能、macOS的HID设备管理以及硬件通信逆向工程的复杂性。代码已在GitHub上提供,供任何想要尝试在Logitech鼠标中存储数据的人使用。

一篇博客文章详细描述了一名用户成功地将2字节的数据存储在罗技鼠标*内部*,这引发了Hacker News上的争论。作者timwehrle将此过程描述为一次学习练习,重点不在于存储的少量数据。 然而,一些评论员怀疑这篇文章是在AI的帮助下撰写的,理由是文风不一致和“LLMisms”(大型语言模型的特征)。作者澄清说,他的写作风格天生就比较冗长,尤其是英语不是他的母语,并且承认在收到初步反馈后编辑了文章。 尽管存在对AI的担忧,但其他人称赞了这篇文章的独创性和与调试令人沮丧的无声系统错误的 relatable 经验。这场讨论凸显了人们对AI生成内容的日益怀疑,以及对可证明的人工努力的偏好,即使写作不够完美。最终,这篇文章与一些人产生了共鸣,认为这是一个有趣但不太实用的技术挑战。
相关文章

原文

It started with a dumb idea. 

I have a Logitech MX Vertical, which travels between my home machine, work laptop and other devices constantly. At some point I looked at it and thought: this thing has a flash memory. It has to, otherwise how does it remember the DPI setting between plugs. So what if I stored something in it?

Yea, I was bored.

The plan was to treat the mouse like a tiny USB drive. Since it physically travels between computers, it could technically carry data with it. 2 bytes on a 64GB stick is embarrassing. 2 bytes in your mouse is art.

Logitech mice communicate over something called HID++, a protocol they built on top of standard USB HID. It's partially documented by Logitech, partially reverse engineered by the open source community. I wrote a Rust tool to enumerate every feature the mouse exposes. Turns out it has 33 of them.

HID++ 2.0 works like this: every device has a feature table. Each entry maps a stable feature ID to a device-specific index. The ID is consistent across all Logitech devices. The index varies per model. So you first ask the device "where is feature 0x2201?" and it tells you "index 0x12 on this mouse". Then you use that index for all subsequent calls. Every call is a short packet: report ID, device index, feature index, function ID, and up to 3 bytes of params. The response comes back in the same shape.

Most are undocumented. Some have names like EnableHiddenFeatures and TemplateBytesNVS. That last one sounds exactly like what I wanted: non-volatile storage, index 0x1eb0.

I spent a while on 0x1c00 first. Six slots, read/write flags, the whole thing. Turns out macOS's IOHIDManager silently blocks the longer HID++ report format you need to actually write to it. The OS just drops the packets. No error, no explanation, nothing. I found this out after writing a pile of probe code and staring at empty responses for longer than I'd like to admit. There are ways around IOHIDManager, like talking directly to the USB device via IOKit, but that's a different story.

The device name register looked promising too. The write calls were accepted. The mouse kept saying "MX Vertical" regardless of what I sent. It was just ghosting me.

What actually worked was the DPI register.

I mean, it's pretty obvious since the DPIs have to be stored somewhere. And it turns out that it accepts any u16 value you throw at it. No rounding, no validation, not a "that's not a real DPI" error. Write 0x6869, unplug the mouse, plug it into a different computer, read it back.

Still “hi”.

That's it. That's the whole thing. 2 bytes of persistent cross-computer storage, living in the DPI register of a Logitech mouse.

I've been thinking about why this kind of project is worth doing at all. The result is objectively useless. 2 bytes is nothing. You could store more data by changing your hostname.

But the investigation was the point. I learned how HID++ works. I learned how macOS manages HID devices at kernel level and where it draws lines. I learned that "feature table" and "feature index" are different things and that the IFeatureSet reverse lookup is apparently broken on this device. I learned that the device name register will politely accept your writes and then completely ignore them, which is a deeply relatable response.

None of the knowledge came from reading docs. It came from poking at a thing until it did something unexpected, then following the thread.

The 2 bytes were never the goal. The goal was to see how far in I could get.

Code is here if you want to store something in your mouse: https://github.com/timwehrle/mouse-fs. Works with any Logitech mouse on a Unifying receiver. 

联系我们 contact @ memedata.com