Index: /trunk/include/iprt/ldr.h
===================================================================
--- /trunk/include/iprt/ldr.h	(revision 65238)
+++ /trunk/include/iprt/ldr.h	(revision 65239)
@@ -376,5 +376,5 @@
 
 /**
- * Open a binary image file, extended version.
+ * Open a binary image file.
  *
  * @returns iprt status code.
@@ -385,4 +385,16 @@
  */
 RTDECL(int) RTLdrOpen(const char *pszFilename, uint32_t fFlags, RTLDRARCH enmArch, PRTLDRMOD phLdrMod);
+
+/**
+ * Open a binary image file, extended version.
+ *
+ * @returns iprt status code.
+ * @param   pszFilename Image filename.
+ * @param   fFlags      Valid RTLDR_O_XXX combination.
+ * @param   enmArch     CPU architecture specifier for the image to be loaded.
+ * @param   phLdrMod    Where to store the handle to the loader module.
+ * @param   pErrInfo    Where to return extended error information. Optional.
+ */
+RTDECL(int) RTLdrOpenEx(const char *pszFilename, uint32_t fFlags, RTLDRARCH enmArch, PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo);
 
 /**
Index: /trunk/include/iprt/mangling.h
===================================================================
--- /trunk/include/iprt/mangling.h	(revision 65238)
+++ /trunk/include/iprt/mangling.h	(revision 65239)
@@ -1005,4 +1005,5 @@
 # define RTLdrLoadSystem                                RT_MANGLER(RTLdrLoadSystem)
 # define RTLdrOpen                                      RT_MANGLER(RTLdrOpen)
+# define RTLdrOpenEx                                    RT_MANGLER(RTLdrOpenEx)
 # define RTLdrOpenInMemory                              RT_MANGLER(RTLdrOpenInMemory)
 # define RTLdrOpenkLdr                                  RT_MANGLER(RTLdrOpenkLdr)
Index: /trunk/src/VBox/Runtime/common/ldr/ldrFile.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/ldr/ldrFile.cpp	(revision 65238)
+++ /trunk/src/VBox/Runtime/common/ldr/ldrFile.cpp	(revision 65239)
@@ -243,9 +243,9 @@
 
 /**
- * Open a binary image file, extended version.
+ * Open a binary image file.
  *
  * @returns iprt status code.
  * @param   pszFilename Image filename.
- * @param   fFlags      Reserved, MBZ.
+ * @param   fFlags      Valid RTLDR_O_XXX combination.
  * @param   enmArch     CPU architecture specifier for the image to be loaded.
  * @param   phLdrMod    Where to store the handle to the loader module.
@@ -253,5 +253,22 @@
 RTDECL(int) RTLdrOpen(const char *pszFilename, uint32_t fFlags, RTLDRARCH enmArch, PRTLDRMOD phLdrMod)
 {
-    LogFlow(("RTLdrOpen: pszFilename=%p:{%s} fFlags=%#x enmArch=%d phLdrMod=%p\n",
+    return RTLdrOpenEx(pszFilename, fFlags, enmArch, phLdrMod, NULL /*pErrInfo*/);
+}
+RT_EXPORT_SYMBOL(RTLdrOpen);
+
+
+/**
+ * Open a binary image file, extended version.
+ *
+ * @returns iprt status code.
+ * @param   pszFilename Image filename.
+ * @param   fFlags      Valid RTLDR_O_XXX combination.
+ * @param   enmArch     CPU architecture specifier for the image to be loaded.
+ * @param   phLdrMod    Where to store the handle to the loader module.
+ * @param   pErrInfo    Where to return extended error information. Optional.
+ */
+RTDECL(int) RTLdrOpenEx(const char *pszFilename, uint32_t fFlags, RTLDRARCH enmArch, PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo)
+{
+    LogFlow(("RTLdrOpenEx: pszFilename=%p:{%s} fFlags=%#x enmArch=%d phLdrMod=%p\n",
              pszFilename, pszFilename, fFlags, enmArch, phLdrMod));
     AssertMsgReturn(!(fFlags & ~RTLDR_O_VALID_MASK), ("%#x\n", fFlags), VERR_INVALID_PARAMETER);
@@ -265,8 +282,8 @@
     if (RT_SUCCESS(rc))
     {
-        rc = RTLdrOpenWithReader(pReader, fFlags, enmArch, phLdrMod, NULL);
+        rc = RTLdrOpenWithReader(pReader, fFlags, enmArch, phLdrMod, pErrInfo);
         if (RT_SUCCESS(rc))
         {
-            LogFlow(("RTLdrOpen: return %Rrc *phLdrMod=%p\n", rc, *phLdrMod));
+            LogFlow(("RTLdrOpenEx: return %Rrc *phLdrMod=%p\n", rc, *phLdrMod));
             return rc;
         }
@@ -274,8 +291,8 @@
     }
     *phLdrMod = NIL_RTLDRMOD;
-    LogFlow(("RTLdrOpen: return %Rrc\n", rc));
-    return rc;
-}
-RT_EXPORT_SYMBOL(RTLdrOpen);
+    LogFlow(("RTLdrOpenEx: return %Rrc\n", rc));
+    return rc;
+}
+RT_EXPORT_SYMBOL(RTLdrOpenEx);
 
 
Index: /trunk/src/VBox/Runtime/testcase/tstLdr-2.cpp
===================================================================
--- /trunk/src/VBox/Runtime/testcase/tstLdr-2.cpp	(revision 65238)
+++ /trunk/src/VBox/Runtime/testcase/tstLdr-2.cpp	(revision 65239)
@@ -94,9 +94,12 @@
 static int testLdrOne(const char *pszFilename)
 {
+    RTERRINFOSTATIC ErrInfo;
     RTLDRMOD hLdrMod;
-    int rc = RTLdrOpen(pszFilename, 0, RTLDRARCH_WHATEVER, &hLdrMod);
+    int rc = RTLdrOpenEx(pszFilename, 0, RTLDRARCH_WHATEVER, &hLdrMod, RTErrInfoInitStatic(&ErrInfo));
     if (RT_FAILURE(rc))
     {
         RTPrintf("tstLdr: Failed to open '%s', rc=%Rrc. aborting test.\n", pszFilename, rc);
+        if (ErrInfo.szMsg[0])
+            RTPrintf("tstLdr: %s\n", ErrInfo.szMsg);
         Assert(hLdrMod == NIL_RTLDRMOD);
         return 1;
Index: /trunk/src/VBox/Runtime/testcase/tstLdr-3.cpp
===================================================================
--- /trunk/src/VBox/Runtime/testcase/tstLdr-3.cpp	(revision 65238)
+++ /trunk/src/VBox/Runtime/testcase/tstLdr-3.cpp	(revision 65239)
@@ -302,9 +302,12 @@
      * Load the module.
      */
+    RTERRINFOSTATIC ErrInfo;
     g_uLoadAddr = (RTUINTPTR)RTStrToUInt64(argv[1]);
-    int rc = RTLdrOpen(argv[2], 0, RTLDRARCH_WHATEVER, &g_hLdrMod);
+    int rc = RTLdrOpenEx(argv[2], 0, RTLDRARCH_WHATEVER, &g_hLdrMod, RTErrInfoInitStatic(&ErrInfo));
     if (RT_FAILURE(rc))
     {
         RTPrintf("tstLdr-3: Failed to open '%s': %Rra\n", argv[2], rc);
+        if (ErrInfo.szMsg[0])
+            RTPrintf("tstLdr-3: %s\n", ErrInfo.szMsg);
         return 1;
     }
