Skip to content

Commit e558bd3

Browse files
committed
add temp dirs to the search path
1 parent d0ae0f3 commit e558bd3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

loader/src/platform/windows/crashlog.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ using namespace geode::prelude;
2323

2424
static bool g_lastLaunchCrashed = false;
2525
static bool g_symbolsInitialized = false;
26+
static std::string g_unzippedSearchPaths;
2627

2728
static std::string getDateString(bool filesafe) {
2829
auto const now = std::time(nullptr);
@@ -478,6 +479,15 @@ static void handleException(LPEXCEPTION_POINTERS info) {
478479
if (!g_symbolsInitialized) {
479480
log::warn("Failed to initialize debug symbols: Error {}", GetLastError());
480481
}
482+
else {
483+
// set the search path to include the mods' temp directories
484+
if (std::array<char, 4096> searchPathBuffer;
485+
SymGetSearchPath(static_cast<HMODULE>(GetCurrentProcess()), searchPathBuffer.data(), searchPathBuffer.size())) {
486+
std::string searchPath(searchPathBuffer.data());
487+
searchPath += ";" + g_unzippedSearchPaths;
488+
SymSetSearchPath(static_cast<HMODULE>(GetCurrentProcess()), searchPath.c_str());
489+
}
490+
}
481491

482492
// in some cases, we can be pretty certain that the first mod found while unwinding
483493
// is the one that caused the crash, so using `suspectedFaultyMod` is safe and correct.
@@ -521,6 +531,11 @@ static LONG WINAPI exceptionHandler(LPEXCEPTION_POINTERS info) {
521531
bool crashlog::setupPlatformHandler() {
522532
SetUnhandledExceptionFilter(exceptionHandler);
523533

534+
g_unzippedSearchPaths.clear();
535+
for (auto& mod : Loader::get()->getAllMods()) {
536+
g_unzippedSearchPaths += mod->getTempDir().string() + ";";
537+
}
538+
524539
auto lastCrashedFile = crashlog::getCrashLogDirectory() / "last-crashed";
525540
if (std::filesystem::exists(lastCrashedFile)) {
526541
g_lastLaunchCrashed = true;

0 commit comments

Comments
 (0)