public inbox for cygwin-apps-cvs@sourceware.org help / color / mirror / Atom feed
From: Jon TURNEY <jturney@sourceware.org> To: cygwin-apps-cvs@sourceware.org Subject: [setup - the official Cygwin setup program] branch master, updated. release_2.922 Date: Tue, 20 Sep 2022 16:07:26 +0000 (GMT) [thread overview] Message-ID: <20220920160726.572D33858D38@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=4bf4dd68da0344a18f6e603a5fb60df0d9231ab7 commit 4bf4dd68da0344a18f6e603a5fb60df0d9231ab7 Author: Jon Turney <jon.turney@dronecode.org.uk> 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 <jon.turney@dronecode.org.uk> 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 <jon.turney@dronecode.org.uk> 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 <shlwapi.h> #include <stdio.h> #include <stdarg.h> @@ -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);
reply other threads:[~2022-09-20 16:07 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220920160726.572D33858D38@sourceware.org \ --to=jturney@sourceware.org \ --cc=cygwin-apps-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).