Statistics We have 934 registered users The newest registered user is chickas4513 Our users have posted a total of 344 messages in 84 subjects
Hook EndScene Engine
Author Message ThaBot Pro
Posts : 63AP : 2147528267Join date : 04/09/2012 Subject: Hook EndScene Engine Sat Oct 27, 2012 9:59 am Code: #include <windows.h> #include <d3d9.h> #include <d3dx9.h> #pragma comment(lib, "d3d9.lib") #pragma comment(lib, "d3dx9.lib") #define EndSceneEngine 0x00455ECF DWORD retEndSceneEngine = ( EndSceneEngine + 0x8 ); #define Red D3DCOLOR_ARGB( 255, 255, 000, 000 ) #define Green D3DCOLOR_ARGB( 255, 000, 255, 000 ) #define Blue D3DCOLOR_ARGB( 255, 000, 000, 255 ) #define Black D3DCOLOR_ARGB( 255, 000, 000, 000 ) LPD3DXFONT Font; VOID StartFont( LPDIRECT3DDEVICE9 pDevice ) { if( Font ) { Font->Release(); Font = NULL; } if( !Font ) { D3DXCreateFont( pDevice, 14, 0, FW_BOLD, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &Font ); } } VOID WriteText( LPDIRECT3DDEVICE9 pDevice, INT x, INT y, DWORD color, CHAR *text ) { RECT rect; SetRect( &rect, x, y, x, y ); Font->DrawText( NULL, text, -1, &rect, DT_NOCLIP | DT_LEFT, color ); } __declspec( naked ) HRESULT WINAPI EndSceneMidfunction( ) { static LPDIRECT3DDEVICE9 pDevice; __asm { MOV ECX, DWORD PTR DS:[EAX] MOV EDX, DWORD PTR DS:[ECX + 0xA8] MOV DWORD PTR DS:[pDevice], EAX PUSHAD } StartFont( pDevice ); if( Font ) WriteText( pDevice, 300, 300, Red, "CrossFire: Hook EndScene Engine" ); __asm { POPAD JMP retEndSceneEngine } } VOID *DetourCreate( BYTE *src, CONST BYTE *dst, CONST INT len ) { BYTE *jmp =( BYTE * ) malloc( len + 5 ); DWORD dwBack; VirtualProtect( src, len, PAGE_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 ); } DWORD WINAPI StartRoutine( LPVOID ) { while( TRUE ) { if( memcmp( ( VOID * )EndSceneEngine, ( VOID * )( PBYTE )"\x8B\x08", 2 ) == 0 ) { Sleep( 100 ); DetourCreate( ( PBYTE )EndSceneEngine, ( PBYTE )EndSceneMidfunction, 8 ); } Sleep( 50 ); } return 0; } BOOL WINAPI DllMain( HMODULE hDll, DWORD dwReason, LPVOID lpReserved ) { if( dwReason == DLL_PROCESS_ATTACH ) { DisableThreadLibraryCalls( hDll ); MessageBox( 0, "Hook EndScene Engine", "Crossfire", 0 ); CreateThread( 0, 0, (LPTHREAD_START_ROUTINE)StartRoutine, 0, 0, 0 ); } return TRUE; }
Code: EndScene: 00455E80 6A FF PUSH -1 00455E82 68 28B96200 PUSH 62B928 00455E87 64:A1 00000000 MOV EAX,DWORD PTR FS:[0] 00455E8D 50 PUSH EAX 00455E8E 51 PUSH ECX 00455E8F 53 PUSH EBX 00455E90 A1 40446A00 MOV EAX,DWORD PTR DS:[6A4440] 00455E95 33C4 XOR EAX,ESP 00455E97 50 PUSH EAX 00455E98 8D4424 0C LEA EAX,DWORD PTR SS:[ESP+C] 00455E9C 64:A3 00000000 MOV DWORD PTR FS:[0],EAX 00455EA2 68 F82F6C00 PUSH 6C2FF8 00455EA7 8D4C24 0C LEA ECX,DWORD PTR SS:[ESP+C] 00455EAB E8 200EFCFF CALL 416CD0 00455EB0 33C9 XOR ECX,ECX 00455EB2 894C24 14 MOV DWORD PTR SS:[ESP+14],ECX 00455EB6 380D F42F6C00 CMP BYTE PTR DS:[6C2FF4],CL 00455EBC 74 3D JE SHORT 455EFB 00455EBE A1 702E6C00 MOV EAX,DWORD PTR DS:[6C2E70]=> DeviceGame 00455EC3 3BC1 CMP EAX,ECX 00455EC5 74 34 JE SHORT 455EFB 00455EC7 880D F42F6C00 MOV BYTE PTR DS:[6C2FF4],CL 00455ECD 8B00 MOV EAX,DWORD PTR DS:[EAX] 00455ECF 8B08 MOV ECX,DWORD PTR DS:[EAX] => this is the code! 00455ED1 8B91 A8000000 MOV EDX,DWORD PTR DS:[ECX+A8]=> EndScene 00455ED7 50 PUSH EAX 00455ED8 FFD2 CALL EDX 00455EDA 85C0 TEST EAX,EAX 00455EDC 8D4C24 08 LEA ECX,DWORD PTR SS:[ESP+8] 00455EE0 0F94C3 SETE BL 00455EE3 E8 080EFCFF CALL 416CF0 00455EE8 8AC3 MOV AL,BL 00455EEA 8B4C24 0C MOV ECX,DWORD PTR SS:[ESP+C] 00455EEE 64:890D 00000000 MOV DWORD PTR FS:[0],ECX 00455EF5 59 POP ECX 00455EF6 5B POP EBX 00455EF7 83C4 10 ADD ESP,10 00455EFA C3 RETN 00455EFB 8D4C24 08 LEA ECX,DWORD PTR SS:[ESP+8] 00455EFF E8 EC0DFCFF CALL 416CF0 00455F04 32C0 XOR AL,AL 00455F06 8B4C24 0C MOV ECX,DWORD PTR SS:[ESP+C] 00455F0A 64:890D 00000000 MOV DWORD PTR FS:[0],ECX 00455F11 59 POP ECX 00455F12 5B POP EBX 00455F13 83C4 10 ADD ESP,10 00455F16 C3 RETN
Code: Pattern Scan for to update adress EndSceneEngine: \x8B\x08\x8B\x91\x00\x00\x00\x00\x50\xFF\xD2\x85\xC0\x8D\x4C\x24\x00\x0F\x94\xC3\xE8\x00\x00\x00\x00\x8A\xC3\x8B xxxx????xxxxxxxx?xxxx????xxx
Code: Binary Scan for to update adress EndSceneEngine: 8B 08 8B 91 ?? ?? ?? ?? 50 FF D2 85 C0 8D 4C 24 ?? 0F 94 C3 E8 ?? ?? ?? ?? 8A C3 8B
Hook EndScene Engine
Permissions in this forum: You cannot reply to topics in this forum