chore: change VEH env var, add var to enable full dumps

This commit is contained in:
goaaats 2022-05-18 18:33:34 +02:00
parent 74fd48c5cb
commit 524d100bdc
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
3 changed files with 35 additions and 9 deletions

View file

@ -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<char*>(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<char*>(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");
}

View file

@ -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;
}

View file

@ -2,6 +2,6 @@
namespace veh
{
bool add_handler();
bool add_handler(bool doFullDump);
bool remove_handler();
}