master
1/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) Steve Holme, <steve_holme@hotmail.com>.
9 *
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.se/docs/copyright.html.
13 *
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 * SPDX-License-Identifier: curl
22 *
23 ***************************************************************************/
24#include "curl_setup.h"
26#ifdef _WIN32
28#include "curlx/version_win32.h"
30#ifndef CURL_WINDOWS_UWP
31/* This Unicode version struct works for VerifyVersionInfoW (OSVERSIONINFOEXW)
32 and RtlVerifyVersionInfo (RTLOSVERSIONINFOEXW) */
33struct OUR_OSVERSIONINFOEXW {
34 ULONG dwOSVersionInfoSize;
35 ULONG dwMajorVersion;
36 ULONG dwMinorVersion;
37 ULONG dwBuildNumber;
38 ULONG dwPlatformId;
39 WCHAR szCSDVersion[128];
40 USHORT wServicePackMajor;
41 USHORT wServicePackMinor;
42 USHORT wSuiteMask;
43 UCHAR wProductType;
44 UCHAR wReserved;
45};
47typedef LONG (APIENTRY *RTLVERIFYVERSIONINFO_FN)
48 (struct OUR_OSVERSIONINFOEXW *, ULONG, ULONGLONG);
49static RTLVERIFYVERSIONINFO_FN s_pRtlVerifyVersionInfo;
51void curlx_verify_windows_init(void)
52{
53#if defined(__clang__) && __clang_major__ >= 16
54#pragma clang diagnostic push
55#pragma clang diagnostic ignored "-Wcast-function-type-strict"
56#endif
57 s_pRtlVerifyVersionInfo = CURLX_FUNCTION_CAST(RTLVERIFYVERSIONINFO_FN,
58 GetProcAddress(GetModuleHandle(TEXT("ntdll")), "RtlVerifyVersionInfo"));
59#if defined(__clang__) && __clang_major__ >= 16
60#pragma clang diagnostic pop
61#endif
62}
63#endif /* !CURL_WINDOWS_UWP */
65/*
66 * curlx_verify_windows_version()
67 *
68 * This is used to verify if we are running on a specific Windows version.
69 *
70 * Parameters:
71 *
72 * majorVersion [in] - The major version number.
73 * minorVersion [in] - The minor version number.
74 * buildVersion [in] - The build version number. If 0, this parameter is
75 * ignored.
76 * platform [in] - The optional platform identifier.
77 * condition [in] - The test condition used to specifier whether we are
78 * checking a version less than, equal to or greater than
79 * what is specified in the major and minor version
80 * numbers.
81 *
82 * Returns TRUE if matched; otherwise FALSE.
83 */
84bool curlx_verify_windows_version(const unsigned int majorVersion,
85 const unsigned int minorVersion,
86 const unsigned int buildVersion,
87 const PlatformIdentifier platform,
88 const VersionCondition condition)
89{
90 bool matched = FALSE;
92#ifdef CURL_WINDOWS_UWP
93 /* We have no way to determine the Windows version from Windows apps,
94 so let's assume we are running on the target Windows version. */
95 const WORD fullVersion = MAKEWORD(minorVersion, majorVersion);
96 const WORD targetVersion = (WORD)_WIN32_WINNT;
98 (void)buildVersion;
100 switch(condition) {
101 case VERSION_LESS_THAN:
102 matched = targetVersion < fullVersion;
103 break;
105 case VERSION_LESS_THAN_EQUAL:
106 matched = targetVersion <= fullVersion;
107 break;
109 case VERSION_EQUAL:
110 matched = targetVersion == fullVersion;
111 break;
113 case VERSION_GREATER_THAN_EQUAL:
114 matched = targetVersion >= fullVersion;
115 break;
117 case VERSION_GREATER_THAN:
118 matched = targetVersion > fullVersion;
119 break;
120 }
122 if(matched && (platform == PLATFORM_WINDOWS)) {
123 /* we are always running on PLATFORM_WINNT */
124 matched = FALSE;
125 }
126#else
127 ULONGLONG cm = 0;
128 struct OUR_OSVERSIONINFOEXW osver;
129 BYTE majorCondition;
130 BYTE minorCondition;
131 BYTE buildCondition;
132 BYTE spMajorCondition;
133 BYTE spMinorCondition;
134 DWORD dwTypeMask = VER_MAJORVERSION | VER_MINORVERSION |
135 VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR;
137 switch(condition) {
138 case VERSION_LESS_THAN:
139 majorCondition = VER_LESS;
140 minorCondition = VER_LESS;
141 buildCondition = VER_LESS;
142 spMajorCondition = VER_LESS_EQUAL;
143 spMinorCondition = VER_LESS_EQUAL;
144 break;
146 case VERSION_LESS_THAN_EQUAL:
147 majorCondition = VER_LESS_EQUAL;
148 minorCondition = VER_LESS_EQUAL;
149 buildCondition = VER_LESS_EQUAL;
150 spMajorCondition = VER_LESS_EQUAL;
151 spMinorCondition = VER_LESS_EQUAL;
152 break;
154 case VERSION_EQUAL:
155 majorCondition = VER_EQUAL;
156 minorCondition = VER_EQUAL;
157 buildCondition = VER_EQUAL;
158 spMajorCondition = VER_GREATER_EQUAL;
159 spMinorCondition = VER_GREATER_EQUAL;
160 break;
162 case VERSION_GREATER_THAN_EQUAL:
163 majorCondition = VER_GREATER_EQUAL;
164 minorCondition = VER_GREATER_EQUAL;
165 buildCondition = VER_GREATER_EQUAL;
166 spMajorCondition = VER_GREATER_EQUAL;
167 spMinorCondition = VER_GREATER_EQUAL;
168 break;
170 case VERSION_GREATER_THAN:
171 majorCondition = VER_GREATER;
172 minorCondition = VER_GREATER;
173 buildCondition = VER_GREATER;
174 spMajorCondition = VER_GREATER_EQUAL;
175 spMinorCondition = VER_GREATER_EQUAL;
176 break;
178 default:
179 return FALSE;
180 }
182 memset(&osver, 0, sizeof(osver));
183 osver.dwOSVersionInfoSize = sizeof(osver);
184 osver.dwMajorVersion = majorVersion;
185 osver.dwMinorVersion = minorVersion;
186 osver.dwBuildNumber = buildVersion;
187 if(platform == PLATFORM_WINDOWS)
188 osver.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS;
189 else if(platform == PLATFORM_WINNT)
190 osver.dwPlatformId = VER_PLATFORM_WIN32_NT;
192 cm = VerSetConditionMask(cm, VER_MAJORVERSION, majorCondition);
193 cm = VerSetConditionMask(cm, VER_MINORVERSION, minorCondition);
194 cm = VerSetConditionMask(cm, VER_SERVICEPACKMAJOR, spMajorCondition);
195 cm = VerSetConditionMask(cm, VER_SERVICEPACKMINOR, spMinorCondition);
197 if(platform != PLATFORM_DONT_CARE) {
198 cm = VerSetConditionMask(cm, VER_PLATFORMID, VER_EQUAL);
199 dwTypeMask |= VER_PLATFORMID;
200 }
202 /* Later versions of Windows have version functions that may not return the
203 real version of Windows unless the application is so manifested. We prefer
204 the real version always, so we use the Rtl variant of the function when
205 possible. Note though the function signatures have underlying fundamental
206 types that are the same, the return values are different. */
207 if(s_pRtlVerifyVersionInfo)
208 matched = !s_pRtlVerifyVersionInfo(&osver, dwTypeMask, cm);
209 else
210 matched = !!VerifyVersionInfoW((OSVERSIONINFOEXW *)&osver, dwTypeMask, cm);
212 /* Compare the build number separately. VerifyVersionInfo normally compares
213 major.minor in hierarchical order (eg 1.9 is less than 2.0) but does not
214 do the same for build (eg 1.9 build 222 is not less than 2.0 build 111).
215 Build comparison is only needed when build numbers are equal (eg 1.9 is
216 always less than 2.0 so build comparison is not needed). */
217 if(matched && buildVersion &&
218 (condition == VERSION_EQUAL ||
219 ((condition == VERSION_GREATER_THAN_EQUAL ||
220 condition == VERSION_LESS_THAN_EQUAL) &&
221 curlx_verify_windows_version(majorVersion, minorVersion, 0,
222 platform, VERSION_EQUAL)))) {
224 cm = VerSetConditionMask(0, VER_BUILDNUMBER, buildCondition);
225 dwTypeMask = VER_BUILDNUMBER;
226 if(s_pRtlVerifyVersionInfo)
227 matched = !s_pRtlVerifyVersionInfo(&osver, dwTypeMask, cm);
228 else
229 matched = !!VerifyVersionInfoW((OSVERSIONINFOEXW *)&osver,
230 dwTypeMask, cm);
231 }
233#endif
235 return matched;
236}
238#endif /* _WIN32 */
Diagnostics4 git calls · 25 ms
CallStatusSizeTime025 ms
discover200152 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=1 git.response.bytes=152 git.server.agent=gitty/1.0 git.server.object_format=sha1 git.server.caps=agent ls-refs fetch object-format git.server.fetch=shallow filter sideband-all git.protocol.version=2 git.pkt.frames=8 git.pkt.data=6 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=152 git.pkt.payload.max=34
ls-refs200149 B · hit2 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=2 git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=149 git.pkt.payload.max=78 git.ls_refs.count=2 git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=20 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=blob:none git.fetch.filter.requested=tree:0 git.fetch.filter.fallback=blob:none git.fetch.filter.learned=false git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=10 git.pkt.data=8 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=293470 git.pkt.payload.max=65516 git.sideband.band1.bytes=293354 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=87 git.pack.bytes=293354 git.pack.ofs_delta=0 git.pack.ref_delta=1 git.pack.chain.max=1 git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0 git.pack.full=86Open pack map
fetch2002.6 KiB · hit20 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=2629 git.response.cache=HIT git.response.duration_ms=20 git.fetch.wants=296a38d9247b176476cd5613ca6c7d1859bd1875 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=2629 git.pkt.payload.max=2608 git.sideband.band1.bytes=2607 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
- Ref
- refs/heads/master
- Commit
- 31c911efe5652725e930f4d2e60c9060e5f6646d
- cf-ray
- a5e3344cefb5f485
- Request
- 1b79b8ee…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format