From 32b9eeb3c06bc56574b5490ac994ecb5693bf441 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Fri, 28 Jul 2023 08:02:46 +0200 Subject: [PATCH] [winpr,sysinfo] deprecage GetVersionInfoEx the function is deprecated under windows, so deprecate it in WinPR too and remove/replace usage --- libfreerdp/codec/rfx.c | 14 +------------- winpr/include/winpr/sysinfo.h | 4 ++++ winpr/libwinpr/sspi/NTLM/ntlm_compute.c | 15 +++++++++++++-- winpr/libwinpr/sysinfo/sysinfo.c | 3 +++ 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/libfreerdp/codec/rfx.c b/libfreerdp/codec/rfx.c index e1aaa9285..b9e32bbdd 100644 --- a/libfreerdp/codec/rfx.c +++ b/libfreerdp/codec/rfx.c @@ -271,20 +271,8 @@ RFX_CONTEXT* rfx_context_new_ex(BOOL encoder, UINT32 ThreadingFlags) if (!(ThreadingFlags & THREADING_FLAGS_DISABLE_THREADS)) { -#ifdef _WIN32 - { - BOOL isVistaOrLater; - OSVERSIONINFOA verinfo = { 0 }; - - verinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA); - GetVersionExA(&verinfo); - isVistaOrLater = - ((verinfo.dwMajorVersion >= 6) && (verinfo.dwMinorVersion >= 0)) ? TRUE : FALSE; - priv->UseThreads = isVistaOrLater; - } -#else priv->UseThreads = TRUE; -#endif + GetNativeSystemInfo(&sysinfo); priv->MinThreadCount = sysinfo.dwNumberOfProcessors; priv->MaxThreadCount = 0; diff --git a/winpr/include/winpr/sysinfo.h b/winpr/include/winpr/sysinfo.h index 64ce8f6ca..5b8cac16c 100644 --- a/winpr/include/winpr/sysinfo.h +++ b/winpr/include/winpr/sysinfo.h @@ -100,6 +100,7 @@ extern "C" WINPR_API void GetSystemInfo(LPSYSTEM_INFO lpSystemInfo); WINPR_API void GetNativeSystemInfo(LPSYSTEM_INFO lpSystemInfo); +#if defined(WITH_WINPR_DEPRECATED) typedef struct { DWORD dwOSVersionInfoSize; @@ -181,6 +182,7 @@ extern "C" #define VER_SUITE_STORAGE_SERVER 0x00002000 #define VER_SUITE_TERMINAL 0x00000010 #define VER_SUITE_WH_SERVER 0x00008000 +#endif #define VER_NT_DOMAIN_CONTROLLER 0x0000002 #define VER_NT_SERVER 0x0000003 @@ -262,6 +264,7 @@ extern "C" #if !defined(_WIN32) || defined(_UWP) +#if defined(WITH_WINPR_DEPRECATED) WINPR_API BOOL GetVersionExA(LPOSVERSIONINFOA lpVersionInformation); WINPR_API BOOL GetVersionExW(LPOSVERSIONINFOW lpVersionInformation); @@ -271,6 +274,7 @@ extern "C" #define GetVersionEx GetVersionExA #endif +#endif #endif #if !defined(_WIN32) || defined(_UWP) diff --git a/winpr/libwinpr/sspi/NTLM/ntlm_compute.c b/winpr/libwinpr/sspi/NTLM/ntlm_compute.c index 9d33c178f..711779c8c 100644 --- a/winpr/libwinpr/sspi/NTLM/ntlm_compute.c +++ b/winpr/libwinpr/sspi/NTLM/ntlm_compute.c @@ -57,16 +57,27 @@ static const BYTE NTLM_NULL_BUFFER[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0 BOOL ntlm_get_version_info(NTLM_VERSION_INFO* versionInfo) { - OSVERSIONINFOA osVersionInfo = { 0 }; - WINPR_ASSERT(versionInfo); +#if defined(WITH_WINPR_DEPRECATED) + OSVERSIONINFOA osVersionInfo = { 0 }; osVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA); if (!GetVersionExA(&osVersionInfo)) return FALSE; versionInfo->ProductMajorVersion = (UINT8)osVersionInfo.dwMajorVersion; versionInfo->ProductMinorVersion = (UINT8)osVersionInfo.dwMinorVersion; versionInfo->ProductBuild = (UINT16)osVersionInfo.dwBuildNumber; +#else + /* Always return fixed version number. + * + * ProductVersion is fixed since windows 10 to Major 10, Minor 0 + * ProductBuild taken from https://en.wikipedia.org/wiki/Windows_11_version_history + * with most recent (pre) release build number + */ + versionInfo->ProductMajorVersion = 10; + versionInfo->ProductMinorVersion = 0; + versionInfo->ProductBuild = 22631; +#endif ZeroMemory(versionInfo->Reserved, sizeof(versionInfo->Reserved)); versionInfo->NTLMRevisionCurrent = NTLMSSP_REVISION_W2K3; return TRUE; diff --git a/winpr/libwinpr/sysinfo/sysinfo.c b/winpr/libwinpr/sysinfo/sysinfo.c index b87a91414..1050956fa 100644 --- a/winpr/libwinpr/sysinfo/sysinfo.c +++ b/winpr/libwinpr/sysinfo/sysinfo.c @@ -316,6 +316,7 @@ DWORD GetTickCount(void) #if !defined(_WIN32) || defined(_UWP) +#if defined(WITH_WINPR_DEPRECATED) /* OSVERSIONINFOEX Structure: * http://msdn.microsoft.com/en-us/library/windows/desktop/ms724833 */ @@ -384,6 +385,8 @@ BOOL GetVersionExW(LPOSVERSIONINFOW lpVersionInformation) #endif +#endif + #if !defined(_WIN32) || defined(_UWP) BOOL GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)