diff options
author | Pixel <Pixel> | 2002-07-19 09:03:28 +0000 |
---|---|---|
committer | Pixel <Pixel> | 2002-07-19 09:03:28 +0000 |
commit | 5b2403b222ac4499984b109f98dd34cad6708974 (patch) | |
tree | 07626b822fd8eaf6122ed7411ee895f79f384418 | |
parent | 4ec72c36d4c8d5bbade0d828a184b20340e5e140 (diff) |
new file
-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); +} |