#include #include #include main(int argc, char **argv) { int base[4+1]; int pal0[4+1]; int pal1[4+1]; int pal2[4+1]; int pal3_unused[4+1]; int c; unsigned char c0, c1, c2, cc1, cc2; FILE *ap; int s2=0, x=0; unsigned long i=0, j=0; int fin=0; long where; unsigned char orig[]={ 0x05, 0x48, 0x00, 0x68, 0x01, 0x28, 0x09, 0xD0, 0x01, 0x28, 0x13, 0xDD, 0x02, 0x28, 0x09, 0xD0, 0x03, 0x28, 0x0B, 0xD0, 0x0E, 0xE0, 0x00, 0x00, 0x00, 0x30, 0x07, 0x58, 0x00, 0x48, 0x0A, 0xE0, 0x28, 0x7B, 0x29, 0x50, 0x00, 0x48, 0x06, 0xE0, 0x28, 0x8F, 0x29, 0x50, 0x00, 0x48, 0x02, 0xE0, 0x28, 0xA3, 0x29, 0x50, 0x00, 0x48, 0x70, 0x47, 0x28, 0x67, 0x29, 0x50 }; int target[]= { 0x05, 0x48, 0x00, 0x68, 0x02, 0xB4, 0x07, 0x21, 0x08, 0x40, 0x80, 0x00, 0x03, 0x49, 0x09, 0x18, 0x08, 0x68, 0x02, 0xBC, 0x70, 0x47, 0x00, 0x00, 0x00, 0x30, 0x07, 0x58, 0xC8, 0x66, 0x29, 0x50, 0x28, 0x67, 0x29, 0x50, 0x28, 0x7B, 0x29, 0x50, 0x28, 0x8F, 0x29, 0x50}; int pal3[]={0x04, 0x30, 0x07, 0x58}; int pal4[]={0x04, 0x44, 0x07, 0x58}; int pal5[]={0x04, 0x58, 0x07, 0x58}; ap=fopen("palette4.dll","rb"); if(ap==NULL) { printf("Can not find file palette4.dll \n" ); exit(1); } fin=0; x=0; fin=0; where=ftell(ap); while(!feof(ap) && fin!=2) { c=getc(ap); c0=c; where=ftell(ap); fin=0; for(i=0;i<16 && fin==0;i++) { if(c!=orig[i]) fin=1; c=getc(ap); } if(fin==0) { /* printf("found at %X \n", where); */ fseek(ap,where,SEEK_SET); for(i=0;i<15;i++) c=getc(ap); for(j=0;j<4*32 && fin==0;j++) { for(i=0;i<4;i++) { c=getc(ap); base[i]=c; } /* printf(" %0.2X %0.2X %0.2X %0.2X\n", base[0], base[1], base[2], base[3] ); */ if(base[0]==0x00 && base[1]==0x00 && base[2]==0x00 && base[3]==0x00 ) { fin=1; for(i=0;i<8+3*4;i++) { c=getc(ap); /* printf("found %0.2X \n", c); */ } } } for(i=0;i<4;i++) {c=getc(ap);pal0[i]=c;}; for(i=0;i<4;i++) {c=getc(ap);pal1[i]=c;}; for(i=0;i<4;i++) {c=getc(ap);pal2[i]=c;}; for(i=0;i<4;i++) {c=getc(ap);pal3_unused[i]=c;}; /* printf("pal0=%0.2X %0.2X %0.2X %0.2X \n", pal0[3], pal0[2], pal0[1], pal0[0]); printf("pal1=%0.2X %0.2X %0.2X %0.2X \n", pal1[3], pal1[2], pal1[1], pal1[0]); printf("pal2=%0.2X %0.2X %0.2X %0.2X \n", pal2[3], pal2[2], pal2[1], pal2[0]); printf("pal3=%0.2X %0.2X %0.2X %0.2X \n", pal3[3], pal3[2], pal3[1], pal3[0]); */ j=pal0[3]*256*256*256+pal0[2]*256*256+pal0[1]*256+pal0[0]; j=j-0x60; base[0]=j%256; j/=256; base[1]=j%256; j/=256; base[2]=j%256; j/=256; base[3]=j%256; j/=256; /* printf("base=%0.2X %0.2X %0.2X %0.2X \n", base[3], base[2], base[1], base[0]); */ printf("\nreplace:"); for(i=0;i<32;i++) printf("%0.2X", orig[i]); j=0; printf(":"); for(i=0;i<16;i++) printf("%0.2X", target[j++] ); for(i=0;i<8;i++) printf("%0.2X", target[j++] ); for(i=0;i<4;i++) printf("%0.2X", target[j++] ); for(i=0;i<4;i++) printf("%0.2X", base[i] ); for(i=0;i<4;i++) printf("%0.2X", pal0[i] ); for(i=0;i<4;i++) printf("%0.2X", pal1[i] ); for(i=0;i<4;i++) printf("%0.2X", pal2[i] ); for(i=0;i<4;i++) printf("%0.2X", pal3[i] ); for(i=0;i<4;i++) printf("%0.2X", pal4[i] ); for(i=0;i<4;i++) printf("%0.2X", pal5[i] ); printf("\n"); fin=2; } } if(fin!=2) { printf("Can not generate patch because didn't find string:\n"); for(i=0;i<32;i++) printf("%0.2X", orig[i]); } fclose(ap); }