Go Back   UnKnoWnCheaTs - Multiplayer Game Hacks and Cheats > Anti-Cheat Software & Programming > Direct3D

- Sponsored Advertisement -
http://www.myfpscheats.com/

Welcome to the UnKnoWnCheaTs - Multiplayer Game Hacks and Cheats.
You have to register before you can post and see and access any of the advanced forum features, please click the register link to proceed to the registration form. To start viewing threads or posts, select a forum that you want to visit from the selection below.
Direct3D
hacking programming reversing
You are Unregistered, please register to gain Full access.    
Reply
 
Thread Tools

D3d9 hook
Old 05-31-2010, 05:12 PM   #1
n00bie

jokerjoza555's Avatar

Join Date: Feb 2010
Posts: 9
Reputation: 10
Rep Power: 25
jokerjoza555 has made posts that are generally average in quality
Points: 1,533, Level: 3
Points: 1,533, Level: 3 Points: 1,533, Level: 3 Points: 1,533, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Last Achievements
D3d9 hook

hi i compile wallhack PSF Special Force Undected Hook work win7

F1 =xhair = work
F2 =chams = don't work ??? //cause = ??

Source code texnum work d:


Help! Source Code it fail , I Seach no find

I speak english no get Thank you!!

ใครก็ได้ช่วยผมที่ครับ

Code:
//-----------------------------------------------------------------------------------------------------------------------------------
/****************************************************************
Coded by: JoshRose
Type: D3D VTable Base Hook
Credits: Strife, R4z8r, Zoomgod, Roverturbo and MSDN. Thanks all
for helping me when i got stuck.
****************************************************************/
 
#include "stdafx.h"
//----------------------------------------------------------------------------------------------------------------------------------
#include <windows.h>
//----------------------------------------------------------------------------------------------------------------------------------
#include "Main.h"
//-----------------------------------------------------------------------------------------------------------------------------------
#include <mmsystem.h>
#pragma comment(lib, "winmm.lib")
//-----------------------------------------------------------------------------------------------------------------------------------
#include <stdio.h>
//-----------------------------------------------------------------------------------------------------------------------------------
#include <fstream>
//-----------------------------------------------------------------------------------------------------------------------------------
#include "detours.h"
#pragma comment(lib,"detours.lib")
//-----------------------------------------------------------------------------------------------------------------------------------
#include <d3d9.h>
#include <d3dx9.h>
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")
float ScreenCenterX = 0.0f;
float ScreenCenterY = 0.0f;
bool Xhair;
bool Chams;
int texnum;
int m_Stride;
int NumVertices;
int PrimitiveCount;
void *DetourFunc(BYTE *src, const BYTE *dst, const int len);
bool bCompare(const BYTE* pData, const BYTE* bMask, const char* szMask);
DWORD FindPattern(DWORD dwAddress,DWORD dwLen,BYTE *bMask,char * szMask);
//=====================================================================================================================================================================================================================================================================================================================//
//==================================Defines============================================
#define ForceRecon (NumVertices == 83 && PrimitiveCount == 137 || NumVertices == 79 && PrimitiveCount == 105 || NumVertices == 142 && PrimitiveCount == 174 || NumVertices == 278 && PrimitiveCount == 462 || NumVertices == 263 && PrimitiveCount == 290 || NumVertices == 316 && PrimitiveCount == 556)
#define ForceReconAddons (NumVertices == 432 && PrimitiveCount == 354 || NumVertices == 144 && PrimitiveCount == 136 || NumVertices == 299 && PrimitiveCount == 311 || NumVertices == 167 && PrimitiveCount == 252 || NumVertices == 298 && PrimitiveCount == 506 || NumVertices == 168 && PrimitiveCount == 254 || NumVertices == 860 && NumVertices == 778 || NumVertices == 648 && PrimitiveCount == 710 || NumVertices == 113 && PrimitiveCount == 189 || NumVertices == 142 && PrimitiveCount == 172 || NumVertices == 87 && PrimitiveCount == 90 || NumVertices == 79 && PrimitiveCount == 105 || NumVertices == 84 && PrimitiveCount == 110 || NumVertices == 70 && PrimitiveCount == 70 || NumVertices == 860 && PrimitiveCount == 778 || NumVertices == 85 && PrimitiveCount == 137)
#define Mulan (NumVertices == 118 && PrimitiveCount == 126|| NumVertices == 121 && PrimitiveCount == 180|| NumVertices == 124 && PrimitiveCount == 126|| NumVertices == 295 && PrimitiveCount == 482|| NumVertices == 299 && PrimitiveCount == 452|| NumVertices == 474 && PrimitiveCount == 728)
#define MulanAddons (NumVertices == 162 && PrimitiveCount == 200|| NumVertices == 120 && PrimitiveCount == 188|| NumVertices == 167 && PrimitiveCount == 276|| NumVertices == 108 && PrimitiveCount == 198|| NumVertices == 512 && PrimitiveCount == 728|| NumVertices == 790 && PrimitiveCount == 881|| NumVertices == 619 && PrimitiveCount == 800|| NumVertices == 399 && PrimitiveCount == 532|| NumVertices == 402 && PrimitiveCount == 580|| NumVertices == 102 && PrimitiveCount == 170|| NumVertices == 125 && PrimitiveCount == 98|| NumVertices == 116 && PrimitiveCount == 128|| NumVertices == 160 && PrimitiveCount == 174) 
//===================================================================================================
LPDIRECT3DTEXTURE9 Red,Yellow,Green,Blue,Purple,Pink,Orange,Black,White;
D3DCOLOR colRed = D3DCOLOR_XRGB(255, 0, 0);
//-----------------------------------------------------------------------------------------------------------------------------------
using namespace std;
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;
}
//---------------------------------------------------------------------------------------------------------------------------------
#define HOOK(func,addy) o##func = (t##func)DetourFunction((PBYTE)addy,(PBYTE)hk##func) //Quick Hook using MS Detour
#define UNHOOK(func,addy) o##func = (t##func)DetourFunction((PBYTE)addy,(PBYTE)o##func) //Quick Unook using MS Detour
//---------------------------------------------------------------------------------------------------------------------------------
#define ES 0 //EndScene
#define DIP 1 //DrawIndexedPrimitive
#define RES 2 //Reset
//---------------------------------------------------------------------------------------------------------------------------------
LPDIRECT3DDEVICE9 npDevice; //pDevice is stored here so we can hook through the VTable
//---------------------------------------------------------------------------------------------------------------------------------
D3DVIEWPORT9 g_ViewPort; //ViewPort
//---------------------------------------------------------------------------------------------------------------------------------
LPDIRECT3DVERTEXBUFFER9 Stream_Data;
UINT Offset = 0;
UINT Stride = 40;
//---------------------------------------------------------------------------------------------------------------------------------
ofstream myfile; //Used for logging to a text file
//---------------------------------------------------------------------------------------------------------------------------------
typedef HRESULT (WINAPI* tEndScene)(LPDIRECT3DDEVICE9 pDevice);
tEndScene oEndScene = NULL;
typedef HRESULT (WINAPI* tDrawIndexedPrimitive)(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount);
tDrawIndexedPrimitive oDrawIndexedPrimitive = NULL;
typedef HRESULT(WINAPI* tReset)(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters);
tReset oReset = NULL;
//---------------------------------------------------------------------------------------------------------------------------------
PBYTE HookVTableFunction( PDWORD* dwVTable, PBYTE dwHook, INT Index )
{
DWORD dwOld = 0;
VirtualProtect((void*)((*dwVTable) + (Index*4) ), 4, PAGE_EXECUTE_READWRITE, &dwOld);
PBYTE pOrig = ((PBYTE)(*dwVTable)[Index]);
(*dwVTable)[Index] = (DWORD)dwHook;
VirtualProtect((void*)((*dwVTable) + (Index*4)), 4, dwOld, &dwOld);
return pOrig;
}
//-----------------------------------------------------------------------------------------------------------------------------------
HRESULT WINAPI hkEndScene(LPDIRECT3DDEVICE9 pDevice)
{
_asm pushad;
pDevice->GetViewport(&g_ViewPort);
ScreenCenterX = (float)g_ViewPort.Width / 2;
ScreenCenterY = (float)g_ViewPort.Height / 2;
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 ));
GenerateTexture(pDevice, &Black, D3DCOLOR_ARGB (255,0 ,0 ,0 ));
GenerateTexture(pDevice, &White, D3DCOLOR_ARGB (255,255,255,255));
if (Xhair)
{
D3DRECT rec2 = {ScreenCenterX-8, ScreenCenterY, ScreenCenterX+8, ScreenCenterY+1};
D3DRECT rec3 = {ScreenCenterX, ScreenCenterY-8, ScreenCenterX+1, ScreenCenterY+8};
pDevice->Clear(1, &rec2, D3DCLEAR_TARGET,colRed, 0, 0);
pDevice->Clear(1, &rec3, D3DCLEAR_TARGET,colRed, 0, 0);
}
if(GetAsyncKeyState(VK_F3)&1){Xhair=!Xhair;}
if(GetAsyncKeyState(VK_F4)&1){Chams=!Chams;}
_asm popad;
return oEndScene(pDevice);
}
//---------------------------------------------------------------------------------------------------------------------------------
HRESULT WINAPI hkDrawIndexedPrimitive(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount)
{
_asm pushad;
 
if(pDevice->GetStreamSource(0, &Stream_Data, &Offset, &Stride) == D3D_OK)
Stream_Data->Release();
texnum=(NumVertices*100000)+PrimitiveCount;
if (Chams)
{
if(m_Stride==40 &&
(texnum==34900580)|| // Delta Force Head
(texnum==36100604)|| // Spetsnaz Head
(texnum==38000658)|| // Spetsnaz Legs
(texnum==18300268)|| // Spetsnaz Body
(texnum==36200604)|| // GIGN Head
(texnum==21200306)|| // GIGN Body
(texnum==35500568)|| // GSG9 Head
(texnum==2200024)|| // GSG9 Bangs
(texnum==8800105)|| // GSG9 Feet
(texnum==36900650)|| // GSG9 Legs
(texnum==19600314)|| // GSG9 Body
(texnum==36700612)|| // SAS Head
(texnum==8500105)|| // SAS Feet
(texnum==37000650)|| // SAS Legs
(texnum==18000274)|| // SAS Body
(texnum==35300556)|| // KSF Head
(texnum==7500121)|| // KSF Arms
(texnum==9200115)|| // KSF Feet
(texnum==12400168)|| // KSF Hands
(texnum==30100522)|| // KSF Legs
(texnum==18700288)|| // KSF Body
(texnum==40900594)|| // ARTC Head
(texnum==11700190)|| // ARTC Arms
(texnum==9100118)|| // ARTC Feet
(texnum==12500170)|| // ARTC Hands
(texnum==37000634)|| // ARTC Legs
(texnum==41700516)|| // ARTC Body
(texnum==19400260)|| // ROKMC Body
(texnum==37900592)|| // ROKMC Head
(texnum==36500642)|| // ROKMC Legs
(texnum==44800776)|| // SRG Head
(texnum==15900200)|| // SRG Left Arm
(texnum==10500168)|| // SRG Right Arm
(texnum==80401016)|| // SRG Body
(texnum==10000121)|| // SRG Feet
(texnum==13200180)|| // SRG Hands
(ForceRecon)|| // ForceRecon
(Mulan)||
(texnum==33800534)) // SRG Leg
{
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_NEVER);
pDevice->SetTexture(0,Pink);
oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_LESSEQUAL);
pDevice->SetTexture(0,Orange);
} 
if (NumVertices == 213 && PrimitiveCount == 174) // M67 Grenade =============== //
{
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_NEVER);
pDevice->SetTexture(0,Red);
oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_LESSEQUAL);
pDevice->SetTexture(0,Green);
}
if (NumVertices == 158 && PrimitiveCount == 131) // Flashbang =============== //
{
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_NEVER);
pDevice->SetTexture(0,Red);
oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_LESSEQUAL);
pDevice->SetTexture(0,Green);
}
if (NumVertices == 171 && PrimitiveCount == 143) // Smoke Grenade =============== //
{
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_NEVER);
pDevice->SetTexture(0,Red);
oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_LESSEQUAL);
pDevice->SetTexture(0,Green);
}
if (NumVertices == 271 && PrimitiveCount == 257) // VX Grenade =============== //
{
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_NEVER);
pDevice->SetTexture(0,Red);
oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_LESSEQUAL);
pDevice->SetTexture(0,Green);
}
if (NumVertices == 338 && PrimitiveCount == 339) // RGD-5 Grenade =============== //
{
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_NEVER);
pDevice->SetTexture(0,Red);
oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_LESSEQUAL);
pDevice->SetTexture(0,Green);
}
if (m_Stride==40 && // Equipment =============== //
(texnum==13200212)|| // Delta Force Helmet
(texnum==13200212)|| // Delta Force Helmet 2
(texnum==34700538)|| // Delta Force Gas Mask
(texnum==19500352)|| // Delta Force Balaclava
(texnum==84900778)|| // Delta Force Clan BDU
(texnum==27500442)|| // Delta Force Body Armor
(texnum==42800576)|| // Delta Force Body Armor 2
(texnum==52100658)|| // Delta Force Tactical Vest
(texnum==12200196)|| // Spetsnaz Helmet
(texnum==27100464)|| // Spetsnaz Gas Mask
(texnum==33600552)|| // Spetsnaz Body Armor
(texnum==44100646)|| // Spetsnaz Tactical Vest
(texnum==17800292)|| // GIGN Red Bandana
(texnum==21300290)|| // GIGN Helmet
(texnum==2800036)|| // GIGN Helmet Lens
(texnum==35700558)|| // GIGN Gas Mask
(texnum==22100396)|| // GIGN Balaclava
(texnum==29700492)|| // GIGN Body Armor
(texnum==11200188)|| // ROKMC Beret
(texnum==12000194)|| // ROKMC Helmet
(texnum==29800450)|| // ROKMC Gas Mask
(texnum==27100394)|| // ROKMC Body Armor
(texnum==28700374)|| // ROKMC X Harness
(texnum==34700470)|| // ROKMC X Harness
(texnum==5100056)|| // ROKMC Pouch
(texnum==9900163)|| // ROKMC Left Arm
(texnum==18300163)|| // ROKMC Right Arm
(texnum==16400266)|| // GSG9 Red Bandana
(texnum==16200243)|| // GSG9 Helmet
(texnum==31900466)|| // GSG9 Gas Mask
(texnum==19300342)|| // GSG9 Balaclava
(texnum==83600752)|| // GSG9 Clan BDU
(texnum==33400477)|| // GSG9 Body Armor
(texnum==10500163)|| // GSG9 Rolled Up Sleeves
(texnum==38100666)|| // GSG9 Tactical Knee Pads
(texnum==9600172)|| // SAS Boonie Hat
(texnum==14200236)|| // SAS Helmet
(texnum==37800552)|| // SAS Gas Mask
(texnum==28100486)|| // SAS Balaclava
(texnum==62400752)|| // SAS Clan BDU
(texnum==27900456)|| // SAS Body Armor
(texnum==45700654)|| // SAS Tactical Vest
(texnum==39800532)|| // SAS Tactical Vest 2
(texnum==9200100)|| // SAS Holster
(texnum==4800040)|| // SAS Magazine Pouch
(texnum==4000044)|| // SAS Pouch
(texnum==6500110) || // KSF Boonie Hat
(texnum==12900208)|| // KSF Helmet
(texnum==29600448)|| // KSF Gas Mask
(texnum==31100398)|| // KSF Sunglasses
(texnum==84700776)|| // KSF Clan BDU
(texnum==600004)|| // KSF Clan BDU Logo
(texnum==36500606)|| // KSF Body Armor
(texnum==63100646)|| // KSF Tactical Vest
(texnum==19800163)|| // KSF Rolled Up Sleeves
(texnum==7000066)|| // KSF Holster
(texnum==10400190)|| // SRG Beret
(texnum==23800294)|| // SRG Deer Head
(texnum==11600180)|| // SRG NIJ IIIA Helmet
(texnum==17100278)|| // SRG Red Bandana
(texnum==14600198)|| // SRG Battle Cap
(texnum==18200266)|| // SRG Helmet
(texnum==19100106)|| // SRG Gas Mask
(texnum==54300350)|| // SRG Sunglasses
(texnum==30800380)|| // SRG Mid Class Sunglasses
(texnum==79300995)|| // SRG Clan BDU 1
(texnum==13300138)|| // SRG Clan BDU 2
(texnum==300001)|| // SRG Clan BDU 3
(texnum==1200012)|| // SRG Clan BDU Logo
(texnum==10900110)|| // SRG Bulletproof Vest
(texnum==6200064)|| // SRG Holster
(ForceReconAddons)||
(MulanAddons)||
(texnum==22700250)) // SRG Pouch
{
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_NEVER);
pDevice->SetTexture(0,Pink);
oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_LESSEQUAL);
pDevice->SetTexture(0,Orange);
} 
if (m_Stride==40 && // Guns =============== //
(texnum==187200968)|| // GALIL
(texnum==187200968)|| // GALIL 2
(texnum==149701124)|| // UZI
(texnum==193701304)|| // M249
(texnum==232501431)|| // SIG551
(texnum==161500751)|| // FA-MAS
(texnum==107400724)|| // FR-F2
(texnum==141600900)|| // AN94
(texnum==145900805)|| // G36C
(texnum==42200339)|| // K1
(texnum==23400116)|| // K1 2
(texnum==17500073)|| // K1 3
(texnum==3200012)|| // K1 4
(texnum==2300012)|| // K1 5
(texnum==71900459)|| // MP5
(texnum==1800008)|| // MP5 2
(texnum==20300084)|| // MP5 3
(texnum==16700083)|| // MP5 4
(texnum==79100469)|| // M4A1
(texnum==12000044)|| // M4A1 2
(texnum==16800062)|| // M4A1 3
(texnum==2400008)|| // M4A1 4
(texnum==600002)|| // M4A1 5
(texnum==12800050)|| // M4A1 6
(texnum==2600010)|| // M4A1 7
(texnum==4200014)|| // M4A1 8
(texnum==1400008)|| // M4A1 9
(texnum==80600442)|| // M16A2
(texnum==13400052)|| // M16A2 2
(texnum==17600066)|| // M16A2 3
(texnum==5400018)|| // M16A2 4
(texnum==46200348)|| // STEYR_AUG 
(texnum==27000133)|| // STEYR_AUG 2
(texnum==4100025)|| // STEYR_AUG 3
(texnum==1200006)|| // STEYR_AUG 4
(texnum==400002)|| // STEYR_AUG 5
(texnum==46800367)|| // PSG-1
(texnum==9600042)|| // PSG-1 2
(texnum==18800092)|| // PSG-1 3
(texnum==16900071)|| // PSG-1 4
(texnum==3400012)|| // PSG-1 5
(texnum==800004)|| // PSG-1 6
(texnum==40500383)|| // K2
(texnum==15800089)|| // K2 2
(texnum==2200012)|| // K2 3
(texnum==7000034)|| // K2 4
(texnum==60700349)|| // P90
(texnum==5500033)|| // P90 2
(texnum==47700227)|| // P90 3
(texnum==10300047)|| // P90 4
(texnum==3800014)|| // P90 5
(texnum==50300349)|| // AK-74
(texnum==14700071)|| // AK-74 2
(texnum==13100061)|| // AK-74 3
(texnum==194501145)|| // MG36
(texnum==116000670)|| // DESERT EAGLE
(texnum==182101089)|| // MR73
(texnum==62500454)|| // REMINGTON M870
(texnum==95200571)|| // BENELLI M1
(texnum==40700334)|| // GLOCK 23
(texnum==71500449)|| // BERETTA M92F
(texnum==11000044)|| // BERETTA M92F 2
(texnum==16500075)|| // BERETTA M92F 3
(texnum==4400020)|| // BERETTA M92F 4
(texnum==2800014)|| // BERETTA M92F 5
(texnum==92000543)|| // COLT 45
(texnum==239001276)) // DRAGONUV
{
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_NEVER);
pDevice->SetTexture(0,Pink);
oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_LESSEQUAL);
pDevice->SetTexture(0,Orange);
}
 
}
_asm popad;
return oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
}
HRESULT APIENTRY pfnPresentCb( HANDLE pDevice, LPVOID pData )//remember that pDevice is not the d3d device :p
{
_asm pushad;
 
 
_asm popad;
HRESULT hRet = pfnPresentCb( pDevice, pData ); 
return hRet; 
}
//---------------------------------------------------------------------------------------------------------------------------------
HRESULT WINAPI hkReset(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters)
{
return oReset(pDevice, pPresentationParameters);
}
//-----------------------------------------------------------------------------------------------------------------------------------
LRESULT CALLBACK MsgProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam){return DefWindowProc(hwnd, uMsg, wParam, lParam);}
void DX_Init(DWORD* table)
{
WNDCLASSEX wc = {sizeof(WNDCLASSEX),CS_CLASSDC,MsgProc,0L,0L,GetModuleHandle(NULL),NULL,NULL,NULL,NULL,"DX",NULL};
RegisterClassEx(&wc);
HWND hWnd = CreateWindow("DX",NULL,WS_OVERLAPPEDWINDOW,100,100,300,300,GetDesktopWindow(),NULL,wc.hInstance,NULL);
LPDIRECT3D9 pD3D = Direct3DCreate9( D3D_SDK_VERSION );
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
LPDIRECT3DDEVICE9 pd3dDevice;
pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp,&pd3dDevice);
DWORD* pVTable = (DWORD*)pd3dDevice;
pVTable = (DWORD*)pVTable[0];
table[ES] = pVTable[42]; //EndScene address
table[DIP] = pVTable[82]; //DrawIndexedPrimitive address
table[RES] = pVTable[16]; //Reset address
DestroyWindow(hWnd);
}
//==========================================FindPatt======================================================================//
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;
}
//=======================================================================
void *DetourFunc(BYTE *src, const BYTE *dst, const int len)
{
BYTE *jmp = (BYTE*)malloc(len+5);
DWORD dwBack;
VirtualProtect(src, len, PAGE_READWRITE, &dwBack);
memcpy(jmp, src, len); 
jmp += len;
jmp[0] = 0xE9;
*(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;
src[0] = 0x90; //50
src[1] = 0x90; // 58
src[2] = 0xE9;
*(DWORD*)(&src[3]) = (DWORD)(dst - src) - 7;
for (int i=7; i<len; i++) src[i] = 0x90;
VirtualProtect(src, len, dwBack, &dwBack);
return (jmp-len);
}
//------------------------------------------------------------------------------------------------------------------------------------
DWORD WINAPI VirtualMethodTableRepatchingLoopToCounterExtensionRepatching( LPVOID Param )
{
while(1) {
Sleep(100);
HookVTableFunction((PDWORD*)npDevice, (PBYTE)hkDrawIndexedPrimitive, 82); //Hook DrawIndexedPrimitive
HookVTableFunction((PDWORD*)npDevice, (PBYTE)hkEndScene, 42); //Hook EndScene
HookVTableFunction((PDWORD*)npDevice, (PBYTE)hkReset, 16); //Hook Reset
}
return 1;
}
//------------------------------------------------------------------------------------------------------------------------------------
bool hooked = false;
DWORD WINAPI LoopFunction( LPVOID lpParam )
{
while(1) {
if( hooked == false) {
DWORD VTable[3] = {0};
while(GetModuleHandle("d3d9.dll")==NULL) {
Sleep(250);
}
DX_Init(VTable);
HOOK(EndScene,VTable[ES]); //Hook EndScene as a device discovery hook
while(!npDevice) {
Sleep(50); //Sleep until npDevice is not equal to NULL
}
UNHOOK(EndScene, VTable[ES]); //Unhook as soon as we have a valid pointer to pDevice
*(PDWORD)&oDrawIndexedPrimitive = VTable[DIP];
*(PDWORD)&oEndScene = VTable[ES];
*(PDWORD)&oReset = VTable[RES];
CreateThread(NULL,0,&VirtualMethodTableRepatchingLoopToCounterExtensionRepatching,NULL,0,NULL); //Create hooking thread
hooked = true;
Sleep(200);
}
}
return 0;
}
//------------------------------------------------------------------------------------------------------------------------------------
BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpvReserved)
{
if(dwReason == DLL_PROCESS_ATTACH) {
CreateThread(0, 0, LoopFunction, 0, 0, 0);
 
}
return TRUE;
}
//------------------------------------------------------------------------------------------------------------------------------------
jokerjoza555 is offline

Reply With Quote


Old 05-31-2010, 05:48 PM   #2
SEGnosis
Guest

Posts: n/a
You have to understand what you are doing, do not expect to just paste together snippets and expect them to work.

There are many resources available in this section.
As for tutorial sites, the links are stickied.

Properly post your thread in the D3D Programming section next time.

Moved.

Reply With Quote

Old 06-24-2010, 05:11 AM   #3
n00bie

emyeusss7's Avatar

Join Date: Jan 2010
Posts: 1
Reputation: 10
Rep Power: 26
emyeusss7 has made posts that are generally average in quality
Points: 1,440, Level: 3
Points: 1,440, Level: 3 Points: 1,440, Level: 3 Points: 1,440, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Last Achievements
if(CH_Chams){
//By kukuma CF VietNam
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_NEVER);
pDevice->SetTexture(0,Pink);
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_LESSEQUAL);
pDevice->SetTexture(0,Orange);}
emyeusss7 is offline

Reply With Quote

Old 06-27-2010, 09:13 PM   #4
Hacker Supreme

chuculun's Avatar

Join Date: Feb 2010
Posts: 240
Reputation: 6024
Rep Power: 89
chuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATS
Points: 5,094, Level: 7
Points: 5,094, Level: 7 Points: 5,094, Level: 7 Points: 5,094, Level: 7
Activity: 15.3%
Activity: 15.3% Activity: 15.3% Activity: 15.3%
Last Achievements
This can be easily change to D3D8 right?
So instead of working in Ded9 i can make it work in a d3d8 game Since Drawindirexprimitive, reset and endscene is hooked...
chuculun is online now

Reply With Quote

Old 06-27-2010, 09:31 PM   #5
Supreme H4x0|2

4bply's Avatar

Join Date: Jan 2009
Location: uoy dniheB
Posts: 676
Reputation: 8706
Rep Power: 138
4bply DEFINES UNKNOWNCHEATS4bply DEFINES UNKNOWNCHEATS4bply DEFINES UNKNOWNCHEATS4bply DEFINES UNKNOWNCHEATS4bply DEFINES UNKNOWNCHEATS4bply DEFINES UNKNOWNCHEATS4bply DEFINES UNKNOWNCHEATS4bply DEFINES UNKNOWNCHEATS4bply DEFINES UNKNOWNCHEATS4bply DEFINES UNKNOWNCHEATS4bply DEFINES UNKNOWNCHEATS
Recognitions:
Members who have contributed financial support towards UnKnoWnCheaTs. Donation (1)
Points: 8,003, Level: 10
Points: 8,003, Level: 10 Points: 8,003, Level: 10 Points: 8,003, Level: 10
Activity: 1.1%
Activity: 1.1% Activity: 1.1% Activity: 1.1%
Last Achievements
Quote:
Code:
if (NumVertices == 158 && PrimitiveCount == 131) 
{
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_NEVER);
pDevice->SetTexture(0,Red);
oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_LESSEQUAL);
pDevice->SetTexture(0,Green);
}
I use this, and it works fine.

Code:
  if(D3DChams == true && Pac) 
  {
  pDevice->SetRenderState(D3DRS_ZENABLE, false);

   pDevice->SetTexture(0, texYellow);

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

  pDevice->SetRenderState(D3DRS_ZENABLE, true);

  }
__________________
"Stay on top but remain from the underground"

Last edited by 4bply; 06-27-2010 at 09:35 PM.
4bply is offline

Reply With Quote

Old 06-28-2010, 08:05 AM   #6
Hacker Supreme

chuculun's Avatar

Join Date: Feb 2010
Posts: 240
Reputation: 6024
Rep Power: 89
chuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATS
Points: 5,094, Level: 7
Points: 5,094, Level: 7 Points: 5,094, Level: 7 Points: 5,094, Level: 7
Activity: 15.3%
Activity: 15.3% Activity: 15.3% Activity: 15.3%
Last Achievements
Hey M8 i copy Your source code and edited it to D3d8 , yet i dont know when i am injecting it to the process of EXE the game does not want to start.....
here is the source i hope you Can help me a lilt with it ... i thank the people who cooperate with you on this...100%




Code:
//-----------------------------------------------------------------------------------------------------------------------------------
/****************************************************************
Coded by: JoshRose
Type: D3D VTable Base Hook
Credits: Strife, R4z8r, Zoomgod, Roverturbo and MSDN. Thanks all
for helping me when i got stuck.
****************************************************************/
 
#include "stdafx.h"
//----------------------------------------------------------------------------------------------------------------------------------
#include <windows.h>
//----------------------------------------------------------------------------------------------------------------------------------
#include "Main.h"
//-----------------------------------------------------------------------------------------------------------------------------------
#include <mmsystem.h>
#pragma comment(lib, "winmm.lib")
//-----------------------------------------------------------------------------------------------------------------------------------
#include <stdio.h>
//-----------------------------------------------------------------------------------------------------------------------------------
#include <fstream>
//-----------------------------------------------------------------------------------------------------------------------------------
#include "detours.h"
#pragma comment(lib,"detours.lib")
//-----------------------------------------------------------------------------------------------------------------------------------
#include <d3d8.h>
#include <d3dx8.h>
#pragma comment(lib, "d3d8.lib")
#pragma comment(lib, "d3dx8.lib")
float ScreenCenterX = 0.0f;
float ScreenCenterY = 0.0f;
bool Xhair;
bool Chams;
int texnum;
int m_Stride;
int NumVertices;
int PrimitiveCount;
void *DetourFunc(BYTE *src, const BYTE *dst, const int len);
bool bCompare(const BYTE* pData, const BYTE* bMask, const char* szMask);
DWORD FindPattern(DWORD dwAddress,DWORD dwLen,BYTE *bMask,char * szMask);
//=====================================================================================================================================================================================================================================================================================================================//
//==================================Defines============================================
#define ForceRecon (NumVertices == 83 && PrimitiveCount == 137 || NumVertices == 79 && PrimitiveCount == 105 || NumVertices == 142 && PrimitiveCount == 174 || NumVertices == 278 && PrimitiveCount == 462 || NumVertices == 263 && PrimitiveCount == 290 || NumVertices == 316 && PrimitiveCount == 556)
#define ForceReconAddons (NumVertices == 432 && PrimitiveCount == 354 || NumVertices == 144 && PrimitiveCount == 136 || NumVertices == 299 && PrimitiveCount == 311 || NumVertices == 167 && PrimitiveCount == 252 || NumVertices == 298 && PrimitiveCount == 506 || NumVertices == 168 && PrimitiveCount == 254 || NumVertices == 860 && NumVertices == 778 || NumVertices == 648 && PrimitiveCount == 710 || NumVertices == 113 && PrimitiveCount == 189 || NumVertices == 142 && PrimitiveCount == 172 || NumVertices == 87 && PrimitiveCount == 90 || NumVertices == 79 && PrimitiveCount == 105 || NumVertices == 84 && PrimitiveCount == 110 || NumVertices == 70 && PrimitiveCount == 70 || NumVertices == 860 && PrimitiveCount == 778 || NumVertices == 85 && PrimitiveCount == 137)
#define Mulan (NumVertices == 118 && PrimitiveCount == 126|| NumVertices == 121 && PrimitiveCount == 180|| NumVertices == 124 && PrimitiveCount == 126|| NumVertices == 295 && PrimitiveCount == 482|| NumVertices == 299 && PrimitiveCount == 452|| NumVertices == 474 && PrimitiveCount == 728)
#define MulanAddons (NumVertices == 162 && PrimitiveCount == 200|| NumVertices == 120 && PrimitiveCount == 188|| NumVertices == 167 && PrimitiveCount == 276|| NumVertices == 108 && PrimitiveCount == 198|| NumVertices == 512 && PrimitiveCount == 728|| NumVertices == 790 && PrimitiveCount == 881|| NumVertices == 619 && PrimitiveCount == 800|| NumVertices == 399 && PrimitiveCount == 532|| NumVertices == 402 && PrimitiveCount == 580|| NumVertices == 102 && PrimitiveCount == 170|| NumVertices == 125 && PrimitiveCount == 98|| NumVertices == 116 && PrimitiveCount == 128|| NumVertices == 160 && PrimitiveCount == 174) 
//===================================================================================================
LPDIRECT3DTEXTURE8 Red,Yellow,Green,Blue,Purple,Pink,Orange,Black,White;
D3DCOLOR colRed = D3DCOLOR_XRGB(255, 0, 0);
//-----------------------------------------------------------------------------------------------------------------------------------
using namespace std;
HRESULT GenerateTexture(IDirect3DDevice8 *pD3Ddev, IDirect3DTexture8 **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;
}

//---------------------------------------------------------------------------------------------------------------------------------
#define HOOK(func,addy) o##func = (t##func)DetourFunction((PBYTE)addy,(PBYTE)hk##func) //Quick Hook using MS Detour
#define UNHOOK(func,addy) o##func = (t##func)DetourFunction((PBYTE)addy,(PBYTE)o##func) //Quick Unook using MS Detour
//---------------------------------------------------------------------------------------------------------------------------------
#define ES 0 //EndScene
#define DIP 1 //DrawIndexedPrimitive
#define RES 2 //Reset
//---------------------------------------------------------------------------------------------------------------------------------
LPDIRECT3DDEVICE8 npDevice; //pDevice is stored here so we can hook through the VTable
//---------------------------------------------------------------------------------------------------------------------------------
D3DVIEWPORT8 g_ViewPort; //ViewPort
//---------------------------------------------------------------------------------------------------------------------------------
LPDIRECT3DVERTEXBUFFER8 Stream_Data;
UINT Offset = 0;
UINT Stride = 40;
//---------------------------------------------------------------------------------------------------------------------------------
ofstream myfile; //Used for logging to a text file
//---------------------------------------------------------------------------------------------------------------------------------
typedef HRESULT (WINAPI* tEndScene)(LPDIRECT3DDEVICE8 pDevice);
tEndScene oEndScene = NULL;
typedef HRESULT (WINAPI* tDrawIndexedPrimitive)(LPDIRECT3DDEVICE8 pDevice, D3DPRIMITIVETYPE PrimType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount);
tDrawIndexedPrimitive oDrawIndexedPrimitive = NULL;
typedef HRESULT(WINAPI* tReset)(LPDIRECT3DDEVICE8 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters);
tReset oReset = NULL;
//---------------------------------------------------------------------------------------------------------------------------------
PBYTE HookVTableFunction( PDWORD* dwVTable, PBYTE dwHook, INT Index )
{
DWORD dwOld = 0;
VirtualProtect((void*)((*dwVTable) + (Index*4) ), 4, PAGE_EXECUTE_READWRITE, &dwOld);
PBYTE pOrig = ((PBYTE)(*dwVTable)[Index]);
(*dwVTable)[Index] = (DWORD)dwHook;
VirtualProtect((void*)((*dwVTable) + (Index*4)), 4, dwOld, &dwOld);
return pOrig;
}
//-----------------------------------------------------------------------------------------------------------------------------------
HRESULT WINAPI hkEndScene(LPDIRECT3DDEVICE8 pDevice)
{
_asm pushad;
pDevice->GetViewport(&g_ViewPort);
ScreenCenterX = (float)g_ViewPort.Width / 2;
ScreenCenterY = (float)g_ViewPort.Height / 2;
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 ));
GenerateTexture(pDevice, &Black, D3DCOLOR_ARGB (255,0 ,0 ,0 ));
GenerateTexture(pDevice, &White, D3DCOLOR_ARGB (255,255,255,255));
if (Xhair)
{
D3DRECT rec2 = {ScreenCenterX-8, ScreenCenterY, ScreenCenterX+8, ScreenCenterY+1};
D3DRECT rec3 = {ScreenCenterX, ScreenCenterY-8, ScreenCenterX+1, ScreenCenterY+8};
pDevice->Clear(1, &rec2, D3DCLEAR_TARGET,colRed, 0, 0);
pDevice->Clear(1, &rec3, D3DCLEAR_TARGET,colRed, 0, 0);
}
if(GetAsyncKeyState(VK_F3)&1){Xhair=!Xhair;}
if(GetAsyncKeyState(VK_F4)&1){Chams=!Chams;}
_asm popad;
return oEndScene(pDevice);
}
//---------------------------------------------------------------------------------------------------------------------------------
HRESULT WINAPI hkDrawIndexedPrimitive(LPDIRECT3DDEVICE8 pDevice, D3DPRIMITIVETYPE PrimType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount)
{
_asm pushad;
 
if (Chams) //if chams on
{ //then
if (m_Stride==40)

{ //then
DWORD dwOldZEnable = D3DZB_TRUE; //define of dwOldZEnable
pDevice->SetTexture(0, Orange); // Fill objects that you see with Orange Color
pDevice->GetRenderState(D3DRS_ZENABLE, &dwOldZEnable); //its for the objects that ou see
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE); // again for the objects that you see
oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
pDevice->SetRenderState(D3DRS_ZENABLE, dwOldZEnable);//objects in background/behind walls
pDevice->SetTexture(0, Red); //fill with red color
}
}
_asm popad;
return oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
}
HRESULT APIENTRY pfnPresentCb( HANDLE pDevice, LPVOID pData )//remember that pDevice is not the d3d device :p
{
_asm pushad;
 
 
_asm popad;
HRESULT hRet = pfnPresentCb( pDevice, pData ); 
return hRet; 
}
//---------------------------------------------------------------------------------------------------------------------------------
HRESULT WINAPI hkReset(LPDIRECT3DDEVICE8 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters)
{
return oReset(pDevice, pPresentationParameters);
}
//-----------------------------------------------------------------------------------------------------------------------------------
LRESULT CALLBACK MsgProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam){return DefWindowProc(hwnd, uMsg, wParam, lParam);}
void DX_Init(DWORD* table)
{
WNDCLASSEX wc = {sizeof(WNDCLASSEX),CS_CLASSDC,MsgProc,0L,0L,GetModuleHandle(NULL),NULL,NULL,NULL,NULL,"DX",NULL};
RegisterClassEx(&wc);
HWND hWnd = CreateWindow("DX",NULL,WS_OVERLAPPEDWINDOW,100,100,300,300,GetDesktopWindow(),NULL,wc.hInstance,NULL);
LPDIRECT3D8 pD3D = Direct3DCreate8( D3D_SDK_VERSION );
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
LPDIRECT3DDEVICE8 pd3dDevice;
pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp,&pd3dDevice);
DWORD* pVTable = (DWORD*)pd3dDevice;
pVTable = (DWORD*)pVTable[0];
table[ES] = pVTable[42]; //EndScene address
table[DIP] = pVTable[82]; //DrawIndexedPrimitive address
table[RES] = pVTable[16]; //Reset address
DestroyWindow(hWnd);
}
//==========================================FindPatt======================================================================//
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;
}
//=======================================================================
void *DetourFunc(BYTE *src, const BYTE *dst, const int len)
{
BYTE *jmp = (BYTE*)malloc(len+5);
DWORD dwBack;
VirtualProtect(src, len, PAGE_READWRITE, &dwBack);
memcpy(jmp, src, len); 
jmp += len;
jmp[0] = 0xE9;
*(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;
src[0] = 0x90; //50
src[1] = 0x90; // 58
src[2] = 0xE9;
*(DWORD*)(&src[3]) = (DWORD)(dst - src) - 7;
for (int i=7; i<len; i++) src[i] = 0x90;
VirtualProtect(src, len, dwBack, &dwBack);
return (jmp-len);
}
//------------------------------------------------------------------------------------------------------------------------------------
DWORD WINAPI VirtualMethodTableRepatchingLoopToCounterExtensionRepatching( LPVOID Param )
{
while(1) {
Sleep(100);
HookVTableFunction((PDWORD*)npDevice, (PBYTE)hkDrawIndexedPrimitive, 82); //Hook DrawIndexedPrimitive
HookVTableFunction((PDWORD*)npDevice, (PBYTE)hkEndScene, 42); //Hook EndScene
HookVTableFunction((PDWORD*)npDevice, (PBYTE)hkReset, 16); //Hook Reset
}
return 1;
}
//------------------------------------------------------------------------------------------------------------------------------------
bool hooked = false;
DWORD WINAPI LoopFunction( LPVOID lpParam )
{
while(1) {
if( hooked == false) {
DWORD VTable[3] = {0};
while(GetModuleHandle("d3d8.dll")==NULL) {
Sleep(250);
}
DX_Init(VTable);
HOOK(EndScene,VTable[ES]); //Hook EndScene as a device discovery hook
while(!npDevice) {
Sleep(50); //Sleep until npDevice is not equal to NULL
}
UNHOOK(EndScene,VTable[ES]); //Unhook as soon as we have a valid pointer to pDevice
*(PDWORD)&oDrawIndexedPrimitive = VTable[DIP];
*(PDWORD)&oEndScene = VTable[ES];
*(PDWORD)&oReset = VTable[RES];
CreateThread(NULL,0,&VirtualMethodTableRepatchingLoopToCounterExtensionRepatching,NULL,0,NULL); //Create hooking thread
hooked = true;
Sleep(200);
}
}
return 0;
}
//------------------------------------------------------------------------------------------------------------------------------------
BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpvReserved)
{
if(dwReason == DLL_PROCESS_ATTACH) {
CreateThread(0, 0, LoopFunction, 0, 0, 0);
 
}
return TRUE;
}
//------------------------------------------------------------------------------------------------------------------------------------

Last edited by learn_more; 06-28-2010 at 10:44 AM. Reason: added code tags
chuculun is online now

Reply With Quote

Old 06-28-2010, 10:43 AM   #7
Retired Admin

learn_more's Avatar

Join Date: Sep 2006
Posts: 5,249
Reputation: 93628
Rep Power: 1106
learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!
Recognitions:
Members who have contributed financial support towards UnKnoWnCheaTs. Donation (2)
sieg heil Nazi
Points: 70,490, Level: 39
Points: 70,490, Level: 39 Points: 70,490, Level: 39 Points: 70,490, Level: 39
Activity: 24.7%
Activity: 24.7% Activity: 24.7% Activity: 24.7%
Last Achievements
Award-Showcase
how hard is it to add code tags yourself? -_-
__________________
learn_more is offline

Reply With Quote

Old 06-28-2010, 11:59 AM   #8
UnKnoWnCheaTeR

Heim Werker's Avatar

Join Date: Dec 2007
Location: Deutsches Reich
Posts: 1,020
Reputation: 60587
Rep Power: 676
Heim Werker has a huge epeen!Heim Werker has a huge epeen!Heim Werker has a huge epeen!Heim Werker has a huge epeen!Heim Werker has a huge epeen!Heim Werker has a huge epeen!Heim Werker has a huge epeen!Heim Werker has a huge epeen!Heim Werker has a huge epeen!Heim Werker has a huge epeen!Heim Werker has a huge epeen!
Snake Champion Troll Rampage Champion Pathfinder Champion Electric Soldier Porygon Champion 2 Ball Pool Champion Boris The Bandit Champion All Ball Champion
Recognitions:
The UC Member of the Month award is a prestigious award given to a single community member on a monthly basis. Based on a vote by UnKnoWnCheaTs staff, the award is given to the forum member that has shown exemplary achievement and potential in the UnKnoWnCheaTs community, and has shown great commitment to upholding the principles upon which UnKnoWnCheaTs stands for. A member who has been awarded the Member of the Month award has been distinguished as an asset to the UnKnoWnCheaTs community. Member of the Month
Points: 40,036, Level: 30
Points: 40,036, Level: 30 Points: 40,036, Level: 30 Points: 40,036, Level: 30
Activity: 8.2%
Activity: 8.2% Activity: 8.2% Activity: 8.2%
Last Achievements
Quote:
Originally Posted by chuculun View Post
Hey M8 i copy Your source code and edited it to D3d8 , yet i dont know when i am injecting it to the process of EXE the game does not want to start.....
here is the source i hope you Can help me a lilt with it ... i thank the people who cooperate with you on this...100%




Code:
code
dx8 have a different vtable
Heim Werker is offline

Reply With Quote

Old 06-28-2010, 12:23 PM   #9
*_*

HOOAH07's Avatar

Join Date: Apr 2008
Location: H.M.P
Posts: 5,436
Reputation: 92853
Rep Power: 1083
HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!
Recognitions:
The UC Member of the Month award is a prestigious award given to a single community member on a monthly basis. Based on a vote by UnKnoWnCheaTs staff, the award is given to the forum member that has shown exemplary achievement and potential in the UnKnoWnCheaTs community, and has shown great commitment to upholding the principles upon which UnKnoWnCheaTs stands for. A member who has been awarded the Member of the Month award has been distinguished as an asset to the UnKnoWnCheaTs community. Member of the Month
Points: 68,706, Level: 38
Points: 68,706, Level: 38 Points: 68,706, Level: 38 Points: 68,706, Level: 38
Activity: 65.9%
Activity: 65.9% Activity: 65.9% Activity: 65.9%
Last Achievements
Award-Showcase
EndScene // 35
DrawIndexedPrimitive // 71
Reset // 14
__________________
┐(_)

°º¤ø„¸¨°º¤ø„¸¸„ø¤º°¨¸„ø¤º°¨

¨°º¤ø„¸ MONKEY „ø¤º°¨

„ø¤º°¨ FOREVER `°º¤ø...
xTc charging me up like a battery, Like 1000 volts rushing through my body
HOOAH07 is online now

Reply With Quote

Old 06-28-2010, 04:15 PM   #10
Hacker Supreme

chuculun's Avatar

Join Date: Feb 2010
Posts: 240
Reputation: 6024
Rep Power: 89
chuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATS
Points: 5,094, Level: 7
Points: 5,094, Level: 7 Points: 5,094, Level: 7 Points: 5,094, Level: 7
Activity: 15.3%
Activity: 15.3% Activity: 15.3% Activity: 15.3%
Last Achievements
ok thank you i get What Your point is... let me try on changing its vtables.... i will repost what i have done...
!) swap EndScene = 35
2)DrawIndexedPrimitive = 71
3)Reset = 14

& rebuild the application but still the same problem... i dont know if it is because i am using Windows 7 That The Game Of Soldier front is not starting up when the Dll is being calling the function and hooked..


Could it be posible For me to put the Dll here So Some1 test it for me!

Last edited by chuculun; 06-28-2010 at 04:31 PM.
chuculun is online now

Reply With Quote

Old 06-28-2010, 10:29 PM   #11
UnKnoWnCheaTeR

Heim Werker's Avatar

Join Date: Dec 2007
Location: Deutsches Reich
Posts: 1,020
Reputation: 60587
Rep Power: 676
Heim Werker has a huge epeen!Heim Werker has a huge epeen!Heim Werker has a huge epeen!Heim Werker has a huge epeen!Heim Werker has a huge epeen!Heim Werker has a huge epeen!Heim Werker has a huge epeen!Heim Werker has a huge epeen!Heim Werker has a huge epeen!Heim Werker has a huge epeen!Heim Werker has a huge epeen!
Snake Champion Troll Rampage Champion Pathfinder Champion Electric Soldier Porygon Champion 2 Ball Pool Champion Boris The Bandit Champion All Ball Champion
Recognitions:
The UC Member of the Month award is a prestigious award given to a single community member on a monthly basis. Based on a vote by UnKnoWnCheaTs staff, the award is given to the forum member that has shown exemplary achievement and potential in the UnKnoWnCheaTs community, and has shown great commitment to upholding the principles upon which UnKnoWnCheaTs stands for. A member who has been awarded the Member of the Month award has been distinguished as an asset to the UnKnoWnCheaTs community. Member of the Month
Points: 40,036, Level: 30
Points: 40,036, Level: 30 Points: 40,036, Level: 30 Points: 40,036, Level: 30
Activity: 8.2%
Activity: 8.2% Activity: 8.2% Activity: 8.2%
Last Achievements
im not a 3d expert but you could check the args from dx9 and dx8 dip/endscene/Reset function could be a bit wrong
and make sure you clean the code out from all functions like inside dip ,endscene and reset function

Last edited by Heim Werker; 06-28-2010 at 10:32 PM.
Heim Werker is offline

Reply With Quote

Old 06-28-2010, 11:05 PM   #12
*_*

HOOAH07's Avatar

Join Date: Apr 2008
Location: H.M.P
Posts: 5,436
Reputation: 92853
Rep Power: 1083
HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!
Recognitions:
The UC Member of the Month award is a prestigious award given to a single community member on a monthly basis. Based on a vote by UnKnoWnCheaTs staff, the award is given to the forum member that has shown exemplary achievement and potential in the UnKnoWnCheaTs community, and has shown great commitment to upholding the principles upon which UnKnoWnCheaTs stands for. A member who has been awarded the Member of the Month award has been distinguished as an asset to the UnKnoWnCheaTs community. Member of the Month
Points: 68,706, Level: 38
Points: 68,706, Level: 38 Points: 68,706, Level: 38 Points: 68,706, Level: 38
Activity: 65.9%
Activity: 65.9% Activity: 65.9% Activity: 65.9%
Last Achievements
Award-Showcase
i dont know anything about D3D8 but take a look at starter kit maybe?
http://www.uc-forum.com/forum/d3d-tu...kit-v3-0b.html
what anti cheat does the game have?
maybe thats why its not starting game?
__________________
┐(_)

°º¤ø„¸¨°º¤ø„¸¸„ø¤º°¨¸„ø¤º°¨

¨°º¤ø„¸ MONKEY „ø¤º°¨

„ø¤º°¨ FOREVER `°º¤ø...
xTc charging me up like a battery, Like 1000 volts rushing through my body
HOOAH07 is online now

Reply With Quote

Old 06-29-2010, 04:59 AM   #13
Hacker Supreme

chuculun's Avatar

Join Date: Feb 2010
Posts: 240
Reputation: 6024
Rep Power: 89
chuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATS
Points: 5,094, Level: 7
Points: 5,094, Level: 7 Points: 5,094, Level: 7 Points: 5,094, Level: 7
Activity: 15.3%
Activity: 15.3% Activity: 15.3% Activity: 15.3%
Last Achievements
Quote:
Originally Posted by HOOAH07 View Post
i dont know anything about D3D8 but take a look at starter kit maybe?
http://www.uc-forum.com/forum/d3d-tu...kit-v3-0b.html
what anti cheat does the game have?
maybe thats why its not starting game?


It has GameGuard ... Hackshield...
chuculun is online now

Reply With Quote

Old 06-29-2010, 08:27 AM   #14
*_*

HOOAH07's Avatar

Join Date: Apr 2008
Location: H.M.P
Posts: 5,436
Reputation: 92853
Rep Power: 1083
HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!HOOAH07 has a huge epeen!
Recognitions:
The UC Member of the Month award is a prestigious award given to a single community member on a monthly basis. Based on a vote by UnKnoWnCheaTs staff, the award is given to the forum member that has shown exemplary achievement and potential in the UnKnoWnCheaTs community, and has shown great commitment to upholding the principles upon which UnKnoWnCheaTs stands for. A member who has been awarded the Member of the Month award has been distinguished as an asset to the UnKnoWnCheaTs community. Member of the Month
Points: 68,706, Level: 38
Points: 68,706, Level: 38 Points: 68,706, Level: 38 Points: 68,706, Level: 38
Activity: 65.9%
Activity: 65.9% Activity: 65.9% Activity: 65.9%
Last Achievements
Award-Showcase
i never used these AC's but wont you need a bypass?
best thing to do would be check anti cheat bypass section see what others say about this AC
__________________
┐(_)

°º¤ø„¸¨°º¤ø„¸¸„ø¤º°¨¸„ø¤º°¨

¨°º¤ø„¸ MONKEY „ø¤º°¨

„ø¤º°¨ FOREVER `°º¤ø...
xTc charging me up like a battery, Like 1000 volts rushing through my body
HOOAH07 is online now

Reply With Quote

Old 06-29-2010, 10:13 AM   #15
Hacker Supreme

chuculun's Avatar

Join Date: Feb 2010
Posts: 240
Reputation: 6024
Rep Power: 89
chuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATSchuculun DEFINES UNKNOWNCHEATS
Points: 5,094, Level: 7
Points: 5,094, Level: 7 Points: 5,094, Level: 7 Points: 5,094, Level: 7
Activity: 15.3%
Activity: 15.3% Activity: 15.3% Activity: 15.3%
Last Achievements
ok thank you m8 i apreciate your help...
chuculun is online now

Reply With Quote

Old 07-09-2010, 07:51 AM   #16
n00bie

dldx's Avatar

Join Date: Apr 2010
Location: In the mega word
Posts: 7
Reputation: 10
Rep Power: 23
dldx has made posts that are generally average in quality
Points: 1,372, Level: 2
Points: 1,372, Level: 2 Points: 1,372, Level: 2 Points: 1,372, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Last Achievements
Quote:
Originally Posted by chuculun View Post
ok thank you m8 i apreciate your help...
If you arrive to bypassed it, let me know how you did it. ;- )

Greetings.
dldx is offline

Reply With Quote

Old 08-21-2010, 02:38 PM   #17
n00bie

bigli's Avatar

Join Date: Aug 2010
Posts: 1
Reputation: 10
Rep Power: 19
bigli has made posts that are generally average in quality
Points: 1,053, Level: 2
Points: 1,053, Level: 2 Points: 1,053, Level: 2 Points: 1,053, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Last Achievements
Quote:
Originally Posted by chuculun View Post
Hey M8 i copy Your source code and edited it to D3d8 , yet i dont know when i am injecting it to the process of EXE the game does not want to start.....
here is the source i hope you Can help me a lilt with it ... i thank the people who cooperate with you on this...100%




Code:
//-----------------------------------------------------------------------------------------------------------------------------------
/****************************************************************
Coded by: JoshRose
Type: D3D VTable Base Hook
Credits: Strife, R4z8r, Zoomgod, Roverturbo and MSDN. Thanks all
for helping me when i got stuck.
****************************************************************/
 
#include "stdafx.h"
//----------------------------------------------------------------------------------------------------------------------------------
#include <windows.h>
//----------------------------------------------------------------------------------------------------------------------------------
#include "Main.h"
//-----------------------------------------------------------------------------------------------------------------------------------
#include <mmsystem.h>
#pragma comment(lib, "winmm.lib")
//-----------------------------------------------------------------------------------------------------------------------------------
#include <stdio.h>
//-----------------------------------------------------------------------------------------------------------------------------------
#include <fstream>
//-----------------------------------------------------------------------------------------------------------------------------------
#include "detours.h"
#pragma comment(lib,"detours.lib")
//-----------------------------------------------------------------------------------------------------------------------------------
#include <d3d8.h>
#include <d3dx8.h>
#pragma comment(lib, "d3d8.lib")
#pragma comment(lib, "d3dx8.lib")
float ScreenCenterX = 0.0f;
float ScreenCenterY = 0.0f;
bool Xhair;
bool Chams;
int texnum;
int m_Stride;
int NumVertices;
int PrimitiveCount;
void *DetourFunc(BYTE *src, const BYTE *dst, const int len);
bool bCompare(const BYTE* pData, const BYTE* bMask, const char* szMask);
DWORD FindPattern(DWORD dwAddress,DWORD dwLen,BYTE *bMask,char * szMask);
//=====================================================================================================================================================================================================================================================================================================================//
//==================================Defines============================================
#define ForceRecon (NumVertices == 83 && PrimitiveCount == 137 || NumVertices == 79 && PrimitiveCount == 105 || NumVertices == 142 && PrimitiveCount == 174 || NumVertices == 278 && PrimitiveCount == 462 || NumVertices == 263 && PrimitiveCount == 290 || NumVertices == 316 && PrimitiveCount == 556)
#define ForceReconAddons (NumVertices == 432 && PrimitiveCount == 354 || NumVertices == 144 && PrimitiveCount == 136 || NumVertices == 299 && PrimitiveCount == 311 || NumVertices == 167 && PrimitiveCount == 252 || NumVertices == 298 && PrimitiveCount == 506 || NumVertices == 168 && PrimitiveCount == 254 || NumVertices == 860 && NumVertices == 778 || NumVertices == 648 && PrimitiveCount == 710 || NumVertices == 113 && PrimitiveCount == 189 || NumVertices == 142 && PrimitiveCount == 172 || NumVertices == 87 && PrimitiveCount == 90 || NumVertices == 79 && PrimitiveCount == 105 || NumVertices == 84 && PrimitiveCount == 110 || NumVertices == 70 && PrimitiveCount == 70 || NumVertices == 860 && PrimitiveCount == 778 || NumVertices == 85 && PrimitiveCount == 137)
#define Mulan (NumVertices == 118 && PrimitiveCount == 126|| NumVertices == 121 && PrimitiveCount == 180|| NumVertices == 124 && PrimitiveCount == 126|| NumVertices == 295 && PrimitiveCount == 482|| NumVertices == 299 && PrimitiveCount == 452|| NumVertices == 474 && PrimitiveCount == 728)
#define MulanAddons (NumVertices == 162 && PrimitiveCount == 200|| NumVertices == 120 && PrimitiveCount == 188|| NumVertices == 167 && PrimitiveCount == 276|| NumVertices == 108 && PrimitiveCount == 198|| NumVertices == 512 && PrimitiveCount == 728|| NumVertices == 790 && PrimitiveCount == 881|| NumVertices == 619 && PrimitiveCount == 800|| NumVertices == 399 && PrimitiveCount == 532|| NumVertices == 402 && PrimitiveCount == 580|| NumVertices == 102 && PrimitiveCount == 170|| NumVertices == 125 && PrimitiveCount == 98|| NumVertices == 116 && PrimitiveCount == 128|| NumVertices == 160 && PrimitiveCount == 174) 
//===================================================================================================
LPDIRECT3DTEXTURE8 Red,Yellow,Green,Blue,Purple,Pink,Orange,Black,White;
D3DCOLOR colRed = D3DCOLOR_XRGB(255, 0, 0);
//-----------------------------------------------------------------------------------------------------------------------------------
using namespace std;
HRESULT GenerateTexture(IDirect3DDevice8 *pD3Ddev, IDirect3DTexture8 **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;
}

//---------------------------------------------------------------------------------------------------------------------------------
#define HOOK(func,addy) o##func = (t##func)DetourFunction((PBYTE)addy,(PBYTE)hk##func) //Quick Hook using MS Detour
#define UNHOOK(func,addy) o##func = (t##func)DetourFunction((PBYTE)addy,(PBYTE)o##func) //Quick Unook using MS Detour
//---------------------------------------------------------------------------------------------------------------------------------
#define ES 0 //EndScene
#define DIP 1 //DrawIndexedPrimitive
#define RES 2 //Reset
//---------------------------------------------------------------------------------------------------------------------------------
LPDIRECT3DDEVICE8 npDevice; //pDevice is stored here so we can hook through the VTable
//---------------------------------------------------------------------------------------------------------------------------------
D3DVIEWPORT8 g_ViewPort; //ViewPort
//---------------------------------------------------------------------------------------------------------------------------------
LPDIRECT3DVERTEXBUFFER8 Stream_Data;
UINT Offset = 0;
UINT Stride = 40;
//---------------------------------------------------------------------------------------------------------------------------------
ofstream myfile; //Used for logging to a text file
//---------------------------------------------------------------------------------------------------------------------------------
typedef HRESULT (WINAPI* tEndScene)(LPDIRECT3DDEVICE8 pDevice);
tEndScene oEndScene = NULL;
typedef HRESULT (WINAPI* tDrawIndexedPrimitive)(LPDIRECT3DDEVICE8 pDevice, D3DPRIMITIVETYPE PrimType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount);
tDrawIndexedPrimitive oDrawIndexedPrimitive = NULL;
typedef HRESULT(WINAPI* tReset)(LPDIRECT3DDEVICE8 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters);
tReset oReset = NULL;
//---------------------------------------------------------------------------------------------------------------------------------
PBYTE HookVTableFunction( PDWORD* dwVTable, PBYTE dwHook, INT Index )
{
DWORD dwOld = 0;
VirtualProtect((void*)((*dwVTable) + (Index*4) ), 4, PAGE_EXECUTE_READWRITE, &dwOld);
PBYTE pOrig = ((PBYTE)(*dwVTable)[Index]);
(*dwVTable)[Index] = (DWORD)dwHook;
VirtualProtect((void*)((*dwVTable) + (Index*4)), 4, dwOld, &dwOld);
return pOrig;
}
//-----------------------------------------------------------------------------------------------------------------------------------
HRESULT WINAPI hkEndScene(LPDIRECT3DDEVICE8 pDevice)
{
_asm pushad;
pDevice->GetViewport(&g_ViewPort);
ScreenCenterX = (float)g_ViewPort.Width / 2;
ScreenCenterY = (float)g_ViewPort.Height / 2;
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 ));
GenerateTexture(pDevice, &Black, D3DCOLOR_ARGB (255,0 ,0 ,0 ));
GenerateTexture(pDevice, &White, D3DCOLOR_ARGB (255,255,255,255));
if (Xhair)
{
D3DRECT rec2 = {ScreenCenterX-8, ScreenCenterY, ScreenCenterX+8, ScreenCenterY+1};
D3DRECT rec3 = {ScreenCenterX, ScreenCenterY-8, ScreenCenterX+1, ScreenCenterY+8};
pDevice->Clear(1, &rec2, D3DCLEAR_TARGET,colRed, 0, 0);
pDevice->Clear(1, &rec3, D3DCLEAR_TARGET,colRed, 0, 0);
}
if(GetAsyncKeyState(VK_F3)&1){Xhair=!Xhair;}
if(GetAsyncKeyState(VK_F4)&1){Chams=!Chams;}
_asm popad;
return oEndScene(pDevice);
}
//---------------------------------------------------------------------------------------------------------------------------------
HRESULT WINAPI hkDrawIndexedPrimitive(LPDIRECT3DDEVICE8 pDevice, D3DPRIMITIVETYPE PrimType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount)
{
_asm pushad;
 
if (Chams) //if chams on
{ //then
if (m_Stride==40)

{ //then
DWORD dwOldZEnable = D3DZB_TRUE; //define of dwOldZEnable
pDevice->SetTexture(0, Orange); // Fill objects that you see with Orange Color
pDevice->GetRenderState(D3DRS_ZENABLE, &dwOldZEnable); //its for the objects that ou see
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE); // again for the objects that you see
oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
pDevice->SetRenderState(D3DRS_ZENABLE, dwOldZEnable);//objects in background/behind walls
pDevice->SetTexture(0, Red); //fill with red color
}
}
_asm popad;
return oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
}
HRESULT APIENTRY pfnPresentCb( HANDLE pDevice, LPVOID pData )//remember that pDevice is not the d3d device :p
{
_asm pushad;
 
 
_asm popad;
HRESULT hRet = pfnPresentCb( pDevice, pData ); 
return hRet; 
}
//---------------------------------------------------------------------------------------------------------------------------------
HRESULT WINAPI hkReset(LPDIRECT3DDEVICE8 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters)
{
return oReset(pDevice, pPresentationParameters);
}
//-----------------------------------------------------------------------------------------------------------------------------------
LRESULT CALLBACK MsgProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam){return DefWindowProc(hwnd, uMsg, wParam, lParam);}
void DX_Init(DWORD* table)
{
WNDCLASSEX wc = {sizeof(WNDCLASSEX),CS_CLASSDC,MsgProc,0L,0L,GetModuleHandle(NULL),NULL,NULL,NULL,NULL,"DX",NULL};
RegisterClassEx(&wc);
HWND hWnd = CreateWindow("DX",NULL,WS_OVERLAPPEDWINDOW,100,100,300,300,GetDesktopWindow(),NULL,wc.hInstance,NULL);
LPDIRECT3D8 pD3D = Direct3DCreate8( D3D_SDK_VERSION );
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
LPDIRECT3DDEVICE8 pd3dDevice;
pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp,&pd3dDevice);
DWORD* pVTable = (DWORD*)pd3dDevice;
pVTable = (DWORD*)pVTable[0];
table[ES] = pVTable[42]; //EndScene address
table[DIP] = pVTable[82]; //DrawIndexedPrimitive address
table[RES] = pVTable[16]; //Reset address
DestroyWindow(hWnd);
}
//==========================================FindPatt======================================================================//
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;
}
//=======================================================================
void *DetourFunc(BYTE *src, const BYTE *dst, const int len)
{
BYTE *jmp = (BYTE*)malloc(len+5);
DWORD dwBack;
VirtualProtect(src, len, PAGE_READWRITE, &dwBack);
memcpy(jmp, src, len); 
jmp += len;
jmp[0] = 0xE9;
*(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;
src[0] = 0x90; //50
src[1] = 0x90; // 58
src[2] = 0xE9;
*(DWORD*)(&src[3]) = (DWORD)(dst - src) - 7;
for (int i=7; i<len; i++) src[i] = 0x90;
VirtualProtect(src, len, dwBack, &dwBack);
return (jmp-len);
}
//------------------------------------------------------------------------------------------------------------------------------------
DWORD WINAPI VirtualMethodTableRepatchingLoopToCounterExtensionRepatching( LPVOID Param )
{
while(1) {
Sleep(100);
HookVTableFunction((PDWORD*)npDevice, (PBYTE)hkDrawIndexedPrimitive, 82); //Hook DrawIndexedPrimitive
HookVTableFunction((PDWORD*)npDevice, (PBYTE)hkEndScene, 42); //Hook EndScene
HookVTableFunction((PDWORD*)npDevice, (PBYTE)hkReset, 16); //Hook Reset
}
return 1;
}
//------------------------------------------------------------------------------------------------------------------------------------
bool hooked = false;
DWORD WINAPI LoopFunction( LPVOID lpParam )
{
while(1) {
if( hooked == false) {
DWORD VTable[3] = {0};
while(GetModuleHandle("d3d8.dll")==NULL) {
Sleep(250);
}
DX_Init(VTable);
HOOK(EndScene,VTable[ES]); //Hook EndScene as a device discovery hook
while(!npDevice) {
Sleep(50); //Sleep until npDevice is not equal to NULL
}
UNHOOK(EndScene,VTable[ES]); //Unhook as soon as we have a valid pointer to pDevice
*(PDWORD)&oDrawIndexedPrimitive = VTable[DIP];
*(PDWORD)&oEndScene = VTable[ES];
*(PDWORD)&oReset = VTable[RES];
CreateThread(NULL,0,&VirtualMethodTableRepatchingLoopToCounterExtensionRepatching,NULL,0,NULL); //Create hooking thread
hooked = true;
Sleep(200);
}
}
return 0;
}
//------------------------------------------------------------------------------------------------------------------------------------
BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpvReserved)
{
if(dwReason == DLL_PROCESS_ATTACH) {
CreateThread(0, 0, LoopFunction, 0, 0, 0);
 
}
return TRUE;
}
//------------------------------------------------------------------------------------------------------------------------------------



Error executing cl.exe.

TatniumD3D.dll - 1 error(s), 0 warning(s)
bigli is offline

Reply With Quote

Old 08-22-2010, 05:55 PM   #18
A God

Tatez's Avatar

Join Date: Nov 2009
Location: NC
Posts: 195
Reputation: 3189
Rep Power: 62
Tatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating community
Recognitions:
Members who have contributed financial support towards UnKnoWnCheaTs. Donation (1)
Could be because in your code, you have f4 designated as your chams hotkey.
Tatez is offline

Reply With Quote
Reply  

  • Submit Thread to Digg
  • Submit Thread to del.icio.us
  • Submit Thread to StumbleUpon
  • Submit Thread to Google
  • Submit Thread to Facebook
  • Submit Thread to My Yahoo!
  • Submit Thread to MySpace
  • Submit Thread to Twitter
  • Submit Thread to Reddit

« help me | Cod4 Hack »


Tags
d3d9, hook
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT +1. The time now is 04:34 PM.