Good afternoon,
Been trying to do this in some c++, really hard tho, as it stops along the line, I have been wanting to code my own detour function, except I didn't know how to go about it
I saw something like this on some c++ site, just been trying and it's not giving me adequate results as I want it
I know this is a pascal forum, but I would be pasting some c/c++ code for your viewing so someone could assist in the creating of a good hooking / detour function for me please.
void *DetourFunction (BYTE *src, const BYTE *dst, const int len)
{
BYTE *jmp = (BYTE*)malloc(len+5);
DWORD dwBack;
VirtualProtect(src, len, PAGE_EXECUTE_READWRITE, &dwBack);
memcpy(jmp, src, len);
jmp += len;
jmp[0] = 0xE9;
*(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;
src[0] = 0xE9;
*(DWORD*)(src+1) = (DWORD)(dst - src) - 5;
for (int i=5; i<len; i++)
src[i]=0x90;
VirtualProtect(src, len, dwBack, &dwBack);
return (jmp-len);
}
Thanking you in advance for your time.