[winpr,sysinfo] deprecage GetVersionInfoEx

the function is deprecated under windows, so deprecate it in WinPR too
and remove/replace usage
This commit is contained in:
Armin Novak 2023-07-28 08:02:46 +02:00 committed by akallabeth
parent 1e0ca536c7
commit 32b9eeb3c0
4 changed files with 21 additions and 15 deletions

View File

@ -271,20 +271,8 @@ RFX_CONTEXT* rfx_context_new_ex(BOOL encoder, UINT32 ThreadingFlags)
if (!(ThreadingFlags & THREADING_FLAGS_DISABLE_THREADS)) 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; priv->UseThreads = TRUE;
#endif
GetNativeSystemInfo(&sysinfo); GetNativeSystemInfo(&sysinfo);
priv->MinThreadCount = sysinfo.dwNumberOfProcessors; priv->MinThreadCount = sysinfo.dwNumberOfProcessors;
priv->MaxThreadCount = 0; priv->MaxThreadCount = 0;

View File

@ -100,6 +100,7 @@ extern "C"
WINPR_API void GetSystemInfo(LPSYSTEM_INFO lpSystemInfo); WINPR_API void GetSystemInfo(LPSYSTEM_INFO lpSystemInfo);
WINPR_API void GetNativeSystemInfo(LPSYSTEM_INFO lpSystemInfo); WINPR_API void GetNativeSystemInfo(LPSYSTEM_INFO lpSystemInfo);
#if defined(WITH_WINPR_DEPRECATED)
typedef struct typedef struct
{ {
DWORD dwOSVersionInfoSize; DWORD dwOSVersionInfoSize;
@ -181,6 +182,7 @@ extern "C"
#define VER_SUITE_STORAGE_SERVER 0x00002000 #define VER_SUITE_STORAGE_SERVER 0x00002000
#define VER_SUITE_TERMINAL 0x00000010 #define VER_SUITE_TERMINAL 0x00000010
#define VER_SUITE_WH_SERVER 0x00008000 #define VER_SUITE_WH_SERVER 0x00008000
#endif
#define VER_NT_DOMAIN_CONTROLLER 0x0000002 #define VER_NT_DOMAIN_CONTROLLER 0x0000002
#define VER_NT_SERVER 0x0000003 #define VER_NT_SERVER 0x0000003
@ -262,6 +264,7 @@ extern "C"
#if !defined(_WIN32) || defined(_UWP) #if !defined(_WIN32) || defined(_UWP)
#if defined(WITH_WINPR_DEPRECATED)
WINPR_API BOOL GetVersionExA(LPOSVERSIONINFOA lpVersionInformation); WINPR_API BOOL GetVersionExA(LPOSVERSIONINFOA lpVersionInformation);
WINPR_API BOOL GetVersionExW(LPOSVERSIONINFOW lpVersionInformation); WINPR_API BOOL GetVersionExW(LPOSVERSIONINFOW lpVersionInformation);
@ -271,6 +274,7 @@ extern "C"
#define GetVersionEx GetVersionExA #define GetVersionEx GetVersionExA
#endif #endif
#endif
#endif #endif
#if !defined(_WIN32) || defined(_UWP) #if !defined(_WIN32) || defined(_UWP)

View File

@ -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) BOOL ntlm_get_version_info(NTLM_VERSION_INFO* versionInfo)
{ {
OSVERSIONINFOA osVersionInfo = { 0 };
WINPR_ASSERT(versionInfo); WINPR_ASSERT(versionInfo);
#if defined(WITH_WINPR_DEPRECATED)
OSVERSIONINFOA osVersionInfo = { 0 };
osVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA); osVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
if (!GetVersionExA(&osVersionInfo)) if (!GetVersionExA(&osVersionInfo))
return FALSE; return FALSE;
versionInfo->ProductMajorVersion = (UINT8)osVersionInfo.dwMajorVersion; versionInfo->ProductMajorVersion = (UINT8)osVersionInfo.dwMajorVersion;
versionInfo->ProductMinorVersion = (UINT8)osVersionInfo.dwMinorVersion; versionInfo->ProductMinorVersion = (UINT8)osVersionInfo.dwMinorVersion;
versionInfo->ProductBuild = (UINT16)osVersionInfo.dwBuildNumber; 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)); ZeroMemory(versionInfo->Reserved, sizeof(versionInfo->Reserved));
versionInfo->NTLMRevisionCurrent = NTLMSSP_REVISION_W2K3; versionInfo->NTLMRevisionCurrent = NTLMSSP_REVISION_W2K3;
return TRUE; return TRUE;

View File

@ -316,6 +316,7 @@ DWORD GetTickCount(void)
#if !defined(_WIN32) || defined(_UWP) #if !defined(_WIN32) || defined(_UWP)
#if defined(WITH_WINPR_DEPRECATED)
/* OSVERSIONINFOEX Structure: /* OSVERSIONINFOEX Structure:
* http://msdn.microsoft.com/en-us/library/windows/desktop/ms724833 * http://msdn.microsoft.com/en-us/library/windows/desktop/ms724833
*/ */
@ -384,6 +385,8 @@ BOOL GetVersionExW(LPOSVERSIONINFOW lpVersionInformation)
#endif #endif
#endif
#if !defined(_WIN32) || defined(_UWP) #if !defined(_WIN32) || defined(_UWP)
BOOL GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize) BOOL GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)