From 5b2403b222ac4499984b109f98dd34cad6708974 Mon Sep 17 00:00:00 2001 From: Pixel Date: Fri, 19 Jul 2002 09:03:28 +0000 Subject: new file --- bgrep.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 bgrep.cpp 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 +#include +#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); +} -- cgit v1.2.3