desowin / usbpcap

USB packet capture for Windows
http://desowin.org/usbpcap
896 stars 170 forks source link

Device address mismatch after windows hibernation when at least 2 devices are connected to same hub #105

Open mkozaaczka opened 4 years ago

mkozaaczka commented 4 years ago

Device address mismatch after windows hibernation when at least 2 devices are connected to same hub

Scenario: 1) Enable hibernation in windows via using following command in cmd.exe "powercfg.exe /hibernate on" 2) Connect mouse and keyboard to same hub (same bus id) 3) Start capture using Wireshark or USBPcapCMD for few seconds then stop it. Observe that device address for injected descriptors and packages that arrives to/from device are matched for instance:

desowin commented 4 years ago

I have reproduced this issue on my laptop (xHCI host controller). I have monitored the USB connection to the mouse with OpenVizsla. The device addresses in Injected descriptors (in user-space USBPcapCMD) are correct. The bug seems to be in kernel-space (USBPcapDriver).

After resuming, USBPcapDriver seems to use the address that was assigned before hibernation. In reality however, the address has changed (in fact it has changed twice; first time by BIOS and then by Windows).

I am not sure if the problem can be reproduced with EHCI host controllers. The important difference between xHCI and EHCI is that xHCI assigns addresses in hardware (OS can check this information; this is why on Linux the device number as seen by usbmon is not necessarily matching the address that was assigned to the device), while with EHCI the address is assigned by kernel software.