Files correlati : Ricompilazione Demo : [ ] Commento : Progetti e altra roba per Linux git-svn-id: svn://10.65.10.50/trunk@11293 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			100 lines
		
	
	
		
			4.0 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			100 lines
		
	
	
		
			4.0 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
| /****************************************************************************/
 | |
| /**                                                                        **/
 | |
| /**                      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:42:15  chris
 | |
| ***  adapted to new error message routine (HL_ERRMSG)
 | |
| ***
 | |
| ***
 | |
| ***  Revision 1.2  1999/10/13 16:35:56  chris
 | |
| ***  removed warnings
 | |
| ***  
 | |
| ***  Revision 1.1  1999/10/13 16:14:34  chris
 | |
| ***  Initial revision
 | |
| **/
 | |
| /****************************************************************************/
 | |
| #include <stdio.h>
 | |
| #include <string.h>
 | |
| #include <malloc.h>
 | |
| #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;
 | |
| FILE   *licf;
 | |
| Byte   *LicBuffer;
 | |
| int    num;
 | |
| 
 | |
| printf("\n+------------------------------+");
 | |
| printf("\n| Hardlock RUS Write Data Test |");
 | |
| printf("\n+------------------------------+\n");
 | |
| 
 | |
| if (argc != 2)
 | |
|   {
 | |
|   printf(" Usage: %s <update block file>\n",*argv);
 | |
|   return(1);
 | |
|   }
 | |
| 
 | |
| licf = fopen(*(argv+1),"rb");
 | |
| if (!licf)
 | |
|   {
 | |
|   printf(" Cannot open license file: %s\n",*(argv+1));
 | |
|   return(1);
 | |
|   }
 | |
| 
 | |
| LicBuffer = (Byte *) malloc(0x80000); /* 512k */
 | |
| num = fread(LicBuffer,1,0x80000,licf);
 | |
| printf(" License lenght: %d bytes\n",num);
 | |
| fclose(licf);
 | |
| 
 | |
| if (!num)
 | |
|   return(1);
 | |
| 
 | |
| res = HLM_WRITELICENSE(num, LicBuffer, DONT_CARE, 0, 0);
 | |
| 
 | |
| if (res == STATUS_OK)
 | |
|   printf(" HLM_WRITELICENSE returned OK\n");
 | |
| else
 | |
|   printf(" HLM_WRITELICENSE returned: %s\n", HL_ERRMSG(res, 0, NULL, NULL));
 | |
| 
 | |
| return(0);
 | |
| }
 | |
| 
 |