Originally Posted by
|WE11ington|
O problema de detectar em seu caso não sei te dizer o que é, pois bem, não sei como esta o seu código após esse trecho que você mencionou. Mas em Windows 7 32 Bits, funciona dessa maneira com esse detour modo:
Code:
LPVOID DetourCreate( PBYTE pbTargetFunction, PBYTE pbDetourFunction, INT intSize )
{
DWORD dwProtect;
PBYTE pbDetour = ( PBYTE )malloc( intSize + 5 );
VirtualProtect( pbTargetFunction, intSize, PAGE_EXECUTE_READWRITE, &dwProtect );
memcpy( pbDetour, pbTargetFunction, intSize );
pbDetour += intSize;
*( BYTE * ) ( pbDetour + 0 ) = 0xE9;
*( DWORD * )( pbDetour + 1 ) = ( DWORD )( pbTargetFunction + intSize - pbDetour ) - 5;
*( BYTE * ) ( pbTargetFunction + 0 ) = 0xB8;
*( DWORD * )( pbTargetFunction + 1 ) = ( DWORD )( pbDetourFunction );
*( WORD * ) ( pbTargetFunction + 5 ) = 0xE0FF;
for( INT i = 7; i < intSize; i++ )
*( BYTE * )( pbTargetFunction + i ) = 0x90;
VirtualProtect( pbTargetFunction, intSize, dwProtect, &dwProtect );
return ( pbDetour - intSize );
}
Code:
DWORD vTable[2] = {0};
CreateDevice(vTable);
oReset = ( tReset ) DetourCreate( ( PBYTE )vTable[16], ( PBYTE )&ResetDevice, ResetSize );
oPresent = ( tPresent ) DetourCreate( ( PBYTE )vTable[17], ( PBYTE )&PresetDevice, PresentSize );
Windows 7 32 e 64 Bits.
ResetSize com esses valores: 11, 12, 13 e 16.
PresentSize com esses valores: 7 e 10.
Aqui testei com sua Detour e todos os números no ResetSize e PresntSize e deu DC, ai eu fiz funcionar assim, porem da 1 minuto dentro do Jogo ele da Conexão Encerrada:
Code:
VOID *DetourJUMP(BYTE *src, CONST BYTE *dst, CONST INT len)
{
DWORD dwback;
VirtualProtect(src, len, PAGE_READWRITE, &dwback);
BYTE *jmp = (BYTE *)malloc(len + 5);
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;
return(jmp - len);
}
void Hook(void)
{
DWORD vTable[2] = {0};
CreateDevice(vTable);
#define ResetSize 5
#define PresentSize 5
#define DetourType DetourJUMP
#define DetourVar1 0
#define DetourVar2 1
oReset = ( tReset ) DetourType( ( PBYTE )vTable[DetourVar1], ( PBYTE )&ResetDevice, ResetSize );
oPresent = ( tPresent ) DetourType( ( PBYTE )vTable[DetourVar2], ( PBYTE )&PresetDevice, PresentSize );
}