RTSystemQueryOSInfo-win.cpp revision 2ebdf3d2131d683bde27a65eeef2450d8834fec9
/* $Id$ */
/** @file
* IPRT - RTSystemQueryOSInfo, generic stub.
*/
/*
* Copyright (C) 2008-2011 Oracle Corporation
*
* 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.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <Windows.h>
#include <WinUser.h>
#include "internal-r3-win.h"
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* These are the PRODUCT_* defines found in the Vista Platform SDK and returned
* by GetProductInfo().
*
* We define them ourselves because we don't necessarily have any Vista PSDK around.
*/
typedef enum RTWINPRODTYPE
{
kRTWinProdType_DATACENTER_SERVER_CORE = 0x0000000C, ///< Server Datacenter Edition (core installation)
kRTWinProdType_ENTERPRISE_SERVER_CORE = 0x0000000E, ///< Server Enterprise Edition (core installation)
kRTWinProdType_ENTERPRISE_SERVER_IA64 = 0x0000000F, ///< Server Enterprise Edition for Itanium-based Systems
kRTWinProdType_SMALLBUSINESS_SERVER_PREMIUM = 0x00000019, ///< Small Business Server Premium Edition
/**
* Wrapper around the GetProductInfo API.
*
* @returns The vista type.
*/
static RTWINPRODTYPE rtSystemWinGetProductInfo(DWORD dwOSMajorVersion, DWORD dwOSMinorVersion, DWORD dwSpMajorVersion, DWORD dwSpMinorVersion)
{
pfnGetProductInfo = (BOOL (WINAPI *)(DWORD, DWORD, DWORD, DWORD, PDWORD))GetProcAddress(GetModuleHandle("kernel32.dll"), "GetProductInfo");
if (pfnGetProductInfo)
{
if (pfnGetProductInfo(dwOSMajorVersion, dwOSMinorVersion, dwSpMajorVersion, dwSpMinorVersion, &dwProductType))
return (RTWINPRODTYPE)dwProductType;
}
return kRTWinProdType_UNDEFINED;
}
/**
* Appends the product type if available.
*
* @param pszTmp The buffer. Assumes it's big enough.
*/
static void rtSystemWinAppendProductType(char *pszTmp)
{
switch (enmVistaType)
{
case kRTWinProdType_DATACENTER_SERVER: strcat(pszTmp, " Server Datacenter Edition (full installation)"); break;
case kRTWinProdType_DATACENTER_SERVER_CORE: strcat(pszTmp, " Server Datacenter Edition (core installation)"); break;
case kRTWinProdType_ENTERPRISE_SERVER: strcat(pszTmp, " Server Enterprise Edition (full installation)"); break;
case kRTWinProdType_ENTERPRISE_SERVER_CORE: strcat(pszTmp, " Server Enterprise Edition (core installation)"); break;
case kRTWinProdType_ENTERPRISE_SERVER_IA64: strcat(pszTmp, " Server Enterprise Edition for Itanium-based Systems"); break;
case kRTWinProdType_SERVER_FOR_SMALLBUSINESS: strcat(pszTmp, " Server for Small Business Edition"); break;
case kRTWinProdType_SMALLBUSINESS_SERVER_PREMIUM: strcat(pszTmp, " Small Business Server Premium Edition"); break;
case kRTWinProdType_STANDARD_SERVER: strcat(pszTmp, " Server Standard Edition (full installation)"); break;
case kRTWinProdType_STANDARD_SERVER_CORE: strcat(pszTmp, " Server Standard Edition (core installation)"); break;
case kRTWinProdType_STORAGE_ENTERPRISE_SERVER: strcat(pszTmp, " Storage Server Enterprise Edition"); break;
case kRTWinProdType_STORAGE_EXPRESS_SERVER: strcat(pszTmp, " Storage Server Express Edition"); break;
case kRTWinProdType_STORAGE_STANDARD_SERVER: strcat(pszTmp, " Storage Server Standard Edition"); break;
case kRTWinProdType_STORAGE_WORKGROUP_SERVER: strcat(pszTmp, " Storage Server Workgroup Edition"); break;
case kRTWinProdType_WEB_SERVER_CORE: strcat(pszTmp, " Web Server Edition (core installation)"); break;
case kRTWinProdType_UNDEFINED: break;
}
}
/**
* Services the RTSYSOSINFO_PRODUCT, RTSYSOSINFO_RELEASE
* and RTSYSOSINFO_SERVICE_PACK requests.
*
* @returns See RTSystemQueryOSInfo.
* @param enmInfo See RTSystemQueryOSInfo.
* @param pszInfo See RTSystemQueryOSInfo.
* @param cchInfo See RTSystemQueryOSInfo.
*/
{
/*
* Make sure it's terminated correctly in case of error.
*/
*pszInfo = '\0';
/*
* Check that we got the windows version at init time.
*/
/*
* Service the request.
*/
char szTmp[512];
szTmp[0] = '\0';
switch (enmInfo)
{
/*
* The product name.
*/
case RTSYSOSINFO_PRODUCT:
{
switch (g_enmWinVer)
{
case kRTWinOSType_XP:
#if 0 /** @todo fixme */
#endif
break;
case kRTWinOSType_VISTA:
{
break;
}
case kRTWinOSType_NT_UNKNOWN:
break;
default:
AssertFailed();
case kRTWinOSType_UNKNOWN:
break;
}
break;
}
/*
* The release.
*/
case RTSYSOSINFO_RELEASE:
{
break;
}
/*
* Get the service pack.
*/
case RTSYSOSINFO_SERVICE_PACK:
{
{
else
(unsigned)g_WinOsInfoEx.wServicePackMajor);
}
else if (g_WinOsInfoEx.szCSDVersion[0])
{
/* just copy the entire string. */
}
else
{
switch (g_enmWinVer)
{
default:
break;
}
}
break;
}
default:
}
/*
* Copy the result to the return buffer.
*/
{
return VINF_SUCCESS;
}
return VERR_BUFFER_OVERFLOW;
}
{
/*
* Quick validation.
*/
if (!cchInfo)
return VERR_BUFFER_OVERFLOW;
/*
* Handle the request.
*/
switch (enmInfo)
{
case RTSYSOSINFO_PRODUCT:
case RTSYSOSINFO_RELEASE:
case RTSYSOSINFO_SERVICE_PACK:
case RTSYSOSINFO_VERSION:
default:
*pszInfo = '\0';
}
return VERR_NOT_SUPPORTED;
}