From patchwork Fri Jul 24 09:56:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lev Stipakov X-Patchwork-Id: 1334 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director7.mail.ord1d.rsapps.net ([172.28.255.1]) by backend30.mail.ord1d.rsapps.net with LMTP id AFo4CTpCG1/lawAAIUCqbw for ; Fri, 24 Jul 2020 16:19:06 -0400 Received: from proxy4.mail.ord1c.rsapps.net ([172.28.255.1]) by director7.mail.ord1d.rsapps.net with LMTP id 4FoWCTpCG19AIAAAovjBpQ (envelope-from ) for ; Fri, 24 Jul 2020 16:19:06 -0400 Received: from smtp36.gate.ord1c ([172.28.255.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy4.mail.ord1c.rsapps.net with LMTP id ENLsCDpCG19FKQAAjcXvpA ; Fri, 24 Jul 2020 16:19:06 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp36.gate.ord1c.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dkim=fail (signature verification failed) header.d=gmail.com; dmarc=fail (p=none; dis=none) header.from=gmail.com X-Suspicious-Flag: YES X-Classification-ID: ebbc1d18-cdea-11ea-aee9-5452006630bd-1-1 Received: from [216.105.38.7] ([216.105.38.7:50620] helo=lists.sourceforge.net) by smtp36.gate.ord1c.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 2B/4C-24507-9324B1F5; Fri, 24 Jul 2020 16:19:05 -0400 Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1jz49C-0008To-Vg; Fri, 24 Jul 2020 20:18:26 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jz49B-0008Tf-OG for openvpn-devel@lists.sourceforge.net; Fri, 24 Jul 2020 20:18:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=EuO7mmlJoGKp+BQqGxNj+E6hjC7H7vi9jwPlmwJNnNc=; b=UuxnzBIZiuWsgSzrGuaqECVcbK RsfOHe6HmEErHLVHoA9IJP2sQyr1IIrwGXDUB4X+EaHxmjxAPO7J09z/SFtgBwe0V9xXxZCFMMt5u c3Q4wePYKUbWGgAlOfy0KJJLyOLCPPtqX1xLMZNkYvK8efKsNArSOkj2pzoAWbeBk7ZM=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To :MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=EuO7mmlJoGKp+BQqGxNj+E6hjC7H7vi9jwPlmwJNnNc=; b=T/+J+JTpnZ90yGXuS5gw686YIT BecxZVnvg6LLwsqKuBRbytKZHLAY92vKytJT4j0sWGkXl73f2Q2Tm7ynbM4fAEm5f1+9Xk4tVQi8W Jp48cefWFJxSpvnlKfIdEP3NX9HM6AUbeGTZ7hKBvwJRhOWx74ZS/XA1JQqG+lBr3Chg=; Received: from mail-lj1-f194.google.com ([209.85.208.194]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.2) id 1jz49A-007v7Y-EG for openvpn-devel@lists.sourceforge.net; Fri, 24 Jul 2020 20:18:25 +0000 Received: by mail-lj1-f194.google.com with SMTP id r19so11170837ljn.12 for ; Fri, 24 Jul 2020 13:18:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EuO7mmlJoGKp+BQqGxNj+E6hjC7H7vi9jwPlmwJNnNc=; b=jmvndLSyiJodBHwoHWtAzhSRJ+n33H8q/2vHWPNrFdJKRxbWS8Jmjbs1LR6tgHDfwU bTN+hQ+zjzhPozEki1+QMn4VVf7E/FPx9E4dhm/IGkTZ9WFEeC13N0DWD1dW95WC6zCo lsZdYkmmvwyRLGG/yHMuVsZhfeZWWEBJ38Mv/DOIlP5ON/3vd7LrCEayakkEGKEDnocu 3lwqTvYK4gdpjnSSBlW7zIzi0hG/q9edhsFMSdlIp0MTqbfw51EwgWZR/m77nKfN5XVx /d2R62IHSqKrgDe+/hEOeGYMmCMIIauZi0yjLhZXfSVmkjf10wIpiWMdk0OJpcDOUAK9 XPiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EuO7mmlJoGKp+BQqGxNj+E6hjC7H7vi9jwPlmwJNnNc=; b=NxLP/Bcu18jei/bTh39VBSCSPnK71MahcABh2rNEnrV06UDOO686ZuiaSSPznnwxdE +b+v2tqmaDVvnV3j6gwX0Tdnq0Fa5fLm9VK+o0BmmG0chft/d2Xog/73kkCcp9aK7DMF nZkvMUHS7+FnRjfbbIsAt7wD49n3o6Tye12/9InN+CqcTDTlT+wEpkJY9+GINPq3Nypl Sl2FWf3L9FVsq+UsMZ/Ddc6dxYsVMAKhGoR4sIYYgOVy1tTyQa1dve7Jnr49ILtXskrh 8Ay7A8v4WmD94chpAthScW9DuMqxQPrX0vUxwekmYj+UGFgZukUb4zcoS46mFQUVms8x OB4g== X-Gm-Message-State: AOAM532ozHNoA25ovHi1M1frHJNKpTZuuPQvQDh2N1UmF+JT68tWNdvP +0y4Y6xn9U8I90MMsO5jDj9ugw0R X-Google-Smtp-Source: ABdhPJwrMw6RYvx9QUgZBWuSktOfMDuYaQLUvfSg3wyFqI63fuOq4bp+eUWa48kyHCsIjr+Qq5mngw== X-Received: by 2002:a2e:7314:: with SMTP id o20mr5238156ljc.233.1595621897199; Fri, 24 Jul 2020 13:18:17 -0700 (PDT) Received: from LAPTOP-4L3N7KFS.localdomain (81-175-130-136.bb.dnainternet.fi. [81.175.130.136]) by smtp.gmail.com with ESMTPSA id v26sm52310lji.65.2020.07.24.13.18.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jul 2020 13:18:16 -0700 (PDT) From: Lev Stipakov To: openvpn-devel@lists.sourceforge.net Date: Fri, 24 Jul 2020 22:56:34 +0300 Message-Id: <20200724195634.493-1-lstipakov@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200724184020.GJ1431@greenie.muc.de> References: <20200724184020.GJ1431@greenie.muc.de> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.208.194 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (lstipakov[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: openvpn.net] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.208.194 listed in wl.mailspike.net] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-Headers-End: 1jz49A-007v7Y-EG Subject: [Openvpn-devel] [PATCH v2] Improve Windows version detection with manifest X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lev Stipakov MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Lev Stipakov Add manifest file to detect Windows versions greater than Windows 8. Below is example output on Windows 10. Before: Windows version 6.2 (Windows 8 or greater) 64bit After: Windows version 10.0 (Windows 10 or greater) 64bit Signed-off-by: Lev Stipakov Acked-by: Gert Doering --- v2: - fix build from tarball (added manifest file to EXTRA_DIST) - fix build on old mingw like ubuntu 18.04 (added missig define) src/compat/compat-versionhelpers.h | 10 ++++++++ src/openvpn/Makefile.am | 3 ++- src/openvpn/openvpn.manifest | 33 ++++++++++++++++++++++++++ src/openvpn/openvpn.vcxproj | 15 ++++++++++++ src/openvpn/openvpn.vcxproj.filters | 5 ++++ src/openvpn/openvpn_win32_resources.rc | 2 ++ src/openvpn/win32.c | 20 ++++++++++++++-- src/openvpn/win32.h | 8 ++++--- 8 files changed, 90 insertions(+), 6 deletions(-) create mode 100644 src/openvpn/openvpn.manifest diff --git a/src/compat/compat-versionhelpers.h b/src/compat/compat-versionhelpers.h index 251fb047..9e25470e 100644 --- a/src/compat/compat-versionhelpers.h +++ b/src/compat/compat-versionhelpers.h @@ -18,6 +18,10 @@ #define _WIN32_WINNT_WINBLUE 0x0603 +#ifndef _WIN32_WINNT_WINTHRESHOLD +#define _WIN32_WINNT_WINTHRESHOLD 0x0A00 // Windows 10 +#endif + VERSIONHELPERAPI IsWindowsVersionOrGreater(WORD major, WORD minor, WORD servpack) { @@ -95,6 +99,12 @@ IsWindows8Point1OrGreater(void) return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINBLUE), LOBYTE(_WIN32_WINNT_WINBLUE), 0); } +VERSIONHELPERAPI +IsWindows10OrGreater() +{ + return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINTHRESHOLD), LOBYTE(_WIN32_WINNT_WINTHRESHOLD), 0); +} + VERSIONHELPERAPI IsWindowsServer(void) { diff --git a/src/openvpn/Makefile.am b/src/openvpn/Makefile.am index 47ad762d..37b002c6 100644 --- a/src/openvpn/Makefile.am +++ b/src/openvpn/Makefile.am @@ -16,7 +16,8 @@ MAINTAINERCLEANFILES = \ EXTRA_DIST = \ openvpn.vcxproj \ - openvpn.vcxproj.filters + openvpn.vcxproj.filters \ + openvpn.manifest AM_CPPFLAGS = \ -I$(top_srcdir)/include \ diff --git a/src/openvpn/openvpn.manifest b/src/openvpn/openvpn.manifest new file mode 100644 index 00000000..fa5b3d7f --- /dev/null +++ b/src/openvpn/openvpn.manifest @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/openvpn/openvpn.vcxproj b/src/openvpn/openvpn.vcxproj index bd1a5844..5367979d 100644 --- a/src/openvpn/openvpn.vcxproj +++ b/src/openvpn/openvpn.vcxproj @@ -70,6 +70,18 @@ <_ProjectFileVersion>10.0.30319.1 + + false + + + false + + + false + + + false + ..\compat;$(TAP_WINDOWS_HOME)/include;$(OPENSSL_HOME)/include;$(LZO_HOME)/include;$(PKCS11H_HOME)/include;%(AdditionalIncludeDirectories) @@ -311,6 +323,9 @@ false + + + diff --git a/src/openvpn/openvpn.vcxproj.filters b/src/openvpn/openvpn.vcxproj.filters index e0bc7d5e..cf5748c7 100644 --- a/src/openvpn/openvpn.vcxproj.filters +++ b/src/openvpn/openvpn.vcxproj.filters @@ -515,4 +515,9 @@ Resource Files + + + Resource Files + + \ No newline at end of file diff --git a/src/openvpn/openvpn_win32_resources.rc b/src/openvpn/openvpn_win32_resources.rc index e4f1ee95..1ea5f878 100644 --- a/src/openvpn/openvpn_win32_resources.rc +++ b/src/openvpn/openvpn_win32_resources.rc @@ -7,6 +7,8 @@ #pragma code_page(65001) /* UTF8 */ +1 RT_MANIFEST "openvpn.manifest" + LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL VS_VERSION_INFO VERSIONINFO diff --git a/src/openvpn/win32.c b/src/openvpn/win32.c index eb4c0307..7e913165 100644 --- a/src/openvpn/win32.c +++ b/src/openvpn/win32.c @@ -1417,10 +1417,18 @@ win32_version_info(void) { return WIN_7; } - else + + if (!IsWindows8Point1OrGreater()) { return WIN_8; } + + if (!IsWindows10OrGreater()) + { + return WIN_8_1; + } + + return WIN_10; } bool @@ -1458,7 +1466,15 @@ win32_version_string(struct gc_arena *gc, bool add_name) break; case WIN_8: - buf_printf(&out, "6.2%s", add_name ? " (Windows 8 or greater)" : ""); + buf_printf(&out, "6.2%s", add_name ? " (Windows 8)" : ""); + break; + + case WIN_8_1: + buf_printf(&out, "6.3%s", add_name ? " (Windows 8.1)" : ""); + break; + + case WIN_10: + buf_printf(&out, "10.0%s", add_name ? " (Windows 10 or greater)" : ""); break; default: diff --git a/src/openvpn/win32.h b/src/openvpn/win32.h index 79504776..da85ed4d 100644 --- a/src/openvpn/win32.h +++ b/src/openvpn/win32.h @@ -298,10 +298,12 @@ bool win_wfp_block_dns(const NET_IFINDEX index, const HANDLE msg_channel); bool win_wfp_uninit(const NET_IFINDEX index, const HANDLE msg_channel); -#define WIN_XP 0 +#define WIN_XP 0 #define WIN_VISTA 1 -#define WIN_7 2 -#define WIN_8 3 +#define WIN_7 2 +#define WIN_8 3 +#define WIN_8_1 4 +#define WIN_10 5 int win32_version_info(void);