1 | /*
|
---|
2 | **
|
---|
3 | ** OMF.H - Object Module Format structures
|
---|
4 | **
|
---|
5 | */
|
---|
6 |
|
---|
7 | struct exehdr_rec {
|
---|
8 | BYTE signature[2]; // Must be "MZ"
|
---|
9 | USHORT image_len; // Image Length
|
---|
10 | USHORT pages; // Pages
|
---|
11 | USHORT reloc_items; // Relocation table items
|
---|
12 | USHORT min_paragraphs; // Mininum 16-bytes paragraphs
|
---|
13 | USHORT max_paragraphs; // Maximum 16-bytes paragraphs
|
---|
14 | USHORT stack_pos; // Stack position
|
---|
15 | USHORT offset_in_sp; // Offset in SP
|
---|
16 | USHORT checksum; // Checksum
|
---|
17 | USHORT offset_in_ip; // Offset in IP
|
---|
18 | USHORT code_pos; // Code segment pos.
|
---|
19 | USHORT reloc_item_pos; // Position of first relocation item
|
---|
20 | USHORT overlay_number; // Overlay number
|
---|
21 | BYTE unused[8]; // Unused bytes
|
---|
22 | USHORT oem_id; // OEM Identifier
|
---|
23 | BYTE oem_info[24]; // OEM Info
|
---|
24 | ULONG lexe_offset; // Offset to linear header
|
---|
25 | };
|
---|
26 |
|
---|
27 | struct lexehdr_rec {
|
---|
28 | BYTE signature[2]; // Must be "LX"
|
---|
29 | BYTE b_ord; // Byte ordering
|
---|
30 | BYTE w_ord; // Word ordering
|
---|
31 | ULONG format_level; // Format level
|
---|
32 | USHORT cpu_type; // CPU Type
|
---|
33 | USHORT os_type; // Operating system
|
---|
34 | ULONG module_version; // Module version
|
---|
35 | ULONG mod_flags; // Module flags
|
---|
36 | ULONG mod_pages; // Module pages
|
---|
37 | ULONG EIP_object; // EIP Object no.
|
---|
38 | ULONG EIP; // EIP Value
|
---|
39 | ULONG ESP_object; // ESP Object no
|
---|
40 | ULONG ESP; // ESP Value
|
---|
41 | ULONG page_size; // Page size
|
---|
42 | ULONG page_ofs_shift; // Page offset shift
|
---|
43 | ULONG fixup_sect_size; // Fixup section size
|
---|
44 | ULONG fixup_sect_checksum; // Fixup section checksum
|
---|
45 | ULONG loader_sect_size; // Loader section size
|
---|
46 | ULONG loader_sect_checksum; // Loader section checksum
|
---|
47 | ULONG obj_table_ofs; // Object table offset
|
---|
48 | ULONG obj_count; // Object count
|
---|
49 | ULONG obj_page_tab_ofs; // Object page table offset
|
---|
50 | ULONG obj_iter_page_ofs; // Object iteration pages offset
|
---|
51 | ULONG res_tab_ofs; // Resource table offset
|
---|
52 | ULONG res_table_entries; // Resource table entries
|
---|
53 | ULONG res_name_tab_ofs; // Resident name table offset;
|
---|
54 | ULONG ent_tab_ofs; // Entry table offset
|
---|
55 | ULONG mod_dir_ofs; // Module directives offset
|
---|
56 | ULONG mod_dir_count; // Number of module directives
|
---|
57 | ULONG fixup_page_tab_ofs; // Fixup page table offset
|
---|
58 | ULONG fixup_rec_tab_ofs; // Fixup record table offset
|
---|
59 | ULONG imp_tab_ofs; // Import module table offset
|
---|
60 | ULONG imp_mod_entries; // Import module entries
|
---|
61 | ULONG imp_proc_tab_ofs; // Import proc table offset
|
---|
62 | ULONG per_page_check_ofs; // Per page checksum offset
|
---|
63 | ULONG data_page_offset; // Data pages offset
|
---|
64 | ULONG preload_page_count; // Preload pages count
|
---|
65 | ULONG nonres_tab_ofs; // Nonresident name table offset
|
---|
66 | ULONG nonres_tab_len; // Nonresident name table len
|
---|
67 | ULONG nonres_tab_check; // Nonresident tables checksum
|
---|
68 | ULONG auto_ds_objectno; // Auto DS object number
|
---|
69 | ULONG debug_info_ofs; // Debug info offset
|
---|
70 | ULONG debug_info_len; // Debug info length
|
---|
71 | ULONG inst_preload_count; // Instance preload count
|
---|
72 | ULONG inst_demand_count; // Instance demand count
|
---|
73 | ULONG heapsize; // Heap size
|
---|
74 | ULONG stacksize; // Stack size
|
---|
75 | };
|
---|
76 |
|
---|
77 | struct debug_head_rec {
|
---|
78 | BYTE signature[3]; // Debug signature
|
---|
79 | BYTE type; // Debug info type
|
---|
80 | };
|
---|
81 |
|
---|
82 | struct dir_inf_rec {
|
---|
83 | USHORT dirstruct_size; // Size of directory structure
|
---|
84 | USHORT number_of_entries; // Number of dnt_rec's in the array
|
---|
85 | USHORT unknown; // Unknown data
|
---|
86 | // Followed by an array of dnt_rec structures
|
---|
87 | };
|
---|
88 |
|
---|
89 | struct dnt_rec {
|
---|
90 | USHORT subsect_type; // sst Subsection type
|
---|
91 | USHORT mod_index; // Module index (1-based)
|
---|
92 | ULONG offset; // Offset of start of section
|
---|
93 | ULONG size; // Size of section
|
---|
94 | };
|
---|
95 |
|
---|
96 | // Modules subsection
|
---|
97 | struct modules_rec {
|
---|
98 | USHORT code_seg_base; // Code segment base
|
---|
99 | ULONG code_seg_offset; // Code segment offset
|
---|
100 | ULONG code_seg_len; // Code segment length
|
---|
101 | USHORT overlay_no; // Overlay number
|
---|
102 | USHORT lib_idx; // Index into library section or 0
|
---|
103 | BYTE segments; // Number of segments
|
---|
104 | BYTE reserved;
|
---|
105 | BYTE debug_style[2]; // "HL" for HLL, "CV" or 0 for CodeView
|
---|
106 | BYTE debug_version[2]; // 00 01 or 00 03 for HLL, 00 00 for CV
|
---|
107 | BYTE name_len; // Length of name (which follows)
|
---|
108 | };
|
---|
109 |
|
---|
110 | // Publics subsection
|
---|
111 | struct publics_rec {
|
---|
112 | ULONG offset; // Offset
|
---|
113 | USHORT segment; // Segment
|
---|
114 | USHORT type; // Type index
|
---|
115 | BYTE name_len; // Length of name (wich follows)
|
---|
116 | };
|
---|
117 |
|
---|
118 | #if 0
|
---|
119 | // Linenumbers header
|
---|
120 | struct linhead_rec {
|
---|
121 | BYTE id; // 0x95 for flat mem, 32 bit progs
|
---|
122 | USHORT length; // Record length
|
---|
123 | USHORT base_group; // Base group
|
---|
124 | USHORT base_segment; // Base segment
|
---|
125 | };
|
---|
126 | #endif
|
---|
127 |
|
---|
128 | // First linenumber record
|
---|
129 | struct linfirst_rec {
|
---|
130 | USHORT lineno; // Line number (0)
|
---|
131 | BYTE entry_type; // Entry type
|
---|
132 | BYTE reserved; // Reserved
|
---|
133 | USHORT entries_count; // Number of table entries
|
---|
134 | USHORT segment_no; // Segment number
|
---|
135 | ULONG filename_tabsize; // File names table size
|
---|
136 | };
|
---|
137 |
|
---|
138 |
|
---|
139 | // Source line numbers
|
---|
140 | struct linsource_rec {
|
---|
141 | USHORT source_line; // Source file line number
|
---|
142 | USHORT source_idx; // Source file index
|
---|
143 | ULONG offset; // Offset into segment
|
---|
144 | };
|
---|
145 |
|
---|
146 |
|
---|
147 | // Listing statement numbers
|
---|
148 | struct linlist_rec {
|
---|
149 | ULONG list_line; // Listing file linenumber
|
---|
150 | ULONG statement; // Listing file statement number
|
---|
151 | ULONG offset; // Offset into segment
|
---|
152 | };
|
---|
153 |
|
---|
154 |
|
---|
155 | // Source and Listing statement numbers
|
---|
156 | struct linsourcelist_rec {
|
---|
157 | USHORT source_line; // Source file line number
|
---|
158 | USHORT source_idx; // Source file index
|
---|
159 | ULONG list_line; // Listing file linenumber
|
---|
160 | ULONG statement; // Listing file statement number
|
---|
161 | ULONG offset; // Offset into segment
|
---|
162 | };
|
---|
163 |
|
---|
164 |
|
---|
165 | // Path table
|
---|
166 | struct pathtab_rec {
|
---|
167 | ULONG offset; // Offset into segment
|
---|
168 | USHORT path_code; // Path code
|
---|
169 | USHORT source_idx; // Source file index
|
---|
170 | };
|
---|
171 |
|
---|
172 |
|
---|
173 | // File names table
|
---|
174 | struct filenam_rec {
|
---|
175 | ULONG first_char; // First displayable char in list file
|
---|
176 | ULONG disp_chars; // Number of displayable chars in list line
|
---|
177 | ULONG filecount; // Number of source/listing files
|
---|
178 | };
|
---|
179 |
|
---|
180 |
|
---|
181 | // Symbol types
|
---|
182 | #define SYM_BEGIN 0x00 // Begin block
|
---|
183 | #define SYM_PROC 0x01 // Function
|
---|
184 | #define SYM_END 0x02 // End block of function
|
---|
185 | #define SYM_AUTO 0x04 // Auto variable
|
---|
186 | #define SYM_STATIC 0x05 // Static variable
|
---|
187 | #define SYM_LABEL 0x0B // Label
|
---|
188 | #define SYM_WITH 0x0C // With start symbol (not used)
|
---|
189 | #define SYM_REG 0x0D // Register variable
|
---|
190 | #define SYM_CONST 0x0E // Constant
|
---|
191 | #define SYM_ENTRY 0x0F // Secondary entry (not in C)
|
---|
192 | #define SYM_SKIP 0x10 // For incremental linking (not used)
|
---|
193 | #define SYM_CHANGESEG 0x11 // Change segment (#pragma alloc_text)
|
---|
194 | #define SYM_TYPEDEF 0x12 // Typedef variable
|
---|
195 | #define SYM_PUBLIC 0x13 // Public reference
|
---|
196 | #define SYM_MEMBER 0x14 // Member of minor or major structure
|
---|
197 | #define SYM_BASED 0x15 // Based variable
|
---|
198 | #define SYM_TAG 0x16 // Tag in struct, union, enum ...
|
---|
199 | #define SYM_TABLE 0x17 // Table (used in RPG - not C)
|
---|
200 | #define SYM_MAP 0x18 // Map variable (extern in C)
|
---|
201 | #define SYM_CLASS 0x19 // Class symbol (C++)
|
---|
202 | #define SYM_MEMFUNC 0x1A // Member function
|
---|
203 | #define SYM_AUTOSCOPE 0x1B // Scoped auto for C++ (not used)
|
---|
204 | #define SYM_STATICSCOPE 0x1C // scoped static for C++ (not used)
|
---|
205 | #define SYM_CPPPROC 0x1D // C++ Proc
|
---|
206 | #define SYM_CPPSTAT 0x1E // C++ Static var
|
---|
207 | #define SYM_COMP 0x40 // Compiler information
|
---|
208 |
|
---|
209 |
|
---|
210 | // Symbolic begin record
|
---|
211 | struct symbegin_rec {
|
---|
212 | ULONG offset; // Segment offset
|
---|
213 | ULONG length; // Length of block
|
---|
214 | BYTE name_len; // Length of block name
|
---|
215 | // Block name follows
|
---|
216 | };
|
---|
217 |
|
---|
218 |
|
---|
219 | // Symbolic auto var record
|
---|
220 | struct symauto_rec {
|
---|
221 | ULONG stack_offset; // Stack offset
|
---|
222 | USHORT type_idx; // Type index
|
---|
223 | BYTE name_len; // Length of name
|
---|
224 | // Var name follows
|
---|
225 | };
|
---|
226 |
|
---|
227 |
|
---|
228 | // Symbolic procedure record
|
---|
229 | struct symproc_rec {
|
---|
230 | ULONG offset; // Segment offset
|
---|
231 | USHORT type_idx; // Type index
|
---|
232 | ULONG length; // Length of procedure
|
---|
233 | USHORT pro_len; // Length of prologue
|
---|
234 | ULONG pro_bodylen; // Length of prologue + body
|
---|
235 | USHORT class_type; // Class type
|
---|
236 | BYTE near_far; // Near or far
|
---|
237 | BYTE name_len; // Length of name
|
---|
238 | // Function name follows
|
---|
239 | };
|
---|
240 |
|
---|
241 |
|
---|
242 | // Symbolic static var record
|
---|
243 | struct symstatic_rec {
|
---|
244 | ULONG offset; // Segment offset
|
---|
245 | USHORT segaddr; // Segment address
|
---|
246 | USHORT type_idx; // Type index
|
---|
247 | BYTE name_len; // Length of name
|
---|
248 | // Var name follows
|
---|
249 | };
|
---|
250 |
|
---|
251 |
|
---|
252 | // Symbolic label var record
|
---|
253 | struct symlabel_rec {
|
---|
254 | ULONG offset; // Segment offset
|
---|
255 | BYTE near_far; // Near or far
|
---|
256 | BYTE name_len; // Length of name
|
---|
257 | // Var name follows
|
---|
258 | };
|
---|
259 |
|
---|
260 | // Symbolic register var record
|
---|
261 | struct symreg_rec {
|
---|
262 | USHORT type_idx; // Type index
|
---|
263 | BYTE reg_no; // Register number
|
---|
264 | BYTE name_len; // Length of name
|
---|
265 | // Var name follows
|
---|
266 | };
|
---|
267 |
|
---|
268 | // Symbolic change-segment record
|
---|
269 | struct symseg_rec {
|
---|
270 | USHORT seg_no; // Segment number
|
---|
271 | };
|
---|
272 |
|
---|
273 | // Symbolic typedef record
|
---|
274 | struct symtypedef_rec {
|
---|
275 | USHORT type_idx; // Type index
|
---|
276 | BYTE name_len; // Length of name
|
---|
277 | // Name follows
|
---|
278 | };
|
---|
279 |
|
---|
280 | // Symbolic public record
|
---|
281 | struct sympublic_rec {
|
---|
282 | ULONG offset; // Segment offset
|
---|
283 | USHORT segaddr; // Segment address
|
---|
284 | USHORT type_idx; // Type index
|
---|
285 | BYTE name_len; // Length of name
|
---|
286 | // Name follows
|
---|
287 | };
|
---|
288 |
|
---|
289 | // Symbolic member record
|
---|
290 | struct symmember_rec {
|
---|
291 | ULONG offset; // Offset to subrecord
|
---|
292 | BYTE name_len; // Length of name
|
---|
293 | // Name follows
|
---|
294 | };
|
---|
295 |
|
---|
296 | // Symbolic based record
|
---|
297 | struct symbased_rec {
|
---|
298 | ULONG offset; // Offset to subrecord
|
---|
299 | USHORT type_idx; // Type index
|
---|
300 | BYTE name_len; // Length of name
|
---|
301 | // Name follows
|
---|
302 | };
|
---|
303 |
|
---|
304 | // Symbolic tag record
|
---|
305 | struct symtag_rec {
|
---|
306 | USHORT type_idx; // Type index
|
---|
307 | BYTE name_len; // Length of name
|
---|
308 | // Name follows
|
---|
309 | };
|
---|
310 |
|
---|
311 |
|
---|
312 | // Symbolic table record
|
---|
313 | struct symtable_rec {
|
---|
314 | ULONG offset; // Segment offset
|
---|
315 | USHORT segaddr; // Segment address
|
---|
316 | USHORT type_idx; // Type index
|
---|
317 | ULONG idx_ofs; // Index offset to subrecord
|
---|
318 | BYTE name_len; // Length of name
|
---|
319 | // Name follows
|
---|
320 | };
|
---|
321 |
|
---|
322 |
|
---|
323 | // Type record
|
---|
324 | struct type_rec {
|
---|
325 | USHORT length; // Length of sub-record
|
---|
326 | BYTE type; // Sub-record type
|
---|
327 | BYTE type_qual; // Type qualifier
|
---|
328 | };
|
---|
329 |
|
---|
330 |
|
---|
331 |
|
---|
332 | // Types
|
---|
333 | #define TYPE_CLASS 0x40 // Class
|
---|
334 | #define TYPE_BASECLASS 0x41 // Base class
|
---|
335 | #define TYPE_FRIEND 0x42 // Friend
|
---|
336 | #define TYPE_CLASSDEF 0x43 // Class definition
|
---|
337 | #define TYPE_MEMBERFUNC 0x45 // Member function
|
---|
338 | #define TYPE_CLASSMEMBER 0x46 // Class member
|
---|
339 | #define TYPE_REF 0x48 // Reference
|
---|
340 | #define TYPE_MEMBERPTR 0x49 // Member pointer
|
---|
341 | #define TYPE_SCALARS 0x51 // Scalars
|
---|
342 | #define TYPE_SET 0x52 // Set
|
---|
343 | #define TYPE_ENTRY 0x53 // Entry
|
---|
344 | #define TYPE_FUNCTION 0x54 // Function
|
---|
345 | #define TYPE_AREA 0x55 // Area
|
---|
346 | #define TYPE_LOGICAL 0x56 // Logical
|
---|
347 | #define TYPE_STACK 0x57 // Stack
|
---|
348 | #define TYPE_MACRO 0x59 // Macro
|
---|
349 | #define TYPE_BITSTRING 0x5C // Bit string
|
---|
350 | #define TYPE_USERDEF 0x5D // User defined
|
---|
351 | #define TYPE_CHARSTR 0x60 // Character string
|
---|
352 | #define TYPE_PICTURE 0x61 // Picture
|
---|
353 | #define TYPE_GRAPHIC 0x62 // Graphic
|
---|
354 | #define TYPE_FORMATLAB 0x65 // Format label
|
---|
355 | #define TYPE_FILE 0x67 // File
|
---|
356 | #define TYPE_SUBRANGE 0x6F // Subrange
|
---|
357 | #define TYPE_CODELABEL 0x72 // Code label
|
---|
358 | #define TYPE_PROCEDURE 0x75 // Procedure
|
---|
359 | #define TYPE_ARRAY 0x78 // Array
|
---|
360 | #define TYPE_STRUCT 0x79 // Structure / Union / Record
|
---|
361 | #define TYPE_POINTER 0x7A // Pointer
|
---|
362 | #define TYPE_ENUM 0x7B // Enum
|
---|
363 | #define TYPE_LIST 0x7F // List
|
---|
364 |
|
---|
365 |
|
---|
366 | // Type userdef
|
---|
367 | struct type_userdefrec {
|
---|
368 | BYTE FID_index; // Field ID
|
---|
369 | USHORT type_index; // Type index
|
---|
370 | BYTE FID_string; // String ID
|
---|
371 | BYTE name_len; // Length of name which follows
|
---|
372 | };
|
---|
373 |
|
---|
374 |
|
---|
375 | // Type function
|
---|
376 | struct type_funcrec {
|
---|
377 | USHORT params;
|
---|
378 | USHORT max_params;
|
---|
379 | BYTE FID_index; // Field ID
|
---|
380 | USHORT type_index; // Type index of return value
|
---|
381 | BYTE FID_index1; // String ID
|
---|
382 | USHORT typelist_index; // Index of list of params
|
---|
383 | };
|
---|
384 |
|
---|
385 |
|
---|
386 | // Type struct
|
---|
387 | struct type_structrec {
|
---|
388 | ULONG size; // Size of structure
|
---|
389 | USHORT field_count; // Number of fields in structure
|
---|
390 | BYTE FID_index; // Field ID
|
---|
391 | USHORT type_list_idx; // Index to type list
|
---|
392 | BYTE FID_index1; // Field ID
|
---|
393 | USHORT type_name_idx; // Index to names / offsets
|
---|
394 | BYTE dont_know; // Haven't a clue, but it seems to be needed
|
---|
395 | BYTE name_len; // Length of structure name which follows
|
---|
396 | };
|
---|
397 |
|
---|
398 | // Type list, type qualifier 1: contains types for structures
|
---|
399 | // This record is repeated for the number of items in the structure definition
|
---|
400 | struct type_list1 {
|
---|
401 | BYTE FID_index; // Field identifier for index
|
---|
402 | USHORT type_index; // Type index.
|
---|
403 | };
|
---|
404 |
|
---|
405 | // Type list, type qualifier 2: contains names and offsets for structure items
|
---|
406 | // This record is repeated for the number of items in the structure definition
|
---|
407 | struct type_list2 {
|
---|
408 | BYTE FID_string; // String identifier
|
---|
409 | BYTE name_len; // Length of name which follows
|
---|
410 | };
|
---|
411 |
|
---|
412 | // Type list, subrecord to the above, contains offset of variable in the structure
|
---|
413 | struct type_list2_1 {
|
---|
414 | BYTE FID_span; // Defines what type of variable follows
|
---|
415 | union {
|
---|
416 | BYTE b_len;
|
---|
417 | USHORT s_len;
|
---|
418 | ULONG l_len;
|
---|
419 | } u;
|
---|
420 | };
|
---|
421 |
|
---|
422 | // Type pointer
|
---|
423 | struct type_pointerrec {
|
---|
424 | BYTE FID_index; // Index identifier
|
---|
425 | USHORT type_index; // Type index
|
---|
426 | BYTE FID_string; // String identifier
|
---|
427 | BYTE name_len; // Length of name which follows
|
---|
428 | };
|
---|