home *** CD-ROM | disk | FTP | other *** search
- /*
- This routine compares dumps to detect bytes
- that satisfy given condition.
- */
-
- #include <io.h>
- #include <fcntl.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <dos.h>
-
- #define TRUE 1
- #define FALSE 0
- #define SIZE_BUF 0x2000
-
- unsigned char buff0[SIZE_BUF];
- unsigned char buff1[SIZE_BUF];
- unsigned char buff2[SIZE_BUF];
- unsigned char buff3[SIZE_BUF];
-
- main( int nargs, char *fname[] )
- {
- int handle0,
- handle1,
- handle2,
- handle3,
- done = FALSE,
- n0, n1, n2, n3, i;
- long p = 0;
- char *file0, *file1, *file2, *file3, *fileres;
- FILE* res;
-
- if( nargs < 6 ){
- printf("\nUsage: compare4 file1 file2 file3 file4 fileres\n");
- exit(0);
- }
- file0 = fname[1];
- file1 = fname[2];
- file2 = fname[3];
- file3 = fname[4];
- fileres = fname[5];
-
- handle0 = open( file0, O_BINARY | O_RDONLY );
- if( handle0 == -1 ){
- printf("\nCan't open file %s", file0 );
- exit(0);
- }
-
- handle1 = open( file1, O_BINARY | O_RDONLY );
- if( handle1 == -1 ){
- printf("\nCan't open file %s", file1 );
- exit(0);
- }
-
- handle2 = open( file2, O_BINARY | O_RDONLY );
- if( handle2 == -1 ){
- printf("\nCan't open file %s", file2 );
- exit(0);
- }
-
- handle3 = open( file3, O_BINARY | O_RDONLY );
- if( handle3 == -1 ){
- printf("\nCan't open file %s", file3 );
- exit(0);
- }
-
- if(( res = fopen( fileres, "w" )) == NULL){
- printf("\nCan't open file %s", fileres );
- exit(0);
- }
-
- done = FALSE;
- while( !done ){
- if(( n0 = read( handle0, buff0, SIZE_BUF )) != SIZE_BUF )
- done = TRUE;
- if(( n1 = read( handle1, buff1, SIZE_BUF )) != SIZE_BUF )
- done = TRUE;
- if(( n2 = read( handle2, buff2, SIZE_BUF )) != SIZE_BUF )
- done = TRUE;
- if(( n3 = read( handle3, buff3, SIZE_BUF )) != SIZE_BUF )
- done = TRUE;
- i = 0;
- while( i < n0 && i < n1 && i < n2 && i < n3 ){
-
- if( buff0[i] - buff1[i] != 0 ) /* Change this condition */
- if( buff1[i] - buff2[i] != 0 ) /* for every concrete */
- if( buff2[i] - buff3[i] != 0 ) /* situation */
-
- fprintf( res, "%08lX\t%X\t%X\t%X\t%X\n", p, buff0[i], buff1[i], buff2[i], buff3[i] );
-
- i++;
- p++;
- }
- }
- close( handle0 );
- close( handle1 );
- close( handle2 );
- close( handle3 );
- fclose( res );
- }