Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Every time I format my system, I get a different MAC address (Windows XP, VISTA and Windows7). Why I am not getting same MAC every time?

Every time I format my system, I get a different MAC address (Windows XP, VISTA and Windows7). Why I am not getting same MAC every time?

Scheduled Pinned Locked Moved C / C++ / MFC
helppythonsalesquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Aseem Sharma
    wrote on last edited by
    #1

    Hello friends, I am using MAC address to implement licensing in my application. As far as I know, MAC address of every system is unique and is very commonly used for licensing purpose. For giving license of my application, I generate a unique key based on MAC address of a particular system and send that key to the customer. But the problem is that every time I format my system, I get a different MAC address. Doing this is problematic as every time customer format his system, he will need a new key (as his MAC address will also change on formatting his system). Another problem is that if someone have two OS say XP and VISTA on his machine, he'll need two different keys to activate the license on both of the OS. What I want, I get same MAC address even though customer keep on formatting his system (so that he can use same key every time). Also I get same MAC address on all the Operating Systems on a single machine (so that he can use same key on all the Operating Systems on his machine). Is it possible to do so? If yes then how? If not then why not? Please help me. Right now I am using below code to get MAC address of a system:

    std::string strMACAddress;
    try
    {
    PIP_ADAPTER_INFO pAdapterInfo = NULL;
    ULONG ulOutBufLen = sizeof (IP_ADAPTER_INFO);
    pAdapterInfo = new IP_ADAPTER_INFO();
    if (pAdapterInfo == NULL)
    {
    return;
    }

    // Make an initial call to GetAdaptersInfo to get
    // the necessary size into the ulOutBufLen variable
    int iResult = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen);
    if ( iResult == ERROR\_BUFFER\_OVERFLOW )
    {
    	delete pAdapterInfo;
    	pAdapterInfo = new IP\_ADAPTER\_INFO\[ulOutBufLen\];
    	if (pAdapterInfo == NULL)
    	{
    		return;
    	}
    }
    
    if ( iResult != ERROR\_SUCCESS )
    {
    	iResult = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen);
    	if ( iResult != ERROR\_SUCCESS )
    	{
    		delete pAdapterInfo;
    		pAdapterInfo = NULL;
    		return;
    	}	
    }
    
    strMACAddress = pAdapterInfo->AdapterName;
    delete pAdapterInfo;
    pAdapterInfo = NULL;
    

    }
    catch (...)
    {
    }

    Thanks in advance, Best Regards Aseem

    E C 2 Replies Last reply
    0
    • A Aseem Sharma

      Hello friends, I am using MAC address to implement licensing in my application. As far as I know, MAC address of every system is unique and is very commonly used for licensing purpose. For giving license of my application, I generate a unique key based on MAC address of a particular system and send that key to the customer. But the problem is that every time I format my system, I get a different MAC address. Doing this is problematic as every time customer format his system, he will need a new key (as his MAC address will also change on formatting his system). Another problem is that if someone have two OS say XP and VISTA on his machine, he'll need two different keys to activate the license on both of the OS. What I want, I get same MAC address even though customer keep on formatting his system (so that he can use same key every time). Also I get same MAC address on all the Operating Systems on a single machine (so that he can use same key on all the Operating Systems on his machine). Is it possible to do so? If yes then how? If not then why not? Please help me. Right now I am using below code to get MAC address of a system:

      std::string strMACAddress;
      try
      {
      PIP_ADAPTER_INFO pAdapterInfo = NULL;
      ULONG ulOutBufLen = sizeof (IP_ADAPTER_INFO);
      pAdapterInfo = new IP_ADAPTER_INFO();
      if (pAdapterInfo == NULL)
      {
      return;
      }

      // Make an initial call to GetAdaptersInfo to get
      // the necessary size into the ulOutBufLen variable
      int iResult = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen);
      if ( iResult == ERROR\_BUFFER\_OVERFLOW )
      {
      	delete pAdapterInfo;
      	pAdapterInfo = new IP\_ADAPTER\_INFO\[ulOutBufLen\];
      	if (pAdapterInfo == NULL)
      	{
      		return;
      	}
      }
      
      if ( iResult != ERROR\_SUCCESS )
      {
      	iResult = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen);
      	if ( iResult != ERROR\_SUCCESS )
      	{
      		delete pAdapterInfo;
      		pAdapterInfo = NULL;
      		return;
      	}	
      }
      
      strMACAddress = pAdapterInfo->AdapterName;
      delete pAdapterInfo;
      pAdapterInfo = NULL;
      

      }
      catch (...)
      {
      }

      Thanks in advance, Best Regards Aseem

      E Offline
      E Offline
      enhzflep
      wrote on last edited by
      #2

      At the end of the day you're only querying a software function that returns the MAC address of the NIC. So as long as the TCP drivers all query the same software function, you can use either the actual MAC address, or an arbitrary one - so long as the software function can return (a) the hardware encoded address and (b)some other arbitrary value. In fact, using only the MAC of the NIC is one of the laziest, sloppiest (and most easily defeated) licensing schemes I can think of. You bigger problem is the fact that one copy of the software (and it's MAC-specific key) can be freely given to and used by anybody that is inclined to change their MAC address to suit the registration key. Been there done that, still got the t-shirt. http://www.klcconsulting.n[^]Here's some quick tidbits:http://www.klcconsulting.net/Change\_MAC\_w2k.htm Pulling serial numbers from Motherboards & HDDs are typically more effective - This is what ZBrush 3.0 used to use. But seriously, if your product is worth protecting it's worth spending a couple of $100 on isn't it? You're far better off using a commercial protector that utilizes a virtual machine and obfuscates the machine code at the same time. Armadillo was(is) a pretty good exe packer/encryptor/anti-debugger (http://www.siliconrealms.com/) ASPack is also a b**tard to reverse engineer. VmProtect is one nasty piece of work. Virtual machine and obfuscation (http://www.vmprotect.ru/) The point is - these folks spend their working weeks coming up with protections schemes. You spend it coming up with the app.Would you service your own car if you kinda had a vague idea of what you were doing, while you knew you could afford to pay somebody that knew all of the idiosyncrasies of the particular model and any little tricks and tips for dealing with them?? If it's worth protecting - I'd suggest you do it properly.

      A 1 Reply Last reply
      0
      • E enhzflep

        At the end of the day you're only querying a software function that returns the MAC address of the NIC. So as long as the TCP drivers all query the same software function, you can use either the actual MAC address, or an arbitrary one - so long as the software function can return (a) the hardware encoded address and (b)some other arbitrary value. In fact, using only the MAC of the NIC is one of the laziest, sloppiest (and most easily defeated) licensing schemes I can think of. You bigger problem is the fact that one copy of the software (and it's MAC-specific key) can be freely given to and used by anybody that is inclined to change their MAC address to suit the registration key. Been there done that, still got the t-shirt. http://www.klcconsulting.n[^]Here's some quick tidbits:http://www.klcconsulting.net/Change\_MAC\_w2k.htm Pulling serial numbers from Motherboards & HDDs are typically more effective - This is what ZBrush 3.0 used to use. But seriously, if your product is worth protecting it's worth spending a couple of $100 on isn't it? You're far better off using a commercial protector that utilizes a virtual machine and obfuscates the machine code at the same time. Armadillo was(is) a pretty good exe packer/encryptor/anti-debugger (http://www.siliconrealms.com/) ASPack is also a b**tard to reverse engineer. VmProtect is one nasty piece of work. Virtual machine and obfuscation (http://www.vmprotect.ru/) The point is - these folks spend their working weeks coming up with protections schemes. You spend it coming up with the app.Would you service your own car if you kinda had a vague idea of what you were doing, while you knew you could afford to pay somebody that knew all of the idiosyncrasies of the particular model and any little tricks and tips for dealing with them?? If it's worth protecting - I'd suggest you do it properly.

        A Offline
        A Offline
        Aseem Sharma
        wrote on last edited by
        #3

        Hi friend, Thanks for reply. Yeah, you are right in that one should use third party licensing libraries. But my software is very cheap. It would cost around 5-8 dollars per license. Also I don't know if I could capture the market. So cannot afford to buy any licensing scheme. But yes, as you said licensing based on MAC address is not a good approach. Can you help me in how get serial number of mother board? 3-4 months back, I did try to get serial number of mother board using WMI. But I could not do so. If you can provide some sample code about how to get serial number of mother board using any other mean (but using C++ only)? Regards Aseem Sharma

        1 Reply Last reply
        0
        • A Aseem Sharma

          Hello friends, I am using MAC address to implement licensing in my application. As far as I know, MAC address of every system is unique and is very commonly used for licensing purpose. For giving license of my application, I generate a unique key based on MAC address of a particular system and send that key to the customer. But the problem is that every time I format my system, I get a different MAC address. Doing this is problematic as every time customer format his system, he will need a new key (as his MAC address will also change on formatting his system). Another problem is that if someone have two OS say XP and VISTA on his machine, he'll need two different keys to activate the license on both of the OS. What I want, I get same MAC address even though customer keep on formatting his system (so that he can use same key every time). Also I get same MAC address on all the Operating Systems on a single machine (so that he can use same key on all the Operating Systems on his machine). Is it possible to do so? If yes then how? If not then why not? Please help me. Right now I am using below code to get MAC address of a system:

          std::string strMACAddress;
          try
          {
          PIP_ADAPTER_INFO pAdapterInfo = NULL;
          ULONG ulOutBufLen = sizeof (IP_ADAPTER_INFO);
          pAdapterInfo = new IP_ADAPTER_INFO();
          if (pAdapterInfo == NULL)
          {
          return;
          }

          // Make an initial call to GetAdaptersInfo to get
          // the necessary size into the ulOutBufLen variable
          int iResult = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen);
          if ( iResult == ERROR\_BUFFER\_OVERFLOW )
          {
          	delete pAdapterInfo;
          	pAdapterInfo = new IP\_ADAPTER\_INFO\[ulOutBufLen\];
          	if (pAdapterInfo == NULL)
          	{
          		return;
          	}
          }
          
          if ( iResult != ERROR\_SUCCESS )
          {
          	iResult = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen);
          	if ( iResult != ERROR\_SUCCESS )
          	{
          		delete pAdapterInfo;
          		pAdapterInfo = NULL;
          		return;
          	}	
          }
          
          strMACAddress = pAdapterInfo->AdapterName;
          delete pAdapterInfo;
          pAdapterInfo = NULL;
          

          }
          catch (...)
          {
          }

          Thanks in advance, Best Regards Aseem

          C Offline
          C Offline
          cp9876
          wrote on last edited by
          #4

          Is there any reason why you are using the AdaptorName member of PIP_ADAPTER_INFO rather than the Address member?

          Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

          A 1 Reply Last reply
          0
          • C cp9876

            Is there any reason why you are using the AdaptorName member of PIP_ADAPTER_INFO rather than the Address member?

            Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

            A Offline
            A Offline
            Aseem Sharma
            wrote on last edited by
            #5

            Actually I found that Address member on many machines comes as an empty string. But it was AdaptorName member of PIP_ADAPTER_INFO which return the string such as "4960B27D-C24F-4C8B-886E-4E6BB93913C4".

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups