diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-11-22 21:01:57 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-11-22 22:00:32 +0100 |
commit | 5b9b1734d7c8823cd71660d39cd9a99818662147 (patch) | |
tree | f2275324c919991bfcdbe390cdf3f70fd7cc4593 | |
parent | installer: remove memmem (diff) | |
download | wireguard-windows-5b9b1734d7c8823cd71660d39cd9a99818662147.tar.xz wireguard-windows-5b9b1734d7c8823cd71660d39cd9a99818662147.zip |
installer: force modal if KB2921916 is missing
This goes against user choice, but it's also required to get Windows 7
users upgrading again.
Reported-by: /u/tarakan1983 on Reddit
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r-- | installer/customactions.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/installer/customactions.c b/installer/customactions.c index eb75d623..b514acf1 100644 --- a/installer/customactions.c +++ b/installer/customactions.c @@ -124,13 +124,30 @@ out: extern NTAPI __declspec(dllimport) void RtlGetNtVersionNumbers(DWORD *MajorVersion, DWORD *MinorVersion, DWORD *BuildNumber); +static int message_box(MSIHANDLE installer, TCHAR *text, UINT type) +{ + TCHAR progressOnly[2]; + DWORD len; + MSIHANDLE record; + int ret; + + len = _countof(progressOnly); + if (MsiGetProperty(installer, TEXT("MsiUIProgressOnly"), progressOnly, &len) == ERROR_SUCCESS && _tcstoul(progressOnly, NULL, 10) == 1) + return MessageBox(GetForegroundWindow(), text, TEXT("WireGuard"), type); + record = MsiCreateRecord(2); + MsiRecordSetString(record, 0, TEXT("[1]")); + MsiRecordSetString(record, 1, text); + ret = MsiProcessMessage(installer, INSTALLMESSAGE_USER | type, record); + MsiCloseHandle(record); + return ret; +} + __declspec(dllexport) UINT __stdcall CheckKB2921916(MSIHANDLE installer) { bool is_com_initialized = SUCCEEDED(CoInitialize(NULL)); UINT ret = ERROR_SUCCESS; DWORD maj, min, build, len; TCHAR uiLevel[10]; - MSIHANDLE record; TCHAR setupapi_path[MAX_PATH]; HANDLE setupapi_handle = INVALID_HANDLE_VALUE; HANDLE setupapi_filemapping = NULL; @@ -172,18 +189,13 @@ __declspec(dllexport) UINT __stdcall CheckKB2921916(MSIHANDLE installer) log_messagef(installer, LOG_LEVEL_MSIERR, TEXT("Use of WireGuard on Windows 7 requires KB2921916.")); goto out; } - #ifdef _WIN64 static const TCHAR url[] = TEXT("https://download.wireguard.com/windows-toolchain/distfiles/Windows6.1-KB2921916-x64.msu"); #else static const TCHAR url[] = TEXT("https://download.wireguard.com/windows-toolchain/distfiles/Windows6.1-KB2921916-x86.msu"); #endif - record = MsiCreateRecord(2); - MsiRecordSetString(record, 0, TEXT("[1]")); - MsiRecordSetString(record, 1, TEXT("Missing Windows Hotfix\n\nUse of WireGuard on Windows 7 requires KB2921916. Would you like to download the hotfix in your web browser?")); - if (MsiProcessMessage(installer, INSTALLMESSAGE_USER | MB_ICONWARNING | MB_YESNO, record) == IDYES) + if (message_box(installer, TEXT("Missing Windows Hotfix\n\nUse of WireGuard on Windows 7 requires KB2921916. Would you like to download the hotfix in your web browser?"), MB_ICONWARNING | MB_YESNO) == IDYES) ShellExecute(GetForegroundWindow(), NULL, url, NULL, NULL, SW_SHOWNORMAL); - MsiCloseHandle(record); ret = ERROR_INSTALL_USEREXIT; out: |