/****************************************************************************/ /** **/ /** Hardlock RUS Demo Program **/ /** **/ /** This demo program is based on the Hardlock application interface, **/ /** called API, to access a Hardlock via a local or a remote port. **/ /** To access the Hardlock remote, HL-Server must be installed first. **/ /** **/ /** Aladdin Knowledge Systems, Germany **/ /** **/ /** Note **/ /** ---- **/ /** The following demo program is not meant to represent a real good **/ /** implementation of software protection into your application. It **/ /** demonstrates the basic use of the Hardlock API functions and is **/ /** thus as short and simple as possible. Please read the manual **/ /** carefully to get an insight in the strategy of the implementation. **/ /** Please keep in mind that there is no general solution for a good **/ /** protection. We provide you with the necessary functions, the **/ /** implementation itself is up to you and your imagination. **/ /** **/ /** Revision history **/ /** ---------------- *** $Log: not supported by cvs2svn $ *** Revision 1.3 2000/02/03 16:41:55 chris *** adapted to new error message routine (HL_ERRMSG) *** *** *** Revision 1.2 1999/10/13 16:31:19 chris *** removed warnings *** *** Revision 1.1 1999/10/13 16:14:22 chris *** Initial revision **/ /****************************************************************************/ #include #include #include #include "hlapi_c.h" #include "demo.h" /* ------------------------------------------------------------------------ */ /* Module address of Hardlock test device and RefKey/VerKey. We generated */ /* the VerifyKey with Latteccino. The API use the keys to identify the */ /* Hardlock with the correct encoding. */ /* The keys defined here are only valid for the demo module. */ /* You have to change module address AND VerKey for your specific Hardlock! */ /* ------------------------------------------------------------------------ */ #define MODAD 29809 Byte RefKey[8] = {'H','A','R','D','L','O','C','K'}; Byte VerKey[8] = {0x18,0x4C,0x97,0xF0,0xC0,0x7A,0x08,0x88}; /****************************************************************************/ /****************************************************************************/ /****************************************************************************/ int main(int argc, char **argv) { Word res; /* Return value from subroutines */ Long BufLen; Byte *LicBuffer; FILE *licf; int num; printf("\n+----------------------------+"); printf("\n| Hardlock RUS Get Data Test |"); printf("\n+----------------------------+\n"); if (argc != 2) { printf(" Usage: %s \n",*argv); return(1); } licf = fopen(*(argv+1),"wb"); if (!licf) { printf(" Cannot create license file: %s\n",*(argv+1)); return(1); } /* ------------------------------------- */ /* First we need to initialize the API : */ /* ------------------------------------- */ res = HLM_LOGIN(MODAD, DONT_CARE, RefKey, VerKey, svk, 0, 0); if(res != STATUS_OK) { printf(" Login: %s\n", HL_ERRMSG(res, 0, NULL, NULL)); return (res); } printf("\n RUS Hardlock with Module address: %d\n", MODAD); res = HL_ACCINF(); switch (res) { case LOCAL_DEVICE: printf(" The Hardlock access is\t\t : Local\n"); break; case NET_DEVICE: printf(" The Hardlock access is\t\t : Remote\n"); break; default: printf(" The Hardlock access is\t\t : No access\n"); break; } printf("\n"); printf(" Getting RUS Data\n"); printf(" ================\n"); BufLen = 0; res = HLM_GETRUSINFO (&BufLen, NULL, 1); if (res != STATUS_OK && res != BUFFER_TOO_SMALL) printf(" GetRUSInfo returns: %s\n", HL_ERRMSG(res, 0, NULL, NULL)); else { printf(" Needed Length : %ld\n", BufLen); LicBuffer = (Byte *) malloc(BufLen); if (LicBuffer) { res = HLM_GETRUSINFO (&BufLen, LicBuffer, 1); printf(" RusInfo returns : %d\n", res); num = fwrite(LicBuffer, 1, BufLen, licf); printf(" License length : %d bytes\n", num); printf(" File written : %s\n", *(argv+1)); fclose(licf); if (!num) return(1); } } /* ---------------------------------------------- */ /* At last we have to release the API structure. */ /* ---------------------------------------------- */ return (HL_LOGOUT()); }