+ Reply to Thread
Results 1 to 12 of 12

Thread: How to hide license keys in windows registry

  1. #1
    Senior Member
    Join Date
    Aug 2004
    Location
    Dehradun, India
    Posts
    363

    Question How to hide license keys in windows registry

    Hi,

    I am a newbie at windows programming, and I am having some diffculty with some (probably simple) things.

    (a) I want to hide license keys in the registry. Someone mentioned in this forum that you could register an OLE object or something like that. How can I do that? Any pointers to information / Api functions etc would be appreciated.

    (b) I would like to programmatically obtain the name of system folders like the Program files folder or the Application data folder. Any w32api functions that would allow me to do that?

    Thanks in advance,
    Pallav

  2. #2
    Senior Member
    Join Date
    Oct 2004
    Location
    Prague
    Posts
    444

    Default

    a) I don't think it is wise to try to "obfuscate" your registry settings in any way. Why? It makes me angry, for instance :-). The most effort in this regard I would find acceptable is encrypting the contents of a registry key...

    b) SHGetFolderPath - http://msdn.microsoft.com/library/de..._appendixa.asp

  3. #3
    Member
    Join Date
    Aug 2004
    Location
    Linköping, Sweden
    Posts
    57

    Default

    To get the path of a "special folder" in Windows, use the function SHGetFolderPath(). Just Google it or look it up in MSDN. It's very straight-forward.

    EDIT: I must be blind. Sorry for repeating what mot said.
    Mattias Brynervall
    Bitbliss Studios

  4. #4
    Senior Member
    Join Date
    Aug 2004
    Location
    Dehradun, India
    Posts
    363

    Default

    Quote Originally Posted by mot
    a) I don't think it is wise to try to "obfuscate" your registry settings in any way.
    First, thanks for your answer. I am not trying to hide all my registry settings, just trying to hide the serial key for obvious reasons. I don't think encryption helps here at all.
    Last edited by Pallav Nawani; 08-30-2005 at 08:40 PM. Reason: Corrected a typo

  5. #5

    Default

    Encrypting the serial key with a fixed key will not do any good, because the encrypted key can be copied across machines. To make things a bit harder for a hacker/cracker, you could encrypt with a key made up from machine information, such as the network MAC address. That way, the same key looks different on every machine once encrypted and so it's no use copying it.

  6. #6
    Senior Member
    Join Date
    Aug 2004
    Location
    New Zealand
    Posts
    126

    Thumbs up

    Quote Originally Posted by pallavnawani
    trying to hide the serial key
    All the would-be pirate needs to do is run a free program like Regmon that shows what registry keys a program is accessing.

    So as far as I know, you can't work with the registry without the computer's owner being able to tell, if they are prepared to look.

    But the others seem to have a good idea.

  7. #7
    Member
    Join Date
    Feb 2005
    Location
    Issaquah, WA
    Posts
    85

    Default

    First let me say, buying third party software protection is the way to go - they do all this for you. For instance, I use EXECryptor which has functions to create registry keys in random locations based on a mishmash of unique hardware ids such as ethernet, disk id, CPU id. I assume others like Software Passport do too. This way, even if the hac*er can figure out where you store it on their system it will be different on other systems. What I would do would be to have a function that returned a random GUID based on the hardware id and then stick that somewhere in the registry.
    Living Desktops - Bring your Desktop to Life!
    Screensavers and Living Desktops

  8. #8

    Default

    Quote Originally Posted by Travis Dorschel
    First let me say, buying third party software protection is the way to go - they do all this for you.
    Just to prevent another Licensing Keys flaming, please take a look at http://indiegamer.com/forums/showthread.php?t=2161.

    To summarize the main counters of using third party licensing software:
    (1) they cost (lots of) money;
    (2) they are typically not cross-platform (especially Mac);
    (3) they are not built by you, and sometimes hard to integrate with your game (especially for custom-made buy screens).

    Regards,

    Alex

  9. #9
    Member
    Join Date
    Aug 2004
    Location
    Liverpool, UK
    Posts
    49

    Default

    Thought I'd reuse this thread rather than create a new one as it's closely related...

    I'm looking for simple bit of code that can save an int to the registry, and also some code to retrieve it again. I've searched for simple code for this but everything i find is either MFC or far too complicated (retrieving lists of pair values etc.) I just want to store one int. Can anyone can point me to a simple online guide or relevant MSDN page? or perhaps paste some code here... that'd be cool
    Paul - Shoecake Games - http://www.shoecakegames.com

  10. #10
    Senior Member
    Join Date
    Sep 2004
    Location
    Netherlands
    Posts
    849

    Default

    From one of my games:
    Code:
    #ifdef _WIN32
    #define REGISTRY_KEY  "Software\\shoecake\\Some Cool Game"
    #endif
    
    int load_setting_int(const char* name, int def)
    {
    #ifdef _WIN32
    	HKEY handle;
    
    	LONG err = ::RegOpenKeyEx(
    		HKEY_CURRENT_USER, REGISTRY_KEY, 0, KEY_QUERY_VALUE, &handle);
    
    	if (err != ERROR_SUCCESS) { return def; }
    
    	DWORD value;
    	DWORD size = sizeof(value);
    	DWORD type = REG_DWORD;
    
    	err = ::RegQueryValueEx(
    		handle, name, NULL, &type, (LPBYTE) &value, &size);
    
    	::RegCloseKey(handle);
    
    	if (err != ERROR_SUCCESS) { return def; }
    
    	return (int) value;
    #else
    # error Not implemented yet
    #endif
    }
    
    ////////////////////////////////////////////////////////////////////////////////
    
    char* load_setting_string(const char* name)
    {
    #ifdef _WIN32
    	HKEY handle;
    
    	LONG err = ::RegOpenKeyEx
    		(HKEY_CURRENT_USER, REGISTRY_KEY, 0, KEY_QUERY_VALUE, &handle);
    
    	if (err != ERROR_SUCCESS) { return NULL; }
    
    	char* str = NULL;
    	DWORD size = 1;
    
    	err = ::RegQueryValueEx(handle, name, NULL, NULL, NULL, &size);
    	if (err == ERROR_SUCCESS)
    	{
    		str = (char*) malloc(size);
    
    		DWORD type = REG_SZ;
    
    		err = ::RegQueryValueEx(
    			handle, name, NULL, &type, (LPBYTE) str, (DWORD*) &size);
    
    		if (err != ERROR_SUCCESS)
    		{
    			free(str); str = NULL;
    		}
    	}
    
    	::RegCloseKey(handle);
    
    	return str;
    #else
    # error Not implemented yet
    #endif
    }
    
    ////////////////////////////////////////////////////////////////////////////////
    
    void save_setting_int(const char* name, int value)
    {
    #ifdef _WIN32
    	HKEY handle;
    	DWORD disposition;
    
    	LONG err = ::RegCreateKeyEx(
    		HKEY_CURRENT_USER, REGISTRY_KEY, 0, NULL, REG_OPTION_NON_VOLATILE,
    		KEY_WRITE, NULL, &handle, &disposition);
    
    	if (err != ERROR_SUCCESS) { return; }
    
    	err = ::RegSetValueEx(
    		handle, name, 0, REG_DWORD, (LPBYTE) &value, sizeof(value));
    		
    	::RegCloseKey(handle);
    #else
    # error Not implemented yet
    #endif
    }
    
    ////////////////////////////////////////////////////////////////////////////////
    
    void save_setting_string(const char* name, const char* str)
    {
    #ifdef _WIN32
    	HKEY handle;
    	DWORD disposition;
    
    	LONG err = ::RegCreateKeyEx(
    		HKEY_CURRENT_USER, REGISTRY_KEY, 0, NULL, REG_OPTION_NON_VOLATILE,
    		KEY_WRITE, NULL, &handle, &disposition);
    
    	if (err != ERROR_SUCCESS) { return; }
    
    	err = ::RegSetValueEx(
    		handle, name, 0, REG_SZ, (LPBYTE) str, strlen(str) + 1);
    		
    	::RegCloseKey(handle);
    #else
    # error Not implemented yet
    #endif
    }

  11. #11
    Member
    Join Date
    Aug 2004
    Location
    Liverpool, UK
    Posts
    49

    Default

    Hi mahlzeit,

    Thanks for the code! it looks exactly what i was after and is certainly enough to get me up to speed on the whole registry subject.

    thanks!
    Paul - Shoecake Games - http://www.shoecakegames.com

  12. #12
    Senior Member
    Join Date
    Jul 2004
    Location
    Calgary, AB
    Posts
    522

    Default for future reference..

    They also have some registry loading and stuffing code within the DXUtil.h/.cpp common folder of the DX8.1/9.0 samples...

    You can even load/store GUID's this way..

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts