Index: /trunk/include/iprt/ldr.h
===================================================================
--- /trunk/include/iprt/ldr.h	(revision 35182)
+++ /trunk/include/iprt/ldr.h	(revision 35183)
@@ -98,8 +98,7 @@
  * @param   phLdrMod    Where to store the handle to the loader module.
  * @param   fFlags      See RTLDFLAGS_.
- * @param   pszError    Where to store an error message on failure. Optional.
- * @param   cbError     The size of the buffer pointed to by @a pszError.
- */
-RTDECL(int) RTLdrLoadEx(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, char *pszError, size_t cbError);
+ * @param   pErrInfo    Where to return extended error information. Optional.
+ */
+RTDECL(int) RTLdrLoadEx(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, PRTERRINFO pErrInfo);
 
 /**
Index: /trunk/src/VBox/HostDrivers/Support/SUPLib.cpp
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/SUPLib.cpp	(revision 35182)
+++ /trunk/src/VBox/HostDrivers/Support/SUPLib.cpp	(revision 35183)
@@ -2104,5 +2104,11 @@
      * Try load it.
      */
-    return RTLdrLoadEx(pszFilename, phLdrMod, fFlags, pszError, cbError);
+    RTERRINFO  ErrInfo;
+    PRTERRINFO pErrInfo;
+    if (!pszError || !cbError)
+        pErrInfo = NULL;
+    else
+        pErrInfo = RTErrInfoInit(&ErrInfo, pszError, cbError);
+    return RTLdrLoadEx(pszFilename, phLdrMod, fFlags, pErrInfo);
 }
 
@@ -2245,5 +2251,11 @@
      * Try load it.
      */
-    return RTLdrLoadEx(pszFilename, phLdrMod, 0 /*=fFlags*/, pszErr, cbErr);
+    RTERRINFO  ErrInfo;
+    PRTERRINFO pErrInfo;
+    if (!pszErr || !cbErr)
+        pErrInfo = NULL;
+    else
+        pErrInfo = RTErrInfoInit(&ErrInfo, pszErr, cbErr);
+    return RTLdrLoadEx(pszFilename, phLdrMod, 0 /*fFlags*/, pErrInfo);
 }
 
Index: /trunk/src/VBox/Runtime/common/ldr/ldrNative.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/ldr/ldrNative.cpp	(revision 35182)
+++ /trunk/src/VBox/Runtime/common/ldr/ldrNative.cpp	(revision 35183)
@@ -96,26 +96,17 @@
 RTDECL(int) RTLdrLoad(const char *pszFilename, PRTLDRMOD phLdrMod)
 {
-    return RTLdrLoadEx(pszFilename, phLdrMod, 0 /*=fFlags*/, NULL, 0);
+    return RTLdrLoadEx(pszFilename, phLdrMod, 0 /*fFlags*/, NULL);
 }
 RT_EXPORT_SYMBOL(RTLdrLoad);
 
 
-RTDECL(int) RTLdrLoadEx(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, char *pszError, size_t cbError)
-{
-    LogFlow(("RTLdrLoadEx: pszFilename=%p:{%s} phLdrMod=%p fFlags=%08x pszError=%p cbError=%zu\n", pszFilename, pszFilename, phLdrMod, fFlags, pszError, cbError));
+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.
      */
-    if (!pszError)
-        AssertReturn(!cbError, VERR_INVALID_PARAMETER);
-    else
-    {
-        AssertPtrReturn(pszError, VERR_INVALID_POINTER);
-        if (cbError)
-            *pszError = '\0';
-        else
-            pszError = NULL;
-    }
+    RTErrInfoClear(pErrInfo);
     AssertPtrReturn(pszFilename, VERR_INVALID_POINTER);
     AssertPtrReturn(phLdrMod, VERR_INVALID_POINTER);
@@ -136,5 +127,5 @@
          * Attempt to open the module.
          */
-        rc = rtldrNativeLoad(pszFilename, &pMod->hNative, fFlags, pszError, cbError);
+        rc = rtldrNativeLoad(pszFilename, &pMod->hNative, fFlags, pErrInfo);
         if (RT_SUCCESS(rc))
         {
@@ -146,6 +137,6 @@
         RTMemFree(pMod);
     }
-    else if (cbError)
-        RTStrPrintf(pszError, cbError, "Failed to allocate %zu bytes for the module handle", sizeof(*pMod));
+    else
+        RTErrInfoSetF(pErrInfo, rc, "Failed to allocate %zu bytes for the module handle", sizeof(*pMod));
     *phLdrMod = NIL_RTLDRMOD;
     LogFlow(("RTLdrLoad: returns %Rrc\n", rc));
Index: /trunk/src/VBox/Runtime/include/internal/ldr.h
===================================================================
--- /trunk/src/VBox/Runtime/include/internal/ldr.h	(revision 35182)
+++ /trunk/src/VBox/Runtime/include/internal/ldr.h	(revision 35183)
@@ -366,8 +366,7 @@
  * @param   phHandle        Where to store the module handle on success.
  * @param   fFlags          See RTLDRFLAGS_.
- * @param   pszError        Where to store the error message. Optional.
- * @param   cbError         The size of the error message buffer.
- */
-int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, char *pszError, size_t cbError);
+ * @param   pErrInfo        Where to return extended error information. Optional.
+ */
+int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, PRTERRINFO pErrInfo);
 
 int rtldrPEOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, RTFOFF offNtHdrs, PRTLDRMOD phLdrMod);
Index: /trunk/src/VBox/Runtime/r3/posix/ldrNative-posix.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/posix/ldrNative-posix.cpp	(revision 35182)
+++ /trunk/src/VBox/Runtime/r3/posix/ldrNative-posix.cpp	(revision 35183)
@@ -41,5 +41,5 @@
 
 
-int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, char *pszError, size_t cbError)
+int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, PRTERRINFO pErrInfo)
 {
     /*
@@ -60,5 +60,5 @@
         char *psz = (char *)alloca(cch + sizeof(s_szSuff));
         if (!psz)
-            return VERR_NO_MEMORY;
+            return RTErrInfoSet(pErrInfo, VERR_NO_MEMORY, "alloca failed");
         memcpy(psz, pszFilename, cch);
         memcpy(psz + cch, s_szSuff, sizeof(s_szSuff));
@@ -82,6 +82,5 @@
 
     const char *pszDlError = dlerror();
-    if (pszError)
-        RTStrCopy(pszError, cbError, pszDlError);
+    RTErrInfoSet(pErrInfo, VERR_FILE_NOT_FOUND, pszDlError);
     LogRel(("rtldrNativeLoad: dlopen('%s', RTLD_NOW | RTLD_LOCAL) failed: %s\n", pszFilename, pszDlError));
     return VERR_FILE_NOT_FOUND;
Index: /trunk/src/VBox/Runtime/r3/win/ldrNative-win.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/win/ldrNative-win.cpp	(revision 35182)
+++ /trunk/src/VBox/Runtime/r3/win/ldrNative-win.cpp	(revision 35183)
@@ -40,5 +40,5 @@
 
 
-int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, char *pszError, size_t cbError)
+int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, PRTERRINFO pErrInfo)
 {
     Assert(sizeof(*phHandle) >= sizeof(HMODULE));
@@ -53,5 +53,5 @@
         char *psz = (char *)alloca(cch + sizeof(".DLL"));
         if (!psz)
-            return VERR_NO_MEMORY;
+            return RTErrInfoSet(pErrInfo, VERR_NO_MEMORY, "alloca failed");
         memcpy(psz, pszFilename, cch);
         memcpy(psz + cch, ".DLL", sizeof(".DLL"));
@@ -74,7 +74,5 @@
     DWORD dwErr = GetLastError();
     int   rc    = RTErrConvertFromWin32(dwErr);
-    if (cbError)
-        RTStrPrintf(pszError, cbError, "GetLastError=%u", dwErr);
-    return rc;
+    return RTErrInfoSetF(pErrInfo, rc, "GetLastError=%u", dwErr);
 }
 
