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)
714 uiResult = ERROR_SUCCESS;
717 else if (uiResult != ERROR_SUCCESS)
719 SetLastError(uiResult);
722 goto cleanup_hRecordProg;
725 INSTALLSTATE iInstalled, iAction;
728 LPWSTR szValue = NULL;
730 if (uiResult != ERROR_SUCCESS)
732 goto cleanup_hRecord;
736 uiResult = MsiGetComponentState(hInstall, szValue, &iInstalled, &iAction);
737 if (uiResult != ERROR_SUCCESS)
739 SetLastError(uiResult);
745 goto cleanup_hRecord;
751 LPWSTR szDisplayName = NULL;
753 if (uiResult != ERROR_SUCCESS)
755 goto cleanup_hRecord;
760 LPWSTR szDisplayNameEx = wcschr(szDisplayName, L
'|');
761 szDisplayNameEx = szDisplayNameEx != NULL ? szDisplayNameEx + 1 : szDisplayName;
764 WCHAR szzHardwareIDs[0x100] = { 0 };
766 LPWSTR szHwId = NULL;
768 if (uiResult != ERROR_SUCCESS)
770 goto cleanup_szDisplayName;
772 memcpy_s(szzHardwareIDs,
773 sizeof(szzHardwareIDs)
774 - 2 *
sizeof(WCHAR) ,
775 szHwId, wcslen(szHwId) *
sizeof(WCHAR));
779 if (iAction > INSTALLSTATE_BROKEN)
783 if (iAction >= INSTALLSTATE_LOCAL)
786 LPWSTR szValue = NULL;
788 if (uiResult != ERROR_SUCCESS)
790 goto cleanup_szDisplayName;
792#if defined(__GNUC__) || defined(__clang__)
797#pragma GCC diagnostic push
798#pragma GCC diagnostic ignored "-Wswitch"
800 switch (MsiEvaluateCondition(hInstall, szValue))
802 case MSICONDITION_FALSE:
804 goto cleanup_szDisplayName;
806 case MSICONDITION_ERROR:
807 uiResult = ERROR_INVALID_FIELD;
809 __FUNCTION__, szValue);
811 goto cleanup_szDisplayName;
813#if defined(__GNUC__) || defined(__clang__)
814#pragma GCC diagnostic pop
820 bRollbackEnabled ? &seqInstallRollback : NULL,
821 szDisplayNameEx, szzHardwareIDs, &iTicks)
824 uiResult = ERROR_INSTALL_FAILED;
825 goto cleanup_szDisplayName;
837 bRollbackEnabled ? &seqUninstallCommit : NULL,
838 bRollbackEnabled ? &seqUninstallRollback : NULL,
839 szDisplayNameEx, szzHardwareIDs, &iTicks);
844 MsiRecordSetInteger(hRecordProg, 1, 3 );
845 MsiRecordSetInteger(hRecordProg, 2, iTicks);
846 if (MsiProcessMessage(hInstall, INSTALLMESSAGE_PROGRESS, hRecordProg) == IDCANCEL)
848 uiResult = ERROR_INSTALL_USEREXIT;
849 goto cleanup_szDisplayName;
853cleanup_szDisplayName:
856 MsiCloseHandle(hRecord);
857 if (uiResult != ERROR_SUCCESS)
859 goto cleanup_hRecordProg;
864 WCHAR tmpDir[MAX_PATH];
865 GetTempPath(MAX_PATH, tmpDir);
867 WCHAR str[MAX_PATH + 7];
868 swprintf_s(str, _countof(str), L
"tmpdir=%ls", tmpDir);
877 if ((uiResult =
setup_sequence(hInstall, L
"InstallTUNTAPAdapters", &seqInstall))
879 || (uiResult =
setup_sequence(hInstall, L
"InstallTUNTAPAdaptersCommit", &seqInstallCommit))
882 setup_sequence(hInstall, L
"InstallTUNTAPAdaptersRollback", &seqInstallRollback))
884 || (uiResult =
setup_sequence(hInstall, L
"UninstallTUNTAPAdapters", &seqUninstall))
887 setup_sequence(hInstall, L
"UninstallTUNTAPAdaptersCommit", &seqUninstallCommit))
890 setup_sequence(hInstall, L
"UninstallTUNTAPAdaptersRollback", &seqUninstallRollback))
893 goto cleanup_hRecordProg;
896 uiResult = ERROR_SUCCESS;
899 MsiCloseHandle(hRecordProg);
900cleanup_hViewST_close:
901 MsiViewClose(hViewST);
903 MsiCloseHandle(hViewST);
905 MsiCloseHandle(hDatabase);
913 if (bIsCoInitialized)
953 WCHAR path[MAX_PATH];
956 msg(
M_WARN,
"%s: Reboot required, create reboot indication file \"%ls\"", __FUNCTION__, path);
959 CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
960 if (file == INVALID_HANDLE_VALUE)
974#pragma comment(linker, DLLEXP_EXPORT)
980 BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));
981 WCHAR tmpDir[MAX_PATH] = { 0 };
986 MsiGetMode(hInstall, MSIRUNMODE_COMMIT) || MsiGetMode(hInstall, MSIRUNMODE_ROLLBACK);
990 LPWSTR szSequence = NULL;
991 uiResult =
msi_get_string(hInstall, L
"CustomActionData", &szSequence);
992 if (uiResult != ERROR_SUCCESS)
994 goto cleanup_CoInitialize;
997 LPWSTR *szArg = CommandLineToArgvW(szSequence, &nArgs);
1000 uiResult = GetLastError();
1003 goto cleanup_szSequence;
1007 MSIHANDLE hRecordProg = MsiCreateRecord(3);
1008 MsiRecordSetInteger(hRecordProg, 1, 1);
1009 MsiRecordSetInteger(hRecordProg, 2, 1);
1010 MsiRecordSetInteger(hRecordProg, 3, 0);
1011 MsiProcessMessage(hInstall, INSTALLMESSAGE_PROGRESS, hRecordProg);
1014 MsiRecordSetInteger(hRecordProg, 1, 2);
1015 MsiRecordSetInteger(hRecordProg, 3, 0);
1017 BOOL bRebootRequired = FALSE;
1019 for (
int i = 1 ; i < nArgs; ++i)
1021 DWORD dwResult = ERROR_SUCCESS;
1023 if (wcsncmp(szArg[i], L
"create=", 7) == 0)
1026 LPWSTR szName = szArg[i] + 7;
1027 LPWSTR szHardwareId = wcschr(szName, L
'|');
1028 if (szHardwareId == NULL)
1030 goto invalid_argument;
1032 szHardwareId[0] = 0;
1037 MSIHANDLE hRecord = MsiCreateRecord(4);
1038 MsiRecordSetString(hRecord, 1, L
"Creating adapter");
1039 MsiRecordSetString(hRecord, 2, szName);
1040 MsiRecordSetString(hRecord, 3, szHardwareId);
1041 int iResult = MsiProcessMessage(hInstall, INSTALLMESSAGE_ACTIONDATA, hRecord);
1042 MsiCloseHandle(hRecord);
1043 if (iResult == IDCANCEL)
1045 uiResult = ERROR_INSTALL_USEREXIT;
1051 dwResult =
tap_create_adapter(NULL, NULL, szHardwareId, &bRebootRequired, &guidAdapter);
1052 if (dwResult == ERROR_SUCCESS)
1059 else if (wcsncmp(szArg[i], L
"deleteN=", 8) == 0)
1062 LPCWSTR szName = szArg[i] + 8;
1066 MSIHANDLE hRecord = MsiCreateRecord(3);
1067 MsiRecordSetString(hRecord, 1, L
"Deleting adapter");
1068 MsiRecordSetString(hRecord, 2, szName);
1069 int iResult = MsiProcessMessage(hInstall, INSTALLMESSAGE_ACTIONDATA, hRecord);
1070 MsiCloseHandle(hRecord);
1071 if (iResult == IDCANCEL)
1073 uiResult = ERROR_INSTALL_USEREXIT;
1081 if (dwResult == ERROR_SUCCESS)
1085 pAdapter = pAdapter->
pNext)
1087 if (wcsicmp(
szName, pAdapter->szName) == 0)
1098 else if (wcsncmp(szArg[i], L
"delete=", 7) == 0)
1104 goto invalid_argument;
1108 else if (wcsncmp(szArg[i], L
"enable=", 7) == 0)
1114 goto invalid_argument;
1118 else if (wcsncmp(szArg[i], L
"disable=", 8) == 0)
1124 goto invalid_argument;
1128 else if (wcsncmp(szArg[i], L
"tmpdir=", 7) == 0)
1130 wcscpy_s(tmpDir, _countof(tmpDir), szArg[i] + 7);
1134 goto invalid_argument;
1137 if (dwResult != ERROR_SUCCESS && !bIsCleanup )
1139 uiResult = ERROR_INSTALL_FAILURE;
1145 if (MsiProcessMessage(hInstall, INSTALLMESSAGE_PROGRESS, hRecordProg) == IDCANCEL)
1147 dwResult = ERROR_INSTALL_USEREXIT;
1154 msg(
M_NONFATAL,
"%s: Ignoring invalid argument: %ls", __FUNCTION__, szArg[i]);
1158 if (bRebootRequired && wcslen(tmpDir) > 0)
1162 MsiCloseHandle(hRecordProg);
1166cleanup_CoInitialize:
1167 if (bIsCoInitialized)
1178#pragma comment(linker, DLLEXP_EXPORT)
1183 BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));
1188 WCHAR tempPath[MAX_PATH];
1189 GetTempPathW(MAX_PATH, tempPath);
1192 WCHAR path[MAX_PATH];
1194 WIN32_FIND_DATA data = { 0 };
1195 HANDLE searchHandle = FindFirstFileW(path, &data);
1196 if (searchHandle != INVALID_HANDLE_VALUE)
1198 msg(
M_WARN,
"%s: Reboot file exists, schedule reboot", __FUNCTION__);
1200 FindClose(searchHandle);
1203 MsiSetMode(hInstall, MSIRUNMODE_REBOOTATEND, TRUE);
1206 if (bIsCoInitialized)
1210 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)