[2826] | 1 | /* $Id: kLdr.h 3525 2007-08-19 22:14:55Z bird $ */
|
---|
[2821] | 2 | /** @file
|
---|
| 3 | *
|
---|
| 4 | * kLdr - The Dynamic Loader.
|
---|
| 5 | *
|
---|
| 6 | * Copyright (c) 2006 knut st. osmundsen <bird@anduin.net>
|
---|
| 7 | *
|
---|
| 8 | *
|
---|
| 9 | * This file is part of kLdr.
|
---|
| 10 | *
|
---|
| 11 | * kLdr is free software; you can redistribute it and/or modify
|
---|
| 12 | * it under the terms of the GNU General Public License as published by
|
---|
| 13 | * the Free Software Foundation; either version 2 of the License, or
|
---|
| 14 | * (at your option) any later version.
|
---|
| 15 | *
|
---|
| 16 | * kLdr is distributed in the hope that it will be useful,
|
---|
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | * GNU General Public License for more details.
|
---|
| 20 | *
|
---|
| 21 | * You should have received a copy of the GNU General Public License
|
---|
| 22 | * along with kLdr; if not, write to the Free Software
|
---|
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
| 24 | *
|
---|
| 25 | */
|
---|
| 26 |
|
---|
[3525] | 27 | #ifndef ___kLdr_h___
|
---|
| 28 | #define ___kLdr_h___
|
---|
[2821] | 29 |
|
---|
| 30 | #ifdef __cplusplus
|
---|
| 31 | extern "C" {
|
---|
| 32 | #endif
|
---|
| 33 |
|
---|
[2952] | 34 | /*
|
---|
[3525] | 35 | * Include the base typedefs and macros.
|
---|
[2944] | 36 | */
|
---|
[3525] | 37 | #include "kLdrBase.h"
|
---|
[2821] | 38 |
|
---|
[2824] | 39 |
|
---|
[2963] | 40 | /** @defgroup grp_kLdrBasic kLdr Basic Types
|
---|
[2825] | 41 | * @{ */
|
---|
[2821] | 42 |
|
---|
[2848] | 43 | /** The kLdr address type. */
|
---|
| 44 | typedef uint64_t KLDRADDR;
|
---|
| 45 | /** Pointer to a kLdr address. */
|
---|
| 46 | typedef KLDRADDR *PKLDRADDR;
|
---|
| 47 | /** Pointer to a const kLdr address. */
|
---|
| 48 | typedef const KLDRADDR *PCKLDRADDR;
|
---|
| 49 |
|
---|
| 50 | /** NIL address. */
|
---|
| 51 | #define NIL_KLDRADDR (~(uint64_t)0)
|
---|
| 52 |
|
---|
[2859] | 53 | /** @def PRI_KLDRADDR
|
---|
| 54 | * printf format type. */
|
---|
| 55 | #ifdef _MSC_VER
|
---|
| 56 | # define PRI_KLDRADDR "I64x"
|
---|
| 57 | #else
|
---|
| 58 | # define PRI_KLDRADDR "llx"
|
---|
| 59 | #endif
|
---|
| 60 |
|
---|
| 61 |
|
---|
[2848] | 62 | /** The kLdr size type. */
|
---|
| 63 | typedef uint64_t KLDRSIZE;
|
---|
| 64 | /** Pointer to a kLdr size. */
|
---|
| 65 | typedef KLDRSIZE *PKLDRSIZE;
|
---|
| 66 | /** Pointer to a const kLdr size. */
|
---|
| 67 | typedef const KLDRSIZE *PCKLDRSIZE;
|
---|
| 68 |
|
---|
[2859] | 69 | /** @def PRI_KLDRSIZE
|
---|
| 70 | * printf format type. */
|
---|
| 71 | #ifdef _MSC_VER
|
---|
| 72 | # define PRI_KLDRSIZE "I64x"
|
---|
| 73 | #else
|
---|
| 74 | # define PRI_KLDRSIZE "llx"
|
---|
| 75 | #endif
|
---|
[2848] | 76 |
|
---|
| 77 |
|
---|
[2974] | 78 | /** The kLdr file offset type. */
|
---|
| 79 | typedef long KLDRFOFF;
|
---|
| 80 | /** Pointer to a kLdr file offset type. */
|
---|
| 81 | typedef KLDRFOFF *PKLDRFOFF;
|
---|
| 82 | /** Pointer to a const kLdr file offset type. */
|
---|
| 83 | typedef const KLDRFOFF *PCKLDRFOFF;
|
---|
| 84 |
|
---|
| 85 | /** @def PRI_KLDRFOFF
|
---|
| 86 | * printf format type. */
|
---|
| 87 | #define PRI_KLDRFOFF "lx"
|
---|
| 88 |
|
---|
| 89 |
|
---|
[2963] | 90 | /**
|
---|
| 91 | * Union of all the integer types.
|
---|
| 92 | */
|
---|
| 93 | typedef union KLDRU
|
---|
| 94 | {
|
---|
| 95 | int8_t i8; /**< int8_t view. */
|
---|
| 96 | uint8_t u8; /**< uint8_t view. */
|
---|
| 97 | int16_t i16; /**< int16_t view. */
|
---|
| 98 | uint16_t u16; /**< uint16_t view. */
|
---|
| 99 | int32_t i32; /**< int32_t view. */
|
---|
| 100 | uint32_t u32; /**< uint32_t view. */
|
---|
| 101 | int64_t i64; /**< int64_t view. */
|
---|
| 102 | uint64_t u64; /**< uint64_t view. */
|
---|
[2859] | 103 |
|
---|
[2963] | 104 | int8_t ai8[8]; /**< int8_t array view . */
|
---|
| 105 | uint8_t au8[8]; /**< uint8_t array view. */
|
---|
| 106 | int16_t ai16[4];/**< int16_t array view . */
|
---|
| 107 | uint16_t au16[4];/**< uint16_t array view. */
|
---|
| 108 | int32_t ai32[2];/**< int32_t array view . */
|
---|
| 109 | uint32_t au32[2];/**< uint32_t array view. */
|
---|
[2861] | 110 |
|
---|
[2963] | 111 | signed char ch; /**< signed char view. */
|
---|
| 112 | unsigned char uch; /**< unsigned char view. */
|
---|
| 113 | signed short s; /**< signed short view. */
|
---|
| 114 | unsigned short us; /**< unsigned short view. */
|
---|
| 115 | signed int i; /**< signed int view. */
|
---|
| 116 | unsigned int u; /**< unsigned int view. */
|
---|
| 117 | signed long l; /**< signed long view. */
|
---|
| 118 | unsigned long ul; /**< unsigned long view. */
|
---|
| 119 | void *pv; /**< void pointer view. */
|
---|
[2861] | 120 |
|
---|
[2963] | 121 | KLDRADDR Addr; /**< kLdr address view. */
|
---|
| 122 | KLDRSIZE Size; /**< kLdr size view. */
|
---|
| 123 | } KLDRU;
|
---|
| 124 | /** Pointer to an integer union. */
|
---|
| 125 | typedef KLDRU *PKLDRU;
|
---|
| 126 | /** Pointer to a const integer union. */
|
---|
| 127 | typedef const KLDRU *PCKLDRU;
|
---|
| 128 |
|
---|
| 129 |
|
---|
[2840] | 130 | /**
|
---|
[2963] | 131 | * Union of pointers to all the integer types.
|
---|
| 132 | */
|
---|
| 133 | typedef union KLDRPU
|
---|
| 134 | {
|
---|
| 135 | int8_t *pi8; /**< int8_t view. */
|
---|
| 136 | uint8_t *pu8; /**< uint8_t view. */
|
---|
| 137 | int16_t *pi16; /**< int16_t view. */
|
---|
| 138 | uint16_t *pu16; /**< uint16_t view. */
|
---|
| 139 | int32_t *pi32; /**< int32_t view. */
|
---|
| 140 | uint32_t *pu32; /**< uint32_t view. */
|
---|
| 141 | int64_t *pi64; /**< int64_t view. */
|
---|
| 142 | uint64_t *pu64; /**< uint64_t view. */
|
---|
| 143 |
|
---|
| 144 | signed char *pch; /**< signed char view. */
|
---|
| 145 | unsigned char *puch; /**< unsigned char view. */
|
---|
| 146 | signed short *ps; /**< signed short view. */
|
---|
| 147 | unsigned short *pus; /**< unsigned short view. */
|
---|
| 148 | signed int *pi; /**< signed int view. */
|
---|
| 149 | unsigned int *pu; /**< unsigned int view. */
|
---|
| 150 | signed long *pl; /**< signed long view. */
|
---|
| 151 | unsigned long *pul; /**< unsigned long view. */
|
---|
| 152 | void *pv; /**< void pointer view. */
|
---|
| 153 | } KLDRPU;
|
---|
| 154 | /** Pointer to an integer pointer union. */
|
---|
| 155 | typedef KLDRPU *PKLDRPU;
|
---|
| 156 | /** Pointer to a const integer pointer union. */
|
---|
| 157 | typedef const KLDRPU *PCKLDRPU;
|
---|
| 158 |
|
---|
| 159 |
|
---|
| 160 | /**
|
---|
[2840] | 161 | * Memory Mapping Protections.
|
---|
| 162 | *
|
---|
| 163 | * @remark Shared segments can be mapped using the non copy-on-write variant.
|
---|
| 164 | * (Normally the copy-on-write variant is used because changes must
|
---|
| 165 | * be private and not shared with other processes mapping the file.)
|
---|
| 166 | */
|
---|
[2829] | 167 | typedef enum KLDRPROT
|
---|
| 168 | {
|
---|
| 169 | /** The usual invalid 0. */
|
---|
| 170 | KLDRPROT_INVALID = 0,
|
---|
| 171 | /** No access (page not present). */
|
---|
| 172 | KLDRPROT_NOACCESS,
|
---|
| 173 | /** Read only. */
|
---|
| 174 | KLDRPROT_READONLY,
|
---|
| 175 | /** Read & write. */
|
---|
| 176 | KLDRPROT_READWRITE,
|
---|
| 177 | /** Read & copy on write. */
|
---|
| 178 | KLDRPROT_WRITECOPY,
|
---|
| 179 | /** Execute only. */
|
---|
| 180 | KLDRPROT_EXECUTE,
|
---|
| 181 | /** Execute & read. */
|
---|
[2830] | 182 | KLDRPROT_EXECUTE_READ,
|
---|
[2829] | 183 | /** Execute, read & write. */
|
---|
| 184 | KLDRPROT_EXECUTE_READWRITE,
|
---|
| 185 | /** Execute, read & copy on write. */
|
---|
| 186 | KLDRPROT_EXECUTE_WRITECOPY,
|
---|
| 187 | /** The usual end value. (exclusive) */
|
---|
| 188 | KLDRPROT_END,
|
---|
| 189 | /** Blow the type up to 32-bits. */
|
---|
| 190 | KLDRPROT_32BIT_HACK = 0x7fffffff
|
---|
| 191 | } KLDRPROT;
|
---|
| 192 |
|
---|
[2963] | 193 | /** Pointer to a loader segment. */
|
---|
| 194 | typedef struct KLDRSEG *PKLDRSEG;
|
---|
| 195 | /** Pointer to a loader segment. */
|
---|
| 196 | typedef const struct KLDRSEG *PCKLDRSEG;
|
---|
[2829] | 197 |
|
---|
[2963] | 198 | /** @} */
|
---|
| 199 |
|
---|
| 200 |
|
---|
| 201 | /** @defgroup grp_kLdrRdr kLdrRdr - The file provider
|
---|
| 202 | * @{ */
|
---|
| 203 |
|
---|
[2825] | 204 | /** Pointer to a file provider instance core. */
|
---|
| 205 | typedef struct KLDRRDR *PKLDRRDR;
|
---|
| 206 | /** Pointer to a file provider instance core pointer. */
|
---|
| 207 | typedef struct KLDRRDR **PPKLDRRDR;
|
---|
| 208 |
|
---|
[2821] | 209 | /**
|
---|
[2825] | 210 | * File provider instance operations.
|
---|
| 211 | */
|
---|
| 212 | typedef struct KLDRRDROPS
|
---|
| 213 | {
|
---|
| 214 | /** The name of this file provider. */
|
---|
| 215 | const char *pszName;
|
---|
| 216 | /** Pointer to the next file provider. */
|
---|
| 217 | const struct KLDRRDROPS *pNext;
|
---|
| 218 |
|
---|
| 219 | /** Try create a new file provider instance.
|
---|
| 220 | *
|
---|
| 221 | * @returns 0 on success, OS specific error code on failure.
|
---|
| 222 | * @param ppRdr Where to store the file provider instance.
|
---|
| 223 | * @param pszFilename The filename to open.
|
---|
| 224 | */
|
---|
| 225 | int (* pfnCreate)( PPKLDRRDR ppRdr, const char *pszFilename);
|
---|
| 226 | /** Destroy the file provider instance.
|
---|
| 227 | *
|
---|
| 228 | * @returns 0 on success, OS specific error code on failure.
|
---|
| 229 | * On failure, the file provider instance will be in an indeterminate state - don't touch it!
|
---|
| 230 | * @param pRdr The file provider instance.
|
---|
| 231 | */
|
---|
| 232 | int (* pfnDestroy)( PKLDRRDR pRdr);
|
---|
[2856] | 233 | /** @copydoc kLdrRdrRead */
|
---|
[2974] | 234 | int (* pfnRead)( PKLDRRDR pRdr, void *pvBuf, size_t cb, KLDRFOFF off);
|
---|
[2856] | 235 | /** @copydoc kLdrRdrAllMap */
|
---|
[2825] | 236 | int (* pfnAllMap)( PKLDRRDR pRdr, const void **ppvBits);
|
---|
[2856] | 237 | /** @copydoc kLdrRdrAllUnmap */
|
---|
[2825] | 238 | int (* pfnAllUnmap)(PKLDRRDR pRdr, const void *pvBits);
|
---|
[2856] | 239 | /** @copydoc kLdrRdrSize */
|
---|
[2974] | 240 | KLDRFOFF (* pfnSize)( PKLDRRDR pRdr);
|
---|
[2856] | 241 | /** @copydoc kLdrRdrTell */
|
---|
[2974] | 242 | KLDRFOFF (* pfnTell)( PKLDRRDR pRdr);
|
---|
[2856] | 243 | /** @copydoc kLdrRdrName */
|
---|
[2825] | 244 | const char * (* pfnName)(PKLDRRDR pRdr);
|
---|
[2856] | 245 | /** @copydoc kLdrRdrPageSize */
|
---|
| 246 | size_t (* pfnPageSize)(PKLDRRDR pRdr);
|
---|
| 247 | /** @copydoc kLdrRdrMap */
|
---|
[2861] | 248 | int (* pfnMap)( PKLDRRDR pRdr, void **ppvBase, uint32_t cSegments, PCKLDRSEG paSegments, unsigned fFixed);
|
---|
| 249 | /** @copydoc kLdrRdrRefresh */
|
---|
| 250 | int (* pfnRefresh)( PKLDRRDR pRdr, void *pvBase, uint32_t cSegments, PCKLDRSEG paSegments);
|
---|
[2856] | 251 | /** @copydoc kLdrRdrProtect */
|
---|
[2861] | 252 | int (* pfnProtect)( PKLDRRDR pRdr, void *pvBase, uint32_t cSegments, PCKLDRSEG paSegments, unsigned fUnprotectOrProtect);
|
---|
[2856] | 253 | /** @copydoc kLdrRdrUnmap */
|
---|
[2861] | 254 | int (* pfnUnmap)( PKLDRRDR pRdr, void *pvBase, uint32_t cSegments, PCKLDRSEG paSegments);
|
---|
[2856] | 255 | /** @copydoc kLdrRdrDone */
|
---|
[2861] | 256 | void (* pfnDone)( PKLDRRDR pRdr);
|
---|
[2829] | 257 | /** The usual non-zero dummy that makes sure we've initialized all members. */
|
---|
| 258 | uint32_t u32Dummy;
|
---|
[2825] | 259 | } KLDRRDROPS;
|
---|
| 260 | /** Pointer to file provider operations. */
|
---|
| 261 | typedef KLDRRDROPS *PKLDRRDROPS;
|
---|
| 262 | /** Pointer to const file provider operations. */
|
---|
| 263 | typedef const KLDRRDROPS *PCKLDRRDROPS;
|
---|
| 264 |
|
---|
| 265 |
|
---|
| 266 | /**
|
---|
| 267 | * File provider instance core.
|
---|
| 268 | */
|
---|
| 269 | typedef struct KLDRRDR
|
---|
| 270 | {
|
---|
[2856] | 271 | /** Magic number (KLDRRDR_MAGIC). */
|
---|
| 272 | uint32_t u32Magic;
|
---|
[2825] | 273 | /** Pointer to the file provider operations. */
|
---|
| 274 | PCKLDRRDROPS pOps;
|
---|
| 275 | } KLDRRDR;
|
---|
| 276 |
|
---|
[2856] | 277 | /** The magic for KLDRRDR::u32Magic. (Katsu Aki (Katsuaki Nakamura)) */
|
---|
| 278 | #define KLDRRDR_MAGIC 0x19610919
|
---|
| 279 |
|
---|
[2825] | 280 | void kLdrRdrAddProvider(PKLDRRDROPS pAdd);
|
---|
| 281 |
|
---|
| 282 | int kLdrRdrOpen( PPKLDRRDR ppRdr, const char *pszFilename);
|
---|
| 283 | int kLdrRdrClose( PKLDRRDR pRdr);
|
---|
[2974] | 284 | int kLdrRdrRead( PKLDRRDR pRdr, void *pvBuf, size_t cb, KLDRFOFF off);
|
---|
[2825] | 285 | int kLdrRdrAllMap( PKLDRRDR pRdr, const void **ppvBits);
|
---|
| 286 | int kLdrRdrAllUnmap(PKLDRRDR pRdr, const void *pvBits);
|
---|
[2974] | 287 | KLDRFOFF kLdrRdrSize( PKLDRRDR pRdr);
|
---|
| 288 | KLDRFOFF kLdrRdrTell( PKLDRRDR pRdr);
|
---|
[2825] | 289 | const char *kLdrRdrName(PKLDRRDR pRdr);
|
---|
[2856] | 290 | size_t kLdrRdrPageSize(PKLDRRDR pRdr);
|
---|
[2861] | 291 | int kLdrRdrMap( PKLDRRDR pRdr, void **ppvBase, uint32_t cSegments, PCKLDRSEG paSegments, unsigned fFixed);
|
---|
| 292 | int kLdrRdrRefresh( PKLDRRDR pRdr, void *pvBase, uint32_t cSegments, PCKLDRSEG paSegments);
|
---|
| 293 | int kLdrRdrProtect( PKLDRRDR pRdr, void *pvBase, uint32_t cSegments, PCKLDRSEG paSegments, unsigned fUnprotectOrProtect);
|
---|
| 294 | int kLdrRdrUnmap( PKLDRRDR pRdr, void *pvBase, uint32_t cSegments, PCKLDRSEG paSegments);
|
---|
[2856] | 295 | void kLdrRdrDone( PKLDRRDR pRdr);
|
---|
[2825] | 296 |
|
---|
| 297 | /** @} */
|
---|
| 298 |
|
---|
| 299 |
|
---|
| 300 |
|
---|
| 301 | /** @defgroup grp_kLdrMod kLdrMod - The executable image intepreter
|
---|
| 302 | * @{ */
|
---|
| 303 |
|
---|
[2855] | 304 | /**
|
---|
| 305 | * CPU Architecture.
|
---|
| 306 | * @todo Double check the non intel architectures.
|
---|
| 307 | */
|
---|
| 308 | typedef enum KLDRARCH
|
---|
| 309 | {
|
---|
| 310 | /** The usual invalid one. */
|
---|
| 311 | KLDRARCH_INVALID = 0,
|
---|
| 312 | /** Clone or Intel 16-bit x86. */
|
---|
| 313 | KLDRARCH_X86_16,
|
---|
| 314 | /** Clone or Intel 32-bit x86. */
|
---|
| 315 | KLDRARCH_X86_32,
|
---|
| 316 | /** AMD64 (including clones). */
|
---|
| 317 | KLDRARCH_AMD64,
|
---|
| 318 | /** Itanic (64-bit). */
|
---|
| 319 | KLDRARCH_IA64,
|
---|
| 320 | /** ALPHA (64-bit). */
|
---|
| 321 | KLDRARCH_ALPHA,
|
---|
| 322 | /** ALPHA limited to 32-bit. */
|
---|
| 323 | KLDRARCH_ALPHA_32,
|
---|
| 324 | /** 32-bit ARM. */
|
---|
| 325 | KLDRARCH_ARM_32,
|
---|
| 326 | /** 64-bit ARM. */
|
---|
| 327 | KLDRARCH_ARM_64,
|
---|
| 328 | /** 32-bit MIPS. */
|
---|
| 329 | KLDRARCH_MIPS_32,
|
---|
| 330 | /** 64-bit MIPS. */
|
---|
| 331 | KLDRARCH_MIPS_64,
|
---|
| 332 | /** 32-bit PowerPC. */
|
---|
| 333 | KLDRARCH_POWERPC_32,
|
---|
| 334 | /** 64-bit PowerPC. */
|
---|
| 335 | KLDRARCH_POWERPC_64,
|
---|
| 336 | /** 32-bit SPARC. */
|
---|
| 337 | KLDRARCH_SPARC_32,
|
---|
| 338 | /** 64-bit SPARC. */
|
---|
| 339 | KLDRARCH_SPARC_64,
|
---|
| 340 | /** The end of the valid architecture values (exclusive). */
|
---|
| 341 | KLDRARCH_END,
|
---|
| 342 | /** Hack to blow the type up to 32-bit. */
|
---|
| 343 | KLDRARCH_32BIT_HACK = 0x7fffffff
|
---|
| 344 | } KLDRARCH;
|
---|
| 345 | /** Pointer to a CPU architecture type. */
|
---|
| 346 | typedef KLDRARCH *PKLDRARCH;
|
---|
[2849] | 347 |
|
---|
[2825] | 348 | /**
|
---|
[2855] | 349 | * CPU models.
|
---|
| 350 | */
|
---|
| 351 | typedef enum KLDRCPU
|
---|
| 352 | {
|
---|
| 353 | /** The usual invalid cpu. */
|
---|
| 354 | KLDRCPU_INVALID = 0,
|
---|
| 355 | /** @name KLDRARCH_X86_16
|
---|
| 356 | * @{ */
|
---|
| 357 | KLDRCPU_I8086,
|
---|
| 358 | KLDRCPU_I8088,
|
---|
| 359 | KLDRCPU_I80186,
|
---|
| 360 | KLDRCPU_I80286,
|
---|
| 361 | KLDRCPU_I386_16,
|
---|
| 362 | KLDRCPU_I486_16,
|
---|
| 363 | KLDRCPU_I486SX_16,
|
---|
| 364 | KLDRCPU_I586_16,
|
---|
| 365 | KLDRCPU_I686_16,
|
---|
| 366 | KLDRCPU_P4_16,
|
---|
| 367 | KLDRCPU_CORE2_16,
|
---|
| 368 | KLDRCPU_K6_16,
|
---|
| 369 | KLDRCPU_K7_16,
|
---|
| 370 | KLDRCPU_K8_16,
|
---|
| 371 | KLDRCPU_FIRST_X86_16 = KLDRCPU_I8086,
|
---|
| 372 | KLDRCPU_LAST_X86_16 = KLDRCPU_K8_16,
|
---|
| 373 | /** @} */
|
---|
| 374 |
|
---|
| 375 | /** @name KLDRARCH_X86_32
|
---|
| 376 | * @{ */
|
---|
| 377 | KLDRCPU_X86_32_BLEND,
|
---|
| 378 | KLDRCPU_I386,
|
---|
| 379 | KLDRCPU_I486,
|
---|
| 380 | KLDRCPU_I486SX,
|
---|
| 381 | KLDRCPU_I586,
|
---|
| 382 | KLDRCPU_I686,
|
---|
| 383 | KLDRCPU_P4,
|
---|
| 384 | KLDRCPU_CORE2_32,
|
---|
| 385 | KLDRCPU_K6,
|
---|
| 386 | KLDRCPU_K7,
|
---|
| 387 | KLDRCPU_K8_32,
|
---|
| 388 | KLDRCPU_FIRST_X86_32 = KLDRCPU_I386,
|
---|
| 389 | KLDRCPU_LAST_X86_32 = KLDRCPU_K8_32,
|
---|
| 390 | /** @} */
|
---|
| 391 |
|
---|
| 392 | /** @name KLDRARCH_AMD64
|
---|
| 393 | * @{ */
|
---|
| 394 | KLDRCPU_AMD64_BLEND,
|
---|
| 395 | KLDRCPU_K8,
|
---|
| 396 | KLDRCPU_P4_64,
|
---|
| 397 | KLDRCPU_CORE2,
|
---|
| 398 | KLDRCPU_FIRST_AMD64 = KLDRCPU_K8,
|
---|
| 399 | KLDRCPU_LAST_AMD64 = KLDRCPU_CORE2,
|
---|
| 400 | /** @} */
|
---|
| 401 |
|
---|
| 402 | /** The end of the valid cpu values (exclusive). */
|
---|
| 403 | KLDRCPU_END,
|
---|
| 404 | /** Hack to blow the type up to 32-bit. */
|
---|
| 405 | KLDRCPU_32BIT_HACK = 0x7fffffff
|
---|
| 406 | } KLDRCPU;
|
---|
| 407 | /** Pointer to a CPU type. */
|
---|
| 408 | typedef KLDRCPU *PKLDRCPU;
|
---|
| 409 |
|
---|
| 410 | void kLdrGetArchCpu(PKLDRARCH penmArch, PKLDRCPU penmCpu);
|
---|
| 411 | int kLdrCompareCpus(KLDRARCH enmCodeArch, KLDRCPU enmCodeCpu, KLDRARCH enmArch, KLDRCPU enmCpu);
|
---|
| 412 |
|
---|
| 413 |
|
---|
| 414 | /**
|
---|
[2849] | 415 | * Debug info type (from the loader point of view).
|
---|
| 416 | */
|
---|
| 417 | typedef enum KLDRDBGINFOTYPE
|
---|
| 418 | {
|
---|
| 419 | /** The usual invalid enum value. */
|
---|
| 420 | KLDRDBGINFOTYPE_INVALID = 0,
|
---|
[2856] | 421 | /** Unknown debug info format. */
|
---|
| 422 | KLDRDBGINFOTYPE_UNKNOWN,
|
---|
[2849] | 423 | /** Stabs. */
|
---|
| 424 | KLDRDBGINFOTYPE_STABS,
|
---|
| 425 | /** Debug With Arbitrary Record Format (DWARF). */
|
---|
| 426 | KLDRDBGINFOTYPE_DWARF,
|
---|
| 427 | /** Microsoft Codeview debug info. */
|
---|
| 428 | KLDRDBGINFOTYPE_CODEVIEW,
|
---|
| 429 | /** Watcom debug info. */
|
---|
| 430 | KLDRDBGINFOTYPE_WATCOM,
|
---|
| 431 | /** IBM High Level Language debug info.. */
|
---|
| 432 | KLDRDBGINFOTYPE_HLL,
|
---|
| 433 | /** The end of the valid debug info values (exclusive). */
|
---|
| 434 | KLDRDBGINFOTYPE_END,
|
---|
| 435 | /** Blow the type up to 32-bit. */
|
---|
| 436 | KLDRDBGINFOTYPE_32BIT_HACK = 0x7fffffff
|
---|
| 437 | } KLDRDBGINFOTYPE;
|
---|
| 438 | /** Pointer to a kLdr debug info type. */
|
---|
| 439 | typedef KLDRDBGINFOTYPE *PKLDRDBGINFOTYPE;
|
---|
| 440 |
|
---|
| 441 |
|
---|
| 442 | /**
|
---|
[2835] | 443 | * Stack information.
|
---|
| 444 | */
|
---|
| 445 | typedef struct KLDRSTACKINFO
|
---|
| 446 | {
|
---|
[2848] | 447 | /** The base address of the stack (sub) segment.
|
---|
| 448 | * Set this to NIL_KLDRADDR if the module doesn't include any stack segment. */
|
---|
| 449 | KLDRADDR Address;
|
---|
[2835] | 450 | /** The base address of the stack (sub) segment, link address.
|
---|
[2848] | 451 | * Set this to NIL_KLDRADDR if the module doesn't include any stack (sub)segment. */
|
---|
| 452 | KLDRADDR LinkAddress;
|
---|
[2835] | 453 | /** The stack size of the main thread.
|
---|
| 454 | * If no stack (sub)segment in the module, this is the stack size of the main thread.
|
---|
| 455 | * If the module doesn't contain this kind of information this field will be set to 0. */
|
---|
[2848] | 456 | KLDRSIZE cbStack;
|
---|
[2835] | 457 | /** The stack size of non-main threads.
|
---|
| 458 | * If the module doesn't contain this kind of information this field will be set to 0. */
|
---|
[2848] | 459 | KLDRSIZE cbStackThread;
|
---|
| 460 | } KLDRSTACKINFO;
|
---|
| 461 | /** Pointer to stack information. */
|
---|
| 462 | typedef KLDRSTACKINFO *PKLDRSTACKINFO;
|
---|
| 463 | /** Pointer to const stack information. */
|
---|
| 464 | typedef const KLDRSTACKINFO *PCKLDRSTACKINFO;
|
---|
[2835] | 465 |
|
---|
| 466 |
|
---|
| 467 | /**
|
---|
[2821] | 468 | * Loader segment.
|
---|
| 469 | */
|
---|
| 470 | typedef struct KLDRSEG
|
---|
| 471 | {
|
---|
[2832] | 472 | /** Variable free to use for the kLdr user. */
|
---|
| 473 | void *pvUser;
|
---|
[2854] | 474 | /** The segment name. (Might not be zero terminated!) */
|
---|
| 475 | const char *pchName;
|
---|
| 476 | /** The length of the segment name. */
|
---|
| 477 | uint32_t cchName;
|
---|
[2948] | 478 | /** The flat selector to use for the segment (i.e. data/code).
|
---|
| 479 | * Primarily a way for the user to specify selectors for the LX/LE and NE interpreters. */
|
---|
| 480 | uint16_t SelFlat;
|
---|
[2952] | 481 | /** The 16-bit selector to use for the segment.
|
---|
[2948] | 482 | * Primarily a way for the user to specify selectors for the LX/LE and NE interpreters. */
|
---|
| 483 | uint16_t Sel16bit;
|
---|
| 484 | /** Segment flags. */
|
---|
| 485 | uint32_t fFlags;
|
---|
[2857] | 486 | /** The segment protection. */
|
---|
| 487 | KLDRPROT enmProt;
|
---|
[2821] | 488 | /** The size of the segment. */
|
---|
[2848] | 489 | KLDRSIZE cb;
|
---|
[2856] | 490 | /** The required segment alignment.
|
---|
| 491 | * The to 0 if the segment isn't supposed to be mapped. */
|
---|
[2854] | 492 | KLDRADDR Alignment;
|
---|
| 493 | /** The link address.
|
---|
[2856] | 494 | * Set to NIL_KLDRADDR if the segment isn't supposed to be
|
---|
| 495 | * mapped or if the image doesn't have link addresses. */
|
---|
[2848] | 496 | KLDRADDR LinkAddress;
|
---|
[2856] | 497 | /** File offset of the segment.
|
---|
| 498 | * Set to -1 if no file backing (like BSS). */
|
---|
[2974] | 499 | KLDRFOFF offFile;
|
---|
[2856] | 500 | /** Size of the file bits of the segment.
|
---|
| 501 | * Set to -1 if no file backing (like BSS). */
|
---|
[2974] | 502 | KLDRFOFF cbFile;
|
---|
[2859] | 503 | /** The relative virtual address when mapped.
|
---|
| 504 | * Set to NIL_KLDRADDR if the segment isn't supposed to be mapped. */
|
---|
| 505 | KLDRADDR RVA;
|
---|
| 506 | /** The size of the segment including the alignment gap up to the next segment when mapped. */
|
---|
| 507 | size_t cbMapped;
|
---|
[2857] | 508 | /** The address the segment was mapped at by kLdrModMap().
|
---|
| 509 | * Set to 0 if not mapped. */
|
---|
| 510 | uintptr_t MapAddress;
|
---|
[2848] | 511 | } KLDRSEG;
|
---|
[2821] | 512 |
|
---|
| 513 |
|
---|
[2952] | 514 | /** @name Segment flags
|
---|
[2948] | 515 | * @{ */
|
---|
| 516 | /** The segment is 16-bit. When not set the default of the target architecture is assumed. */
|
---|
| 517 | #define KLDRSEG_FLAG_16BIT 1
|
---|
| 518 | /** The segment requires a 16-bit selector alias. (OS/2) */
|
---|
| 519 | #define KLDRSEG_FLAG_OS2_ALIAS16 2
|
---|
| 520 | /** Conforming segment (x86 weirdness). (OS/2) */
|
---|
| 521 | #define KLDRSEG_FLAG_OS2_CONFORM 4
|
---|
| 522 | /** IOPL (ring-2) segment. (OS/2) */
|
---|
| 523 | #define KLDRSEG_FLAG_OS2_IOPL 8
|
---|
| 524 | /** @} */
|
---|
| 525 |
|
---|
| 526 |
|
---|
[2821] | 527 | /**
|
---|
[2832] | 528 | * Loader module format.
|
---|
| 529 | */
|
---|
| 530 | typedef enum KLDRFMT
|
---|
| 531 | {
|
---|
| 532 | /** The usual invalid 0 format. */
|
---|
| 533 | KLDRFMT_INVALID = 0,
|
---|
| 534 | /** The native OS loader. */
|
---|
| 535 | KLDRFMT_NATIVE,
|
---|
| 536 | /** The AOUT loader. */
|
---|
| 537 | KLDRFMT_AOUT,
|
---|
| 538 | /** The ELF loader. */
|
---|
| 539 | KLDRFMT_ELF,
|
---|
| 540 | /** The LX loader. */
|
---|
| 541 | KLDRFMT_LX,
|
---|
[2952] | 542 | /** The Mach-O loader. */
|
---|
[2832] | 543 | KLDRFMT_MACHO,
|
---|
[2952] | 544 | /** The PE loader. */
|
---|
[2832] | 545 | KLDRFMT_PE,
|
---|
| 546 | /** The end of the valid format values (exclusive). */
|
---|
| 547 | KLDRFMT_END,
|
---|
| 548 | /** Hack to blow the type up to 32-bit. */
|
---|
| 549 | KLDRFMT_32BIT_HACK = 0x7fffffff
|
---|
| 550 | } KLDRFMT;
|
---|
| 551 |
|
---|
| 552 |
|
---|
| 553 | /**
|
---|
[2821] | 554 | * Loader module type.
|
---|
| 555 | */
|
---|
| 556 | typedef enum KLDRTYPE
|
---|
| 557 | {
|
---|
| 558 | /** The usual invalid 0 type. */
|
---|
| 559 | KLDRTYPE_INVALID = 0,
|
---|
[2832] | 560 | /** Object file. */
|
---|
| 561 | KLDRTYPE_OBJECT,
|
---|
| 562 | /** Executable module, fixed load address. */
|
---|
| 563 | KLDRTYPE_EXECUTABLE_FIXED,
|
---|
| 564 | /** Executable module, relocatable, non-fixed load address. */
|
---|
| 565 | KLDRTYPE_EXECUTABLE_RELOCATABLE,
|
---|
| 566 | /** Executable module, position independent code, non-fixed load address. */
|
---|
| 567 | KLDRTYPE_EXECUTABLE_PIC,
|
---|
| 568 | /** Shared library, fixed load address.
|
---|
| 569 | * Typically a system library. */
|
---|
| 570 | KLDRTYPE_SHARED_LIBRARY_FIXED,
|
---|
| 571 | /** Shared library, relocatable, non-fixed load address. */
|
---|
| 572 | KLDRTYPE_SHARED_LIBRARY_RELOCATABLE,
|
---|
| 573 | /** Shared library, position independent code, non-fixed load address. */
|
---|
| 574 | KLDRTYPE_SHARED_LIBRARY_PIC,
|
---|
| 575 | /** DLL that contains no code or data only imports and exports. (Chiefly OS/2.) */
|
---|
| 576 | KLDRTYPE_FORWARDER_DLL,
|
---|
| 577 | /** Core or dump. */
|
---|
| 578 | KLDRTYPE_CORE,
|
---|
| 579 | /** The end of the valid types values (exclusive). */
|
---|
[2821] | 580 | KLDRTYPE_END,
|
---|
| 581 | /** Hack to blow the type up to 32-bit. */
|
---|
| 582 | KLDRTYPE_32BIT_HACK = 0x7fffffff
|
---|
| 583 | } KLDRTYPE;
|
---|
| 584 |
|
---|
| 585 |
|
---|
| 586 | /**
|
---|
[2832] | 587 | * Loader endian indicator.
|
---|
| 588 | */
|
---|
| 589 | typedef enum KLDRENDIAN
|
---|
| 590 | {
|
---|
| 591 | /** The usual invalid endian. */
|
---|
| 592 | KLDRENDIAN_INVALID,
|
---|
| 593 | /** Little endian. */
|
---|
| 594 | KLDRENDIAN_LITTLE,
|
---|
| 595 | /** Bit endian. */
|
---|
| 596 | KLDRENDIAN_BIG,
|
---|
| 597 | /** Endianness doesn't have a meaning in the context. */
|
---|
| 598 | KLDRENDIAN_NA,
|
---|
| 599 | /** The end of the valid endian values (exclusive). */
|
---|
| 600 | KLDRENDIAN_END,
|
---|
| 601 | /** Hack to blow the type up to 32-bit. */
|
---|
| 602 | KLDRENDIAN_32BIT_HACK = 0x7fffffff
|
---|
| 603 | } KLDRENDIAN;
|
---|
| 604 |
|
---|
| 605 |
|
---|
[2851] | 606 | /** Pointer to a module interpreter method table. */
|
---|
| 607 | typedef struct KLDRMODOPS *PKLDRMODOPS;
|
---|
| 608 | /** Pointer to const module interpreter methods table. */
|
---|
| 609 | typedef const struct KLDRMODOPS *PCKLDRMODOPS;
|
---|
| 610 |
|
---|
[2832] | 611 | /**
|
---|
[2851] | 612 | * Module interpreter instance.
|
---|
| 613 | * All members are read only unless you're kLdrMod or the module interpreter.
|
---|
[2821] | 614 | */
|
---|
| 615 | typedef struct KLDRMOD
|
---|
| 616 | {
|
---|
[2856] | 617 | /** Magic number (KLDRMOD_MAGIC). */
|
---|
[2825] | 618 | uint32_t u32Magic;
|
---|
[2832] | 619 | /** The format of this module. */
|
---|
| 620 | KLDRFMT enmFmt;
|
---|
| 621 | /** The type of module. */
|
---|
[2825] | 622 | KLDRTYPE enmType;
|
---|
[2832] | 623 | /** The architecture this module was built for. */
|
---|
| 624 | KLDRARCH enmArch;
|
---|
| 625 | /** The minium cpu this module was built for.
|
---|
| 626 | * This might not be accurate, so use kLdrModCanExecuteOn() to check. */
|
---|
| 627 | KLDRARCH enmCpu;
|
---|
| 628 | /** The endian used by the module. */
|
---|
| 629 | KLDRENDIAN enmEndian;
|
---|
[2821] | 630 | /** The filename length (bytes). */
|
---|
| 631 | uint32_t cchFilename;
|
---|
| 632 | /** The filename. */
|
---|
| 633 | const char *pszFilename;
|
---|
| 634 | /** The module name. */
|
---|
| 635 | const char *pszName;
|
---|
| 636 | /** The module name length (bytes). */
|
---|
| 637 | uint32_t cchName;
|
---|
| 638 | /** The number of segments in the module. */
|
---|
| 639 | uint32_t cSegments;
|
---|
[2851] | 640 | /** Pointer to the loader methods.
|
---|
| 641 | * Not meant for calling directly thru! */
|
---|
| 642 | PCKLDRMODOPS pOps;
|
---|
[2854] | 643 | /** Pointer to the read instance. (Can be NULL after kLdrModDone().)*/
|
---|
| 644 | PKLDRRDR pRdr;
|
---|
[2832] | 645 | /** The module data. */
|
---|
| 646 | void *pvData;
|
---|
[2821] | 647 | /** Segments. (variable size, can be zero) */
|
---|
| 648 | KLDRSEG aSegments[1];
|
---|
| 649 | } KLDRMOD, *PKLDRMOD, **PPKLDRMOD;
|
---|
| 650 |
|
---|
[2851] | 651 | /** The magic for KLDRMOD::u32Magic. (Kosuke Fujishima) */
|
---|
| 652 | #define KLDRMOD_MAGIC 0x19640707
|
---|
[2821] | 653 |
|
---|
[2851] | 654 |
|
---|
[2832] | 655 | /** Special base address value alias for the link address. */
|
---|
[2848] | 656 | #define KLDRMOD_BASEADDRESS_LINK (~(KLDRADDR)1)
|
---|
[2832] | 657 | /** Special base address value alias for the actual load address (must be mapped). */
|
---|
[2848] | 658 | #define KLDRMOD_BASEADDRESS_MAP (~(KLDRADDR)2)
|
---|
[2825] | 659 |
|
---|
[2848] | 660 | /** Special import module ordinal value used to indicate that there is no
|
---|
| 661 | * specific module associated with the requested symbol. */
|
---|
[2859] | 662 | #define NIL_KLDRMOD_IMPORT (~(uint32_t)0)
|
---|
[2848] | 663 |
|
---|
| 664 | /** Special symbol ordinal value used to indicate that the symbol
|
---|
| 665 | * only has a string name. */
|
---|
[2859] | 666 | #define NIL_KLDRMOD_SYM_ORDINAL (~(uint32_t)0)
|
---|
[2848] | 667 |
|
---|
| 668 |
|
---|
[2832] | 669 | /** @name Load symbol kind flags.
|
---|
| 670 | * @{ */
|
---|
| 671 | /** The bitness doesn't matter. */
|
---|
[2848] | 672 | #define KLDRSYMKIND_NO_BIT 0x00000000
|
---|
[2832] | 673 | /** 16-bit symbol. */
|
---|
[2848] | 674 | #define KLDRSYMKIND_16BIT 0x00000001
|
---|
[2832] | 675 | /** 32-bit symbol. */
|
---|
[2848] | 676 | #define KLDRSYMKIND_32BIT 0x00000002
|
---|
[2832] | 677 | /** 64-bit symbol. */
|
---|
[2848] | 678 | #define KLDRSYMKIND_64BIT 0x00000003
|
---|
[2832] | 679 | /** Mask out the bit.*/
|
---|
[2848] | 680 | #define KLDRSYMKIND_BIT_MASK 0x00000003
|
---|
[2832] | 681 | /** We don't know the type of symbol. */
|
---|
[2848] | 682 | #define KLDRSYMKIND_NO_TYPE 0x00000000
|
---|
[2832] | 683 | /** The symbol is a code object (method/function/procedure/whateveryouwannacallit). */
|
---|
[2848] | 684 | #define KLDRSYMKIND_CODE 0x00000010
|
---|
[2832] | 685 | /** The symbol is a data object. */
|
---|
[2848] | 686 | #define KLDRSYMKIND_DATA 0x00000020
|
---|
[2832] | 687 | /** Mask out the symbol type. */
|
---|
[2848] | 688 | #define KLDRSYMKIND_TYPE_MASK 0x00000030
|
---|
[2832] | 689 | /** Valid symbol kind mask. */
|
---|
[2848] | 690 | #define KLDRSYMKIND_MASK 0x00000033
|
---|
[2850] | 691 | /** Weak symbol. */
|
---|
| 692 | #define KLDRSYMKIND_WEAK 0x00000100
|
---|
[2854] | 693 | /** Forwarder symbol. */
|
---|
| 694 | #define KLDRSYMKIND_FORWARDER 0x00000200
|
---|
[2891] | 695 | /** Request a flat symbol address. */
|
---|
| 696 | #define KLDRSYMKIND_REQ_FLAT 0x00000000
|
---|
| 697 | /** Request a segmented symbol address. */
|
---|
| 698 | #define KLDRSYMKIND_REQ_SEGMENTED 0x40000000
|
---|
[2962] | 699 | /** Request type mask. */
|
---|
| 700 | #define KLDRSYMKIND_REQ_TYPE_MASK 0x40000000
|
---|
[2832] | 701 | /** @} */
|
---|
[2825] | 702 |
|
---|
| 703 | /** @name kLdrModEnumSymbols flags.
|
---|
| 704 | * @{ */
|
---|
| 705 | /** Returns ALL kinds of symbols. The default is to only return public/exported symbols. */
|
---|
[2848] | 706 | #define KLDRMOD_ENUM_SYMS_FLAGS_ALL 0x00000001
|
---|
[2825] | 707 | /** @} */
|
---|
| 708 |
|
---|
[2832] | 709 |
|
---|
[2848] | 710 | /**
|
---|
| 711 | * Callback for resolving imported symbols when applying fixups.
|
---|
| 712 | *
|
---|
| 713 | * @returns 0 on success and *pValue and *pfKind filled.
|
---|
| 714 | * @returns Non-zero OS specific or kLdr status code on failure.
|
---|
| 715 | *
|
---|
| 716 | * @param pMod The module which fixups are begin applied.
|
---|
| 717 | * @param iImport The import module ordinal number or NIL_KLDRMOD_IMPORT.
|
---|
[2859] | 718 | * @param iSymbol The symbol ordinal number or NIL_KLDRMOD_SYM_ORDINAL.
|
---|
[2891] | 719 | * @param pchSymbol The symbol name. Can be NULL if iSymbol isn't nil. Doesn't have to be null-terminated.
|
---|
| 720 | * @param cchSymbol The length of the symbol.
|
---|
| 721 | * @param pszVersion The symbol version. NULL if not versioned.
|
---|
[2848] | 722 | * @param puValue Where to store the symbol value.
|
---|
| 723 | * @param pfKind Where to store the symbol kind flags.
|
---|
| 724 | * @param pvUser The user parameter specified to the relocation function.
|
---|
| 725 | */
|
---|
[2891] | 726 | typedef int FNKLDRMODGETIMPORT(PKLDRMOD pMod, uint32_t iImport, uint32_t iSymbol, const char *pchSymbol, size_t cchSymbol,
|
---|
| 727 | const char *pszVersion, PKLDRADDR puValue, uint32_t *pfKind, void *pvUser);
|
---|
[2848] | 728 | /** Pointer to a import callback. */
|
---|
[2832] | 729 | typedef FNKLDRMODGETIMPORT *PFNKLDRMODGETIMPORT;
|
---|
[2848] | 730 |
|
---|
| 731 | /**
|
---|
| 732 | * Symbol enumerator callback.
|
---|
| 733 | *
|
---|
| 734 | * @returns 0 if enumeration should continue.
|
---|
[2849] | 735 | * @returns non-zero if the enumeration should stop. This status code will then be returned by kLdrModEnumSymbols().
|
---|
[2848] | 736 | *
|
---|
| 737 | * @param pMod The module which symbols are being enumerated.s
|
---|
[2859] | 738 | * @param iSymbol The symbol ordinal number or NIL_KLDRMOD_SYM_ORDINAL.
|
---|
[2891] | 739 | * @param pchSymbol The symbol name. This can be NULL if there is a symbol ordinal.
|
---|
[2848] | 740 | * This can also be an empty string if the symbol doesn't have a name
|
---|
| 741 | * or it's name has been stripped.
|
---|
[2891] | 742 | * Important, this doesn't have to be a null-terminated string.
|
---|
| 743 | * @param cchSymbol The length of the symbol.
|
---|
| 744 | * @param pszVersion The symbol version. NULL if not versioned.
|
---|
[2848] | 745 | * @param uValue The symbol value.
|
---|
| 746 | * @param fKind The symbol kind flags.
|
---|
| 747 | * @param pvUser The user parameter specified to kLdrModEnumSymbols().
|
---|
| 748 | */
|
---|
[2891] | 749 | typedef int FNKLDRMODENUMSYMS(PKLDRMOD pMod, uint32_t iSymbol, const char *pchSymbol, size_t cchSymbol, const char *pszVersion,
|
---|
[2848] | 750 | KLDRADDR uValue, uint32_t fKind, void *pvUser);
|
---|
| 751 | /** Pointer to a symbol enumerator callback. */
|
---|
[2832] | 752 | typedef FNKLDRMODENUMSYMS *PFNKLDRMODENUMSYMS;
|
---|
| 753 |
|
---|
[2849] | 754 | /**
|
---|
| 755 | * Debug info enumerator callback.
|
---|
| 756 | *
|
---|
| 757 | * @returns 0 to continue the enumeration.
|
---|
| 758 | * @returns non-zero if the enumeration should stop. This status code will then be returned by kLdrModEnumDbgInfo().
|
---|
| 759 | *
|
---|
| 760 | * @param pMod The module.
|
---|
[2856] | 761 | * @param iDbgInfo The debug info ordinal number / id.
|
---|
[2849] | 762 | * @param enmType The debug info type.
|
---|
[2856] | 763 | * @param iMajorVer The major version number of the debug info format. -1 if unknow - implies invalid iMinorVer.
|
---|
| 764 | * @param iMinorVer The minor version number of the debug info format. -1 when iMajorVer is -1.
|
---|
[2849] | 765 | * @param offFile The file offset *if* this type has one specific location in the executable image file.
|
---|
| 766 | * This is -1 if there isn't any specific file location.
|
---|
[2856] | 767 | * @param LinkAddress The link address of the debug info if it's loadable. NIL_KLDRADDR if not loadable.
|
---|
| 768 | * @param cb The size of the debug information. -1 is used if this isn't applicable.
|
---|
[2849] | 769 | * @param pszExtFile This points to the name of an external file containing the debug info.
|
---|
| 770 | * This is NULL if there isn't any external file.
|
---|
| 771 | * @param pvUser The user parameter specified to kLdrModEnumDbgInfo.
|
---|
| 772 | */
|
---|
[2856] | 773 | typedef int FNKLDRENUMDBG(PKLDRMOD pMod, uint32_t iDbgInfo, KLDRDBGINFOTYPE enmType, int16_t iMajorVer, int16_t iMinorVer,
|
---|
[2974] | 774 | KLDRFOFF offFile, KLDRADDR LinkAddress, KLDRSIZE cb, const char *pszExtFile, void *pvUser);
|
---|
[2891] | 775 | /** Pointer to a debug info enumerator callback. */
|
---|
[2856] | 776 | typedef FNKLDRENUMDBG *PFNKLDRENUMDBG;
|
---|
[2849] | 777 |
|
---|
[2891] | 778 | /**
|
---|
| 779 | * Resource enumerator callback.
|
---|
| 780 | *
|
---|
| 781 | * @returns 0 to continue the enumeration.
|
---|
| 782 | * @returns non-zero if the enumeration should stop. This status code will then be returned by kLdrModEnumResources().
|
---|
| 783 | *
|
---|
| 784 | * @param pMod The module.
|
---|
| 785 | * @param idType The resource type id. NIL_KLDRMOD_RSRC_TYPE_ID if no type id.
|
---|
| 786 | * @param pszType The resource type name. NULL if no type name.
|
---|
| 787 | * @param idName The resource id. NIL_KLDRMOD_RSRC_NAME_ID if no id.
|
---|
| 788 | * @param pszName The resource name. NULL if no name.
|
---|
[2952] | 789 | * @param idLang The language id.
|
---|
[2891] | 790 | * @param AddrRsrc The address value for the resource.
|
---|
| 791 | * @param cbRsrc The size of the resource.
|
---|
| 792 | * @param pvUser The user parameter specified to kLdrModEnumDbgInfo.
|
---|
| 793 | */
|
---|
[2952] | 794 | typedef int FNKLDRENUMRSRC(PKLDRMOD pMod, uint32_t idType, const char *pszType, uint32_t idName, const char *pszName,
|
---|
[2891] | 795 | uint32_t idLang, KLDRADDR AddrRsrc, KLDRSIZE cbRsrc, void *pvUser);
|
---|
| 796 | /** Pointer to a resource enumerator callback. */
|
---|
| 797 | typedef FNKLDRENUMRSRC *PFNKLDRENUMRSRC;
|
---|
| 798 |
|
---|
| 799 | /** NIL resource name ID. */
|
---|
| 800 | #define NIL_KLDRMOD_RSRC_NAME_ID ( ~(uint32_t)0 )
|
---|
| 801 | /** NIL resource type ID. */
|
---|
| 802 | #define NIL_KLDRMOD_RSRC_TYPE_ID ( ~(uint32_t)0 )
|
---|
| 803 | /** @name Language ID
|
---|
[2952] | 804 | *
|
---|
| 805 | * Except for the special IDs #defined here, the values are considered
|
---|
[2891] | 806 | * format specific for now since it's only used by the PE resources.
|
---|
[2952] | 807 | *
|
---|
[2891] | 808 | * @{ */
|
---|
| 809 | /** NIL language ID. */
|
---|
| 810 | #define NIL_KLDR_LANG_ID ( ~(uint32_t)0 )
|
---|
| 811 | /** Special language id value for matching any language. */
|
---|
| 812 | #define KLDR_LANG_ID_ANY ( ~(uint32_t)1 )
|
---|
| 813 | /** Special language id value indicating language neutral. */
|
---|
| 814 | #define KLDR_LANG_ID_NEUTRAL ( ~(uint32_t)2 )
|
---|
| 815 | /** Special language id value indicating user default language. */
|
---|
| 816 | #define KLDR_LANG_ID_USER_DEFAULT ( ~(uint32_t)3 )
|
---|
| 817 | /** Special language id value indicating system default language. */
|
---|
| 818 | #define KLDR_LANG_ID_SYS_DEFAULT ( ~(uint32_t)4 )
|
---|
| 819 | /** Special language id value indicating default custom locale. */
|
---|
| 820 | #define KLDR_LANG_ID_CUSTOM_DEFAULT ( ~(uint32_t)5 )
|
---|
| 821 | /** Special language id value indicating unspecified custom locale. */
|
---|
| 822 | #define KLDR_LANG_ID_CUSTOM_UNSPECIFIED ( ~(uint32_t)6 )
|
---|
| 823 | /** Special language id value indicating default custom MUI locale. */
|
---|
| 824 | #define KLDR_LANG_ID_UI_CUSTOM_DEFAULT ( ~(uint32_t)7 )
|
---|
| 825 | /** @} */
|
---|
| 826 |
|
---|
| 827 |
|
---|
[2832] | 828 | int kLdrModOpen(const char *pszFilename, PPKLDRMOD ppMod);
|
---|
[2845] | 829 | int kLdrModOpenFromRdr(PKLDRRDR pRdr, PPKLDRMOD ppMod);
|
---|
| 830 | int kLdrModOpenNative(const char *pszFilename, PPKLDRMOD ppMod);
|
---|
[2877] | 831 | int kLdrModOpenNativeByHandle(uintptr_t uHandle, PPKLDRMOD ppMod);
|
---|
[2832] | 832 | int kLdrModClose(PKLDRMOD pMod);
|
---|
[2848] | 833 |
|
---|
[2859] | 834 | int kLdrModQuerySymbol(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_t iSymbol,
|
---|
[2952] | 835 | const char *pchSymbol, size_t cchSymbol, const char *pszVersion,
|
---|
[2891] | 836 | PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, uint32_t *pfKind);
|
---|
[2854] | 837 | int kLdrModEnumSymbols(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress,
|
---|
| 838 | uint32_t fFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser);
|
---|
[2855] | 839 | int kLdrModGetImport(PKLDRMOD pMod, const void *pvBits, uint32_t iImport, char *pszName, size_t cchName);
|
---|
| 840 | int32_t kLdrModNumberOfImports(PKLDRMOD pMod, const void *pvBits);
|
---|
| 841 | int kLdrModCanExecuteOn(PKLDRMOD pMod, const void *pvBits, KLDRARCH enmArch, KLDRCPU enmCpu);
|
---|
| 842 | int kLdrModGetStackInfo(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, PKLDRSTACKINFO pStackInfo);
|
---|
| 843 | int kLdrModQueryMainEntrypoint(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, PKLDRADDR pMainEPAddress);
|
---|
[2891] | 844 | int kLdrModQueryResource(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_t idType, const char *pszType,
|
---|
| 845 | uint32_t idName, const char *pszName, uint32_t idLang, PKLDRADDR pAddrRsrc, size_t *pcbRsrc);
|
---|
[2952] | 846 | int kLdrModEnumResources(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_t idType, const char *pszType,
|
---|
[2891] | 847 | uint32_t idName, const char *pszName, uint32_t idLang, PFNKLDRENUMRSRC pfnCallback, void *pvUser);
|
---|
[2855] | 848 | int kLdrModEnumDbgInfo(PKLDRMOD pMod, const void *pvBits, PFNKLDRENUMDBG pfnCallback, void *pvUser);
|
---|
| 849 | int kLdrModHasDbgInfo(PKLDRMOD pMod, const void *pvBits);
|
---|
[2891] | 850 | int kLdrModMostlyDone(PKLDRMOD pMod);
|
---|
[2848] | 851 |
|
---|
[2891] | 852 |
|
---|
[2848] | 853 | /** @name Operations On The Internally Managed Mapping
|
---|
| 854 | * @{ */
|
---|
[2832] | 855 | int kLdrModMap(PKLDRMOD pMod);
|
---|
| 856 | int kLdrModUnmap(PKLDRMOD pMod);
|
---|
[2846] | 857 | int kLdrModAllocTLS(PKLDRMOD pMod);
|
---|
[2847] | 858 | void kLdrModFreeTLS(PKLDRMOD pMod);
|
---|
[2846] | 859 | int kLdrModReload(PKLDRMOD pMod);
|
---|
[2848] | 860 | int kLdrModFixupMapping(PKLDRMOD pMod, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);
|
---|
[2856] | 861 | int kLdrModCallInit(PKLDRMOD pMod, uintptr_t uHandle);
|
---|
| 862 | int kLdrModCallTerm(PKLDRMOD pMod, uintptr_t uHandle);
|
---|
| 863 | int kLdrModCallThread(PKLDRMOD pMod, uintptr_t uHandle, unsigned fAttachingOrDetaching);
|
---|
[2848] | 864 | /** @} */
|
---|
[2832] | 865 |
|
---|
[2848] | 866 | /** @name Operations On The Externally Managed Mappings
|
---|
| 867 | * @{ */
|
---|
[2856] | 868 | KLDRADDR kLdrModSize(PKLDRMOD pMod);
|
---|
[2848] | 869 | int kLdrModGetBits(PKLDRMOD pMod, void *pvBits, KLDRADDR BaseAddress, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);
|
---|
| 870 | int kLdrModRelocateBits(PKLDRMOD pMod, void *pvBits, KLDRADDR NewBaseAddress, KLDRADDR OldBaseAddress,
|
---|
| 871 | PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);
|
---|
[2825] | 872 | /** @} */
|
---|
| 873 |
|
---|
[2849] | 874 |
|
---|
[2851] | 875 | /**
|
---|
| 876 | * The loader module operation.
|
---|
| 877 | */
|
---|
| 878 | typedef struct KLDRMODOPS
|
---|
| 879 | {
|
---|
| 880 | /** The name of this module interpreter. */
|
---|
| 881 | const char *pszName;
|
---|
| 882 | /** Pointer to the next module interpreter. */
|
---|
| 883 | PCKLDRMODOPS pNext;
|
---|
| 884 |
|
---|
| 885 | /**
|
---|
| 886 | * Create a loader module instance interpreting the executable image found
|
---|
| 887 | * in the specified file provider instance.
|
---|
| 888 | *
|
---|
| 889 | * @returns 0 on success and *ppMod pointing to a module instance.
|
---|
| 890 | * On failure, a non-zero OS specific error code is returned.
|
---|
| 891 | * @param pOps Pointer to the registered method table.
|
---|
| 892 | * @param pRdr The file provider instance to use.
|
---|
| 893 | * @param offNewHdr The offset of the new header in MZ files. -1 if not found.
|
---|
| 894 | * @param ppMod Where to store the module instance pointer.
|
---|
| 895 | */
|
---|
[2974] | 896 | int (* pfnCreate)(PCKLDRMODOPS pOps, PKLDRRDR pRdr, KLDRFOFF offNewHdr, PPKLDRMOD ppMod);
|
---|
[2851] | 897 | /**
|
---|
| 898 | * Destroys an loader module instance.
|
---|
| 899 | *
|
---|
| 900 | * The caller is responsible for calling kLdrModUnmap() and kLdrFreeTLS() first.
|
---|
| 901 | *
|
---|
| 902 | * @returns 0 on success, non-zero on failure. The module instance state
|
---|
| 903 | * is unknown on failure, it's best not to touch it.
|
---|
| 904 | * @param pMod The module.
|
---|
| 905 | */
|
---|
| 906 | int (* pfnDestroy)(PKLDRMOD pMod);
|
---|
| 907 |
|
---|
| 908 | /** @copydoc kLdrModQuerySymbol */
|
---|
[2859] | 909 | int (* pfnQuerySymbol)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_t iSymbol,
|
---|
[2952] | 910 | const char *pchSymbol, size_t cchSymbol, const char *pszVersion,
|
---|
[2891] | 911 | PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, uint32_t *pfKind);
|
---|
[2851] | 912 | /** @copydoc kLdrModEnumSymbols */
|
---|
[2854] | 913 | int (* pfnEnumSymbols)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_t fFlags,
|
---|
[2851] | 914 | PFNKLDRMODENUMSYMS pfnCallback, void *pvUser);
|
---|
| 915 | /** @copydoc kLdrModGetImport */
|
---|
[2855] | 916 | int (* pfnGetImport)(PKLDRMOD pMod, const void *pvBits, uint32_t iImport, char *pszName, size_t cchName);
|
---|
[2851] | 917 | /** @copydoc kLdrModNumberOfImports */
|
---|
[2855] | 918 | int32_t (* pfnNumberOfImports)(PKLDRMOD pMod, const void *pvBits);
|
---|
[2851] | 919 | /** @copydoc kLdrModCanExecuteOn */
|
---|
[2855] | 920 | int (* pfnCanExecuteOn)(PKLDRMOD pMod, const void *pvBits, KLDRARCH enmArch, KLDRCPU enmCpu);
|
---|
[2851] | 921 | /** @copydoc kLdrModGetStackInfo */
|
---|
[2855] | 922 | int (* pfnGetStackInfo)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, PKLDRSTACKINFO pStackInfo);
|
---|
[2851] | 923 | /** @copydoc kLdrModQueryMainEntrypoint */
|
---|
[2855] | 924 | int (* pfnQueryMainEntrypoint)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, PKLDRADDR pMainEPAddress);
|
---|
[2891] | 925 | /** @copydoc kLdrModQueryResource */
|
---|
| 926 | int (* pfnQueryResource)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_t idType, const char *pszType,
|
---|
| 927 | uint32_t idName, const char *pszName, uint32_t idLang, PKLDRADDR pAddrRsrc, size_t *pcbRsrc);
|
---|
| 928 | /** @copydoc kLdrModEnumResources */
|
---|
[2952] | 929 | int (* pfnEnumResources)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_t idType, const char *pszType,
|
---|
[2891] | 930 | uint32_t idName, const char *pszName, uint32_t idLang, PFNKLDRENUMRSRC pfnCallback, void *pvUser);
|
---|
[2851] | 931 | /** @copydoc kLdrModEnumDbgInfo */
|
---|
[2855] | 932 | int (* pfnEnumDbgInfo)(PKLDRMOD pMod, const void *pvBits, PFNKLDRENUMDBG pfnCallback, void *pvUser);
|
---|
[2851] | 933 | /** @copydoc kLdrModHasDbgInfo */
|
---|
[2855] | 934 | int (* pfnHasDbgInfo)(PKLDRMOD pMod, const void *pvBits);
|
---|
[2851] | 935 | /** @copydoc kLdrModMap */
|
---|
| 936 | int (* pfnMap)(PKLDRMOD pMod);
|
---|
| 937 | /** @copydoc kLdrModUnmap */
|
---|
| 938 | int (* pfnUnmap)(PKLDRMOD pMod);
|
---|
| 939 | /** @copydoc kLdrModAllocTLS */
|
---|
| 940 | int (* pfnAllocTLS)(PKLDRMOD pMod);
|
---|
| 941 | /** @copydoc kLdrModFreeTLS */
|
---|
| 942 | void (* pfnFreeTLS)(PKLDRMOD pMod);
|
---|
| 943 | /** @copydoc kLdrModReload */
|
---|
| 944 | int (* pfnReload)(PKLDRMOD pMod);
|
---|
| 945 | /** @copydoc kLdrModFixupMapping */
|
---|
| 946 | int (* pfnFixupMapping)(PKLDRMOD pMod, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);
|
---|
| 947 | /** @copydoc kLdrModCallInit */
|
---|
[2856] | 948 | int (* pfnCallInit)(PKLDRMOD pMod, uintptr_t uHandle);
|
---|
[2851] | 949 | /** @copydoc kLdrModCallTerm */
|
---|
[2856] | 950 | int (* pfnCallTerm)(PKLDRMOD pMod, uintptr_t uHandle);
|
---|
[2851] | 951 | /** @copydoc kLdrModCallThread */
|
---|
[2856] | 952 | int (* pfnCallThread)(PKLDRMOD pMod, uintptr_t uHandle, unsigned fAttachingOrDetaching);
|
---|
[2851] | 953 | /** @copydoc kLdrModSize */
|
---|
[2856] | 954 | KLDRADDR (* pfnSize)(PKLDRMOD pMod);
|
---|
[2851] | 955 | /** @copydoc kLdrModGetBits */
|
---|
| 956 | int (* pfnGetBits)(PKLDRMOD pMod, void *pvBits, KLDRADDR BaseAddress, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);
|
---|
| 957 | /** @copydoc kLdrModRelocateBits */
|
---|
| 958 | int (* pfnRelocateBits)(PKLDRMOD pMod, void *pvBits, KLDRADDR NewBaseAddress, KLDRADDR OldBaseAddress,
|
---|
| 959 | PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);
|
---|
[2891] | 960 | /** @copydoc kLdrModMostlyDone */
|
---|
| 961 | int (* pfnMostlyDone)(PKLDRMOD pMod);
|
---|
[2851] | 962 | /** Dummy which should be assigned a non-zero value. */
|
---|
| 963 | uint32_t uEndOfStructure;
|
---|
| 964 | } KLDRMODOPS;
|
---|
| 965 |
|
---|
| 966 |
|
---|
[2848] | 967 | /** @} */
|
---|
[2825] | 968 |
|
---|
| 969 |
|
---|
| 970 |
|
---|
[2848] | 971 |
|
---|
[2832] | 972 | /** @defgroup grp_kLdrDyld kLdrDyld - The dynamic loader
|
---|
[2825] | 973 | * @{ */
|
---|
| 974 |
|
---|
[2832] | 975 | /** The handle to a dynamic loader module. */
|
---|
[2833] | 976 | typedef struct KLDRDYLDMOD *HKLDRMOD;
|
---|
[2832] | 977 | /** Pointer to the handle to a dynamic loader module. */
|
---|
| 978 | typedef HKLDRMOD *PHKLDRMOD;
|
---|
[2833] | 979 | /** NIL handle value. */
|
---|
| 980 | #define NIL_HKLDRMOD ((HKLDRMOD)0)
|
---|
[2825] | 981 |
|
---|
| 982 |
|
---|
[2832] | 983 | /**
|
---|
| 984 | * File search method.
|
---|
| 985 | *
|
---|
| 986 | * In addition to it's own way of finding files, kLdr emulates
|
---|
| 987 | * the methods employed by the most popular systems.
|
---|
| 988 | */
|
---|
| 989 | typedef enum KLDRDYLDSEARCH
|
---|
| 990 | {
|
---|
| 991 | /** The usual invalid file search method. */
|
---|
| 992 | KLDRDYLD_SEARCH_INVALID = 0,
|
---|
| 993 | /** Uses the kLdr file search method.
|
---|
| 994 | * @todo invent me. */
|
---|
| 995 | KLDRDYLD_SEARCH_KLDR,
|
---|
| 996 | /** Use the emulation closest to the host system. */
|
---|
| 997 | KLDRDYLD_SEARCH_HOST,
|
---|
| 998 | /** Emulate the OS/2 file search method.
|
---|
| 999 | * On non-OS/2 systems, BEGINLIBPATH, LIBPATH, ENDLIBPATH and LIBPATHSTRICT are
|
---|
| 1000 | * taken form the environment. */
|
---|
| 1001 | KLDRDYLD_SEARCH_OS2,
|
---|
| 1002 | /** Emulate the standard window file search method. */
|
---|
| 1003 | KLDRDYLD_SEARCH_WINDOWS,
|
---|
| 1004 | /** Emulate the alternative window file search method. */
|
---|
| 1005 | KLDRDYLD_SEARCH_WINDOWS_ALTERED,
|
---|
| 1006 | /** Emulate the most common UNIX file search method. */
|
---|
| 1007 | KLDRDYLD_SEARCH_UNIX_COMMON,
|
---|
[2833] | 1008 | /** End of the valid file search method values. */
|
---|
| 1009 | KLDRDYLD_SEARCH_END,
|
---|
| 1010 | /** Hack to blow the type up to 32-bit. */
|
---|
| 1011 | KLDRDYLD_SEARCH_32BIT_HACK = 0x7fffffff
|
---|
[2832] | 1012 | } KLDRDYLDSEARCH;
|
---|
| 1013 |
|
---|
[2836] | 1014 | /** @name kLdrDyldLoad and kLdrDyldFindByName flags.
|
---|
[2832] | 1015 | * @{ */
|
---|
| 1016 | /** The symbols in the module should be loaded into the global unix namespace.
|
---|
| 1017 | * If not specified, the symbols are local and can only be referenced directly. */
|
---|
| 1018 | #define KLDRYDLD_LOAD_FLAGS_GLOBAL_SYMBOLS 0x00000001
|
---|
[2870] | 1019 | /** The symbols in the module should be loaded into the global unix namespace and
|
---|
| 1020 | * it's symbols should take precedence over all currently loaded modules.
|
---|
| 1021 | * This implies KLDRYDLD_LOAD_FLAGS_GLOBAL_SYMBOLS. */
|
---|
| 1022 | #define KLDRYDLD_LOAD_FLAGS_DEEP_SYMBOLS 0x00000002
|
---|
[2832] | 1023 | /** The module shouldn't be found by a global module search.
|
---|
| 1024 | * If not specified, the module can be found by unspecified module searches,
|
---|
| 1025 | * typical used when loading import/dep modules. */
|
---|
[2870] | 1026 | #define KLDRYDLD_LOAD_FLAGS_SPECIFIC_MODULE 0x00000004
|
---|
[2843] | 1027 | /** Do a recursive initialization calls instead of defering them to the outermost call. */
|
---|
[2870] | 1028 | #define KLDRDYLD_LOAD_FLAGS_RECURSIVE_INIT 0x00000008
|
---|
[2843] | 1029 | /** We're loading the executable module.
|
---|
[2867] | 1030 | * @internal */
|
---|
[2843] | 1031 | #define KLDRDYLD_LOAD_FLAGS_EXECUTABLE 0x40000000
|
---|
[2832] | 1032 | /** @} */
|
---|
| 1033 |
|
---|
| 1034 |
|
---|
[2843] | 1035 | int kLdrDyldLoad(const char *pszDll, const char *pszPrefix, const char *pszSuffix, KLDRDYLDSEARCH enmSearch,
|
---|
[2833] | 1036 | unsigned fFlags, PHKLDRMOD phMod, char *pszErr, size_t cchErr);
|
---|
[2832] | 1037 | int kLdrDyldUnload(HKLDRMOD hMod);
|
---|
[2843] | 1038 | int kLdrDyldFindByName(const char *pszDll, const char *pszPrefix, const char *pszSuffix, KLDRDYLDSEARCH enmSearch,
|
---|
[2836] | 1039 | unsigned fFlags, PHKLDRMOD phMod);
|
---|
[2833] | 1040 | int kLdrDyldFindByAddress(uintptr_t Address, PHKLDRMOD phMod, uint32_t *piSegment, uintptr_t *poffSegment);
|
---|
[2832] | 1041 | int kLdrDyldGetName(HKLDRMOD hMod, char *pszName, size_t cchName);
|
---|
[2835] | 1042 | int kLdrDyldGetFilename(HKLDRMOD hMod, char *pszFilename, size_t cchFilename);
|
---|
[2952] | 1043 | int kLdrDyldQuerySymbol(HKLDRMOD hMod, uint32_t uSymbolOrdinal, const char *pszSymbolName,
|
---|
[2891] | 1044 | const char *pszSymbolVersion, uintptr_t *pValue, uint32_t *pfKind);
|
---|
[2952] | 1045 | int kLdrDyldQueryResource(HKLDRMOD hMod, uint32_t idType, const char *pszType, uint32_t idName,
|
---|
[2891] | 1046 | const char *pszName, uint32_t idLang, void **pvRsrc, size_t *pcbRsrc);
|
---|
[2952] | 1047 | int kLdrDyldEnumResources(HKLDRMOD hMod, uint32_t idType, const char *pszType, uint32_t idName,
|
---|
[2891] | 1048 | const char *pszName, uint32_t idLang, PFNKLDRENUMRSRC pfnCallback, void *pvUser);
|
---|
[2832] | 1049 |
|
---|
| 1050 | /** @name OS/2 like API
|
---|
| 1051 | * @{ */
|
---|
[2891] | 1052 | #if defined(__OS2__)
|
---|
| 1053 | # define KLDROS2API _System
|
---|
| 1054 | #else
|
---|
| 1055 | # define KLDROS2API
|
---|
| 1056 | #endif
|
---|
[2832] | 1057 | int kLdrDosLoadModule(char *pszObject, size_t cbObject, const char *pszModule, PHKLDRMOD phMod);
|
---|
| 1058 | int kLdrDosFreeModule(HKLDRMOD hMod);
|
---|
| 1059 | int kLdrDosQueryModuleHandle(const char *pszModname, PHKLDRMOD phMod);
|
---|
| 1060 | int kLdrDosQueryModuleName(HKLDRMOD hMod, size_t cchName, char *pszName);
|
---|
| 1061 | int kLdrDosQueryProcAddr(HKLDRMOD hMod, uint32_t iOrdinal, const char *pszProcName, void **ppvProcAddr);
|
---|
| 1062 | int kLdrDosQueryProcType(HKLDRMOD hMod, uint32_t iOrdinal, const char *pszProcName, uint32_t *pfProcType);
|
---|
| 1063 | int kLdrDosQueryModFromEIP(PHKLDRMOD phMod, uint32_t *piObject, size_t cbName, char *pszName, uintptr_t *poffObject, uintptr_t ulEIP);
|
---|
| 1064 | int kLdrDosReplaceModule(const char *pszOldModule, const char *pszNewModule, const char *pszBackupModule);
|
---|
| 1065 | int kLdrDosGetResource(HKLDRMOD hMod, uint32_t idType, uint32_t idName, void **pvResAddr);
|
---|
[2891] | 1066 | int kLdrDosQueryResourceSize(HKLDRMOD hMod, uint32_t idType, uint32_t idName, uint32_t *pcb);
|
---|
[2832] | 1067 | int kLdrDosFreeResource(void *pvResAddr);
|
---|
| 1068 | /** @} */
|
---|
| 1069 |
|
---|
| 1070 | /** @name POSIX like API
|
---|
| 1071 | * @{ */
|
---|
| 1072 | HKLDRMOD kLdrDlOpen(const char *pszLibrary, int fFlags);
|
---|
| 1073 | const char *kLdrDlError(void);
|
---|
| 1074 | void * kLdrDlSym(HKLDRMOD hMod, const char *pszSymbol);
|
---|
| 1075 | int kLdrDlClose(HKLDRMOD hMod);
|
---|
[2891] | 1076 | /** @todo GNU extensions */
|
---|
[2832] | 1077 | /** @} */
|
---|
| 1078 |
|
---|
| 1079 | /** @name Win32 like API
|
---|
| 1080 | * @{ */
|
---|
[2891] | 1081 | #if defined(_MSC_VER)
|
---|
| 1082 | # define KLDRWINAPI __stdcall
|
---|
| 1083 | #else
|
---|
| 1084 | # define KLDRWINAPI
|
---|
| 1085 | #endif
|
---|
| 1086 | HKLDRMOD KLDRWINAPI kLdrWLoadLibrary(const char *pszFilename);
|
---|
| 1087 | HKLDRMOD KLDRWINAPI kLdrWLoadLibraryEx(const char *pszFilename, void *hFileReserved, uint32_t fFlags);
|
---|
| 1088 | uint32_t KLDRWINAPI kLdrWGetModuleFileName(HKLDRMOD hMod, char *pszModName, size_t cchModName);
|
---|
| 1089 | HKLDRMOD KLDRWINAPI kLdrWGetModuleHandle(const char *pszFilename);
|
---|
| 1090 | int KLDRWINAPI kLdrWGetModuleHandleEx(uint32_t fFlags, const char *pszFilename, HKLDRMOD hMod);
|
---|
| 1091 | void * KLDRWINAPI kLdrWGetProcAddress(HKLDRMOD hMod, const char *pszProcName);
|
---|
| 1092 | uint32_t KLDRWINAPI kLdrWGetDllDirectory(size_t cchDir, char *pszDir);
|
---|
| 1093 | int KLDRWINAPI kLdrWSetDllDirectory(const char *pszDir);
|
---|
| 1094 | int KLDRWINAPI kLdrWFreeLibrary(HKLDRMOD hMod);
|
---|
| 1095 | int KLDRWINAPI kLdrWDisableThreadLibraryCalls(HKLDRMOD hMod);
|
---|
[2832] | 1096 |
|
---|
[2891] | 1097 | /** The handle to a resource that's been found. */
|
---|
| 1098 | typedef struct KLDRWRSRCFOUND *HKLDRWRSRCFOUND;
|
---|
| 1099 | /** The handle to a loaded resource. */
|
---|
| 1100 | typedef struct KLDRWRSRCLOADED *HKLDRWRSRCLOADED;
|
---|
| 1101 | HKLDRWRSRCFOUND KLDRWINAPI kLdrWFindResource(HKLDRMOD hMod, const char *pszType, const char *pszName);
|
---|
| 1102 | HKLDRWRSRCFOUND KLDRWINAPI kLdrWFindResourceEx(HKLDRMOD hMod, const char *pszType, const char *pszName, uint16_t idLang);
|
---|
| 1103 | uint32_t KLDRWINAPI kLdrWSizeofResource(HKLDRMOD hMod, HKLDRWRSRCFOUND hFoundRsrc);
|
---|
| 1104 | HKLDRWRSRCLOADED KLDRWINAPI kLdrWLoadResource(HKLDRMOD hMod, HKLDRWRSRCFOUND hFoundRsrc);
|
---|
| 1105 | void *KLDRWINAPI kLdrWLockResource(HKLDRMOD hMod, HKLDRWRSRCLOADED hLoadedRsrc);
|
---|
| 1106 | int KLDRWINAPI kLdrWFreeResource(HKLDRMOD hMod, HKLDRWRSRCLOADED hLoadedRsrc);
|
---|
| 1107 |
|
---|
| 1108 | typedef int (KLDRWINAPI *PFNKLDRWENUMRESTYPE)(HKLDRMOD hMod, const char *pszType, uintptr_t uUser);
|
---|
| 1109 | int KLDRWINAPI kLdrWEnumResourceTypes(HKLDRMOD hMod, PFNKLDRWENUMRESTYPE pfnEnum, uintptr_t uUser);
|
---|
| 1110 | int KLDRWINAPI kLdrWEnumResourceTypesEx(HKLDRMOD hMod, PFNKLDRWENUMRESTYPE pfnEnum, uintptr_t uUser, uint32_t fFlags, uint16_t idLang);
|
---|
| 1111 |
|
---|
| 1112 | typedef int (KLDRWINAPI *PFNKLDRWENUMRESNAME)(HKLDRMOD hMod, const char *pszType, char *pszName, uintptr_t uUser);
|
---|
| 1113 | int KLDRWINAPI kLdrWEnumResourceNames(HKLDRMOD hMod, const char *pszType, PFNKLDRWENUMRESNAME pfnEnum, uintptr_t uUser);
|
---|
| 1114 | int KLDRWINAPI kLdrWEnumResourceNamesEx(HKLDRMOD hMod, const char *pszType, PFNKLDRWENUMRESNAME pfnEnum, uintptr_t uUser, uint32_t fFlags, uint16_t idLang);
|
---|
| 1115 |
|
---|
| 1116 | typedef int (KLDRWINAPI *PFNKLDRWENUMRESLANG)(HKLDRMOD hMod, const char *pszType, const char *pszName, uint16_t idLang, uintptr_t uUser);
|
---|
| 1117 | int KLDRWINAPI kLdrWEnumResourceLanguages(HKLDRMOD hMod, const char *pszType, const char *pszName, PFNKLDRWENUMRESLANG pfnEnum, uintptr_t uUser);
|
---|
| 1118 | int KLDRWINAPI kLdrWEnumResourceLanguagesEx(HKLDRMOD hMod, const char *pszType, const char *pszName,
|
---|
| 1119 | PFNKLDRWENUMRESLANG pfnEnum, uintptr_t uUser, uint32_t fFlags, uint16_t idLang);
|
---|
[2832] | 1120 | /** @} */
|
---|
| 1121 |
|
---|
| 1122 |
|
---|
[2821] | 1123 | /** @name Process Bootstrapping
|
---|
| 1124 | * @{ */
|
---|
| 1125 |
|
---|
| 1126 | /**
|
---|
| 1127 | * Argument package from the stub.
|
---|
| 1128 | */
|
---|
| 1129 | typedef struct KLDREXEARGS
|
---|
| 1130 | {
|
---|
[2875] | 1131 | /** Load & search flags, some which will become defaults. */
|
---|
[2821] | 1132 | uint32_t fFlags;
|
---|
[2875] | 1133 | /** The default search method. */
|
---|
[2843] | 1134 | KLDRDYLDSEARCH enmSearch;
|
---|
[2821] | 1135 | /** The executable file that the stub is supposed to load. */
|
---|
| 1136 | char szExecutable[260];
|
---|
[2843] | 1137 | /** The default prefix used when searching for DLLs. */
|
---|
| 1138 | char szDefPrefix[16];
|
---|
| 1139 | /** The default suffix used when searching for DLLs. */
|
---|
| 1140 | char szDefSuffix[16];
|
---|
[2821] | 1141 | /** The LD_LIBRARY_PATH prefix for the process.. */
|
---|
[2843] | 1142 | char szLibPath[4096 - sizeof(uint32_t) - sizeof(KLDRDYLDSEARCH) - 16 - 16 - 260];
|
---|
[2821] | 1143 | } KLDREXEARGS, *PKLDREXEARGS;
|
---|
[2874] | 1144 | /** Pointer to a const argument package from the stub. */
|
---|
| 1145 | typedef const KLDREXEARGS *PCKLDREXEARGS;
|
---|
[2821] | 1146 |
|
---|
[2875] | 1147 | void kLdrLoadExe(PCKLDREXEARGS pArgs, void *pvOS);
|
---|
[2832] | 1148 |
|
---|
[2821] | 1149 | /** @} */
|
---|
| 1150 |
|
---|
| 1151 | /** @} */
|
---|
| 1152 |
|
---|
[2827] | 1153 |
|
---|
| 1154 | /** @defgroup grp_kLdrErr kLdr Status Codes
|
---|
| 1155 | * kLdr uses a mix of native status codes and it's own status codes.
|
---|
| 1156 | * A status code of 0 means success, all other status codes means failure.
|
---|
| 1157 | * @{
|
---|
| 1158 | */
|
---|
[2965] | 1159 |
|
---|
| 1160 | #define KLDR_ERR_BASE 420000
|
---|
| 1161 |
|
---|
[2827] | 1162 | /** The image format is unknown. */
|
---|
[2965] | 1163 | #define KLDR_ERR_UNKNOWN_FORMAT (KLDR_ERR_BASE + 0)
|
---|
[2827] | 1164 | /** The MZ image format isn't supported by this kLdr build. */
|
---|
[2965] | 1165 | #define KLDR_ERR_MZ_NOT_SUPPORTED (KLDR_ERR_BASE + 1)
|
---|
[2827] | 1166 | /** The NE image format isn't supported by this kLdr build. */
|
---|
[2965] | 1167 | #define KLDR_ERR_NE_NOT_SUPPORTED (KLDR_ERR_BASE + 2)
|
---|
[2827] | 1168 | /** The LX image format isn't supported by this kLdr build. */
|
---|
[2965] | 1169 | #define KLDR_ERR_LX_NOT_SUPPORTED (KLDR_ERR_BASE + 3)
|
---|
[2827] | 1170 | /** The LE image format isn't supported by this kLdr build. */
|
---|
[2965] | 1171 | #define KLDR_ERR_LE_NOT_SUPPORTED (KLDR_ERR_BASE + 4)
|
---|
[2827] | 1172 | /** The PE image format isn't supported by this kLdr build. */
|
---|
[2965] | 1173 | #define KLDR_ERR_PE_NOT_SUPPORTED (KLDR_ERR_BASE + 5)
|
---|
[2827] | 1174 | /** The ELF image format isn't supported by this kLdr build. */
|
---|
[2965] | 1175 | #define KLDR_ERR_ELF_NOT_SUPPORTED (KLDR_ERR_BASE + 6)
|
---|
[2827] | 1176 | /** The mach-o image format isn't supported by this kLdr build. */
|
---|
[2965] | 1177 | #define KLDR_ERR_MACHO_NOT_SUPPORTED (KLDR_ERR_BASE + 7)
|
---|
[2954] | 1178 | /** The FAT image format isn't supported by this kLdr build or
|
---|
| 1179 | * a direct open was attempt without going thru the FAT file provider.
|
---|
| 1180 | * FAT images are also known as Universal Binaries. */
|
---|
[2965] | 1181 | #define KLDR_ERR_FAT_NOT_SUPPORTED (KLDR_ERR_BASE + 8)
|
---|
[2954] | 1182 | /** The a.out image format isn't supported by this kLdr build. */
|
---|
[2965] | 1183 | #define KLDR_ERR_AOUT_NOT_SUPPORTED (KLDR_ERR_BASE + 9)
|
---|
[2827] | 1184 |
|
---|
[2833] | 1185 | /** Invalid parameter to a kLdr API. */
|
---|
[2842] | 1186 | #define KLDR_ERR_INVALID_PARAMETER (KLDR_ERR_BASE + 32)
|
---|
[2833] | 1187 | /** Invalid handle parameter to a kLdr API. */
|
---|
[2842] | 1188 | #define KLDR_ERR_INVALID_HANDLE (KLDR_ERR_BASE + 33)
|
---|
| 1189 | /** The module wasn't loaded dynamically. */
|
---|
| 1190 | #define KLDR_ERR_NOT_LOADED_DYNAMICALLY (KLDR_ERR_BASE + 34)
|
---|
[2836] | 1191 | /** The module wasn't found. */
|
---|
[2842] | 1192 | #define KLDR_ERR_MODULE_NOT_FOUND (KLDR_ERR_BASE + 35)
|
---|
[2837] | 1193 | /** A prerequisit module wasn't found. */
|
---|
[2842] | 1194 | #define KLDR_ERR_PREREQUISITE_MODULE_NOT_FOUND (KLDR_ERR_BASE + 36)
|
---|
[2837] | 1195 | /** The module is being terminated and can therefore not be loaded. */
|
---|
[2842] | 1196 | #define KLDR_ERR_MODULE_TERMINATING (KLDR_ERR_BASE + 37)
|
---|
[2837] | 1197 | /** A prerequisit module is being terminated and can therefore not be loaded. */
|
---|
[2842] | 1198 | #define KLDR_ERR_PREREQUISITE_MODULE_TERMINATING (KLDR_ERR_BASE + 38)
|
---|
| 1199 | /** The module initialization failed. */
|
---|
| 1200 | #define KLDR_ERR_MODULE_INIT_FAILED (KLDR_ERR_BASE + 39)
|
---|
| 1201 | /** The initialization of a prerequisite module failed. */
|
---|
| 1202 | #define KLDR_ERR_PREREQUISITE_MODULE_INIT_FAILED (KLDR_ERR_BASE + 40)
|
---|
| 1203 | /** The module has already failed initialization and can't be attempted reloaded until
|
---|
| 1204 | * after we've finished garbage collection. */
|
---|
| 1205 | #define KLDR_ERR_MODULE_INIT_FAILED_ALREADY (KLDR_ERR_BASE + 41)
|
---|
| 1206 | /** A prerequisite module has already failed initialization and can't be attempted
|
---|
| 1207 | * reloaded until after we've finished garbage collection. */
|
---|
| 1208 | #define KLDR_ERR_PREREQUISITE_MODULE_INIT_FAILED_ALREADY (KLDR_ERR_BASE + 42)
|
---|
| 1209 | /** Prerequisite recursed too deeply. */
|
---|
| 1210 | #define KLDR_ERR_PREREQUISITE_RECURSED_TOO_DEEPLY (KLDR_ERR_BASE + 43)
|
---|
[2846] | 1211 | /** Failed to allocate the main stack. */
|
---|
| 1212 | #define KLDR_ERR_MAIN_STACK_ALLOC_FAILED (KLDR_ERR_BASE + 44)
|
---|
| 1213 | /** Buffer overflow. */
|
---|
| 1214 | #define KLDR_ERR_BUFFER_OVERFLOW (KLDR_ERR_BASE + 45)
|
---|
[2848] | 1215 | /** The specified ARCH+CPU isn't compatible with image. */
|
---|
[2945] | 1216 | #define KLDR_ERR_ARCH_CPU_NOT_COMPATIBLE (KLDR_ERR_BASE + 46)
|
---|
[2850] | 1217 | /** Symbol not found. */
|
---|
[2945] | 1218 | #define KLDR_ERR_SYMBOL_NOT_FOUND (KLDR_ERR_BASE + 47)
|
---|
[2854] | 1219 | /** A forward symbol was encountered but the caller didn't provide any means to resolve it. */
|
---|
[2945] | 1220 | #define KLDR_ERR_FORWARDER_SYMBOL (KLDR_ERR_BASE + 48)
|
---|
[2833] | 1221 | /** Encountered a bad fixup. */
|
---|
[2945] | 1222 | #define KLDR_ERR_BAD_FIXUP (KLDR_ERR_BASE + 49)
|
---|
[2842] | 1223 | /** A memory allocation failed. */
|
---|
[2945] | 1224 | #define KLDR_ERR_NO_MEMORY (KLDR_ERR_BASE + 50)
|
---|
[2855] | 1225 | /** The import ordinal was out of bounds. */
|
---|
[2945] | 1226 | #define KLDR_ERR_IMPORT_ORDINAL_OUT_OF_BOUNDS (KLDR_ERR_BASE + 51)
|
---|
[2855] | 1227 | /** A forwarder chain was too long. */
|
---|
[2945] | 1228 | #define KLDR_ERR_TOO_LONG_FORWARDER_CHAIN (KLDR_ERR_BASE + 52)
|
---|
[2856] | 1229 | /** The module has no debug info. */
|
---|
[2945] | 1230 | #define KLDR_ERR_NO_DEBUG_INFO (KLDR_ERR_BASE + 53)
|
---|
[2856] | 1231 | /** The module is already mapped.
|
---|
| 1232 | * kLdrModMap() can only be called once (without kLdrModUnmap() in between). */
|
---|
[2945] | 1233 | #define KLDR_ERR_ALREADY_MAPPED (KLDR_ERR_BASE + 54)
|
---|
[2856] | 1234 | /** The module was not mapped.
|
---|
| 1235 | * kLdrModUnmap() should not called without being preceeded by a kLdrModMap(). */
|
---|
[2945] | 1236 | #define KLDR_ERR_NOT_MAPPED (KLDR_ERR_BASE + 55)
|
---|
[2857] | 1237 | /** Couldn't fit the address value into the field. Typically a relocation kind of error. */
|
---|
[2945] | 1238 | #define KLDR_ERR_ADDRESS_OVERFLOW (KLDR_ERR_BASE + 56)
|
---|
[2961] | 1239 | /** Couldn't fit a calculated size value into the native size type of the host. */
|
---|
| 1240 | #define KLDR_ERR_SIZE_OVERFLOW (KLDR_ERR_BASE + 57)
|
---|
[2857] | 1241 | /** Thread attach failed. */
|
---|
[2961] | 1242 | #define KLDR_ERR_THREAD_ATTACH_FAILED (KLDR_ERR_BASE + 58)
|
---|
[2861] | 1243 | /** The file reader can't take more concurrent mappings. */
|
---|
[2961] | 1244 | #define KLDR_ERR_TOO_MANY_MAPPINGS (KLDR_ERR_BASE + 59)
|
---|
[2870] | 1245 | /** The module wasn't a DLL or object file. */
|
---|
[2961] | 1246 | #define KLDR_ERR_NOT_DLL (KLDR_ERR_BASE + 60)
|
---|
[2870] | 1247 | /** The module wasn't an EXE. */
|
---|
[2961] | 1248 | #define KLDR_ERR_NOT_EXE (KLDR_ERR_BASE + 61)
|
---|
[2956] | 1249 | /** Not implemented yet. */
|
---|
[2961] | 1250 | #define KLDR_ERR_TODO (KLDR_ERR_BASE + 62)
|
---|
[2842] | 1251 |
|
---|
[2857] | 1252 |
|
---|
[2854] | 1253 | /** @name kLdrModPE status codes
|
---|
| 1254 | * @{ */
|
---|
[2961] | 1255 | #define KLDR_ERR_PE_BASE (KLDR_ERR_BASE + 63)
|
---|
[2854] | 1256 | /** The machine isn't supported by the interpreter. */
|
---|
[2879] | 1257 | #define KLDR_ERR_PE_UNSUPPORTED_MACHINE (KLDR_ERR_PE_BASE + 0)
|
---|
[2854] | 1258 | /** The file handler isn't valid. */
|
---|
[2879] | 1259 | #define KLDR_ERR_PE_BAD_FILE_HEADER (KLDR_ERR_PE_BASE + 1)
|
---|
[2854] | 1260 | /** The the optional headers isn't valid. */
|
---|
[2879] | 1261 | #define KLDR_ERR_PE_BAD_OPTIONAL_HEADER (KLDR_ERR_PE_BASE + 2)
|
---|
[2854] | 1262 | /** One of the section headers aren't valid. */
|
---|
[2879] | 1263 | #define KLDR_ERR_PE_BAD_SECTION_HEADER (KLDR_ERR_PE_BASE + 3)
|
---|
[2854] | 1264 | /** Bad forwarder entry. */
|
---|
[2879] | 1265 | #define KLDR_ERR_PE_BAD_FORWARDER (KLDR_ERR_PE_BASE + 4)
|
---|
[2854] | 1266 | /** Forwarder module not found in the import descriptor table. */
|
---|
[2879] | 1267 | #define KLDR_ERR_PE_FORWARDER_IMPORT_NOT_FOUND (KLDR_ERR_PE_BASE + 5)
|
---|
[2857] | 1268 | /** Bad PE fixups. */
|
---|
[2879] | 1269 | #define KLDR_ERR_PE_BAD_FIXUP (KLDR_ERR_PE_BASE + 6)
|
---|
[2857] | 1270 | /** Bad PE import (thunk). */
|
---|
[2879] | 1271 | #define KLDR_ERR_PE_BAD_IMPORT (KLDR_ERR_PE_BASE + 7)
|
---|
[2827] | 1272 | /** @} */
|
---|
| 1273 |
|
---|
[2879] | 1274 | /** @name kLdrModLX status codes
|
---|
| 1275 | * @{ */
|
---|
| 1276 | #define KLDR_ERR_LX_BASE (KLDR_ERR_PE_BASE + 8)
|
---|
| 1277 | /** validation of LX header failed. */
|
---|
| 1278 | #define KLDR_ERR_LX_BAD_HEADER (KLDR_ERR_LX_BASE + 0)
|
---|
| 1279 | /** validation of the loader section (in the LX header) failed. */
|
---|
| 1280 | #define KLDR_ERR_LX_BAD_LOADER_SECTION (KLDR_ERR_LX_BASE + 1)
|
---|
| 1281 | /** validation of the fixup section (in the LX header) failed. */
|
---|
| 1282 | #define KLDR_ERR_LX_BAD_FIXUP_SECTION (KLDR_ERR_LX_BASE + 2)
|
---|
| 1283 | /** validation of the LX object table failed. */
|
---|
| 1284 | #define KLDR_ERR_LX_BAD_OBJECT_TABLE (KLDR_ERR_LX_BASE + 3)
|
---|
[2880] | 1285 | /** A bad page map entry was encountered. */
|
---|
| 1286 | #define KLDR_ERR_LX_BAD_PAGE_MAP (KLDR_ERR_LX_BASE + 4)
|
---|
| 1287 | /** Bad iterdata (EXEPACK) data. */
|
---|
| 1288 | #define KLDR_ERR_LX_BAD_ITERDATA (KLDR_ERR_LX_BASE + 5)
|
---|
| 1289 | /** Bad iterdata2 (EXEPACK2) data. */
|
---|
| 1290 | #define KLDR_ERR_LX_BAD_ITERDATA2 (KLDR_ERR_LX_BASE + 6)
|
---|
[2882] | 1291 | /** Bad bundle data. */
|
---|
| 1292 | #define KLDR_ERR_LX_BAD_BUNDLE (KLDR_ERR_LX_BASE + 7)
|
---|
| 1293 | /** No soname. */
|
---|
| 1294 | #define KLDR_ERR_LX_NO_SONAME (KLDR_ERR_LX_BASE + 8)
|
---|
| 1295 | /** Bad soname. */
|
---|
| 1296 | #define KLDR_ERR_LX_BAD_SONAME (KLDR_ERR_LX_BASE + 9)
|
---|
| 1297 | /** Bad forwarder entry. */
|
---|
| 1298 | #define KLDR_ERR_LX_BAD_FORWARDER (KLDR_ERR_LX_BASE + 10)
|
---|
[2889] | 1299 | /** internal fixup chain isn't implemented yet. */
|
---|
| 1300 | #define KLDR_ERR_LX_NRICHAIN_NOT_SUPPORTED (KLDR_ERR_LX_BASE + 11)
|
---|
[2879] | 1301 | /** @} */
|
---|
| 1302 |
|
---|
[2952] | 1303 | /** @name
|
---|
| 1304 | * @{ */
|
---|
| 1305 | #define KLDR_ERR_MACHO_BASE (KLDR_ERR_LX_BASE + 12)
|
---|
[2954] | 1306 | /** Only native endian Mach-O files are supported. */
|
---|
[2952] | 1307 | #define KLDR_ERR_MACHO_OTHER_ENDIAN_NOT_SUPPORTED (KLDR_ERR_MACHO_BASE + 0)
|
---|
[2954] | 1308 | /** 64-bit Mach-O files aren't supported yet. */
|
---|
[2952] | 1309 | #define KLDR_ERR_MACHO_64BIT_NOT_SUPPORTED (KLDR_ERR_MACHO_BASE + 1)
|
---|
[2954] | 1310 | /** The Mach-O header is bad or contains new and unsupported features. */
|
---|
[2952] | 1311 | #define KLDR_ERR_MACHO_BAD_HEADER (KLDR_ERR_MACHO_BASE + 2)
|
---|
| 1312 | /** The file type isn't supported. */
|
---|
| 1313 | #define KLDR_ERR_MACHO_UNSUPPORTED_FILE_TYPE (KLDR_ERR_MACHO_BASE + 3)
|
---|
| 1314 | /** The machine (cputype / cpusubtype combination) isn't supported. */
|
---|
| 1315 | #define KLDR_ERR_MACHO_UNSUPPORTED_MACHINE (KLDR_ERR_MACHO_BASE + 4)
|
---|
[2954] | 1316 | /** Bad load command(s). */
|
---|
| 1317 | #define KLDR_ERR_MACHO_BAD_LOAD_COMMAND (KLDR_ERR_MACHO_BASE + 5)
|
---|
| 1318 | /** Encountered an unknown load command.*/
|
---|
| 1319 | #define KLDR_ERR_MACHO_UNKNOWN_LOAD_COMMAND (KLDR_ERR_MACHO_BASE + 6)
|
---|
| 1320 | /** Encountered a load command that's not implemented.*/
|
---|
| 1321 | #define KLDR_ERR_MACHO_UNSUPPORTED_LOAD_COMMAND (KLDR_ERR_MACHO_BASE + 7)
|
---|
| 1322 | /** Bad section. */
|
---|
| 1323 | #define KLDR_ERR_MACHO_BAD_SECTION (KLDR_ERR_MACHO_BASE + 8)
|
---|
| 1324 | /** Encountered a section type that's not implemented.*/
|
---|
| 1325 | #define KLDR_ERR_MACHO_UNSUPPORTED_SECTION (KLDR_ERR_MACHO_BASE + 9)
|
---|
| 1326 | /** Encountered a section type that's not known to the loader. (probably invalid) */
|
---|
| 1327 | #define KLDR_ERR_MACHO_UNKNOWN_SECTION (KLDR_ERR_MACHO_BASE + 10)
|
---|
| 1328 | /** The sections aren't ordered by segment as expected by the loader. */
|
---|
| 1329 | #define KLDR_ERR_MACHO_BAD_SECTION_ORDER (KLDR_ERR_MACHO_BASE + 11)
|
---|
[2955] | 1330 | /** The image is 32-bit and contains 64-bit load commands or vise versa. */
|
---|
| 1331 | #define KLDR_ERR_MACHO_BIT_MIX (KLDR_ERR_MACHO_BASE + 12)
|
---|
[2961] | 1332 | /** Bad MH_OBJECT file. */
|
---|
[2955] | 1333 | #define KLDR_ERR_MACHO_BAD_OBJECT_FILE (KLDR_ERR_MACHO_BASE + 13)
|
---|
[2961] | 1334 | /** Bad symbol table entry. */
|
---|
| 1335 | #define KLDR_ERR_MACHO_BAD_SYMBOL (KLDR_ERR_MACHO_BASE + 14)
|
---|
[2964] | 1336 | /** Unsupported fixup type. */
|
---|
| 1337 | #define KLDR_ERR_MACHO_UNSUPPORTED_FIXUP_TYPE (KLDR_ERR_MACHO_BASE + 15)
|
---|
[2952] | 1338 | /** @} */
|
---|
| 1339 |
|
---|
[2868] | 1340 | /** End of the valid kLdr status codes. */
|
---|
[2964] | 1341 | #define KLDR_ERR_END (KLDR_ERR_MACHO_BASE + 16)
|
---|
[2827] | 1342 |
|
---|
[2955] | 1343 | const char *kLdrErrStr(int rc);
|
---|
| 1344 |
|
---|
[2854] | 1345 | /** @} */
|
---|
| 1346 |
|
---|
| 1347 |
|
---|
[2821] | 1348 | #ifdef __cplusplus
|
---|
| 1349 | }
|
---|
| 1350 | #endif
|
---|
| 1351 |
|
---|
| 1352 | #endif
|
---|
| 1353 |
|
---|