Browse Source

UI/updater: Exit with error if elevation failed

In rare cases, "runas" would somehow launch the updater as a non-admin user
again, resulting in a loop where the updater constantly spawns processes.
Fixes https://github.com/obsproject/obs-studio/issues/2984
Richard Stanway 5 years ago
parent
commit
f26941b566
1 changed files with 11 additions and 0 deletions
  1. 11 0
      UI/win-update/updater/updater.cpp

+ 11 - 0
UI/win-update/updater/updater.cpp

@@ -1629,6 +1629,17 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpCmdLine, int)
 	is32bit = wcsstr(cwd, L"bin\\32bit") != nullptr;
 
 	if (!HasElevation()) {
+
+		WinHandle hMutex = OpenMutex(
+			SYNCHRONIZE, false, L"OBSUpdaterRunningAsNonAdminUser");
+		if (hMutex) {
+			MessageBox(
+				nullptr, L"Updater Error",
+				L"OBS Studio Updater must be run as an administrator.",
+				MB_ICONWARNING);
+			return 2;
+		}
+
 		HANDLE hLowMutex = CreateMutexW(
 			nullptr, true, L"OBSUpdaterRunningAsNonAdminUser");