Repository navigation
Conversation
…s 10/11 features (like TLS 1.3).
|
Apart from the checksrc failures, this looks good to me. |
There was a problem hiding this comment.
I tried this and it doesn't work the way I expected. For example, if I have Windows 7 which is 6.1 (major.minor) build 7601 and I try to match a higher build number but a lower version it will return false. For example:
if(curlx_verify_windows_version(6, 0, 7602, PLATFORM_WINNT,
VERSION_GREATER_THAN_EQUAL))
// won't happen because 7602 > 7601, even though 6.0 < 6.1
That does not make sense to me but is because of the way MS implemented the function. OTOH build numbers seem to only increase but I don't know where that's guaranteed. (edit: to clarify I mean I don't know what's to say windows 10 can't have a build number higher than a windows 11 build number)
I think we would need to call the verifyversion function more than once. Changes would also be needed to the separate legacy code that uses XXX_THAN_EQUAL , for example
case VERSION_GREATER_THAN_EQUAL:
if(osver.dwMajorVersion > majorVersion ||
(osver.dwMajorVersion == majorVersion &&
osver.dwMinorVersion >= minorVersion) ||
(buildVersion != 0 &&
(osver.dwMajorVersion == majorVersion &&
osver.dwMinorVersion == minorVersion &&
osver.dwBuildNumber >= buildVersion)))should probably be this:
case VERSION_GREATER_THAN_EQUAL:
if(osver.dwMajorVersion > majorVersion ||
(osver.dwMajorVersion == majorVersion &&
osver.dwMinorVersion > minorVersion) ||
((osver.dwMajorVersion == majorVersion &&
osver.dwMinorVersion == minorVersion &&
osver.dwBuildNumber >= buildVersion)))
actually probably this: diff --git a/lib/version_win32.c b/lib/version_win32.c
index 3eb3c20..a7ad487 100644
--- a/lib/version_win32.c
+++ b/lib/version_win32.c
@@ -132,10 +132,10 @@ bool curlx_verify_windows_version(const unsigned int majorVersion,
case VERSION_LESS_THAN_EQUAL:
if(osver.dwMajorVersion < majorVersion ||
(osver.dwMajorVersion == majorVersion &&
- osver.dwMinorVersion <= minorVersion) ||
- (buildVersion != 0 &&
- (osver.dwMajorVersion == majorVersion &&
- osver.dwMinorVersion == minorVersion &&
+ osver.dwMinorVersion < minorVersion) ||
+ (osver.dwMajorVersion == majorVersion &&
+ osver.dwMinorVersion == minorVersion &&
+ (buildVersion == 0 ||
osver.dwBuildNumber <= buildVersion)))
matched = TRUE;
break;
@@ -151,10 +151,10 @@ bool curlx_verify_windows_version(const unsigned int majorVersion,
case VERSION_GREATER_THAN_EQUAL:
if(osver.dwMajorVersion > majorVersion ||
(osver.dwMajorVersion == majorVersion &&
- osver.dwMinorVersion >= minorVersion) ||
- (buildVersion != 0 &&
- (osver.dwMajorVersion == majorVersion &&
- osver.dwMinorVersion == minorVersion &&
+ osver.dwMinorVersion > minorVersion) ||
+ (osver.dwMajorVersion == majorVersion &&
+ osver.dwMinorVersion == minorVersion &&
+ (buildVersion == 0 ||
osver.dwBuildNumber >= buildVersion)))
matched = TRUE;
break;I will see if I can do something similar for the VerifyVersionInfo call. I don't see any way to get around calling it more than once. |
For our purposes (and as things are right now), this is fine. Windows 11 is really Windows 10.0 with a build number higher than the newest Windows 10. But more broadly, this is why in my original PR I dropped the half of the algorithm that used Ultimately, I think that's the better design decision, but there was pushback on that PR, and one person in particular didn't like that I made that choice.
I'm a bit confused on that suggestion. Are you suggesting that change so it more closely matches the quirky behavior of VerifyVersionInfoW()? If so, wouldn't the better option just be to just coalesce around one non-quirky algorithm rather than splitting it into 2 and trying to match the quirky behavior? I mentioned this in the other PR as a way to reduce bugs and increase security (less divergent paths & more eyeball on one algo). |
No what I'm suggesting is for example 10.0 build 222 should compare less than 11.0 build 111. VerifyVersionInfoW cannot do that comparison correctly (IMO) in a single call. See master...jay:pr_7824_modified, the squashme commit for the changes I think are needed. Basically multiple comparisons are needed if the build number needs to be compared. (edit: squashme commit updated this afternoon)
I don't know why it was necessary to keep GetVersionEx but I assume very old Windows systems. I really don't know why we need two paths but other project members have spoken up for those legacy systems in the past, and in particular separating GetVersionEx (because MS said they will remove it) from VerifyVersionInfo. I sympathize but I'm not interested in having that discussion right now because it might stop this from moving forward. |
I think it's needed for Windows Embedded Compact (formerly CE), which is not based on Windows NT. |
Since there hasn't been any reply I intend to land that version and I've moved it to #7867 to run CI. Normally I would force push to the existing PR branch but I didn't here because it looks like the head branch is in your organization's repo. |
|
Either way, Jay. Sorry for not getting back to this. Hadn’t had a free second in a while. |
|
Closing in favor of #7867 |
Check build version numbers on Windows. Required for enabling "evergreen" Windows 10/11 features (like TLS 1.3).
Builds upon @jay 's PR: #7810
This is required for: #7784
Less controversial version of #7727