VBoxGuestR3LibAdditions.cpp revision e6660f4933111b0649ffa77483102881f4e75c3b
/* $Id$ */
/** @file
* VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, Additions Info.
*/
/*
* Copyright (C) 2007-2010 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "VBGLR3Internal.h"
/**
* Fallback for vbglR3GetAdditionsVersion.
*/
{
if (ppszVer)
{
if (!*ppszVer)
return VERR_NO_STR_MEMORY;
}
if (ppszRev)
{
char szRev[64];
if (!*ppszRev)
{
if (ppszVer)
{
}
return VERR_NO_STR_MEMORY;
}
}
return VINF_SUCCESS;
}
#ifdef RT_OS_WINDOWS
/**
* 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().
*/
{
/*
* 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 RTErrConvertFromWin32(r);
}
/**
* Closes the storage path handle (registry).
*
* @returns IPRT status value
* @param hKey Handle to close, retrieved by
* vbglR3GetAdditionsWinStoragePath().
*/
{
}
#endif /* RT_OS_WINDOWS */
/**
*
* @returns IPRT status value
* @param ppszVer Receives pointer of allocated version string. NULL is
* accepted. The returned pointer must be freed using
* RTStrFree().
* @param ppszRev Receives pointer of allocated revision string. NULL is
* accepted. The returned pointer must be freed using
* RTStrFree().
*/
{
#ifdef RT_OS_WINDOWS
if (RT_SUCCESS(rc))
{
/* Version. */
LONG l;
char *pszTmp;
if (ppszVer)
{
if (pszTmp)
{
if (l == ERROR_SUCCESS)
{
else
}
else
{
rc = RTErrConvertFromWin32(l);
}
}
else
rc = VERR_NO_MEMORY;
}
/* Revision. */
if (ppszRev)
{
if (pszTmp)
{
if (l == ERROR_SUCCESS)
{
else
}
else
{
rc = RTErrConvertFromWin32(l);
}
}
else
rc = VERR_NO_MEMORY;
{
}
}
}
else
{
/*
* No registry entries found, return the version string compiled
* into this binary.
*/
}
return rc;
#else /* !RT_OS_WINDOWS */
/*
* On non-Windows platforms just return the compile-time version string.
*/
#endif /* !RT_OS_WINDOWS */
}
/**
* 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().
*/
{
int rc;
#ifdef RT_OS_WINDOWS
if (RT_SUCCESS(rc))
{
/* Installation directory. */
if (pszTmp)
{
if ((l != ERROR_SUCCESS) && (l != ERROR_FILE_NOT_FOUND))
{
rc = RTErrConvertFromNtStatus(l);
}
else
{
else
if (RT_SUCCESS(rc))
{
/* Flip slashes. */
if (*pszTmp2 == '\\')
*pszTmp2 = '/';
}
}
}
else
rc = VERR_NO_MEMORY;
}
#else
/** @todo implement me */
#endif
return rc;
}