29#include "../tapctl/basic.h"
30#include "../tapctl/error.h"
31#include "../tapctl/tap.h"
49#pragma comment(lib, "advapi32.lib")
50#pragma comment(lib, "iphlpapi.lib")
51#pragma comment(lib, "shell32.lib")
52#pragma comment(lib, "shlwapi.lib")
53#pragma comment(lib, "version.lib")
62#define MSICA_ADAPTER_TICK_SIZE (16 * 1024)
64#define FILE_NEED_REBOOT L".ovpn_need_reboot"
66#define OPENVPN_CONNECT_ADAPTER_SUBSTR L"OpenVPN Connect"
84 uiResult = MsiSetProperty(hInstall, szProperty, szSequence);
86 if (uiResult != ERROR_SUCCESS)
90 SetLastError(uiResult);
108_debug_popup(
_In_z_ LPCSTR szFunctionName)
110 WCHAR szTitle[0x100], szMessage[0x100 + MAX_PATH], szProcessPath[MAX_PATH];
114 swprintf_s(szTitle, _countof(szTitle), L
"%hs v%ls", szFunctionName,
_L(
PACKAGE_VERSION));
117 GetModuleFileName(NULL, szProcessPath, _countof(szProcessPath));
118 LPCWSTR szProcessName = wcsrchr(szProcessPath, L
'\\');
119 szProcessName = szProcessName ? szProcessName + 1 : szProcessPath;
123 szMessage, _countof(szMessage),
124 L
"The %ls process (PID: %u) has started to execute the %hs"
125 L
" custom action.\r\n"
127 L
"If you would like to debug the custom action, attach a debugger to this process and set breakpoints before dismissing this dialog.\r\n"
129 L
"If you are not debugging this custom action, you can safely ignore this message.",
130 szProcessName, GetCurrentProcessId(), szFunctionName);
132 MessageBox(NULL, szMessage, szTitle, MB_OK);
135#define debug_popup(f) _debug_popup(f)
137#define debug_popup(f)
142 _In_z_ LPCWSTR szAdaptersPropertyName,
_In_z_ LPCWSTR szActiveAdaptersPropertyName)
149 if (uiResult != ERROR_SUCCESS)
153 else if (pAdapterList == NULL)
161 PIP_ADAPTER_ADDRESSES pAdapterAdresses = NULL;
162 ULONG ulAdapterAdressesSize = 16 * 1024;
163 for (
size_t iteration = 0; iteration < 2; iteration++)
165 pAdapterAdresses = (PIP_ADAPTER_ADDRESSES)malloc(ulAdapterAdressesSize);
166 if (pAdapterAdresses == NULL)
168 msg(
M_NONFATAL,
"%s: malloc(%lu) failed", __FUNCTION__, ulAdapterAdressesSize);
169 uiResult = ERROR_OUTOFMEMORY;
170 goto cleanup_pAdapterList;
173 ULONG ulResult = GetAdaptersAddresses(
175 GAA_FLAG_SKIP_UNICAST | GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST
176 | GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_SKIP_FRIENDLY_NAME
177 | GAA_FLAG_INCLUDE_ALL_INTERFACES,
178 NULL, pAdapterAdresses, &ulAdapterAdressesSize);
180 if (ulResult == ERROR_SUCCESS)
185 free(pAdapterAdresses);
186 if (ulResult != ERROR_BUFFER_OVERFLOW)
190 SetLastError(ulResult);
193 goto cleanup_pAdapterList;
198 size_t adapter_count = 0;
207 (LPWSTR)malloc(adapter_count * (38 + 1 ) *
sizeof(WCHAR)),
208 szAdaptersTail = szAdapters;
209 if (szAdapters == NULL)
211 msg(
M_FATAL,
"%s: malloc(%zu) failed", __FUNCTION__,
212 adapter_count * (38 + 1 ) *
sizeof(WCHAR));
213 uiResult = ERROR_OUTOFMEMORY;
214 goto cleanup_pAdapterAdresses;
219 (LPWSTR)malloc(adapter_count * (38 + 1 ) *
sizeof(WCHAR)),
220 szAdaptersActiveTail = szAdaptersActive;
221 if (szAdaptersActive == NULL)
223 msg(
M_FATAL,
"%s: malloc(%zu) failed", __FUNCTION__,
224 adapter_count * (38 + 1 ) *
sizeof(WCHAR));
225 uiResult = ERROR_OUTOFMEMORY;
226 goto cleanup_szAdapters;
235 msg(
M_WARN,
"%s: skip OpenVPN Connect adapter '%ls'", __FUNCTION__, pAdapter->szName);
240 LPOLESTR szAdapterId = NULL;
241 StringFromIID((REFIID)&pAdapter->guid, &szAdapterId);
244 if (szAdapters < szAdaptersTail)
246 *(szAdaptersTail++) = L
';';
248 memcpy(szAdaptersTail, szAdapterId, 38 *
sizeof(WCHAR));
249 szAdaptersTail += 38;
252 for (PIP_ADAPTER_ADDRESSES p = pAdapterAdresses; p; p = p->Next)
254 OLECHAR szId[38 + 1 ];
256 if (MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, p->AdapterName, -1, szId,
259 && SUCCEEDED(IIDFromString(szId, &
guid))
260 && memcmp(&
guid, &pAdapter->guid,
sizeof(GUID)) == 0)
262 if (p->OperStatus == IfOperStatusUp)
265 if (szAdaptersActive < szAdaptersActiveTail)
267 *(szAdaptersActiveTail++) = L
';';
269 memcpy(szAdaptersActiveTail, szAdapterId, 38 *
sizeof(WCHAR));
270 szAdaptersActiveTail += 38;
275 CoTaskMemFree(szAdapterId);
277 szAdaptersTail[0] = 0;
278 szAdaptersActiveTail[0] = 0;
281 uiResult = MsiSetProperty(hInstall, szAdaptersPropertyName, szAdapters);
282 if (uiResult != ERROR_SUCCESS)
284 SetLastError(uiResult);
287 szAdaptersPropertyName);
288 goto cleanup_szAdaptersActive;
290 uiResult = MsiSetProperty(hInstall, szActiveAdaptersPropertyName, szAdaptersActive);
291 if (uiResult != ERROR_SUCCESS)
295 SetLastError(uiResult);
297 szActiveAdaptersPropertyName);
298 goto cleanup_szAdaptersActive;
301cleanup_szAdaptersActive:
302 free(szAdaptersActive);
305cleanup_pAdapterAdresses:
306 free(pAdapterAdresses);
316#pragma comment(linker, DLLEXP_EXPORT)
321 BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));
326 L
"TAPWINDOWS6ADAPTERS", L
"ACTIVETAPWINDOWS6ADAPTERS");
330 L
"OVPNDCOADAPTERS", L
"ACTIVEOVPNDCOADAPTERS");
332 if (bIsCoInitialized)
336 return ERROR_SUCCESS;
344#pragma comment(linker, DLLEXP_EXPORT)
346 UNREFERENCED_PARAMETER(hInstall);
352 HWND hWnd = FindWindow(L
"OpenVPN-GUI", NULL);
357 SendMessage(hWnd, WM_CLOSE, 0, 0);
361 return ERROR_SUCCESS;
369#pragma comment(linker, DLLEXP_EXPORT)
375 BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));
380 MSIHANDLE hRecord = MsiCreateRecord(1);
383 uiResult = ERROR_INVALID_HANDLE;
385 goto cleanup_CoInitialize;
387 uiResult = MsiRecordSetString(hRecord, 0, L
"\"[#bin.openvpn_gui.exe]\"");
388 if (uiResult != ERROR_SUCCESS)
392 SetLastError(uiResult);
394 goto cleanup_MsiCreateRecord;
398 WCHAR szStackBuf[MAX_PATH];
399 DWORD dwPathSize = _countof(szStackBuf);
400 LPWSTR szPath = szStackBuf;
401 uiResult = MsiFormatRecord(hInstall, hRecord, szPath, &dwPathSize);
402 if (uiResult == ERROR_MORE_DATA)
405 szPath = (LPWSTR)malloc((++dwPathSize) *
sizeof(WCHAR));
408 msg(
M_FATAL,
"%s: malloc(%zu) failed", __FUNCTION__, dwPathSize *
sizeof(WCHAR));
409 uiResult = ERROR_OUTOFMEMORY;
410 goto cleanup_MsiCreateRecord;
413 uiResult = MsiFormatRecord(hInstall, hRecord, szPath, &dwPathSize);
415 if (uiResult != ERROR_SUCCESS)
419 SetLastError(uiResult);
421 goto cleanup_malloc_szPath;
425 SHELLEXECUTEINFO sei = { .cbSize =
sizeof(SHELLEXECUTEINFO),
427 .fMask = SEE_MASK_FLAG_NO_UI,
429 .nShow = SW_SHOWNORMAL };
430 if (!ShellExecuteEx(&sei))
432 uiResult = GetLastError();
434 goto cleanup_malloc_szPath;
437 uiResult = ERROR_SUCCESS;
439cleanup_malloc_szPath:
440 if (szPath != szStackBuf)
444cleanup_MsiCreateRecord:
445 MsiCloseHandle(hRecord);
447 if (bIsCoInitialized)
483 if (dwResult != ERROR_SUCCESS)
490 pAdapterOther = pAdapterOther->
pNext)
492 if (pAdapterOther == NULL)
495 WCHAR szArgument[10 + MAX_PATH + 1
499 swprintf_s(szArgument, _countof(szArgument), L
"create=\"%.*s|%.*s\"", MAX_PATH,
500 szDisplayName, MAX_PATH, szHardwareId);
506 swprintf_s(szArgument, _countof(szArgument), L
"deleteN=\"%.*s\"", MAX_PATH,
514 else if (_wcsicmp(szDisplayName, pAdapterOther->szName) == 0)
517 for (LPCWSTR hwid = pAdapterOther->szzHardwareIDs;; hwid += wcslen(hwid) + 1)
522 msg(
M_NONFATAL,
"%s: Adapter with name \"%ls\" already exists", __FUNCTION__,
523 pAdapterOther->szName);
524 dwResult = ERROR_ALREADY_EXISTS;
525 goto cleanup_pAdapterList;
527 else if (_wcsicmp(hwid, szHardwareId) == 0)
581 if (dwResult != ERROR_SUCCESS)
588 pAdapter = pAdapter->
pNext)
590 if (_wcsicmp(szDisplayName, pAdapter->szName) == 0)
595 if (seqCommit && seqRollback)
598 swprintf_s(szArgument, _countof(szArgument), L
"disable=" _L(
PRIXGUID),
603 swprintf_s(szArgument, _countof(szArgument), L
"enable=" _L(
PRIXGUID),
608 swprintf_s(szArgument, _countof(szArgument), L
"delete=" _L(
PRIXGUID),
615 swprintf_s(szArgument, _countof(szArgument), L
"delete=" _L(
PRIXGUID),
635#pragma comment(linker, DLLEXP_EXPORT)
641 BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));
645 struct msica_arg_seq seqInstall, seqInstallCommit, seqInstallRollback, seqUninstall,
646 seqUninstallCommit, seqUninstallRollback;
655 bool bRollbackEnabled =
656 MsiEvaluateCondition(hInstall, L
"RollbackDisabled") != MSICONDITION_TRUE;
659 MSIHANDLE hDatabase = MsiGetActiveDatabase(hInstall);
662 msg(
M_NONFATAL,
"%s: MsiGetActiveDatabase failed", __FUNCTION__);
663 uiResult = ERROR_INVALID_HANDLE;
664 goto cleanup_exec_seq;
668 switch (MsiDatabaseIsTablePersistent(hDatabase, L
"TUNTAPAdapter"))
670 case MSICONDITION_FALSE:
671 case MSICONDITION_TRUE:
675 uiResult = ERROR_SUCCESS;
676 goto cleanup_hDatabase;
680 MSIHANDLE hViewST = 0;
682 L
"SELECT `Adapter`,`DisplayName`,`Condition`,`Component_`,`HardwareId` FROM `TUNTAPAdapter`";
683 uiResult = MsiDatabaseOpenView(hDatabase, szQuery, &hViewST);
684 if (uiResult != ERROR_SUCCESS)
688 SetLastError(uiResult);
690 goto cleanup_hDatabase;
694 uiResult = MsiViewExecute(hViewST, 0);
695 if (uiResult != ERROR_SUCCESS)
699 SetLastError(uiResult);
701 goto cleanup_hViewST;
705 MSIHANDLE hRecordProg = MsiCreateRecord(2);
708 uiResult = ERROR_INVALID_HANDLE;
710 goto cleanup_hViewST_close;
716 MSIHANDLE hRecord = 0;
717 uiResult = MsiViewFetch(hViewST, &hRecord);
718 if (uiResult == ERROR_NO_MORE_ITEMS)
722 else if (uiResult != ERROR_SUCCESS)
726 SetLastError(uiResult);
728 goto cleanup_hRecordProg;
731 INSTALLSTATE iInstalled, iAction;
734 LPWSTR szValue = NULL;
736 if (uiResult != ERROR_SUCCESS)
738 goto cleanup_hRecord;
742 uiResult = MsiGetComponentState(hInstall, szValue, &iInstalled, &iAction);
743 if (uiResult != ERROR_SUCCESS)
748 SetLastError(uiResult);
752 goto cleanup_hRecord;
758 LPWSTR szDisplayName = NULL;
760 if (uiResult != ERROR_SUCCESS)
762 goto cleanup_hRecord;
767 LPWSTR szDisplayNameEx = wcschr(szDisplayName, L
'|');
768 szDisplayNameEx = szDisplayNameEx != NULL ? szDisplayNameEx + 1 : szDisplayName;
771 WCHAR szzHardwareIDs[0x100] = { 0 };
773 LPWSTR szHwId = NULL;
775 if (uiResult != ERROR_SUCCESS)
777 goto cleanup_szDisplayName;
779 memcpy_s(szzHardwareIDs,
780 sizeof(szzHardwareIDs)
781 - 2 *
sizeof(WCHAR) ,
782 szHwId, wcslen(szHwId) *
sizeof(WCHAR));
786 if (iAction > INSTALLSTATE_BROKEN)
790 if (iAction >= INSTALLSTATE_LOCAL)
793 LPWSTR szValue = NULL;
795 if (uiResult != ERROR_SUCCESS)
797 goto cleanup_szDisplayName;
799#if defined(__GNUC__) || defined(__clang__)
804#pragma GCC diagnostic push
805#pragma GCC diagnostic ignored "-Wswitch"
807 switch (MsiEvaluateCondition(hInstall, szValue))
809 case MSICONDITION_FALSE:
811 goto cleanup_szDisplayName;
813 case MSICONDITION_ERROR:
814 uiResult = ERROR_INVALID_FIELD;
816 __FUNCTION__, szValue);
818 goto cleanup_szDisplayName;
820#if defined(__GNUC__) || defined(__clang__)
821#pragma GCC diagnostic pop
827 bRollbackEnabled ? &seqInstallRollback : NULL,
828 szDisplayNameEx, szzHardwareIDs, &iTicks)
831 uiResult = ERROR_INSTALL_FAILED;
832 goto cleanup_szDisplayName;
844 bRollbackEnabled ? &seqUninstallCommit : NULL,
845 bRollbackEnabled ? &seqUninstallRollback : NULL,
846 szDisplayNameEx, szzHardwareIDs, &iTicks);
851 MsiRecordSetInteger(hRecordProg, 1, 3 );
852 MsiRecordSetInteger(hRecordProg, 2, iTicks);
853 if (MsiProcessMessage(hInstall, INSTALLMESSAGE_PROGRESS, hRecordProg) == IDCANCEL)
855 uiResult = ERROR_INSTALL_USEREXIT;
856 goto cleanup_szDisplayName;
860cleanup_szDisplayName:
863 MsiCloseHandle(hRecord);
864 if (uiResult != ERROR_SUCCESS)
866 goto cleanup_hRecordProg;
871 WCHAR tmpDir[MAX_PATH];
872 GetTempPath(MAX_PATH, tmpDir);
874 WCHAR str[MAX_PATH + 7];
875 swprintf_s(str, _countof(str), L
"tmpdir=%ls", tmpDir);
884 if ((uiResult =
setup_sequence(hInstall, L
"InstallTUNTAPAdapters", &seqInstall))
886 || (uiResult =
setup_sequence(hInstall, L
"InstallTUNTAPAdaptersCommit", &seqInstallCommit))
889 setup_sequence(hInstall, L
"InstallTUNTAPAdaptersRollback", &seqInstallRollback))
891 || (uiResult =
setup_sequence(hInstall, L
"UninstallTUNTAPAdapters", &seqUninstall))
894 setup_sequence(hInstall, L
"UninstallTUNTAPAdaptersCommit", &seqUninstallCommit))
897 setup_sequence(hInstall, L
"UninstallTUNTAPAdaptersRollback", &seqUninstallRollback))
900 goto cleanup_hRecordProg;
903 uiResult = ERROR_SUCCESS;
906 MsiCloseHandle(hRecordProg);
907cleanup_hViewST_close:
908 MsiViewClose(hViewST);
910 MsiCloseHandle(hViewST);
912 MsiCloseHandle(hDatabase);
920 if (bIsCoInitialized)
960 WCHAR path[MAX_PATH];
963 msg(
M_WARN,
"%s: Reboot required, create reboot indication file \"%ls\"", __FUNCTION__, path);
966 CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
967 if (file == INVALID_HANDLE_VALUE)
981#pragma comment(linker, DLLEXP_EXPORT)
987 BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));
988 WCHAR tmpDir[MAX_PATH] = { 0 };
993 MsiGetMode(hInstall, MSIRUNMODE_COMMIT) || MsiGetMode(hInstall, MSIRUNMODE_ROLLBACK);
997 LPWSTR szSequence = NULL;
998 uiResult =
msi_get_string(hInstall, L
"CustomActionData", &szSequence);
999 if (uiResult != ERROR_SUCCESS)
1001 goto cleanup_CoInitialize;
1004 LPWSTR *szArg = CommandLineToArgvW(szSequence, &nArgs);
1007 uiResult = GetLastError();
1010 goto cleanup_szSequence;
1014 MSIHANDLE hRecordProg = MsiCreateRecord(3);
1015 MsiRecordSetInteger(hRecordProg, 1, 1);
1016 MsiRecordSetInteger(hRecordProg, 2, 1);
1017 MsiRecordSetInteger(hRecordProg, 3, 0);
1018 MsiProcessMessage(hInstall, INSTALLMESSAGE_PROGRESS, hRecordProg);
1021 MsiRecordSetInteger(hRecordProg, 1, 2);
1022 MsiRecordSetInteger(hRecordProg, 3, 0);
1024 BOOL bRebootRequired = FALSE;
1026 for (
int i = 1 ; i < nArgs; ++i)
1028 DWORD dwResult = ERROR_SUCCESS;
1030 if (wcsncmp(szArg[i], L
"create=", 7) == 0)
1033 LPWSTR szName = szArg[i] + 7;
1034 LPWSTR szHardwareId = wcschr(szName, L
'|');
1035 if (szHardwareId == NULL)
1037 goto invalid_argument;
1039 szHardwareId[0] = 0;
1044 MSIHANDLE hRecord = MsiCreateRecord(4);
1045 MsiRecordSetString(hRecord, 1, L
"Creating adapter");
1046 MsiRecordSetString(hRecord, 2, szName);
1047 MsiRecordSetString(hRecord, 3, szHardwareId);
1048 int iResult = MsiProcessMessage(hInstall, INSTALLMESSAGE_ACTIONDATA, hRecord);
1049 MsiCloseHandle(hRecord);
1050 if (iResult == IDCANCEL)
1052 uiResult = ERROR_INSTALL_USEREXIT;
1058 dwResult =
tap_create_adapter(NULL, NULL, szHardwareId, &bRebootRequired, &guidAdapter);
1059 if (dwResult == ERROR_SUCCESS)
1066 else if (wcsncmp(szArg[i], L
"deleteN=", 8) == 0)
1069 LPCWSTR szName = szArg[i] + 8;
1073 MSIHANDLE hRecord = MsiCreateRecord(3);
1074 MsiRecordSetString(hRecord, 1, L
"Deleting adapter");
1075 MsiRecordSetString(hRecord, 2, szName);
1076 int iResult = MsiProcessMessage(hInstall, INSTALLMESSAGE_ACTIONDATA, hRecord);
1077 MsiCloseHandle(hRecord);
1078 if (iResult == IDCANCEL)
1080 uiResult = ERROR_INSTALL_USEREXIT;
1088 if (dwResult == ERROR_SUCCESS)
1092 pAdapter = pAdapter->
pNext)
1094 if (_wcsicmp(
szName, pAdapter->szName) == 0)
1105 else if (wcsncmp(szArg[i], L
"delete=", 7) == 0)
1111 goto invalid_argument;
1115 else if (wcsncmp(szArg[i], L
"enable=", 7) == 0)
1121 goto invalid_argument;
1125 else if (wcsncmp(szArg[i], L
"disable=", 8) == 0)
1131 goto invalid_argument;
1135 else if (wcsncmp(szArg[i], L
"tmpdir=", 7) == 0)
1137 wcscpy_s(tmpDir, _countof(tmpDir), szArg[i] + 7);
1141 goto invalid_argument;
1144 if (dwResult != ERROR_SUCCESS && !bIsCleanup )
1146 uiResult = ERROR_INSTALL_FAILURE;
1152 if (MsiProcessMessage(hInstall, INSTALLMESSAGE_PROGRESS, hRecordProg) == IDCANCEL)
1154 dwResult = ERROR_INSTALL_USEREXIT;
1161 msg(
M_NONFATAL,
"%s: Ignoring invalid argument: %ls", __FUNCTION__, szArg[i]);
1165 if (bRebootRequired && wcslen(tmpDir) > 0)
1169 MsiCloseHandle(hRecordProg);
1173cleanup_CoInitialize:
1174 if (bIsCoInitialized)
1185#pragma comment(linker, DLLEXP_EXPORT)
1190 BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));
1195 WCHAR tempPath[MAX_PATH];
1196 GetTempPathW(MAX_PATH, tempPath);
1199 WCHAR path[MAX_PATH];
1201 WIN32_FIND_DATA data = { 0 };
1202 HANDLE searchHandle = FindFirstFileW(path, &data);
1203 if (searchHandle != INVALID_HANDLE_VALUE)
1205 msg(
M_WARN,
"%s: Reboot file exists, schedule reboot", __FUNCTION__);
1207 FindClose(searchHandle);
1210 MsiSetMode(hInstall, MSIRUNMODE_REBOOTATEND, TRUE);
1213 if (bIsCoInitialized)
1217 return ERROR_SUCCESS;
#define TAP_WIN_COMPONENT_ID
void msica_arg_seq_free(_Inout_ struct msica_arg_seq *seq)
Frees argument sequence.
void msica_arg_seq_init(_Inout_ struct msica_arg_seq *seq)
Initializes argument sequence.
void msica_arg_seq_add_tail(_Inout_ struct msica_arg_seq *seq, _Inout_ LPCWSTR argument)
Appends argument to the end of the argument sequence.
void msica_arg_seq_add_head(_Inout_ struct msica_arg_seq *seq, _In_z_ LPCWSTR argument)
Inserts argument to the beginning of the argument sequence.
LPWSTR msica_arg_seq_join(_In_ const struct msica_arg_seq *seq)
Join arguments of the argument sequence into a space delimited string.
UINT msi_format_field(_In_ MSIHANDLE hInstall, _In_ MSIHANDLE hRecord, _In_ unsigned int iField, _Out_ LPWSTR *pszValue)
Formats MSI record field.
UINT msi_get_record_string(_In_ MSIHANDLE hRecord, _In_ unsigned int iField, _Out_ LPWSTR *pszValue)
Gets MSI record string value.
UINT msi_get_string(_In_ MSIHANDLE hInstall, _In_z_ LPCWSTR szName, _Out_ LPWSTR *pszValue)
Gets MSI property value.
UINT __stdcall CheckAndScheduleReboot(_In_ MSIHANDLE hInstall)
Schedule reboot after installation if reboot indication file is found in user's temp directory.
#define OPENVPN_CONNECT_ADAPTER_SUBSTR
UINT __stdcall FindSystemInfo(_In_ MSIHANDLE hInstall)
Determines Windows information:
UINT __stdcall ProcessDeferredAction(_In_ MSIHANDLE hInstall)
Perform scheduled deferred action.
#define MSICA_ADAPTER_TICK_SIZE
Local constants.
UINT __stdcall CloseOpenVPNGUI(_In_ MSIHANDLE hInstall)
Find OpenVPN GUI window and send it a WM_CLOSE message.
static DWORD schedule_adapter_delete(_Inout_ struct msica_arg_seq *seq, _Inout_opt_ struct msica_arg_seq *seqCommit, _Inout_opt_ struct msica_arg_seq *seqRollback, _In_z_ LPCWSTR szDisplayName, _In_z_ LPCWSTR szzHardwareIDs, _Inout_ int *iTicks)
Schedules adapter deletion.
UINT __stdcall StartOpenVPNGUI(_In_ MSIHANDLE hInstall)
Launches OpenVPN GUI.
static void find_adapters(_In_ MSIHANDLE hInstall, _In_z_ LPCWSTR szzHardwareIDs, _In_z_ LPCWSTR szAdaptersPropertyName, _In_z_ LPCWSTR szActiveAdaptersPropertyName)
static UINT setup_sequence(_In_ MSIHANDLE hInstall, _In_z_ LPCWSTR szProperty, _In_ struct msica_arg_seq *seq)
Joins an argument sequence and sets it to the MSI property.
static BOOL parse_guid(_In_z_ LPCWSTR szArg, _Out_ GUID *guid)
Parses string encoded GUID.
static void CreateRebootFile(_In_z_ LPCWSTR szTmpDir)
Create empty file in user's temp directory.
static DWORD schedule_adapter_create(_Inout_ struct msica_arg_seq *seq, _Inout_opt_ struct msica_arg_seq *seqRollback, _In_z_ LPCWSTR szDisplayName, _In_z_ LPCWSTR szHardwareId, _Inout_ int *iTicks)
Schedules adapter creation.
UINT __stdcall EvaluateTUNTAPAdapters(_In_ MSIHANDLE hInstall)
Evaluate the TUNTAPAdapter table of the MSI package database and prepare a list of TAP adapters to in...
#define OPENVPNMSICA_SAVE_MSI_SESSION(hInstall)
Set MSI session handle in thread local storage.
Network adapter list node.
LPWSTR szzHardwareIDs
Device hardware ID(s)
struct tap_adapter_node * pNext
Pointer to next adapter.
LPWSTR szName
Adapter name.
DWORD tap_list_adapters(_In_opt_ HWND hwndParent, _In_opt_ LPCWSTR szzHwIDs, _Out_ struct tap_adapter_node **ppAdapter)
Creates a list of existing network adapters.
DWORD tap_set_adapter_name(_In_ LPCGUID pguidAdapter, _In_ LPCWSTR szName, _In_ BOOL bSilent)
Sets adapter name.
DWORD tap_create_adapter(_In_opt_ HWND hwndParent, _In_opt_ LPCWSTR szDeviceDescription, _In_ LPCWSTR szHwId, _Inout_ LPBOOL pbRebootRequired, _Out_ LPGUID pguidAdapter)
Creates a TUN/TAP adapter.
DWORD tap_delete_adapter(_In_opt_ HWND hwndParent, _In_ LPCGUID pguidAdapter, _Inout_ LPBOOL pbRebootRequired)
Deletes an adapter.
void tap_free_adapter_list(_In_ struct tap_adapter_node *pAdapterList)
Frees a list of network adapters.
DWORD tap_enable_adapter(_In_opt_ HWND hwndParent, _In_ LPCGUID pguidAdapter, _In_ BOOL bEnable, _Inout_ LPBOOL pbRebootRequired)
Enables or disables an adapter.
#define PRIGUID_PARAM_REF(g)
static int cleanup(void **state)