mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-22 23:48:08 -05:00
Operation Big Sister - Make TodoReturn a struct and disallow modifying TodoReturn functions
This commit is contained in:
parent
7155705f35
commit
f3267b0f43
3 changed files with 57 additions and 23 deletions
|
@ -1,6 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
using TodoReturn = void;
|
||||
struct TodoReturnPlaceholder {};
|
||||
|
||||
using TodoReturn = TodoReturnPlaceholder;
|
||||
|
||||
// thanks pie
|
||||
enum class SearchType {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
#include "AsStaticFunction.hpp"
|
||||
#include "Field.hpp"
|
||||
#include <Geode/Enums.hpp>
|
||||
#include "IDManager.hpp"
|
||||
|
||||
#include <Geode/loader/Loader.hpp>
|
||||
|
@ -10,10 +11,18 @@
|
|||
|
||||
#define GEODE_APPLY_MODIFY_FOR_FUNCTION(AddressInline_, Convention_, ClassName_, FunctionName_, ...) \
|
||||
do { \
|
||||
if constexpr (Unique::different< \
|
||||
static auto constexpr different = Unique::different< \
|
||||
Resolve<__VA_ARGS__>::func(&Base::FunctionName_), \
|
||||
Resolve<__VA_ARGS__>::func(&Derived::FunctionName_)>()) { \
|
||||
Resolve<__VA_ARGS__>::func(&Derived::FunctionName_) \
|
||||
>(); \
|
||||
using BaseFuncType = decltype(Resolve<__VA_ARGS__>::func(&Base::FunctionName_)); \
|
||||
using DerivedFuncType = decltype(Resolve<__VA_ARGS__>::func(&Derived::FunctionName_)); \
|
||||
if constexpr (different) { \
|
||||
static auto address = AddressInline_; \
|
||||
static_assert(!different || !std::is_same_v<typename ReturnType<BaseFuncType>::type, TodoReturn>, \
|
||||
"Function" #ClassName_ "::" #FunctionName_ " has a TodoReturn type, " \
|
||||
"please fix it by editing the bindings." \
|
||||
); \
|
||||
if (address == 0) { \
|
||||
log::error( \
|
||||
"Address of {} returned nullptr, can't hook", #ClassName_ "::" #FunctionName_ \
|
||||
|
@ -24,7 +33,7 @@
|
|||
reinterpret_cast<void*>(address), \
|
||||
AsStaticFunction_##FunctionName_< \
|
||||
Derived, \
|
||||
decltype(Resolve<__VA_ARGS__>::func(&Derived::FunctionName_))>::value, \
|
||||
DerivedFuncType>::value, \
|
||||
#ClassName_ "::" #FunctionName_, \
|
||||
tulip::hook::TulipConvention::Convention_ \
|
||||
); \
|
||||
|
|
|
@ -166,6 +166,29 @@ namespace geode::modifier {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the return type of a given resolved function pointer.
|
||||
*/
|
||||
template <class Func>
|
||||
struct ReturnType {
|
||||
using type = void;
|
||||
};
|
||||
|
||||
template <class Return, class... Params>
|
||||
struct ReturnType<Return(*)(Params...)> {
|
||||
using type = Return;
|
||||
};
|
||||
|
||||
template <class Return, class Class, class... Params>
|
||||
struct ReturnType<Return(Class::*)(Params...)> {
|
||||
using type = Return;
|
||||
};
|
||||
|
||||
template <class Return, class Class, class... Params>
|
||||
struct ReturnType<Return(Class::*)(Params...) const> {
|
||||
using type = Return;
|
||||
};
|
||||
|
||||
/**
|
||||
* A specialization for giving the variadic types as a single type with the
|
||||
* function type. The return type is ignored.
|
||||
|
|
Loading…
Reference in a new issue