2005-01-20 23:22:22 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
2002-06-06 18:50:12 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation;
|
|
|
|
// either version 2.1 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This software is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
|
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2002-06-06 18:50:12 +00:00
|
|
|
|
2004-06-16 23:29:48 +00:00
|
|
|
#include "boinc_win.h"
|
2006-05-16 20:43:11 +00:00
|
|
|
#define COMPILE_MULTIMON_STUBS
|
|
|
|
#include <multimon.h>
|
2004-06-16 23:29:48 +00:00
|
|
|
|
2002-06-06 18:50:12 +00:00
|
|
|
#include "client_types.h"
|
2003-06-19 18:19:35 +00:00
|
|
|
#include "filesys.h"
|
2007-02-21 17:06:11 +00:00
|
|
|
#include "str_util.h"
|
2005-01-07 07:32:23 +00:00
|
|
|
#include "client_msgs.h"
|
2004-06-16 19:21:11 +00:00
|
|
|
#include "hostinfo_network.h"
|
|
|
|
#include "hostinfo.h"
|
2002-06-06 18:50:12 +00:00
|
|
|
|
2006-01-23 08:47:05 +00:00
|
|
|
HINSTANCE g_hClientLibraryDll;
|
2004-06-29 23:31:51 +00:00
|
|
|
|
2006-05-16 20:43:11 +00:00
|
|
|
|
2006-11-20 08:20:29 +00:00
|
|
|
// Newer system metrics values
|
|
|
|
#ifndef SM_SERVERR2
|
|
|
|
#define SM_SERVERR2 89
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2006-05-17 22:29:37 +00:00
|
|
|
// Newer processor features than what is currently defined in
|
|
|
|
// Visual Studio 2003
|
|
|
|
#ifndef PF_SSE_DAZ_MODE_AVAILABLE
|
|
|
|
#define PF_SSE_DAZ_MODE_AVAILABLE 11
|
|
|
|
#endif
|
|
|
|
#ifndef PF_NX_ENABLED
|
|
|
|
#define PF_NX_ENABLED 12
|
|
|
|
#endif
|
|
|
|
#ifndef PF_SSE3_INSTRUCTIONS_AVAILABLE
|
|
|
|
#define PF_SSE3_INSTRUCTIONS_AVAILABLE 13
|
|
|
|
#endif
|
|
|
|
#ifndef PF_COMPARE_EXCHANGE128
|
|
|
|
#define PF_COMPARE_EXCHANGE128 14
|
|
|
|
#endif
|
|
|
|
#ifndef PF_COMPARE64_EXCHANGE128
|
|
|
|
#define PF_COMPARE64_EXCHANGE128 15
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2005-11-07 11:12:51 +00:00
|
|
|
// Memory Status Structure for Win2K and WinXP based systems.
|
|
|
|
typedef struct _MYMEMORYSTATUSEX {
|
|
|
|
DWORD dwLength;
|
|
|
|
DWORD dwMemoryLoad;
|
|
|
|
DWORDLONG ullTotalPhys;
|
|
|
|
DWORDLONG ullAvailPhys;
|
|
|
|
DWORDLONG ullTotalPageFile;
|
|
|
|
DWORDLONG ullAvailPageFile;
|
|
|
|
DWORDLONG ullTotalVirtual;
|
|
|
|
DWORDLONG ullAvailVirtual;
|
|
|
|
DWORDLONG ullAvailExtendedVirtual;
|
|
|
|
} MYMEMORYSTATUSEX, *LPMYMEMORYSTATUSEX;
|
|
|
|
|
|
|
|
typedef BOOL (WINAPI *MYGLOBALMEMORYSTATUSEX)(LPMYMEMORYSTATUSEX lpBuffer);
|
|
|
|
|
|
|
|
|
2006-05-16 20:43:11 +00:00
|
|
|
// Traverse the video adapters and flag them as potiential accelerators.
|
|
|
|
struct INTERNALMONITORINFO
|
|
|
|
{
|
|
|
|
DWORD cb;
|
|
|
|
TCHAR DeviceName[32];
|
|
|
|
TCHAR DeviceString[128];
|
|
|
|
DWORD StateFlags;
|
|
|
|
TCHAR DeviceID[128];
|
|
|
|
TCHAR DeviceKey[128];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-12-09 23:52:17 +00:00
|
|
|
// Returns the number of seconds difference from UTC
|
|
|
|
//
|
2006-05-17 22:29:37 +00:00
|
|
|
int get_timezone(int& timezone) {
|
|
|
|
|
|
|
|
TIME_ZONE_INFORMATION tzi;
|
|
|
|
|
|
|
|
memset(&tzi, '\0', sizeof(TIME_ZONE_INFORMATION));
|
|
|
|
|
|
|
|
GetTimeZoneInformation(&tzi);
|
|
|
|
|
|
|
|
timezone = -(tzi.Bias * 60);
|
|
|
|
|
|
|
|
return 0;
|
2002-12-09 23:52:17 +00:00
|
|
|
}
|
|
|
|
|
2006-05-17 22:29:37 +00:00
|
|
|
|
|
|
|
// Returns the memory information
|
2002-07-15 23:21:20 +00:00
|
|
|
//
|
2006-05-17 22:29:37 +00:00
|
|
|
int get_memory_info(double& bytes, double& swap) {
|
|
|
|
HMODULE hKernel32Lib;
|
2006-11-10 18:21:05 +00:00
|
|
|
MYGLOBALMEMORYSTATUSEX myGlobalMemoryStatusEx=0;
|
2006-05-17 22:29:37 +00:00
|
|
|
hKernel32Lib = GetModuleHandle("kernel32.dll");
|
|
|
|
if (hKernel32Lib) {
|
|
|
|
myGlobalMemoryStatusEx = (MYGLOBALMEMORYSTATUSEX) GetProcAddress(hKernel32Lib, "GlobalMemoryStatusEx");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hKernel32Lib && myGlobalMemoryStatusEx) {
|
|
|
|
MYMEMORYSTATUSEX mStatusEx;
|
|
|
|
ZeroMemory(&mStatusEx, sizeof(MYMEMORYSTATUSEX));
|
|
|
|
mStatusEx.dwLength = sizeof(MYMEMORYSTATUSEX);
|
|
|
|
(*myGlobalMemoryStatusEx)(&mStatusEx);
|
|
|
|
bytes = (double)mStatusEx.ullTotalPhys;
|
|
|
|
swap = (double)mStatusEx.ullTotalPageFile;
|
|
|
|
} else {
|
|
|
|
MEMORYSTATUS mStatus;
|
|
|
|
ZeroMemory(&mStatus, sizeof(MEMORYSTATUS));
|
|
|
|
mStatus.dwLength = sizeof(MEMORYSTATUS);
|
|
|
|
GlobalMemoryStatus(&mStatus);
|
|
|
|
bytes = (double)mStatus.dwTotalPhys;
|
|
|
|
swap = (double)mStatus.dwTotalPageFile;
|
|
|
|
}
|
2004-03-02 09:46:18 +00:00
|
|
|
|
2006-05-17 22:29:37 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2004-05-05 00:41:32 +00:00
|
|
|
|
2006-05-17 22:29:37 +00:00
|
|
|
|
|
|
|
// Returns the OS name and version
|
|
|
|
//
|
2006-11-20 08:20:29 +00:00
|
|
|
|
|
|
|
typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
|
|
|
|
|
2006-05-17 22:29:37 +00:00
|
|
|
int get_os_information(
|
2006-11-10 18:21:05 +00:00
|
|
|
char* os_name, int /*os_name_size*/, char* os_version, int os_version_size
|
2006-05-17 22:29:37 +00:00
|
|
|
)
|
|
|
|
{
|
2004-03-02 09:46:18 +00:00
|
|
|
// This code snip-it was copied straight out of the MSDN Platform SDK
|
|
|
|
// Getting the System Version example and modified to dump the output
|
2004-03-31 19:53:31 +00:00
|
|
|
// into os_name.
|
2006-11-20 08:20:29 +00:00
|
|
|
char szVersion[128];
|
|
|
|
char szSKU[128];
|
|
|
|
char szServicePack[128];
|
2004-03-02 09:46:18 +00:00
|
|
|
OSVERSIONINFOEX osvi;
|
2006-11-20 08:20:29 +00:00
|
|
|
SYSTEM_INFO si;
|
|
|
|
PGNSI pGNSI;
|
2004-03-02 09:46:18 +00:00
|
|
|
BOOL bOsVersionInfoEx;
|
|
|
|
|
2006-11-20 08:20:29 +00:00
|
|
|
ZeroMemory(szVersion, sizeof(szVersion));
|
|
|
|
ZeroMemory(szSKU, sizeof(szSKU));
|
|
|
|
ZeroMemory(szServicePack, sizeof(szServicePack));
|
|
|
|
ZeroMemory(&si, sizeof(SYSTEM_INFO));
|
2004-03-02 09:46:18 +00:00
|
|
|
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
|
|
|
|
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
|
|
|
|
2006-11-20 08:20:29 +00:00
|
|
|
|
|
|
|
// Try calling GetVersionEx using the OSVERSIONINFOEX structure.
|
|
|
|
// If that fails, try using the OSVERSIONINFO structure.
|
2006-11-10 18:21:05 +00:00
|
|
|
bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi);
|
|
|
|
if(!bOsVersionInfoEx) {
|
2004-03-02 09:46:18 +00:00
|
|
|
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
|
|
|
|
GetVersionEx ( (OSVERSIONINFO *) &osvi );
|
2002-06-06 18:50:12 +00:00
|
|
|
}
|
|
|
|
|
2006-11-20 08:20:29 +00:00
|
|
|
|
|
|
|
// Call GetNativeSystemInfo if supported or GetSystemInfo otherwise.
|
|
|
|
pGNSI = (PGNSI) GetProcAddress(GetModuleHandle(_T("kernel32.dll")), "GetNativeSystemInfo");
|
|
|
|
if(NULL != pGNSI) {
|
|
|
|
pGNSI(&si);
|
|
|
|
} else {
|
|
|
|
GetSystemInfo(&si);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-02 09:46:18 +00:00
|
|
|
switch (osvi.dwPlatformId)
|
|
|
|
{
|
|
|
|
case VER_PLATFORM_WIN32_NT:
|
|
|
|
|
2006-11-20 08:20:29 +00:00
|
|
|
if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 )
|
|
|
|
{
|
|
|
|
if( osvi.wProductType == VER_NT_WORKSTATION ) {
|
|
|
|
strcpy(os_name, "Microsoft Windows Vista");
|
|
|
|
} else {
|
|
|
|
strcpy(os_name, "Microsoft Windows Server \"Longhorn\"");
|
|
|
|
}
|
|
|
|
}
|
2004-03-02 09:46:18 +00:00
|
|
|
|
|
|
|
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
|
2006-11-20 08:20:29 +00:00
|
|
|
{
|
|
|
|
if( GetSystemMetrics(SM_SERVERR2) ) {
|
|
|
|
strcpy(os_name, "Microsoft Windows Server 2003 \"R2\"");
|
|
|
|
} else if( osvi.wProductType == VER_NT_WORKSTATION && si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) {
|
|
|
|
strcpy(os_name, "Microsoft Windows XP Professional x64 Edition");
|
|
|
|
} else {
|
|
|
|
strcpy(os_name, "Microsoft Windows Server 2003");
|
|
|
|
}
|
|
|
|
}
|
2004-03-02 09:46:18 +00:00
|
|
|
|
|
|
|
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
|
2004-05-05 00:41:32 +00:00
|
|
|
strcpy(os_name, "Microsoft Windows XP" );
|
2004-03-02 09:46:18 +00:00
|
|
|
|
|
|
|
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
|
2004-05-05 00:41:32 +00:00
|
|
|
strcpy(os_name, "Microsoft Windows 2000" );
|
2004-03-02 09:46:18 +00:00
|
|
|
|
|
|
|
if ( osvi.dwMajorVersion <= 4 )
|
2004-05-05 00:41:32 +00:00
|
|
|
strcpy(os_name, "Microsoft Windows NT" );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VER_PLATFORM_WIN32_WINDOWS:
|
|
|
|
|
|
|
|
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
|
|
|
|
strcpy(os_name, "Microsoft Windows 95" );
|
|
|
|
|
|
|
|
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
|
|
|
|
strcpy( os_name, "Microsoft Windows 98" );
|
|
|
|
|
|
|
|
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
|
|
|
|
strcpy( os_name, "Microsoft Windows Millennium" );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VER_PLATFORM_WIN32s:
|
|
|
|
|
|
|
|
strcpy( os_name, "Microsoft Win32s" );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
snprintf( szVersion, sizeof(szVersion), ", (%.2u.%.2u.%.4u.%.2u)",
|
|
|
|
osvi.dwMajorVersion, osvi.dwMinorVersion, (osvi.dwBuildNumber & 0xFFFF), 0 );
|
|
|
|
|
|
|
|
|
|
|
|
switch (osvi.dwPlatformId)
|
|
|
|
{
|
|
|
|
// Test for the Windows NT product family.
|
|
|
|
case VER_PLATFORM_WIN32_NT:
|
2004-03-02 09:46:18 +00:00
|
|
|
|
|
|
|
// Test for specific product on Windows NT 4.0 SP6 and later.
|
2006-11-20 08:20:29 +00:00
|
|
|
if( bOsVersionInfoEx ) {
|
|
|
|
|
2004-03-02 09:46:18 +00:00
|
|
|
// Test for the workstation type.
|
2006-11-20 08:20:29 +00:00
|
|
|
if ( osvi.wProductType == VER_NT_WORKSTATION && si.wProcessorArchitecture != PROCESSOR_ARCHITECTURE_AMD64) {
|
|
|
|
if( osvi.dwMajorVersion == 4 ) {
|
2004-05-05 00:41:32 +00:00
|
|
|
strcpy( szSKU, "Workstation Edition" );
|
2006-11-20 08:20:29 +00:00
|
|
|
} else if( osvi.wSuiteMask & VER_SUITE_PERSONAL ) {
|
2004-05-05 00:41:32 +00:00
|
|
|
strcpy( szSKU, "Home Edition" );
|
2006-11-20 08:20:29 +00:00
|
|
|
} else {
|
2004-05-05 00:41:32 +00:00
|
|
|
strcpy( szSKU, "Professional Edition" );
|
2006-11-20 08:20:29 +00:00
|
|
|
}
|
2004-03-02 09:46:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Test for the server type.
|
2006-11-20 08:20:29 +00:00
|
|
|
else if ( (osvi.wProductType == VER_NT_SERVER) || (osvi.wProductType == VER_NT_DOMAIN_CONTROLLER) ) {
|
|
|
|
if( (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0) || (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) ) {
|
|
|
|
|
2007-04-03 13:14:30 +00:00
|
|
|
if ( si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64 ) {
|
2006-11-20 08:20:29 +00:00
|
|
|
if( osvi.wSuiteMask & VER_SUITE_DATACENTER ) {
|
|
|
|
strcpy( szSKU, "Datacenter Edition for Itanium-based Systems" );
|
|
|
|
} else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE ) {
|
|
|
|
strcpy( szSKU, "Enterprise Edition for Itanium-based Systems" );
|
|
|
|
}
|
2007-04-03 13:14:30 +00:00
|
|
|
} else if ( si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ) {
|
2006-11-20 08:20:29 +00:00
|
|
|
if( osvi.wSuiteMask & VER_SUITE_DATACENTER ) {
|
|
|
|
strcpy( szSKU, "Datacenter x64 Edition" );
|
|
|
|
} else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE ) {
|
|
|
|
strcpy( szSKU, "Enterprise x64 Edition" );
|
|
|
|
} else {
|
|
|
|
strcpy( szSKU, "Standard x64 Edition" );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if( osvi.wSuiteMask & VER_SUITE_DATACENTER ) {
|
|
|
|
strcpy( szSKU, "Datacenter Server Edition" );
|
|
|
|
} else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE ) {
|
|
|
|
strcpy( szSKU, "Enterprise Server Edition" );
|
|
|
|
} else if ( osvi.wSuiteMask == VER_SUITE_BLADE ) {
|
|
|
|
strcpy( szSKU, "Web Server Edition" );
|
|
|
|
} else {
|
|
|
|
strcpy( szSKU, "Standard Server Edition" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 ) {
|
|
|
|
|
|
|
|
if( osvi.wSuiteMask & VER_SUITE_DATACENTER ) {
|
2004-05-05 00:41:32 +00:00
|
|
|
strcpy( szSKU, "Datacenter Server Edition" );
|
2006-11-20 08:20:29 +00:00
|
|
|
} else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE ) {
|
2004-05-05 00:41:32 +00:00
|
|
|
strcpy( szSKU, "Advanced Server Edition" );
|
2006-11-20 08:20:29 +00:00
|
|
|
} else {
|
2004-05-05 00:41:32 +00:00
|
|
|
strcpy( szSKU, "Standard Server Edition" );
|
2006-11-20 08:20:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else { // Windows NT 4.0
|
|
|
|
if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE ) {
|
2004-05-05 00:41:32 +00:00
|
|
|
strcpy( szSKU, "Enterprise Server Edition" );
|
2006-11-20 08:20:29 +00:00
|
|
|
} else {
|
2004-05-05 00:41:32 +00:00
|
|
|
strcpy( szSKU, "Server Edition" );
|
2006-11-20 08:20:29 +00:00
|
|
|
}
|
2004-03-02 09:46:18 +00:00
|
|
|
}
|
|
|
|
}
|
2006-11-20 08:20:29 +00:00
|
|
|
|
|
|
|
} else { // Test for specific product on Windows NT 4.0 SP5 and earlier
|
|
|
|
|
2004-03-02 09:46:18 +00:00
|
|
|
HKEY hKey;
|
|
|
|
char szProductType[80];
|
|
|
|
DWORD dwBufLen=sizeof(szProductType);
|
|
|
|
LONG lRet;
|
|
|
|
|
|
|
|
lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
|
|
|
|
"SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
|
|
|
|
0, KEY_QUERY_VALUE, &hKey );
|
|
|
|
if( lRet != ERROR_SUCCESS )
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
lRet = RegQueryValueEx( hKey, "ProductType", NULL, NULL,
|
|
|
|
(LPBYTE) szProductType, &dwBufLen);
|
|
|
|
if( (lRet != ERROR_SUCCESS) || (dwBufLen > 80) )
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
RegCloseKey( hKey );
|
|
|
|
|
2006-11-20 08:20:29 +00:00
|
|
|
if ( lstrcmpi( "WINNT", szProductType) == 0 ) {
|
2004-05-05 00:41:32 +00:00
|
|
|
strcpy( szSKU, "Workstation Edition" );
|
2006-11-20 08:20:29 +00:00
|
|
|
} if ( lstrcmpi( "LANMANNT", szProductType) == 0 ) {
|
2004-05-05 00:41:32 +00:00
|
|
|
strcpy( szSKU, "Server Edition" );
|
2006-11-20 08:20:29 +00:00
|
|
|
} if ( lstrcmpi( "SERVERNT", szProductType) == 0 ) {
|
2004-05-05 00:41:32 +00:00
|
|
|
strcpy( szSKU, "Advanced Server Edition" );
|
2006-11-20 08:20:29 +00:00
|
|
|
}
|
2004-03-02 09:46:18 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Display service pack (if any) and build number.
|
2004-03-10 00:55:28 +00:00
|
|
|
if( osvi.dwMajorVersion == 4 && lstrcmpi( osvi.szCSDVersion, "Service Pack 6" ) == 0 )
|
2004-03-02 09:46:18 +00:00
|
|
|
{
|
|
|
|
HKEY hKey;
|
|
|
|
LONG lRet;
|
|
|
|
|
|
|
|
// Test for SP6 versus SP6a.
|
|
|
|
lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
|
|
|
|
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009",
|
|
|
|
0, KEY_QUERY_VALUE, &hKey );
|
2006-11-20 08:20:29 +00:00
|
|
|
|
|
|
|
if( lRet == ERROR_SUCCESS ) {
|
2004-05-05 00:41:32 +00:00
|
|
|
strcpy( szServicePack, ", " );
|
|
|
|
strcat( szServicePack, "Service Pack 6a" );
|
2006-11-20 08:20:29 +00:00
|
|
|
} else {// Windows NT 4.0 prior to SP6a
|
|
|
|
if ( strlen(osvi.szCSDVersion) > 0 ) {
|
2004-05-05 00:41:32 +00:00
|
|
|
strcpy( szServicePack, ", " );
|
|
|
|
strcat( szServicePack, osvi.szCSDVersion );
|
2004-03-02 09:46:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey( hKey );
|
2006-11-20 08:20:29 +00:00
|
|
|
|
|
|
|
} else { // Windows NT 3.51 and earlier or Windows 2000 and later
|
|
|
|
if ( strlen(osvi.szCSDVersion) > 0 ) {
|
2004-05-05 00:41:32 +00:00
|
|
|
strcpy( szServicePack, ", " );
|
|
|
|
strcat( szServicePack, osvi.szCSDVersion );
|
2004-03-02 09:46:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Test for the Windows 95 product family.
|
|
|
|
case VER_PLATFORM_WIN32_WINDOWS:
|
|
|
|
|
2006-11-20 08:20:29 +00:00
|
|
|
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0) {
|
2004-03-02 09:46:18 +00:00
|
|
|
if ( osvi.szCSDVersion[1] == 'C' || osvi.szCSDVersion[1] == 'B' )
|
2004-05-05 00:41:32 +00:00
|
|
|
strcpy( szServicePack, "OSR2" );
|
2004-03-02 09:46:18 +00:00
|
|
|
}
|
|
|
|
|
2006-11-20 08:20:29 +00:00
|
|
|
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10) {
|
2004-03-02 09:46:18 +00:00
|
|
|
if ( osvi.szCSDVersion[1] == 'A' )
|
2004-05-05 00:41:32 +00:00
|
|
|
strcpy( szServicePack, "SE" );
|
2004-03-02 09:46:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-05-17 22:29:37 +00:00
|
|
|
snprintf( os_version, os_version_size, "%s%s%s", szSKU, szServicePack, szVersion );
|
2002-06-06 18:50:12 +00:00
|
|
|
|
2006-05-17 22:29:37 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2006-05-16 20:43:11 +00:00
|
|
|
|
|
|
|
|
2006-05-17 22:29:37 +00:00
|
|
|
// Check to see if a processor feature is available for use
|
|
|
|
BOOL test_processor_feature(DWORD feature) {
|
|
|
|
__try {
|
|
|
|
switch (feature) {
|
|
|
|
case PF_XMMI_INSTRUCTIONS_AVAILABLE:
|
|
|
|
__asm {
|
|
|
|
xorps xmm0, xmm0 // executing SSE instruction
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PF_XMMI64_INSTRUCTIONS_AVAILABLE:
|
|
|
|
__asm {
|
|
|
|
xorpd xmm0, xmm0 // executing SSE2 instruction
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PF_3DNOW_INSTRUCTIONS_AVAILABLE:
|
|
|
|
__asm {
|
|
|
|
pfrcp mm0, mm0 // executing 3DNow! instruction
|
|
|
|
emms
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PF_MMX_INSTRUCTIONS_AVAILABLE:
|
|
|
|
__asm {
|
|
|
|
pxor mm0, mm0 // executing MMX instruction
|
|
|
|
emms
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
__except (EXCEPTION_EXECUTE_HANDLER) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
2006-05-16 20:43:11 +00:00
|
|
|
|
2006-05-17 22:29:37 +00:00
|
|
|
|
|
|
|
// Detect to see if a processor feature is available for use
|
2006-05-17 22:56:08 +00:00
|
|
|
|
|
|
|
// IsProcessorFeaturePresent()
|
|
|
|
typedef BOOL (__stdcall *tIPFP)( IN DWORD dwFeature );
|
|
|
|
|
2006-05-17 22:29:37 +00:00
|
|
|
BOOL is_processor_feature_supported(DWORD feature) {
|
|
|
|
// Detect platform information
|
|
|
|
OSVERSIONINFO osvi;
|
|
|
|
osvi.dwOSVersionInfoSize = sizeof(osvi);
|
|
|
|
GetVersionEx(&osvi);
|
|
|
|
|
|
|
|
if (VER_PLATFORM_WIN32_WINDOWS == osvi.dwPlatformId) {
|
|
|
|
// Win9x does have the IsProcessorFeaturePresent function, so just
|
|
|
|
// run a quick test.
|
|
|
|
return test_processor_feature(feature);
|
|
|
|
} else {
|
2006-05-17 22:56:08 +00:00
|
|
|
HMODULE hKernel32Lib = GetModuleHandle("kernel32.dll");
|
|
|
|
tIPFP pIPFP = (tIPFP)GetProcAddress(hKernel32Lib, "IsProcessorFeaturePresent");
|
|
|
|
if (pIPFP) {
|
|
|
|
// IsProcessorFeaturePresent is available, use it.
|
|
|
|
return pIPFP(feature);
|
|
|
|
} else {
|
|
|
|
// Ooooppppssss, whichever version of Windows we are running on
|
|
|
|
// doesn't support IsProcessorFeaturePresent, so just test things
|
|
|
|
// out.
|
|
|
|
return test_processor_feature(feature);
|
|
|
|
}
|
2006-05-17 22:29:37 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-01-22 19:34:59 +00:00
|
|
|
// Returns the processor make, model, and additional cpu flags supported by
|
|
|
|
// the processor, use the Linux CPU processor feature descriptions.
|
2006-05-17 22:29:37 +00:00
|
|
|
//
|
2007-01-22 19:34:59 +00:00
|
|
|
int get_processor_info(
|
2007-03-19 23:00:46 +00:00
|
|
|
char* p_vendor, int p_vendor_size, char* p_model, int p_model_size,
|
|
|
|
char* p_features, int p_features_size
|
2007-01-22 19:34:59 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
char vendorName[256], processorName[256], identifierName[256], capabilities[256], temp_model[256];
|
|
|
|
HKEY hKey = NULL;
|
|
|
|
LONG retval = 0;
|
|
|
|
DWORD nameSize = 0, procSpeed = 0;
|
|
|
|
bool gotIdent = false, gotProcName = false, gotMHz = false, gotVendIdent = false;
|
|
|
|
|
|
|
|
strcpy(vendorName, "");
|
|
|
|
strcpy(processorName, "");
|
2006-05-23 06:55:00 +00:00
|
|
|
strcpy(capabilities, "");
|
2007-01-22 19:34:59 +00:00
|
|
|
strcpy(temp_model, "");
|
|
|
|
|
|
|
|
// determine what the cpu's capabilities are
|
2006-05-19 02:06:14 +00:00
|
|
|
if (!is_processor_feature_supported(PF_FLOATING_POINT_EMULATED)) {
|
2007-01-22 19:34:59 +00:00
|
|
|
strncat(capabilities, "fpu ", sizeof(capabilities) - strlen(capabilities));
|
2006-05-19 02:06:14 +00:00
|
|
|
}
|
2006-05-17 22:29:37 +00:00
|
|
|
if (is_processor_feature_supported(PF_RDTSC_INSTRUCTION_AVAILABLE)) {
|
2007-01-22 19:34:59 +00:00
|
|
|
strncat(capabilities, "tsc ", sizeof(capabilities) - strlen(capabilities));
|
2006-05-17 22:29:37 +00:00
|
|
|
}
|
|
|
|
if (is_processor_feature_supported(PF_PAE_ENABLED)) {
|
2007-01-22 19:34:59 +00:00
|
|
|
strncat(capabilities, "pae ", sizeof(capabilities) - strlen(capabilities));
|
2006-05-17 22:29:37 +00:00
|
|
|
}
|
|
|
|
if (is_processor_feature_supported(PF_NX_ENABLED)) {
|
2007-01-22 19:34:59 +00:00
|
|
|
strncat(capabilities, "nx ", sizeof(capabilities) - strlen(capabilities));
|
2006-05-17 22:29:37 +00:00
|
|
|
}
|
|
|
|
if (is_processor_feature_supported(PF_XMMI_INSTRUCTIONS_AVAILABLE)) {
|
2007-01-22 19:34:59 +00:00
|
|
|
strncat(capabilities, "sse ", sizeof(capabilities) - strlen(capabilities));
|
2006-05-17 22:29:37 +00:00
|
|
|
}
|
|
|
|
if (is_processor_feature_supported(PF_XMMI64_INSTRUCTIONS_AVAILABLE)) {
|
2007-01-22 19:34:59 +00:00
|
|
|
strncat(capabilities, "sse2 ", sizeof(capabilities) - strlen(capabilities));
|
2006-05-17 22:29:37 +00:00
|
|
|
}
|
|
|
|
if (is_processor_feature_supported(PF_SSE3_INSTRUCTIONS_AVAILABLE)) {
|
2007-03-13 15:04:11 +00:00
|
|
|
strncat(capabilities, "pni ", sizeof(capabilities) - strlen(capabilities));
|
2006-05-17 22:29:37 +00:00
|
|
|
}
|
|
|
|
if (is_processor_feature_supported(PF_3DNOW_INSTRUCTIONS_AVAILABLE)) {
|
2007-01-22 19:34:59 +00:00
|
|
|
strncat(capabilities, "3dnow ", sizeof(capabilities) - strlen(capabilities));
|
2006-05-17 22:29:37 +00:00
|
|
|
}
|
|
|
|
if (is_processor_feature_supported(PF_MMX_INSTRUCTIONS_AVAILABLE)) {
|
2007-01-22 19:34:59 +00:00
|
|
|
strncat(capabilities, "mmx ", sizeof(capabilities) - strlen(capabilities));
|
2006-05-17 22:29:37 +00:00
|
|
|
}
|
|
|
|
strip_whitespace(capabilities);
|
2007-01-22 19:34:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
retval = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Hardware\\Description\\System\\CentralProcessor\\0", 0, KEY_QUERY_VALUE, &hKey);
|
|
|
|
if(retval == ERROR_SUCCESS) {
|
|
|
|
// Win9x and WinNT store different information in these field.
|
|
|
|
// NT Examples:
|
|
|
|
// ProcessorNameString: Intel(R) Xeon(TM) CPU 3.06GHz
|
|
|
|
// Identifier: x86 Family 15 Model 2 Stepping 7
|
|
|
|
// VendorIdentifier: GenuineIntel
|
|
|
|
// ~MHz: 3056
|
|
|
|
// 9X Examples:
|
|
|
|
// ProcessorNameString: <Not Defined>
|
|
|
|
// Identifier: Pentium(r) Processor
|
|
|
|
// ~MHz: <Not Defined>
|
|
|
|
// VendorIdentifier: GenuineIntel
|
|
|
|
|
|
|
|
// Look in various places for processor information, add'l
|
|
|
|
// entries suggested by mark mcclure
|
|
|
|
nameSize = sizeof(vendorName);
|
|
|
|
retval = RegQueryValueEx(hKey, "VendorIdentifier", NULL, NULL, (LPBYTE)vendorName, &nameSize);
|
|
|
|
if (retval == ERROR_SUCCESS) gotVendIdent = true;
|
|
|
|
|
|
|
|
nameSize = sizeof(identifierName);
|
|
|
|
retval = RegQueryValueEx(hKey, "Identifier", NULL, NULL, (LPBYTE)identifierName, &nameSize);
|
|
|
|
if (retval == ERROR_SUCCESS) gotIdent = true;
|
|
|
|
|
|
|
|
nameSize = sizeof(processorName);
|
|
|
|
retval = RegQueryValueEx(hKey, "ProcessorNameString", NULL, NULL, (LPBYTE)processorName, &nameSize);
|
|
|
|
if (retval == ERROR_SUCCESS) gotProcName = true;
|
|
|
|
|
|
|
|
nameSize = sizeof(DWORD);
|
|
|
|
retval = RegQueryValueEx(hKey, "~MHz", NULL, NULL, (LPBYTE)&procSpeed, &nameSize);
|
|
|
|
if (retval == ERROR_SUCCESS) gotMHz = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// populate vendor field.
|
|
|
|
if (gotVendIdent) {
|
|
|
|
strlcpy( p_vendor, vendorName, p_vendor_size );
|
|
|
|
} else {
|
|
|
|
strlcpy( p_vendor, "Unknown", p_vendor_size );
|
|
|
|
}
|
|
|
|
|
|
|
|
// construct the human readable model name
|
|
|
|
if (gotProcName) {
|
|
|
|
strlcpy( temp_model, processorName, sizeof(temp_model) );
|
|
|
|
} else if (gotIdent && gotMHz) {
|
|
|
|
sprintf( temp_model, "%s %dMHz", identifierName, procSpeed );
|
|
|
|
} else if (gotVendIdent && gotMHz) {
|
|
|
|
sprintf( temp_model, "%s %dMHz", vendorName, procSpeed );
|
|
|
|
} else if (gotIdent) {
|
|
|
|
strlcpy( temp_model, identifierName, sizeof(temp_model) );
|
|
|
|
} else if (gotVendIdent) {
|
|
|
|
strlcpy( temp_model, vendorName, sizeof(temp_model) );
|
|
|
|
} else {
|
|
|
|
strlcpy( temp_model, "Unknown", sizeof(temp_model) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Merge all the seperate pieces of information into one.
|
2007-04-03 13:14:30 +00:00
|
|
|
snprintf(p_model, p_model_size, "%s [%s]", temp_model, identifierName);
|
2007-01-22 19:34:59 +00:00
|
|
|
p_model[p_model_size-1] = 0;
|
2007-03-19 23:00:46 +00:00
|
|
|
strlcpy(p_features, capabilities, p_features_size);
|
2007-01-22 19:34:59 +00:00
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Returns the CPU count
|
|
|
|
//
|
|
|
|
int get_processor_count(int& processor_count) {
|
|
|
|
SYSTEM_INFO SystemInfo;
|
|
|
|
memset( &SystemInfo, NULL, sizeof( SystemInfo ) );
|
|
|
|
::GetSystemInfo( &SystemInfo );
|
|
|
|
|
|
|
|
processor_count = SystemInfo.dwNumberOfProcessors;
|
2006-05-17 22:29:37 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Returns the accelerator list.
|
|
|
|
//
|
|
|
|
int get_accelerators(
|
|
|
|
char* accelerators, int accelerators_size
|
|
|
|
)
|
|
|
|
{
|
2006-05-16 20:43:11 +00:00
|
|
|
// Detect video accelerators on the system.
|
|
|
|
DWORD iDevice = 0;
|
|
|
|
INTERNALMONITORINFO dispdev;
|
|
|
|
dispdev.cb = sizeof(dispdev);
|
2006-06-22 20:16:02 +00:00
|
|
|
strcpy(accelerators, "");
|
2006-05-16 20:43:11 +00:00
|
|
|
while(EnumDisplayDevices(NULL, iDevice, (PDISPLAY_DEVICE)&dispdev, 0)) {
|
|
|
|
// Ignore NetMeeting's mirrored displays
|
|
|
|
if ((dispdev.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) == 0) {
|
|
|
|
// Is the entry already listed?
|
|
|
|
if (!strstr(accelerators, dispdev.DeviceString)) {
|
|
|
|
// Is this the first entry?
|
|
|
|
if (!strlen(accelerators)) {
|
2006-05-17 22:29:37 +00:00
|
|
|
strncat(accelerators, dispdev.DeviceString, accelerators_size - strlen(accelerators));
|
2006-05-16 20:43:11 +00:00
|
|
|
} else {
|
2006-05-17 22:29:37 +00:00
|
|
|
strncat(accelerators, "/", accelerators_size - strlen(accelerators));
|
|
|
|
strncat(accelerators, dispdev.DeviceString, accelerators_size - strlen(accelerators));
|
2006-05-16 20:43:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
iDevice++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Detect the ClearSpeed accelerator card(s)
|
|
|
|
// TODO: Detect any other types of accelerators that might be useful
|
2006-05-17 22:29:37 +00:00
|
|
|
// for the scheduler to know about.
|
2006-05-16 20:43:11 +00:00
|
|
|
|
2006-05-17 22:29:37 +00:00
|
|
|
strip_whitespace(accelerators);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Gets windows specific host information (not complete)
|
|
|
|
//
|
|
|
|
int HOST_INFO::get_host_info() {
|
|
|
|
|
|
|
|
// Get timezone
|
|
|
|
get_timezone(timezone);
|
|
|
|
|
|
|
|
// Detect the filesystem information
|
|
|
|
get_filesystem_info(d_total, d_free);
|
|
|
|
|
|
|
|
// Detect the amount of memory the system has
|
|
|
|
get_memory_info(m_nbytes, m_swap);
|
|
|
|
|
|
|
|
// Detect OS Information
|
|
|
|
get_os_information(
|
|
|
|
os_name, sizeof(os_name), os_version, sizeof(os_version)
|
|
|
|
);
|
|
|
|
|
|
|
|
// Detect proccessor make and model.
|
|
|
|
get_processor_info(
|
2007-03-19 23:00:46 +00:00
|
|
|
p_vendor, sizeof(p_vendor),
|
|
|
|
p_model, sizeof(p_model),
|
|
|
|
p_features, sizeof(p_features)
|
2006-05-17 22:29:37 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// Detect the number of CPUs
|
|
|
|
get_processor_count(p_ncpus);
|
|
|
|
|
|
|
|
// Detect host name/ip info
|
2006-06-23 20:41:47 +00:00
|
|
|
get_local_network_info();
|
2006-05-17 22:29:37 +00:00
|
|
|
|
|
|
|
// Detect which accelerators are installed on the system
|
|
|
|
get_accelerators(
|
|
|
|
accelerators, sizeof(accelerators)
|
|
|
|
);
|
2006-05-16 20:43:11 +00:00
|
|
|
|
2005-01-20 18:50:49 +00:00
|
|
|
if (!strlen(host_cpid)) {
|
|
|
|
generate_host_cpid();
|
|
|
|
}
|
2002-06-06 18:50:12 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2002-10-06 01:12:54 +00:00
|
|
|
|
2004-03-31 19:53:31 +00:00
|
|
|
bool HOST_INFO::host_is_running_on_batteries() {
|
2002-12-09 23:52:17 +00:00
|
|
|
SYSTEM_POWER_STATUS pStatus;
|
|
|
|
ZeroMemory(&pStatus, sizeof(SYSTEM_POWER_STATUS));
|
2003-02-25 00:19:50 +00:00
|
|
|
if (!GetSystemPowerStatus(&pStatus)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-01-27 20:02:41 +00:00
|
|
|
// Sometimes the system reports the ACLineStatus as an
|
|
|
|
// undocumented value, so lets check to see if the
|
|
|
|
// battery is charging or missing and make that part
|
|
|
|
// of the decision.
|
|
|
|
bool bIsOnBatteryPower = (pStatus.ACLineStatus != 1);
|
2005-01-27 20:04:58 +00:00
|
|
|
bool bIsBatteryCharging = ((pStatus.BatteryFlag & 8) == 8);
|
|
|
|
bool bIsBatteryMissing = ((pStatus.BatteryFlag & 128) == 128);
|
2005-01-27 20:02:41 +00:00
|
|
|
|
|
|
|
return (bIsOnBatteryPower && !bIsBatteryCharging && !bIsBatteryMissing);
|
2002-12-05 22:50:21 +00:00
|
|
|
}
|
2004-06-29 19:54:50 +00:00
|
|
|
|
2006-11-10 18:21:05 +00:00
|
|
|
bool HOST_INFO::users_idle(bool /*check_all_logins*/, double idle_time_to_run) {
|
2004-12-18 20:52:14 +00:00
|
|
|
typedef DWORD (CALLBACK* GetFn)();
|
2006-01-23 08:47:05 +00:00
|
|
|
static GetFn fn = (GetFn)GetProcAddress(g_hClientLibraryDll, "BOINCGetIdleTickCount");
|
2004-12-18 20:52:14 +00:00
|
|
|
|
2006-03-24 22:46:46 +00:00
|
|
|
if (g_hClientLibraryDll && fn) {
|
|
|
|
double seconds_idle = fn() / 1000;
|
|
|
|
double seconds_time_to_run = 60 * idle_time_to_run;
|
|
|
|
return seconds_idle > seconds_time_to_run;
|
2004-06-29 19:54:50 +00:00
|
|
|
}
|
2004-12-18 20:52:14 +00:00
|
|
|
|
2004-06-29 19:54:50 +00:00
|
|
|
return false;
|
|
|
|
}
|
2004-12-08 00:40:19 +00:00
|
|
|
|
2005-01-02 18:29:53 +00:00
|
|
|
const char *BOINC_RCSID_37fbd07edd = "$Id$";
|