#include <stdio.h>
#include <string.h>
#include <windows.h>

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

unsigned int FileErrorExceptionHandler()
{
	printf("FileErrorExceptionHandler() called\n");
	printf("Killing Process\n");
	ExitProcess(1);
	return 0;
}

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

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

	*bytes_read = fread(buf,1,2048,fp);
	fclose(fp);
	//} __except(FileErrorExceptionHandler())
	//{
		//printf("file was no good\n");
	//}
}

int main(int argc, char **argv)
{
	HMODULE hFlash;
	hFlash = LoadLibrary("Flash6.ocx");
	if (hFlash) {
		printf("loaded flash successfully\n");
	} else {
		printf("flash failed to load\n");
	}
	int n;
	printf("address of prize is: 0x%08x\n", prize);
	printf("address of n is: %x\n", &n);
	n = 0x11223344;
	if (argc != 2)
	{
		printf("usage: %s filename\n", argv[0]);
		return -1;
	}

	read_file(argv[1], &n);
	printf("read_file reported reading %d bytes\n",n);
	return 0;
}



