Upload New File

master
xerox 5 years ago
parent 992db93708
commit 289ed6a828

@ -0,0 +1,45 @@
#include "Hook.hpp"
#include <iostream>
namespace Hook
{
//--- default constructor
Detour::Detour(uintptr_t addrToHook, uintptr_t jmpTo)
: HookAddress(addrToHook), DetourAddress(jmpTo)
{
//finish the shellcode by adding the address to jmp to
*(uintptr_t*)(jmpCode + OFFSET_TO_ADDRESS) = jmpTo;
//save old bytes
memcpy(originalBytes, (void*)HookAddress, JMP_CODE_SIZE);
//install the hook.
InstallHook();
}
Detour::~Detour()
{UninstallHook();}
void Detour::InstallHook()
{
//install the hook.
WriteToReadOnly(HookAddress, (void *)jmpCode, JMP_CODE_SIZE);
isHookInstalled = true;
}
void Detour::UninstallHook()
{
//write the original bytes back.
WriteToReadOnly(HookAddress, originalBytes, JMP_CODE_SIZE);
isHookInstalled = false;
}
uintptr_t Detour::GetHookAddress()
{return HookAddress;}
uintptr_t Detour::GetDetourAddress()
{return DetourAddress;}
bool Detour::IsInstalled()
{return isHookInstalled;}
}
Loading…
Cancel
Save