]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
curl.rc: embed manifest for correct Windows version detection
authorViktor Szakats <vszakats@users.noreply.github.com>
Wed, 30 May 2018 12:08:26 +0000 (12:08 +0000)
committerViktor Szakats <vszakats@users.noreply.github.com>
Wed, 30 May 2018 12:08:26 +0000 (12:08 +0000)
* enable it in `src/Makefile.m32`
* enable it in `winbuild/MakefileBuild.vc` if a custom manifest is
  _not_ enabled via the existing `EMBED_MANIFEST` option
* enable it for all Windows CMake builds (also disable the built-in
  minimal manifest, added by CMake by default.)

For other build systems, add the `-DCURL_EMBED_MANIFEST` option to
the list of RC (Resource Compiler) flags to enable the manifest
included in `src/curl.rc`. This may require to disable whatever
automatic or other means in which way another manifest is added to
`curl.exe`.

Notice that Borland C doesn't support this method due to a
long-pending resource compiler bug. Watcom C may also not handle
it correctly when the `-zm` `wrc` option is used (this option may
be unnecessary though) and regardless of options in certain earlier
revisions of the 2.0 beta version.

Closes https://github.com/curl/curl/pull/1221
Fixes https://github.com/curl/curl/issues/2591

CMakeLists.txt
src/Makefile.m32
src/curl.rc
winbuild/MakefileBuild.vc

index b85e1f58d7ebd7bb42bae0f66027036c54c106d4..e8cdcc5554a55204cbaeab4263487cb8d90e5341 100644 (file)
@@ -1107,12 +1107,18 @@ include(CMake/OtherTests.cmake)
 
 add_definitions(-DHAVE_CONFIG_H)
 
-# For windows, all compilers used by cmake should support large files
+# For Windows, all compilers used by CMake should support large files
 if(WIN32)
   set(USE_WIN32_LARGE_FILES ON)
+
+  # Use the manifest embedded in the Windows Resource
+  set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -DCURL_EMBED_MANIFEST")
 endif(WIN32)
 
 if(MSVC)
+  # Disable default manifest added by CMake
+  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
+
   add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
   if(CMAKE_C_FLAGS MATCHES "/W[0-4]")
     string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
index 700cccfa856b652b61ea7bd04f9f6642b77fbaa1..33e4ecfc2669bc64454d1c29239491b0d6202c30 100644 (file)
@@ -5,7 +5,7 @@
 #                            | (__| |_| |  _ <| |___
 #                             \___|\___/|_| \_\_____|
 #
-# Copyright (C) 1999 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 1999 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
@@ -107,7 +107,7 @@ CFLAGS      += -fno-strict-aliasing
 LDFLAGS        = $(CURL_LDFLAG_EXTRAS) $(CURL_LDFLAG_EXTRAS_EXE) -s
 AR     = $(CURL_AR)
 RC     = $(CROSSPREFIX)windres
-RCFLAGS        = --include-dir=$(PROOT)/include -O COFF
+RCFLAGS        = --include-dir=$(PROOT)/include -O COFF -DCURL_EMBED_MANIFEST
 STRIP  = $(CROSSPREFIX)strip -g
 
 # We may need these someday
index 5f49d223697588df571ff2fd42062c66d706dbbe..d47f50635189f2edb9e164a813a7823b0701068e 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -61,3 +61,51 @@ 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
+  "<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>"
+  "<assembly xmlns=""urn:schemas-microsoft-com:asm.v1"" manifestVersion=""1.0"">"
+    "<assemblyIdentity name=""The curl executable"" version="""
+      _STR(LIBCURL_VERSION_MAJOR) "."
+      _STR(LIBCURL_VERSION_MINOR) "."
+      _STR(LIBCURL_VERSION_PATCH) ".0"" type=""win32""/>"
+    "<compatibility xmlns=""urn:schemas-microsoft-com:compatibility.v1"">"
+      "<application>"
+        "<supportedOS Id=""{e2011457-1546-43c5-a5fe-008deee3d3f0}""/>"  /* Vista / Server 2008 */
+        "<supportedOS Id=""{35138b9a-5d96-4fbd-8e2d-a2440225f93a}""/>"  /* 7 / Server 2008 R2 */
+        "<supportedOS Id=""{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}""/>"  /* 8 / Server 2012 */
+        "<supportedOS Id=""{1f676c76-80e1-4239-95bb-83d0f6d0da78}""/>"  /* 8.1 / Server 2012 R2 */
+        "<supportedOS Id=""{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}""/>"  /* 10 / Server 2016 */
+      "</application>"
+    "</compatibility>"
+    "<trustInfo xmlns=""urn:schemas-microsoft-com:asm.v3"">"
+      "<security>"
+        "<requestedPrivileges>"
+          "<requestedExecutionLevel level=""asInvoker"" uiAccess=""false""/>"
+        "</requestedPrivileges>"
+      "</security>"
+    "</trustInfo>"
+  "</assembly>"
+END
+
+#endif
index 51ebfb8675f6f0b5527829b89ed79ea80d0055d3..019a414a0bcc0dbe2e8594711bbdb9f5ddb08b32 100644 (file)
@@ -5,7 +5,7 @@
 #                            | (__| |_| |  _ <| |___\r
 #                             \___|\___/|_| \_\_____|\r
 #\r
-# Copyright (C) 1999 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.\r
+# Copyright (C) 1999 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.\r
 #\r
 # This software is licensed as described in the file COPYING, which\r
 # you should have received as part of this distribution. The terms\r
@@ -352,6 +352,8 @@ GEN_PDB = true
 \r
 !IFDEF EMBED_MANIFEST\r
 MANIFESTTOOL = $(MT) -manifest $(DIRDIST)\bin\$(PROGRAM_NAME).manifest -outputresource:$(DIRDIST)\bin\$(PROGRAM_NAME);1\r
+!ELSE\r
+CURL_RC_FLAGS = $(CURL_RC_FLAGS) /dCURL_EMBED_MANIFEST\r
 !ENDIF\r
 \r
 # Runtime library configuration\r