30#include "../tapctl/basic.h"
31#include "../tapctl/error.h"
32#include "../tapctl/tap.h"
50#pragma comment(lib, "advapi32.lib")
51#pragma comment(lib, "iphlpapi.lib")
52#pragma comment(lib, "shell32.lib")
53#pragma comment(lib, "shlwapi.lib")
54#pragma comment(lib, "version.lib")
63#define MSICA_ADAPTER_TICK_SIZE (16 * 1024)
65#define FILE_NEED_REBOOT L".ovpn_need_reboot"
67#define OPENVPN_CONNECT_ADAPTER_SUBSTR L"OpenVPN Connect"
82 _In_ MSIHANDLE hInstall,
88 uiResult = MsiSetProperty(hInstall, szProperty, szSequence);
90 if (uiResult != ERROR_SUCCESS)
94 SetLastError(uiResult);
112_debug_popup(
_In_z_ LPCSTR szFunctionName)
114 WCHAR szTitle[0x100], szMessage[0x100+MAX_PATH], szProcessPath[MAX_PATH];
118 swprintf_s(szTitle, _countof(szTitle), L
"%hs v%ls",
122 GetModuleFileName(NULL, szProcessPath, _countof(szProcessPath));
123 LPCWSTR szProcessName = wcsrchr(szProcessPath, L
'\\');
124 szProcessName = szProcessName ? szProcessName + 1 : szProcessPath;
128 szMessage, _countof(szMessage),
129 L
"The %ls process (PID: %u) has started to execute the %hs"
130 L
" custom action.\r\n"
132 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"
134 L
"If you are not debugging this custom action, you can safely ignore this message.",
136 GetCurrentProcessId(),
139 MessageBox(NULL, szMessage, szTitle, MB_OK);
142#define debug_popup(f) _debug_popup(f)
144#define debug_popup(f)
149 _In_ MSIHANDLE hInstall,
150 _In_z_ LPCWSTR szzHardwareIDs,
151 _In_z_ LPCWSTR szAdaptersPropertyName,
152 _In_z_ LPCWSTR szActiveAdaptersPropertyName)
159 if (uiResult != ERROR_SUCCESS)
163 else if (pAdapterList == NULL)
170 PIP_ADAPTER_ADDRESSES pAdapterAdresses = NULL;
171 ULONG ulAdapterAdressesSize = 16*1024;
172 for (
size_t iteration = 0; iteration < 2; iteration++)
174 pAdapterAdresses = (PIP_ADAPTER_ADDRESSES)malloc(ulAdapterAdressesSize);
175 if (pAdapterAdresses == NULL)
177 msg(
M_NONFATAL,
"%s: malloc(%u) failed", __FUNCTION__, ulAdapterAdressesSize);
178 uiResult = ERROR_OUTOFMEMORY;
goto cleanup_pAdapterList;
181 ULONG ulResult = GetAdaptersAddresses(
183 GAA_FLAG_SKIP_UNICAST | GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_SKIP_FRIENDLY_NAME | GAA_FLAG_INCLUDE_ALL_INTERFACES,
186 &ulAdapterAdressesSize);
188 if (ulResult == ERROR_SUCCESS)
193 free(pAdapterAdresses);
194 if (ulResult != ERROR_BUFFER_OVERFLOW)
196 SetLastError(ulResult);
198 uiResult = ulResult;
goto cleanup_pAdapterList;
203 size_t adapter_count = 0;
211 szAdapters = (LPWSTR)malloc(adapter_count * (38 + 1 ) *
sizeof(WCHAR)),
212 szAdaptersTail = szAdapters;
213 if (szAdapters == NULL)
215 msg(
M_FATAL,
"%s: malloc(%u) failed", __FUNCTION__, adapter_count * (38 + 1 ) *
sizeof(WCHAR));
216 uiResult = ERROR_OUTOFMEMORY;
goto cleanup_pAdapterAdresses;
220 szAdaptersActive = (LPWSTR)malloc(adapter_count * (38 + 1 ) *
sizeof(WCHAR)),
221 szAdaptersActiveTail = szAdaptersActive;
222 if (szAdaptersActive == NULL)
224 msg(
M_FATAL,
"%s: malloc(%u) failed", __FUNCTION__, adapter_count * (38 + 1 ) *
sizeof(WCHAR));
225 uiResult = ERROR_OUTOFMEMORY;
goto cleanup_szAdapters;
233 msg(
M_WARN,
"%s: skip OpenVPN Connect adapter '%ls'", __FUNCTION__, pAdapter->szName);
238 LPOLESTR szAdapterId = NULL;
239 StringFromIID((REFIID)&pAdapter->guid, &szAdapterId);
242 if (szAdapters < szAdaptersTail)
244 *(szAdaptersTail++) = L
';';
246 memcpy(szAdaptersTail, szAdapterId, 38 *
sizeof(WCHAR));
247 szAdaptersTail += 38;
250 for (PIP_ADAPTER_ADDRESSES p = pAdapterAdresses; p; p = p->Next)
252 OLECHAR szId[38 + 1 ];
254 if (MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, p->AdapterName, -1, szId, _countof(szId)) > 0
255 && SUCCEEDED(IIDFromString(szId, &
guid))
256 && memcmp(&
guid, &pAdapter->guid,
sizeof(GUID)) == 0)
258 if (p->OperStatus == IfOperStatusUp)
261 if (szAdaptersActive < szAdaptersActiveTail)
263 *(szAdaptersActiveTail++) = L
';';
265 memcpy(szAdaptersActiveTail, szAdapterId, 38 *
sizeof(WCHAR));
266 szAdaptersActiveTail += 38;
271 CoTaskMemFree(szAdapterId);
273 szAdaptersTail [0] = 0;
274 szAdaptersActiveTail[0] = 0;
277 uiResult = MsiSetProperty(hInstall, szAdaptersPropertyName, szAdapters);
278 if (uiResult != ERROR_SUCCESS)
280 SetLastError(uiResult);
281 msg(
M_NONFATAL |
M_ERRNO,
"%s: MsiSetProperty(\"%s\") failed", __FUNCTION__, szAdaptersPropertyName);
282 goto cleanup_szAdaptersActive;
284 uiResult = MsiSetProperty(hInstall, szActiveAdaptersPropertyName, szAdaptersActive);
285 if (uiResult != ERROR_SUCCESS)
287 SetLastError(uiResult);
288 msg(
M_NONFATAL |
M_ERRNO,
"%s: MsiSetProperty(\"%s\") failed", __FUNCTION__, szActiveAdaptersPropertyName);
289 goto cleanup_szAdaptersActive;
292cleanup_szAdaptersActive:
293 free(szAdaptersActive);
296cleanup_pAdapterAdresses:
297 free(pAdapterAdresses);
307#pragma comment(linker, DLLEXP_EXPORT)
312 BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));
319 L
"TAPWINDOWS6ADAPTERS",
320 L
"ACTIVETAPWINDOWS6ADAPTERS");
325 L
"ACTIVEOVPNDCOADAPTERS");
327 if (bIsCoInitialized)
331 return ERROR_SUCCESS;
339#pragma comment(linker, DLLEXP_EXPORT)
341 UNREFERENCED_PARAMETER(hInstall);
346 HWND hWnd = FindWindow(L
"OpenVPN-GUI", NULL);
350 SendMessage(hWnd, WM_CLOSE, 0, 0);
354 return ERROR_SUCCESS;
362#pragma comment(linker, DLLEXP_EXPORT)
368 BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));
373 MSIHANDLE hRecord = MsiCreateRecord(1);
376 uiResult = ERROR_INVALID_HANDLE;
378 goto cleanup_CoInitialize;
380 uiResult = MsiRecordSetString(hRecord, 0, L
"\"[#bin.openvpn_gui.exe]\"");
381 if (uiResult != ERROR_SUCCESS)
383 SetLastError(uiResult);
385 goto cleanup_MsiCreateRecord;
389 WCHAR szStackBuf[MAX_PATH];
390 DWORD dwPathSize = _countof(szStackBuf);
391 LPWSTR szPath = szStackBuf;
392 uiResult = MsiFormatRecord(hInstall, hRecord, szPath, &dwPathSize);
393 if (uiResult == ERROR_MORE_DATA)
396 szPath = (LPWSTR)malloc((++dwPathSize) *
sizeof(WCHAR));
399 msg(
M_FATAL,
"%s: malloc(%u) failed", __FUNCTION__, dwPathSize *
sizeof(WCHAR));
400 uiResult = ERROR_OUTOFMEMORY;
goto cleanup_MsiCreateRecord;
403 uiResult = MsiFormatRecord(hInstall, hRecord, szPath, &dwPathSize);
405 if (uiResult != ERROR_SUCCESS)
407 SetLastError(uiResult);
409 goto cleanup_malloc_szPath;
413 SHELLEXECUTEINFO sei = {
414 .cbSize =
sizeof(SHELLEXECUTEINFO),
415 .fMask = SEE_MASK_FLAG_NO_UI,
417 .nShow = SW_SHOWNORMAL
419 if (!ShellExecuteEx(&sei))
421 uiResult = GetLastError();
423 goto cleanup_malloc_szPath;
426 uiResult = ERROR_SUCCESS;
428cleanup_malloc_szPath:
429 if (szPath != szStackBuf)
433cleanup_MsiCreateRecord:
434 MsiCloseHandle(hRecord);
436 if (bIsCoInitialized)
468 _In_z_ LPCWSTR szDisplayName,
469 _In_z_ LPCWSTR szHardwareId,
475 if (dwResult != ERROR_SUCCESS)
483 if (pAdapterOther == NULL)
486 WCHAR szArgument[10 + MAX_PATH + 1 + MAX_PATH + 1 ];
490 szArgument, _countof(szArgument),
491 L
"create=\"%.*s|%.*s\"",
492 MAX_PATH, szDisplayName,
493 MAX_PATH, szHardwareId);
500 szArgument, _countof(szArgument),
502 MAX_PATH, szDisplayName);
509 else if (wcsicmp(szDisplayName, pAdapterOther->szName) == 0)
512 for (LPCWSTR hwid = pAdapterOther->szzHardwareIDs;; hwid += wcslen(hwid) + 1)
517 msg(
M_NONFATAL,
"%s: Adapter with name \"%ls\" already exists", __FUNCTION__, pAdapterOther->szName);
518 dwResult = ERROR_ALREADY_EXISTS;
519 goto cleanup_pAdapterList;
521 else if (wcsicmp(hwid, szHardwareId) == 0)
569 _In_z_ LPCWSTR szDisplayName,
576 if (dwResult != ERROR_SUCCESS)
584 if (wcsicmp(szDisplayName, pAdapter->szName) == 0)
587 WCHAR szArgument[8 + 38 + 1 ];
588 if (seqCommit && seqRollback)
592 szArgument, _countof(szArgument),
599 szArgument, _countof(szArgument),
606 szArgument, _countof(szArgument),
615 szArgument, _countof(szArgument),
635#pragma comment(linker, DLLEXP_EXPORT)
641 BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));
651 seqUninstallRollback;
660 bool bRollbackEnabled = MsiEvaluateCondition(hInstall, L
"RollbackDisabled") != MSICONDITION_TRUE;
663 MSIHANDLE hDatabase = MsiGetActiveDatabase(hInstall);
666 msg(
M_NONFATAL,
"%s: MsiGetActiveDatabase failed", __FUNCTION__);
667 uiResult = ERROR_INVALID_HANDLE;
668 goto cleanup_exec_seq;
672 switch (MsiDatabaseIsTablePersistent(hDatabase, L
"TUNTAPAdapter"))
674 case MSICONDITION_FALSE:
675 case MSICONDITION_TRUE:
break;
678 uiResult = ERROR_SUCCESS;
679 goto cleanup_hDatabase;
683 MSIHANDLE hViewST = 0;
684 LPCWSTR szQuery = L
"SELECT `Adapter`,`DisplayName`,`Condition`,`Component_`,`HardwareId` FROM `TUNTAPAdapter`";
685 uiResult = MsiDatabaseOpenView(hDatabase, szQuery, &hViewST);
686 if (uiResult != ERROR_SUCCESS)
688 SetLastError(uiResult);
690 goto cleanup_hDatabase;
694 uiResult = MsiViewExecute(hViewST, 0);
695 if (uiResult != ERROR_SUCCESS)
697 SetLastError(uiResult);
699 goto cleanup_hViewST;
703 MSIHANDLE hRecordProg = MsiCreateRecord(2);
706 uiResult = ERROR_INVALID_HANDLE;
708 goto cleanup_hViewST_close;
714 MSIHANDLE hRecord = 0;
715 uiResult = MsiViewFetch(hViewST, &hRecord);
716 if (uiResult == ERROR_NO_MORE_ITEMS)
718 uiResult = ERROR_SUCCESS;
721 else if (uiResult != ERROR_SUCCESS)
723 SetLastError(uiResult);
725 goto cleanup_hRecordProg;
728 INSTALLSTATE iInstalled, iAction;
731 LPWSTR szValue = NULL;
733 if (uiResult != ERROR_SUCCESS)
735 goto cleanup_hRecord;
739 uiResult = MsiGetComponentState(hInstall, szValue, &iInstalled, &iAction);
740 if (uiResult != ERROR_SUCCESS)
742 SetLastError(uiResult);
745 goto cleanup_hRecord;
751 LPWSTR szDisplayName = NULL;
753 if (uiResult != ERROR_SUCCESS)
755 goto cleanup_hRecord;
758 LPWSTR szDisplayNameEx = wcschr(szDisplayName, L
'|');
759 szDisplayNameEx = szDisplayNameEx != NULL ? szDisplayNameEx + 1 : szDisplayName;
762 WCHAR szzHardwareIDs[0x100] = { 0 };
764 LPWSTR szHwId = NULL;
766 if (uiResult != ERROR_SUCCESS)
768 goto cleanup_szDisplayName;
770 memcpy_s(szzHardwareIDs,
sizeof(szzHardwareIDs) - 2*
sizeof(WCHAR) , szHwId, wcslen(szHwId)*
sizeof(WCHAR));
774 if (iAction > INSTALLSTATE_BROKEN)
778 if (iAction >= INSTALLSTATE_LOCAL)
781 LPWSTR szValue = NULL;
783 if (uiResult != ERROR_SUCCESS)
785 goto cleanup_szDisplayName;
787#if defined(__GNUC__) || defined(__clang__)
792#pragma GCC diagnostic push
793#pragma GCC diagnostic ignored "-Wswitch"
795 switch (MsiEvaluateCondition(hInstall, szValue))
797 case MSICONDITION_FALSE:
799 goto cleanup_szDisplayName;
801 case MSICONDITION_ERROR:
802 uiResult = ERROR_INVALID_FIELD;
805 goto cleanup_szDisplayName;
807#if defined(__GNUC__) || defined(__clang__)
808#pragma GCC diagnostic pop
815 bRollbackEnabled ? &seqInstallRollback : NULL,
818 &iTicks) != ERROR_SUCCESS)
820 uiResult = ERROR_INSTALL_FAILED;
821 goto cleanup_szDisplayName;
833 bRollbackEnabled ? &seqUninstallCommit : NULL,
834 bRollbackEnabled ? &seqUninstallRollback : NULL,
842 MsiRecordSetInteger(hRecordProg, 1, 3 );
843 MsiRecordSetInteger(hRecordProg, 2, iTicks);
844 if (MsiProcessMessage(hInstall, INSTALLMESSAGE_PROGRESS, hRecordProg) == IDCANCEL)
846 uiResult = ERROR_INSTALL_USEREXIT;
847 goto cleanup_szDisplayName;
851cleanup_szDisplayName:
854 MsiCloseHandle(hRecord);
855 if (uiResult != ERROR_SUCCESS)
857 goto cleanup_hRecordProg;
862 WCHAR tmpDir[MAX_PATH];
863 GetTempPath(MAX_PATH, tmpDir);
865 WCHAR str[MAX_PATH + 7];
866 swprintf_s(str, _countof(str), L
"tmpdir=%ls", tmpDir);
875 if ((uiResult =
setup_sequence(hInstall, L
"InstallTUNTAPAdapters", &seqInstall )) != ERROR_SUCCESS
876 || (uiResult =
setup_sequence(hInstall, L
"InstallTUNTAPAdaptersCommit", &seqInstallCommit )) != ERROR_SUCCESS
877 || (uiResult =
setup_sequence(hInstall, L
"InstallTUNTAPAdaptersRollback", &seqInstallRollback )) != ERROR_SUCCESS
878 || (uiResult =
setup_sequence(hInstall, L
"UninstallTUNTAPAdapters", &seqUninstall )) != ERROR_SUCCESS
879 || (uiResult =
setup_sequence(hInstall, L
"UninstallTUNTAPAdaptersCommit", &seqUninstallCommit )) != ERROR_SUCCESS
880 || (uiResult =
setup_sequence(hInstall, L
"UninstallTUNTAPAdaptersRollback", &seqUninstallRollback)) != ERROR_SUCCESS)
882 goto cleanup_hRecordProg;
885 uiResult = ERROR_SUCCESS;
888 MsiCloseHandle(hRecordProg);
889cleanup_hViewST_close:
890 MsiViewClose(hViewST);
892 MsiCloseHandle(hViewST);
894 MsiCloseHandle(hDatabase);
902 if (bIsCoInitialized)
944 WCHAR path[MAX_PATH];
947 msg(
M_WARN,
"%s: Reboot required, create reboot indication file \"%ls\"", __FUNCTION__, path);
949 HANDLE file = CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
950 if (file == INVALID_HANDLE_VALUE)
964#pragma comment(linker, DLLEXP_EXPORT)
970 BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));
971 WCHAR tmpDir[MAX_PATH] = {0};
975 BOOL bIsCleanup = MsiGetMode(hInstall, MSIRUNMODE_COMMIT) || MsiGetMode(hInstall, MSIRUNMODE_ROLLBACK);
978 LPWSTR szSequence = NULL;
979 uiResult =
msi_get_string(hInstall, L
"CustomActionData", &szSequence);
980 if (uiResult != ERROR_SUCCESS)
982 goto cleanup_CoInitialize;
985 LPWSTR *szArg = CommandLineToArgvW(szSequence, &nArgs);
988 uiResult = GetLastError();
990 goto cleanup_szSequence;
994 MSIHANDLE hRecordProg = MsiCreateRecord(3);
995 MsiRecordSetInteger(hRecordProg, 1, 1);
996 MsiRecordSetInteger(hRecordProg, 2, 1);
997 MsiRecordSetInteger(hRecordProg, 3, 0);
998 MsiProcessMessage(hInstall, INSTALLMESSAGE_PROGRESS, hRecordProg);
1001 MsiRecordSetInteger(hRecordProg, 1, 2);
1002 MsiRecordSetInteger(hRecordProg, 3, 0);
1004 BOOL bRebootRequired = FALSE;
1006 for (
int i = 1 ; i < nArgs; ++i)
1008 DWORD dwResult = ERROR_SUCCESS;
1010 if (wcsncmp(szArg[i], L
"create=", 7) == 0)
1013 LPWSTR szName = szArg[i] + 7;
1014 LPWSTR szHardwareId = wcschr(szName, L
'|');
1015 if (szHardwareId == NULL)
1017 goto invalid_argument;
1019 szHardwareId[0] = 0;
1024 MSIHANDLE hRecord = MsiCreateRecord(4);
1025 MsiRecordSetString(hRecord, 1, L
"Creating adapter");
1026 MsiRecordSetString(hRecord, 2, szName);
1027 MsiRecordSetString(hRecord, 3, szHardwareId);
1028 int iResult = MsiProcessMessage(hInstall, INSTALLMESSAGE_ACTIONDATA, hRecord);
1029 MsiCloseHandle(hRecord);
1030 if (iResult == IDCANCEL)
1032 uiResult = ERROR_INSTALL_USEREXIT;
1038 dwResult =
tap_create_adapter(NULL, NULL, szHardwareId, &bRebootRequired, &guidAdapter);
1039 if (dwResult == ERROR_SUCCESS)
1046 else if (wcsncmp(szArg[i], L
"deleteN=", 8) == 0)
1049 LPCWSTR szName = szArg[i] + 8;
1053 MSIHANDLE hRecord = MsiCreateRecord(3);
1054 MsiRecordSetString(hRecord, 1, L
"Deleting adapter");
1055 MsiRecordSetString(hRecord, 2, szName);
1056 int iResult = MsiProcessMessage(hInstall, INSTALLMESSAGE_ACTIONDATA, hRecord);
1057 MsiCloseHandle(hRecord);
1058 if (iResult == IDCANCEL)
1060 uiResult = ERROR_INSTALL_USEREXIT;
1068 if (dwResult == ERROR_SUCCESS)
1071 for (
struct tap_adapter_node *pAdapter = pAdapterList; pAdapter != NULL; pAdapter = pAdapter->
pNext)
1073 if (wcsicmp(
szName, pAdapter->szName) == 0)
1084 else if (wcsncmp(szArg[i], L
"delete=", 7) == 0)
1090 goto invalid_argument;
1094 else if (wcsncmp(szArg[i], L
"enable=", 7) == 0)
1100 goto invalid_argument;
1104 else if (wcsncmp(szArg[i], L
"disable=", 8) == 0)
1110 goto invalid_argument;
1114 else if (wcsncmp(szArg[i], L
"tmpdir=", 7) == 0)
1116 wcscpy_s(tmpDir, _countof(tmpDir), szArg[i] + 7);
1120 goto invalid_argument;
1123 if (dwResult != ERROR_SUCCESS && !bIsCleanup )
1125 uiResult = ERROR_INSTALL_FAILURE;
1131 if (MsiProcessMessage(hInstall, INSTALLMESSAGE_PROGRESS, hRecordProg) == IDCANCEL)
1133 dwResult = ERROR_INSTALL_USEREXIT;
1140 msg(
M_NONFATAL,
"%s: Ignoring invalid argument: %ls", __FUNCTION__, szArg[i]);
1144 if (bRebootRequired && wcslen(tmpDir) > 0)
1148 MsiCloseHandle(hRecordProg);
1152cleanup_CoInitialize:
1153 if (bIsCoInitialized)
1164#pragma comment(linker, DLLEXP_EXPORT)
1169 BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));
1174 WCHAR tempPath[MAX_PATH];
1175 GetTempPathW(MAX_PATH, tempPath);
1178 WCHAR path[MAX_PATH];
1180 WIN32_FIND_DATA data = { 0 };
1181 HANDLE searchHandle = FindFirstFileW(path, &data);
1182 if (searchHandle != INVALID_HANDLE_VALUE)
1184 msg(
M_WARN,
"%s: Reboot file exists, schedule reboot", __FUNCTION__);
1186 FindClose(searchHandle);
1189 MsiSetMode(hInstall, MSIRUNMODE_REBOOTATEND, TRUE);
1192 if (bIsCoInitialized)
1196 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)