From 8856f1f00e5f9cd88def245222c55297130d869b Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Tue, 19 Nov 2013 22:26:37 +0000 Subject: * cygcheck.cc (RtlGetVersion): Declare. (dump_sysinfo): Call RtlGetVersion rather than GetVersionEx to get correct OS info even on Windows 8.1. Don't check return value since RtlGetVersion never fails per MSDN. Move fetching kernel32 module handle where it's really needed. Drop temporary comment added by previous checkin. --- winsup/utils/ChangeLog | 9 +++++++++ winsup/utils/cygcheck.cc | 18 +++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index cdda174cb..9797cc16b 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,3 +1,12 @@ +2013-11-19 Corinna Vinschen + + * cygcheck.cc (RtlGetVersion): Declare. + (dump_sysinfo): Call RtlGetVersion rather than GetVersionEx to get + correct OS info even on Windows 8.1. Don't check return value since + RtlGetVersion never fails per MSDN. Move fetching kernel32 module + handle where it's really needed. Drop temporary comment added by + previous checkin. + 2013-11-19 Corinna Vinschen * cygcheck.cc (dump_sysinfo): Revert Windows 8.1 hack. It's not diff --git a/winsup/utils/cygcheck.cc b/winsup/utils/cygcheck.cc index 106577c9c..465bc7861 100644 --- a/winsup/utils/cygcheck.cc +++ b/winsup/utils/cygcheck.cc @@ -1422,6 +1422,8 @@ handle_unique_object_name (int opt, char *path) return 1; } +extern "C" NTSTATUS NTAPI RtlGetVersion (PRTL_OSVERSIONINFOEXW); + static void dump_sysinfo () { @@ -1438,12 +1440,9 @@ dump_sysinfo () time (&now); printf ("Current System Time: %s\n", ctime (&now)); - OSVERSIONINFOEX osversion; - osversion.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX); - if (!GetVersionEx (reinterpret_cast(&osversion))) - display_error ("dump_sysinfo: GetVersionEx()"); - - HMODULE k32 = GetModuleHandleW (L"kernel32.dll"); + RTL_OSVERSIONINFOEXW osversion; + osversion.dwOSVersionInfoSize = sizeof (RTL_OSVERSIONINFOEXW); + RtlGetVersion (&osversion); switch (osversion.dwPlatformId) { @@ -1451,6 +1450,7 @@ dump_sysinfo () is_nt = true; if (osversion.dwMajorVersion == 6) { + HMODULE k32 = GetModuleHandleW (L"kernel32.dll"); BOOL (WINAPI *GetProductInfo) (DWORD, DWORD, DWORD, DWORD, PDWORD) = (BOOL (WINAPI *)(DWORD, DWORD, DWORD, DWORD, PDWORD)) GetProcAddress (k32, "GetProductInfo"); @@ -1468,7 +1468,7 @@ dump_sysinfo () strcpy (osname, osversion.wProductType == VER_NT_WORKSTATION ? "8" : "2012"); break; - case 3: /* Unreached due to mainfest nonsense. */ + case 3: default: osversion.dwMinorVersion = 3; strcpy (osname, osversion.wProductType == VER_NT_WORKSTATION @@ -1639,12 +1639,12 @@ dump_sysinfo () strcpy (osname, "??"); break; } - printf ("Windows %s Ver %lu.%lu Build %lu %s\n", osname, + printf ("Windows %s Ver %lu.%lu Build %lu %ls\n", osname, osversion.dwMajorVersion, osversion.dwMinorVersion, osversion.dwPlatformId == VER_PLATFORM_WIN32_NT ? osversion.dwBuildNumber : (osversion.dwBuildNumber & 0xffff), osversion.dwPlatformId == VER_PLATFORM_WIN32_NT ? - osversion.szCSDVersion : ""); + osversion.szCSDVersion : L""); if (osversion.dwPlatformId == VER_PLATFORM_WIN32s || osversion.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) -- cgit v1.2.3