summaryrefslogtreecommitdiff
path: root/bgrep.cpp
blob: b3ff3242cfb53cb84fc857a624352539dba922f3 (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
30
31
32
33
34
#include <stdio.h>
#include <stdlib.h>
#include "Input.h"
#include "Main.h"

#define THRESHOLD 20480

CODE_BEGINS
virtual int startup() throw (GeneralException) {
    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;

    return 0;
}
CODE_ENDS