mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-26 17:36:05 -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
|
#pragma once
|
||||||
|
|
||||||
using TodoReturn = void;
|
struct TodoReturnPlaceholder {};
|
||||||
|
|
||||||
|
using TodoReturn = TodoReturnPlaceholder;
|
||||||
|
|
||||||
// thanks pie
|
// thanks pie
|
||||||
enum class SearchType {
|
enum class SearchType {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "AsStaticFunction.hpp"
|
#include "AsStaticFunction.hpp"
|
||||||
#include "Field.hpp"
|
#include "Field.hpp"
|
||||||
|
#include <Geode/Enums.hpp>
|
||||||
#include "IDManager.hpp"
|
#include "IDManager.hpp"
|
||||||
|
|
||||||
#include <Geode/loader/Loader.hpp>
|
#include <Geode/loader/Loader.hpp>
|
||||||
|
@ -8,28 +9,36 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <tulip/TulipHook.hpp>
|
#include <tulip/TulipHook.hpp>
|
||||||
|
|
||||||
#define GEODE_APPLY_MODIFY_FOR_FUNCTION(AddressInline_, Convention_, ClassName_, FunctionName_, ...) \
|
#define GEODE_APPLY_MODIFY_FOR_FUNCTION(AddressInline_, Convention_, ClassName_, FunctionName_, ...) \
|
||||||
do { \
|
do { \
|
||||||
if constexpr (Unique::different< \
|
static auto constexpr different = Unique::different< \
|
||||||
Resolve<__VA_ARGS__>::func(&Base::FunctionName_), \
|
Resolve<__VA_ARGS__>::func(&Base::FunctionName_), \
|
||||||
Resolve<__VA_ARGS__>::func(&Derived::FunctionName_)>()) { \
|
Resolve<__VA_ARGS__>::func(&Derived::FunctionName_) \
|
||||||
static auto address = AddressInline_; \
|
>(); \
|
||||||
if (address == 0) { \
|
using BaseFuncType = decltype(Resolve<__VA_ARGS__>::func(&Base::FunctionName_)); \
|
||||||
log::error( \
|
using DerivedFuncType = decltype(Resolve<__VA_ARGS__>::func(&Derived::FunctionName_)); \
|
||||||
"Address of {} returned nullptr, can't hook", #ClassName_ "::" #FunctionName_ \
|
if constexpr (different) { \
|
||||||
); \
|
static auto address = AddressInline_; \
|
||||||
break; \
|
static_assert(!different || !std::is_same_v<typename ReturnType<BaseFuncType>::type, TodoReturn>, \
|
||||||
} \
|
"Function" #ClassName_ "::" #FunctionName_ " has a TodoReturn type, " \
|
||||||
auto hook = Hook::create( \
|
"please fix it by editing the bindings." \
|
||||||
reinterpret_cast<void*>(address), \
|
); \
|
||||||
AsStaticFunction_##FunctionName_< \
|
if (address == 0) { \
|
||||||
Derived, \
|
log::error( \
|
||||||
decltype(Resolve<__VA_ARGS__>::func(&Derived::FunctionName_))>::value, \
|
"Address of {} returned nullptr, can't hook", #ClassName_ "::" #FunctionName_ \
|
||||||
#ClassName_ "::" #FunctionName_, \
|
); \
|
||||||
tulip::hook::TulipConvention::Convention_ \
|
break; \
|
||||||
); \
|
} \
|
||||||
this->m_hooks[#ClassName_ "::" #FunctionName_] = hook; \
|
auto hook = Hook::create( \
|
||||||
} \
|
reinterpret_cast<void*>(address), \
|
||||||
|
AsStaticFunction_##FunctionName_< \
|
||||||
|
Derived, \
|
||||||
|
DerivedFuncType>::value, \
|
||||||
|
#ClassName_ "::" #FunctionName_, \
|
||||||
|
tulip::hook::TulipConvention::Convention_ \
|
||||||
|
); \
|
||||||
|
this->m_hooks[#ClassName_ "::" #FunctionName_] = hook; \
|
||||||
|
} \
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
#define GEODE_APPLY_MODIFY_FOR_CONSTRUCTOR(AddressInline_, Convention_, ClassName_, ...) \
|
#define GEODE_APPLY_MODIFY_FOR_CONSTRUCTOR(AddressInline_, Convention_, ClassName_, ...) \
|
||||||
|
|
|
@ -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
|
* A specialization for giving the variadic types as a single type with the
|
||||||
* function type. The return type is ignored.
|
* function type. The return type is ignored.
|
||||||
|
|
Loading…
Reference in a new issue