adding registration keys

BlitzMax Forums/BlitzMax Programming/adding registration keys

ckob(Posted 2006) [#1]
I have a way to generate my serial keys but how/whats the best way to check the machine the software is on to make sure its the correct machine?


H&K(Posted 2006) [#2]
You want to make sure your softwere licence is machine specific?
The same way that Microsoft want to with Vista? Ie the thing we slagged off no end?


ckob(Posted 2006) [#3]
yes but I dont want to discuss why I want to or why its frowned about I just would like help.


H&K(Posted 2006) [#4]
Well, ok, you make them connect to your central server, with firewall turned off, and ask the computer for all its details. Probably as well you would ask for ramdom sector information that you have made unmoveable from their Hard drive, and compare it with the last time they were online

For sure very few people will actualy use your software if you asked them to do this. In fact you could probably only get away with it, if you were a semi monopoly operating system publisher


xlsior(Posted 2006) [#5]
It kind of depends on how strictly you want to lock it down...

You can obtain a lot of info about a computer through the windows API:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/computer_system_hardware_classes.asp

Of course, locking any program to the hardware comes with some technical problems, in that it is very common for people to upgrade one or more of their hardware components. Additional memory, bigger harddrive, faster video card, etc.
Windows XP addresses this by determining the info on a lot of different components, and allowing you to make a certain number of changes over a certain time frame. Too many changes in too short a time, and it will want to be re-activated. If you do decide to tie your program to the hardware, that is pretty much a must, or you'll end up with a lot of legitimate users that will be legitimately pissed off that your program stops working. (Especially since they most likely paid for it, or why bother locking it to a computer in the first place?)

I've also seen some software that does a lot more basic test, simply by looking to the name of the computer. That does not actually tie it to specific hardware, but it will limit it to a single computer by that name on your local network -- more than one and you'll get problems thanks to the duplicate name, especially in larger networks that use a domain controller. It's not as 'secure' as looking at the actual hardware, but it's a lot more user friendly to the end user, and allows them limited portability -- as long as their new computer has the same name as the old, they can simply reinstall it regardless of the actual hardware.


ckob(Posted 2006) [#6]
ok that sounds a little better, what about getting the registration key for windows and checking that with the key? not the serial key for windows but the reg key is there a simple way of doing that ?


Amon(Posted 2006) [#7]
You could always invest in "armadillo - Software passport" which would take care of this for you. It generates reg keys, locks to hardware if specified etc..

It may take you some time to implement a system like that but above all implement one that works properly.

Sorry I couldn't be of help.

Incase you want to check out Software Passport: http://siliconrealms.com/index.shtml


H&K(Posted 2006) [#8]
Well, I apologise Ckob, it seems a lot easyer to do than I had thought.


xlsior(Posted 2006) [#9]
ok that sounds a little better, what about getting the registration key for windows and checking that with the key? not the serial key for windows but the reg key is there a simple way of doing that ?


It's in the registry:

windows 95: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion and look for an entry in the right pane called "ProductId"

Windows 98 and ME:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion and look for an entry called "ProductKey"

Windows 2000 and XP: two locations: "ProductKey", one under
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion and another in
HKEY_LOCAL_MACHINE\Software\Microsoft\WinNT\CurrentVersion.

However, this probably isn't going to help you much, since it not as unique as you might think. In large companies, almost all machines are imaged from a single source, meaning they have the same serial/productkey in the registry.

That also includes pretty much any assembly-line computer: If you buy a Dell for example, you'll find a sticker on the case with a product key. However, the installed version on the PC itself got put there from an image in the factory, and there will be tens or hundreds of thousands of other people with the identical code on theirs. The windows key listed on the sticker on the case doesn't come into play until you actually re-install the operating system and it asks you for the key.


ckob(Posted 2006) [#10]
armadillo looks nice but i dont have that kinda cash to throw around :/

I'll have to make my own system im sure, I already have it working with a key but I want to make it more secure so people can't just share their key with someone else.


Kev(Posted 2006) [#11]
ckob,

google hardware serial number set by the manufacturer or PC MAC Address.

both are unique to the owners pc.

kev


popcade(Posted 2006) [#12]
Use Armadillo, a wrapper available here.


FlameDuck(Posted 2006) [#13]
Hardware serial numbers can be a) blocked or b) changed. As can the NIC's MAC Address (assuming the user has a network interface card).

In short, there is no way to lock software to a particular machine. At least not until "trusted computing" takes off, and in that case, it's gonna cost you way more than an armadillo license to get on the list of trusted companies.


ckob(Posted 2006) [#14]
I'll probebly end up using a system which just connects to my database and make sure the key and email address match. This isn't as secure as I would like but armadillo is to expensive and locking it to one machine isn't sounding as good as I thought it would.


Dreamora(Posted 2006) [#15]
FD: How do you change the HD serial?

Thats what I actually would lock it too, to the harddisk and to the windows serial (or a similar non hardware thing). The serial is only to prevent users from installing it on a USB or similar and take it with them.


xlsior(Posted 2006) [#16]
The HD serial actually contains the date and time of its initial format, and can be changed either by doing a low-level format, or IIRC there are tools out there that can modify the information as well. It's written somewhere on the disk itself.


FlameDuck(Posted 2006) [#17]
FD: How do you change the HD serial?
Reformat it.


Winni(Posted 2006) [#18]
Trust and liberal licenses are the best ways to loyal and satisfied customers. Per-device licenses are not very user friendly; if you want to make your customers happy, allow them to install the software on more than one computer. Nobodoy wants to pay twice just because they also want to install the software on a notebook. The reasoning is simple: Nobody usually uses the same program twice at the same time, so why the heck would you need two licenses? Right: To satisfy the vendor's greed, that's the only reason.

In my opinion, selling a license key is okay, but product activation, transmitting of individual hard- and software information and dongling are not.

If you want your customers to trust you, you first have to trust them.


popcade(Posted 2006) [#19]
Armadillo isn't that expensive for commercial products, actually is a very cheap solution.

Otherwise, make your own algo is easy too.


JoshK(Posted 2006) [#20]
Here's an example to get and set regkeys:
Import leadwerks.lwbank
Import "-ladvapi32"

Extern "win32"
   Function RegOpenKey:Int(hKeyParent:Int,SubKey$z,phkResult:Byte Ptr)="RegOpenKeyA@12"
   Function RegCloseKey:Int(hKey:Int)="RegCloseKey@4"
   Function RegCreateKey:Int(hKeyParent:Int,SubKey$z,phkResult:Byte Ptr)="RegCreateKeyA@12"
   Function RegDeleteKey:Int(hKeyParent:Int,SubKey$z)="RegDeleteKeyA@8"
   Function RegSetValueEx:Int(hKey:Int,ValueName$z,Reserved:Int,nType:Int,Bytes:Byte Ptr,size:Int)="RegSetValueExA@24"
   Function RegDeleteValue:Int(hKey:Int,ValueName$z)="RegDeleteValueA@8"
   Function RegEnumKey:Int(hKey:Int,idx:Int,Key:Byte Ptr,size:Int)="RegEnumKeyA@16"
   Function RegEnumValue:Int(hKey:Int,idx:Int,ValueName:Byte Ptr,NameSize:Byte Ptr,Reserved:Int,nType:Byte Ptr,ValueBytes:Byte Ptr,ValueSize:Byte Ptr)="RegEnumValueA@32"
   Function RegQueryValueEx:Int(hKey:Int,ValueName$z,Reserved:Int,nType:Byte Ptr,ValueBytes:Byte Ptr,ValueSize:Byte Ptr)="RegQueryValueExA@24"
EndExtern

Const HKEY_CLASSES_ROOT = $80000000
Const HKEY_CURRENT_USER = $80000001
Const HKEY_LOCAL_MACHINE = $80000002
Const HKEY_USERS = $80000003

Const KEY_QUERY_VALUE = $1
Const KEY_SET_VALUE = $2
Const KEY_CREATE_SUB_KEY = $4
Const KEY_ENUMERATE_SUB_KEYS = $8
Const KEY_NOTIFY = $10
Const KEY_CREATE_LINK = $20
Const SYNCHRONIZE = $100000

Const REG_NONE                            =0
Const REG_SZ                              =1
Const REG_EXPAND_SZ                       =2
Const REG_BINARY                          =3
Const REG_DWORD                           =4
Const REG_DWORD_BIG_ENDIAN                =5
Const REG_LINK                            =6
Const REG_MULTI_SZ                        =7
Const REG_RESOURCE_LIST                   =8
Const REG_FULL_RESOURCE_DESCRIPTOR        =9
Const REG_RESOURCE_REQUIREMENTS_LIST      =10
Const REG_QWORD                           =11

Const KEY_ACCESS_ALL = KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY

Local hkey:Int

If RegOpenKey(HKEY_LOCAL_MACHINE,"SOFTWARE\3DWorldStudio\",Varptr hkey)<>0
	End
EndIf

Local data1:Int=69
Local data2$="Hello"

RegSetValueEx:Int(hKey,"integer",0,REG_DWORD,Varptr data1,4)
RegSetValueEx:Int(hKey,"string",0,REG_SZ,data2.ToCString(),data2.length)

Local nType:Int
Local size:Int

RegQueryValueEx:Int(hKey,"integer",0,Varptr nType,Null,Varptr size)
bank:TBank=CreateBank(size)
RegQueryValueEx:Int(hKey,"integer",0,Null,bank.buf(),Varptr size)
Notify PeekInt(bank,0)

RegQueryValueEx:Int(hKey,"string",0,Varptr nType,Null,Varptr size)
bank:TBank=CreateBank(size)
RegQueryValueEx:Int(hKey,"string",0,Null,bank.buf(),Varptr size)
Notify PeekString(bank,0)



Will(Posted 2006) [#21]
Can you use their MAC address and just lock it to their ethernet card?


Filax(Posted 2007) [#22]
A new version with filetype creation and deletion

Note : Any ideas to set and get binary data ?




ziggy(Posted 2007) [#23]
Filax, any chance to get this source code without HTML tags?


Filax(Posted 2007) [#24]
Maybe by email ? :) Check you mail box