-
Notifications
You must be signed in to change notification settings - Fork 496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix machine_id on windows to be like the steam client #1167
Conversation
First, the first available physical network interface is found. Using registry keys to differentiate the physical ones. Then, instead of hashing only the MAC address, we hash 16 bytes where the first 8 are the MAC address. That is because the steam client on windows hashes the first 16 bytes of a struct containing the mac address at the start and only zeroes afterwards.
//Accessing the registry key corresponding to each adapter | ||
string fRegistryKey = | ||
$@"SYSTEM\CurrentControlSet\Control\Network\{{4D36E972-E325-11CE-BFC1-08002BE10318}}\{adapter.Id}\Connection"; | ||
RegistryKey? rk = Registry.LocalMachine.OpenSubKey( fRegistryKey, false ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remember right, registry opens need to be disposed of.
Okay, after investigating with a friend, there's a bit more to it. The bytes afterwards are not always zeroes. I'm on it right now, and I'll update the code. |
After investigating, the structure that is hashed is like this : My computer is a desktop, and I had only one network adapter so the last 8 bytes were always zeroes, after reverse engineering steam a bit more on a friend's laptop we found this. He had Ethernet and wifi as different network adapters, so he had the second part filled. I'll update the code tomorrow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on my machine, I get the same values as the Steam client.
@LelouBil can you add |
Merged in 74a32bb |
I am currently looking at the linux version, and it feels similar, however I have question: What happens if you have more than 2 interfaces? Are we sure it blindly takes the first two it finds, or there's a missing sort by the mac address? Also we might need a fallback to reading non-physical mac addresses if there are no physical ones. |
First, the first available physical network interface is found. Using registry keys to differentiate the physical ones.
Then, instead of hashing only the MAC address, we hash 16 bytes where the first 8 are the MAC address.
That is because the steam client on windows hashes the first 16 bytes of a struct containing the mac address at the start and only zeroes afterwards.