#include
struct EXEHEAD
{
char id[2]; // ‘M’ & ‘Z’
unsigned lastpg; // no of bytes on last page
unsigned size; // total no of 512 byte pages
unsigned reloc; // no of relocation table items
unsigned headersize; // header size in paras
unsigned minpara; // min. paras reqd. by prog.
unsigned maxpara; // max. paras reqd. by prog.
unsigned stackseg; // initial value of stack seg.
unsigned stackoff; // initial value of SP
unsigned chksum; // header check sum
unsigned IP; // entry point IP
unsigned CS; // entry point CS
unsigned relocoff; // offset of 1st relocation item
unsigned char overlay; // overlay number
};
int main(int argc, char *argv[])
{
FILE *fp;
struct EXEHEAD exehead;
if((fp = fopen(“sound.exe”, “rb”)) == NULL)
{
printf(“ERROR: file open errorn”);
return 1;
}
fread(&exehead, sizeof(exehead), 1, fp);
printf(“EXE file signature: %c%cn”, exehead.id[0], exehead.id[1]);
printf(“Total bytes on last sectors: %un”, exehead.lastpg);
printf(“Total sectors(1 sector = 512 bytes): %un”, exehead.size);
printf(“No. of relocation table items: %un”, exehead.reloc);
printf(“Header size in paragraphs: %un”, exehead.headersize);
printf(“Min. paras. reqd. by program: %un”, exehead.minpara);
printf(“Max. paras. reqd. by program: %un”, exehead.maxpara);
printf(“Initial value of SS: %un”, exehead.stackseg);
printf(“Initial value of SP: %un”, exehead.stackoff);
printf(“Header checksum: %un”, exehead.chksum);
printf(“Initial value of IP: %un”, exehead.IP);
printf(“Initial value of CS: %un”, exehead.CS);
printf(“Offset of 1st relocation item: %un”, exehead.relocoff);
printf(“Overlay number: %dn”, exehead.overlay);
return 0;
}
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
























