-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cpp
100 lines (84 loc) · 3.06 KB
/
Main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include "Headers.h"
LONG WINAPI ExceptionHandler( EXCEPTION_POINTERS* ExceptionInfo );
BYTE OriginalBytes[5];
VOID SetBreakpoints()
{
AddVectoredExceptionHandler( rand() % 0xFFFFFF, ExceptionHandler );
CONTEXT Context = { CONTEXT_DEBUG_REGISTERS };
Context.Dr0 = Engine::DrawXModelSkinnedCachedOffset;
Context.Dr7 = 0x1;
SetThreadContext( GetCurrentThread(), &Context );
}
VOID MyDrawXModelSkinnedCached( INT a1, INT a2, INT a3 )
{
CHAR* ModelName;
_asm{
PUSHAD;
MOV EBX, [EDI + 0xB8];
MOV EAX, [EBX];
MOV ModelName, EAX;
}
static BOOL bRemove = FALSE;
if( !bRemove )
{
DWORD Protect = 0x0;
VirtualProtect( ( VOID* )Engine::DrawXModelSkinnedCachedOffset, 5, PAGE_EXECUTE_READWRITE, &Protect );
for( INT i = 0; i < 5; i++ )
*( BYTE* )( Engine::DrawXModelSkinnedCachedOffset + i ) = OriginalBytes[i];
VirtualProtect( ( VOID* )Engine::DrawXModelSkinnedCachedOffset, 5, Protect, &Protect );
SetBreakpoints();
bRemove = TRUE;
}
if( Engine::D3DDevice != NULL)
{
if(Tools::Textura == NULL)
{
Tools::CreateTexturaDoCairo(Engine::D3DDevice, Tools::Textura);
}
if( !strstr( ModelName, "mi24p" ) && !strstr( ModelName, "weapon" ) && !strstr( ModelName, "cobra" ) )
{
if( strstr( ModelName, "sas" ) || strstr( ModelName, "usmc" ) )
{
sndPlaySound("cairo.wav", SND_ASYNC);
Engine::D3DDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE );
Engine::D3DDevice->SetTexture( 0, Tools::Textura );
Engine::DrawXModelSkinnedCached( a1, a2, a3 );
Engine::D3DDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE );
Engine::D3DDevice->SetTexture(0, Tools::Textura);
}
else if( strstr( ModelName, "opforce" ) || strstr( ModelName, "arab" ) || strstr( ModelName, "head_suren" ) )
{
sndPlaySound("cairo.wav", SND_ASYNC);
Engine::D3DDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE );
Engine::D3DDevice->SetTexture(0, Tools::Textura);
Engine::DrawXModelSkinnedCached( a1, a2, a3 );
Engine::D3DDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE );
Engine::D3DDevice->SetTexture(0, Tools::Textura);
}
}
}
_asm POPAD;
Engine::DrawXModelSkinnedCached( a1, a2, a3 );
}
LONG WINAPI ExceptionHandler( EXCEPTION_POINTERS* ExceptionInfo )
{
if( ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_SINGLE_STEP && ( DWORD )ExceptionInfo->ExceptionRecord->ExceptionAddress == Engine::DrawXModelSkinnedCachedOffset )
{
ExceptionInfo->ContextRecord->Eip = ( DWORD )MyDrawXModelSkinnedCached;
return EXCEPTION_CONTINUE_EXECUTION;
}
return EXCEPTION_CONTINUE_SEARCH;
}
DWORD WINAPI HookThread( VOID* Arguments )
{
for( INT i = 0; i < 5; i++ )
OriginalBytes[i] = *( BYTE* )( Engine::DrawXModelSkinnedCachedOffset + i );
Engine::DrawXModelSkinnedCached = ( Engine::tDrawXModelSkinnedCached )Tools::JMPHook( ( BYTE* )Engine::DrawXModelSkinnedCachedOffset, ( BYTE* )MyDrawXModelSkinnedCached, 5 );
return 0;
}
BOOL WINAPI DllMain( HMODULE hModule, DWORD Reason, VOID* Reserved )
{
if( Reason == DLL_PROCESS_ATTACH )
CreateThread( NULL, 0, ( LPTHREAD_START_ROUTINE )HookThread, NULL, 0x0, NULL );
return TRUE;
}