Code:
#include "Main.h"
/*
D3D AIM
By: SOH
Credits: aBnet/UC/GD/***/Sandaasu
F12 - Enable remove dead bodies
F11 - Aim through
F10 - Choose team to target
F9 - Choose aim spot (1 - 3)
F8 - Increase FOV Size
F7 - Decrease FOV Size
F6 - Wall hack
F5 - Enable trigger
F4 - Enable aim
F3 - Enable esp
F2 - Enable fov
F1 - Enable Draw fov
Shift - Aim key
Trigger bot presses Mouse1 for attack... xD
*/
signed int __stdcall hkReset(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* Params);
typedef HRESULT(__stdcall* Reset_t)(LPDIRECT3DDEVICE9, D3DPRESENT_PARAMETERS*);
Reset_t OrigReset;
signed int __stdcall hkDrawIndexedPrimitive(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE Type, INT BaseVertexIndex, UINT MinIndex, UINT NumVertices, UINT StartIndex, UINT primCount);
typedef HRESULT(__stdcall* DrawIndexedPrimitive_t)(LPDIRECT3DDEVICE9, D3DPRIMITIVETYPE, INT, UINT, UINT, UINT, UINT);
DrawIndexedPrimitive_t OrigDrawIndexedPrimitive;
signed int __stdcall hkEndScene(LPDIRECT3DDEVICE9 pDevice);
typedef HRESULT(__stdcall* EndScene_t)(LPDIRECT3DDEVICE9);
EndScene_t OrigEndScene;
D3DVIEWPORT9 D3DVP = { NULL };
HRESULT __stdcall sys_DrawIndexedPrimitive(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE Type, INT BaseVertexIndex, UINT MinIndex, UINT nVertices, UINT sIndex, UINT pCount)
{
AimDrawPrim(pDevice, Type, BaseVertexIndex, MinIndex, nVertices, sIndex, pCount);
return OrigDrawIndexedPrimitive(pDevice, Type, BaseVertexIndex, MinIndex, nVertices, sIndex, pCount);
}
HRESULT __stdcall sys_Reset(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* Params)
{
AimReset(pDevice);
return OrigReset(pDevice, Params);
}
HRESULT __stdcall sys_EndScene(LPDIRECT3DDEVICE9 pDevice)
{
pDevice->GetViewport(&D3DVP);
AimEndScene(pDevice);
return OrigEndScene(pDevice);
}
#define D3DSDEX D3DSURFACE_DESC_EX
#define D3DSD D3DSURFACE_DESC
CHAR STR[MAX_PATH] = {NULL};
LONG ScreenHeightHalf = NULL;
LONG ScreenWidthHalf = NULL;
FLOAT FScrSizeX = 0.0f;
FLOAT FScrSizeY = 0.0f;
LONG ScrSizeX = 0;
LONG ScrSizeY = 0;
BOOL BDepth = FALSE;
BOOL BAimThr = TRUE;
BOOL BFiring = FALSE;
BOOL Wall = TRUE;
BOOL TriggerOn = FALSE;
BOOL AimOn = TRUE;
BOOL EspOn = FALSE;
BOOL FOVOn = FALSE;
BOOL FOVDrawOn = FALSE;
BOOL RemDeadOn = FALSE;
INT iTeam = 1;
DWORD TrigTime = 0;
INT AimSpot = 1;
INT FOVSize = 150;
PDWORD LabelTable = NULL;
PDWORD LabelBuffer = NULL;
PENTITIES Entities = NULL;
D3DVIEWPORT9 VP = {NULL};
LPDIRECT3DSURFACE9 pRender = NULL;
LPDIRECT3DSURFACE9 pStencil = NULL;
LPDIRECT3DSURFACE9 pAimRender = NULL;
LPDIRECT3DSURFACE9 pAim = NULL;
LPDIRECT3DSURFACE9 pOff = NULL;
LPDIRECT3DSURFACE9 pMapRender = NULL;
LPDIRECT3DSURFACE9 pVisibleRender = NULL;
LPDIRECT3DSURFACE9 pBlankStencil = NULL;
LPDIRECT3DSURFACE9 pTrig = NULL;
LPDIRECT3DSURFACE9 pTrigOff = NULL;
LPDIRECT3DSURFACE9 pVis = NULL;
LPDIRECT3DSURFACE9 pVisOff = NULL;
LPDIRECT3DTEXTURE9 Blue = NULL;
LPDIRECT3DTEXTURE9 Red = NULL;
LPDIRECT3DTEXTURE9 Green = NULL;
LPDIRECT3DTEXTURE9 Orange = NULL;
LPDIRECT3DTEXTURE9 Pink = NULL;
LPDIRECT3DTEXTURE9 Yellow = NULL;
//LPD3DXFONT pFont = NULL;
DWORD clientdll = NULL;
RECT FOV = {NULL};
// get pshader
IDirect3DPixelShader9* pShader;
UINT psData;
//get vshader
IDirect3DVertexShader9* vShader;
UINT vsData;
//models
bool MODELS;
//aimsmooth
int aimsmooth = 3; //use 2 with low mouse sensitivity (mouse accel affects aiming, disable it if possible)
VOID WINAPI CreateSurface( LPDIRECT3DDEVICE9 pDevice )
{
if( !pRender || !pStencil || !pAim || !pOff ||
!pTrig || !pTrigOff || !pAimRender || !pMapRender ||
!pVisibleRender || !pBlankStencil || !pVis || !pVisOff )
{
LPDIRECT3DSURFACE9 pRen = NULL;
LPDIRECT3DSURFACE9 pSten = NULL;
FScrSizeX = (FLOAT)VP.Width / 400.0f;
FScrSizeY = (FLOAT)VP.Height / 300.0f;
ScrSizeX = LONG((FLOAT)VP.Width / FScrSizeX);
ScrSizeY = LONG((FLOAT)VP.Height / FScrSizeY);
D3DSURFACE_DESC RDESC;
D3DSURFACE_DESC SDESC;
memset( &RDESC, 0, sizeof(D3DSURFACE_DESC) );
memset( &SDESC, 0, sizeof(D3DSURFACE_DESC) );
if( pDevice->GetRenderTarget( 0, &pRen ) == D3D_OK )
if( pRen->GetDesc( &RDESC ) == D3D_OK )
{
if( !pRender )
pDevice->CreateRenderTarget( RDESC.Width, RDESC.Height,
D3DFMT_A8R8G8B8, RDESC.MultiSampleType, RDESC.MultiSampleQuality,
FALSE, &pRender, NULL);
if( !pAimRender )
pDevice->CreateRenderTarget( RDESC.Width, RDESC.Height,
D3DFMT_A8R8G8B8, RDESC.MultiSampleType, RDESC.MultiSampleQuality,
FALSE, &pAimRender, NULL);
if( !pMapRender )
pDevice->CreateRenderTarget( RDESC.Width, RDESC.Height,
D3DFMT_A8R8G8B8, RDESC.MultiSampleType, RDESC.MultiSampleQuality,
FALSE, &pMapRender, NULL);
if( !pVisibleRender )
pDevice->CreateRenderTarget( RDESC.Width, RDESC.Height,
D3DFMT_A8R8G8B8, RDESC.MultiSampleType, RDESC.MultiSampleQuality,
FALSE, &pVisibleRender, NULL);
if( !pAim )
pDevice->CreateRenderTarget( ScrSizeX, ScrSizeY, D3DFMT_A8R8G8B8,
D3DMULTISAMPLE_NONE, 0, FALSE, &pAim, NULL);
if( !pVis )
pDevice->CreateRenderTarget( ScrSizeX, ScrSizeY, D3DFMT_A8R8G8B8,
D3DMULTISAMPLE_NONE, 0, FALSE, &pVis, NULL);
if( !pTrig )
pDevice->CreateRenderTarget( 3, 3, D3DFMT_A8R8G8B8,
D3DMULTISAMPLE_NONE, 0, FALSE, &pTrig, NULL);
}
if( pDevice->GetDepthStencilSurface( &pSten ) == D3D_OK )
if( pSten->GetDesc( &SDESC ) == D3D_OK )
{
if( !pStencil )
pDevice->CreateDepthStencilSurface( SDESC.Width, SDESC.Height,
SDESC.Format, SDESC.MultiSampleType, SDESC.MultiSampleQuality,
FALSE, &pStencil, NULL );
if( !pBlankStencil )
pDevice->CreateDepthStencilSurface( SDESC.Width, SDESC.Height,
SDESC.Format, SDESC.MultiSampleType, SDESC.MultiSampleQuality,
FALSE, &pBlankStencil, NULL );
}
if( !pOff )
pDevice->CreateOffscreenPlainSurface( ScrSizeX, ScrSizeY,
D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &pOff, NULL );
if( !pTrigOff )
pDevice->CreateOffscreenPlainSurface( 3, 3, D3DFMT_A8R8G8B8,
D3DPOOL_SYSTEMMEM, &pTrigOff, NULL );
if( !pVisOff )
pDevice->CreateOffscreenPlainSurface( ScrSizeX, ScrSizeY,
D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &pVisOff, NULL );
D3D_RELEASE( pRen )
D3D_RELEASE( pSten )
}
}
VOID WINAPI SetDeadBodies( VOID )
{
//counter strike source only
// cl_ragdoll_physics_enable 0
//if( !clientdll )
//clientdll = (DWORD)GetModuleHandle( "client.dll" );
//else
//{
//if( RemDeadOn && *PINT(clientdll + 0x5960F0) )
//*PINT(clientdll + 0x5960F0) = 0;
//}
}
BOOL WINAPI GetDepth( LPDIRECT3DDEVICE9 pDevice )
{
if( !pStencil )
return FALSE;
LPDIRECT3DSURFACE9 pSten = NULL;
BOOL Result = FALSE;
if( pDevice->GetDepthStencilSurface( &pSten ) == D3D_OK )
{
if( SUCCEEDED(pDevice->StretchRect( pSten, NULL, pStencil, NULL, D3DTEXF_NONE )) )
{
if( pDevice->SetDepthStencilSurface( pStencil ) == D3D_OK )
{
pDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER ,
D3DCOLOR_ARGB( 0, 0, 0, 0 ), 1.0f, 0 );
pDevice->SetDepthStencilSurface( pSten );
Result = TRUE;
}
}
}
else
{
D3D_RELEASE( pSten )
return FALSE;
}
D3D_RELEASE( pSten )
return Result;
}
BOOL WINAPI IsVisible( LPDIRECT3DDEVICE9 pDevice, LONG X, LONG Y )
{
if( !pVis || !pVisOff || !pVisibleRender )
return FALSE;
D3DLOCKED_RECT D3DLR = {NULL};
BOOL Result = FALSE;
LONG Max_X = ScrSizeX - 1;
LONG Max_Y = ScrSizeY - 1;
if( X > 0 && Y > 0 && X < Max_X && Y < Max_Y )
{
if( SUCCEEDED( pVisOff->LockRect( &D3DLR,
NULL, D3DLOCK_DISCARD )) )
{
PDWORD PIX = (PDWORD)D3DGetPixel( ((DWORD)D3DLR.pBits), Y, X, 32, ( D3DLR.Pitch ) );
if( *PIX ) Result = TRUE;
pVisOff->UnlockRect( );
}
}
return Result;
}
BOOL WINAPI VisibleReady( LPDIRECT3DDEVICE9 pDevice )
{
if( !pVis || !pVisOff || !pVisibleRender )
return FALSE;
if( SUCCEEDED(pDevice->StretchRect( pVisibleRender, NULL,
pVis, NULL, D3DTEXF_NONE )) )
{
if( SUCCEEDED(pDevice->GetRenderTargetData( pVis, pVisOff )) )
{
return TRUE;
}
}
return FALSE;
}
BOOL WINAPI Trigger( LPDIRECT3DDEVICE9 pDevice )
{
if( !pTrig || !pTrigOff || !pRender )
return FALSE;
D3DLOCKED_RECT D3DLR = {NULL};
BOOL Result = FALSE;
BOOL Fire = FALSE;
RECT RTR = {ScreenWidthHalf - 1,ScreenHeightHalf - 1,
ScreenWidthHalf + 1,ScreenHeightHalf + 1};
if( SUCCEEDED(pDevice->StretchRect( pRender, &RTR,
pTrig, NULL, D3DTEXF_NONE )) )
{
if( SUCCEEDED(pDevice->GetRenderTargetData( pTrig, pTrigOff )) )
{
if( SUCCEEDED( pTrigOff->LockRect( &D3DLR,
NULL, D3DLOCK_DISCARD )) )
{
for( long y = 0;y < 3;y++ )
{
for( long x = 0;x < 3;x++ )
{
PDWORD Pixel = D3DGetPixel( (DWORD)
D3DLR.pBits, y, x, 32, D3DLR.Pitch );
if( *Pixel ) Fire = TRUE;
}
}
pTrigOff->UnlockRect( );
Result = TRUE;
}
}
}
if( !( GetAsyncKeyState( VK_LBUTTON ) < 0 ) )
{
if( Fire )
{
if( !BFiring )
{
mouse_event( MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 );
mouse_event( MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 );
TrigTime = GetTickCount( );
BFiring = TRUE;
}
else
{
DWORD Span = GetTickCount( ) - TrigTime;
if( Span > 5 )
{
mouse_event( MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 );
BFiring = FALSE;
}
}
}
else
{
if( BFiring )
{
mouse_event( MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 );
BFiring = FALSE;
}
}
}
return Result;
}
VOID WINAPI ClearRenTarget( LPDIRECT3DDEVICE9 pDevice )
{
if( pRender && pAimRender && pVisibleRender &&
pMapRender && pStencil && pBlankStencil )
{
LPDIRECT3DSURFACE9 pRen = NULL;
LPDIRECT3DSURFACE9 pSten = NULL;
if( pDevice->GetRenderTarget( 0, &pRen ) == D3D_OK )
{
#ifdef DEBUG_STRETCHRECT
RECT DebugA = {(VP.Width - (VP.Width / 4)) - 10,
10,VP.Width - 10,VP.Height / 4 + 10};
pDevice->StretchRect( pRender, NULL, pRen, &DebugA, D3DTEXF_NONE );
RECT DebugB = {(VP.Width - (VP.Width / 4)) - 10,
DebugA.bottom + 10,VP.Width - 10,(DebugA.bottom * 2) + 10};
pDevice->StretchRect( pAimRender, NULL, pRen, &DebugB, D3DTEXF_NONE );
#endif
if( pDevice->GetDepthStencilSurface( &pSten ) == D3D_OK )
{
pDevice->SetRenderTarget( 0, pRender );
pDevice->SetDepthStencilSurface( pSten );
pDevice->Clear( 0, NULL, D3DCLEAR_TARGET,
D3DCOLOR_ARGB( 0, 0, 0, 0 ), 1.0f, 0 );
pDevice->SetRenderTarget( 0, pAimRender );
pDevice->SetDepthStencilSurface( pSten );
pDevice->Clear( 0, NULL, D3DCLEAR_TARGET,
D3DCOLOR_ARGB( 0, 0, 0, 0 ), 1.0f, 0 );
pDevice->SetRenderTarget( 0, pVisibleRender );
pDevice->SetDepthStencilSurface( pSten );
pDevice->Clear( 0, NULL, D3DCLEAR_TARGET,
D3DCOLOR_ARGB( 0, 0, 0, 0 ), 1.0f, 0 );
pDevice->SetRenderTarget( 0, pMapRender );
pDevice->SetDepthStencilSurface( pStencil );
pDevice->Clear( 0, NULL, D3DCLEAR_TARGET |
D3DCLEAR_STENCIL | D3DCLEAR_ZBUFFER ,
D3DCOLOR_ARGB( 0, 0, 0, 0 ), 1.0f, 0 );
pDevice->SetRenderTarget( 0, pMapRender );
pDevice->SetDepthStencilSurface( pBlankStencil );
pDevice->Clear( 0, NULL, D3DCLEAR_STENCIL |
D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB( 0, 0, 0, 0 ), 1.0f, 0 );
pDevice->SetRenderTarget( 0, pRen );
pDevice->SetDepthStencilSurface( pSten );
}
}
D3D_RELEASE( pSten )
D3D_RELEASE( pRen )
}
}
VOID WINAPI KeyState( VOID )
{
if( GetAsyncKeyState( VK_F12 ) &1 )
if( RemDeadOn ) RemDeadOn = FALSE;
else RemDeadOn = TRUE;
if( GetAsyncKeyState( VK_F11 ) &1 )
if( BAimThr) BAimThr = FALSE;
else BAimThr = TRUE;
if( GetAsyncKeyState( VK_F10 ) &1 )
if( iTeam < 2 ) iTeam++;
else iTeam = 1;
if( GetAsyncKeyState( VK_F9 ) &1 )
if( AimSpot < 3 ) AimSpot++;
else AimSpot = 1;
if( GetAsyncKeyState( VK_F8 ) &1 )
if( FOVSize < ScreenHeightHalf ) FOVSize+=10;
else FOVSize = 0;
if( GetAsyncKeyState( VK_F7 ) &1 )
if( FOVSize > 1 ) FOVSize-=10;
else FOVSize = ScreenHeightHalf - 1;
if( GetAsyncKeyState( VK_F6 ) &1 )
if( Wall ) Wall = FALSE;
else Wall = TRUE;
if( GetAsyncKeyState( VK_F5 ) &1 )
if( TriggerOn ) TriggerOn = FALSE;
else TriggerOn = TRUE;
if( GetAsyncKeyState( VK_F4 ) &1 )
if( AimOn ) AimOn = FALSE;
else AimOn = TRUE;
if( GetAsyncKeyState( VK_F3 ) &1 )
if( EspOn ) EspOn = FALSE;
else EspOn = TRUE;
if( GetAsyncKeyState( VK_F2 ) &1 )
if( FOVOn ) FOVOn = FALSE;
else FOVOn = TRUE;
if( GetAsyncKeyState( VK_F1 ) &1 )
if( FOVDrawOn ) FOVDrawOn = FALSE;
else FOVDrawOn = TRUE;
}
VOID WINAPI DrawFOV( LPDIRECT3DDEVICE9 pDev )
{
if( !FOVOn || !FOVDrawOn )
return;
DWORD BoxColor = D3DCOLOR_ARGB( 255, 255, 20, 20 );
LONG X = ScreenWidthHalf;
LONG Y = ScreenHeightHalf;
LONG Size = FOVSize;
D3DRECT R1 = { X - Size, Y - Size,
X + Size, Y - Size + 1 };
pDev->Clear( 1, &R1, D3DCLEAR_TARGET, BoxColor, 1.0f, 0 );
D3DRECT R2 = { X - Size, Y + Size - 1,
X + Size, Y + Size };
pDev->Clear( 1, &R2, D3DCLEAR_TARGET, BoxColor, 1.0f, 0 );
D3DRECT R3 = { X - Size, Y - Size,
X - Size + 1, Y + Size };
pDev->Clear( 1, &R3, D3DCLEAR_TARGET, BoxColor, 1.0f, 0 );
D3DRECT R4 = { X + Size - 1, Y - Size,
X + Size, Y + Size };
pDev->Clear( 1, &R4, D3DCLEAR_TARGET, BoxColor, 1.0f, 0 );
}
VOID WINAPI DrawESP( LPDIRECT3DDEVICE9 pDev,
LONG X, LONG Y, LONG Size, BOOL IsVis )
{
if( !EspOn )
return;
DWORD BoxColor = 0;
if( !IsVis )
BoxColor = D3DCOLOR_ARGB( 255, 255, 255, 20 ); // Yellow
else if( IsVis )
BoxColor = D3DCOLOR_ARGB( 255, 20, 255, 20 ); // Green
D3DRECT R1 = { X - Size, Y - Size,
X + Size, Y - Size + 1 };
pDev->Clear( 1, &R1, D3DCLEAR_TARGET, BoxColor, 1.0f, 0 );
D3DRECT R2 = { X - Size, Y + Size - 1,
X + Size, Y + Size };
pDev->Clear( 1, &R2, D3DCLEAR_TARGET, BoxColor, 1.0f, 0 );
D3DRECT R3 = { X - Size, Y - Size,
X - Size + 1, Y + Size };
pDev->Clear( 1, &R3, D3DCLEAR_TARGET, BoxColor, 1.0f, 0 );
D3DRECT R4 = { X + Size - 1, Y - Size,
X + Size, Y + Size };
pDev->Clear( 1, &R4, D3DCLEAR_TARGET, BoxColor, 1.0f, 0 );
}
DWORD WINAPI Get2DDistance( PLONG A, PLONG B )
{
LONG DistanceX = A[0] - B[0];
LONG DistanceY = A[1] - B[1];
return (DWORD)sqrt( FLOAT(( DistanceX * DistanceX ) + ( DistanceY * DistanceY )) );
}
VOID WINAPI LabelPixel( PDWORD Buffer, LONG y, LONG x, INT iLabel, INT Pitch )
{
PDWORD PX = (PDWORD)D3DGetPixel( ((DWORD)Buffer), y, x, 32, ( Pitch ) );
*PX = iLabel;
}
BOOL WINAPI Aim( LPDIRECT3DDEVICE9 pDevice )
{
if( !pAimRender || !pAim || !pOff )
return FALSE;
D3DLOCKED_RECT D3DLR = {NULL};
BOOL Result = FALSE;
LONG Label = 1;
LONG Objects = 0;
DWORD MaxDistance = 0xFFFFFFFF;
LONG AimX = 0;
LONG AimY = 0;
LONG Max_X = ScrSizeX;
LONG Max_Y = ScrSizeY;
LONG PiSize = Max_X * 4;
LONG ScreenCenter[2] = {ScreenWidthHalf,ScreenHeightHalf};
// The maximum number of blobs is given by an image filled
// with equally spaced single pixel blobs.
if( !LabelTable )
LabelTable = (PDWORD)malloc( (Max_X * Max_Y / 4) * sizeof(DWORD) );
else
memset( LabelTable, 0, (Max_X * Max_Y / 4) * sizeof(DWORD) );
if( !Entities )
Entities = (PENTITIES)malloc( (Max_X * Max_Y / 4) * sizeof(PENTITIES) );
else
memset( Entities, 0, (Max_X * Max_Y / 4) * sizeof(PENTITIES) );
if( !LabelBuffer )
LabelBuffer = (PDWORD)malloc( Max_X * Max_Y * 4 );
else
memset( LabelBuffer, 0, Max_X * Max_Y * 4 );
if( !LabelTable || !Entities || !LabelBuffer )
return FALSE;
if( SUCCEEDED(pDevice->StretchRect( pAimRender, NULL,
pAim, NULL, D3DTEXF_NONE )) )
{
if( SUCCEEDED(pDevice->GetRenderTargetData( pAim, pOff )) )
{
if( SUCCEEDED( pOff->LockRect( &D3DLR,
NULL, D3DLOCK_DISCARD )) )
{
for( long y = 1;y < Max_Y - 1;y++ )
{
for( long x = 1;x < Max_X - 1;x++ )
{
PDWORD PRX = (PDWORD)D3DGetPixel( ((DWORD)D3DLR.pBits), y, x, 32, ( D3DLR.Pitch ) );
PDWORD PRA = (PDWORD)D3DGetPixel( ((DWORD)D3DLR.pBits), (y - 1), (x - 1), 32, ( D3DLR.Pitch ) );
PDWORD PRB = (PDWORD)D3DGetPixel( ((DWORD)D3DLR.pBits), (y - 1), x, 32, ( D3DLR.Pitch ) );
PDWORD PRC = (PDWORD)D3DGetPixel( ((DWORD)D3DLR.pBits), (y - 1), (x + 1), 32, ( D3DLR.Pitch ) );
PDWORD PRD = (PDWORD)D3DGetPixel( ((DWORD)D3DLR.pBits), y, (x - 1), 32, ( D3DLR.Pitch ) );
PDWORD PA = (PDWORD)D3DGetPixel( ((DWORD)LabelBuffer), (y - 1), (x - 1), 32, ( PiSize ) );
PDWORD PB = (PDWORD)D3DGetPixel( ((DWORD)LabelBuffer), (y - 1), x, 32, ( PiSize ) );
PDWORD PC = (PDWORD)D3DGetPixel( ((DWORD)LabelBuffer), (y - 1), (x + 1), 32, ( PiSize ) );
PDWORD PD = (PDWORD)D3DGetPixel( ((DWORD)LabelBuffer), y, (x - 1), 32, ( PiSize ) );
if( *PRX )
{
if( !*PA && !*PB && !*PC && !*PD )
{
LabelPixel( LabelBuffer, y, x, Label, PiSize );
LabelTable[Label-1] = Label;
Label++;
}
else
{
DWORD Num = 0xFFFFFFFF;
if( *PA && *PA <= Num )
Num = *PA;
if( *PB && *PB <= Num )
Num = *PB;
if( *PC && *PC <= Num )
Num = *PC;
if( *PD && *PD <= Num )
Num = *PD;
LabelPixel( LabelBuffer, y, x, Num, PiSize );
if( *PA )
LabelTable[*PA-1] = Num;
if( *PB )
LabelTable[*PB-1] = Num;
if( *PC )
LabelTable[*PC-1] = Num;
if( *PD )
LabelTable[*PD-1] = Num;
}
}
}
}
pOff->UnlockRect( );
Result = TRUE;
}
}
}
if( Label > 1 )
{
for(long y = 1; y < Max_Y - 1; y++)
{
for(long x = 1; x < Max_X - 1; x++)
{
PDWORD PX = (PDWORD)D3DGetPixel( ((DWORD)LabelBuffer), y, x, 32, ( PiSize ) );
LONG LabelData = *PX;
if( LabelData && LabelData < Label )
{
while( 1 )
{
if( LabelData && LabelData < Label )
{
if( LabelData == LabelTable[LabelData-1] && LabelData < Label )
break;
else
{
LabelData = LabelTable[LabelData-1];
}
}
}
if( y > Entities[LabelData-1].Low )
Entities[LabelData-1].Low = y;
if( !Entities[LabelData-1].High )
Entities[LabelData-1].High = y;
else
{
if( y < Entities[LabelData-1].High )
Entities[LabelData-1].High = y;
}
*PX = LabelData;
Entities[LabelData-1].X += x;
Entities[LabelData-1].Y += y;
Entities[LabelData-1].Count++;
Objects++;
}
}
}
for( LONG i = 0;i < Objects;i++ )
{
if( i >= Label )
break;
LONG Count = Entities[i].Count;
LONG SCXY[2] = {Entities[i].X,Entities[i].Y};
LONG ESPX = Entities[i].X;
LONG ESPY = Entities[i].Y;
LONG VDist = 0;
if( Count && SCXY[0] && SCXY[1] )
{
if( Count > 1 )
{
SCXY[0] /= Count;
SCXY[1] /= Count; // 3: Body ( no change :DDD )
ESPX /= Count; // ESP
ESPY /= Count;
VDist = SCXY[1] - Entities[i].High;
if( VDist )
{
if( AimSpot == 1 )
SCXY[1] = (SCXY[1] - VDist) + (VDist/8); // 1: Head
else if( AimSpot == 2 )
SCXY[1] -= (VDist/2); // 2: Chest
}
}
BOOL IsVisESP = IsVisible( pDevice, ESPX, ESPY );
// Resizing ESP coords and drawing ESP ...
ESPX = LONG((FLOAT)ESPX * FScrSizeX);
ESPY = LONG((FLOAT)ESPY * FScrSizeY);
DrawESP( pDevice, ESPX, ESPY, VDist, IsVisESP );
// IsVisible before Resizing aim coords ...
BOOL IsVis = IsVisible( pDevice, SCXY[0], SCXY[1] );
// Resizing aim coords here ...
SCXY[0] = LONG((FLOAT)SCXY[0] * FScrSizeX);
SCXY[1] = LONG((FLOAT)SCXY[1] * FScrSizeY);
DWORD Distance = Get2DDistance( ScreenCenter, SCXY );
if( (IsVis && !BAimThr) || BAimThr )
{
if( ( SCXY[0] > FOV.left &&
SCXY[0] < FOV.right &&
SCXY[1] > FOV.top &&
SCXY[1] < FOV.bottom && FOVOn ) || !FOVOn )
{
if( Distance <= MaxDistance )
{
MaxDistance = Distance;
AimX = SCXY[0];
AimY = SCXY[1];
}
}
}
}
}
if( AimX && AimY && MaxDistance != 0xFFFFFFFF && AimOn )
{
if(GetAsyncKeyState( VK_SHIFT ) < 0 )
//if( ( GetAsyncKeyState( VK_LBUTTON ) < 0 ) ||
//( GetAsyncKeyState( VK_XBUTTON1 ) < 0 ) ||
//( GetAsyncKeyState( VK_XBUTTON2 ) < 0 ) )
{
if(AimX > ScreenWidthHalf) AimX = +((AimX - ScreenWidthHalf)/ aimsmooth);//4
else if (AimX < ScreenWidthHalf) AimX = -((ScreenWidthHalf - AimX) / aimsmooth);
else if(AimX == ScreenWidthHalf) AimX = 0L;
if (AimY > ScreenHeightHalf) AimY = +((AimY - ScreenHeightHalf) / aimsmooth);
else if (AimY < ScreenHeightHalf) AimY = -((ScreenHeightHalf - AimY) / aimsmooth);
else if(AimY == ScreenHeightHalf) AimY = 0L;
mouse_event( MOUSEEVENTF_MOVE,
AimX, AimY, NULL, NULL );
}
}
}
return Result;
}
VOID WINAPI CreateTextures( LPDIRECT3DDEVICE9 pDev )
{
if( !Blue ) GenTex( pDev, &Blue, D3DCOLOR_ARGB( 255, 20, 20, 255 ) );
if( !Red ) GenTex( pDev, &Red, D3DCOLOR_ARGB( 255, 255, 20, 20 ) );
if( !Green ) GenTex( pDev, &Green, D3DCOLOR_ARGB( 255, 20, 255, 20 ) );
if( !Orange ) GenTex( pDev, &Orange, D3DCOLOR_ARGB( 255, 255, 128, 20 ) );
if( !Pink ) GenTex( pDev, &Pink, D3DCOLOR_ARGB( 255, 255, 20, 255 ) );
if( !Yellow ) GenTex( pDev, &Yellow, D3DCOLOR_ARGB( 255, 255, 255, 20 ) );
}
VOID WINAPI AimEndScene( LPDIRECT3DDEVICE9 pDev )
{
pDev->GetViewport( &VP );
ScreenWidthHalf = VP.Width / 2;
ScreenHeightHalf = VP.Height / 2;
FOV.left = ScreenWidthHalf - FOVSize;
FOV.top = ScreenHeightHalf - FOVSize;
FOV.right = ScreenWidthHalf + FOVSize;
FOV.bottom = ScreenHeightHalf + FOVSize;
CreateSurface( pDev );
CreateTextures( pDev );
DrawFOV( pDev );
//if( !pFont )
//D3DXCreateFontA( pDev, 16, 0, 700, 0, 0, 1, 0,
//0, DEFAULT_PITCH | FF_DONTCARE, "Calibri", &pFont );
D3DRECT CrssRctA = {ScreenWidthHalf,ScreenHeightHalf - 5,
ScreenWidthHalf + 1,ScreenHeightHalf + 6};
pDev->Clear( 1, &CrssRctA, D3DCLEAR_TARGET,
D3DCOLOR_ARGB( 255, 255, 20, 20 ), 1.0f, 0 );
D3DRECT CrssRctB = {ScreenWidthHalf - 5,ScreenHeightHalf,
ScreenWidthHalf + 6,ScreenHeightHalf + 1};
pDev->Clear( 1, &CrssRctB, D3DCLEAR_TARGET,
D3DCOLOR_ARGB( 255, 255, 20, 20 ), 1.0f, 0 );
#ifdef TRIGGER_D3D
if( TriggerOn ) Trigger( pDev );
#endif
#ifdef AIM_D3D
if( AimOn || EspOn )
{
if( VisibleReady( pDev ) )
Aim( pDev );
}
#endif
if( AimOn || EspOn || TriggerOn )
ClearRenTarget( pDev );
KeyState( );
SetDeadBodies( );
}
VOID WINAPI AimReset( LPDIRECT3DDEVICE9 pDevice )
{
D3D_RELEASE( pRender )
D3D_RELEASE( pStencil )
D3D_RELEASE( pAim )
D3D_RELEASE( pOff )
D3D_RELEASE( pTrig )
D3D_RELEASE( pTrigOff )
D3D_RELEASE( pAimRender )
D3D_RELEASE( pMapRender )
//D3D_RELEASE( pFont )
D3D_RELEASE( pVisibleRender )
D3D_RELEASE( pBlankStencil )
D3D_RELEASE( pVis )
D3D_RELEASE( pVisOff )
D3D_RELEASE( Blue )
D3D_RELEASE( Red )
D3D_RELEASE( Green )
D3D_RELEASE( Orange )
D3D_RELEASE( Pink )
D3D_RELEASE( Yellow )
}
BOOL WINAPI AimDrawPrim( LPDIRECT3DDEVICE9 pDevice,
D3DPRIMITIVETYPE Type, INT Base, UINT Min, UINT NumVertices,
UINT Start, UINT PrimitiveCount )
{
if( !pMapRender || !pStencil || !pVisibleRender || !pRender ||
!pAimRender || !pBlankStencil || !Red || !Blue ||
!Orange || !Green || !Pink || !Yellow )
return FALSE;
LPDIRECT3DVERTEXBUFFER9 Stream = NULL;
UINT Offset = 0;
UINT Stride = 0;
BOOL TeamTE = FALSE;
BOOL TeamCTE = FALSE;
BOOL TeamC4 = FALSE;
if( pDevice->GetStreamSource( 0, &Stream, &Offset, &Stride ) == D3D_OK )
Stream->Release( );
//get psdata
if (SUCCEEDED(pDevice->GetPixelShader(&pShader)))
if (pShader != NULL)
if (SUCCEEDED(pShader->GetFunction(NULL, &psData)))
if (pShader != NULL){ pShader->Release(); pShader = NULL; }
//get vsdata
if (SUCCEEDED(pDevice->GetVertexShader(&vShader)))
if (vShader != NULL)
if (SUCCEEDED(vShader->GetFunction(NULL, &vsData)))
if (vShader != NULL){ vShader->Release(); vShader = NULL; }
//get models
if(Stride == 32) //EDIT THIS ONE
//half life 2 demo combine soldier
//if ((Stride == 32 && NumVertices == 3147 && PrimitiveCount == 3852) ||//combine 1
//(Stride == 32 && NumVertices == 2421 && PrimitiveCount == 3232) ||//combine 2
//(Stride == 32 && NumVertices == 1946 && PrimitiveCount == 2536) ||//combine 3
//(Stride == 32 && NumVertices == 1308 && PrimitiveCount == 1652) ||//combine 4
//(Stride == 32 && NumVertices == 785 && PrimitiveCount == 948) ||//combine 5
//(Stride == 32 && NumVertices == 275 && PrimitiveCount == 284)) //combine 6
//if (Stride == 88) //fallout new vegas models
//defiance models
//if((Stride == 60 && psData == 1048 && vsData == 2256) ||
//(Stride == 36 && psData == 752 && vsData == 1516) ||
//(Stride == 60 && psData == 1536 && vsData == 2340) ||
//(Stride == 60 && psData == 1000 && vsData == 2256))
//if ((Stride == 16 && vsData == 2064) || //enemy front eyes
//(Stride == 16 && vsData == 1544) || //heads and hands
//(Stride == 16 && vsData == 1996)) //bodies
MODELS = true;
else MODELS = false;
if (MODELS)
{
LPDIRECT3DSURFACE9 pRen = NULL;
LPDIRECT3DSURFACE9 pSten = NULL;
D3DSDEX RDESC = {0};
if( pDevice->GetRenderTarget( 0, &pRen ) == D3D_OK )
{
if( pRen->GetDesc( (D3DSD*)&RDESC ) == D3D_OK )
{
if( RDESC.Width == VP.Width && RDESC.Height == VP.Height )
{
if( pDevice->GetDepthStencilSurface( &pSten ) == D3D_OK )
{
pDevice->SetRenderTarget( 0, pMapRender );
pDevice->SetDepthStencilSurface( pStencil );
pDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
OrigDrawIndexedPrimitive(pDevice, Type, Base, Min, NumVertices, Start, PrimitiveCount);
pDevice->SetRenderTarget( 0, pRen );
pDevice->SetDepthStencilSurface( pSten );
pDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
}
}
}
}
D3D_RELEASE( pRen )
D3D_RELEASE( pSten )
}
if ((iTeam == 1 && MODELS) ||
(iTeam == 2 && MODELS))
{
LPDIRECT3DSURFACE9 pRen = NULL;
LPDIRECT3DSURFACE9 pSten = NULL;
D3DSDEX RDESC = {0};
if( pDevice->GetRenderTarget( 0, &pRen ) == D3D_OK )
{
if( pRen->GetDesc( (D3DSD*)&RDESC ) == D3D_OK )
{
if( RDESC.Width == VP.Width && RDESC.Height == VP.Height )
{
if( pDevice->GetDepthStencilSurface( &pSten ) == D3D_OK )
{
//////VISIBLE/////////////
if( !BAimThr && ( AimOn || EspOn ) )
{
pDevice->SetRenderTarget( 0, pVisibleRender );
pDevice->SetDepthStencilSurface( pStencil );
pDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
OrigDrawIndexedPrimitive(pDevice, Type, Base, Min, NumVertices, Start, PrimitiveCount);
}
//////TRIGGER/////////////
if( TriggerOn )
{
pDevice->SetRenderTarget( 0, pRender );
if( !BAimThr )
{
pDevice->SetDepthStencilSurface( pStencil );
pDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
}
else
{
pDevice->SetDepthStencilSurface( pBlankStencil );
pDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
}
OrigDrawIndexedPrimitive(pDevice, Type, Base, Min, NumVertices, Start, PrimitiveCount);
}
//////AIM/ESP//////////////
if( ( AimOn || EspOn ) )
{
pDevice->SetRenderTarget( 0, pAimRender );
pDevice->SetDepthStencilSurface( pBlankStencil );
pDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
OrigDrawIndexedPrimitive(pDevice, Type, Base, Min, NumVertices, Start, PrimitiveCount);
}
/////////////////////////////
pDevice->SetRenderTarget( 0, pRen );
pDevice->SetDepthStencilSurface( pSten );
pDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
}
}
}
}
D3D_RELEASE( pSten )
D3D_RELEASE( pRen )
}
if (Wall && (MODELS))
{
pDevice->SetTexture( 0, Orange );
pDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
OrigDrawIndexedPrimitive(pDevice, Type, Base, Min, NumVertices, Start, PrimitiveCount);
pDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
pDevice->SetTexture( 0, Green );
}
return TRUE;
}
BOOL WINAPI GenTex( LPDIRECT3DDEVICE9 pDev,
LPDIRECT3DTEXTURE9 * ppD3Dtex, DWORD Color )
{
D3DLOCKED_RECT d3dlr = {NULL};
IDirect3DTexture9 * Temp = NULL;
if( FAILED( pDev->CreateTexture( 100, 100, 1, 0, D3DFMT_A8R8G8B8,
D3DPOOL_DEFAULT, ppD3Dtex, NULL ) ) )
return FALSE;
if( FAILED( pDev->CreateTexture( 100, 100, 1, 0, D3DFMT_A8R8G8B8,
D3DPOOL_SYSTEMMEM, &Temp, NULL ) ) )
{
D3D_RELEASE( (*ppD3Dtex) )
return FALSE;
}
if( Temp->LockRect( 0, &d3dlr, 0, 0 ) == S_OK )
{
for( int i = 0;i < 100*100;i++ )
((PDWORD)d3dlr.pBits)[i] = Color;
Temp->UnlockRect( 0 );
pDev->UpdateTexture( Temp, *ppD3Dtex );
}
else
{
D3D_RELEASE( Temp )
D3D_RELEASE( (*ppD3Dtex) )
return FALSE;
}
D3D_RELEASE( Temp )
return TRUE;
}
bool WINAPI bDataCompare(const BYTE* pData, const BYTE* bMask, const char* szMask)
{
for (; *szMask; ++szMask, ++pData, ++bMask)
{
if (*szMask == 'x' && *pData != *bMask)
{
return false;
}
}
return (*szMask) == NULL;
}
DWORD WINAPI dwFindPattern(DWORD dwAddress, DWORD dwSize, BYTE* pbMask, char* szMask)
{
for (DWORD i = NULL; i < dwSize; i++)
{
if (bDataCompare((BYTE*)(dwAddress + i), pbMask, szMask))
{
return (DWORD)(dwAddress + i);
}
}
return 0;
}
VOID WINAPI GetD3D(VOID)
{
DWORD *vtbl;
// wait for the d3dx dll
DWORD hD3D = 0;
do {
hD3D = (DWORD)GetModuleHandleA("d3d9.dll");
Sleep(10);
} while (!hD3D);
DWORD adre = dwFindPattern(hD3D, 0x128000, (PBYTE)"\xC7\x06\x00\x00\x00\x00\x89\x86\x00\x00\x00\x00\x89\x86", "xx????xx????xx");
if (adre)
{
memcpy(&vtbl, (void*)(adre + 2), 4);
//ms detours 1.5
OrigReset = (Reset_t)DetourFunction((BYTE*)vtbl[16], (BYTE*)sys_Reset);
OrigDrawIndexedPrimitive = (DrawIndexedPrimitive_t)DetourFunction((BYTE*)vtbl[82], (BYTE*)sys_DrawIndexedPrimitive);
OrigEndScene = (EndScene_t)DetourFunction((BYTE*)vtbl[42], (BYTE*)sys_EndScene);
}
}
BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpvReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
DisableThreadLibraryCalls(hModule);
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)GetD3D, 0, 0, 0);
}
return TRUE;
}