From f94ceb7a9772a4b68fa3d2eb95bb44c9aa8cc2fe Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sat, 27 May 2017 19:56:35 +0200 Subject: Windows: use RtlGetVersion instead of GetVersionEx in order to get accurate Windows version information on Windows 10. --- src/Common/Dlgcode.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index 97c55da4..62b0a4e5 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -2540,13 +2540,34 @@ void DoPostInstallTasks (HWND hwndDlg) SavePostInstallTasksSettings (TC_POST_INSTALL_CFG_REMOVE_ALL); } +/* + * Use RtlGetVersion to get Windows version because GetVersionEx is affected by application manifestation. + */ +typedef NTSTATUS (WINAPI* RtlGetVersionPtr)(PRTL_OSVERSIONINFOW); + +static BOOL GetWindowsVersion(LPOSVERSIONINFOW lpVersionInformation) +{ + BOOL bRet = FALSE; + RtlGetVersionPtr RtlGetVersionFn = (RtlGetVersionPtr) GetProcAddress(GetModuleHandle (L"ntdll.dll"), "RtlGetVersion"); + if (RtlGetVersionFn != NULL) + { + if (ERROR_SUCCESS == RtlGetVersionFn (lpVersionInformation)) + bRet = TRUE; + } + + if (!bRet) + bRet = GetVersionExW (lpVersionInformation); + + return bRet; +} + void InitOSVersionInfo () { OSVERSIONINFOEXW os; os.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEXW); - if (GetVersionExW ((LPOSVERSIONINFOW) &os) == FALSE) + if (GetWindowsVersion ((LPOSVERSIONINFOW) &os) == FALSE) AbortProcess ("NO_OS_VER"); CurrentOSMajor = os.dwMajorVersion; -- cgit v1.2.3