gsc hook safe set

This commit is contained in:
ineed bots 2023-09-01 20:05:59 -06:00
parent ca306d785b
commit db053c05d2
3 changed files with 26 additions and 3 deletions

View File

@ -123,11 +123,17 @@ namespace gsc
void post_unpack() override
{
// custom gsc methods
scr_getmethod_hook.create(utils::hook::get_displacement_addr(SELECT(0x0, 0x683043)), scr_getmethod_stub);
if (game::plutonium::scr_get_method_stub != nullptr)
{
scr_getmethod_hook.create(game::plutonium::scr_get_method_stub.get(), scr_getmethod_stub);
}
// custom gsc funcs
scr_getfunction_stub_ret_loc = utils::hook::get_displacement_addr(SELECT(0x0, 0x682D99));
utils::hook::jump(SELECT(0x0, 0x682D99), scr_getfunction_stub);
if (game::plutonium::scr_get_function_stub != nullptr)
{
scr_getfunction_stub_ret_loc = game::plutonium::scr_get_function_stub.get();
utils::hook::jump(SELECT(0x0, 0x682D99), scr_getfunction_stub);
}
}
private:

View File

@ -170,6 +170,7 @@ namespace signatures
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)) \
@ -186,6 +187,16 @@ namespace signatures
game::plutonium::name.set(addr1)
#define SAFE_SET_PLUTO_SYMBOL(name, addr) \
addr1 = reinterpret_cast<size_t>(utils::hook::get_displacement_addr(addr)); \
if (!addr_is_in_image_space(addr1)) \
{ \
err_reason = #name; \
return false; \
} \
game::plutonium::name.set(addr1)
bool handle_funcs()
{
size_t addr1;
@ -199,6 +210,9 @@ namespace signatures
SAFE_SET_PLUTO_SYMBOL_DOUBLE(scr_execentthread_update_codepos_func, 0x699640, 0x7);
SAFE_SET_PLUTO_SYMBOL_DOUBLE(scr_addexecthread_update_codepos_func, 0x699730, 0x7);
SAFE_SET_PLUTO_SYMBOL(scr_get_function_stub, 0x682D99);
SAFE_SET_PLUTO_SYMBOL(scr_get_method_stub, 0x683043);
return true;
}

View File

@ -78,5 +78,8 @@ namespace game
WEAK symbol<void(game::scriptInstance_t, game::scriptInstance_t, unsigned int*, unsigned int*)> scr_execthread_update_codepos_func{0x0, 0x0};
WEAK symbol<void(game::scriptInstance_t, unsigned int*)> scr_execentthread_update_codepos_func{ 0x0, 0x0 };
WEAK symbol<void(game::scriptInstance_t, unsigned int*)> scr_addexecthread_update_codepos_func{ 0x0, 0x0 };
WEAK symbol<void()> scr_get_method_stub{ 0x0, 0x0 };
WEAK symbol<void()> scr_get_function_stub{ 0x0, 0x0 };
}
}