I need to find a unique identifier with any PC.
The only sure way seems to be reading CPU serial number.
How do I do that in vanilla C?
My sole experience is with C, not C++.
I need to find a unique identifier with any PC.
The only sure way seems to be reading CPU serial number.
How do I do that in vanilla C?
My sole experience is with C, not C++.
You'll probably have to do inline assembly. Look at the documentation for your compiler on how exactly to do that. There is no way in pure standard C to do it.
What can this strange device be?
When I touch it, it gives forth a sound
It's got wires that vibrate and give music
What can this thing be that I found?
In general this is a difficult task. It requires reading multiple pieces of information and being able to deal with "reasonable" hardware changes. If it's important to you then you should purchase a commercial solution.
Nope!The only sure way seems to be reading CPU serial number.
Impossible.How do I do that in vanilla C?
OK, thanks for the responses.
Certainly it CAN be done since we purchased a commercial solution some years ago for a different software project.
It isn't what we need now so I thought to write my own code to do it.
Sorry. I took your "impossible" too generally.
I have coded Assembler but that was in MSDOS days so I'd struggle to find the correct calls, today.
If you're just looking for a unique identifier...
uuidgen - Google Search
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I had a look at uuidgen. Managed to download a Windows copy with PUP embedded.
However it doesn't do what I need.
It generates a UUID but it's not repeatable for one computer, i.e. every time it is asked to generate a UUID it comes up with a different one every time.
So not usable for software protection.
assembly - CPUID implementations in C++ - Stack Overflow
But if you're serious about software protection, then consider an off the shelf package. Be wary of spending large amounts of time on s/w protection (in an inferior way) that could be better spent making your actual s/w functionality better.
A machine fingerprint should perhaps consist of (motherboard + cpu + gpu + ram + harddisk). You can change any two and still call it the same machine.
At the moment, you're suggesting if I replace just the CPU in the machine, then your licensing will break.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
The CPUID is not at all unique to the individual CPU, however. It just gives information about the CPU. So as Salem said, you need to combine information and allow a couple pieces to change. That's what a commercial package will do.
If you just want something quick-and-dirty, people often try using the MAC address, although this is easily spoofed and can also obviously change.