mirror of
https://github.com/JezuzLizard/T4SP-Server-Plugin.git
synced 2025-07-03 17:51:51 +00:00
added more detours
This commit is contained in:
79
src/component/decomp/clientscript/re_cscr_readwrite.cpp
Normal file
79
src/component/decomp/clientscript/re_cscr_readwrite.cpp
Normal file
@ -0,0 +1,79 @@
|
||||
#include <stdinc.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
#include "utils/hook.hpp"
|
||||
//#include "codsrc/clientscript/cscr_readwrite.hpp"
|
||||
|
||||
#define RE_CSCR_READWRITE_USE_WRAPPERS
|
||||
|
||||
namespace re_cscr_readwrite
|
||||
{
|
||||
utils::hook::detour FindVariableIndexInternal2_hook;
|
||||
utils::hook::detour FindLastSibling_hook;
|
||||
|
||||
void* FindVariableIndexInternal2_original;
|
||||
void* FindLastSibling_original;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
unsigned int FindVariableIndexInternal2_call(game::scriptInstance_t inst, [[maybe_unused]] void* caller_addr, unsigned int name, unsigned int index)
|
||||
{
|
||||
#ifdef RE_CSCR_READWRITE_USE_WRAPPERS
|
||||
return game::FindVariableIndexInternal2(inst, name, index, FindVariableIndexInternal2_original);
|
||||
#else
|
||||
return codsrc::FindVariableIndexInternal2(inst, name, index);
|
||||
#endif
|
||||
}
|
||||
|
||||
// unsigned int __usercall FindVariableIndexInternal2@<eax>(scriptInstance_t inst@<eax>, unsigned int name, unsigned int index)
|
||||
NAKED unsigned int FindVariableIndexInternal2_stub()
|
||||
{
|
||||
_asm
|
||||
{
|
||||
push eax;
|
||||
call FindVariableIndexInternal2_call;
|
||||
add esp, 0x4;
|
||||
ret;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int FindLastSibling_call(unsigned int parentId, game::scriptInstance_t inst, [[maybe_unused]] void* caller_addr)
|
||||
{
|
||||
#ifdef RE_CSCR_READWRITE_USE_WRAPPERS
|
||||
return game::FindLastSibling(parentId, inst, FindLastSibling_original);
|
||||
#else
|
||||
return codsrc::FindLastSibling(parentId, inst);
|
||||
#endif
|
||||
}
|
||||
|
||||
// unsigned int __usercall FindLastSibling@<eax>(unsigned int parentId@<edx>, scriptInstance_t inst@<esi>)
|
||||
NAKED unsigned int FindLastSibling_stub()
|
||||
{
|
||||
_asm
|
||||
{
|
||||
push esi;
|
||||
push edx;
|
||||
call FindLastSibling_call;
|
||||
add esp, 0x8;
|
||||
ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class component final : public component_interface
|
||||
{
|
||||
public:
|
||||
void post_unpack() override
|
||||
{
|
||||
FindVariableIndexInternal2_hook.create(game::FindVariableIndexInternal2_ADDR(), FindVariableIndexInternal2_stub);
|
||||
FindLastSibling_hook.create(game::FindLastSibling_ADDR(), FindLastSibling_stub);
|
||||
|
||||
//Original hook function addresses
|
||||
FindVariableIndexInternal2_original = FindVariableIndexInternal2_hook.get_original();
|
||||
FindLastSibling_original = FindLastSibling_hook.get_original();
|
||||
}
|
||||
|
||||
private:
|
||||
};
|
||||
}
|
||||
REGISTER_COMPONENT(re_cscr_readwrite::component)
|
Reference in New Issue
Block a user