QuestionDetectedD3D hook (wallhack+aimbot)

Posts 115 of 41 · Page 1 of 3
D3D hook (wallhack+aimbot)
só compilar e se divertir...

Code:
#include "stdafx.h"

#include "D3dx9math.h"
#include "SDK.h"
#include "DX.h"
#include "CMenu.h"


 #include <fstream>
using namespace std;

typedef HRESULT (WINAPI *CreateQuery_t)                (LPDIRECT3DDEVICE9 pDevice, D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery);
typedef HRESULT (WINAPI *Reset_t)                    (LPDIRECT3DDEVICE9 pDevice,D3DPRESENT_PARAMETERS* pPresentationParameters);
typedef HRESULT (WINAPI *EndScene_t)                (LPDIRECT3DDEVICE9 pDevice);
typedef HRESULT (WINAPI *BeginScene_t)                (LPDIRECT3DDEVICE9 pDevice);
typedef HRESULT (WINAPI *DrawIndexedPrimitive_t)    (LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount);
typedef HRESULT (WINAPI *Lock_t)                    ( UINT OffsetToLock, UINT SizeToLock, VOID **data, DWORD Flags );

CreateQuery_t            _CreateQuery;
BeginScene_t            _BeginScene;
EndScene_t                _EndScene;
Reset_t                    _Reset;
DrawIndexedPrimitive_t    _DrawIndexedPrimitive;
Lock_t                    _Lock;

void Log(const char *fmt, ...);

CDX9Canvas                Canvas;
D3DVIEWPORT9            Viewport;

Menu* menu;

UINT m_Stride;
LPDIRECT3DVERTEXBUFFER9 m_StreamData;
UINT m_OffsetInBytes;

#define FOV_MULTI 20


bool

method = false,
g_bMenu = false,
init = false,

fullbright = false,
chams = true,        // **
loging = false,
wallhack = true,    // **
crossHair = true,    // **
removals = true,    // **
lambert = true,        // **
NoFog = false,
walls = false,
ESP = true,            // **
AIM = true,            // **
AimThru = false,
AimKey = false,
Shooting = true,    // **
IsPressed = false,
AimZombies = false,
ShowBotFov = false,
AllVisOff = true;
UINT 

curr=0,
curl=0,
stri[50000],
vert[50000],
prim[50000];

D3DCOLOR *pColor;

LPDIRECT3DSURFACE9 

originalSurface            = NULL,
originalDStencilSurface = NULL,
NewLSurface                = NULL,
NewSurface                = NULL;
D3DSURFACE_DESC 
originalSurfaceDesc,
originalDepthSurfaceDesc;

DWORD
TempX[220]  = {NULL},
TempY[220]  = {NULL},
color[220]    = {NULL},
ColorArray[400000] = {0};

UINT 
Scale   = 0,
Radius    = 0;
BYTE ColorDetector    = 0x00;
ID3DXBuffer *MyBuffer    = NULL;

D3DLOCKED_RECT LOCKEDRECT;
LPBYTE pBits = NULL;
POINT AimAt[400000] = {-1};
LPDIRECT3DPIXELSHADER9 
shadecolor[220] = {NULL},
OriginalShaders = NULL;
char MyShader    [MAX_PATH];

float 
    
View = 1.0f,
Step  = 0.0f,
circ1 = 0.0f,
circ2 = 0.0f,
circ3 = 0.0f,
circ4 = 0.0f;
    

int 

recoil            = 2,
FOV                = 0,
Count            = 0,
FirstPos        = 0,
LastPos            = 0,
NumberOfObjects = 0,
NumberOfShaders = 0,
BITSPERPIXEL    = 32;


int __stdcall GetDistance( long x1, long x2, long y1, long y2 )
{
    long ResA = (x1 - x2) * (x1 - x2);

    long ResB = (y1 - y2) * (y1 - y2);

    double ResC = (double)(ResA + ResB);

    return (int)sqrt( ResC );
}

BOOL __stdcall Aimbot(LPDIRECT3DDEVICE9 Device_Interface, D3DPRIMITIVETYPE Type, INT Base, UINT Min, UINT Num, UINT start, UINT prim)
{
    /* Filter calls to setrenderstate that distort color (incomplete) */
    //Device_Interface->GetRenderState( D3DRS_FOGENABLE, reinterpret_cast<DWORD*>(&FGE) );
 //   Device_Interface->GetRenderState( D3DRS_SRGBWRITEENABLE, reinterpret_cast<DWORD*>(&SRGBE) );
    
    /* Switch Rendertarget */
    Device_Interface->GetPixelShader( &OriginalShaders );
    Device_Interface->GetRenderTarget( 0,&originalSurface );
    Device_Interface->GetDepthStencilSurface( &originalDStencilSurface );
    Device_Interface->SetRenderTarget( 0,NewLSurface );
    Device_Interface->SetDepthStencilSurface( originalDStencilSurface );
    
    Device_Interface->SetRenderState( D3DRS_FOGENABLE, FALSE );
    Device_Interface->SetRenderState( D3DRS_SRGBWRITEENABLE, FALSE );
    
    Device_Interface->SetPixelShader( shadecolor[NumberOfObjects] );
    
    if(AimThru)
        Device_Interface->SetRenderState( D3DRS_ZENABLE,D3DZB_FALSE );
    
    _DrawIndexedPrimitive(Device_Interface, Type, Base, Min, Num, start, prim);
    
    if(AimThru)
        Device_Interface->SetRenderState( D3DRS_ZENABLE,D3DZB_TRUE );

    Device_Interface->SetRenderTarget( 0,originalSurface );
    Device_Interface->SetDepthStencilSurface( originalDStencilSurface );
    Device_Interface->SetPixelShader( OriginalShaders );

    //Device_Interface->SetRenderState( D3DRS_FOGENABLE, *reinterpret_cast<DWORD*>(&FGE) );
 //   Device_Interface->SetRenderState( D3DRS_SRGBWRITEENABLE, *reinterpret_cast<DWORD*>(&SRGBE) );

    if( originalSurface )
        if(originalSurface->Release() == S_OK)
            originalSurface = NULL;

    if( originalDStencilSurface )
        if(originalDStencilSurface->Release() == S_OK)
            originalDStencilSurface = NULL;

    if( OriginalShaders )
        if(OriginalShaders->Release() == S_OK)
            OriginalShaders = NULL;

    if( NumberOfObjects < 216 )
        NumberOfObjects++;

    return TRUE;
}

void Log(const char *fmt, ...)
{
    char logbuf[256]="";
#ifdef __TIME
    char time[9]="";
#endif
    va_list va_alist;
    ofstream logfile ("C:\\**************\\HOOK_LOG.TXT", ios::app);
#ifdef __TIME
    SYSTEMTIME systime;
    GetLocalTime(&systime);
    wsprintf(time, "%02d:%02d:%02d", systime.wHour, systime.wMinute, systime.wSecond);
#endif
    va_start (va_alist, fmt);
    _vsnprintf_s(logbuf+strlen(logbuf),512,511, fmt, va_alist);
    va_end (va_alist);
#ifdef __TIME
    logfile << time << ": " << logbuf << endl;
#else
    logfile << logbuf << endl;
#endif
}

HRESULT GenerateTexture(IDirect3DDevice9 *pD3Ddev, IDirect3DTexture9 **ppD3Dtex, DWORD colour32)
{
    if( FAILED(pD3Ddev->CreateTexture(8, 8, 1, 0, D3DFMT_A4R4G4B4, D3DPOOL_MANAGED, ppD3Dtex, NULL)) )
        return E_FAIL;
     
    WORD colour16 =    ((WORD)((colour32>>28)&0xF)<<12)
            |(WORD)(((colour32>>20)&0xF)<<8)
            |(WORD)(((colour32>>12)&0xF)<<4)
            |(WORD)(((colour32>>4)&0xF)<<0);
 
    D3DLOCKED_RECT d3dlr;   
    (*ppD3Dtex)->LockRect(0, &d3dlr, 0, 0);
    WORD *pDst16 = (WORD*)d3dlr.pBits;
 
    for(int xy=0; xy < 8*8; xy++)
        *pDst16++ = colour16;
 
    (*ppD3Dtex)->UnlockRect(0);
 
    return S_OK;
}

void PrintText(int x,int y,int r,int g,int b,int a, const char *fmt, ...)
{
    char draw[99]="";
    va_list va_alist;
    va_start (va_alist, fmt);
    //RECT Rectangle = {x, y, 1000+x, 1000+y};
    _vsnprintf_s(draw+strlen(draw),512,511, fmt, va_alist);
    va_end (va_alist);
    menu->drawText(x,y, r,g,b,    draw);
    //m_font->DrawText(NULL, draw , -1, &Rectangle, 0, D3DCOLOR_ARGB(r,g,b,a) );
}

void SetModelColor(LPDIRECT3DDEVICE9 pDevice, float r, float g, float b, float a, float glowr, float glowg, float glowb, float glowa)
{
    float lightValues[4] = {r, g, b, a};
    float glowValues[4] = {glowr, glowg, glowb, glowa};

    pDevice->SetPixelShaderConstantF(1, lightValues, 1);
    pDevice->SetPixelShaderConstantF(3, glowValues, 1);
} 

HRESULT WINAPI MyReset(LPDIRECT3DDEVICE9 pDevice,D3DPRESENT_PARAMETERS* pPresentationParameters)
{
    pCanvas->Reset();
    //Log("MyReset");
    return _Reset(pDevice,pPresentationParameters);
}

HRESULT WINAPI MyDrawIndexedPrimitive(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount)
{
    //Log("MyDrawIndexedPrimitive");

    bool gotPlayer = false;
    bool gotWeapon = false;
    bool gotZombie = false;
    bool gotTarget = false;

    if(pDevice->GetStreamSource(0, &m_StreamData, &m_OffsetInBytes, &m_Stride) == D3D_OK) m_StreamData->Release();

    if(removals && !AllVisOff)
    {
        if((NumVertices == 1652 && primCount == 826) ||
            (NumVertices == 2124 && primCount == 1062) ||
            (NumVertices == 812 && primCount == 406) ||
            (NumVertices == 575 && primCount == 299) ||
            (NumVertices == 928 && primCount == 464) ||
            (NumVertices == 160 && primCount == 80) ||
            (NumVertices == 5600 && primCount == 2800) ||
            (NumVertices == 288 && primCount == 144) ||
            (NumVertices == 1428 && primCount == 714) ||
            (NumVertices == 4284 && primCount == 2142) ||
            (NumVertices == 1175 && primCount == 611) ||
            (NumVertices == 1888 && primCount == 944) ||
            (NumVertices == 7996 && primCount == 4424) || // trees
            (NumVertices == 44 && primCount == 24) || // trees
            //(NumVertices == 8 && primCount == 4) || // trees
            (NumVertices == 352 && primCount == 176) ||
            (NumVertices == 11200 && primCount == 5600) ||
            (NumVertices == 576 && primCount == 288) ||
            (NumVertices == 480 && primCount == 240) ||
            (NumVertices == 320 && primCount == 160) ||
            (NumVertices == 32880 && primCount == 16440) ||
            (NumVertices == 8224 && primCount == 4112) ||
            (NumVertices == 1408 && primCount == 704) ||
            (NumVertices == 5120 && primCount == 2560) ||
            (NumVertices == 2856 && primCount == 1428) ||
            (NumVertices == 1421 && primCount == 1106) || // scope m4
            (NumVertices == 1670 && primCount == 1028) ) // scope m16
            return D3D_OK;
    }

     if(
        (NumVertices == 5650 && primCount == 2886) ||// zombies
        (NumVertices == 5046 && primCount == 2862) ||
        (NumVertices == 5037 && primCount == 2738) ||
        (NumVertices == 5043 && primCount == 2838) ||
        (NumVertices == 3709 && primCount == 2979) ||
        (NumVertices == 5640 && primCount == 2886) ||
        (NumVertices == 5125 && primCount == 2888) ||
        (NumVertices == 5905 && primCount == 2892) ||
        (NumVertices == 4987 && primCount == 2846) ||
        (NumVertices == 3873 && primCount == 3032) ||
        (NumVertices == 5438 && primCount == 2954) ||
        (NumVertices == 3840 && primCount == 3439) ||
        (NumVertices == 3500 && primCount == 3164) ||
        (NumVertices == 5300 && primCount == 4209) ||
        (NumVertices == 3875 && primCount == 3032) ||
        (NumVertices == 5045 && primCount == 2862) ||
        (NumVertices == 5438 && primCount == 2954) ||
        (NumVertices == 3380 && primCount == 3169) ||
        (NumVertices == 4987 && primCount == 2846) ||
        (NumVertices == 3873 && primCount == 3032) ||
        (NumVertices == 5438 && primCount == 2954) ||
        (NumVertices == 5045 && primCount == 2862) ||
        (NumVertices == 5864 && primCount == 2892) ||
        (NumVertices == 3500 && primCount == 3164) ||
        (NumVertices == 3978 && primCount == 3546) ||
        (NumVertices == 3403 && primCount == 2859) ||
        (NumVertices == 4112 && primCount == 3649) )
    {
        gotZombie = true;

        if(AimZombies)
            gotTarget = true;
    }
    
    if(
    (NumVertices == 3989 && primCount == 2014) || // Packpackmodels
    (NumVertices == 3557 && primCount == 1672) ||
    (NumVertices == 4404 && primCount == 2285) ||
    (NumVertices == 4510 && primCount == 2285) || // Player models
    (NumVertices == 1898 && primCount == 1683) ||
    (NumVertices == 4185 && primCount == 2668) || // new
    (NumVertices == 8862 && primCount == 4748) || // new
    (NumVertices == 3339 && primCount == 2236) ||
    (NumVertices == 1336 && primCount == 1683) ||
    (NumVertices == 3323 && primCount == 3603) ||
    (NumVertices == 3955 && primCount == 2588) ||
    (NumVertices == 3555 && primCount == 1958) ||
    (NumVertices == 5643 && primCount == 3989) ||
    (NumVertices == 7796 && primCount == 5111) ||
    (NumVertices == 6088 && primCount == 4044) ||
    (NumVertices == 7771 && primCount == 5111) ||
    (NumVertices == 4868 && primCount == 3407) ||
    (NumVertices == 9023 && primCount == 5547) ||
    (NumVertices == 3555 && primCount == 38)   ||
    (NumVertices == 5224 && primCount == 3603) ||
    (NumVertices == 7769 && primCount == 5111) ||
    (NumVertices == 7805 && primCount == 5111)
    )
    {
        gotPlayer = true;

    }

    if( // Heads
        (NumVertices == 3339 && primCount == 2236) ||
        (NumVertices == 3955 && primCount == 2588) ||
        (NumVertices == 3555 && primCount == 1958) ||
        (NumVertices == 4236 && primCount == 2475) ||
        (NumVertices == 5182 && primCount == 2889) ||
        (NumVertices == 8830 && primCount == 4587) ||
        (NumVertices == 4528 && primCount == 2525) ||
        (NumVertices == 4759 && primCount == 2650) ||
        (NumVertices == 8862 && primCount == 4748) ||
        (NumVertices == 7007 && primCount == 3744) ||
        (NumVertices == 3823 && primCount == 2194) )

        // Bodys
        //(NumVertices == 5224 && primCount == 3603) ||
        //(NumVertices == 3323 && primCount == 3603) ||
        //(NumVertices == 7796 && primCount == 5111) ||
        //(NumVertices == 7769 && primCount == 5111) ||
        //(NumVertices == 7771 && primCount == 5111) ||
        //(NumVertices == 7805 && primCount == 5111) ||
        //(NumVertices == 5643 && primCount == 3989) ||
        //(NumVertices == 8674 && primCount == 5302) ||
        //(NumVertices == 8952 && primCount == 5430) ||
        //(NumVertices == 8690 && primCount == 5302) ||
        //(NumVertices == 6115 && primCount == 4616) ||
        //(NumVertices == 6304 && primCount == 4768) ||
        //(NumVertices == 6575 && primCount == 4848) ||
        //(NumVertices == 6152 && primCount == 4680) )

        // Heads + Bodys
    //(NumVertices == 3339 && primCount == 2236) ||
    //(NumVertices == 5224 && primCount == 3603) ||
    //(NumVertices == 3323 && primCount == 3603) ||
    //(NumVertices == 3955 && primCount == 2588) ||
    //(NumVertices == 3555 && primCount == 1958) ||
    //(NumVertices == 4236 && primCount == 2475) ||
    //(NumVertices == 5182 && primCount == 2889) ||
    //(NumVertices == 5182 && primCount == 170)  ||
    //(NumVertices == 8830 && primCount == 4587) ||
    //(NumVertices == 4528 && primCount == 2525) ||
    //(NumVertices == 4759 && primCount == 2650) ||
    //(NumVertices == 8862 && primCount == 4748) ||
    //(NumVertices == 7007 && primCount == 288)  ||
    //(NumVertices == 7007 && primCount == 3744) ||
    //(NumVertices == 3823 && primCount == 288)  ||
    //(NumVertices == 3823 && primCount == 2194) ||
    //(NumVertices == 7796 && primCount == 5111) ||
    //(NumVertices == 7769 && primCount == 5111) ||
    //(NumVertices == 7771 && primCount == 5111) ||
    //(NumVertices == 7805 && primCount == 5111) ||
    //(NumVertices == 5643 && primCount == 3989) ||
    //(NumVertices == 8674 && primCount == 5302) ||
    //(NumVertices == 8952 && primCount == 5430) ||
    //(NumVertices == 8690 && primCount == 5302) ||
    //(NumVertices == 6115 && primCount == 4616) ||
    //(NumVertices == 6304 && primCount == 4768) ||
    //(NumVertices == 6575 && primCount == 4848) ||
    //(NumVertices == 6152 && primCount == 4680) )
    {
                gotTarget = true;
    }

    if( (NumVertices == 3379 && primCount == 2224) || // Moosberg
        (NumVertices == 7159 && primCount == 3527) || // Mauser
        (NumVertices == 5178 && primCount == 3303) || // M4
        (NumVertices == 5748 && primCount == 2785) || // Mp5
        (NumVertices == 4793 && primCount == 2753) || // Saiga
        (NumVertices == 4968 && primCount == 2502) || // AA-12
        (NumVertices == 3689 && primCount == 2080) || // M16
        (NumVertices == 4847 && primCount == 2502) || // AKS
        (NumVertices == 4878 && primCount == 2520) || // AKH
        (NumVertices == 4851 && primCount == 3142) || // M4G
        (NumVertices == 4891 && primCount == 2962) ) // WESTE
    {
        gotWeapon = true;
    }
    

    if(((wallhack || chams) && (gotPlayer || gotWeapon || gotZombie) && !AllVisOff))
    {
        if(wallhack)// invisible 
        {
            pDevice->SetRenderState(D3DRS_ZENABLE,D3DZB_FALSE);
        }
        if(chams)
        {
            if(lambert)
            {
                if(gotZombie)
                    SetModelColor(pDevice, 0.0f, 255.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f);  // green

                if(gotPlayer)
                    SetModelColor(pDevice, 200.0f, 165.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f);  // orange

                if(gotWeapon)
                    SetModelColor(pDevice, 0.0f, 0.0f, 255.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f);  // blue
            }
            else
            {
                if(gotZombie)
                    SetModelColor(pDevice, 0.0f, 255.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);  // green

                if(gotPlayer)
                    SetModelColor(pDevice, 200.0f, 165.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);  // orange

                if(gotWeapon)
                    SetModelColor(pDevice, 0.0f, 0.0f, 255.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);  // blue
            }
        }

        _DrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);

        if(wallhack)// visible 
        {
            pDevice->SetRenderState(D3DRS_ZENABLE,D3DZB_TRUE);
        }
        if(chams)
        {
            if(lambert)
            {
                if(gotZombie)
                    SetModelColor(pDevice, 0.0f, 255.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f);  // green

                if(gotPlayer)
                    SetModelColor(pDevice, 255.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f);  // red

                if(gotWeapon)
                    SetModelColor(pDevice, 0.0f, 0.0f, 255.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f);  // blue
            }
            else
            {

                if(gotZombie)
                    SetModelColor(pDevice, 0.0f, 255.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);  // green

                if(gotPlayer)
                    SetModelColor(pDevice, 255.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);  // red

                if(gotWeapon)
                    SetModelColor(pDevice, 0.0f, 0.0f, 255.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);  // blue
            }
        }
    }

    if( NoFog && !AllVisOff)
        pDevice->SetRenderState(D3DRS_FOGENABLE, false);
    
    if(fullbright && !AllVisOff)
    {
        pDevice->SetRenderState(D3DRS_LIGHTING, true);
        pDevice->SetRenderState(D3DRS_AMBIENT,D3DCOLOR_ARGB(255,255,255,255));
    }

    if((m_Stride == 32) && walls && !AllVisOff)
    {
            pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE); 
            pDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA); // Transparency
    }

    if(AIM)
    {    
        if(AIM && gotTarget)
        {
            Aimbot(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);

            if(!AllVisOff)
            {
                if(lambert)
                    SetModelColor(pDevice, 148.0f, 0.0f, 211.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f); // purple
                
                else
                    SetModelColor(pDevice, 148.0f, 0.0f, 211.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); // purple
            }
                
        }
    }

    if(loging)
    {
        bool bHave=false;
        for(int i=0;i<50000;i++)
        { 
            if(stri[i]==m_Stride && vert[i]==NumVertices && prim[i]==primCount)
            { 
                bHave=true;
                break; 
            } 
        }
        if(!bHave)
        {
            stri[curr]=m_Stride;
            vert[curr]=NumVertices;
            prim[curr]=primCount;
            curr++;
        }

        if(stri[curl]==m_Stride && vert[curl]==NumVertices && prim[curl]==primCount)
        {
            if(method)
                return NULL;
            else
                SetModelColor(pDevice, 255.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f);
        }
    }

    return _DrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
}

HRESULT WINAPI MyBeginScene(LPDIRECT3DDEVICE9 pDevice)
{    
    //Log("MyBeginScene");
    pDevice->GetViewport( &Viewport );

    if( !init )
    {
        init = true;

        pCanvas->Init(pDevice);
        //Log("Initialisation");
        menu = new Menu(pDevice,100,250);
        menu->addHack("   AllVisOff",&AllVisOff);
        menu->addHack("   Texture Log",&loging);
        menu->addHack("   Chams",&chams);
        menu->addHack("   Lambert",&lambert);
        menu->addHack("   FullBright",&fullbright);
        menu->addHack("   NoFog",&NoFog);
        menu->addHack("   Walls",&walls);
        menu->addHack("   Wallhack",&wallhack);
        menu->addHack("   Aimbot",&AIM);
        menu->addHack("   Aim Thru Walls",&AimThru);
        menu->addHack("   Aim Zombies",&AimZombies);
        menu->addHack("   AutoShoot",&Shooting);
        menu->addHack("   ESP AimTarget",&ESP);
        menu->addHack("   ShowBotFov",&ShowBotFov);
        menu->addHack("   CrossHair",&crossHair);
        menu->addHack("   Removals",&removals);

        /* Get Original Rendertarget Data */
        pDevice->GetRenderTarget( 0,&originalSurface );
        originalSurface->GetDesc( &originalSurfaceDesc );

        if( originalSurface )
            if(originalSurface->Release() == S_OK)
                originalSurface = NULL;

        /* Set The Default Radius */
        Radius = Viewport.Width / FOV_MULTI;

        /* Screen size difference */
        Scale = (UINT)(Viewport.Width/400);

        /* Create Small RenderTarget */
        pDevice->CreateRenderTarget( (UINT)(Viewport.Width/Scale),(UINT)(Viewport.Height/Scale), D3DFMT_A8R8G8B8,D3DMULTISAMPLE_NONE, 0,TRUE, &NewSurface, NULL);

        /* Create Large RenderTarget */
        pDevice->CreateRenderTarget((UINT)Viewport.Width,     (UINT)Viewport.Height, D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, TRUE, &NewLSurface, NULL);

        /* Create Shaders */
        NumberOfShaders = 0;
        for(int x = 1;x < 7;x++)
        {
            for(int y = 1;y < 7;y++)
            {
                for(int z = 1;z < 7;z++)
                {
                    MyBuffer = NULL;
                    
                    sprintf( MyShader, "ps.1.1\ndef c0, %f, %f, %f, %f\nmov r0,c0", 
                        (float)((float)x*(float)40)/(float)255, (float)((float)y*(float)40)/(float)255, 
                            (float)((float)z*(float)40)/(float)255,(float) (float)255/(float)255 );

                    D3DXAssembleShader( MyShader, sizeof( MyShader ), NULL, NULL, 0, &MyBuffer , NULL );

                    pDevice->CreatePixelShader((const DWORD*)MyBuffer ->GetBufferPointer(), &shadecolor[NumberOfShaders]);

                    color[NumberOfShaders] = (DWORD)D3DXCOLOR((float)((float)x*(float)40)/(float)255, 
                        (float)((float)y*(float)40)/(float)255, (float)((float)z*(float)40)/(float)255, 
                            (float) ((float)255/(float)255));

                    NumberOfShaders++;
                }
            }
        }
        /* Initialize StretchRect */
        pDevice->StretchRect( NewLSurface, NULL,NewSurface, NULL, D3DTEXF_NONE );
        /* Set The FOV */
        FOV = Radius;
    }

    NumberOfObjects = 0;

    // KEYS
    if( GetAsyncKeyState(VK_RBUTTON))
        AimKey = true;
    else
        AimKey = false;

    // 46 = F
    if( GetAsyncKeyState(0x46) &1){ AllVisOff = !AllVisOff; }

    if( GetAsyncKeyState(VK_DELETE) &1){ g_bMenu = !g_bMenu; }
    if( GetAsyncKeyState( VK_NUMPAD1 ) & 1 ){ method = !method; }
     
    if( GetAsyncKeyState( VK_MULTIPLY ) & 1 )
    {
        if(recoil > -10)
            recoil--;
    }

    if( GetAsyncKeyState( VK_DIVIDE ) & 1 )
    {
        if(recoil < 10)
            recoil++;
    }

    if( GetAsyncKeyState( VK_SUBTRACT ) & 1 )
    {
        if(loging)
        {
            if(curl != 0)
                curl--; 
        }
        else
        {
            if(FOV>20)
                FOV--;
        }
    }

    if( GetAsyncKeyState( VK_ADD ) & 1 )
    {
        if(loging)
        {
            if(curl < curr-1)
                curl++; 
        }
        else
        {
            if(FOV<500)
                FOV++;
        }
    }

    if( GetAsyncKeyState( VK_NUMPAD9 ) & 1 ){ if(curl != 0){ curl-=100; } }
    if( GetAsyncKeyState( VK_NUMPAD6 ) & 1 ){ if(curl < curr-1){ curl+=100; } }
    if( GetAsyncKeyState( VK_NUMPAD5 ) & 1 ){ Log("(NumVertices == %u && primCount == %u) ||",vert[curl],prim[curl]);}

    return _BeginScene(pDevice);
}

HRESULT WINAPI MyEndScene(LPDIRECT3DDEVICE9 pDevice)
{
    //Log("MyEndScene");
    int ClosestPosition = 0;
    int curDistance = 0;
    int PixelCtr = 0;

    POINT ClosestTarget,Target;
    ClosestTarget.x = -1;
    ClosestTarget.y = -1;

    pDevice->GetViewport(&Viewport);


    if( NumberOfObjects > 0 && AIM && AimKey)
    {    /* Lock the small rendertarget to get 2d coords . auto edge included . */
        pDevice->StretchRect( NewLSurface, NULL,NewSurface, NULL, D3DTEXF_NONE );

        if( NewSurface->LockRect( &LOCKEDRECT, NULL, D3DLOCK_READONLY ) == S_OK )
        {                
            for( long scy = (long)1 ; scy <= (long) ( Viewport.Height / (int) +Scale ); scy++ )
            {
                for( long scx = (long)1 ; scx <= (long) ( Viewport.Width / (int) +Scale); scx++ )
                {
                    AimAt[ PixelCtr ].x = -1;
                    AimAt[ PixelCtr ].y = -1;
                    ColorArray[ PixelCtr ] = -1;
                    pBits = ( LPBYTE ) LOCKEDRECT.pBits;
                    pBits += ( ( scy * LOCKEDRECT.Pitch ) + ( scx * ( BITSPERPIXEL / 8 ) ) );
                    pColor = ( D3DCOLOR* ) pBits;

                    if( *pColor != NULL )
                    {            
                        AimAt[ PixelCtr ].x = scx;
                        AimAt[ PixelCtr ].y = scy;
                        ColorArray[ PixelCtr ] = *pColor;

                        if( PixelCtr < 400000 )
                            PixelCtr++;
                    }
                }
            }
            NewSurface->UnlockRect( );
        }

        /* loop through the pixel data to get colors */

        ClosestPosition = FOV;
    
        for( int i = 0; i < NumberOfObjects; i++ )
        {
            ColorDetector = 0x00;
            TempX[i] = -1;
            TempY[i] = -1;

            for( int j = 0; j <= PixelCtr; j++ )
            {
                if( ColorArray[j] == color[i] && !ColorDetector )
                {    
                    FirstPos = j;
                    ColorDetector = 0x01;
                }
                if( ColorArray[j] == color[i] && ColorDetector )
                {    
                    LastPos = j;
                }
            }
            if( ColorDetector )
            {
                TempX[i] = ( DWORD )( AimAt[FirstPos].x + AimAt[LastPos].x ) / 2;
                TempY[i] = ( DWORD )( AimAt[FirstPos].y + AimAt[LastPos].y ) / 2;
    
                TempX[i] *= Scale;
                TempY[i] *= Scale;

                curDistance = GetDistance( TempX[i], Viewport.Width/2, TempY[i], Viewport.Height/2 );

                if(    curDistance < ClosestPosition)
                {
                    ClosestTarget.x = TempX[i];
                    ClosestTarget.y = TempY[i];
                }
            }
        }
        /* Aim at closest position */
        if( ClosestTarget.x != -1 && ClosestTarget.y != -1 && AIM && AimKey)
        {
            if((DWORD)ClosestTarget.x > (Viewport.Width/2))
            {
                Target.x = ClosestTarget.x - (Viewport.Width/2);
                Target.x /= 4;
                Target.x = +Target.x;
            }
                                
            if((DWORD)ClosestTarget.x < (Viewport.Width/2))
            {
                Target.x = (Viewport.Width/2) - ClosestTarget.x;
                Target.x /= 4;
                Target.x = -Target.x;
            }
                                
            if((DWORD)ClosestTarget.x == (Viewport.Width/2))
            {
                Target.x = 0;
            }
            
            if((DWORD)ClosestTarget.y > (Viewport.Height/2))
            {
                Target.y = ClosestTarget.y - (Viewport.Height/2);
                Target.y /= 4;
                Target.y = +Target.y;
            }
                                
            if((DWORD)ClosestTarget.y < (Viewport.Height/2))
            {
                Target.y = (Viewport.Height/2) - ClosestTarget.y;
                Target.y /= 4;
                Target.y = -Target.y;
            }
                                
            if((DWORD)ClosestTarget.y == (Viewport.Height/2))
            {
                Target.y = 0;
            }

            mouse_event( MOUSEEVENTF_MOVE, Target.x, Target.y + recoil , 0 , NULL );

            if(Shooting)
            {
                if(((DWORD)Target.x == 0) && ((DWORD)Target.y > 0))
                {
                    if(!IsPressed)
                    {
                        IsPressed = true;
                        mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
                    }
                        
                }
            }
        }

    }

    if(IsPressed && Shooting && ((DWORD)Target.x != 0) && ((DWORD)Target.y != 0))
    {
        IsPressed = false;
        mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
    }

    pCanvas->Begin();
    menu->updateMenu();
    menu->showMenu(g_bMenu);

    if(!AllVisOff)
    {    
        if(NumberOfObjects != 0)
        {
            menu->drawBox((Viewport.Width/2)-150,20,180,60,0,0,0,0,0,0);
            pCanvas->Box((Viewport.Width/2)-150,20,180,60,0xff0000);
        
            PrintText((Viewport.Width/2)-150+30,30, 255,0,0,255,"!! FOUND %i ENEMYS !!",NumberOfObjects);
            //PrintText((Viewport.Width/2)-150+30,40, 255,0,0,255,"Target.x: %i",Target.x);
            //PrintText((Viewport.Width/2)-150+30,50, 255,0,0,255,"Target.y: %i ",Target.y);
            PrintText((Viewport.Width/2)-150+30,50, 255,0,0,255,"DIS: %i FOV: %i REC: %i",curDistance,FOV,recoil);

            //if(AimKey)
            //    PrintText((Viewport.Width/2)-150+30,40, 255,0,0,255,"AimKey button pressed",NumberOfObjects);
            //else
            //    PrintText((Viewport.Width/2)-150+30,40, 255,0,0,255,"AimKey button released",NumberOfObjects);

            //if(IsPressed && Shooting)
            //    PrintText((Viewport.Width/2)-150+30,50, 255,0,0,255,"** shooting **",NumberOfObjects);
            //else
            //    PrintText((Viewport.Width/2)-150+30,50, 255,0,0,255,"not shooting",NumberOfObjects);
        }
    
        if(loging)
        {    
            menu->drawBox(0,6,300,16*13,0,0,0,0,0,0);
            PrintText(5,16*1, 255, 0, 0, 255, "[ Stride[%d]: %d ]", curl, stri[curl]);
            PrintText(5,16*2, 255, 0, 0, 255, "[ NumVertices[%d]: %d ]", curl, vert[curl]);
            PrintText(5,16*3, 255, 0, 0, 255, "[ PrimCount[%d]: %d ]", curl, prim[curl]);
            PrintText(5,16*4, 255, 0, 0, 255, "[ Logged: %d ]", curr);

            if(method){    PrintText(5,16*5, 255, 0, 0, 255, "[ Viewing: Remove ]"); }
            else{        PrintText(5,16*5, 255, 0, 0, 255, "[ Viewing: Color ]"); }

            PrintText(5,16*8, 255, 0, 0, 255, "Numpad 1 to change viewing-mode (Remove/Color).", curr);
            PrintText(5,16*9, 255, 0, 0, 255, "Numpad +/- to see next/prev. logged texture.", curr);
            PrintText(5,16*10, 255, 0, 0, 255, "Numpad 6/9 to see next/prev. by 100 logged texture.", curr);
            PrintText(5,16*11, 255, 0, 0, 255, "Numpad 5 to save current to log-file.", curr);
            PrintText(5,16*12, 255, 0, 0, 255, "Key Delete to switch menu on/off");
        }

        if(crossHair)
        {
            pCanvas->Line(Viewport.Width/2-20    ,Viewport.Height/2        ,Viewport.Width/2-5        ,Viewport.Height/2        ,0xFFFFFFFF);
            pCanvas->Line(Viewport.Width/2+5    ,Viewport.Height/2        ,Viewport.Width/2+20    ,Viewport.Height/2        ,0xFFFFFFFF);
            pCanvas->Line(Viewport.Width/2        ,Viewport.Height/2-20    ,Viewport.Width/2        ,Viewport.Height/2-5    ,0xFFFFFFFF);
            pCanvas->Line(Viewport.Width/2        ,Viewport.Height/2+5    ,Viewport.Width/2        ,Viewport.Height/2+20    ,0xFFFFFFFF);          
        }

        if(AIM && ShowBotFov)
        {
            if(AimKey)
                pCanvas->Circle(Viewport.Width/2,Viewport.Height/2,FOV,FOV,0xff0000);
            else
                pCanvas->Circle(Viewport.Width/2,Viewport.Height/2,FOV,FOV,0x00ff00ff);

        }

        /* Draw esp on all objects */
        if(ESP && AIM && AimKey)
        {
            for( int i = 0; i < NumberOfObjects; i++ )
            {
                if( TempX[i] != -1 && TempY[i] != -1 )
                {
                    //pCanvas->Box(TempX[i]-10,TempY[i]-10,30,40,0xff00ffff);
                    pCanvas->Circle(TempX[i],TempY[i],10,20,0xff00ffff);
                    //pCanvas->Line(TempX[i]-10    ,TempY[i]        ,TempX[i]-5        ,TempY[i]        ,0xff00ffff);
                    //pCanvas->Line(TempX[i]+5    ,TempY[i]        ,TempX[i]+10    ,TempY[i]        ,0xff00ffff);
                    //pCanvas->Line(TempX[i]        ,TempY[i]-10    ,TempX[i]        ,TempY[i]-5        ,0xff00ffff);
                    //pCanvas->Line(TempX[i]        ,TempY[i]+5        ,TempX[i]        ,TempY[i]+10    ,0xff00ffff);
                }
            }
        }
    }
    pCanvas->End();    

    if( AIM && AimKey)
    {
        /* Clear RenderTarget */
        pDevice->GetRenderTarget( 0,&originalSurface );
        pDevice->GetDepthStencilSurface( &originalDStencilSurface );
        pDevice->SetRenderTarget( 0,NewLSurface );
        pDevice->SetDepthStencilSurface( originalDStencilSurface );
        pDevice->Clear( 0, NULL, D3DCLEAR_TARGET , D3DXCOLOR(0.0, 0.0, 0.0, 1.0), 0.0f,  0 );
        pDevice->SetRenderTarget( 0,originalSurface );
        pDevice->SetDepthStencilSurface( originalDStencilSurface );

        if(originalSurface)
            if(originalSurface->Release() == S_OK)
                originalSurface = NULL;

        if(originalDStencilSurface)
            if(originalDStencilSurface->Release() == S_OK)
                originalDStencilSurface = NULL;
    }

    return _EndScene(pDevice);
}

HRESULT WINAPI MyCreateQuery(LPDIRECT3DDEVICE9 pDevice, D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery)
{
    //Log("MyCreateQuery");
    if( Type == D3DQUERYTYPE_OCCLUSION )
    {
        Type = D3DQUERYTYPE_EVENT;
    }
    return _CreateQuery(pDevice, Type, ppQuery);
} 
HRESULT WINAPI MyLock( UINT OffsetToLock, UINT SizeToLock, VOID **data, DWORD Flags )
{
    //Log("MyLock");
    AllVisOff = true;
    return _Lock(OffsetToLock,SizeToLock,data,Flags);
    //AllVisOff = false;
}
bool bCompare(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 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;
}

BOOL APIENTRY DllMain( HMODULE hModule,DWORD  ul_reason_for_call,LPVOID lpReserved)
{
    if (ul_reason_for_call == DLL_PROCESS_ATTACH)
    {
        //Log("DLL_PROCESS_ATTACH");
        //Beep(50,500);

        DWORD* vtbl = 0;     
        DWORD table = FindPattern((DWORD)GetModuleHandle("d3d9.dll"), 0x128000,     (PBYTE)"\xC7\x06\x00\x00\x00\x00\x89\x86\x00\x00\x00\x00\x89\x86", "xx????xx????xx");
        memcpy(&vtbl, (void*)(table+2), 4);

        pCanvas = &Canvas;

        if(vtbl)
        {            
            // CreateTexture // 23
            _Reset                    = (Reset_t)                    DetourFunction((PBYTE)(vtbl[16]),(PBYTE)&MyReset);
            _Lock                    = (Lock_t)                    DetourFunction((PBYTE)(vtbl[25]),(PBYTE)&MyLock);
            _BeginScene                = (BeginScene_t)            DetourFunction((PBYTE)(vtbl[41]),(PBYTE)&MyBeginScene);
            _EndScene                = (EndScene_t)                DetourFunction((PBYTE)(vtbl[42]),(PBYTE)&MyEndScene);
            _DrawIndexedPrimitive    = (DrawIndexedPrimitive_t)    DetourFunction((PBYTE)(vtbl[82]),(PBYTE)&MyDrawIndexedPrimitive);
            _CreateQuery            = (CreateQuery_t)            DetourFunction((PBYTE)(vtbl[118]),(PBYTE)&MyCreateQuery);
        }
    }
    if (ul_reason_for_call == DLL_PROCESS_DETACH)
    {
        //Log("DLL_PROCESS_ATTACH");
        //Beep(50,500);

        DetourRemove((PBYTE)_CreateQuery            , (PBYTE)MyCreateQuery);
        DetourRemove((PBYTE)_Reset                    , (PBYTE)MyReset);
        DetourRemove((PBYTE)_EndScene                , (PBYTE)MyEndScene);
        DetourRemove((PBYTE)_BeginScene            , (PBYTE)MyBeginScene);
        DetourRemove((PBYTE)_DrawIndexedPrimitive    , (PBYTE)MyDrawIndexedPrimitive);
    }

    return TRUE;
}
How exactly do u use this?im bad at programming so yea if anyone could make a dll out of this so we can inject it would be appreciated.
To use this I'm guessing you'll have to have an IDE for C? So you'll need to compile this. Not sure if it works though.
you compile this into a dll and use it to inject it into WarZ
How do i compile this?
Quote Originally Posted by tidu View Post
How do i compile this?
Im also wondering how too compile it, can anyone find out if it works and then make a how-to ?
Quote Originally Posted by reli1 View Post
Im also wondering how too compile it, can anyone find out if it works and then make a how-to ?
Ive tried too put it all in notepad, then save the file as a D3D Hook.dll, still I dont think it actually works.
It does not inject, gets an error!
How to make dll file?
i've tried to compile it but half of it gives an error... maybe im overlooking something
Quote Originally Posted by tidu View Post
i've tried to compile it but half of it gives an error... maybe im overlooking something
I got an error to.
First of all, this post is useless if we dont know what language this is in, is it "C# , C++ , F# , Visual basic?

Also should it be compiled to an Class Library (.Dll) or should it be compiled into a Console application?

Please leave more information before posting a post, this is totaly useless mate.....
/Cheers
Quote Originally Posted by akke92 View Post
First of all, this post is useless if we dont know what language this is in, is it "C# , C++ , F# , Visual basic?

Also should it be compiled to an Class Library (.Dll) or should it be compiled into a Console application?

Please leave more information before posting a post, this is totaly useless mate.....
/Cheers
Visual C++ , .DLL
Hello
I'm very bad in this Shit.
I dont understand C++, Notepad++ and all of this.
Can someone help me to complite this hack ?
Thanks D
Quote Originally Posted by akke92 View Post
First of all, this post is useless if we dont know what language this is in, is it "C# , C++ , F# , Visual basic?

Also should it be compiled to an Class Library (.Dll) or should it be compiled into a Console application?

Please leave more information before posting a post, this is totaly useless mate.....
/Cheers
It's only useless for people who don't know how to use them.

Quote Originally Posted by TheOnlyTrueMCT View Post
Hello
I'm very bad in this Shit.
I dont understand C++, Notepad++ and all of this.
Can someone help me to complite this hack ?
Thanks D
No.
Posts 115 of 41 · Page 1 of 3

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?