mirror of
https://github.com/JezuzLizard/T4SP-Server-Plugin.git
synced 2025-04-19 21:22:54 +00:00
Safe pluto hooks
This commit is contained in:
parent
8c36a218de
commit
ca306d785b
@ -300,9 +300,16 @@ namespace codsrc
|
|||||||
game::gScrCompilePub[inst].parseBuf = sourceBuffer;
|
game::gScrCompilePub[inst].parseBuf = sourceBuffer;
|
||||||
|
|
||||||
// pluto
|
// pluto
|
||||||
game::plutonium::script_preprocess(sourceBuffer, inst, &parseData); // the pluto hook will call ScriptParse, so we dont have to
|
if (game::plutonium::script_preprocess != nullptr)
|
||||||
// game::ScriptParse(inst, &parseData);
|
{
|
||||||
|
game::plutonium::script_preprocess(sourceBuffer, inst, &parseData); // the pluto hook will call ScriptParse, so we dont have to
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
else
|
||||||
|
{
|
||||||
|
game::ScriptParse(inst, &parseData);
|
||||||
|
}
|
||||||
|
|
||||||
scriptPosVar = game::GetVariable(inst, game::gScrCompilePub[inst].scriptsPos, name);
|
scriptPosVar = game::GetVariable(inst, game::gScrCompilePub[inst].scriptsPos, name);
|
||||||
filePosId = game::GetObject(inst, scriptPosVar);
|
filePosId = game::GetObject(inst, scriptPosVar);
|
||||||
@ -330,7 +337,10 @@ namespace codsrc
|
|||||||
void Scr_EndLoadScripts(game::scriptInstance_t inst)
|
void Scr_EndLoadScripts(game::scriptInstance_t inst)
|
||||||
{
|
{
|
||||||
// pluto
|
// pluto
|
||||||
game::plutonium::load_custom_script_func(inst);
|
if (game::plutonium::load_custom_script_func != nullptr)
|
||||||
|
{
|
||||||
|
game::plutonium::load_custom_script_func(inst);
|
||||||
|
}
|
||||||
//
|
//
|
||||||
|
|
||||||
game::SL_ShutdownSystem(inst, 2u);
|
game::SL_ShutdownSystem(inst, 2u);
|
||||||
|
@ -1275,7 +1275,10 @@ namespace codsrc
|
|||||||
game::gScrVmPub[inst].function_frame->fs.localId = game::gFs[inst].localId;
|
game::gScrVmPub[inst].function_frame->fs.localId = game::gFs[inst].localId;
|
||||||
|
|
||||||
// pluto
|
// pluto
|
||||||
game::plutonium::vm_execute_update_codepos(inst);
|
if (game::plutonium::vm_execute_update_codepos != nullptr)
|
||||||
|
{
|
||||||
|
game::plutonium::vm_execute_update_codepos(inst);
|
||||||
|
}
|
||||||
//
|
//
|
||||||
|
|
||||||
assert(game::gFs[inst].pos);
|
assert(game::gFs[inst].pos);
|
||||||
@ -4510,7 +4513,10 @@ namespace codsrc
|
|||||||
const char* pos;
|
const char* pos;
|
||||||
|
|
||||||
// pluto
|
// pluto
|
||||||
game::plutonium::scr_execthread_update_codepos_func(inst, inst, &handle, &handle);
|
if (game::plutonium::scr_execthread_update_codepos_func != nullptr)
|
||||||
|
{
|
||||||
|
game::plutonium::scr_execthread_update_codepos_func(inst, inst, &handle, &handle);
|
||||||
|
}
|
||||||
//
|
//
|
||||||
|
|
||||||
pos = &game::gScrVarPub[inst].programBuffer[handle];
|
pos = &game::gScrVarPub[inst].programBuffer[handle];
|
||||||
@ -4555,7 +4561,10 @@ namespace codsrc
|
|||||||
game::classNum_e classnum = game::CLASS_NUM_ENTITY;
|
game::classNum_e classnum = game::CLASS_NUM_ENTITY;
|
||||||
|
|
||||||
// pluto
|
// pluto
|
||||||
game::plutonium::scr_execentthread_update_codepos_func(inst, &handle);
|
if (game::plutonium::scr_execentthread_update_codepos_func != nullptr)
|
||||||
|
{
|
||||||
|
game::plutonium::scr_execentthread_update_codepos_func(inst, &handle);
|
||||||
|
}
|
||||||
//
|
//
|
||||||
|
|
||||||
pos = &game::gScrVarPub[inst].programBuffer[handle];
|
pos = &game::gScrVarPub[inst].programBuffer[handle];
|
||||||
@ -4598,7 +4607,10 @@ namespace codsrc
|
|||||||
unsigned int paramcount = 0;
|
unsigned int paramcount = 0;
|
||||||
|
|
||||||
// pluto
|
// pluto
|
||||||
game::plutonium::scr_addexecthread_update_codepos_func(inst, &handle);
|
if (game::plutonium::scr_addexecthread_update_codepos_func != nullptr)
|
||||||
|
{
|
||||||
|
game::plutonium::scr_addexecthread_update_codepos_func(inst, &handle);
|
||||||
|
}
|
||||||
//
|
//
|
||||||
|
|
||||||
if ( !game::gScrVmPub[inst].function_count )
|
if ( !game::gScrVmPub[inst].function_count )
|
||||||
|
@ -86,11 +86,29 @@ namespace signatures
|
|||||||
return image_size;
|
return image_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t load_iamge_base()
|
||||||
|
{
|
||||||
|
return reinterpret_cast<size_t>(GetModuleHandle("plutonium-bootstrapper-win32.exe"));
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t get_image_base()
|
||||||
|
{
|
||||||
|
static const auto image_base = load_iamge_base();
|
||||||
|
return image_base;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool addr_is_in_image_space(size_t wheree)
|
||||||
|
{
|
||||||
|
static const auto image_base = load_iamge_base();
|
||||||
|
|
||||||
|
return wheree >= image_base && wheree < image_base + get_image_size();
|
||||||
|
}
|
||||||
|
|
||||||
size_t find_string_ptr(const std::string& string)
|
size_t find_string_ptr(const std::string& string)
|
||||||
{
|
{
|
||||||
const char* string_ptr = nullptr;
|
const char* string_ptr = nullptr;
|
||||||
std::string mask(string.size(), 'x');
|
std::string mask(string.size(), 'x');
|
||||||
const auto base = reinterpret_cast<size_t>(GetModuleHandle("plutonium-bootstrapper-win32.exe"));
|
const auto base = get_image_base();
|
||||||
utils::hook::signature signature(base, get_image_size() - base);
|
utils::hook::signature signature(base, get_image_size() - base);
|
||||||
|
|
||||||
signature.add({
|
signature.add({
|
||||||
@ -119,6 +137,13 @@ namespace signatures
|
|||||||
return find_string_ptr({bytes, 4});
|
return find_string_ptr({bytes, 4});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string err_reason;
|
||||||
|
|
||||||
|
std::string get_err_reason()
|
||||||
|
{
|
||||||
|
return err_reason;
|
||||||
|
}
|
||||||
|
|
||||||
bool process_printf()
|
bool process_printf()
|
||||||
{
|
{
|
||||||
auto cache_info = get_cache_info_for_our_version();
|
auto cache_info = get_cache_info_for_our_version();
|
||||||
@ -132,6 +157,7 @@ namespace signatures
|
|||||||
const auto string_ref = find_string_ref("A critical exception occured!\n");
|
const auto string_ref = find_string_ref("A critical exception occured!\n");
|
||||||
if (!string_ref)
|
if (!string_ref)
|
||||||
{
|
{
|
||||||
|
err_reason = "printf";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,15 +170,34 @@ namespace signatures
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define SAFE_SET_PLUTO_SYMBOL_DOUBLE(name, addr, off) \
|
||||||
|
addr2 = reinterpret_cast<size_t>(utils::hook::get_displacement_addr(addr)); \
|
||||||
|
if (!addr_is_in_image_space(addr2)) \
|
||||||
|
{ \
|
||||||
|
err_reason = #name " 1"; \
|
||||||
|
return false; \
|
||||||
|
} \
|
||||||
|
addr1 = reinterpret_cast<size_t>(utils::hook::get_displacement_addr(addr2 + off)); \
|
||||||
|
if (!addr_is_in_image_space(addr1)) \
|
||||||
|
{ \
|
||||||
|
err_reason = #name " 2"; \
|
||||||
|
return false; \
|
||||||
|
} \
|
||||||
|
game::plutonium::name.set(addr1)
|
||||||
|
|
||||||
|
|
||||||
bool handle_funcs()
|
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)));
|
size_t addr1;
|
||||||
game::plutonium::script_preprocess.set(reinterpret_cast<size_t>(utils::hook::get_displacement_addr(reinterpret_cast<size_t>(utils::hook::get_displacement_addr(0x689BCF)) + 0x2)));
|
size_t addr2;
|
||||||
|
|
||||||
game::plutonium::vm_execute_update_codepos.set(reinterpret_cast<size_t>(utils::hook::get_displacement_addr(reinterpret_cast<size_t>(utils::hook::get_displacement_addr(0x69608C)) + 0x2)));
|
SAFE_SET_PLUTO_SYMBOL_DOUBLE(load_custom_script_func, 0x689C80, 0x6);
|
||||||
game::plutonium::scr_execthread_update_codepos_func.set(reinterpret_cast<size_t>(utils::hook::get_displacement_addr(reinterpret_cast<size_t>(utils::hook::get_displacement_addr(0x699560)) + 0x11)));
|
SAFE_SET_PLUTO_SYMBOL_DOUBLE(script_preprocess, 0x689BCF, 0x2);
|
||||||
game::plutonium::scr_execentthread_update_codepos_func.set(reinterpret_cast<size_t>(utils::hook::get_displacement_addr(reinterpret_cast<size_t>(utils::hook::get_displacement_addr(0x699640)) + 0x7)));
|
|
||||||
game::plutonium::scr_addexecthread_update_codepos_func.set(reinterpret_cast<size_t>(utils::hook::get_displacement_addr(reinterpret_cast<size_t>(utils::hook::get_displacement_addr(0x699730)) + 0x7)));
|
SAFE_SET_PLUTO_SYMBOL_DOUBLE(vm_execute_update_codepos, 0x69608C, 0x2);
|
||||||
|
SAFE_SET_PLUTO_SYMBOL_DOUBLE(scr_execthread_update_codepos_func, 0x699560, 0x11);
|
||||||
|
SAFE_SET_PLUTO_SYMBOL_DOUBLE(scr_execentthread_update_codepos_func, 0x699640, 0x7);
|
||||||
|
SAFE_SET_PLUTO_SYMBOL_DOUBLE(scr_addexecthread_update_codepos_func, 0x699730, 0x7);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -161,8 +206,6 @@ namespace signatures
|
|||||||
{
|
{
|
||||||
utils::cryptography::des::set_key("694201337");
|
utils::cryptography::des::set_key("694201337");
|
||||||
|
|
||||||
handle_funcs();
|
return handle_funcs() && process_printf();
|
||||||
|
|
||||||
return process_printf();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,5 +2,6 @@
|
|||||||
|
|
||||||
namespace signatures
|
namespace signatures
|
||||||
{
|
{
|
||||||
|
std::string get_err_reason();
|
||||||
bool process();
|
bool process();
|
||||||
}
|
}
|
@ -13,8 +13,9 @@ BOOL APIENTRY DllMain(HMODULE /*module_*/, DWORD ul_reason_for_call, LPVOID /*re
|
|||||||
if (!signatures::process())
|
if (!signatures::process())
|
||||||
{
|
{
|
||||||
MessageBoxA(NULL,
|
MessageBoxA(NULL,
|
||||||
"This version of t4sp-server-plugin is outdated.\n" \
|
std::format("This version of t4sp-server-plugin is outdated.\n" \
|
||||||
"Download the latest dll from here: https://github.com/JezuzLizard/T4SP-Server-Plugin/releases",
|
"Download the latest dll from here: https://github.com/JezuzLizard/T4SP-Server-Plugin/releases\n" \
|
||||||
|
"'{}' failed", signatures::get_err_reason()).c_str(),
|
||||||
"ERROR", MB_ICONERROR);
|
"ERROR", MB_ICONERROR);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user