From patchwork Mon Nov 12 01:22:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Rozman X-Patchwork-Id: 603 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director11.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id 4LlmOx1x6VsnXAAAIUCqbw for ; Mon, 12 Nov 2018 07:25:02 -0500 Received: from proxy17.mail.ord1d.rsapps.net ([172.30.191.6]) by director11.mail.ord1d.rsapps.net with LMTP id yLUUOx1x6VvzdQAAvGGmqA ; Mon, 12 Nov 2018 07:25:01 -0500 Received: from smtp6.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy17.mail.ord1d.rsapps.net with LMTP id cAwCOx1x6VsCJAAAWC7mWg ; Mon, 12 Nov 2018 07:25:01 -0500 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: smtp6.gate.ord1d.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=rozman.si; dmarc=fail (p=none; dis=none) header.from=rozman.si X-Suspicious-Flag: YES X-Classification-ID: f99111e0-e675-11e8-bebd-52540050e3e0-1-1 Received: from [216.105.38.7] ([216.105.38.7:30722] helo=lists.sourceforge.net) by smtp6.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id B7/26-19378-D1179EB5; Mon, 12 Nov 2018 07:25:01 -0500 Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1gMBFc-0005AJ-G5; Mon, 12 Nov 2018 12:23:32 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1gMBFZ-0005AA-Om for openvpn-devel@lists.sourceforge.net; Mon, 12 Nov 2018 12:23:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=+5H9cVH37wglVz8X/b8ptsXm3hnsPSemGsOkyimuAz0=; b=ZZoPB2icCZNyyDR77skDKvZy9n Y2IIOP8GtgRsSgHGsBOo4vOE5/+uSsU7v7ZWwKVkP3RHN7UyYduA3zH9r/58Dweq2CBGtDfdGc8VY Zti+4JEyH1W3vSR7uxyvWPw16FyWbgVkLdk7Rvjpnm/GPHo9cK2BXJSvLXxrH4lXBRPk=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=+5H9cVH37wglVz8X/b8ptsXm3hnsPSemGsOkyimuAz0=; b=P 9ln0DFLbhUKfIe134FchCBxqEkfw51rpLW6PxcpBoTvKcsKHJZtyBmpKSuv4JDsCED83tvTKJOyP8 lz96ET9cR3ZFeyeeJlg4T53Zhg5vgcCFUUj1c5sGl4HeXTJ9nQ+x8zXf0XeqZgKcstOj46FiXfYDx TFwZSBIFplOEUxgA=; Received: from pub5.amebis.si ([213.250.55.21]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1gMBFO-000kT8-As for openvpn-devel@lists.sourceforge.net; Mon, 12 Nov 2018 12:23:29 +0000 Received: from SR6.amebis.doma (unknown [IPv6:2a00:ee2:209:164:8cd9:ee93:28f1:f852]) by pub5.amebis.si (Postfix) with ESMTP id E03DF20107; Mon, 12 Nov 2018 13:23:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=rozman.si; s=default; t=1542025384; bh=2kf8tYdlo08O+f49NcMi1O4nJluPyTCi9PCzmHhP3ag=; h=From:To:Cc:Subject:Date:From; b=APrAavEYZhZiCsjxW2KGmRJm6Uoyw1IqtyD5YJP/m3iywO3NOW1yWxWwLqEB1lzSB EyX1HxOmHQZEOyKv1wHsuk8OOk3BsKwr4189uqGTP8FVzcOz+xRvJotFM/QMncTJ5U EFq2n7q9xnRcZHeT3h591GS2fV31+27agBUvgZyg= From: Simon Rozman To: openvpn-devel@lists.sourceforge.net Date: Mon, 12 Nov 2018 13:22:44 +0100 Message-Id: <20181112122246.13556-1-simon@rozman.si> X-Mailer: git-send-email 2.19.1.windows.1 MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 SPF_PASS SPF: sender matches SPF record -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 0.2 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1gMBFO-000kT8-As Subject: [Openvpn-devel] [PATCH 1/3] Delete TAP interface before the TAP driver is uninstalled 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: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox The previous version of MSI installer did: - Execution Pass: rename the TAP interface to some temporary name - Commit/Rollback Pass: delete the TAP interface / rename the interface back to original name However, the WiX Toolset's Diffx extension to install and remove drivers removed the TAP driver between the execution and commit passes. The TAP driver removal makes all TAP interfaces unavailable and our custom action couldn't find the interface to delete any more. While the system where OpenVPN was uninstalled didn't have any TAP interfaces any more as expected behaviour, the problem appears after reinstalling the OpenVPN. Some residue TAP interface registry keys remain on the system, causing the TAP interface to reappear as "Ethernet NN" interface next time the TAP driver is installed. This causes TAP interfaces to accumulate when cycling install-uninstall-install... Therefore, it is better to remove the TAP interfaces before the TAP driver is removed, and reinstall the TAP interface back should the rollback be required. Though it won't be exactly the same interface again. I wonder if the WiX Diffx extension supports execute/commit/rollback feature of MSI in the first place. Acked-by: Gert Doering --- src/openvpnmsica/msica_op.c | 87 ++++++++++++++----------------------- 1 file changed, 33 insertions(+), 54 deletions(-) diff --git a/src/openvpnmsica/msica_op.c b/src/openvpnmsica/msica_op.c index 8e9a3832..2ce69444 100644 --- a/src/openvpnmsica/msica_op.c +++ b/src/openvpnmsica/msica_op.c @@ -454,62 +454,41 @@ msica_op_tap_interface_delete( DWORD dwResult; - if (session->rollback_enabled) - { - int count = 0; - - do { - /* Rename the interface to keep it as a backup. */ - TCHAR szNameBackup[10/*"Interface "*/ + 10/*maximum int*/ + 1/*terminator*/]; - _stprintf_s( - szNameBackup, _countof(szNameBackup), - TEXT("Interface %i"), - ++count); - for (struct tap_interface_node *pInterfaceOther = pInterfaceList; ; pInterfaceOther = pInterfaceOther->pNext) - { - if (pInterfaceOther == NULL) - { - /* No interface with a same name found. All clear to rename the interface. */ - dwResult = tap_set_interface_name(&pInterface->guid, szNameBackup); - break; - } - else if (_tcsicmp(szNameBackup, pInterfaceOther->szName) == 0) - { - /* Interface with a same name found. Duplicate interface names are not allowed. */ - dwResult = ERROR_ALREADY_EXISTS; - break; - } - } - } while (dwResult == ERROR_ALREADY_EXISTS); + /* Delete the interface. */ + BOOL bRebootRequired = FALSE; + dwResult = tap_delete_interface(NULL, &pInterface->guid, &bRebootRequired); + if (bRebootRequired) + MsiSetMode(session->hInstall, MSIRUNMODE_REBOOTATEND, TRUE); - if (dwResult == ERROR_SUCCESS) { - /* Schedule rollback action to rename the interface back. */ - msica_op_seq_add_head( - &session->seq_cleanup[MSICA_CLEANUP_ACTION_ROLLBACK], - msica_op_create_guid_string( - msica_op_tap_interface_set_name, - 0, - NULL, - &pInterface->guid, - pInterface->szName)); - - /* Schedule commit action to delete the interface. */ - msica_op_seq_add_tail( - &session->seq_cleanup[MSICA_CLEANUP_ACTION_COMMIT], - msica_op_create_guid( - msica_op_tap_interface_delete_by_guid, - 0, - NULL, - &pInterface->guid)); - } - } - else + if (session->rollback_enabled) { - /* Delete the interface. */ - BOOL bRebootRequired = FALSE; - dwResult = tap_delete_interface(NULL, &pInterface->guid, &bRebootRequired); - if (bRebootRequired) - MsiSetMode(session->hInstall, MSIRUNMODE_REBOOTATEND, TRUE); + /* + Schedule rollback action to create the interface back. Though it won't be exactly the same interface again. + + The previous version of this function did: + - Execution Pass: rename the interface to some temporary name + - Commit/Rollback Pass: delete the interface / rename the interface back to original name + + However, the WiX Toolset's Diffx extension to install and remove drivers removed the TAP driver between the + execution and commit passes. TAP driver removal makes all TAP interfaces unavailable and our CA couldn't find + the interface to delete any more. + + While the system where OpenVPN was uninstalled didn't have any TAP interfaces any more as expected behaviour, + the problem appears after reinstalling the OpenVPN. Some residue TAP interface registry keys remain on the + system, causing the TAP interface to reappear as "Ethernet NN" interface next time the TAP driver is + installed. This causes TAP interfaces to accumulate over cyclic install-uninstall-install... + + Therefore, it is better to remove the TAP interfaces before the TAP driver is removed, and reinstall the TAP + interface back should the rollback be required. I wonder if the WiX Diffx extension supports execute/commit/ + rollback feature of MSI in the first place. + */ + msica_op_seq_add_head( + &session->seq_cleanup[MSICA_CLEANUP_ACTION_ROLLBACK], + msica_op_create_string( + msica_op_tap_interface_create, + 0, + NULL, + pInterface->szName)); } return dwResult; From patchwork Mon Nov 12 01:22:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Rozman X-Patchwork-Id: 604 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director8.mail.ord1d.rsapps.net ([172.27.255.59]) by backend30.mail.ord1d.rsapps.net with LMTP id 2FpcAh5x6VuDIgAAIUCqbw for ; Mon, 12 Nov 2018 07:25:02 -0500 Received: from proxy15.mail.iad3a.rsapps.net ([172.27.255.59]) by director8.mail.ord1d.rsapps.net with LMTP id MBaNOx1x6Vs3XQAAfY0hYg ; Mon, 12 Nov 2018 07:25:02 -0500 Received: from smtp3.gate.iad3a ([172.27.255.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy15.mail.iad3a.rsapps.net with LMTP id WI9zNh1x6VtOTQAAHi9b9g ; Mon, 12 Nov 2018 07:25:01 -0500 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: smtp3.gate.iad3a.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=rozman.si; dmarc=fail (p=none; dis=none) header.from=rozman.si X-Suspicious-Flag: YES X-Classification-ID: f9605dca-e675-11e8-b837-525400af4d07-1-1 Received: from [216.105.38.7] ([216.105.38.7:22000] helo=lists.sourceforge.net) by smtp3.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id B0/37-30429-D1179EB5; Mon, 12 Nov 2018 07:25:01 -0500 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 1gMBFh-0002PI-JL; Mon, 12 Nov 2018 12:23:37 +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 1gMBFg-0002PB-HZ for openvpn-devel@lists.sourceforge.net; Mon, 12 Nov 2018 12:23:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: 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=TQnYOpyEsITJw9nPwpKW4DIwEWUBYTEXb/Q0ekhc6Fo=; b=Slq2I07r3aGYuTPjLx+btv/Ule eMkJyhK+sCpwigrC9dR3y1UFtZ6yD+T2+Ur8NdZSHGwFSwRZUr5XCrLOQEwASx8JWEJWGRZvjrptX Yy11B5k7EpArbQYVaAwg1JGui3WDjiiWO3CBTFxy08OAc/CCij0tOmaWs3rt8TOEuRcI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=TQnYOpyEsITJw9nPwpKW4DIwEWUBYTEXb/Q0ekhc6Fo=; b=mSQ8vIDR6crukwh/WI9mPv3wa+ wIsvUtVf0q9RMLS0zPzOE8GwD07OmHo6r7GBuvnCbP8kQVyDMhXlizYNWi56X4khNmkFngOySqPGi zijUkB3HxeGywzHsT3bz2WtbtPJNRiDXY5g6q9PevitE0miiS9cMzYOWtgkgSpsB92po=; Received: from pub5.amebis.si ([213.250.55.21]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1gMBFN-00EywG-Pa for openvpn-devel@lists.sourceforge.net; Mon, 12 Nov 2018 12:23:36 +0000 Received: from SR6.amebis.doma (unknown [IPv6:2a00:ee2:209:164:8cd9:ee93:28f1:f852]) by pub5.amebis.si (Postfix) with ESMTP id DA197203C3; Mon, 12 Nov 2018 13:23:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=rozman.si; s=default; t=1542025387; bh=khpTqwIwHe8eOHBgzjIyQrght7zzNZxmuK2wA/VZOlA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SgZMPjnNlNYda7jD3aSvOyo/xPqyxH0YXpmxHVgrQUJ0eozDr0rnNHd4ZnEIq+G9n Y/Q/suslmXzpVA1m4ZYydedNKQ/fR4QsHp3/OvVuub+X8AgyEUAzwVLuUn63tYQWBm T7vuRz4tFyMH0WWcNpopsYwMsez+JXL6bKSSpX/4= From: Simon Rozman To: openvpn-devel@lists.sourceforge.net Date: Mon, 12 Nov 2018 13:22:45 +0100 Message-Id: <20181112122246.13556-2-simon@rozman.si> X-Mailer: git-send-email 2.19.1.windows.1 In-Reply-To: <20181112122246.13556-1-simon@rozman.si> References: <20181112122246.13556-1-simon@rozman.si> MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -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 0.0 TIME_LIMIT_EXCEEDED Exceeded time limit / deadline X-Headers-End: 1gMBFN-00EywG-Pa Subject: [Openvpn-devel] [PATCH 2/3] Change C++ to C comments 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: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox --- src/openvpnmsica/openvpnmsica.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) Acked-by: Gert Doering diff --git a/src/openvpnmsica/openvpnmsica.c b/src/openvpnmsica/openvpnmsica.c index d1642d6a..99b47bf0 100644 --- a/src/openvpnmsica/openvpnmsica.c +++ b/src/openvpnmsica/openvpnmsica.c @@ -162,7 +162,7 @@ FindSystemInfo(_In_ MSIHANDLE hInstall) struct openvpnmsica_tls_data *s = (struct openvpnmsica_tls_data *)TlsGetValue(openvpnmsica_tlsidx_session); s->hInstall = hInstall; - // Get Windows version. + /* Get Windows version. */ OSVERSIONINFOEX ver_info = { .dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX) }; if (!GetVersionEx((LPOSVERSIONINFO)&ver_info)) { uiResult = GetLastError(); @@ -170,7 +170,7 @@ FindSystemInfo(_In_ MSIHANDLE hInstall) goto cleanup_CoInitialize; } - // The Windows version is usually spoofed, check using RtlGetVersion(). + /* The Windows version is usually spoofed, check using RtlGetVersion(). */ TCHAR szDllPath[0x1000]; ExpandEnvironmentStrings(TEXT("%SystemRoot%\\System32\\ntdll.dll"), szDllPath, #ifdef UNICODE @@ -193,7 +193,7 @@ FindSystemInfo(_In_ MSIHANDLE hInstall) rtl_ver_info.dwMajorVersion == ver_info.dwMajorVersion && rtl_ver_info.dwMinorVersion > ver_info.dwMinorVersion || rtl_ver_info.dwMajorVersion == ver_info.dwMajorVersion && rtl_ver_info.dwMinorVersion == ver_info.dwMinorVersion && rtl_ver_info.dwBuildNumber > ver_info.dwBuildNumber) { - // We got RtlGetVersion() and it reported newer version than GetVersionEx(). + /* We got RtlGetVersion() and it reported newer version than GetVersionEx(). */ ver_info.dwMajorVersion = rtl_ver_info.dwMajorVersion; ver_info.dwMinorVersion = rtl_ver_info.dwMinorVersion; ver_info.dwBuildNumber = rtl_ver_info.dwBuildNumber; @@ -204,7 +204,7 @@ FindSystemInfo(_In_ MSIHANDLE hInstall) FreeLibrary(hNtDllModule); } - // We don't trust RtlGetVersion() either. Check the version resource of kernel32.dll. + /* We don't trust RtlGetVersion() either. Check the version resource of kernel32.dll. */ ExpandEnvironmentStrings(TEXT("%SystemRoot%\\System32\\kernel32.dll"), szDllPath, #ifdef UNICODE _countof(szDllPath) @@ -220,10 +220,10 @@ FindSystemInfo(_In_ MSIHANDLE hInstall) LPVOID pVersionInfo = malloc(dwVerInfoSize); if (pVersionInfo) { - // Read version info. + /* Read version info. */ if (GetFileVersionInfo(szDllPath, dwHandle, dwVerInfoSize, pVersionInfo)) { - // Get the value for the root block. + /* Get the value for the root block. */ UINT uiSize = 0; VS_FIXEDFILEINFO *pVSFixedFileInfo = NULL; if (VerQueryValue(pVersionInfo, TEXT("\\"), &pVSFixedFileInfo, &uiSize) && uiSize && pVSFixedFileInfo) @@ -231,7 +231,7 @@ FindSystemInfo(_In_ MSIHANDLE hInstall) HIWORD(pVSFixedFileInfo->dwProductVersionMS) == ver_info.dwMajorVersion && LOWORD(pVSFixedFileInfo->dwProductVersionMS) > ver_info.dwMinorVersion || HIWORD(pVSFixedFileInfo->dwProductVersionMS) == ver_info.dwMajorVersion && LOWORD(pVSFixedFileInfo->dwProductVersionMS) == ver_info.dwMinorVersion && HIWORD(pVSFixedFileInfo->dwProductVersionLS) > ver_info.dwBuildNumber) { - // We got kernel32.dll version and it is newer. + /* We got kernel32.dll version and it is newer. */ ver_info.dwMajorVersion = HIWORD(pVSFixedFileInfo->dwProductVersionMS); ver_info.dwMinorVersion = LOWORD(pVSFixedFileInfo->dwProductVersionMS); ver_info.dwBuildNumber = HIWORD(pVSFixedFileInfo->dwProductVersionLS); From patchwork Mon Nov 12 01:22:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Rozman X-Patchwork-Id: 605 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director9.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id mLxzBSNx6VsnXAAAIUCqbw for ; Mon, 12 Nov 2018 07:25:07 -0500 Received: from proxy15.mail.ord1d.rsapps.net ([172.30.191.6]) by director9.mail.ord1d.rsapps.net with LMTP id WDNbBSNx6VtsDQAAalYnBA ; Mon, 12 Nov 2018 07:25:07 -0500 Received: from smtp24.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy15.mail.ord1d.rsapps.net with LMTP id 6PQiBSNx6VsYFAAAAY1PeQ ; Mon, 12 Nov 2018 07:25:07 -0500 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: smtp24.gate.ord1d.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=rozman.si; dmarc=fail (p=none; dis=none) header.from=rozman.si X-Suspicious-Flag: YES X-Classification-ID: fc8b1fc6-e675-11e8-ab62-52540091a1c4-1-1 Received: from [216.105.38.7] ([216.105.38.7:49413] helo=lists.sourceforge.net) by smtp24.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id CA/A7-05022-22179EB5; Mon, 12 Nov 2018 07:25:06 -0500 Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1gMBFf-0005Ac-Io; Mon, 12 Nov 2018 12:23:35 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1gMBFf-0005AW-1m for openvpn-devel@lists.sourceforge.net; Mon, 12 Nov 2018 12:23:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: 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=Sy5/OhXYvBS38NViX/POzHwyb4Qqd68s5IKaLspMYew=; b=MCvzLRiNxc4+G+2fVSVO0w0s5K VmHDua0VAQiFFSJywk9yg1eV15BXf94RneI5Y7PPZWPktxfrIHmYAkJVAF6ovnlHO/bd2n6ZigwVz 8NGzdPEzHsBcjACOA+1MhISxxwbygxxlld3CmECnP+nLv7hypwT9nT8s3qSEgR1fDUgs=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=Sy5/OhXYvBS38NViX/POzHwyb4Qqd68s5IKaLspMYew=; b=XffMhq0Pm1jpC64S658Az8RBpD 6G7pTYdAP0dyh2HdWhS8eu5iiZ7LGKl8sQLxwJ68Rru0O0HZ8ld45dBqE4h9hyZx5B5fi7YG0FIH0 rH+DW0VNROEljT+AcpR5li4fEWPwf+k1iRfcJW6ccvvPja8hIYL0HL06kTMtFRPsqcI8=; Received: from pub5.amebis.si ([213.250.55.21]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1gMBFQ-006bvd-EM for openvpn-devel@lists.sourceforge.net; Mon, 12 Nov 2018 12:23:35 +0000 Received: from SR6.amebis.doma (unknown [IPv6:2a00:ee2:209:164:8cd9:ee93:28f1:f852]) by pub5.amebis.si (Postfix) with ESMTP id 70BCD20512; Mon, 12 Nov 2018 13:23:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=rozman.si; s=default; t=1542025391; bh=rYIx2QqRXOzU5hyMXYrUWisg3uesdm9wCWNwWH2y+9A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S1y7cL+fv5+/74Pygq5DqXfO3h1oDRnJnUPm/DAvF9uoYIL3CrinWZMuPQTUqZi6e 6CGvX4uL1artCpC4G4IlwbV9qa6cA/cBvOfrMXz1HUhW8RWI+XiFI5wDxUK3q3XNtq OJc8gz9xTRd2K1csySvMAjEriP+ZaWVFkkVcDs70= From: Simon Rozman To: openvpn-devel@lists.sourceforge.net Date: Mon, 12 Nov 2018 13:22:46 +0100 Message-Id: <20181112122246.13556-3-simon@rozman.si> X-Mailer: git-send-email 2.19.1.windows.1 In-Reply-To: <20181112122246.13556-1-simon@rozman.si> References: <20181112122246.13556-1-simon@rozman.si> MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 SPF_PASS SPF: sender matches SPF record -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 0.1 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1gMBFQ-006bvd-EM Subject: [Openvpn-devel] [PATCH 3/3] Make MSI custom action debug pop-up more informative 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: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox Each MSI custom action pops-up a message box in the _DEBUG version before commencing execution. This opens a time window for developer to attach debugger to the msiexec.exe process, set the breakpoints before custom action proceeds with execution. While those pop-up dialogs are targeted to a limited audience, they were very sparse. With this patch, they become more informative and they also provide PID of the msiexec.exe process to attach debugger to. Acked-by: Gert Doering --- src/openvpnmsica/openvpnmsica.c | 60 ++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/src/openvpnmsica/openvpnmsica.c b/src/openvpnmsica/openvpnmsica.c index 99b47bf0..a2819e62 100644 --- a/src/openvpnmsica/openvpnmsica.c +++ b/src/openvpnmsica/openvpnmsica.c @@ -144,6 +144,50 @@ openvpnmsica_setup_sequence_filename( } +#ifdef _DEBUG + +/** + * Pops up a message box creating a time window to attach a debugger to the installer process in + * order to debug custom actions. + * + * @param szFunctionName Function name that triggered the pop-up. Displayed in message box's + * title. + */ +static void +_openvpnmsica_debug_popup(_In_z_ LPCTSTR szFunctionName) +{ + TCHAR szTitle[0x100], szMessage[0x100+MAX_PATH], szProcessPath[MAX_PATH]; + + /* Compose pop-up title. The dialog title will contain function name to ease the process + locating. Mind that Visual Studio displays window titles on the process list. */ + _stprintf_s(szTitle, _countof(szTitle), TEXT("%s v%s"), szFunctionName, TEXT(PACKAGE_VERSION)); + + /* Get process name. */ + GetModuleFileName(NULL, szProcessPath, _countof(szProcessPath)); + LPCTSTR szProcessName = _tcsrchr(szProcessPath, TEXT('\\')); + szProcessName = szProcessName ? szProcessName + 1 : szProcessPath; + + /* Compose the pop-up message. */ + _stprintf_s( + szMessage, _countof(szMessage), + TEXT("The %s process (PID: %u) has started to execute the %s custom action.\r\n") + TEXT("\r\n") + TEXT("If you would like to debug the custom action, attach a debugger to this process and set breakpoints before dismissing this dialog.\r\n") + TEXT("\r\n") + TEXT("If you are not debugging this custom action, you can safely ignore this message."), + szProcessName, + GetCurrentProcessId(), + szFunctionName); + + MessageBox(NULL, szMessage, szTitle, MB_OK); +} + +#define openvpnmsica_debug_popup(f) _openvpnmsica_debug_popup(f) +#else +#define openvpnmsica_debug_popup(f) +#endif + + UINT __stdcall FindSystemInfo(_In_ MSIHANDLE hInstall) { @@ -151,9 +195,7 @@ FindSystemInfo(_In_ MSIHANDLE hInstall) #pragma comment(linker, DLLEXP_EXPORT) #endif -#ifdef _DEBUG - MessageBox(NULL, TEXT("Attach debugger!"), TEXT(__FUNCTION__) TEXT(" v") TEXT(PACKAGE_VERSION), MB_OK); -#endif + openvpnmsica_debug_popup(TEXT(__FUNCTION__)); UINT uiResult; BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL)); @@ -265,9 +307,7 @@ FindTAPInterfaces(_In_ MSIHANDLE hInstall) #pragma comment(linker, DLLEXP_EXPORT) #endif -#ifdef _DEBUG - MessageBox(NULL, TEXT("Attach debugger!"), TEXT(__FUNCTION__) TEXT(" v") TEXT(PACKAGE_VERSION), MB_OK); -#endif + openvpnmsica_debug_popup(TEXT(__FUNCTION__)); UINT uiResult; BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL)); @@ -371,9 +411,7 @@ EvaluateTAPInterfaces(_In_ MSIHANDLE hInstall) #pragma comment(linker, DLLEXP_EXPORT) #endif -#ifdef _DEBUG - MessageBox(NULL, TEXT("Attach debugger!"), TEXT(__FUNCTION__) TEXT(" v") TEXT(PACKAGE_VERSION), MB_OK); -#endif + openvpnmsica_debug_popup(TEXT(__FUNCTION__)); UINT uiResult; BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL)); @@ -633,9 +671,7 @@ ProcessDeferredAction(_In_ MSIHANDLE hInstall) #pragma comment(linker, DLLEXP_EXPORT) #endif -#ifdef _DEBUG - MessageBox(NULL, TEXT("Attach debugger!"), TEXT(__FUNCTION__) TEXT(" v") TEXT(PACKAGE_VERSION), MB_OK); -#endif + openvpnmsica_debug_popup(TEXT(__FUNCTION__)); UINT uiResult; BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));