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(%u) 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)
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(%u) 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(%u) 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)
293 SetLastError(uiResult);
296 szActiveAdaptersPropertyName);
297 goto cleanup_szAdaptersActive;
300cleanup_szAdaptersActive:
301 free(szAdaptersActive);
304cleanup_pAdapterAdresses:
305 free(pAdapterAdresses);
315#pragma comment(linker, DLLEXP_EXPORT)
320 BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));
324 find_adapters(hInstall, L
"root\\" _L(TAP_WIN_COMPONENT_ID) L
"\0" _L(TAP_WIN_COMPONENT_ID) L
"\0",
325 L
"TAPWINDOWS6ADAPTERS", L
"ACTIVETAPWINDOWS6ADAPTERS");
329 L
"OVPNDCOADAPTERS", L
"ACTIVEOVPNDCOADAPTERS");
331 if (bIsCoInitialized)
335 return ERROR_SUCCESS;
343#pragma comment(linker, DLLEXP_EXPORT)
345 UNREFERENCED_PARAMETER(hInstall);
351 HWND hWnd = FindWindow(L
"OpenVPN-GUI", NULL);
356 SendMessage(hWnd, WM_CLOSE, 0, 0);
360 return ERROR_SUCCESS;
368#pragma comment(linker, DLLEXP_EXPORT)
374 BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));
379 MSIHANDLE hRecord = MsiCreateRecord(1);
382 uiResult = ERROR_INVALID_HANDLE;
384 goto cleanup_CoInitialize;
386 uiResult = MsiRecordSetString(hRecord, 0, L
"\"[#bin.openvpn_gui.exe]\"");
387 if (uiResult != ERROR_SUCCESS)
389 SetLastError(uiResult);
392 goto cleanup_MsiCreateRecord;
396 WCHAR szStackBuf[MAX_PATH];
397 DWORD dwPathSize = _countof(szStackBuf);
398 LPWSTR szPath = szStackBuf;
399 uiResult = MsiFormatRecord(hInstall, hRecord, szPath, &dwPathSize);
400 if (uiResult == ERROR_MORE_DATA)
403 szPath = (LPWSTR)malloc((++dwPathSize) *
sizeof(WCHAR));
406 msg(
M_FATAL,
"%s: malloc(%u) failed", __FUNCTION__, dwPathSize *
sizeof(WCHAR));
407 uiResult = ERROR_OUTOFMEMORY;
408 goto cleanup_MsiCreateRecord;
411 uiResult = MsiFormatRecord(hInstall, hRecord, szPath, &dwPathSize);
413 if (uiResult != ERROR_SUCCESS)
415 SetLastError(uiResult);
418 goto cleanup_malloc_szPath;
422 SHELLEXECUTEINFO sei = { .cbSize =
sizeof(SHELLEXECUTEINFO),
426 .nShow = SW_SHOWNORMAL };
427 if (!ShellExecuteEx(&sei))
429 uiResult = GetLastError();
431 goto cleanup_malloc_szPath;
434 uiResult = ERROR_SUCCESS;
436cleanup_malloc_szPath:
437 if (szPath != szStackBuf)
441cleanup_MsiCreateRecord:
442 MsiCloseHandle(hRecord);
444 if (bIsCoInitialized)
480 if (dwResult != ERROR_SUCCESS)
487 pAdapterOther = pAdapterOther->
pNext)
489 if (pAdapterOther == NULL)
492 WCHAR szArgument[10 + MAX_PATH + 1
496 swprintf_s(szArgument, _countof(szArgument), L
"create=\"%.*s|%.*s\"", MAX_PATH,
497 szDisplayName, MAX_PATH, szHardwareId);
503 swprintf_s(szArgument, _countof(szArgument), L
"deleteN=\"%.*s\"", MAX_PATH,
511 else if (_wcsicmp(szDisplayName, pAdapterOther->szName) == 0)
514 for (LPCWSTR hwid = pAdapterOther->szzHardwareIDs;; hwid += wcslen(hwid) + 1)
519 msg(
M_NONFATAL,
"%s: Adapter with name \"%ls\" already exists", __FUNCTION__,
520 pAdapterOther->szName);
521 dwResult = ERROR_ALREADY_EXISTS;
522 goto cleanup_pAdapterList;
524 else if (_wcsicmp(hwid, szHardwareId) == 0)
577 if (dwResult != ERROR_SUCCESS)
584 pAdapter = pAdapter->
pNext)
586 if (_wcsicmp(szDisplayName, pAdapter->szName) == 0)
591 if (seqCommit && seqRollback)
594 swprintf_s(szArgument, _countof(szArgument), L
"disable=" _L(
PRIXGUID),
599 swprintf_s(szArgument, _countof(szArgument), L
"enable=" _L(
PRIXGUID),
604 swprintf_s(szArgument, _countof(szArgument), L
"delete=" _L(
PRIXGUID),
611 swprintf_s(szArgument, _countof(szArgument), L
"delete=" _L(
PRIXGUID),
630#pragma comment(linker, DLLEXP_EXPORT)
636 BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));
640 struct msica_arg_seq seqInstall, seqInstallCommit, seqInstallRollback, seqUninstall,
641 seqUninstallCommit, seqUninstallRollback;
650 bool bRollbackEnabled =
651 MsiEvaluateCondition(hInstall, L
"RollbackDisabled") != MSICONDITION_TRUE;
654 MSIHANDLE hDatabase = MsiGetActiveDatabase(hInstall);
657 msg(
M_NONFATAL,
"%s: MsiGetActiveDatabase failed", __FUNCTION__);
658 uiResult = ERROR_INVALID_HANDLE;
659 goto cleanup_exec_seq;
663 switch (MsiDatabaseIsTablePersistent(hDatabase, L
"TUNTAPAdapter"))
665 case MSICONDITION_FALSE:
666 case MSICONDITION_TRUE:
670 uiResult = ERROR_SUCCESS;
671 goto cleanup_hDatabase;
675 MSIHANDLE hViewST = 0;
677 L
"SELECT `Adapter`,`DisplayName`,`Condition`,`Component_`,`HardwareId` FROM `TUNTAPAdapter`";
678 uiResult = MsiDatabaseOpenView(hDatabase, szQuery, &hViewST);
679 if (uiResult != ERROR_SUCCESS)
685 goto cleanup_hDatabase;
689 uiResult = MsiViewExecute(hViewST, 0);
690 if (uiResult != ERROR_SUCCESS)
692 SetLastError(uiResult);
695 goto cleanup_hViewST;
699 MSIHANDLE hRecordProg = MsiCreateRecord(2);
702 uiResult = ERROR_INVALID_HANDLE;
704 goto cleanup_hViewST_close;
710 MSIHANDLE hRecord = 0;
711 uiResult = MsiViewFetch(hViewST, &hRecord);
712 if (uiResult == ERROR_NO_MORE_ITEMS)
716 else if (uiResult != ERROR_SUCCESS)
718 SetLastError(uiResult);
721 goto cleanup_hRecordProg;
724 INSTALLSTATE iInstalled, iAction;
727 LPWSTR szValue = NULL;
729 if (uiResult != ERROR_SUCCESS)
731 goto cleanup_hRecord;
735 uiResult = MsiGetComponentState(hInstall, szValue, &iInstalled, &iAction);
736 if (uiResult != ERROR_SUCCESS)
738 SetLastError(uiResult);
744 goto cleanup_hRecord;
750 LPWSTR szDisplayName = NULL;
752 if (uiResult != ERROR_SUCCESS)
754 goto cleanup_hRecord;
759 LPWSTR szDisplayNameEx = wcschr(szDisplayName, L
'|');
760 szDisplayNameEx = szDisplayNameEx != NULL ? szDisplayNameEx + 1 : szDisplayName;
763 WCHAR szzHardwareIDs[0x100] = { 0 };
765 LPWSTR szHwId = NULL;
767 if (uiResult != ERROR_SUCCESS)
769 goto cleanup_szDisplayName;
771 memcpy_s(szzHardwareIDs,
772 sizeof(szzHardwareIDs)
773 - 2 *
sizeof(WCHAR) ,
774 szHwId, wcslen(szHwId) *
sizeof(WCHAR));
778 if (iAction > INSTALLSTATE_BROKEN)
782 if (iAction >= INSTALLSTATE_LOCAL)
785 LPWSTR szValue = NULL;
787 if (uiResult != ERROR_SUCCESS)
789 goto cleanup_szDisplayName;
791#if defined(__GNUC__) || defined(__clang__)
796#pragma GCC diagnostic push
797#pragma GCC diagnostic ignored "-Wswitch"
799 switch (MsiEvaluateCondition(hInstall, szValue))
801 case MSICONDITION_FALSE:
803 goto cleanup_szDisplayName;
805 case MSICONDITION_ERROR:
806 uiResult = ERROR_INVALID_FIELD;
808 __FUNCTION__, szValue);
810 goto cleanup_szDisplayName;
812#if defined(__GNUC__) || defined(__clang__)
813#pragma GCC diagnostic pop
819 bRollbackEnabled ? &seqInstallRollback : NULL,
820 szDisplayNameEx, szzHardwareIDs, &iTicks)
823 uiResult = ERROR_INSTALL_FAILED;
824 goto cleanup_szDisplayName;
836 bRollbackEnabled ? &seqUninstallCommit : NULL,
837 bRollbackEnabled ? &seqUninstallRollback : NULL,
838 szDisplayNameEx, szzHardwareIDs, &iTicks);
843 MsiRecordSetInteger(hRecordProg, 1, 3 );
844 MsiRecordSetInteger(hRecordProg, 2, iTicks);
845 if (MsiProcessMessage(hInstall, INSTALLMESSAGE_PROGRESS, hRecordProg) == IDCANCEL)
847 uiResult = ERROR_INSTALL_USEREXIT;
848 goto cleanup_szDisplayName;
852cleanup_szDisplayName:
855 MsiCloseHandle(hRecord);
856 if (uiResult != ERROR_SUCCESS)
858 goto cleanup_hRecordProg;
863 WCHAR tmpDir[MAX_PATH];
864 GetTempPath(MAX_PATH, tmpDir);
866 WCHAR str[MAX_PATH + 7];
867 swprintf_s(str, _countof(str), L
"tmpdir=%ls", tmpDir);
876 if ((uiResult =
setup_sequence(hInstall, L
"InstallTUNTAPAdapters", &seqInstall))
878 || (uiResult =
setup_sequence(hInstall, L
"InstallTUNTAPAdaptersCommit", &seqInstallCommit))
881 setup_sequence(hInstall, L
"InstallTUNTAPAdaptersRollback", &seqInstallRollback))
883 || (uiResult =
setup_sequence(hInstall, L
"UninstallTUNTAPAdapters", &seqUninstall))
886 setup_sequence(hInstall, L
"UninstallTUNTAPAdaptersCommit", &seqUninstallCommit))
889 setup_sequence(hInstall, L
"UninstallTUNTAPAdaptersRollback", &seqUninstallRollback))
892 goto cleanup_hRecordProg;
895 uiResult = ERROR_SUCCESS;
898 MsiCloseHandle(hRecordProg);
899cleanup_hViewST_close:
900 MsiViewClose(hViewST);
902 MsiCloseHandle(hViewST);
904 MsiCloseHandle(hDatabase);
912 if (bIsCoInitialized)
952 WCHAR path[MAX_PATH];
955 msg(
M_WARN,
"%s: Reboot required, create reboot indication file \"%ls\"", __FUNCTION__, path);
958 CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
959 if (file == INVALID_HANDLE_VALUE)
973#pragma comment(linker, DLLEXP_EXPORT)
979 BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));
980 WCHAR tmpDir[MAX_PATH] = { 0 };
985 MsiGetMode(hInstall, MSIRUNMODE_COMMIT) || MsiGetMode(hInstall, MSIRUNMODE_ROLLBACK);
989 LPWSTR szSequence = NULL;
990 uiResult =
msi_get_string(hInstall, L
"CustomActionData", &szSequence);
991 if (uiResult != ERROR_SUCCESS)
993 goto cleanup_CoInitialize;
996 LPWSTR *szArg = CommandLineToArgvW(szSequence, &nArgs);
999 uiResult = GetLastError();
1002 goto cleanup_szSequence;
1006 MSIHANDLE hRecordProg = MsiCreateRecord(3);
1007 MsiRecordSetInteger(hRecordProg, 1, 1);
1008 MsiRecordSetInteger(hRecordProg, 2, 1);
1009 MsiRecordSetInteger(hRecordProg, 3, 0);
1010 MsiProcessMessage(hInstall, INSTALLMESSAGE_PROGRESS, hRecordProg);
1013 MsiRecordSetInteger(hRecordProg, 1, 2);
1014 MsiRecordSetInteger(hRecordProg, 3, 0);
1016 BOOL bRebootRequired = FALSE;
1018 for (
int i = 1 ; i < nArgs; ++i)
1020 DWORD dwResult = ERROR_SUCCESS;
1022 if (wcsncmp(szArg[i], L
"create=", 7) == 0)
1025 LPWSTR szName = szArg[i] + 7;
1026 LPWSTR szHardwareId = wcschr(szName, L
'|');
1027 if (szHardwareId == NULL)
1029 goto invalid_argument;
1031 szHardwareId[0] = 0;
1036 MSIHANDLE hRecord = MsiCreateRecord(4);
1037 MsiRecordSetString(hRecord, 1, L
"Creating adapter");
1038 MsiRecordSetString(hRecord, 2, szName);
1039 MsiRecordSetString(hRecord, 3, szHardwareId);
1040 int iResult = MsiProcessMessage(hInstall, INSTALLMESSAGE_ACTIONDATA, hRecord);
1041 MsiCloseHandle(hRecord);
1042 if (iResult == IDCANCEL)
1044 uiResult = ERROR_INSTALL_USEREXIT;
1050 dwResult =
tap_create_adapter(NULL, NULL, szHardwareId, &bRebootRequired, &guidAdapter);
1051 if (dwResult == ERROR_SUCCESS)
1058 else if (wcsncmp(szArg[i], L
"deleteN=", 8) == 0)
1061 LPCWSTR szName = szArg[i] + 8;
1065 MSIHANDLE hRecord = MsiCreateRecord(3);
1066 MsiRecordSetString(hRecord, 1, L
"Deleting adapter");
1067 MsiRecordSetString(hRecord, 2, szName);
1068 int iResult = MsiProcessMessage(hInstall, INSTALLMESSAGE_ACTIONDATA, hRecord);
1069 MsiCloseHandle(hRecord);
1070 if (iResult == IDCANCEL)
1072 uiResult = ERROR_INSTALL_USEREXIT;
1080 if (dwResult == ERROR_SUCCESS)
1084 pAdapter = pAdapter->
pNext)
1086 if (_wcsicmp(
szName, pAdapter->szName) == 0)
1097 else if (wcsncmp(szArg[i], L
"delete=", 7) == 0)
1103 goto invalid_argument;
1107 else if (wcsncmp(szArg[i], L
"enable=", 7) == 0)
1113 goto invalid_argument;
1117 else if (wcsncmp(szArg[i], L
"disable=", 8) == 0)
1123 goto invalid_argument;
1127 else if (wcsncmp(szArg[i], L
"tmpdir=", 7) == 0)
1129 wcscpy_s(tmpDir, _countof(tmpDir), szArg[i] + 7);
1133 goto invalid_argument;
1136 if (dwResult != ERROR_SUCCESS && !bIsCleanup )
1138 uiResult = ERROR_INSTALL_FAILURE;
1144 if (MsiProcessMessage(hInstall, INSTALLMESSAGE_PROGRESS, hRecordProg) == IDCANCEL)
1146 dwResult = ERROR_INSTALL_USEREXIT;
1153 msg(
M_NONFATAL,
"%s: Ignoring invalid argument: %ls", __FUNCTION__, szArg[i]);
1157 if (bRebootRequired && wcslen(tmpDir) > 0)
1161 MsiCloseHandle(hRecordProg);
1165cleanup_CoInitialize:
1166 if (bIsCoInitialized)
1177#pragma comment(linker, DLLEXP_EXPORT)
1182 BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));
1187 WCHAR tempPath[MAX_PATH];
1188 GetTempPathW(MAX_PATH, tempPath);
1191 WCHAR path[MAX_PATH];
1193 WIN32_FIND_DATA data = { 0 };
1194 HANDLE searchHandle = FindFirstFileW(path, &data);
1195 if (searchHandle != INVALID_HANDLE_VALUE)
1197 msg(
M_WARN,
"%s: Reboot file exists, schedule reboot", __FUNCTION__);
1199 FindClose(searchHandle);
1202 MsiSetMode(hInstall, MSIRUNMODE_REBOOTATEND, TRUE);
1205 if (bIsCoInitialized)
1209 return ERROR_SUCCESS;
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)