/* $Id: kLdr.h 2833 2006-10-26 00:08:09Z bird $ */ /** @file * * kLdr - The Dynamic Loader. * * 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 __kLdr_h__ #define __kLdr_h__ #ifdef __cplusplus extern "C" { #endif /* kLdr depend on size_t, [u]intNN_t, [u]intptr_t and some related constants. */ #include #include #ifdef _MSC_VER typedef signed char int8_t; typedef unsigned char uint8_t; typedef signed short int16_t; typedef unsigned short uint16_t; typedef signed int int32_t; typedef unsigned int uint32_t; typedef signed __int64 int64_t; typedef unsigned __int64 uint64_t; typedef uint64_t uintmax_t; #else # include #endif /** @defgroup grp_kLdrRdr kLdrRdr - The file provider * @{ */ typedef enum KLDRPROT { /** The usual invalid 0. */ KLDRPROT_INVALID = 0, /** No access (page not present). */ KLDRPROT_NOACCESS, /** Read only. */ KLDRPROT_READONLY, /** Read & write. */ KLDRPROT_READWRITE, /** Read & copy on write. */ KLDRPROT_WRITECOPY, /** Execute only. */ KLDRPROT_EXECUTE, /** Execute & read. */ KLDRPROT_EXECUTE_READ, /** Execute, read & write. */ KLDRPROT_EXECUTE_READWRITE, /** Execute, read & copy on write. */ KLDRPROT_EXECUTE_WRITECOPY, /** The usual end value. (exclusive) */ KLDRPROT_END, /** Blow the type up to 32-bits. */ KLDRPROT_32BIT_HACK = 0x7fffffff } KLDRPROT; /** Pointer to a file provider instance core. */ typedef struct KLDRRDR *PKLDRRDR; /** Pointer to a file provider instance core pointer. */ typedef struct KLDRRDR **PPKLDRRDR; /** * File provider instance operations. */ typedef struct KLDRRDROPS { /** The name of this file provider. */ const char *pszName; /** Pointer to the next file provider. */ const struct KLDRRDROPS *pNext; /** Try create a new file provider instance. * * @returns 0 on success, OS specific error code on failure. * @param ppRdr Where to store the file provider instance. * @param pszFilename The filename to open. */ int (* pfnCreate)( PPKLDRRDR ppRdr, const char *pszFilename); /** Destroy the file provider instance. * * @returns 0 on success, OS specific error code on failure. * On failure, the file provider instance will be in an indeterminate state - don't touch it! * @param pRdr The file provider instance. */ int (* pfnDestroy)( PKLDRRDR pRdr); /** Read bits from the file. * * @returns 0 on success, OS specific error code on failure. * @param pRdr The file provider instance. * @param pvBuf Where to put the bits. * @param cb The number of bytes to read. * @param off Where to start reading. */ int (* pfnRead)( PKLDRRDR pRdr, void *pvBuf, size_t cb, off_t off); /** Map all the file bits into memory (read only). * * @returns 0 on success, OS specific error code on failure. * @param pRdr The file provider instance. * @param ppvBits Where to store the address of the mapping. * The size can be obtained using pfnSize. */ int (* pfnAllMap)( PKLDRRDR pRdr, const void **ppvBits); /** Unmap a file bits mapping obtained by KLDRRDROPS::pfnAllMap. * * @returns 0 on success, OS specific error code on failure. * @param pRdr The file provider instance. * @param pvBits The mapping address. */ int (* pfnAllUnmap)(PKLDRRDR pRdr, const void *pvBits); /** Get the file size. * * @returns The file size. Returns -1 on failure. * @param pRdr The file provider instance. */ off_t (* pfnSize)( PKLDRRDR pRdr); /** Get the file pointer offset. * * @returns The file pointer offset. Returns -1 on failure. * @param pRdr The file provider instance. */ off_t (* pfnTell)( PKLDRRDR pRdr); /** Get the file name. * * @returns The file size. Returns -1 on failure. * @param pRdr The file provider instance. */ const char * (* pfnName)(PKLDRRDR pRdr); /** * Prepares a memory region to map file sections into. * * @returns 0 on success, OS specific error code on failure. * @param pRdr The file provider instance. * @param ppv If fFixed is set, *ppv contains the memory location which * the region should be based at. If fFixed is clear the OS * is free to choose the location. * On successful return *ppv contains address of the prepared * memory region. * @param cb The size of the memory region to prepare. * @param fFixed When set *ppv will contain the desired region address. * */ int (* pfnPrepare)(PKLDRRDR pRdr, void **ppv, size_t cb, unsigned fFixed); /** * Maps a section of the file into the memory region reserved by pfnPrepare. * * @returns 0 on success, OS specific error code on failure. * @param pRdr The file provider instance. * @param pv The address in the prepared region. * @param cb The size of the memory mapping. * @param enmProt The desired memory protection. * @param offFile The start of the raw file bytes. * @param cbFile The number of raw file bytes. This must be less or equal to cb. */ int (* pfnMap)(PKLDRRDR pRdr, void *pv, size_t cb, KLDRPROT enmProt, off_t offFile, size_t cbFile); /** * Changes the page protection of a section mapped using pfnMap. * * This is typically used for applying fixups and similar. * * @returns 0 on success, OS specific error code on failure. * @param pRdr The file provider instance. * @param pv The address passed to pfnMap. * @param cb The size passed to pfnMap. * @param enmProt The desired memory protection. */ int (* pfnProtect)(PKLDRRDR pRdr, void *pv, size_t cb, KLDRPROT enmProt); /** * Unmaps a section of the file previously mapped using pfnMap. * * @returns 0 on success, OS specific error code on failure. * @param pRdr The file provider instance. * @param pv The address passed to pfnMap. * @param cb The size passed to pfnMap. */ int (* pfnUnmap)(PKLDRRDR pRdr, void *pv, size_t cb); /** * Releases the memory region prepared by pfnPrepare(). * * Before calling this function, all sections mapped by pfnMap must first be unmapped by calling pfnUnmap. * * @returns 0 on success, OS specific error code on failure. * @param pRdr The file provider instance. * @param pv The address of the prepared region. * @param cb The size of the prepared region. */ int (* pfnUnprepare)(PKLDRRDR pRdr, void *pv, size_t cb); /** * We're done reading from the file but would like to keep file mappings. * * If the OS support closing the file handle while the file is mapped, * the reader should do so. * * @param pRdr The file provider instance. */ void (* pfnDone)(PKLDRRDR pRdr); /** The usual non-zero dummy that makes sure we've initialized all members. */ uint32_t u32Dummy; } KLDRRDROPS; /** Pointer to file provider operations. */ typedef KLDRRDROPS *PKLDRRDROPS; /** Pointer to const file provider operations. */ typedef const KLDRRDROPS *PCKLDRRDROPS; /** * File provider instance core. */ typedef struct KLDRRDR { /** Pointer to the file provider operations. */ PCKLDRRDROPS pOps; } KLDRRDR; void kLdrRdrAddProvider(PKLDRRDROPS pAdd); int kLdrRdrOpen( PPKLDRRDR ppRdr, const char *pszFilename); int kLdrRdrClose( PKLDRRDR pRdr); int kLdrRdrRead( PKLDRRDR pRdr, void *pvBuf, size_t cb, off_t off); int kLdrRdrAllMap( PKLDRRDR pRdr, const void **ppvBits); int kLdrRdrAllUnmap(PKLDRRDR pRdr, const void *pvBits); off_t kLdrRdrSize( PKLDRRDR pRdr); off_t kLdrRdrTell( PKLDRRDR pRdr); const char *kLdrRdrName(PKLDRRDR pRdr); /** @} */ /** @defgroup grp_kLdrMod kLdrMod - The executable image intepreter * @{ */ /** * Loader segment. */ typedef struct KLDRSEG { /** Variable free to use for the kLdr user. */ void *pvUser; /** The segment name. */ const char *pszName; /** The size of the segment. */ size_t cb; /** The link time load address. */ void *pvLink; /** The actual load address (if loaded). */ void *pv; /** The segment protection. */ KLDRPROT enmProt; } KLDRSEG, *PKLDRSEG; /** * Loader module format. */ typedef enum KLDRFMT { /** The usual invalid 0 format. */ KLDRFMT_INVALID = 0, /** The native OS loader. */ KLDRFMT_NATIVE, /** The AOUT loader. */ KLDRFMT_AOUT, /** The ELF loader. */ KLDRFMT_ELF, /** The LX loader. */ KLDRFMT_LX, /** The mach-o loader. */ KLDRFMT_MACHO, /** The LX loader. */ KLDRFMT_PE, /** The end of the valid format values (exclusive). */ KLDRFMT_END, /** Hack to blow the type up to 32-bit. */ KLDRFMT_32BIT_HACK = 0x7fffffff } KLDRFMT; /** * Loader module type. */ typedef enum KLDRTYPE { /** The usual invalid 0 type. */ KLDRTYPE_INVALID = 0, /** Object file. */ KLDRTYPE_OBJECT, /** Executable module, fixed load address. */ KLDRTYPE_EXECUTABLE_FIXED, /** Executable module, relocatable, non-fixed load address. */ KLDRTYPE_EXECUTABLE_RELOCATABLE, /** Executable module, position independent code, non-fixed load address. */ KLDRTYPE_EXECUTABLE_PIC, /** Shared library, fixed load address. * Typically a system library. */ KLDRTYPE_SHARED_LIBRARY_FIXED, /** Shared library, relocatable, non-fixed load address. */ KLDRTYPE_SHARED_LIBRARY_RELOCATABLE, /** Shared library, position independent code, non-fixed load address. */ KLDRTYPE_SHARED_LIBRARY_PIC, /** DLL that contains no code or data only imports and exports. (Chiefly OS/2.) */ KLDRTYPE_FORWARDER_DLL, /** Core or dump. */ KLDRTYPE_CORE, /** The end of the valid types values (exclusive). */ KLDRTYPE_END, /** Hack to blow the type up to 32-bit. */ KLDRTYPE_32BIT_HACK = 0x7fffffff } KLDRTYPE; /** * CPU Architecture. * @todo Double check the non intel architectures. */ typedef enum KLDRARCH { /** The usual invalid one. */ KLDRARCH_INVALID = 0, /** Clone or Intel 16-bit x86. */ KLDRARCH_X86_16, /** Clone or Intel 32-bit x86. */ KLDRARCH_X86_32, /** AMD64 (including clones). */ KLDRARCH_AMD64, /** Itanic (64-bit). */ KLDRARCH_IA64, /** ALPHA (64-bit). */ KLDRARCH_ALPHA, /** ALPHA limited to 32-bit. */ KLDRARCH_ALPHA_32, /** 32-bit ARM. */ KLDRARCH_ARM_32, /** 64-bit ARM. */ KLDRARCH_ARM_64, /** 32-bit MIPS. */ KLDRARCH_MIPS_32, /** 64-bit MIPS. */ KLDRARCH_MIPS_64, /** 32-bit PowerPC. */ KLDRARCH_POWERPC_32, /** 64-bit PowerPC. */ KLDRARCH_POWERPC_64, /** 32-bit SPARC. */ KLDRARCH_SPARC_32, /** 64-bit SPARC. */ KLDRARCH_SPARC_64, /** The end of the valid architecture values (exclusive). */ KLDRARCH_END, /** Hack to blow the type up to 32-bit. */ KLDRARCH_32BIT_HACK = 0x7fffffff } KLDRARCH; /** * CPU models. */ typedef enum KLDRCPU { /** The usual invalid cpu. */ KLDRCPU_INVALID = 0, /** @name KLDRARCH_X86_16 * @{ */ KLDRCPU_I8086, KLDRCPU_I8088, KLDRCPU_I80186, KLDRCPU_I80286, KLDRCPU_I386_16, KLDRCPU_I486_16, KLDRCPU_I486SX_16, KLDRCPU_I586_16, KLDRCPU_I686_16, KLDRCPU_K6_16, KLDRCPU_K7_16, KLDRCPU_K8_16, /** @} */ /** @name KLDRARCH_X86_32 * @{ */ KLDRCPU_I386, KLDRCPU_I486, KLDRCPU_I486SX, KLDRCPU_I586, KLDRCPU_I686, KLDRCPU_P4, KLDRCPU_CORE2_32, KLDRCPU_K6, KLDRCPU_K7, KLDRCPU_K8_32, /** @} */ /** @name KLDRARCH_AMD64 * @{ */ KLDRCPU_K8, KLDRCPU_P4_64, KLDRCPU_CORE2, /** @} */ /** The end of the valid cpu values (exclusive). */ KLDRCPU_END, /** Hack to blow the type up to 32-bit. */ KLDRCPU_32BIT_HACK = 0x7fffffff } KLDRCPU; /** * Loader endian indicator. */ typedef enum KLDRENDIAN { /** The usual invalid endian. */ KLDRENDIAN_INVALID, /** Little endian. */ KLDRENDIAN_LITTLE, /** Bit endian. */ KLDRENDIAN_BIG, /** Endianness doesn't have a meaning in the context. */ KLDRENDIAN_NA, /** The end of the valid endian values (exclusive). */ KLDRENDIAN_END, /** Hack to blow the type up to 32-bit. */ KLDRENDIAN_32BIT_HACK = 0x7fffffff } KLDRENDIAN; /** * Loader module. */ typedef struct KLDRMOD { /** Magic number. */ uint32_t u32Magic; /** The format of this module. */ KLDRFMT enmFmt; /** The type of module. */ KLDRTYPE enmType; /** The architecture this module was built for. */ KLDRARCH enmArch; /** The minium cpu this module was built for. * This might not be accurate, so use kLdrModCanExecuteOn() to check. */ KLDRARCH enmCpu; /** The endian used by the module. */ KLDRENDIAN enmEndian; /** The filename length (bytes). */ uint32_t cchFilename; /** The filename. */ const char *pszFilename; /** The module name. */ const char *pszName; /** The module name length (bytes). */ uint32_t cchName; /** The number of segments in the module. */ uint32_t cSegments; /** The module data. */ void *pvData; /** Segments. (variable size, can be zero) */ KLDRSEG aSegments[1]; } KLDRMOD, *PKLDRMOD, **PPKLDRMOD; /** Special base address value alias for the link address. */ #define KLDRMOD_BASEADDRESS_LINK (~(uintmax_t)1) /** Special base address value alias for the actual load address (must be mapped). */ #define KLDRMOD_BASEADDRESS_MAP (~(uintmax_t)2) /** @name Load symbol kind flags. * @{ */ /** The bitness doesn't matter. */ #define KLDRSYMKIND_NO_BIT 0x00000000 /** 16-bit symbol. */ #define KLDRSYMKIND_16BIT 0x00000001 /** 32-bit symbol. */ #define KLDRSYMKIND_32BIT 0x00000002 /** 64-bit symbol. */ #define KLDRSYMKIND_64BIT 0x00000003 /** Mask out the bit.*/ #define KLDRSYMKIND_BIT_MASK 0x00000003 /** We don't know the type of symbol. */ #define KLDRSYMKIND_NO_TYPE 0x00000000 /** The symbol is a code object (method/function/procedure/whateveryouwannacallit). */ #define KLDRSYMKIND_CODE 0x00000010 /** The symbol is a data object. */ #define KLDRSYMKIND_DATA 0x00000020 /** Mask out the symbol type. */ #define KLDRSYMKIND_TYPE_MASK 0x00000030 /** Valid symbol kind mask. */ #define KLDRSYMKIND_MASK 0x00000033 /** @} */ /** @name kLdrModEnumSymbols flags. * @{ */ /** Returns ALL kinds of symbols. The default is to only return public/exported symbols. */ #define KLDRMOD_ENUM_SYMBOL_FLAGS_ALL 0x00000001 /** @} */ typedef int FNKLDRMODGETIMPORT(PKLDRMOD pMod, const char *pszModule, const char *pszSymbol, uint32_t uSymbol, uintmax_t *pValue, uint32_t *pfKind, void *pvModuleUser, void *pvUser); typedef FNKLDRMODGETIMPORT *PFNKLDRMODGETIMPORT; typedef int FNKLDRMODENUMIMPMODS(PKLDRMOD pMod, const char *pszImpMod, unsigned fFlags, void *pvUser); typedef FNKLDRMODENUMIMPMODS *PFNKLDRMODENUMIMPMODS; typedef int FNKLDRMODENUMSYMS(PKLDRMOD pMod, const char *pszSymbol, unsigned uSymbol, uintmax_t Value, uint32_t fKind, void *pvUser); typedef FNKLDRMODENUMSYMS *PFNKLDRMODENUMSYMS; int kLdrModOpen(const char *pszFilename, PPKLDRMOD ppMod); int kLdrModClose(PKLDRMOD pMod); int kLdrModGetSymbol(PKLDRMOD pMod, const void *pvBits, uintmax_t BaseAddress, const char *pszSymbol, uintmax_t *pValue, uint32_t *pfKind); int kLdrModEnumSymbols(PKLDRMOD pMod, unsigned fFlags, const void *pvBits, uintmax_t BaseAddress, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser); int kLdrModEnumImportModules(PKLDRMOD pMod, unsigned fFlags, const void *pvBits, FNKLDRMODENUMIMPMODS pfnCallback, void *pvUser); int kLdrModMap(PKLDRMOD pMod); int kLdrModUnmap(PKLDRMOD pMod); int kLdrModFixupMapping(PKLDRMOD pMod, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser); size_t kLdrModSize(PKLDRMOD pMod); int kLdrModGetBits(PKLDRMOD pMod, void *pvBits, uintmax_t BaseAddress, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser); int kLdrModRelocateBits(PKLDRMOD pMod, void *pvBits, uintmax_t NewBaseAddress, uintmax_t OldBaseAddress, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser); int kLdrModCanExecuteOn(PKLDRMOD pMod, KLDRARCH enmArch, KLDRCPU enmCpu); /** @} */ /** @defgroup grp_kLdrDyld kLdrDyld - The dynamic loader * @{ */ /** The handle to a dynamic loader module. */ typedef struct KLDRDYLDMOD *HKLDRMOD; /** Pointer to the handle to a dynamic loader module. */ typedef HKLDRMOD *PHKLDRMOD; /** NIL handle value. */ #define NIL_HKLDRMOD ((HKLDRMOD)0) /** * File search method. * * In addition to it's own way of finding files, kLdr emulates * the methods employed by the most popular systems. */ typedef enum KLDRDYLDSEARCH { /** The usual invalid file search method. */ KLDRDYLD_SEARCH_INVALID = 0, /** Uses the kLdr file search method. * @todo invent me. */ KLDRDYLD_SEARCH_KLDR, /** Use the emulation closest to the host system. */ KLDRDYLD_SEARCH_HOST, /** Emulate the OS/2 file search method. * On non-OS/2 systems, BEGINLIBPATH, LIBPATH, ENDLIBPATH and LIBPATHSTRICT are * taken form the environment. */ KLDRDYLD_SEARCH_OS2, /** Emulate the standard window file search method. */ KLDRDYLD_SEARCH_WINDOWS, /** Emulate the alternative window file search method. */ KLDRDYLD_SEARCH_WINDOWS_ALTERED, /** Emulate the most common UNIX file search method. */ KLDRDYLD_SEARCH_UNIX_COMMON, /** End of the valid file search method values. */ KLDRDYLD_SEARCH_END, /** Hack to blow the type up to 32-bit. */ KLDRDYLD_SEARCH_32BIT_HACK = 0x7fffffff } KLDRDYLDSEARCH; /** @name kLdrLoadDll flags. * @{ */ /** The symbols in the module should be loaded into the global unix namespace. * If not specified, the symbols are local and can only be referenced directly. */ #define KLDRYDLD_LOAD_FLAGS_GLOBAL_SYMBOLS 0x00000001 /** The module shouldn't be found by a global module search. * If not specified, the module can be found by unspecified module searches, * typical used when loading import/dep modules. */ #define KLDRYDLD_LOAD_FLAGS_SPECIFIC_MODULE 0x00000002 /** @todo more to come. */ /** @} */ int kLdrDyldLoad(const char *pszDll, const char *pszDefPrefix, const char *pszDefSuffix, KLDRDYLDSEARCH enmSearch, unsigned fFlags, PHKLDRMOD phMod, char *pszErr, size_t cchErr); int kLdrDyldUnload(HKLDRMOD hMod); int kLdrDyldFindByName(const char *pszDll, const char *pszDefPrefix, const char *pszDefSuffix, KLDRDYLDSEARCH enmSearch, PHKLDRMOD phMod); int kLdrDyldFindByAddress(uintptr_t Address, PHKLDRMOD phMod, uint32_t *piSegment, uintptr_t *poffSegment); int kLdrDyldGetName(HKLDRMOD hMod, char *pszName, size_t cchName); int kLdrDyldGetFilename(HKLDRMOD hMod, char *pszFilename, size_t cchFilenamep); int kLdrDyldQuerySymbol(HKLDRMOD hMod, uint32_t uSymbolOrdinal, const char *pszSymbolName, uintptr_t *pValue, uint32_t *pfKind); /** @name OS/2 like API * @{ */ int kLdrDosLoadModule(char *pszObject, size_t cbObject, const char *pszModule, PHKLDRMOD phMod); int kLdrDosFreeModule(HKLDRMOD hMod); int kLdrDosQueryModuleHandle(const char *pszModname, PHKLDRMOD phMod); int kLdrDosQueryModuleName(HKLDRMOD hMod, size_t cchName, char *pszName); int kLdrDosQueryProcAddr(HKLDRMOD hMod, uint32_t iOrdinal, const char *pszProcName, void **ppvProcAddr); int kLdrDosQueryProcType(HKLDRMOD hMod, uint32_t iOrdinal, const char *pszProcName, uint32_t *pfProcType); int kLdrDosQueryModFromEIP(PHKLDRMOD phMod, uint32_t *piObject, size_t cbName, char *pszName, uintptr_t *poffObject, uintptr_t ulEIP); int kLdrDosReplaceModule(const char *pszOldModule, const char *pszNewModule, const char *pszBackupModule); int kLdrDosGetResource(HKLDRMOD hMod, uint32_t idType, uint32_t idName, void **pvResAddr); int kLdrDosQueryResourceSize(HKLDRMOD hMod, uint32_t idTypeID, uint32_t idName, uint32_t *pcb); int kLdrDosFreeResource(void *pvResAddr); /** @} */ /** @name POSIX like API * @{ */ HKLDRMOD kLdrDlOpen(const char *pszLibrary, int fFlags); const char *kLdrDlError(void); void * kLdrDlSym(HKLDRMOD hMod, const char *pszSymbol); int kLdrDlClose(HKLDRMOD hMod); /** @} */ /** @name Win32 like API * @{ */ HKLDRMOD kLdrWLoadLibrary(const char *pszFilename); HKLDRMOD kLdrWLoadLibraryEx(const char *pszFilename, void *hFileReserved, uint32_t fFlags); uint32_t kLdrWGetModuleFileName(HKLDRMOD hMod, char *pszModName, size_t cchModName); HKLDRMOD kLdrWGetModuleHandle(const char *pszFilename); int kLdrWGetModuleHandleEx(uint32_t fFlags, const char *pszFilename, HKLDRMOD hMod); void * kLdrWGetProcAddress(HKLDRMOD hMod, const char *pszProcName); uint32_t kLdrWGetDllDirectory(size_t cchDir, char *pszDir); int kLdrWSetDllDirectory(const char *pszDir); int kLdrWFreeLibrary(HKLDRMOD hMod); int kLdrWDisableThreadLibraryCalls(HKLDRMOD hMod); /** @} */ /** @name Process Bootstrapping * @{ */ /** * Argument package from the stub. */ typedef struct KLDREXEARGS { /** Flags. (Currently unused, MBZ.) */ uint32_t fFlags; /** The executable file that the stub is supposed to load. */ char szExecutable[260]; /** The LD_LIBRARY_PATH prefix for the process.. */ char szLibPath[4096 - 260 - sizeof(uint32_t)]; } KLDREXEARGS, *PKLDREXEARGS; void kLdrLoadExe(PKLDREXEARGS pArgs, void *pvOS); /** @} */ /** @} */ /** @defgroup grp_kLdrErr kLdr Status Codes * kLdr uses a mix of native status codes and it's own status codes. * A status code of 0 means success, all other status codes means failure. * @{ */ #ifdef __OS2__ # define KLDR_ERR_BASE 0x7face000 #elif defined(__WIN__) # define KLDR_ERR_BASE 0x7face000 #else # error "port me" #endif /** The image format is unknown. */ #define KLDR_ERR_UNKNOWN_FORMAT (KLDR_ERR_BASE + 0) /** The MZ image format isn't supported by this kLdr build. */ #define KLDR_ERR_MZ_NOT_SUPPORTED (KLDR_ERR_BASE + 1) /** The NE image format isn't supported by this kLdr build. */ #define KLDR_ERR_NE_NOT_SUPPORTED (KLDR_ERR_BASE + 2) /** The LX image format isn't supported by this kLdr build. */ #define KLDR_ERR_LX_NOT_SUPPORTED (KLDR_ERR_BASE + 3) /** The LE image format isn't supported by this kLdr build. */ #define KLDR_ERR_LE_NOT_SUPPORTED (KLDR_ERR_BASE + 4) /** The PE image format isn't supported by this kLdr build. */ #define KLDR_ERR_PE_NOT_SUPPORTED (KLDR_ERR_BASE + 5) /** The ELF image format isn't supported by this kLdr build. */ #define KLDR_ERR_ELF_NOT_SUPPORTED (KLDR_ERR_BASE + 6) /** The mach-o image format isn't supported by this kLdr build. */ #define KLDR_ERR_MACHO_NOT_SUPPORTED (KLDR_ERR_BASE + 7) /** The mach-o image format isn't supported by this kLdr build. */ #define KLDR_ERR_AOUT_NOT_SUPPORTED (KLDR_ERR_BASE + 8) /** Invalid parameter to a kLdr API. */ #define KLDR_ERR_INVALID_PARAMETER (KLDR_ERR_BASE + 32) /** Invalid handle parameter to a kLdr API. */ #define KLDR_ERR_INVALID_HANDLE (KLDR_ERR_BASE + 33) /** Encountered a bad fixup. */ #define KLDR_ERR_BAD_FIXUP (KLDR_ERR_BASE + 48) /** @} */ #ifdef __cplusplus } #endif #endif