6 static void *map_file(char *fname, size_t *size)
8 int fd = open(fname, O_RDONLY);
13 p = mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
20 int main(int argc, char *argv[])
22 size_t size1, size2, ofs1=0;
25 p1 = map_file(argv[1], &size1);
26 p2 = map_file(argv[2], &size2);
28 while (ofs1 < size1) {
30 char *q, *p = memmem(p2, size2, p1+ofs1, 32);
32 printf("data at %d not found!\n", ofs1);
36 while (p[n] == p1[ofs1+n]) n++;
37 printf("found 0x%x bytes at 0x%x (to 0x%x)\n",
38 n, (int)(p-p2), (int)(n+(p-p2)));