TmpMenu/src/invoker.hpp
maybegreat48 97a8c5d60b Add more spoofing options and added clang-format (#1020)
* feat(Spoofing): add spoofing
* feat(Spoofing): prepare code for player attach
* remove(PlayerAttach): isn't going to work due to netsync architecture
* fix(GUI): fix scaling
* feat(Project): add clang-format file
* feat(Classes): update classes
* fix(BlackHole): remove unnecessary cleanup
* fix(Formatting): fix formatting for initializer lists
* feat(clang-format): Set tab width and 1 space before comment

Co-authored-by: Yimura <24669514+Yimura@users.noreply.github.com>
2023-03-01 21:27:15 +00:00

48 lines
898 B
C++

#pragma once
#include "common.hpp"
#include "gta/natives.hpp"
namespace big
{
class native_call_context : public rage::scrNativeCallContext
{
public:
native_call_context();
private:
std::uint64_t m_return_stack[10];
std::uint64_t m_arg_stack[100];
};
class native_invoker
{
public:
explicit native_invoker() = default;
~native_invoker() = default;
void cache_handlers();
void begin_call();
void end_call(rage::scrNativeHash hash);
template<typename T>
void push_arg(T&& value)
{
m_call_context.push_arg(std::forward<T>(value));
}
template<typename T>
T& get_return_value()
{
return *m_call_context.get_return_value<T>();
}
private:
native_call_context m_call_context;
std::unordered_map<rage::scrNativeHash, rage::scrNativeHandler> m_handler_cache;
bool m_handlers_cached = false;
};
inline native_invoker g_native_invoker;
}