OpenVPN
Data Structures | Functions
msica_op.c File Reference
#include "msica_op.h"
#include "../tapctl/error.h"
#include "../tapctl/tap.h"
#include <windows.h>
#include <malloc.h>
#include <msiquery.h>
#include <objbase.h>
Include dependency graph for msica_op.c:

Go to the source code of this file.

Data Structures

struct  msica_op_hdr
 Operation data persist header. 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_opmsica_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_opmsica_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_opmsica_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_opmsica_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_opmsica_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...
 
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...
 
static DWORD msica_op_tap_interface_create_exec (_Inout_ const struct msica_op_string *op, _Inout_ struct msica_session *session)
 
static DWORD msica_op_tap_interface_delete (_In_ struct tap_interface_node *pInterfaceList, _In_ struct tap_interface_node *pInterface, _Inout_ struct msica_session *session)
 
static DWORD msica_op_tap_interface_delete_by_name_exec (_Inout_ const struct msica_op_string *op, _Inout_ struct msica_session *session)
 
static DWORD msica_op_tap_interface_delete_by_guid_exec (_Inout_ const struct msica_op_guid *op, _Inout_ struct msica_session *session)
 
static DWORD msica_op_tap_interface_set_name_exec (_Inout_ const struct msica_op_guid_string *op, _Inout_ struct msica_session *session)
 
static DWORD msica_op_file_delete_exec (_Inout_ const struct msica_op_string *op, _Inout_ struct msica_session *session)
 
static DWORD msica_op_file_move_exec (_Inout_ const struct msica_op_multistring *op, _Inout_ struct msica_session *session)
 
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...
 

Function Documentation

◆ msica_op_create_bool()

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.

Parameters
typeOperation type
ticksNumber of ticks on the progress indicator this operation represents
nextPointer to the next operation in the sequence
valueBoolean value
Returns
A new msica_op_bool operation. Must be added to a sequence list or released using free() after use. The function returns a pointer to msica_op to reduce type-casting in code.

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().

◆ msica_op_create_guid()

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.

Parameters
typeOperation type
ticksNumber of ticks on the progress indicator this operation represents
nextPointer to the next operation in the sequence
valuePointer to GUID value
Returns
A new msica_op_guid operation. Must be added to a sequence list or released using free() after use. The function returns a pointer to msica_op to reduce type-casting in code.

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().

◆ msica_op_create_guid_string()

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.

Parameters
typeOperation type
ticksNumber of ticks on the progress indicator this operation represents
nextPointer to the next operation in the sequence
value_guidPointer to GUID value
value_strString value
Returns
A new msica_op_guid_string operation. Must be added to a sequence list or released using free() after use. The function returns a pointer to msica_op to reduce type-casting in code.

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().

◆ msica_op_create_multistring_va()

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.

Parameters
typeOperation type
ticksNumber of ticks on the progress indicator this operation represents
nextPointer to the next operation in the sequence
arglistList of non-empty strings. The last string must be NULL.
Returns
A new msica_op_string operation. Must be added to a sequence list or released using free() after use. The function returns a pointer to msica_op to reduce type-casting in code.

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().

◆ msica_op_create_string()

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.

Parameters
typeOperation type
ticksNumber of ticks on the progress indicator this operation represents
nextPointer to the next operation in the sequence
valueString value
Returns
A new msica_op_string operation. Must be added to a sequence list or released using free() after use. The function returns a pointer to msica_op to reduce type-casting in code.

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().

◆ msica_op_file_delete_exec()

static DWORD msica_op_file_delete_exec ( _Inout_ const struct msica_op_string op,
_Inout_ struct msica_session session 
)
static

◆ msica_op_file_move_exec()

static DWORD msica_op_file_move_exec ( _Inout_ const struct msica_op_multistring op,
_Inout_ struct msica_session session 
)
static

◆ msica_op_seq_add_head()

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.

Parameters
seqPointer to operation sequence
operationPointer 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().

◆ msica_op_seq_add_tail()

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.

Parameters
seqPointer to operation sequence
operationPointer 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().

◆ msica_op_seq_free()

void msica_op_seq_free ( _Inout_ struct msica_op_seq seq)

Frees operation sequence.

Parameters
seqPointer to operation sequence

Definition at line 62 of file msica_op.c.

References free, and msica_op::next.

Referenced by EvaluateTAPInterfaces(), and ProcessDeferredAction().

◆ msica_op_seq_init()

void msica_op_seq_init ( _Inout_ struct msica_op_seq seq)

Initializes operation sequence.

Parameters
seqPointer to uninitialized operation sequence

Definition at line 54 of file msica_op.c.

Referenced by EvaluateTAPInterfaces(), and openvpnmsica_session_init().

◆ msica_op_seq_load()

DWORD msica_op_seq_load ( _Inout_ struct msica_op_seq seq,
_In_ HANDLE  hFile 
)

Loads the operation sequence from the file.

Parameters
seqPointer to uninitialized or empty operation sequence
hFileHandle of the file opened with GENERIC_READ access
Returns
ERROR_SUCCESS on success; An error code otherwise

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().

◆ msica_op_seq_process()

DWORD msica_op_seq_process ( _Inout_ const struct msica_op_seq seq,
_Inout_ struct msica_session session 
)

Executes all operations in sequence.

Parameters
seqPointer to operation sequence
sessionMSI session. The execution updates its members, most notably rollback_enabled and fills cleanup sequences with commit/rollback operations.
Returns
ERROR_SUCCESS on success; An error code otherwise

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().

◆ msica_op_seq_save()

DWORD msica_op_seq_save ( _In_ const struct msica_op_seq seq,
_In_ HANDLE  hFile 
)

Saves the operation sequence to the file.

Parameters
seqPointer to operation sequence
hFileHandle of the file opened with GENERIC_WRITE access
Returns
ERROR_SUCCESS on success; An error code otherwise

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().

◆ msica_op_tap_interface_create_exec()

static DWORD msica_op_tap_interface_create_exec ( _Inout_ const struct msica_op_string op,
_Inout_ struct msica_session session 
)
static

◆ msica_op_tap_interface_delete()

static DWORD msica_op_tap_interface_delete ( _In_ struct tap_interface_node pInterfaceList,
_In_ struct tap_interface_node pInterface,
_Inout_ struct msica_session session 
)
static

◆ msica_op_tap_interface_delete_by_guid_exec()

static DWORD msica_op_tap_interface_delete_by_guid_exec ( _Inout_ const struct msica_op_guid op,
_Inout_ struct msica_session session 
)
static

◆ msica_op_tap_interface_delete_by_name_exec()

static DWORD msica_op_tap_interface_delete_by_name_exec ( _Inout_ const struct msica_op_string op,
_Inout_ struct msica_session session 
)
static

◆ msica_op_tap_interface_set_name_exec()

static DWORD msica_op_tap_interface_set_name_exec ( _Inout_ const struct msica_op_guid_string op,
_Inout_ struct msica_session session 
)
static

◆ openvpnmsica_session_init()

void openvpnmsica_session_init ( _Inout_ struct msica_session session,
_In_ MSIHANDLE  hInstall,
_In_ bool  continue_on_error,
_In_ bool  rollback_enabled 
)

Initializes execution session.

Parameters
sessionPointer to an uninitialized execution session
hInstallInstaller handle
continue_on_errorContinue execution on operation error?
rollback_enabledIs rollback enabled?

Definition at line 946 of file msica_op.c.

References MSICA_CLEANUP_ACTION_COUNT, and msica_op_seq_init().

Referenced by ProcessDeferredAction().