summaryrefslogtreecommitdiff
path: root/bgrep.cpp
blob: 87599071171ef48f9ec8869e741033c684bfcbda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <stdio.h>
#include <stdlib.h>
#include "Input.h"

#define THRESHOLD 20480

int main(int argc, char ** argv) {
    unsigned int p = strtol(argv[1], 0, 0);
    char * fn = argv[2];
    Handle * f = new Input(fn);
    
    if (!f) {
	printf("Bleeh.\n");
	exit(-1);
    }
    int l = f->GetSize(), i;
    char * b = (char *) malloc(l);
    
    f->read(b, l);
    
    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);
	}
    }
    
    delete f;
}