VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2017-05-27 19:56:35 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2017-05-28 00:04:27 +0200
commitf94ceb7a9772a4b68fa3d2eb95bb44c9aa8cc2fe (patch)
tree385bebb8695c6e70021e0af22ad391a043874d9d /src
parent86ababb2a47019231acbed75855fc0687efd1d32 (diff)
downloadVeraCrypt-f94ceb7a9772a4b68fa3d2eb95bb44c9aa8cc2fe.tar.gz
VeraCrypt-f94ceb7a9772a4b68fa3d2eb95bb44c9aa8cc2fe.zip
Windows: use RtlGetVersion instead of GetVersionEx in order to get accurate Windows version information on Windows 10.
Diffstat (limited to 'src')
-rw-r--r--src/Common/Dlgcode.c23
1 files changed, 22 insertions, 1 deletions
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;