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