#include <stdio.h>

unsigned char nops[] = "\x90\x90\x90\x90";

void prize()
{
	printf("prize ran!!!\n");
}

void hexdump_file(char *file)
{
	FILE *fp;
	unsigned char buf[64];
	unsigned int i;
	unsigned int n;
	
	memset(buf,0x00,64);
	printf("address of buf: 0x%08x\n", &buf[0]);

	fp = fopen(file, "r");
	if (fp == NULL)
	{
		printf("Can't open file\n");
		return;
	}

	n = fread(buf,1,128,fp);
	printf("read %d bytes\n", n);
	for (i=0;i<sizeof(buf);i++)
	{
		if (i%16==0&&i!=0)
			printf("\n");
		printf("%02x ", buf[i]);
	}
	printf("\n");
}

int main(int argc, char **argv)
{
	printf("address of nops is: 0x%08x\n", nops);
	printf("address of prize is: 0x%08x\n", prize);
	printf("address of hexdump_file is: 0x%08x\n", hexdump_file);

	if (argc != 2)
	{
		printf("usage: %s filename\n", argv[0]);
		return -1;
	}

	hexdump_file(argv[1]);
	printf("returned from hexdump_file\n");
	return 0;
}