mirror of
https://github.com/JezuzLizard/T4SP-Server-Plugin.git
synced 2025-04-20 05:25:44 +00:00
sigs from fedddd
This commit is contained in:
parent
b0ee289a3c
commit
8a6f707e4e
81
src/component/signatures.cpp
Normal file
81
src/component/signatures.cpp
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
#include <stdinc.hpp>
|
||||||
|
#include "signatures.hpp"
|
||||||
|
#include <utils/hook.hpp>
|
||||||
|
|
||||||
|
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<size_t>(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<size_t>(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<size_t*>(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<size_t>(utils::hook::get_displacement_addr(reinterpret_cast<size_t>(utils::hook::get_displacement_addr(0x689C80)) + 0x6)));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool process()
|
||||||
|
{
|
||||||
|
handle_funcs();
|
||||||
|
|
||||||
|
return process_printf();
|
||||||
|
}
|
||||||
|
}
|
6
src/component/signatures.hpp
Normal file
6
src/component/signatures.hpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace signatures
|
||||||
|
{
|
||||||
|
bool process();
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
#include <stdinc.hpp>
|
#include <stdinc.hpp>
|
||||||
#include "loader/component_loader.hpp"
|
#include "loader/component_loader.hpp"
|
||||||
|
#include "component/signatures.hpp"
|
||||||
|
|
||||||
#include <utils/hook.hpp>
|
#include <utils/hook.hpp>
|
||||||
|
|
||||||
@ -9,11 +10,28 @@ BOOL APIENTRY DllMain(HMODULE /*module_*/, DWORD ul_reason_for_call, LPVOID /*re
|
|||||||
{
|
{
|
||||||
if (game::environment::t4sp())
|
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<uintptr_t>(&printf), game::plutonium::printf);
|
||||||
|
}
|
||||||
|
|
||||||
component_loader::post_unpack();
|
component_loader::post_unpack();
|
||||||
}
|
}
|
||||||
else
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,5 +13,8 @@ namespace game
|
|||||||
|
|
||||||
namespace plutonium
|
namespace plutonium
|
||||||
{
|
{
|
||||||
|
WEAK symbol<int(const char* fmt, ...)> printf{0x0, 0x0};
|
||||||
|
|
||||||
|
WEAK symbol<void(game::scriptInstance_t)> load_custom_script_func{0x0, 0x0};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,4 @@
|
|||||||
#include "game/game.hpp"
|
#include "game/game.hpp"
|
||||||
#include "game/symbols.hpp"
|
#include "game/symbols.hpp"
|
||||||
|
|
||||||
#define printf(__fmt__, ...) \
|
|
||||||
game::Com_Printf(game::CON_CHANNEL_SERVER, __fmt__, __VA_ARGS__)
|
|
||||||
|
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
Loading…
x
Reference in New Issue
Block a user