VirtualBox

Changeset 35183 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Dec 16, 2010 1:59:44 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
69022
Message:

RTLdrLoadEx use RTERRINFO.

Location:
trunk/src/VBox/Runtime
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/ldr/ldrNative.cpp

    r35152 r35183  
    9696RTDECL(int) RTLdrLoad(const char *pszFilename, PRTLDRMOD phLdrMod)
    9797{
    98     return RTLdrLoadEx(pszFilename, phLdrMod, 0 /*=fFlags*/, NULL, 0);
     98    return RTLdrLoadEx(pszFilename, phLdrMod, 0 /*fFlags*/, NULL);
    9999}
    100100RT_EXPORT_SYMBOL(RTLdrLoad);
    101101
    102102
    103 RTDECL(int) RTLdrLoadEx(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, char *pszError, size_t cbError)
    104 {
    105     LogFlow(("RTLdrLoadEx: pszFilename=%p:{%s} phLdrMod=%p fFlags=%08x pszError=%p cbError=%zu\n", pszFilename, pszFilename, phLdrMod, fFlags, pszError, cbError));
     103RTDECL(int) RTLdrLoadEx(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, PRTERRINFO pErrInfo)
     104{
     105    LogFlow(("RTLdrLoadEx: pszFilename=%p:{%s} phLdrMod=%p fFlags=%#x pErrInfo=%p\n", pszFilename, pszFilename, phLdrMod, fFlags, pErrInfo));
    106106
    107107    /*
    108108     * Validate and massage the input.
    109109     */
    110     if (!pszError)
    111         AssertReturn(!cbError, VERR_INVALID_PARAMETER);
    112     else
    113     {
    114         AssertPtrReturn(pszError, VERR_INVALID_POINTER);
    115         if (cbError)
    116             *pszError = '\0';
    117         else
    118             pszError = NULL;
    119     }
     110    RTErrInfoClear(pErrInfo);
    120111    AssertPtrReturn(pszFilename, VERR_INVALID_POINTER);
    121112    AssertPtrReturn(phLdrMod, VERR_INVALID_POINTER);
     
    136127         * Attempt to open the module.
    137128         */
    138         rc = rtldrNativeLoad(pszFilename, &pMod->hNative, fFlags, pszError, cbError);
     129        rc = rtldrNativeLoad(pszFilename, &pMod->hNative, fFlags, pErrInfo);
    139130        if (RT_SUCCESS(rc))
    140131        {
     
    146137        RTMemFree(pMod);
    147138    }
    148     else if (cbError)
    149         RTStrPrintf(pszError, cbError, "Failed to allocate %zu bytes for the module handle", sizeof(*pMod));
     139    else
     140        RTErrInfoSetF(pErrInfo, rc, "Failed to allocate %zu bytes for the module handle", sizeof(*pMod));
    150141    *phLdrMod = NIL_RTLDRMOD;
    151142    LogFlow(("RTLdrLoad: returns %Rrc\n", rc));
  • trunk/src/VBox/Runtime/include/internal/ldr.h

    r35152 r35183  
    366366 * @param   phHandle        Where to store the module handle on success.
    367367 * @param   fFlags          See RTLDRFLAGS_.
    368  * @param   pszError        Where to store the error message. Optional.
    369  * @param   cbError         The size of the error message buffer.
    370  */
    371 int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, char *pszError, size_t cbError);
     368 * @param   pErrInfo        Where to return extended error information. Optional.
     369 */
     370int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, PRTERRINFO pErrInfo);
    372371
    373372int rtldrPEOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, RTFOFF offNtHdrs, PRTLDRMOD phLdrMod);
  • trunk/src/VBox/Runtime/r3/posix/ldrNative-posix.cpp

    r35152 r35183  
    4141
    4242
    43 int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, char *pszError, size_t cbError)
     43int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, PRTERRINFO pErrInfo)
    4444{
    4545    /*
     
    6060        char *psz = (char *)alloca(cch + sizeof(s_szSuff));
    6161        if (!psz)
    62             return VERR_NO_MEMORY;
     62            return RTErrInfoSet(pErrInfo, VERR_NO_MEMORY, "alloca failed");
    6363        memcpy(psz, pszFilename, cch);
    6464        memcpy(psz + cch, s_szSuff, sizeof(s_szSuff));
     
    8282
    8383    const char *pszDlError = dlerror();
    84     if (pszError)
    85         RTStrCopy(pszError, cbError, pszDlError);
     84    RTErrInfoSet(pErrInfo, VERR_FILE_NOT_FOUND, pszDlError);
    8685    LogRel(("rtldrNativeLoad: dlopen('%s', RTLD_NOW | RTLD_LOCAL) failed: %s\n", pszFilename, pszDlError));
    8786    return VERR_FILE_NOT_FOUND;
  • trunk/src/VBox/Runtime/r3/win/ldrNative-win.cpp

    r35152 r35183  
    4040
    4141
    42 int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, char *pszError, size_t cbError)
     42int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, PRTERRINFO pErrInfo)
    4343{
    4444    Assert(sizeof(*phHandle) >= sizeof(HMODULE));
     
    5353        char *psz = (char *)alloca(cch + sizeof(".DLL"));
    5454        if (!psz)
    55             return VERR_NO_MEMORY;
     55            return RTErrInfoSet(pErrInfo, VERR_NO_MEMORY, "alloca failed");
    5656        memcpy(psz, pszFilename, cch);
    5757        memcpy(psz + cch, ".DLL", sizeof(".DLL"));
     
    7474    DWORD dwErr = GetLastError();
    7575    int   rc    = RTErrConvertFromWin32(dwErr);
    76     if (cbError)
    77         RTStrPrintf(pszError, cbError, "GetLastError=%u", dwErr);
    78     return rc;
     76    return RTErrInfoSetF(pErrInfo, rc, "GetLastError=%u", dwErr);
    7977}
    8078
Note: See TracChangeset for help on using the changeset viewer.

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