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);
314#pragma comment(linker, DLLEXP_EXPORT)
319 BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));
323 find_adapters(hInstall, L
"root\\" _L(TAP_WIN_COMPONENT_ID) L
"\0" _L(TAP_WIN_COMPONENT_ID) L
"\0",
324 L
"TAPWINDOWS6ADAPTERS", L
"ACTIVETAPWINDOWS6ADAPTERS");
328 L
"OVPNDCOADAPTERS", L
"ACTIVEOVPNDCOADAPTERS");
330 if (bIsCoInitialized)
334 return ERROR_SUCCESS;
341#pragma comment(linker, DLLEXP_EXPORT)
343 UNREFERENCED_PARAMETER(hInstall);
349 HWND hWnd = FindWindow(L
"OpenVPN-GUI", NULL);
354 SendMessage(hWnd, WM_CLOSE, 0, 0);
358 return ERROR_SUCCESS;
365#pragma comment(linker, DLLEXP_EXPORT)
371 BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));
376 MSIHANDLE hRecord = MsiCreateRecord(1);
379 uiResult = ERROR_INVALID_HANDLE;
381 goto cleanup_CoInitialize;
383 uiResult = MsiRecordSetString(hRecord, 0, L
"\"[#bin.openvpn_gui.exe]\"");
384 if (uiResult != ERROR_SUCCESS)
386 SetLastError(uiResult);
389 goto cleanup_MsiCreateRecord;
393 WCHAR szStackBuf[MAX_PATH];
394 DWORD dwPathSize = _countof(szStackBuf);
395 LPWSTR szPath = szStackBuf;
396 uiResult = MsiFormatRecord(hInstall, hRecord, szPath, &dwPathSize);
397 if (uiResult == ERROR_MORE_DATA)
400 szPath = (LPWSTR)malloc((++dwPathSize) *
sizeof(WCHAR));
403 msg(
M_FATAL,
"%s: malloc(%u) failed", __FUNCTION__, dwPathSize *
sizeof(WCHAR));
404 uiResult = ERROR_OUTOFMEMORY;
405 goto cleanup_MsiCreateRecord;
408 uiResult = MsiFormatRecord(hInstall, hRecord, szPath, &dwPathSize);
410 if (uiResult != ERROR_SUCCESS)
412 SetLastError(uiResult);
415 goto cleanup_malloc_szPath;
419 SHELLEXECUTEINFO sei = { .cbSize =
sizeof(SHELLEXECUTEINFO),
423 .nShow = SW_SHOWNORMAL };
424 if (!ShellExecuteEx(&sei))
426 uiResult = GetLastError();
428 goto cleanup_malloc_szPath;
431 uiResult = ERROR_SUCCESS;
433cleanup_malloc_szPath:
434 if (szPath != szStackBuf)
438cleanup_MsiCreateRecord:
439 MsiCloseHandle(hRecord);
441 if (bIsCoInitialized)
477 if (dwResult != ERROR_SUCCESS)
484 pAdapterOther = pAdapterOther->
pNext)
486 if (pAdapterOther == NULL)
489 WCHAR szArgument[10 + MAX_PATH + 1
493 swprintf_s(szArgument, _countof(szArgument), L
"create=\"%.*s|%.*s\"", MAX_PATH,
494 szDisplayName, MAX_PATH, szHardwareId);
500 swprintf_s(szArgument, _countof(szArgument), L
"deleteN=\"%.*s\"", MAX_PATH,
508 else if (wcsicmp(szDisplayName, pAdapterOther->szName) == 0)
511 for (LPCWSTR hwid = pAdapterOther->szzHardwareIDs;; hwid += wcslen(hwid) + 1)
516 msg(
M_NONFATAL,
"%s: Adapter with name \"%ls\" already exists", __FUNCTION__,
517 pAdapterOther->szName);
518 dwResult = ERROR_ALREADY_EXISTS;
519 goto cleanup_pAdapterList;
521 else if (wcsicmp(hwid, szHardwareId) == 0)
574 if (dwResult != ERROR_SUCCESS)
581 pAdapter = pAdapter->
pNext)
583 if (wcsicmp(szDisplayName, pAdapter->szName) == 0)
588 if (seqCommit && seqRollback)
591 swprintf_s(szArgument, _countof(szArgument), L
"disable=" _L(
PRIXGUID),
596 swprintf_s(szArgument, _countof(szArgument), L
"enable=" _L(
PRIXGUID),
601 swprintf_s(szArgument, _countof(szArgument), L
"delete=" _L(
PRIXGUID),
608 swprintf_s(szArgument, _countof(szArgument), L
"delete=" _L(
PRIXGUID),
626#pragma comment(linker, DLLEXP_EXPORT)
632 BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));
636 struct msica_arg_seq seqInstall, seqInstallCommit, seqInstallRollback, seqUninstall,
637 seqUninstallCommit, seqUninstallRollback;
646 bool bRollbackEnabled =
647 MsiEvaluateCondition(hInstall, L
"RollbackDisabled") != MSICONDITION_TRUE;
650 MSIHANDLE hDatabase = MsiGetActiveDatabase(hInstall);
653 msg(
M_NONFATAL,
"%s: MsiGetActiveDatabase failed", __FUNCTION__);
654 uiResult = ERROR_INVALID_HANDLE;
655 goto cleanup_exec_seq;
659 switch (MsiDatabaseIsTablePersistent(hDatabase, L
"TUNTAPAdapter"))
661 case MSICONDITION_FALSE:
662 case MSICONDITION_TRUE:
666 uiResult = ERROR_SUCCESS;
667 goto cleanup_hDatabase;
671 MSIHANDLE hViewST = 0;
673 L
"SELECT `Adapter`,`DisplayName`,`Condition`,`Component_`,`HardwareId` FROM `TUNTAPAdapter`";
674 uiResult = MsiDatabaseOpenView(hDatabase, szQuery, &hViewST);
675 if (uiResult != ERROR_SUCCESS)
681 goto cleanup_hDatabase;
685 uiResult = MsiViewExecute(hViewST, 0);
686 if (uiResult != ERROR_SUCCESS)
688 SetLastError(uiResult);
691 goto cleanup_hViewST;
695 MSIHANDLE hRecordProg = MsiCreateRecord(2);
698 uiResult = ERROR_INVALID_HANDLE;
700 goto cleanup_hViewST_close;
706 MSIHANDLE hRecord = 0;
707 uiResult = MsiViewFetch(hViewST, &hRecord);
708 if (uiResult == ERROR_NO_MORE_ITEMS)
710 uiResult = ERROR_SUCCESS;
713 else if (uiResult != ERROR_SUCCESS)
715 SetLastError(uiResult);
718 goto cleanup_hRecordProg;
721 INSTALLSTATE iInstalled, iAction;
724 LPWSTR szValue = NULL;
726 if (uiResult != ERROR_SUCCESS)
728 goto cleanup_hRecord;
732 uiResult = MsiGetComponentState(hInstall, szValue, &iInstalled, &iAction);
733 if (uiResult != ERROR_SUCCESS)
735 SetLastError(uiResult);
741 goto cleanup_hRecord;
747 LPWSTR szDisplayName = NULL;
749 if (uiResult != ERROR_SUCCESS)
751 goto cleanup_hRecord;
756 LPWSTR szDisplayNameEx = wcschr(szDisplayName, L
'|');
757 szDisplayNameEx = szDisplayNameEx != NULL ? szDisplayNameEx + 1 : szDisplayName;
760 WCHAR szzHardwareIDs[0x100] = { 0 };
762 LPWSTR szHwId = NULL;
764 if (uiResult != ERROR_SUCCESS)
766 goto cleanup_szDisplayName;
768 memcpy_s(szzHardwareIDs,
769 sizeof(szzHardwareIDs)
770 - 2 *
sizeof(WCHAR) ,
771 szHwId, wcslen(szHwId) *
sizeof(WCHAR));
775 if (iAction > INSTALLSTATE_BROKEN)
779 if (iAction >= INSTALLSTATE_LOCAL)
782 LPWSTR szValue = NULL;
784 if (uiResult != ERROR_SUCCESS)
786 goto cleanup_szDisplayName;
788#if defined(__GNUC__) || defined(__clang__)
793#pragma GCC diagnostic push
794#pragma GCC diagnostic ignored "-Wswitch"
796 switch (MsiEvaluateCondition(hInstall, szValue))
798 case MSICONDITION_FALSE:
800 goto cleanup_szDisplayName;
802 case MSICONDITION_ERROR:
803 uiResult = ERROR_INVALID_FIELD;
805 __FUNCTION__, szValue);
807 goto cleanup_szDisplayName;
809#if defined(__GNUC__) || defined(__clang__)
810#pragma GCC diagnostic pop
816 bRollbackEnabled ? &seqInstallRollback : NULL,
817 szDisplayNameEx, szzHardwareIDs, &iTicks)
820 uiResult = ERROR_INSTALL_FAILED;
821 goto cleanup_szDisplayName;
833 bRollbackEnabled ? &seqUninstallCommit : NULL,
834 bRollbackEnabled ? &seqUninstallRollback : NULL,
835 szDisplayNameEx, szzHardwareIDs, &iTicks);
840 MsiRecordSetInteger(hRecordProg, 1, 3 );
841 MsiRecordSetInteger(hRecordProg, 2, iTicks);
842 if (MsiProcessMessage(hInstall, INSTALLMESSAGE_PROGRESS, hRecordProg) == IDCANCEL)
844 uiResult = ERROR_INSTALL_USEREXIT;
845 goto cleanup_szDisplayName;
849cleanup_szDisplayName:
852 MsiCloseHandle(hRecord);
853 if (uiResult != ERROR_SUCCESS)
855 goto cleanup_hRecordProg;
860 WCHAR tmpDir[MAX_PATH];
861 GetTempPath(MAX_PATH, tmpDir);
863 WCHAR str[MAX_PATH + 7];
864 swprintf_s(str, _countof(str), L
"tmpdir=%ls", tmpDir);
873 if ((uiResult =
setup_sequence(hInstall, L
"InstallTUNTAPAdapters", &seqInstall))
875 || (uiResult =
setup_sequence(hInstall, L
"InstallTUNTAPAdaptersCommit", &seqInstallCommit))
878 setup_sequence(hInstall, L
"InstallTUNTAPAdaptersRollback", &seqInstallRollback))
880 || (uiResult =
setup_sequence(hInstall, L
"UninstallTUNTAPAdapters", &seqUninstall))
883 setup_sequence(hInstall, L
"UninstallTUNTAPAdaptersCommit", &seqUninstallCommit))
886 setup_sequence(hInstall, L
"UninstallTUNTAPAdaptersRollback", &seqUninstallRollback))
889 goto cleanup_hRecordProg;
892 uiResult = ERROR_SUCCESS;
895 MsiCloseHandle(hRecordProg);
896cleanup_hViewST_close:
897 MsiViewClose(hViewST);
899 MsiCloseHandle(hViewST);
901 MsiCloseHandle(hDatabase);
909 if (bIsCoInitialized)
949 WCHAR path[MAX_PATH];
952 msg(
M_WARN,
"%s: Reboot required, create reboot indication file \"%ls\"", __FUNCTION__, path);
955 CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
956 if (file == INVALID_HANDLE_VALUE)
969#pragma comment(linker, DLLEXP_EXPORT)
975 BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));
976 WCHAR tmpDir[MAX_PATH] = { 0 };
981 MsiGetMode(hInstall, MSIRUNMODE_COMMIT) || MsiGetMode(hInstall, MSIRUNMODE_ROLLBACK);
985 LPWSTR szSequence = NULL;
986 uiResult =
msi_get_string(hInstall, L
"CustomActionData", &szSequence);
987 if (uiResult != ERROR_SUCCESS)
989 goto cleanup_CoInitialize;
992 LPWSTR *szArg = CommandLineToArgvW(szSequence, &nArgs);
995 uiResult = GetLastError();
998 goto cleanup_szSequence;
1002 MSIHANDLE hRecordProg = MsiCreateRecord(3);
1003 MsiRecordSetInteger(hRecordProg, 1, 1);
1004 MsiRecordSetInteger(hRecordProg, 2, 1);
1005 MsiRecordSetInteger(hRecordProg, 3, 0);
1006 MsiProcessMessage(hInstall, INSTALLMESSAGE_PROGRESS, hRecordProg);
1009 MsiRecordSetInteger(hRecordProg, 1, 2);
1010 MsiRecordSetInteger(hRecordProg, 3, 0);
1012 BOOL bRebootRequired = FALSE;
1014 for (
int i = 1 ;
i < nArgs; ++
i)
1016 DWORD dwResult = ERROR_SUCCESS;
1018 if (wcsncmp(szArg[
i], L
"create=", 7) == 0)
1021 LPWSTR szName = szArg[
i] + 7;
1022 LPWSTR szHardwareId = wcschr(szName, L
'|');
1023 if (szHardwareId == NULL)
1025 goto invalid_argument;
1027 szHardwareId[0] = 0;
1032 MSIHANDLE hRecord = MsiCreateRecord(4);
1033 MsiRecordSetString(hRecord, 1, L
"Creating adapter");
1034 MsiRecordSetString(hRecord, 2, szName);
1035 MsiRecordSetString(hRecord, 3, szHardwareId);
1036 int iResult = MsiProcessMessage(hInstall, INSTALLMESSAGE_ACTIONDATA, hRecord);
1037 MsiCloseHandle(hRecord);
1038 if (iResult == IDCANCEL)
1040 uiResult = ERROR_INSTALL_USEREXIT;
1046 dwResult =
tap_create_adapter(NULL, NULL, szHardwareId, &bRebootRequired, &guidAdapter);
1047 if (dwResult == ERROR_SUCCESS)
1054 else if (wcsncmp(szArg[
i], L
"deleteN=", 8) == 0)
1057 LPCWSTR szName = szArg[
i] + 8;
1061 MSIHANDLE hRecord = MsiCreateRecord(3);
1062 MsiRecordSetString(hRecord, 1, L
"Deleting adapter");
1063 MsiRecordSetString(hRecord, 2, szName);
1064 int iResult = MsiProcessMessage(hInstall, INSTALLMESSAGE_ACTIONDATA, hRecord);
1065 MsiCloseHandle(hRecord);
1066 if (iResult == IDCANCEL)
1068 uiResult = ERROR_INSTALL_USEREXIT;
1076 if (dwResult == ERROR_SUCCESS)
1080 pAdapter = pAdapter->
pNext)
1082 if (wcsicmp(
szName, pAdapter->szName) == 0)
1093 else if (wcsncmp(szArg[
i], L
"delete=", 7) == 0)
1099 goto invalid_argument;
1103 else if (wcsncmp(szArg[
i], L
"enable=", 7) == 0)
1109 goto invalid_argument;
1113 else if (wcsncmp(szArg[
i], L
"disable=", 8) == 0)
1119 goto invalid_argument;
1123 else if (wcsncmp(szArg[
i], L
"tmpdir=", 7) == 0)
1125 wcscpy_s(tmpDir, _countof(tmpDir), szArg[
i] + 7);
1129 goto invalid_argument;
1132 if (dwResult != ERROR_SUCCESS && !bIsCleanup )
1134 uiResult = ERROR_INSTALL_FAILURE;
1140 if (MsiProcessMessage(hInstall, INSTALLMESSAGE_PROGRESS, hRecordProg) == IDCANCEL)
1142 dwResult = ERROR_INSTALL_USEREXIT;
1149 msg(
M_NONFATAL,
"%s: Ignoring invalid argument: %ls", __FUNCTION__, szArg[
i]);
1153 if (bRebootRequired && wcslen(tmpDir) > 0)
1157 MsiCloseHandle(hRecordProg);
1161cleanup_CoInitialize:
1162 if (bIsCoInitialized)
1172#pragma comment(linker, DLLEXP_EXPORT)
1177 BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));
1182 WCHAR tempPath[MAX_PATH];
1183 GetTempPathW(MAX_PATH, tempPath);
1186 WCHAR path[MAX_PATH];
1188 WIN32_FIND_DATA data = { 0 };
1189 HANDLE searchHandle = FindFirstFileW(path, &data);
1190 if (searchHandle != INVALID_HANDLE_VALUE)
1192 msg(
M_WARN,
"%s: Reboot file exists, schedule reboot", __FUNCTION__);
1194 FindClose(searchHandle);
1197 MsiSetMode(hInstall, MSIRUNMODE_REBOOTATEND, TRUE);
1200 if (bIsCoInitialized)
1204 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)