home *** CD-ROM | disk | FTP | other *** search
- #include <io.h>
- #include <sys\stat.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <conio.h>
- #include <string.h>
- #include <fcntl.h>
-
- #define KEYSIZE 0x65
- #define FILESIZE 0x400
-
- long Change( char *pBuf )
- {
- static char bKey[] = {
- 0x08, 0x0e, 0x1f, 0x09, 0x1b, 0x0f, 0x08, 0x0f, 0x09
- };
- int i, j, t;
- long lCRC;
-
- j = 1;
- lCRC = 0;
- for( i = 0; i < KEYSIZE; i ++ ){
- t = bKey[ j ] ^ ( pBuf[ i ] ^ j );
- pBuf[ i ] = t;
- lCRC += t << j;
- if( j++ == bKey[ 0 ] ) j = 1;
- }
- return lCRC;
- }
-
- void main( void )
- {
- int nZone, nRegion, nNode, nPoint;
- int nHandle, t;
- char bName[ 64 ], *pBuf;
-
- pBuf = ( char * ) malloc( FILESIZE );
-
- printf( "\nXMK --- XMail 1.00 Key file gen..." );
-
- printf( "\nEnter you Zone: " );
- pBuf[ 0 ] = 6;
- nZone = atoi( cgets( pBuf ) );
-
- printf( "\nEnter you Region: " );
- pBuf[ 0 ] = 6;
- nRegion = atoi( cgets( pBuf ) );
-
- printf( "\nEnter you Node: " );
- pBuf[ 0 ] = 6;
- nNode = atoi( cgets( pBuf ) );
-
- printf( "\nEnter you Point: " );
- pBuf[ 0 ] = 6;
- nPoint = atoi( cgets( pBuf ) );
-
- printf( "\nEnter you Name: " );
- pBuf[ 0 ] = 62;
- cgets( pBuf );
- strcpy( bName, &pBuf[ 1 ] );
-
- memset( pBuf, 0, FILESIZE );
- *( ( int * ) &pBuf[ 0x28c ] ) = nZone;
- *( ( int * ) &pBuf[ 0x28e ] ) = nRegion;
- *( ( int * ) &pBuf[ 0x290 ] ) = nNode;
- *( ( int * ) &pBuf[ 0x292 ] ) = nPoint;
- pBuf[ 0x294 ] = 6; // Flag
- pBuf[ 0x2e9 ] = 100; // Version Flag
- pBuf[ 0x2ef ] = 0x10; // Pro. Flag
- strcpy( &pBuf[ 0x2a9 ], bName );
-
- Change( &pBuf[ 0x28b ] );
- *( ( long * ) &pBuf[ 0x2f1 ] ) = Change( &pBuf[ 0x28b ] );
- Change( &pBuf[ 0x28b ] );
-
- nHandle = open( "XMAIL.KEY", O_TRUNC | O_CREAT | O_WRONLY | O_BINARY );
- write( nHandle, pBuf, FILESIZE );
- close( nHandle );
- free( pBuf );
- }
-