{"thread":{"id":"51393","subject":"[PATCH 0/1] windows: embed a manifest","startedAt":"2019-06-27T08:49:36Z","lastAt":"2019-06-27T08:49:38Z","messageCount":2,"participants":["Johannes Schindelin via GitGitGadget","Cesar Eduardo Barros via GitGitGadget"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"378129","messageId":"pull.214.git.gitgitgadget@gmail.com","threadId":"51393","inReplyTo":null,"subject":"[PATCH 0/1] windows: embed a manifest","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-27T08:49:33Z","receivedAt":"2019-06-27T08:49:36Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"On Windows, you can embed a \"manifest\" into an executable that changes\nbehavior in subtle (and not so subtle) ways. Let's embed one, to be able to\ndefine precisely what behavior we want.\n\nCesar Eduardo Barros (1):\n  mingw: embed a manifest to trick UAC into Doing The Right Thing\n\n compat/win32/git.manifest | 25 +++++++++++++++++++++++++\n git.rc                    |  2 ++\n 2 files changed, 27 insertions(+)\n create mode 100644 compat/win32/git.manifest\n\n\nbase-commit: aa25c82427ae70aebf3b8f970f2afd54e9a2a8c6\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-214%2Fdscho%2Fmingw-manifest-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-214/dscho/mingw-manifest-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/214\n-- \ngitgitgadget\n"},{"id":"378130","messageId":"781bc458f2f72b435b9ae1f7b684ef60fe03c810.1561625372.git.gitgitgadget@gmail.com","threadId":"51393","inReplyTo":"pull.214.git.gitgitgadget@gmail.com","subject":"[PATCH 1/1] mingw: embed a manifest to trick UAC into Doing The Right Thing","fromName":"Cesar Eduardo Barros via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-27T08:49:33Z","receivedAt":"2019-06-27T08:49:38Z","isPatch":true,"sender":{"key":"cesarb@cesarb.net","avatar":"https://avatars.githubusercontent.com/u/31324?v=4"},"body":"From: Cesar Eduardo Barros <cesarb@cesarb.net>\n\nOn Windows >= Vista, not having an application manifest with a\nrequestedExecutionLevel can cause several kinds of confusing behavior.\n\nThe first and more obvious behavior is \"Installer Detection\" of the\n\"User Account Control\" (also known as \"UAC\") feature, where Windows\nsometimes decides (by looking at things like the file name and even\nsequences of bytes within the executable) that an executable is an\ninstaller and should run elevated (causing the well-known popup dialog\nto appear). In Git's context, subcommands such as \"git patch-id\" or \"git\nupdate-index\" fall prey to this behavior.\n\nThe second and more confusing behavior is \"File Virtualization\". It\nmeans that when files are written without having write permission, it\ndoes not fail (as expected), but they are instead redirected to\nsomewhere else. When the files are read, the original contents are\nreturned, though, not the ones that were just written somewhere else.\nEven more confusing, not all write accesses are redirected; Trying to\nwrite to write-protected .exe files, for example, will fail instead of\nredirecting.\n\nIn addition to being unwanted behavior, File Virtualization causes\ndramatic slowdowns in Git (see for instance\nhttp://code.google.com/p/msysgit/issues/detail?id=320).\n\nA third unwanted behavior of Windows >= Vista is that it lies about the\nWindows version when calling `GetWindowsVersionEx()`.\n\nThere are two ways to prevent these unwanted behaviors: Either you embed\nan application manifest (which really is an XML document conforming to a\nspecific schema) within all your executables, or you add an external\nmanifest (a file with the same name followed by `.manifest`) to all your\nexecutables. Since Git's builtins are hardlinked (or copied), it is\nsimpler and more robust to embed a manifest.\n\nRecent enough MSVC compilers already embed a working internal manifest,\nand building with mingw-w64 (which is the case in Git for Windows' SDK)\ndoes it, too, but for MinGW you have to do so by hand.\n\nIn any case, it is better to be explicit about this manifest, that way\nchanges in the compiler toolchain won't surprise us (as mingw-w64 once\ndid when it broke `GetWindowsVersionEx()` by mistake).\n\nReferences:\n  - New UAC Technologies for Windows Vista\n    http://msdn.microsoft.com/en-us/library/bb756960.aspx\n  - Create and Embed an Application Manifest (UAC)\n    http://msdn.microsoft.com/en-us/library/bb756929.aspx\n\nSigned-off-by: Cesar Eduardo Barros <cesarb@cesarb.net>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/win32/git.manifest | 25 +++++++++++++++++++++++++\n git.rc                    |  2 ++\n 2 files changed, 27 insertions(+)\n create mode 100644 compat/win32/git.manifest\n\ndiff --git a/compat/win32/git.manifest b/compat/win32/git.manifest\nnew file mode 100644\nindex 0000000000..771e3cce43\n--- /dev/null\n+++ b/compat/win32/git.manifest\n@@ -0,0 +1,25 @@\n+<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n+<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\n+\t<assemblyIdentity type=\"win32\" name=\"Git\" version=\"0.0.0.1\" />\n+\t<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">\n+\t\t<security>\n+\t\t\t<requestedPrivileges>\n+\t\t\t\t<requestedExecutionLevel level=\"asInvoker\" uiAccess=\"false\" />\n+\t\t\t</requestedPrivileges>\n+\t\t</security>\n+\t</trustInfo>\n+\t<compatibility xmlns=\"urn:schemas-microsoft-com:compatibility.v1\">\n+\t\t<application>\n+\t\t\t<!-- Windows Vista -->\n+\t\t\t<supportedOS Id=\"{e2011457-1546-43c5-a5fe-008deee3d3f0}\"/>\n+\t\t\t<!-- Windows 7 -->\n+\t\t\t<supportedOS Id=\"{35138b9a-5d96-4fbd-8e2d-a2440225f93a}\"/>\n+\t\t\t<!-- Windows 8 -->\n+\t\t\t<supportedOS Id=\"{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}\"/>\n+\t\t\t<!-- Windows 8.1 -->\n+\t\t\t<supportedOS Id=\"{1f676c76-80e1-4239-95bb-83d0f6d0da78}\"/>\n+\t\t\t<!-- Windows 10 -->\n+\t\t\t<supportedOS Id=\"{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}\"/>\n+\t\t</application>\n+\t</compatibility>\n+</assembly>\ndiff --git a/git.rc b/git.rc\nindex 49002e0d54..cc3fdc6cc6 100644\n--- a/git.rc\n+++ b/git.rc\n@@ -20,3 +20,5 @@ BEGIN\n     VALUE \"Translation\", 0x409, 1200\n   END\n END\n+\n+1 RT_MANIFEST \"compat/win32/git.manifest\"\n-- \ngitgitgadget\n"}]}