[2826] | 1 | /* $Id: kLdr.h 2843 2006-10-30 04:16:08Z 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 |
|
---|
| 27 | #ifndef __kLdr_h__
|
---|
| 28 | #define __kLdr_h__
|
---|
| 29 |
|
---|
| 30 | #ifdef __cplusplus
|
---|
| 31 | extern "C" {
|
---|
| 32 | #endif
|
---|
| 33 |
|
---|
[2824] | 34 | /* kLdr depend on size_t, [u]intNN_t, [u]intptr_t and some related constants. */
|
---|
[2821] | 35 | #include <sys/types.h>
|
---|
[2825] | 36 | #include <stddef.h>
|
---|
| 37 | #ifdef _MSC_VER
|
---|
| 38 | typedef signed char int8_t;
|
---|
| 39 | typedef unsigned char uint8_t;
|
---|
| 40 | typedef signed short int16_t;
|
---|
| 41 | typedef unsigned short uint16_t;
|
---|
| 42 | typedef signed int int32_t;
|
---|
| 43 | typedef unsigned int uint32_t;
|
---|
| 44 | typedef signed __int64 int64_t;
|
---|
| 45 | typedef unsigned __int64 uint64_t;
|
---|
[2836] | 46 | typedef int64_t intmax_t;
|
---|
[2825] | 47 | typedef uint64_t uintmax_t;
|
---|
| 48 | #else
|
---|
| 49 | # include <stdint.h>
|
---|
| 50 | #endif
|
---|
[2821] | 51 |
|
---|
[2824] | 52 |
|
---|
[2825] | 53 | /** @defgroup grp_kLdrRdr kLdrRdr - The file provider
|
---|
| 54 | * @{ */
|
---|
[2821] | 55 |
|
---|
[2840] | 56 | /**
|
---|
| 57 | * Memory Mapping Protections.
|
---|
| 58 | *
|
---|
| 59 | * @remark Shared segments can be mapped using the non copy-on-write variant.
|
---|
| 60 | * (Normally the copy-on-write variant is used because changes must
|
---|
| 61 | * be private and not shared with other processes mapping the file.)
|
---|
| 62 | */
|
---|
[2829] | 63 | typedef enum KLDRPROT
|
---|
| 64 | {
|
---|
| 65 | /** The usual invalid 0. */
|
---|
| 66 | KLDRPROT_INVALID = 0,
|
---|
| 67 | /** No access (page not present). */
|
---|
| 68 | KLDRPROT_NOACCESS,
|
---|
| 69 | /** Read only. */
|
---|
| 70 | KLDRPROT_READONLY,
|
---|
| 71 | /** Read & write. */
|
---|
| 72 | KLDRPROT_READWRITE,
|
---|
| 73 | /** Read & copy on write. */
|
---|
| 74 | KLDRPROT_WRITECOPY,
|
---|
| 75 | /** Execute only. */
|
---|
| 76 | KLDRPROT_EXECUTE,
|
---|
| 77 | /** Execute & read. */
|
---|
[2830] | 78 | KLDRPROT_EXECUTE_READ,
|
---|
[2829] | 79 | /** Execute, read & write. */
|
---|
| 80 | KLDRPROT_EXECUTE_READWRITE,
|
---|
| 81 | /** Execute, read & copy on write. */
|
---|
| 82 | KLDRPROT_EXECUTE_WRITECOPY,
|
---|
| 83 | /** The usual end value. (exclusive) */
|
---|
| 84 | KLDRPROT_END,
|
---|
| 85 | /** Blow the type up to 32-bits. */
|
---|
| 86 | KLDRPROT_32BIT_HACK = 0x7fffffff
|
---|
| 87 | } KLDRPROT;
|
---|
| 88 |
|
---|
| 89 |
|
---|
[2825] | 90 | /** Pointer to a file provider instance core. */
|
---|
| 91 | typedef struct KLDRRDR *PKLDRRDR;
|
---|
| 92 | /** Pointer to a file provider instance core pointer. */
|
---|
| 93 | typedef struct KLDRRDR **PPKLDRRDR;
|
---|
| 94 |
|
---|
[2821] | 95 | /**
|
---|
[2825] | 96 | * File provider instance operations.
|
---|
| 97 | */
|
---|
| 98 | typedef struct KLDRRDROPS
|
---|
| 99 | {
|
---|
| 100 | /** The name of this file provider. */
|
---|
| 101 | const char *pszName;
|
---|
| 102 | /** Pointer to the next file provider. */
|
---|
| 103 | const struct KLDRRDROPS *pNext;
|
---|
| 104 |
|
---|
| 105 | /** Try create a new file provider instance.
|
---|
| 106 | *
|
---|
| 107 | * @returns 0 on success, OS specific error code on failure.
|
---|
| 108 | * @param ppRdr Where to store the file provider instance.
|
---|
| 109 | * @param pszFilename The filename to open.
|
---|
| 110 | */
|
---|
| 111 | int (* pfnCreate)( PPKLDRRDR ppRdr, const char *pszFilename);
|
---|
| 112 | /** Destroy the file provider instance.
|
---|
| 113 | *
|
---|
| 114 | * @returns 0 on success, OS specific error code on failure.
|
---|
| 115 | * On failure, the file provider instance will be in an indeterminate state - don't touch it!
|
---|
| 116 | * @param pRdr The file provider instance.
|
---|
| 117 | */
|
---|
| 118 | int (* pfnDestroy)( PKLDRRDR pRdr);
|
---|
| 119 | /** Read bits from the file.
|
---|
| 120 | *
|
---|
| 121 | * @returns 0 on success, OS specific error code on failure.
|
---|
| 122 | * @param pRdr The file provider instance.
|
---|
| 123 | * @param pvBuf Where to put the bits.
|
---|
| 124 | * @param cb The number of bytes to read.
|
---|
| 125 | * @param off Where to start reading.
|
---|
| 126 | */
|
---|
| 127 | int (* pfnRead)( PKLDRRDR pRdr, void *pvBuf, size_t cb, off_t off);
|
---|
| 128 | /** Map all the file bits into memory (read only).
|
---|
| 129 | *
|
---|
| 130 | * @returns 0 on success, OS specific error code on failure.
|
---|
| 131 | * @param pRdr The file provider instance.
|
---|
| 132 | * @param ppvBits Where to store the address of the mapping.
|
---|
| 133 | * The size can be obtained using pfnSize.
|
---|
| 134 | */
|
---|
| 135 | int (* pfnAllMap)( PKLDRRDR pRdr, const void **ppvBits);
|
---|
| 136 | /** Unmap a file bits mapping obtained by KLDRRDROPS::pfnAllMap.
|
---|
| 137 | *
|
---|
| 138 | * @returns 0 on success, OS specific error code on failure.
|
---|
| 139 | * @param pRdr The file provider instance.
|
---|
| 140 | * @param pvBits The mapping address.
|
---|
| 141 | */
|
---|
| 142 | int (* pfnAllUnmap)(PKLDRRDR pRdr, const void *pvBits);
|
---|
| 143 | /** Get the file size.
|
---|
| 144 | *
|
---|
| 145 | * @returns The file size. Returns -1 on failure.
|
---|
| 146 | * @param pRdr The file provider instance.
|
---|
| 147 | */
|
---|
| 148 | off_t (* pfnSize)( PKLDRRDR pRdr);
|
---|
| 149 | /** Get the file pointer offset.
|
---|
| 150 | *
|
---|
| 151 | * @returns The file pointer offset. Returns -1 on failure.
|
---|
| 152 | * @param pRdr The file provider instance.
|
---|
| 153 | */
|
---|
| 154 | off_t (* pfnTell)( PKLDRRDR pRdr);
|
---|
| 155 | /** Get the file name.
|
---|
| 156 | *
|
---|
| 157 | * @returns The file size. Returns -1 on failure.
|
---|
| 158 | * @param pRdr The file provider instance.
|
---|
| 159 | */
|
---|
| 160 | const char * (* pfnName)(PKLDRRDR pRdr);
|
---|
[2829] | 161 | /**
|
---|
| 162 | * Prepares a memory region to map file sections into.
|
---|
| 163 | *
|
---|
| 164 | * @returns 0 on success, OS specific error code on failure.
|
---|
| 165 | * @param pRdr The file provider instance.
|
---|
| 166 | * @param ppv If fFixed is set, *ppv contains the memory location which
|
---|
| 167 | * the region should be based at. If fFixed is clear the OS
|
---|
| 168 | * is free to choose the location.
|
---|
| 169 | * On successful return *ppv contains address of the prepared
|
---|
| 170 | * memory region.
|
---|
| 171 | * @param cb The size of the memory region to prepare.
|
---|
| 172 | * @param fFixed When set *ppv will contain the desired region address.
|
---|
| 173 | *
|
---|
| 174 | */
|
---|
| 175 | int (* pfnPrepare)(PKLDRRDR pRdr, void **ppv, size_t cb, unsigned fFixed);
|
---|
| 176 | /**
|
---|
| 177 | * Maps a section of the file into the memory region reserved by pfnPrepare.
|
---|
| 178 | *
|
---|
| 179 | * @returns 0 on success, OS specific error code on failure.
|
---|
| 180 | * @param pRdr The file provider instance.
|
---|
| 181 | * @param pv The address in the prepared region.
|
---|
| 182 | * @param cb The size of the memory mapping.
|
---|
| 183 | * @param enmProt The desired memory protection.
|
---|
| 184 | * @param offFile The start of the raw file bytes.
|
---|
| 185 | * @param cbFile The number of raw file bytes. This must be less or equal to cb.
|
---|
| 186 | */
|
---|
| 187 | int (* pfnMap)(PKLDRRDR pRdr, void *pv, size_t cb, KLDRPROT enmProt, off_t offFile, size_t cbFile);
|
---|
| 188 | /**
|
---|
| 189 | * Changes the page protection of a section mapped using pfnMap.
|
---|
| 190 | *
|
---|
| 191 | * This is typically used for applying fixups and similar.
|
---|
| 192 | *
|
---|
| 193 | * @returns 0 on success, OS specific error code on failure.
|
---|
| 194 | * @param pRdr The file provider instance.
|
---|
| 195 | * @param pv The address passed to pfnMap.
|
---|
| 196 | * @param cb The size passed to pfnMap.
|
---|
| 197 | * @param enmProt The desired memory protection.
|
---|
| 198 | */
|
---|
| 199 | int (* pfnProtect)(PKLDRRDR pRdr, void *pv, size_t cb, KLDRPROT enmProt);
|
---|
| 200 | /**
|
---|
| 201 | * Unmaps a section of the file previously mapped using pfnMap.
|
---|
| 202 | *
|
---|
| 203 | * @returns 0 on success, OS specific error code on failure.
|
---|
| 204 | * @param pRdr The file provider instance.
|
---|
| 205 | * @param pv The address passed to pfnMap.
|
---|
| 206 | * @param cb The size passed to pfnMap.
|
---|
| 207 | */
|
---|
| 208 | int (* pfnUnmap)(PKLDRRDR pRdr, void *pv, size_t cb);
|
---|
| 209 | /**
|
---|
| 210 | * Releases the memory region prepared by pfnPrepare().
|
---|
| 211 | *
|
---|
| 212 | * Before calling this function, all sections mapped by pfnMap must first be unmapped by calling pfnUnmap.
|
---|
| 213 | *
|
---|
| 214 | * @returns 0 on success, OS specific error code on failure.
|
---|
| 215 | * @param pRdr The file provider instance.
|
---|
| 216 | * @param pv The address of the prepared region.
|
---|
| 217 | * @param cb The size of the prepared region.
|
---|
| 218 | */
|
---|
| 219 | int (* pfnUnprepare)(PKLDRRDR pRdr, void *pv, size_t cb);
|
---|
| 220 | /**
|
---|
| 221 | * We're done reading from the file but would like to keep file mappings.
|
---|
| 222 | *
|
---|
| 223 | * If the OS support closing the file handle while the file is mapped,
|
---|
| 224 | * the reader should do so.
|
---|
| 225 | *
|
---|
| 226 | * @param pRdr The file provider instance.
|
---|
| 227 | */
|
---|
| 228 | void (* pfnDone)(PKLDRRDR pRdr);
|
---|
| 229 | /** The usual non-zero dummy that makes sure we've initialized all members. */
|
---|
| 230 | uint32_t u32Dummy;
|
---|
[2825] | 231 | } KLDRRDROPS;
|
---|
| 232 | /** Pointer to file provider operations. */
|
---|
| 233 | typedef KLDRRDROPS *PKLDRRDROPS;
|
---|
| 234 | /** Pointer to const file provider operations. */
|
---|
| 235 | typedef const KLDRRDROPS *PCKLDRRDROPS;
|
---|
| 236 |
|
---|
| 237 |
|
---|
| 238 | /**
|
---|
| 239 | * File provider instance core.
|
---|
| 240 | */
|
---|
| 241 | typedef struct KLDRRDR
|
---|
| 242 | {
|
---|
| 243 | /** Pointer to the file provider operations. */
|
---|
| 244 | PCKLDRRDROPS pOps;
|
---|
| 245 | } KLDRRDR;
|
---|
| 246 |
|
---|
| 247 | void kLdrRdrAddProvider(PKLDRRDROPS pAdd);
|
---|
| 248 |
|
---|
| 249 | int kLdrRdrOpen( PPKLDRRDR ppRdr, const char *pszFilename);
|
---|
| 250 | int kLdrRdrClose( PKLDRRDR pRdr);
|
---|
| 251 | int kLdrRdrRead( PKLDRRDR pRdr, void *pvBuf, size_t cb, off_t off);
|
---|
| 252 | int kLdrRdrAllMap( PKLDRRDR pRdr, const void **ppvBits);
|
---|
| 253 | int kLdrRdrAllUnmap(PKLDRRDR pRdr, const void *pvBits);
|
---|
| 254 | off_t kLdrRdrSize( PKLDRRDR pRdr);
|
---|
| 255 | off_t kLdrRdrTell( PKLDRRDR pRdr);
|
---|
| 256 | const char *kLdrRdrName(PKLDRRDR pRdr);
|
---|
| 257 |
|
---|
| 258 | /** @} */
|
---|
| 259 |
|
---|
| 260 |
|
---|
| 261 |
|
---|
| 262 | /** @defgroup grp_kLdrMod kLdrMod - The executable image intepreter
|
---|
| 263 | * @{ */
|
---|
| 264 |
|
---|
| 265 | /**
|
---|
[2835] | 266 | * Stack information.
|
---|
| 267 | */
|
---|
| 268 | typedef struct KLDRSTACKINFO
|
---|
| 269 | {
|
---|
| 270 | /** The base address of the stack (sub) segment, link address.
|
---|
| 271 | * Set this to ~(uintptr_t)0 if the module doesn't include any stack (sub)segment. */
|
---|
| 272 | uintmax_t uLinkAddress;
|
---|
| 273 | /** The base address of the stack (sub) segment, actual load address.
|
---|
| 274 | * Set this to ~(uintptr_t)0 if the module doesn't include any stack (sub)segment or if
|
---|
| 275 | * the module isn't mapped (loaded) yet. */
|
---|
| 276 | uintmax_t uLoadAddress;
|
---|
| 277 | /** The stack size of the main thread.
|
---|
| 278 | * If no stack (sub)segment in the module, this is the stack size of the main thread.
|
---|
| 279 | * If the module doesn't contain this kind of information this field will be set to 0. */
|
---|
| 280 | uintmax_t cbStack;
|
---|
| 281 | /** The stack size of non-main threads.
|
---|
| 282 | * If the module doesn't contain this kind of information this field will be set to 0. */
|
---|
| 283 | uintmax_t cbStackThread;
|
---|
| 284 | } KLDRSTACKINFO, *PKLDRSTACKINFO;
|
---|
| 285 |
|
---|
| 286 |
|
---|
| 287 | /**
|
---|
[2821] | 288 | * Loader segment.
|
---|
| 289 | */
|
---|
| 290 | typedef struct KLDRSEG
|
---|
| 291 | {
|
---|
[2832] | 292 | /** Variable free to use for the kLdr user. */
|
---|
| 293 | void *pvUser;
|
---|
| 294 | /** The segment name. */
|
---|
| 295 | const char *pszName;
|
---|
[2821] | 296 | /** The size of the segment. */
|
---|
[2836] | 297 | uintmax_t cb;
|
---|
[2832] | 298 | /** The link time load address. */
|
---|
[2836] | 299 | uintmax_t LinkAddress;
|
---|
[2832] | 300 | /** The actual load address (if loaded). */
|
---|
[2836] | 301 | uintmax_t LoadAddress;
|
---|
[2832] | 302 | /** The segment protection. */
|
---|
| 303 | KLDRPROT enmProt;
|
---|
[2821] | 304 | } KLDRSEG, *PKLDRSEG;
|
---|
| 305 |
|
---|
| 306 |
|
---|
| 307 | /**
|
---|
[2832] | 308 | * Loader module format.
|
---|
| 309 | */
|
---|
| 310 | typedef enum KLDRFMT
|
---|
| 311 | {
|
---|
| 312 | /** The usual invalid 0 format. */
|
---|
| 313 | KLDRFMT_INVALID = 0,
|
---|
| 314 | /** The native OS loader. */
|
---|
| 315 | KLDRFMT_NATIVE,
|
---|
| 316 | /** The AOUT loader. */
|
---|
| 317 | KLDRFMT_AOUT,
|
---|
| 318 | /** The ELF loader. */
|
---|
| 319 | KLDRFMT_ELF,
|
---|
| 320 | /** The LX loader. */
|
---|
| 321 | KLDRFMT_LX,
|
---|
| 322 | /** The mach-o loader. */
|
---|
| 323 | KLDRFMT_MACHO,
|
---|
| 324 | /** The LX loader. */
|
---|
| 325 | KLDRFMT_PE,
|
---|
| 326 | /** The end of the valid format values (exclusive). */
|
---|
| 327 | KLDRFMT_END,
|
---|
| 328 | /** Hack to blow the type up to 32-bit. */
|
---|
| 329 | KLDRFMT_32BIT_HACK = 0x7fffffff
|
---|
| 330 | } KLDRFMT;
|
---|
| 331 |
|
---|
| 332 |
|
---|
| 333 | /**
|
---|
[2821] | 334 | * Loader module type.
|
---|
| 335 | */
|
---|
| 336 | typedef enum KLDRTYPE
|
---|
| 337 | {
|
---|
| 338 | /** The usual invalid 0 type. */
|
---|
| 339 | KLDRTYPE_INVALID = 0,
|
---|
[2832] | 340 | /** Object file. */
|
---|
| 341 | KLDRTYPE_OBJECT,
|
---|
| 342 | /** Executable module, fixed load address. */
|
---|
| 343 | KLDRTYPE_EXECUTABLE_FIXED,
|
---|
| 344 | /** Executable module, relocatable, non-fixed load address. */
|
---|
| 345 | KLDRTYPE_EXECUTABLE_RELOCATABLE,
|
---|
| 346 | /** Executable module, position independent code, non-fixed load address. */
|
---|
| 347 | KLDRTYPE_EXECUTABLE_PIC,
|
---|
| 348 | /** Shared library, fixed load address.
|
---|
| 349 | * Typically a system library. */
|
---|
| 350 | KLDRTYPE_SHARED_LIBRARY_FIXED,
|
---|
| 351 | /** Shared library, relocatable, non-fixed load address. */
|
---|
| 352 | KLDRTYPE_SHARED_LIBRARY_RELOCATABLE,
|
---|
| 353 | /** Shared library, position independent code, non-fixed load address. */
|
---|
| 354 | KLDRTYPE_SHARED_LIBRARY_PIC,
|
---|
| 355 | /** DLL that contains no code or data only imports and exports. (Chiefly OS/2.) */
|
---|
| 356 | KLDRTYPE_FORWARDER_DLL,
|
---|
| 357 | /** Core or dump. */
|
---|
| 358 | KLDRTYPE_CORE,
|
---|
| 359 | /** The end of the valid types values (exclusive). */
|
---|
[2821] | 360 | KLDRTYPE_END,
|
---|
| 361 | /** Hack to blow the type up to 32-bit. */
|
---|
| 362 | KLDRTYPE_32BIT_HACK = 0x7fffffff
|
---|
| 363 | } KLDRTYPE;
|
---|
| 364 |
|
---|
| 365 |
|
---|
| 366 | /**
|
---|
[2832] | 367 | * CPU Architecture.
|
---|
| 368 | * @todo Double check the non intel architectures.
|
---|
| 369 | */
|
---|
| 370 | typedef enum KLDRARCH
|
---|
| 371 | {
|
---|
| 372 | /** The usual invalid one. */
|
---|
| 373 | KLDRARCH_INVALID = 0,
|
---|
| 374 | /** Clone or Intel 16-bit x86. */
|
---|
| 375 | KLDRARCH_X86_16,
|
---|
| 376 | /** Clone or Intel 32-bit x86. */
|
---|
| 377 | KLDRARCH_X86_32,
|
---|
| 378 | /** AMD64 (including clones). */
|
---|
| 379 | KLDRARCH_AMD64,
|
---|
| 380 | /** Itanic (64-bit). */
|
---|
| 381 | KLDRARCH_IA64,
|
---|
| 382 | /** ALPHA (64-bit). */
|
---|
| 383 | KLDRARCH_ALPHA,
|
---|
| 384 | /** ALPHA limited to 32-bit. */
|
---|
| 385 | KLDRARCH_ALPHA_32,
|
---|
| 386 | /** 32-bit ARM. */
|
---|
| 387 | KLDRARCH_ARM_32,
|
---|
| 388 | /** 64-bit ARM. */
|
---|
| 389 | KLDRARCH_ARM_64,
|
---|
| 390 | /** 32-bit MIPS. */
|
---|
| 391 | KLDRARCH_MIPS_32,
|
---|
| 392 | /** 64-bit MIPS. */
|
---|
| 393 | KLDRARCH_MIPS_64,
|
---|
| 394 | /** 32-bit PowerPC. */
|
---|
| 395 | KLDRARCH_POWERPC_32,
|
---|
| 396 | /** 64-bit PowerPC. */
|
---|
| 397 | KLDRARCH_POWERPC_64,
|
---|
| 398 | /** 32-bit SPARC. */
|
---|
| 399 | KLDRARCH_SPARC_32,
|
---|
| 400 | /** 64-bit SPARC. */
|
---|
| 401 | KLDRARCH_SPARC_64,
|
---|
| 402 | /** The end of the valid architecture values (exclusive). */
|
---|
| 403 | KLDRARCH_END,
|
---|
| 404 | /** Hack to blow the type up to 32-bit. */
|
---|
| 405 | KLDRARCH_32BIT_HACK = 0x7fffffff
|
---|
| 406 | } KLDRARCH;
|
---|
| 407 |
|
---|
| 408 | /**
|
---|
| 409 | * CPU models.
|
---|
| 410 | */
|
---|
| 411 | typedef enum KLDRCPU
|
---|
| 412 | {
|
---|
| 413 | /** The usual invalid cpu. */
|
---|
| 414 | KLDRCPU_INVALID = 0,
|
---|
| 415 | /** @name KLDRARCH_X86_16
|
---|
| 416 | * @{ */
|
---|
| 417 | KLDRCPU_I8086,
|
---|
| 418 | KLDRCPU_I8088,
|
---|
| 419 | KLDRCPU_I80186,
|
---|
| 420 | KLDRCPU_I80286,
|
---|
| 421 | KLDRCPU_I386_16,
|
---|
| 422 | KLDRCPU_I486_16,
|
---|
| 423 | KLDRCPU_I486SX_16,
|
---|
| 424 | KLDRCPU_I586_16,
|
---|
| 425 | KLDRCPU_I686_16,
|
---|
| 426 | KLDRCPU_K6_16,
|
---|
| 427 | KLDRCPU_K7_16,
|
---|
| 428 | KLDRCPU_K8_16,
|
---|
| 429 | /** @} */
|
---|
| 430 |
|
---|
| 431 | /** @name KLDRARCH_X86_32
|
---|
| 432 | * @{ */
|
---|
| 433 | KLDRCPU_I386,
|
---|
| 434 | KLDRCPU_I486,
|
---|
| 435 | KLDRCPU_I486SX,
|
---|
| 436 | KLDRCPU_I586,
|
---|
| 437 | KLDRCPU_I686,
|
---|
| 438 | KLDRCPU_P4,
|
---|
| 439 | KLDRCPU_CORE2_32,
|
---|
| 440 | KLDRCPU_K6,
|
---|
| 441 | KLDRCPU_K7,
|
---|
| 442 | KLDRCPU_K8_32,
|
---|
| 443 | /** @} */
|
---|
| 444 |
|
---|
| 445 | /** @name KLDRARCH_AMD64
|
---|
| 446 | * @{ */
|
---|
| 447 | KLDRCPU_K8,
|
---|
| 448 | KLDRCPU_P4_64,
|
---|
| 449 | KLDRCPU_CORE2,
|
---|
| 450 | /** @} */
|
---|
| 451 |
|
---|
| 452 | /** The end of the valid cpu values (exclusive). */
|
---|
| 453 | KLDRCPU_END,
|
---|
| 454 | /** Hack to blow the type up to 32-bit. */
|
---|
| 455 | KLDRCPU_32BIT_HACK = 0x7fffffff
|
---|
| 456 | } KLDRCPU;
|
---|
| 457 |
|
---|
| 458 |
|
---|
| 459 | /**
|
---|
| 460 | * Loader endian indicator.
|
---|
| 461 | */
|
---|
| 462 | typedef enum KLDRENDIAN
|
---|
| 463 | {
|
---|
| 464 | /** The usual invalid endian. */
|
---|
| 465 | KLDRENDIAN_INVALID,
|
---|
| 466 | /** Little endian. */
|
---|
| 467 | KLDRENDIAN_LITTLE,
|
---|
| 468 | /** Bit endian. */
|
---|
| 469 | KLDRENDIAN_BIG,
|
---|
| 470 | /** Endianness doesn't have a meaning in the context. */
|
---|
| 471 | KLDRENDIAN_NA,
|
---|
| 472 | /** The end of the valid endian values (exclusive). */
|
---|
| 473 | KLDRENDIAN_END,
|
---|
| 474 | /** Hack to blow the type up to 32-bit. */
|
---|
| 475 | KLDRENDIAN_32BIT_HACK = 0x7fffffff
|
---|
| 476 | } KLDRENDIAN;
|
---|
| 477 |
|
---|
| 478 |
|
---|
| 479 | /**
|
---|
[2821] | 480 | * Loader module.
|
---|
| 481 | */
|
---|
| 482 | typedef struct KLDRMOD
|
---|
| 483 | {
|
---|
[2825] | 484 | /** Magic number. */
|
---|
| 485 | uint32_t u32Magic;
|
---|
[2832] | 486 | /** The format of this module. */
|
---|
| 487 | KLDRFMT enmFmt;
|
---|
| 488 | /** The type of module. */
|
---|
[2825] | 489 | KLDRTYPE enmType;
|
---|
[2832] | 490 | /** The architecture this module was built for. */
|
---|
| 491 | KLDRARCH enmArch;
|
---|
| 492 | /** The minium cpu this module was built for.
|
---|
| 493 | * This might not be accurate, so use kLdrModCanExecuteOn() to check. */
|
---|
| 494 | KLDRARCH enmCpu;
|
---|
| 495 | /** The endian used by the module. */
|
---|
| 496 | KLDRENDIAN enmEndian;
|
---|
[2821] | 497 | /** The filename length (bytes). */
|
---|
| 498 | uint32_t cchFilename;
|
---|
| 499 | /** The filename. */
|
---|
| 500 | const char *pszFilename;
|
---|
| 501 | /** The module name. */
|
---|
| 502 | const char *pszName;
|
---|
| 503 | /** The module name length (bytes). */
|
---|
| 504 | uint32_t cchName;
|
---|
| 505 | /** The number of segments in the module. */
|
---|
| 506 | uint32_t cSegments;
|
---|
[2832] | 507 | /** The module data. */
|
---|
| 508 | void *pvData;
|
---|
[2821] | 509 | /** Segments. (variable size, can be zero) */
|
---|
| 510 | KLDRSEG aSegments[1];
|
---|
| 511 | } KLDRMOD, *PKLDRMOD, **PPKLDRMOD;
|
---|
| 512 |
|
---|
| 513 |
|
---|
[2832] | 514 | /** Special base address value alias for the link address. */
|
---|
| 515 | #define KLDRMOD_BASEADDRESS_LINK (~(uintmax_t)1)
|
---|
| 516 | /** Special base address value alias for the actual load address (must be mapped). */
|
---|
| 517 | #define KLDRMOD_BASEADDRESS_MAP (~(uintmax_t)2)
|
---|
[2825] | 518 |
|
---|
[2832] | 519 | /** @name Load symbol kind flags.
|
---|
| 520 | * @{ */
|
---|
| 521 | /** The bitness doesn't matter. */
|
---|
| 522 | #define KLDRSYMKIND_NO_BIT 0x00000000
|
---|
| 523 | /** 16-bit symbol. */
|
---|
| 524 | #define KLDRSYMKIND_16BIT 0x00000001
|
---|
| 525 | /** 32-bit symbol. */
|
---|
| 526 | #define KLDRSYMKIND_32BIT 0x00000002
|
---|
| 527 | /** 64-bit symbol. */
|
---|
| 528 | #define KLDRSYMKIND_64BIT 0x00000003
|
---|
| 529 | /** Mask out the bit.*/
|
---|
| 530 | #define KLDRSYMKIND_BIT_MASK 0x00000003
|
---|
| 531 | /** We don't know the type of symbol. */
|
---|
| 532 | #define KLDRSYMKIND_NO_TYPE 0x00000000
|
---|
| 533 | /** The symbol is a code object (method/function/procedure/whateveryouwannacallit). */
|
---|
| 534 | #define KLDRSYMKIND_CODE 0x00000010
|
---|
| 535 | /** The symbol is a data object. */
|
---|
| 536 | #define KLDRSYMKIND_DATA 0x00000020
|
---|
| 537 | /** Mask out the symbol type. */
|
---|
| 538 | #define KLDRSYMKIND_TYPE_MASK 0x00000030
|
---|
| 539 | /** Valid symbol kind mask. */
|
---|
| 540 | #define KLDRSYMKIND_MASK 0x00000033
|
---|
| 541 | /** @} */
|
---|
[2825] | 542 |
|
---|
| 543 | /** @name kLdrModEnumSymbols flags.
|
---|
| 544 | * @{ */
|
---|
| 545 | /** Returns ALL kinds of symbols. The default is to only return public/exported symbols. */
|
---|
| 546 | #define KLDRMOD_ENUM_SYMBOL_FLAGS_ALL 0x00000001
|
---|
| 547 | /** @} */
|
---|
| 548 |
|
---|
[2832] | 549 |
|
---|
| 550 | typedef int FNKLDRMODGETIMPORT(PKLDRMOD pMod, const char *pszModule, const char *pszSymbol, uint32_t uSymbol,
|
---|
| 551 | uintmax_t *pValue, uint32_t *pfKind, void *pvModuleUser, void *pvUser);
|
---|
| 552 | typedef FNKLDRMODGETIMPORT *PFNKLDRMODGETIMPORT;
|
---|
| 553 | typedef int FNKLDRMODENUMIMPMODS(PKLDRMOD pMod, const char *pszImpMod, unsigned fFlags, void *pvUser);
|
---|
| 554 | typedef FNKLDRMODENUMIMPMODS *PFNKLDRMODENUMIMPMODS;
|
---|
| 555 | typedef int FNKLDRMODENUMSYMS(PKLDRMOD pMod, const char *pszSymbol, unsigned uSymbol, uintmax_t Value, uint32_t fKind, void *pvUser);
|
---|
| 556 | typedef FNKLDRMODENUMSYMS *PFNKLDRMODENUMSYMS;
|
---|
| 557 |
|
---|
| 558 | int kLdrModOpen(const char *pszFilename, PPKLDRMOD ppMod);
|
---|
| 559 | int kLdrModClose(PKLDRMOD pMod);
|
---|
| 560 | int kLdrModGetSymbol(PKLDRMOD pMod, const void *pvBits, uintmax_t BaseAddress, const char *pszSymbol, uintmax_t *pValue, uint32_t *pfKind);
|
---|
| 561 | int kLdrModEnumSymbols(PKLDRMOD pMod, unsigned fFlags, const void *pvBits, uintmax_t BaseAddress, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser);
|
---|
| 562 | int kLdrModEnumImportModules(PKLDRMOD pMod, unsigned fFlags, const void *pvBits, FNKLDRMODENUMIMPMODS pfnCallback, void *pvUser);
|
---|
| 563 | int kLdrModMap(PKLDRMOD pMod);
|
---|
| 564 | int kLdrModUnmap(PKLDRMOD pMod);
|
---|
| 565 | int kLdrModFixupMapping(PKLDRMOD pMod, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);
|
---|
| 566 | size_t kLdrModSize(PKLDRMOD pMod);
|
---|
| 567 | int kLdrModGetBits(PKLDRMOD pMod, void *pvBits, uintmax_t BaseAddress, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);
|
---|
| 568 | int kLdrModRelocateBits(PKLDRMOD pMod, void *pvBits, uintmax_t NewBaseAddress, uintmax_t OldBaseAddress, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);
|
---|
| 569 | int kLdrModCanExecuteOn(PKLDRMOD pMod, KLDRARCH enmArch, KLDRCPU enmCpu);
|
---|
[2835] | 570 | int kLdrModGetStackInfo(PKLDRMOD pMod, PKLDRSTACKINFO pStackInfo);
|
---|
[2832] | 571 |
|
---|
[2825] | 572 | /** @} */
|
---|
| 573 |
|
---|
| 574 |
|
---|
| 575 |
|
---|
| 576 |
|
---|
[2832] | 577 | /** @defgroup grp_kLdrDyld kLdrDyld - The dynamic loader
|
---|
[2825] | 578 | * @{ */
|
---|
| 579 |
|
---|
[2832] | 580 | /** The handle to a dynamic loader module. */
|
---|
[2833] | 581 | typedef struct KLDRDYLDMOD *HKLDRMOD;
|
---|
[2832] | 582 | /** Pointer to the handle to a dynamic loader module. */
|
---|
| 583 | typedef HKLDRMOD *PHKLDRMOD;
|
---|
[2833] | 584 | /** NIL handle value. */
|
---|
| 585 | #define NIL_HKLDRMOD ((HKLDRMOD)0)
|
---|
[2825] | 586 |
|
---|
| 587 |
|
---|
[2832] | 588 | /**
|
---|
| 589 | * File search method.
|
---|
| 590 | *
|
---|
| 591 | * In addition to it's own way of finding files, kLdr emulates
|
---|
| 592 | * the methods employed by the most popular systems.
|
---|
| 593 | */
|
---|
| 594 | typedef enum KLDRDYLDSEARCH
|
---|
| 595 | {
|
---|
| 596 | /** The usual invalid file search method. */
|
---|
| 597 | KLDRDYLD_SEARCH_INVALID = 0,
|
---|
| 598 | /** Uses the kLdr file search method.
|
---|
| 599 | * @todo invent me. */
|
---|
| 600 | KLDRDYLD_SEARCH_KLDR,
|
---|
| 601 | /** Use the emulation closest to the host system. */
|
---|
| 602 | KLDRDYLD_SEARCH_HOST,
|
---|
| 603 | /** Emulate the OS/2 file search method.
|
---|
| 604 | * On non-OS/2 systems, BEGINLIBPATH, LIBPATH, ENDLIBPATH and LIBPATHSTRICT are
|
---|
| 605 | * taken form the environment. */
|
---|
| 606 | KLDRDYLD_SEARCH_OS2,
|
---|
| 607 | /** Emulate the standard window file search method. */
|
---|
| 608 | KLDRDYLD_SEARCH_WINDOWS,
|
---|
| 609 | /** Emulate the alternative window file search method. */
|
---|
| 610 | KLDRDYLD_SEARCH_WINDOWS_ALTERED,
|
---|
| 611 | /** Emulate the most common UNIX file search method. */
|
---|
| 612 | KLDRDYLD_SEARCH_UNIX_COMMON,
|
---|
[2833] | 613 | /** End of the valid file search method values. */
|
---|
| 614 | KLDRDYLD_SEARCH_END,
|
---|
| 615 | /** Hack to blow the type up to 32-bit. */
|
---|
| 616 | KLDRDYLD_SEARCH_32BIT_HACK = 0x7fffffff
|
---|
[2832] | 617 | } KLDRDYLDSEARCH;
|
---|
| 618 |
|
---|
[2836] | 619 | /** @name kLdrDyldLoad and kLdrDyldFindByName flags.
|
---|
[2832] | 620 | * @{ */
|
---|
| 621 | /** The symbols in the module should be loaded into the global unix namespace.
|
---|
| 622 | * If not specified, the symbols are local and can only be referenced directly. */
|
---|
| 623 | #define KLDRYDLD_LOAD_FLAGS_GLOBAL_SYMBOLS 0x00000001
|
---|
| 624 | /** The module shouldn't be found by a global module search.
|
---|
| 625 | * If not specified, the module can be found by unspecified module searches,
|
---|
| 626 | * typical used when loading import/dep modules. */
|
---|
| 627 | #define KLDRYDLD_LOAD_FLAGS_SPECIFIC_MODULE 0x00000002
|
---|
[2843] | 628 | /** Do a recursive initialization calls instead of defering them to the outermost call. */
|
---|
| 629 | #define KLDRDYLD_LOAD_FLAGS_RECURSIVE_INIT 0x00000004
|
---|
| 630 | /** We're loading the executable module.
|
---|
| 631 | * Internal flag which will be rejected by kLdrDyldLoad. */
|
---|
| 632 | #define KLDRDYLD_LOAD_FLAGS_EXECUTABLE 0x40000000
|
---|
[2832] | 633 | /** @} */
|
---|
| 634 |
|
---|
| 635 |
|
---|
[2843] | 636 | int kLdrDyldLoad(const char *pszDll, const char *pszPrefix, const char *pszSuffix, KLDRDYLDSEARCH enmSearch,
|
---|
[2833] | 637 | unsigned fFlags, PHKLDRMOD phMod, char *pszErr, size_t cchErr);
|
---|
[2832] | 638 | int kLdrDyldUnload(HKLDRMOD hMod);
|
---|
[2843] | 639 | int kLdrDyldFindByName(const char *pszDll, const char *pszPrefix, const char *pszSuffix, KLDRDYLDSEARCH enmSearch,
|
---|
[2836] | 640 | unsigned fFlags, PHKLDRMOD phMod);
|
---|
[2833] | 641 | int kLdrDyldFindByAddress(uintptr_t Address, PHKLDRMOD phMod, uint32_t *piSegment, uintptr_t *poffSegment);
|
---|
[2832] | 642 | int kLdrDyldGetName(HKLDRMOD hMod, char *pszName, size_t cchName);
|
---|
[2835] | 643 | int kLdrDyldGetFilename(HKLDRMOD hMod, char *pszFilename, size_t cchFilename);
|
---|
[2832] | 644 | int kLdrDyldQuerySymbol(HKLDRMOD hMod, uint32_t uSymbolOrdinal, const char *pszSymbolName, uintptr_t *pValue, uint32_t *pfKind);
|
---|
| 645 |
|
---|
| 646 | /** @name OS/2 like API
|
---|
| 647 | * @{ */
|
---|
| 648 | int kLdrDosLoadModule(char *pszObject, size_t cbObject, const char *pszModule, PHKLDRMOD phMod);
|
---|
| 649 | int kLdrDosFreeModule(HKLDRMOD hMod);
|
---|
| 650 | int kLdrDosQueryModuleHandle(const char *pszModname, PHKLDRMOD phMod);
|
---|
| 651 | int kLdrDosQueryModuleName(HKLDRMOD hMod, size_t cchName, char *pszName);
|
---|
| 652 | int kLdrDosQueryProcAddr(HKLDRMOD hMod, uint32_t iOrdinal, const char *pszProcName, void **ppvProcAddr);
|
---|
| 653 | int kLdrDosQueryProcType(HKLDRMOD hMod, uint32_t iOrdinal, const char *pszProcName, uint32_t *pfProcType);
|
---|
| 654 | int kLdrDosQueryModFromEIP(PHKLDRMOD phMod, uint32_t *piObject, size_t cbName, char *pszName, uintptr_t *poffObject, uintptr_t ulEIP);
|
---|
| 655 | int kLdrDosReplaceModule(const char *pszOldModule, const char *pszNewModule, const char *pszBackupModule);
|
---|
| 656 | int kLdrDosGetResource(HKLDRMOD hMod, uint32_t idType, uint32_t idName, void **pvResAddr);
|
---|
| 657 | int kLdrDosQueryResourceSize(HKLDRMOD hMod, uint32_t idTypeID, uint32_t idName, uint32_t *pcb);
|
---|
| 658 | int kLdrDosFreeResource(void *pvResAddr);
|
---|
| 659 | /** @} */
|
---|
| 660 |
|
---|
| 661 | /** @name POSIX like API
|
---|
| 662 | * @{ */
|
---|
| 663 | HKLDRMOD kLdrDlOpen(const char *pszLibrary, int fFlags);
|
---|
| 664 | const char *kLdrDlError(void);
|
---|
| 665 | void * kLdrDlSym(HKLDRMOD hMod, const char *pszSymbol);
|
---|
| 666 | int kLdrDlClose(HKLDRMOD hMod);
|
---|
| 667 | /** @} */
|
---|
| 668 |
|
---|
| 669 | /** @name Win32 like API
|
---|
| 670 | * @{ */
|
---|
| 671 | HKLDRMOD kLdrWLoadLibrary(const char *pszFilename);
|
---|
| 672 | HKLDRMOD kLdrWLoadLibraryEx(const char *pszFilename, void *hFileReserved, uint32_t fFlags);
|
---|
| 673 | uint32_t kLdrWGetModuleFileName(HKLDRMOD hMod, char *pszModName, size_t cchModName);
|
---|
| 674 | HKLDRMOD kLdrWGetModuleHandle(const char *pszFilename);
|
---|
| 675 | int kLdrWGetModuleHandleEx(uint32_t fFlags, const char *pszFilename, HKLDRMOD hMod);
|
---|
| 676 | void * kLdrWGetProcAddress(HKLDRMOD hMod, const char *pszProcName);
|
---|
| 677 | uint32_t kLdrWGetDllDirectory(size_t cchDir, char *pszDir);
|
---|
| 678 | int kLdrWSetDllDirectory(const char *pszDir);
|
---|
| 679 | int kLdrWFreeLibrary(HKLDRMOD hMod);
|
---|
| 680 | int kLdrWDisableThreadLibraryCalls(HKLDRMOD hMod);
|
---|
| 681 |
|
---|
| 682 | /** @} */
|
---|
| 683 |
|
---|
| 684 |
|
---|
[2821] | 685 | /** @name Process Bootstrapping
|
---|
| 686 | * @{ */
|
---|
| 687 |
|
---|
| 688 | /**
|
---|
| 689 | * Argument package from the stub.
|
---|
| 690 | */
|
---|
| 691 | typedef struct KLDREXEARGS
|
---|
| 692 | {
|
---|
| 693 | /** Flags. (Currently unused, MBZ.) */
|
---|
| 694 | uint32_t fFlags;
|
---|
[2843] | 695 | /** The search method to use when loading this executable. */
|
---|
| 696 | KLDRDYLDSEARCH enmSearch;
|
---|
[2821] | 697 | /** The executable file that the stub is supposed to load. */
|
---|
| 698 | char szExecutable[260];
|
---|
[2843] | 699 | /** The default prefix used when searching for DLLs. */
|
---|
| 700 | char szDefPrefix[16];
|
---|
| 701 | /** The default suffix used when searching for DLLs. */
|
---|
| 702 | char szDefSuffix[16];
|
---|
[2821] | 703 | /** The LD_LIBRARY_PATH prefix for the process.. */
|
---|
[2843] | 704 | char szLibPath[4096 - sizeof(uint32_t) - sizeof(KLDRDYLDSEARCH) - 16 - 16 - 260];
|
---|
[2821] | 705 | } KLDREXEARGS, *PKLDREXEARGS;
|
---|
| 706 |
|
---|
[2832] | 707 | void kLdrLoadExe(PKLDREXEARGS pArgs, void *pvOS);
|
---|
| 708 |
|
---|
[2821] | 709 | /** @} */
|
---|
| 710 |
|
---|
| 711 | /** @} */
|
---|
| 712 |
|
---|
[2827] | 713 |
|
---|
| 714 | /** @defgroup grp_kLdrErr kLdr Status Codes
|
---|
| 715 | * kLdr uses a mix of native status codes and it's own status codes.
|
---|
| 716 | * A status code of 0 means success, all other status codes means failure.
|
---|
| 717 | * @{
|
---|
| 718 | */
|
---|
| 719 | #ifdef __OS2__
|
---|
| 720 | # define KLDR_ERR_BASE 0x7face000
|
---|
| 721 | #elif defined(__WIN__)
|
---|
| 722 | # define KLDR_ERR_BASE 0x7face000
|
---|
| 723 | #else
|
---|
| 724 | # error "port me"
|
---|
| 725 | #endif
|
---|
| 726 | /** The image format is unknown. */
|
---|
| 727 | #define KLDR_ERR_UNKNOWN_FORMAT (KLDR_ERR_BASE + 0)
|
---|
| 728 | /** The MZ image format isn't supported by this kLdr build. */
|
---|
| 729 | #define KLDR_ERR_MZ_NOT_SUPPORTED (KLDR_ERR_BASE + 1)
|
---|
| 730 | /** The NE image format isn't supported by this kLdr build. */
|
---|
| 731 | #define KLDR_ERR_NE_NOT_SUPPORTED (KLDR_ERR_BASE + 2)
|
---|
| 732 | /** The LX image format isn't supported by this kLdr build. */
|
---|
| 733 | #define KLDR_ERR_LX_NOT_SUPPORTED (KLDR_ERR_BASE + 3)
|
---|
| 734 | /** The LE image format isn't supported by this kLdr build. */
|
---|
| 735 | #define KLDR_ERR_LE_NOT_SUPPORTED (KLDR_ERR_BASE + 4)
|
---|
| 736 | /** The PE image format isn't supported by this kLdr build. */
|
---|
| 737 | #define KLDR_ERR_PE_NOT_SUPPORTED (KLDR_ERR_BASE + 5)
|
---|
| 738 | /** The ELF image format isn't supported by this kLdr build. */
|
---|
| 739 | #define KLDR_ERR_ELF_NOT_SUPPORTED (KLDR_ERR_BASE + 6)
|
---|
| 740 | /** The mach-o image format isn't supported by this kLdr build. */
|
---|
| 741 | #define KLDR_ERR_MACHO_NOT_SUPPORTED (KLDR_ERR_BASE + 7)
|
---|
| 742 | /** The mach-o image format isn't supported by this kLdr build. */
|
---|
| 743 | #define KLDR_ERR_AOUT_NOT_SUPPORTED (KLDR_ERR_BASE + 8)
|
---|
| 744 |
|
---|
[2833] | 745 | /** Invalid parameter to a kLdr API. */
|
---|
[2842] | 746 | #define KLDR_ERR_INVALID_PARAMETER (KLDR_ERR_BASE + 32)
|
---|
[2833] | 747 | /** Invalid handle parameter to a kLdr API. */
|
---|
[2842] | 748 | #define KLDR_ERR_INVALID_HANDLE (KLDR_ERR_BASE + 33)
|
---|
| 749 | /** The module wasn't loaded dynamically. */
|
---|
| 750 | #define KLDR_ERR_NOT_LOADED_DYNAMICALLY (KLDR_ERR_BASE + 34)
|
---|
[2836] | 751 | /** The module wasn't found. */
|
---|
[2842] | 752 | #define KLDR_ERR_MODULE_NOT_FOUND (KLDR_ERR_BASE + 35)
|
---|
[2837] | 753 | /** A prerequisit module wasn't found. */
|
---|
[2842] | 754 | #define KLDR_ERR_PREREQUISITE_MODULE_NOT_FOUND (KLDR_ERR_BASE + 36)
|
---|
[2837] | 755 | /** The module is being terminated and can therefore not be loaded. */
|
---|
[2842] | 756 | #define KLDR_ERR_MODULE_TERMINATING (KLDR_ERR_BASE + 37)
|
---|
[2837] | 757 | /** A prerequisit module is being terminated and can therefore not be loaded. */
|
---|
[2842] | 758 | #define KLDR_ERR_PREREQUISITE_MODULE_TERMINATING (KLDR_ERR_BASE + 38)
|
---|
| 759 | /** The module initialization failed. */
|
---|
| 760 | #define KLDR_ERR_MODULE_INIT_FAILED (KLDR_ERR_BASE + 39)
|
---|
| 761 | /** The initialization of a prerequisite module failed. */
|
---|
| 762 | #define KLDR_ERR_PREREQUISITE_MODULE_INIT_FAILED (KLDR_ERR_BASE + 40)
|
---|
| 763 | /** The module has already failed initialization and can't be attempted reloaded until
|
---|
| 764 | * after we've finished garbage collection. */
|
---|
| 765 | #define KLDR_ERR_MODULE_INIT_FAILED_ALREADY (KLDR_ERR_BASE + 41)
|
---|
| 766 | /** A prerequisite module has already failed initialization and can't be attempted
|
---|
| 767 | * reloaded until after we've finished garbage collection. */
|
---|
| 768 | #define KLDR_ERR_PREREQUISITE_MODULE_INIT_FAILED_ALREADY (KLDR_ERR_BASE + 42)
|
---|
| 769 | /** Prerequisite recursed too deeply. */
|
---|
| 770 | #define KLDR_ERR_PREREQUISITE_RECURSED_TOO_DEEPLY (KLDR_ERR_BASE + 43)
|
---|
[2833] | 771 |
|
---|
[2837] | 772 |
|
---|
[2833] | 773 | /** Encountered a bad fixup. */
|
---|
[2842] | 774 | #define KLDR_ERR_BAD_FIXUP (KLDR_ERR_BASE + 48)
|
---|
[2833] | 775 |
|
---|
[2842] | 776 | /** A memory allocation failed. */
|
---|
| 777 | #define KLDR_ERR_NO_MEMORY (KLDR_ERR_BASE + 64)
|
---|
| 778 |
|
---|
[2827] | 779 | /** @} */
|
---|
| 780 |
|
---|
| 781 |
|
---|
[2821] | 782 | #ifdef __cplusplus
|
---|
| 783 | }
|
---|
| 784 | #endif
|
---|
| 785 |
|
---|
| 786 | #endif
|
---|
| 787 |
|
---|