// SubDataSearch #include #include #include #include typedef struct Info_ { unsigned long off; unsigned char* inp1; unsigned char* inp2; unsigned long size;}Info; typedef struct Addr_ { unsigned int f1:32; unsigned int f2:32; unsigned int f3:32; unsigned int sz:32;}Addr; FILE *f1,*f2,*f3,*f4,*f5,*f0,*f0_; unsigned char *p0,*p1,*p2,*p3,*p4,*p5,*w,*q,*r,*t,c; unsigned long s1,s2,s3,s4,s5,s6,s,i,j,k,per,maxsize,a1[65537],*a3[65537],*a2,b1[65537],*b3[65537],*b2; bool b; Addr addr; Info *p6,*pp6,*I; int main(int ParamCount,const char *ParamString[]){ParamCount--; if (ParamCount<1)return 0; f1=fopen(ParamString[1],"rb"); f2=fopen(ParamString[2],"rb"); f3=fopen(ParamString[3],"rb"); fseek(f1,0,2);s1=ftell(f1);fseek(f1,0,0); fseek(f2,0,2);s2=ftell(f2);fseek(f2,0,0); fseek(f3,0,2);s3=ftell(f3);fseek(f3,0,0); p1=(unsigned char*)malloc(s1+2); p2=(unsigned char*)malloc(s2+2); p3=(unsigned char*)malloc(s3+2); fread(p1,1,s1,f1); fread(p2,1,s2,f2); fread(p3,1,s3,f3); p1[s1]=0; p2[s2]=0; p3[s3]=0; f4=fopen(ParamString[4],"wb"); f5=fopen(ParamString[5],"wb"); if (s1>s2) s5=s1; else s5=s2; s4=0;s6=0; p4=(unsigned char*)malloc(s5+2); p5=(unsigned char*)malloc(s5+2); p0=(unsigned char*)malloc(s5+2); memset(p4,0,s5); memset(p5,'0',s5); memset(p0,'0',s5); p6=(Info*)malloc(sizeof(Info)*s5); pp6=p6; per=(s1/100)+1;maxsize=2; sscanf(ParamString[6],"%d",&maxsize); f0=fopen("0.txt","wb");f0_=fopen("0_.txt","wb"); memset(a1,0,65536*sizeof(unsigned long)); memset(a3,0,65536*sizeof(unsigned long*)); s2--;s=0; for (q=p2;q2) { memset(b1,0,65536*sizeof(unsigned long)); memset(b3,0,65536*sizeof(unsigned long*)); s3--;s=0; for (q=p3;qk){ r=q;b=true;k=s;} } } if (k=s5){ printf("Out of memory\n");return 1;} memcpy(p4+s4,r,k); pp6->off=s4; pp6->size=k; pp6->inp1=w; pp6->inp2=r; s4+=k; *(p5+s4-1)='1'; pp6++;s6++; } } //for (w=p4;woff+1; for (q=p4+I->off+1;qsize<=p4+s4)&&(memcmp(I->inp1,q,I->size)==0)&&(memcmp(t,p0,I->size-1)==0)) {b=false;break;} t++; } if(b){ addr.f1=I->inp1-p1; addr.f2=I->inp2-p2; addr.f3=ftell(f4); addr.sz=I->size; fwrite(&addr,1,sizeof(Addr),f5); fwrite(I->inp1,1,I->size,f4); fwrite(p5+I->off,1,I->size,f0);fwrite(p4+I->off,1,I->size,f0_); // for(i=0;isize;i++){printf("%c",*((I->inp1)+i));} //printf("\t| %d\t| %d\t| %d\n",I->inp1-p1,I->inp2-p2,I->size); } } fclose(f1);fclose(f2);fclose(f3);fclose(f4);fclose(f5); // getchar(); return 0;}