mirror of
https://git.recroomarchive.org/Radium/libradhook.git
synced 2026-08-07 09:10:59 +00:00
feat: added capability for finding handle from target pointer
This commit is contained in:
@@ -42,6 +42,7 @@ enum class RadHookResult : int {
|
||||
InvalidHandle,
|
||||
TrampolineTooFar,
|
||||
TargetTooSmall,
|
||||
UnknownTarget,
|
||||
Unknown,
|
||||
};
|
||||
|
||||
@@ -412,4 +413,46 @@ RADHOOK_API
|
||||
RadHookResult
|
||||
RadHookApplyQueued();
|
||||
|
||||
_Success_(return == RadHookResult::Success)
|
||||
/**
|
||||
* @brief Finds a hook handle from a specified target.
|
||||
*
|
||||
* @param target Target.
|
||||
* @param outHandle Receives the hook handle on success.
|
||||
*
|
||||
* @return Operation result.
|
||||
*/
|
||||
RADHOOK_API
|
||||
RadHookResult
|
||||
RadHookGetHandleFromTarget(
|
||||
_In_ void* target,
|
||||
_Out_ RadHookHandle* outHandle
|
||||
);
|
||||
|
||||
_Success_(return == RadHookResult::Success)
|
||||
/**
|
||||
* @brief Finds a hook handle from a specified target function pointer.
|
||||
*
|
||||
* Convenience overload that accepts a typed function pointer for the target.
|
||||
*
|
||||
* @tparam TargetFn Target function pointer type.
|
||||
* @param target Target function.
|
||||
* @param outHandle Receives the hook handle on success.
|
||||
*
|
||||
* @return Operation result.
|
||||
*/
|
||||
template <typename TargetFn>
|
||||
requires std::is_function_v<std::remove_pointer_t<TargetFn>>
|
||||
RadHookResult
|
||||
RadHookGetHandleFromTarget(
|
||||
TargetFn target,
|
||||
_Out_ RadHookHandle* outHandle
|
||||
)
|
||||
{
|
||||
return RadHookGetHandleFromTarget(
|
||||
reinterpret_cast<void*>(target),
|
||||
outHandle
|
||||
);
|
||||
}
|
||||
|
||||
#endif // __LIBRADHOOK_API_H__
|
||||
Reference in New Issue
Block a user