Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NativeHookManager: Add more "explicit" hook macros #303

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Mods/SML/Source/SML/Public/Patching/NativeHookManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,18 @@ using CallScope = TCallScope<T>;
return HookInvoker<decltype(&MethodReference), &MethodReference>::AddHandlerAfter(Handler); \
} )

#define SUBSCRIBE_METHOD_EXPLICIT(MethodSignature, MethodReference, Handler) \
Invoke( [&]() { \
HookInvoker<MethodSignature, &MethodReference>::InstallHook(TEXT(#MethodReference)); \
return HookInvoker<MethodSignature, &MethodReference>::AddHandlerBefore(Handler); \
} )

#define SUBSCRIBE_METHOD_EXPLICIT_AFTER(MethodSignature, MethodReference, Handler) \
Invoke( [&]() { \
HookInvoker<MethodSignature, &MethodReference>::InstallHook(TEXT(#MethodReference)); \
return HookInvoker<MethodSignature, &MethodReference>::AddHandlerAfter(Handler); \
} )

#define SUBSCRIBE_METHOD_VIRTUAL(MethodReference, SampleObjectInstance, Handler) \
Invoke( [&]() { \
HookInvoker<decltype(&MethodReference), &MethodReference>::InstallHook(TEXT(#MethodReference), SampleObjectInstance); \
Expand All @@ -598,6 +610,12 @@ using CallScope = TCallScope<T>;
return HookInvoker<decltype(&MethodReference), &MethodReference>::AddHandlerAfter(Handler); \
} )

#define SUBSCRIBE_METHOD_EXPLICIT_VIRTUAL(MethodSignature, MethodReference, SampleObjectInstance, Handler) \
Invoke( [&]() { \
HookInvoker<MethodSignature, &MethodReference>::InstallHook(TEXT(#MethodReference), SampleObjectInstance); \
return HookInvoker<MethodSignature, &MethodReference>::AddHandlerBefore(Handler); \
} )

#define SUBSCRIBE_METHOD_EXPLICIT_VIRTUAL_AFTER(MethodSignature, MethodReference, SampleObjectInstance, Handler) \
Invoke( [&]() { \
HookInvoker<MethodSignature, &MethodReference>::InstallHook(TEXT(#MethodReference), SampleObjectInstance); \
Expand All @@ -616,8 +634,26 @@ using CallScope = TCallScope<T>;
return HookInvoker<decltype(&ObjectClass::MethodName), &ObjectClass::MethodName>::AddHandlerAfter(Handler); \
} )

#define SUBSCRIBE_UOBJECT_METHOD_EXPLICIT(MethodSignature, ObjectClass, MethodName, Handler) \
Invoke( [&]() { \
HookInvoker<MethodSignature, &ObjectClass::MethodName>::InstallHook(TEXT(#ObjectClass "::" #MethodName), GetDefault<ObjectClass>()); \
return HookInvoker<MethodSignature, &ObjectClass::MethodName>::AddHandlerBefore(Handler); \
} )

#define SUBSCRIBE_UOBJECT_METHOD_EXPLICIT_AFTER(MethodSignature, ObjectClass, MethodName, Handler) \
Invoke( [&]() { \
HookInvoker<MethodSignature, &ObjectClass::MethodName>::InstallHook(TEXT(#ObjectClass "::" #MethodName), GetDefault<ObjectClass>()); \
return HookInvoker<MethodSignature, &ObjectClass::MethodName>::AddHandlerAfter(Handler); \
} )

#define UNSUBSCRIBE_METHOD(MethodReference, HandlerHandle) \
HookInvoker<decltype(&MethodReference), &MethodReference>::RemoveHandler(TEXT(#MethodReference), HandlerHandle )

#define UNSUBSCRIBE_METHOD_EXPLICIT(MethodSignature, MethodReference, HandlerHandle) \
HookInvoker<MethodSignature, &MethodReference>::RemoveHandler(TEXT(#MethodReference), HandlerHandle )

#define UNSUBSCRIBE_UOBJECT_METHOD(ObjectClass, MethodName, HandlerHandle) \
HookInvoker<decltype(&ObjectClass::MethodName), &ObjectClass::MethodName>::RemoveHandler(TEXT(#ObjectClass "::" #MethodName), HandlerHandle )

#define UNSUBSCRIBE_UOBJECT_METHOD_EXPLICIT(MethodSignature, ObjectClass, MethodName, HandlerHandle) \
HookInvoker<MethodSignature, &ObjectClass::MethodName>::RemoveHandler(TEXT(#ObjectClass "::" #MethodName), HandlerHandle )
Loading