1 /* $Id: neexe.h,v 1.4 1993/07/04 04:04:21 root Exp root $
4 * Copyright Robert J. Amstadt, 1993
10 * Old MZ header for DOS programs. Actually just a couple of fields
11 * from it, so that we can find the start of the NE header.
15 u_char dont_care1
[0x18]; /* MZ Header stuff */
16 u_char must_be_0x40
; /* 0x40 for non-MZ program */
17 u_char dont_care2
[0x23]; /* More MZ header stuff */
18 u_short ne_offset
; /* Offset to extended header */
22 * This is the Windows executable (NE) header.
26 char header_type
[2]; /* Must contain 'N' 'E' */
27 u_char linker_version
; /* Linker version number */
28 u_char linker_revision
; /* Linker revision number */
29 u_short entry_tab_offset
; /* Offset to entry table relative to NE */
30 u_short entry_tab_length
; /* Length of etnry table in bytes */
31 u_long reserved1
; /* Reserved by Microsoft */
32 u_short format_flags
; /* Flags that segments in this file */
33 u_short auto_data_seg
; /* Automatic data segment number */
34 u_short local_heap_length
; /* Initial size of local heap */
35 u_short stack_length
; /* Initial size of stack */
36 u_short ip
; /* Initial IP */
37 u_short cs
; /* Initial CS */
38 u_short sp
; /* Initial SP */
39 u_short ss
; /* Initial SS */
40 u_short n_segment_tab
; /* # of entries in segment table */
41 u_short n_mod_ref_tab
; /* # of entries in module reference tab.*/
42 u_short nrname_tab_length
; /* Length of nonresident-name table */
43 u_short segment_tab_offset
; /* Offset to segment table */
44 u_short resource_tab_offset
;/* Offset to resource table */
45 u_short rname_tab_offset
; /* Offset to resident-name table */
46 u_short moduleref_tab_offset
;/* Offset to module reference table */
47 u_short iname_tab_offset
; /* Offset to imported name table */
48 u_long nrname_tab_offset
; /* Offset to nonresident-name table */
49 u_short n_mov_entry_points
; /* # of movable entry points */
50 u_short align_shift_count
; /* Logical sector alignment shift count */
51 u_short n_resource_seg
; /* # of resource segments */
52 u_char operating_system
; /* Flags indicating target OS */
53 u_char additional_flags
; /* Additional information flags */
54 u_short fastload_offset
; /* Offset to fast load area */
55 u_short fastload_length
; /* Length of fast load area */
56 u_short reserved2
; /* Reserved by Microsoft */
57 u_short expect_version
; /* Expected Windows version number */
61 * NE Header FORMAT FLAGS
63 #define NE_FFLAGS_SINGLEDATA 0x0001
64 #define NE_FFLAGS_MULTIPLEDATA 0x0002
65 #define NE_FFLAGS_SELFLOAD 0x0800
66 #define NE_FFLAGS_LINKERROR 0x2000
67 #define NE_FFLAGS_LIBMODULE 0x8000
70 * NE Header OPERATING SYSTEM
72 #define NE_OSFLAGS_UNKNOWN 0x01
73 #define NE_OSFLAGS_WINDOWS 0x04
76 * NE Header ADDITIONAL FLAGS
78 #define NE_AFLAGS_WIN2_PROTMODE 0x02
79 #define NE_AFLAGS_WIN2_PROFONTS 0x04
80 #define NE_AFLAGS_FASTLOAD 0x08
85 struct ne_segment_table_entry_s
87 u_short seg_data_offset
; /* Sector offset of segment data */
88 u_short seg_data_length
; /* Length of segment data */
89 u_short seg_flags
; /* Flags associated with this segment */
90 u_short min_alloc
; /* Minimum allocation size for this */
96 #define NE_SEGFLAGS_DATA 0x0001
97 #define NE_SEGFLAGS_ALLOCATED 0x0002
98 #define NE_SEGFLAGS_LOADED 0x0004
99 #define NE_SEGFLAGS_MOVEABLE 0x0010
100 #define NE_SEGFLAGS_SHAREABLE 0x0020
101 #define NE_SEGFLAGS_PRELOAD 0x0040
102 #define NE_SEGFLAGS_EXECUTEONLY 0x0080
103 #define NE_SEGFLAGS_READONLY 0x0080
104 #define NE_SEGFLAGS_RELOC_DATA 0x0100
105 #define NE_SEGFLAGS_DISCARDABLE 0x1000
108 * Relocation table entry
110 struct relocation_entry_s
112 u_char address_type
; /* Relocation address type */
113 u_char relocation_type
; /* Relocation type */
114 u_short offset
; /* Offset in segment to fixup */
115 u_short target1
; /* Target specification */
116 u_short target2
; /* Target specification */
120 * Relocation address types
122 #define NE_RADDR_LOWBYTE 0
123 #define NE_RADDR_SELECTOR 2
124 #define NE_RADDR_POINTER32 3
125 #define NE_RADDR_OFFSET16 5
126 #define NE_RADDR_POINTER48 11
127 #define NE_RADDR_OFFSET32 13
132 #define NE_RELTYPE_INTERNAL 0
133 #define NE_RELTYPE_ORDINAL 1
134 #define NE_RELTYPE_NAME 2
135 #define NE_RELTYPE_OSFIXUP 3
136 /* Used by Windows 3.0 programs, like when getting selector to be
137 given to makeprocinst */
138 #define NE_RELTYPE_INT1 4
139 #define NE_RELTYPE_ORDINALADD 5
140 #define NE_RELTYPE_NAMEADD 6
147 unsigned short pspInt20
;
148 unsigned short pspNextParagraph
;
149 unsigned char pspReserved1
;
150 unsigned char pspDispatcher
[5];
151 unsigned short pspTerminateVector
[2];
152 unsigned short pspControlCVector
[2];
153 unsigned short pspCritErrorVector
[2];
154 unsigned short pspReserved2
[11];
155 unsigned short pspEnvironment
;
156 unsigned short pspReserved3
[23];
157 unsigned char pspFCB_1
[16];
158 unsigned char pspFCB_2
[16];
159 unsigned char pspReserved4
[4];
160 unsigned char pspCommandTailCount
;
161 unsigned char pspCommandTail
[128];
165 * Entry table structures.
167 struct entry_tab_header_s
169 unsigned char n_entries
;
170 unsigned char seg_number
;
173 struct entry_tab_movable_s
176 unsigned char int3f
[2];
177 unsigned char seg_number
;
178 unsigned short offset
;
181 struct entry_tab_fixed_s
184 unsigned char offset
[2];
188 * Resource table structures.
190 struct resource_nameinfo_s
192 unsigned short offset
;
193 unsigned short length
;
194 unsigned short flags
;
196 unsigned short handle
;
197 unsigned short usage
;
200 struct resource_typeinfo_s
202 unsigned short type_id
; /* Type identifier */
203 unsigned short count
; /* Number of resources of this type */
204 unsigned long reserved
;
210 #define NE_RSCTYPE_ACCELERATOR 0x8009
211 #define NE_RSCTYPE_BITMAP 0x8002
212 #define NE_RSCTYPE_CURSOR 0x8001
213 #define NE_RSCTYPE_DIALOG 0x8005
214 #define NE_RSCTYPE_FONT 0x8008
215 #define NE_RSCTYPE_FONTDIR 0x8007
216 #define NE_RSCTYPE_GROUP_CURSOR 0x800c
217 #define NE_RSCTYPE_GROUP_ICON 0x800e
218 #define NE_RSCTYPE_ICON 0x8003
219 #define NE_RSCTYPE_MENU 0x8004
220 #define NE_RSCTYPE_RCDATA 0x800a
221 #define NE_RSCTYPE_STRING 0x8006