You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since you still want to make sure your hook gets called,
60
-
no care about if the final function got called or not we introduce the "after" hooks.
60
+
no care about whether the final function got called or not we introduce the "after" hooks.
61
61
These hooks get all called after the normal hook calls and only allow you to
62
62
read the parameters as well as the resulting return value.
63
63
That means you can't influence the final function call.
64
64
Also, don't use the TCallScope object, instead the first parameter of your hooks signature
65
-
is the return value following by the function call parameters.
65
+
is the return value followed by the function call parameters.
66
66
67
67
[source,cpp]
68
68
----
@@ -76,7 +76,7 @@ void hook(int returnValue, int exampleArg) {
76
76
By 'hook types' we mean the different ways of attaching a hook to a function.
77
77
Each attachment method works differently under the hood, and it's important to pay attention to the key differences between the different types of hooks.
78
78
79
-
Be aware that type of return values and parameters etc has nothing to do with each other or if it is a member function, you can use them in any way.
79
+
Be aware that the type of return values and parameters etc has nothing to do with each other or if it is a member function, you can use them in any way.
80
80
Note that the Hook function is a std::function, which means that it can be any type a std::function can accept, such as function pointers, function pointers with bound placeholders, or even lambdas.
81
81
82
82
[IMPORTANT]
@@ -94,7 +94,7 @@ if (!WITH_EDITOR) {
94
94
}
95
95
----
96
96
97
-
Using `#if !WITH_EDITOR` and `#endif` directives is also an option, but it is not recommended: it hides errors until building shipping and confuses IDEs, making development and debugging slightly more annoying with no benefit.
97
+
Using `#if !WITH_EDITOR` and `#endif` directives are also an option, but it is not recommended: they hide errors until building shipping and confuse IDEs, making development and debugging slightly more annoying with no benefit.
98
98
====
99
99
100
100
=== Type: SUBSCRIBE_METHOD
@@ -105,7 +105,7 @@ such that the code you pass will be called before the function executes.
105
105
If multiple mods have subscribed to the same function,
106
106
the hooks will be called in the order they were registered.
107
107
108
-
Usage goes as following:
108
+
Usage goes as follows:
109
109
110
110
[source,cpp]
111
111
----
@@ -131,7 +131,7 @@ void registerHooks() {
131
131
[WARNING]
132
132
====
133
133
Hooking an overloaded function might not work as intended since the compiler has no clue what exact symbol you now want to hook.
134
-
For that you should have an look at the `SUBSCRIBE_METHOD_MANUAL`-Macro which allows you
134
+
For that, you should have a look at the `SUBSCRIBE_METHOD_MANUAL`-Macro which allows you
135
135
to explicitly set the symbol you want to hook.
136
136
====
137
137
@@ -145,7 +145,7 @@ but the hook will still run if the hooked function is called by the overriding i
145
145
If the overriding implementation of a subclass does not "call super", you have to hook said subclass separately.
146
146
Because pure virtual functions do not have a proper function body, they cannot possibly be hooked.
147
147
148
-
Usage goes as following:
148
+
Usage goes as follows:
149
149
150
150
[source,cpp]
151
151
----
@@ -162,7 +162,7 @@ public:
162
162
#include "Patching/NativeHookManager.h"
163
163
164
164
void registerHooks() {
165
-
SomeClass* SampleObject = new SomeClass(); // For UObject derived classes, use SUBSCRIBE_UOBJECT_METHOD instead
165
+
SomeClass* SampleObject = GetMutableDefault<SomeClass>(); // For UObject derived classes, use SUBSCRIBE_UOBJECT_METHOD instead
166
166
SUBSCRIBE_METHOD_VIRTUAL(SomeClass::MemberFunction, SampleObject, [](auto& scope, SomeClass* self, int arg1) {
167
167
// do some nice stuff there
168
168
});
@@ -192,8 +192,10 @@ For "after" hooks, add the `_AFTER` postfix to the macro names.
192
192
193
193
Be aware that the hook function signature changes accordingly and will no longer need the "scope":
0 commit comments