// // Created by Vlad on 8/8/2025. // #pragma once #include #include namespace omath::rev_eng { class InternalReverseEngineeredObject { protected: template [[nodiscard]] Type& get_by_offset(const std::ptrdiff_t offset) { return *reinterpret_cast(reinterpret_cast(this) + offset); } template [[nodiscard]] const Type& get_by_offset(const std::ptrdiff_t offset) const { return *reinterpret_cast(reinterpret_cast(this) + offset); } template ReturnType call_virtual_method(Args&&... arg_list) { #ifdef _MSC_VER using VirtualMethodType = ReturnType(__thiscall*)(void*, decltype(arg_list)...); #else using VirtualMethodType = ReturnType (*)(void*, decltype(arg_list)...); #endif return (*reinterpret_cast(this))[id](this, std::forward(arg_list)...); } template ReturnType call_virtual_method(Args&&... arg_list) const { using This = std::remove_cv_t>; #ifdef _MSC_VER using VirtualMethodType = ReturnType(__thiscall*)(const void*, decltype(arg_list)...); #else using VirtualMethodType = ReturnType (*)(void*, decltype(arg_list)...); #endif return (*reinterpret_cast(const_cast(this)))[id]( const_cast(static_cast(this)), std::forward(arg_list)...); } }; } // namespace omath::rev_eng