Subversion Repositories shark

Rev

Rev 3 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1063 tullio 1
 
2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License as published by
5
 * the Free Software Foundation; either version 2 of the License, or
6
 * (at your option) any later version.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 * GNU General Public License for more details.
12
 *
13
 * You should have received a copy of the GNU General Public License
14
 * along with this program; if not, write to the Free Software
15
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 *
17
 */
18
 
2 pj 19
#include <malloc.h>
20
#include <stdio.h>
21
#include "../ll/i386/mb-hdr.h"
22
 
23
/*
24
 * Warning!!! This program does not work properly...
25
 * FIXIT!
26
 */
27
void main(int argc, char *argv[])
28
{
29
    FILE *in;
30
    char *buf,*p;
31
    register scan;
32
    unsigned long multiboot_sign = MULTIBOOT_MAGIC, size;
33
    unsigned long *search;
34
 
35
    if (argc != 2) {
36
        printf("Usage: binfin <file>\n");
37
        exit(0);
38
    }
39
    in = fopen(argv[1],"rb");
40
    if (in == NULL) {
41
        printf("Error! File %s not found\n",argv[1]);
42
        exit(-1);
43
    }
44
    fseek(in, 0, SEEK_END);
45
    size = ftell(in);
46
    buf = malloc(size);
47
    if (buf == NULL) {
48
        printf("Malloc error! Requested : %lu\n",size);
49
        exit(-2);
50
    }
51
    fread(buf,1,size,in);
52
    fclose(in);
53
    for (scan = 0, p = buf; scan < size; scan++,p++) {
54
        search = (unsigned long *)(p);
55
        if (*search == multiboot_sign) {
56
            printf("Gotta! Offset = %lx(%lu)\nAligned = %s",scan,scan, scan == (scan & ~0x00000003) ? "Yes" : "No" );
57
            free(buf);
58
            exit(1);       
59
        }
60
    }
61
    printf("Not found!\n");
62
    exit(1);
63
}