obs-StreamFX/source/windll.cpp
Michael Fabian 'Xaymar' Dirks 9d0233a740 code: Create mutexes to prevent Windows (un)installer from continuing
Might fix the problem where people uninstall StreamFX while they still have OBS Studio open with StreamFX loaded. InnoSetup appears to ignore this in /VERYSILENT, so this is an additional guard against that.
2023-05-20 19:24:06 +02:00

28 lines
841 B
C++

// AUTOGENERATED COPYRIGHT HEADER START
// Copyright (C) 2020-2023 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
// AUTOGENERATED COPYRIGHT HEADER END
#include "warning-disable.hpp"
#include <Windows.h>
#include <mutex>
#include "warning-enable.hpp"
std::shared_ptr<void> local_mutex;
std::shared_ptr<void> global_mutex;
BOOL WINAPI DllMain(HINSTANCE, DWORD dwReason, LPVOID)
{
if (dwReason == DLL_PROCESS_ATTACH) {
// Prevent installer from progressing while StreamFX is still active.
local_mutex = std::shared_ptr<void>(CreateMutexW(NULL, TRUE, L"Local\\StreamFX-Setup"), [](HANDLE p) {
ReleaseMutex(p);
CloseHandle(p);
});
global_mutex = std::shared_ptr<void>(CreateMutexW(NULL, TRUE, L"Global\\StreamFX-Setup"), [](HANDLE p) {
ReleaseMutex(p);
CloseHandle(p);
});
}
return TRUE;
}