blob: bfc40ea3a7094c7a02865e4b1f2ee311a32fad9c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
/*
* openvpnmsica -- Custom Action DLL to provide OpenVPN-specific support to MSI packages
* https://community.openvpn.net/openvpn/wiki/OpenVPNMSICA
*
* Copyright (C) 2018-2021 Simon Rozman <simon@rozman.si>
*
* 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 <windows.h>
#include <msi.h>
#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);
/**
* 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
#endif /* ifndef MSICA_H */
|