From 8a6f707e4e177fc07e0794cb2f9fe999bd88ceb1 Mon Sep 17 00:00:00 2001 From: ineed bots Date: Tue, 29 Aug 2023 12:04:20 -0600 Subject: [PATCH] sigs from fedddd --- src/component/signatures.cpp | 81 ++++++++++++++++++++++++++++++++++++ src/component/signatures.hpp | 6 +++ src/dllmain.cpp | 20 ++++++++- src/game/symbols.hpp | 3 ++ src/stdinc.hpp | 3 -- 5 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 src/component/signatures.cpp create mode 100644 src/component/signatures.hpp diff --git a/src/component/signatures.cpp b/src/component/signatures.cpp new file mode 100644 index 0000000..643515d --- /dev/null +++ b/src/component/signatures.cpp @@ -0,0 +1,81 @@ +#include +#include "signatures.hpp" +#include + +namespace signatures +{ + size_t load_image_size() + { + MODULEINFO info{}; + GetModuleInformation(GetCurrentProcess(), + GetModuleHandle("plutonium-bootstrapper-win32.exe"), &info, sizeof(MODULEINFO)); + return info.SizeOfImage; + } + + size_t get_image_size() + { + static const auto image_size = load_image_size(); + return image_size; + } + + size_t find_string_ptr(const std::string& string) + { + const char* string_ptr = nullptr; + std::string mask(string.size(), 'x'); + const auto base = reinterpret_cast(GetModuleHandle("plutonium-bootstrapper-win32.exe")); + utils::hook::signature signature(base, get_image_size() - base); + + signature.add({ + string, + mask, + [&](char* address) + { + string_ptr = address; + } + }); + + signature.process(); + return reinterpret_cast(string_ptr); + } + + size_t find_string_ref(const std::string& string) + { + char bytes[4] = {0}; + const auto string_ptr = find_string_ptr(string); + if (!string_ptr) + { + return 0; + } + + std::memcpy(bytes, &string_ptr, sizeof(bytes)); + return find_string_ptr({bytes, 4}); + } + + bool process_printf() + { + const auto string_ref = find_string_ref("A critical exception occured!\n"); + if (!string_ref) + { + return false; + } + + const auto offset = *reinterpret_cast(string_ref + 5); + game::plutonium::printf.set(string_ref + 4 + 5 + offset); + + return true; + } + + bool handle_funcs() + { + game::plutonium::load_custom_script_func.set(reinterpret_cast(utils::hook::get_displacement_addr(reinterpret_cast(utils::hook::get_displacement_addr(0x689C80)) + 0x6))); + + return true; + } + + bool process() + { + handle_funcs(); + + return process_printf(); + } +} diff --git a/src/component/signatures.hpp b/src/component/signatures.hpp new file mode 100644 index 0000000..c713f38 --- /dev/null +++ b/src/component/signatures.hpp @@ -0,0 +1,6 @@ +#pragma once + +namespace signatures +{ + bool process(); +} \ No newline at end of file diff --git a/src/dllmain.cpp b/src/dllmain.cpp index ddfbf29..d08ffa6 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -1,5 +1,6 @@ #include #include "loader/component_loader.hpp" +#include "component/signatures.hpp" #include @@ -9,11 +10,28 @@ BOOL APIENTRY DllMain(HMODULE /*module_*/, DWORD ul_reason_for_call, LPVOID /*re { if (game::environment::t4sp()) { + if (!signatures::process()) + { + MessageBoxA(NULL, + "This version of t4sp-server-plugin is outdated.\n" \ + "Download the latest dll from here: https://github.com/JezuzLizard/T4SP-Server-Plugin/releases", + "ERROR", MB_ICONERROR); + + return FALSE; + } + + if (game::plutonium::printf.get() != nullptr) + { + utils::hook::jump(reinterpret_cast(&printf), game::plutonium::printf); + } + component_loader::post_unpack(); } else { - // MessageBoxA(nullptr, "Unsupported game executable. (t4sp is only supported)", "ERROR, BRO!", 0); + MessageBoxA(nullptr, "Unsupported game executable. (t4sp is only supported)", "ERROR, BRO!", 0); + + return FALSE; } } diff --git a/src/game/symbols.hpp b/src/game/symbols.hpp index b51f542..107e77c 100644 --- a/src/game/symbols.hpp +++ b/src/game/symbols.hpp @@ -13,5 +13,8 @@ namespace game namespace plutonium { + WEAK symbol printf{0x0, 0x0}; + + WEAK symbol load_custom_script_func{0x0, 0x0}; } } diff --git a/src/stdinc.hpp b/src/stdinc.hpp index 416fcf8..c49690f 100644 --- a/src/stdinc.hpp +++ b/src/stdinc.hpp @@ -62,7 +62,4 @@ #include "game/game.hpp" #include "game/symbols.hpp" -#define printf(__fmt__, ...) \ - game::Com_Printf(game::CON_CHANNEL_SERVER, __fmt__, __VA_ARGS__) - using namespace std::literals; \ No newline at end of file