Skip to content

version_win32: use actual version instead of manifested version - #7810

Closed
jay wants to merge 2 commits into
curl:masterfrom
jay:win32_improve_vercheck
Closed

jay wants to merge 2 commits into
curl:masterfrom
jay:win32_improve_vercheck

Conversation

@jay

@jay jay commented Oct 4, 2021

Copy link
Copy Markdown
Member
  • Use RtlVerifyVersionInfo instead of VerifyVersionInfo, when possible.

Later versions of Windows have normal version functions that compare and
return versions based on the way the application is manifested, instead
of the actual version of Windows the application is running on. We
prefer the actual version of Windows so we'll now call the Rtl variant
of version functions (RtlVerifyVersionInfo) which does a proper
comparison of the actual version.

Reported-by: Wyatt O'Day

Ref: #7727

Fixes #7742
Closes #xxxx

@wyattoday

Copy link
Copy Markdown
Contributor

Looks good to me. Just needs build-version support to properly support my TLS 1.3 PR.

- Use RtlVerifyVersionInfo instead of VerifyVersionInfo, when possible.

Later versions of Windows have normal version functions that compare and
return versions based on the way the application is manifested, instead
of the actual version of Windows the application is running on. We
prefer the actual version of Windows so we'll now call the Rtl variant
of version functions (RtlVerifyVersionInfo) which does a proper
comparison of the actual version.

Reported-by: Wyatt O'Day

Ref: curl#7727

Fixes curl#7742
Closes #xxxx
@jay
jay force-pushed the win32_improve_vercheck branch from 8e2579e to 61bd2e1 Compare October 4, 2021 20:11
@jay

jay commented Oct 4, 2021

Copy link
Copy Markdown
Member Author

You're welcome to add a const unsigned int buildNumber param after this change lands. I'd like to keep this as simple as possible to move things along.

@MarcelRaad MarcelRaad left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record, I agree with @vszakats that it's not libcurl's job to work around bugs in applications libcurl is directly or indirectly used in, and even if it does, there are many more libraries that don't. I don't have a strong opinion on that though, which is why I've been silent in #7727. And as this seems to have no drawbacks, and especially if it helps to land #7784 in a less controversial way, I'm fine with it. Thanks to both of you @jay and @wyattoday !

@vszakats

vszakats commented Oct 5, 2021 •

Copy link
Copy Markdown
Member

This looks good. With the concern that it's not libcurl's job to fix the bad OS design around Windows version/feature detection. Such practice will result in libcurl behaving unexpectedly and differently from other code that's designed to honor manifests and the official way of feature-detection. I don't think this is the correct direction, though with some luck, it will not cause (or seldom cause) problems in practice.

Comment thread lib/version_win32.c Resolved
@wyattoday

wyattoday commented Oct 5, 2021 •

Copy link
Copy Markdown
Contributor

You're welcome to add a const unsigned int buildNumber param after this change lands. I'd like to keep this as simple as possible to move things along.

Will do. As soon as this is merged I'll make a new PR.

OSVERSIONINFOEXW and RTLOSVERSIONINFOEXW have always been defined by MS
as the same struct. It's unlikely they'll diverge at some point however
in the interest of best practice I've copied the current one as
OUR_OSVERSIONINFOEXW so there is no chance that in the future some
(RTL)OSVERSIONINFOEXW ends up being passed that is not compatible with
both VerifyVersionInfoW and RtlVerifyVersionInfo.
@jay

jay commented Oct 5, 2021

Copy link
Copy Markdown
Member Author

I've made a slight change to this, defining OUR_OSVERSIONINFOEXW to be certain the struct we use is always compatible with both VerifyVersionInfoW and RtlVerifyVersionInfo. More details can be seen in the separate commit which I will later squash in.

@jay jay closed this in 5044909 Oct 7, 2021
@jay
jay deleted the win32_improve_vercheck branch October 7, 2021 07:23
vszakats added a commit to vszakats/curl that referenced this pull request Feb 24, 2025
curl requires Windows XP since 2023. Drop version detection code using
`GetVersionEx()` aimed to support earlier Windows versions. With that
call deleted, the embedded manifest in `curl.rc` becomes unnecessary.
Delete it too, along with the enabler logic in build systems.

This allows to stop forcing `/MANIFEST:NO` for MSVC builds. Dropping it
fixes VS2008 shared builds, that require an auto-generated SxS manifest
to find their CRT DLLs. This was the issue that prevented VS2008
`curl.exe` launching on AppVeyor CI.

FWIW the `curl.rc` embedded manifest wasn't ever enabled for VS2008 CI
builds either, because CMake did not pass our custom macro via
`CMAKE_RC_FLAGS` to `rc.exe`. For reasons I couldn't figure out.

After this patch the curl build no longer inject its own manifest, and
lets the default be applied by linkers and toolchains. It fixes VS2008
shared builds. curl continues to detect the real Windows version via
`RtlVerifyVersionInfo` from `ntdll`.

Follow-up to 960d601 curl#12225
Follow-up to 5044909 curl#7810
Follow-up to ebd2132 curl#1221
Cherry-picked from curl#16394
vszakats added a commit that referenced this pull request Feb 24, 2025
curl requires Windows XP since 2023. Drop version detection code using
`GetVersionEx()` aimed to support earlier Windows versions. With that
call deleted, the embedded manifest in `curl.rc` becomes unnecessary.
Delete it too, along with the enabler logic in build systems.

This allows to stop forcing `/MANIFEST:NO` for MSVC builds. Dropping it
fixes VS2008 shared builds, that require an auto-generated SxS
(side-by-side assembly) manifest to find their CRT DLLs. This was the
issue that prevented VS2008 `curl.exe` launching on AppVeyor CI:
```
src/curl.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directory
```
Ref: https://ci.appveyor.com/project/curlorg/curl/builds/51577006/job/eitypvwlb1rxr11d#L261

FWIW the `curl.rc` embedded manifest wasn't ever enabled for VS2008 CI
builds either, because CMake did not pass our custom macro via
`CMAKE_RC_FLAGS` to `rc.exe`. For reasons I could not figure out.

After this patch the curl build no longer inject its own manifest, and
lets the default be applied by linkers and toolchains. It fixes VS2008
shared builds. curl continues to detect the real Windows version via
`RtlVerifyVersionInfo()` from `ntdll`.

Follow-up to 960d601 #12225
Follow-up to 5044909 #7810
Follow-up to ebd2132 #1221
Ref: #15972
Cherry-picked from #16394

Closes #16453
icing pushed a commit to icing/curl that referenced this pull request Feb 25, 2025
curl requires Windows XP since 2023. Drop version detection code using
`GetVersionEx()` aimed to support earlier Windows versions. With that
call deleted, the embedded manifest in `curl.rc` becomes unnecessary.
Delete it too, along with the enabler logic in build systems.

This allows to stop forcing `/MANIFEST:NO` for MSVC builds. Dropping it
fixes VS2008 shared builds, that require an auto-generated SxS
(side-by-side assembly) manifest to find their CRT DLLs. This was the
issue that prevented VS2008 `curl.exe` launching on AppVeyor CI:
```
src/curl.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directory
```
Ref: https://ci.appveyor.com/project/curlorg/curl/builds/51577006/job/eitypvwlb1rxr11d#L261

FWIW the `curl.rc` embedded manifest wasn't ever enabled for VS2008 CI
builds either, because CMake did not pass our custom macro via
`CMAKE_RC_FLAGS` to `rc.exe`. For reasons I could not figure out.

After this patch the curl build no longer inject its own manifest, and
lets the default be applied by linkers and toolchains. It fixes VS2008
shared builds. curl continues to detect the real Windows version via
`RtlVerifyVersionInfo()` from `ntdll`.

Follow-up to 960d601 curl#12225
Follow-up to 5044909 curl#7810
Follow-up to ebd2132 curl#1221
Ref: curl#15972
Cherry-picked from curl#16394

Closes curl#16453
pps83 pushed a commit to pps83/curl that referenced this pull request Apr 26, 2025
curl requires Windows XP since 2023. Drop version detection code using
`GetVersionEx()` aimed to support earlier Windows versions. With that
call deleted, the embedded manifest in `curl.rc` becomes unnecessary.
Delete it too, along with the enabler logic in build systems.

This allows to stop forcing `/MANIFEST:NO` for MSVC builds. Dropping it
fixes VS2008 shared builds, that require an auto-generated SxS
(side-by-side assembly) manifest to find their CRT DLLs. This was the
issue that prevented VS2008 `curl.exe` launching on AppVeyor CI:
```
src/curl.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directory
```
Ref: https://ci.appveyor.com/project/curlorg/curl/builds/51577006/job/eitypvwlb1rxr11d#L261

FWIW the `curl.rc` embedded manifest wasn't ever enabled for VS2008 CI
builds either, because CMake did not pass our custom macro via
`CMAKE_RC_FLAGS` to `rc.exe`. For reasons I could not figure out.

After this patch the curl build no longer inject its own manifest, and
lets the default be applied by linkers and toolchains. It fixes VS2008
shared builds. curl continues to detect the real Windows version via
`RtlVerifyVersionInfo()` from `ntdll`.

Follow-up to 960d601 curl#12225
Follow-up to 5044909 curl#7810
Follow-up to ebd2132 curl#1221
Ref: curl#15972
Cherry-picked from curl#16394

Closes curl#16453
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Windows Windows-specific

Development

Successfully merging this pull request may close these issues.

libcurl from a Windows dll sometimes incorrectly identifies presence of ALPN

5 participants