/* * Pro-Wizard_1.c * * 1997-2016 (c) Sylvain "Asle" Chipaux * */ #include "globals.h" #include "extern.h" #include "vars.h" #if 0 int main ( int ac , char **av ) #else int prowizard_search (uint8_t *in_data_p, int PW_in_size_p) #endif { #if 0 printf ( "\n\n-<([ Pro-Wizard v1.70a ])>-\n\n" ); if ( ac != 2 ) { printf ( "%s \n" , av[0] ); printf ( "Check for the documentation for more info !\n" ); exit ( 0 ); } PW_in = fopen ( av[1] , "rb" ); if ( PW_in == NULL ) { printf ( "cant find \"%s\" !\n" , av[1] ); exit ( 0 ); } /* take care of the editable extensions */ Support_Types (); /*printf ( "%x,%x,%x\n" , Extensions[70][0], Extensions[70][1], Extensions[70][2] );*/ /* get input file size */ PW_in_size = PWGetFileSize (av[1]); fseek ( PW_in , 0 , 0 ); /* probably useless */ printf ( "input file size : %d\n" , PW_in_size ); if ( PW_in_size < MINIMAL_FILE_LENGHT ) { printf ( "! input file size is too small ...\n" ); fclose ( PW_in ); exit ( 1 ); } /* alloc mem */ in_data = (uint8_t *) malloc ( PW_in_size ); if ( in_data == NULL ) { perror ( "Couldn't allocate memory" ); exit ( 0 ); } fread ( in_data , PW_in_size , 1 , PW_in ); fclose ( PW_in ); #else Support_Types_FileDefault (); in_data = in_data_p; PW_in_size = PW_in_size_p; #endif /********************************************************************/ /************************** SEARCH ******************************/ /********************************************************************/ for ( PW_i=0 ; PW_i<(PW_in_size-MINIMAL_FILE_LENGHT) ; PW_i+=1 ) { /* display where we are every 10 Kbytes */ /* if ( (PW_i%10240) == 0 )*/ /* {*/ /* ... and rewrites on itself. */ /* printf ( "\r%ld", PW_i );*/ /* force printing on stdout (i.e. the screen) */ /* fflush ( stdout );*/ /* }*/ /*******************************************************************/ /* ok, now the real job starts here. So, we look for ID or Volume */ /* values. A simple switch case follows .. based on Hex values of, */ /* as foretold, ID or volume (not all file have ID ... few in fact */ /* do ..). */ /*******************************************************************/ if ( in_data[PW_i] <= 0x40 ) { /* try to get rid of those 00 hanging all the time everywhere :( */ if ( in_data[PW_i] == 0x00 ) { for ( PW_j = 0 ; PW_j= 1) && (in_data[PW_i-1] == 0x03) ) { if ( testPHA() != BAD ) { Rip_PHA (); Depack_PHA (); } } break; case 0xE0: /* if ( (in_data[PW_i+1] == 0x01) && (in_data[PW_i+2] == 0x00) && (in_data[PW_i+3] == 0x00) && (in_data[PW_i+7] == 0x00) && (in_data[PW_i+8] == 0x01) && (in_data[PW_i+9] == 0x00) && (in_data[PW_i+10] == 0x00) && (in_data[PW_i+11] == 0x00) && (in_data[PW_i+12] == 0x00) ) { if ( testViruz2_E0 () == BAD ) break; continue; }*/ break; default: /* do nothing ... save continuing :) */ break; } /* end of switch */ } #if 0 free ( in_data ); printf ( "\n" ); printf ( " 1997-2016 (c) Sylvain \"Asle\" Chipaux (asle@free.fr)\n\n"); /* getchar();*/ exit ( 0 ); #endif return 0; }