
Originally Posted by
Disconect
Win 7 32bits
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.