@@ -38,12 +38,18 @@ static std::string getDateString(bool filesafe) {
38
38
return oss.str ();
39
39
}
40
40
41
- static std::string getModuleName (HMODULE module , bool fullPath = true ) {
41
+ static std::string getModuleName (HMODULE module , bool fullPath = true , bool shortKnown = false ) {
42
42
char buffer[MAX_PATH];
43
43
if (!GetModuleFileNameA (module , buffer, MAX_PATH)) {
44
44
return " <Unknown>" ;
45
45
}
46
46
if (fullPath) {
47
+ if (shortKnown) {
48
+ auto gdDir = utils::string::wideToUtf8 (dirs::getGameDir ().wstring ());
49
+ if (std::string_view (buffer).starts_with (gdDir)) {
50
+ return std::filesystem::path (buffer).filename ().string ();
51
+ }
52
+ }
47
53
return buffer;
48
54
}
49
55
return std::filesystem::path (buffer).filename ().string ();
@@ -129,7 +135,7 @@ static void printAddr(std::ostream& stream, void const* addr, bool fullPath = tr
129
135
)) {
130
136
// calculate base + [address]
131
137
auto const diff = reinterpret_cast <uintptr_t >(addr) - reinterpret_cast <uintptr_t >(module );
132
- stream << getModuleName (module , fullPath) << " + " << std::hex << diff << std::dec;
138
+ stream << getModuleName (module , fullPath, true ) << " + " << std::hex << diff << std::dec;
133
139
134
140
// log symbol if possible
135
141
if (g_symbolsInitialized) {
@@ -248,7 +254,7 @@ static std::string getStacktrace(PCONTEXT context, Mod*& suspectedFaultyMod) {
248
254
return ret;
249
255
}
250
256
return SymFunctionTableAccess64 (hProcess, AddrBase);
251
- },
257
+ },
252
258
+[](HANDLE hProcess, DWORD64 dwAddr) -> DWORD64 {
253
259
auto ret = GeodeFunctionTableAccess64 (hProcess, dwAddr);
254
260
if (ret) {
@@ -510,14 +516,14 @@ static void handleException(LPEXCEPTION_POINTERS info) {
510
516
}
511
517
else {
512
518
// set the search path to include the mods' temp directories
513
- if (std::array<char , 4096 > searchPathBuffer;
519
+ if (std::array<char , 4096 > searchPathBuffer;
514
520
SymGetSearchPath (static_cast <HMODULE>(GetCurrentProcess ()), searchPathBuffer.data (), searchPathBuffer.size ())) {
515
521
std::string searchPath (searchPathBuffer.data ());
516
522
searchPath += " ;" + g_unzippedSearchPaths;
517
523
SymSetSearchPath (static_cast <HMODULE>(GetCurrentProcess ()), searchPath.c_str ());
518
524
}
519
525
}
520
-
526
+
521
527
// in some cases, we can be pretty certain that the first mod found while unwinding
522
528
// is the one that caused the crash, so using `suspectedFaultyMod` is safe and correct.
523
529
//
0 commit comments