1 |
|
---|
2 | /*
|
---|
3 | *@@sourcefile debug.h:
|
---|
4 | * header file for debug.c (exception handling and debugging).
|
---|
5 | * See remarks there.
|
---|
6 | *
|
---|
7 | * Note: Version numbering in this file relates to XWorkplace version
|
---|
8 | * numbering.
|
---|
9 | *
|
---|
10 | *@@changed V0.9.0: included contents of newexe.h
|
---|
11 | *
|
---|
12 | *@@include #define INCL_BASE
|
---|
13 | *@@include #include <os2.h>
|
---|
14 | *@@include #include <stdio.h>
|
---|
15 | *@@include #include "helpers\debug.h"
|
---|
16 | */
|
---|
17 |
|
---|
18 | /*
|
---|
19 | * This file incorporates code from the following:
|
---|
20 | * -- Marc Fiammante, John Currier, Kim Rasmussen,
|
---|
21 | * Anthony Cruise (EXCEPT3.ZIP package for a generic
|
---|
22 | * exception handling DLL, available at Hobbes).
|
---|
23 | *
|
---|
24 | * This file Copyright (C) 1992-99 Ulrich Mller,
|
---|
25 | * Kim Rasmussen,
|
---|
26 | * Marc Fiammante,
|
---|
27 | * John Currier,
|
---|
28 | * Anthony Cruise.
|
---|
29 | * This program is free software; you can redistribute it and/or modify
|
---|
30 | * it under the terms of the GNU General Public License as published by
|
---|
31 | * the Free Software Foundation, in version 2 as it comes in the COPYING
|
---|
32 | * file of the XFolder main distribution.
|
---|
33 | * This program is distributed in the hope that it will be useful,
|
---|
34 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
35 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
36 | * GNU General Public License for more details.
|
---|
37 | */
|
---|
38 |
|
---|
39 | #ifndef DEBUG_HEADER_INCLUDED
|
---|
40 | #define DEBUG_HEADER_INCLUDED
|
---|
41 |
|
---|
42 | /********************************************************************
|
---|
43 | *
|
---|
44 | * SYM file declarations
|
---|
45 | *
|
---|
46 | ********************************************************************/
|
---|
47 |
|
---|
48 | // Pointer means offset from beginning of file or beginning of struct
|
---|
49 | #pragma pack(1)
|
---|
50 |
|
---|
51 | typedef struct
|
---|
52 | {
|
---|
53 | unsigned short int ppNextMap; // paragraph pointer to next map
|
---|
54 | unsigned char bFlags; // symbol types
|
---|
55 | unsigned char bReserved1; // reserved
|
---|
56 | unsigned short int pSegEntry; // segment entry point value
|
---|
57 | unsigned short int cConsts; // count of constants in map
|
---|
58 | unsigned short int pConstDef; // pointer to constant chain
|
---|
59 | unsigned short int cSegs; // count of segments in map
|
---|
60 | unsigned short int ppSegDef; // paragraph pointer to first segment
|
---|
61 | unsigned char cbMaxSym; // maximum symbol-name length
|
---|
62 | unsigned char cbModName; // length of module name
|
---|
63 | char achModName[1]; // cbModName Bytes of module-name member
|
---|
64 | } MAPDEF;
|
---|
65 |
|
---|
66 | typedef struct
|
---|
67 | {
|
---|
68 | unsigned short int ppNextMap; // always zero
|
---|
69 | unsigned char release; // release number (minor version number)
|
---|
70 | unsigned char version; // major version number
|
---|
71 | } LAST_MAPDEF;
|
---|
72 |
|
---|
73 | typedef struct
|
---|
74 | {
|
---|
75 | unsigned short int ppNextSeg; // paragraph pointer to next segment
|
---|
76 | unsigned short int cSymbols; // count of symbols in list
|
---|
77 | unsigned short int pSymDef; // offset of symbol chain
|
---|
78 | unsigned short int wReserved1; // reserved
|
---|
79 | unsigned short int wReserved2; // reserved
|
---|
80 | unsigned short int wReserved3; // reserved
|
---|
81 | unsigned short int wReserved4; // reserved
|
---|
82 | unsigned char bFlags; // symbol types; bit 0 signals 32-bit (*UM)
|
---|
83 | unsigned char bReserved1; // reserved
|
---|
84 | unsigned short int ppLineDef; // offset of line number record
|
---|
85 | unsigned char bReserved2; // reserved
|
---|
86 | unsigned char bReserved3; // reserved
|
---|
87 | unsigned char cbSegName; // length of segment name
|
---|
88 | char achSegName[1]; /* cbSegName Bytes of segment-name member*/
|
---|
89 | } SEGDEF;
|
---|
90 |
|
---|
91 | typedef struct
|
---|
92 | {
|
---|
93 | unsigned short int wSymVal; // symbol address or constant
|
---|
94 | unsigned char cbSymName; // length of symbol name
|
---|
95 | char achSymName[1]; // cbSymName Bytes of symbol-name member
|
---|
96 | } SYMDEF16;
|
---|
97 |
|
---|
98 | typedef struct
|
---|
99 | {
|
---|
100 | unsigned int wSymVal; // symbol address or constant
|
---|
101 | unsigned char cbSymName; // length of symbol name
|
---|
102 | char achSymName[1]; // cbSymName Bytes of symbol-name member
|
---|
103 | } SYMDEF32;
|
---|
104 |
|
---|
105 | typedef struct
|
---|
106 | {
|
---|
107 | unsigned short int ppNextLine; // ptr to next linedef (0 if last)
|
---|
108 | unsigned short int wReserved1; // reserved
|
---|
109 | unsigned short int pLines; // pointer to line numbers
|
---|
110 | unsigned short int cLines; // reserved
|
---|
111 | unsigned char cbFileName; // length of filename
|
---|
112 | char achFileName[1];// cbFileName Bytes of filename
|
---|
113 | } LINEDEF;
|
---|
114 |
|
---|
115 | typedef struct
|
---|
116 | {
|
---|
117 | unsigned short int wCodeOffset; // executable offset
|
---|
118 | unsigned short int dwFileOffset; // source offset
|
---|
119 | } LINEINF;
|
---|
120 |
|
---|
121 | #define SEGDEFOFFSET(MapDef) (MapDef.ppSegDef*16)
|
---|
122 | #define NEXTSEGDEFOFFSET(SegDef) (SegDef.ppNextSeg*16)
|
---|
123 |
|
---|
124 | #define ASYMPTROFFSET(SegDefOffset,Segdef) (SegDefOffset+SegDef.pSymDef)
|
---|
125 | #define SYMDEFOFFSET(SegDefOffset,SegDef,n) (ASYMPTROFFSET(SegDefOffset,SegDef)+(n)*(sizeof(unsigned short int)))
|
---|
126 |
|
---|
127 | #define ACONSTPTROFFSET(MapDef) (MapDef.ppConstDef)
|
---|
128 | #define CONSTDEFOFFSET(MapDef,n) ((MapDef.ppConstDef)+(n)*(sizeof(unsigned short int)))
|
---|
129 |
|
---|
130 | #define LINEDEFOFFSET(SegDef) (SegDef.ppLineDef*16)
|
---|
131 | #define NEXTLINEDEFOFFSET(LineDef) (LineDef.ppNextLine*16)
|
---|
132 | #define LINESOFFSET(LinedefOffset,LineDef) ((LinedefOffset)+LineDef.pLines)
|
---|
133 |
|
---|
134 | /********************************************************************
|
---|
135 | *
|
---|
136 | * EXE declarations taken from exe.h
|
---|
137 | *
|
---|
138 | ********************************************************************/
|
---|
139 |
|
---|
140 | #ifndef WORD
|
---|
141 | typedef unsigned short WORD;
|
---|
142 | #endif
|
---|
143 |
|
---|
144 | typedef WORD bbmask;
|
---|
145 |
|
---|
146 | struct exe {
|
---|
147 | WORD eid; // contains EXEID, below
|
---|
148 | WORD elast; // # of bytes in last page
|
---|
149 | WORD epagsiz; // # of pages in whole file
|
---|
150 | WORD erelcnt; // # of relocation entrys
|
---|
151 | WORD ehdrsiz; // size of header, in paragraphs
|
---|
152 | WORD eminfre; // min # of free paragraphs needed
|
---|
153 | WORD emaxfre; // max # of free paragraphs needed
|
---|
154 | WORD eiSS; // initial SS value
|
---|
155 | WORD eiSP; // initial SP value
|
---|
156 | WORD enegsum; // negative sum of entire file
|
---|
157 | WORD eiIP; // initial IP value
|
---|
158 | WORD eiCS; // initial CS value
|
---|
159 | WORD ereloff; // offset in file of relocation table
|
---|
160 | WORD eovlnum; // number of the overlay
|
---|
161 |
|
---|
162 | /* the following fields may not be present.
|
---|
163 | * ereloff = 28 not present
|
---|
164 | * = 30 exe.ever present and valid
|
---|
165 | * = 32 exe.ever field contains garbage
|
---|
166 | * ereloff > 32 exe.ever present and valid
|
---|
167 | * = 0 if "don't know"
|
---|
168 | */
|
---|
169 |
|
---|
170 | WORD ever; // version # of producing linker
|
---|
171 | WORD dumy; // unused
|
---|
172 |
|
---|
173 | /* the following fields may not be present - if the exe.ereloff
|
---|
174 | * value encompasses the fields then they are present and valid.
|
---|
175 | */
|
---|
176 |
|
---|
177 | bbmask ebb; // behavior bits
|
---|
178 | WORD dumy2[7]; // must be 0 until defined
|
---|
179 | };
|
---|
180 |
|
---|
181 |
|
---|
182 | #define EXEID 0x5a4d // magic ID value
|
---|
183 |
|
---|
184 | /********************************************************************
|
---|
185 | *
|
---|
186 | * Object Module Format (OMF) declarations
|
---|
187 | *
|
---|
188 | ********************************************************************/
|
---|
189 |
|
---|
190 | struct exehdr_rec
|
---|
191 | {
|
---|
192 | BYTE signature[2]; // Must be "MZ"
|
---|
193 | USHORT image_len; // Image Length
|
---|
194 | USHORT pages; // Pages
|
---|
195 | USHORT reloc_items; // Relocation table items
|
---|
196 | USHORT min_paragraphs; // Mininum 16-bytes paragraphs
|
---|
197 | USHORT max_paragraphs; // Maximum 16-bytes paragraphs
|
---|
198 | USHORT stack_pos; // Stack position
|
---|
199 | USHORT offset_in_sp; // Offset in SP
|
---|
200 | USHORT checksum; // Checksum
|
---|
201 | USHORT offset_in_ip; // Offset in IP
|
---|
202 | USHORT code_pos; // Code segment pos.
|
---|
203 | USHORT reloc_item_pos; // Position of first relocation item
|
---|
204 | USHORT overlay_number; // Overlay number
|
---|
205 | BYTE unused[8]; // Unused bytes
|
---|
206 | USHORT oem_id; // OEM Identifier
|
---|
207 | BYTE oem_info[24]; // OEM Info
|
---|
208 | ULONG lexe_offset; // Offset to linear header
|
---|
209 | };
|
---|
210 |
|
---|
211 | struct lexehdr_rec
|
---|
212 | {
|
---|
213 | BYTE signature[2]; // Must be "LX"
|
---|
214 | BYTE b_ord; // Byte ordering
|
---|
215 | BYTE w_ord; // Word ordering
|
---|
216 | ULONG format_level; // Format level
|
---|
217 | USHORT cpu_type; // CPU Type
|
---|
218 | USHORT os_type; // Operating system
|
---|
219 | ULONG module_version; // Module version
|
---|
220 | ULONG mod_flags; // Module flags
|
---|
221 | ULONG mod_pages; // Module pages
|
---|
222 | ULONG EIP_object; // EIP Object no.
|
---|
223 | ULONG EIP; // EIP Value
|
---|
224 | ULONG ESP_object; // ESP Object no
|
---|
225 | ULONG ESP; // ESP Value
|
---|
226 | ULONG page_size; // Page size
|
---|
227 | ULONG page_ofs_shift; // Page offset shift
|
---|
228 | ULONG fixup_sect_size; // Fixup section size
|
---|
229 | ULONG fixup_sect_checksum; // Fixup section checksum
|
---|
230 | ULONG loader_sect_size; // Loader section size
|
---|
231 | ULONG loader_sect_checksum; // Loader section checksum
|
---|
232 | ULONG obj_table_ofs; // Object table offset
|
---|
233 | ULONG obj_count; // Object count
|
---|
234 | ULONG obj_page_tab_ofs; // Object page table offset
|
---|
235 | ULONG obj_iter_page_ofs; // Object iteration pages offset
|
---|
236 | ULONG res_tab_ofs; // Resource table offset
|
---|
237 | ULONG res_table_entries; // Resource table entries
|
---|
238 | ULONG res_name_tab_ofs; // Resident name table offset;
|
---|
239 | ULONG ent_tab_ofs; // Entry table offset
|
---|
240 | ULONG mod_dir_ofs; // Module directives offset
|
---|
241 | ULONG mod_dir_count; // Number of module directives
|
---|
242 | ULONG fixup_page_tab_ofs; // Fixup page table offset
|
---|
243 | ULONG fixup_rec_tab_ofs; // Fixup record table offset
|
---|
244 | ULONG imp_tab_ofs; // Import module table offset
|
---|
245 | ULONG imp_mod_entries; // Import module entries
|
---|
246 | ULONG imp_proc_tab_ofs; // Import proc table offset
|
---|
247 | ULONG per_page_check_ofs; // Per page checksum offset
|
---|
248 | ULONG data_page_offset; // Data pages offset
|
---|
249 | ULONG preload_page_count; // Preload pages count
|
---|
250 | ULONG nonres_tab_ofs; // Nonresident name table offset
|
---|
251 | ULONG nonres_tab_len; // Nonresident name table len
|
---|
252 | ULONG nonres_tab_check; // Nonresident tables checksum
|
---|
253 | ULONG auto_ds_objectno; // Auto DS object number
|
---|
254 | ULONG debug_info_ofs; // Debug info offset
|
---|
255 | ULONG debug_info_len; // Debug info length
|
---|
256 | ULONG inst_preload_count; // Instance preload count
|
---|
257 | ULONG inst_demand_count; // Instance demand count
|
---|
258 | ULONG heapsize; // Heap size
|
---|
259 | ULONG stacksize; // Stack size
|
---|
260 | };
|
---|
261 |
|
---|
262 | struct debug_head_rec
|
---|
263 | {
|
---|
264 | BYTE signature[3]; // Debug signature
|
---|
265 | BYTE type; // Debug info type
|
---|
266 | };
|
---|
267 |
|
---|
268 | struct dir_inf_rec
|
---|
269 | {
|
---|
270 | USHORT dirstruct_size; // Size of directory structure
|
---|
271 | USHORT number_of_entries; // Number of dnt_rec's in the array
|
---|
272 | USHORT unknown; // Unknown data
|
---|
273 | // Followed by an array of dnt_rec structures
|
---|
274 | };
|
---|
275 |
|
---|
276 | struct dnt_rec
|
---|
277 | {
|
---|
278 | USHORT subsect_type; // sst Subsection type
|
---|
279 | USHORT mod_index; // Module index (1-based)
|
---|
280 | ULONG offset; // Offset of start of section
|
---|
281 | ULONG size; // Size of section
|
---|
282 | };
|
---|
283 |
|
---|
284 | // Modules subsection
|
---|
285 | struct modules_rec
|
---|
286 | {
|
---|
287 | USHORT code_seg_base; // Code segment base
|
---|
288 | ULONG code_seg_offset; // Code segment offset
|
---|
289 | ULONG code_seg_len; // Code segment length
|
---|
290 | USHORT overlay_no; // Overlay number
|
---|
291 | USHORT lib_idx; // Index into library section or 0
|
---|
292 | BYTE segments; // Number of segments
|
---|
293 | BYTE reserved;
|
---|
294 | BYTE debug_style[2]; // "HL" for HLL, "CV" or 0 for CodeView
|
---|
295 | BYTE debug_version[2]; // 00 01 or 00 03 for HLL, 00 00 for CV
|
---|
296 | BYTE name_len; // Length of name (which follows)
|
---|
297 | };
|
---|
298 |
|
---|
299 | // Publics subsection
|
---|
300 | struct publics_rec
|
---|
301 | {
|
---|
302 | ULONG offset; // Offset
|
---|
303 | USHORT segment; // Segment
|
---|
304 | USHORT type; // Type index
|
---|
305 | BYTE name_len; // Length of name (wich follows)
|
---|
306 | };
|
---|
307 |
|
---|
308 | #if 0
|
---|
309 | // Linenumbers header
|
---|
310 | struct linhead_rec
|
---|
311 | {
|
---|
312 | BYTE id; // 0x95 for flat mem, 32 bit progs
|
---|
313 | USHORT length; // Record length
|
---|
314 | USHORT base_group; // Base group
|
---|
315 | USHORT base_segment; // Base segment
|
---|
316 | };
|
---|
317 | #endif
|
---|
318 |
|
---|
319 | // First linenumber record
|
---|
320 | struct linfirst_rec
|
---|
321 | {
|
---|
322 | USHORT lineno; // Line number (0)
|
---|
323 | BYTE entry_type; // Entry type
|
---|
324 | BYTE reserved; // Reserved
|
---|
325 | USHORT entries_count; // Number of table entries
|
---|
326 | USHORT segment_no; // Segment number
|
---|
327 | ULONG filename_tabsize; // File names table size
|
---|
328 | };
|
---|
329 |
|
---|
330 | // Source line numbers
|
---|
331 | struct linsource_rec
|
---|
332 | {
|
---|
333 | USHORT source_line; // Source file line number
|
---|
334 | USHORT source_idx; // Source file index
|
---|
335 | ULONG offset; // Offset into segment
|
---|
336 | };
|
---|
337 |
|
---|
338 | // Listing statement numbers
|
---|
339 | struct linlist_rec
|
---|
340 | {
|
---|
341 | ULONG list_line; // Listing file linenumber
|
---|
342 | ULONG statement; // Listing file statement number
|
---|
343 | ULONG offset; // Offset into segment
|
---|
344 | };
|
---|
345 |
|
---|
346 | // Source and Listing statement numbers
|
---|
347 | struct linsourcelist_rec
|
---|
348 | {
|
---|
349 | USHORT source_line; // Source file line number
|
---|
350 | USHORT source_idx; // Source file index
|
---|
351 | ULONG list_line; // Listing file linenumber
|
---|
352 | ULONG statement; // Listing file statement number
|
---|
353 | ULONG offset; // Offset into segment
|
---|
354 | };
|
---|
355 |
|
---|
356 | // Path table
|
---|
357 | struct pathtab_rec
|
---|
358 | {
|
---|
359 | ULONG offset; // Offset into segment
|
---|
360 | USHORT path_code; // Path code
|
---|
361 | USHORT source_idx; // Source file index
|
---|
362 | };
|
---|
363 |
|
---|
364 | // File names table
|
---|
365 | struct filenam_rec
|
---|
366 | {
|
---|
367 | ULONG first_char; // First displayable char in list file
|
---|
368 | ULONG disp_chars; // Number of displayable chars in list line
|
---|
369 | ULONG filecount; // Number of source/listing files
|
---|
370 | };
|
---|
371 |
|
---|
372 | // Symbol types
|
---|
373 | #define SYM_BEGIN 0x00 // Begin block
|
---|
374 | #define SYM_PROC 0x01 // Function
|
---|
375 | #define SYM_END 0x02 // End block of function
|
---|
376 | #define SYM_AUTO 0x04 // Auto variable
|
---|
377 | #define SYM_STATIC 0x05 // Static variable
|
---|
378 | #define SYM_LABEL 0x0B // Label
|
---|
379 | #define SYM_WITH 0x0C // With start symbol (not used)
|
---|
380 | #define SYM_REG 0x0D // Register variable
|
---|
381 | #define SYM_CONST 0x0E // Constant
|
---|
382 | #define SYM_ENTRY 0x0F // Secondary entry (not in C)
|
---|
383 | #define SYM_SKIP 0x10 // For incremental linking (not used)
|
---|
384 | #define SYM_CHANGESEG 0x11 // Change segment (#pragma alloc_text)
|
---|
385 | #define SYM_TYPEDEF 0x12 // Typedef variable
|
---|
386 | #define SYM_PUBLIC 0x13 // Public reference
|
---|
387 | #define SYM_MEMBER 0x14 // Member of minor or major structure
|
---|
388 | #define SYM_BASED 0x15 // Based variable
|
---|
389 | #define SYM_TAG 0x16 // Tag in struct, union, enum ...
|
---|
390 | #define SYM_TABLE 0x17 // Table (used in RPG - not C)
|
---|
391 | #define SYM_MAP 0x18 // Map variable (extern in C)
|
---|
392 | #define SYM_CLASS 0x19 // Class symbol (C++)
|
---|
393 | #define SYM_MEMFUNC 0x1A // Member function
|
---|
394 | #define SYM_AUTOSCOPE 0x1B // Scoped auto for C++ (not used)
|
---|
395 | #define SYM_STATICSCOPE 0x1C // scoped static for C++ (not used)
|
---|
396 | #define SYM_CPPPROC 0x1D // C++ Proc
|
---|
397 | #define SYM_CPPSTAT 0x1E // C++ Static var
|
---|
398 | #define SYM_COMP 0x40 // Compiler information
|
---|
399 |
|
---|
400 | // Symbolic begin record
|
---|
401 | struct symbegin_rec
|
---|
402 | {
|
---|
403 | ULONG offset; // Segment offset
|
---|
404 | ULONG length; // Length of block
|
---|
405 | BYTE name_len; // Length of block name
|
---|
406 | // Block name follows
|
---|
407 | };
|
---|
408 |
|
---|
409 | // Symbolic auto var record
|
---|
410 | struct symauto_rec
|
---|
411 | {
|
---|
412 | ULONG stack_offset; // Stack offset
|
---|
413 | USHORT type_idx; // Type index
|
---|
414 | BYTE name_len; // Length of name
|
---|
415 | // Var name follows
|
---|
416 | };
|
---|
417 |
|
---|
418 | // Symbolic procedure record
|
---|
419 | struct symproc_rec
|
---|
420 | {
|
---|
421 | ULONG offset; // Segment offset
|
---|
422 | USHORT type_idx; // Type index
|
---|
423 | ULONG length; // Length of procedure
|
---|
424 | USHORT pro_len; // Length of prologue
|
---|
425 | ULONG pro_bodylen; // Length of prologue + body
|
---|
426 | USHORT class_type; // Class type
|
---|
427 | BYTE near_far; // Near or far
|
---|
428 | BYTE name_len; // Length of name
|
---|
429 | // Function name follows
|
---|
430 | };
|
---|
431 |
|
---|
432 | // Symbolic static var record
|
---|
433 | struct symstatic_rec
|
---|
434 | {
|
---|
435 | ULONG offset; // Segment offset
|
---|
436 | USHORT segaddr; // Segment address
|
---|
437 | USHORT type_idx; // Type index
|
---|
438 | BYTE name_len; // Length of name
|
---|
439 | // Var name follows
|
---|
440 | };
|
---|
441 |
|
---|
442 | // Symbolic label var record
|
---|
443 | struct symlabel_rec
|
---|
444 | {
|
---|
445 | ULONG offset; // Segment offset
|
---|
446 | BYTE near_far; // Near or far
|
---|
447 | BYTE name_len; // Length of name
|
---|
448 | // Var name follows
|
---|
449 | };
|
---|
450 |
|
---|
451 | // Symbolic register var record
|
---|
452 | struct symreg_rec
|
---|
453 | {
|
---|
454 | USHORT type_idx; // Type index
|
---|
455 | BYTE reg_no; // Register number
|
---|
456 | BYTE name_len; // Length of name
|
---|
457 | // Var name follows
|
---|
458 | };
|
---|
459 |
|
---|
460 | // Symbolic change-segment record
|
---|
461 | struct symseg_rec
|
---|
462 | {
|
---|
463 | USHORT seg_no; // Segment number
|
---|
464 | };
|
---|
465 |
|
---|
466 | // Symbolic typedef record
|
---|
467 | struct symtypedef_rec
|
---|
468 | {
|
---|
469 | USHORT type_idx; // Type index
|
---|
470 | BYTE name_len; // Length of name
|
---|
471 | // Name follows
|
---|
472 | };
|
---|
473 |
|
---|
474 | // Symbolic public record
|
---|
475 | struct sympublic_rec
|
---|
476 | {
|
---|
477 | ULONG offset; // Segment offset
|
---|
478 | USHORT segaddr; // Segment address
|
---|
479 | USHORT type_idx; // Type index
|
---|
480 | BYTE name_len; // Length of name
|
---|
481 | // Name follows
|
---|
482 | };
|
---|
483 |
|
---|
484 | // Symbolic member record
|
---|
485 | struct symmember_rec
|
---|
486 | {
|
---|
487 | ULONG offset; // Offset to subrecord
|
---|
488 | BYTE name_len; // Length of name
|
---|
489 | // Name follows
|
---|
490 | };
|
---|
491 |
|
---|
492 | // Symbolic based record
|
---|
493 | struct symbased_rec
|
---|
494 | {
|
---|
495 | ULONG offset; // Offset to subrecord
|
---|
496 | USHORT type_idx; // Type index
|
---|
497 | BYTE name_len; // Length of name
|
---|
498 | // Name follows
|
---|
499 | };
|
---|
500 |
|
---|
501 | // Symbolic tag record
|
---|
502 | struct symtag_rec
|
---|
503 | {
|
---|
504 | USHORT type_idx; // Type index
|
---|
505 | BYTE name_len; // Length of name
|
---|
506 | // Name follows
|
---|
507 | };
|
---|
508 |
|
---|
509 | // Symbolic table record
|
---|
510 | struct symtable_rec
|
---|
511 | {
|
---|
512 | ULONG offset; // Segment offset
|
---|
513 | USHORT segaddr; // Segment address
|
---|
514 | USHORT type_idx; // Type index
|
---|
515 | ULONG idx_ofs; // Index offset to subrecord
|
---|
516 | BYTE name_len; // Length of name
|
---|
517 | // Name follows
|
---|
518 | };
|
---|
519 |
|
---|
520 | // Type record
|
---|
521 | struct type_rec
|
---|
522 | {
|
---|
523 | USHORT length; // Length of sub-record
|
---|
524 | BYTE type; // Sub-record type
|
---|
525 | BYTE type_qual; // Type qualifier
|
---|
526 | };
|
---|
527 |
|
---|
528 | // Types
|
---|
529 | #define TYPE_CLASS 0x40 // Class
|
---|
530 | #define TYPE_BASECLASS 0x41 // Base class
|
---|
531 | #define TYPE_FRIEND 0x42 // Friend
|
---|
532 | #define TYPE_CLASSDEF 0x43 // Class definition
|
---|
533 | #define TYPE_MEMBERFUNC 0x45 // Member function
|
---|
534 | #define TYPE_CLASSMEMBER 0x46 // Class member
|
---|
535 | #define TYPE_REF 0x48 // Reference
|
---|
536 | #define TYPE_MEMBERPTR 0x49 // Member pointer
|
---|
537 | #define TYPE_SCALARS 0x51 // Scalars
|
---|
538 | #define TYPE_SET 0x52 // Set
|
---|
539 | #define TYPE_ENTRY 0x53 // Entry
|
---|
540 | #define TYPE_FUNCTION 0x54 // Function
|
---|
541 | #define TYPE_AREA 0x55 // Area
|
---|
542 | #define TYPE_LOGICAL 0x56 // Logical
|
---|
543 | #define TYPE_STACK 0x57 // Stack
|
---|
544 | #define TYPE_MACRO 0x59 // Macro
|
---|
545 | #define TYPE_BITSTRING 0x5C // Bit string
|
---|
546 | #define TYPE_USERDEF 0x5D // User defined
|
---|
547 | #define TYPE_CHARSTR 0x60 // Character string
|
---|
548 | #define TYPE_PICTURE 0x61 // Picture
|
---|
549 | #define TYPE_GRAPHIC 0x62 // Graphic
|
---|
550 | #define TYPE_FORMATLAB 0x65 // Format label
|
---|
551 | #define TYPE_FILE 0x67 // File
|
---|
552 | #define TYPE_SUBRANGE 0x6F // Subrange
|
---|
553 | #define TYPE_CODELABEL 0x72 // Code label
|
---|
554 | #define TYPE_PROCEDURE 0x75 // Procedure
|
---|
555 | #define TYPE_ARRAY 0x78 // Array
|
---|
556 | #define TYPE_STRUCT 0x79 // Structure / Union / Record
|
---|
557 | #define TYPE_POINTER 0x7A // Pointer
|
---|
558 | #define TYPE_ENUM 0x7B // Enum
|
---|
559 | #define TYPE_LIST 0x7F // List
|
---|
560 |
|
---|
561 | // Type userdef
|
---|
562 | struct type_userdefrec
|
---|
563 | {
|
---|
564 | BYTE FID_index; // Field ID
|
---|
565 | USHORT type_index; // Type index
|
---|
566 | BYTE FID_string; // String ID
|
---|
567 | BYTE name_len; // Length of name which follows
|
---|
568 | };
|
---|
569 |
|
---|
570 | // Type function
|
---|
571 | struct type_funcrec
|
---|
572 | {
|
---|
573 | USHORT params;
|
---|
574 | USHORT max_params;
|
---|
575 | BYTE FID_index; // Field ID
|
---|
576 | USHORT type_index; // Type index of return value
|
---|
577 | BYTE FID_index1; // String ID
|
---|
578 | USHORT typelist_index; // Index of list of params
|
---|
579 | };
|
---|
580 |
|
---|
581 | // Type struct
|
---|
582 | struct type_structrec
|
---|
583 | {
|
---|
584 | ULONG size; // Size of structure
|
---|
585 | USHORT field_count; // Number of fields in structure
|
---|
586 | BYTE FID_index; // Field ID
|
---|
587 | USHORT type_list_idx; // Index to type list
|
---|
588 | BYTE FID_index1; // Field ID
|
---|
589 | USHORT type_name_idx; // Index to names / offsets
|
---|
590 | BYTE dont_know; // Haven't a clue, but it seems to be needed
|
---|
591 | BYTE name_len; // Length of structure name which follows
|
---|
592 | };
|
---|
593 |
|
---|
594 | // Type list, type qualifier 1: contains types for structures
|
---|
595 | // This record is repeated for the number of items in the structure definition
|
---|
596 | struct type_list1
|
---|
597 | {
|
---|
598 | BYTE FID_index; // Field identifier for index
|
---|
599 | USHORT type_index; // Type index.
|
---|
600 | };
|
---|
601 |
|
---|
602 | // Type list, type qualifier 2: contains names and offsets for structure items
|
---|
603 | // This record is repeated for the number of items in the structure definition
|
---|
604 | struct type_list2
|
---|
605 | {
|
---|
606 | BYTE FID_string; // String identifier
|
---|
607 | BYTE name_len; // Length of name which follows
|
---|
608 | };
|
---|
609 |
|
---|
610 | // Type list, subrecord to the above, contains offset of variable in the structure
|
---|
611 | struct type_list2_1
|
---|
612 | {
|
---|
613 | BYTE FID_span; // Defines what type of variable follows
|
---|
614 | union {
|
---|
615 | BYTE b_len;
|
---|
616 | USHORT s_len;
|
---|
617 | ULONG l_len;
|
---|
618 | } u;
|
---|
619 | };
|
---|
620 |
|
---|
621 | // Type pointer
|
---|
622 | struct type_pointerrec
|
---|
623 | {
|
---|
624 | BYTE FID_index; // Index identifier
|
---|
625 | USHORT type_index; // Type index
|
---|
626 | BYTE FID_string; // String identifier
|
---|
627 | BYTE name_len; // Length of name which follows
|
---|
628 | };
|
---|
629 |
|
---|
630 | /********************************************************************
|
---|
631 | *
|
---|
632 | * Prototypes
|
---|
633 | *
|
---|
634 | ********************************************************************/
|
---|
635 |
|
---|
636 | BOOL dbgPrintStackFrame(FILE *LogFile,
|
---|
637 | PSZ pszModuleName, // in: module name (fully q'fied)
|
---|
638 | ULONG ulObject,
|
---|
639 | ULONG ulOffset);
|
---|
640 |
|
---|
641 | VOID dbgPrintStack(FILE *file,
|
---|
642 | PUSHORT StackBottom,
|
---|
643 | PUSHORT StackTop,
|
---|
644 | PUSHORT Ebp,
|
---|
645 | PUSHORT ExceptionAddress);
|
---|
646 |
|
---|
647 | APIRET APIENTRY DosQueryModFromEIP(HMODULE *phMod, // out: trapping module
|
---|
648 | ULONG *pulObjNum, // out: object/segment number
|
---|
649 | ULONG ulBuffLen, // in: sizeof(*pszBuff)
|
---|
650 | CHAR *pszBuff, // out: module name
|
---|
651 | ULONG *pulOffset, // out: offset in module
|
---|
652 | ULONG ulAddress); // in: address to be analyzed
|
---|
653 |
|
---|
654 | APIRET APIENTRY DOSQUERYMODFROMEIP(HMODULE * phMod,
|
---|
655 | ULONG * pObjNum,
|
---|
656 | ULONG BuffLen,
|
---|
657 | PCHAR pBuff,
|
---|
658 | ULONG * pOffset,
|
---|
659 | PVOID Address);
|
---|
660 |
|
---|
661 | typedef ULONG *_Seg16 PULONG16;
|
---|
662 | APIRET16 APIENTRY16 DOS16SIZESEG(USHORT Seg, PULONG16 Size);
|
---|
663 | typedef APIRET16(APIENTRY16 _PFN16) (VOID);
|
---|
664 | ULONG APIENTRY DosSelToFlat(ULONG);
|
---|
665 |
|
---|
666 | APIRET16 APIENTRY16 DOSQPROCSTATUS(ULONG * _Seg16 pBuf, USHORT cbBuf);
|
---|
667 |
|
---|
668 | #define CONVERT(fp,QSsel) MAKEP((QSsel),OFFSETOF(fp))
|
---|
669 |
|
---|
670 | #pragma pack() // added V0.9.0
|
---|
671 |
|
---|
672 |
|
---|
673 | /********************************************************************
|
---|
674 | *
|
---|
675 | * Executable definitions
|
---|
676 | *
|
---|
677 | ********************************************************************/
|
---|
678 |
|
---|
679 | #define EXE386 1
|
---|
680 |
|
---|
681 | #ifndef __NEWEXE__
|
---|
682 | #define __NEWEXE__
|
---|
683 |
|
---|
684 | #pragma pack(1)
|
---|
685 |
|
---|
686 | /*_________________________________________________________________*
|
---|
687 | | |
|
---|
688 | | |
|
---|
689 | | DOS3 .EXE FILE HEADER DEFINITION |
|
---|
690 | | |
|
---|
691 | |_________________________________________________________________|
|
---|
692 | * */
|
---|
693 |
|
---|
694 |
|
---|
695 | #define EMAGIC 0x5A4D // Old magic number
|
---|
696 | #define ENEWEXE sizeof(struct exe_hdr)
|
---|
697 | // Value of E_LFARLC for new .EXEs
|
---|
698 | #define ENEWHDR 0x003C // Offset in old hdr. of ptr. to new
|
---|
699 | #define ERESWDS 0x0010 // No. of reserved words (OLD)
|
---|
700 | #define ERES1WDS 0x0004 // No. of reserved words in e_res
|
---|
701 | #define ERES2WDS 0x000A // No. of reserved words in e_res2
|
---|
702 | #define ECP 0x0004 // Offset in struct of E_CP
|
---|
703 | #define ECBLP 0x0002 // Offset in struct of E_CBLP
|
---|
704 | #define EMINALLOC 0x000A // Offset in struct of E_MINALLOC
|
---|
705 |
|
---|
706 | /*
|
---|
707 | *@@ exe_hdr:
|
---|
708 | * DOS 1, 2, 3 .EXE header.
|
---|
709 | */
|
---|
710 |
|
---|
711 | struct exe_hdr
|
---|
712 | {
|
---|
713 | unsigned short e_magic; // Magic number
|
---|
714 | unsigned short e_cblp; // Bytes on last page of file
|
---|
715 | unsigned short e_cp; // Pages in file
|
---|
716 | unsigned short e_crlc; // Relocations
|
---|
717 | unsigned short e_cparhdr; // Size of header in paragraphs
|
---|
718 | unsigned short e_minalloc; // Minimum extra paragraphs needed
|
---|
719 | unsigned short e_maxalloc; // Maximum extra paragraphs needed
|
---|
720 | unsigned short e_ss; // Initial (relative) SS value
|
---|
721 | unsigned short e_sp; // Initial SP value
|
---|
722 | unsigned short e_csum; // Checksum
|
---|
723 | unsigned short e_ip; // Initial IP value
|
---|
724 | unsigned short e_cs; // Initial (relative) CS value
|
---|
725 | unsigned short e_lfarlc; // File address of relocation table
|
---|
726 | unsigned short e_ovno; // Overlay number
|
---|
727 | unsigned short e_res[ERES1WDS];// Reserved words
|
---|
728 | unsigned short e_oemid; // OEM identifier (for e_oeminfo)
|
---|
729 | unsigned short e_oeminfo; // OEM information; e_oemid specific
|
---|
730 | unsigned short e_res2[ERES2WDS];// Reserved words
|
---|
731 | long e_lfanew; // File address of new exe header
|
---|
732 | };
|
---|
733 |
|
---|
734 | #define E_MAGIC(x) (x).e_magic
|
---|
735 | #define E_CBLP(x) (x).e_cblp
|
---|
736 | #define E_CP(x) (x).e_cp
|
---|
737 | #define E_CRLC(x) (x).e_crlc
|
---|
738 | #define E_CPARHDR(x) (x).e_cparhdr
|
---|
739 | #define E_MINALLOC(x) (x).e_minalloc
|
---|
740 | #define E_MAXALLOC(x) (x).e_maxalloc
|
---|
741 | #define E_SS(x) (x).e_ss
|
---|
742 | #define E_SP(x) (x).e_sp
|
---|
743 | #define E_CSUM(x) (x).e_csum
|
---|
744 | #define E_IP(x) (x).e_ip
|
---|
745 | #define E_CS(x) (x).e_cs
|
---|
746 | #define E_LFARLC(x) (x).e_lfarlc
|
---|
747 | #define E_OVNO(x) (x).e_ovno
|
---|
748 | #define E_RES(x) (x).e_res
|
---|
749 | #define E_OEMID(x) (x).e_oemid
|
---|
750 | #define E_OEMINFO(x) (x).e_oeminfo
|
---|
751 | #define E_RES2(x) (x).e_res2
|
---|
752 | #define E_LFANEW(x) (x).e_lfanew
|
---|
753 |
|
---|
754 |
|
---|
755 | /*_________________________________________________________________*
|
---|
756 | | |
|
---|
757 | | |
|
---|
758 | | OS/2 & WINDOWS .EXE FILE HEADER DEFINITION - 286 version |
|
---|
759 | | |
|
---|
760 | |_________________________________________________________________|
|
---|
761 | * */
|
---|
762 |
|
---|
763 | #define NEMAGIC 0x454E // New magic number
|
---|
764 | #define NERESBYTES 8 // Eight bytes reserved (now)
|
---|
765 | #define NECRC 8 // Offset into new header of NE_CRC
|
---|
766 |
|
---|
767 | /*
|
---|
768 | *@@ new_exe:
|
---|
769 | * New Executable (NE) header.
|
---|
770 | * Follows DOS header in the executable file.
|
---|
771 | */
|
---|
772 |
|
---|
773 | struct new_exe
|
---|
774 | {
|
---|
775 | unsigned short ne_magic; // Magic number NE_MAGIC
|
---|
776 | unsigned char ne_ver; // Version number
|
---|
777 | unsigned char ne_rev; // Revision number
|
---|
778 | unsigned short ne_enttab; // Offset of Entry Table
|
---|
779 | unsigned short ne_cbenttab; // Number of bytes in Entry Table
|
---|
780 | long ne_crc; // Checksum of whole file
|
---|
781 | unsigned short ne_flags; // Flag word
|
---|
782 | unsigned short ne_autodata; // Automatic data segment number
|
---|
783 | unsigned short ne_heap; // Initial heap allocation
|
---|
784 | unsigned short ne_stack; // Initial stack allocation
|
---|
785 | long ne_csip; // Initial CS:IP setting
|
---|
786 | long ne_sssp; // Initial SS:SP setting
|
---|
787 | unsigned short ne_cseg; // Count of file segments
|
---|
788 | unsigned short ne_cmod; // Entries in Module Reference Table
|
---|
789 | unsigned short ne_cbnrestab; // Size of non-resident name table
|
---|
790 | unsigned short ne_segtab; // Offset of Segment Table
|
---|
791 | unsigned short ne_rsrctab; // Offset of Resource Table
|
---|
792 | unsigned short ne_restab; // Offset of resident name table
|
---|
793 | unsigned short ne_modtab; // Offset of Module Reference Table
|
---|
794 | unsigned short ne_imptab; // Offset of Imported Names Table
|
---|
795 | long ne_nrestab; // Offset of Non-resident Names Table
|
---|
796 | unsigned short ne_cmovent; // Count of movable entries
|
---|
797 | unsigned short ne_align; // Segment alignment shift count
|
---|
798 | unsigned short ne_cres; // Count of resource entries
|
---|
799 | unsigned char ne_exetyp; // Target operating system
|
---|
800 | unsigned char ne_flagsothers; // Other .EXE flags
|
---|
801 | char ne_res[NERESBYTES]; // Pad structure to 64 bytes
|
---|
802 | };
|
---|
803 |
|
---|
804 | #pragma pack()
|
---|
805 |
|
---|
806 | #define NE_MAGIC(x) (x).ne_magic
|
---|
807 | #define NE_VER(x) (x).ne_ver
|
---|
808 | #define NE_REV(x) (x).ne_rev
|
---|
809 | #define NE_ENTTAB(x) (x).ne_enttab
|
---|
810 | #define NE_CBENTTAB(x) (x).ne_cbenttab
|
---|
811 | #define NE_CRC(x) (x).ne_crc
|
---|
812 | #define NE_FLAGS(x) (x).ne_flags
|
---|
813 | #define NE_AUTODATA(x) (x).ne_autodata
|
---|
814 | #define NE_HEAP(x) (x).ne_heap
|
---|
815 | #define NE_STACK(x) (x).ne_stack
|
---|
816 | #define NE_CSIP(x) (x).ne_csip
|
---|
817 | #define NE_SSSP(x) (x).ne_sssp
|
---|
818 | #define NE_CSEG(x) (x).ne_cseg
|
---|
819 | #define NE_CMOD(x) (x).ne_cmod
|
---|
820 | #define NE_CBNRESTAB(x) (x).ne_cbnrestab
|
---|
821 | #define NE_SEGTAB(x) (x).ne_segtab
|
---|
822 | #define NE_RSRCTAB(x) (x).ne_rsrctab
|
---|
823 | #define NE_RESTAB(x) (x).ne_restab
|
---|
824 | #define NE_MODTAB(x) (x).ne_modtab
|
---|
825 | #define NE_IMPTAB(x) (x).ne_imptab
|
---|
826 | #define NE_NRESTAB(x) (x).ne_nrestab
|
---|
827 | #define NE_CMOVENT(x) (x).ne_cmovent
|
---|
828 | #define NE_ALIGN(x) (x).ne_align
|
---|
829 | #define NE_CRES(x) (x).ne_cres
|
---|
830 | #define NE_RES(x) (x).ne_res
|
---|
831 | #define NE_EXETYP(x) (x).ne_exetyp
|
---|
832 | #define NE_FLAGSOTHERS(x) (x).ne_flagsothers
|
---|
833 |
|
---|
834 | #define NE_USAGE(x) (WORD)*((WORD *)(x)+1)
|
---|
835 | #define NE_PNEXTEXE(x) (WORD)(x).ne_cbenttab
|
---|
836 | #define NE_ONEWEXE(x) (WORD)(x).ne_crc
|
---|
837 | #define NE_PFILEINFO(x) (WORD)((DWORD)(x).ne_crc >> 16)
|
---|
838 |
|
---|
839 |
|
---|
840 | /*
|
---|
841 | * Target operating systems
|
---|
842 | */
|
---|
843 |
|
---|
844 | #define NE_UNKNOWN 0x0 /* Unknown (any "new-format" OS) */
|
---|
845 | #define NE_OS2 0x1 /* OS/2 (default) */
|
---|
846 | #define NE_WINDOWS 0x2 /* Windows */
|
---|
847 | #define NE_DOS4 0x3 /* DOS 4.x */
|
---|
848 | #define NE_DEV386 0x4 /* Windows 386 */
|
---|
849 |
|
---|
850 |
|
---|
851 | /*
|
---|
852 | * Format of NE_FLAGS(x):
|
---|
853 | *
|
---|
854 | * p Not-a-process
|
---|
855 | * x Unused
|
---|
856 | * e Errors in image
|
---|
857 | * x Unused
|
---|
858 | * b Bound Family/API
|
---|
859 | * ttt Application type
|
---|
860 | * f Floating-point instructions
|
---|
861 | * 3 386 instructions
|
---|
862 | * 2 286 instructions
|
---|
863 | * 0 8086 instructions
|
---|
864 | * P Protected mode only
|
---|
865 | * p Per-process library initialization
|
---|
866 | * i Instance data
|
---|
867 | * s Solo data
|
---|
868 | */
|
---|
869 | #define NENOTP 0x8000 /* Not a process */
|
---|
870 | #define NEIERR 0x2000 /* Errors in image */
|
---|
871 | #define NEBOUND 0x0800 /* Bound Family/API */
|
---|
872 | #define NEAPPTYP 0x0700 /* Application type mask */
|
---|
873 | #define NENOTWINCOMPAT 0x0100 /* Not compatible with P.M. Windowing */
|
---|
874 | #define NEWINCOMPAT 0x0200 /* Compatible with P.M. Windowing */
|
---|
875 | #define NEWINAPI 0x0300 /* Uses P.M. Windowing API */
|
---|
876 | #define NEFLTP 0x0080 /* Floating-point instructions */
|
---|
877 | #define NEI386 0x0040 /* 386 instructions */
|
---|
878 | #define NEI286 0x0020 /* 286 instructions */
|
---|
879 | #define NEI086 0x0010 /* 8086 instructions */
|
---|
880 | #define NEPROT 0x0008 /* Runs in protected mode only */
|
---|
881 | #define NEPPLI 0x0004 /* Per-Process Library Initialization */
|
---|
882 | #define NEINST 0x0002 /* Instance data */
|
---|
883 | #define NESOLO 0x0001 /* Solo data */
|
---|
884 |
|
---|
885 | /*
|
---|
886 | * Format of NE_FLAGSOTHERS(x):
|
---|
887 | *
|
---|
888 | * 7 6 5 4 3 2 1 0 - bit no
|
---|
889 | * | | | |
|
---|
890 | * | | | +---------------- Support for long file names
|
---|
891 | * | | +------------------ Windows 2.x app runs in prot mode
|
---|
892 | * | +-------------------- Windows 2.x app gets prop. font
|
---|
893 | * +------------------------------ WLO appl on OS/2 (markwlo.exe)
|
---|
894 | *
|
---|
895 | */
|
---|
896 |
|
---|
897 | #define NELONGNAMES 0x01
|
---|
898 | #define NEWINISPROT 0x02
|
---|
899 | #define NEWINGETPROPFON 0x04
|
---|
900 | #define NEWLOAPPL 0x80
|
---|
901 |
|
---|
902 |
|
---|
903 |
|
---|
904 | struct new_seg /* New .EXE segment table entry */
|
---|
905 | {
|
---|
906 | unsigned short ns_sector; /* File sector of start of segment */
|
---|
907 | unsigned short ns_cbseg; /* Number of bytes in file */
|
---|
908 | unsigned short ns_flags; /* Attribute flags */
|
---|
909 | unsigned short ns_minalloc; /* Minimum allocation in bytes */
|
---|
910 | };
|
---|
911 |
|
---|
912 | #define NS_SECTOR(x) (x).ns_sector
|
---|
913 | #define NS_CBSEG(x) (x).ns_cbseg
|
---|
914 | #define NS_FLAGS(x) (x).ns_flags
|
---|
915 | #define NS_MINALLOC(x) (x).ns_minalloc
|
---|
916 |
|
---|
917 |
|
---|
918 | /*
|
---|
919 | * Format of NS_FLAGS(x)
|
---|
920 | *
|
---|
921 | * Flag word has the following format:
|
---|
922 | *
|
---|
923 | * 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 - bit no
|
---|
924 | * | | | | | | | | | | | | | | |
|
---|
925 | * | | | | | | | | | | | | +-+-+--- Segment type DATA/CODE
|
---|
926 | * | | | | | | | | | | | +--------- Iterated segment
|
---|
927 | * | | | | | | | | | | +----------- Movable segment
|
---|
928 | * | | | | | | | | | +------------- Segment can be shared
|
---|
929 | * | | | | | | | | +--------------- Preload segment
|
---|
930 | * | | | | | | | +----------------- Execute/read-only for code/data segment
|
---|
931 | * | | | | | | +------------------- Segment has relocations
|
---|
932 | * | | | | | +--------------------- Code conforming/Data is expand down
|
---|
933 | * | | | +--+----------------------- I/O privilege level
|
---|
934 | * | | +----------------------------- Discardable segment
|
---|
935 | * | +-------------------------------- 32-bit code segment
|
---|
936 | * +----------------------------------- Huge segment/GDT allocation requested
|
---|
937 | *
|
---|
938 | */
|
---|
939 |
|
---|
940 | #define NSTYPE 0x0007 /* Segment type mask */
|
---|
941 |
|
---|
942 | #ifdef EXE386
|
---|
943 | #define NSCODE 0x0000 /* Code segment */
|
---|
944 | #define NSDATA 0x0001 /* Data segment */
|
---|
945 | #define NSITER 0x0008 /* Iterated segment flag */
|
---|
946 | #define NSMOVE 0x0010 /* Movable segment flag */
|
---|
947 | #define NSSHARED 0x0020 /* Shared segment flag */
|
---|
948 | #define NSPRELOAD 0x0040 /* Preload segment flag */
|
---|
949 | #define NSEXRD 0x0080 /* Execute-only (code segment), or
|
---|
950 | * read-only (data segment)
|
---|
951 | */
|
---|
952 | #define NSRELOC 0x0100 /* Segment has relocations */
|
---|
953 | #define NSCONFORM 0x0200 /* Conforming segment */
|
---|
954 | #define NSEXPDOWN 0x0200 /* Data segment is expand down */
|
---|
955 | #define NSDPL 0x0C00 /* I/O privilege level (286 DPL bits) */
|
---|
956 | #define SHIFTDPL 10 /* Left shift count for SEGDPL field */
|
---|
957 | #define NSDISCARD 0x1000 /* Segment is discardable */
|
---|
958 | #define NS32BIT 0x2000 /* 32-bit code segment */
|
---|
959 | #define NSHUGE 0x4000 /* Huge memory segment, length of
|
---|
960 | * segment and minimum allocation
|
---|
961 | * size are in segment sector units
|
---|
962 | */
|
---|
963 | #define NSGDT 0x8000 /* GDT allocation requested */
|
---|
964 |
|
---|
965 | #define NSPURE NSSHARED /* For compatibility */
|
---|
966 |
|
---|
967 | #define NSALIGN 9 /* Segment data aligned on 512 byte boundaries */
|
---|
968 |
|
---|
969 | #define NSLOADED 0x0004 /* ns_sector field contains memory addr */
|
---|
970 | #endif
|
---|
971 |
|
---|
972 |
|
---|
973 | struct new_segdata /* Segment data */
|
---|
974 | {
|
---|
975 | union
|
---|
976 | {
|
---|
977 | struct
|
---|
978 | {
|
---|
979 | unsigned short ns_niter; /* number of iterations */
|
---|
980 | unsigned short ns_nbytes; /* number of bytes */
|
---|
981 | char ns_iterdata; /* iterated data bytes */
|
---|
982 | } ns_iter;
|
---|
983 | struct
|
---|
984 | {
|
---|
985 | char ns_data; /* data bytes */
|
---|
986 | } ns_noniter;
|
---|
987 | } ns_union;
|
---|
988 | };
|
---|
989 |
|
---|
990 | struct new_rlcinfo /* Relocation info */
|
---|
991 | {
|
---|
992 | unsigned short nr_nreloc; /* number of relocation items that */
|
---|
993 | }; /* follow */
|
---|
994 |
|
---|
995 | #pragma pack(1)
|
---|
996 |
|
---|
997 |
|
---|
998 | struct new_rlc /* Relocation item */
|
---|
999 | {
|
---|
1000 | char nr_stype; /* Source type */
|
---|
1001 | char nr_flags; /* Flag byte */
|
---|
1002 | unsigned short nr_soff; /* Source offset */
|
---|
1003 | union
|
---|
1004 | {
|
---|
1005 | struct
|
---|
1006 | {
|
---|
1007 | char nr_segno; /* Target segment number */
|
---|
1008 | char nr_res; /* Reserved */
|
---|
1009 | unsigned short nr_entry; /* Target Entry Table offset */
|
---|
1010 | } nr_intref; /* Internal reference */
|
---|
1011 | struct
|
---|
1012 | {
|
---|
1013 | unsigned short nr_mod; /* Index into Module Reference Table */
|
---|
1014 | unsigned short nr_proc; /* Procedure ordinal or name offset */
|
---|
1015 | } nr_import; /* Import */
|
---|
1016 | struct
|
---|
1017 | {
|
---|
1018 | unsigned short nr_ostype; /* OSFIXUP type */
|
---|
1019 | unsigned short nr_osres; /* reserved */
|
---|
1020 | } nr_osfix; /* Operating system fixup */
|
---|
1021 | } nr_union; /* Union */
|
---|
1022 | };
|
---|
1023 |
|
---|
1024 | #pragma pack()
|
---|
1025 |
|
---|
1026 |
|
---|
1027 | #define NR_STYPE(x) (x).nr_stype
|
---|
1028 | #define NR_FLAGS(x) (x).nr_flags
|
---|
1029 | #define NR_SOFF(x) (x).nr_soff
|
---|
1030 | #define NR_SEGNO(x) (x).nr_union.nr_intref.nr_segno
|
---|
1031 | #define NR_RES(x) (x).nr_union.nr_intref.nr_res
|
---|
1032 | #define NR_ENTRY(x) (x).nr_union.nr_intref.nr_entry
|
---|
1033 | #define NR_MOD(x) (x).nr_union.nr_import.nr_mod
|
---|
1034 | #define NR_PROC(x) (x).nr_union.nr_import.nr_proc
|
---|
1035 | #define NR_OSTYPE(x) (x).nr_union.nr_osfix.nr_ostype
|
---|
1036 | #define NR_OSRES(x) (x).nr_union.nr_osfix.nr_osres
|
---|
1037 |
|
---|
1038 |
|
---|
1039 |
|
---|
1040 | /*
|
---|
1041 | * Format of NR_STYPE(x) and R32_STYPE(x):
|
---|
1042 | *
|
---|
1043 | * 7 6 5 4 3 2 1 0 - bit no
|
---|
1044 | * | | | |
|
---|
1045 | * +-+-+-+--- source type
|
---|
1046 | *
|
---|
1047 | */
|
---|
1048 |
|
---|
1049 | #define NRSTYP 0x0f /* Source type mask */
|
---|
1050 | #define NRSBYT 0x00 /* lo byte (8-bits)*/
|
---|
1051 | #define NRSSEG 0x02 /* 16-bit segment (16-bits) */
|
---|
1052 | #define NRSPTR 0x03 /* 16:16 pointer (32-bits) */
|
---|
1053 | #define NRSOFF 0x05 /* 16-bit offset (16-bits) */
|
---|
1054 | #define NRPTR48 0x06 /* 16:32 pointer (48-bits) */
|
---|
1055 | #define NROFF32 0x07 /* 32-bit offset (32-bits) */
|
---|
1056 | #define NRSOFF32 0x08 /* 32-bit self-relative offset (32-bits) */
|
---|
1057 |
|
---|
1058 |
|
---|
1059 | /*
|
---|
1060 | * Format of NR_FLAGS(x) and R32_FLAGS(x):
|
---|
1061 | *
|
---|
1062 | * 7 6 5 4 3 2 1 0 - bit no
|
---|
1063 | * | | |
|
---|
1064 | * | +-+--- Reference type
|
---|
1065 | * +------- Additive fixup
|
---|
1066 | */
|
---|
1067 |
|
---|
1068 | #define NRADD 0x04 /* Additive fixup */
|
---|
1069 | #define NRRTYP 0x03 /* Reference type mask */
|
---|
1070 | #define NRRINT 0x00 /* Internal reference */
|
---|
1071 | #define NRRORD 0x01 /* Import by ordinal */
|
---|
1072 | #define NRRNAM 0x02 /* Import by name */
|
---|
1073 | #define NRROSF 0x03 /* Operating system fixup */
|
---|
1074 |
|
---|
1075 |
|
---|
1076 | #if (EXE386 == 0)
|
---|
1077 |
|
---|
1078 | /* Resource type or name string */
|
---|
1079 | struct rsrc_string
|
---|
1080 | {
|
---|
1081 | char rs_len; /* number of bytes in string */
|
---|
1082 | char rs_string[ 1 ]; /* text of string */
|
---|
1083 | };
|
---|
1084 |
|
---|
1085 | #define RS_LEN( x ) (x).rs_len
|
---|
1086 | #define RS_STRING( x ) (x).rs_string
|
---|
1087 |
|
---|
1088 | /* Resource type information block */
|
---|
1089 | struct rsrc_typeinfo
|
---|
1090 | {
|
---|
1091 | unsigned short rt_id;
|
---|
1092 | unsigned short rt_nres;
|
---|
1093 | long rt_proc;
|
---|
1094 | };
|
---|
1095 |
|
---|
1096 | #define RT_ID( x ) (x).rt_id
|
---|
1097 | #define RT_NRES( x ) (x).rt_nres
|
---|
1098 | #define RT_PROC( x ) (x).rt_proc
|
---|
1099 |
|
---|
1100 | /* Resource name information block */
|
---|
1101 | struct rsrc_nameinfo
|
---|
1102 | {
|
---|
1103 | /* The following two fields must be shifted left by the value of */
|
---|
1104 | /* the rs_align field to compute their actual value. This allows */
|
---|
1105 | /* resources to be larger than 64k, but they do not need to be */
|
---|
1106 | /* aligned on 512 byte boundaries, the way segments are */
|
---|
1107 | unsigned short rn_offset; /* file offset to resource data */
|
---|
1108 | unsigned short rn_length; /* length of resource data */
|
---|
1109 | unsigned short rn_flags; /* resource flags */
|
---|
1110 | unsigned short rn_id; /* resource name id */
|
---|
1111 | unsigned short rn_handle; /* If loaded, then global handle */
|
---|
1112 | unsigned short rn_usage; /* Initially zero. Number of times */
|
---|
1113 | /* the handle for this resource has */
|
---|
1114 | /* been given out */
|
---|
1115 | };
|
---|
1116 |
|
---|
1117 | #define RN_OFFSET( x ) (x).rn_offset
|
---|
1118 | #define RN_LENGTH( x ) (x).rn_length
|
---|
1119 | #define RN_FLAGS( x ) (x).rn_flags
|
---|
1120 | #define RN_ID( x ) (x).rn_id
|
---|
1121 | #define RN_HANDLE( x ) (x).rn_handle
|
---|
1122 | #define RN_USAGE( x ) (x).rn_usage
|
---|
1123 |
|
---|
1124 | #define RSORDID 0x8000 /* if high bit of ID set then integer id */
|
---|
1125 | /* otherwise ID is offset of string from
|
---|
1126 | the beginning of the resource table */
|
---|
1127 |
|
---|
1128 | /* Ideally these are the same as the */
|
---|
1129 | /* corresponding segment flags */
|
---|
1130 | #define RNMOVE 0x0010 /* Moveable resource */
|
---|
1131 | #define RNPURE 0x0020 /* Pure (read-only) resource */
|
---|
1132 | #define RNPRELOAD 0x0040 /* Preloaded resource */
|
---|
1133 | #define RNDISCARD 0xF000 /* Discard priority level for resource */
|
---|
1134 |
|
---|
1135 | /* Resource table */
|
---|
1136 | struct new_rsrc
|
---|
1137 | {
|
---|
1138 | unsigned short rs_align; /* alignment shift count for resources */
|
---|
1139 | struct rsrc_typeinfo rs_typeinfo;
|
---|
1140 | };
|
---|
1141 |
|
---|
1142 | #define RS_ALIGN( x ) (x).rs_align
|
---|
1143 |
|
---|
1144 |
|
---|
1145 | #endif /* NOT EXE386 */
|
---|
1146 |
|
---|
1147 | #endif /* __NEWEXE__ */
|
---|
1148 |
|
---|
1149 | #ifndef DWORD
|
---|
1150 | #define DWORD long int
|
---|
1151 | #endif
|
---|
1152 |
|
---|
1153 | #ifndef WORD
|
---|
1154 | #define WORD short int
|
---|
1155 | #endif
|
---|
1156 |
|
---|
1157 | #ifndef __EXE386__
|
---|
1158 | #define __EXE386__
|
---|
1159 |
|
---|
1160 | #pragma pack(1) /* Force byte alignment */
|
---|
1161 |
|
---|
1162 | /*_________________________________________________________________*
|
---|
1163 | | |
|
---|
1164 | | |
|
---|
1165 | | OS/2 .EXE FILE HEADER DEFINITION - 386 version 0:32 |
|
---|
1166 | | |
|
---|
1167 | |_________________________________________________________________|
|
---|
1168 | * */
|
---|
1169 |
|
---|
1170 | #define BITPERWORD 16
|
---|
1171 | #define BITPERBYTE 8
|
---|
1172 | #define OBJPAGELEN 4096
|
---|
1173 | #define E32MAGIC1 'L' /* New magic number "LX" */
|
---|
1174 | #define E32MAGIC2 'X' /* New magic number "LX" */
|
---|
1175 | #define E32MAGIC 0x584c /* New magic number "LX" */
|
---|
1176 | #define E32RESBYTES1 0 /* First bytes reserved */
|
---|
1177 | #define E32RESBYTES2 0 /* Second bytes reserved */
|
---|
1178 | #define E32RESBYTES3 20 /* Third bytes reserved */
|
---|
1179 | #define E32LEBO 0x00 /* Little Endian Byte Order */
|
---|
1180 | #define E32BEBO 0x01 /* Big Endian Byte Order */
|
---|
1181 | #define E32LEWO 0x00 /* Little Endian Word Order */
|
---|
1182 | #define E32BEWO 0x01 /* Big Endian Word Order */
|
---|
1183 | #define E32LEVEL 0L /* 32-bit EXE format level */
|
---|
1184 | #define E32CPU286 0x001 /* Intel 80286 or upwardly compatibile */
|
---|
1185 | #define E32CPU386 0x002 /* Intel 80386 or upwardly compatibile */
|
---|
1186 | #define E32CPU486 0x003 /* Intel 80486 or upwardly compatibile */
|
---|
1187 |
|
---|
1188 |
|
---|
1189 |
|
---|
1190 | struct e32_exe /* New 32-bit .EXE header */
|
---|
1191 | {
|
---|
1192 | unsigned char e32_magic[2]; /* Magic number E32_MAGIC */
|
---|
1193 | unsigned char e32_border; /* The byte ordering for the .EXE */
|
---|
1194 | unsigned char e32_worder; /* The word ordering for the .EXE */
|
---|
1195 | unsigned long e32_level; /* The EXE format level for now = 0 */
|
---|
1196 | unsigned short e32_cpu; /* The CPU type */
|
---|
1197 | unsigned short e32_os; /* The OS type */
|
---|
1198 | unsigned long e32_ver; /* Module version */
|
---|
1199 | unsigned long e32_mflags; /* Module flags */
|
---|
1200 | unsigned long e32_mpages; /* Module # pages */
|
---|
1201 | unsigned long e32_startobj; /* Object # for instruction pointer */
|
---|
1202 | unsigned long e32_eip; /* Extended instruction pointer */
|
---|
1203 | unsigned long e32_stackobj; /* Object # for stack pointer */
|
---|
1204 | unsigned long e32_esp; /* Extended stack pointer */
|
---|
1205 | unsigned long e32_pagesize; /* .EXE page size */
|
---|
1206 | unsigned long e32_pageshift; /* Page alignment shift in .EXE */
|
---|
1207 | unsigned long e32_fixupsize; /* Fixup section size */
|
---|
1208 | unsigned long e32_fixupsum; /* Fixup section checksum */
|
---|
1209 | unsigned long e32_ldrsize; /* Loader section size */
|
---|
1210 | unsigned long e32_ldrsum; /* Loader section checksum */
|
---|
1211 | unsigned long e32_objtab; /* Object table offset */
|
---|
1212 | unsigned long e32_objcnt; /* Number of objects in module */
|
---|
1213 | unsigned long e32_objmap; /* Object page map offset */
|
---|
1214 | unsigned long e32_itermap; /* Object iterated data map offset */
|
---|
1215 | unsigned long e32_rsrctab; /* Offset of Resource Table */
|
---|
1216 | unsigned long e32_rsrccnt; /* Number of resource entries */
|
---|
1217 | unsigned long e32_restab; /* Offset of resident name table */
|
---|
1218 | unsigned long e32_enttab; /* Offset of Entry Table */
|
---|
1219 | unsigned long e32_dirtab; /* Offset of Module Directive Table */
|
---|
1220 | unsigned long e32_dircnt; /* Number of module directives */
|
---|
1221 | unsigned long e32_fpagetab; /* Offset of Fixup Page Table */
|
---|
1222 | unsigned long e32_frectab; /* Offset of Fixup Record Table */
|
---|
1223 | unsigned long e32_impmod; /* Offset of Import Module Name Table */
|
---|
1224 | unsigned long e32_impmodcnt; /* Number of entries in Import Module Name Table */
|
---|
1225 | unsigned long e32_impproc; /* Offset of Import Procedure Name Table */
|
---|
1226 | unsigned long e32_pagesum; /* Offset of Per-Page Checksum Table */
|
---|
1227 | unsigned long e32_datapage; /* Offset of Enumerated Data Pages */
|
---|
1228 | unsigned long e32_preload; /* Number of preload pages */
|
---|
1229 | unsigned long e32_nrestab; /* Offset of Non-resident Names Table */
|
---|
1230 | unsigned long e32_cbnrestab; /* Size of Non-resident Name Table */
|
---|
1231 | unsigned long e32_nressum; /* Non-resident Name Table Checksum */
|
---|
1232 | unsigned long e32_autodata; /* Object # for automatic data object */
|
---|
1233 | unsigned long e32_debuginfo; /* Offset of the debugging information */
|
---|
1234 | unsigned long e32_debuglen; /* The length of the debugging info. in bytes */
|
---|
1235 | unsigned long e32_instpreload;/* Number of instance pages in preload section of .EXE file */
|
---|
1236 | unsigned long e32_instdemand; /* Number of instance pages in demand load section of .EXE file */
|
---|
1237 | unsigned long e32_heapsize; /* Size of heap - for 16-bit apps */
|
---|
1238 | unsigned long e32_stacksize; /* Size of stack */
|
---|
1239 | unsigned char e32_res3[E32RESBYTES3];
|
---|
1240 | /* Pad structure to 196 bytes */
|
---|
1241 | };
|
---|
1242 |
|
---|
1243 |
|
---|
1244 |
|
---|
1245 | #define E32_MAGIC1(x) (x).e32_magic[0]
|
---|
1246 | #define E32_MAGIC2(x) (x).e32_magic[1]
|
---|
1247 | #define E32_BORDER(x) (x).e32_border
|
---|
1248 | #define E32_WORDER(x) (x).e32_worder
|
---|
1249 | #define E32_LEVEL(x) (x).e32_level
|
---|
1250 | #define E32_CPU(x) (x).e32_cpu
|
---|
1251 | #define E32_OS(x) (x).e32_os
|
---|
1252 | #define E32_VER(x) (x).e32_ver
|
---|
1253 | #define E32_MFLAGS(x) (x).e32_mflags
|
---|
1254 | #define E32_MPAGES(x) (x).e32_mpages
|
---|
1255 | #define E32_STARTOBJ(x) (x).e32_startobj
|
---|
1256 | #define E32_EIP(x) (x).e32_eip
|
---|
1257 | #define E32_STACKOBJ(x) (x).e32_stackobj
|
---|
1258 | #define E32_ESP(x) (x).e32_esp
|
---|
1259 | #define E32_PAGESIZE(x) (x).e32_pagesize
|
---|
1260 | #define E32_PAGESHIFT(x) (x).e32_pageshift
|
---|
1261 | #define E32_FIXUPSIZE(x) (x).e32_fixupsize
|
---|
1262 | #define E32_FIXUPSUM(x) (x).e32_fixupsum
|
---|
1263 | #define E32_LDRSIZE(x) (x).e32_ldrsize
|
---|
1264 | #define E32_LDRSUM(x) (x).e32_ldrsum
|
---|
1265 | #define E32_OBJTAB(x) (x).e32_objtab
|
---|
1266 | #define E32_OBJCNT(x) (x).e32_objcnt
|
---|
1267 | #define E32_OBJMAP(x) (x).e32_objmap
|
---|
1268 | #define E32_ITERMAP(x) (x).e32_itermap
|
---|
1269 | #define E32_RSRCTAB(x) (x).e32_rsrctab
|
---|
1270 | #define E32_RSRCCNT(x) (x).e32_rsrccnt
|
---|
1271 | #define E32_RESTAB(x) (x).e32_restab
|
---|
1272 | #define E32_ENTTAB(x) (x).e32_enttab
|
---|
1273 | #define E32_DIRTAB(x) (x).e32_dirtab
|
---|
1274 | #define E32_DIRCNT(x) (x).e32_dircnt
|
---|
1275 | #define E32_FPAGETAB(x) (x).e32_fpagetab
|
---|
1276 | #define E32_FRECTAB(x) (x).e32_frectab
|
---|
1277 | #define E32_IMPMOD(x) (x).e32_impmod
|
---|
1278 | #define E32_IMPMODCNT(x) (x).e32_impmodcnt
|
---|
1279 | #define E32_IMPPROC(x) (x).e32_impproc
|
---|
1280 | #define E32_PAGESUM(x) (x).e32_pagesum
|
---|
1281 | #define E32_DATAPAGE(x) (x).e32_datapage
|
---|
1282 | #define E32_PRELOAD(x) (x).e32_preload
|
---|
1283 | #define E32_NRESTAB(x) (x).e32_nrestab
|
---|
1284 | #define E32_CBNRESTAB(x) (x).e32_cbnrestab
|
---|
1285 | #define E32_NRESSUM(x) (x).e32_nressum
|
---|
1286 | #define E32_AUTODATA(x) (x).e32_autodata
|
---|
1287 | #define E32_DEBUGINFO(x) (x).e32_debuginfo
|
---|
1288 | #define E32_DEBUGLEN(x) (x).e32_debuglen
|
---|
1289 | #define E32_INSTPRELOAD(x) (x).e32_instpreload
|
---|
1290 | #define E32_INSTDEMAND(x) (x).e32_instdemand
|
---|
1291 | #define E32_HEAPSIZE(x) (x).e32_heapsize
|
---|
1292 | #define E32_STACKSIZE(x) (x).e32_stacksize
|
---|
1293 |
|
---|
1294 |
|
---|
1295 |
|
---|
1296 | /*
|
---|
1297 | * Format of E32_MFLAGS(x):
|
---|
1298 | *
|
---|
1299 | * Low word has the following format:
|
---|
1300 | *
|
---|
1301 | * 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 - bit no
|
---|
1302 | * | | | | | | | |
|
---|
1303 | * | | | | | | | +------- Per-Process Library Initialization
|
---|
1304 | * | | | | | | +--------- SystemDLL (internal fixups discarded)
|
---|
1305 | * | | | | | +----------- No Internal Fixups for Module in .EXE
|
---|
1306 | * | | | | +------------- No External Fixups for Module in .EXE
|
---|
1307 | * | | | +------------------- Incompatible with PM Windowing
|
---|
1308 | * | | +--------------------- Compatible with PM Windowing
|
---|
1309 | * | | Uses PM Windowing API
|
---|
1310 | * | +-------------------------------- Module not Loadable
|
---|
1311 | * +-------------------------------------- Library Module
|
---|
1312 | */
|
---|
1313 |
|
---|
1314 |
|
---|
1315 | #define E32NOTP 0x8000L /* Library Module - used as NENOTP */
|
---|
1316 | #define E32NOLOAD 0x2000L /* Module not Loadable */
|
---|
1317 | #define E32PMAPI 0x0300L /* Uses PM Windowing API */
|
---|
1318 | #define E32PMW 0x0200L /* Compatible with PM Windowing */
|
---|
1319 | #define E32NOPMW 0x0100L /* Incompatible with PM Windowing */
|
---|
1320 | #define E32NOEXTFIX 0x0020L /* NO External Fixups in .EXE */
|
---|
1321 | #define E32NOINTFIX 0x0010L /* NO Internal Fixups in .EXE */
|
---|
1322 | #define E32SYSDLL 0x0008L /* System DLL, Internal Fixups discarded*/
|
---|
1323 | #define E32LIBINIT 0x0004L /* Per-Process Library Initialization */
|
---|
1324 | #define E32LIBTERM 0x40000000L /* Per-Process Library Termination */
|
---|
1325 | #define E32APPMASK 0x0300L /* Application Type Mask */
|
---|
1326 |
|
---|
1327 |
|
---|
1328 | /*
|
---|
1329 | * Format of E32_MFLAGS(x):
|
---|
1330 | *
|
---|
1331 | * High word has the following format:
|
---|
1332 | *
|
---|
1333 | * 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 - bit no
|
---|
1334 | * | |
|
---|
1335 | * | +--- Protected memory library module
|
---|
1336 | * +----- Device driver
|
---|
1337 | */
|
---|
1338 |
|
---|
1339 | #define E32PROTDLL 0x10000L /* Protected memory library module */
|
---|
1340 | #define E32DEVICE 0x20000L /* Device driver */
|
---|
1341 | #define E32MODEXE 0x00000L /* .EXE module */
|
---|
1342 | #define E32MODDLL 0x08000L /* .DLL module */
|
---|
1343 | #define E32MODPROTDLL 0x18000L /* Protected memory library module */
|
---|
1344 | #define E32MODPDEV 0x20000L /* Physical device driver */
|
---|
1345 | #define E32MODVDEV 0x28000L /* Virtual device driver */
|
---|
1346 | #define E32MODMASK 0x38000L /* Module type mask */
|
---|
1347 |
|
---|
1348 | /*
|
---|
1349 | * RELOCATION DEFINITIONS - RUN-TIME FIXUPS
|
---|
1350 | */
|
---|
1351 |
|
---|
1352 | typedef union _RELOC_OFS
|
---|
1353 | {
|
---|
1354 | unsigned short offset16;
|
---|
1355 | unsigned long offset32;
|
---|
1356 | } RELOC_OFS; /* 16-bit or 32-bit offset */
|
---|
1357 |
|
---|
1358 |
|
---|
1359 | /***ET+ r32_rlc - Relocation item */
|
---|
1360 |
|
---|
1361 | struct r32_rlc /* Relocation item */
|
---|
1362 | {
|
---|
1363 | unsigned char nr_stype; /* Source type - field shared with new_rlc */
|
---|
1364 | unsigned char nr_flags; /* Flag byte - field shared with new_rlc */
|
---|
1365 | short r32_soff; /* Source offset */
|
---|
1366 | unsigned short r32_objmod; /* Target object number or Module ordinal */
|
---|
1367 |
|
---|
1368 | union targetid
|
---|
1369 | {
|
---|
1370 | RELOC_OFS intref; /* Internal fixup */
|
---|
1371 |
|
---|
1372 | union extfixup
|
---|
1373 | {
|
---|
1374 | RELOC_OFS proc; /* Procedure name offset */
|
---|
1375 | unsigned long ord; /* Procedure odrinal */
|
---|
1376 | } extref; /* External fixup */
|
---|
1377 |
|
---|
1378 | struct addfixup
|
---|
1379 | {
|
---|
1380 | unsigned short entry; /* Entry ordinal */
|
---|
1381 | RELOC_OFS addval; /* Value added to the address */
|
---|
1382 | } addfix; /* Additive fixup */
|
---|
1383 | }
|
---|
1384 | r32_target; /* Target data */
|
---|
1385 | unsigned short r32_srccount; /* Number of chained fixup records */
|
---|
1386 | unsigned short r32_chain; /* Chain head */
|
---|
1387 | };
|
---|
1388 |
|
---|
1389 | /*
|
---|
1390 | * In 32-bit .EXE file run-time relocations are written as varying size
|
---|
1391 | * records, so we need many size definitions.
|
---|
1392 | */
|
---|
1393 |
|
---|
1394 | #define RINTSIZE16 8
|
---|
1395 | #define RINTSIZE32 10
|
---|
1396 | #define RORDSIZE 8
|
---|
1397 | #define RNAMSIZE16 8
|
---|
1398 | #define RNAMSIZE32 10
|
---|
1399 | #define RADDSIZE16 10
|
---|
1400 | #define RADDSIZE32 12
|
---|
1401 |
|
---|
1402 | #if FALSE
|
---|
1403 | /*
|
---|
1404 | * Access macros defined in NEWEXE.H !!!
|
---|
1405 | */
|
---|
1406 | #define NR_STYPE(x) (x).nr_stype
|
---|
1407 | #define NR_FLAGS(x) (x).nr_flags
|
---|
1408 | #endif
|
---|
1409 |
|
---|
1410 | #define R32_SOFF(x) (x).r32_soff
|
---|
1411 | #define R32_OBJNO(x) (x).r32_objmod
|
---|
1412 | #define R32_MODORD(x) (x).r32_objmod
|
---|
1413 | #define R32_OFFSET16(x) (x).r32_target.intref.offset16
|
---|
1414 | #define R32_OFFSET32(x) (x).r32_target.intref.offset32
|
---|
1415 | #define R32_PROCOFF16(x) (x).r32_target.extref.proc.offset16
|
---|
1416 | #define R32_PROCOFF32(x) (x).r32_target.extref.proc.offset32
|
---|
1417 | #define R32_PROCORD(x) (x).r32_target.extref.ord
|
---|
1418 | #define R32_ENTRY(x) (x).r32_target.addfix.entry
|
---|
1419 | #define R32_ADDVAL16(x) (x).r32_target.addfix.addval.offset16
|
---|
1420 | #define R32_ADDVAL32(x) (x).r32_target.addfix.addval.offset32
|
---|
1421 | #define R32_SRCCNT(x) (x).r32_srccount
|
---|
1422 | #define R32_CHAIN(x) (x).r32_chain
|
---|
1423 |
|
---|
1424 |
|
---|
1425 |
|
---|
1426 | /*
|
---|
1427 | * Format of NR_STYPE(x)
|
---|
1428 | *
|
---|
1429 | * 7 6 5 4 3 2 1 0 - bit no
|
---|
1430 | * | | | | | |
|
---|
1431 | * | | +-+-+-+--- Source type
|
---|
1432 | * | +----------- Fixup to 16:16 alias
|
---|
1433 | * +------------- List of source offset follows fixup record
|
---|
1434 | */
|
---|
1435 |
|
---|
1436 | #if FALSE
|
---|
1437 |
|
---|
1438 | /* DEFINED in newexe.h !!! */
|
---|
1439 |
|
---|
1440 | #define NRSTYP 0x0f /* Source type mask */
|
---|
1441 | #define NRSBYT 0x00 /* lo byte (8-bits)*/
|
---|
1442 | #define NRSSEG 0x02 /* 16-bit segment (16-bits) */
|
---|
1443 | #define NRSPTR 0x03 /* 16:16 pointer (32-bits) */
|
---|
1444 | #define NRSOFF 0x05 /* 16-bit offset (16-bits) */
|
---|
1445 | #define NRPTR48 0x06 /* 16:32 pointer (48-bits) */
|
---|
1446 | #define NROFF32 0x07 /* 32-bit offset (32-bits) */
|
---|
1447 | #define NRSOFF32 0x08 /* 32-bit self-relative offset (32-bits) */
|
---|
1448 | #endif
|
---|
1449 |
|
---|
1450 |
|
---|
1451 | #define NRSRCMASK 0x0f /* Source type mask */
|
---|
1452 | #define NRALIAS 0x10 /* Fixup to alias */
|
---|
1453 | #define NRCHAIN 0x20 /* List of source offset follows */
|
---|
1454 | /* fixup record, source offset field */
|
---|
1455 | /* in fixup record contains number */
|
---|
1456 | /* of elements in list */
|
---|
1457 |
|
---|
1458 | /*
|
---|
1459 | * Format of NR_FLAGS(x) and R32_FLAGS(x):
|
---|
1460 | *
|
---|
1461 | * 7 6 5 4 3 2 1 0 - bit no
|
---|
1462 | * | | | | | | |
|
---|
1463 | * | | | | | +-+--- Reference type
|
---|
1464 | * | | | | +------- Additive fixup
|
---|
1465 | * | | | +----------- 32-bit Target Offset Flag (1 - 32-bit; 0 - 16-bit)
|
---|
1466 | * | | +------------- 32-bit Additive Flag (1 - 32-bit; 0 - 16-bit)
|
---|
1467 | * | +--------------- 16-bit Object/Module ordinal (1 - 16-bit; 0 - 8-bit)
|
---|
1468 | * +----------------- 8-bit import ordinal (1 - 8-bit;
|
---|
1469 | * 0 - NR32BITOFF toggles
|
---|
1470 | * between 16 and 32 bit
|
---|
1471 | * ordinal)
|
---|
1472 | */
|
---|
1473 |
|
---|
1474 | #ifdef NEVER_INCLUDE_THE_FOLLWING
|
---|
1475 | /* DEFINED in newexe.h !!! */
|
---|
1476 | #define NRRTYP 0x03 /* Reference type mask */
|
---|
1477 | #define NRRINT 0x00 /* Internal reference */
|
---|
1478 | #define NRRORD 0x01 /* Import by ordinal */
|
---|
1479 | #define NRRNAM 0x02 /* Import by name */
|
---|
1480 | #define NRADD 0x04 /* Additive fixup */
|
---|
1481 | #endif
|
---|
1482 |
|
---|
1483 | #define NRRENT 0x03 /* Internal entry table fixup */
|
---|
1484 |
|
---|
1485 | #define NR32BITOFF 0x10 /* 32-bit Target Offset */
|
---|
1486 | #define NR32BITADD 0x20 /* 32-bit Additive fixup */
|
---|
1487 | #define NR16OBJMOD 0x40 /* 16-bit Object/Module ordinal */
|
---|
1488 | #define NR8BITORD 0x80 /* 8-bit import ordinal */
|
---|
1489 | /*end*/
|
---|
1490 |
|
---|
1491 | /*
|
---|
1492 | * Data structures for storing run-time fixups in linker virtual memory.
|
---|
1493 | *
|
---|
1494 | * Each object has a list of Object Page Directories which specify
|
---|
1495 | * fixups for given page. Each page has its own hash table which is
|
---|
1496 | * used to detect fixups to the same target.
|
---|
1497 | */
|
---|
1498 |
|
---|
1499 | #define PAGEPERDIR 62
|
---|
1500 | #define LG2DIR 7
|
---|
1501 |
|
---|
1502 |
|
---|
1503 | typedef struct _OBJPAGEDIR
|
---|
1504 | {
|
---|
1505 | DWORD next; /* Virtual pointer to next dir on list */
|
---|
1506 | WORD ht[PAGEPERDIR]; /* Pointers to individual hash tables */
|
---|
1507 | }
|
---|
1508 | OBJPAGEDIR;
|
---|
1509 |
|
---|
1510 | /*
|
---|
1511 | * OBJECT TABLE
|
---|
1512 | */
|
---|
1513 |
|
---|
1514 | /***ET+ o32_obj Object Table Entry */
|
---|
1515 |
|
---|
1516 | struct o32_obj /* Flat .EXE object table entry */
|
---|
1517 | {
|
---|
1518 | unsigned long o32_size; /* Object virtual size */
|
---|
1519 | unsigned long o32_base; /* Object base virtual address */
|
---|
1520 | unsigned long o32_flags; /* Attribute flags */
|
---|
1521 | unsigned long o32_pagemap; /* Object page map index */
|
---|
1522 | unsigned long o32_mapsize; /* Number of entries in object page map */
|
---|
1523 | unsigned long o32_reserved; /* Reserved */
|
---|
1524 | };
|
---|
1525 |
|
---|
1526 |
|
---|
1527 | #define O32_SIZE(x) (x).o32_size
|
---|
1528 | #define O32_BASE(x) (x).o32_base
|
---|
1529 | #define O32_FLAGS(x) (x).o32_flags
|
---|
1530 | #define O32_PAGEMAP(x) (x).o32_pagemap
|
---|
1531 | #define O32_MAPSIZE(x) (x).o32_mapsize
|
---|
1532 | #define O32_RESERVED(x) (x).o32_reserved
|
---|
1533 |
|
---|
1534 | /*
|
---|
1535 | * Format of O32_FLAGS(x)
|
---|
1536 | *
|
---|
1537 | * High word of dword flag field is not used for now.
|
---|
1538 | * Low word has the following format:
|
---|
1539 | *
|
---|
1540 | * 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 - bit no
|
---|
1541 | * | | | | | | | | | | | | | | |
|
---|
1542 | * | | | | | | | | | | | | | | +--- Readable Object
|
---|
1543 | * | | | | | | | | | | | | | +----- Writeable Object
|
---|
1544 | * | | | | | | | | | | | | +------- Executable Object
|
---|
1545 | * | | | | | | | | | | | +--------- Resource Object
|
---|
1546 | * | | | | | | | | | | +----------- Object is Discardable
|
---|
1547 | * | | | | | | | | | +------------- Object is Shared
|
---|
1548 | * | | | | | | | | +--------------- Object has preload pages
|
---|
1549 | * | | | | | | | +----------------- Object has invalid pages
|
---|
1550 | * | | | | | | +------------------- Object is permanent and swappable
|
---|
1551 | * | | | | | +--------------------- Object is permanent and resident
|
---|
1552 | * | | | | +----------------------- Object is permanent and long lockable
|
---|
1553 | * | | | +----------------------------- 16:16 alias required (80x86 specific)
|
---|
1554 | * | | +-------------------------------- Big/Default bit setting (80x86 specific)
|
---|
1555 | * | +----------------------------------- Object is conforming for code (80x86 specific)
|
---|
1556 | * +-------------------------------------- Object I/O privilege level (80x86 specific)
|
---|
1557 | *
|
---|
1558 | */
|
---|
1559 |
|
---|
1560 | #define OBJREAD 0x0001L /* Readable Object */
|
---|
1561 | #define OBJWRITE 0x0002L /* Writeable Object */
|
---|
1562 | #define OBJRSRC 0x0008L /* Resource Object */
|
---|
1563 | #define OBJINVALID 0x0080L /* Object has invalid pages */
|
---|
1564 | #define LNKNONPERM 0x0600L /* Object is nonpermanent - should be */
|
---|
1565 | #define OBJNONPERM 0x0000L /* zero in the .EXE but LINK386 uses 6 */
|
---|
1566 | #define OBJPERM 0x0100L /* Object is permanent and swappable */
|
---|
1567 | #define OBJRESIDENT 0x0200L /* Object is permanent and resident */
|
---|
1568 | #define OBJCONTIG 0x0300L /* Object is resident and contiguous */
|
---|
1569 | #define OBJDYNAMIC 0x0400L /* Object is permanent and long locable */
|
---|
1570 | #define OBJTYPEMASK 0x0700L /* Object type mask */
|
---|
1571 | #define OBJALIAS16 0x1000L /* 16:16 alias required (80x86 specific) */
|
---|
1572 | #define OBJBIGDEF 0x2000L /* Big/Default bit setting (80x86 specific) */
|
---|
1573 | #define OBJIOPL 0x8000L /* Object I/O privilege level (80x86 specific) */
|
---|
1574 | #if FOR_EXEHDR
|
---|
1575 | /*
|
---|
1576 | * Name these flags differently for EXEHDR.EXE - avoid conflicts with 286 version
|
---|
1577 | */
|
---|
1578 | #define OBJDISCARD 0x0010L /* Object is Discardable */
|
---|
1579 | #define OBJSHARED 0x0020L /* Object is Shared */
|
---|
1580 | #define OBJPRELOAD 0x0040L /* Object has preload pages */
|
---|
1581 | #define OBJEXEC 0x0004L /* Executable Object */
|
---|
1582 | #define OBJCONFORM 0x4000L /* Object is conforming for code (80x86 specific) */
|
---|
1583 | #else
|
---|
1584 | /*
|
---|
1585 | * Life will be easier, if we keep the same names for the following flags:
|
---|
1586 | */
|
---|
1587 | #ifndef NSDISCARD
|
---|
1588 | #define NSDISCARD 0x0010L /* Object is Discardable */
|
---|
1589 | #endif
|
---|
1590 | #ifndef NSMOVE
|
---|
1591 | #define NSMOVE NSDISCARD /* Moveable object is for sure Discardable */
|
---|
1592 | #endif
|
---|
1593 | #ifndef NSSHARED
|
---|
1594 | #define NSSHARED 0x0020L /* Object is Shared */
|
---|
1595 | #endif
|
---|
1596 | #ifndef NSPRELOAD
|
---|
1597 | #define NSPRELOAD 0x0040L /* Object has preload pages */
|
---|
1598 | #endif
|
---|
1599 | #ifndef NSEXRD
|
---|
1600 | #define NSEXRD 0x0004L /* Executable Object */
|
---|
1601 | #endif
|
---|
1602 | #ifndef NSCONFORM
|
---|
1603 | #define NSCONFORM 0x4000L /* Object is conforming for code (80x86 specific) */
|
---|
1604 | #endif
|
---|
1605 | #endif
|
---|
1606 | /*end*/
|
---|
1607 |
|
---|
1608 | /***ET+ o32_map - Object Page Map entry */
|
---|
1609 |
|
---|
1610 | struct o32_map /* Object Page Table entry */
|
---|
1611 | {
|
---|
1612 | unsigned long o32_pagedataoffset; /* file offset of page */
|
---|
1613 | unsigned short o32_pagesize; /* # bytes of page data */
|
---|
1614 | unsigned short o32_pageflags; /* Per-Page attributes */
|
---|
1615 | };
|
---|
1616 |
|
---|
1617 |
|
---|
1618 | #define GETPAGEIDX(x) ((x).o32_pagedataoffset)
|
---|
1619 |
|
---|
1620 | #define PUTPAGEIDX(x,i) ((x).o32_pagedataoffset = ((unsigned long)(i)))
|
---|
1621 |
|
---|
1622 | #define PUTPAGESIZ(x,i) ((x).o32_pagesize = ((unsigned int)(i)))
|
---|
1623 |
|
---|
1624 | #define GETPAGESIZ(x) ((x).o32_pagesize)
|
---|
1625 |
|
---|
1626 | #define PAGEFLAGS(x) (x).o32_pageflags
|
---|
1627 |
|
---|
1628 |
|
---|
1629 | #define VALID 0x0000 /* Valid Physical Page in .EXE */
|
---|
1630 | #define ITERDATA 0x0001 /* Iterated Data Page */
|
---|
1631 | #define INVALID 0x0002 /* Invalid Page */
|
---|
1632 | #define ZEROED 0x0003 /* Zero Filled Page */
|
---|
1633 | #define RANGE 0x0004 /* Range of pages */
|
---|
1634 | #define ITERDATA2 0x0005 /* Iterated Data Page Type II */
|
---|
1635 | /*end*/
|
---|
1636 |
|
---|
1637 | /*
|
---|
1638 | * RESOURCE TABLE
|
---|
1639 | */
|
---|
1640 |
|
---|
1641 | /***ET+ rsrc32 - Resource Table Entry */
|
---|
1642 |
|
---|
1643 | struct rsrc32 /* Resource Table Entry */
|
---|
1644 | {
|
---|
1645 | unsigned short type; /* Resource type */
|
---|
1646 | unsigned short name; /* Resource name */
|
---|
1647 | unsigned long cb; /* Resource size */
|
---|
1648 | unsigned short obj; /* Object number */
|
---|
1649 | unsigned long offset; /* Offset within object */
|
---|
1650 | };
|
---|
1651 | /*end*/
|
---|
1652 |
|
---|
1653 |
|
---|
1654 | /*
|
---|
1655 | * Iteration Record format for 'EXEPACK'ed pages.
|
---|
1656 | */
|
---|
1657 | struct LX_Iter
|
---|
1658 | {
|
---|
1659 | unsigned short LX_nIter; /* number of iterations */
|
---|
1660 | unsigned short LX_nBytes; /* number of bytes */
|
---|
1661 | unsigned char LX_Iterdata; /* iterated data byte(s) */
|
---|
1662 | };
|
---|
1663 |
|
---|
1664 |
|
---|
1665 | /*
|
---|
1666 | * ENTRY TABLE DEFINITIONS
|
---|
1667 | */
|
---|
1668 |
|
---|
1669 | /***ET+ b32_bundle - Entry Table */
|
---|
1670 |
|
---|
1671 | struct b32_bundle
|
---|
1672 | {
|
---|
1673 | unsigned char b32_cnt; /* Number of entries in this bundle */
|
---|
1674 | unsigned char b32_type; /* Bundle type */
|
---|
1675 | unsigned short b32_obj; /* Object number */
|
---|
1676 | }; /* Follows entry types */
|
---|
1677 |
|
---|
1678 | struct e32_entry
|
---|
1679 | {
|
---|
1680 | unsigned char e32_flags; /* Entry point flags */
|
---|
1681 | union entrykind
|
---|
1682 | {
|
---|
1683 | RELOC_OFS e32_offset; /* 16-bit/32-bit offset entry */
|
---|
1684 | struct callgate
|
---|
1685 | {
|
---|
1686 | unsigned short offset; /* Offset in segment */
|
---|
1687 | unsigned short callgate; /* Callgate selector */
|
---|
1688 | }
|
---|
1689 | e32_callgate; /* 286 (16-bit) call gate */
|
---|
1690 | struct fwd
|
---|
1691 | {
|
---|
1692 | unsigned short modord; /* Module ordinal number */
|
---|
1693 | unsigned long value; /* Proc name offset or ordinal */
|
---|
1694 | }
|
---|
1695 | e32_fwd; /* Forwarder */
|
---|
1696 | }
|
---|
1697 | e32_variant; /* Entry variant */
|
---|
1698 | };
|
---|
1699 |
|
---|
1700 |
|
---|
1701 |
|
---|
1702 | #define B32_CNT(x) (x).b32_cnt
|
---|
1703 | #define B32_TYPE(x) (x).b32_type
|
---|
1704 | #define B32_OBJ(x) (x).b32_obj
|
---|
1705 |
|
---|
1706 | #define E32_EFLAGS(x) (x).e32_flags
|
---|
1707 | #define E32_OFFSET16(x) (x).e32_variant.e32_offset.offset16
|
---|
1708 | #define E32_OFFSET32(x) (x).e32_variant.e32_offset.offset32
|
---|
1709 | #define E32_GATEOFF(x) (x).e32_variant.e32_callgate.offset
|
---|
1710 | #define E32_GATE(x) (x).e32_variant.e32_callgate.callgate
|
---|
1711 | #define E32_MODORD(x) (x).e32_variant.e32_fwd.modord
|
---|
1712 | #define E32_VALUE(x) (x).e32_variant.e32_fwd.value
|
---|
1713 |
|
---|
1714 | #define FIXENT16 3
|
---|
1715 | #define FIXENT32 5
|
---|
1716 | #define GATEENT16 5
|
---|
1717 | #define FWDENT 7
|
---|
1718 |
|
---|
1719 | /*
|
---|
1720 | * BUNDLE TYPES
|
---|
1721 | */
|
---|
1722 |
|
---|
1723 | #define EMPTY 0x00 /* Empty bundle */
|
---|
1724 | #define ENTRY16 0x01 /* 16-bit offset entry point */
|
---|
1725 | #define GATE16 0x02 /* 286 call gate (16-bit IOPL) */
|
---|
1726 | #define ENTRY32 0x03 /* 32-bit offset entry point */
|
---|
1727 | #define ENTRYFWD 0x04 /* Forwarder entry point */
|
---|
1728 | #define TYPEINFO 0x80 /* Typing information present flag */
|
---|
1729 |
|
---|
1730 |
|
---|
1731 | /*
|
---|
1732 | * Format for E32_EFLAGS(x)
|
---|
1733 | *
|
---|
1734 | * 7 6 5 4 3 2 1 0 - bit no
|
---|
1735 | * | | | | | | | |
|
---|
1736 | * | | | | | | | +--- exported entry
|
---|
1737 | * | | | | | | +----- uses shared data
|
---|
1738 | * +-+-+-+-+-+------- parameter word count
|
---|
1739 | */
|
---|
1740 |
|
---|
1741 | #define E32EXPORT 0x01 /* Exported entry */
|
---|
1742 | #define E32SHARED 0x02 /* Uses shared data */
|
---|
1743 | #define E32PARAMS 0xf8 /* Parameter word count mask */
|
---|
1744 |
|
---|
1745 | /*
|
---|
1746 | * Flags for forwarders only:
|
---|
1747 | */
|
---|
1748 |
|
---|
1749 | #define FWD_ORDINAL 0x01 /* Imported by ordinal */
|
---|
1750 |
|
---|
1751 |
|
---|
1752 | #pragma pack() /* Restore default alignment */
|
---|
1753 |
|
---|
1754 | /*end*/
|
---|
1755 |
|
---|
1756 | #endif /* __EXE386__ */
|
---|
1757 |
|
---|
1758 | #endif
|
---|