summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCameron Cawley <ccawley2011@gmail.com>2020-07-31 20:36:56 +0100
committerMarcel Raad <Marcel.Raad@teamviewer.com>2020-08-02 17:58:44 +0200
commit790137b0f701fc9dc8e40d903b89be9f1ecadd00 (patch)
tree871ec08dc406d5edade332912442f704303632a0
parent5c2728eb42bc49533bb3a7abd00071549fb377fb (diff)
downloadcurl-790137b0f701fc9dc8e40d903b89be9f1ecadd00.tar.gz
win32: Add Curl_verify_windows_version() to curlx
Closes https://github.com/curl/curl/pull/5754
-rw-r--r--lib/Makefile.inc5
-rw-r--r--lib/connect.c6
-rw-r--r--lib/curl_sspi.c3
-rw-r--r--lib/curlx.h3
-rw-r--r--lib/system_win32.c197
-rw-r--r--lib/system_win32.h22
-rw-r--r--lib/version_win32.c226
-rw-r--r--lib/version_win32.h53
-rw-r--r--lib/vtls/schannel.c18
-rw-r--r--lib/vtls/schannel_verify.c8
-rw-r--r--projects/generate.bat2
-rw-r--r--src/Makefile.inc6
-rw-r--r--winbuild/MakefileBuild.vc5
13 files changed, 316 insertions, 238 deletions
diff --git a/lib/Makefile.inc b/lib/Makefile.inc
index 723b826e9..ae3f961cf 100644
--- a/lib/Makefile.inc
+++ b/lib/Makefile.inc
@@ -60,7 +60,8 @@ LIB_CFILES = altsvc.c amigaos.c asyn-ares.c asyn-thread.c base64.c \
sendf.c setopt.c sha256.c share.c slist.c smb.c smtp.c socketpair.c socks.c \
socks_gssapi.c socks_sspi.c speedcheck.c splay.c strcase.c strdup.c \
strerror.c strtok.c strtoofft.c system_win32.c telnet.c tftp.c timeval.c \
- transfer.c urlapi.c version.c warnless.c wildcard.c x509asn1.c dynbuf.c
+ transfer.c urlapi.c version.c warnless.c wildcard.c x509asn1.c dynbuf.c \
+ version_win32.c
LIB_HFILES = altsvc.h amigaos.h arpa_telnet.h asyn.h conncache.h connect.h \
content_encoding.h cookie.h curl_addrinfo.h curl_base64.h curl_ctype.h \
@@ -79,7 +80,7 @@ LIB_HFILES = altsvc.h amigaos.h arpa_telnet.h asyn.h conncache.h connect.h \
smb.h smtp.h sockaddr.h socketpair.h socks.h speedcheck.h splay.h strcase.h \
strdup.h strerror.h strtok.h strtoofft.h system_win32.h telnet.h tftp.h \
timeval.h transfer.h urlapi-int.h urldata.h warnless.h wildcard.h \
- x509asn1.h dynbuf.h
+ x509asn1.h dynbuf.h version_win32.h
LIB_RCFILES = libcurl.rc
diff --git a/lib/connect.c b/lib/connect.c
index bb30aa62c..313c23315 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -74,7 +74,7 @@
#include "warnless.h"
#include "conncache.h"
#include "multihandle.h"
-#include "system_win32.h"
+#include "version_win32.h"
#include "quic.h"
#include "socks.h"
@@ -1085,8 +1085,8 @@ void Curl_sndbufset(curl_socket_t sockfd)
static int detectOsState = DETECT_OS_NONE;
if(detectOsState == DETECT_OS_NONE) {
- if(Curl_verify_windows_version(6, 0, PLATFORM_WINNT,
- VERSION_GREATER_THAN_EQUAL))
+ if(curlx_verify_windows_version(6, 0, PLATFORM_WINNT,
+ VERSION_GREATER_THAN_EQUAL))
detectOsState = DETECT_OS_VISTA_OR_LATER;
else
detectOsState = DETECT_OS_PREVISTA;
diff --git a/lib/curl_sspi.c b/lib/curl_sspi.c
index 83ece9afd..512ce2411 100644
--- a/lib/curl_sspi.c
+++ b/lib/curl_sspi.c
@@ -28,6 +28,7 @@
#include "curl_sspi.h"
#include "curl_multibyte.h"
#include "system_win32.h"
+#include "version_win32.h"
#include "warnless.h"
/* The last #include files should be: */
@@ -82,7 +83,7 @@ CURLcode Curl_sspi_global_init(void)
* have both these DLLs (security.dll forwards calls to secur32.dll) */
/* Load SSPI dll into the address space of the calling process */
- if(Curl_verify_windows_version(4, 0, PLATFORM_WINNT, VERSION_EQUAL))
+ if(curlx_verify_windows_version(4, 0, PLATFORM_WINNT, VERSION_EQUAL))
s_hSecDll = Curl_load_library(TEXT("security.dll"));
else
s_hSecDll = Curl_load_library(TEXT("secur32.dll"));
diff --git a/lib/curlx.h b/lib/curlx.h
index a8bae14b9..98e51bf56 100644
--- a/lib/curlx.h
+++ b/lib/curlx.h
@@ -63,6 +63,9 @@
curlx_unicodefree()
*/
+#include "version_win32.h"
+/* "version_win32.h" provides curlx_verify_windows_version() */
+
/* Now setup curlx_ * names for the functions that are to become curlx_ and
be removed from a future libcurl official API:
curlx_getenv
diff --git a/lib/system_win32.c b/lib/system_win32.c
index b9587b5f3..2e59e032e 100644
--- a/lib/system_win32.c
+++ b/lib/system_win32.c
@@ -26,6 +26,7 @@
#include <curl/curl.h>
#include "system_win32.h"
+#include "version_win32.h"
#include "curl_sspi.h"
#include "warnless.h"
@@ -106,8 +107,8 @@ CURLcode Curl_win32_init(long flags)
Curl_if_nametoindex = pIfNameToIndex;
}
- if(Curl_verify_windows_version(6, 0, PLATFORM_WINNT,
- VERSION_GREATER_THAN_EQUAL)) {
+ if(curlx_verify_windows_version(6, 0, PLATFORM_WINNT,
+ VERSION_GREATER_THAN_EQUAL)) {
Curl_isVistaOrGreater = TRUE;
}
else
@@ -160,198 +161,6 @@ typedef HMODULE (APIENTRY *LOADLIBRARYEX_FN)(LPCTSTR, HANDLE, DWORD);
#endif
/*
- * Curl_verify_windows_version()
- *
- * This is used to verify if we are running on a specific windows version.
- *
- * Parameters:
- *
- * majorVersion [in] - The major version number.
- * minorVersion [in] - The minor version number.
- * platform [in] - The optional platform identifier.
- * condition [in] - The test condition used to specifier whether we are
- * checking a version less then, equal to or greater than
- * what is specified in the major and minor version
- * numbers.
- *
- * Returns TRUE if matched; otherwise FALSE.
- */
-bool Curl_verify_windows_version(const unsigned int majorVersion,
- const unsigned int minorVersion,
- const PlatformIdentifier platform,
- const VersionCondition condition)
-{
- bool matched = FALSE;
-
-#if defined(CURL_WINDOWS_APP)
- /* We have no way to determine the Windows version from Windows apps,
- so let's assume we're running on the target Windows version. */
- const WORD fullVersion = MAKEWORD(minorVersion, majorVersion);
- const WORD targetVersion = (WORD)_WIN32_WINNT;
-
- switch(condition) {
- case VERSION_LESS_THAN:
- matched = targetVersion < fullVersion;
- break;
-
- case VERSION_LESS_THAN_EQUAL:
- matched = targetVersion <= fullVersion;
- break;
-
- case VERSION_EQUAL:
- matched = targetVersion == fullVersion;
- break;
-
- case VERSION_GREATER_THAN_EQUAL:
- matched = targetVersion >= fullVersion;
- break;
-
- case VERSION_GREATER_THAN:
- matched = targetVersion > fullVersion;
- break;
- }
-
- if(matched && (platform == PLATFORM_WINDOWS)) {
- /* we're always running on PLATFORM_WINNT */
- matched = FALSE;
- }
-#elif !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_WIN2K) || \
- (_WIN32_WINNT < _WIN32_WINNT_WIN2K)
- OSVERSIONINFO osver;
-
- memset(&osver, 0, sizeof(osver));
- osver.dwOSVersionInfoSize = sizeof(osver);
-
- /* Find out Windows version */
- if(GetVersionEx(&osver)) {
- /* Verify the Operating System version number */
- switch(condition) {
- case VERSION_LESS_THAN:
- if(osver.dwMajorVersion < majorVersion ||
- (osver.dwMajorVersion == majorVersion &&
- osver.dwMinorVersion < minorVersion))
- matched = TRUE;
- break;
-
- case VERSION_LESS_THAN_EQUAL:
- if(osver.dwMajorVersion < majorVersion ||
- (osver.dwMajorVersion == majorVersion &&
- osver.dwMinorVersion <= minorVersion))
- matched = TRUE;
- break;
-
- case VERSION_EQUAL:
- if(osver.dwMajorVersion == majorVersion &&
- osver.dwMinorVersion == minorVersion)
- matched = TRUE;
- break;
-
- case VERSION_GREATER_THAN_EQUAL:
- if(osver.dwMajorVersion > majorVersion ||
- (osver.dwMajorVersion == majorVersion &&
- osver.dwMinorVersion >= minorVersion))
- matched = TRUE;
- break;
-
- case VERSION_GREATER_THAN:
- if(osver.dwMajorVersion > majorVersion ||
- (osver.dwMajorVersion == majorVersion &&
- osver.dwMinorVersion > minorVersion))
- matched = TRUE;
- break;
- }
-
- /* Verify the platform identifier (if necessary) */
- if(matched) {
- switch(platform) {
- case PLATFORM_WINDOWS:
- if(osver.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS)
- matched = FALSE;
- break;
-
- case PLATFORM_WINNT:
- if(osver.dwPlatformId != VER_PLATFORM_WIN32_NT)
- matched = FALSE;
-
- default: /* like platform == PLATFORM_DONT_CARE */
- break;
- }
- }
- }
-#else
- ULONGLONG cm = 0;
- OSVERSIONINFOEX osver;
- BYTE majorCondition;
- BYTE minorCondition;
- BYTE spMajorCondition;
- BYTE spMinorCondition;
-
- switch(condition) {
- case VERSION_LESS_THAN:
- majorCondition = VER_LESS;
- minorCondition = VER_LESS;
- spMajorCondition = VER_LESS_EQUAL;
- spMinorCondition = VER_LESS_EQUAL;
- break;
-
- case VERSION_LESS_THAN_EQUAL:
- majorCondition = VER_LESS_EQUAL;
- minorCondition = VER_LESS_EQUAL;
- spMajorCondition = VER_LESS_EQUAL;
- spMinorCondition = VER_LESS_EQUAL;
- break;
-
- case VERSION_EQUAL:
- majorCondition = VER_EQUAL;
- minorCondition = VER_EQUAL;
- spMajorCondition = VER_GREATER_EQUAL;
- spMinorCondition = VER_GREATER_EQUAL;
- break;
-
- case VERSION_GREATER_THAN_EQUAL:
- majorCondition = VER_GREATER_EQUAL;
- minorCondition = VER_GREATER_EQUAL;
- spMajorCondition = VER_GREATER_EQUAL;
- spMinorCondition = VER_GREATER_EQUAL;
- break;
-
- case VERSION_GREATER_THAN:
- majorCondition = VER_GREATER;
- minorCondition = VER_GREATER;
- spMajorCondition = VER_GREATER_EQUAL;
- spMinorCondition = VER_GREATER_EQUAL;
- break;
-
- default:
- return FALSE;
- }
-
- memset(&osver, 0, sizeof(osver));
- osver.dwOSVersionInfoSize = sizeof(osver);
- osver.dwMajorVersion = majorVersion;
- osver.dwMinorVersion = minorVersion;
- if(platform == PLATFORM_WINDOWS)
- osver.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS;
- else if(platform == PLATFORM_WINNT)
- osver.dwPlatformId = VER_PLATFORM_WIN32_NT;
-
- cm = VerSetConditionMask(cm, VER_MAJORVERSION, majorCondition);
- cm = VerSetConditionMask(cm, VER_MINORVERSION, minorCondition);
- cm = VerSetConditionMask(cm, VER_SERVICEPACKMAJOR, spMajorCondition);
- cm = VerSetConditionMask(cm, VER_SERVICEPACKMINOR, spMinorCondition);
- if(platform != PLATFORM_DONT_CARE)
- cm = VerSetConditionMask(cm, VER_PLATFORMID, VER_EQUAL);
-
- if(VerifyVersionInfo(&osver, (VER_MAJORVERSION | VER_MINORVERSION |
- VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR),
- cm))
- matched = TRUE;
-#endif
-
- return matched;
-}
-
-/*
* Curl_load_library()
*
* This is used to dynamically load DLLs using the most secure method available
diff --git a/lib/system_win32.h b/lib/system_win32.h
index d2882fce1..474fc8bed 100644
--- a/lib/system_win32.h
+++ b/lib/system_win32.h
@@ -32,34 +32,12 @@ extern bool Curl_isVistaOrGreater;
CURLcode Curl_win32_init(long flags);
void Curl_win32_cleanup(long init_flags);
-/* Version condition */
-typedef enum {
- VERSION_LESS_THAN,
- VERSION_LESS_THAN_EQUAL,
- VERSION_EQUAL,
- VERSION_GREATER_THAN_EQUAL,
- VERSION_GREATER_THAN
-} VersionCondition;
-
-/* Platform identifier */
-typedef enum {
- PLATFORM_DONT_CARE,
- PLATFORM_WINDOWS,
- PLATFORM_WINNT
-} PlatformIdentifier;
-
/* We use our own typedef here since some headers might lack this */
typedef unsigned int(WINAPI *IF_NAMETOINDEX_FN)(const char *);
/* This is used instead of if_nametoindex if available on Windows */
extern IF_NAMETOINDEX_FN Curl_if_nametoindex;
-/* This is used to verify if we are running on a specific windows version */
-bool Curl_verify_windows_version(const unsigned int majorVersion,
- const unsigned int minorVersion,
- const PlatformIdentifier platform,
- const VersionCondition condition);
-
/* This is used to dynamically load DLLs */
HMODULE Curl_load_library(LPCTSTR filename);
diff --git a/lib/version_win32.c b/lib/version_win32.c
new file mode 100644
index 000000000..6561d36be
--- /dev/null
+++ b/lib/version_win32.c
@@ -0,0 +1,226 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2016 - 2020, Steve Holme, <steve_holme@hotmail.com>.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#if defined(WIN32)
+
+#include <curl/curl.h>
+#include "version_win32.h"
+
+/* The last #include files should be: */
+#include "curl_memory.h"
+#include "memdebug.h"
+
+/*
+ * curlx_verify_windows_version()
+ *
+ * This is used to verify if we are running on a specific windows version.
+ *
+ * Parameters:
+ *
+ * majorVersion [in] - The major version number.
+ * minorVersion [in] - The minor version number.
+ * platform [in] - The optional platform identifier.
+ * condition [in] - The test condition used to specifier whether we are
+ * checking a version less then, equal to or greater than
+ * what is specified in the major and minor version
+ * numbers.
+ *
+ * Returns TRUE if matched; otherwise FALSE.
+ */
+bool curlx_verify_windows_version(const unsigned int majorVersion,
+ const unsigned int minorVersion,
+ const PlatformIdentifier platform,
+ const VersionCondition condition)
+{
+ bool matched = FALSE;
+
+#if defined(CURL_WINDOWS_APP)
+ /* We have no way to determine the Windows version from Windows apps,
+ so let's assume we're running on the target Windows version. */
+ const WORD fullVersion = MAKEWORD(minorVersion, majorVersion);
+ const WORD targetVersion = (WORD)_WIN32_WINNT;
+
+ switch(condition) {
+ case VERSION_LESS_THAN:
+ matched = targetVersion < fullVersion;
+ break;
+
+ case VERSION_LESS_THAN_EQUAL:
+ matched = targetVersion <= fullVersion;
+ break;
+
+ case VERSION_EQUAL:
+ matched = targetVersion == fullVersion;
+ break;
+
+ case VERSION_GREATER_THAN_EQUAL:
+ matched = targetVersion >= fullVersion;
+ break;
+
+ case VERSION_GREATER_THAN:
+ matched = targetVersion > fullVersion;
+ break;
+ }
+
+ if(matched && (platform == PLATFORM_WINDOWS)) {
+ /* we're always running on PLATFORM_WINNT */
+ matched = FALSE;
+ }
+#elif !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_WIN2K) || \
+ (_WIN32_WINNT < _WIN32_WINNT_WIN2K)
+ OSVERSIONINFO osver;
+
+ memset(&osver, 0, sizeof(osver));
+ osver.dwOSVersionInfoSize = sizeof(osver);
+
+ /* Find out Windows version */
+ if(GetVersionEx(&osver)) {
+ /* Verify the Operating System version number */
+ switch(condition) {
+ case VERSION_LESS_THAN:
+ if(osver.dwMajorVersion < majorVersion ||
+ (osver.dwMajorVersion == majorVersion &&
+ osver.dwMinorVersion < minorVersion))
+ matched = TRUE;
+ break;
+
+ case VERSION_LESS_THAN_EQUAL:
+ if(osver.dwMajorVersion < majorVersion ||
+ (osver.dwMajorVersion == majorVersion &&
+ osver.dwMinorVersion <= minorVersion))
+ matched = TRUE;
+ break;
+
+ case VERSION_EQUAL:
+ if(osver.dwMajorVersion == majorVersion &&
+ osver.dwMinorVersion == minorVersion)
+ matched = TRUE;
+ break;
+
+ case VERSION_GREATER_THAN_EQUAL:
+ if(osver.dwMajorVersion > majorVersion ||
+ (osver.dwMajorVersion == majorVersion &&
+ osver.dwMinorVersion >= minorVersion))
+ matched = TRUE;
+ break;
+
+ case VERSION_GREATER_THAN:
+ if(osver.dwMajorVersion > majorVersion ||
+ (osver.dwMajorVersion == majorVersion &&
+ osver.dwMinorVersion > minorVersion))
+ matched = TRUE;
+ break;
+ }
+
+ /* Verify the platform identifier (if necessary) */
+ if(matched) {
+ switch(platform) {
+ case PLATFORM_WINDOWS:
+ if(osver.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS)
+ matched = FALSE;
+ break;
+
+ case PLATFORM_WINNT:
+ if(osver.dwPlatformId != VER_PLATFORM_WIN32_NT)
+ matched = FALSE;
+
+ default: /* like platform == PLATFORM_DONT_CARE */
+ break;
+ }
+ }
+ }
+#else
+ ULONGLONG cm = 0;
+ OSVERSIONINFOEX osver;
+ BYTE majorCondition;
+ BYTE minorCondition;
+ BYTE spMajorCondition;
+ BYTE spMinorCondition;
+
+ switch(condition) {
+ case VERSION_LESS_THAN:
+ majorCondition = VER_LESS;
+ minorCondition = VER_LESS;
+ spMajorCondition = VER_LESS_EQUAL;
+ spMinorCondition = VER_LESS_EQUAL;
+ break;
+
+ case VERSION_LESS_THAN_EQUAL:
+ majorCondition = VER_LESS_EQUAL;
+ minorCondition = VER_LESS_EQUAL;
+ spMajorCondition = VER_LESS_EQUAL;
+ spMinorCondition = VER_LESS_EQUAL;
+ break;
+
+ case VERSION_EQUAL:
+ majorCondition = VER_EQUAL;
+ minorCondition = VER_EQUAL;
+ spMajorCondition = VER_GREATER_EQUAL;
+ spMinorCondition = VER_GREATER_EQUAL;
+ break;
+
+ case VERSION_GREATER_THAN_EQUAL:
+ majorCondition = VER_GREATER_EQUAL;
+ minorCondition = VER_GREATER_EQUAL;
+ spMajorCondition = VER_GREATER_EQUAL;
+ spMinorCondition = VER_GREATER_EQUAL;
+ break;
+
+ case VERSION_GREATER_THAN:
+ majorCondition = VER_GREATER;
+ minorCondition = VER_GREATER;
+ spMajorCondition = VER_GREATER_EQUAL;
+ spMinorCondition = VER_GREATER_EQUAL;
+ break;
+
+ default:
+ return FALSE;
+ }
+
+ memset(&osver, 0, sizeof(osver));
+ osver.dwOSVersionInfoSize = sizeof(osver);
+ osver.dwMajorVersion = majorVersion;
+ osver.dwMinorVersion = minorVersion;
+ if(platform == PLATFORM_WINDOWS)
+ osver.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS;
+ else if(platform == PLATFORM_WINNT)
+ osver.dwPlatformId = VER_PLATFORM_WIN32_NT;
+
+ cm = VerSetConditionMask(cm, VER_MAJORVERSION, majorCondition);
+ cm = VerSetConditionMask(cm, VER_MINORVERSION, minorCondition);
+ cm = VerSetConditionMask(cm, VER_SERVICEPACKMAJOR, spMajorCondition);
+ cm = VerSetConditionMask(cm, VER_SERVICEPACKMINOR, spMinorCondition);
+ if(platform != PLATFORM_DONT_CARE)
+ cm = VerSetConditionMask(cm, VER_PLATFORMID, VER_EQUAL);
+
+ if(VerifyVersionInfo(&osver, (VER_MAJORVERSION | VER_MINORVERSION |
+ VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR),
+ cm))
+ matched = TRUE;
+#endif
+
+ return matched;
+}
+
+#endif /* WIN32 */
diff --git a/lib/version_win32.h b/lib/version_win32.h
new file mode 100644
index 000000000..b0b60dd37
--- /dev/null
+++ b/lib/version_win32.h
@@ -0,0 +1,53 @@
+#ifndef HEADER_CURL_VERSION_WIN32_H
+#define HEADER_CURL_VERSION_WIN32_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2016 - 2019, Steve Holme, <steve_holme@hotmail.com>.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#if defined(WIN32)
+
+/* Version condition */
+typedef enum {
+ VERSION_LESS_THAN,
+ VERSION_LESS_THAN_EQUAL,
+ VERSION_EQUAL,
+ VERSION_GREATER_THAN_EQUAL,
+ VERSION_GREATER_THAN
+} VersionCondition;
+
+/* Platform identifier */
+typedef enum {
+ PLATFORM_DONT_CARE,
+ PLATFORM_WINDOWS,
+ PLATFORM_WINNT
+} PlatformIdentifier;
+
+/* This is used to verify if we are running on a specific windows version */
+bool curlx_verify_windows_version(const unsigned int majorVersion,
+ const unsigned int minorVersion,
+ const PlatformIdentifier platform,
+ const VersionCondition condition);
+
+#endif /* WIN32 */
+
+#endif /* HEADER_CURL_VERSION_WIN32_H */
diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c
index c685de2e1..1c1432d75 100644
--- a/lib/vtls/schannel.c
+++ b/lib/vtls/schannel.c
@@ -50,7 +50,7 @@
#include "x509asn1.h"
#include "curl_printf.h"
#include "multiif.h"
-#include "system_win32.h"
+#include "version_win32.h"
/* The last #include file should be: */
#include "curl_memory.h"
@@ -436,8 +436,8 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
"schannel: SSL/TLS connection with %s port %hu (step 1/3)\n",
hostname, conn->remote_port));
- if(Curl_verify_windows_version(5, 1, PLATFORM_WINNT,
- VERSION_LESS_THAN_EQUAL)) {
+ if(curlx_verify_windows_version(5, 1, PLATFORM_WINNT,
+ VERSION_LESS_THAN_EQUAL)) {
/* Schannel in Windows XP (OS version 5.1) uses legacy handshakes and
algorithms that may not be supported by all servers. */
infof(data, "schannel: Windows version is old and may not be able to "
@@ -450,8 +450,8 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
BACKEND->use_alpn = conn->bits.tls_enable_alpn &&
!GetProcAddress(GetModuleHandle(TEXT("ntdll")),
"wine_get_version") &&
- Curl_verify_windows_version(6, 3, PLATFORM_WINNT,
- VERSION_GREATER_THAN_EQUAL);
+ curlx_verify_windows_version(6, 3, PLATFORM_WINNT,
+ VERSION_GREATER_THAN_EQUAL);
#else
BACKEND->use_alpn = false;
#endif
@@ -467,8 +467,8 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
#else
#ifdef HAS_MANUAL_VERIFY_API
if(SSL_CONN_CONFIG(CAfile)) {
- if(Curl_verify_windows_version(6, 1, PLATFORM_WINNT,
- VERSION_GREATER_THAN_EQUAL)) {
+ if(curlx_verify_windows_version(6, 1, PLATFORM_WINNT,
+ VERSION_GREATER_THAN_EQUAL)) {
BACKEND->use_manual_cred_validation = true;
}
else {
@@ -2015,8 +2015,8 @@ schannel_recv(struct connectdata *conn, int sockindex,
*/
if(len && !BACKEND->decdata_offset && BACKEND->recv_connection_closed &&
!BACKEND->recv_sspi_close_notify) {
- bool isWin2k = Curl_verify_windows_version(5, 0, PLATFORM_WINNT,
- VERSION_EQUAL);
+ bool isWin2k = curlx_verify_windows_version(5, 0, PLATFORM_WINNT,
+ VERSION_EQUAL);
if(isWin2k && sspi_status == SEC_E_OK)
BACKEND->recv_sspi_close_notify = true;
diff --git a/lib/vtls/schannel_verify.c b/lib/vtls/schannel_verify.c
index bdd7199e4..ab7be3950 100644
--- a/lib/vtls/schannel_verify.c
+++ b/lib/vtls/schannel_verify.c
@@ -45,7 +45,7 @@
#include "curl_multibyte.h"
#include "curl_printf.h"
#include "hostcheck.h"
-#include "system_win32.h"
+#include "version_win32.h"
/* The last #include file should be: */
#include "curl_memory.h"
@@ -317,8 +317,8 @@ static DWORD cert_get_name_string(struct Curl_easy *data,
DWORD i;
/* CERT_NAME_SEARCH_ALL_NAMES_FLAG is available from Windows 8 onwards. */
- if(Curl_verify_windows_version(6, 2, PLATFORM_WINNT,
- VERSION_GREATER_THAN_EQUAL)) {
+ if(curlx_verify_windows_version(6, 2, PLATFORM_WINNT,
+ VERSION_GREATER_THAN_EQUAL)) {
#ifdef CERT_NAME_SEARCH_ALL_NAMES_FLAG
/* CertGetNameString will provide the 8-bit character string without
* any decoding */
@@ -564,7 +564,7 @@ CURLcode Curl_verify_certificate(struct connectdata *conn, int sockindex)
* trusted certificates. This is only supported on Windows 7+.
*/
- if(Curl_verify_windows_version(6, 1, PLATFORM_WINNT, VERSION_LESS_THAN)) {
+ if(curlx_verify_windows_version(6, 1, PLATFORM_WINNT, VERSION_LESS_THAN)) {
failf(data, "schannel: this version of Windows is too old to support "
"certificate verification via CA bundle file.");
result = CURLE_SSL_CACERT_BADFILE;
diff --git a/projects/generate.bat b/projects/generate.bat
index 148a290de..88979683f 100644
--- a/projects/generate.bat
+++ b/projects/generate.bat
@@ -286,6 +286,7 @@ rem
call :element %1 lib "warnless.c" %3
call :element %1 lib "curl_ctype.c" %3
call :element %1 lib "curl_multibyte.c" %3
+ call :element %1 lib "version_win32.c" %3
) else if "!var!" == "CURL_SRC_X_H_FILES" (
call :element %1 lib "config-win32.h" %3
call :element %1 lib "curl_setup.h" %3
@@ -294,6 +295,7 @@ rem
call :element %1 lib "warnless.h" %3
call :element %1 lib "curl_ctype.h" %3
call :element %1 lib "curl_multibyte.h" %3
+ call :element %1 lib "version_win32.h" %3
) else if "!var!" == "CURL_LIB_C_FILES" (
for /f "delims=" %%c in ('dir /b ..\lib\*.c') do call :element %1 lib "%%c" %3
) else if "!var!" == "CURL_LIB_H_FILES" (
diff --git a/src/Makefile.inc b/src/Makefile.inc
index 17dd178e0..c0b9ad864 100644
--- a/src/Makefile.inc
+++ b/src/Makefile.inc
@@ -35,7 +35,8 @@ CURLX_CFILES = \
../lib/nonblock.c \
../lib/warnless.c \
../lib/curl_ctype.c \
- ../lib/curl_multibyte.c
+ ../lib/curl_multibyte.c \
+ ../lib/version_win32.c
CURLX_HFILES = \
../lib/curl_setup.h \
@@ -43,7 +44,8 @@ CURLX_HFILES = \
../lib/nonblock.h \
../lib/warnless.h \
../lib/curl_ctype.h \
- ../lib/curl_multibyte.h
+ ../lib/curl_multibyte.h \
+ ../lib/version_win32.h
CURL_CFILES = \
slist_wc.c \
diff --git a/winbuild/MakefileBuild.vc b/winbuild/MakefileBuild.vc
index db01eab7f..568fb11b6 100644
--- a/winbuild/MakefileBuild.vc
+++ b/winbuild/MakefileBuild.vc
@@ -619,7 +619,8 @@ CURL_FROM_LIBCURL=$(CURL_DIROBJ)\tool_hugehelp.obj \
$(CURL_DIROBJ)\strtoofft.obj \
$(CURL_DIROBJ)\warnless.obj \
$(CURL_DIROBJ)\curl_ctype.obj \
- $(CURL_DIROBJ)\curl_multibyte.obj
+ $(CURL_DIROBJ)\curl_multibyte.obj \
+ $(CURL_DIROBJ)\version_win32.obj
$(PROGRAM_NAME): $(CURL_DIROBJ) $(CURL_FROM_LIBCURL) $(EXE_OBJS)
$(CURL_LINK) $(CURL_LFLAGS) $(CURL_LIBCURL_LIBNAME) $(WIN_LIBS) $(CURL_FROM_LIBCURL) $(EXE_OBJS)
@@ -640,6 +641,8 @@ $(CURL_DIROBJ)\curl_ctype.obj: ../lib/curl_ctype.c
$(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/curl_ctype.c
$(CURL_DIROBJ)\curl_multibyte.obj: ../lib/curl_multibyte.c
$(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/curl_multibyte.c
+$(CURL_DIROBJ)\version_win32.obj: ../lib/version_win32.c
+ $(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/version_win32.c
$(CURL_DIROBJ)\curl.res: $(CURL_SRC_DIR)\curl.rc
rc $(CURL_RC_FLAGS)