Fix callable symbols

This commit is contained in:
momo5502 2023-03-19 21:22:59 +01:00
parent 32040ce966
commit 638ea0862a

View File

@ -83,20 +83,24 @@ namespace game
}; };
template <typename T> template <typename T>
struct callable_symbol : base_symbol<T> struct symbol : base_symbol<T>
{ {
using base_symbol<T>::base_symbol; using base_symbol<T>::base_symbol;
template <typename... Args>
std::invoke_result_t<T> call_safe(Args... args)
{
arxan::detail::set_address_to_call(this->get());
return static_cast<T*>(arxan::detail::callstack_proxy_addr)(args...);
}
}; };
template <typename T> template <typename T, typename... Args>
using symbol = std::conditional_t<std::is_invocable_v<T>, callable_symbol<T>, base_symbol<T>>; struct symbol<T(Args...)> : base_symbol<T(Args...)>
{
using func_type = T(Args...);
using base_symbol<func_type>::base_symbol;
T call_safe(Args... args)
{
arxan::detail::set_address_to_call(this->get());
return static_cast<func_type*>(arxan::detail::callstack_proxy_addr)(args...);
}
};
std::filesystem::path get_appdata_path(); std::filesystem::path get_appdata_path();
} }