OpenVPN
|
#include <windows.h>
#include <msi.h>
#include <stdarg.h>
#include <stdbool.h>
#include <tchar.h>
#include "../tapctl/basic.h"
Go to the source code of this file.
Data Structures | |
struct | msica_op |
Operation data. More... | |
struct | msica_op_seq |
Operation sequence. More... | |
struct | msica_op_bool |
Operation data (bool, 0x1) More... | |
struct | msica_op_string |
Operation data (string, 0x2) More... | |
struct | msica_op_multistring |
Operation data (multi-string, 0x3) More... | |
struct | msica_op_guid |
Operation data (GUID, 0x4) More... | |
struct | msica_op_guid_string |
Operation data (guid-string, 0x5) More... | |
struct | msica_session |
Execution session. More... | |
Macros | |
#define | MSICA_MAKE_OP_TYPE(op, data) (((op)<<4)|((data)&0xf)) |
Operation type macros. More... | |
#define | MSICA_OP_TYPE_OP(type) ((unsigned int)(type)>>4) |
#define | MSICA_OP_TYPE_DATA(type) ((unsigned int)(type)&0xf) |
#define | MSICA_CLEANUP_ACTION_COMMIT 0 |
Execution session constants. More... | |
#define | MSICA_CLEANUP_ACTION_ROLLBACK 1 |
#define | MSICA_CLEANUP_ACTION_COUNT 2 |
Enumerations | |
enum | msica_op_type { msica_op_rollback_enable = MSICA_MAKE_OP_TYPE(0x1, 0x1), msica_op_tap_interface_create = MSICA_MAKE_OP_TYPE(0x2, 0x2), msica_op_tap_interface_delete_by_name = MSICA_MAKE_OP_TYPE(0x3, 0x2), msica_op_tap_interface_delete_by_guid = MSICA_MAKE_OP_TYPE(0x3, 0x4), msica_op_tap_interface_set_name = MSICA_MAKE_OP_TYPE(0x4, 0x5), msica_op_file_delete = MSICA_MAKE_OP_TYPE(0x5, 0x2), msica_op_file_move = MSICA_MAKE_OP_TYPE(0x6, 0x3) } |
Operation types. More... | |
Functions | |
void | msica_op_seq_init (_Inout_ struct msica_op_seq *seq) |
Initializes operation sequence. More... | |
void | msica_op_seq_free (_Inout_ struct msica_op_seq *seq) |
Frees operation sequence. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
static bool | msica_op_seq_is_empty (_In_ const struct msica_op_seq *seq) |
Is operation sequence empty. More... | |
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. More... | |
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. More... | |
DWORD | msica_op_seq_save (_In_ const struct msica_op_seq *seq, _In_ HANDLE hFile) |
Saves the operation sequence to the file. More... | |
DWORD | msica_op_seq_load (_Inout_ struct msica_op_seq *seq, _In_ HANDLE hFile) |
Loads the operation sequence from the file. More... | |
void | openvpnmsica_session_init (_Inout_ struct msica_session *session, _In_ MSIHANDLE hInstall, _In_ bool continue_on_error, _In_ bool rollback_enabled) |
Initializes execution session. More... | |
DWORD | msica_op_seq_process (_Inout_ const struct msica_op_seq *seq, _Inout_ struct msica_session *session) |
Executes all operations in sequence. More... | |
#define MSICA_CLEANUP_ACTION_COMMIT 0 |
Execution session constants.
Definition at line 374 of file msica_op.h.
Referenced by msica_op_file_delete_exec().
#define MSICA_CLEANUP_ACTION_COUNT 2 |
Definition at line 376 of file msica_op.h.
Referenced by openvpnmsica_session_init(), openvpnmsica_setup_sequence_filename(), and ProcessDeferredAction().
#define MSICA_CLEANUP_ACTION_ROLLBACK 1 |
Definition at line 375 of file msica_op.h.
Referenced by msica_op_file_delete_exec(), msica_op_file_move_exec(), msica_op_tap_interface_create_exec(), msica_op_tap_interface_delete(), msica_op_tap_interface_set_name_exec(), and ProcessDeferredAction().
#define MSICA_MAKE_OP_TYPE | ( | op, | |
data | |||
) | (((op)<<4)|((data)&0xf)) |
Operation type macros.
Definition at line 40 of file msica_op.h.
#define MSICA_OP_TYPE_DATA | ( | type | ) | ((unsigned int)(type)&0xf) |
Definition at line 42 of file msica_op.h.
Referenced by msica_op_create_bool(), msica_op_create_guid(), msica_op_create_guid_string(), msica_op_create_multistring_va(), msica_op_create_string(), and msica_op_seq_save().
#define MSICA_OP_TYPE_OP | ( | type | ) | ((unsigned int)(type)>>4) |
Definition at line 41 of file msica_op.h.
enum msica_op_type |
Operation types.
Enumerator | |
---|---|
msica_op_rollback_enable | |
msica_op_tap_interface_create | Enable/disable rollback | msica_op_bool. |
msica_op_tap_interface_delete_by_name | Create TAP/TUN interface | msica_op_string. |
msica_op_tap_interface_delete_by_guid | Delete TAP/TUN interface | msica_op_string. |
msica_op_tap_interface_set_name | Delete TAP/TUN interface | msica_op_guid. |
msica_op_file_delete | Rename TAP/TUN interface | msica_op_guid_string. |
msica_op_file_move | Delete file | msica_op_string. |
Definition at line 48 of file msica_op.h.
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.
type | Operation type |
ticks | Number of ticks on the progress indicator this operation represents |
next | Pointer to the next operation in the sequence |
value | Boolean value |
Definition at line 75 of file msica_op.c.
References msica_op_bool::base, M_FATAL, M_NONFATAL, malloc, msg, MSICA_OP_TYPE_DATA, msica_op::next, msica_op_hdr::ticks, msica_op::ticks, msica_op::type, msica_op_hdr::type, and msica_op_bool::value.
Referenced by EvaluateTAPInterfaces().
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.
type | Operation type |
ticks | Number of ticks on the progress indicator this operation represents |
next | Pointer to the next operation in the sequence |
value | Pointer to GUID value |
Definition at line 181 of file msica_op.c.
References msica_op_guid::base, M_FATAL, M_NONFATAL, malloc, msg, MSICA_OP_TYPE_DATA, msica_op::next, msica_op_hdr::ticks, msica_op::ticks, msica_op::type, msica_op_hdr::type, and msica_op_guid::value.
Referenced by msica_op_tap_interface_create_exec().
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.
type | Operation type |
ticks | Number of ticks on the progress indicator this operation represents |
next | Pointer to the next operation in the sequence |
value_guid | Pointer to GUID value |
value_str | String value |
Definition at line 211 of file msica_op.c.
References msica_op_guid_string::base, M_FATAL, M_NONFATAL, malloc, msg, MSICA_OP_TYPE_DATA, msica_op::next, msica_op_hdr::ticks, msica_op::ticks, msica_op::type, msica_op_hdr::type, msica_op_guid_string::value_guid, and msica_op_guid_string::value_str.
Referenced by msica_op_tap_interface_set_name_exec().
|
static |
Allocates and fills a new msica_op_multistring operation.
Strings must be non-empty. The last string passed as the input parameter must be NULL.
type | Operation type |
ticks | Number of ticks on the progress indicator this operation represents |
next | Pointer to the next operation in the sequence |
Definition at line 283 of file msica_op.h.
References msica_op_create_multistring_va().
Referenced by msica_op_file_delete_exec(), and msica_op_file_move_exec().
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.
type | Operation type |
ticks | Number of ticks on the progress indicator this operation represents |
next | Pointer to the next operation in the sequence |
arglist | List of non-empty strings. The last string must be NULL. |
Definition at line 136 of file msica_op.c.
References msica_op_multistring::base, M_FATAL, M_NONFATAL, malloc, msg, MSICA_OP_TYPE_DATA, msica_op::next, msica_op_hdr::ticks, msica_op::ticks, msica_op::type, msica_op_hdr::type, and msica_op_multistring::value.
Referenced by msica_op_create_multistring().
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.
type | Operation type |
ticks | Number of ticks on the progress indicator this operation represents |
next | Pointer to the next operation in the sequence |
value | String value |
Definition at line 105 of file msica_op.c.
References msica_op_string::base, M_FATAL, M_NONFATAL, malloc, msg, MSICA_OP_TYPE_DATA, msica_op::next, msica_op_hdr::ticks, msica_op::ticks, msica_op::type, msica_op_hdr::type, and msica_op_string::value.
Referenced by EvaluateTAPInterfaces(), msica_op_file_delete_exec(), msica_op_tap_interface_delete(), and ProcessDeferredAction().
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.
seq | Pointer to operation sequence |
operation | Pointer to the operation to insert. All operations in the list are added until the list is terminated with msica_op.next field set to NULL. Operations must be allocated using malloc(). |
Definition at line 244 of file msica_op.c.
References msica_op::next.
Referenced by msica_op_file_delete_exec(), msica_op_file_move_exec(), msica_op_seq_is_empty(), msica_op_tap_interface_create_exec(), msica_op_tap_interface_delete(), and msica_op_tap_interface_set_name_exec().
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.
seq | Pointer to operation sequence |
operation | Pointer to the operation to append. All operations in the list are added until the list is terminated with msica_op.next field set to NULL. Operations must be allocated using malloc(). |
Definition at line 270 of file msica_op.c.
References msica_op::next.
Referenced by EvaluateTAPInterfaces(), msica_op_file_delete_exec(), msica_op_seq_is_empty(), msica_op_seq_load(), and ProcessDeferredAction().
void msica_op_seq_free | ( | _Inout_ struct msica_op_seq * | seq | ) |
Frees operation sequence.
seq | Pointer to operation sequence |
Definition at line 62 of file msica_op.c.
References free, and msica_op::next.
Referenced by EvaluateTAPInterfaces(), and ProcessDeferredAction().
void msica_op_seq_init | ( | _Inout_ struct msica_op_seq * | seq | ) |
Initializes operation sequence.
seq | Pointer to uninitialized operation sequence |
Definition at line 54 of file msica_op.c.
Referenced by EvaluateTAPInterfaces(), and openvpnmsica_session_init().
|
inlinestatic |
Is operation sequence empty.
seq | Pointer to operation sequence |
Definition at line 305 of file msica_op.h.
References _In_, _Inout_, msica_op_seq_add_head(), msica_op_seq_add_tail(), msica_op_seq_load(), and msica_op_seq_save().
DWORD msica_op_seq_load | ( | _Inout_ struct msica_op_seq * | seq, |
_In_ HANDLE | hFile | ||
) |
Loads the operation sequence from the file.
seq | Pointer to uninitialized or empty operation sequence |
hFile | Handle of the file opened with GENERIC_READ access |
Definition at line 362 of file msica_op.c.
References free, M_ERRNO, M_FATAL, M_NONFATAL, malloc, msg, msica_op_seq_add_tail(), msica_op::next, msica_op_hdr::size_data, msica_op_hdr::ticks, msica_op::ticks, msica_op::type, and msica_op_hdr::type.
Referenced by msica_op_seq_is_empty(), and ProcessDeferredAction().
DWORD msica_op_seq_process | ( | _Inout_ const struct msica_op_seq * | seq, |
_Inout_ struct msica_session * | session | ||
) |
Executes all operations in sequence.
seq | Pointer to operation sequence |
session | MSI session. The execution updates its members, most notably rollback_enabled and fills cleanup sequences with commit/rollback operations. |
Definition at line 963 of file msica_op.c.
References M_NONFATAL, msg, msica_op_file_delete, msica_op_file_delete_exec(), msica_op_file_move, msica_op_file_move_exec(), msica_op_rollback_enable, msica_op_tap_interface_create, msica_op_tap_interface_create_exec(), msica_op_tap_interface_delete_by_guid, msica_op_tap_interface_delete_by_guid_exec(), msica_op_tap_interface_delete_by_name, msica_op_tap_interface_delete_by_name_exec(), msica_op_tap_interface_set_name, msica_op_tap_interface_set_name_exec(), and msica_op::next.
Referenced by ProcessDeferredAction().
DWORD msica_op_seq_save | ( | _In_ const struct msica_op_seq * | seq, |
_In_ HANDLE | hFile | ||
) |
Saves the operation sequence to the file.
seq | Pointer to operation sequence |
hFile | Handle of the file opened with GENERIC_WRITE access |
Definition at line 297 of file msica_op.c.
References M_ERRNO, M_NONFATAL, msg, MSICA_OP_TYPE_DATA, msica_op::next, msica_op_hdr::size_data, msica_op_hdr::ticks, msica_op_hdr::type, msica_op_string::value, and msica_op_multistring::value.
Referenced by EvaluateTAPInterfaces(), msica_op_seq_is_empty(), and ProcessDeferredAction().
void openvpnmsica_session_init | ( | _Inout_ struct msica_session * | session, |
_In_ MSIHANDLE | hInstall, | ||
_In_ bool | continue_on_error, | ||
_In_ bool | rollback_enabled | ||
) |
Initializes execution session.
session | Pointer to an uninitialized execution session |
hInstall | Installer handle |
continue_on_error | Continue execution on operation error? |
rollback_enabled | Is rollback enabled? |
Definition at line 946 of file msica_op.c.
References MSICA_CLEANUP_ACTION_COUNT, and msica_op_seq_init().
Referenced by ProcessDeferredAction().