Code:
void WriteMemory(PVOID dwAdd, void *val, int bytes)
{
DWORD d, ds;
VirtualProtect(dwAdd, bytes, PAGE_EXECUTE_READWRITE, &d);
memcpy(dwAdd, val, bytes);
VirtualProtect(dwAdd,bytes,d,&ds);
}
LPVOID DetourCreate(LPVOID lpFuncOrig, LPVOID lpFuncDetour)
{
LPBYTE Jmp,Org; DWORD dwBack; INT len;
BYTE * pFuncOrig = (BYTE *)lpFuncOrig;
BYTE * pFuncDetour = (BYTE *)lpFuncDetour;
len = (pFuncOrig,6);
Org = Jmp = (LPBYTE)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,len+6);
Jmp[0] = (BYTE)len;
Jmp++;
VirtualProtect(pFuncOrig,len, PAGE_READWRITE,&dwBack);
WriteMemory(Jmp,pFuncOrig,len); //Function at top
Jmp += len;
Jmp[0] = 0xE9;
*(DWORD*)(Jmp+1) = (DWORD)(pFuncOrig + len - Jmp) - 5;
pFuncOrig[0] = 0x68;
*(DWORD*)(pFuncOrig+1) = (DWORD)(pFuncDetour);
pFuncOrig[5] = 0xC3;
for (int i = 6; i<len; i++) pFuncOrig[i] = 0x90;
VirtualProtect(pFuncOrig,len,dwBack,&dwBack);
return &Org[1];
}
Then where your old hook (w/ detour) was.. put this:
Code:
DetourCreate((PBYTE)VTable[16], ( BYTE* )gellPresent); //First option is VTable stuf.... 42 for endscene, 17 for present, 16 for reset, 82 for DIP... ,Second option would be name of w/e it is.. endscene, beginscene, present, reset, DIP, etc etc