Windows NT 4.0 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

645 lines
22 KiB

4 years ago
  1. /*
  2. * SCCSID = @(#)newexe.h 13.4 89/06/26
  3. *
  4. * Title
  5. *
  6. * newexe.h
  7. * Pete Stewart
  8. * (C) Copyright Microsoft Corp 1984-1995
  9. * 17 August 1984
  10. *
  11. * Description
  12. *
  13. * Data structure definitions for the DOS 4.0/Windows 2.0
  14. * executable file format.
  15. *
  16. * Modification History
  17. *
  18. * 84/08/17 Pete Stewart Initial version
  19. * 84/10/17 Pete Stewart Changed some constants to match OMF
  20. * 84/10/23 Pete Stewart Updates to match .EXE format revision
  21. * 84/11/20 Pete Stewart Substantial .EXE format revision
  22. * 85/01/09 Pete Stewart Added constants ENEWEXE and ENEWHDR
  23. * 85/01/10 Steve Wood Added resource definitions
  24. * 85/03/04 Vic Heller Reconciled Windows and DOS 4.0 versions
  25. * 85/03/07 Pete Stewart Added movable entry count
  26. * 85/04/01 Pete Stewart Segment alignment field, error bit
  27. * 85/10/03 Reuben Borman Removed segment discard priority
  28. * 85/10/11 Vic Heller Added PIF header fields
  29. * 86/03/10 Reuben Borman Changes for DOS 5.0
  30. * 86/09/02 Reuben Borman NSPURE ==> NSSHARED
  31. * 87/05/04 Reuben Borman Added ne_cres and NSCONFORM
  32. * 87/07/08 Reuben Borman Added NEAPPTYPE definitions
  33. * 88/03/24 Wieslaw Kalkus Added 32-bit .EXE format
  34. * 89/03/23 Wieslaw Kalkus Added ne_flagsothers for OS/2 1.2
  35. */
  36. /*INT32*/
  37. /*_________________________________________________________________*
  38. | |
  39. | |
  40. | DOS3 .EXE FILE HEADER DEFINITION |
  41. | |
  42. |_________________________________________________________________|
  43. * */
  44. #define EMAGIC 0x5A4D /* Old magic number */
  45. #define ENEWEXE sizeof(struct exe_hdr)
  46. /* Value of E_LFARLC for new .EXEs */
  47. #define ENEWHDR 0x003C /* Offset in old hdr. of ptr. to new */
  48. #define ERESWDS 0x0010 /* No. of reserved words (OLD) */
  49. #define ERES1WDS 0x0004 /* No. of reserved words in e_res */
  50. #define ERES2WDS 0x000A /* No. of reserved words in e_res2 */
  51. #define ECP 0x0004 /* Offset in struct of E_CP */
  52. #define ECBLP 0x0002 /* Offset in struct of E_CBLP */
  53. #define EMINALLOC 0x000A /* Offset in struct of E_MINALLOC */
  54. struct exe_hdr { /* DOS 1, 2, 3 .EXE header */
  55. unsigned short e_magic; /* Magic number */
  56. unsigned short e_cblp; /* Bytes on last page of file */
  57. unsigned short e_cp; /* Pages in file */
  58. unsigned short e_crlc; /* Relocations */
  59. unsigned short e_cparhdr; /* Size of header in paragraphs */
  60. unsigned short e_minalloc; /* Minimum extra paragraphs needed */
  61. unsigned short e_maxalloc; /* Maximum extra paragraphs needed */
  62. unsigned short e_ss; /* Initial (relative) SS value */
  63. unsigned short e_sp; /* Initial SP value */
  64. unsigned short e_csum; /* Checksum */
  65. unsigned short e_ip; /* Initial IP value */
  66. unsigned short e_cs; /* Initial (relative) CS value */
  67. unsigned short e_lfarlc; /* File address of relocation table */
  68. unsigned short e_ovno; /* Overlay number */
  69. unsigned short e_res[ERES1WDS];/* Reserved words */
  70. unsigned short e_oemid; /* OEM identifier (for e_oeminfo) */
  71. unsigned short e_oeminfo; /* OEM information; e_oemid specific */
  72. unsigned short e_res2[ERES2WDS];/* Reserved words */
  73. long e_lfanew; /* File address of new exe header */
  74. };
  75. /* XLATOFF */
  76. #define E_MAGIC(x) (x).e_magic
  77. #define E_CBLP(x) (x).e_cblp
  78. #define E_CP(x) (x).e_cp
  79. #define E_CRLC(x) (x).e_crlc
  80. #define E_CPARHDR(x) (x).e_cparhdr
  81. #define E_MINALLOC(x) (x).e_minalloc
  82. #define E_MAXALLOC(x) (x).e_maxalloc
  83. #define E_SS(x) (x).e_ss
  84. #define E_SP(x) (x).e_sp
  85. #define E_CSUM(x) (x).e_csum
  86. #define E_IP(x) (x).e_ip
  87. #define E_CS(x) (x).e_cs
  88. #define E_LFARLC(x) (x).e_lfarlc
  89. #define E_OVNO(x) (x).e_ovno
  90. #define E_RES(x) (x).e_res
  91. #define E_OEMID(x) (x).e_oemid
  92. #define E_OEMINFO(x) (x).e_oeminfo
  93. #define E_RES2(x) (x).e_res2
  94. #define E_LFANEW(x) (x).e_lfanew
  95. /* XLATON */
  96. /*_________________________________________________________________*
  97. | |
  98. | |
  99. | OS/2 & WINDOWS .EXE FILE HEADER DEFINITION - 286 version |
  100. | |
  101. |_________________________________________________________________|
  102. * */
  103. #define NEMAGIC 0x454E /* New magic number */
  104. #define NECRC 8 /* Offset into new header of NE_CRC */
  105. #ifdef CRUISER
  106. #define NERESBYTES 8 /* Eight bytes reserved (now) */
  107. struct new_exe { /* New .EXE header */
  108. unsigned short ne_magic; /* Magic number NE_MAGIC */
  109. unsigned char ne_ver; /* Version number */
  110. unsigned char ne_rev; /* Revision number */
  111. unsigned short ne_enttab; /* Offset of Entry Table */
  112. unsigned short ne_cbenttab; /* Number of bytes in Entry Table */
  113. long ne_crc; /* Checksum of whole file */
  114. unsigned short ne_flags; /* Flag word */
  115. unsigned short ne_autodata; /* Automatic data segment number */
  116. unsigned short ne_heap; /* Initial heap allocation */
  117. unsigned short ne_stack; /* Initial stack allocation */
  118. long ne_csip; /* Initial CS:IP setting */
  119. long ne_sssp; /* Initial SS:SP setting */
  120. unsigned short ne_cseg; /* Count of file segments */
  121. unsigned short ne_cmod; /* Entries in Module Reference Table */
  122. unsigned short ne_cbnrestab; /* Size of non-resident name table */
  123. unsigned short ne_segtab; /* Offset of Segment Table */
  124. unsigned short ne_rsrctab; /* Offset of Resource Table */
  125. unsigned short ne_restab; /* Offset of resident name table */
  126. unsigned short ne_modtab; /* Offset of Module Reference Table */
  127. unsigned short ne_imptab; /* Offset of Imported Names Table */
  128. long ne_nrestab; /* Offset of Non-resident Names Table */
  129. unsigned short ne_cmovent; /* Count of movable entries */
  130. unsigned short ne_align; /* Segment alignment shift count */
  131. unsigned short ne_cres; /* Count of resource entries */
  132. unsigned char ne_exetyp; /* Target operating system */
  133. unsigned char ne_flagsothers; /* Other .EXE flags */
  134. char ne_res[NERESBYTES];
  135. /* Pad structure to 64 bytes */
  136. };
  137. #else
  138. #define NERESBYTES 0
  139. struct new_exe { /* New .EXE header */
  140. unsigned short int ne_magic; /* Magic number NE_MAGIC */
  141. char ne_ver; /* Version number */
  142. char ne_rev; /* Revision number */
  143. unsigned short int ne_enttab; /* Offset of Entry Table */
  144. unsigned short int ne_cbenttab; /* Number of bytes in Entry Table */
  145. long ne_crc; /* Checksum of whole file */
  146. unsigned short int ne_flags; /* Flag word */
  147. unsigned short int ne_autodata; /* Automatic data segment number */
  148. unsigned short int ne_heap; /* Initial heap allocation */
  149. unsigned short int ne_stack; /* Initial stack allocation */
  150. long ne_csip; /* Initial CS:IP setting */
  151. long ne_sssp; /* Initial SS:SP setting */
  152. unsigned short int ne_cseg; /* Count of file segments */
  153. unsigned short int ne_cmod; /* Entries in Module Reference Table */
  154. unsigned short int ne_cbnrestab; /* Size of non-resident name table */
  155. unsigned short int ne_segtab; /* Offset of Segment Table */
  156. unsigned short int ne_rsrctab; /* Offset of Resource Table */
  157. unsigned short int ne_restab; /* Offset of resident name table */
  158. unsigned short int ne_modtab; /* Offset of Module Reference Table */
  159. unsigned short int ne_imptab; /* Offset of Imported Names Table */
  160. long ne_nrestab; /* Offset of Non-resident Names Table */
  161. unsigned short int ne_cmovent; /* Count of movable entries */
  162. unsigned short int ne_align; /* Segment alignment shift count */
  163. unsigned short int ne_cres; /* Count of resource segments */
  164. unsigned char ne_exetyp; /* Target operating system */
  165. unsigned char ne_flagsothers; /* Other .EXE flags */
  166. unsigned short int ne_pretthunks; /* offset to return thunks */
  167. unsigned short int ne_psegrefbytes;/* offset to segment ref. bytes */
  168. unsigned short int ne_swaparea; /* Minimum code swap area size */
  169. unsigned short int ne_expver; /* Expected Windows version number */
  170. };
  171. #endif
  172. /* ASM
  173. ; Chksum not supported unless ne_psegcsum defined in NEW_EXE structure
  174. ne_psegcsum = word ptr ne_exetyp
  175. ne_onextexe = word ptr ne_crc
  176. ; New 3.0 Gang Load area description
  177. ne_gang_start = ne_pretthunks
  178. ne_gang_length = ne_psegrefbytes
  179. new_exe1 struc
  180. dw ?
  181. ne_usage dw ?
  182. dw ?
  183. ne_pnextexe dw ?
  184. ne_pautodata dw ?
  185. ne_pfileinfo dw ?
  186. new_exe1 ends
  187. */
  188. /* XLATOFF */
  189. #define NE_MAGIC(x) (x).ne_magic
  190. #define NE_VER(x) (x).ne_ver
  191. #define NE_REV(x) (x).ne_rev
  192. #define NE_ENTTAB(x) (x).ne_enttab
  193. #define NE_CBENTTAB(x) (x).ne_cbenttab
  194. #define NE_CRC(x) (x).ne_crc
  195. #define NE_FLAGS(x) (x).ne_flags
  196. #define NE_AUTODATA(x) (x).ne_autodata
  197. #define NE_HEAP(x) (x).ne_heap
  198. #define NE_STACK(x) (x).ne_stack
  199. #define NE_CSIP(x) (x).ne_csip
  200. #define NE_SSSP(x) (x).ne_sssp
  201. #define NE_CSEG(x) (x).ne_cseg
  202. #define NE_CMOD(x) (x).ne_cmod
  203. #define NE_CBNRESTAB(x) (x).ne_cbnrestab
  204. #define NE_SEGTAB(x) (x).ne_segtab
  205. #define NE_RSRCTAB(x) (x).ne_rsrctab
  206. #define NE_RESTAB(x) (x).ne_restab
  207. #define NE_MODTAB(x) (x).ne_modtab
  208. #define NE_IMPTAB(x) (x).ne_imptab
  209. #define NE_NRESTAB(x) (x).ne_nrestab
  210. #define NE_CMOVENT(x) (x).ne_cmovent
  211. #define NE_ALIGN(x) (x).ne_align
  212. #define NE_CRES(x) (x).ne_cres
  213. #define NE_RES(x) (x).ne_res
  214. #define NE_EXETYP(x) (x).ne_exetyp
  215. #define NE_FLAGSOTHERS(x) (x).ne_flagsothers
  216. #define NE_USAGE(x) (WORD)*((WORD *)(x)+1)
  217. #define NE_PNEXTEXE(x) (WORD)(x).ne_cbenttab
  218. #define NE_ONEWEXE(x) (WORD)(x).ne_crc
  219. #define NE_PFILEINFO(x) (WORD)((DWORD)(x).ne_crc >> 16)
  220. #ifdef DOS5
  221. #define NE_MTE(x) (x).ne_psegcsum /* DOS 5 MTE handle for this module */
  222. #endif
  223. /* XLATON */
  224. /*
  225. * Format of NE_FLAGS(x):
  226. *
  227. * p Not-a-process
  228. * x Unused
  229. * e Errors in image
  230. * x Unused
  231. * b Bound Family/API
  232. * ttt Application type
  233. * f Floating-point instructions
  234. * 3 386 instructions
  235. * 2 286 instructions
  236. * 0 8086 instructions
  237. * P Protected mode only
  238. * p Per-process library initialization
  239. * i Instance data
  240. * s Solo data
  241. */
  242. #define NENOTP 0x8000 /* Not a process */
  243. #define NENONC 0x4000 /* Non-conforming program */
  244. #define NEPRIVLIB 0x4000 /* A lib which lives above the line */
  245. #define NEIERR 0x2000 /* Errors in image */
  246. #define NEBOUND 0x0800 /* Bound Family/API */
  247. #define NEAPPTYP 0x0700 /* Application type mask */
  248. #define NENOTWINCOMPAT 0x0100 /* Not compatible with P.M. Windowing */
  249. #define NEWINCOMPAT 0x0200 /* Compatible with P.M. Windowing */
  250. #define NEWINAPI 0x0300 /* Uses P.M. Windowing API */
  251. #define NEFLTP 0x0080 /* Floating-point instructions */
  252. #define NEI386 0x0040 /* 386 instructions */
  253. #define NEI286 0x0020 /* 286 instructions */
  254. #define NEI086 0x0010 /* 8086 instructions */
  255. #define NEPROT 0x0008 /* Runs in protected mode only */
  256. #define NEREAL 0x0004 /* Runs in real mode */
  257. #define NEPPLI 0x0004 /* Per-Process Library Initialization */
  258. #define NEINST 0x0002 /* Instance data */
  259. #define NESOLO 0x0001 /* Solo data */
  260. /*
  261. * Below are the private bits used by the Windows 2.0 loader. All are
  262. * in the file, with the exception of NENONRES and NEWINPROT which are
  263. * runtime only flags.
  264. */
  265. #define NEWINPROT NEIERR
  266. #define NENONRES NEFLTP /* Contains non-resident code segments */
  267. #define NEALLOCHIGH NEI386 /* Private allocs above the line okay */
  268. #define NEEMSSEPINST NEI286 /* Want each instance in separate */
  269. #define NELIM32 NEI086 /* Uses LIM 3.2 API (Intel Above board) */
  270. /*
  271. * Format of NE_FLAGSOTHERS(x):
  272. *
  273. * 7 6 5 4 3 2 1 0 - bit no
  274. * | | | |
  275. * | | | +---------------- Support for long file names
  276. * | | +------------------------ Reserved for Win16 loader: must be 0
  277. * | +---------------------------- Intl versions use this for ml shell
  278. * +------------------------------ Some segs of this module get patched
  279. */
  280. #define NELONGNAMES 0x01
  281. #define NEFORCESTUB 0x02 /* WIN40 - Always run the stub from DOS */
  282. #define NEINFONT 0x02 /* WIN30 - 2.x app runs in 3.x prot mode */
  283. #define NEINPROT 0x04 /* WIN30 - 2.x app gets proportional font */
  284. #define NEGANGLOAD 0x08 /* WIN30 - Contains gangload area */
  285. #define NEASSUMENODEP 0x10 /* Reserved for Win16 loader. Must be 0 in file */
  286. #define NEINTLAPP 0x40 /* WIN31 - intl versions use this. */
  287. #define NEHASPATCH 0x80 /* WIN40 - Some segs of this module get patched */
  288. /*
  289. * Target operating systems
  290. */
  291. #define NE_UNKNOWN 0x0 /* Unknown (any "new-format" OS) */
  292. #define NE_OS2 0x1 /* Microsoft/IBM OS/2 (default) */
  293. #define NE_WINDOWS 0x2 /* Microsoft Windows */
  294. #define NE_DOS4 0x3 /* Microsoft MS-DOS 4.x */
  295. #define NE_DEV386 0x4 /* Microsoft Windows 386 */
  296. #ifndef NO_APPLOADER
  297. #define NEAPPLOADER 0x0800 /* set if app has its own loader */
  298. #endif /* !NO_APPLOADER */
  299. struct new_seg { /* New .EXE segment table entry */
  300. unsigned short ns_sector; /* File sector of start of segment */
  301. unsigned short ns_cbseg; /* Number of bytes in file */
  302. unsigned short ns_flags; /* Attribute flags */
  303. unsigned short ns_minalloc; /* Minimum allocation in bytes */
  304. };
  305. /* ASM
  306. new_seg1 struc
  307. db size new_seg dup (?)
  308. ns_handle dw ?
  309. new_seg1 ends
  310. */
  311. /* XLATOFF */
  312. struct new_seg1 { /* New .EXE segment table entry */
  313. unsigned short ns_sector; /* File sector of start of segment */
  314. unsigned short ns_cbseg; /* Number of bytes in file */
  315. unsigned short ns_flags; /* Attribute flags */
  316. unsigned short ns_minalloc; /* Minimum allocation in bytes */
  317. unsigned short ns_handle; /* Handle of segment */
  318. };
  319. #define NS_SECTOR(x) (x).ns_sector
  320. #define NS_CBSEG(x) (x).ns_cbseg
  321. #define NS_FLAGS(x) (x).ns_flags
  322. #define NS_MINALLOC(x) (x).ns_minalloc
  323. /* XLATON */
  324. /*
  325. * Format of NS_FLAGS(x)
  326. *
  327. * Flag word has the following format:
  328. *
  329. * 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 - bit no
  330. * | | | | | | | | | | | | | | |
  331. * | | | | | | | | | | | | +-+-+--- Segment type DATA/CODE
  332. * | | | | | | | | | | | +--------- Iterated segment
  333. * | | | | | | | | | | +----------- Movable segment
  334. * | | | | | | | | | +------------- Segment can be shared
  335. * | | | | | | | | +--------------- Preload segment
  336. * | | | | | | | +----------------- Execute/read-only for code/data segment
  337. * | | | | | | +------------------- Segment has relocations
  338. * | | | | | +--------------------- Code conforming/Data is expand down
  339. * | | | +--+----------------------- I/O privilege level
  340. * | | +----------------------------- Discardable segment
  341. * | +-------------------------------- 32-bit code segment
  342. * +----------------------------------- Huge segment/GDT allocation requested
  343. *
  344. */
  345. #define NSTYPE 0x0007 /* Segment type mask */
  346. #define NSCODE 0x0000 /* Code segment */
  347. #define NSDATA 0x0001 /* Data segment */
  348. #define NSITER 0x0008 /* Iterated segment flag */
  349. #define NSMOVE 0x0010 /* Movable segment flag */
  350. #define NSPURE 0x0020 /* Pure segment flag */
  351. #define NSSHARED 0x0020 /* Shared segment flag */
  352. #define NSSHARE 0x0020
  353. #define NSPRELOAD 0x0040 /* Preload segment flag */
  354. #define NSEXRD 0x0080 /* Execute-only (code segment) or */
  355. #define NSERONLY 0x0080 /* read-only (data segment) */
  356. #define NSRELOC 0x0100 /* Segment has relocations */
  357. #define NSCONFORM 0x0200 /* Conforming segment */
  358. #define NSEXPDOWN 0x0200 /* Data segment is expand down */
  359. #define NSDEBUG 0x0200 /* Segment has debug info */
  360. #define NSDPL 0x0C00 /* I/O privilege level (286 DPL bits) */
  361. #define SHIFTDPL 10 /* Left shift count for SEGDPL field */
  362. #define NSDISCARD 0x1000 /* Segment is discardable */
  363. #define NS32BIT 0x2000 /* 32-bit code segment */
  364. #define NSHUGE 0x4000 /* Huge memory segment, length of
  365. segment and minimum allocation
  366. size are in segment sector units */
  367. #define NSGDT 0x8000 /* GDT allocation requested */
  368. #define NS286DOS 0xEE06 /* These bits only used by 286DOS */
  369. #define NSALIGN 9 /* Segment data aligned on 512 byte
  370. boundaries */
  371. #define NSALLOCED 0x0002 /* Set if ns_handle points to
  372. uninitialized mem */
  373. #define NSLOADED 0x0004 /* ns_sector field contains memory
  374. address */
  375. #define NSUSESDATA 0x0400 /* Set if an entry point in this
  376. segment uses the automatic data
  377. segment of a SOLO library */
  378. #define NSGETHIGH 0x0200
  379. #define NSINDIRECT 0x2000
  380. #define NSWINCODE 0x4000 /* flag for code */
  381. #define NSKCACHED 0x0800 /* cached by kernel */
  382. #define NSPRIVLIB NSITER
  383. #define NSNOTP 0x8000
  384. #ifndef NO_APPLOADER
  385. #define NSCACHED 0x8000 /* in AppLoader Cache */
  386. #endif /*!NO_APPLOADER */
  387. /* XLATOFF */
  388. struct new_segdata { /* Segment data */
  389. union {
  390. struct {
  391. unsigned short ns_niter; /* number of iterations */
  392. unsigned short ns_nbytes; /* number of bytes */
  393. char ns_iterdata; /* iterated data bytes */
  394. } ns_iter;
  395. struct {
  396. char ns_data; /* data bytes */
  397. } ns_noniter;
  398. } ns_union;
  399. };
  400. /* XLATON */
  401. struct new_rlcinfo { /* Relocation info */
  402. unsigned short nr_nreloc; /* number of relocation items that */
  403. }; /* follow */
  404. /* XLATOFF */
  405. #pragma pack(1)
  406. struct new_rlc { /* Relocation item */
  407. char nr_stype; /* Source type */
  408. char nr_flags; /* Flag byte */
  409. unsigned short nr_soff; /* Source offset */
  410. union {
  411. struct {
  412. char nr_segno; /* Target segment number */
  413. char nr_res; /* Reserved */
  414. unsigned short nr_entry; /* Target Entry Table offset */
  415. } nr_intref; /* Internal reference */
  416. struct {
  417. unsigned short nr_mod; /* Index into Module Reference Table */
  418. unsigned short nr_proc; /* Procedure ordinal or name offset */
  419. } nr_import; /* Import */
  420. struct {
  421. unsigned short nr_ostype; /* OSFIXUP type */
  422. unsigned short nr_osres; /* reserved */
  423. } nr_osfix; /* Operating system fixup */
  424. } nr_union; /* Union */
  425. };
  426. #pragma pack()
  427. /* XLATON */
  428. /* ASM
  429. new_rlc struc
  430. nr_stype db ?
  431. nr_flags db ?
  432. nr_soff dw ?
  433. nr_mod dw ?
  434. nr_proc dw ?
  435. new_rlc ends
  436. nr_segno equ nr_flags+3
  437. nr_entry equ nr_proc
  438. */
  439. /* XLATOFF */
  440. #define NR_STYPE(x) (x).nr_stype
  441. #define NR_FLAGS(x) (x).nr_flags
  442. #define NR_SOFF(x) (x).nr_soff
  443. #define NR_SEGNO(x) (x).nr_union.nr_intref.nr_segno
  444. #define NR_RES(x) (x).nr_union.nr_intref.nr_res
  445. #define NR_ENTRY(x) (x).nr_union.nr_intref.nr_entry
  446. #define NR_MOD(x) (x).nr_union.nr_import.nr_mod
  447. #define NR_PROC(x) (x).nr_union.nr_import.nr_proc
  448. #define NR_OSTYPE(x) (x).nr_union.nr_osfix.nr_ostype
  449. #define NR_OSRES(x) (x).nr_union.nr_osfix.nr_osres
  450. /* XLATON */
  451. /*
  452. * Format of NR_STYPE(x) and R32_STYPE(x):
  453. *
  454. * 7 6 5 4 3 2 1 0 - bit no
  455. * | | | |
  456. * +-+-+-+--- source type
  457. *
  458. */
  459. #define NRSTYP 0x0f /* Source type mask */
  460. #define NRSBYT 0x00 /* lo byte (8-bits)*/
  461. #define NRSBYTE 0x00
  462. #define NRSSEG 0x02 /* 16-bit segment (16-bits) */
  463. #define NRSPTR 0x03 /* 16:16 pointer (32-bits) */
  464. #define NRSOFF 0x05 /* 16-bit offset (16-bits) */
  465. #define NRPTR48 0x06 /* 16:32 pointer (48-bits) */
  466. #define NROFF32 0x07 /* 32-bit offset (32-bits) */
  467. #define NRSOFF32 0x08 /* 32-bit self-relative offset (32-bits) */
  468. /*
  469. * Format of NR_FLAGS(x) and R32_FLAGS(x):
  470. *
  471. * 7 6 5 4 3 2 1 0 - bit no
  472. * | | |
  473. * | +-+--- Reference type
  474. * +------- Additive fixup
  475. */
  476. #define NRADD 0x04 /* Additive fixup */
  477. #define NRRTYP 0x03 /* Reference type mask */
  478. #define NRRINT 0x00 /* Internal reference */
  479. #define NRRORD 0x01 /* Import by ordinal */
  480. #define NRRNAM 0x02 /* Import by name */
  481. #define NRROSF 0x03 /* Operating system fixup */
  482. #define OSFIXUP NRROSF
  483. /* Resource type or name string */
  484. struct rsrc_string {
  485. char rs_len; /* number of bytes in string */
  486. char rs_string[ 1 ]; /* text of string */
  487. };
  488. /* XLATOFF */
  489. #define RS_LEN( x ) (x).rs_len
  490. #define RS_STRING( x ) (x).rs_string
  491. /* XLATON */
  492. /* Resource type information block */
  493. struct rsrc_typeinfo {
  494. unsigned short rt_id;
  495. unsigned short rt_nres;
  496. long rt_proc;
  497. };
  498. /* XLATOFF */
  499. #define RT_ID( x ) (x).rt_id
  500. #define RT_NRES( x ) (x).rt_nres
  501. #define RT_PROC( x ) (x).rt_proc
  502. /* XLATON */
  503. /* Resource name information block */
  504. struct rsrc_nameinfo {
  505. /* The following two fields must be shifted left by the value of */
  506. /* the rs_align field to compute their actual value. This allows */
  507. /* resources to be larger than 64k, but they do not need to be */
  508. /* aligned on 512 byte boundaries, the way segments are */
  509. unsigned short rn_offset; /* file offset to resource data */
  510. unsigned short rn_length; /* length of resource data */
  511. unsigned short rn_flags; /* resource flags */
  512. unsigned short rn_id; /* resource name id */
  513. unsigned short rn_handle; /* If loaded, then global handle */
  514. unsigned short rn_usage; /* Initially zero. Number of times */
  515. /* the handle for this resource has */
  516. /* been given out */
  517. };
  518. /* XLATOFF */
  519. #define RN_OFFSET( x ) (x).rn_offset
  520. #define RN_LENGTH( x ) (x).rn_length
  521. #define RN_FLAGS( x ) (x).rn_flags
  522. #define RN_ID( x ) (x).rn_id
  523. #define RN_HANDLE( x ) (x).rn_handle
  524. #define RN_USAGE( x ) (x).rn_usage
  525. /* XLATON */
  526. #define RSORDID 0x8000 /* if high bit of ID set then integer id */
  527. /* otherwise ID is offset of string from
  528. the beginning of the resource table */
  529. /* Ideally these are the same as the */
  530. /* corresponding segment flags */
  531. #define RNMOVE 0x0010 /* Moveable resource */
  532. #define RNPURE 0x0020 /* Pure (read-only) resource */
  533. #define RNPRELOAD 0x0040 /* Preloaded resource */
  534. #define RNDISCARD 0x1000 /* Discard priority level for resource */
  535. #define RNLOADED 0x0004 /* True if handler proc return handle */
  536. #define RNUNUSED 0x0EF8B /* Unused resource flags */
  537. /* XLATOFF */
  538. /* Resource table */
  539. struct new_rsrc {
  540. unsigned short rs_align; /* alignment shift count for resources */
  541. struct rsrc_typeinfo rs_typeinfo;
  542. };
  543. #define RS_ALIGN( x ) (x).rs_align
  544. /* XLATON */
  545. /* ASM
  546. new_rsrc struc
  547. rs_align dw ?
  548. new_rsrc ends
  549. entfixed struc
  550. entflags db ?
  551. entoffset dw ?
  552. entfixed ends
  553. pent struc
  554. penttype db ?
  555. pentflags db ?
  556. pentsegno db ?
  557. pentoffset dw ?
  558. pent ends
  559. pm_entstruc struc
  560. pm_entstart dw ?
  561. pm_entend dw ?
  562. pm_entnext dw ?
  563. pm_entstruc ends
  564. ENT_UNUSED = 000h
  565. ENT_ABSSEG = 0FEh
  566. ENT_MOVEABLE = 0FFh
  567. ENT_PUBLIC = 001h
  568. ENT_DATA = 002h
  569. INTOPCODE = 0CDh
  570. savedCS = 4
  571. savedIP = 2
  572. savedBP = 0
  573. savedDS = -2
  574. */