/* $Id: kLdrInternal.h 2827 2006-10-22 18:05:28Z bird $ */ /** @file * * kLdr - The Dynamic Loader, internal header. * * Copyright (c) 2006 knut st. osmundsen * * * This file is part of kLdr. * * kLdr is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * kLdr is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with kLdr; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ifndef __kLdrInternal_h__ #define __kLdrInternal_h__ #ifdef __cplusplus extern "C" { #endif /* ignore definitions in winnt.h */ #undef IMAGE_DOS_SIGNATURE #undef IMAGE_NT_SIGNATURE /** @name Signatures we know * @{ */ /** ELF signature ("\x7fELF"). */ #define IMAGE_ELF_SIGNATURE KLDRHLP_LE2H_U32(0x7f | ('E' << 8) | ((uint32_t)'L' << 16) | ((uint32_t)'F' << 24)) /** PE signature ("PE\0\0"). */ #define IMAGE_NT_SIGNATURE KLDRHLP_LE2H_U32('P' | ('E' << 8)) /** LX signature ("LX") */ #define IMAGE_LX_SIGNATURE KLDRHLP_LE2H_U16('L' | ('X' << 8)) /** LE signature ("LE") */ #define IMAGE_LE_SIGNATURE KLDRHLP_LE2H_U16('L' | ('E' << 8)) /** NE signature ("NE") */ #define IMAGE_NE_SIGNATURE KLDRHLP_LE2H_U16('N' | ('E' << 8)) /** MZ signature ("MZ"). */ #define IMAGE_DOS_SIGNATURE KLDRHLP_LE2H_U16('M' | ('Z' << 8)) /** @} */ /** Native file provider operations. */ extern const KLDRRDROPS g_kLdrRdrFileOps; /** * The state of a dynamic loader module. */ typedef enum KLDRSTATE { /** The usual invalid 0 enum. */ KLDRSTATE_INVALID = 0, /** kldrOpen succeeded. * Modules in this state will be freed at */ KLDRSTATE_OPEN, /** Dependencies has been loaded. */ KLDRSTATE_DEPS, /** Fixups has been applied. */ KLDRSTATE_FIXED, /** The module has been initialized. */ KLDRSTATE_INITED, /** The module is loaded successfully. */ KLDRSTATE_LOADED, /** The end of valid states (exclusive) */ KLDRSTATE_END, /** The usual 32-bit blowup. */ KLDRSTATE_32BIT_HACK = 0x7fffffff } KLDRSTATE; /** * Dynamic loader module. */ typedef struct KLDRDY { /** The next module in the list. */ PKLDRDY pNext; /** The prev module in the list. */ PKLDRDY pPrev; /** The module. */ PKLDRMOD pMod; /** The module state. */ KLDRSTATE enmState; /** The number of references. */ uint32_t cRefs; /** The number of dynamic references. */ uint32_t cDynRefs; /** Magic number. */ uint32_t u32Magic; /** Set if this is the executable module. */ uint32_t fExecutable : 1; /** Global DLL (set) or specific DLL (clear). */ uint32_t fGlobal : 1; /** Load stage one. */ uint32_t fLoadStageOne : 1; /** Reserved for future use. */ uint32_t fReserved : 29; } KLDRDY; /** Pointer to the head module (the executable). */ extern PKLDRDY kLdrModuleHead; /** Pointer to the tail module. */ extern PKLDRDY kLdrModuleTail; /** The Library search path. */ extern char kLdrLibraryPath[4096]; /** @name The Internal APIs * @internal * @{ */ #if 0 int kldrDyOpenExe(const char *pszFilename, PPKLDRMOD ppMod) int kldrDyOpen(const char *pszFilename, unsigned fFlags, PPKLDRMOD ppMod); int kldrClose(PKLDRMOD pMod); void kldrFailure(const char *pszFilename, ...); #endif /** @} */ #ifdef __cplusplus } #endif #endif