From 7474c819587a138b458e898847fbce93e1dd1d65 Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Wed, 27 Dec 2023 11:43:04 +0100 Subject: pluginapi: Trampoline hooks %rip patching improvements (#4256) --------- Co-authored-by: Jan Beich --- src/plugins/HookSystem.hpp | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'src/plugins/HookSystem.hpp') diff --git a/src/plugins/HookSystem.hpp b/src/plugins/HookSystem.hpp index 00494733..8714ac32 100644 --- a/src/plugins/HookSystem.hpp +++ b/src/plugins/HookSystem.hpp @@ -22,21 +22,31 @@ class CFunctionHook { void* m_pOriginal = nullptr; private: - void* m_pSource = nullptr; - void* m_pFunctionAddr = nullptr; - void* m_pTrampolineAddr = nullptr; - void* m_pDestination = nullptr; - size_t m_iHookLen = 0; - size_t m_iTrampoLen = 0; - HANDLE m_pOwner = nullptr; - bool m_bActive = false; + void* m_pSource = nullptr; + void* m_pFunctionAddr = nullptr; + void* m_pTrampolineAddr = nullptr; + void* m_pDestination = nullptr; + size_t m_iHookLen = 0; + size_t m_iTrampoLen = 0; + HANDLE m_pOwner = nullptr; + bool m_bActive = false; - std::vector> m_vTrampolineRIPUses; + void* m_pOriginalBytes = nullptr; - void* m_pOriginalBytes = nullptr; + struct SInstructionProbe { + size_t len = 0; + std::string assembly = ""; + std::vector insSizes; + }; - size_t probeMinimumJumpSize(void* start, size_t min); - size_t getInstructionLenAt(void* start); + struct SAssembly { + std::vector bytes; + }; + + SInstructionProbe probeMinimumJumpSize(void* start, size_t min); + SInstructionProbe getInstructionLenAt(void* start); + + SAssembly fixInstructionProbeRIPCalls(const SInstructionProbe& probe); friend class CHookSystem; }; -- cgit v1.2.3