1 |
|
---|
2 | /*
|
---|
3 | *@@sourcefile exeh.h:
|
---|
4 | * header file for exeh.c. See remarks there.
|
---|
5 | *
|
---|
6 | * Note: Version numbering in this file relates to XWorkplace version
|
---|
7 | * numbering.
|
---|
8 | *
|
---|
9 | *@@include #include <os2.h>
|
---|
10 | *@@include #include "helpers\dosh.h"
|
---|
11 | *@@include #include "helpers\exeh.h"
|
---|
12 | */
|
---|
13 |
|
---|
14 | /* This file Copyright (C) 2000-2002 Ulrich Mller,
|
---|
15 | * Martin Lafaix.
|
---|
16 | * This file is part of the "XWorkplace helpers" source package.
|
---|
17 | * This is free software; you can redistribute it and/or modify
|
---|
18 | * it under the terms of the GNU General Public License as published
|
---|
19 | * by the Free Software Foundation, in version 2 as it comes in the
|
---|
20 | * "COPYING" file of the XWorkplace main distribution.
|
---|
21 | * This program is distributed in the hope that it will be useful,
|
---|
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
24 | * GNU General Public License for more details.
|
---|
25 | */
|
---|
26 |
|
---|
27 | #if __cplusplus
|
---|
28 | extern "C" {
|
---|
29 | #endif
|
---|
30 |
|
---|
31 | #ifndef EXEH_HEADER_INCLUDED
|
---|
32 | #define EXEH_HEADER_INCLUDED
|
---|
33 |
|
---|
34 | /********************************************************************
|
---|
35 | *
|
---|
36 | * Executable helpers
|
---|
37 | *
|
---|
38 | ********************************************************************/
|
---|
39 |
|
---|
40 | #pragma pack(1)
|
---|
41 |
|
---|
42 | /*
|
---|
43 | *@@ DOSEXEHEADER:
|
---|
44 | * old DOS EXE header at offset 0
|
---|
45 | * in any EXE file.
|
---|
46 | *
|
---|
47 | *@@changed V0.9.7 (2000-12-20) [umoeller]: fixed NE offset
|
---|
48 | *@@changed V0.9.9 (2001-04-06) [lafaix]: additional fields defined
|
---|
49 | */
|
---|
50 |
|
---|
51 | typedef struct _DOSEXEHEADER
|
---|
52 | {
|
---|
53 | USHORT usDosExeID; // 00: DOS exeid (0x5a4d)
|
---|
54 | USHORT usFileLenMod512; // 02: filelen mod 512
|
---|
55 | USHORT usFileLenDiv512; // 04: filelen div 512
|
---|
56 | USHORT usSegFix; // 06: count of segment adds to fix
|
---|
57 | USHORT usHdrPargCnt; // 08: size of header in paragrphs
|
---|
58 | USHORT usMinAddPargCnt; // 0a: minimum addtl paragraphs count
|
---|
59 | USHORT usMaxAddPargCnt; // 0c: max addtl paragraphs count
|
---|
60 | USHORT usSSStartup; // 0e: SS at startup
|
---|
61 | USHORT usSPStartup; // 10: SP at startup
|
---|
62 | USHORT usHdrChecksum; // 12: header checksum
|
---|
63 | USHORT usIPStartup; // 14: IP at startup
|
---|
64 | USHORT usCodeSegOfs; // 16: code segment offset from EXE start
|
---|
65 | USHORT usRelocTableOfs; // 18: reloc table ofs.header (Win: >= 0x40)
|
---|
66 | USHORT usOverlayNo; // 1a: overlay no.
|
---|
67 | USHORT usLinkerVersion; // 1c: linker version (if 0x18 > 0x28)
|
---|
68 | USHORT usUnused1; // 1e: unused
|
---|
69 | USHORT usBehaviorBits; // 20: exe.h says this field contains
|
---|
70 | // 'behavior bits'
|
---|
71 | USHORT usUnused2; // 22: unused
|
---|
72 | USHORT usOEMIdentifier; // 24: OEM identifier
|
---|
73 | USHORT usOEMInformation; // 26: OEM information
|
---|
74 | ULONG ulUnused3; // 28:
|
---|
75 | ULONG ulUnused4; // 2c:
|
---|
76 | ULONG ulUnused5; // 30:
|
---|
77 | ULONG ulUnused6; // 34:
|
---|
78 | ULONG ulUnused7; // 38:
|
---|
79 | ULONG ulNewHeaderOfs; // 3c: new header ofs (if 0x18 > 0x40)
|
---|
80 | // fixed this from USHORT, thanks Martin Lafaix
|
---|
81 | // V0.9.7 (2000-12-20) [umoeller]
|
---|
82 | } DOSEXEHEADER, *PDOSEXEHEADER;
|
---|
83 |
|
---|
84 | // NE and LX OS types
|
---|
85 | #define NEOS_UNKNOWN 0
|
---|
86 | #define NEOS_OS2 1 // Win16 SDK says: "reserved"...
|
---|
87 | #define NEOS_WIN16 2
|
---|
88 | #define NEOS_DOS4 3 // Win16 SDK says: "reserved"...
|
---|
89 | #define NEOS_WIN386 4 // Win16 SDK says: "reserved"...
|
---|
90 |
|
---|
91 | /*
|
---|
92 | *@@ NEHEADER:
|
---|
93 | * linear executable (LX) header format,
|
---|
94 | * which comes after the DOS header in the
|
---|
95 | * EXE file (at DOSEXEHEADER.ulNewHeaderOfs).
|
---|
96 | *
|
---|
97 | *@@changed V0.9.9 (2001-04-06) [lafaix]: fixed typo in usMoveableEntries
|
---|
98 | */
|
---|
99 |
|
---|
100 | typedef struct _NEHEADER
|
---|
101 | {
|
---|
102 | CHAR achNE[2]; // 00: "NE" magic ne_magic
|
---|
103 | BYTE bLinkerVersion; // 02: linker version ne_ver
|
---|
104 | BYTE bLinkerRevision; // 03: linker revision ne_rev
|
---|
105 | USHORT usEntryTblOfs; // 04: ofs from this to entrytable ne_enttab
|
---|
106 | USHORT usEntryTblLen; // 06: length of entrytable ne_cbenttab
|
---|
107 | ULONG ulChecksum; // 08: MS: reserved, OS/2: checksum ne_crc
|
---|
108 | USHORT usFlags; // 0c: flags ne_flags
|
---|
109 | /*
|
---|
110 | #define NENOTP 0x8000 // Not a process == library
|
---|
111 | #define NENOTMPSAFE 0x4000 // Process is not multi-processor safe
|
---|
112 | // (Win3.1 SDK: "reserved")
|
---|
113 | #define NEIERR 0x2000 // Errors in image
|
---|
114 | #define NEBOUND 0x0800 // Bound Family/API
|
---|
115 | // (Win3.1 SDK: "first segment contains code
|
---|
116 | // that loads the application")
|
---|
117 | #define NEAPPTYP 0x0700 // Application type mask
|
---|
118 | // (Win3.1 SDK: "reserved")
|
---|
119 | #define NENOTWINCOMPAT 0x0100 // Not compatible with P.M. Windowing
|
---|
120 | // (Win3.1 SDK: "reserved")
|
---|
121 | #define NEWINCOMPAT 0x0200 // Compatible with P.M. Windowing
|
---|
122 | // (Win3.1 SDK: "reserved")
|
---|
123 | #define NEWINAPI 0x0300 // Uses P.M. Windowing API
|
---|
124 | // (Win3.1 SDK: "reserved")
|
---|
125 | #define NEFLTP 0x0080 // Floating-point instructions
|
---|
126 | #define NEI386 0x0040 // 386 instructions
|
---|
127 | #define NEI286 0x0020 // 286 instructions
|
---|
128 | #define NEI086 0x0010 // 8086 instructions
|
---|
129 | #define NEPROT 0x0008 // Runs in protected mode only
|
---|
130 | // (Win3.1 SDK: "reserved")
|
---|
131 | #define NEPPLI 0x0004 // Per-Process Library Initialization
|
---|
132 | // (Win3.1 SDK: "reserved")
|
---|
133 | #define NEINST 0x0002 // Instance data
|
---|
134 | #define NESOLO 0x0001 // Solo data (single data)
|
---|
135 | */
|
---|
136 | USHORT usAutoDataSegNo; // 0e: auto-data seg no. ne_autodata
|
---|
137 | // (Win3.1 SDK: "0 if both NEINST and NESOLO are cleared")
|
---|
138 | USHORT usInitlHeapSize; // 10: initl. heap size ne_heap
|
---|
139 | // (Win3.1 SDK: "0 if no local allocation")
|
---|
140 | USHORT usInitlStackSize; // 12: initl. stack size ne_stack
|
---|
141 | // (Win3.1 SDK: "0 if SS != DS")
|
---|
142 | ULONG ulCSIP; // 14: CS:IP ne_csip
|
---|
143 | ULONG ulSSSP; // 18: SS:SP ne_sssp
|
---|
144 | USHORT usSegTblEntries; // 1c: segment tbl entry count ne_cseg
|
---|
145 | USHORT usModuleTblEntries; // 1e: module ref. table entry count ne_cmod
|
---|
146 | USHORT usNonResdTblLen; // 20: non-resd. name tbl length ne_cbnrestab
|
---|
147 | USHORT usSegTblOfs; // 22: segment tbl ofs ne_segtab
|
---|
148 | // (from start of NEHEADER)
|
---|
149 | USHORT usResTblOfs; // 24: resource tbl ofs ne_rsrctab
|
---|
150 | // (from start of NEHEADER)
|
---|
151 | USHORT usResdNameTblOfs; // 26: resd. name tbl ofs ne_restab
|
---|
152 | // (from start of NEHEADER)
|
---|
153 | USHORT usModRefTblOfs; // 28: module ref. table ofs ne_modtab
|
---|
154 | // (from start of NEHEADER)
|
---|
155 | USHORT usImportTblOfs; // 2a: import name tbl ofs ne_imptab
|
---|
156 | // (from start of NEHEADER)
|
---|
157 | ULONG ulNonResdTblOfs; // 2c: non-resd. name tbl ofs ne_nrestab
|
---|
158 | // (from start of EXE!)
|
---|
159 | USHORT usMoveableEntries; // 30: moveable entry points count ne_cmovent
|
---|
160 | USHORT usLogicalSectShift; // 32: logcl. sector shift ne_align
|
---|
161 | // (Win3.1 SDK: "typically 4, but default is 9")
|
---|
162 | USHORT usResSegmCount; // 34: resource segm. count ne_cres
|
---|
163 | BYTE bTargetOS; // 36: target OS (NEOS_* flags) ne_exetyp
|
---|
164 | BYTE bFlags2; // 37: addtl. flags ne_flagsothers
|
---|
165 | // Win3.1 SDK:
|
---|
166 | // bit 1 --> Win2.x, but runs in Win3.x protected mode
|
---|
167 | // bit 2 --> Win2.x that supports prop. fonts
|
---|
168 | // bit 3 --> exec contains fastload area
|
---|
169 | /*
|
---|
170 | #define NELONGNAMES 0x01
|
---|
171 | #define NEWINISPROT 0x02
|
---|
172 | #define NEWINGETPROPFON 0x04
|
---|
173 | #define NEWLOAPPL 0x80
|
---|
174 | */
|
---|
175 | // the following are not listed in newexe.h, but are documented for Win3.x
|
---|
176 | USHORT usFastLoadOfs; // 38: fast-load area ofs
|
---|
177 | USHORT usFastLoadLen; // 3a: fast-load area length
|
---|
178 | USHORT usReserved; // 3c: MS: 'reserved'
|
---|
179 | USHORT usReqWinVersion; // 3e: Win-only: min. Win version
|
---|
180 | } NEHEADER, *PNEHEADER;
|
---|
181 |
|
---|
182 | /*
|
---|
183 | *@@ LXHEADER:
|
---|
184 | * linear executable (LX) header format,
|
---|
185 | * which comes after the DOS header in the
|
---|
186 | * EXE file (at DOSEXEHEADER.ulNewHeaderOfs).
|
---|
187 | *
|
---|
188 | *@@changed V0.9.9 (2001-04-06) [lafaix]: fixed auto data object and ulinstanceDemdCnt
|
---|
189 | */
|
---|
190 |
|
---|
191 | typedef struct _LXHEADER
|
---|
192 | {
|
---|
193 | CHAR achLX[2]; // 00: e32_magic "LX" or "LE" magic
|
---|
194 | // this is "LX" for 32-bit OS/2 programs, but
|
---|
195 | // "LE" for MS-DOS progs which use this format
|
---|
196 | // (e.g. WINDOWS\SMARTDRV.EXE). IBM says the
|
---|
197 | // LE format was never released and superceded
|
---|
198 | // by LX... I am unsure what the differences are.
|
---|
199 | BYTE fByteBigEndian; // 02: e32_border byte ordering (1 = big endian)
|
---|
200 | BYTE fWordBigEndian; // 03: e32_worder word ordering (1 = big endian)
|
---|
201 | ULONG ulFormatLevel; // 04: e32_level exe format level (0)
|
---|
202 | USHORT usCPU; // 08: e32_cpu CPU type
|
---|
203 | USHORT usTargetOS; // 0a: e32_os OS type (NEOS_* flags)
|
---|
204 | ULONG ulModuleVersion; // 0c: e32_ver module version
|
---|
205 | ULONG ulFlags; // 10: e32_mflags module flags
|
---|
206 | /* #define E32NOTP 0x8000L // Library Module - used as NENOTP
|
---|
207 | #define E32NOLOAD 0x2000L // Module not Loadable
|
---|
208 | #define E32PMAPI 0x0300L // Uses PM Windowing API
|
---|
209 | #define E32PMW 0x0200L // Compatible with PM Windowing
|
---|
210 | #define E32NOPMW 0x0100L // Incompatible with PM Windowing
|
---|
211 | #define E32NOEXTFIX 0x0020L // NO External Fixups in .EXE
|
---|
212 | #define E32NOINTFIX 0x0010L // NO Internal Fixups in .EXE
|
---|
213 | #define E32SYSDLL 0x0008L // System DLL, Internal Fixups discarded
|
---|
214 | #define E32LIBINIT 0x0004L // Per-Process Library Initialization
|
---|
215 | #define E32LIBTERM 0x40000000L // Per-Process Library Termination
|
---|
216 | #define E32APPMASK 0x0300L // Application Type Mask
|
---|
217 | */
|
---|
218 | ULONG ulPageCount; // 14: e32_mpages no. of pages in module
|
---|
219 | ULONG ulEIPRelObj; // 18: e32_startobj obj # for IP
|
---|
220 | // object to which EIP is relative
|
---|
221 | ULONG ulEIPEntryAddr; // 1c: e32_eip EIP entry addr
|
---|
222 | ULONG ulESPObj; // 20: e32_stackobj ESP object
|
---|
223 | ULONG ulESP; // 24: e32_esp ESP
|
---|
224 | ULONG ulPageSize; // 28: e32_pagesize page size (4K)
|
---|
225 | ULONG ulPageLeftShift; // 2c: e32_pageshift page left-shift
|
---|
226 | ULONG ulFixupTblLen; // 30: e32_fixupsize fixup section total size
|
---|
227 | ULONG ulFixupTblChecksum; // 34: e32_fixupsum fixup section checksum
|
---|
228 | ULONG ulLoaderLen; // 38: e32_ldrsize size req. for loader section
|
---|
229 | ULONG ulLoaderChecksum; // 3c: e32_ldrsum loader section checksum
|
---|
230 | ULONG ulObjTblOfs; // 40: e32_objtab object table offset
|
---|
231 | ULONG ulObjCount; // 44: e32_objcnt object count
|
---|
232 | ULONG ulObjPageTblOfs; // 48: e32_objmap object page table ofs
|
---|
233 | ULONG ulObjIterPagesOfs; // 4c: e32_itermap object iter pages ofs
|
---|
234 | ULONG ulResTblOfs; // 50: e32_rsrctab resource table ofs
|
---|
235 | ULONG ulResTblCnt; // 54: e32_rsrccnt resource entry count
|
---|
236 | ULONG ulResdNameTblOfs; // 58: e32_restab resident name tbl ofs
|
---|
237 | ULONG ulEntryTblOfs; // 5c: e32_enttab entry tbl ofs
|
---|
238 | ULONG ulModDirectivesOfs; // 60: e32_dirtab module directives ofs
|
---|
239 | ULONG ulModDirectivesCnt; // 64: e32_dircnt module directives count
|
---|
240 | ULONG ulFixupPagePageTblOfs;// 68: e32_fpagetab fixup page tbl ofs
|
---|
241 | ULONG ulFixupRecTblOfs; // 6c: e32_frectab fixup record tbl ofs
|
---|
242 | ULONG ulImportModTblOfs; // 70: e32_impmod import modl tbl ofs
|
---|
243 | ULONG ulImportModTblCnt; // 74: e32_impmodcnt import modl tbl count
|
---|
244 | ULONG ulImportProcTblOfs; // 78: e32_impproc import proc tbl ofs
|
---|
245 | ULONG ulPerPageCSOfs; // 7c: e32_pagesum per page checksum ofs
|
---|
246 | ULONG ulDataPagesOfs; // 80: e32_datapage data pages ofs
|
---|
247 | ULONG ulPreloadPagesCnt; // 84: e32_preload preload pages count
|
---|
248 | ULONG ulNonResdNameTblOfs; // 88: e32_nrestab non-resdnt name tbl ofs
|
---|
249 | ULONG ulNonResdNameTblLen; // 8c: e32_cbnrestab non-resdnt name tbl length
|
---|
250 | ULONG ulNonResdNameTblCS; // 90: e32_nressum non-res name tbl checksum
|
---|
251 | ULONG ulAutoDataSegObj; // 94: e32_autodata auto dataseg object
|
---|
252 | ULONG ulDebugOfs; // 98: e32_debuginfo debug info ofs
|
---|
253 | ULONG ulDebugLen; // 9c: e32_debuglen debug info length
|
---|
254 | ULONG ulInstancePrelCnt; // a0: e32_instpreload instance preload count
|
---|
255 | ULONG ulInstanceDemdCnt; // a0: e32_instdemand instance demand count
|
---|
256 | ULONG ulHeapSize16; // a8: e32_heapsize heap size (16-bit)
|
---|
257 | ULONG ulStackSize; // ac: e32_stacksize stack size
|
---|
258 | BYTE e32_res3[20];
|
---|
259 | // Pad structure to 196 bytes
|
---|
260 | } LXHEADER, *PLXHEADER;
|
---|
261 |
|
---|
262 | /*
|
---|
263 | *@@ PEHEADER:
|
---|
264 | * portable executable (PE) header format,
|
---|
265 | * which comes after the DOS header in the
|
---|
266 | * EXE file (at DOSEXEHEADER.ulNewHeaderOfs).
|
---|
267 | *
|
---|
268 | *@@added V0.9.10 (2001-04-08) [lafaix]
|
---|
269 | */
|
---|
270 |
|
---|
271 | typedef struct _PEHEADER
|
---|
272 | {
|
---|
273 | // standard header
|
---|
274 | ULONG ulSignature; // 00: 'P', 'E', 0, 0
|
---|
275 | USHORT usCPU; // 04: CPU type
|
---|
276 | USHORT usObjCount; // 06: number of object entries
|
---|
277 | ULONG ulTimeDateStamp; // 08: store the time and date the
|
---|
278 | // file was created or modified
|
---|
279 | // by the linker
|
---|
280 | ULONG ulReserved1; // 0c: reserved
|
---|
281 | ULONG ulReserved2; // 10: reserved
|
---|
282 | USHORT usHeaderSize; // 14: number of remaining bytes after
|
---|
283 | // usImageFlags
|
---|
284 | USHORT usImageFlags; // 16: flags bits for the image
|
---|
285 |
|
---|
286 | // optional header (always present in valid Win32 files)
|
---|
287 | USHORT usReserved3; // 18: reserved
|
---|
288 | USHORT usLinkerMajor; // 1a: linker major version number
|
---|
289 | USHORT usLinkerMinor; // 1c: linker minor version number
|
---|
290 | USHORT usReserved4; // 1e: reserved
|
---|
291 | ULONG ulReserved5; // 20: reserved
|
---|
292 | ULONG ulReserved6; // 24: reserved
|
---|
293 | ULONG ulEntryPointRVA; // 28: entry point relative virtual address
|
---|
294 | ULONG ulReserved7; // 2c: reserved
|
---|
295 | ULONG ulReserved8; // 30: reserved
|
---|
296 | ULONG ulImageBase; // 34:
|
---|
297 | ULONG ulObjectAlign; // 38:
|
---|
298 | ULONG ulFileAlign; // 3c:
|
---|
299 | USHORT usOSMajor; // 40:
|
---|
300 | USHORT usOSMinor; // 42:
|
---|
301 | USHORT usUserMajor; // 44:
|
---|
302 | USHORT usUserMinor; // 46:
|
---|
303 | USHORT usSubSystemMajor; // 48:
|
---|
304 | USHORT usSubSystemMinor; // 4a:
|
---|
305 | ULONG ulReserved9; // 4c: reserved
|
---|
306 | ULONG ulImageSize; // 50:
|
---|
307 | ULONG ulHeaderSize; // 54:
|
---|
308 | ULONG ulFileChecksum; // 58:
|
---|
309 | USHORT usSubSystem; // 5c:
|
---|
310 | USHORT usDLLFlags; // 5e:
|
---|
311 | ULONG ulStackReserveSize; // 60:
|
---|
312 | ULONG ulStackCommitSize; // 64:
|
---|
313 | ULONG ulHeapReserveSize; // 68:
|
---|
314 | ULONG ulHeapCommitSize; // 6c:
|
---|
315 | ULONG ulReserved10; // 70: reserved
|
---|
316 | ULONG ulInterestingRVACount;// 74:
|
---|
317 | ULONG aulRVASize[1]; // 78: array of RVA/Size entries
|
---|
318 | } PEHEADER, *PPEHEADER;
|
---|
319 |
|
---|
320 | // additional LX structures
|
---|
321 |
|
---|
322 | /*
|
---|
323 | *@@ RESOURCETABLEENTRY:
|
---|
324 | * LX resource table entry.
|
---|
325 | *
|
---|
326 | *@@added V0.9.16 (2001-12-08) [umoeller]
|
---|
327 | */
|
---|
328 |
|
---|
329 | typedef struct _RESOURCETABLEENTRY // rsrc32
|
---|
330 | {
|
---|
331 | USHORT type; // Resource type
|
---|
332 | USHORT name; // Resource name
|
---|
333 | ULONG cb; // Resource size
|
---|
334 | USHORT obj; // Object number
|
---|
335 | ULONG offset; // Offset within object
|
---|
336 | } RESOURCETABLEENTRY;
|
---|
337 |
|
---|
338 | /*
|
---|
339 | *@@ OBJECTTABLEENTRY:
|
---|
340 | * LX object table entry.
|
---|
341 | *
|
---|
342 | *@@added V0.9.16 (2001-12-08) [umoeller]
|
---|
343 | */
|
---|
344 |
|
---|
345 | typedef struct _OBJECTTABLEENTRY // o32_obj
|
---|
346 | {
|
---|
347 | ULONG o32_size; // Object virtual size
|
---|
348 | ULONG o32_base; // Object base virtual address
|
---|
349 | ULONG o32_flags; // Attribute flags
|
---|
350 | ULONG o32_pagemap; // Object page map index
|
---|
351 | ULONG o32_mapsize; // Number of entries in object page map
|
---|
352 | ULONG o32_reserved; // Reserved
|
---|
353 | } OBJECTTABLEENTRY;
|
---|
354 |
|
---|
355 | /*
|
---|
356 | *@@ OBJECTPAGETABLEENTRY:
|
---|
357 | * LX object _page_ table entry, sometimes
|
---|
358 | * referred to as map entry.
|
---|
359 | *
|
---|
360 | *@@added V0.9.16 (2001-12-08) [umoeller]
|
---|
361 | */
|
---|
362 |
|
---|
363 | typedef struct _OBJECTPAGETABLEENTRY // o32_map
|
---|
364 | {
|
---|
365 | ULONG o32_pagedataoffset; // file offset of page
|
---|
366 | USHORT o32_pagesize; // # of real bytes of page data
|
---|
367 | USHORT o32_pageflags; // Per-Page attributes
|
---|
368 | } OBJECTPAGETABLEENTRY;
|
---|
369 |
|
---|
370 | /*
|
---|
371 | *@@ LXITER:
|
---|
372 | * iteration Record format for 'EXEPACK'ed pages.
|
---|
373 | *
|
---|
374 | *@@added V0.9.16 (2001-12-08) [umoeller]
|
---|
375 | */
|
---|
376 |
|
---|
377 | typedef struct _LXITER
|
---|
378 | {
|
---|
379 | USHORT LX_nIter; // number of iterations
|
---|
380 | USHORT LX_nBytes; // number of bytes
|
---|
381 | unsigned char LX_Iterdata; // iterated data byte(s)
|
---|
382 | } LXITER, *PLXITER;
|
---|
383 |
|
---|
384 | /*
|
---|
385 | *@@ OS2NERESTBLENTRY:
|
---|
386 | * OS/2 NE resource table entry.
|
---|
387 | *
|
---|
388 | *@@added V0.9.16 (2001-12-08) [umoeller]
|
---|
389 | */
|
---|
390 |
|
---|
391 | typedef struct _OS2NERESTBLENTRY
|
---|
392 | {
|
---|
393 | USHORT usType;
|
---|
394 | USHORT usID;
|
---|
395 | } OS2NERESTBLENTRY, *POS2NERESTBLENTRY;
|
---|
396 |
|
---|
397 | /*
|
---|
398 | *@@ OS2NESEGMENT:
|
---|
399 | * OS/2 NE segment definition.
|
---|
400 | *
|
---|
401 | *@@added V0.9.16 (2001-12-08) [umoeller]
|
---|
402 | */
|
---|
403 |
|
---|
404 | typedef struct _OS2NESEGMENT // New .EXE segment table entry
|
---|
405 | {
|
---|
406 | USHORT ns_sector; // File sector of start of segment
|
---|
407 | USHORT ns_cbseg; // Number of bytes in file
|
---|
408 | USHORT ns_flags; // Attribute flags
|
---|
409 | USHORT ns_minalloc; // Minimum allocation in bytes
|
---|
410 | } OS2NESEGMENT, *POS2NESEGMENT;
|
---|
411 |
|
---|
412 | #pragma pack()
|
---|
413 |
|
---|
414 | // object/segment flags (in NE and LX)
|
---|
415 | #define OBJWRITE 0x0002L // Writeable Object
|
---|
416 | #define OBJDISCARD 0x0010L // Object is Discardable
|
---|
417 | #define OBJSHARED 0x0020L // Object is Shared
|
---|
418 | #define OBJPRELOAD 0x0040L // Object has preload pages
|
---|
419 |
|
---|
420 | // resource flags
|
---|
421 | #define RNMOVE 0x0010 // Moveable resource
|
---|
422 | #define RNPURE 0x0020 // Pure (read-only) resource
|
---|
423 | #define RNPRELOAD 0x0040 // Preloaded resource
|
---|
424 | #define RNDISCARD 0xF000 // Discard priority level for resource
|
---|
425 |
|
---|
426 | // EXE format
|
---|
427 | #define EXEFORMAT_OLDDOS 1
|
---|
428 | #define EXEFORMAT_NE 2
|
---|
429 | #define EXEFORMAT_PE 3
|
---|
430 | #define EXEFORMAT_LX 4
|
---|
431 | #define EXEFORMAT_TEXT_BATCH 5
|
---|
432 | #define EXEFORMAT_TEXT_CMD 6 // REXX or plain OS/2 batch
|
---|
433 | #define EXEFORMAT_COM 7 // added V0.9.16 (2002-01-04) [umoeller]
|
---|
434 |
|
---|
435 | // target OS (in NE and LX)
|
---|
436 | #define EXEOS_DOS3 1
|
---|
437 | #define EXEOS_DOS4 2 // there is a flag for this in NE
|
---|
438 | #define EXEOS_OS2 3
|
---|
439 | #define EXEOS_WIN16 4
|
---|
440 | #define EXEOS_WIN386 5 // according to IBM, there are flags
|
---|
441 | // for this both in NE and LX
|
---|
442 | #define EXEOS_WIN32 6
|
---|
443 |
|
---|
444 | #ifndef __STRIP_DOWN_EXECUTABLE__
|
---|
445 | // for mini stubs in warpin, which has its own
|
---|
446 | // implementation of this
|
---|
447 |
|
---|
448 | /*
|
---|
449 | *@@ EXECUTABLE:
|
---|
450 | * structure used with all the exeh*
|
---|
451 | * functions.
|
---|
452 | */
|
---|
453 |
|
---|
454 | typedef struct _EXECUTABLE
|
---|
455 | {
|
---|
456 | // executable opened by doshOpen;
|
---|
457 | // still NULLHANDLE for .COM, .BAT, .CMD files
|
---|
458 | // (V0.9.16)
|
---|
459 | PXFILE pFile;
|
---|
460 |
|
---|
461 | // Most of the following fields are set by
|
---|
462 | // exehOpen if NO_ERROR is returned:
|
---|
463 |
|
---|
464 | // old DOS EXE header;
|
---|
465 | // warning, this is NULL if
|
---|
466 | // -- the executable has a new header only
|
---|
467 | // (NOSTUB, V0.9.12);
|
---|
468 | // -- for .COM, .BAT, .CMD files (V0.9.16)
|
---|
469 | PDOSEXEHEADER pDosExeHeader;
|
---|
470 | ULONG cbDosExeHeader;
|
---|
471 |
|
---|
472 | // New Executable (NE) header, if ulExeFormat == EXEFORMAT_NE
|
---|
473 | PNEHEADER pNEHeader;
|
---|
474 | ULONG cbNEHeader;
|
---|
475 |
|
---|
476 | // Linear Executable (LX) header, if ulExeFormat == EXEFORMAT_LX
|
---|
477 | PLXHEADER pLXHeader;
|
---|
478 | ULONG cbLXHeader;
|
---|
479 |
|
---|
480 | // Portable Executable (PE) header, if ulExeFormat == EXEFORMAT_PE
|
---|
481 | PPEHEADER pPEHeader;
|
---|
482 | ULONG cbPEHeader;
|
---|
483 |
|
---|
484 | // module analysis (always set):
|
---|
485 | ULONG ulExeFormat;
|
---|
486 | // one of:
|
---|
487 | // EXEFORMAT_OLDDOS 1
|
---|
488 | // EXEFORMAT_NE 2
|
---|
489 | // EXEFORMAT_PE 3
|
---|
490 | // EXEFORMAT_LX 4
|
---|
491 | // EXEFORMAT_TEXT_BATCH 5 // for all .BAT files
|
---|
492 | // EXEFORMAT_TEXT_CMD 6 // for all .CMD files
|
---|
493 | // EXEFORMAT_COM 7 // for all .COM files
|
---|
494 |
|
---|
495 | BOOL fLibrary, // TRUE if this is a DLL
|
---|
496 | f32Bits; // TRUE if this a 32-bits module
|
---|
497 |
|
---|
498 | ULONG ulOS;
|
---|
499 | // target operating system as flagged in one of
|
---|
500 | // the EXE headers; one of:
|
---|
501 | // EXEOS_DOS3 1 // always for .BAT, possibly for .COM
|
---|
502 | // EXEOS_DOS4 2 // there is a flag for this in NE
|
---|
503 | // EXEOS_OS2 3 // always for .CMD, possibly for .COM
|
---|
504 | // EXEOS_WIN16 4
|
---|
505 | // EXEOS_WIN386 5 // according to IBM, there are flags
|
---|
506 | // for this both in NE and LX
|
---|
507 | // EXEOS_WIN32 6
|
---|
508 |
|
---|
509 | // The following fields are only set after
|
---|
510 | // an extra call to exehQueryBldLevel:
|
---|
511 |
|
---|
512 | PSZ pszDescription;
|
---|
513 | // whole string (first non-res name tbl entry)
|
---|
514 | PSZ pszVendor;
|
---|
515 | // vendor substring (if IBM BLDLEVEL format)
|
---|
516 | PSZ pszVersion;
|
---|
517 | // version substring (if IBM BLDLEVEL format)
|
---|
518 |
|
---|
519 | PSZ pszInfo;
|
---|
520 | // module info substring (if IBM BLDLEVEL format)
|
---|
521 |
|
---|
522 | // if pszInfo is extended DESCRIPTION field, the following
|
---|
523 | // are set as well:
|
---|
524 | PSZ pszBuildDateTime,
|
---|
525 | pszBuildMachine,
|
---|
526 | pszASD,
|
---|
527 | pszLanguage,
|
---|
528 | pszCountry,
|
---|
529 | pszRevision,
|
---|
530 | pszUnknown,
|
---|
531 | pszFixpak;
|
---|
532 |
|
---|
533 | // the following fields are set after exehLoadLXMaps
|
---|
534 | BOOL fLXMapsLoaded; // TRUE after good exehLoadLXMaps
|
---|
535 | RESOURCETABLEENTRY *pRsTbl; // pLXHeader->ulResTblCnt
|
---|
536 | OBJECTTABLEENTRY *pObjTbl; // pLXHeader->ulObjCount
|
---|
537 | OBJECTPAGETABLEENTRY *pObjPageTbl; // pLXHeader->ulPageCount
|
---|
538 |
|
---|
539 | // the following fields are set after exehLoadOS2NEMaps
|
---|
540 | BOOL fOS2NEMapsLoaded; // TRUE after good exehLoadOS2NEMaps
|
---|
541 | POS2NERESTBLENTRY paOS2NEResTblEntry;
|
---|
542 | POS2NESEGMENT paOS2NESegments;
|
---|
543 | } EXECUTABLE, *PEXECUTABLE;
|
---|
544 |
|
---|
545 | APIRET exehOpen(const char* pcszExecutable,
|
---|
546 | PEXECUTABLE* ppExec);
|
---|
547 |
|
---|
548 | APIRET exehQueryBldLevel(PEXECUTABLE pExec);
|
---|
549 |
|
---|
550 | /*
|
---|
551 | *@@ FSYSMODULE:
|
---|
552 | *
|
---|
553 | *@@added V0.9.9 (2001-03-11) [lafaix]
|
---|
554 | */
|
---|
555 |
|
---|
556 | typedef struct _FSYSMODULE
|
---|
557 | {
|
---|
558 | CHAR achModuleName[256];
|
---|
559 | } FSYSMODULE, *PFSYSMODULE;
|
---|
560 |
|
---|
561 | APIRET exehQueryImportedModules(PEXECUTABLE pExec,
|
---|
562 | PFSYSMODULE *ppaModules,
|
---|
563 | PULONG pcModules);
|
---|
564 |
|
---|
565 | APIRET exehFreeImportedModules(PFSYSMODULE paModules);
|
---|
566 |
|
---|
567 | /*
|
---|
568 | *@@ FSYSFUNCTION:
|
---|
569 | *
|
---|
570 | *@@added V0.9.9 (2001-03-11) [lafaix]
|
---|
571 | */
|
---|
572 |
|
---|
573 | typedef struct _FSYSFUNCTION
|
---|
574 | {
|
---|
575 | ULONG ulOrdinal;
|
---|
576 | ULONG ulType;
|
---|
577 | CHAR achFunctionName[256];
|
---|
578 | } FSYSFUNCTION, *PFSYSFUNCTION;
|
---|
579 |
|
---|
580 | APIRET exehQueryExportedFunctions(PEXECUTABLE pExec,
|
---|
581 | PFSYSFUNCTION *ppaFunctions,
|
---|
582 | PULONG pcFunctions);
|
---|
583 |
|
---|
584 | APIRET exehFreeExportedFunctions(PFSYSFUNCTION paFunctions);
|
---|
585 |
|
---|
586 | #define WINRT_CURSOR 1
|
---|
587 | #define WINRT_BITMAP 2
|
---|
588 | #define WINRT_ICON 3
|
---|
589 | #define WINRT_MENU 4
|
---|
590 | #define WINRT_DIALOG 5
|
---|
591 | #define WINRT_STRING 6
|
---|
592 | #define WINRT_FONTDIR 7
|
---|
593 | #define WINRT_FONT 8
|
---|
594 | #define WINRT_ACCELERATOR 9
|
---|
595 | #define WINRT_RCDATA 10
|
---|
596 |
|
---|
597 | /*
|
---|
598 | *@@ FSYSRESOURCE:
|
---|
599 | *
|
---|
600 | *@@added V0.9.7 (2000-12-18) [lafaix]
|
---|
601 | */
|
---|
602 |
|
---|
603 | typedef struct _FSYSRESOURCE
|
---|
604 | {
|
---|
605 | ULONG ulID; // resource ID
|
---|
606 | ULONG ulType; // resource type
|
---|
607 | ULONG ulSize; // resource size in bytes
|
---|
608 | ULONG ulFlag; // resource flags
|
---|
609 |
|
---|
610 | } FSYSRESOURCE, *PFSYSRESOURCE;
|
---|
611 |
|
---|
612 | APIRET exehQueryResources(PEXECUTABLE pExec,
|
---|
613 | PFSYSRESOURCE *ppaResources,
|
---|
614 | PULONG pcResources);
|
---|
615 |
|
---|
616 | APIRET exehFreeResources(PFSYSRESOURCE paResources);
|
---|
617 |
|
---|
618 | APIRET exehLoadLXMaps(PEXECUTABLE pExec);
|
---|
619 |
|
---|
620 | VOID exehFreeLXMaps(PEXECUTABLE pExec);
|
---|
621 |
|
---|
622 | APIRET exehLoadLXResource(PEXECUTABLE pExec,
|
---|
623 | ULONG ulType,
|
---|
624 | ULONG idResource,
|
---|
625 | PBYTE *ppbResData,
|
---|
626 | PULONG pcbResData);
|
---|
627 |
|
---|
628 | APIRET exehLoadOS2NEMaps(PEXECUTABLE pExec);
|
---|
629 |
|
---|
630 | VOID exehFreeNEMaps(PEXECUTABLE pExec);
|
---|
631 |
|
---|
632 | APIRET exehLoadOS2NEResource(PEXECUTABLE pExec,
|
---|
633 | ULONG ulType,
|
---|
634 | ULONG idResource,
|
---|
635 | PBYTE *ppbResData,
|
---|
636 | PULONG pcbResData);
|
---|
637 |
|
---|
638 | APIRET exehClose(PEXECUTABLE *ppExec);
|
---|
639 |
|
---|
640 | #endif
|
---|
641 |
|
---|
642 | #endif
|
---|
643 |
|
---|
644 | #if __cplusplus
|
---|
645 | }
|
---|
646 | #endif
|
---|
647 |
|
---|