VirtualBox

Changeset 46080 in vbox for trunk


Ignore:
Timestamp:
May 14, 2013 8:09:08 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
85756
Message:

Added RTLdrOpenInMemory.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/ldr.h

    r46023 r46080  
    184184RTDECL(int) RTLdrOpenkLdr(const char *pszFilename, uint32_t fFlags, RTLDRARCH enmArch, PRTLDRMOD phLdrMod);
    185185
    186 /**
    187  * What to expect and do with the bits passed to RTLdrOpenBits().
    188  */
    189 typedef enum RTLDROPENBITS
    190 {
    191     /** The usual invalid 0 entry. */
    192     RTLDROPENBITS_INVALID = 0,
    193     /** The bits are readonly and will never be changed. */
    194     RTLDROPENBITS_READONLY,
    195     /** The bits are going to be changed and the loader will have to duplicate them
    196      * when opening the image. */
    197     RTLDROPENBITS_WRITABLE,
    198     /** The bits are both the source and destination for the loader operation.
    199      * This means that the loader may have to duplicate them prior to changing them. */
    200     RTLDROPENBITS_SRC_AND_DST,
    201     /** The end of the valid enums. This entry marks the
    202      * first invalid entry.. */
    203     RTLDROPENBITS_END,
    204     RTLDROPENBITS_32BIT_HACK = 0x7fffffff
    205 } RTLDROPENBITS;
    206 
    207 /**
    208  * Open a binary image from in-memory bits.
    209  *
    210  * @returns iprt status code.
    211  * @param   pvBits      The start of the raw-image.
    212  * @param   cbBits      The size of the raw-image.
    213  * @param   enmBits     What to expect from the pvBits.
    214  * @param   pszLogName  What to call the raw-image when logging.
    215  *                      For RTLdrLoad and RTLdrOpen the filename is used for this.
    216  * @param   phLdrMod    Where to store the handle to the loader module.
    217  */
    218 RTDECL(int) RTLdrOpenBits(const void *pvBits, size_t cbBits, RTLDROPENBITS enmBits, const char *pszLogName, PRTLDRMOD phLdrMod);
     186
     187/**
     188 * Called to read @a cb bytes at @a off into @a pvBuf.
     189 *
     190 * @returns IPRT status code
     191 * @param   pvBuf       The output buffer.
     192 * @param   cb          The number of bytes to read.
     193 * @param   off         Where to start reading.
     194 * @param   pvUser      The user parameter.
     195 */
     196typedef DECLCALLBACK(int) FNRTLDRRDRMEMREAD(void *pvBuf, size_t cb, size_t off, void *pvUser);
     197/** Pointer to a RTLdrOpenInMemory reader callback. */
     198typedef FNRTLDRRDRMEMREAD *PFNRTLDRRDRMEMREAD;
     199
     200/**
     201 * Called to when the module is unloaded (or done loading) to release resources
     202 * associated with it (@a pvUser).
     203 *
     204 * @returns IPRT status code
     205 * @param   pvUser      The user parameter.
     206 */
     207typedef DECLCALLBACK(void) FNRTLDRRDRMEMDTOR(void *pvUser);
     208/** Pointer to a RTLdrOpenInMemory destructor callback. */
     209typedef FNRTLDRRDRMEMDTOR *PFNRTLDRRDRMEMDTOR;
     210
     211/**
     212 * Open a in-memory image or an image with a custom reader callback.
     213 *
     214 * @returns IPRT status code.
     215 * @param   pszName     The image name.
     216 * @param   fFlags      Valid RTLDR_O_XXX combination.
     217 * @param   enmArch     CPU architecture specifier for the image to be loaded.
     218 * @param   cbImage     The size of the image (fake file).
     219 * @param   pfnRead     The read function.  If NULL is passed in, a default
     220 *                      reader function is provided that assumes @a pvUser
     221 *                      points to the raw image bits, at least @a cbImage of
     222 *                      valid memory.
     223 * @param   pfnDtor     The destructor function.  If NULL is passed, a default
     224 *                      destructor will be provided that passes @a pvUser to
     225 *                      RTMemFree.
     226 * @param   pvUser      The user argument or, if any of the callbacks are NULL,
     227 *                      a pointer to a memory block.
     228 * @param   phLdrMod    Where to return the module handle.
     229 */
     230RTDECL(int) RTLdrOpenInMemory(const char *pszName, uint32_t fFlags, RTLDRARCH enmArch, size_t cbImage,
     231                              PFNRTLDRRDRMEMREAD pfnRead, PFNRTLDRRDRMEMDTOR pfnDtor, void *pvUser,
     232                              PRTLDRMOD phLdrMod);
     233
    219234
    220235/**
     
    222237 *
    223238 * The handle can be obtained using any of the RTLdrLoad(), RTLdrOpen()
    224  * and RTLdrOpenBits() functions.
     239 * and RTLdrOpenInMemory() functions.
    225240 *
    226241 * @returns iprt status code.
     
    262277/**
    263278 * Gets the size of the loaded image.
    264  * This is only supported for modules which has been opened using RTLdrOpen() and RTLdrOpenBits().
     279 *
     280 * This is not necessarily available for images that has been loaded using
     281 * RTLdrLoad().
    265282 *
    266283 * @returns image size (in bytes).
    267  * @returns ~(size_t)0 on if not opened by RTLdrOpen().
     284 * @returns ~(size_t)0 on if not available.
    268285 * @param   hLdrMod     Handle to the loader module.
    269  * @remark  Not supported for RTLdrLoad() images.
    270286 */
    271287RTDECL(size_t) RTLdrSize(RTLDRMOD hLdrMod);
  • trunk/include/iprt/mangling.h

    r46077 r46080  
    628628# define RTLdrLoadEx                                    RT_MANGLER(RTLdrLoadEx)
    629629# define RTLdrOpen                                      RT_MANGLER(RTLdrOpen)
     630# define RTLdrOpenInMemory                              RT_MANGLER(RTLdrOpenInMemory)
    630631# define RTLdrOpenkLdr                                  RT_MANGLER(RTLdrOpenkLdr)
    631632# define RTLdrRelocate                                  RT_MANGLER(RTLdrRelocate)
  • trunk/src/VBox/Runtime/Makefile.kmk

    r46053 r46080  
    298298        common/ldr/ldrEx.cpp \
    299299        common/ldr/ldrFile.cpp \
     300        common/ldr/ldrMemory.cpp \
    300301        common/ldr/ldrNative.cpp \
    301302        common/ldr/ldrPE.cpp \
  • trunk/src/VBox/Runtime/common/ldr/ldrEx.cpp

    r44528 r46080  
    166166
    167167
    168 /**
    169  * Gets the size of the loaded image.
    170  * This is only supported for modules which has been opened using RTLdrOpen() and RTLdrOpenBits().
    171  *
    172  * @returns image size (in bytes).
    173  * @returns ~(size_t)0 on if not opened by RTLdrOpen().
    174  * @param   hLdrMod     Handle to the loader module.
    175  * @remark  Not supported for RTLdrLoad() images.
    176  */
    177168RTDECL(size_t) RTLdrSize(RTLDRMOD hLdrMod)
    178169{
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette