Skip to content

Commit

Permalink
Fixed error info not being added to crash dump
Browse files Browse the repository at this point in the history
  • Loading branch information
3vcloud committed Jan 24, 2025
1 parent 5b90489 commit 5aaca4a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
Binary file modified Dependencies/GWCA/bin/gwca.dll
Binary file not shown.
4 changes: 2 additions & 2 deletions Dependencies/GWCA/include/GWCA/GWCAVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#define GWCA_VERSION_MAJOR 1
#define GWCA_VERSION_MINOR 0
#define GWCA_VERSION_PATCH 9
#define GWCA_VERSION_PATCH 10
#define GWCA_VERSION_BUILD 0
#define GWCA_VERSION "1.0.9.0"
#define GWCA_VERSION "1.0.10.0"

namespace GWCA {
constexpr int VersionMajor = GWCA_VERSION_MAJOR;
Expand Down
22 changes: 10 additions & 12 deletions GWToolboxdll/Modules/CrashHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <Modules/Resources.h>
#include <GWToolbox.h>
#include <Defines.h>
#include <Utils/TextUtils.h>

namespace {
char* tb_exception_message = nullptr;
Expand Down Expand Up @@ -52,13 +53,6 @@ namespace {
}
}








void OnGWCrash(GWDebugInfo* details, const uint32_t param_2, EXCEPTION_POINTERS* pExceptionPointers, char* exception_message, char* exception_file, const uint32_t exception_line)
{
GW::Hook::EnterHook();
Expand All @@ -68,12 +62,13 @@ namespace {
if (!pExceptionPointers) {
CrashHandler::FatalAssert(exception_message, exception_file, exception_line);
}
#ifdef _DEBUG
__try {
// Debug break here to catch stack trace in debug mode before dumping
__debugbreak();
}
__except (EXCEPTION_CONTINUE_EXECUTION) {}

#endif
// Assertion here will throw a GWToolbox exception if pExceptionPointers isn't found; this will give us the correct call stack for a GW Assertion failure in the subsequent crash dump.
if (CrashHandler::Crash(pExceptionPointers)) {
abort();
Expand All @@ -99,10 +94,13 @@ void CrashHandler::GWCAPanicHandler(
void CrashHandler::FatalAssert(const char* expr, const char* file, const unsigned line)
{
__try {
__debugbreak();
const size_t len = snprintf(nullptr, 0, "Assertion Error(expr: '%s', file : '%s', line : %u", expr, file, line);
const char* fmt = "Assertion Error: '%s' in '%s' line %u";
const size_t len = snprintf(nullptr, 0, fmt, expr, file, line);
tb_exception_message = new char[len + 1];
snprintf(tb_exception_message, len + 1, "Assertion Error(expr: '%s', file : '%s', line : %u", expr, file, line);
snprintf(tb_exception_message, len + 1, fmt, expr, file, line);
#ifdef _DEBUG
__debugbreak();
#endif
throw std::runtime_error(tb_exception_message);
}
__except (EXCEPT_EXPRESSION_ENTRY) {}
Expand Down Expand Up @@ -160,7 +158,7 @@ LONG WINAPI CrashHandler::Crash(EXCEPTION_POINTERS* pExceptionPointers)
const auto s = new MINIDUMP_USER_STREAM();
s->Type = CommentStreamA;
s->Buffer = extra_info;
s->BufferSize = (strlen(extra_info) + 1) * sizeof(extra_info[0]);
s->BufferSize = static_cast<ULONG>(strlen(extra_info) + 1);
UserStreamParam->UserStreamCount = 1;
UserStreamParam->UserStreamArray = s;
}
Expand Down

0 comments on commit 5aaca4a

Please sign in to comment.