Skip to content

Commit

Permalink
Allow different target and destination types
Browse files Browse the repository at this point in the history
  • Loading branch information
CrackedMatter committed Dec 20, 2024
1 parent 3d0f378 commit 7c70f1d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions include/safetyhook/easy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ namespace safetyhook {
/// @param destination The address of the destination function.
/// @param flags The flags to use.
/// @return The InlineHook object.
template <typename T>
[[nodiscard]] InlineHook create_inline(T target, T destination, InlineHook::Flags flags = InlineHook::Default) {
template <typename T, typename U>
[[nodiscard]] InlineHook create_inline(T target, U destination, InlineHook::Flags flags = InlineHook::Default) {
return create_inline(reinterpret_cast<void*>(target), reinterpret_cast<void*>(destination), flags);
}

Expand Down
8 changes: 4 additions & 4 deletions include/safetyhook/inline_hook.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ class InlineHook final {
/// @return The InlineHook or an InlineHook::Error if an error occurred.
/// @note This will use the default global Allocator.
/// @note If you don't care about error handling, use the easy API (safetyhook::create_inline).
template <typename T>
[[nodiscard]] static std::expected<InlineHook, Error> create(T target, T destination, Flags flags = Default) {
template <typename T, typename U>
[[nodiscard]] static std::expected<InlineHook, Error> create(T target, U destination, Flags flags = Default) {
return create(reinterpret_cast<void*>(target), reinterpret_cast<void*>(destination), flags);
}

Expand All @@ -132,9 +132,9 @@ class InlineHook final {
/// @param flags The flags to use.
/// @return The InlineHook or an InlineHook::Error if an error occurred.
/// @note If you don't care about error handling, use the easy API (safetyhook::create_inline).
template <typename T>
template <typename T, typename U>
[[nodiscard]] static std::expected<InlineHook, Error> create(
const std::shared_ptr<Allocator>& allocator, T target, T destination, Flags flags = Default) {
const std::shared_ptr<Allocator>& allocator, T target, U destination, Flags flags = Default) {
return create(allocator, reinterpret_cast<void*>(target), reinterpret_cast<void*>(destination), flags);
}

Expand Down

0 comments on commit 7c70f1d

Please sign in to comment.