Software Distributor
Free Copy Protection
Software Downloads
Help>Sample Code For C++
Software Distributor
Copy Protection
Menu
Info
Company
Resources
Copy Protection Sample Code for C++

// Put this code in your Main routine

// The following EXEs and DLLs are required along with your
// program:
// ZSSGL.exe
// ZSSGLOCK.dll
// ZSSGCRC32.dll

BOOLEAN bShutdown; // Required for ShareGuard Lock
// Start ShareGuard Lock
bShutdown = ShareGuardLockTest(); // Call the Lock Program
  if (bShutdown == TRUE)
     {
     MessageBox(0, "Application will be shut down due to
previous reason.", "Error!",
     MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);
       return 0;
     }
// End ShareGuard Lock

// Here is the subroutine
// Start ShareGuard Lock
//-------------------------------------------------//
// ShareGuard Lock Routine
// Returns the boolean result of whether the
// application should be shut down.
// TRUE - shut down the application
// FALSE - application is fine
//-------------------------------------------------//
BOOL ShareGuardLockTest()
{
//-------------------------------------------------//
// Declaratives
//-------------------------------------------------//
BOOLEAN bShutdown;

CHAR *hexresult;
CHAR *reasoncode;
INT i;
CHAR *myresult;
CHAR *myreasoncode;
HINSTANCE hinstDLL = LoadLibrary ("ZSSGCRC32.DLL");
FARPROC CRC32FileCheck = GetProcAddress (hinstDLL,"CRC32FileCheck");
HINSTANCE hinstLockDLL = LoadLibrary ("ZSSGLOCK.DLL");
FARPROC ShareGuardLock = GetProcAddress (hinstLockDLL,"ShareGuardLock");
// ZSSGLOCK.DLL V1.5 CRC Value is BDC9352B
// ZSSGLOCK DLL V2.0 CRC Value is 7DB4D285
char *filename = "ZSSGLOCK.DLL";
char *hexanswer = "7DB4D285";
char *rcanswer = "0";
// This is where the ShareGuard Lock parameters are entered
char *lockparms = "ZSSGL.EXE /D /A030 /R030 /$0.00 /I
/KDC97C8877E90E4DA /LD9A4C239E763D306
/Hwww.zappersoftware.com
/Mwebmaster@zappersoftware.com /NWilliam_Bradshaw /OFile_Editor
/PFileEditor.exe /Uwww.zappersoftware.com /TFile_Editor_Demo";
//-------------------------------------------------//
// Check the CRC Value of ZSSGLOCK.DLL to ensure
// that nobody has replaced it with a dummy module
//-------------------------------------------------//
bShutdown = FALSE; // initialize the Shutdown to false
if (CRC32FileCheck != NULL)
     hexresult = CRC32FileCheck(filename);
else
   {
     MessageBox(0, "DLL not successfully loaded -
application will terminate.", "ShareGuard Error",
     MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);
     bShutdown = TRUE;
   }
myresult = (char *)malloc(9*sizeof(char)); // Room for 8 characters, plus null...
myresult = hexresult;
if(strcmp(hexanswer,myresult)!=0)
   {
       MessageBox(0, "CRC not valid for ZSSGLOCK.DLL - application will terminate.",
"ShareGuard Error", MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);
       bShutdown = TRUE;
   }
// Do not free library until result has been tested
if (CRC32FileCheck != NULL)
   FreeLibrary (hinstDLL);
free(myresult);
//-------------------------------------------------//
// Check the reason code of the demo to see if it
// still a demo or production or has expired or...
// NOTE: Only reason code 0 is valid
//-------------------------------------------------//
if (ShareGuardLock != NULL)
   reasoncode = ShareGuardLock(lockparms);
else
   {
     MessageBox(0, "DLL not successfully loaded",
"ShareGuard Error",
MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);
     bShutdown = TRUE;
   }
// Room for 1 character, plus null...
myreasoncode = (char *)malloc(2*sizeof(char));
myreasoncode = reasoncode;
if(strcmp(rcanswer,myreasoncode)!=0)
   {
     MessageBox(0, "Reason code not not valid for
ZSSGLOCK.DLL - application will terminate.", "ShareGuard Error",
MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);
       bShutdown = TRUE;
   }
// Do not free library until result has been tested
if (ShareGuardLock != NULL)
   FreeLibrary (hinstLockDLL);
free(myreasoncode);
return bShutdown;
}
// End ShareGuard Lock

NOTE: The previous code says to create a main routine and then call the subroutine. It should actually either be inline code (in your form create or startup code) or you can place "magic numbers" or something else to ensure that the subroutine has been executed. A hacker could, conceivably, bypass the subroutine call. Adding some additional tests makes it much more difficult. This code was setup this way to isolate what exact coding is required.

Simple Copy Protection Code Snippet
This code snippet is really easy as you just embed it within FormCreate of your module and then change the LocksmithParameters to the generated parameters from the ShareGuard Locksmith Lock Page.
Get The FREE Software:
Company Summary:

- Incorporated in 1995

- Consulting Services to Fortune 500 companies

- Developing software since 1980

- Developer Member of ASP

Products and Services for Windows and IBM

Software Distributor

Copyright © 1995-2004 Zapper Software 510862 B.C. Ltd. All rights reserved. Privacy Policy