diff --git a/loader/src/platform/windows/main.cpp b/loader/src/platform/windows/main.cpp index 084d64e97..9f91f880c 100644 --- a/loader/src/platform/windows/main.cpp +++ b/loader/src/platform/windows/main.cpp @@ -372,11 +372,23 @@ DWORD WINAPI upgradeThread(void*) { return 0; } +DWORD WINAPI earlyErrorThread(void* param) { + auto* msg = reinterpret_cast(param); + console::messageBox("Unable to Load Geode!", *msg); + delete msg; + return 0; +} + void earlyError(std::string message) { // try to write a file and display a message box // wine might not display the message box but *should* write a file (void) utils::file::writeString("_geode_early_error.txt", message); - console::messageBox("Unable to Load Geode!", message); + + // show the error after dllmain returns and the loader lock releases + CreateThread( + nullptr, 0, earlyErrorThread, + new std::string(message), 0, nullptr + ); } BOOL WINAPI DllMain(HINSTANCE module, DWORD reason, LPVOID) { @@ -392,7 +404,12 @@ BOOL WINAPI DllMain(HINSTANCE module, DWORD reason, LPVOID) { std::error_code error; bool oldBootstrapperExists = std::filesystem::exists(workingDir / "GeodeBootstrapper.dll", error); if (error) { - earlyError("There was an error checking whether the old GeodeBootstrapper.dll exists: " + error.message()); + // can't use a thread here, dll is about to unload + console::messageBox( + "Unable to Load Geode!", + "There was an error checking whether the old " + "GeodeBootstrapper.dll exists: " + error.message() + ); return FALSE; } else if (oldBootstrapperExists)