[130] | 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 | *
|
---|
[242] | 9 | *@@include #define INCL_WINPROGRAMLIST // for some funcs only
|
---|
[130] | 10 | *@@include #include <os2.h>
|
---|
| 11 | *@@include #include "helpers\dosh.h"
|
---|
| 12 | *@@include #include "helpers\exeh.h"
|
---|
| 13 | */
|
---|
| 14 |
|
---|
| 15 | /* This file Copyright (C) 2000-2002 Ulrich Mller,
|
---|
| 16 | * Martin Lafaix.
|
---|
| 17 | * This file is part of the "XWorkplace helpers" source package.
|
---|
| 18 | * This is free software; you can redistribute it and/or modify
|
---|
| 19 | * it under the terms of the GNU General Public License as published
|
---|
| 20 | * by the Free Software Foundation, in version 2 as it comes in the
|
---|
| 21 | * "COPYING" file of the XWorkplace main distribution.
|
---|
| 22 | * This program is distributed in the hope that it will be useful,
|
---|
| 23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 25 | * GNU General Public License for more details.
|
---|
| 26 | */
|
---|
| 27 |
|
---|
| 28 | #if __cplusplus
|
---|
| 29 | extern "C" {
|
---|
| 30 | #endif
|
---|
| 31 |
|
---|
| 32 | #ifndef EXEH_HEADER_INCLUDED
|
---|
| 33 | #define EXEH_HEADER_INCLUDED
|
---|
| 34 |
|
---|
[131] | 35 | #pragma pack(1)
|
---|
| 36 |
|
---|
[130] | 37 | /********************************************************************
|
---|
| 38 | *
|
---|
[131] | 39 | * DOS exe header
|
---|
[130] | 40 | *
|
---|
| 41 | ********************************************************************/
|
---|
| 42 |
|
---|
| 43 | /*
|
---|
| 44 | *@@ DOSEXEHEADER:
|
---|
| 45 | * old DOS EXE header at offset 0
|
---|
| 46 | * in any EXE file.
|
---|
| 47 | *
|
---|
| 48 | *@@changed V0.9.7 (2000-12-20) [umoeller]: fixed NE offset
|
---|
| 49 | *@@changed V0.9.9 (2001-04-06) [lafaix]: additional fields defined
|
---|
| 50 | */
|
---|
| 51 |
|
---|
| 52 | typedef struct _DOSEXEHEADER
|
---|
| 53 | {
|
---|
| 54 | USHORT usDosExeID; // 00: DOS exeid (0x5a4d)
|
---|
| 55 | USHORT usFileLenMod512; // 02: filelen mod 512
|
---|
| 56 | USHORT usFileLenDiv512; // 04: filelen div 512
|
---|
| 57 | USHORT usSegFix; // 06: count of segment adds to fix
|
---|
| 58 | USHORT usHdrPargCnt; // 08: size of header in paragrphs
|
---|
| 59 | USHORT usMinAddPargCnt; // 0a: minimum addtl paragraphs count
|
---|
| 60 | USHORT usMaxAddPargCnt; // 0c: max addtl paragraphs count
|
---|
| 61 | USHORT usSSStartup; // 0e: SS at startup
|
---|
| 62 | USHORT usSPStartup; // 10: SP at startup
|
---|
| 63 | USHORT usHdrChecksum; // 12: header checksum
|
---|
| 64 | USHORT usIPStartup; // 14: IP at startup
|
---|
| 65 | USHORT usCodeSegOfs; // 16: code segment offset from EXE start
|
---|
[261] | 66 | USHORT usRelocTableOfs; // 18: reloc table ofs.header (Win: >= 0x40 || 0)
|
---|
[130] | 67 | USHORT usOverlayNo; // 1a: overlay no.
|
---|
| 68 | USHORT usLinkerVersion; // 1c: linker version (if 0x18 > 0x28)
|
---|
| 69 | USHORT usUnused1; // 1e: unused
|
---|
| 70 | USHORT usBehaviorBits; // 20: exe.h says this field contains
|
---|
| 71 | // 'behavior bits'
|
---|
| 72 | USHORT usUnused2; // 22: unused
|
---|
| 73 | USHORT usOEMIdentifier; // 24: OEM identifier
|
---|
| 74 | USHORT usOEMInformation; // 26: OEM information
|
---|
| 75 | ULONG ulUnused3; // 28:
|
---|
| 76 | ULONG ulUnused4; // 2c:
|
---|
| 77 | ULONG ulUnused5; // 30:
|
---|
| 78 | ULONG ulUnused6; // 34:
|
---|
| 79 | ULONG ulUnused7; // 38:
|
---|
[261] | 80 | ULONG ulNewHeaderOfs; // 3c: new header ofs (if 0x18 >= 0x40 || 0)
|
---|
[130] | 81 | // fixed this from USHORT, thanks Martin Lafaix
|
---|
| 82 | // V0.9.7 (2000-12-20) [umoeller]
|
---|
| 83 | } DOSEXEHEADER, *PDOSEXEHEADER;
|
---|
| 84 |
|
---|
[131] | 85 | /********************************************************************
|
---|
| 86 | *
|
---|
| 87 | * New Executable (NE)
|
---|
| 88 | *
|
---|
| 89 | ********************************************************************/
|
---|
| 90 |
|
---|
[130] | 91 | // NE and LX OS types
|
---|
| 92 | #define NEOS_UNKNOWN 0
|
---|
| 93 | #define NEOS_OS2 1 // Win16 SDK says: "reserved"...
|
---|
| 94 | #define NEOS_WIN16 2
|
---|
| 95 | #define NEOS_DOS4 3 // Win16 SDK says: "reserved"...
|
---|
| 96 | #define NEOS_WIN386 4 // Win16 SDK says: "reserved"...
|
---|
| 97 |
|
---|
| 98 | /*
|
---|
| 99 | *@@ NEHEADER:
|
---|
| 100 | * linear executable (LX) header format,
|
---|
| 101 | * which comes after the DOS header in the
|
---|
| 102 | * EXE file (at DOSEXEHEADER.ulNewHeaderOfs).
|
---|
| 103 | *
|
---|
| 104 | *@@changed V0.9.9 (2001-04-06) [lafaix]: fixed typo in usMoveableEntries
|
---|
| 105 | */
|
---|
| 106 |
|
---|
| 107 | typedef struct _NEHEADER
|
---|
| 108 | {
|
---|
| 109 | CHAR achNE[2]; // 00: "NE" magic ne_magic
|
---|
| 110 | BYTE bLinkerVersion; // 02: linker version ne_ver
|
---|
| 111 | BYTE bLinkerRevision; // 03: linker revision ne_rev
|
---|
| 112 | USHORT usEntryTblOfs; // 04: ofs from this to entrytable ne_enttab
|
---|
| 113 | USHORT usEntryTblLen; // 06: length of entrytable ne_cbenttab
|
---|
| 114 | ULONG ulChecksum; // 08: MS: reserved, OS/2: checksum ne_crc
|
---|
| 115 | USHORT usFlags; // 0c: flags ne_flags
|
---|
[131] | 116 | #ifndef NENOTP // do not conflict with toolkit exe defs
|
---|
| 117 | #define NENOTP 0x8000 // Not a process == library
|
---|
| 118 | #define NENOTMPSAFE 0x4000 // Process is not multi-processor safe
|
---|
| 119 | // (Win3.1 SDK: "reserved")
|
---|
| 120 | #define NEIERR 0x2000 // Errors in image
|
---|
| 121 | #define NEBOUND 0x0800 // Bound Family/API
|
---|
| 122 | // (Win3.1 SDK: "first segment contains code
|
---|
| 123 | // that loads the application")
|
---|
| 124 | #define NEAPPTYP 0x0700 // Application type mask
|
---|
| 125 | // (Win3.1 SDK: "reserved")
|
---|
| 126 | #define NENOTWINCOMPAT 0x0100 // Not compatible with P.M. Windowing
|
---|
| 127 | // (Win3.1 SDK: "reserved")
|
---|
| 128 | #define NEWINCOMPAT 0x0200 // Compatible with P.M. Windowing
|
---|
| 129 | // (Win3.1 SDK: "reserved")
|
---|
| 130 | #define NEWINAPI 0x0300 // Uses P.M. Windowing API
|
---|
| 131 | // (Win3.1 SDK: "reserved")
|
---|
| 132 | #define NEFLTP 0x0080 // Floating-point instructions
|
---|
| 133 | #define NEI386 0x0040 // 386 instructions
|
---|
| 134 | #define NEI286 0x0020 // 286 instructions
|
---|
| 135 | #define NEI086 0x0010 // 8086 instructions
|
---|
| 136 | #define NEPROT 0x0008 // Runs in protected mode only
|
---|
| 137 | // (Win3.1 SDK: "reserved")
|
---|
| 138 | #define NEPPLI 0x0004 // Per-Process Library Initialization
|
---|
| 139 | // (Win3.1 SDK: "reserved")
|
---|
| 140 | #define NEINST 0x0002 // Instance data
|
---|
| 141 | #define NESOLO 0x0001 // Solo data (single data)
|
---|
| 142 | #endif
|
---|
[130] | 143 | USHORT usAutoDataSegNo; // 0e: auto-data seg no. ne_autodata
|
---|
| 144 | // (Win3.1 SDK: "0 if both NEINST and NESOLO are cleared")
|
---|
| 145 | USHORT usInitlHeapSize; // 10: initl. heap size ne_heap
|
---|
| 146 | // (Win3.1 SDK: "0 if no local allocation")
|
---|
| 147 | USHORT usInitlStackSize; // 12: initl. stack size ne_stack
|
---|
| 148 | // (Win3.1 SDK: "0 if SS != DS")
|
---|
| 149 | ULONG ulCSIP; // 14: CS:IP ne_csip
|
---|
| 150 | ULONG ulSSSP; // 18: SS:SP ne_sssp
|
---|
| 151 | USHORT usSegTblEntries; // 1c: segment tbl entry count ne_cseg
|
---|
| 152 | USHORT usModuleTblEntries; // 1e: module ref. table entry count ne_cmod
|
---|
| 153 | USHORT usNonResdTblLen; // 20: non-resd. name tbl length ne_cbnrestab
|
---|
| 154 | USHORT usSegTblOfs; // 22: segment tbl ofs ne_segtab
|
---|
| 155 | // (from start of NEHEADER)
|
---|
| 156 | USHORT usResTblOfs; // 24: resource tbl ofs ne_rsrctab
|
---|
| 157 | // (from start of NEHEADER)
|
---|
| 158 | USHORT usResdNameTblOfs; // 26: resd. name tbl ofs ne_restab
|
---|
| 159 | // (from start of NEHEADER)
|
---|
| 160 | USHORT usModRefTblOfs; // 28: module ref. table ofs ne_modtab
|
---|
| 161 | // (from start of NEHEADER)
|
---|
| 162 | USHORT usImportTblOfs; // 2a: import name tbl ofs ne_imptab
|
---|
| 163 | // (from start of NEHEADER)
|
---|
| 164 | ULONG ulNonResdTblOfs; // 2c: non-resd. name tbl ofs ne_nrestab
|
---|
| 165 | // (from start of EXE!)
|
---|
| 166 | USHORT usMoveableEntries; // 30: moveable entry points count ne_cmovent
|
---|
| 167 | USHORT usLogicalSectShift; // 32: logcl. sector shift ne_align
|
---|
| 168 | // (Win3.1 SDK: "typically 4, but default is 9")
|
---|
| 169 | USHORT usResSegmCount; // 34: resource segm. count ne_cres
|
---|
| 170 | BYTE bTargetOS; // 36: target OS (NEOS_* flags) ne_exetyp
|
---|
| 171 | BYTE bFlags2; // 37: addtl. flags ne_flagsothers
|
---|
| 172 | // Win3.1 SDK:
|
---|
| 173 | // bit 1 --> Win2.x, but runs in Win3.x protected mode
|
---|
| 174 | // bit 2 --> Win2.x that supports prop. fonts
|
---|
| 175 | // bit 3 --> exec contains fastload area
|
---|
| 176 | /*
|
---|
| 177 | #define NELONGNAMES 0x01
|
---|
| 178 | #define NEWINISPROT 0x02
|
---|
| 179 | #define NEWINGETPROPFON 0x04
|
---|
| 180 | #define NEWLOAPPL 0x80
|
---|
| 181 | */
|
---|
| 182 | // the following are not listed in newexe.h, but are documented for Win3.x
|
---|
| 183 | USHORT usFastLoadOfs; // 38: fast-load area ofs
|
---|
| 184 | USHORT usFastLoadLen; // 3a: fast-load area length
|
---|
| 185 | USHORT usReserved; // 3c: MS: 'reserved'
|
---|
| 186 | USHORT usReqWinVersion; // 3e: Win-only: min. Win version
|
---|
| 187 | } NEHEADER, *PNEHEADER;
|
---|
| 188 |
|
---|
| 189 | /*
|
---|
[131] | 190 | *@@ OS2NERESTBLENTRY:
|
---|
| 191 | * OS/2 NE resource table entry.
|
---|
| 192 | *
|
---|
| 193 | *@@added V0.9.16 (2001-12-08) [umoeller]
|
---|
| 194 | */
|
---|
| 195 |
|
---|
| 196 | typedef struct _OS2NERESTBLENTRY
|
---|
| 197 | {
|
---|
| 198 | USHORT usType;
|
---|
| 199 | USHORT usID;
|
---|
| 200 | } OS2NERESTBLENTRY, *POS2NERESTBLENTRY;
|
---|
| 201 |
|
---|
| 202 | /*
|
---|
| 203 | *@@ OS2NESEGMENT:
|
---|
| 204 | * OS/2 NE segment definition.
|
---|
| 205 | *
|
---|
| 206 | *@@added V0.9.16 (2001-12-08) [umoeller]
|
---|
| 207 | */
|
---|
| 208 |
|
---|
| 209 | typedef struct _OS2NESEGMENT // New .EXE segment table entry
|
---|
| 210 | {
|
---|
| 211 | USHORT ns_sector; // File sector of start of segment
|
---|
| 212 | USHORT ns_cbseg; // Number of bytes in file
|
---|
| 213 | USHORT ns_flags; // Attribute flags
|
---|
| 214 | USHORT ns_minalloc; // Minimum allocation in bytes
|
---|
| 215 | } OS2NESEGMENT, *POS2NESEGMENT;
|
---|
| 216 |
|
---|
| 217 | /********************************************************************
|
---|
| 218 | *
|
---|
| 219 | * Linear Executable (LX)
|
---|
| 220 | *
|
---|
| 221 | ********************************************************************/
|
---|
| 222 |
|
---|
| 223 | /*
|
---|
[130] | 224 | *@@ LXHEADER:
|
---|
| 225 | * linear executable (LX) header format,
|
---|
| 226 | * which comes after the DOS header in the
|
---|
| 227 | * EXE file (at DOSEXEHEADER.ulNewHeaderOfs).
|
---|
| 228 | *
|
---|
| 229 | *@@changed V0.9.9 (2001-04-06) [lafaix]: fixed auto data object and ulinstanceDemdCnt
|
---|
| 230 | */
|
---|
| 231 |
|
---|
| 232 | typedef struct _LXHEADER
|
---|
| 233 | {
|
---|
[242] | 234 | CHAR achLX[2]; // 00: e32_magic "LX" or "LE" magic
|
---|
[130] | 235 | // this is "LX" for 32-bit OS/2 programs, but
|
---|
| 236 | // "LE" for MS-DOS progs which use this format
|
---|
| 237 | // (e.g. WINDOWS\SMARTDRV.EXE). IBM says the
|
---|
| 238 | // LE format was never released and superceded
|
---|
| 239 | // by LX... I am unsure what the differences are.
|
---|
| 240 | BYTE fByteBigEndian; // 02: e32_border byte ordering (1 = big endian)
|
---|
| 241 | BYTE fWordBigEndian; // 03: e32_worder word ordering (1 = big endian)
|
---|
| 242 | ULONG ulFormatLevel; // 04: e32_level exe format level (0)
|
---|
| 243 | USHORT usCPU; // 08: e32_cpu CPU type
|
---|
| 244 | USHORT usTargetOS; // 0a: e32_os OS type (NEOS_* flags)
|
---|
| 245 | ULONG ulModuleVersion; // 0c: e32_ver module version
|
---|
| 246 | ULONG ulFlags; // 10: e32_mflags module flags
|
---|
[131] | 247 | #ifndef E32NOTP // do not conflict with toolkit exe defs
|
---|
[242] | 248 | #define E32NOTP 0x00008000L // Library Module - used as NENOTP
|
---|
| 249 | #define E32NOLOAD 0x00002000L // Module not Loadable
|
---|
| 250 | #define E32PMAPI 0x00000300L // Uses PM Windowing API
|
---|
| 251 | #define E32PMW 0x00000200L // Compatible with PM Windowing
|
---|
| 252 | #define E32NOPMW 0x00000100L // Incompatible with PM Windowing
|
---|
| 253 | #define E32NOEXTFIX 0x00000020L // NO External Fixups in .EXE
|
---|
| 254 | #define E32NOINTFIX 0x00000010L // NO Internal Fixups in .EXE
|
---|
| 255 | #define E32SYSDLL 0x00000008L // System DLL, Internal Fixups discarded
|
---|
| 256 | #define E32LIBINIT 0x00000004L // Per-Process Library Initialization
|
---|
[131] | 257 | #define E32LIBTERM 0x40000000L // Per-Process Library Termination
|
---|
[242] | 258 |
|
---|
| 259 | #define E32APPMASK 0x00000300L // Application Type Mask
|
---|
| 260 |
|
---|
| 261 | // hiword defs added V1.0.1 (2003-01-17) [umoeller]
|
---|
| 262 | #define E32PROTDLL 0x00010000L // Protected memory library module *
|
---|
| 263 | #define E32DEVICE 0x00020000L // Device driver *
|
---|
| 264 | #define E32MODEXE 0x00000000L // .EXE module *
|
---|
| 265 | #define E32MODDLL 0x00008000L // .DLL module *
|
---|
| 266 | #define E32MODPROTDLL 0x00018000L // Protected memory library module *
|
---|
| 267 | #define E32MODPDEV 0x00020000L // Physical device driver *
|
---|
| 268 | #define E32MODVDEV 0x00028000L // Virtual device driver *
|
---|
| 269 | #define E32MODMASK 0x00038000L // Module type mask *
|
---|
| 270 | #define E32NOTMPSAFE 0x00080000L // Process is multi-processor unsafe *
|
---|
[131] | 271 | #endif
|
---|
[130] | 272 | ULONG ulPageCount; // 14: e32_mpages no. of pages in module
|
---|
| 273 | ULONG ulEIPRelObj; // 18: e32_startobj obj # for IP
|
---|
| 274 | // object to which EIP is relative
|
---|
| 275 | ULONG ulEIPEntryAddr; // 1c: e32_eip EIP entry addr
|
---|
| 276 | ULONG ulESPObj; // 20: e32_stackobj ESP object
|
---|
| 277 | ULONG ulESP; // 24: e32_esp ESP
|
---|
| 278 | ULONG ulPageSize; // 28: e32_pagesize page size (4K)
|
---|
| 279 | ULONG ulPageLeftShift; // 2c: e32_pageshift page left-shift
|
---|
| 280 | ULONG ulFixupTblLen; // 30: e32_fixupsize fixup section total size
|
---|
| 281 | ULONG ulFixupTblChecksum; // 34: e32_fixupsum fixup section checksum
|
---|
| 282 | ULONG ulLoaderLen; // 38: e32_ldrsize size req. for loader section
|
---|
| 283 | ULONG ulLoaderChecksum; // 3c: e32_ldrsum loader section checksum
|
---|
| 284 | ULONG ulObjTblOfs; // 40: e32_objtab object table offset
|
---|
| 285 | ULONG ulObjCount; // 44: e32_objcnt object count
|
---|
| 286 | ULONG ulObjPageTblOfs; // 48: e32_objmap object page table ofs
|
---|
| 287 | ULONG ulObjIterPagesOfs; // 4c: e32_itermap object iter pages ofs
|
---|
| 288 | ULONG ulResTblOfs; // 50: e32_rsrctab resource table ofs
|
---|
| 289 | ULONG ulResTblCnt; // 54: e32_rsrccnt resource entry count
|
---|
| 290 | ULONG ulResdNameTblOfs; // 58: e32_restab resident name tbl ofs
|
---|
| 291 | ULONG ulEntryTblOfs; // 5c: e32_enttab entry tbl ofs
|
---|
| 292 | ULONG ulModDirectivesOfs; // 60: e32_dirtab module directives ofs
|
---|
| 293 | ULONG ulModDirectivesCnt; // 64: e32_dircnt module directives count
|
---|
| 294 | ULONG ulFixupPagePageTblOfs;// 68: e32_fpagetab fixup page tbl ofs
|
---|
| 295 | ULONG ulFixupRecTblOfs; // 6c: e32_frectab fixup record tbl ofs
|
---|
| 296 | ULONG ulImportModTblOfs; // 70: e32_impmod import modl tbl ofs
|
---|
| 297 | ULONG ulImportModTblCnt; // 74: e32_impmodcnt import modl tbl count
|
---|
| 298 | ULONG ulImportProcTblOfs; // 78: e32_impproc import proc tbl ofs
|
---|
| 299 | ULONG ulPerPageCSOfs; // 7c: e32_pagesum per page checksum ofs
|
---|
| 300 | ULONG ulDataPagesOfs; // 80: e32_datapage data pages ofs
|
---|
| 301 | ULONG ulPreloadPagesCnt; // 84: e32_preload preload pages count
|
---|
| 302 | ULONG ulNonResdNameTblOfs; // 88: e32_nrestab non-resdnt name tbl ofs
|
---|
| 303 | ULONG ulNonResdNameTblLen; // 8c: e32_cbnrestab non-resdnt name tbl length
|
---|
| 304 | ULONG ulNonResdNameTblCS; // 90: e32_nressum non-res name tbl checksum
|
---|
| 305 | ULONG ulAutoDataSegObj; // 94: e32_autodata auto dataseg object
|
---|
| 306 | ULONG ulDebugOfs; // 98: e32_debuginfo debug info ofs
|
---|
| 307 | ULONG ulDebugLen; // 9c: e32_debuglen debug info length
|
---|
| 308 | ULONG ulInstancePrelCnt; // a0: e32_instpreload instance preload count
|
---|
| 309 | ULONG ulInstanceDemdCnt; // a0: e32_instdemand instance demand count
|
---|
| 310 | ULONG ulHeapSize16; // a8: e32_heapsize heap size (16-bit)
|
---|
| 311 | ULONG ulStackSize; // ac: e32_stacksize stack size
|
---|
| 312 | BYTE e32_res3[20];
|
---|
| 313 | // Pad structure to 196 bytes
|
---|
| 314 | } LXHEADER, *PLXHEADER;
|
---|
| 315 |
|
---|
| 316 | // additional LX structures
|
---|
| 317 |
|
---|
| 318 | /*
|
---|
| 319 | *@@ RESOURCETABLEENTRY:
|
---|
| 320 | * LX resource table entry.
|
---|
| 321 | *
|
---|
| 322 | *@@added V0.9.16 (2001-12-08) [umoeller]
|
---|
| 323 | */
|
---|
| 324 |
|
---|
| 325 | typedef struct _RESOURCETABLEENTRY // rsrc32
|
---|
| 326 | {
|
---|
| 327 | USHORT type; // Resource type
|
---|
| 328 | USHORT name; // Resource name
|
---|
| 329 | ULONG cb; // Resource size
|
---|
| 330 | USHORT obj; // Object number
|
---|
| 331 | ULONG offset; // Offset within object
|
---|
| 332 | } RESOURCETABLEENTRY;
|
---|
| 333 |
|
---|
| 334 | /*
|
---|
| 335 | *@@ OBJECTTABLEENTRY:
|
---|
| 336 | * LX object table entry.
|
---|
| 337 | *
|
---|
| 338 | *@@added V0.9.16 (2001-12-08) [umoeller]
|
---|
| 339 | */
|
---|
| 340 |
|
---|
| 341 | typedef struct _OBJECTTABLEENTRY // o32_obj
|
---|
| 342 | {
|
---|
| 343 | ULONG o32_size; // Object virtual size
|
---|
| 344 | ULONG o32_base; // Object base virtual address
|
---|
| 345 | ULONG o32_flags; // Attribute flags
|
---|
| 346 | ULONG o32_pagemap; // Object page map index
|
---|
| 347 | ULONG o32_mapsize; // Number of entries in object page map
|
---|
| 348 | ULONG o32_reserved; // Reserved
|
---|
| 349 | } OBJECTTABLEENTRY;
|
---|
| 350 |
|
---|
| 351 | /*
|
---|
| 352 | *@@ OBJECTPAGETABLEENTRY:
|
---|
| 353 | * LX object _page_ table entry, sometimes
|
---|
| 354 | * referred to as map entry.
|
---|
| 355 | *
|
---|
| 356 | *@@added V0.9.16 (2001-12-08) [umoeller]
|
---|
| 357 | */
|
---|
| 358 |
|
---|
| 359 | typedef struct _OBJECTPAGETABLEENTRY // o32_map
|
---|
| 360 | {
|
---|
| 361 | ULONG o32_pagedataoffset; // file offset of page
|
---|
| 362 | USHORT o32_pagesize; // # of real bytes of page data
|
---|
| 363 | USHORT o32_pageflags; // Per-Page attributes
|
---|
| 364 | } OBJECTPAGETABLEENTRY;
|
---|
| 365 |
|
---|
| 366 | /*
|
---|
| 367 | *@@ LXITER:
|
---|
| 368 | * iteration Record format for 'EXEPACK'ed pages.
|
---|
| 369 | *
|
---|
| 370 | *@@added V0.9.16 (2001-12-08) [umoeller]
|
---|
| 371 | */
|
---|
| 372 |
|
---|
| 373 | typedef struct _LXITER
|
---|
| 374 | {
|
---|
| 375 | USHORT LX_nIter; // number of iterations
|
---|
| 376 | USHORT LX_nBytes; // number of bytes
|
---|
| 377 | unsigned char LX_Iterdata; // iterated data byte(s)
|
---|
| 378 | } LXITER, *PLXITER;
|
---|
| 379 |
|
---|
[131] | 380 | // object/segment flags (in NE and LX)
|
---|
| 381 | #define OBJWRITE 0x0002L // Writeable Object
|
---|
| 382 | #define OBJDISCARD 0x0010L // Object is Discardable
|
---|
| 383 | #define OBJSHARED 0x0020L // Object is Shared
|
---|
| 384 | #define OBJPRELOAD 0x0040L // Object has preload pages
|
---|
| 385 |
|
---|
| 386 | // resource flags
|
---|
| 387 | #define RNMOVE 0x0010 // Moveable resource
|
---|
| 388 | #define RNPURE 0x0020 // Pure (read-only) resource
|
---|
| 389 | #define RNPRELOAD 0x0040 // Preloaded resource
|
---|
| 390 | #define RNDISCARD 0xF000 // Discard priority level for resource
|
---|
| 391 |
|
---|
| 392 | /********************************************************************
|
---|
| 393 | *
|
---|
| 394 | * Portable Executable (PE)
|
---|
| 395 | *
|
---|
| 396 | ********************************************************************/
|
---|
| 397 |
|
---|
[130] | 398 | /*
|
---|
[131] | 399 | *@@ IMAGE_FILE_HEADER:
|
---|
| 400 | * first part of PE header (standard header).
|
---|
[130] | 401 | *
|
---|
[131] | 402 | *@@added V0.9.16 (2002-01-09) [umoeller]
|
---|
[130] | 403 | */
|
---|
| 404 |
|
---|
[131] | 405 | typedef struct _IMAGE_FILE_HEADER
|
---|
[130] | 406 | {
|
---|
[131] | 407 | USHORT usMachine; // CPU type
|
---|
| 408 | #define IMAGE_FILE_MACHINE_UNKNOWN 0
|
---|
| 409 | #define IMAGE_FILE_MACHINE_I860 0x14d
|
---|
| 410 | #define IMAGE_FILE_MACHINE_I386 0x14c
|
---|
| 411 | #define IMAGE_FILE_MACHINE_R3000 0x162
|
---|
| 412 | #define IMAGE_FILE_MACHINE_R4000 0x166
|
---|
| 413 | #define IMAGE_FILE_MACHINE_R10000 0x168
|
---|
| 414 | #define IMAGE_FILE_MACHINE_ALPHA 0x184
|
---|
| 415 | #define IMAGE_FILE_MACHINE_POWERPC 0x1F0
|
---|
| 416 | USHORT usNumberOfSections;
|
---|
| 417 | ULONG ulTimeDateStamp;
|
---|
| 418 | ULONG ulPointerToSymbolTable;
|
---|
| 419 | ULONG ulNumberOfSymbols;
|
---|
| 420 | USHORT usSizeOfOptionalHeader;
|
---|
| 421 | USHORT fsCharacteristics;
|
---|
| 422 | #define IMAGE_FILE_RELOCS_STRIPPED 1 // No relocation info
|
---|
| 423 | #define IMAGE_FILE_EXECUTABLE_IMAGE 2
|
---|
| 424 | #define IMAGE_FILE_LINE_NUMS_STRIPPED 4
|
---|
| 425 | #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 8
|
---|
| 426 | #define IMAGE_FILE_16BIT_MACHINE 0x40
|
---|
| 427 | #define IMAGE_FILE_BYTES_REVERSED_LO 0x80
|
---|
| 428 | #define IMAGE_FILE_32BIT_MACHINE 0x100
|
---|
| 429 | #define IMAGE_FILE_DEBUG_STRIPPED 0x200
|
---|
| 430 | #define IMAGE_FILE_SYSTEM 0x1000
|
---|
| 431 | #define IMAGE_FILE_DLL 0x2000
|
---|
| 432 | #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
|
---|
| 433 | } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
|
---|
[130] | 434 |
|
---|
[131] | 435 | typedef struct _IMAGE_DATA_DIRECTORY
|
---|
| 436 | {
|
---|
| 437 | ULONG VirtualAddress;
|
---|
| 438 | ULONG Size;
|
---|
| 439 | } IMAGE_DATA_DIRECTORY,*PIMAGE_DATA_DIRECTORY;
|
---|
| 440 |
|
---|
| 441 | #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
|
---|
| 442 |
|
---|
[130] | 443 | /*
|
---|
[131] | 444 | *@@ IMAGE_OPTIONAL_HEADER:
|
---|
| 445 | * second part of PE header (optional header).
|
---|
[130] | 446 | *
|
---|
[131] | 447 | *@@added V0.9.16 (2002-01-09) [umoeller]
|
---|
[130] | 448 | */
|
---|
| 449 |
|
---|
[131] | 450 | typedef struct _IMAGE_OPTIONAL_HEADER
|
---|
[130] | 451 | {
|
---|
[131] | 452 | // Standard fields
|
---|
| 453 | USHORT Magic; // 00
|
---|
| 454 | #define IMAGE_NT_OPTIONAL_HDR_MAGIC 0x10b
|
---|
| 455 | #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
|
---|
| 456 | BYTE MajorLinkerVersion; // 02
|
---|
| 457 | BYTE MinorLinkerVersion; // 03
|
---|
| 458 | ULONG SizeOfCode; // 04
|
---|
| 459 | ULONG SizeOfInitializedData; // 08
|
---|
| 460 | ULONG SizeOfUninitializedData; // 0C
|
---|
| 461 | ULONG AddressOfEntryPoint; // 10
|
---|
| 462 | ULONG BaseOfCode; // 14
|
---|
| 463 | ULONG BaseOfData; // 18
|
---|
[130] | 464 |
|
---|
[131] | 465 | // NT additional fields
|
---|
| 466 | ULONG ImageBase; // 1C
|
---|
| 467 | ULONG SectionAlignment; // 20
|
---|
| 468 | ULONG FileAlignment; // 24
|
---|
| 469 | USHORT MajorOperatingSystemVersion; // 28
|
---|
| 470 | USHORT MinorOperatingSystemVersion; // 2A
|
---|
| 471 | USHORT MajorImageVersion; // 2C
|
---|
| 472 | USHORT MinorImageVersion; // 2E
|
---|
| 473 | USHORT MajorSubsystemVersion; // 30
|
---|
| 474 | USHORT MinorSubsystemVersion; // 32
|
---|
| 475 | ULONG Reserved1; // 34
|
---|
| 476 | ULONG SizeOfImage; // 38
|
---|
| 477 | ULONG SizeOfHeaders; // 3C
|
---|
| 478 | ULONG CheckSum; // 40
|
---|
| 479 | USHORT usSubsystem; // 44
|
---|
| 480 | #define IMAGE_SUBSYSTEM_UNKNOWN 0
|
---|
| 481 | #define IMAGE_SUBSYSTEM_NATIVE 1
|
---|
| 482 | #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 // Windows GUI subsystem
|
---|
| 483 | #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 // Windows character subsystem
|
---|
| 484 | #define IMAGE_SUBSYSTEM_OS2_CUI 5
|
---|
| 485 | #define IMAGE_SUBSYSTEM_POSIX_CUI 7
|
---|
| 486 | USHORT DllCharacteristics; // 46
|
---|
| 487 | ULONG SizeOfStackReserve; // 48
|
---|
| 488 | ULONG SizeOfStackCommit; // 4C
|
---|
| 489 | ULONG SizeOfHeapReserve; // 50
|
---|
| 490 | ULONG SizeOfHeapCommit; // 54
|
---|
| 491 | ULONG LoaderFlags; // 58
|
---|
| 492 | ULONG NumberOfRvaAndSizes; // 5C
|
---|
| 493 | // 60:
|
---|
| 494 | IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
|
---|
| 495 | } IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER;
|
---|
[130] | 496 |
|
---|
[131] | 497 | // indices into the DataDirectory array
|
---|
| 498 | #define IMAGE_FILE_EXPORT_DIRECTORY 0
|
---|
| 499 | #define IMAGE_FILE_IMPORT_DIRECTORY 1
|
---|
| 500 | #define IMAGE_FILE_RESOURCE_DIRECTORY 2
|
---|
| 501 | #define IMAGE_FILE_EXCEPTION_DIRECTORY 3
|
---|
| 502 | #define IMAGE_FILE_SECURITY_DIRECTORY 4
|
---|
| 503 | #define IMAGE_FILE_BASE_RELOCATION_TABLE 5
|
---|
| 504 | #define IMAGE_FILE_DEBUG_DIRECTORY 6
|
---|
| 505 | #define IMAGE_FILE_DESCRIPTION_STRING 7
|
---|
| 506 | #define IMAGE_FILE_MACHINE_VALUE 8 // Mips
|
---|
| 507 | #define IMAGE_FILE_THREAD_LOCAL_STORAGE 9
|
---|
| 508 | #define IMAGE_FILE_CALLBACK_DIRECTORY 10
|
---|
[130] | 509 |
|
---|
[131] | 510 | // directory entries, indices into the DataDirectory array
|
---|
| 511 | #define IMAGE_DIRECTORY_ENTRY_EXPORT 0
|
---|
| 512 | #define IMAGE_DIRECTORY_ENTRY_IMPORT 1
|
---|
| 513 | #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
|
---|
| 514 | #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
|
---|
| 515 | #define IMAGE_DIRECTORY_ENTRY_SECURITY 4
|
---|
| 516 | #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5
|
---|
| 517 | #define IMAGE_DIRECTORY_ENTRY_DEBUG 6
|
---|
| 518 | #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
|
---|
| 519 | #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 // (MIPS GP)
|
---|
| 520 | #define IMAGE_DIRECTORY_ENTRY_TLS 9
|
---|
| 521 | #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
|
---|
| 522 | #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11
|
---|
| 523 | #define IMAGE_DIRECTORY_ENTRY_IAT 12 // Import Address Table
|
---|
| 524 | #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
|
---|
| 525 | #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
|
---|
[130] | 526 |
|
---|
[131] | 527 | /*
|
---|
| 528 | *@@ PEHEADER:
|
---|
| 529 | * portable executable (PE) header format,
|
---|
| 530 | * which comes after the DOS header in the
|
---|
| 531 | * EXE file (at DOSEXEHEADER.ulNewHeaderOfs).
|
---|
| 532 | *
|
---|
| 533 | *@@added V0.9.16 (2002-01-09) [umoeller]
|
---|
| 534 | */
|
---|
[130] | 535 |
|
---|
[131] | 536 | typedef struct _PEHEADER
|
---|
| 537 | {
|
---|
| 538 | // standard header
|
---|
| 539 | ULONG ulSignature; // 00: 'P', 'E', 0, 0
|
---|
| 540 | IMAGE_FILE_HEADER // 04
|
---|
| 541 | FileHeader;
|
---|
| 542 | IMAGE_OPTIONAL_HEADER // 18
|
---|
| 543 | OptionalHeader;
|
---|
[130] | 544 |
|
---|
[131] | 545 | } PEHEADER, *PPEHEADER;
|
---|
| 546 |
|
---|
| 547 | /*
|
---|
| 548 | #define PE_HEADER(module) \
|
---|
| 549 | ((IMAGE_NT_HEADERS*)((LPBYTE)(module) + \
|
---|
| 550 | (((IMAGE_DOS_HEADER*)(module))->e_lfanew)))
|
---|
| 551 |
|
---|
| 552 | #define PE_SECTIONS(module) \
|
---|
| 553 | ((IMAGE_SECTION_HEADER*)((LPBYTE)&PE_HEADER(module)->OptionalHeader + \
|
---|
| 554 | PE_HEADER(module)->FileHeader.SizeOfOptionalHeader))
|
---|
| 555 |
|
---|
| 556 | #define RVA_PTR(module,field) ((LPBYTE)(module) + PE_HEADER(module)->field)
|
---|
| 557 | */
|
---|
| 558 |
|
---|
| 559 | // Section header format
|
---|
| 560 |
|
---|
| 561 | #define IMAGE_SIZEOF_SHORT_NAME 8
|
---|
| 562 |
|
---|
| 563 | /*
|
---|
| 564 | *@@ IMAGE_SECTION_HEADER:
|
---|
| 565 | * comes right after PEHEADER in executable.
|
---|
| 566 | *
|
---|
| 567 | *@@added V0.9.16 (2002-01-09) [umoeller]
|
---|
| 568 | */
|
---|
| 569 |
|
---|
| 570 | typedef struct _IMAGE_SECTION_HEADER
|
---|
| 571 | {
|
---|
| 572 | BYTE Name[IMAGE_SIZEOF_SHORT_NAME]; // 00:
|
---|
| 573 | union
|
---|
| 574 | {
|
---|
| 575 | ULONG PhysicalAddress; // 04:
|
---|
| 576 | ULONG VirtualSize; // 04:
|
---|
| 577 | } Misc;
|
---|
| 578 | ULONG VirtualAddress; // 08:
|
---|
| 579 | ULONG ulSizeOfRawData; // 0C:
|
---|
| 580 | ULONG ulPointerToRawData; // 10:
|
---|
| 581 | ULONG PointerToRelocations; // 14:
|
---|
| 582 | ULONG PointerToLinenumbers; // 18:
|
---|
| 583 | USHORT NumberOfRelocations; // 1C:
|
---|
| 584 | USHORT NumberOfLinenumbers; // 1E:
|
---|
| 585 | ULONG flCharacteristics; // 20:
|
---|
| 586 | // #define IMAGE_SCN_TYPE_REG 0x00000000 - Reserved
|
---|
| 587 | // #define IMAGE_SCN_TYPE_DSECT 0x00000001 - Reserved
|
---|
| 588 | // #define IMAGE_SCN_TYPE_NOLOAD 0x00000002 - Reserved
|
---|
| 589 | // #define IMAGE_SCN_TYPE_GROUP 0x00000004 - Reserved
|
---|
| 590 | // #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 - Reserved
|
---|
| 591 | // #define IMAGE_SCN_TYPE_COPY 0x00000010 - Reserved
|
---|
| 592 | #define IMAGE_SCN_CNT_CODE 0x00000020
|
---|
| 593 | #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
|
---|
| 594 | #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
|
---|
| 595 | #define IMAGE_SCN_LNK_OTHER 0x00000100
|
---|
| 596 | #define IMAGE_SCN_LNK_INFO 0x00000200
|
---|
| 597 | // #define IMAGE_SCN_TYPE_OVER 0x00000400 - Reserved
|
---|
| 598 | #define IMAGE_SCN_LNK_REMOVE 0x00000800
|
---|
| 599 | #define IMAGE_SCN_LNK_COMDAT 0x00001000
|
---|
| 600 | // 0x00002000 - Reserved
|
---|
| 601 | // #define IMAGE_SCN_MEM_PROTECTED 0x00004000 - Obsolete
|
---|
| 602 | #define IMAGE_SCN_MEM_FARDATA 0x00008000
|
---|
| 603 | // #define IMAGE_SCN_MEM_SYSHEAP 0x00010000 - Obsolete
|
---|
| 604 | #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
|
---|
| 605 | #define IMAGE_SCN_MEM_16BIT 0x00020000
|
---|
| 606 | #define IMAGE_SCN_MEM_LOCKED 0x00040000
|
---|
| 607 | #define IMAGE_SCN_MEM_PRELOAD 0x00080000
|
---|
| 608 | #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
|
---|
| 609 | #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
|
---|
| 610 | #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
|
---|
| 611 | #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
|
---|
| 612 | #define IMAGE_SCN_ALIGN_16BYTES 0x00500000 // Default
|
---|
| 613 | #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
|
---|
| 614 | #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
|
---|
| 615 | // 0x00800000 - Unused
|
---|
| 616 | #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
|
---|
| 617 | #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
|
---|
| 618 | #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
|
---|
| 619 | #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
|
---|
| 620 | #define IMAGE_SCN_MEM_SHARED 0x10000000
|
---|
| 621 | #define IMAGE_SCN_MEM_EXECUTE 0x20000000
|
---|
| 622 | #define IMAGE_SCN_MEM_READ 0x40000000
|
---|
| 623 | #define IMAGE_SCN_MEM_WRITE 0x80000000
|
---|
| 624 | // 24:
|
---|
| 625 | } IMAGE_SECTION_HEADER,*PIMAGE_SECTION_HEADER;
|
---|
| 626 |
|
---|
| 627 | #define IMAGE_SIZEOF_SECTION_HEADER 40
|
---|
| 628 |
|
---|
| 629 | /*
|
---|
| 630 | *@@ IMAGE_IMPORT_BY_NAME:
|
---|
| 631 | * import name entry.
|
---|
| 632 | *
|
---|
| 633 | *@@added V0.9.16 (2002-01-09) [umoeller]
|
---|
| 634 | */
|
---|
| 635 |
|
---|
| 636 | typedef struct _IMAGE_IMPORT_BY_NAME
|
---|
| 637 | {
|
---|
| 638 | USHORT Hint;
|
---|
| 639 | BYTE Name[1];
|
---|
| 640 | } IMAGE_IMPORT_BY_NAME,*PIMAGE_IMPORT_BY_NAME;
|
---|
| 641 |
|
---|
| 642 | /*
|
---|
| 643 | *@@ IMAGE_THUNK_DATA:
|
---|
| 644 | * import thunk.
|
---|
| 645 | *
|
---|
| 646 | *@@added V0.9.16 (2002-01-09) [umoeller]
|
---|
| 647 | */
|
---|
| 648 |
|
---|
| 649 | typedef struct _IMAGE_THUNK_DATA
|
---|
| 650 | {
|
---|
| 651 | union
|
---|
| 652 | {
|
---|
| 653 | PBYTE ForwarderString;
|
---|
| 654 | PFN Function;
|
---|
| 655 | ULONG Ordinal;
|
---|
| 656 | PIMAGE_IMPORT_BY_NAME
|
---|
| 657 | AddressOfData;
|
---|
| 658 | } u1;
|
---|
| 659 | } IMAGE_THUNK_DATA,*PIMAGE_THUNK_DATA;
|
---|
| 660 |
|
---|
| 661 | /*
|
---|
| 662 | *@@ IMAGE_IMPORT_DESCRIPTOR:
|
---|
| 663 | * import module directory.
|
---|
| 664 | *
|
---|
| 665 | *@@added V0.9.16 (2002-01-09) [umoeller]
|
---|
| 666 | */
|
---|
| 667 |
|
---|
| 668 | typedef struct _IMAGE_IMPORT_DESCRIPTOR
|
---|
| 669 | {
|
---|
| 670 | union
|
---|
| 671 | {
|
---|
| 672 | ULONG Characteristics; // 0 for terminating null import descriptor
|
---|
| 673 | PIMAGE_THUNK_DATA
|
---|
| 674 | OriginalFirstThunk; // RVA to original unbound IAT
|
---|
| 675 | } u;
|
---|
| 676 | ULONG TimeDateStamp; // 0 if not bound,
|
---|
| 677 | // -1 if bound, and real date\time stamp
|
---|
| 678 | // in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT
|
---|
| 679 | // (new BIND)
|
---|
| 680 | // otherwise date/time stamp of DLL bound to
|
---|
| 681 | // (Old BIND)
|
---|
| 682 | ULONG ForwarderChain; // -1 if no forwarders
|
---|
| 683 | ULONG Name;
|
---|
| 684 | // RVA to IAT (if bound this IAT has actual addresses)
|
---|
| 685 | PIMAGE_THUNK_DATA
|
---|
| 686 | FirstThunk;
|
---|
| 687 | } IMAGE_IMPORT_DESCRIPTOR,*PIMAGE_IMPORT_DESCRIPTOR;
|
---|
| 688 |
|
---|
| 689 | #define IMAGE_ORDINAL_FLAG 0x80000000
|
---|
| 690 | #define IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG) != 0)
|
---|
| 691 | #define IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff)
|
---|
| 692 |
|
---|
| 693 | /*
|
---|
| 694 | *@@ IMAGE_EXPORT_DIRECTORY:
|
---|
| 695 | * export module directory
|
---|
| 696 | *
|
---|
| 697 | *@@added V0.9.16 (2002-01-09) [umoeller]
|
---|
| 698 | */
|
---|
| 699 |
|
---|
| 700 | typedef struct _IMAGE_EXPORT_DIRECTORY
|
---|
| 701 | {
|
---|
| 702 | ULONG Characteristics;
|
---|
| 703 | ULONG TimeDateStamp;
|
---|
| 704 | USHORT MajorVersion;
|
---|
| 705 | USHORT MinorVersion;
|
---|
| 706 | ULONG Name;
|
---|
| 707 | ULONG Base;
|
---|
| 708 | ULONG NumberOfFunctions;
|
---|
| 709 | ULONG NumberOfNames;
|
---|
| 710 | PULONG *AddressOfFunctions;
|
---|
| 711 | PULONG *AddressOfNames;
|
---|
| 712 | PUSHORT *AddressOfNameOrdinals;
|
---|
| 713 | // u_char ModuleName[1];
|
---|
| 714 | } IMAGE_EXPORT_DIRECTORY,*PIMAGE_EXPORT_DIRECTORY;
|
---|
| 715 |
|
---|
| 716 | /*
|
---|
| 717 | *@@ IMAGE_RESOURCE_DIRECTORY:
|
---|
| 718 | *
|
---|
| 719 | *@@added V0.9.16 (2002-01-09) [umoeller]
|
---|
| 720 | */
|
---|
| 721 |
|
---|
| 722 | typedef struct _IMAGE_RESOURCE_DIRECTORY
|
---|
| 723 | {
|
---|
| 724 | ULONG Characteristics;
|
---|
| 725 | ULONG TimeDateStamp;
|
---|
| 726 | USHORT MajorVersion;
|
---|
| 727 | USHORT MinorVersion;
|
---|
| 728 | USHORT NumberOfNamedEntries;
|
---|
| 729 | USHORT NumberOfIdEntries;
|
---|
| 730 | // IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[];
|
---|
| 731 | } IMAGE_RESOURCE_DIRECTORY,*PIMAGE_RESOURCE_DIRECTORY;
|
---|
| 732 |
|
---|
| 733 | #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
|
---|
| 734 | #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
|
---|
| 735 |
|
---|
| 736 | /*
|
---|
| 737 | *@@ IMAGE_RESOURCE_DIRECTORY_ENTRY:
|
---|
| 738 | *
|
---|
| 739 | *@@added V0.9.16 (2002-01-09) [umoeller]
|
---|
| 740 | */
|
---|
| 741 |
|
---|
| 742 | typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY
|
---|
| 743 | {
|
---|
| 744 | union
|
---|
| 745 | {
|
---|
| 746 | struct
|
---|
| 747 | {
|
---|
| 748 | unsigned NameOffset:31;
|
---|
| 749 | unsigned NameIsString:1;
|
---|
| 750 | } s;
|
---|
| 751 | ULONG Name;
|
---|
| 752 | USHORT Id;
|
---|
| 753 | } u1;
|
---|
| 754 | union
|
---|
| 755 | {
|
---|
| 756 | ULONG OffsetToData;
|
---|
| 757 | struct
|
---|
| 758 | {
|
---|
| 759 | unsigned OffsetToDirectory:31;
|
---|
| 760 | unsigned DataIsDirectory:1;
|
---|
| 761 | } s;
|
---|
| 762 | } u2;
|
---|
| 763 | } IMAGE_RESOURCE_DIRECTORY_ENTRY, *PIMAGE_RESOURCE_DIRECTORY_ENTRY;
|
---|
| 764 |
|
---|
| 765 | /*
|
---|
| 766 | *@@ IMAGE_RESOURCE_DIRECTORY_STRING:
|
---|
| 767 | *
|
---|
| 768 | *@@added V0.9.16 (2002-01-09) [umoeller]
|
---|
| 769 | */
|
---|
| 770 |
|
---|
| 771 | typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING
|
---|
| 772 | {
|
---|
| 773 | USHORT Length;
|
---|
| 774 | CHAR NameString[1];
|
---|
| 775 | } IMAGE_RESOURCE_DIRECTORY_STRING, *PIMAGE_RESOURCE_DIRECTORY_STRING;
|
---|
| 776 |
|
---|
| 777 | typedef USHORT WCHAR;
|
---|
| 778 |
|
---|
| 779 | /*
|
---|
| 780 | *@@ IMAGE_RESOURCE_DIR_STRING_U:
|
---|
| 781 | *
|
---|
| 782 | *@@added V0.9.16 (2002-01-09) [umoeller]
|
---|
| 783 | */
|
---|
| 784 |
|
---|
| 785 | typedef struct _IMAGE_RESOURCE_DIR_STRING_U
|
---|
| 786 | {
|
---|
| 787 | USHORT Length;
|
---|
| 788 | WCHAR NameString[ 1 ];
|
---|
| 789 | } IMAGE_RESOURCE_DIR_STRING_U,*PIMAGE_RESOURCE_DIR_STRING_U;
|
---|
| 790 |
|
---|
| 791 | /*
|
---|
| 792 | *@@ IMAGE_RESOURCE_DATA_ENTRY:
|
---|
| 793 | *
|
---|
| 794 | *@@added V0.9.16 (2002-01-09) [umoeller]
|
---|
| 795 | */
|
---|
| 796 |
|
---|
| 797 | typedef struct _IMAGE_RESOURCE_DATA_ENTRY
|
---|
| 798 | {
|
---|
| 799 | ULONG OffsetToData;
|
---|
| 800 | ULONG Size;
|
---|
| 801 | ULONG CodePage;
|
---|
| 802 | ULONG ResourceHandle;
|
---|
| 803 | } IMAGE_RESOURCE_DATA_ENTRY,*PIMAGE_RESOURCE_DATA_ENTRY;
|
---|
| 804 |
|
---|
| 805 | /*
|
---|
| 806 | *@@ IMAGE_BASE_RELOCATION:
|
---|
| 807 | *
|
---|
| 808 | *@@added V0.9.16 (2002-01-09) [umoeller]
|
---|
| 809 | */
|
---|
| 810 |
|
---|
| 811 | typedef struct _IMAGE_BASE_RELOCATION
|
---|
| 812 | {
|
---|
| 813 | ULONG VirtualAddress;
|
---|
| 814 | ULONG SizeOfBlock;
|
---|
| 815 | USHORT TypeOffset[1];
|
---|
| 816 | } IMAGE_BASE_RELOCATION,*PIMAGE_BASE_RELOCATION;
|
---|
| 817 |
|
---|
| 818 | /*
|
---|
| 819 | *@@ IMAGE_LOAD_CONFIG_DIRECTORY:
|
---|
| 820 | *
|
---|
| 821 | *@@added V0.9.16 (2002-01-09) [umoeller]
|
---|
| 822 | */
|
---|
| 823 |
|
---|
| 824 | typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY
|
---|
| 825 | {
|
---|
| 826 | ULONG Characteristics;
|
---|
| 827 | ULONG TimeDateStamp;
|
---|
| 828 | USHORT MajorVersion;
|
---|
| 829 | USHORT MinorVersion;
|
---|
| 830 | ULONG GlobalFlagsClear;
|
---|
| 831 | ULONG GlobalFlagsSet;
|
---|
| 832 | ULONG CriticalSectionDefaultTimeout;
|
---|
| 833 | ULONG DeCommitFreeBlockThreshold;
|
---|
| 834 | ULONG DeCommitTotalFreeThreshold;
|
---|
| 835 | PVOID LockPrefixTable;
|
---|
| 836 | ULONG MaximumAllocationSize;
|
---|
| 837 | ULONG VirtualMemoryThreshold;
|
---|
| 838 | ULONG ProcessHeapFlags;
|
---|
| 839 | ULONG Reserved[ 4 ];
|
---|
| 840 | } IMAGE_LOAD_CONFIG_DIRECTORY,*PIMAGE_LOAD_CONFIG_DIRECTORY;
|
---|
| 841 |
|
---|
| 842 | typedef VOID (* /* CALLBACK */ PIMAGE_TLS_CALLBACK)(PVOID DllHandle,
|
---|
| 843 | ULONG Reason,
|
---|
| 844 | PVOID Reserved);
|
---|
| 845 |
|
---|
| 846 | /*
|
---|
| 847 | *@@ IMAGE_TLS_DIRECTORY:
|
---|
| 848 | *
|
---|
| 849 | *@@added V0.9.16 (2002-01-09) [umoeller]
|
---|
| 850 | */
|
---|
| 851 |
|
---|
| 852 | typedef struct _IMAGE_TLS_DIRECTORY
|
---|
| 853 | {
|
---|
| 854 | ULONG StartAddressOfRawData;
|
---|
| 855 | ULONG EndAddressOfRawData;
|
---|
| 856 | PULONG AddressOfIndex;
|
---|
| 857 | PIMAGE_TLS_CALLBACK *AddressOfCallBacks;
|
---|
| 858 | ULONG SizeOfZeroFill;
|
---|
| 859 | ULONG Characteristics;
|
---|
| 860 | } IMAGE_TLS_DIRECTORY,*PIMAGE_TLS_DIRECTORY;
|
---|
| 861 |
|
---|
| 862 | /*
|
---|
| 863 | *@@ IMAGE_DEBUG_DIRECTORY:
|
---|
| 864 | * the IMAGE_DEBUG_DIRECTORY data directory points
|
---|
| 865 | * to an array of these structures.
|
---|
| 866 | *
|
---|
| 867 | *@@added V0.9.16 (2002-01-09) [umoeller]
|
---|
| 868 | */
|
---|
| 869 |
|
---|
| 870 | typedef struct _IMAGE_DEBUG_DIRECTORY
|
---|
| 871 | {
|
---|
| 872 | ULONG Characteristics;
|
---|
| 873 | ULONG TimeDateStamp;
|
---|
| 874 | USHORT MajorVersion;
|
---|
| 875 | USHORT MinorVersion;
|
---|
| 876 | ULONG Type;
|
---|
| 877 | ULONG SizeOfData;
|
---|
| 878 | ULONG AddressOfRawData;
|
---|
| 879 | ULONG ulPointerToRawData;
|
---|
| 880 | } IMAGE_DEBUG_DIRECTORY,*PIMAGE_DEBUG_DIRECTORY;
|
---|
| 881 |
|
---|
| 882 | /*
|
---|
| 883 | * The type field above can take these (plus a few other
|
---|
| 884 | * irrelevant) values.
|
---|
| 885 | */
|
---|
| 886 | #define IMAGE_DEBUG_TYPE_UNKNOWN 0
|
---|
| 887 | #define IMAGE_DEBUG_TYPE_COFF 1
|
---|
| 888 | #define IMAGE_DEBUG_TYPE_CODEVIEW 2
|
---|
| 889 | #define IMAGE_DEBUG_TYPE_FPO 3
|
---|
| 890 | #define IMAGE_DEBUG_TYPE_MISC 4
|
---|
| 891 | #define IMAGE_DEBUG_TYPE_EXCEPTION 5
|
---|
| 892 | #define IMAGE_DEBUG_TYPE_FIXUP 6
|
---|
| 893 | #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
|
---|
| 894 | #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
|
---|
| 895 |
|
---|
| 896 | // generic relocation types
|
---|
| 897 | #define IMAGE_REL_BASED_ABSOLUTE 0
|
---|
| 898 | #define IMAGE_REL_BASED_HIGH 1
|
---|
| 899 | #define IMAGE_REL_BASED_LOW 2
|
---|
| 900 | #define IMAGE_REL_BASED_HIGHLOW 3
|
---|
| 901 | #define IMAGE_REL_BASED_HIGHADJ 4
|
---|
| 902 | #define IMAGE_REL_BASED_MIPS_JMPADDR 5
|
---|
| 903 | #define IMAGE_REL_BASED_SECTION 6
|
---|
| 904 | #define IMAGE_REL_BASED_REL 7
|
---|
| 905 | #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
|
---|
| 906 | #define IMAGE_REL_BASED_IA64_IMM64 9 // yes, 9 too
|
---|
| 907 | #define IMAGE_REL_BASED_DIR64 10
|
---|
| 908 | #define IMAGE_REL_BASED_HIGH3ADJ 11
|
---|
| 909 |
|
---|
| 910 | // I386 relocation types
|
---|
| 911 | #define IMAGE_REL_I386_ABSOLUTE 0
|
---|
| 912 | #define IMAGE_REL_I386_DIR16 1
|
---|
| 913 | #define IMAGE_REL_I386_REL16 2
|
---|
| 914 | #define IMAGE_REL_I386_DIR 6
|
---|
| 915 | #define IMAGE_REL_I386_DIR32NB 7
|
---|
| 916 | #define IMAGE_REL_I386_SEG12 9
|
---|
| 917 | #define IMAGE_REL_I386_SECTION 10
|
---|
| 918 | #define IMAGE_REL_I386_SECREL 11
|
---|
| 919 | #define IMAGE_REL_I386_REL 20
|
---|
| 920 |
|
---|
| 921 | // MIPS relocation types
|
---|
| 922 | #define IMAGE_REL_MIPS_ABSOLUTE 0x0000
|
---|
| 923 | #define IMAGE_REL_MIPS_REFHALF 0x0001
|
---|
| 924 | #define IMAGE_REL_MIPS_REFWORD 0x0002
|
---|
| 925 | #define IMAGE_REL_MIPS_JMPADDR 0x0003
|
---|
| 926 | #define IMAGE_REL_MIPS_REFHI 0x0004
|
---|
| 927 | #define IMAGE_REL_MIPS_REFLO 0x0005
|
---|
| 928 | #define IMAGE_REL_MIPS_GPREL 0x0006
|
---|
| 929 | #define IMAGE_REL_MIPS_LITERAL 0x0007
|
---|
| 930 | #define IMAGE_REL_MIPS_SECTION 0x000A
|
---|
| 931 | #define IMAGE_REL_MIPS_SECREL 0x000B
|
---|
| 932 | #define IMAGE_REL_MIPS_SECRELLO 0x000C
|
---|
| 933 | #define IMAGE_REL_MIPS_SECRELHI 0x000D
|
---|
| 934 | #define IMAGE_REL_MIPS_JMPADDR16 0x0010
|
---|
| 935 | #define IMAGE_REL_MIPS_REFWORDNB 0x0022
|
---|
| 936 | #define IMAGE_REL_MIPS_PAIR 0x0025
|
---|
| 937 |
|
---|
| 938 | // ALPHA relocation types
|
---|
| 939 | #define IMAGE_REL_ALPHA_ABSOLUTE 0x0000
|
---|
| 940 | #define IMAGE_REL_ALPHA_REFLONG 0x0001
|
---|
| 941 | #define IMAGE_REL_ALPHA_REFQUAD 0x0002
|
---|
| 942 | #define IMAGE_REL_ALPHA_GPREL 0x0003
|
---|
| 943 | #define IMAGE_REL_ALPHA_LITERAL 0x0004
|
---|
| 944 | #define IMAGE_REL_ALPHA_LITUSE 0x0005
|
---|
| 945 | #define IMAGE_REL_ALPHA_GPDISP 0x0006
|
---|
| 946 | #define IMAGE_REL_ALPHA_BRADDR 0x0007
|
---|
| 947 | #define IMAGE_REL_ALPHA_HINT 0x0008
|
---|
| 948 | #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x0009
|
---|
| 949 | #define IMAGE_REL_ALPHA_REFHI 0x000A
|
---|
| 950 | #define IMAGE_REL_ALPHA_REFLO 0x000B
|
---|
| 951 | #define IMAGE_REL_ALPHA_PAIR 0x000C
|
---|
| 952 | #define IMAGE_REL_ALPHA_MATCH 0x000D
|
---|
| 953 | #define IMAGE_REL_ALPHA_SECTION 0x000E
|
---|
| 954 | #define IMAGE_REL_ALPHA_SECREL 0x000F
|
---|
| 955 | #define IMAGE_REL_ALPHA_REFLONGNB 0x0010
|
---|
| 956 | #define IMAGE_REL_ALPHA_SECRELLO 0x0011
|
---|
| 957 | #define IMAGE_REL_ALPHA_SECRELHI 0x0012
|
---|
| 958 | #define IMAGE_REL_ALPHA_REFQ3 0x0013
|
---|
| 959 | #define IMAGE_REL_ALPHA_REFQ2 0x0014
|
---|
| 960 | #define IMAGE_REL_ALPHA_REFQ1 0x0015
|
---|
| 961 | #define IMAGE_REL_ALPHA_GPRELLO 0x0016
|
---|
| 962 | #define IMAGE_REL_ALPHA_GPRELHI 0x0017
|
---|
| 963 |
|
---|
| 964 | // PowerPC relocation types
|
---|
| 965 | #define IMAGE_REL_PPC_ABSOLUTE 0x0000
|
---|
| 966 | #define IMAGE_REL_PPC_ADDR64 0x0001
|
---|
| 967 | #define IMAGE_REL_PPC_ADDR 0x0002
|
---|
| 968 | #define IMAGE_REL_PPC_ADDR24 0x0003
|
---|
| 969 | #define IMAGE_REL_PPC_ADDR16 0x0004
|
---|
| 970 | #define IMAGE_REL_PPC_ADDR14 0x0005
|
---|
| 971 | #define IMAGE_REL_PPC_REL24 0x0006
|
---|
| 972 | #define IMAGE_REL_PPC_REL14 0x0007
|
---|
| 973 | #define IMAGE_REL_PPC_TOCREL16 0x0008
|
---|
| 974 | #define IMAGE_REL_PPC_TOCREL14 0x0009
|
---|
| 975 | #define IMAGE_REL_PPC_ADDR32NB 0x000A
|
---|
| 976 | #define IMAGE_REL_PPC_SECREL 0x000B
|
---|
| 977 | #define IMAGE_REL_PPC_SECTION 0x000C
|
---|
| 978 | #define IMAGE_REL_PPC_IFGLUE 0x000D
|
---|
| 979 | #define IMAGE_REL_PPC_IMGLUE 0x000E
|
---|
| 980 | #define IMAGE_REL_PPC_SECREL16 0x000F
|
---|
| 981 | #define IMAGE_REL_PPC_REFHI 0x0010
|
---|
| 982 | #define IMAGE_REL_PPC_REFLO 0x0011
|
---|
| 983 | #define IMAGE_REL_PPC_PAIR 0x0012
|
---|
| 984 | #define IMAGE_REL_PPC_SECRELLO 0x0013
|
---|
| 985 | #define IMAGE_REL_PPC_SECRELHI 0x0014
|
---|
| 986 | #define IMAGE_REL_PPC_GPREL 0x0015
|
---|
| 987 | #define IMAGE_REL_PPC_TYPEMASK 0x00FF
|
---|
| 988 | // modifier bits
|
---|
| 989 | #define IMAGE_REL_PPC_NEG 0x0100
|
---|
| 990 | #define IMAGE_REL_PPC_BRTAKEN 0x0200
|
---|
| 991 | #define IMAGE_REL_PPC_BRNTAKEN 0x0400
|
---|
| 992 | #define IMAGE_REL_PPC_TOCDEFN 0x0800
|
---|
| 993 |
|
---|
| 994 | // SH3 ? relocation type
|
---|
| 995 | #define IMAGE_REL_SH3_ABSOLUTE 0x0000
|
---|
| 996 | #define IMAGE_REL_SH3_DIRECT16 0x0001
|
---|
| 997 | #define IMAGE_REL_SH3_DIRECT 0x0002
|
---|
| 998 | #define IMAGE_REL_SH3_DIRECT8 0x0003
|
---|
| 999 | #define IMAGE_REL_SH3_DIRECT8_WORD 0x0004
|
---|
| 1000 | #define IMAGE_REL_SH3_DIRECT8_LONG 0x0005
|
---|
| 1001 | #define IMAGE_REL_SH3_DIRECT4 0x0006
|
---|
| 1002 | #define IMAGE_REL_SH3_DIRECT4_WORD 0x0007
|
---|
| 1003 | #define IMAGE_REL_SH3_DIRECT4_LONG 0x0008
|
---|
| 1004 | #define IMAGE_REL_SH3_PCREL8_WORD 0x0009
|
---|
| 1005 | #define IMAGE_REL_SH3_PCREL8_LONG 0x000A
|
---|
| 1006 | #define IMAGE_REL_SH3_PCREL12_WORD 0x000B
|
---|
| 1007 | #define IMAGE_REL_SH3_STARTOF_SECTION 0x000C
|
---|
| 1008 | #define IMAGE_REL_SH3_SIZEOF_SECTION 0x000D
|
---|
| 1009 | #define IMAGE_REL_SH3_SECTION 0x000E
|
---|
| 1010 | #define IMAGE_REL_SH3_SECREL 0x000F
|
---|
| 1011 | #define IMAGE_REL_SH3_DIRECT32_NB 0x0010
|
---|
| 1012 |
|
---|
| 1013 | // ARM (Archimedes?) relocation types
|
---|
| 1014 | #define IMAGE_REL_ARM_ABSOLUTE 0x0000
|
---|
| 1015 | #define IMAGE_REL_ARM_ADDR 0x0001
|
---|
| 1016 | #define IMAGE_REL_ARM_ADDR32NB 0x0002
|
---|
| 1017 | #define IMAGE_REL_ARM_BRANCH24 0x0003
|
---|
| 1018 | #define IMAGE_REL_ARM_BRANCH11 0x0004
|
---|
| 1019 | #define IMAGE_REL_ARM_SECTION 0x000E
|
---|
| 1020 | #define IMAGE_REL_ARM_SECREL 0x000F
|
---|
| 1021 |
|
---|
| 1022 | // IA64 relocation types
|
---|
| 1023 | #define IMAGE_REL_IA64_ABSOLUTE 0x0000
|
---|
| 1024 | #define IMAGE_REL_IA64_IMM14 0x0001
|
---|
| 1025 | #define IMAGE_REL_IA64_IMM22 0x0002
|
---|
| 1026 | #define IMAGE_REL_IA64_IMM64 0x0003
|
---|
| 1027 | #define IMAGE_REL_IA64_DIR 0x0004
|
---|
| 1028 | #define IMAGE_REL_IA64_DIR64 0x0005
|
---|
| 1029 | #define IMAGE_REL_IA64_PCREL21B 0x0006
|
---|
| 1030 | #define IMAGE_REL_IA64_PCREL21M 0x0007
|
---|
| 1031 | #define IMAGE_REL_IA64_PCREL21F 0x0008
|
---|
| 1032 | #define IMAGE_REL_IA64_GPREL22 0x0009
|
---|
| 1033 | #define IMAGE_REL_IA64_LTOFF22 0x000A
|
---|
| 1034 | #define IMAGE_REL_IA64_SECTION 0x000B
|
---|
| 1035 | #define IMAGE_REL_IA64_SECREL22 0x000C
|
---|
| 1036 | #define IMAGE_REL_IA64_SECREL64I 0x000D
|
---|
| 1037 | #define IMAGE_REL_IA64_SECREL 0x000E
|
---|
| 1038 | #define IMAGE_REL_IA64_LTOFF64 0x000F
|
---|
| 1039 | #define IMAGE_REL_IA64_DIR32NB 0x0010
|
---|
| 1040 | #define IMAGE_REL_IA64_RESERVED_11 0x0011
|
---|
| 1041 | #define IMAGE_REL_IA64_RESERVED_12 0x0012
|
---|
| 1042 | #define IMAGE_REL_IA64_RESERVED_13 0x0013
|
---|
| 1043 | #define IMAGE_REL_IA64_RESERVED_14 0x0014
|
---|
| 1044 | #define IMAGE_REL_IA64_RESERVED_15 0x0015
|
---|
| 1045 | #define IMAGE_REL_IA64_RESERVED_16 0x0016
|
---|
| 1046 | #define IMAGE_REL_IA64_ADDEND 0x001F
|
---|
| 1047 |
|
---|
| 1048 | /*
|
---|
| 1049 | *@@ IMAGE_SEPARATE_DEBUG_HEADER:
|
---|
| 1050 | * structure that appears at the very start of a .DBG file.
|
---|
| 1051 | *
|
---|
| 1052 | *@@added V0.9.16 (2002-01-09) [umoeller]
|
---|
| 1053 | */
|
---|
| 1054 |
|
---|
| 1055 | typedef struct _IMAGE_SEPARATE_DEBUG_HEADER
|
---|
| 1056 | {
|
---|
| 1057 | USHORT Signature;
|
---|
| 1058 | USHORT Flags;
|
---|
| 1059 | USHORT Machine;
|
---|
| 1060 | USHORT Characteristics;
|
---|
| 1061 | ULONG TimeDateStamp;
|
---|
| 1062 | ULONG CheckSum;
|
---|
| 1063 | ULONG ImageBase;
|
---|
| 1064 | ULONG SizeOfImage;
|
---|
| 1065 | ULONG NumberOfSections;
|
---|
| 1066 | ULONG ExportedNamesSize;
|
---|
| 1067 | ULONG DebugDirectorySize;
|
---|
| 1068 | ULONG Reserved[ 3 ];
|
---|
| 1069 | } IMAGE_SEPARATE_DEBUG_HEADER,*PIMAGE_SEPARATE_DEBUG_HEADER;
|
---|
| 1070 |
|
---|
| 1071 | #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
|
---|
| 1072 |
|
---|
| 1073 | /*
|
---|
| 1074 | *@@ MESSAGE_RESOURCE_ENTRY:
|
---|
| 1075 | *
|
---|
| 1076 | *@@added V0.9.16 (2002-01-09) [umoeller]
|
---|
| 1077 | */
|
---|
| 1078 |
|
---|
| 1079 | typedef struct tagMESSAGE_RESOURCE_ENTRY
|
---|
| 1080 | {
|
---|
| 1081 | USHORT Length;
|
---|
| 1082 | USHORT Flags;
|
---|
| 1083 | BYTE Text[1];
|
---|
| 1084 | } MESSAGE_RESOURCE_ENTRY,*PMESSAGE_RESOURCE_ENTRY;
|
---|
| 1085 | #define MESSAGE_RESOURCE_UNICODE 0x0001
|
---|
| 1086 |
|
---|
| 1087 | /*
|
---|
| 1088 | *@@ MESSAGE_RESOURCE_BLOCK:
|
---|
| 1089 | *
|
---|
| 1090 | *@@added V0.9.16 (2002-01-09) [umoeller]
|
---|
| 1091 | */
|
---|
| 1092 |
|
---|
| 1093 | typedef struct tagMESSAGE_RESOURCE_BLOCK
|
---|
| 1094 | {
|
---|
| 1095 | ULONG LowId;
|
---|
| 1096 | ULONG HighId;
|
---|
| 1097 | ULONG OffsetToEntries;
|
---|
| 1098 | } MESSAGE_RESOURCE_BLOCK, *PMESSAGE_RESOURCE_BLOCK;
|
---|
| 1099 |
|
---|
| 1100 | /*
|
---|
| 1101 | *@@ MESSAGE_RESOURCE_DATA:
|
---|
| 1102 | *
|
---|
| 1103 | *@@added V0.9.16 (2002-01-09) [umoeller]
|
---|
| 1104 | */
|
---|
| 1105 |
|
---|
| 1106 | typedef struct tagMESSAGE_RESOURCE_DATA
|
---|
| 1107 | {
|
---|
| 1108 | ULONG NumberOfBlocks;
|
---|
| 1109 | MESSAGE_RESOURCE_BLOCK Blocks[ 1 ];
|
---|
| 1110 | } MESSAGE_RESOURCE_DATA,*PMESSAGE_RESOURCE_DATA;
|
---|
| 1111 |
|
---|
| 1112 | /*
|
---|
| 1113 | *@@ IMAGE_IMPORT_MODULE_DIRECTORY:
|
---|
| 1114 | *
|
---|
| 1115 | *@@added V0.9.16 (2002-01-09) [umoeller]
|
---|
| 1116 | */
|
---|
| 1117 |
|
---|
| 1118 | typedef struct _IMAGE_IMPORT_MODULE_DIRECTORY // tagImportDirectory
|
---|
| 1119 | {
|
---|
| 1120 | ULONG dwRVAFunctionNameList;
|
---|
| 1121 | ULONG dwUseless1;
|
---|
| 1122 | ULONG dwUseless2;
|
---|
| 1123 | ULONG dwRVAModuleName;
|
---|
| 1124 | ULONG dwRVAFunctionAddressList;
|
---|
| 1125 | } IMAGE_IMPORT_MODULE_DIRECTORY, *PIMAGE_IMPORT_MODULE_DIRECTORY;
|
---|
| 1126 |
|
---|
| 1127 | #pragma pack()
|
---|
| 1128 |
|
---|
| 1129 | /********************************************************************
|
---|
| 1130 | *
|
---|
| 1131 | * Declarations and APIs
|
---|
| 1132 | *
|
---|
| 1133 | ********************************************************************/
|
---|
| 1134 |
|
---|
[130] | 1135 | #ifndef __STRIP_DOWN_EXECUTABLE__
|
---|
| 1136 | // for mini stubs in warpin, which has its own
|
---|
| 1137 | // implementation of this
|
---|
| 1138 |
|
---|
| 1139 | /*
|
---|
| 1140 | *@@ EXECUTABLE:
|
---|
| 1141 | * structure used with all the exeh*
|
---|
| 1142 | * functions.
|
---|
| 1143 | */
|
---|
| 1144 |
|
---|
| 1145 | typedef struct _EXECUTABLE
|
---|
| 1146 | {
|
---|
| 1147 | // executable opened by doshOpen;
|
---|
[131] | 1148 | // note, NULL for .COM, .BAT, .CMD files (V0.9.16)
|
---|
[130] | 1149 | PXFILE pFile;
|
---|
| 1150 |
|
---|
| 1151 | // Most of the following fields are set by
|
---|
| 1152 | // exehOpen if NO_ERROR is returned:
|
---|
| 1153 |
|
---|
| 1154 | // old DOS EXE header;
|
---|
| 1155 | // warning, this is NULL if
|
---|
| 1156 | // -- the executable has a new header only
|
---|
| 1157 | // (NOSTUB, V0.9.12);
|
---|
| 1158 | // -- for .COM, .BAT, .CMD files (V0.9.16)
|
---|
[257] | 1159 | DOSEXEHEADER DosExeHeader; // no longer a ptr, but inline struct V1.0.2 (2003-11-13) [umoeller]
|
---|
| 1160 | ULONG cbDosExeHeader; // if != 0, DosExeHeader is present
|
---|
[130] | 1161 |
|
---|
| 1162 | // New Executable (NE) header, if ulExeFormat == EXEFORMAT_NE
|
---|
| 1163 | PNEHEADER pNEHeader;
|
---|
| 1164 | ULONG cbNEHeader;
|
---|
| 1165 |
|
---|
| 1166 | // Linear Executable (LX) header, if ulExeFormat == EXEFORMAT_LX
|
---|
| 1167 | PLXHEADER pLXHeader;
|
---|
| 1168 | ULONG cbLXHeader;
|
---|
| 1169 |
|
---|
| 1170 | // Portable Executable (PE) header, if ulExeFormat == EXEFORMAT_PE
|
---|
| 1171 | PPEHEADER pPEHeader;
|
---|
| 1172 | ULONG cbPEHeader;
|
---|
[131] | 1173 | // note, this one may vary; however, all Win32 programs
|
---|
| 1174 | // will have sizeof(PEHEADER) in here since they all
|
---|
| 1175 | // use both the standard and the optional PE header
|
---|
[130] | 1176 |
|
---|
[131] | 1177 | // module analysis (always set, otherwise error would be
|
---|
| 1178 | // returned by exehOpen):
|
---|
[130] | 1179 | ULONG ulExeFormat;
|
---|
[136] | 1180 | #endif
|
---|
[131] | 1181 | #define EXEFORMAT_OLDDOS 1
|
---|
| 1182 | #define EXEFORMAT_NE 2
|
---|
| 1183 | #define EXEFORMAT_PE 3
|
---|
| 1184 | #define EXEFORMAT_LX 4
|
---|
| 1185 | #define EXEFORMAT_TEXT_BATCH 5
|
---|
| 1186 | #define EXEFORMAT_TEXT_CMD 6 // REXX or plain OS/2 batch
|
---|
| 1187 | #define EXEFORMAT_COM 7 // added V0.9.16 (2002-01-04) [umoeller]
|
---|
[130] | 1188 |
|
---|
[136] | 1189 | #ifndef __STRIP_DOWN_EXECUTABLE__
|
---|
[130] | 1190 | BOOL fLibrary, // TRUE if this is a DLL
|
---|
[131] | 1191 | // (works for NE, LX, PE)
|
---|
[130] | 1192 | f32Bits; // TRUE if this a 32-bits module
|
---|
[131] | 1193 | // (TRUE always for PE)
|
---|
[130] | 1194 |
|
---|
| 1195 | ULONG ulOS;
|
---|
[136] | 1196 | #endif
|
---|
[130] | 1197 | // target operating system as flagged in one of
|
---|
| 1198 | // the EXE headers; one of:
|
---|
[131] | 1199 | #define EXEOS_UNKNOWN 0
|
---|
| 1200 | // set for non-standard PE files too
|
---|
| 1201 | #define EXEOS_DOS3 1
|
---|
| 1202 | #define EXEOS_DOS4 2
|
---|
| 1203 | // there is a flag for this in NE
|
---|
| 1204 | #define EXEOS_OS2 3
|
---|
| 1205 | #define EXEOS_WIN16 4
|
---|
| 1206 | #define EXEOS_WIN386 5
|
---|
| 1207 | // according to IBM, there are flags
|
---|
| 1208 | // for this both in NE and LX
|
---|
| 1209 | #define EXEOS_WIN32_GUI 6
|
---|
| 1210 | // Win32 GUI (see IMAGE_OPTIONAL_HEADER.usSubsystem),
|
---|
| 1211 | // if PE optional header was successfully read
|
---|
| 1212 | #define EXEOS_WIN32_CLI 7
|
---|
| 1213 | // Win32 command line (see IMAGE_OPTIONAL_HEADER.usSubsystem),
|
---|
| 1214 | // if PE optional header was successfully read
|
---|
[130] | 1215 |
|
---|
[136] | 1216 | #ifndef __STRIP_DOWN_EXECUTABLE__
|
---|
[130] | 1217 | // The following fields are only set after
|
---|
[131] | 1218 | // an extra call to exehQueryBldLevel (NE and LX only):
|
---|
[130] | 1219 |
|
---|
| 1220 | PSZ pszDescription;
|
---|
| 1221 | // whole string (first non-res name tbl entry)
|
---|
| 1222 | PSZ pszVendor;
|
---|
| 1223 | // vendor substring (if IBM BLDLEVEL format)
|
---|
| 1224 | PSZ pszVersion;
|
---|
| 1225 | // version substring (if IBM BLDLEVEL format)
|
---|
| 1226 |
|
---|
| 1227 | PSZ pszInfo;
|
---|
| 1228 | // module info substring (if IBM BLDLEVEL format)
|
---|
| 1229 |
|
---|
| 1230 | // if pszInfo is extended DESCRIPTION field, the following
|
---|
| 1231 | // are set as well:
|
---|
| 1232 | PSZ pszBuildDateTime,
|
---|
| 1233 | pszBuildMachine,
|
---|
| 1234 | pszASD,
|
---|
| 1235 | pszLanguage,
|
---|
| 1236 | pszCountry,
|
---|
| 1237 | pszRevision,
|
---|
| 1238 | pszUnknown,
|
---|
| 1239 | pszFixpak;
|
---|
| 1240 |
|
---|
[131] | 1241 | // the following fields are set after exehLoadLXMaps (LX only)
|
---|
[130] | 1242 | BOOL fLXMapsLoaded; // TRUE after good exehLoadLXMaps
|
---|
| 1243 | RESOURCETABLEENTRY *pRsTbl; // pLXHeader->ulResTblCnt
|
---|
| 1244 | OBJECTTABLEENTRY *pObjTbl; // pLXHeader->ulObjCount
|
---|
| 1245 | OBJECTPAGETABLEENTRY *pObjPageTbl; // pLXHeader->ulPageCount
|
---|
| 1246 |
|
---|
[131] | 1247 | // the following fields are set after exehLoadOS2NEMaps (OS/2 NE only)
|
---|
[130] | 1248 | BOOL fOS2NEMapsLoaded; // TRUE after good exehLoadOS2NEMaps
|
---|
| 1249 | POS2NERESTBLENTRY paOS2NEResTblEntry;
|
---|
| 1250 | POS2NESEGMENT paOS2NESegments;
|
---|
| 1251 | } EXECUTABLE, *PEXECUTABLE;
|
---|
| 1252 |
|
---|
| 1253 | APIRET exehOpen(const char* pcszExecutable,
|
---|
| 1254 | PEXECUTABLE* ppExec);
|
---|
| 1255 |
|
---|
| 1256 | APIRET exehQueryBldLevel(PEXECUTABLE pExec);
|
---|
| 1257 |
|
---|
[242] | 1258 | #ifdef INCL_WINPROGRAMLIST
|
---|
| 1259 |
|
---|
| 1260 | // additional PROG_* flags for exehQueryProgType; moved these here
|
---|
| 1261 | // from app.h V1.0.1 (2003-01-17) [umoeller]
|
---|
| 1262 |
|
---|
| 1263 | // #define PROG_XWP_DLL 998 // dynamic link library
|
---|
| 1264 | // removed, PROG_DLL exists already
|
---|
| 1265 | // V0.9.16 (2001-10-06)
|
---|
| 1266 |
|
---|
| 1267 | #define PROG_WIN32 990 // added V0.9.16 (2001-12-08) [umoeller]
|
---|
| 1268 |
|
---|
| 1269 | APIRET exehQueryProgType(const EXECUTABLE *pExec,
|
---|
| 1270 | PROGCATEGORY *pulProgType);
|
---|
| 1271 |
|
---|
| 1272 | PCSZ exehDescribeProgType(PROGCATEGORY progc);
|
---|
| 1273 |
|
---|
| 1274 | #endif
|
---|
| 1275 |
|
---|
[130] | 1276 | /*
|
---|
| 1277 | *@@ FSYSMODULE:
|
---|
| 1278 | *
|
---|
| 1279 | *@@added V0.9.9 (2001-03-11) [lafaix]
|
---|
| 1280 | */
|
---|
| 1281 |
|
---|
| 1282 | typedef struct _FSYSMODULE
|
---|
| 1283 | {
|
---|
| 1284 | CHAR achModuleName[256];
|
---|
| 1285 | } FSYSMODULE, *PFSYSMODULE;
|
---|
| 1286 |
|
---|
| 1287 | APIRET exehQueryImportedModules(PEXECUTABLE pExec,
|
---|
| 1288 | PFSYSMODULE *ppaModules,
|
---|
| 1289 | PULONG pcModules);
|
---|
| 1290 |
|
---|
| 1291 | APIRET exehFreeImportedModules(PFSYSMODULE paModules);
|
---|
| 1292 |
|
---|
| 1293 | /*
|
---|
| 1294 | *@@ FSYSFUNCTION:
|
---|
| 1295 | *
|
---|
| 1296 | *@@added V0.9.9 (2001-03-11) [lafaix]
|
---|
| 1297 | */
|
---|
| 1298 |
|
---|
| 1299 | typedef struct _FSYSFUNCTION
|
---|
| 1300 | {
|
---|
| 1301 | ULONG ulOrdinal;
|
---|
| 1302 | ULONG ulType;
|
---|
| 1303 | CHAR achFunctionName[256];
|
---|
| 1304 | } FSYSFUNCTION, *PFSYSFUNCTION;
|
---|
| 1305 |
|
---|
| 1306 | APIRET exehQueryExportedFunctions(PEXECUTABLE pExec,
|
---|
| 1307 | PFSYSFUNCTION *ppaFunctions,
|
---|
| 1308 | PULONG pcFunctions);
|
---|
| 1309 |
|
---|
| 1310 | APIRET exehFreeExportedFunctions(PFSYSFUNCTION paFunctions);
|
---|
| 1311 |
|
---|
| 1312 | #define WINRT_CURSOR 1
|
---|
| 1313 | #define WINRT_BITMAP 2
|
---|
| 1314 | #define WINRT_ICON 3
|
---|
| 1315 | #define WINRT_MENU 4
|
---|
| 1316 | #define WINRT_DIALOG 5
|
---|
| 1317 | #define WINRT_STRING 6
|
---|
| 1318 | #define WINRT_FONTDIR 7
|
---|
| 1319 | #define WINRT_FONT 8
|
---|
| 1320 | #define WINRT_ACCELERATOR 9
|
---|
| 1321 | #define WINRT_RCDATA 10
|
---|
[131] | 1322 | #define WINRT_MESSAGELIST 11 // Win32
|
---|
| 1323 | #define WINRT_GROUP_CURSOR 12 // Win32
|
---|
| 1324 | #define WINRT_GROUP_ICON 13 // Win32
|
---|
[130] | 1325 |
|
---|
| 1326 | /*
|
---|
| 1327 | *@@ FSYSRESOURCE:
|
---|
| 1328 | *
|
---|
| 1329 | *@@added V0.9.7 (2000-12-18) [lafaix]
|
---|
| 1330 | */
|
---|
| 1331 |
|
---|
| 1332 | typedef struct _FSYSRESOURCE
|
---|
| 1333 | {
|
---|
| 1334 | ULONG ulID; // resource ID
|
---|
| 1335 | ULONG ulType; // resource type
|
---|
| 1336 | ULONG ulSize; // resource size in bytes
|
---|
| 1337 | ULONG ulFlag; // resource flags
|
---|
| 1338 |
|
---|
| 1339 | } FSYSRESOURCE, *PFSYSRESOURCE;
|
---|
| 1340 |
|
---|
| 1341 | APIRET exehQueryResources(PEXECUTABLE pExec,
|
---|
| 1342 | PFSYSRESOURCE *ppaResources,
|
---|
| 1343 | PULONG pcResources);
|
---|
| 1344 |
|
---|
| 1345 | APIRET exehFreeResources(PFSYSRESOURCE paResources);
|
---|
| 1346 |
|
---|
| 1347 | APIRET exehLoadLXMaps(PEXECUTABLE pExec);
|
---|
| 1348 |
|
---|
| 1349 | VOID exehFreeLXMaps(PEXECUTABLE pExec);
|
---|
| 1350 |
|
---|
| 1351 | APIRET exehLoadLXResource(PEXECUTABLE pExec,
|
---|
| 1352 | ULONG ulType,
|
---|
| 1353 | ULONG idResource,
|
---|
| 1354 | PBYTE *ppbResData,
|
---|
[257] | 1355 | PULONG pulOffset,
|
---|
[130] | 1356 | PULONG pcbResData);
|
---|
| 1357 |
|
---|
| 1358 | APIRET exehLoadOS2NEMaps(PEXECUTABLE pExec);
|
---|
| 1359 |
|
---|
| 1360 | VOID exehFreeNEMaps(PEXECUTABLE pExec);
|
---|
| 1361 |
|
---|
| 1362 | APIRET exehLoadOS2NEResource(PEXECUTABLE pExec,
|
---|
| 1363 | ULONG ulType,
|
---|
| 1364 | ULONG idResource,
|
---|
| 1365 | PBYTE *ppbResData,
|
---|
| 1366 | PULONG pcbResData);
|
---|
| 1367 |
|
---|
| 1368 | APIRET exehClose(PEXECUTABLE *ppExec);
|
---|
| 1369 |
|
---|
| 1370 | #endif
|
---|
| 1371 |
|
---|
| 1372 | #endif
|
---|
| 1373 |
|
---|
| 1374 | #if __cplusplus
|
---|
| 1375 | }
|
---|
| 1376 | #endif
|
---|
| 1377 |
|
---|