diff options
author | Simon Rozman <simon@rozman.si> | 2020-11-16 20:06:40 +0100 |
---|---|---|
committer | Simon Rozman <simon@rozman.si> | 2020-11-16 20:07:27 +0100 |
commit | 572b823dd674abb1fdb0ded3aa57f5a8600b802f (patch) | |
tree | 4bb0b2a881975cdb859a696d22dfdb8577ff3c15 | |
parent | installer: add missing thread handle close (diff) | |
download | wireguard-windows-572b823dd674abb1fdb0ded3aa57f5a8600b802f.tar.xz wireguard-windows-572b823dd674abb1fdb0ded3aa57f5a8600b802f.zip |
installer: launch GUI before attempting a reinstall
With the recently introduced wireguard-installer.exe an issue in MSI
internal caching appeared. With the temporary MSI file used at install
time gone, the MSI was unable to load our custom actions in the
reinstall attempt.
Rather than attempting to reinstall the product and fail, the MSI was
upgraded to launch GUI early in the reinstall attempt and cancel the
execute sequence then.
Signed-off-by: Simon Rozman <simon@rozman.si>
-rw-r--r-- | installer/customactions.c | 26 | ||||
-rw-r--r-- | installer/wireguard.wxs | 16 |
2 files changed, 34 insertions, 8 deletions
diff --git a/installer/customactions.c b/installer/customactions.c index 72ee0ae3..b7aee8c1 100644 --- a/installer/customactions.c +++ b/installer/customactions.c @@ -82,6 +82,32 @@ static void log_errorf(MSIHANDLE installer, enum log_level level, DWORD error_co LocalFree(system_message); } +__declspec(dllexport) UINT __stdcall LaunchApplicationAndAbort(MSIHANDLE installer) +{ + UINT ret = ERROR_INSTALL_FAILURE; + TCHAR path[MAX_PATH]; + DWORD path_len = _countof(path); + PROCESS_INFORMATION pi; + STARTUPINFO si = { .cb = sizeof(STARTUPINFO) }; + + ret = MsiGetProperty(installer, TEXT("WireGuardFolder"), path, &path_len); + if (ret != ERROR_SUCCESS) { + log_errorf(installer, LOG_LEVEL_WARN, ret, TEXT("MsiGetProperty(\"WireGuardFolder\") failed")); + goto out; + } + if (!path[0] || !PathAppend(path, TEXT("wireguard.exe"))) + goto out; + log_messagef(installer, LOG_LEVEL_INFO, TEXT("Launching %1"), path); + if (!CreateProcess(path, TEXT("wireguard"), NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi)) { + log_errorf(installer, LOG_LEVEL_WARN, GetLastError(), TEXT("Failed to create \"%1\" process"), path); + goto out; + } + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); +out: + return ERROR_INSTALL_USEREXIT; +} + static UINT insert_service_control(MSIHANDLE installer, MSIHANDLE view, const TCHAR *service_name, bool start) { static unsigned int index = 0; diff --git a/installer/wireguard.wxs b/installer/wireguard.wxs index 71445560..2757c882 100644 --- a/installer/wireguard.wxs +++ b/installer/wireguard.wxs @@ -108,6 +108,14 @@ </InstallExecuteSequence> <!-- + Launch wireguard.exe on product reconfiguration (starting same MSI again) + --> + <CustomAction Id="LaunchApplicationAndAbort" BinaryKey="customactions.dll" DllEntry="LaunchApplicationAndAbort" /> + <InstallExecuteSequence> + <Custom Action="LaunchApplicationAndAbort" After="CostFinalize">ProductState=5 AND NOT REMOVE AND NOT DO_NOT_LAUNCH</Custom> + </InstallExecuteSequence> + + <!-- Evaluate WireGuard services and populate ServiceControl table --> <CustomAction Id="EvaluateWireGuardServices" BinaryKey="customactions.dll" DllEntry="EvaluateWireGuardServices" /> @@ -154,13 +162,5 @@ <InstallExecuteSequence> <Custom Action="LaunchApplication" Before="InstallFinalize">(&WireGuardFeature = 3) AND NOT DO_NOT_LAUNCH</Custom> </InstallExecuteSequence> - - <!-- - Launch wireguard.exe on product reconfiguration (starting same MSI again) - --> - <CustomAction Id="LaunchApplicationAsOrdinaryUser" HideTarget="yes" FileKey="wireguard.exe" ExeCommand="" Return="asyncNoWait" /> - <InstallExecuteSequence> - <Custom Action="LaunchApplicationAsOrdinaryUser" After="InstallFinalize">(&WireGuardFeature = -1) AND (!WireGuardFeature = 3) AND NOT DO_NOT_LAUNCH</Custom> - </InstallExecuteSequence> </Product> </Wix> |