1 | /* $Id: MZexe.h,v 1.1 2002-02-24 02:47:22 bird Exp $
|
---|
2 | *
|
---|
3 | * MZ DEFINITIONS AND DECLARATIONS.
|
---|
4 | * --------------------------------
|
---|
5 | *
|
---|
6 | * Copyright Robert J. Amstadt 1993
|
---|
7 | * Copyright IBM Corp 1984-1992
|
---|
8 | * Copyright IBM Corp 1987-1992
|
---|
9 | * Copyright Microsoft Corp 1984-1987
|
---|
10 | * Copyright knut st. osmundsen 2001 (I've messed them up ;-)
|
---|
11 | *
|
---|
12 | */
|
---|
13 |
|
---|
14 | #ifndef _MZexe_h_
|
---|
15 | #define _MZexe_h_
|
---|
16 |
|
---|
17 |
|
---|
18 | /*
|
---|
19 | * The EXE.h way of declaring this struct.
|
---|
20 | */
|
---|
21 | struct exe
|
---|
22 | {
|
---|
23 | unsigned short eid; /* contains EXEID, below */
|
---|
24 | unsigned short elast; /* # of bytes in last page */
|
---|
25 | unsigned short epagsiz; /* # of pages in whole file */
|
---|
26 | unsigned short erelcnt; /* # of relocation entrys */
|
---|
27 | unsigned short ehdrsiz; /* size of header, in paragraphs */
|
---|
28 | unsigned short eminfre; /* min # of free paragraphs needed */
|
---|
29 | unsigned short emaxfre; /* max # of free paragraphs needed */
|
---|
30 | unsigned short eiSS; /* initial SS value */
|
---|
31 | unsigned short eiSP; /* initial SP value */
|
---|
32 | unsigned short enegsum; /* negative sum of entire file */
|
---|
33 | unsigned short eiIP; /* initial IP value */
|
---|
34 | unsigned short eiCS; /* initial CS value */
|
---|
35 | unsigned short ereloff; /* offset in file of relocation table */
|
---|
36 | unsigned short eovlnum; /* number of the overlay */
|
---|
37 |
|
---|
38 | /*
|
---|
39 | * the following fields may not be present.
|
---|
40 | * ereloff = 28 not present
|
---|
41 | * = 30 exe.ever present and valid
|
---|
42 | * = 32 exe.ever field contains garbage
|
---|
43 | * ereloff > 32 exe.ever present and valid
|
---|
44 | * = 0 if "don't know"
|
---|
45 | */
|
---|
46 | unsigned short ever; /* version # of producing linker */
|
---|
47 | unsigned short dumy; /* unused */
|
---|
48 |
|
---|
49 | /*
|
---|
50 | * the following fields may not be present - if the exe.ereloff
|
---|
51 | * value encompasses the fields then they are present and valid.
|
---|
52 | */
|
---|
53 | unsigned short ebb; /* behavior bits */
|
---|
54 | unsigned short dumy2[7]; /* must be 0 until defined */
|
---|
55 | };
|
---|
56 |
|
---|
57 |
|
---|
58 |
|
---|
59 | /*
|
---|
60 | * The NEWEXE.h way of declaring this header.
|
---|
61 | */
|
---|
62 | #define EMAGIC 0x5A4D /* Old magic number */
|
---|
63 | #define ENEWEXE sizeof(struct exe_hdr) /* Value of E_LFARLC for new .EXEs */
|
---|
64 | #define ENEWHDR 0x003C /* Offset in old hdr. of ptr. to new */
|
---|
65 | #define ERESWDS 0x0010 /* No. of reserved words (OLD) */
|
---|
66 | #define ERES1WDS 0x0004 /* No. of reserved words in e_res */
|
---|
67 | #define ERES2WDS 0x000A /* No. of reserved words in e_res2 */
|
---|
68 | #define ECP 0x0004 /* Offset in struct of E_CP */
|
---|
69 | #define ECBLP 0x0002 /* Offset in struct of E_CBLP */
|
---|
70 | #define EMINALLOC 0x000A /* Offset in struct of E_MINALLOC */
|
---|
71 | struct exe_hdr /* DOS 1, 2, 3 .EXE header */
|
---|
72 | {
|
---|
73 | unsigned short e_magic; /* Magic number */
|
---|
74 | unsigned short e_cblp; /* Bytes on last page of file */
|
---|
75 | unsigned short e_cp; /* Pages in file */
|
---|
76 | unsigned short e_crlc; /* Relocations */
|
---|
77 | unsigned short e_cparhdr; /* Size of header in paragraphs */
|
---|
78 | unsigned short e_minalloc; /* Minimum extra paragraphs needed */
|
---|
79 | unsigned short e_maxalloc; /* Maximum extra paragraphs needed */
|
---|
80 | unsigned short e_ss; /* Initial (relative) SS value */
|
---|
81 | unsigned short e_sp; /* Initial SP value */
|
---|
82 | unsigned short e_csum; /* Checksum */
|
---|
83 | unsigned short e_ip; /* Initial IP value */
|
---|
84 | unsigned short e_cs; /* Initial (relative) CS value */
|
---|
85 | unsigned short e_lfarlc; /* File address of relocation table */
|
---|
86 | unsigned short e_ovno; /* Overlay number */
|
---|
87 | unsigned short e_res[ERES1WDS];/* Reserved words */
|
---|
88 | unsigned short e_oemid; /* OEM identifier (for e_oeminfo) */
|
---|
89 | unsigned short e_oeminfo; /* OEM information; e_oemid specific */
|
---|
90 | unsigned short e_res2[ERES2WDS];/* Reserved words */
|
---|
91 | long e_lfanew; /* File address of new exe header */
|
---|
92 | };
|
---|
93 |
|
---|
94 |
|
---|
95 |
|
---|
96 | /*
|
---|
97 | * The NT way of declaring this header.
|
---|
98 | */
|
---|
99 | typedef struct
|
---|
100 | {
|
---|
101 | unsigned short e_magic; /* MZ Header signature */
|
---|
102 | unsigned short e_cblp; /* Bytes on last page of file */
|
---|
103 | unsigned short e_cp; /* Pages in file */
|
---|
104 | unsigned short e_crlc; /* Relocations */
|
---|
105 | unsigned short e_cparhdr; /* Size of header in paragraphs */
|
---|
106 | unsigned short e_minalloc; /* Minimum extra paragraphs needed */
|
---|
107 | unsigned short e_maxalloc; /* Maximum extra paragraphs needed */
|
---|
108 | unsigned short e_ss; /* Initial (relative) SS value */
|
---|
109 | unsigned short e_sp; /* Initial SP value */
|
---|
110 | unsigned short e_csum; /* Checksum */
|
---|
111 | unsigned short e_ip; /* Initial IP value */
|
---|
112 | unsigned short e_cs; /* Initial (relative) CS value */
|
---|
113 | unsigned short e_lfarlc; /* File address of relocation table */
|
---|
114 | unsigned short e_ovno; /* Overlay number */
|
---|
115 | unsigned short e_res[4]; /* Reserved words */
|
---|
116 | unsigned short e_oemid; /* OEM identifier (for e_oeminfo) */
|
---|
117 | unsigned short e_oeminfo; /* OEM information; e_oemid specific */
|
---|
118 | unsigned short e_res2[10]; /* Reserved words */
|
---|
119 | unsigned long e_lfanew; /* Offset to extended header */
|
---|
120 | } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
|
---|
121 |
|
---|
122 | #define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */
|
---|
123 |
|
---|
124 |
|
---|
125 |
|
---|
126 | #endif
|
---|