From 524d100bdcc0a97e27f95ebeb7843ccb9d6dc79b Mon Sep 17 00:00:00 2001 From: goaaats Date: Wed, 18 May 2022 18:33:34 +0200 Subject: [PATCH] chore: change VEH env var, add var to enable full dumps --- Dalamud.Boot/dllmain.cpp | 25 ++++++++++++++++++++++--- Dalamud.Boot/veh.cpp | 17 ++++++++++++----- Dalamud.Boot/veh.h | 2 +- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/Dalamud.Boot/dllmain.cpp b/Dalamud.Boot/dllmain.cpp index cb2fa9226..33344eecf 100644 --- a/Dalamud.Boot/dllmain.cpp +++ b/Dalamud.Boot/dllmain.cpp @@ -33,12 +33,31 @@ bool is_running_on_linux() bool is_veh_enabled() { size_t required_size; - getenv_s(&required_size, nullptr, 0, "DALAMUD_IS_STAGING"); + getenv_s(&required_size, nullptr, 0, "DALAMUD_IS_VEH"); if (required_size > 0) { if (char* is_no_veh = static_cast(malloc(required_size * sizeof(char)))) { - getenv_s(&required_size, is_no_veh, required_size, "DALAMUD_IS_STAGING"); + getenv_s(&required_size, is_no_veh, required_size, "DALAMUD_IS_VEH"); + auto result = _stricmp(is_no_veh, "true"); + free(is_no_veh); + if (result == 0) + return true; + } + } + + return false; +} + +bool is_full_dumps() +{ + size_t required_size; + getenv_s(&required_size, nullptr, 0, "DALAMUD_IS_VEH_FULL"); + if (required_size > 0) + { + if (char* is_no_veh = static_cast(malloc(required_size * sizeof(char)))) + { + getenv_s(&required_size, is_no_veh, required_size, "DALAMUD_IS_VEH_FULL"); auto result = _stricmp(is_no_veh, "true"); free(is_no_veh); if (result == 0) @@ -91,7 +110,7 @@ DllExport DWORD WINAPI Initialize(LPVOID lpParam) } else if (is_veh_enabled()) { - if (veh::add_handler()) + if (veh::add_handler(is_full_dumps())) printf("Done!\n"); else printf("Failed!\n"); } diff --git a/Dalamud.Boot/veh.cpp b/Dalamud.Boot/veh.cpp index 16ea2ab8f..933502c20 100644 --- a/Dalamud.Boot/veh.cpp +++ b/Dalamud.Boot/veh.cpp @@ -2,6 +2,9 @@ #include "veh.h" +PVOID g_veh_handle = nullptr; +bool g_veh_do_full_dump = false; + bool is_whitelist_exception(const DWORD code) { switch (code) @@ -251,8 +254,12 @@ LONG exception_handler(EXCEPTION_POINTERS* ex) ex_info.ExceptionPointers = ex; ex_info.ThreadId = GetCurrentThreadId(); + auto miniDumpType = MiniDumpWithDataSegs; + if (g_veh_do_full_dump) + miniDumpType = MiniDumpWithFullMemory; + HANDLE file = CreateFileW(dmp_path.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); - MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), file, MiniDumpWithDataSegs, &ex_info, nullptr, nullptr); + MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), file, miniDumpType, &ex_info, nullptr, nullptr); CloseHandle(file); void* fn; @@ -282,15 +289,15 @@ LONG exception_handler(EXCEPTION_POINTERS* ex) return EXCEPTION_CONTINUE_SEARCH; } - -PVOID g_veh_handle = nullptr; - -bool veh::add_handler() +bool veh::add_handler(bool doFullDump) { if (g_veh_handle) return false; g_veh_handle = AddVectoredExceptionHandler(1, exception_handler); SetUnhandledExceptionFilter(nullptr); + + g_veh_do_full_dump = doFullDump; + return g_veh_handle != nullptr; } diff --git a/Dalamud.Boot/veh.h b/Dalamud.Boot/veh.h index d83284e87..bf0c549f3 100644 --- a/Dalamud.Boot/veh.h +++ b/Dalamud.Boot/veh.h @@ -2,6 +2,6 @@ namespace veh { - bool add_handler(); + bool add_handler(bool doFullDump); bool remove_handler(); }