Index: /trunk/src/VBox/Runtime/include/internal/dir.h
===================================================================
--- /trunk/src/VBox/Runtime/include/internal/dir.h	(revision 78049)
+++ /trunk/src/VBox/Runtime/include/internal/dir.h	(revision 78050)
@@ -175,7 +175,4 @@
  * @param   pDir                The directory to open. The pszPath member contains the
  *                              path to the directory.
- * @param   pszPathBuf          Pointer to a RTPATH_MAX sized buffer containing
- *                              pszPath.  Find-first style systems can use this
- *                              to setup the wildcard expression.
  * @param   hRelativeDir        The directory @a pvNativeRelative is relative,
  *                              ~(uintptr_t)0 if absolute.
@@ -183,5 +180,5 @@
  *                              we're to use (consume) hRelativeDir.
  */
-int rtDirNativeOpen(PRTDIRINTERNAL pDir, char *pszPathBuf, uintptr_t hRelativeDir, void *pvNativeRelative);
+int rtDirNativeOpen(PRTDIRINTERNAL pDir, uintptr_t hRelativeDir, void *pvNativeRelative);
 
 /**
Index: /trunk/src/VBox/Runtime/r3/dir.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/dir.cpp	(revision 78049)
+++ /trunk/src/VBox/Runtime/r3/dir.cpp	(revision 78050)
@@ -527,6 +527,5 @@
      * As a sideeffect we also validate the path here.
      */
-    char   szRealPath[RTPATH_MAX + 1];
-    int    rc;
+    char  *pszAbsPath;
     size_t cbFilter;                    /* includes '\0' (thus cb and not cch). */
     size_t cucFilter0;                  /* includes U+0. */
@@ -544,5 +543,5 @@
 
         cbFilter = cucFilter0 = 0;
-        rc = RTPathAbs(pszPath, szRealPath, sizeof(szRealPath) - 1);
+        pszAbsPath = RTPathAbsDup(pszPath);
     }
     else
@@ -558,21 +557,15 @@
                 return VERR_NO_MEMORY;
             pszTmp[pszFilter - pszPath] = '\0';
-            rc = RTPathAbs(pszTmp, szRealPath, sizeof(szRealPath) - 1);
+            pszAbsPath = RTPathAbsDup(pszTmp);
             RTStrFree(pszTmp);
         }
         else
-            rc = RTPathReal(".", szRealPath, sizeof(szRealPath) - 1);
+            pszAbsPath = RTPathAbsDup(".");
         fDirSlash = true;
     }
-    if (RT_FAILURE(rc))
-        return rc;
-
-    /* add trailing '/' if missing. */
-    size_t cchRealPath = strlen(szRealPath);
-    if (!RTPATH_IS_SEP(szRealPath[cchRealPath - 1]))
-    {
-        szRealPath[cchRealPath++] = RTPATH_SLASH;
-        szRealPath[cchRealPath] = '\0';
-    }
+    if (!pszAbsPath)
+        return VERR_NO_MEMORY;
+
+
 
     /*
@@ -582,12 +575,17 @@
      * thus the horrible ugliness here. Solaris uses d_name[1] for instance.
      */
-    size_t cbDir = rtDirNativeGetStructSize(szRealPath);
-    size_t const cbAllocated = cbDir
-                             + cucFilter0 * sizeof(RTUNICP)
-                             + cbFilter
-                             + cchRealPath + 1 + 4;
+    size_t const cchAbsPath      = strlen(pszAbsPath);
+    size_t const cchAbsPathExtra = !RTPATH_IS_SEP(pszAbsPath[cchAbsPath - 1]) ? 1 : 0; /* add trailing '/' if missing */
+    size_t const cbDir           = rtDirNativeGetStructSize(pszAbsPath);
+    size_t const cbAllocated     = cbDir
+                                 + cucFilter0 * sizeof(RTUNICP)
+                                 + cbFilter
+                                 + cchAbsPath + cchAbsPathExtra + 1 + 4;
     PRTDIRINTERNAL pDir = (PRTDIRINTERNAL)RTMemAllocZ(cbAllocated);
     if (!pDir)
+    {
+        RTStrFree(pszAbsPath);
         return VERR_NO_MEMORY;
+    }
     uint8_t *pb = (uint8_t *)pDir + cbDir;
 
@@ -598,6 +596,6 @@
     {
         pDir->puszFilter = (PRTUNICP)pb;
-        rc = RTStrToUniEx(pszFilter, RTSTR_MAX, &pDir->puszFilter, cucFilter0, &pDir->cucFilter);
-        AssertRC(rc);
+        int rc2 = RTStrToUniEx(pszFilter, RTSTR_MAX, &pDir->puszFilter, cucFilter0, &pDir->cucFilter);
+        AssertRC(rc2);
         pb += cucFilter0 * sizeof(RTUNICP);
         pDir->pszFilter = (char *)memcpy(pb, pszFilter, cbFilter);
@@ -629,7 +627,9 @@
             break;
     }
-    pDir->cchPath       = cchRealPath;
-    pDir->pszPath       = (char *)memcpy(pb, szRealPath, cchRealPath + 1);
-    Assert(pb - (uint8_t *)pDir + cchRealPath + 1 <= cbAllocated);
+    pDir->cchPath       = cchAbsPath + cchAbsPathExtra;
+    pDir->pszPath       = (char *)memcpy(pb, pszAbsPath, cchAbsPath);
+    pb[cchAbsPath]                   = RTPATH_SLASH;
+    pb[cchAbsPath + cchAbsPathExtra] = '\0';
+    Assert(pb - (uint8_t *)pDir + cchAbsPath + cchAbsPathExtra + 1 <= cbAllocated);
     pDir->pszName       = NULL;
     pDir->cchName       = 0;
@@ -641,10 +641,10 @@
      * Hand it over to the native part.
      */
-    rc = rtDirNativeOpen(pDir, szRealPath, hRelativeDir, pvNativeRelative);
+    int rc = rtDirNativeOpen(pDir, hRelativeDir, pvNativeRelative);
     if (RT_SUCCESS(rc))
         *phDir = pDir;
     else
         RTMemFree(pDir);
-
+    RTStrFree(pszAbsPath);
     return rc;
 }
Index: /trunk/src/VBox/Runtime/r3/nt/direnum-r3-nt.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/nt/direnum-r3-nt.cpp	(revision 78049)
+++ /trunk/src/VBox/Runtime/r3/nt/direnum-r3-nt.cpp	(revision 78050)
@@ -83,5 +83,5 @@
 
 
-int rtDirNativeOpen(PRTDIRINTERNAL pDir, char *pszPathBuf, uintptr_t hRelativeDir, void *pvNativeRelative)
+int rtDirNativeOpen(PRTDIRINTERNAL pDir, uintptr_t hRelativeDir, void *pvNativeRelative)
 {
     /*
@@ -130,5 +130,5 @@
         {
             if (pvNativeRelative == NULL)
-                rc = RTNtPathOpenDir(pszPathBuf,
+                rc = RTNtPathOpenDir(pDir->pszPath,
                                      FILE_LIST_DIRECTORY | FILE_READ_ATTRIBUTES | FILE_TRAVERSE | SYNCHRONIZE,
                                      FILE_SHARE_READ | FILE_SHARE_WRITE,
Index: /trunk/src/VBox/Runtime/r3/posix/dir-posix.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/posix/dir-posix.cpp	(revision 78049)
+++ /trunk/src/VBox/Runtime/r3/posix/dir-posix.cpp	(revision 78050)
@@ -242,7 +242,6 @@
 
 
-int rtDirNativeOpen(PRTDIRINTERNAL pDir, char *pszPathBuf, uintptr_t hRelativeDir, void *pvNativeRelative)
-{
-    NOREF(pszPathBuf); /* only used on windows */
+int rtDirNativeOpen(PRTDIRINTERNAL pDir, uintptr_t hRelativeDir, void *pvNativeRelative)
+{
     NOREF(hRelativeDir);
     NOREF(pvNativeRelative);
Index: /trunk/src/VBox/Runtime/r3/win/direnum-win.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/win/direnum-win.cpp	(revision 78049)
+++ /trunk/src/VBox/Runtime/r3/win/direnum-win.cpp	(revision 78050)
@@ -51,5 +51,5 @@
 
 
-int rtDirNativeOpen(PRTDIRINTERNAL pDir, char *pszPathBuf, uintptr_t hRelativeDir, void *pvNativeRelative))
+int rtDirNativeOpen(PRTDIRINTERNAL pDir, uintptr_t hRelativeDir, void *pvNativeRelative))
 {
     RT_NOREF(hRelativeDir, pvNativeRelative);
@@ -62,4 +62,5 @@
      * it when adding the wildcard expression.
      */
+/** @todo the pszPathBuf argument was removed in order to support paths longer than RTPATH_MAX.  Rewrite this code. */
     size_t cbExpr;
     const char *pszExpr;
