Thread: Serialnumber generation

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    166

    Serialnumber generation

    Hi, for a plugin I'm doing I need to come up with the best way to generate a unique requestnumber that in turn will generate a serialnumber, which will activate the product.

    I have been looking around a bit and found an option to use the MAC Adress of the Network card which is supposed to be unique for every computer. Is that a good way to handle such a thing? I'm not sure if every computer even has a network card...like laptops and such. What I need is some sort of Machine ID that is unique for each computer.

    Keep in mind that I am fairly new to c++ so you will have to explain it to me as if I am a complete idiot.

    cheers,
    Carl-Mikael

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    http://clusty.com/search?query=uuid+...Mozilla-search
    Some systems have an API call to make this for you.
    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.

  3. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    166
    Hmm, that might be something like what I want but isn't a UUID different everytime it is retrieved, like random generated? I need some value that is the same everytime on a specific computer.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Generate it once, then save it somewhere for later retrieval ?

    What if the user changes their network card, and you're relying on the MAC staying constant?
    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.

  5. #5
    Registered User
    Join Date
    Oct 2007
    Posts
    166
    I do not want a specfic copy of the program to be linked to a specific value. The program can be freely downloaded and used in demo mode but needs to bind itself to a specific computer when activated. Is using the MAC adress a good way in that case or is there something better?

    Changing network card is not too common I think and if they do (or change computer)they will be able to contact support for such an issue.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Sounds like you've settled on the MAC address then.

    > I do not want a specfic copy of the program to be linked to a specific value.
    But it (the UUID) is generated on the local machine the first time you run it, and thereafter remains constant.

    Whatever you choose which is bound to physical hardware (MAC address, HD serial number, whatever), you're going to get complaints from people whenever they upgrade. Prepare an extensive FAQ for support.
    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.

  7. #7
    Registered User
    Join Date
    Oct 2007
    Posts
    166
    Well I already do hehe. Right now the activation is tied to an ID that is specific for the program that the plugin is for so whenever they reinstall or upgrade that program I have that issue. If it can be tied to the computer instead it would be a load lifted of me and better for the users. The plugin is currently maxscript based and I am converting it to c++.

    So...is it correct that I can assume that every computer will have a MAC adress? (I will only deal with windows based computers)

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Since you're assuming the delivery mechanism is to download it, then it's pretty safe to assume that there is a MAC address of some sort (I think).

    But then again I tend to think that far too much effort is put into over elaborate, and ultimately ineffective protection mechanisms, where such effort would be better directed at improving the product in the first place.
    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.

  9. #9
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    Is using the MAC adress a good way in that case or is there something better?
    AFAIK MAC addresses are no longer burnt into the hardware. Modern network cards just send everything to the OS for it to deal with. This means that its quite easy to change your MAC address if you want to. One of my teachers showed me how to do it in linux.

  10. #10
    Registered User
    Join Date
    Oct 2007
    Posts
    166
    Salem - It will also need to work on a computer without internet connection. About the need for protection, well nobody is willing to pay for a free program are they? My program is quite extensive and I would not put as much effort into it if it was sharewere. I just need something simple though.

    mike_g - Ok so it might not be such a good idea then.

    I found this in another thread here. Do you think it is a good idea to use something like this? Supposedly the volume serialnumber is possible to change but I don't think that is a thing you generally do. The code:
    Code:
    #include <windows.h>
    
    int GetVolumeSerial()
    {
        DWORD dwVolSerial;
        BOOL bIsRetrieved;
        bIsRetrieved = GetVolumeInformation("C:\\",NULL,NULL,&dwVolSerial,NULL,NULL,NULL,NULL);
        if (bIsRetrieved) 
        {
            int serial = (int)dwVolSerial;
            return serial;
        } 
        return 0;
    }
    This is modified form a sample found here:
    http://cboard.cprogramming.com/showthread.php?p=427642

  11. #11
    Registered User
    Join Date
    Oct 2007
    Posts
    166
    See in my example that typecast the dwVolSerial to an int...is that a safe thing to do? The dwVolSerial can as an example be D403B623. What happens when I type cast that to an int?

  12. #12
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    That data as a string is more than an int can store. If its eight ASCII characters it could be casted as a 'long long'.

  13. #13
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Salem View Post
    But then again I tend to think that far too much effort is put into over elaborate, and ultimately ineffective protection mechanisms, where such effort would be better directed at improving the product in the first place.
    MAC-locking is reasonably simple to do and stops casual or accidental piracy. Shrug.

    Once you start actively considering "Now, if I do this, and then THEY do THIS, then I'll do THIS, etc etc etc..." Then you've gone into pointless-land.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Adventures in labyrinth generation.
    By guesst in forum Game Programming
    Replies: 8
    Last Post: 10-12-2008, 01:30 PM
  2. Labyrinth generation
    By guesst in forum Game Programming
    Replies: 16
    Last Post: 10-09-2008, 06:02 PM
  3. Diablo's random level generation
    By glo in forum Game Programming
    Replies: 7
    Last Post: 07-19-2008, 03:04 AM
  4. C Program with Tone Generation. HELP
    By LaVieEnRose in forum C Programming
    Replies: 1
    Last Post: 11-22-2007, 08:37 PM
  5. Grid generation from scattered points?
    By canada-paul in forum C Programming
    Replies: 6
    Last Post: 12-12-2003, 05:46 PM