diff options
-rw-r--r-- | bgrep.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/bgrep.cpp b/bgrep.cpp new file mode 100644 index 0000000..f67b39f --- /dev/null +++ b/bgrep.cpp @@ -0,0 +1,27 @@ +#include <stdio.h> +#include <stdlib.h> +#include "fileutils.h" + +int main(int argc, char ** argv) { + unsigned int p = strtol(argv[1], 0, 0); + char * fn = argv[2]; + FILE * f = fopen(fn, "r+"); + + if (!f) { + printf("Bleeh.\n"); + exit(-1); + } + int l = filesize(f), i; + char * b = (char *) malloc(l); + + fread(b, 1, l, f); + + for (i = 0; i < l - 3; i++) { + unsigned int r = *((unsigned int *) &(b[i])); + if (r == p) { + printf("Found 0x%08x at %i = 0x%08x in %s\n", p, i, i, fn); + } + } + + fclose(f); +} |