added external class

This commit is contained in:
2025-10-04 09:47:48 +03:00
parent 70f2f90100
commit 46457b81ac
3 changed files with 68 additions and 27 deletions

View File

@@ -0,0 +1,33 @@
//
// Created by Vlad on 8/8/2025.
//
#pragma once
#include <cstddef>
#include <cstdint>
namespace omath::rev_eng
{
class InternalReverseEngineeredObject
{
protected:
template<class Type>
[[nodiscard]] Type& get_by_offset(const std::ptrdiff_t offset)
{
return *reinterpret_cast<Type*>(reinterpret_cast<std::uintptr_t>(this) + offset);
}
template<class Type>
[[nodiscard]] const Type& get_by_offset(const std::ptrdiff_t offset) const
{
return *reinterpret_cast<Type*>(reinterpret_cast<std::uintptr_t>(this) + offset);
}
template<std::size_t id, class ReturnType>
ReturnType call_virtual_method(auto&&... arg_list)
{
using VirtualMethodType = ReturnType(__thiscall*)(void*, decltype(arg_list)...);
return (*static_cast<VirtualMethodType**>(this))[id](this, arg_list...);
}
};
} // namespace omath::rev_eng