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