Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18
  1. #1
    SoreBack's Avatar
    Join Date
    Jul 2008
    Gender
    male
    Posts
    25
    Reputation
    10
    Thanks
    4

    [Source]Chams w/ Vtable

    Code:
    #include <Windows.h>
    #include <d3d9.h>
    #include <detours.h>
    #include "stdafx.h"
    #pragma comment (lib, "d3d9.lib")
    
    IDirect3DDevice9 * pGameDevice;
    LPDIRECT3DTEXTURE9  Red,Yellow,Green,Blue,Purple,Pink,Orange;
    UINT iStride;
    bool Chams = true;
    
     
    //============================================================//
    HRESULT GenerateTexture(IDirect3DDevice9 *pD3Ddev, IDirect3DTexture9 **ppD3Dtex, DWORD colour32)
    {
        if( FAILED(pD3Ddev->CreateTexture(8, 8, 1, 0, D3DFMT_A4R4G4B4, D3DPOOL_MANAGED, ppD3Dtex)) )
            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;
    }//==================================Texture=========================//
    ////////////////
    ///BeginScene///
    ////////////////
    typedef HRESULT(WINAPI* BeginScene_)(LPDIRECT3DDEVICE9 pDevice);
    BeginScene_ pBeginScene;
    HRESULT WINAPI nBeginScene(LPDIRECT3DDEVICE9 pDevice)
    {
    	_asm NOP;
    	HRESULT hRet = pBeginScene(pDevice);
    	if (GetAsyncKeyState(VK_F1)&1)
    {
    	Chams = !Chams;
    }
    
    	return hRet;
    }
    
    /**************************************************************************************************/
    
    //////////////
    ///EndScene///
    //////////////
    typedef HRESULT(WINAPI* EndScene_)(LPDIRECT3DDEVICE9 pDevice);
    EndScene_ pEndScene;
    HRESULT WINAPI nEndScene(LPDIRECT3DDEVICE9 pDevice)
    {	
    	if(Chams)
    { 
    GenerateTexture(pDevice, &Red,      D3DCOLOR_ARGB    (255   ,   255  ,     0      ,    0      ));
    GenerateTexture(pDevice, &Yellow,   D3DCOLOR_ARGB    (255   ,   255  ,     255    ,    0      ));
    GenerateTexture(pDevice, &Green,    D3DCOLOR_ARGB    (255   ,   0    ,     255    ,    0      ));
    GenerateTexture(pDevice, &Blue,     D3DCOLOR_ARGB    (255   ,   0    ,     0      ,    255    ));
    GenerateTexture(pDevice, &Purple,   D3DCOLOR_ARGB    (255   ,   102  ,     0      ,    153    ));
    GenerateTexture(pDevice, &Pink,     D3DCOLOR_ARGB    (255   ,   255  ,     20      ,   147    ));
    GenerateTexture(pDevice, &Orange,   D3DCOLOR_ARGB    (255   ,   255  ,     165      ,  0      ));
    Color=false; 
    }
     
    return pEndScene(pDevice);
    }
    
    /**************************************************************************************************/
    
    //////////////////////////
    ///DrawIndexedPrimitive///
    //////////////////////////
    typedef HRESULT(WINAPI* DrawIndexedPrimitive_)(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE Type, INT BaseVertexIndex, UINT MinIndex,
    											  UINT NumVertices, UINT StartIndex, UINT PrimitiveCount);
    DrawIndexedPrimitive_ pDrawIndexedPrimitive;
    HRESULT WINAPI nDrawIndexedPrimitive(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE Type, INT BaseVertexIndex, UINT MinIndex,
    									UINT NumVertices, UINT StartIndex, UINT PrimitiveCount)
    {	
    	
    	
    	
    	
    	{	
    
    		pDevice->SetRenderState( D3DRS_FOGENABLE, false );
    
    	}	
    
    
    
    	IDirect3DVertexBuffer9* pStreamData = NULL;
    
    	UINT iOffsetInBytes,iStride; 
    
    	pDevice->GetStreamSource(0,&pStreamData,&iOffsetInBytes,&iStride); 
    
    	if (Chams) 
    	{
    		if (iStride == 44)
    		{
                 DWORD dwOldZEnable = D3DZB_TRUE;
                 pDevice->SetTexture(0, Orange);
                 pDevice->GetRenderState(D3DRS_ZENABLE, &dwOldZEnable);
                 pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
    			 pDevice->DrawIndexedPrimitive(Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
                 pDevice->SetRenderState(D3DRS_ZENABLE, dwOldZEnable);
                 pDevice->SetTexture(0, Red);
    }
    	}
    
    	
    	
    	
    	
    	return pDrawIndexedPrimitive(pDevice, Type, BaseVertexIndex, MinIndex, NumVertices, StartIndex, PrimitiveCount);
    			
    	
    }
    
    /**************************************************************************************************/
    
    /////////////////////
    ///SetStreamSource///
    /////////////////////
    typedef HRESULT(WINAPI* SetStreamSource_)(LPDIRECT3DDEVICE9 pDevice, UINT StreamNumber, IDirect3DVertexBuffer9 * pStreamData, UINT OffsetInBytes, UINT Stride);
    SetStreamSource_ pSetStreamSource;
    HRESULT WINAPI nSetStreamSource(LPDIRECT3DDEVICE9 pDevice, UINT StreamNumber, IDirect3DVertexBuffer9 * pStreamData, UINT OffsetInBytes, UINT Stride)
    {	
    	_asm NOP;
    	HRESULT hRet = pSetStreamSource(pDevice, StreamNumber, pStreamData, OffsetInBytes, Stride);
    if( StreamNumber == 0 ){iStride = Stride;}
    
    	return hRet;
    }
    
    /**************************************************************************************************/
    
    ///////////
    ///Reset///
    ///////////
    typedef HRESULT(WINAPI* Reset_)(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters);
    Reset_ pReset;
    HRESULT WINAPI nReset(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters)
    {
    	_asm NOP;
    	HRESULT hRet = pReset(pDevice, pPresentationParameters);
    
    	return hRet;
    }
    
    /**************************************************************************************************/
    
    
    DWORD dwWait(LPVOID lpArgs)
    {
    	
    	DWORD Base = NULL;
    
    	for (;Base == NULL;Sleep(100))           
    		Base = (DWORD)GetModuleHandle("Engine.exe//Whatever the processname is");  
    	
    	for(;pGameDevice == NULL; Sleep(10000))  
    	{
    		DWORD dwProtect;
    		VirtualProtect((void*)(0x7D0840), 4, PAGE_EXECUTE_READWRITE, &dwProtect);
    		memcpy(&pGameDevice, (void*)(0x7D0840), 4);
    		VirtualProtect((void*)(0x7D0840), 4, dwProtect, NULL);
    	}
    			
    		
    
    
    	DWORD* pdwNewDevice  =(DWORD*)*(DWORD*)pGameDevice;
    	pdwNewDevice = (DWORD*)pdwNewDevice[0];  //turn our pointer into an array for the vtable
    	
    	
    	pReset = (Reset_)DetourFunction((PBYTE)pdwNewDevice[16],(PBYTE)nReset);
    	pBeginScene = (BeginScene_)DetourFunction((PBYTE)pdwNewDevice[41],(PBYTE)nBeginScene);
    	pEndScene = (EndScene_)DetourFunction((PBYTE)pdwNewDevice[42],(PBYTE)nEndScene);
    	pDrawIndexedPrimitive = (DrawIndexedPrimitive_)DetourFunction((PBYTE)pdwNewDevice[82],(PBYTE)nDrawIndexedPrimitive);
    	pSetStreamSource = (SetStreamSource_)DetourFunction((PBYTE)pdwNewDevice[100],(PBYTE)nSetStreamSource);
    	
    	return 0;
    }
    
    bool WINAPI DllMain(HMODULE hMod, DWORD dwReason, LPVOID lpReserved)
    {
    	if(dwReason == DLL_PROCESS_ATTACH)
    	{
    				
    		CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)dwWait, NULL, NULL, NULL);
    		
    		return true;
    	}
    	
    	return false;
    }
    It has errors, i dont know if it still works.

    This isnt flawless, identify the errors and fix it. I dont want to make it a easy c/p..

    Have fun. Hopefully you'll get the base idea.

    Credits for Strife for the base.

    Credits to fatboy for his D3D8 offsets tutorial.
    I did this on the top of my head.
    Last edited by SoreBack; 01-29-2009 at 11:46 AM.

  2. #16
    Obama's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Location
    The Black house
    Posts
    22,195
    Reputation
    870
    Thanks
    6,076
    My Mood
    Cool
    Quote Originally Posted by rwkeith View Post
    I would if I had some help here >.>. I prefer to do something all the way too. If going to make something its going to have everything. Plus I wouldn't charge a dime. I'm better at cracking anyways.
    MPGH already has a bad reputation. We dont want your cracked hacks. If you say you have talent in coding than make a basic cham hack and theyll probably make u an admin or something.

  3. #17
    Remorse's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Location
    Follow the yellow brick road
    Posts
    2,286
    Reputation
    33
    Thanks
    184
    My Mood
    Psychedelic
    dont listen to him lol we really want your cracked hacks and if they dont make him an admin or anything mpgh's rep cant be hurt
    Time to start cycling through old sigs.
    [IMG]https://i381.photobucke*****m/albums/oo259/darkstar9540/5infection.png[/IMG]
    __________________________________________________

    Well that is that and this is this,
    You tell me what you want and I'll tell you what you get,
    You get away from me.
    You get away from me
    .
    Modest Mouse
    Ocean Breathes Salty
    Float On
    __________________________________________________

  4. #18
    SoreBack's Avatar
    Join Date
    Jul 2008
    Gender
    male
    Posts
    25
    Reputation
    10
    Thanks
    4
    Oh, i used the same hook for crossfire,(CF hook released by fatboy, atleast the device pointer).

Page 2 of 2 FirstFirst 12

Similar Threads

  1. [Release] Vtable hook source
    By nitega in forum All Points Bulletin Reloaded Hacks
    Replies: 26
    Last Post: 10-06-2011, 09:24 AM
  2. [CODE]VTable hooking
    By Hell_Demon in forum C++/C Programming
    Replies: 4
    Last Post: 10-31-2010, 01:49 PM
  3. crossfire wallhack source for hook
    By GangsterCode in forum CrossFire Hack Coding / Programming / Source Code
    Replies: 9
    Last Post: 10-04-2010, 06:47 AM
  4. Counter Strike Source Killa Hook
    By chrisisfat in forum CounterStrike (CS) 1.6 Hacks / Counter Strike: Source (CSS) Hacks
    Replies: 0
    Last Post: 12-15-2008, 05:51 AM
  5. [Source] WH_KEYBOARD Hook Hotkeys
    By d.vel.oper in forum C++/C Programming
    Replies: 1
    Last Post: 02-20-2008, 08:41 AM

Tags for this Thread