|
|
1.1 ! root 1: /* ! 2: * Title ! 3: * ! 4: * newexe.h ! 5: * (C) Copyright Microsoft Corp 1984-1987 ! 6: * 17 August 1984 ! 7: * ! 8: * Description ! 9: * ! 10: * Data structure definitions for the DOS 4.0/Windows 2.0 ! 11: * executable file format. ! 12: * ! 13: * ! 14: */ ! 15: ! 16: #define EMAGIC 0x5A4D /* Old magic number */ ! 17: #define ENEWEXE sizeof(struct exe_hdr) ! 18: /* Value of E_LFARLC for new .EXEs */ ! 19: #define ENEWHDR 0x003C /* Offset in old hdr. of ptr. to new */ ! 20: #define ERESWDS 0x0010 /* No. of reserved words (OLD) */ ! 21: #define ERES1WDS 0x0004 /* No. of reserved words in e_res */ ! 22: #define ERES2WDS 0x000A /* No. of reserved words in e_res2 */ ! 23: #define ECP 0x0004 /* Offset in struct of E_CP */ ! 24: #define ECBLP 0x0002 /* Offset in struct of E_CBLP */ ! 25: #define EMINALLOC 0x000A /* Offset in struct of E_MINALLOC */ ! 26: ! 27: struct exe_hdr /* DOS 1, 2, 3 .EXE header */ ! 28: { ! 29: unsigned short e_magic; /* Magic number */ ! 30: unsigned short e_cblp; /* Bytes on last page of file */ ! 31: unsigned short e_cp; /* Pages in file */ ! 32: unsigned short e_crlc; /* Relocations */ ! 33: unsigned short e_cparhdr; /* Size of header in paragraphs */ ! 34: unsigned short e_minalloc; /* Minimum extra paragraphs needed */ ! 35: unsigned short e_maxalloc; /* Maximum extra paragraphs needed */ ! 36: unsigned short e_ss; /* Initial (relative) SS value */ ! 37: unsigned short e_sp; /* Initial SP value */ ! 38: unsigned short e_csum; /* Checksum */ ! 39: unsigned short e_ip; /* Initial IP value */ ! 40: unsigned short e_cs; /* Initial (relative) CS value */ ! 41: unsigned short e_lfarlc; /* File address of relocation table */ ! 42: unsigned short e_ovno; /* Overlay number */ ! 43: unsigned short e_res[ERES1WDS];/* Reserved words */ ! 44: unsigned short e_oemid; /* OEM identifier (for e_oeminfo) */ ! 45: unsigned short e_oeminfo; /* OEM information; e_oemid specific */ ! 46: unsigned short e_res2[ERES2WDS];/* Reserved words */ ! 47: long e_lfanew; /* File address of new exe header */ ! 48: }; ! 49: ! 50: #define E_MAGIC(x) (x).e_magic ! 51: #define E_CBLP(x) (x).e_cblp ! 52: #define E_CP(x) (x).e_cp ! 53: #define E_CRLC(x) (x).e_crlc ! 54: #define E_CPARHDR(x) (x).e_cparhdr ! 55: #define E_MINALLOC(x) (x).e_minalloc ! 56: #define E_MAXALLOC(x) (x).e_maxalloc ! 57: #define E_SS(x) (x).e_ss ! 58: #define E_SP(x) (x).e_sp ! 59: #define E_CSUM(x) (x).e_csum ! 60: #define E_IP(x) (x).e_ip ! 61: #define E_CS(x) (x).e_cs ! 62: #define E_LFARLC(x) (x).e_lfarlc ! 63: #define E_OVNO(x) (x).e_ovno ! 64: #define E_RES(x) (x).e_res ! 65: #define E_OEMID(x) (x).e_oemid ! 66: #define E_OEMINFO(x) (x).e_oeminfo ! 67: #define E_RES2(x) (x).e_res2 ! 68: #define E_LFANEW(x) (x).e_lfanew ! 69: ! 70: #define NEMAGIC 0x454E /* New magic number */ ! 71: #define NERESBYTES 10 /* Ten bytes reserved (now) */ ! 72: #define NECRC 8 /* Offset into new header of NE_CRC */ ! 73: ! 74: struct new_exe /* New .EXE header */ ! 75: { ! 76: unsigned short ne_magic; /* Magic number NE_MAGIC */ ! 77: unsigned char ne_ver; /* Version number */ ! 78: unsigned char ne_rev; /* Revision number */ ! 79: unsigned short ne_enttab; /* Offset of Entry Table */ ! 80: unsigned short ne_cbenttab; /* Number of bytes in Entry Table */ ! 81: long ne_crc; /* Checksum of whole file */ ! 82: unsigned short ne_flags; /* Flag word */ ! 83: unsigned short ne_autodata; /* Automatic data segment number */ ! 84: unsigned short ne_heap; /* Initial heap allocation */ ! 85: unsigned short ne_stack; /* Initial stack allocation */ ! 86: long ne_csip; /* Initial CS:IP setting */ ! 87: long ne_sssp; /* Initial SS:SP setting */ ! 88: unsigned short ne_cseg; /* Count of file segments */ ! 89: unsigned short ne_cmod; /* Entries in Module Reference Table */ ! 90: unsigned short ne_cbnrestab; /* Size of non-resident name table */ ! 91: unsigned short ne_segtab; /* Offset of Segment Table */ ! 92: unsigned short ne_rsrctab; /* Offset of Resource Table */ ! 93: unsigned short ne_restab; /* Offset of resident name table */ ! 94: unsigned short ne_modtab; /* Offset of Module Reference Table */ ! 95: unsigned short ne_imptab; /* Offset of Imported Names Table */ ! 96: long ne_nrestab; /* Offset of Non-resident Names Table */ ! 97: unsigned short ne_cmovent; /* Count of movable entries */ ! 98: unsigned short ne_align; /* Segment alignment shift count */ ! 99: unsigned short ne_cres; /* Count of resource entries */ ! 100: char ne_res[NERESBYTES]; ! 101: /* Pad structure to 64 bytes */ ! 102: }; ! 103: ! 104: #define NE_MAGIC(x) (x).ne_magic ! 105: #define NE_VER(x) (x).ne_ver ! 106: #define NE_REV(x) (x).ne_rev ! 107: #define NE_ENTTAB(x) (x).ne_enttab ! 108: #define NE_CBENTTAB(x) (x).ne_cbenttab ! 109: #define NE_CRC(x) (x).ne_crc ! 110: #define NE_FLAGS(x) (x).ne_flags ! 111: #define NE_AUTODATA(x) (x).ne_autodata ! 112: #define NE_HEAP(x) (x).ne_heap ! 113: #define NE_STACK(x) (x).ne_stack ! 114: #define NE_CSIP(x) (x).ne_csip ! 115: #define NE_SSSP(x) (x).ne_sssp ! 116: #define NE_CSEG(x) (x).ne_cseg ! 117: #define NE_CMOD(x) (x).ne_cmod ! 118: #define NE_CBNRESTAB(x) (x).ne_cbnrestab ! 119: #define NE_SEGTAB(x) (x).ne_segtab ! 120: #define NE_RSRCTAB(x) (x).ne_rsrctab ! 121: #define NE_RESTAB(x) (x).ne_restab ! 122: #define NE_MODTAB(x) (x).ne_modtab ! 123: #define NE_IMPTAB(x) (x).ne_imptab ! 124: #define NE_NRESTAB(x) (x).ne_nrestab ! 125: #define NE_CMOVENT(x) (x).ne_cmovent ! 126: #define NE_ALIGN(x) (x).ne_align ! 127: #define NE_CRES(x) (x).ne_cres ! 128: #define NE_RES(x) (x).ne_res ! 129: ! 130: #define NE_USAGE(x) (WORD)*((WORD *)(x)+1) ! 131: #define NE_PNEXTEXE(x) (WORD)(x).ne_cbenttab ! 132: #define NE_ONEWEXE(x) (WORD)(x).ne_crc ! 133: #define NE_PFILEINFO(x) (WORD)((DWORD)(x).ne_crc >> 16) ! 134: ! 135: /* ! 136: * Format of NE_FLAGS(x): ! 137: * ! 138: * p Not-a-process ! 139: * x Unused ! 140: * e Errors in image ! 141: * xx Unused ! 142: * ttt Application type ! 143: * f Floating-point instructions ! 144: * 3 386 instructions ! 145: * 2 286 instructions ! 146: * 0 8086 instructions ! 147: * P Protected mode only ! 148: * p Per-process library initialization ! 149: * i Instance data ! 150: * s Solo data ! 151: */ ! 152: #define NENOTP 0x8000 /* Not a process */ ! 153: #define NEIERR 0x2000 /* Errors in image */ ! 154: #define NEAPPTYP 0x0700 /* Application type mask */ ! 155: #define NENOTWINCOMPAT 0x0100 /* Not compatible with P.M. Windowing */ ! 156: #define NEWINCOMPAT 0x0200 /* Compatible with P.M. Windowing */ ! 157: #define NEWINAPI 0x0300 /* Uses P.M. Windowing API */ ! 158: #define NEFLTP 0x0080 /* Floating-point instructions */ ! 159: #define NEI386 0x0040 /* 386 instructions */ ! 160: #define NEI286 0x0020 /* 286 instructions */ ! 161: #define NEI086 0x0010 /* 8086 instructions */ ! 162: #define NEPROT 0x0008 /* Runs in protected mode only */ ! 163: #define NEPPLI 0x0004 /* Per-Process Library Initialization */ ! 164: #define NEINST 0x0002 /* Instance data */ ! 165: #define NESOLO 0x0001 /* Solo data */ ! 166: ! 167: struct new_seg /* New .EXE segment table entry */ ! 168: { ! 169: unsigned short ns_sector; /* File sector of start of segment */ ! 170: unsigned short ns_cbseg; /* Number of bytes in file */ ! 171: unsigned short ns_flags; /* Attribute flags */ ! 172: unsigned short ns_minalloc; /* Minimum allocation in bytes */ ! 173: }; ! 174: ! 175: #define NS_SECTOR(x) (x).ns_sector ! 176: #define NS_CBSEG(x) (x).ns_cbseg ! 177: #define NS_FLAGS(x) (x).ns_flags ! 178: #define NS_MINALLOC(x) (x).ns_minalloc ! 179: ! 180: /* ! 181: * Format of NS_FLAGS(x): ! 182: * ! 183: * x Unused ! 184: * h Huge segment ! 185: * c 32-bit code segment ! 186: * d Discardable segment ! 187: * DD I/O privilege level (286 DPL bits) ! 188: * c Conforming segment ! 189: * r Segment has relocations ! 190: * e Execute/read only ! 191: * p Preload segment ! 192: * P Pure segment ! 193: * m Movable segment ! 194: * i Iterated segment ! 195: * ttt Segment type ! 196: */ ! 197: #define NSTYPE 0x0007 /* Segment type mask */ ! 198: #define NSCODE 0x0000 /* Code segment */ ! 199: #define NSDATA 0x0001 /* Data segment */ ! 200: #define NSITER 0x0008 /* Iterated segment flag */ ! 201: #define NSMOVE 0x0010 /* Movable segment flag */ ! 202: #define NSSHARED 0x0020 /* Shared segment flag */ ! 203: #define NSPRELOAD 0x0040 /* Preload segment flag */ ! 204: #define NSEXRD 0x0080 /* Execute-only (code segment), or ! 205: * read-only (data segment) ! 206: */ ! 207: #define NSRELOC 0x0100 /* Segment has relocations */ ! 208: #define NSCONFORM 0x0200 /* Conforming segment */ ! 209: #define NSDPL 0x0C00 /* I/O privilege level (286 DPL bits) */ ! 210: #define SHIFTDPL 10 /* Left shift count for SEGDPL field */ ! 211: #define NSDISCARD 0x1000 /* Segment is discardable */ ! 212: #define NS32BIT 0x2000 /* 32-bit code segment */ ! 213: #define NSHUGE 0x4000 /* Huge memory segment, length of ! 214: * segment and minimum allocation ! 215: * size are in segment sector units ! 216: */ ! 217: #define NSPURE NSSHARED /* For compatibility */ ! 218: ! 219: #define NSALIGN 9 /* Segment data aligned on 512 byte boundaries */ ! 220: ! 221: #define NSLOADED 0x0004 /* ns_sector field contains memory addr */ ! 222: ! 223: struct new_segdata /* Segment data */ ! 224: { ! 225: union ! 226: { ! 227: struct ! 228: { ! 229: unsigned short ns_niter; /* number of iterations */ ! 230: unsigned short ns_nbytes; /* number of bytes */ ! 231: char ns_iterdata; /* iterated data bytes */ ! 232: } ns_iter; ! 233: struct ! 234: { ! 235: char ns_data; /* data bytes */ ! 236: } ns_noniter; ! 237: } ns_union; ! 238: }; ! 239: ! 240: struct new_rlcinfo /* Relocation info */ ! 241: { ! 242: unsigned short nr_nreloc; /* number of relocation items that */ ! 243: }; /* follow */ ! 244: ! 245: struct new_rlc /* Relocation item */ ! 246: { ! 247: char nr_stype; /* Source type */ ! 248: char nr_flags; /* Flag byte */ ! 249: unsigned short nr_soff; /* Source offset */ ! 250: union ! 251: { ! 252: struct ! 253: { ! 254: char nr_segno; /* Target segment number */ ! 255: char nr_res; /* Reserved */ ! 256: unsigned short nr_entry; /* Target Entry Table offset */ ! 257: } nr_intref; /* Internal reference */ ! 258: struct ! 259: { ! 260: unsigned short nr_mod; /* Index into Module Reference Table */ ! 261: unsigned short nr_proc; /* Procedure ordinal or name offset */ ! 262: } nr_import; /* Import */ ! 263: struct ! 264: { ! 265: unsigned short nr_ostype; /* OSFIXUP type */ ! 266: unsigned short nr_osres; /* reserved */ ! 267: } nr_osfix; /* Operating system fixup */ ! 268: } nr_union; /* Union */ ! 269: }; ! 270: ! 271: #define NR_STYPE(x) (x).nr_stype ! 272: #define NR_FLAGS(x) (x).nr_flags ! 273: #define NR_SOFF(x) (x).nr_soff ! 274: #define NR_SEGNO(x) (x).nr_union.nr_intref.nr_segno ! 275: #define NR_RES(x) (x).nr_union.nr_intref.nr_res ! 276: #define NR_ENTRY(x) (x).nr_union.nr_intref.nr_entry ! 277: #define NR_MOD(x) (x).nr_union.nr_import.nr_mod ! 278: #define NR_PROC(x) (x).nr_union.nr_import.nr_proc ! 279: #define NR_OSTYPE(x) (x).nr_union.nr_osfix.nr_ostype ! 280: #define NR_OSRES(x) (x).nr_union.nr_osfix.nr_osres ! 281: ! 282: /* ! 283: * Format of NR_STYPE(x): ! 284: * ! 285: * xxxxx Unused ! 286: * sss Source type ! 287: */ ! 288: #define NRSTYP 0x0f /* Source type mask */ ! 289: #define NRSBYT 0x00 /* lo byte */ ! 290: #define NRSSEG 0x02 /* 16-bit segment */ ! 291: #define NRSPTR 0x03 /* 32-bit pointer */ ! 292: #define NRSOFF 0x05 /* 16-bit offset */ ! 293: #define NRSPTR48 0x0B /* 48-bit pointer */ ! 294: #define NRSOFF32 0x0D /* 32-bit offset */ ! 295: ! 296: /* ! 297: * Format of NR_FLAGS(x): ! 298: * ! 299: * xxxxx Unused ! 300: * a Additive fixup ! 301: * rr Reference type ! 302: */ ! 303: #define NRADD 0x04 /* Additive fixup */ ! 304: #define NRRTYP 0x03 /* Reference type mask */ ! 305: #define NRRINT 0x00 /* Internal reference */ ! 306: #define NRRORD 0x01 /* Import by ordinal */ ! 307: #define NRRNAM 0x02 /* Import by name */ ! 308: #define NRROSF 0x03 /* Operating system fixup */ ! 309: ! 310: ! 311: /* Resource type or name string */ ! 312: struct rsrc_string ! 313: { ! 314: char rs_len; /* number of bytes in string */ ! 315: char rs_string[ 1 ]; /* text of string */ ! 316: }; ! 317: ! 318: #define RS_LEN( x ) (x).rs_len ! 319: #define RS_STRING( x ) (x).rs_string ! 320: ! 321: /* Resource type information block */ ! 322: struct rsrc_typeinfo ! 323: { ! 324: unsigned short rt_id; ! 325: unsigned short rt_nres; ! 326: long rt_proc; ! 327: }; ! 328: ! 329: #define RT_ID( x ) (x).rt_id ! 330: #define RT_NRES( x ) (x).rt_nres ! 331: #define RT_PROC( x ) (x).rt_proc ! 332: ! 333: /* Resource name information block */ ! 334: struct rsrc_nameinfo ! 335: { ! 336: /* The following two fields must be shifted left by the value of */ ! 337: /* the rs_align field to compute their actual value. This allows */ ! 338: /* resources to be larger than 64k, but they do not need to be */ ! 339: /* aligned on 512 byte boundaries, the way segments are */ ! 340: unsigned short rn_offset; /* file offset to resource data */ ! 341: unsigned short rn_length; /* length of resource data */ ! 342: unsigned short rn_flags; /* resource flags */ ! 343: unsigned short rn_id; /* resource name id */ ! 344: unsigned short rn_handle; /* If loaded, then global handle */ ! 345: unsigned short rn_usage; /* Initially zero. Number of times */ ! 346: /* the handle for this resource has */ ! 347: /* been given out */ ! 348: }; ! 349: ! 350: #define RN_OFFSET( x ) (x).rn_offset ! 351: #define RN_LENGTH( x ) (x).rn_length ! 352: #define RN_FLAGS( x ) (x).rn_flags ! 353: #define RN_ID( x ) (x).rn_id ! 354: #define RN_HANDLE( x ) (x).rn_handle ! 355: #define RN_USAGE( x ) (x).rn_usage ! 356: ! 357: #define RSORDID 0x8000 /* if high bit of ID set then integer id */ ! 358: /* otherwise ID is offset of string from ! 359: the beginning of the resource table */ ! 360: ! 361: /* Ideally these are the same as the */ ! 362: /* corresponding segment flags */ ! 363: #define RNMOVE 0x0010 /* Moveable resource */ ! 364: #define RNPURE 0x0020 /* Pure (read-only) resource */ ! 365: #define RNPRELOAD 0x0040 /* Preloaded resource */ ! 366: #define RNDISCARD 0xF000 /* Discard priority level for resource */ ! 367: ! 368: /* Resource table */ ! 369: struct new_rsrc ! 370: { ! 371: unsigned short rs_align; /* alignment shift count for resources */ ! 372: struct rsrc_typeinfo rs_typeinfo; ! 373: }; ! 374: ! 375: #define RS_ALIGN( x ) (x).rs_align ! 376:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.