Unit IceLock

************************************************************************** IceLock, v2.0b ============== Copyright 1996,97 - B. Walker IceBrakr@ix.netcom.com See the end of this section for history information, and new features! Well folks, here it is, finally, the new version! This is the easiest way to handle registration of your delphi applications. Or, at least, the easiest for me. Oh, and legal stuff, this component is FreeWare, I make no guarantees, or warranties of any kind, you use this at your own risk. And I definately do not guarantee it is secure. I, and others, have tried to hack using this, with no success...so It's probably "pretty good protection"...nothing is perfect.. On to usage... First, customize IceLock: modify the following Constants: UserPad ProgPad MasterKey (this is an array of values for masking the record, when written to a file) ** The defaults will work just fine, but, if you use the defaults, anybody with this component can create valid keys for your applications!!. ** In the Create method modify the variable initialization for: fSeedVal1 { These can also be set at design time } fSeedVal2 Seed { Set in the Create Method, because it's Private! } And any others you may wish to modify... This will make your copy of IceLock, ** much ** different from anybody elses. If you are really worried about hackers, read further into the source, there are plenty of notes for further obfuscating the keys/files. Next, install this component in your component palette, it automatically installs into the 'Samples' page. Now, to use it, drop on your main form, modify the properties (most particularly IceString1 and IceString2.. possibly also the KeyFileName). And you are affectively done, for a minimum install...call LoadKeyFile then either check the result of LoadKeyFile, or check the IsRegistered variable to see if it's registered. A better example of usage is in the IceReg application, included with version 1.0. This application is a fully functional database, for tracking users/applications and keys... Make sure that you re-build this application, using the copy of IceLock that you have modified/installed into delphi...otherwise, the keys created will be invalid!. ** The Most important thing to remember!! When you create keys for users, the ** fProgKey1 and fProgKey2 must be the same when you check the key!!! This ** is why I suggest modifying the above mentioned const/variables, and then ** specify unique IceStrings for each application, this is the easiest way to ** go...(unless you find an easier way...) Last bit, have fun with this... All I ask is that you give credit where it is due....and if you come up with cool enhancements, please send them to me, so I can keep track of modifications, and re-release with a new version number... If you find a hole, that you cannot plug, let me know, again, I can probably plug it..and re-release. History ------- v1.0 - Initial release, with a few buggies. After receiving a lot of questions and suggestions ....requests for feature, and a new version of the source code from Jorge Cue (Thanks!), we are now at.... v2.0 - Fixed the bugs (I hope), fixed the source code to compile under Delphi version 1, 2 AND 3!! Added the following files, so you do not have to recompile the library everytime you switch from different versions of Delphi. Note: There may still be a problem using it in Delphi1, if you first install in 2/3, If you get Unit file format error, just erase ICELOCK.DCU, and Delphi will rebuild it: ilock16.pas : Delphi 1 component. ilock32.pas : Delphi 2 component. ilock332.pas : Delphi 3 component. - All version will support the same key! (assuming your program is using the same IceString1 and IceString2. Also, now the ProgramKeys should calculate the same for all versions. NOTE: The key files are transportable in both 32-bit versions, but the 32-bit keys will not work in 16-bit (see below) - Jorge Cue had added a HDSerialNumber to the registration record. problem is, he had to use ASM to get the HD Serial. This works when compiled using D1, but only under Win95 (or something like that). I modified his GetHdSerialNumber to be a little more portable, if not as secure under Win3.1. For 16-bit apps, I use GetWinFlags to get a longint with information about the current version and operating mode of windows. Under Win32 I use the Win32 API function GetVolumeInformation to actually get the HD serial number. These procedures will require a user to re-enter his/her Registered Name and Key if the environment/ HD serial number changes. - The last change Jorge Cue implemented was, Licensetype. In the code he sent me, he used an enumerated type, I changed it to a boolean property "DemoLicense". This will be set to true when a user enters a key you have generated with DemoLicense set to true. I also added a TrialDays property, that lets you select the number of days a trial license is good for. This way, when a user enters their key, and it happens to be a demo key, the systems automatically generates an expiration date, and includes it in the key. This requires that you program not allow them to enter the key again! Of course, users could just delete the key and start again...of course you could modify the program to put the key somewhere strange (or even the registry), and maybe mark it read-only/hidden....on and on...sorry, I'm rambling. - Now LoadKey will return ieExpired or ieNotSameHD if the license is expired, or the environment/HDserial changes. See error constants for the rest. - New (cheezy...and much smaller) demo program. Very basic. For a more detailed demo, get Icelock 1.0 - Oh, and last, but not least, the source code is not as heavily commented as v1.0. Sorry, but I lack the ambition to comment it again with all the changes. Thanks again to Jorge Cue, and all the other folks who have given me feedback on this (and in one case sent me a license to a spiffy Delphi 1.0 expert!)

Classes

tIceLock - *************************************************************************) (*** ***) (*** Here it is!!! The tIceLock Component!! ***) (*** ***) (

Functions

Types

aIceArray
CRCBuffType
KeyString
NameString
pIceArray
rIceRecord
sstring

Constants

ieExpired
ieFileError
ieInvalidKey
ieNotSameHD
ieOkay
ProgPad
UserPad

Variables


Functions


Types


aIceArray = Array[1..SizeOf(rIceRecord)] of Byte;
This is a Record and it's associated pointer, which is used to "encrypt/decrypt" the IceRecord, before storage in a file... Note that it will adjust to any changes made to rIceRecord..
CRCBuffType = ARRAY[0..70] OF BYTE;
Buffer for calculating CRC values
KeyString   = String[9]
String for holding Keys
NameString  = String[50]
String for holding Names
pIceArray = ^aIceArray

rIceRecord = record
Name : NameString;
Key : KeyString;
HDSerialNo : LongInt;
DemoLicense : Boolean;
ExpirationDate : TDateTime;
end;

sstring = ShortString
The CRC Lookup Table.. You're best bet is to NOT MUCK } { WITH THIS!! If you do, it could affect the security } { of the keys..

Constants

ieExpired = 4

+++ This KeyFile was not make on this Hard Disk

ieFileError = 2

Key is invalide

ieInvalidKey = 1

Everything Okay

ieNotSameHD = 3

Some file error occurred, check LastIoResult for } { error code

ieOkay = 0

* Error Constants

ProgPad = #42

UserPad = #42

+++ Temporary License Has Expired } (** Feel free to change these to mind fuck others, this allows an added level of security against other programers who have this code

Variables