views:

1894

answers:

3

What is the best way to generate a unique hardware ID on Microsoft Windows with C++ that is not easily spoofable (with for example changing the MAC Address)?

+6  A: 

Windows stores a unique Guid per machine in the registry at:

HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\MachineGuid
AgileJon
You could use this with the name of your program as the key to an HMAC hash function in CAPI.
Jeff Moser
Is that standard on ALL Versions of Windows? What about Mobile Windows?
JoshBerke
The question would be "how easy is that to spoof...?"
jesup
Hint for all 64-bit users: Pass KEY_WOW64_64KEY as samDesired to RegOpenKeyEx(), since Windows only creates a 64-bit key which is mapped into an own key.
Patrick Daryll Glandien
I am not sure that this MachineGuid is *really* hardware driven. For example, if I reformat the hard disk and install a new copy of windows, will this id remain same?
Hemant
I'm really not sure what the MachineGuid is based on. If it's truly a Guid then it may just be generated at install time (ie: it may stay the same)... rather than something like a hash of your hardware S/Ns.
AgileJon
A: 

There are various IDs assigned to hardware that can be read and combined to form a machine key. For example, you could get the ID of the hard drive where the software is stored, the proc ID, etc. Some of these can be set more easily than others, but part of the strength is in combining multiple pieces together that are not necessarily strong enough by themselves.

GalacticCowboy
A: 

Use Win32 System HDS apis
Don't read the registry, it has no sense at all.