From 1079962e4c06f88a54e50d997c1b7e84303d30b4 Mon Sep 17 00:00:00 2001 From: Bernhard Schmidt Date: Sat, 15 Aug 2020 21:29:50 +0200 Subject: New upstream version 2.5~beta1 --- src/openvpnmsica/openvpnmsica.h | 153 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 src/openvpnmsica/openvpnmsica.h (limited to 'src/openvpnmsica/openvpnmsica.h') diff --git a/src/openvpnmsica/openvpnmsica.h b/src/openvpnmsica/openvpnmsica.h new file mode 100644 index 0000000..221d03c --- /dev/null +++ b/src/openvpnmsica/openvpnmsica.h @@ -0,0 +1,153 @@ +/* + * openvpnmsica -- Custom Action DLL to provide OpenVPN-specific support to MSI packages + * https://community.openvpn.net/openvpn/wiki/OpenVPNMSICA + * + * Copyright (C) 2018 Simon Rozman + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MSICA_H +#define MSICA_H + +#include +#include +#include "../tapctl/basic.h" + + +/* + * Error codes (next unused 2552L) + */ +#define ERROR_MSICA 2550L +#define ERROR_MSICA_ERRNO 2551L + + +/** + * Thread local storage data + */ +struct openvpnmsica_thread_data +{ + MSIHANDLE hInstall; /** Handle to the installation session. */ +}; + + +/** + * MSI session handle thread local storage index + */ +extern DWORD openvpnmsica_thread_data_idx; + + +/** + * Set MSI session handle in thread local storage. + */ +#define OPENVPNMSICA_SAVE_MSI_SESSION(hInstall) \ +{ \ + struct openvpnmsica_thread_data *s = (struct openvpnmsica_thread_data *)TlsGetValue(openvpnmsica_thread_data_idx); \ + s->hInstall = (hInstall); \ +} + + +/* + * Exported DLL Functions + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __GNUC__ +#define DLLEXP_DECL __declspec(dllexport) +#else +#define DLLEXP_DECL +#define DLLEXP_EXPORT "/EXPORT:" __FUNCTION__ "=" __FUNCDNAME__ +#endif + + +/** + * Determines Windows information: + * + * - Sets `OPENVPNSERVICE` MSI property to PID of OpenVPN Service if running, or its EXE path if + * configured for auto-start. + * + * - Finds existing TAP-Windows6 adapters and set TAPWINDOWS6ADAPTERS and + * ACTIVETAPWINDOWS6ADAPTERS properties with semicolon delimited list of all installed adapter + * GUIDs and active adapter GUIDs respectively. + * + * - Finds existing Wintun adapters and set WINTUNADAPTERS and ACTIVEWINTUNADAPTERS properties + * with semicolon delimited list of all installed adapter GUIDs and active adapter GUIDs + * respectively. + * + * @param hInstall Handle to the installation provided to the DLL custom action + * + * @return ERROR_SUCCESS on success; An error code otherwise + * See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa368072.aspx + */ +DLLEXP_DECL UINT __stdcall +FindSystemInfo(_In_ MSIHANDLE hInstall); + + +/** + * Find OpenVPN GUI window and send it a WM_CLOSE message. + * + * @param hInstall Handle to the installation provided to the DLL custom action + * + * @return ERROR_SUCCESS on success; An error code otherwise + * See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa368072.aspx + */ +DLLEXP_DECL UINT __stdcall +CloseOpenVPNGUI(_In_ MSIHANDLE hInstall); + + +/** + * Launches OpenVPN GUI. It's path is obtained by expanding the `[#bin.openvpn_gui.exe]` + * therefore, its Id field in File table must be "bin.openvpn_gui.exe". + * + * @param hInstall Handle to the installation provided to the DLL custom action + * + * @return ERROR_SUCCESS on success; An error code otherwise + * See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa368072.aspx + */ +DLLEXP_DECL UINT __stdcall +StartOpenVPNGUI(_In_ MSIHANDLE hInstall); + + +/** + * Evaluate the TUNTAPAdapter table of the MSI package database and prepare a list of TAP + * adapters to install/remove. + * + * @param hInstall Handle to the installation provided to the DLL custom action + * + * @return ERROR_SUCCESS on success; An error code otherwise + * See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa368072.aspx + */ +DLLEXP_DECL UINT __stdcall +EvaluateTUNTAPAdapters(_In_ MSIHANDLE hInstall); + + +/** + * Perform scheduled deferred action. + * + * @param hInstall Handle to the installation provided to the DLL custom action + * + * @return ERROR_SUCCESS on success; An error code otherwise + * See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa368072.aspx + */ +DLLEXP_DECL UINT __stdcall +ProcessDeferredAction(_In_ MSIHANDLE hInstall); + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef MSICA_H */ -- cgit v1.2.3 From f2b3dda12a731c2e0971cb7889728edaf23f6cb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Mon, 29 Nov 2021 20:46:00 +0100 Subject: New upstream version 2.5.4 --- src/openvpnmsica/openvpnmsica.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/openvpnmsica/openvpnmsica.h') diff --git a/src/openvpnmsica/openvpnmsica.h b/src/openvpnmsica/openvpnmsica.h index 221d03c..bfc40ea 100644 --- a/src/openvpnmsica/openvpnmsica.h +++ b/src/openvpnmsica/openvpnmsica.h @@ -2,7 +2,7 @@ * openvpnmsica -- Custom Action DLL to provide OpenVPN-specific support to MSI packages * https://community.openvpn.net/openvpn/wiki/OpenVPNMSICA * - * Copyright (C) 2018 Simon Rozman + * Copyright (C) 2018-2021 Simon Rozman * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 @@ -146,6 +146,19 @@ EvaluateTUNTAPAdapters(_In_ MSIHANDLE hInstall); DLLEXP_DECL UINT __stdcall ProcessDeferredAction(_In_ MSIHANDLE hInstall); + +/** + * Schedule reboot after installation if reboot + * indication file is found in user's temp directory + * + * @param hInstall Handle to the installation provided to the DLL custom action + * + * @return ERROR_SUCCESS on success; An error code otherwise + * See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa368072.aspx + */ +DLLEXP_DECL UINT __stdcall +CheckAndScheduleReboot(_In_ MSIHANDLE hInstall); + #ifdef __cplusplus } #endif -- cgit v1.2.3