44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#ifndef AE625BF8_B0F9_452E_8772_8819F311CB57
|
|
#define AE625BF8_B0F9_452E_8772_8819F311CB57
|
|
|
|
#include <stdexcept>
|
|
|
|
struct GHStubException : public std::exception {
|
|
GHStubException(const char *msg);
|
|
};
|
|
|
|
void *gh_stub_impl_ptr(void *ptr);
|
|
|
|
template <typename T, typename... Args>
|
|
T gh_stub_impl_cdecl(void *ptr_, Args... args) {
|
|
#if RE_DBG_INJECTED
|
|
#if MSVC
|
|
static T (*__cdecl ptr)(Args...) = (T(*)(Args...))gh_stub_impl_ptr(ptr_);
|
|
#else
|
|
using TFn = __cdecl T (*)(Args...);
|
|
static TFn ptr = (TFn)gh_stub_impl_ptr(ptr_);
|
|
#endif
|
|
return ptr(args...);
|
|
#else
|
|
throw GHStubException("Function not implemented");
|
|
#endif
|
|
}
|
|
|
|
template <typename T, typename... Args>
|
|
T gh_stub_impl_stdcall(void *ptr_, Args... args) {
|
|
#if RE_DBG_INJECTED
|
|
#if MSVC
|
|
static T (*__stdcall ptr)(Args...) =
|
|
(T(*__stdcall)(Args...))gh_stub_impl_ptr(ptr_);
|
|
#else
|
|
using TFn = __stdcall T (*)(Args...);
|
|
static TFn ptr = (TFn)gh_stub_impl_ptr(ptr_);
|
|
#endif
|
|
return ptr(args...);
|
|
#else
|
|
throw GHStubException("Function not implemented");
|
|
#endif
|
|
}
|
|
|
|
#endif /* AE625BF8_B0F9_452E_8772_8819F311CB57 */
|