From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2201) id 572D33858D38; Tue, 20 Sep 2022 16:07:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 572D33858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663690046; bh=AoRU2cyPoKYSorc2mG39HCnf/Mqa1X5dHHC/lms043M=; h=To:Subject:Date:From:From; b=LMjHPuUO5CmYB7Lk0IKCeOgIqR08i7B/JsjAMYzO9V1yFerEM1HREkFmFq+iXZRNB 4Ryqft9m1cf4yVXqUikrfvj+0BIO3WxUeXX+U8L0L2VxFH3YMCs8ap2nuZSMLMnGr/ 2TtGOkMfFmviGg+lRUldbOraB2hpqkFHhOwl3RH0= To: cygwin-apps-cvs@sourceware.org Subject: [setup - the official Cygwin setup program] branch master, updated. release_2.922 X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: b5b442157755ec33779783188b88e3349379c79b X-Git-Newrev: 4bf4dd68da0344a18f6e603a5fb60df0d9231ab7 Message-Id: <20220920160726.572D33858D38@sourceware.org> Date: Tue, 20 Sep 2022 16:07:26 +0000 (GMT) From: Jon TURNEY List-Id: https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=4bf4dd68da0344a18f6e603a5fb60df0d9231ab7 commit 4bf4dd68da0344a18f6e603a5fb60df0d9231ab7 Author: Jon Turney Date: Mon Sep 12 19:43:47 2022 +0100 Link with mingwex before libntll Link with mingwex (which gcc specs will cause us to link with anyhow) before ntll. Some versions of the MinGW ntdll implib contain a subset of crt functions (erroneously, they were later moved to ntllcrt). This means that if the linker command specifies -lntdll, an application will use ntdll.dll for things like strnlen(), which is (a) unexpected, and (b) causes problems, as that specific export is not provided by ntll on XP. https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=450d4db7bcc0c476b4fb8de003683d5e50c9aebb commit 450d4db7bcc0c476b4fb8de003683d5e50c9aebb Author: Jon Turney Date: Mon Sep 12 14:40:59 2022 +0100 Allow to run on Windows lacking CreateSymbolicLinkW() https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=f540161b77b24366f99fc6f596b57b78fafb0268 commit f540161b77b24366f99fc6f596b57b78fafb0268 Author: Jon Turney Date: Mon Sep 12 14:46:40 2022 +0100 Allow to run on Windows lacking SHMessageBoxCheckW() Diff: --- Makefile.am | 1 + main.cc | 7 +++++++ mklink2.cc | 14 +++++++++++++- msg.cc | 22 +++++++++++++--------- 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/Makefile.am b/Makefile.am index bf8b52ec..d8300e8d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -95,6 +95,7 @@ inilint_SOURCES = \ $(BZ2_LIBS) \ $(ZLIB_LIBS) \ $(LIBSOLV_LIBS) -lregex \ + -lmingwex \ -lshlwapi -lcomctl32 -lole32 -lpsapi -luuid -lntdll -lwininet -lws2_32 \ -lmingw32 -lssp @SETUP@_LDFLAGS = -mwindows -Wc,-static -static-libtool-libs diff --git a/main.cc b/main.cc index 1cc8a0c1..ca5639cf 100644 --- a/main.cc +++ b/main.cc @@ -414,6 +414,13 @@ WinMain (HINSTANCE h, } else if (symlinkType == SymlinkTypeNative) { + VersionInfo v = GetVer(); + if (v.major() < 6) + { + fprintf (stderr, "*** --symlink-type native requires Windows 6.0 or later\n"); + exit(1); + } + if (!(elevate || is_developer_mode() || nt_sec.hasSymlinkCreationRights())) { fprintf (stderr, "*** --symlink-type native requires SeCreateSymbolicLink privilege or 'Developer Mode'\n"); diff --git a/mklink2.cc b/mklink2.cc index cf4df8b1..098f3be2 100644 --- a/mklink2.cc +++ b/mklink2.cc @@ -302,7 +302,19 @@ mknativesymlink (const char *from, const char *to) ((v.major() == 10) && (v.buildNumber() >= 15063))) flags |= SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE; - status = CreateSymbolicLinkW (wfrom, wto, flags); + typedef BOOLEAN (WINAPI *PFNCREATESYMBOLICLINKW)(LPCWSTR, LPCWSTR, DWORD); + static PFNCREATESYMBOLICLINKW pfnCreateSymbolicLinkW = 0; + static bool doOnce = FALSE; + + if (!doOnce) + { + doOnce = TRUE; + pfnCreateSymbolicLinkW = (PFNCREATESYMBOLICLINKW)GetProcAddress(GetModuleHandle("kernel32"), "CreateSymbolicLinkW"); + } + + status = 0; + if (pfnCreateSymbolicLinkW) + status = pfnCreateSymbolicLinkW (wfrom, wto, flags); if (!status) Log (LOG_PLAIN) << "Linking " << from << " to " << to << " failed " << std::hex << GetLastError() << endLog; diff --git a/msg.cc b/msg.cc index bcb32660..8e344ff8 100644 --- a/msg.cc +++ b/msg.cc @@ -20,7 +20,6 @@ #include "LogFile.h" #include "win32.h" -#include #include #include @@ -29,11 +28,6 @@ #include "String++.h" #include "resource.h" -// no prototype in shlwapi.h until MinGW64 headers 9.0.0 -#if __MINGW64_VERSION_MAJOR < 9 -extern "C" int WINAPI SHMessageBoxCheckW(HWND hwnd, LPCWSTR pszText, LPCWSTR pszCaption, UINT uType, int iDefault, LPCWSTR pszRegVal); -#endif - static int unattended_result(int mb_type) { @@ -172,14 +166,24 @@ mbox(HWND owner, unsigned int format_id, int mb_type, ...) hMsgBoxHook = SetWindowsHookEx(WH_CBT, CBTProc, NULL, GetCurrentThreadId()); } + typedef int (WINAPI *PFNSHMESSAGEBOXCHECKW)(HWND, LPCWSTR, LPCWSTR, UINT, int, LPCWSTR); + static PFNSHMESSAGEBOXCHECKW pfnSHMessageBoxCheckW = 0; + static bool doOnce = FALSE; + + if (!doOnce) + { + doOnce = TRUE; + pfnSHMessageBoxCheckW = (PFNSHMESSAGEBOXCHECKW)GetProcAddress(GetModuleHandle("shlwapi.dll"), "SHMessageBoxCheckW"); + } + std::wstring caption = LoadStringW(IDS_MBOX_CAPTION); int retval; - if (mb_type & MB_DSA_CHECKBOX) + if (pfnSHMessageBoxCheckW && (mb_type & MB_DSA_CHECKBOX)) { mb_type &= ~MB_DSA_CHECKBOX; std::wstring regkey_msg = format(L"%s-%d", regkey, format_id); - retval = SHMessageBoxCheckW(owner, buf.c_str(), caption.c_str(), mb_type, - unattended_result(mb_type), regkey_msg.c_str()); + retval = pfnSHMessageBoxCheckW(owner, buf.c_str(), caption.c_str(), mb_type, + unattended_result(mb_type), regkey_msg.c_str()); } else retval = MessageBoxW(owner, buf.c_str(), caption.c_str(), mb_type);