Index: /trunk/include/VBox/sup.h
===================================================================
--- /trunk/include/VBox/sup.h	(revision 35187)
+++ /trunk/include/VBox/sup.h	(revision 35188)
@@ -894,9 +894,8 @@
  * @param   pszModule       The module name. Max 32 bytes.
  * @param   ppvImageBase    Where to store the image address.
- * @param   pszErr          Where to return error message on failure.
- * @param   cbErr           The size of the error buffer.
- */
-SUPR3DECL(int) SUPR3LoadModule(const char *pszFilename, const char *pszModule,
-                               void **ppvImageBase, char *pszErr, size_t cbErr);
+ * @param   pErrInfo        Where to return extended error information.
+ *                          Optional.
+ */
+SUPR3DECL(int) SUPR3LoadModule(const char *pszFilename, const char *pszModule, void **ppvImageBase, PRTERRINFO pErrInfo);
 
 /**
@@ -990,8 +989,7 @@
  * @param   fInternal       Set this to @c true if this is an internal
  *                          VirtualBox application.  Otherwise pass @c false.
- * @param   pszErr          Where to return error message on failure.
- * @param   cbErr           The size of the error buffer.
- */
-SUPR3DECL(int) SUPR3HardenedVerifySelf(const char *pszArgv0, bool fInternal, char *pszErr, size_t cbErr);
+ * @param   pErrInfo        Where to return extended error information.
+ */
+SUPR3DECL(int) SUPR3HardenedVerifySelf(const char *pszArgv0, bool fInternal, PRTERRINFO pErrInfo);
 
 /**
@@ -1010,8 +1008,8 @@
  * @param   fCheckFiles     Whether to apply the same basic integrity check to
  *                          the files in the directory as the directory itself.
- * @param   pszErr          Where to return error message on failure.
- * @param   cbErr           The size of the error buffer.
- */
-SUPR3DECL(int) SUPR3HardenedVerifyDir(const char *pszDirPath, bool fRecursive, bool fCheckFiles, char *pszErr, size_t cbErr);
+ * @param   pErrInfo        Where to return extended error information.
+ *                          Optional.
+ */
+SUPR3DECL(int) SUPR3HardenedVerifyDir(const char *pszDirPath, bool fRecursive, bool fCheckFiles, PRTERRINFO pErrInfo);
 
 /**
@@ -1025,8 +1023,8 @@
  * @param   pszFilename     The filename of the plug-in module (nothing can be
  *                          omitted here).
- * @param   pszErr          Where to return error message on failure.
- * @param   cbErr           The size of the error buffer.
- */
-SUPR3DECL(int) SUPR3HardenedVerifyPlugIn(const char *pszFilename, char *pszErr, size_t cbErr);
+ * @param   pErrInfo        Where to return extended error information.
+ *                          Optional.
+ */
+SUPR3DECL(int) SUPR3HardenedVerifyPlugIn(const char *pszFilename, PRTERRINFO pErrInfo);
 
 /**
@@ -1039,8 +1037,8 @@
  * @param   phLdrMod        Where to store the handle to the loaded module.
  * @param   fFlags          See RTLDRFLAGS_.
- * @param   pszError        Where to return error message on failure.
- * @param   cbError         The size of the error buffer.
- */
-SUPR3DECL(int) SUPR3HardenedLdrLoad(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, char *pszError, size_t cbError);
+ * @param   pErrInfo        Where to return extended error information.
+ *                          Optional.
+ */
+SUPR3DECL(int) SUPR3HardenedLdrLoad(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, PRTERRINFO pErrInfo);
 
 /**
@@ -1055,8 +1053,8 @@
  * @param   phLdrMod        Where to store the handle to the loaded module.
  * @param   fFlags          See RTLDRFLAGS_*.
- * @param   pszError        Where to return error message on failure.
- * @param   cbError         The size of the error buffer.
- */
-SUPR3DECL(int) SUPR3HardenedLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, char *pszError, size_t cbError);
+ * @param   pErrInfo        Where to return extended error information.
+ *                          Optional.
+ */
+SUPR3DECL(int) SUPR3HardenedLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, PRTERRINFO pErrInfo);
 
 /**
@@ -1070,8 +1068,8 @@
  * @param   pszFilename     The full path to the module, with extension.
  * @param   phLdrMod        Where to store the handle to the loaded module.
- * @param   pszErr          Where to return error message on failure.
- * @param   cbErr           The size of the error buffer.
- */
-SUPR3DECL(int) SUPR3HardenedLdrLoadPlugIn(const char *pszFilename, PRTLDRMOD phLdrMod, char *pszErr, size_t cbErr);
+ * @param   pErrInfo        Where to return extended error information.
+ *                          Optional.
+ */
+SUPR3DECL(int) SUPR3HardenedLdrLoadPlugIn(const char *pszFilename, PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo);
 
 /**
Index: /trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp	(revision 35187)
+++ /trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp	(revision 35188)
@@ -835,10 +835,11 @@
         if (fFFMPEG)
         {
-            HRESULT rcc = S_OK;
-            int     rrc = VINF_SUCCESS;
-            char    szErr[8192];
+            HRESULT         rcc = S_OK;
+            int             rrc = VINF_SUCCESS;
+            RTERRINFOSTATIC ErrInfo;
 
             Log2(("VBoxHeadless: loading VBoxFFmpegFB shared library\n"));
-            rrc = SUPR3HardenedLdrLoadAppPriv("VBoxFFmpegFB", &hLdrFFmpegFB, 0 /*=fFlags*/, szErr, sizeof(szErr));
+            RTErrInfoInitStatic(&ErrInfo);
+            rrc = SUPR3HardenedLdrLoadAppPriv("VBoxFFmpegFB", &hLdrFFmpegFB, 0 /*fFlags*/, &ErrInfo.Core);
 
             if (RT_SUCCESS(rrc))
@@ -861,5 +862,5 @@
                              "you wish to use is supported on your system\n", rcc);
             }
-            if (RT_SUCCESS(rrc) && (rcc == S_OK))
+            if (RT_SUCCESS(rrc) && rcc == S_OK)
             {
                 Log2(("VBoxHeadless: Registering framebuffer\n"));
@@ -867,5 +868,5 @@
                 display->SetFramebuffer(VBOX_VIDEO_PRIMARY_SCREEN, pFramebuffer);
             }
-            if (!RT_SUCCESS(rrc) || (rcc != S_OK))
+            if (!RT_SUCCESS(rrc) || rcc != S_OK)
                 rc = E_FAIL;
         }
Index: /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp	(revision 35187)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp	(revision 35188)
@@ -5113,12 +5113,12 @@
     if (mDbgEnabled)
     {
-        char szErr[8192];
-        szErr[0] = '\0';
-        int vrc = SUPR3HardenedLdrLoadAppPriv("VBoxDbg", &mhVBoxDbg, 0 /*=fFlags*/, szErr, sizeof(szErr));
+        RTERRINFOSTATIC ErrInfo;
+        RTErrInfoInitStatic(&ErrInfo);
+        int vrc = SUPR3HardenedLdrLoadAppPriv("VBoxDbg", &mhVBoxDbg, 0 /*fFlags*/, &ErrInfo.Core);
         if (RT_FAILURE(vrc))
         {
             mhVBoxDbg = NIL_RTLDRMOD;
             mDbgAutoShow =  mDbgAutoShowCommandLine = mDbgAutoShowStatistics = false;
-            LogRel(("Failed to load VBoxDbg, rc=%Rrc - %s\n", vrc, szErr));
+            LogRel(("Failed to load VBoxDbg, rc=%Rrc - %s\n", vrc, ErrInfo.Core.pszMsg));
         }
     }
Index: /trunk/src/VBox/HostDrivers/Support/SUPLib.cpp
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/SUPLib.cpp	(revision 35187)
+++ /trunk/src/VBox/HostDrivers/Support/SUPLib.cpp	(revision 35188)
@@ -1438,5 +1438,5 @@
 
 
-SUPR3DECL(int) SUPR3HardenedVerifySelf(const char *pszArgv0, bool fInternal, char *pszErr, size_t cbErr)
+SUPR3DECL(int) SUPR3HardenedVerifySelf(const char *pszArgv0, bool fInternal, PRTERRINFO pErrInfo)
 {
     /*
@@ -1444,6 +1444,5 @@
      */
     AssertPtr(pszArgv0);
-    AssertPtr(pszErr);
-    Assert(cbErr > 32);
+    RTErrInfoClear(pErrInfo);
 
     /*
@@ -1452,8 +1451,5 @@
     char szExecPath[RTPATH_MAX];
     if (!RTProcGetExecutablePath(szExecPath, sizeof(szExecPath)))
-    {
-        RTStrPrintf(pszErr, cbErr, "RTProcGetExecutablePath failed");
-        return VERR_INTERNAL_ERROR_2;
-    }
+        return RTErrInfoSet(pErrInfo, VERR_INTERNAL_ERROR_2, "RTProcGetExecutablePath failed");
 
     int rc;
@@ -1465,8 +1461,6 @@
          */
         if (RTPathCompare(pszArgv0, szExecPath) != 0)
-        {
-            RTStrPrintf(pszErr, cbErr, "argv[0] does not match the executable image path: '%s' != '%s'", pszArgv0, szExecPath);
-            return VERR_SUPLIB_INVALID_ARGV0_INTERNAL;
-        }
+            return RTErrInfoSetF(pErrInfo, VERR_SUPLIB_INVALID_ARGV0_INTERNAL,
+                                 "argv[0] does not match the executable image path: '%s' != '%s'", pszArgv0, szExecPath);
 
         /*
@@ -1477,21 +1471,15 @@
         rc = RTPathAppPrivateArch(szAppPrivateArch, sizeof(szAppPrivateArch));
         if (RT_FAILURE(rc))
-        {
-            RTStrPrintf(pszErr, cbErr, "RTPathAppPrivateArch failed with rc=%Rrc", rc);
-            return VERR_SUPLIB_INVALID_ARGV0_INTERNAL;
-        }
+            return RTErrInfoSetF(pErrInfo, VERR_SUPLIB_INVALID_ARGV0_INTERNAL,
+                                 "RTPathAppPrivateArch failed with rc=%Rrc", rc);
         size_t cchAppPrivateArch = strlen(szAppPrivateArch);
         if (   cchAppPrivateArch >= strlen(szExecPath)
             || !RTPATH_IS_SLASH(szExecPath[cchAppPrivateArch]))
-        {
-            RTStrPrintf(pszErr, cbErr, "Internal executable does reside under RTPathAppPrivateArch");
-            return VERR_SUPLIB_INVALID_INTERNAL_APP_DIR;
-        }
+            return RTErrInfoSet(pErrInfo, VERR_SUPLIB_INVALID_INTERNAL_APP_DIR,
+                                "Internal executable does reside under RTPathAppPrivateArch");
         szExecPath[cchAppPrivateArch] = '\0';
         if (RTPathCompare(szExecPath, szAppPrivateArch) != 0)
-        {
-            RTStrPrintf(pszErr, cbErr, "Internal executable does reside under RTPathAppPrivateArch");
-            return VERR_SUPLIB_INVALID_INTERNAL_APP_DIR;
-        }
+            return RTErrInfoSet(pErrInfo, VERR_SUPLIB_INVALID_INTERNAL_APP_DIR,
+                                "Internal executable does reside under RTPathAppPrivateArch");
         szExecPath[cchAppPrivateArch] = RTPATH_SLASH;
     }
@@ -1501,5 +1489,5 @@
      * Verify that the image file and parent directories are sane.
      */
-    rc = supR3HardenedVerifyFile(szExecPath, RTHCUINTPTR_MAX, pszErr, cbErr);
+    rc = supR3HardenedVerifyFile(szExecPath, RTHCUINTPTR_MAX, pErrInfo);
     if (RT_FAILURE(rc))
         return rc;
@@ -1510,5 +1498,5 @@
 
 
-SUPR3DECL(int) SUPR3HardenedVerifyDir(const char *pszDirPath, bool fRecursive, bool fCheckFiles, char *pszErr, size_t cbErr)
+SUPR3DECL(int) SUPR3HardenedVerifyDir(const char *pszDirPath, bool fRecursive, bool fCheckFiles, PRTERRINFO pErrInfo)
 {
     /*
@@ -1516,6 +1504,5 @@
      */
     AssertPtr(pszDirPath);
-    AssertPtr(pszErr);
-    Assert(cbErr > 32);
+    RTErrInfoClear(pErrInfo);
 
     /*
@@ -1523,6 +1510,6 @@
      */
 #ifdef VBOX_WITH_HARDENING
-    int rc = supR3HardenedVerifyDir(pszDirPath, fRecursive, fCheckFiles, pszErr, cbErr);
-    if (RT_FAILURE(rc) && (!pszErr || !cbErr))
+    int rc = supR3HardenedVerifyDir(pszDirPath, fRecursive, fCheckFiles, pErrInfo);
+    if (RT_FAILURE(rc) && !RTErrInfoIsSet(pErrInfo))
         LogRel(("supR3HardenedVerifyDir: Verification of \"%s\" failed, rc=%Rrc\n", pszDirPath, rc));
     return rc;
@@ -1533,5 +1520,5 @@
 
 
-SUPR3DECL(int) SUPR3HardenedVerifyPlugIn(const char *pszFilename, char *pszErr, size_t cbErr)
+SUPR3DECL(int) SUPR3HardenedVerifyPlugIn(const char *pszFilename, PRTERRINFO pErrInfo)
 {
     /*
@@ -1539,6 +1526,5 @@
      */
     AssertPtr(pszFilename);
-    AssertPtr(pszErr);
-    Assert(cbErr > 32);
+    RTErrInfoClear(pErrInfo);
 
     /*
@@ -1546,6 +1532,6 @@
      */
 #ifdef VBOX_WITH_HARDENING
-    int rc = supR3HardenedVerifyFile(pszFilename, RTHCUINTPTR_MAX,  pszErr, cbErr);
-    if (RT_FAILURE(rc) && (!pszErr || !cbErr))
+    int rc = supR3HardenedVerifyFile(pszFilename, RTHCUINTPTR_MAX, pErrInfo);
+    if (RT_FAILURE(rc) && !RTErrInfoIsSet(pErrInfo))
         LogRel(("supR3HardenedVerifyFile: Verification of \"%s\" failed, rc=%Rrc\n", pszFilename, rc));
     return rc;
@@ -1556,15 +1542,15 @@
 
 
-SUPR3DECL(int) SUPR3LoadModule(const char *pszFilename, const char *pszModule, void **ppvImageBase, char *pszErr, size_t cbErr)
+SUPR3DECL(int) SUPR3LoadModule(const char *pszFilename, const char *pszModule, void **ppvImageBase, PRTERRINFO pErrInfo)
 {
     /*
      * Check that the module can be trusted.
      */
-    int rc = SUPR3HardenedVerifyPlugIn(pszFilename, pszErr, cbErr);
+    int rc = SUPR3HardenedVerifyPlugIn(pszFilename, pErrInfo);
     if (RT_SUCCESS(rc))
     {
         rc = supLoadModule(pszFilename, pszModule, NULL, ppvImageBase);
         if (RT_FAILURE(rc))
-            RTStrPrintf(pszErr, cbErr, "supLoadModule returned %Rrc", rc);
+            RTErrInfoSetF(pErrInfo, rc, "supLoadModule returned %Rrc", rc);
     }
     return rc;
@@ -2055,5 +2041,5 @@
 {
     void *pvImageBase;
-    return SUPR3LoadModule(pszFilename, "VMMR0.r0", &pvImageBase, NULL, 0);
+    return SUPR3LoadModule(pszFilename, "VMMR0.r0", &pvImageBase, NULL /*pErrInfo*/);
 }
 
@@ -2084,8 +2070,9 @@
  * @param   phLdrMod        Where to store the handle to the loaded module.
  * @param   fFlags          See RTLDFLAGS_.
- * @param   pszError        Where to return the loader error. Optional.
- * @param   cbError         The size of the buffer pointed to by @a pszError.
+ * @param   pErrInfo        Where to return extended error information.
+ *                          Optional.
+ *
  */
-static int supR3HardenedLdrLoadIt(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, char *pszError, size_t cbError)
+static int supR3HardenedLdrLoadIt(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, PRTERRINFO pErrInfo)
 {
 #ifdef VBOX_WITH_HARDENING
@@ -2097,5 +2084,5 @@
     {
         LogRel(("supR3HardenedLdrLoadIt: Verification of \"%s\" failed, rc=%Rrc\n", pszFilename, rc));
-        return rc;
+        return RTErrInfoSet(pErrInfo, rc, "supR3HardenedVerifyFixedFile failed");
     }
 #endif
@@ -2104,29 +2091,14 @@
      * Try load it.
      */
-    RTERRINFO  ErrInfo;
-    PRTERRINFO pErrInfo;
-    if (!pszError || !cbError)
-        pErrInfo = NULL;
-    else
-        pErrInfo = RTErrInfoInit(&ErrInfo, pszError, cbError);
     return RTLdrLoadEx(pszFilename, phLdrMod, fFlags, pErrInfo);
 }
 
 
-SUPR3DECL(int) SUPR3HardenedLdrLoad(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, char *pszError, size_t cbError)
+SUPR3DECL(int) SUPR3HardenedLdrLoad(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, PRTERRINFO pErrInfo)
 {
     /*
      * Validate 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);
@@ -2152,25 +2124,16 @@
      * Pass it on to the common library loader.
      */
-    return supR3HardenedLdrLoadIt(pszFilename, phLdrMod, fFlags, pszError, cbError);
-}
-
-
-SUPR3DECL(int) SUPR3HardenedLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, char *pszError, size_t cbError)
-{
-    LogFlow(("SUPR3HardenedLdrLoadAppPriv: pszFilename=%p:{%s} phLdrMod=%p fFlags=%08x pszError=%p cbError=%zu\n", pszFilename, pszFilename, phLdrMod, fFlags, pszError, cbError));
+    return supR3HardenedLdrLoadIt(pszFilename, phLdrMod, fFlags, pErrInfo);
+}
+
+
+SUPR3DECL(int) SUPR3HardenedLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, PRTERRINFO pErrInfo)
+{
+    LogFlow(("SUPR3HardenedLdrLoadAppPriv: pszFilename=%p:{%s} phLdrMod=%p fFlags=%08x pErrInfo=%p\n", pszFilename, pszFilename, phLdrMod, fFlags, pErrInfo));
 
     /*
      * Validate input.
      */
-    if (!pszError)
-        AssertReturn(!cbError, VERR_INVALID_PARAMETER);
-    else
-    {
-        AssertPtrReturn(pszError, VERR_INVALID_POINTER);
-        if (cbError)
-            *pszError = '\0';
-        else
-            pszError = NULL;
-    }
+    RTErrInfoClear(pErrInfo);
     AssertPtrReturn(phLdrMod, VERR_INVALID_PARAMETER);
     *phLdrMod = NIL_RTLDRMOD;
@@ -2214,5 +2177,5 @@
      * Pass it on to SUPR3HardenedLdrLoad.
      */
-    rc = SUPR3HardenedLdrLoad(szPath, phLdrMod, fFlags, pszError, cbError);
+    rc = SUPR3HardenedLdrLoad(szPath, phLdrMod, fFlags, pErrInfo);
 
     LogFlow(("SUPR3HardenedLdrLoadAppPriv: returns %Rrc\n", rc));
@@ -2221,5 +2184,5 @@
 
 
-SUPR3DECL(int) SUPR3HardenedLdrLoadPlugIn(const char *pszFilename, PRTLDRMOD phLdrMod, char *pszErr, size_t cbErr)
+SUPR3DECL(int) SUPR3HardenedLdrLoadPlugIn(const char *pszFilename, PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo)
 {
     int rc;
@@ -2228,6 +2191,5 @@
      * Validate input.
      */
-    AssertPtr(pszErr);
-    Assert(cbErr > 32);
+    RTErrInfoClear(pErrInfo);
     AssertPtrReturn(phLdrMod, VERR_INVALID_PARAMETER);
     *phLdrMod = NIL_RTLDRMOD;
@@ -2239,8 +2201,8 @@
      * Verify the image file.
      */
-    rc = supR3HardenedVerifyFile(pszFilename, RTHCUINTPTR_MAX, pszErr, cbErr);
+    rc = supR3HardenedVerifyFile(pszFilename, RTHCUINTPTR_MAX, pErrInfo);
     if (RT_FAILURE(rc))
     {
-        if (!pszErr || !cbErr)
+        if (!RTErrInfoIsSet(pErrInfo))
             LogRel(("supR3HardenedVerifyFile: Verification of \"%s\" failed, rc=%Rrc\n", pszFilename, rc));
         return rc;
@@ -2251,10 +2213,4 @@
      * Try load it.
      */
-    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/HostDrivers/Support/SUPLibInternal.h
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/SUPLibInternal.h	(revision 35187)
+++ /trunk/src/VBox/HostDrivers/Support/SUPLibInternal.h	(revision 35188)
@@ -320,6 +320,6 @@
 DECLHIDDEN(int)     supR3HardenedVerifyFixedDir(SUPINSTDIR enmDir, bool fFatal);
 DECLHIDDEN(int)     supR3HardenedVerifyFixedFile(const char *pszFilename, bool fFatal);
-DECLHIDDEN(int)     supR3HardenedVerifyDir(const char *pszDirPath, bool fRecursive, bool fCheckFiles, char *pszErr, size_t cbErr);
-DECLHIDDEN(int)     supR3HardenedVerifyFile(const char *pszFilename, RTHCUINTPTR hNativeFile, char *pszErr, size_t cbErr);
+DECLHIDDEN(int)     supR3HardenedVerifyDir(const char *pszDirPath, bool fRecursive, bool fCheckFiles, PRTERRINFO pErrInfo);
+DECLHIDDEN(int)     supR3HardenedVerifyFile(const char *pszFilename, RTHCUINTPTR hNativeFile, PRTERRINFO pErrInfo);
 DECLHIDDEN(void)    supR3HardenedGetPreInitData(PSUPPREINITDATA pPreInitData);
 DECLHIDDEN(int)     supR3HardenedRecvPreInitData(PCSUPPREINITDATA pPreInitData);
Index: /trunk/src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp	(revision 35187)
+++ /trunk/src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp	(revision 35188)
@@ -764,25 +764,33 @@
  * @returns Returns @a rc
  * @param   rc                  The return code.
- * @param   pszErr              The error buffer.
- * @param   cbErr               The size of the error buffer.
+ * @param   pErrInfo            The error info structure.
  * @param   cMsgs               The number of messages in the ellipsis.
  * @param   ...                 Message parts.
  */
-static int supR3HardenedSetErrorN(int rc, char *pszErr, size_t cbErr, unsigned cMsgs, ...)
-{
-    va_list va;
-    va_start(va, cMsgs);
-    while (cMsgs-- > 0 && cbErr > 0)
-    {
-        const char *pszMsg = va_arg(va,  const char *);
-        size_t cchMsg = VALID_PTR(pszMsg) ? strlen(pszMsg) : 0;
-        if (cchMsg >= cbErr)
-            cchMsg = cbErr - 1;
-        memcpy(pszErr, pszMsg, cchMsg);
-        pszErr[cchMsg] = '\0';
-        pszErr += cchMsg;
-        cbErr -= cchMsg;
-    }
-    va_end(va);
+static int supR3HardenedSetErrorN(int rc, PRTERRINFO pErrInfo, unsigned cMsgs, ...)
+{
+    if (pErrInfo)
+    {
+        size_t cbErr  = pErrInfo->cbMsg;
+        char  *pszErr = pErrInfo->pszMsg;
+
+        va_list va;
+        va_start(va, cMsgs);
+        while (cMsgs-- > 0 && cbErr > 0)
+        {
+            const char *pszMsg = va_arg(va,  const char *);
+            size_t cchMsg = VALID_PTR(pszMsg) ? strlen(pszMsg) : 0;
+            if (cchMsg >= cbErr)
+                cchMsg = cbErr - 1;
+            memcpy(pszErr, pszMsg, cchMsg);
+            pszErr[cchMsg] = '\0';
+            pszErr += cchMsg;
+            cbErr -= cchMsg;
+        }
+        va_end(va);
+
+        pErrInfo->rc      = rc;
+        pErrInfo->fFlags |= RTERRINFO_FLAGS_SET;
+    }
 
     return rc;
@@ -795,14 +803,13 @@
  * @returns Returns @a rc
  * @param   rc                  The return code.
- * @param   pszErr              The error buffer.
- * @param   cbErr               The size of the error buffer.
+ * @param   pErrInfo            The error info structure.
  * @param   pszMsg1             The first message part.
  * @param   pszMsg2             The second message part.
  * @param   pszMsg3             The third message part.
  */
-static int supR3HardenedSetError3(int rc, char *pszErr, size_t cbErr, const char *pszMsg1,
+static int supR3HardenedSetError3(int rc, PRTERRINFO pErrInfo, const char *pszMsg1,
                                   const char *pszMsg2, const char *pszMsg3)
 {
-    return supR3HardenedSetErrorN(rc, pszErr, cbErr, 3, pszMsg1, pszMsg2, pszMsg3);
+    return supR3HardenedSetErrorN(rc, pErrInfo, 3, pszMsg1, pszMsg2, pszMsg3);
 }
 
@@ -813,13 +820,12 @@
  * @returns Returns @a rc
  * @param   rc                  The return code.
- * @param   pszErr              The error buffer.
- * @param   cbErr               The size of the error buffer.
+ * @param   pErrInfo            The error info structure.
  * @param   pszMsg1             The first message part.
  * @param   pszMsg2             The second message part.
  */
-static int supR3HardenedSetError2(int rc, char *pszErr, size_t cbErr, const char *pszMsg1,
+static int supR3HardenedSetError2(int rc, PRTERRINFO pErrInfo, const char *pszMsg1,
                                   const char *pszMsg2)
 {
-    return supR3HardenedSetErrorN(rc, pszErr, cbErr, 2, pszMsg1, pszMsg2);
+    return supR3HardenedSetErrorN(rc, pErrInfo, 2, pszMsg1, pszMsg2);
 }
 
@@ -830,11 +836,10 @@
  * @returns Returns @a rc
  * @param   rc                  The return code.
- * @param   pszErr              The error buffer.
- * @param   cbErr               The size of the error buffer.
+ * @param   pErrInfo            The error info structure.
  * @param   pszMsg              The message.
  */
-static int supR3HardenedSetError(int rc, char *pszErr, size_t cbErr, const char *pszMsg)
-{
-    return supR3HardenedSetErrorN(rc, pszErr, cbErr, 1, pszMsg);
+static int supR3HardenedSetError(int rc, PRTERRINFO pErrInfo, const char *pszMsg)
+{
+    return supR3HardenedSetErrorN(rc, pErrInfo, 1, pszMsg);
 }
 
@@ -877,10 +882,9 @@
  * @returns VBox status code.
  * @param   pszPath             The path to check.
- * @param   pszErr              The error buffer.
- * @param   cbErr               The size of the error buffer.
+ * @param   pErrInfo            The error info structure.
  * @param   pInfo               Where to return a copy of the path along with
  *                              parsing information.
  */
-static int supR3HardenedVerifyPathSanity(const char *pszPath, char *pszErr, size_t cbErr, PSUPR3HARDENEDPATHINFO pInfo)
+static int supR3HardenedVerifyPathSanity(const char *pszPath, PRTERRINFO pErrInfo, PSUPR3HARDENEDPATHINFO pInfo)
 {
     const char *pszSrc = pszPath;
@@ -894,5 +898,5 @@
         || pszSrc[1] != ':'
         || !RTPATH_IS_SLASH(pszSrc[2]))
-        return supR3HardenedSetError3(VERR_SUPLIB_PATH_NOT_ABSOLUTE, pszErr, cbErr, "The path is not absolute: '", pszPath, "'");
+        return supR3HardenedSetError3(VERR_SUPLIB_PATH_NOT_ABSOLUTE, pErrInfo, "The path is not absolute: '", pszPath, "'");
 
     *pszDst++ = RT_C_TO_UPPER(pszSrc[0]);
@@ -903,5 +907,5 @@
 #else
     if (!RTPATH_IS_SLASH(pszSrc[0]))
-        return supR3HardenedSetError3(VERR_SUPLIB_PATH_NOT_ABSOLUTE, pszErr, cbErr, "The path is not absolute: '", pszPath, "'");
+        return supR3HardenedSetError3(VERR_SUPLIB_PATH_NOT_ABSOLUTE, pErrInfo, "The path is not absolute: '", pszPath, "'");
 
     *pszDst++ = RTPATH_SLASH;
@@ -914,8 +918,8 @@
      */
     if (pszSrc[0] == '\0')
-        return supR3HardenedSetError3(VERR_SUPLIB_PATH_IS_ROOT, pszErr, cbErr, "The path is root: '", pszPath, "'");
+        return supR3HardenedSetError3(VERR_SUPLIB_PATH_IS_ROOT, pErrInfo, "The path is root: '", pszPath, "'");
     if (   pszSrc[1] == '\0'
         || pszSrc[2] == '\0')
-        return supR3HardenedSetError3(VERR_SUPLIB_PATH_TOO_SHORT, pszErr, cbErr, "The path is too short: '", pszPath, "'");
+        return supR3HardenedSetError3(VERR_SUPLIB_PATH_TOO_SHORT, pErrInfo, "The path is too short: '", pszPath, "'");
 
     /*
@@ -928,15 +932,15 @@
         /* Sanity checks. */
         if (RTPATH_IS_SLASH(pszSrc[0])) /* can be relaxed if we care. */
-            return supR3HardenedSetError3(VERR_SUPLIB_PATH_NOT_CLEAN, pszErr, cbErr,
+            return supR3HardenedSetError3(VERR_SUPLIB_PATH_NOT_CLEAN, pErrInfo,
                                           "The path is not clean of double slashes: '", pszPath, "'");
         if (   pszSrc[0] == '.'
             && pszSrc[1] == '.'
             && RTPATH_IS_SLASH(pszSrc[2]))
-            return supR3HardenedSetError3(VERR_SUPLIB_PATH_NOT_ABSOLUTE, pszErr, cbErr,
+            return supR3HardenedSetError3(VERR_SUPLIB_PATH_NOT_ABSOLUTE, pErrInfo,
                                           "The path is not absolute: '", pszPath, "'");
 
         /* Record the start of the component. */
         if (pInfo->cComponents >= RT_ELEMENTS(pInfo->aoffComponents) - 1)
-            return supR3HardenedSetError3(VERR_SUPLIB_PATH_TOO_MANY_COMPONENTS, pszErr, cbErr,
+            return supR3HardenedSetError3(VERR_SUPLIB_PATH_TOO_MANY_COMPONENTS, pErrInfo,
                                           "The path has too many components: '", pszPath, "'");
         pInfo->aoffComponents[pInfo->cComponents++] = pszDst - &pInfo->szPath[0];
@@ -956,5 +960,5 @@
             *pszDst++ = *pszSrc++;
             if ((uintptr_t)(pszDst - &pInfo->szPath[0]) >= SUPR3HARDENED_MAX_PATH)
-                return supR3HardenedSetError3(VERR_SUPLIB_PATH_TOO_LONG, pszErr, cbErr,
+                return supR3HardenedSetError3(VERR_SUPLIB_PATH_TOO_LONG, pErrInfo,
                                               "The path is too long: '", pszPath, "'");
         }
@@ -1000,9 +1004,7 @@
  * @param   pszPath             The path to the object.
  * @param   pFsObjState         Where to return the state information.
- * @param   pszErr              The error buffer.
- * @param   cbErr               The size of the error buffer.
- */
-static int supR3HardenedQueryFsObjectByPath(char const *pszPath, PSUPR3HARDENEDFSOBJSTATE pFsObjState,
-                                            char *pszErr, size_t cbErr)
+ * @param   pErrInfo            The error info structure.
+ */
+static int supR3HardenedQueryFsObjectByPath(char const *pszPath, PSUPR3HARDENEDFSOBJSTATE pFsObjState, PRTERRINFO pErrInfo)
 {
 #if defined(RT_OS_WINDOWS)
@@ -1019,5 +1021,5 @@
         /* Ignore access errors */
         if (errno != EACCES)
-            return supR3HardenedSetErrorN(VERR_SUPLIB_STAT_FAILED, pszErr, cbErr,
+            return supR3HardenedSetErrorN(VERR_SUPLIB_STAT_FAILED, pErrInfo,
                                           5, "stat failed with ", strerror(errno), " on: '", pszPath, "'");
     }
@@ -1043,9 +1045,8 @@
  * @param   pszPath             The path to the object. (For the error message
  *                              only.)
- * @param   pszErr              The error buffer.
- * @param   cbErr               The size of the error buffer.
+ * @param   pErrInfo            The error info structure.
  */
 static int supR3HardenedQueryFsObjectByHandle(RTHCUINTPTR hNative, PSUPR3HARDENEDFSOBJSTATE pFsObjState,
-                                              char const *pszPath, char *pszErr, size_t cbErr)
+                                              char const *pszPath, PRTERRINFO pErrInfo)
 {
 #if defined(RT_OS_WINDOWS)
@@ -1059,5 +1060,5 @@
      */
     if (fstat((int)hNative, &pFsObjState->Stat) != 0)
-        return supR3HardenedSetErrorN(VERR_SUPLIB_STAT_FAILED, pszErr, cbErr,
+        return supR3HardenedSetErrorN(VERR_SUPLIB_STAT_FAILED, pErrInfo,
                                       5, "fstat failed with ", strerror(errno), " on '", pszPath, "'");
 
@@ -1081,9 +1082,8 @@
  * @param   pszPath             The path to the object @a pFsObjState
  *                              describes.  (For the error message.)
- * @param   pszErr              The error buffer.
- * @param   cbErr               The size of the error buffer.
+ * @param   pErrInfo            The error info structure.
  */
 static int supR3HardenedIsSameFsObject(PCSUPR3HARDENEDFSOBJSTATE pFsObjState1, PCSUPR3HARDENEDFSOBJSTATE pFsObjState2,
-                                       const char *pszPath, char *pszErr, size_t cbErr)
+                                       const char *pszPath, PRTERRINFO pErrInfo)
 {
 #if defined(RT_OS_WINDOWS)
@@ -1101,13 +1101,13 @@
     if (   pFsObjState1->Stat.st_ino != pFsObjState2->Stat.st_ino
         || pFsObjState1->Stat.st_dev != pFsObjState2->Stat.st_dev)
-        return supR3HardenedSetError3(VERR_SUPLIB_NOT_SAME_OBJECT, pszErr, cbErr,
+        return supR3HardenedSetError3(VERR_SUPLIB_NOT_SAME_OBJECT, pErrInfo,
                                       "The native handle is not the same as '", pszPath, "' (ino/dev)");
     if (   pFsObjState1->Stat.st_uid != pFsObjState2->Stat.st_uid
         || pFsObjState1->Stat.st_gid != pFsObjState2->Stat.st_gid)
-        return supR3HardenedSetError3(VERR_SUPLIB_NOT_SAME_OBJECT, pszErr, cbErr,
+        return supR3HardenedSetError3(VERR_SUPLIB_NOT_SAME_OBJECT, pErrInfo,
                                       "The native handle is not the same as '", pszPath, "' (uid/gid)");
     if (   (pFsObjState1->Stat.st_mode & (S_IFMT | S_IWUSR | S_IWGRP | S_IWOTH))
         != (pFsObjState2->Stat.st_mode & (S_IFMT | S_IWUSR | S_IWGRP | S_IWOTH)))
-        return supR3HardenedSetError3(VERR_SUPLIB_NOT_SAME_OBJECT, pszErr, cbErr,
+        return supR3HardenedSetError3(VERR_SUPLIB_NOT_SAME_OBJECT, pErrInfo,
                                       "The native handle is not the same as '", pszPath, "' (mode)");
     return VINF_SUCCESS;
@@ -1128,9 +1128,8 @@
  * @param   pszPath             The path to the object. (For error messages
  *                              only.)
- * @param   pszErr              The error buffer.
- * @param   cbErr               The size of the error buffer.
+ * @param   pErrInfo            The error info structure.
  */
 static int supR3HardenedVerifyFsObject(PCSUPR3HARDENEDFSOBJSTATE pFsObjState, bool fDir, bool fRelaxed,
-                                       const char *pszPath, char *pszErr, size_t cbErr)
+                                       const char *pszPath, PRTERRINFO pErrInfo)
 {
 #if defined(RT_OS_WINDOWS)
@@ -1149,5 +1148,5 @@
      */
     if (pFsObjState->Stat.st_uid != 0)
-        return supR3HardenedSetError3(VERR_SUPLIB_OWNER_NOT_ROOT, pszErr, cbErr, "The owner is not root: '", pszPath, "'");
+        return supR3HardenedSetError3(VERR_SUPLIB_OWNER_NOT_ROOT, pErrInfo, "The owner is not root: '", pszPath, "'");
 
     /*
@@ -1167,5 +1166,5 @@
         if (pFsObjState->Stat.st_gid != 80 /*admin*/) /** @todo dynamically resolve the admin group? */
 #endif
-            return supR3HardenedSetError3(VERR_SUPLIB_WRITE_NON_SYS_GROUP, pszErr, cbErr,
+            return supR3HardenedSetError3(VERR_SUPLIB_WRITE_NON_SYS_GROUP, pErrInfo,
                                           "The group is not a system group and it has write access to '", pszPath, "'");
     }
@@ -1175,5 +1174,5 @@
      */
     if (pFsObjState->Stat.st_mode & S_IWOTH)
-        return supR3HardenedSetError3(VERR_SUPLIB_WORLD_WRITABLE, pszErr, cbErr,
+        return supR3HardenedSetError3(VERR_SUPLIB_WORLD_WRITABLE, pErrInfo,
                                       "World writable: '", pszPath, "'");
 
@@ -1190,7 +1189,7 @@
     {
         if (S_ISLNK(pFsObjState->Stat.st_mode))
-            return supR3HardenedSetError3(VERR_SUPLIB_SYMLINKS_ARE_NOT_PERMITTED, pszErr, cbErr,
+            return supR3HardenedSetError3(VERR_SUPLIB_SYMLINKS_ARE_NOT_PERMITTED, pErrInfo,
                                           "Symlinks are not permitted: '", pszPath, "'");
-        return supR3HardenedSetError3(VERR_SUPLIB_NOT_DIR_NOT_FILE, pszErr, cbErr,
+        return supR3HardenedSetError3(VERR_SUPLIB_NOT_DIR_NOT_FILE, pErrInfo,
                                       "Not regular file or directory: '", pszPath, "'");
     }
@@ -1198,7 +1197,7 @@
     {
         if (S_ISDIR(pFsObjState->Stat.st_mode))
-            return supR3HardenedSetError3(VERR_SUPLIB_IS_DIRECTORY, pszErr, cbErr,
+            return supR3HardenedSetError3(VERR_SUPLIB_IS_DIRECTORY, pErrInfo,
                                           "Expected file but found directory: '", pszPath, "'");
-        return supR3HardenedSetError3(VERR_SUPLIB_IS_FILE, pszErr, cbErr,
+        return supR3HardenedSetError3(VERR_SUPLIB_IS_FILE, pErrInfo,
                                       "Expected directory but found file: '", pszPath, "'");
     }
@@ -1222,14 +1221,13 @@
  * @param   pszPath             The path to the object @a pFsObjState
  *                              describes.  (For the error message.)
- * @param   pszErr              The error buffer.
- * @param   cbErr               The size of the error buffer.
+ * @param   pErrInfo            The error info structure.
  */
 static int supR3HardenedVerifySameFsObject(RTHCUINTPTR hNative, PCSUPR3HARDENEDFSOBJSTATE pFsObjState,
-                                           const char *pszPath, char *pszErr, size_t cbErr)
+                                           const char *pszPath, PRTERRINFO pErrInfo)
 {
     SUPR3HARDENEDFSOBJSTATE FsObjState2;
-    int rc = supR3HardenedQueryFsObjectByHandle(hNative, &FsObjState2, pszPath, pszErr, cbErr);
+    int rc = supR3HardenedQueryFsObjectByHandle(hNative, &FsObjState2, pszPath, pErrInfo);
     if (RT_SUCCESS(rc))
-        rc = supR3HardenedIsSameFsObject(pFsObjState, &FsObjState2, pszPath, pszErr, cbErr);
+        rc = supR3HardenedIsSameFsObject(pFsObjState, &FsObjState2, pszPath, pErrInfo);
     return rc;
 }
@@ -1252,9 +1250,8 @@
  *                              thing.
  * @param   fRecursive          Whether to recurse into subdirectories.
- * @param   pszErr              The error buffer.
- * @param   cbErr               The size of the error buffer.
+ * @param   pErrInfo            The error info structure.
  */
 static int supR3HardenedVerifyDirRecursive(char *pszDirPath, size_t cchDirPath, PSUPR3HARDENEDFSOBJSTATE pFsObjState,
-                                           bool fRecursive, char *pszErr, size_t cbErr)
+                                           bool fRecursive, PRTERRINFO pErrInfo)
 {
 #if defined(RT_OS_WINDOWS)
@@ -1278,10 +1275,10 @@
         if (errno == EACCES)
             return VINF_SUCCESS;
-        return supR3HardenedSetErrorN(VERR_SUPLIB_DIR_ENUM_FAILED, pszErr, cbErr,
+        return supR3HardenedSetErrorN(VERR_SUPLIB_DIR_ENUM_FAILED, pErrInfo,
                                       5, "opendir failed with ", strerror(errno), " on '", pszDirPath, "'");
     }
     if (dirfd(pDir) != -1)
     {
-        int rc = supR3HardenedVerifySameFsObject(dirfd(pDir), pFsObjState, pszDirPath, pszErr, cbErr);
+        int rc = supR3HardenedVerifySameFsObject(dirfd(pDir), pFsObjState, pszDirPath, pErrInfo);
         if (RT_FAILURE(rc))
         {
@@ -1304,5 +1301,5 @@
         if (iErr)
         {
-            rc = supR3HardenedSetErrorN(VERR_SUPLIB_DIR_ENUM_FAILED, pszErr, cbErr,
+            rc = supR3HardenedSetErrorN(VERR_SUPLIB_DIR_ENUM_FAILED, pErrInfo,
                                         5, "readdir_r failed with ", strerror(iErr), " in '", pszDirPath, "'");
             break;
@@ -1318,5 +1315,5 @@
         if (cchName + cchDirPath > SUPR3HARDENED_MAX_PATH)
         {
-            rc = supR3HardenedSetErrorN(VERR_SUPLIB_PATH_TOO_LONG, pszErr, cbErr,
+            rc = supR3HardenedSetErrorN(VERR_SUPLIB_PATH_TOO_LONG, pErrInfo,
                                         4, "Path grew too long during recursion: '", pszDirPath, pEntry->d_name, "'");
             break;
@@ -1329,9 +1326,9 @@
          * of extra checks doesn't hurt and neither requires relaxed handling.)
          */
-        rc = supR3HardenedQueryFsObjectByPath(pszDirPath, pFsObjState, pszErr, cbErr);
+        rc = supR3HardenedQueryFsObjectByPath(pszDirPath, pFsObjState, pErrInfo);
         if (RT_SUCCESS(rc))
             break;
         rc = supR3HardenedVerifyFsObject(pFsObjState, S_ISDIR(pFsObjState->Stat.st_mode), false /*fRelaxed*/,
-                                         pszDirPath, pszErr, cbErr);
+                                         pszDirPath, pErrInfo);
         if (RT_FAILURE(rc))
             break;
@@ -1349,5 +1346,5 @@
 
             rc = supR3HardenedVerifyDirRecursive(pszDirPath, cchDirPath + cchName + 1, pFsObjState,
-                                                 fRecursive, pszErr, cbErr);
+                                                 fRecursive, pErrInfo);
             if (RT_FAILURE(rc))
                 break;
@@ -1368,8 +1365,7 @@
  * @param   fRecursive          See SUPR3HardenedVerifyDir.
  * @param   fCheckFiles         See SUPR3HardenedVerifyDir.
- * @param   pszErr              See SUPR3HardenedVerifyDir.
- * @param   cbErr               See SUPR3HardenedVerifyDir.
- */
-DECLHIDDEN(int) supR3HardenedVerifyDir(const char *pszDirPath, bool fRecursive, bool fCheckFiles, char *pszErr, size_t cbErr)
+ * @param   pErrInfo            See SUPR3HardenedVerifyDir.
+ */
+DECLHIDDEN(int) supR3HardenedVerifyDir(const char *pszDirPath, bool fRecursive, bool fCheckFiles, PRTERRINFO pErrInfo)
 {
     /*
@@ -1377,5 +1373,5 @@
      */
     SUPR3HARDENEDPATHINFO Info;
-    int rc = supR3HardenedVerifyPathSanity(pszDirPath, pszErr, cbErr, &Info);
+    int rc = supR3HardenedVerifyPathSanity(pszDirPath, pErrInfo, &Info);
     if (RT_FAILURE(rc))
         return rc;
@@ -1390,7 +1386,7 @@
         bool fRelaxed = iComponent + 2 < cComponents;
         Info.szPath[Info.aoffComponents[iComponent + 1] - 1] = '\0';
-        rc = supR3HardenedQueryFsObjectByPath(Info.szPath, &FsObjState, pszErr, cbErr);
+        rc = supR3HardenedQueryFsObjectByPath(Info.szPath, &FsObjState, pErrInfo);
         if (RT_SUCCESS(rc))
-            rc = supR3HardenedVerifyFsObject(&FsObjState, true /*fDir*/, fRelaxed, Info.szPath, pszErr, cbErr);
+            rc = supR3HardenedVerifyFsObject(&FsObjState, true /*fDir*/, fRelaxed, Info.szPath, pErrInfo);
         if (RT_FAILURE(rc))
             return rc;
@@ -1406,5 +1402,5 @@
         Info.szPath[Info.cch + 1] = '\0';
         return supR3HardenedVerifyDirRecursive(Info.szPath, Info.cch + 1, &FsObjState,
-                                               fRecursive, pszErr, cbErr);
+                                               fRecursive, pErrInfo);
     }
 
@@ -1421,8 +1417,8 @@
  *                              as we ended up with when verifying the path.
  *                              RTHCUINTPTR_MAX means NIL here.
- * @param   pszErr              The error buffer.
- * @param   cbErr               The size of the error buffer.
- */
-DECLHIDDEN(int) supR3HardenedVerifyFile(const char *pszFilename, RTHCUINTPTR hNativeFile, char *pszErr, size_t cbErr)
+ * @param   pErrInfo            Where to return extended error information.
+ *                              Optional.
+ */
+DECLHIDDEN(int) supR3HardenedVerifyFile(const char *pszFilename, RTHCUINTPTR hNativeFile, PRTERRINFO pErrInfo)
 {
     /*
@@ -1430,9 +1426,9 @@
      */
     SUPR3HARDENEDPATHINFO Info;
-    int rc = supR3HardenedVerifyPathSanity(pszFilename, pszErr, cbErr, &Info);
+    int rc = supR3HardenedVerifyPathSanity(pszFilename, pErrInfo, &Info);
     if (RT_FAILURE(rc))
         return rc;
     if (Info.fDirSlash)
-        return supR3HardenedSetError3(VERR_SUPLIB_IS_DIRECTORY, pszErr, cbErr,
+        return supR3HardenedSetError3(VERR_SUPLIB_IS_DIRECTORY, pErrInfo,
                                       "The file path specifies a directory: '", pszFilename, "'");
 
@@ -1447,7 +1443,7 @@
         bool fRelaxed = iComponent + 2 < cComponents;
         Info.szPath[Info.aoffComponents[iComponent + 1] - 1] = '\0';
-        rc = supR3HardenedQueryFsObjectByPath(Info.szPath, &FsObjState, pszErr, cbErr);
+        rc = supR3HardenedQueryFsObjectByPath(Info.szPath, &FsObjState, pErrInfo);
         if (RT_SUCCESS(rc))
-            rc = supR3HardenedVerifyFsObject(&FsObjState, !fFinal /*fDir*/, fRelaxed, Info.szPath, pszErr, cbErr);
+            rc = supR3HardenedVerifyFsObject(&FsObjState, !fFinal /*fDir*/, fRelaxed, Info.szPath, pErrInfo);
         if (RT_FAILURE(rc))
             return rc;
@@ -1459,5 +1455,5 @@
      */
     if (hNativeFile != RTHCUINTPTR_MAX)
-        return supR3HardenedVerifySameFsObject(hNativeFile, &FsObjState, Info.szPath, pszErr, cbErr);
+        return supR3HardenedVerifySameFsObject(hNativeFile, &FsObjState, Info.szPath, pErrInfo);
     return VINF_SUCCESS;
 }
Index: /trunk/src/VBox/HostDrivers/Support/testcase/tstSupLoadModule.cpp
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/testcase/tstSupLoadModule.cpp	(revision 35187)
+++ /trunk/src/VBox/HostDrivers/Support/testcase/tstSupLoadModule.cpp	(revision 35188)
@@ -70,10 +70,11 @@
             case VINF_GETOPT_NOT_OPTION:
             {
-                char szErr[4096+1024];
-                void *pvImageBase;
-                rc = SUPR3LoadModule(ValueUnion.psz, RTPathFilename(ValueUnion.psz), &pvImageBase, szErr, sizeof(szErr));
+                void           *pvImageBase;
+                RTERRINFOSTATIC ErrInfo;
+                RTErrInfoInitStatic(&ErrInfo);
+                rc = SUPR3LoadModule(ValueUnion.psz, RTPathFilename(ValueUnion.psz), &pvImageBase, &ErrInfo.Core);
                 if (RT_FAILURE(rc))
                 {
-                    RTMsgError("%Rrc when attempting to load '%s': %s\n", rc, ValueUnion.psz, szErr);
+                    RTMsgError("%Rrc when attempting to load '%s': %s\n", rc, ValueUnion.psz, ErrInfo.Core.pszMsg);
                     return 1;
                 }
Index: /trunk/src/VBox/Main/ConsoleVRDPServer.cpp
===================================================================
--- /trunk/src/VBox/Main/ConsoleVRDPServer.cpp	(revision 35187)
+++ /trunk/src/VBox/Main/ConsoleVRDPServer.cpp	(revision 35188)
@@ -2335,10 +2335,11 @@
     if (mVRDPLibrary == NIL_RTLDRMOD)
     {
-        char szErr[4096 + 512];
-        szErr[0] = '\0';
+        RTERRINFOSTATIC ErrInfo;
+        RTErrInfoInitStatic(&ErrInfo);
+
         if (RTPathHavePath(pszLibraryName))
-            rc = SUPR3HardenedLdrLoadPlugIn(pszLibraryName, &mVRDPLibrary, szErr, sizeof(szErr));
+            rc = SUPR3HardenedLdrLoadPlugIn(pszLibraryName, &mVRDPLibrary, &ErrInfo.Core);
         else
-            rc = SUPR3HardenedLdrLoadAppPriv(pszLibraryName, &mVRDPLibrary, 0 /*=fFlags*/, szErr, sizeof(szErr));
+            rc = SUPR3HardenedLdrLoadAppPriv(pszLibraryName, &mVRDPLibrary, 0 /*fFlags*/, &ErrInfo.Core);
         if (RT_SUCCESS(rc))
         {
@@ -2371,6 +2372,6 @@
         else
         {
-            if (szErr[0])
-                LogRel(("VRDE: Error loading the library '%s': %s (%Rrc)\n", pszLibraryName, szErr, rc));
+            if (RTErrInfoIsSet(&ErrInfo.Core))
+                LogRel(("VRDE: Error loading the library '%s': %s (%Rrc)\n", pszLibraryName, ErrInfo.Core.pszMsg, rc));
             else
                 LogRel(("VRDE: Error loading the library '%s' rc = %Rrc.\n", pszLibraryName, rc));
Index: /trunk/src/VBox/Main/ExtPackManagerImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/ExtPackManagerImpl.cpp	(revision 35187)
+++ /trunk/src/VBox/Main/ExtPackManagerImpl.cpp	(revision 35188)
@@ -1123,10 +1123,10 @@
     }
 
-    char szErr[2048];
-    RT_ZERO(szErr);
-    vrc = SUPR3HardenedVerifyDir(m->strExtPackPath.c_str(), true /*fRecursive*/, true /*fCheckFiles*/, szErr, sizeof(szErr));
+    RTERRINFOSTATIC ErrInfo;
+    RTErrInfoInitStatic(&ErrInfo);
+    vrc = SUPR3HardenedVerifyDir(m->strExtPackPath.c_str(), true /*fRecursive*/, true /*fCheckFiles*/, &ErrInfo.Core);
     if (RT_FAILURE(vrc))
     {
-        m->strWhyUnusable.printf(tr("%s (rc=%Rrc)"), szErr, vrc);
+        m->strWhyUnusable.printf(tr("%s (rc=%Rrc)"), ErrInfo.Core.pszMsg, vrc);
         return;
     }
@@ -1168,13 +1168,11 @@
     }
 
-    vrc = SUPR3HardenedVerifyPlugIn(m->strMainModPath.c_str(), szErr, sizeof(szErr));
+    vrc = SUPR3HardenedVerifyPlugIn(m->strMainModPath.c_str(), &ErrInfo.Core);
     if (RT_FAILURE(vrc))
     {
-        m->strWhyUnusable.printf(tr("%s"), szErr);
+        m->strWhyUnusable.printf(tr("%s"), ErrInfo.Core.pszMsg);
         return;
     }
 
-    RTERRINFOSTATIC ErrInfo;
-    RTErrInfoInitStatic(&ErrInfo);
     if (fIsNative)
     {
@@ -1773,6 +1771,5 @@
     if (a_enmContext == VBOXEXTPACKCTX_PER_USER_DAEMON)
     {
-        char szError[8192];
-        int vrc = SUPR3HardenedLdrLoadAppPriv("VBoxVMM", &m->hVBoxVMM, RTLDRFLAGS_GLOBAL, szError, sizeof(szError));
+        int vrc = SUPR3HardenedLdrLoadAppPriv("VBoxVMM", &m->hVBoxVMM, RTLDRFLAGS_GLOBAL, NULL);
         if (RT_FAILURE(vrc))
             m->hVBoxVMM = NIL_RTLDRMOD;
Index: /trunk/src/VBox/Main/VBoxExtPackHelperApp.cpp
===================================================================
--- /trunk/src/VBox/Main/VBoxExtPackHelperApp.cpp	(revision 35187)
+++ /trunk/src/VBox/Main/VBoxExtPackHelperApp.cpp	(revision 35188)
@@ -309,8 +309,9 @@
     RTMsgInfo("Validating unpacked extension pack...");
 
-    char szErr[4096+1024];
-    int rc = SUPR3HardenedVerifyDir(pszDir, true /*fRecursive*/, true /*fCheckFiles*/, szErr, sizeof(szErr));
-    if (RT_FAILURE(rc))
-        return RTMsgErrorExit(RTEXITCODE_FAILURE, "Hardening check failed with %Rrc: %s", rc, szErr);
+    RTERRINFOSTATIC ErrInfo;
+    RTErrInfoInitStatic(&ErrInfo);
+    int rc = SUPR3HardenedVerifyDir(pszDir, true /*fRecursive*/, true /*fCheckFiles*/, &ErrInfo.Core);
+    if (RT_FAILURE(rc))
+        return RTMsgErrorExit(RTEXITCODE_FAILURE, "Hardening check failed with %Rrc: %s", rc, ErrInfo.Core.pszMsg);
     return RTEXITCODE_SUCCESS;
 }
@@ -1480,8 +1481,9 @@
         return RTMsgInitFailure(rc);
 
-    char szErr[2048];
-    rc = SUPR3HardenedVerifySelf(argv[0], true /*fInternal*/, szErr, sizeof(szErr));
-    if (RT_FAILURE(rc))
-        return RTMsgErrorExit(RTEXITCODE_FAILURE, "%s", szErr);
+    RTERRINFOSTATIC ErrInfo;
+    RTErrInfoInitStatic(&ErrInfo);
+    rc = SUPR3HardenedVerifySelf(argv[0], true /*fInternal*/, &ErrInfo.Core);
+    if (RT_FAILURE(rc))
+        return RTMsgErrorExit(RTEXITCODE_FAILURE, "%s", ErrInfo.Core.pszMsg);
 
     /*
Index: /trunk/src/VBox/Main/VRDEServerImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/VRDEServerImpl.cpp	(revision 35187)
+++ /trunk/src/VBox/Main/VRDEServerImpl.cpp	(revision 35188)
@@ -489,10 +489,10 @@
     RTLDRMOD hmod = NIL_RTLDRMOD;
 
-    char szErr[4096 + 512];
-    szErr[0] = '\0';
+    RTERRINFOSTATIC ErrInfo;
+    RTErrInfoInitStatic(&ErrInfo);
     if (RTPathHavePath(pszLibraryName))
-        rc = SUPR3HardenedLdrLoadPlugIn(pszLibraryName, &hmod, szErr, sizeof(szErr));
+        rc = SUPR3HardenedLdrLoadPlugIn(pszLibraryName, &hmod, &ErrInfo.Core);
     else
-        rc = SUPR3HardenedLdrLoadAppPriv(pszLibraryName, &hmod, 0 /*=fFlags*/, szErr, sizeof(szErr));
+        rc = SUPR3HardenedLdrLoadAppPriv(pszLibraryName, &hmod, 0 /*fFlags*/, &ErrInfo.Core);
     if (RT_SUCCESS(rc))
     {
@@ -504,6 +504,6 @@
     else
     {
-        if (szErr[0])
-            LogRel(("VRDE: Error loading the library '%s': %s (%Rrc)\n", pszLibraryName, szErr, rc));
+        if (RTErrInfoIsSet(&ErrInfo.Core))
+            LogRel(("VRDE: Error loading the library '%s': %s (%Rrc)\n", pszLibraryName, ErrInfo.Core.pszMsg, rc));
         else
             LogRel(("VRDE: Error loading the library '%s' rc = %Rrc.\n", pszLibraryName, rc));
Index: /trunk/src/VBox/Main/hgcm/HGCM.cpp
===================================================================
--- /trunk/src/VBox/Main/hgcm/HGCM.cpp	(revision 35187)
+++ /trunk/src/VBox/Main/hgcm/HGCM.cpp	(revision 35188)
@@ -262,7 +262,8 @@
     }
 
-    char szErr[8192];
-    szErr[0] = '\0';
-    int rc = SUPR3HardenedLdrLoadAppPriv (m_pszSvcLibrary, &m_hLdrMod, 0 /*=fFlags*/, szErr, sizeof(szErr));
+    RTERRINFOSTATIC ErrInfo;
+    RTErrInfoInitStatic (&ErrInfo);
+
+    int rc = SUPR3HardenedLdrLoadAppPriv (m_pszSvcLibrary, &m_hLdrMod, 0 /*fFlags*/, &ErrInfo.Core);
 
     if (RT_SUCCESS(rc))
@@ -320,5 +321,5 @@
     {
         LogRel(("HGCM: Failed to load the service library: [%s], rc = %Rrc - %s. The service will be not available.\n",
-                m_pszSvcLibrary, rc, szErr));
+                m_pszSvcLibrary, rc, ErrInfo.Core.pszMsg));
         m_hLdrMod = NIL_RTLDRMOD;
     }
Index: /trunk/src/VBox/Storage/VD.cpp
===================================================================
--- /trunk/src/VBox/Storage/VD.cpp	(revision 35187)
+++ /trunk/src/VBox/Storage/VD.cpp	(revision 35188)
@@ -2129,5 +2129,5 @@
         }
 
-        rc = SUPR3HardenedLdrLoad(pszPluginPath, &hPlugin, 0 /*=fFlags*/, NULL, 0);
+        rc = SUPR3HardenedLdrLoadPlugIn(pszPluginPath, &hPlugin, NULL);
         if (RT_SUCCESS(rc))
         {
@@ -2253,5 +2253,5 @@
         }
 
-        rc = SUPR3HardenedLdrLoad(pszPluginPath, &hPlugin, 0 /*=fFlags*/, NULL, 0);
+        rc = SUPR3HardenedLdrLoadPlugIn(pszPluginPath, &hPlugin, NULL);
         if (RT_SUCCESS(rc))
         {
Index: /trunk/src/VBox/VMM/PDMLdr.cpp
===================================================================
--- /trunk/src/VBox/VMM/PDMLdr.cpp	(revision 35187)
+++ /trunk/src/VBox/VMM/PDMLdr.cpp	(revision 35188)
@@ -295,6 +295,7 @@
          * Load the loader item.
          */
-        char szErr[4096+1024];
-        rc = SUPR3HardenedLdrLoadPlugIn(pModule->szFilename, &pModule->hLdrMod, szErr, sizeof(szErr));
+        RTERRINFOSTATIC ErrInfo;
+        RTErrInfoInitStatic(&ErrInfo);
+        rc = SUPR3HardenedLdrLoadPlugIn(pModule->szFilename, &pModule->hLdrMod, &ErrInfo.Core);
         if (RT_SUCCESS(rc))
         {
@@ -306,5 +307,5 @@
             /* Something went wrong, most likely module not found. Don't consider other unlikely errors */
             rc = VMSetError(pUVM->pVM, rc, RT_SRC_POS,
-                            N_("Unable to load R3 module %s (%s): %s"), pModule->szFilename, pszName, szErr);
+                            N_("Unable to load R3 module %s (%s): %s"), pModule->szFilename, pszName, ErrInfo.Core.pszMsg);
             RTMemFree(pModule);
         }
@@ -483,9 +484,10 @@
      * Open the loader item.
      */
-    char szErr[4096+1024];
-    int rc = SUPR3HardenedVerifyPlugIn(pszFilename, szErr, sizeof(szErr));
+    RTERRINFOSTATIC ErrInfo;
+    RTErrInfoInitStatic(&ErrInfo);
+    int rc = SUPR3HardenedVerifyPlugIn(pszFilename, &ErrInfo.Core);
     if (RT_SUCCESS(rc))
     {
-        szErr[0] = '\0';
+        RTErrInfoClear(&ErrInfo.Core);
         rc = RTLdrOpen(pszFilename, 0, RTLDRARCH_X86_32, &pModule->hLdrMod);
     }
@@ -565,6 +567,6 @@
 
     /* Don't consider VERR_PDM_MODULE_NAME_CLASH and VERR_NO_MEMORY above as these are very unlikely. */
-    if (RT_FAILURE(rc) && szErr[0])
-        rc = VMSetError(pVM, rc, RT_SRC_POS, N_("Cannot load RC module %s: %s"), pszFilename, szErr);
+    if (RT_FAILURE(rc) && RTErrInfoIsSet(&ErrInfo.Core))
+        rc = VMSetError(pVM, rc, RT_SRC_POS, N_("Cannot load RC module %s: %s"), pszFilename, ErrInfo.Core.pszMsg);
     else if (RT_FAILURE(rc))
         rc = VMSetError(pVM, rc, RT_SRC_POS, N_("Cannot load RC module %s"), pszFilename);
@@ -633,7 +635,8 @@
      * Ask the support library to load it.
      */
-    char szErr[4096+1024];
-    void *pvImageBase;
-    int rc = SUPR3LoadModule(pszFilename, pszName, &pvImageBase, szErr, sizeof(szErr));
+    void           *pvImageBase;
+    RTERRINFOSTATIC ErrInfo;
+    RTErrInfoInitStatic(&ErrInfo);
+    int rc = SUPR3LoadModule(pszFilename, pszName, &pvImageBase, &ErrInfo.Core);
     if (RT_SUCCESS(rc))
     {
@@ -662,9 +665,9 @@
     RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
     RTMemFree(pModule);
-    LogRel(("pdmR3LoadR0U: pszName=\"%s\" rc=%Rrc szErr=\"%s\"\n", pszName, rc, szErr));
+    LogRel(("pdmR3LoadR0U: pszName=\"%s\" rc=%Rrc szErr=\"%s\"\n", pszName, rc, ErrInfo.Core.pszMsg));
 
     /* Don't consider VERR_PDM_MODULE_NAME_CLASH and VERR_NO_MEMORY above as these are very unlikely. */
     if (RT_FAILURE(rc) && pUVM->pVM) /** @todo VMR3SetErrorU. */
-        rc = VMSetError(pUVM->pVM, rc, RT_SRC_POS, N_("Cannot load R0 module %s: %s"), pszFilename, szErr);
+        rc = VMSetError(pUVM->pVM, rc, RT_SRC_POS, N_("Cannot load R0 module %s: %s"), pszFilename, ErrInfo.Core.pszMsg);
 
     RTMemTmpFree(pszFile); /* might be reference thru pszFilename in the above VMSetError call. */
Index: /trunk/src/recompiler/VBoxREMWrapper.cpp
===================================================================
--- /trunk/src/recompiler/VBoxREMWrapper.cpp	(revision 35187)
+++ /trunk/src/recompiler/VBoxREMWrapper.cpp	(revision 35188)
@@ -1983,5 +1983,5 @@
     if (g_ModVMM != NIL_RTLDRMOD)
     {
-        rc = SUPR3HardenedLdrLoadAppPriv("VBoxVMM", &g_ModVMM, 0 /*=fFlags*/, NULL, 0);
+        rc = SUPR3HardenedLdrLoadAppPriv("VBoxVMM", &g_ModVMM, 0 /*fFlags*/, NULL);
         AssertRCReturn(rc, rc);
         for (size_t i = 0; i < RT_ELEMENTS(g_aVMMImports); i++)
@@ -2097,5 +2097,5 @@
     if (g_ModVMM == NIL_RTLDRMOD)
     {
-        rc = SUPR3HardenedLdrLoadAppPriv("VBoxVMM", &g_ModVMM, 0 /*=fFlags*/, NULL, 0);
+        rc = SUPR3HardenedLdrLoadAppPriv("VBoxVMM", &g_ModVMM, 0 /*fFlags*/, NULL);
         AssertRCReturn(rc, false);
     }
@@ -2133,5 +2133,5 @@
      */
     const char *pszModule = remIs64bitEnabled(pVM) ? "VBoxREM64" : "VBoxREM32";
-    int rc = SUPR3HardenedLdrLoadAppPriv(pszModule, &g_ModREM2, 0 /*=fFlags*/, NULL, 0);
+    int rc = SUPR3HardenedLdrLoadAppPriv(pszModule, &g_ModREM2, 0 /*fFlags*/, NULL);
     if (RT_SUCCESS(rc))
     {
