diff --git a/src/component/gsc.cpp b/src/component/gsc.cpp index 4b3fd4c..3337890 100644 --- a/src/component/gsc.cpp +++ b/src/component/gsc.cpp @@ -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: diff --git a/src/component/signatures.cpp b/src/component/signatures.cpp index fa3857d..901ab37 100644 --- a/src/component/signatures.cpp +++ b/src/component/signatures.cpp @@ -170,6 +170,7 @@ namespace signatures return true; } + #define SAFE_SET_PLUTO_SYMBOL_DOUBLE(name, addr, off) \ addr2 = reinterpret_cast(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(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; } diff --git a/src/game/symbols.hpp b/src/game/symbols.hpp index 229ba97..7311db5 100644 --- a/src/game/symbols.hpp +++ b/src/game/symbols.hpp @@ -78,5 +78,8 @@ namespace game WEAK symbol scr_execthread_update_codepos_func{0x0, 0x0}; WEAK symbol scr_execentthread_update_codepos_func{ 0x0, 0x0 }; WEAK symbol scr_addexecthread_update_codepos_func{ 0x0, 0x0 }; + + WEAK symbol scr_get_method_stub{ 0x0, 0x0 }; + WEAK symbol scr_get_function_stub{ 0x0, 0x0 }; } }