Code:
#include "Base.h"
#include "Menu.h"
#pragma comment( lib, "d3dx" )
cBase Base;
DWORD dwHSDevicePointer;
#define HOOKD3DAPI(a, b) \
if(*(DWORD*)GetAddressPtr(b) != (DWORD)&hk##a) { \
p##a = (a##_t) *(DWORD*)GetAddressPtr(b); \
*(DWORD*)GetAddressPtr(b) = (DWORD)&hk##a; \
*(DWORD*)GetD3DHSApi(b) = (DWORD)&hk##a; \
}
void __cdecl cBase::PushToConsole( const char* szCommand )
{
DWORD *LTClient = ( DWORD* )( 0x37775D68 );
void* CONoff = ( void* )*( DWORD* )( *LTClient + 0x208 );
__asm
{
push szCommand;
call CONoff;
add esp, 4;
}
}
//Every Frame
void cBase::RenderFrame(LPDIRECT3DDEVICE9 pDevice)
{
if( !Base.bSet.bInit )
{
D3DXCreateFont(pDevice, 15, 0, FW_BOLD, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &Directx.pFont);
Base.bSet.bInit = true;
}
if( Directx.pFont == NULL )
Directx.pFont->OnLostDevice();
else
{
Directx.DrawString(10, 185, D3DCOLOR_ARGB(255, 190, 0, 0), Directx.pFont, "MPGH Combat Arms Clan");
Menu.RenderMenu();
}
}
//4x Per Second
void cBase::Update(void)
{
while(1)
{
if( Menu.mOpt[1].nopt > 0 )//3D Box's
{
this->PushToConsole( "ModelDebug_DrawBoxes 1" );
this->PushToConsole("SkelModelStencil 1");
}else{
this->PushToConsole("ModelDebug_DrawBoxes 0");
this->PushToConsole("SkelModelStencil 0");
}
Sleep(300);
if( Menu.mOpt[2].nopt > 0 )//Full Bright
this->PushToConsole("FullBright 1");
else
this->PushToConsole("FullBright 0");
Sleep(300);
if( Menu.mOpt[3].nopt > 0 )//No Fog
this->PushToConsole( "FogEnable 0" );
else
this->PushToConsole( "FogEnable 1" );
Sleep(300);
if( Menu.mOpt[4].nopt > 0 )//Less Spread
{
this->PushToConsole("PerturbRotationEffect 0.000000");
this->PushToConsole("PerturbIncreaseSpeed 0.000000");
this->PushToConsole("PerturbWalkPercent 0.000000");
this->PushToConsole("PerturbFiringIncreaseSpeed 0.000000");
}else{
this->PushToConsole("PerturbRotationEffect 3.000000");
this->PushToConsole("PerturbIncreaseSpeed 3.000000");
this->PushToConsole("PerturbDecreaseSpeed 9.000000");
this->PushToConsole("PerturbWalkPercent 0.500000");
}
Sleep(300);
if( Menu.mOpt[5].nopt > 0 )//No Sway
this->PushToConsole("WeaponSway 0");
else
this->PushToConsole("WeaponSway 1");
Sleep(300);
if( Menu.mOpt[6].nopt > 0 )//Tracers
this->PushToConsole("ShowFirePath 1");
else
this->PushToConsole("ShowFirePath 0");
Sleep(300);
if( Menu.mOpt[7].nopt > 0 )//Fps
this->PushToConsole( "ShowFps 1");
else
this->PushToConsole( "ShowFps 0");
Sleep(300);
}
}
DWORD cBase::GetPointer(int index)
{
DWORD* devicePtr = ***(DWORD****)0x9096F8;
if( devicePtr == NULL )
return 0;
return devicePtr[index];
}
bool cBase::IsGameReadyForHook(void)
{
if( GetModuleHandle( "d3d9.dll" ) != NULL
&& GetModuleHandle( "ClientFX.fxd" ) != NULL
&& GetModuleHandle( "CShell.dll" ) != NULL )
return true;
return false;
}
bool bCompare(const BYTE* pData, const BYTE* bMask, const char* szMask)
{
for(;*szMask;++szMask,++pData,++bMask)
if(*szMask=='x' && *pData!=*bMask) return 0;
return (*szMask) == NULL;
}
DWORD FindPattern(DWORD dwAddress,DWORD dwLen,BYTE *bMask,char * szMask)
{
for(DWORD i=0; i<dwLen; i++)
if (bCompare((BYTE*)(dwAddress+i),bMask,szMask)) return (DWORD)(dwAddress+i);
return 0;
}
DWORD dwHSDevicePointer = FindPattern((DWORD)GetModuleHandleA("EHSvc.dll"), 0x90000, (PBYTE)"\x8B\x84\x11\x00\x00\x00\x00\x8B\x8D\xCC\xFD\xFF\xFF\x8B\x95", "xxx????xxxxxxxx");
if(dwHSDevicePointer)
{
dwHSDevicePointer = *(DWORD*)(dwHSDevicePointer+3);
dwHSDevicePointer += 0x10;
}
DWORD dwTempDevicePointer = FindPattern((DWORD)GetModuleHandle(0), (DWORD)0xFFFFFFFF, (PBYTE)"\xA1\x00\x00\x00\x00\x89\x45\xF8\x8D", "x????xxxx");
if(dwTempDevicePointer != NULL)
{
dwDevicePointer = *(DWORD*)(dwTempDevicePointer+1);
}
DWORD GetAddressPtr(int index)
{
DWORD dwBase = *(DWORD*)dwDevicePointer;
if(dwBase == 0) return 0;
dwBase = *(DWORD*)dwBase;
if(dwBase == 0) return 0;
dwBase = *(DWORD*)dwBase;
if(dwBase == 0) return 0;
return dwBase+4*index;
}
DWORD GetD3DHSApi(int index)
{
DWORD dwVA = dwHSDevicePointer;
if(IsBadReadPtr((void*)dwVA, 4)) return 0;
dwVA = *(DWORD*)dwVA;
if(!dwVA || IsBadReadPtr((void*)dwVA, 0x200)) return 0;
return dwVA + (4*index);
}
DWORD WINAPI HookD3DApis(LPVOID)
{
bool bValid = false;
while(true) {
bValid = GetAddressPtr(0) > 0;
if(bValid) {
HOOKD3DAPI(Reset, 16)
HOOKD3DAPI(EndScene, 42)
HOOKD3DAPI(DrawIndexedPrimitive, 82)
HOOKD3DAPI(SetStreamSource, 100)
}
Sleep(300);
}
return 1;
}
DWORD WINAPI dwMainThread(LPVOID)
{
while ( !Base.IsGameReadyForHook() )
Sleep(iWaitTime);
Directx.Hook();
return 0;
}
DWORD WINAPI dwHackThread(LPVOID)
{
while( !Base.IsGameReadyForHook() )
Sleep(iWaitTime);
Base.Update();
return 0;
}
BOOL WINAPI DllMain ( HMODULE hDll, DWORD dwReason, LPVOID lpReserved )
{
DisableThreadLibraryCalls(hDll);
if ( dwReason == DLL_PROCESS_ATTACH )
{
#ifdef LOG
DeleteFile(LogPath);
#endif
CreateThread(NULL, NULL, dwMainThread, NULL, NULL, NULL);
CreateThread(NULL, NULL, dwHackThread, NULL, NULL, NULL);
}
return TRUE;
Did not work,