source: trunk/kLdr/kLdrInternal.h@ 2827

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

image format headers.

  • Property svn:keywords set to Id
File size: 3.9 KB
Line 
1/* $Id: kLdrInternal.h 2827 2006-10-22 18:05:28Z bird $ */
2/** @file
3 *
4 * kLdr - The Dynamic Loader, internal header.
5 *
6 * Copyright (c) 2006 knut st. osmundsen <bird-kbuild-src@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
28#ifndef __kLdrInternal_h__
29#define __kLdrInternal_h__
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35/* ignore definitions in winnt.h */
36#undef IMAGE_DOS_SIGNATURE
37#undef IMAGE_NT_SIGNATURE
38
39/** @name Signatures we know
40 * @{ */
41/** ELF signature ("\x7fELF"). */
42#define IMAGE_ELF_SIGNATURE KLDRHLP_LE2H_U32(0x7f | ('E' << 8) | ((uint32_t)'L' << 16) | ((uint32_t)'F' << 24))
43/** PE signature ("PE\0\0"). */
44#define IMAGE_NT_SIGNATURE KLDRHLP_LE2H_U32('P' | ('E' << 8))
45/** LX signature ("LX") */
46#define IMAGE_LX_SIGNATURE KLDRHLP_LE2H_U16('L' | ('X' << 8))
47/** LE signature ("LE") */
48#define IMAGE_LE_SIGNATURE KLDRHLP_LE2H_U16('L' | ('E' << 8))
49/** NE signature ("NE") */
50#define IMAGE_NE_SIGNATURE KLDRHLP_LE2H_U16('N' | ('E' << 8))
51/** MZ signature ("MZ"). */
52#define IMAGE_DOS_SIGNATURE KLDRHLP_LE2H_U16('M' | ('Z' << 8))
53/** @} */
54
55
56/** Native file provider operations. */
57extern const KLDRRDROPS g_kLdrRdrFileOps;
58
59
60/**
61 * The state of a dynamic loader module.
62 */
63typedef enum KLDRSTATE
64{
65 /** The usual invalid 0 enum. */
66 KLDRSTATE_INVALID = 0,
67 /** kldrOpen succeeded.
68 * Modules in this state will be freed at */
69 KLDRSTATE_OPEN,
70 /** Dependencies has been loaded. */
71 KLDRSTATE_DEPS,
72 /** Fixups has been applied. */
73 KLDRSTATE_FIXED,
74 /** The module has been initialized. */
75 KLDRSTATE_INITED,
76 /** The module is loaded successfully. */
77 KLDRSTATE_LOADED,
78 /** The end of valid states (exclusive) */
79 KLDRSTATE_END,
80 /** The usual 32-bit blowup. */
81 KLDRSTATE_32BIT_HACK = 0x7fffffff
82} KLDRSTATE;
83
84
85/**
86 * Dynamic loader module.
87 */
88typedef struct KLDRDY
89{
90 /** The next module in the list. */
91 PKLDRDY pNext;
92 /** The prev module in the list. */
93 PKLDRDY pPrev;
94 /** The module. */
95 PKLDRMOD pMod;
96 /** The module state. */
97 KLDRSTATE enmState;
98 /** The number of references. */
99 uint32_t cRefs;
100 /** The number of dynamic references. */
101 uint32_t cDynRefs;
102 /** Magic number. */
103 uint32_t u32Magic;
104 /** Set if this is the executable module. */
105 uint32_t fExecutable : 1;
106 /** Global DLL (set) or specific DLL (clear). */
107 uint32_t fGlobal : 1;
108 /** Load stage one. */
109 uint32_t fLoadStageOne : 1;
110 /** Reserved for future use. */
111 uint32_t fReserved : 29;
112} KLDRDY;
113
114
115/** Pointer to the head module (the executable). */
116extern PKLDRDY kLdrModuleHead;
117/** Pointer to the tail module. */
118extern PKLDRDY kLdrModuleTail;
119/** The Library search path. */
120extern char kLdrLibraryPath[4096];
121
122/** @name The Internal APIs
123 * @internal
124 * @{ */
125#if 0
126int kldrDyOpenExe(const char *pszFilename, PPKLDRMOD ppMod)
127int kldrDyOpen(const char *pszFilename, unsigned fFlags, PPKLDRMOD ppMod);
128int kldrClose(PKLDRMOD pMod);
129
130void kldrFailure(const char *pszFilename, ...);
131#endif
132/** @} */
133
134#ifdef __cplusplus
135}
136#endif
137
138#endif
Note: See TracBrowser for help on using the repository browser.