提交 710b34a9 编写于 作者: C ctornqvi

8059803: Update use of GetVersionEx to get correct Windows version in hs_err files

Summary: Update use of GetVersionEx to get correct Windows version in hs_err files
Reviewed-by: dcubed, gtriantafill
上级 b283b91e
...@@ -268,7 +268,7 @@ LD=link.exe ...@@ -268,7 +268,7 @@ LD=link.exe
!endif !endif
LD_FLAGS= $(LD_FLAGS) kernel32.lib user32.lib gdi32.lib winspool.lib \ LD_FLAGS= $(LD_FLAGS) kernel32.lib user32.lib gdi32.lib winspool.lib \
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \ comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \
uuid.lib Wsock32.lib winmm.lib /nologo /machine:$(MACHINE) /opt:REF \ uuid.lib Wsock32.lib winmm.lib version.lib /nologo /machine:$(MACHINE) /opt:REF \
/opt:ICF,8 /opt:ICF,8
!if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1" !if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1"
LD_FLAGS= $(LD_FLAGS) /map /debug LD_FLAGS= $(LD_FLAGS) /map /debug
......
...@@ -1650,96 +1650,123 @@ void os::print_os_info(outputStream* st) { ...@@ -1650,96 +1650,123 @@ void os::print_os_info(outputStream* st) {
void os::win32::print_windows_version(outputStream* st) { void os::win32::print_windows_version(outputStream* st) {
OSVERSIONINFOEX osvi; OSVERSIONINFOEX osvi;
SYSTEM_INFO si; VS_FIXEDFILEINFO *file_info;
TCHAR kernel32_path[MAX_PATH];
UINT len, ret;
// Use the GetVersionEx information to see if we're on a server or
// workstation edition of Windows. Starting with Windows 8.1 we can't
// trust the OS version information returned by this API.
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
if (!GetVersionEx((OSVERSIONINFO *)&osvi)) { if (!GetVersionEx((OSVERSIONINFO *)&osvi)) {
st->print_cr("N/A"); st->print_cr("Call to GetVersionEx failed");
return; return;
} }
bool is_workstation = (osvi.wProductType == VER_NT_WORKSTATION);
int os_vers = osvi.dwMajorVersion * 1000 + osvi.dwMinorVersion; // Get the full path to \Windows\System32\kernel32.dll and use that for
// determining what version of Windows we're running on.
len = MAX_PATH - (UINT)strlen("\\kernel32.dll") - 1;
ret = GetSystemDirectory(kernel32_path, len);
if (ret == 0 || ret > len) {
st->print_cr("Call to GetSystemDirectory failed");
return;
}
strncat(kernel32_path, "\\kernel32.dll", MAX_PATH - ret);
ZeroMemory(&si, sizeof(SYSTEM_INFO)); DWORD version_size = GetFileVersionInfoSize(kernel32_path, NULL);
if (os_vers >= 5002) { if (version_size == 0) {
// Retrieve SYSTEM_INFO from GetNativeSystemInfo call so that we could st->print_cr("Call to GetFileVersionInfoSize failed");
// find out whether we are running on 64 bit processor or not. return;
if (os::Kernel32Dll::GetNativeSystemInfoAvailable()) {
os::Kernel32Dll::GetNativeSystemInfo(&si);
} else {
GetSystemInfo(&si);
} }
LPTSTR version_info = (LPTSTR)os::malloc(version_size, mtInternal);
if (version_info == NULL) {
st->print_cr("Failed to allocate version_info");
return;
} }
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) { if (!GetFileVersionInfo(kernel32_path, NULL, version_size, version_info)) {
switch (os_vers) { os::free(version_info);
case 3051: st->print(" Windows NT 3.51"); break; st->print_cr("Call to GetFileVersionInfo failed");
case 4000: st->print(" Windows NT 4.0"); break; return;
case 5000: st->print(" Windows 2000"); break; }
case 5001: st->print(" Windows XP"); break;
case 5002: if (!VerQueryValue(version_info, TEXT("\\"), (LPVOID*)&file_info, &len)) {
if (osvi.wProductType == VER_NT_WORKSTATION && os::free(version_info);
si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) { st->print_cr("Call to VerQueryValue failed");
st->print(" Windows XP x64 Edition"); return;
} else {
st->print(" Windows Server 2003 family");
} }
break;
int major_version = HIWORD(file_info->dwProductVersionMS);
int minor_version = LOWORD(file_info->dwProductVersionMS);
int build_number = HIWORD(file_info->dwProductVersionLS);
int build_minor = LOWORD(file_info->dwProductVersionLS);
int os_vers = major_version * 1000 + minor_version;
os::free(version_info);
st->print(" Windows ");
switch (os_vers) {
case 6000: case 6000:
if (osvi.wProductType == VER_NT_WORKSTATION) { if (is_workstation) {
st->print(" Windows Vista"); st->print("Vista");
} else { } else {
st->print(" Windows Server 2008"); st->print("Server 2008");
} }
break; break;
case 6001: case 6001:
if (osvi.wProductType == VER_NT_WORKSTATION) { if (is_workstation) {
st->print(" Windows 7"); st->print("7");
} else { } else {
st->print(" Windows Server 2008 R2"); st->print("Server 2008 R2");
} }
break; break;
case 6002: case 6002:
if (osvi.wProductType == VER_NT_WORKSTATION) { if (is_workstation) {
st->print(" Windows 8"); st->print("8");
} else { } else {
st->print(" Windows Server 2012"); st->print("Server 2012");
} }
break; break;
case 6003: case 6003:
if (osvi.wProductType == VER_NT_WORKSTATION) { if (is_workstation) {
st->print(" Windows 8.1"); st->print("8.1");
} else { } else {
st->print(" Windows Server 2012 R2"); st->print("Server 2012 R2");
} }
break; break;
default: // future os case 6004:
// Unrecognized windows, print out its major and minor versions if (is_workstation) {
st->print(" Windows NT %d.%d", osvi.dwMajorVersion, osvi.dwMinorVersion); st->print("10");
}
} else { } else {
switch (os_vers) { // The server version name of Windows 10 is not known at this time
case 4000: st->print(" Windows 95"); break; st->print("%d.%d", major_version, minor_version);
case 4010: st->print(" Windows 98"); break;
case 4090: st->print(" Windows Me"); break;
default: // future windows, print out its major and minor versions
st->print(" Windows %d.%d", osvi.dwMajorVersion, osvi.dwMinorVersion);
} }
break;
default:
// Unrecognized windows, print out its major and minor versions
st->print("%d.%d", major_version, minor_version);
break;
} }
if (os_vers >= 6000 && si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) { // Retrieve SYSTEM_INFO from GetNativeSystemInfo call so that we could
// find out whether we are running on 64 bit processor or not
SYSTEM_INFO si;
ZeroMemory(&si, sizeof(SYSTEM_INFO));
os::Kernel32Dll::GetNativeSystemInfo(&si);
if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) {
st->print(" , 64 bit"); st->print(" , 64 bit");
} }
st->print(" Build %d", osvi.dwBuildNumber); st->print(" Build %d", build_number);
st->print(" %s", osvi.szCSDVersion); // service pack st->print(" (%d.%d.%d.%d)", major_version, minor_version, build_number, build_minor);
st->cr(); st->cr();
} }
...@@ -5350,11 +5377,6 @@ inline BOOL os::Kernel32Dll::Module32Next(HANDLE hSnapshot,LPMODULEENTRY32 lpme) ...@@ -5350,11 +5377,6 @@ inline BOOL os::Kernel32Dll::Module32Next(HANDLE hSnapshot,LPMODULEENTRY32 lpme)
return ::Module32Next(hSnapshot, lpme); return ::Module32Next(hSnapshot, lpme);
} }
inline BOOL os::Kernel32Dll::GetNativeSystemInfoAvailable() {
return true;
}
inline void os::Kernel32Dll::GetNativeSystemInfo(LPSYSTEM_INFO lpSystemInfo) { inline void os::Kernel32Dll::GetNativeSystemInfo(LPSYSTEM_INFO lpSystemInfo) {
::GetNativeSystemInfo(lpSystemInfo); ::GetNativeSystemInfo(lpSystemInfo);
} }
......
...@@ -192,7 +192,6 @@ public: ...@@ -192,7 +192,6 @@ public:
static BOOL Module32First(HANDLE,LPMODULEENTRY32); static BOOL Module32First(HANDLE,LPMODULEENTRY32);
static BOOL Module32Next(HANDLE,LPMODULEENTRY32); static BOOL Module32Next(HANDLE,LPMODULEENTRY32);
static BOOL GetNativeSystemInfoAvailable();
static void GetNativeSystemInfo(LPSYSTEM_INFO); static void GetNativeSystemInfo(LPSYSTEM_INFO);
// NUMA calls // NUMA calls
......
...@@ -398,7 +398,7 @@ class CompilerInterfaceVC10 extends CompilerInterface { ...@@ -398,7 +398,7 @@ class CompilerInterfaceVC10 extends CompilerInterface {
"/export:JVM_GetThreadStateNames "+ "/export:JVM_GetThreadStateNames "+
"/export:JVM_GetThreadStateValues "+ "/export:JVM_GetThreadStateValues "+
"/export:JVM_InitAgentProperties"); "/export:JVM_InitAgentProperties");
addAttr(rv, "AdditionalDependencies", "kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;Wsock32.lib;winmm.lib;psapi.lib"); addAttr(rv, "AdditionalDependencies", "kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;Wsock32.lib;winmm.lib;psapi.lib;version.lib");
addAttr(rv, "OutputFile", outDll); addAttr(rv, "OutputFile", outDll);
addAttr(rv, "SuppressStartupBanner", "true"); addAttr(rv, "SuppressStartupBanner", "true");
addAttr(rv, "ModuleDefinitionFile", outDir+Util.sep+"vm.def"); addAttr(rv, "ModuleDefinitionFile", outDir+Util.sep+"vm.def");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册