From 046857dfb88f05e6b310fe9ef07b9f2d3ac5922d Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Thu, 20 Feb 2014 22:42:56 +0100 Subject: Restructure project, make names more clear --- src/extractblocks_new.c | 131 ------------------------------------------------ 1 file changed, 131 deletions(-) delete mode 100644 src/extractblocks_new.c (limited to 'src/extractblocks_new.c') diff --git a/src/extractblocks_new.c b/src/extractblocks_new.c deleted file mode 100644 index fe85252..0000000 --- a/src/extractblocks_new.c +++ /dev/null @@ -1,131 +0,0 @@ -#include -#include "mystdlib.h" -#include -#include -#include -#include - -/* lha header: - -00 Header length -01 Header checksum [02-length] -02 0x2d ('-') -03 0x6c ('l') -04 0x68 ('h') -05 0x?? ('0' or '5') unsure -06 0x2d ('-') -07 0x?? LSB of compressed size -08 0x?? .. -09 0x00 .. -10 0x00 MSB of compressed size, i.e. 0 -.. -21 Length of path name - - -*/ - -static uint8_t mantra_in[] = { 0x68, 0x35, 0x2d, 0x6c }; - -int main( int args, char **argv ) -{ - int filenum = 0, run = 1; - size_t offset = 0, oldoffset = -1, reported = 0, enc_len = 32; - uint8_t mantra[4], id0, id5, *mappedfile; - MAP map; - - /* For streets we do have a enc_len of 34 */ - while( run ) { - switch( getopt( args, argv, ":e:" ) ) { - case -1 : run = 0; break; - case 'e': - enc_len = atol( optarg ); - break; - default: - fputs( "Syntax: %s [-e encrypted_length (default: 32, for streets 34 or 0)] path-to-teiln.dat", stderr ); exit( 1 ); - break; - } - } - run = 1; - - if( optind == args ) - { fputs( "Missing filename.", stderr ); exit( 1 ); } - - map = map_file( argv[optind], 1 ); - mappedfile = map->addr; - - mantra[0] = mantra_in[0] ^ mappedfile[4]; - mantra[1] = mantra_in[1] ^ mappedfile[5]; - mantra[2] = mantra_in[2] ^ mappedfile[2]; - mantra[3] = mantra_in[3] ^ mappedfile[3]; - - id0 = mappedfile[0]; - id5 = mappedfile[5]; - - while( run ) - { - while( ( offset < map->size ) && ( - ( mappedfile[ offset + 0 ] != id0 ) || - ( mappedfile[ offset + 2 ] != ( '-' ^ mantra[2] )) || - ( mappedfile[ offset + 3 ] != ( 'l' ^ mantra[3] )) || - ( mappedfile[ offset + 4 ] != ( 'h' ^ mantra[0] )) || - ( mappedfile[ offset + 5 ] != id5 ) || - ( mappedfile[ offset + 6 ] != ( '-' ^ mantra[2] )) - ) ) offset++; - - // printf( "Found an appropriate offset at: %zd\n", offset ); - - if( reported < ( offset * 10 ) / map->size ) - { - reported++; - printf( "%zd%% ", 10 * reported ); - fflush( stdout ); - } - - if( offset == map->size ) - run = 0; - - if( oldoffset != -1 ) - { - uint8_t *mf = mappedfile + oldoffset, df[128]; - size_t filename_len, header_len; - char filename_template[32], filename[32]; - int i; - - /* De-"crypt" obfuscation to our header copy */ - for( i=0; i header_len ) { - write( i, df, enc_len ); - write( i, mf + enc_len, offset - oldoffset - enc_len ); - } else { - write( i, df, header_len ); - write( i, mf + header_len, offset - oldoffset - header_len ); - } - close( i ); - } - oldoffset = offset; - offset++; - } - - unmap_file( &map ); - return 0; -} -- cgit v1.2.3