Skip to content

Commit

Permalink
Sort functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Smertig committed Mar 20, 2023
1 parent 8ee2d8b commit e2d154b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
18 changes: 9 additions & 9 deletions include/rcmp/detail/hook_policy/indirect_policy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ struct HookIndirectPolicy {

#if defined(RCMP_HAS_HOOK_INDIRECT_POLICY)

template <class Tag, class Signature, class F>
void hook_indirect_function(rcmp::address_t indirect_function_address, F&& hook) {
using wrapped_policy_t = detail::WithGlobalState<
detail::HookIndirectPolicy,
Tag
>;
rcmp::generic_hook_function<wrapped_policy_t::template Policy, Signature>(indirect_function_address, std::forward<F>(hook));
}

template <auto IndirectFunctionAddress, class Signature, class F>
void hook_indirect_function(F&& hook) {
static_assert(std::is_constructible_v<rcmp::address_t, decltype(IndirectFunctionAddress)>);
Expand All @@ -41,15 +50,6 @@ void hook_indirect_function(F&& hook) {
rcmp::generic_hook_function<wrapped_policy_t::template Policy, Signature>(IndirectFunctionAddress, std::forward<F>(hook));
}

template <class Tag, class Signature, class F>
void hook_indirect_function(rcmp::address_t indirect_function_address, F&& hook) {
using wrapped_policy_t = detail::WithGlobalState<
detail::HookIndirectPolicy,
Tag
>;
rcmp::generic_hook_function<wrapped_policy_t::template Policy, Signature>(indirect_function_address, std::forward<F>(hook));
}

template <class Signature, class F>
void hook_indirect_function(rcmp::address_t indirect_function_address, F&& hook) {
rcmp::hook_indirect_function<class Tag, Signature>(indirect_function_address, std::forward<F>(hook));
Expand Down
24 changes: 12 additions & 12 deletions include/rcmp/detail/hook_policy/prolog_policy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ struct HookPrologPolicy {
#if defined(RCMP_HAS_HOOK_PROLOG_POLICY)

// TODO: cleanup copy-paste
template <class Tag, class Signature, class F>
void hook_function(rcmp::address_t function_address, F&& hook) {
using wrapped_policy_t = detail::WithGlobalState<
detail::HookPrologPolicy,
Tag
>;
rcmp::generic_hook_function<
wrapped_policy_t::template Policy,
Signature
>(function_address, std::forward<F>(hook));
}

template <auto FunctionAddress, class Signature, class F>
void hook_function(F&& hook) {
static_assert(std::is_constructible_v<rcmp::address_t, decltype(FunctionAddress)>);
Expand All @@ -52,18 +64,6 @@ void hook_function(F&& hook) {
rcmp::generic_hook_function<wrapped_policy_t::template Policy, Signature>(rcmp::bit_cast<const void*>(Function), std::forward<F>(hook));
}

template <class Tag, class Signature, class F>
void hook_function(rcmp::address_t function_address, F&& hook) {
using wrapped_policy_t = detail::WithGlobalState<
detail::HookPrologPolicy,
Tag
>;
rcmp::generic_hook_function<
wrapped_policy_t::template Policy,
Signature
>(function_address, std::forward<F>(hook));
}

template <class Signature, class F>
void hook_function(rcmp::address_t function_address, F&& hook) {
rcmp::hook_function<class Tag, Signature>(function_address, std::forward<F>(hook));
Expand Down

0 comments on commit e2d154b

Please sign in to comment.