Changeset 35183 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Dec 16, 2010 1:59:44 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 69022
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/ldr/ldrNative.cpp
r35152 r35183 96 96 RTDECL(int) RTLdrLoad(const char *pszFilename, PRTLDRMOD phLdrMod) 97 97 { 98 return RTLdrLoadEx(pszFilename, phLdrMod, 0 /* =fFlags*/, NULL, 0);98 return RTLdrLoadEx(pszFilename, phLdrMod, 0 /*fFlags*/, NULL); 99 99 } 100 100 RT_EXPORT_SYMBOL(RTLdrLoad); 101 101 102 102 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));103 RTDECL(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)); 106 106 107 107 /* 108 108 * Validate and massage the input. 109 109 */ 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); 120 111 AssertPtrReturn(pszFilename, VERR_INVALID_POINTER); 121 112 AssertPtrReturn(phLdrMod, VERR_INVALID_POINTER); … … 136 127 * Attempt to open the module. 137 128 */ 138 rc = rtldrNativeLoad(pszFilename, &pMod->hNative, fFlags, p szError, cbError);129 rc = rtldrNativeLoad(pszFilename, &pMod->hNative, fFlags, pErrInfo); 139 130 if (RT_SUCCESS(rc)) 140 131 { … … 146 137 RTMemFree(pMod); 147 138 } 148 else if (cbError)149 RT StrPrintf(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)); 150 141 *phLdrMod = NIL_RTLDRMOD; 151 142 LogFlow(("RTLdrLoad: returns %Rrc\n", rc)); -
trunk/src/VBox/Runtime/include/internal/ldr.h
r35152 r35183 366 366 * @param phHandle Where to store the module handle on success. 367 367 * @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 */ 370 int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, PRTERRINFO pErrInfo); 372 371 373 372 int rtldrPEOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, RTFOFF offNtHdrs, PRTLDRMOD phLdrMod); -
trunk/src/VBox/Runtime/r3/posix/ldrNative-posix.cpp
r35152 r35183 41 41 42 42 43 int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, char *pszError, size_t cbError)43 int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, PRTERRINFO pErrInfo) 44 44 { 45 45 /* … … 60 60 char *psz = (char *)alloca(cch + sizeof(s_szSuff)); 61 61 if (!psz) 62 return VERR_NO_MEMORY;62 return RTErrInfoSet(pErrInfo, VERR_NO_MEMORY, "alloca failed"); 63 63 memcpy(psz, pszFilename, cch); 64 64 memcpy(psz + cch, s_szSuff, sizeof(s_szSuff)); … … 82 82 83 83 const char *pszDlError = dlerror(); 84 if (pszError) 85 RTStrCopy(pszError, cbError, pszDlError); 84 RTErrInfoSet(pErrInfo, VERR_FILE_NOT_FOUND, pszDlError); 86 85 LogRel(("rtldrNativeLoad: dlopen('%s', RTLD_NOW | RTLD_LOCAL) failed: %s\n", pszFilename, pszDlError)); 87 86 return VERR_FILE_NOT_FOUND; -
trunk/src/VBox/Runtime/r3/win/ldrNative-win.cpp
r35152 r35183 40 40 41 41 42 int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, char *pszError, size_t cbError)42 int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, PRTERRINFO pErrInfo) 43 43 { 44 44 Assert(sizeof(*phHandle) >= sizeof(HMODULE)); … … 53 53 char *psz = (char *)alloca(cch + sizeof(".DLL")); 54 54 if (!psz) 55 return VERR_NO_MEMORY;55 return RTErrInfoSet(pErrInfo, VERR_NO_MEMORY, "alloca failed"); 56 56 memcpy(psz, pszFilename, cch); 57 57 memcpy(psz + cch, ".DLL", sizeof(".DLL")); … … 74 74 DWORD dwErr = GetLastError(); 75 75 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); 79 77 } 80 78
Note:
See TracChangeset
for help on using the changeset viewer.