Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions loader/src/platform/windows/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,23 @@ DWORD WINAPI upgradeThread(void*) {
return 0;
}

DWORD WINAPI earlyErrorThread(void* param) {
auto* msg = reinterpret_cast<std::string*>(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) {
Expand All @@ -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)
Expand Down