file,header,info
Quick Search for:  in language:    
file,header,info
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
C/ C++ Stats

 Code: 451,578 lines
 Jobs: 558 postings

 
Sponsored by:

 

You are in:

 
Login



Latest Code Ticker for C/ C++.
Url Test
By Richard Creary on 8/27


Nice Console Calc
By Andrew Carter on 8/26


Visual Pi Hex 2
By jo122321323 on 8/26


Cascade Clone v1.0
By Paulo Jorente - aka JungleBoy on 8/26


Bubble Sort Algo
By d1rtyw0rm on 8/26


Copy File I/O
By Olivier Bastien on 8/25


Visual Pi Hex
By jo122321323 on 8/25


Click here to see a screenshot of this code!ShortCutSample
By Massimiliano Tomassetti on 8/25

(Screen Shot)

AnPMoneyManager beta
By Anthony Tristan on 8/24


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

EXE Header Info

Print
Email
 
VB icon
Submitted on: 11/3/2000 11:20:56 PM
By: Shoots AndLadders 
Level: Intermediate
User Rating: By 6 Users
Compatibility:C, C++ (general), Microsoft Visual C++, Borland C++

Users have accessed this code 5993 times.
 

(About the author)
 
     Get .exe file header info
 

INCLUDE files:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!

//**************************************
//     
//INCLUDE files for :EXE Header Info
//**************************************
//     
stdio.h
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

//**************************************
//     
// Name: EXE Header Info
// Description:Get .exe file header info
//     
// By: Shoots AndLadders
//
// Inputs:a File to read header of.
//
// Returns:outputs header info
//
//This code is copyrighted and has// limited warranties.Please see http://
//     www.Planet-Source-Code.com/xq/ASP/txtCod
//     eId.830/lngWId.3/qx/vb/scripts/ShowCode.
//     htm//for details.//**************************************
//     

#include <stdio.h>
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(argv[1], "rb")) == NULL) { printf("ERROR: file open error: %s\n", argv[1]); return 1; } fread(&exehead;, sizeof(exehead), 1, fp); printf("EXE file signature: %c%c\n", exehead.id[0], exehead.id[1]); printf("Total bytes on last sectors: %u\n", exehead.lastpg); printf("Total sectors(1 sector = 512 bytes): %u\n", exehead.size); printf("No. of relocation table items: %u\n", exehead.reloc); printf("Header size in paragraphs: %u\n", exehead.headersize); printf("Min. paras. reqd. by program: %u\n", exehead.minpara); printf("Max. paras. reqd. by program: %u\n", exehead.maxpara); printf("Initial value of SS: %u\n", exehead.stackseg); printf("Initial value of SP: %u\n", exehead.stackoff); printf("Header checksum: %u\n", exehead.chksum); printf("Initial value of IP: %u\n", exehead.IP); printf("Initial value of CS: %u\n", exehead.CS); printf("Offset of 1st relocation item: %u\n", exehead.relocoff); printf("Overlay number: %d\n", exehead.overlay); return 0; }


Other 1 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments

 There are no comments on this submission.
 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | C/ C++ Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.