int main()
{
FILE *fp;
unsigned long size;
unsigned char *loc;
fp=fopen("Hello.exe","rb");
if(fp==NULL)
{
printf("\nCouldn't load file");
getchar();
return 0;
}
fseek(fp,0,SEEK_END);
size = ftell(fp);
fseek(fp,0,SEEK_SET);
loc=(unsigned char*)malloc(sizeof(size));
printf("\nSize of file is : %d",size);
if(loc==NULL){
printf("\nError in allocating memory.");
}
printf("\nFread called");
fread(loc,size,1,fp);
printf("\nFread fails:");
return 0;
}
I was trying to load a "Hello World" application into heap and this fread hangs me out.
Can anybody figure out why is this happening out!