ldrNative.cpp revision 43481c598c5a5892f31afd00ca6624d41de6470d
/* $Id$ */
/** @file
* IPRT - Binary Image Loader, Native interface.
*/
/*
* Copyright (C) 2006-2007 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP RTLOGGROUP_LDR
/** @copydoc RTLDROPS::pfnEnumSymbols */
static DECLCALLBACK(int) rtldrNativeEnumSymbols(PRTLDRMODINTERNAL pMod, unsigned fFlags, const void *pvBits, RTUINTPTR BaseAddress,
{
return VERR_NOT_SUPPORTED;
}
/** @copydoc RTLDROPS::pfnDone */
{
return VINF_SUCCESS;
}
/**
* Operations for a native module.
*/
static const RTLDROPS s_rtldrNativeOps =
{
"native",
/* ext: */
NULL,
NULL,
NULL,
NULL,
42
};
/**
* Loads a dynamic load library (/shared object) image file using native
* OS facilities.
*
* the platform if it have been omitted. This means that it's not
* but that's not a bad tradeoff.
*
* If no path is specified in the filename, the OS will usually search it's library
* path to find the image file.
*
* @returns iprt status code.
* @param pszFilename Image filename.
* @param phLdrMod Where to store the handle to the loaded module.
*/
{
}
RTDECL(int) RTLdrLoadEx(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, PRTERRINFO pErrInfo)
{
LogFlow(("RTLdrLoadEx: pszFilename=%p:{%s} phLdrMod=%p fFlags=%#x pErrInfo=%p\n", pszFilename, pszFilename, phLdrMod, fFlags, pErrInfo));
/*
* Validate and massage the input.
*/
/*
* Allocate and initialize module structure.
*/
int rc = VERR_NO_MEMORY;
if (pMod)
{
/*
* Attempt to open the module.
*/
if (RT_SUCCESS(rc))
{
return rc;
}
}
else
*phLdrMod = NIL_RTLDRMOD;
return rc;
}
/**
* Loads a dynamic load library (/shared object) image file residing in the
* RTPathAppPrivateArch() directory.
*
* Suffix is not required.
*
* @returns iprt status code.
* @param pszFilename Image filename. No path.
* @param phLdrMod Where to store the handle to the loaded module.
*/
{
LogFlow(("RTLdrLoadAppPriv: pszFilename=%p:{%s} phLdrMod=%p\n", pszFilename, pszFilename, phLdrMod));
/*
* Validate input.
*/
*phLdrMod = NIL_RTLDRMOD;
/*
* Check the filename.
*/
AssertMsgReturn(cchFilename < (RTPATH_MAX / 4) * 3, ("%zu\n", cchFilename), VERR_INVALID_PARAMETER);
const char *pszExt = "";
if (!RTPathHaveExt(pszFilename))
{
pszExt = RTLdrGetSuff();
}
/*
* Construct the private arch path and check if the file exists.
*/
char szPath[RTPATH_MAX];
*psz++ = RTPATH_SLASH;
psz += cchFilename;
if (!RTPathExists(szPath))
{
return VERR_FILE_NOT_FOUND;
}
/*
* Pass it on to RTLdrLoad.
*/
return rc;
}
/**
*
* @returns The stuff (readonly).
*/
RTDECL(const char *) RTLdrGetSuff(void)
{
#if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
static const char s_szSuff[] = ".DLL";
#elif defined(RT_OS_DARWIN)
static const char s_szSuff[] = ".dylib";
#else
static const char s_szSuff[] = ".so";
#endif
return s_szSuff;
}