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));