ldrMemory.cpp revision dd3bf01d4d20cb65188917a7936a93466d8d231b
/* $Id$ */
/** @file
*/
/*
* Copyright (C) 2006-2013 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
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* Memory reader (for debuggers) instance.
*/
typedef struct RTLDRRDRMEM
{
/** The core. */
/** The size of the image. */
/** The current offset. */
/** User parameter for the reader and destructor functions.*/
void *pvUser;
/** Read function. */
/** Destructor callback. */
/** Mapping of the file. */
void *pvMapping;
/** Mapping usage counter. */
/** The fake filename (variable size). */
char szName[1];
} RTLDRRDRMEM;
/** Memory based loader reader instance data. */
typedef RTLDRRDRMEM *PRTLDRRDRMEM;
/** @callback_method_impl{FNRTLDRRDRMEMDTOR,
* Default destructor - pvUser points to the image memory block.}
*/
{
}
/** @callback_method_impl{FNRTLDRRDRMEMREAD,
* Default memory reader - pvUser points to the image memory block.}
*/
{
return VINF_SUCCESS;
}
/** @copydoc RTLDRREADER::pfnRead */
{
{
return VERR_EOF;
}
if (RT_SUCCESS(rc))
else
return rc;
}
/** @copydoc RTLDRREADER::pfnTell */
{
}
/** @copydoc RTLDRREADER::pfnSize */
{
}
/** @copydoc RTLDRREADER::pfnLogName */
{
}
/** @copydoc RTLDRREADER::pfnMap */
{
/*
* Already mapped?
*/
{
return VINF_SUCCESS;
}
/*
* Allocate memory.
*/
return VERR_NO_MEMORY;
if (RT_SUCCESS(rc))
{
}
else
{
}
return rc;
}
/** @copydoc RTLDRREADER::pfnUnmap */
{
{
}
return VINF_SUCCESS;
}
/** @copydoc RTLDRREADER::pfnDestroy */
{
return VINF_SUCCESS;
}
/**
* Opens a memory based loader reader.
*
* @returns iprt status code.
* @param ppReader Where to store the reader instance on success.
* @param pszName The name to give the image.
* @param cbImage The image size.
* @param pfnRead The reader function. If NULL, a default reader is
* used that assumes pvUser points to a memory buffer
* of at least @a cbImage size.
* @param pfnDtor The destructor. If NULL, a default destructore is
* used that will call RTMemFree on @a pvUser.
* @param pvUser User argument. If either @a pfnRead or @a pfnDtor
* is NULL, this must be a pointer to readable memory
* (see above).
*/
{
#endif
int rc = VERR_NO_MEMORY;
if (pThis)
{
return VINF_SUCCESS;
}
return rc;
}
RTDECL(int) RTLdrOpenInMemory(const char *pszName, uint32_t fFlags, RTLDRARCH enmArch, size_t cbImage,
{
LogFlow(("RTLdrOpenInMemory: pszName=%p:{%s} fFlags=%#x enmArch=%d cbImage=%#zu pfnRead=%p pfnDtor=%p pvUser=%p phLdrMod=%p\n",
if (!pfnDtor)
else
/* The rest of the validations will call the destructor. */
if (!pfnRead)
else
/*
* Resolve RTLDRARCH_HOST.
*/
if (enmArch == RTLDRARCH_HOST)
#if defined(RT_ARCH_AMD64)
#elif defined(RT_ARCH_X86)
#else
#endif
/*
* Create file reader & invoke worker which identifies and calls the image interpreter.
*/
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
return rc;
}
}
else
*phLdrMod = NIL_RTLDRMOD;
return rc;
}