minidump changes

This commit is contained in:
m 2022-09-17 09:04:45 -05:00
parent bac89feba9
commit 0b935f0c69
3 changed files with 18 additions and 9 deletions

View File

@ -68,14 +68,15 @@ namespace exception
void display_error_dialog() void display_error_dialog()
{ {
const std::string error_str = utils::string::va("Fatal error (0x%08X) at 0x%p.\n" const std::string error_str = utils::string::va("Fatal error (0x%08X) at 0x%p (0x%p).\n"
"A minidump has been written.\n\n", "A minidump has been written.\n",
exception_data.code, exception_data.address); exception_data.code, exception_data.address,
reinterpret_cast<uint64_t>(exception_data.address) - get_base());
utils::thread::suspend_other_threads(); utils::thread::suspend_other_threads();
show_mouse_cursor(); show_mouse_cursor();
MessageBoxA(nullptr, error_str.data(), "S1x ERROR", MB_ICONERROR); MessageBoxA(nullptr, error_str.data(), "BOIII ERROR", MB_ICONERROR);
TerminateProcess(GetCurrentProcess(), exception_data.code); TerminateProcess(GetCurrentProcess(), exception_data.code);
} }
@ -86,11 +87,12 @@ namespace exception
recovery_data.last_recovery = std::chrono::high_resolution_clock::now(); recovery_data.last_recovery = std::chrono::high_resolution_clock::now();
++recovery_data.recovery_counts; ++recovery_data.recovery_counts;
game::Com_Error(game::ERR_DROP, "Fatal error (0x%08X) at 0x%p.\nA minidump has been written.\n\n" game::Com_Error(game::ERR_DROP, "Fatal error (0x%08X) at 0x%p (0x%p).\nA minidump has been written.\n\n"
"BOIII has tried to recover your game, but it might not run stable anymore.\n\n" "BOIII has tried to recover your game, but it might not run stable anymore.\n\n"
"Make sure to update your graphics card drivers and install operating system updates!\n" "Make sure to update your graphics card drivers and install operating system updates!\n"
"Closing or restarting Steam might also help.", "Closing or restarting Steam might also help.",
exception_data.code, exception_data.address); exception_data.code, exception_data.address,
reinterpret_cast<uint64_t>(exception_data.address) - get_base());
} }
else else
{ {
@ -137,6 +139,7 @@ namespace exception
line("Timestamp: "s + get_timestamp()); line("Timestamp: "s + get_timestamp());
line(utils::string::va("Exception: 0x%08X", exceptioninfo->ExceptionRecord->ExceptionCode)); line(utils::string::va("Exception: 0x%08X", exceptioninfo->ExceptionRecord->ExceptionCode));
line(utils::string::va("Address: 0x%llX", exceptioninfo->ExceptionRecord->ExceptionAddress)); line(utils::string::va("Address: 0x%llX", exceptioninfo->ExceptionRecord->ExceptionAddress));
line(utils::string::va("Base: 0x%llX", get_base()));
#pragma warning(push) #pragma warning(push)
#pragma warning(disable: 4996) #pragma warning(disable: 4996)

View File

@ -136,17 +136,22 @@ std::vector<std::unique_ptr<component_interface>>& component_loader::get_compone
return *components; return *components;
} }
size_t operator"" _g(const size_t val) size_t get_base()
{ {
static auto base = size_t(utils::nt::library{}.get_ptr()); static auto base = size_t(utils::nt::library{}.get_ptr());
assert(base && "Failed to resolve base"); assert(base && "Failed to resolve base");
return base;
}
size_t operator"" _g(const size_t val)
{
static auto base = get_base();
return base + (val - 0x140000000); return base + (val - 0x140000000);
} }
size_t reverse_g(const size_t val) size_t reverse_g(const size_t val)
{ {
static auto base = size_t(utils::nt::library{}.get_ptr()); static auto base = get_base();
assert(base && "Failed to resolve base");
return (val - base) + 0x140000000; return (val - base) + 0x140000000;
} }

View File

@ -57,6 +57,7 @@ namespace \
static component_loader::installer<name> __component; \ static component_loader::installer<name> __component; \
} }
size_t get_base();
size_t operator"" _g(size_t val); size_t operator"" _g(size_t val);
size_t reverse_g(size_t val); size_t reverse_g(size_t val);
size_t reverse_g(const void* val); size_t reverse_g(const void* val);