From 3a5ecdef29a8654a7a2832f2282b91cbe3c0076c Mon Sep 17 00:00:00 2001 From: m Date: Sat, 17 Sep 2022 07:51:34 -0500 Subject: [PATCH 1/4] renderer pipeline --- src/client/component/branding.cpp | 4 +++- src/client/component/scheduler.cpp | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/client/component/branding.cpp b/src/client/component/branding.cpp index 16d8d7eb..c53fe40f 100644 --- a/src/client/component/branding.cpp +++ b/src/client/component/branding.cpp @@ -2,6 +2,8 @@ #include "loader/component_loader.hpp" #include "game/game.hpp" +#include "scheduler.hpp" + #include #include @@ -39,7 +41,7 @@ namespace branding public: void post_unpack() override { - r_end_frame_hook.create(0x142273560_g, r_end_frame_stub); + scheduler::loop(draw_branding, scheduler::renderer); } }; } diff --git a/src/client/component/scheduler.cpp b/src/client/component/scheduler.cpp index 47bda262..2bb37784 100644 --- a/src/client/component/scheduler.cpp +++ b/src/client/component/scheduler.cpp @@ -85,6 +85,7 @@ namespace scheduler volatile bool kill = false; std::thread thread; task_pipeline pipelines[pipeline::count]; + utils::hook::detour r_end_frame_hook; utils::hook::detour g_run_frame_hook; utils::hook::detour main_frame_hook; @@ -162,6 +163,11 @@ namespace scheduler }); } + void post_unpack() override + { + r_end_frame_hook.create(0x142273560_g, r_end_frame_stub); + } + void pre_destroy() override { kill = true; From bac89feba90d8fe4d11c3c8ad3a57bf072ed0feb Mon Sep 17 00:00:00 2001 From: m Date: Sat, 17 Sep 2022 08:11:44 -0500 Subject: [PATCH 2/4] add server and main pipelines --- src/client/component/scheduler.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client/component/scheduler.cpp b/src/client/component/scheduler.cpp index 2bb37784..8b23a465 100644 --- a/src/client/component/scheduler.cpp +++ b/src/client/component/scheduler.cpp @@ -165,7 +165,9 @@ namespace scheduler void post_unpack() override { - r_end_frame_hook.create(0x142273560_g, r_end_frame_stub); + r_end_frame_hook.create(0x142273560_g, r_end_frame_stub); // some func called before R_EndFrame, maybe SND_EndFrame? + g_run_frame_hook.create(0x14065C360_g, server_frame_stub); // GlassSv_Update + main_frame_hook.create(0x1420F9860_g, main_frame_stub); // Com_Frame_Try_Block_Function } void pre_destroy() override From 0b935f0c6947ef700c9ec23eaa28b04f76c06506 Mon Sep 17 00:00:00 2001 From: m Date: Sat, 17 Sep 2022 09:04:45 -0500 Subject: [PATCH 3/4] minidump changes --- src/client/component/exception.cpp | 15 +++++++++------ src/client/loader/component_loader.cpp | 11 ++++++++--- src/client/loader/component_loader.hpp | 1 + 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/client/component/exception.cpp b/src/client/component/exception.cpp index 6d01ea12..2d572533 100644 --- a/src/client/component/exception.cpp +++ b/src/client/component/exception.cpp @@ -68,14 +68,15 @@ namespace exception void display_error_dialog() { - const std::string error_str = utils::string::va("Fatal error (0x%08X) at 0x%p.\n" - "A minidump has been written.\n\n", - exception_data.code, exception_data.address); + const std::string error_str = utils::string::va("Fatal error (0x%08X) at 0x%p (0x%p).\n" + "A minidump has been written.\n", + exception_data.code, exception_data.address, + reinterpret_cast(exception_data.address) - get_base()); utils::thread::suspend_other_threads(); 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); } @@ -86,11 +87,12 @@ namespace exception recovery_data.last_recovery = std::chrono::high_resolution_clock::now(); ++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" "Make sure to update your graphics card drivers and install operating system updates!\n" "Closing or restarting Steam might also help.", - exception_data.code, exception_data.address); + exception_data.code, exception_data.address, + reinterpret_cast(exception_data.address) - get_base()); } else { @@ -137,6 +139,7 @@ namespace exception line("Timestamp: "s + get_timestamp()); line(utils::string::va("Exception: 0x%08X", exceptioninfo->ExceptionRecord->ExceptionCode)); line(utils::string::va("Address: 0x%llX", exceptioninfo->ExceptionRecord->ExceptionAddress)); + line(utils::string::va("Base: 0x%llX", get_base())); #pragma warning(push) #pragma warning(disable: 4996) diff --git a/src/client/loader/component_loader.cpp b/src/client/loader/component_loader.cpp index 94cb35a5..fa4617d3 100644 --- a/src/client/loader/component_loader.cpp +++ b/src/client/loader/component_loader.cpp @@ -136,17 +136,22 @@ std::vector>& component_loader::get_compone return *components; } -size_t operator"" _g(const size_t val) +size_t get_base() { static auto base = size_t(utils::nt::library{}.get_ptr()); 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); } size_t reverse_g(const size_t val) { - static auto base = size_t(utils::nt::library{}.get_ptr()); - assert(base && "Failed to resolve base"); + static auto base = get_base(); return (val - base) + 0x140000000; } diff --git a/src/client/loader/component_loader.hpp b/src/client/loader/component_loader.hpp index d7bce797..1e4a97d0 100644 --- a/src/client/loader/component_loader.hpp +++ b/src/client/loader/component_loader.hpp @@ -57,6 +57,7 @@ namespace \ static component_loader::installer __component; \ } +size_t get_base(); size_t operator"" _g(size_t val); size_t reverse_g(size_t val); size_t reverse_g(const void* val); From 3855c173bf7f2056ca0a02106d35466824591e13 Mon Sep 17 00:00:00 2001 From: m Date: Sat, 17 Sep 2022 09:22:54 -0500 Subject: [PATCH 4/4] branding cleanup normal scale again use reverse_g format --- src/client/component/branding.cpp | 11 +---------- src/client/component/exception.cpp | 4 ++-- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/client/component/branding.cpp b/src/client/component/branding.cpp index c53fe40f..13ed4cc4 100644 --- a/src/client/component/branding.cpp +++ b/src/client/component/branding.cpp @@ -1,24 +1,21 @@ #include #include "loader/component_loader.hpp" #include "game/game.hpp" +#include "version.hpp" #include "scheduler.hpp" #include -#include namespace branding { namespace { - utils::hook::detour r_end_frame_hook; - void draw_branding() { constexpr auto x = 4; constexpr auto y = 0; constexpr auto scale = 0.5f; - //float color[4] = {0.666f, 0.666f, 0.666f, 0.666f}; float color[4] = {236 / 255.0f, 113 / 255.0f, 10 / 255.0f, 1.0f}; auto* font = reinterpret_cast(0x141CAC8E0_g)(); @@ -28,12 +25,6 @@ namespace branding y + static_cast(font[2]) * scale, scale, scale, 0.0f, color, game::ITEM_TEXTSTYLE_SHADOWEDMORE); } - - void r_end_frame_stub() - { - draw_branding(); - r_end_frame_hook.invoke(); - } } class component final : public component_interface diff --git a/src/client/component/exception.cpp b/src/client/component/exception.cpp index 2d572533..1166d03f 100644 --- a/src/client/component/exception.cpp +++ b/src/client/component/exception.cpp @@ -71,7 +71,7 @@ namespace exception const std::string error_str = utils::string::va("Fatal error (0x%08X) at 0x%p (0x%p).\n" "A minidump has been written.\n", exception_data.code, exception_data.address, - reinterpret_cast(exception_data.address) - get_base()); + reverse_g(reinterpret_cast(exception_data.address))); utils::thread::suspend_other_threads(); show_mouse_cursor(); @@ -92,7 +92,7 @@ namespace exception "Make sure to update your graphics card drivers and install operating system updates!\n" "Closing or restarting Steam might also help.", exception_data.code, exception_data.address, - reinterpret_cast(exception_data.address) - get_base()); + reverse_g(reinterpret_cast(exception_data.address))); } else {