From dc170d7a179f430ea8627ee1c5af2b642f92a4ae Mon Sep 17 00:00:00 2001 From: dankmeme01 <42031238+dankmeme01@users.noreply.github.com> Date: Wed, 11 Sep 2024 15:21:42 +0200 Subject: [PATCH] temp workaround to fix crashes on wine --- loader/src/platform/windows/console.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/loader/src/platform/windows/console.cpp b/loader/src/platform/windows/console.cpp index ce0c06337..5157c53b3 100644 --- a/loader/src/platform/windows/console.cpp +++ b/loader/src/platform/windows/console.cpp @@ -94,6 +94,14 @@ bool redirectStd(FILE* which, std::string const& name, const Severity sev) { return true; } +static bool isWine() { + if (auto mod = GetModuleHandle("ntdll.dll")) { + return GetProcAddress(mod, "wine_get_version") != nullptr; + } + + return false; +} + void console::setup() { // if the game launched from a console or with a console already attached, // this is where we find that out and save its handle @@ -117,7 +125,8 @@ void console::setup() { // count == 0 => not a console and not a file, assume it's closed // wine does something weird with /dev/null? not sure tbh but it's definitely up to no good - if ((count == 0 || path.ends_with("\\dev\\null"))) { + // TODO: the isWine check is pretty hacky but without it the game does not launch at all and i cba to figure it out rn + if ((count == 0 || path.ends_with("\\dev\\null")) && !isWine()) { s_outHandle = nullptr; CloseHandle(GetStdHandle(STD_OUTPUT_HANDLE)); CloseHandle(GetStdHandle(STD_INPUT_HANDLE));