From 012bc72ad0e444ce231c08538a1848b1561f8d76 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 2 Aug 2021 02:29:55 +0200 Subject: installer: do not require KB2921916 In anticipation of upcoming wintun changes. Signed-off-by: Jason A. Donenfeld --- installer/customactions.c | 88 ----------------------------------------------- installer/wireguard.wxs | 8 ----- 2 files changed, 96 deletions(-) diff --git a/installer/customactions.c b/installer/customactions.c index 981415e1..7c6a528e 100644 --- a/installer/customactions.c +++ b/installer/customactions.c @@ -122,94 +122,6 @@ out: return ret; } -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]; - TCHAR setupapi_path[MAX_PATH]; - HANDLE setupapi_handle = INVALID_HANDLE_VALUE; - HANDLE setupapi_filemapping = NULL; - const char *setupapi_bytes = NULL; - MEMORY_BASIC_INFORMATION setupapi_meminfo; - static const char setupapi_marker[] = "Signature Hash"; - - RtlGetNtVersionNumbers(&maj, &min, &build); - if (maj != 6 || min != 1) - goto out; - - ret = ERROR_INSTALL_FAILURE; - if (!GetSystemDirectory(setupapi_path, _countof(setupapi_path))) - goto out; - if (!PathAppend(setupapi_path, TEXT("setupapi.dll"))) - goto out; - setupapi_handle = CreateFile(setupapi_path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (setupapi_handle == INVALID_HANDLE_VALUE) - goto out; - setupapi_filemapping = CreateFileMapping(setupapi_handle, NULL, PAGE_READONLY, 0, 0, NULL); - if (!setupapi_filemapping) - goto out; - setupapi_bytes = MapViewOfFile(setupapi_filemapping, FILE_MAP_READ, 0, 0, 0); - if (!setupapi_bytes) - goto out; - if (VirtualQuery(setupapi_bytes, &setupapi_meminfo, sizeof(setupapi_meminfo)) != sizeof(setupapi_meminfo)) - goto out; - if (setupapi_meminfo.RegionSize > strlen(setupapi_marker)) { - for (const char *p = setupapi_bytes + strlen(setupapi_marker) - 1; (p = memchr(p, 'h', setupapi_meminfo.RegionSize - (p - setupapi_bytes))); ++p) { - if (!memcmp(p - strlen(setupapi_marker) + 1, setupapi_marker, strlen(setupapi_marker))) { - ret = ERROR_SUCCESS; - goto out; - } - } - } - - len = _countof(uiLevel); - if (MsiGetProperty(installer, TEXT("UILevel"), uiLevel, &len) != ERROR_SUCCESS || _tcstoul(uiLevel, NULL, 10) < INSTALLUILEVEL_BASIC) { - 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 - 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); - ret = ERROR_INSTALL_USEREXIT; - -out: - if (setupapi_bytes) - UnmapViewOfFile(setupapi_bytes); - if (setupapi_filemapping) - CloseHandle(setupapi_filemapping); - if (setupapi_handle != INVALID_HANDLE_VALUE) - CloseHandle(setupapi_handle); - if (is_com_initialized) - CoUninitialize(); - return ret; -} - static UINT insert_service_control(MSIHANDLE installer, MSIHANDLE view, const TCHAR *service_name, bool start) { static unsigned int index = 0; diff --git a/installer/wireguard.wxs b/installer/wireguard.wxs index a0fc1396..9cc27156 100644 --- a/installer/wireguard.wxs +++ b/installer/wireguard.wxs @@ -101,14 +101,6 @@ NOT REMOVE - - - - NOT REMOVE - - -- cgit v1.2.3-59-g8ed1b