From b7f2c993a373311d0fae6f73f4d5a4a1af551e4f Mon Sep 17 00:00:00 2001 From: NeKz Date: Sat, 16 Sep 2023 01:45:33 +0100 Subject: [PATCH] fix: clean up of VEH --- src/CrashHandler.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/CrashHandler.cpp b/src/CrashHandler.cpp index b73c0c059..f57b13c67 100644 --- a/src/CrashHandler.cpp +++ b/src/CrashHandler.cpp @@ -172,10 +172,11 @@ static void handler(int signal, siginfo_t *info, void *ucontext) } #ifdef _WIN32 +static PVOID g_handle = nullptr; void CrashHandler::Init() { g_isMainThread = true; - AddVectoredExceptionHandler(1, &handler); + g_handle = AddVectoredExceptionHandler(1, &handler); HANDLE process = GetCurrentProcess(); SymInitialize(process, 0, true); @@ -189,7 +190,7 @@ void CrashHandler::Cleanup() { HANDLE process = GetCurrentProcess(); SymGetModuleInfo(process, (DWORD)&Utils::GetSARPath, &info); SymUnloadModule(process, info.BaseOfImage); - RemoveVectoredExceptionHandler(&handler); + RemoveVectoredExceptionHandler(g_handle); SymCleanup(GetCurrentProcess()); }