]> git.ipfire.org Git - thirdparty/wireguard-tools.git/commitdiff
wg: windows: raise min windows version to 10
authorJason A. Donenfeld <Jason@zx2c4.com>
Fri, 20 Mar 2026 21:07:25 +0000 (22:07 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Sat, 21 Mar 2026 10:42:07 +0000 (11:42 +0100)
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
src/Makefile
src/ipc-windows.h
src/wincompat/init.c
src/wincompat/load_config.c [new file with mode: 0644]
src/wincompat/manifest.xml

index 1c4b3f65ca4d8862de6d9fe0cc1b5ea8760e7da2..976a39691a4411e07b8b9603638d75caafa015a3 100644 (file)
@@ -61,14 +61,14 @@ endif
 ifeq ($(PLATFORM),windows)
 CC := x86_64-w64-mingw32-clang
 WINDRES := $(shell $(CC) $(CFLAGS) -print-prog-name=windres 2>/dev/null)
-CFLAGS += -Iwincompat/include -include wincompat/compat.h -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 -flto
+CFLAGS += -Iwincompat/include -include wincompat/compat.h -DWINVER=0x0A00 -D_WIN32_WINNT=0x0A00 -flto
 LDLIBS += -lws2_32 -lsetupapi -lole32 -ladvapi32 -lntdll -Lwincompat
 LDFLAGS += -flto -Wl,--dynamicbase -Wl,--nxcompat -Wl,--tsaware -mconsole
-LDFLAGS += -Wl,--major-os-version=6 -Wl,--minor-os-version=1 -Wl,--major-subsystem-version=6 -Wl,--minor-subsystem-version=1
+LDFLAGS += -Wl,--major-os-version=10 -Wl,--minor-os-version=0 -Wl,--major-subsystem-version=10 -Wl,--minor-subsystem-version=0
 # The use of -Wl,/delayload: here implies we're using llvm-mingw
 LDFLAGS += -Wl,/delayload:ws2_32.dll -Wl,/delayload:setupapi.dll -Wl,/delayload:ole32.dll -Wl,/delayload:advapi32.dll
 VERSION := $(patsubst "%",%,$(filter "%",$(file < version.h)))
-wg: wincompat/libc.o wincompat/init.o wincompat/loader.o wincompat/resources.o
+wg: wincompat/libc.o wincompat/init.o wincompat/load_config.o wincompat/loader.o wincompat/resources.o
 wincompat/resources.o: wincompat/resources.rc wincompat/manifest.xml
        $(WINDRES) -DVERSION_STR=$(VERSION) -O coff -c 65001 -i $< -o $@
 endif
index a71911e67354800d85dd07f9790b7bc891bf7b0f..c882bf933d4193bba4a87eac8e624bf8b86503f6 100644 (file)
 static bool have_cached_kernel_interfaces;
 static struct hashtable cached_kernel_interfaces;
 static const DEVPROPKEY devpkey_name = DEVPKEY_WG_NAME;
-extern bool is_win7;
 
 static int kernel_get_wireguard_interfaces(struct string_list *list)
 {
-       HDEVINFO dev_info = SetupDiGetClassDevsExW(&GUID_DEVCLASS_NET, is_win7 ? L"ROOT\\WIREGUARD" : L"SWD\\WireGuard", NULL, DIGCF_PRESENT, NULL, NULL, NULL);
+       HDEVINFO dev_info = SetupDiGetClassDevsExW(&GUID_DEVCLASS_NET, L"SWD\\WireGuard", NULL, DIGCF_PRESENT, NULL, NULL, NULL);
        bool will_have_cached_kernel_interfaces = true;
 
        if (dev_info == INVALID_HANDLE_VALUE) {
@@ -130,7 +129,7 @@ err_hash:
                }
        }
 
-       dev_info = SetupDiGetClassDevsExW(&GUID_DEVCLASS_NET, is_win7 ? L"ROOT\\WIREGUARD" : L"SWD\\WireGuard", NULL, DIGCF_PRESENT, NULL, NULL, NULL);
+       dev_info = SetupDiGetClassDevsExW(&GUID_DEVCLASS_NET, L"SWD\\WireGuard", NULL, DIGCF_PRESENT, NULL, NULL, NULL);
        if (dev_info == INVALID_HANDLE_VALUE)
                return NULL;
 
index f92c0a962f9660178fa7e08732aa8f31b25e440f..5a34dcb3c21eabdb356de27fbb018449889b963e 100644 (file)
 #define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x4
 #endif
 
-extern void NTAPI RtlGetNtVersionNumbers(DWORD *major, DWORD *minor, DWORD *build);
-bool is_win7 = false;
-
 __attribute__((constructor)) static void init(void)
 {
-       char *colormode;
-       DWORD console_mode, major, minor;
        HANDLE stdout_handle;
+       DWORD console_mode;
        WSADATA wsaData;
+       char *colormode;
 
        if (!SetDllDirectoryA("") || !SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_SYSTEM32))
                abort();
 
-       RtlGetNtVersionNumbers(&major, &minor, NULL);
-       is_win7 = (major == 6 && minor <= 1) || major < 6;
-
        WSAStartup(MAKEWORD(2, 2), &wsaData);
 
        stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE); // We don't close this.
diff --git a/src/wincompat/load_config.c b/src/wincompat/load_config.c
new file mode 100644 (file)
index 0000000..4d1494d
--- /dev/null
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2015-2026 Jason A. Donenfeld. All Rights Reserved.
+ *
+ * This here is a bit of a hack. We're compiling with subsystem=10.0 in the PE
+ * header, and so the Windows loader expects to see either
+ * _load_config.SecurityCookie set to the initial magic value, or for
+ * IMAGE_GUARD_SECURITY_COOKIE_UNUSED to be set. libssp doesn't use
+ * SecurityCookie anyway; SecurityCookie is for MSVC's /GS protection. So it
+ * seems like the proper thing to do is signal to the OS that it doesn't need
+ * to initialize SecurityCookie.
+ */
+
+#include <windows.h>
+
+#define IMAGE_GUARD_SECURITY_COOKIE_UNUSED 0x00000800
+const IMAGE_LOAD_CONFIG_DIRECTORY _load_config_used = {
+       .Size = sizeof(_load_config_used),
+       .GuardFlags = IMAGE_GUARD_SECURITY_COOKIE_UNUSED
+};
index fb9a1b42f61bc6cb884b0b57734b32664df9ee42..dc7d476610b162353f095af92b39afbe33cc05e4 100644 (file)
@@ -3,14 +3,8 @@
     <assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="wg" type="win32" />
     <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
         <application>
-            <!-- Windows 10 -->
+            <!-- Windows 10 and 11 -->
             <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
-            <!-- Windows 8.1 -->
-            <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
-            <!-- Windows 8 -->
-            <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
-            <!-- Windows 7 -->
-            <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
         </application>
     </compatibility>
     <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">