source: trunk/kLdr/kLdr.h@ 2856

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

More code.

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