diff --git a/include/safetyhook/inline_hook.hpp b/include/safetyhook/inline_hook.hpp index b773d99..a9c38da 100644 --- a/include/safetyhook/inline_hook.hpp +++ b/include/safetyhook/inline_hook.hpp @@ -149,6 +149,10 @@ class InlineHook final { /// @return The address of the trampoline to call the original function. template [[nodiscard]] T original() const { return reinterpret_cast(m_trampoline.address()); } + /// @brief Returns a vector containing the original bytes of the target function. + /// @return A vector of the original bytes of the target function. + [[nodiscard]] const auto& original_bytes() const { return m_original_bytes; } + /// @brief Calls the original function. /// @tparam RetT The return type of the function. /// @tparam ...Args The argument types of the function. @@ -265,6 +269,8 @@ class InlineHook final { } private: + friend class MidHook; + uint8_t* m_target{}; uint8_t* m_destination{}; Allocation m_trampoline{}; diff --git a/include/safetyhook/mid_hook.hpp b/include/safetyhook/mid_hook.hpp index 4aa927c..2d4fcaa 100644 --- a/include/safetyhook/mid_hook.hpp +++ b/include/safetyhook/mid_hook.hpp @@ -111,6 +111,10 @@ class MidHook final { /// @return The destination function. [[nodiscard]] MidHookFn destination() const { return m_destination; } + /// @brief Returns a vector containing the original bytes of the target function. + /// @return A vector of the original bytes of the target function. + [[nodiscard]] const auto& original_bytes() const { return m_hook.m_original_bytes; } + /// @brief Tests if the hook is valid. /// @return true if the hook is valid, false otherwise. explicit operator bool() const { return static_cast(m_stub); }