OpenVPN
msica_op.h
Go to the documentation of this file.
1 /*
2  * openvpnmsica -- Custom Action DLL to provide OpenVPN-specific support to MSI packages
3  * https://community.openvpn.net/openvpn/wiki/OpenVPNMSICA
4  *
5  * Copyright (C) 2018 Simon Rozman <simon@rozman.si>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2
9  * as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #ifndef MSICA_OP_H
22 #define MSICA_OP_H
23 
24 #include <windows.h>
25 #include <msi.h>
26 #include <stdarg.h>
27 #include <stdbool.h>
28 #include <tchar.h>
29 #include "../tapctl/basic.h"
30 
31 #ifdef _MSC_VER
32 #pragma warning(push)
33 #pragma warning(disable: 4200) /* Using zero-sized arrays in struct/union. */
34 #endif
35 
36 
40 #define MSICA_MAKE_OP_TYPE(op, data) (((op)<<4)|((data)&0xf))
41 #define MSICA_OP_TYPE_OP(type) ((unsigned int)(type)>>4)
42 #define MSICA_OP_TYPE_DATA(type) ((unsigned int)(type)&0xf)
43 
44 
49 {
57 };
58 
59 
63 struct msica_op
64 {
66  int ticks;
67  struct msica_op *next;
68 };
69 
70 
75 {
76  struct msica_op *head;
77  struct msica_op *tail;
78 };
79 
80 
86 void
88 
89 
95 void
97 
98 
103 {
104  struct msica_op base;
105  bool value;
106 };
107 
108 
124 struct msica_op *
126  _In_ enum msica_op_type type,
127  _In_ int ticks,
128  _In_opt_ struct msica_op *next,
129  _In_ bool value);
130 
131 
136 {
137  struct msica_op base;
138  TCHAR value[];
139 };
140 
141 
157 struct msica_op *
159  _In_ enum msica_op_type type,
160  _In_ int ticks,
161  _In_opt_ struct msica_op *next,
162  _In_z_ LPCTSTR value);
163 
164 
169 {
170  struct msica_op base;
171  TCHAR value[];
172 };
173 
174 
190 struct msica_op *
192  _In_ enum msica_op_type type,
193  _In_ int ticks,
194  _In_opt_ struct msica_op *next,
195  _In_ va_list arglist);
196 
197 
202 {
203  struct msica_op base;
204  GUID value;
205 };
206 
207 
223 struct msica_op *
225  _In_ enum msica_op_type type,
226  _In_ int ticks,
227  _In_opt_ struct msica_op *next,
228  _In_ const GUID *value);
229 
230 
235 {
236  struct msica_op base;
237  GUID value_guid;
238  TCHAR value_str[];
239 };
240 
241 
259 struct msica_op *
261  _In_ enum msica_op_type type,
262  _In_ int ticks,
263  _In_opt_ struct msica_op *next,
264  _In_ const GUID *value_guid,
265  _In_z_ LPCTSTR value_str);
266 
267 
282 static inline struct msica_op *
284  _In_ enum msica_op_type type,
285  _In_ int ticks,
286  _In_opt_ struct msica_op *next,
287  ...)
288 {
289  va_list arglist;
290  va_start(arglist, next);
291  struct msica_op *op = msica_op_create_multistring_va(type, ticks, next, arglist);
292  va_end(arglist);
293  return op;
294 }
295 
296 
304 static inline bool
306 {
307  return seq->head != NULL;
308 }
309 
310 
320 void
322  _Inout_ struct msica_op_seq *seq,
323  _Inout_ struct msica_op *operation);
324 
325 
335 void
337  _Inout_ struct msica_op_seq *seq,
338  _Inout_ struct msica_op *operation);
339 
340 
350 DWORD
352  _In_ const struct msica_op_seq *seq,
353  _In_ HANDLE hFile);
354 
355 
365 DWORD
367  _Inout_ struct msica_op_seq *seq,
368  _In_ HANDLE hFile);
369 
370 
374 #define MSICA_CLEANUP_ACTION_COMMIT 0
375 #define MSICA_CLEANUP_ACTION_ROLLBACK 1
376 #define MSICA_CLEANUP_ACTION_COUNT 2
377 
378 
383 {
384  MSIHANDLE hInstall;
388 };
389 
390 
402 void
404  _Inout_ struct msica_session *session,
405  _In_ MSIHANDLE hInstall,
406  _In_ bool continue_on_error,
407  _In_ bool rollback_enabled);
408 
409 
421 DWORD
423  _Inout_ const struct msica_op_seq *seq,
424  _Inout_ struct msica_session *session);
425 
426 #ifdef _MSC_VER
427 #pragma warning(pop)
428 #endif
429 
430 #endif /* ifndef MSICA_OP_H */
msica_op_type
Operation types.
Definition: msica_op.h:48
Operation data.
Definition: msica_op.h:63
struct msica_op * head
Definition: msica_op.h:76
Delete TAP/TUN interface | msica_op_string.
Definition: msica_op.h:53
struct msica_op * msica_op_create_guid_string(_In_ enum msica_op_type type, _In_ int ticks, _In_opt_ struct msica_op *next, _In_ const GUID *value_guid, _In_z_ LPCTSTR value_str)
Allocates and fills a new msica_op_guid_string operation.
Definition: msica_op.c:211
DWORD msica_op_seq_load(_Inout_ struct msica_op_seq *seq, _In_ HANDLE hFile)
Loads the operation sequence from the file.
Definition: msica_op.c:362
Operation data (bool, 0x1)
Definition: msica_op.h:102
Execution session.
Definition: msica_op.h:382
Operation sequence.
Definition: msica_op.h:74
bool rollback_enabled
Continue execution on operation error?
Definition: msica_op.h:386
DWORD msica_op_seq_process(_Inout_ const struct msica_op_seq *seq, _Inout_ struct msica_session *session)
Executes all operations in sequence.
Definition: msica_op.c:963
enum msica_op_type type
Definition: msica_op.h:65
void msica_op_seq_init(_Inout_ struct msica_op_seq *seq)
Initializes operation sequence.
Definition: msica_op.c:54
GUID value
Common operation data.
Definition: msica_op.h:204
#define MSICA_CLEANUP_ACTION_COUNT
Definition: msica_op.h:376
Operation data (guid-string, 0x5)
Definition: msica_op.h:234
Create TAP/TUN interface | msica_op_string.
Definition: msica_op.h:52
Operation data (GUID, 0x4)
Definition: msica_op.h:201
#define _In_
Definition: basic.h:34
struct msica_op * tail
Pointer to the first operation in the sequence.
Definition: msica_op.h:77
struct msica_op * msica_op_create_multistring_va(_In_ enum msica_op_type type, _In_ int ticks, _In_opt_ struct msica_op *next, _In_ va_list arglist)
Allocates and fills a new msica_op_multistring operation.
Definition: msica_op.c:136
#define _Inout_
Definition: basic.h:43
Operation data (multi-string, 0x3)
Definition: msica_op.h:168
static bool msica_op_seq_is_empty(_In_ const struct msica_op_seq *seq)
Is operation sequence empty.
Definition: msica_op.h:305
Operation data (string, 0x2)
Definition: msica_op.h:135
static struct msica_op * msica_op_create_multistring(_In_ enum msica_op_type type, _In_ int ticks, _In_opt_ struct msica_op *next,...)
Allocates and fills a new msica_op_multistring operation.
Definition: msica_op.h:283
DWORD msica_op_seq_save(_In_ const struct msica_op_seq *seq, _In_ HANDLE hFile)
Saves the operation sequence to the file.
Definition: msica_op.c:297
Delete TAP/TUN interface | msica_op_guid.
Definition: msica_op.h:54
MSIHANDLE hInstall
Definition: msica_op.h:384
Enable/disable rollback | msica_op_bool.
Definition: msica_op.h:51
void msica_op_seq_add_tail(_Inout_ struct msica_op_seq *seq, _Inout_ struct msica_op *operation)
Appends operation(s) to the end of the operation sequence.
Definition: msica_op.c:270
Delete file | msica_op_string.
Definition: msica_op.h:56
#define _In_opt_
Definition: basic.h:37
struct msica_op * msica_op_create_bool(_In_ enum msica_op_type type, _In_ int ticks, _In_opt_ struct msica_op *next, _In_ bool value)
Allocates and fills a new msica_op_bool operation.
Definition: msica_op.c:75
#define _In_z_
Definition: basic.h:40
struct msica_op * next
Number of ticks on the progress indicator this operation represents.
Definition: msica_op.h:67
Rename TAP/TUN interface | msica_op_guid_string.
Definition: msica_op.h:55
struct msica_op * msica_op_create_guid(_In_ enum msica_op_type type, _In_ int ticks, _In_opt_ struct msica_op *next, _In_ const GUID *value)
Allocates and fills a new msica_op_guid operation.
Definition: msica_op.c:181
void msica_op_seq_free(_Inout_ struct msica_op_seq *seq)
Frees operation sequence.
Definition: msica_op.c:62
bool continue_on_error
Installer handle.
Definition: msica_op.h:385
struct msica_op * msica_op_create_string(_In_ enum msica_op_type type, _In_ int ticks, _In_opt_ struct msica_op *next, _In_z_ LPCTSTR value)
Allocates and fills a new msica_op_string operation.
Definition: msica_op.c:105
GUID value_guid
Common operation data.
Definition: msica_op.h:237
bool value
Common operation data.
Definition: msica_op.h:105
void openvpnmsica_session_init(_Inout_ struct msica_session *session, _In_ MSIHANDLE hInstall, _In_ bool continue_on_error, _In_ bool rollback_enabled)
Initializes execution session.
Definition: msica_op.c:946
int ticks
Operation type.
Definition: msica_op.h:66
void msica_op_seq_add_head(_Inout_ struct msica_op_seq *seq, _Inout_ struct msica_op *operation)
Inserts operation(s) to the beginning of the operation sequence.
Definition: msica_op.c:244
#define MSICA_MAKE_OP_TYPE(op, data)
Operation type macros.
Definition: msica_op.h:40