mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-14 19:15:05 -05:00
Windows stacktrace fix (#925)
* fix the windows hook exceptions * update tuliphook * update tuliphook * remove old code --------- Co-authored-by: altalk23 <45172705+altalk23@users.noreply.github.com> Co-authored-by: dankmeme01 <42031238+dankmeme01@users.noreply.github.com> Co-authored-by: mat <26722564+matcool@users.noreply.github.com>
This commit is contained in:
parent
815c4a31d8
commit
70fe096724
2 changed files with 21 additions and 4 deletions
|
@ -239,7 +239,7 @@ if (DEFINED GEODE_TULIPHOOK_REPO_PATH)
|
|||
message(STATUS "Using ${GEODE_TULIPHOOK_REPO_PATH} for TulipHook")
|
||||
add_subdirectory(${GEODE_TULIPHOOK_REPO_PATH} ${GEODE_TULIPHOOK_REPO_PATH}/build)
|
||||
else()
|
||||
CPMAddPackage("gh:geode-sdk/TulipHook#1ecee12")
|
||||
CPMAddPackage("gh:geode-sdk/TulipHook#e15aaee")
|
||||
endif()
|
||||
set(CMAKE_WARN_DEPRECATED ON CACHE BOOL "" FORCE)
|
||||
|
||||
|
|
|
@ -144,10 +144,13 @@ static void printAddr(std::ostream& stream, void const* addr, bool fullPath = tr
|
|||
}
|
||||
}
|
||||
|
||||
PVOID CustomFunctionTableAccess64(HANDLE hProcess, DWORD64 AddrBase);
|
||||
|
||||
// https://stackoverflow.com/a/50208684/9124836
|
||||
static std::string getStacktrace(PCONTEXT context) {
|
||||
std::stringstream stream;
|
||||
STACKFRAME64 stack;
|
||||
static STACKFRAME64 stack;
|
||||
static PCONTEXT pcontext = context;
|
||||
memset(&stack, 0, sizeof(STACKFRAME64));
|
||||
|
||||
auto process = GetCurrentProcess();
|
||||
|
@ -159,7 +162,7 @@ static std::string getStacktrace(PCONTEXT context) {
|
|||
#else
|
||||
stack.AddrPC.Offset = context->Rip;
|
||||
stack.AddrStack.Offset = context->Rsp;
|
||||
stack.AddrFrame.Offset = context->Rbp;
|
||||
stack.AddrFrame.Offset = context->Rdi;
|
||||
#endif
|
||||
|
||||
stack.AddrPC.Mode = AddrModeFlat;
|
||||
|
@ -170,7 +173,21 @@ static std::string getStacktrace(PCONTEXT context) {
|
|||
while (true) {
|
||||
if (!StackWalk64(
|
||||
IMAGE_FILE_MACHINE_AMD64, process, thread, &stack, context, nullptr,
|
||||
SymFunctionTableAccess64, SymGetModuleBase64, nullptr
|
||||
+[](HANDLE hProcess, DWORD64 AddrBase) {
|
||||
auto ret = CustomFunctionTableAccess64(hProcess, AddrBase);
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
return SymFunctionTableAccess64(hProcess, AddrBase);
|
||||
},
|
||||
+[](HANDLE hProcess, DWORD64 dwAddr) -> DWORD64 {
|
||||
auto ret = CustomFunctionTableAccess64(hProcess, dwAddr);
|
||||
if (ret) {
|
||||
return dwAddr & (~0xffffull);
|
||||
}
|
||||
return SymGetModuleBase64(hProcess, dwAddr);
|
||||
}
|
||||
, nullptr
|
||||
))
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in a new issue