source: trunk/kLdr/kLdr.h@ 2859

Last change on this file since 2859 was 2859, checked in by bird, 19 years ago

More debugging.

  • Property svn:keywords set to Id
File size: 41.6 KB
Line 
1/* $Id: kLdr.h 2859 2006-11-06 04:48:53Z bird $ */
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
31extern "C" {
32#endif
33
34/* kLdr depend on size_t, [u]intNN_t, [u]intptr_t and some related constants. */
35#include <sys/types.h>
36#include <stddef.h>
37#ifdef _MSC_VER
38typedef signed char int8_t;
39typedef unsigned char uint8_t;
40typedef signed short int16_t;
41typedef unsigned short uint16_t;
42typedef signed int int32_t;
43typedef unsigned int uint32_t;
44typedef signed __int64 int64_t;
45typedef unsigned __int64 uint64_t;
46typedef int64_t intmax_t;
47typedef uint64_t uintmax_t;
48#else
49# include <stdint.h>
50#endif
51
52
53/** @defgroup grp_kLdrRdr kLdrRdr - The file provider
54 * @{ */
55
56/** The kLdr address type. */
57typedef uint64_t KLDRADDR;
58/** Pointer to a kLdr address. */
59typedef KLDRADDR *PKLDRADDR;
60/** Pointer to a const kLdr address. */
61typedef const KLDRADDR *PCKLDRADDR;
62
63/** NIL address. */
64#define NIL_KLDRADDR (~(uint64_t)0)
65
66/** @def PRI_KLDRADDR
67 * printf format type. */
68#ifdef _MSC_VER
69# define PRI_KLDRADDR "I64x"
70#else
71# define PRI_KLDRADDR "llx"
72#endif
73
74
75/** The kLdr size type. */
76typedef uint64_t KLDRSIZE;
77/** Pointer to a kLdr size. */
78typedef KLDRSIZE *PKLDRSIZE;
79/** Pointer to a const kLdr size. */
80typedef const KLDRSIZE *PCKLDRSIZE;
81
82/** @def PRI_KLDRSIZE
83 * printf format type. */
84#ifdef _MSC_VER
85# define PRI_KLDRSIZE "I64x"
86#else
87# define PRI_KLDRSIZE "llx"
88#endif
89
90
91
92/**
93 * Memory Mapping Protections.
94 *
95 * @remark Shared segments can be mapped using the non copy-on-write variant.
96 * (Normally the copy-on-write variant is used because changes must
97 * be private and not shared with other processes mapping the file.)
98 */
99typedef enum KLDRPROT
100{
101 /** The usual invalid 0. */
102 KLDRPROT_INVALID = 0,
103 /** No access (page not present). */
104 KLDRPROT_NOACCESS,
105 /** Read only. */
106 KLDRPROT_READONLY,
107 /** Read & write. */
108 KLDRPROT_READWRITE,
109 /** Read & copy on write. */
110 KLDRPROT_WRITECOPY,
111 /** Execute only. */
112 KLDRPROT_EXECUTE,
113 /** Execute & read. */
114 KLDRPROT_EXECUTE_READ,
115 /** Execute, read & write. */
116 KLDRPROT_EXECUTE_READWRITE,
117 /** Execute, read & copy on write. */
118 KLDRPROT_EXECUTE_WRITECOPY,
119 /** The usual end value. (exclusive) */
120 KLDRPROT_END,
121 /** Blow the type up to 32-bits. */
122 KLDRPROT_32BIT_HACK = 0x7fffffff
123} KLDRPROT;
124
125
126/** Pointer to a file provider instance core. */
127typedef struct KLDRRDR *PKLDRRDR;
128/** Pointer to a file provider instance core pointer. */
129typedef struct KLDRRDR **PPKLDRRDR;
130
131/**
132 * File provider instance operations.
133 */
134typedef struct KLDRRDROPS
135{
136 /** The name of this file provider. */
137 const char *pszName;
138 /** Pointer to the next file provider. */
139 const struct KLDRRDROPS *pNext;
140
141 /** Try create a new file provider instance.
142 *
143 * @returns 0 on success, OS specific error code on failure.
144 * @param ppRdr Where to store the file provider instance.
145 * @param pszFilename The filename to open.
146 */
147 int (* pfnCreate)( PPKLDRRDR ppRdr, const char *pszFilename);
148 /** Destroy the file provider instance.
149 *
150 * @returns 0 on success, OS specific error code on failure.
151 * On failure, the file provider instance will be in an indeterminate state - don't touch it!
152 * @param pRdr The file provider instance.
153 */
154 int (* pfnDestroy)( PKLDRRDR pRdr);
155 /** @copydoc kLdrRdrRead */
156 int (* pfnRead)( PKLDRRDR pRdr, void *pvBuf, size_t cb, off_t off);
157 /** @copydoc kLdrRdrAllMap */
158 int (* pfnAllMap)( PKLDRRDR pRdr, const void **ppvBits);
159 /** @copydoc kLdrRdrAllUnmap */
160 int (* pfnAllUnmap)(PKLDRRDR pRdr, const void *pvBits);
161 /** @copydoc kLdrRdrSize */
162 off_t (* pfnSize)( PKLDRRDR pRdr);
163 /** @copydoc kLdrRdrTell */
164 off_t (* pfnTell)( PKLDRRDR pRdr);
165 /** @copydoc kLdrRdrName */
166 const char * (* pfnName)(PKLDRRDR pRdr);
167 /** @copydoc kLdrRdrPageSize */
168 size_t (* pfnPageSize)(PKLDRRDR pRdr);
169 /** @copydoc kLdrRdrPrepare */
170 int (* pfnPrepare)(PKLDRRDR pRdr, void **ppv, size_t cb, unsigned fFixed);
171 /** @copydoc kLdrRdrMap */
172 int (* pfnMap)(PKLDRRDR pRdr, void *pv, size_t cb, KLDRPROT enmProt, off_t offFile, size_t cbFile);
173 /** @copydoc kLdrRdrRefreshMap */
174 int (* pfnRefreshMap)(PKLDRRDR pRdr, void *pv, size_t cb, KLDRPROT enmProt, off_t offFile, size_t cbFile);
175 /** @copydoc kLdrRdrProtect */
176 int (* pfnProtect)(PKLDRRDR pRdr, void *pv, size_t cb, KLDRPROT enmProt);
177 /** @copydoc kLdrRdrUnmap */
178 int (* pfnUnmap)(PKLDRRDR pRdr, void *pv, size_t cb);
179 /** @copydoc kLdrRdrUnprepare */
180 int (* pfnUnprepare)(PKLDRRDR pRdr, void *pv, size_t cb);
181 /** @copydoc kLdrRdrDone */
182 void (* pfnDone)(PKLDRRDR pRdr);
183 /** The usual non-zero dummy that makes sure we've initialized all members. */
184 uint32_t u32Dummy;
185} KLDRRDROPS;
186/** Pointer to file provider operations. */
187typedef KLDRRDROPS *PKLDRRDROPS;
188/** Pointer to const file provider operations. */
189typedef const KLDRRDROPS *PCKLDRRDROPS;
190
191
192/**
193 * File provider instance core.
194 */
195typedef struct KLDRRDR
196{
197 /** Magic number (KLDRRDR_MAGIC). */
198 uint32_t u32Magic;
199 /** Pointer to the file provider operations. */
200 PCKLDRRDROPS pOps;
201} KLDRRDR;
202
203/** The magic for KLDRRDR::u32Magic. (Katsu Aki (Katsuaki Nakamura)) */
204#define KLDRRDR_MAGIC 0x19610919
205
206void kLdrRdrAddProvider(PKLDRRDROPS pAdd);
207
208int kLdrRdrOpen( PPKLDRRDR ppRdr, const char *pszFilename);
209int kLdrRdrClose( PKLDRRDR pRdr);
210int kLdrRdrRead( PKLDRRDR pRdr, void *pvBuf, size_t cb, off_t off);
211int kLdrRdrAllMap( PKLDRRDR pRdr, const void **ppvBits);
212int kLdrRdrAllUnmap(PKLDRRDR pRdr, const void *pvBits);
213off_t kLdrRdrSize( PKLDRRDR pRdr);
214off_t kLdrRdrTell( PKLDRRDR pRdr);
215const char *kLdrRdrName(PKLDRRDR pRdr);
216size_t kLdrRdrPageSize(PKLDRRDR pRdr);
217int kLdrRdrPrepare( PKLDRRDR pRdr, void **ppv, size_t cb, unsigned fFixed);
218int kLdrRdrMap( PKLDRRDR pRdr, void *pv, size_t cb, KLDRPROT enmProt, off_t offFile, size_t cbFile);
219int kLdrRdrRefreshMap(PKLDRRDR pRdr, void *pv, size_t cb, KLDRPROT enmProt, off_t offFile, size_t cbFile);
220int kLdrRdrProtect( PKLDRRDR pRdr, void *pv, size_t cb, KLDRPROT enmProt);
221int kLdrRdrUnmap( PKLDRRDR pRdr, void *pv, size_t cb);
222int kLdrRdrUnprepare(PKLDRRDR pRdr, void *pv, size_t cb);
223void kLdrRdrDone( PKLDRRDR pRdr);
224
225/** @} */
226
227
228
229/** @defgroup grp_kLdrMod kLdrMod - The executable image intepreter
230 * @{ */
231
232/**
233 * CPU Architecture.
234 * @todo Double check the non intel architectures.
235 */
236typedef enum KLDRARCH
237{
238 /** The usual invalid one. */
239 KLDRARCH_INVALID = 0,
240 /** Clone or Intel 16-bit x86. */
241 KLDRARCH_X86_16,
242 /** Clone or Intel 32-bit x86. */
243 KLDRARCH_X86_32,
244 /** AMD64 (including clones). */
245 KLDRARCH_AMD64,
246 /** Itanic (64-bit). */
247 KLDRARCH_IA64,
248 /** ALPHA (64-bit). */
249 KLDRARCH_ALPHA,
250 /** ALPHA limited to 32-bit. */
251 KLDRARCH_ALPHA_32,
252 /** 32-bit ARM. */
253 KLDRARCH_ARM_32,
254 /** 64-bit ARM. */
255 KLDRARCH_ARM_64,
256 /** 32-bit MIPS. */
257 KLDRARCH_MIPS_32,
258 /** 64-bit MIPS. */
259 KLDRARCH_MIPS_64,
260 /** 32-bit PowerPC. */
261 KLDRARCH_POWERPC_32,
262 /** 64-bit PowerPC. */
263 KLDRARCH_POWERPC_64,
264 /** 32-bit SPARC. */
265 KLDRARCH_SPARC_32,
266 /** 64-bit SPARC. */
267 KLDRARCH_SPARC_64,
268 /** The end of the valid architecture values (exclusive). */
269 KLDRARCH_END,
270 /** Hack to blow the type up to 32-bit. */
271 KLDRARCH_32BIT_HACK = 0x7fffffff
272} KLDRARCH;
273/** Pointer to a CPU architecture type. */
274typedef KLDRARCH *PKLDRARCH;
275
276/**
277 * CPU models.
278 */
279typedef enum KLDRCPU
280{
281 /** The usual invalid cpu. */
282 KLDRCPU_INVALID = 0,
283 /** @name KLDRARCH_X86_16
284 * @{ */
285 KLDRCPU_I8086,
286 KLDRCPU_I8088,
287 KLDRCPU_I80186,
288 KLDRCPU_I80286,
289 KLDRCPU_I386_16,
290 KLDRCPU_I486_16,
291 KLDRCPU_I486SX_16,
292 KLDRCPU_I586_16,
293 KLDRCPU_I686_16,
294 KLDRCPU_P4_16,
295 KLDRCPU_CORE2_16,
296 KLDRCPU_K6_16,
297 KLDRCPU_K7_16,
298 KLDRCPU_K8_16,
299 KLDRCPU_FIRST_X86_16 = KLDRCPU_I8086,
300 KLDRCPU_LAST_X86_16 = KLDRCPU_K8_16,
301 /** @} */
302
303 /** @name KLDRARCH_X86_32
304 * @{ */
305 KLDRCPU_X86_32_BLEND,
306 KLDRCPU_I386,
307 KLDRCPU_I486,
308 KLDRCPU_I486SX,
309 KLDRCPU_I586,
310 KLDRCPU_I686,
311 KLDRCPU_P4,
312 KLDRCPU_CORE2_32,
313 KLDRCPU_K6,
314 KLDRCPU_K7,
315 KLDRCPU_K8_32,
316 KLDRCPU_FIRST_X86_32 = KLDRCPU_I386,
317 KLDRCPU_LAST_X86_32 = KLDRCPU_K8_32,
318 /** @} */
319
320 /** @name KLDRARCH_AMD64
321 * @{ */
322 KLDRCPU_AMD64_BLEND,
323 KLDRCPU_K8,
324 KLDRCPU_P4_64,
325 KLDRCPU_CORE2,
326 KLDRCPU_FIRST_AMD64 = KLDRCPU_K8,
327 KLDRCPU_LAST_AMD64 = KLDRCPU_CORE2,
328 /** @} */
329
330 /** The end of the valid cpu values (exclusive). */
331 KLDRCPU_END,
332 /** Hack to blow the type up to 32-bit. */
333 KLDRCPU_32BIT_HACK = 0x7fffffff
334} KLDRCPU;
335/** Pointer to a CPU type. */
336typedef KLDRCPU *PKLDRCPU;
337
338void kLdrGetArchCpu(PKLDRARCH penmArch, PKLDRCPU penmCpu);
339int kLdrCompareCpus(KLDRARCH enmCodeArch, KLDRCPU enmCodeCpu, KLDRARCH enmArch, KLDRCPU enmCpu);
340
341
342/**
343 * Debug info type (from the loader point of view).
344 */
345typedef enum KLDRDBGINFOTYPE
346{
347 /** The usual invalid enum value. */
348 KLDRDBGINFOTYPE_INVALID = 0,
349 /** Unknown debug info format. */
350 KLDRDBGINFOTYPE_UNKNOWN,
351 /** Stabs. */
352 KLDRDBGINFOTYPE_STABS,
353 /** Debug With Arbitrary Record Format (DWARF). */
354 KLDRDBGINFOTYPE_DWARF,
355 /** Microsoft Codeview debug info. */
356 KLDRDBGINFOTYPE_CODEVIEW,
357 /** Watcom debug info. */
358 KLDRDBGINFOTYPE_WATCOM,
359 /** IBM High Level Language debug info.. */
360 KLDRDBGINFOTYPE_HLL,
361 /** The end of the valid debug info values (exclusive). */
362 KLDRDBGINFOTYPE_END,
363 /** Blow the type up to 32-bit. */
364 KLDRDBGINFOTYPE_32BIT_HACK = 0x7fffffff
365} KLDRDBGINFOTYPE;
366/** Pointer to a kLdr debug info type. */
367typedef KLDRDBGINFOTYPE *PKLDRDBGINFOTYPE;
368
369
370/**
371 * Stack information.
372 */
373typedef struct KLDRSTACKINFO
374{
375 /** The base address of the stack (sub) segment.
376 * Set this to NIL_KLDRADDR if the module doesn't include any stack segment. */
377 KLDRADDR Address;
378 /** The base address of the stack (sub) segment, link address.
379 * Set this to NIL_KLDRADDR if the module doesn't include any stack (sub)segment. */
380 KLDRADDR LinkAddress;
381 /** The stack size of the main thread.
382 * If no stack (sub)segment in the module, this is the stack size of the main thread.
383 * If the module doesn't contain this kind of information this field will be set to 0. */
384 KLDRSIZE cbStack;
385 /** The stack size of non-main threads.
386 * If the module doesn't contain this kind of information this field will be set to 0. */
387 KLDRSIZE cbStackThread;
388} KLDRSTACKINFO;
389/** Pointer to stack information. */
390typedef KLDRSTACKINFO *PKLDRSTACKINFO;
391/** Pointer to const stack information. */
392typedef const KLDRSTACKINFO *PCKLDRSTACKINFO;
393
394
395/**
396 * Loader segment.
397 */
398typedef struct KLDRSEG
399{
400 /** Variable free to use for the kLdr user. */
401 void *pvUser;
402 /** The segment name. (Might not be zero terminated!) */
403 const char *pchName;
404 /** The length of the segment name. */
405 uint32_t cchName;
406 /** The segment protection. */
407 KLDRPROT enmProt;
408 /** The size of the segment. */
409 KLDRSIZE cb;
410 /** The required segment alignment.
411 * The to 0 if the segment isn't supposed to be mapped. */
412 KLDRADDR Alignment;
413 /** The link address.
414 * Set to NIL_KLDRADDR if the segment isn't supposed to be
415 * mapped or if the image doesn't have link addresses. */
416 KLDRADDR LinkAddress;
417 /** File offset of the segment.
418 * Set to -1 if no file backing (like BSS). */
419 off_t offFile;
420 /** Size of the file bits of the segment.
421 * Set to -1 if no file backing (like BSS). */
422 off_t cbFile;
423 /** The relative virtual address when mapped.
424 * Set to NIL_KLDRADDR if the segment isn't supposed to be mapped. */
425 KLDRADDR RVA;
426 /** The size of the segment including the alignment gap up to the next segment when mapped. */
427 size_t cbMapped;
428 /** The address the segment was mapped at by kLdrModMap().
429 * Set to 0 if not mapped. */
430 uintptr_t MapAddress;
431} KLDRSEG;
432/** Pointer to a loader segment. */
433typedef KLDRSEG *PKLDRSEG;
434/** Pointer to a loader segment. */
435typedef const KLDRSEG *PCKLDRSEG;
436
437
438/**
439 * Loader module format.
440 */
441typedef enum KLDRFMT
442{
443 /** The usual invalid 0 format. */
444 KLDRFMT_INVALID = 0,
445 /** The native OS loader. */
446 KLDRFMT_NATIVE,
447 /** The AOUT loader. */
448 KLDRFMT_AOUT,
449 /** The ELF loader. */
450 KLDRFMT_ELF,
451 /** The LX loader. */
452 KLDRFMT_LX,
453 /** The mach-o loader. */
454 KLDRFMT_MACHO,
455 /** The LX loader. */
456 KLDRFMT_PE,
457 /** The end of the valid format values (exclusive). */
458 KLDRFMT_END,
459 /** Hack to blow the type up to 32-bit. */
460 KLDRFMT_32BIT_HACK = 0x7fffffff
461} KLDRFMT;
462
463
464/**
465 * Loader module type.
466 */
467typedef enum KLDRTYPE
468{
469 /** The usual invalid 0 type. */
470 KLDRTYPE_INVALID = 0,
471 /** Object file. */
472 KLDRTYPE_OBJECT,
473 /** Executable module, fixed load address. */
474 KLDRTYPE_EXECUTABLE_FIXED,
475 /** Executable module, relocatable, non-fixed load address. */
476 KLDRTYPE_EXECUTABLE_RELOCATABLE,
477 /** Executable module, position independent code, non-fixed load address. */
478 KLDRTYPE_EXECUTABLE_PIC,
479 /** Shared library, fixed load address.
480 * Typically a system library. */
481 KLDRTYPE_SHARED_LIBRARY_FIXED,
482 /** Shared library, relocatable, non-fixed load address. */
483 KLDRTYPE_SHARED_LIBRARY_RELOCATABLE,
484 /** Shared library, position independent code, non-fixed load address. */
485 KLDRTYPE_SHARED_LIBRARY_PIC,
486 /** DLL that contains no code or data only imports and exports. (Chiefly OS/2.) */
487 KLDRTYPE_FORWARDER_DLL,
488 /** Core or dump. */
489 KLDRTYPE_CORE,
490 /** The end of the valid types values (exclusive). */
491 KLDRTYPE_END,
492 /** Hack to blow the type up to 32-bit. */
493 KLDRTYPE_32BIT_HACK = 0x7fffffff
494} KLDRTYPE;
495
496
497/**
498 * Loader endian indicator.
499 */
500typedef enum KLDRENDIAN
501{
502 /** The usual invalid endian. */
503 KLDRENDIAN_INVALID,
504 /** Little endian. */
505 KLDRENDIAN_LITTLE,
506 /** Bit endian. */
507 KLDRENDIAN_BIG,
508 /** Endianness doesn't have a meaning in the context. */
509 KLDRENDIAN_NA,
510 /** The end of the valid endian values (exclusive). */
511 KLDRENDIAN_END,
512 /** Hack to blow the type up to 32-bit. */
513 KLDRENDIAN_32BIT_HACK = 0x7fffffff
514} KLDRENDIAN;
515
516
517/** Pointer to a module interpreter method table. */
518typedef struct KLDRMODOPS *PKLDRMODOPS;
519/** Pointer to const module interpreter methods table. */
520typedef const struct KLDRMODOPS *PCKLDRMODOPS;
521
522/**
523 * Module interpreter instance.
524 * All members are read only unless you're kLdrMod or the module interpreter.
525 */
526typedef struct KLDRMOD
527{
528 /** Magic number (KLDRMOD_MAGIC). */
529 uint32_t u32Magic;
530 /** The format of this module. */
531 KLDRFMT enmFmt;
532 /** The type of module. */
533 KLDRTYPE enmType;
534 /** The architecture this module was built for. */
535 KLDRARCH enmArch;
536 /** The minium cpu this module was built for.
537 * This might not be accurate, so use kLdrModCanExecuteOn() to check. */
538 KLDRARCH enmCpu;
539 /** The endian used by the module. */
540 KLDRENDIAN enmEndian;
541 /** The filename length (bytes). */
542 uint32_t cchFilename;
543 /** The filename. */
544 const char *pszFilename;
545 /** The module name. */
546 const char *pszName;
547 /** The module name length (bytes). */
548 uint32_t cchName;
549 /** The number of segments in the module. */
550 uint32_t cSegments;
551 /** Pointer to the loader methods.
552 * Not meant for calling directly thru! */
553 PCKLDRMODOPS pOps;
554 /** Pointer to the read instance. (Can be NULL after kLdrModDone().)*/
555 PKLDRRDR pRdr;
556 /** The module data. */
557 void *pvData;
558 /** Segments. (variable size, can be zero) */
559 KLDRSEG aSegments[1];
560} KLDRMOD, *PKLDRMOD, **PPKLDRMOD;
561
562/** The magic for KLDRMOD::u32Magic. (Kosuke Fujishima) */
563#define KLDRMOD_MAGIC 0x19640707
564
565
566/** Special base address value alias for the link address. */
567#define KLDRMOD_BASEADDRESS_LINK (~(KLDRADDR)1)
568/** Special base address value alias for the actual load address (must be mapped). */
569#define KLDRMOD_BASEADDRESS_MAP (~(KLDRADDR)2)
570
571/** Special import module ordinal value used to indicate that there is no
572 * specific module associated with the requested symbol. */
573#define NIL_KLDRMOD_IMPORT (~(uint32_t)0)
574
575/** Special symbol ordinal value used to indicate that the symbol
576 * only has a string name. */
577#define NIL_KLDRMOD_SYM_ORDINAL (~(uint32_t)0)
578
579
580/** @name Load symbol kind flags.
581 * @{ */
582/** The bitness doesn't matter. */
583#define KLDRSYMKIND_NO_BIT 0x00000000
584/** 16-bit symbol. */
585#define KLDRSYMKIND_16BIT 0x00000001
586/** 32-bit symbol. */
587#define KLDRSYMKIND_32BIT 0x00000002
588/** 64-bit symbol. */
589#define KLDRSYMKIND_64BIT 0x00000003
590/** Mask out the bit.*/
591#define KLDRSYMKIND_BIT_MASK 0x00000003
592/** We don't know the type of symbol. */
593#define KLDRSYMKIND_NO_TYPE 0x00000000
594/** The symbol is a code object (method/function/procedure/whateveryouwannacallit). */
595#define KLDRSYMKIND_CODE 0x00000010
596/** The symbol is a data object. */
597#define KLDRSYMKIND_DATA 0x00000020
598/** Mask out the symbol type. */
599#define KLDRSYMKIND_TYPE_MASK 0x00000030
600/** Valid symbol kind mask. */
601#define KLDRSYMKIND_MASK 0x00000033
602/** Weak symbol. */
603#define KLDRSYMKIND_WEAK 0x00000100
604/** Forwarder symbol. */
605#define KLDRSYMKIND_FORWARDER 0x00000200
606/** @} */
607
608/** @name kLdrModEnumSymbols flags.
609 * @{ */
610/** Returns ALL kinds of symbols. The default is to only return public/exported symbols. */
611#define KLDRMOD_ENUM_SYMS_FLAGS_ALL 0x00000001
612/** @} */
613
614
615/**
616 * Callback for resolving imported symbols when applying fixups.
617 *
618 * @returns 0 on success and *pValue and *pfKind filled.
619 * @returns Non-zero OS specific or kLdr status code on failure.
620 *
621 * @param pMod The module which fixups are begin applied.
622 * @param iImport The import module ordinal number or NIL_KLDRMOD_IMPORT.
623 * @param iSymbol The symbol ordinal number or NIL_KLDRMOD_SYM_ORDINAL.
624 * @param pszSymbol The symbol name. Can be NULL if iSymbol isn't nil.
625 * @param puValue Where to store the symbol value.
626 * @param pfKind Where to store the symbol kind flags.
627 * @param pvUser The user parameter specified to the relocation function.
628 */
629typedef int FNKLDRMODGETIMPORT(PKLDRMOD pMod, uint32_t iImport, uint32_t iSymbol, const char *pszSymbol,
630 PKLDRADDR puValue, uint32_t *pfKind, void *pvUser);
631/** Pointer to a import callback. */
632typedef FNKLDRMODGETIMPORT *PFNKLDRMODGETIMPORT;
633
634/**
635 * Symbol enumerator callback.
636 *
637 * @returns 0 if enumeration should continue.
638 * @returns non-zero if the enumeration should stop. This status code will then be returned by kLdrModEnumSymbols().
639 *
640 * @param pMod The module which symbols are being enumerated.s
641 * @param iSymbol The symbol ordinal number or NIL_KLDRMOD_SYM_ORDINAL.
642 * @param pszSymbol The symbol name. This can be NULL if there is a symbol ordinal.
643 * This can also be an empty string if the symbol doesn't have a name
644 * or it's name has been stripped.
645 * @param uValue The symbol value.
646 * @param fKind The symbol kind flags.
647 * @param pvUser The user parameter specified to kLdrModEnumSymbols().
648 */
649typedef int FNKLDRMODENUMSYMS(PKLDRMOD pMod, uint32_t iSymbol, const char *pszSymbol,
650 KLDRADDR uValue, uint32_t fKind, void *pvUser);
651/** Pointer to a symbol enumerator callback. */
652typedef FNKLDRMODENUMSYMS *PFNKLDRMODENUMSYMS;
653
654/**
655 * Debug info enumerator callback.
656 *
657 * @returns 0 to continue the enumeration.
658 * @returns non-zero if the enumeration should stop. This status code will then be returned by kLdrModEnumDbgInfo().
659 *
660 * @param pMod The module.
661 * @param iDbgInfo The debug info ordinal number / id.
662 * @param enmType The debug info type.
663 * @param iMajorVer The major version number of the debug info format. -1 if unknow - implies invalid iMinorVer.
664 * @param iMinorVer The minor version number of the debug info format. -1 when iMajorVer is -1.
665 * @param offFile The file offset *if* this type has one specific location in the executable image file.
666 * This is -1 if there isn't any specific file location.
667 * @param LinkAddress The link address of the debug info if it's loadable. NIL_KLDRADDR if not loadable.
668 * @param cb The size of the debug information. -1 is used if this isn't applicable.
669 * @param pszExtFile This points to the name of an external file containing the debug info.
670 * This is NULL if there isn't any external file.
671 * @param pvUser The user parameter specified to kLdrModEnumDbgInfo.
672 */
673typedef int FNKLDRENUMDBG(PKLDRMOD pMod, uint32_t iDbgInfo, KLDRDBGINFOTYPE enmType, int16_t iMajorVer, int16_t iMinorVer,
674 off_t offFile, KLDRADDR LinkAddress, KLDRSIZE cb, const char *pszExtFile, void *pvUser);
675/** Pointer to a debug info enumberator callback. */
676typedef FNKLDRENUMDBG *PFNKLDRENUMDBG;
677
678int kLdrModOpen(const char *pszFilename, PPKLDRMOD ppMod);
679int kLdrModOpenFromRdr(PKLDRRDR pRdr, PPKLDRMOD ppMod);
680int kLdrModOpenNative(const char *pszFilename, PPKLDRMOD ppMod);
681int kLdrModClose(PKLDRMOD pMod);
682
683int kLdrModQuerySymbol(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_t iSymbol,
684 const char *pszSymbol, PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser,
685 PKLDRADDR puValue, uint32_t *pfKind);
686int kLdrModEnumSymbols(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress,
687 uint32_t fFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser);
688int kLdrModGetImport(PKLDRMOD pMod, const void *pvBits, uint32_t iImport, char *pszName, size_t cchName);
689int32_t kLdrModNumberOfImports(PKLDRMOD pMod, const void *pvBits);
690int kLdrModCanExecuteOn(PKLDRMOD pMod, const void *pvBits, KLDRARCH enmArch, KLDRCPU enmCpu);
691int kLdrModGetStackInfo(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, PKLDRSTACKINFO pStackInfo);
692int kLdrModQueryMainEntrypoint(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, PKLDRADDR pMainEPAddress);
693int kLdrModEnumDbgInfo(PKLDRMOD pMod, const void *pvBits, PFNKLDRENUMDBG pfnCallback, void *pvUser);
694int kLdrModHasDbgInfo(PKLDRMOD pMod, const void *pvBits);
695
696/** @name Operations On The Internally Managed Mapping
697 * @{ */
698int kLdrModMap(PKLDRMOD pMod);
699int kLdrModUnmap(PKLDRMOD pMod);
700int kLdrModAllocTLS(PKLDRMOD pMod);
701void kLdrModFreeTLS(PKLDRMOD pMod);
702int kLdrModReload(PKLDRMOD pMod);
703int kLdrModFixupMapping(PKLDRMOD pMod, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);
704int kLdrModCallInit(PKLDRMOD pMod, uintptr_t uHandle);
705int kLdrModCallTerm(PKLDRMOD pMod, uintptr_t uHandle);
706int kLdrModCallThread(PKLDRMOD pMod, uintptr_t uHandle, unsigned fAttachingOrDetaching);
707/** @} */
708
709/** @name Operations On The Externally Managed Mappings
710 * @{ */
711KLDRADDR kLdrModSize(PKLDRMOD pMod);
712int kLdrModGetBits(PKLDRMOD pMod, void *pvBits, KLDRADDR BaseAddress, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);
713int kLdrModRelocateBits(PKLDRMOD pMod, void *pvBits, KLDRADDR NewBaseAddress, KLDRADDR OldBaseAddress,
714 PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);
715/** @} */
716
717
718/**
719 * The loader module operation.
720 */
721typedef struct KLDRMODOPS
722{
723 /** The name of this module interpreter. */
724 const char *pszName;
725 /** Pointer to the next module interpreter. */
726 PCKLDRMODOPS pNext;
727
728 /**
729 * Create a loader module instance interpreting the executable image found
730 * in the specified file provider instance.
731 *
732 * @returns 0 on success and *ppMod pointing to a module instance.
733 * On failure, a non-zero OS specific error code is returned.
734 * @param pOps Pointer to the registered method table.
735 * @param pRdr The file provider instance to use.
736 * @param offNewHdr The offset of the new header in MZ files. -1 if not found.
737 * @param ppMod Where to store the module instance pointer.
738 */
739 int (* pfnCreate)(PCKLDRMODOPS pOps, PKLDRRDR pRdr, off_t offNewHdr, PPKLDRMOD ppMod);
740 /**
741 * Destroys an loader module instance.
742 *
743 * The caller is responsible for calling kLdrModUnmap() and kLdrFreeTLS() first.
744 *
745 * @returns 0 on success, non-zero on failure. The module instance state
746 * is unknown on failure, it's best not to touch it.
747 * @param pMod The module.
748 */
749 int (* pfnDestroy)(PKLDRMOD pMod);
750
751 /** @copydoc kLdrModQuerySymbol */
752 int (* pfnQuerySymbol)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_t iSymbol,
753 const char *pszSymbol, PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser,
754 PKLDRADDR puValue, uint32_t *pfKind);
755 /** @copydoc kLdrModEnumSymbols */
756 int (* pfnEnumSymbols)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_t fFlags,
757 PFNKLDRMODENUMSYMS pfnCallback, void *pvUser);
758 /** @copydoc kLdrModGetImport */
759 int (* pfnGetImport)(PKLDRMOD pMod, const void *pvBits, uint32_t iImport, char *pszName, size_t cchName);
760 /** @copydoc kLdrModNumberOfImports */
761 int32_t (* pfnNumberOfImports)(PKLDRMOD pMod, const void *pvBits);
762 /** @copydoc kLdrModCanExecuteOn */
763 int (* pfnCanExecuteOn)(PKLDRMOD pMod, const void *pvBits, KLDRARCH enmArch, KLDRCPU enmCpu);
764 /** @copydoc kLdrModGetStackInfo */
765 int (* pfnGetStackInfo)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, PKLDRSTACKINFO pStackInfo);
766 /** @copydoc kLdrModQueryMainEntrypoint */
767 int (* pfnQueryMainEntrypoint)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, PKLDRADDR pMainEPAddress);
768 /** @copydoc kLdrModEnumDbgInfo */
769 int (* pfnEnumDbgInfo)(PKLDRMOD pMod, const void *pvBits, PFNKLDRENUMDBG pfnCallback, void *pvUser);
770 /** @copydoc kLdrModHasDbgInfo */
771 int (* pfnHasDbgInfo)(PKLDRMOD pMod, const void *pvBits);
772 /** @copydoc kLdrModMap */
773 int (* pfnMap)(PKLDRMOD pMod);
774 /** @copydoc kLdrModUnmap */
775 int (* pfnUnmap)(PKLDRMOD pMod);
776 /** @copydoc kLdrModAllocTLS */
777 int (* pfnAllocTLS)(PKLDRMOD pMod);
778 /** @copydoc kLdrModFreeTLS */
779 void (* pfnFreeTLS)(PKLDRMOD pMod);
780 /** @copydoc kLdrModReload */
781 int (* pfnReload)(PKLDRMOD pMod);
782 /** @copydoc kLdrModFixupMapping */
783 int (* pfnFixupMapping)(PKLDRMOD pMod, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);
784 /** @copydoc kLdrModCallInit */
785 int (* pfnCallInit)(PKLDRMOD pMod, uintptr_t uHandle);
786 /** @copydoc kLdrModCallTerm */
787 int (* pfnCallTerm)(PKLDRMOD pMod, uintptr_t uHandle);
788 /** @copydoc kLdrModCallThread */
789 int (* pfnCallThread)(PKLDRMOD pMod, uintptr_t uHandle, unsigned fAttachingOrDetaching);
790 /** @copydoc kLdrModSize */
791 KLDRADDR (* pfnSize)(PKLDRMOD pMod);
792 /** @copydoc kLdrModGetBits */
793 int (* pfnGetBits)(PKLDRMOD pMod, void *pvBits, KLDRADDR BaseAddress, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);
794 /** @copydoc kLdrModRelocateBits */
795 int (* pfnRelocateBits)(PKLDRMOD pMod, void *pvBits, KLDRADDR NewBaseAddress, KLDRADDR OldBaseAddress,
796 PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);
797 /** Dummy which should be assigned a non-zero value. */
798 uint32_t uEndOfStructure;
799} KLDRMODOPS;
800
801
802/** @} */
803
804
805
806
807/** @defgroup grp_kLdrDyld kLdrDyld - The dynamic loader
808 * @{ */
809
810/** The handle to a dynamic loader module. */
811typedef struct KLDRDYLDMOD *HKLDRMOD;
812/** Pointer to the handle to a dynamic loader module. */
813typedef HKLDRMOD *PHKLDRMOD;
814/** NIL handle value. */
815#define NIL_HKLDRMOD ((HKLDRMOD)0)
816
817
818/**
819 * File search method.
820 *
821 * In addition to it's own way of finding files, kLdr emulates
822 * the methods employed by the most popular systems.
823 */
824typedef enum KLDRDYLDSEARCH
825{
826 /** The usual invalid file search method. */
827 KLDRDYLD_SEARCH_INVALID = 0,
828 /** Uses the kLdr file search method.
829 * @todo invent me. */
830 KLDRDYLD_SEARCH_KLDR,
831 /** Use the emulation closest to the host system. */
832 KLDRDYLD_SEARCH_HOST,
833 /** Emulate the OS/2 file search method.
834 * On non-OS/2 systems, BEGINLIBPATH, LIBPATH, ENDLIBPATH and LIBPATHSTRICT are
835 * taken form the environment. */
836 KLDRDYLD_SEARCH_OS2,
837 /** Emulate the standard window file search method. */
838 KLDRDYLD_SEARCH_WINDOWS,
839 /** Emulate the alternative window file search method. */
840 KLDRDYLD_SEARCH_WINDOWS_ALTERED,
841 /** Emulate the most common UNIX file search method. */
842 KLDRDYLD_SEARCH_UNIX_COMMON,
843 /** End of the valid file search method values. */
844 KLDRDYLD_SEARCH_END,
845 /** Hack to blow the type up to 32-bit. */
846 KLDRDYLD_SEARCH_32BIT_HACK = 0x7fffffff
847} KLDRDYLDSEARCH;
848
849/** @name kLdrDyldLoad and kLdrDyldFindByName flags.
850 * @{ */
851/** The symbols in the module should be loaded into the global unix namespace.
852 * If not specified, the symbols are local and can only be referenced directly. */
853#define KLDRYDLD_LOAD_FLAGS_GLOBAL_SYMBOLS 0x00000001
854/** The module shouldn't be found by a global module search.
855 * If not specified, the module can be found by unspecified module searches,
856 * typical used when loading import/dep modules. */
857#define KLDRYDLD_LOAD_FLAGS_SPECIFIC_MODULE 0x00000002
858/** Do a recursive initialization calls instead of defering them to the outermost call. */
859#define KLDRDYLD_LOAD_FLAGS_RECURSIVE_INIT 0x00000004
860/** We're loading the executable module.
861 * Internal flag which will be rejected by kLdrDyldLoad. */
862#define KLDRDYLD_LOAD_FLAGS_EXECUTABLE 0x40000000
863/** @} */
864
865
866int kLdrDyldLoad(const char *pszDll, const char *pszPrefix, const char *pszSuffix, KLDRDYLDSEARCH enmSearch,
867 unsigned fFlags, PHKLDRMOD phMod, char *pszErr, size_t cchErr);
868int kLdrDyldUnload(HKLDRMOD hMod);
869int kLdrDyldFindByName(const char *pszDll, const char *pszPrefix, const char *pszSuffix, KLDRDYLDSEARCH enmSearch,
870 unsigned fFlags, PHKLDRMOD phMod);
871int kLdrDyldFindByAddress(uintptr_t Address, PHKLDRMOD phMod, uint32_t *piSegment, uintptr_t *poffSegment);
872int kLdrDyldGetName(HKLDRMOD hMod, char *pszName, size_t cchName);
873int kLdrDyldGetFilename(HKLDRMOD hMod, char *pszFilename, size_t cchFilename);
874int kLdrDyldQuerySymbol(HKLDRMOD hMod, uint32_t uSymbolOrdinal, const char *pszSymbolName, uintptr_t *pValue, uint32_t *pfKind);
875
876/** @name OS/2 like API
877 * @{ */
878int kLdrDosLoadModule(char *pszObject, size_t cbObject, const char *pszModule, PHKLDRMOD phMod);
879int kLdrDosFreeModule(HKLDRMOD hMod);
880int kLdrDosQueryModuleHandle(const char *pszModname, PHKLDRMOD phMod);
881int kLdrDosQueryModuleName(HKLDRMOD hMod, size_t cchName, char *pszName);
882int kLdrDosQueryProcAddr(HKLDRMOD hMod, uint32_t iOrdinal, const char *pszProcName, void **ppvProcAddr);
883int kLdrDosQueryProcType(HKLDRMOD hMod, uint32_t iOrdinal, const char *pszProcName, uint32_t *pfProcType);
884int kLdrDosQueryModFromEIP(PHKLDRMOD phMod, uint32_t *piObject, size_t cbName, char *pszName, uintptr_t *poffObject, uintptr_t ulEIP);
885int kLdrDosReplaceModule(const char *pszOldModule, const char *pszNewModule, const char *pszBackupModule);
886int kLdrDosGetResource(HKLDRMOD hMod, uint32_t idType, uint32_t idName, void **pvResAddr);
887int kLdrDosQueryResourceSize(HKLDRMOD hMod, uint32_t idTypeID, uint32_t idName, uint32_t *pcb);
888int kLdrDosFreeResource(void *pvResAddr);
889/** @} */
890
891/** @name POSIX like API
892 * @{ */
893HKLDRMOD kLdrDlOpen(const char *pszLibrary, int fFlags);
894const char *kLdrDlError(void);
895void * kLdrDlSym(HKLDRMOD hMod, const char *pszSymbol);
896int kLdrDlClose(HKLDRMOD hMod);
897/** @} */
898
899/** @name Win32 like API
900 * @{ */
901HKLDRMOD kLdrWLoadLibrary(const char *pszFilename);
902HKLDRMOD kLdrWLoadLibraryEx(const char *pszFilename, void *hFileReserved, uint32_t fFlags);
903uint32_t kLdrWGetModuleFileName(HKLDRMOD hMod, char *pszModName, size_t cchModName);
904HKLDRMOD kLdrWGetModuleHandle(const char *pszFilename);
905int kLdrWGetModuleHandleEx(uint32_t fFlags, const char *pszFilename, HKLDRMOD hMod);
906void * kLdrWGetProcAddress(HKLDRMOD hMod, const char *pszProcName);
907uint32_t kLdrWGetDllDirectory(size_t cchDir, char *pszDir);
908int kLdrWSetDllDirectory(const char *pszDir);
909int kLdrWFreeLibrary(HKLDRMOD hMod);
910int kLdrWDisableThreadLibraryCalls(HKLDRMOD hMod);
911
912/** @} */
913
914
915/** @name Process Bootstrapping
916 * @{ */
917
918/**
919 * Argument package from the stub.
920 */
921typedef struct KLDREXEARGS
922{
923 /** Flags. (Currently unused, MBZ.) */
924 uint32_t fFlags;
925 /** The search method to use when loading this executable. */
926 KLDRDYLDSEARCH enmSearch;
927 /** The executable file that the stub is supposed to load. */
928 char szExecutable[260];
929 /** The default prefix used when searching for DLLs. */
930 char szDefPrefix[16];
931 /** The default suffix used when searching for DLLs. */
932 char szDefSuffix[16];
933 /** The LD_LIBRARY_PATH prefix for the process.. */
934 char szLibPath[4096 - sizeof(uint32_t) - sizeof(KLDRDYLDSEARCH) - 16 - 16 - 260];
935} KLDREXEARGS, *PKLDREXEARGS;
936
937void kLdrLoadExe(PKLDREXEARGS pArgs, void *pvOS);
938
939/** @} */
940
941/** @} */
942
943
944/** @defgroup grp_kLdrErr kLdr Status Codes
945 * kLdr uses a mix of native status codes and it's own status codes.
946 * A status code of 0 means success, all other status codes means failure.
947 * @{
948 */
949#ifdef __OS2__
950# define KLDR_ERR_BASE 420000
951#elif defined(__WIN__)
952# define KLDR_ERR_BASE 420000
953#else
954# error "port me"
955#endif
956/** The image format is unknown. */
957#define KLDR_ERR_UNKNOWN_FORMAT (KLDR_ERR_BASE + 0)
958/** The MZ image format isn't supported by this kLdr build. */
959#define KLDR_ERR_MZ_NOT_SUPPORTED (KLDR_ERR_BASE + 1)
960/** The NE image format isn't supported by this kLdr build. */
961#define KLDR_ERR_NE_NOT_SUPPORTED (KLDR_ERR_BASE + 2)
962/** The LX image format isn't supported by this kLdr build. */
963#define KLDR_ERR_LX_NOT_SUPPORTED (KLDR_ERR_BASE + 3)
964/** The LE image format isn't supported by this kLdr build. */
965#define KLDR_ERR_LE_NOT_SUPPORTED (KLDR_ERR_BASE + 4)
966/** The PE image format isn't supported by this kLdr build. */
967#define KLDR_ERR_PE_NOT_SUPPORTED (KLDR_ERR_BASE + 5)
968/** The ELF image format isn't supported by this kLdr build. */
969#define KLDR_ERR_ELF_NOT_SUPPORTED (KLDR_ERR_BASE + 6)
970/** The mach-o image format isn't supported by this kLdr build. */
971#define KLDR_ERR_MACHO_NOT_SUPPORTED (KLDR_ERR_BASE + 7)
972/** The mach-o image format isn't supported by this kLdr build. */
973#define KLDR_ERR_AOUT_NOT_SUPPORTED (KLDR_ERR_BASE + 8)
974
975/** Invalid parameter to a kLdr API. */
976#define KLDR_ERR_INVALID_PARAMETER (KLDR_ERR_BASE + 32)
977/** Invalid handle parameter to a kLdr API. */
978#define KLDR_ERR_INVALID_HANDLE (KLDR_ERR_BASE + 33)
979/** The module wasn't loaded dynamically. */
980#define KLDR_ERR_NOT_LOADED_DYNAMICALLY (KLDR_ERR_BASE + 34)
981/** The module wasn't found. */
982#define KLDR_ERR_MODULE_NOT_FOUND (KLDR_ERR_BASE + 35)
983/** A prerequisit module wasn't found. */
984#define KLDR_ERR_PREREQUISITE_MODULE_NOT_FOUND (KLDR_ERR_BASE + 36)
985/** The module is being terminated and can therefore not be loaded. */
986#define KLDR_ERR_MODULE_TERMINATING (KLDR_ERR_BASE + 37)
987/** A prerequisit module is being terminated and can therefore not be loaded. */
988#define KLDR_ERR_PREREQUISITE_MODULE_TERMINATING (KLDR_ERR_BASE + 38)
989/** The module initialization failed. */
990#define KLDR_ERR_MODULE_INIT_FAILED (KLDR_ERR_BASE + 39)
991/** The initialization of a prerequisite module failed. */
992#define KLDR_ERR_PREREQUISITE_MODULE_INIT_FAILED (KLDR_ERR_BASE + 40)
993/** The module has already failed initialization and can't be attempted reloaded until
994 * after we've finished garbage collection. */
995#define KLDR_ERR_MODULE_INIT_FAILED_ALREADY (KLDR_ERR_BASE + 41)
996/** A prerequisite module has already failed initialization and can't be attempted
997 * reloaded until after we've finished garbage collection. */
998#define KLDR_ERR_PREREQUISITE_MODULE_INIT_FAILED_ALREADY (KLDR_ERR_BASE + 42)
999/** Prerequisite recursed too deeply. */
1000#define KLDR_ERR_PREREQUISITE_RECURSED_TOO_DEEPLY (KLDR_ERR_BASE + 43)
1001/** Failed to allocate the main stack. */
1002#define KLDR_ERR_MAIN_STACK_ALLOC_FAILED (KLDR_ERR_BASE + 44)
1003/** Buffer overflow. */
1004#define KLDR_ERR_BUFFER_OVERFLOW (KLDR_ERR_BASE + 45)
1005/** The specified ARCH+CPU isn't compatible with image. */
1006#define KLDR_ERR_ARCH_CPU_NOT_COMPATIBLE (KLDR_ERR_BASE + 45)
1007/** Symbol not found. */
1008#define KLDR_ERR_SYMBOL_NOT_FOUND (KLDR_ERR_BASE + 46)
1009/** A forward symbol was encountered but the caller didn't provide any means to resolve it. */
1010#define KLDR_ERR_FORWARDER_SYMBOL (KLDR_ERR_BASE + 47)
1011/** Encountered a bad fixup. */
1012#define KLDR_ERR_BAD_FIXUP (KLDR_ERR_BASE + 48)
1013/** A memory allocation failed. */
1014#define KLDR_ERR_NO_MEMORY (KLDR_ERR_BASE + 49)
1015/** The import ordinal was out of bounds. */
1016#define KLDR_ERR_IMPORT_ORDINAL_OUT_OF_BOUNDS (KLDR_ERR_BASE + 50)
1017/** A forwarder chain was too long. */
1018#define KLDR_ERR_TOO_LONG_FORWARDER_CHAIN (KLDR_ERR_BASE + 51)
1019/** The module has no debug info. */
1020#define KLDR_ERR_NO_DEBUG_INFO (KLDR_ERR_BASE + 52)
1021/** The module is already mapped.
1022 * kLdrModMap() can only be called once (without kLdrModUnmap() in between). */
1023#define KLDR_ERR_ALREADY_MAPPED (KLDR_ERR_BASE + 53)
1024/** The module was not mapped.
1025 * kLdrModUnmap() should not called without being preceeded by a kLdrModMap(). */
1026#define KLDR_ERR_NOT_MAPPED (KLDR_ERR_BASE + 54)
1027/** Couldn't fit the address value into the field. Typically a relocation kind of error. */
1028#define KLDR_ERR_ADDRESS_OVERFLOW (KLDR_ERR_BASE + 55)
1029/** Thread attach failed. */
1030#define KLDR_ERR_THREAD_ATTACH_FAILED (KLDR_ERR_BASE + 57)
1031
1032
1033/** @name kLdrModPE status codes
1034 * @{ */
1035#define KLDR_ERR_BASE_PE (KLDR_ERR_BASE + 96)
1036/** The machine isn't supported by the interpreter. */
1037#define KLDR_ERR_PE_UNSUPPORTED_MACHINE (KLDR_ERR_BASE_PE + 0)
1038/** The file handler isn't valid. */
1039#define KLDR_ERR_PE_BAD_FILE_HEADER (KLDR_ERR_BASE_PE + 1)
1040/** The the optional headers isn't valid. */
1041#define KLDR_ERR_PE_BAD_OPTIONAL_HEADER (KLDR_ERR_BASE_PE + 2)
1042/** One of the section headers aren't valid. */
1043#define KLDR_ERR_PE_BAD_SECTION_HEADER (KLDR_ERR_BASE_PE + 3)
1044/** Bad forwarder entry. */
1045#define KLDR_ERR_PE_BAD_FORWARDER (KLDR_ERR_BASE_PE + 4)
1046/** Forwarder module not found in the import descriptor table. */
1047#define KLDR_ERR_PE_FORWARDER_IMPORT_NOT_FOUND (KLDR_ERR_BASE_PE + 5)
1048/** Bad PE fixups. */
1049#define KLDR_ERR_PE_BAD_FIXUP (KLDR_ERR_BASE_PE + 6)
1050/** Bad PE import (thunk). */
1051#define KLDR_ERR_PE_BAD_IMPORT (KLDR_ERR_BASE_PE + 7)
1052/** @} */
1053
1054
1055/** @} */
1056
1057
1058#ifdef __cplusplus
1059}
1060#endif
1061
1062#endif
1063
Note: See TracBrowser for help on using the repository browser.