From 0a4f9c80036b11199da79b6f14fdaa2dd71b10d6 Mon Sep 17 00:00:00 2001 From: Ruben Gonzalez Date: Sat, 3 Sep 2016 12:32:39 -0400 Subject: [PATCH] Remove useless code. Fix incorrect JMP being used and allocating 1 byte to many. --- core/detourhook/detourhook.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/core/detourhook/detourhook.cpp b/core/detourhook/detourhook.cpp index b344a87..3018dcd 100644 --- a/core/detourhook/detourhook.cpp +++ b/core/detourhook/detourhook.cpp @@ -2,11 +2,8 @@ #include #include "asm\asm.h" -//#include "asmjit\asmjit.h" using namespace DetourHook; -//using namespace asmjit; -//using namespace asmjit::x86; int CDetourHookImpl::GetIfaceVersion() { @@ -25,16 +22,16 @@ CDetourHook::CDetourHook(void *addr, void *callback) SourceHook::SetMemAccess(this->pFunc, this->bytes, SH_MEM_READ | SH_MEM_WRITE | SH_MEM_EXEC); memcpy(this->pOrginalBytes, this->pFunc, this->bytes); - this->pTrampoline = malloc(this->bytes + OP_JMP_SIZE + 1); //Allocate space + this->pTrampoline = malloc(this->bytes + OP_JMP_SIZE); //Allocate space - SourceHook::SetMemAccess(this->pTrampoline, bytes + OP_JMP_SIZE + 1, SH_MEM_READ | SH_MEM_WRITE | SH_MEM_EXEC); + SourceHook::SetMemAccess(this->pTrampoline, bytes + OP_JMP_SIZE, SH_MEM_READ | SH_MEM_WRITE | SH_MEM_EXEC); //Copy our original bytes to our trampoline //We use this to fix JMP's and whatever else is relative to the function. copy_bytes((unsigned char *)this->pFunc, (unsigned char *)this->pTrampoline, this->bytes); //JMP from trampoline +bytes to function + bytes - inject_abs_jmp((unsigned char*)this->pTrampoline + this->bytes, (unsigned char*)this->pFunc + this->bytes); + inject_jmp((unsigned char*)this->pTrampoline + this->bytes, (unsigned char*)this->pFunc + this->bytes); } CDetourHook::~CDetourHook()