46 lines
1.2 KiB
C++
46 lines
1.2 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);
|
|
|
|
typedef uintptr_t stub_t;
|
|
|
|
template <stub_t addr, typename T, typename... Args> struct TStubFunctionImpl {
|
|
typedef T (*TFn)(Args...);
|
|
static inline TFn ptr = (TFn)gh_stub_impl_ptr((void *)addr);
|
|
};
|
|
|
|
template <stub_t addr, typename T, typename... Args>
|
|
struct TStubFunctionImplStdCall {
|
|
typedef T (*__stdcall TFn)(Args...);
|
|
static inline TFn ptr = (TFn)gh_stub_impl_ptr((void *)addr);
|
|
};
|
|
|
|
template <stub_t addr, typename T, typename... Args>
|
|
T gh_stub_impl_cdecl(Args... args) {
|
|
#if RE_DBG_INJECTED
|
|
auto ptr = TStubFunctionImpl<addr, T, Args...>::ptr;
|
|
return ptr(args...);
|
|
#else
|
|
throw GHStubException("Function not implemented");
|
|
#endif
|
|
}
|
|
|
|
template <stub_t addr, typename T, typename... Args>
|
|
T gh_stub_impl_stdcall(Args... args) {
|
|
#if RE_DBG_INJECTED
|
|
auto ptr = TStubFunctionImplStdCall<addr, T, Args...>::ptr;
|
|
return ptr(args...);
|
|
#else
|
|
throw GHStubException("Function not implemented");
|
|
#endif
|
|
}
|
|
|
|
#endif /* AE625BF8_B0F9_452E_8772_8819F311CB57 */
|