From 9b0467b169e08b70077f09313975d4eac14a9930 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 24 Feb 2025 16:25:38 +0100 Subject: [PATCH] windows: drop code and curl manifest targeting W2K and older 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 960d601481eed46d7b46391380c4869bcf0d9f19 #12225 Follow-up to 5044909ca251d3d190d8c5cc45243a04d244eaed #7810 Follow-up to ebd213270a017a6830928ee2e1f4a9cabc799898 #1221 Ref: #15972 Cherry-picked from #16394 Closes #16453 --- CMakeLists.txt | 6 --- lib/setup-win32.h | 6 --- lib/version_win32.c | 88 +++------------------------------------ src/Makefile.am | 2 +- src/curl.rc | 48 --------------------- winbuild/MakefileBuild.vc | 2 - 6 files changed, 7 insertions(+), 145 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dcba09d539..af0ce66650 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1983,9 +1983,6 @@ if(WIN32) set(USE_WIN32_LARGE_FILES ON) endif() - # Use the manifest embedded in the Windows Resource - string(APPEND CMAKE_RC_FLAGS " -DCURL_EMBED_MANIFEST") - # We use crypto functions that are not available for UWP apps if(NOT WINDOWS_STORE) set(USE_WIN32_CRYPTO ON) @@ -2001,9 +1998,6 @@ if(WIN32) endif() if(MSVC) - # Disable default manifest added by CMake - string(APPEND CMAKE_EXE_LINKER_FLAGS " -MANIFEST:NO") - string(APPEND CMAKE_C_FLAGS " -MP") # Parallel compilation endif() diff --git a/lib/setup-win32.h b/lib/setup-win32.h index 70d83ad8e9..35fe513a84 100644 --- a/lib/setup-win32.h +++ b/lib/setup-win32.h @@ -93,12 +93,6 @@ * newer symbols. */ -#ifndef _WIN32_WINNT_NT4 -#define _WIN32_WINNT_NT4 0x0400 /* Windows NT 4.0 */ -#endif -#ifndef _WIN32_WINNT_WIN2K -#define _WIN32_WINNT_WIN2K 0x0500 /* Windows 2000 */ -#endif #ifndef _WIN32_WINNT_WINXP #define _WIN32_WINNT_WINXP 0x0501 /* Windows XP */ #endif diff --git a/lib/version_win32.c b/lib/version_win32.c index 21a122f2a6..d58dbec724 100644 --- a/lib/version_win32.c +++ b/lib/version_win32.c @@ -113,88 +113,12 @@ bool curlx_verify_windows_version(const unsigned int majorVersion, /* we are 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) || - (buildVersion != 0 && - (osver.dwMajorVersion == majorVersion && - osver.dwMinorVersion == minorVersion && - osver.dwBuildNumber < buildVersion))) - matched = TRUE; - break; - - case VERSION_LESS_THAN_EQUAL: - if(osver.dwMajorVersion < majorVersion || - (osver.dwMajorVersion == majorVersion && - osver.dwMinorVersion < minorVersion) || - (osver.dwMajorVersion == majorVersion && - osver.dwMinorVersion == minorVersion && - (buildVersion == 0 || - osver.dwBuildNumber <= buildVersion))) - matched = TRUE; - break; - - case VERSION_EQUAL: - if(osver.dwMajorVersion == majorVersion && - osver.dwMinorVersion == minorVersion && - (buildVersion == 0 || - osver.dwBuildNumber == buildVersion)) - matched = TRUE; - break; - - case VERSION_GREATER_THAN_EQUAL: - if(osver.dwMajorVersion > majorVersion || - (osver.dwMajorVersion == majorVersion && - osver.dwMinorVersion > minorVersion) || - (osver.dwMajorVersion == majorVersion && - osver.dwMinorVersion == minorVersion && - (buildVersion == 0 || - osver.dwBuildNumber >= buildVersion))) - matched = TRUE; - break; - - case VERSION_GREATER_THAN: - if(osver.dwMajorVersion > majorVersion || - (osver.dwMajorVersion == majorVersion && - osver.dwMinorVersion > minorVersion) || - (buildVersion != 0 && - (osver.dwMajorVersion == majorVersion && - osver.dwMinorVersion == minorVersion && - osver.dwBuildNumber > buildVersion))) - 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; - break; - - default: /* like platform == PLATFORM_DONT_CARE */ - break; - } - } - } +#elif defined(UNDER_CE) + (void)majorVersion; + (void)minorVersion; + (void)buildVersion; + (void)platform; + (void)condition; #else ULONGLONG cm = 0; struct OUR_OSVERSIONINFOEXW osver; diff --git a/src/Makefile.am b/src/Makefile.am index 0969d81650..b3b4fd0535 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -213,7 +213,7 @@ listhelp: if HAVE_WINDRES .rc.o: - $(RC) -I$(top_srcdir)/include -DCURL_EMBED_MANIFEST $(RCFLAGS) -i $< -o $@ + $(RC) -I$(top_srcdir)/include $(RCFLAGS) -i $< -o $@ endif dist-hook: diff --git a/src/curl.rc b/src/curl.rc index 475dfbe896..389b483b4b 100644 --- a/src/curl.rc +++ b/src/curl.rc @@ -63,51 +63,3 @@ BEGIN VALUE "Translation", 0x409, 1200 END END - -/* Manifest */ - -#if defined(CURL_EMBED_MANIFEST) - -/* String escaping rules: - https://msdn.microsoft.com/library/aa381050 - Application Manifest doc, including the list of 'supportedOS Id's: - https://msdn.microsoft.com/library/aa374191 */ - -#ifndef CREATEPROCESS_MANIFEST_RESOURCE_ID -#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1 -#endif -#ifndef RT_MANIFEST -#define RT_MANIFEST 24 -#endif - -#define _STR(macro) _STR_(macro) -#define _STR_(macro) #macro - -CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST -BEGIN - "" - "" - "" - "" - "" - "" /* Vista / Server 2008 */ - "" /* 7 / Server 2008 R2 */ - "" /* 8 / Server 2012 */ - "" /* 8.1 / Server 2012 R2 */ - "" /* 10 / Server 2016 */ - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" -END - -#endif diff --git a/winbuild/MakefileBuild.vc b/winbuild/MakefileBuild.vc index 06fec81ee7..cb3d0fef43 100644 --- a/winbuild/MakefileBuild.vc +++ b/winbuild/MakefileBuild.vc @@ -415,8 +415,6 @@ GEN_PDB = true !IFDEF EMBED_MANIFEST MANIFESTTOOL = $(MT) -manifest $(DIRDIST)\bin\$(PROGRAM_NAME).manifest -outputresource:$(DIRDIST)\bin\$(PROGRAM_NAME);1 -!ELSE -CURL_RC_FLAGS = $(CURL_RC_FLAGS) /dCURL_EMBED_MANIFEST !ENDIF # Runtime library configuration -- 2.47.2