{"thread":{"id":"49647","subject":"[PATCH 0/1] Load system libraries the recommended way on Windows","startedAt":"2018-10-23T10:51:50Z","lastAt":"2018-10-23T10:51:52Z","messageCount":2,"participants":["Johannes Schindelin via GitGitGadget"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"361276","messageId":"pull.55.git.gitgitgadget@gmail.com","threadId":"49647","inReplyTo":null,"subject":"[PATCH 0/1] Load system libraries the recommended way on Windows","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-10-23T10:51:47Z","receivedAt":"2018-10-23T10:51:50Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"The search order for DLLs on Windows is a bit funny, and for system\nlibraries, it is recommended to use a strict search path.\n\nIn practice, this should not make a difference, as the library has been\nloaded into memory already, and therefore the LoadLibrary() call would just\nreturn the handle instead of loading the library again.\n\nJohannes Schindelin (1):\n  mingw: load system libraries the recommended way\n\n compat/mingw.c                                      | 3 ++-\n contrib/credential/wincred/git-credential-wincred.c | 3 ++-\n 2 files changed, 4 insertions(+), 2 deletions(-)\n\n\nbase-commit: c4df23f7927d8d00e666a3c8d1b3375f1dc8a3c1\nPublished-As: https://github.com/gitgitgadget/git/releases/tags/pr-55%2Fdscho%2Fmingw-load-sys-dll-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-55/dscho/mingw-load-sys-dll-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/55\n-- \ngitgitgadget\n"},{"id":"361277","messageId":"89887345376ccf8813603f10ac51d39527397aee.1540291906.git.gitgitgadget@gmail.com","threadId":"49647","inReplyTo":"pull.55.git.gitgitgadget@gmail.com","subject":"[PATCH 1/1] mingw: load system libraries the recommended way","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-10-23T10:51:49Z","receivedAt":"2018-10-23T10:51:52Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nWhen we access IPv6-related functions, we load the corresponding system\nlibrary using the `LoadLibrary()` function, which is not the recommended\nway to load system libraries.\n\nIn practice, it does not make a difference: the `ws2_32.dll` library\ncontaining the IPv6 functions is already loaded into memory, so\nLoadLibrary() simply reuses the already-loaded library.\n\nStill, recommended way is recommended way, so let's use that instead.\n\nWhile at it, also adjust the code in contrib/ that loads system libraries.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/mingw.c                                      | 3 ++-\n contrib/credential/wincred/git-credential-wincred.c | 3 ++-\n 2 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 18caf2196..9fd7db571 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -1577,7 +1577,8 @@ static void ensure_socket_initialization(void)\n \t\t\tWSAGetLastError());\n \n \tfor (name = libraries; *name; name++) {\n-\t\tipv6_dll = LoadLibrary(*name);\n+\t\tipv6_dll = LoadLibraryExA(*name, NULL,\n+\t\t\t\t\t  LOAD_LIBRARY_SEARCH_SYSTEM32);\n \t\tif (!ipv6_dll)\n \t\t\tcontinue;\n \ndiff --git a/contrib/credential/wincred/git-credential-wincred.c b/contrib/credential/wincred/git-credential-wincred.c\nindex 86518cd93..5bdad41de 100644\n--- a/contrib/credential/wincred/git-credential-wincred.c\n+++ b/contrib/credential/wincred/git-credential-wincred.c\n@@ -75,7 +75,8 @@ static CredDeleteWT CredDeleteW;\n static void load_cred_funcs(void)\n {\n \t/* load DLLs */\n-\tadvapi = LoadLibrary(\"advapi32.dll\");\n+\tadvapi = LoadLibraryExA(\"advapi32.dll\", NULL,\n+\t\t\t\tLOAD_LIBRARY_SEARCH_SYSTEM32);\n \tif (!advapi)\n \t\tdie(\"failed to load advapi32.dll\");\n \n-- \ngitgitgadget\n"}]}