Index: /trunk/include/VBox/VBoxGuestLib.h
===================================================================
--- /trunk/include/VBox/VBoxGuestLib.h	(revision 24685)
+++ /trunk/include/VBox/VBoxGuestLib.h	(revision 24686)
@@ -417,4 +417,5 @@
 VBGLR3DECL(int)     VbglR3WaitEvent(uint32_t fMask, uint32_t cMillies, uint32_t *pfEvents);
 VBGLR3DECL(int)     VbglR3GetAdditionsVersion(char **ppszVer, char **ppszRev);
+VBGLR3DECL(int)     VbglR3GetAdditionsInstallationPath(char **ppszPath);
 /** @} */
 
Index: /trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibMisc.cpp
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibMisc.cpp	(revision 24685)
+++ /trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibMisc.cpp	(revision 24686)
@@ -226,4 +226,58 @@
 
 /**
+ * Looks up the storage path handle (registry).
+ *
+ * @returns IPRT status value
+ * @param   hKey        Receives pointer of allocated version string. NULL is
+ *                      accepted. The returned pointer must be closed by
+ *                      vbglR3CloseAdditionsWinStoragePath().
+ */
+static int vbglR3GetAdditionsWinStoragePath(PHKEY phKey)
+{
+    /*
+     * Try get the *installed* version first.
+     */
+    LONG r;
+
+    /* Check the new path first. */
+    r = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Sun\\VirtualBox Guest Additions", 0, KEY_READ, phKey);
+# ifdef RT_ARCH_AMD64
+    if (r != ERROR_SUCCESS)
+    {
+        /* Check Wow6432Node (for new entries). */
+        r = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wow6432Node\\Sun\\VirtualBox Guest Additions", 0, KEY_READ, phKey);
+    }
+# endif
+
+    /* Still no luck? Then try the old xVM paths ... */
+    if (r != ERROR_SUCCESS)
+    {
+        r = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Sun\\xVM VirtualBox Guest Additions", 0, KEY_READ, phKey);
+# ifdef RT_ARCH_AMD64
+        if (r != ERROR_SUCCESS)
+        {
+            /* Check Wow6432Node (for new entries). */
+            r = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wow6432Node\\Sun\\xVM VirtualBox Guest Additions", 0, KEY_READ, phKey);
+        }
+# endif
+    }
+    return RTErrConvertFromNtStatus(r);
+}
+
+
+/**
+ * Closes the storage path handle (registry).
+ *
+ * @returns IPRT status value
+ * @param   hKey        Handle to close, retrieved by
+ *                      vbglR3GetAdditionsWinStoragePath().
+ */
+static int vbglR3CloseAdditionsWinStoragePath(HKEY hKey)
+{
+    return RTErrConvertFromNtStatus(RegCloseKey(hKey));
+}
+
+
+/**
  * Retrieves the installed Guest Additions version and/or revision.
  *
@@ -239,38 +293,10 @@
 {
 #ifdef RT_OS_WINDOWS
-    /*
-     * Try get the *installed* version first.
-     */
-    HKEY hKey = NULL;
-    LONG r;
-
-    /* Check the new path first. */
-    r = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Sun\\VirtualBox Guest Additions", 0, KEY_READ, &hKey);
-# ifdef RT_ARCH_AMD64
-    if (r != ERROR_SUCCESS)
-    {
-        /* Check Wow6432Node (for new entries). */
-        r = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wow6432Node\\Sun\\VirtualBox Guest Additions", 0, KEY_READ, &hKey);
-    }
-# endif
-
-    /* Still no luck? Then try the old xVM paths ... */
-    if (r != ERROR_SUCCESS)
-    {
-        r = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Sun\\xVM VirtualBox Guest Additions", 0, KEY_READ, &hKey);
-# ifdef RT_ARCH_AMD64
-        if (r != ERROR_SUCCESS)
-        {
-            /* Check Wow6432Node (for new entries). */
-            r = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wow6432Node\\Sun\\xVM VirtualBox Guest Additions", 0, KEY_READ, &hKey);
-        }
-# endif
-    }
-
-    /* Did we get something worth looking at? */
-    int rc = VINF_SUCCESS;
-    if (r == ERROR_SUCCESS)
+    HKEY hKey;
+    int rc = vbglR3GetAdditionsWinStoragePath(&hKey);
+    if (RT_SUCCESS(rc))
     {
         /* Version. */
+        LONG l;
         DWORD dwType;
         DWORD dwSize = 32;
@@ -281,6 +307,6 @@
             if (pszTmp)
             {
-                r = RegQueryValueEx(hKey, "Version", NULL, &dwType, (BYTE*)(LPCTSTR)pszTmp, &dwSize);
-                if (r == ERROR_SUCCESS)
+                l = RegQueryValueEx(hKey, "Version", NULL, &dwType, (BYTE*)(LPCTSTR)pszTmp, &dwSize);
+                if (l == ERROR_SUCCESS)
                 {
                     if (dwType == REG_SZ)
@@ -291,5 +317,5 @@
                 else
                 {
-                    rc = RTErrConvertFromNtStatus(r);
+                    rc = RTErrConvertFromNtStatus(l);
                 }
                 RTMemFree(pszTmp);
@@ -305,6 +331,6 @@
             if (pszTmp)
             {
-                r = RegQueryValueEx(hKey, "Revision", NULL, &dwType, (BYTE*)(LPCTSTR)pszTmp, &dwSize);
-                if (r == ERROR_SUCCESS)
+                l = RegQueryValueEx(hKey, "Revision", NULL, &dwType, (BYTE*)(LPCTSTR)pszTmp, &dwSize);
+                if (l == ERROR_SUCCESS)
                 {
                     if (dwType == REG_SZ)
@@ -315,5 +341,5 @@
                 else
                 {
-                    rc = RTErrConvertFromNtStatus(r);
+                    rc = RTErrConvertFromNtStatus(l);
                 }
                 RTMemFree(pszTmp);
@@ -328,6 +354,5 @@
             }
         }
-        if (hKey != NULL)
-            RegCloseKey(hKey);
+        rc = vbglR3CloseAdditionsWinStoragePath(hKey);
     }
     else
@@ -349,2 +374,56 @@
 }
 
+
+/**
+ * Retrieves the installation path of Guest Additions.
+ *
+ * @returns IPRT status value
+ * @param   ppszPath    Receives pointer of allocated installation path string.
+ *                      The returned pointer must be freed using
+ *                      RTStrFree().
+ */
+VBGLR3DECL(int) VbglR3GetAdditionsInstallationPath(char **ppszPath)
+{
+    int rc;
+#ifdef RT_OS_WINDOWS
+    HKEY hKey;
+    rc = vbglR3GetAdditionsWinStoragePath(&hKey);
+    if (RT_SUCCESS(rc))
+    {
+        /* Installation directory. */
+        DWORD dwType;
+        DWORD dwSize = _MAX_PATH * sizeof(char);
+        char *pszTmp = (char*)RTMemAlloc(dwSize + 1);
+        if (pszTmp)
+        {
+            LONG l = RegQueryValueEx(hKey, "InstallDir", NULL, &dwType, (BYTE*)(LPCTSTR)pszTmp, &dwSize);
+            if ((l != ERROR_SUCCESS) && (l != ERROR_FILE_NOT_FOUND))
+            {
+                rc = RTErrConvertFromNtStatus(l);
+            }
+            else
+            {
+                if (dwType == REG_SZ)
+                    rc = RTStrDupEx(ppszPath, pszTmp);
+                else
+                    rc = VERR_INVALID_PARAMETER;
+                if (RT_SUCCESS(rc))
+                {
+                    /* Flip slashes. */
+                    for (char* pszTmp2 = ppszPath[0]; ppszPath; ++ppszPath)
+                        if (*pszTmp2 == '\\')
+                            *pszTmp2 = '/';
+                }
+            }
+            RTMemFree(pszTmp);
+        }
+        else
+            rc = VERR_NO_MEMORY;
+        rc = vbglR3CloseAdditionsWinStoragePath(hKey);
+    }
+#else
+    /** @todo implement me */
+    rc = VINF_NOT_IMPLEMENTED;
+#endif
+    return rc;
+}
Index: /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo-win.cpp
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo-win.cpp	(revision 24685)
+++ /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo-win.cpp	(revision 24686)
@@ -329,85 +329,4 @@
 
 #endif /* TARGET_NT4 */
-
-int VBoxServiceWinGetAddsVersion(uint32_t uiClientID)
-{
-    char szInstDir[_MAX_PATH] = {0};
-    char szRev[_MAX_PATH] = {0};
-    char szVer[_MAX_PATH] = {0};
-
-    HKEY hKey = NULL;
-    int rc;
-    DWORD dwSize = 0;
-    DWORD dwType = 0;
-
-    VBoxServiceVerbose(3, "Guest Additions version lookup: Looking up ...\n");
-
-    /* Check the new path first. */
-    rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Sun\\VirtualBox Guest Additions", 0, KEY_READ, &hKey);
-#ifdef RT_ARCH_AMD64
-    if (rc != ERROR_SUCCESS)
-    {
-        /* Check Wow6432Node (for new entries). */
-        rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wow6432Node\\Sun\\VirtualBox Guest Additions", 0, KEY_READ, &hKey);
-    }
-#endif
-
-    /* Still no luck? Then try the old xVM paths ... */
-    if (RT_FAILURE(rc))
-    {
-        rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Sun\\xVM VirtualBox Guest Additions", 0, KEY_READ, &hKey);
-#ifdef RT_ARCH_AMD64
-        if (rc != ERROR_SUCCESS)
-        {
-            /* Check Wow6432Node (for new entries). */
-            rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wow6432Node\\Sun\\xVM VirtualBox Guest Additions", 0, KEY_READ, &hKey);
-        }
-#endif
-    }
-
-    /* Did we get something worth looking at? */
-    if (RT_FAILURE(rc))
-    {
-        VBoxServiceError("Failed to open registry key (guest additions)! Error: %Rrc\n", rc);
-    }
-    else
-    {
-        VBoxServiceVerbose(3, "Guest Additions version lookup: Key: 0x%p, rc: %Rrc\n", hKey, rc);
-        /* Installation directory. */
-        dwSize = sizeof(szInstDir);
-        rc = RegQueryValueEx(hKey, "InstallDir", NULL, &dwType, (BYTE*)(LPCTSTR)szInstDir, &dwSize);
-        if ((rc != ERROR_SUCCESS) && (rc != ERROR_FILE_NOT_FOUND))
-        {
-            VBoxServiceError("Failed to query registry key (install directory)! Error: %Rrc\n", rc);
-        }
-        else
-        {
-            /* Flip slashes. */
-            for (char* pszTmp = &szInstDir[0]; *pszTmp; ++pszTmp)
-                if (*pszTmp == '\\')
-                    *pszTmp = '/';
-        }
-        /* Revision. */
-        dwSize = sizeof(szRev);
-        rc = RegQueryValueEx(hKey, "Revision", NULL, &dwType, (BYTE*)(LPCTSTR)szRev, &dwSize);
-        if ((rc != ERROR_SUCCESS) && (rc != ERROR_FILE_NOT_FOUND))
-            VBoxServiceError("Failed to query registry key (revision)! Error: %Rrc\n", rc);
-        /* Version. */
-        dwSize = sizeof(szVer);
-        rc = RegQueryValueEx(hKey, "Version", NULL, &dwType, (BYTE*)(LPCTSTR)szVer, &dwSize);
-        if ((rc != ERROR_SUCCESS) && (rc != ERROR_FILE_NOT_FOUND))
-            VBoxServiceError("Failed to query registry key (version)! Error: %Rrc\n", rc);
-    }
-
-    /* Write information to host. */
-    rc = VBoxServiceWritePropF(uiClientID, "/VirtualBox/GuestAdd/InstallDir", "%s", szInstDir);
-    rc = VBoxServiceWritePropF(uiClientID, "/VirtualBox/GuestAdd/Revision", "%s", szRev);
-    rc = VBoxServiceWritePropF(uiClientID, "/VirtualBox/GuestAdd/Version", "%s", szVer);
-
-    if (NULL != hKey)
-        RegCloseKey(hKey);
-
-    return rc;
-}
 
 int VBoxServiceWinGetComponentVersions(uint32_t uiClientID)
Index: /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp	(revision 24685)
+++ /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp	(revision 24686)
@@ -73,5 +73,4 @@
 fnWTSGetActiveConsoleSessionId g_pfnWTSGetActiveConsoleSessionId = NULL;
 /** External functions. */
-extern int VBoxServiceWinGetAddsVersion(uint32_t uiClientID);
 extern int VBoxServiceWinGetComponentVersions(uint32_t uiClientID);
 #endif
@@ -171,14 +170,24 @@
 
     /* Retrieve version information about Guest Additions and installed files (components). */
-#ifdef RT_OS_WINDOWS
-    rc = VBoxServiceWinGetAddsVersion(g_VMInfoGuestPropSvcClientID);
+    char *pszAddVer, *pszAddRev;
+    rc = VbglR3GetAdditionsVersion(&pszAddVer, &pszAddRev);
+    if (RT_SUCCESS(rc))
+    {
+        /* Write information to host. */
+        rc = VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestAdd/Revision", "%s", pszAddVer);
+        rc = VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestAdd/Version", "%s", pszAddRev);
+        RTStrFree(pszAddVer);
+        RTStrFree(pszAddRev);
+    }
+
+#ifdef RT_OS_WINDOWS
+    char *pszInstDir;
+    rc = VbglR3GetAdditionsInstallationPath(&pszInstDir);
+    if (RT_SUCCESS(rc))
+    {
+        rc = VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestAdd/InstallDir", "%s", pszInstDir);
+        RTStrFree(pszInstDir);
+    }
     rc = VBoxServiceWinGetComponentVersions(g_VMInfoGuestPropSvcClientID);
-#else
-    /* VBoxServiceGetAddsVersion !RT_OS_WINDOWS */
-    VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestAdd/Version", "%s", VBOX_VERSION_STRING);
-
-    char szRevision[32];
-    RTStrPrintf(szRevision, sizeof(szRevision), "%u", VBOX_SVN_REV);
-    VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestAdd/Revision", "%s", szRevision);
 #endif
 
