提交 5f02c9c3 编写于 作者: S sherman

6714428: 'os.name' system property shows wrong value on 64-bit Windows XP

Summary: update to detect the correct os.name for 64-bit XP
Reviewed-by: darcy
上级 c449e27f
......@@ -38,6 +38,12 @@
#define VER_PLATFORM_WIN32_WINDOWS 1
#endif
#ifndef PROCESSOR_ARCHITECTURE_AMD64
#define PROCESSOR_ARCHITECTURE_AMD64 9
#endif
typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
#define SHELL_KEY "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"
/* Encodings for Windows language groups. According to
......@@ -674,9 +680,22 @@ GetJavaProperties(JNIEnv* env)
{
char buf[100];
OSVERSIONINFOEX ver;
SYSTEM_INFO si;
PGNSI pGNSI;
ver.dwOSVersionInfoSize = sizeof(ver);
GetVersionEx((OSVERSIONINFO *) &ver);
ZeroMemory(&si, sizeof(SYSTEM_INFO));
// Call GetNativeSystemInfo if supported or GetSystemInfo otherwise.
pGNSI = (PGNSI) GetProcAddress(
GetModuleHandle(TEXT("kernel32.dll")),
"GetNativeSystemInfo");
if(NULL != pGNSI)
pGNSI(&si);
else
GetSystemInfo(&si);
/*
* From msdn page on OSVERSIONINFOEX, current as of this
* writing, decoding of dwMajorVersion and dwMinorVersion.
......@@ -690,9 +709,14 @@ GetJavaProperties(JNIEnv* env)
* Windows 3.51 3 51
* Windows NT 4.0 4 0
* Windows 2000 5 0
* Windows XP 5 1
* Windows XP 32 bit 5 1
* Windows Server 2003 family 5 2
* Windows XP 64 bit 5 2
* where ((&ver.wServicePackMinor) + 2) = 1
* and si.wProcessorArchitecture = 9
* Windows Vista family 6 0
* Windows 2008 6 0
* where ((&ver.wServicePackMinor) + 2) = 1
*
* This mapping will presumably be augmented as new Windows
* versions are released.
......@@ -720,7 +744,25 @@ GetJavaProperties(JNIEnv* env)
switch (ver.dwMinorVersion) {
case 0: sprops.os_name = "Windows 2000"; break;
case 1: sprops.os_name = "Windows XP"; break;
case 2: sprops.os_name = "Windows 2003"; break;
case 2:
/*
* From MSDN OSVERSIONINFOEX and SYSTEM_INFO documentation:
*
* "Because the version numbers for Windows Server 2003
* and Windows XP 6u4 bit are identical, you must also test
* whether the wProductType member is VER_NT_WORKSTATION.
* and si.wProcessorArchitecture is
* PROCESSOR_ARCHITECTURE_AMD64 (which is 9)
* If it is, the operating system is Windows XP 64 bit;
* otherwise, it is Windows Server 2003."
*/
if(ver.wProductType == VER_NT_WORKSTATION &&
si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) {
sprops.os_name = "Windows XP"; /* 64 bit */
} else {
sprops.os_name = "Windows 2003";
}
break;
default: sprops.os_name = "Windows NT (unknown)"; break;
}
} else if (ver.dwMajorVersion == 6) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册