diff --git a/include/Vutils.h b/include/Vutils.h index 7d2e6b6..876154c 100644 --- a/include/Vutils.h +++ b/include/Vutils.h @@ -1445,8 +1445,8 @@ class AsyncSocket : public LastError * @param[in] F The function name. * @return true if the function succeeds. Otherwise false. */ -#define VU_API_INL_OVERRIDE(O, M, F) O.install(_T( # M ), _T( # F ), (void*)&Hfn ## F, (void**)&pfn ## F) -#define VU_API_INL_RESTORE(O, M, F) O.uninstall(_T( # M ), _T( # F ), (void**)&pfn ## F) +#define VU_API_INL_OVERRIDE(O, M, F) O.install(ts( # M ), ts( # F ), (void*)&Hfn ## F, (void**)&pfn ## F) +#define VU_API_INL_RESTORE(O, M, F) O.uninstall(ts( # M ), ts( # F ), (void**)&pfn ## F) enum class memory_address_type { @@ -1503,6 +1503,9 @@ class INLHookingX INLHookingX() : m_hooked(false) {}; virtual ~INLHookingX() {}; + INLHookingX(const INLHookingX& right); + const INLHookingX& operator=(const INLHookingX& right); + bool vuapi attach(void* ptr_function, void* ptr_hook_function, void** pptr_old_function); bool vuapi detach(void* ptr_function, void** pptr_old_function); }; diff --git a/src/details/apihookinl.cpp b/src/details/apihookinl.cpp index a678f38..81eff52 100644 --- a/src/details/apihookinl.cpp +++ b/src/details/apihookinl.cpp @@ -36,7 +36,7 @@ namespace vu * @param[out] instructions List instructions. * @return True if current instruction is a memory struction, False if it is not. */ -bool vuapi GetAssembleInstruction( +bool vuapi get_assemble_instruction( const HDE::tagHDE& hde, const ulong offset, std::vector& instructions @@ -166,6 +166,18 @@ bool vuapi GetAssembleInstruction( return result; } +INLHookingX::INLHookingX(const INLHookingX& right) +{ + *this = right; +} + +const INLHookingX& INLHookingX::operator=(const INLHookingX& right) +{ + m_hooked = right.m_hooked; + m_memory_instructions = right.m_memory_instructions; + return *this; +} + bool vuapi INLHookingX::attach(void* ptr_function, void* ptr_hook_function, void** pptr_old_function) { /* @@ -194,7 +206,7 @@ bool vuapi INLHookingX::attach(void* ptr_function, void* ptr_hook_function, void } else { - GetAssembleInstruction(hde, trampoline_size, m_memory_instructions); + get_assemble_instruction(hde, trampoline_size, m_memory_instructions); } trampoline_size += hde.len; @@ -252,7 +264,7 @@ bool vuapi INLHookingX::attach(void* ptr_function, void* ptr_hook_function, void // Write the jump code (original -> new) on the top of the target function memcpy(ptr_function, (void*)&O2N, sizeof(O2N)); - return true; + return m_hooked = true; } bool vuapi INLHookingX::detach(void* ptr_function, void** pptr_old_function) @@ -295,9 +307,7 @@ bool vuapi INLHookingA::install( return false; } - m_hooked = this->attach(ptr_function, ptr_hook_function, pptr_old_function); - - return m_hooked; + return this->attach(ptr_function, ptr_hook_function, pptr_old_function); } bool vuapi INLHookingA::uninstall(