Commit 27714139 authored by Gilles Khouzam's avatar Gilles Khouzam Committed by Brad King
Browse files

SystemTools: Call GetVersionEx more robustly

We pass a OSVERSIONINFOEXA structure so call GetVersionExA explicitly to
avoid ever calling GetVersionExW with a structure of the wrong size by
mistake.

Change-Id: I892ae0497ef3ca4b38cd2c1c1870d165b0bd8713
parent dc3fdd7f
......@@ -4879,11 +4879,8 @@ std::string SystemTools::GetOperatingSystemNameAndVersion()
OSVERSIONINFOEXA osvi;
BOOL bOsVersionInfoEx;
// Try calling GetVersionEx using the OSVERSIONINFOEX structure.
// If that fails, try using the OSVERSIONINFO structure.
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEXA));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA);
ZeroMemory(&osvi, sizeof(osvi));
osvi.dwOSVersionInfoSize = sizeof(osvi);
#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
# pragma warning (push)
......@@ -4893,15 +4890,11 @@ std::string SystemTools::GetOperatingSystemNameAndVersion()
# pragma warning (disable:4996)
# endif
#endif
bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *)&osvi);
bOsVersionInfoEx = GetVersionExA((OSVERSIONINFOA *)&osvi);
if (!bOsVersionInfoEx)
{
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if (!GetVersionEx((OSVERSIONINFO *)&osvi))
{
return 0;
}
}
#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
# pragma warning (pop)
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment