mirror of
https://gitlab.com/Mr_Goldberg/goldberg_emulator.git
synced 2024-11-23 20:38:07 +01:00
Fix overlay crash in games that load then unload steam api dll.
This commit is contained in:
parent
e0726f2e9d
commit
7c419e0afe
5 changed files with 40 additions and 2 deletions
|
@ -830,6 +830,11 @@ bool Steam_Client::BShutdownIfAllPipesClosed()
|
||||||
}
|
}
|
||||||
|
|
||||||
steam_controller->Shutdown();
|
steam_controller->Shutdown();
|
||||||
|
#ifdef EMU_OVERLAY
|
||||||
|
if(!settings_client->disable_overlay)
|
||||||
|
steam_overlay->UnSetupOverlay();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (joinable) {
|
if (joinable) {
|
||||||
background_keepalive.join();
|
background_keepalive.join();
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,10 @@ public:
|
||||||
delete vulkan_hook;
|
delete vulkan_hook;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool force_stop_detection;
|
||||||
|
std::condition_variable detect_renderer_thread_cv;
|
||||||
|
std::mutex destroy_render_thread_mutex;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Renderer_Detector():
|
Renderer_Detector():
|
||||||
dxgi_hooked(false),
|
dxgi_hooked(false),
|
||||||
|
@ -94,7 +98,8 @@ private:
|
||||||
dx12_hook(nullptr),
|
dx12_hook(nullptr),
|
||||||
opengl_hook(nullptr),
|
opengl_hook(nullptr),
|
||||||
vulkan_hook(nullptr),
|
vulkan_hook(nullptr),
|
||||||
detection_done(false)
|
detection_done(false),
|
||||||
|
force_stop_detection(false)
|
||||||
{
|
{
|
||||||
std::wstring tmp(4096, L'\0');
|
std::wstring tmp(4096, L'\0');
|
||||||
tmp.resize(GetSystemDirectoryW(&tmp[0], tmp.size()));
|
tmp.resize(GetSystemDirectoryW(&tmp[0], tmp.size()));
|
||||||
|
@ -1064,6 +1069,9 @@ public:
|
||||||
auto start_time = std::chrono::steady_clock::now();
|
auto start_time = std::chrono::steady_clock::now();
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
std::unique_lock<std::mutex> lck(destroy_render_thread_mutex);
|
||||||
|
if (force_stop_detection) break;
|
||||||
|
|
||||||
for (auto const& library : libraries)
|
for (auto const& library : libraries)
|
||||||
{
|
{
|
||||||
void* lib_handle = System::Library::GetLibraryHandle(library.first.c_str());
|
void* lib_handle = System::Library::GetLibraryHandle(library.first.c_str());
|
||||||
|
@ -1074,7 +1082,10 @@ public:
|
||||||
(this->*library.second)(name);
|
(this->*library.second)(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds{ 100 });
|
|
||||||
|
detect_renderer_thread_cv.wait_for(lck, std::chrono::milliseconds(100));
|
||||||
|
if (force_stop_detection) break;
|
||||||
|
|
||||||
} while (!detection_done && (timeout.count() == -1 || (std::chrono::steady_clock::now() - start_time) <= timeout));
|
} while (!detection_done && (timeout.count() == -1 || (std::chrono::steady_clock::now() - start_time) <= timeout));
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1415,3 +1426,11 @@ std::future<Renderer_Hook*> detect_renderer(std::chrono::milliseconds timeout)
|
||||||
{
|
{
|
||||||
return std::async(std::launch::async, &Renderer_Detector::detect_renderer, Renderer_Detector::Inst(), timeout);
|
return std::async(std::launch::async, &Renderer_Detector::detect_renderer, Renderer_Detector::Inst(), timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void stop_renderer_detector()
|
||||||
|
{
|
||||||
|
Renderer_Detector::Inst()->destroy_render_thread_mutex.lock();
|
||||||
|
Renderer_Detector::Inst()->force_stop_detection = true;
|
||||||
|
Renderer_Detector::Inst()->destroy_render_thread_mutex.unlock();
|
||||||
|
Renderer_Detector::Inst()->detect_renderer_thread_cv.notify_all();
|
||||||
|
}
|
||||||
|
|
|
@ -28,3 +28,4 @@
|
||||||
#include "Renderer_Hook.h"
|
#include "Renderer_Hook.h"
|
||||||
|
|
||||||
std::future<Renderer_Hook*> detect_renderer(std::chrono::milliseconds timeout = std::chrono::milliseconds{-1});
|
std::future<Renderer_Hook*> detect_renderer(std::chrono::milliseconds timeout = std::chrono::milliseconds{-1});
|
||||||
|
void stop_renderer_detector();
|
||||||
|
|
|
@ -200,6 +200,17 @@ void Steam_Overlay::SetupOverlay()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Steam_Overlay::UnSetupOverlay()
|
||||||
|
{
|
||||||
|
stop_renderer_detector();
|
||||||
|
if (!Ready() && future_renderer.valid()) {
|
||||||
|
if (future_renderer.wait_for(std::chrono::milliseconds{500}) == std::future_status::ready) {
|
||||||
|
future_renderer.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Steam_Overlay::HookReady(bool ready)
|
void Steam_Overlay::HookReady(bool ready)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
|
|
@ -161,6 +161,7 @@ public:
|
||||||
|
|
||||||
void SetNotificationInset(int nHorizontalInset, int nVerticalInset);
|
void SetNotificationInset(int nHorizontalInset, int nVerticalInset);
|
||||||
void SetupOverlay();
|
void SetupOverlay();
|
||||||
|
void UnSetupOverlay();
|
||||||
|
|
||||||
void HookReady(bool ready);
|
void HookReady(bool ready);
|
||||||
|
|
||||||
|
@ -202,6 +203,7 @@ public:
|
||||||
|
|
||||||
void SetNotificationInset(int nHorizontalInset, int nVerticalInset) {}
|
void SetNotificationInset(int nHorizontalInset, int nVerticalInset) {}
|
||||||
void SetupOverlay() {}
|
void SetupOverlay() {}
|
||||||
|
void UnSetupOverlay() {}
|
||||||
|
|
||||||
void HookReady(bool ready) {}
|
void HookReady(bool ready) {}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue