Subversion Repositories shark

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
#include <malloc.h>
2
#include <stdio.h>
3
#include "../ll/i386/mb-hdr.h"
4
 
5
/*
6
 * Warning!!! This program does not work properly...
7
 * FIXIT!
8
 */
9
void main(int argc, char *argv[])
10
{
11
    FILE *in;
12
    char *buf,*p;
13
    register scan;
14
    unsigned long multiboot_sign = MULTIBOOT_MAGIC, size;
15
    unsigned long *search;
16
 
17
    if (argc != 2) {
18
        printf("Usage: binfin <file>\n");
19
        exit(0);
20
    }
21
    in = fopen(argv[1],"rb");
22
    if (in == NULL) {
23
        printf("Error! File %s not found\n",argv[1]);
24
        exit(-1);
25
    }
26
    fseek(in, 0, SEEK_END);
27
    size = ftell(in);
28
    buf = malloc(size);
29
    if (buf == NULL) {
30
        printf("Malloc error! Requested : %lu\n",size);
31
        exit(-2);
32
    }
33
    fread(buf,1,size,in);
34
    fclose(in);
35
    for (scan = 0, p = buf; scan < size; scan++,p++) {
36
        search = (unsigned long *)(p);
37
        if (*search == multiboot_sign) {
38
            printf("Gotta! Offset = %lx(%lu)\nAligned = %s",scan,scan, scan == (scan & ~0x00000003) ? "Yes" : "No" );
39
            free(buf);
40
            exit(1);       
41
        }
42
    }
43
    printf("Not found!\n");
44
    exit(1);
45
}