Hi Leute,
jetzt hab ich wieder mal ein Problem mit meinem D3D-Hook. Mein Crosshairhack funktioniert auch wunderbar, aber meine Chams gar nicht :( . Leider weiß ich auch nicht an was das es liegen könnte. Den richtigen Stride für Css hab ich auch schon gefunden, mit einem Stride logger vom Internet.
Hier der Source:
Ich hoffe ihr könnt mir helfen.
Mfg Gametester
jetzt hab ich wieder mal ein Problem mit meinem D3D-Hook. Mein Crosshairhack funktioniert auch wunderbar, aber meine Chams gar nicht :( . Leider weiß ich auch nicht an was das es liegen könnte. Den richtigen Stride für Css hab ich auch schon gefunden, mit einem Stride logger vom Internet.
Hier der Source:
Code:
#include <windows.h>
#include <cstdio>
#include <d3d9.h>
#include <d3dx9.h>
#include <iostream>
#pragma comment (lib, "user32.lib")
#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "d3dx9.lib")
//LPDIRECT3DDEVICE9 pDevice;
const D3DCOLOR txtPink = D3DCOLOR_ARGB(255, 0, 0, 255); // Alpha, Rot, Grün, Blau
const D3DCOLOR txtBlue = D3DCOLOR_ARGB(255, 0, 25, 255);
const D3DCOLOR txtBlack = D3DCOLOR_ARGB(255,0,0,0);
const D3DCOLOR txtOrange = D3DCOLOR_ARGB(200,255,128,0);
LPDIRECT3DTEXTURE9 Pink;
LPDIRECT3DTEXTURE9 Red;
LPDIRECT3DTEXTURE9 Green;
void InitHook();
void *DetourFunc(BYTE *src, const BYTE *dst, const int len);
typedef HRESULT(__stdcall* EndScene_t)(LPDIRECT3DDEVICE9);
void DrawRect (LPDIRECT3DDEVICE9 Device_t, int X, int Y, int L, int H, D3DCOLOR color);
EndScene_t pEndScene;
typedef HRESULT (__stdcall* SetStreamSource_t)(LPDIRECT3DDEVICE9 pDevice,UINT StreamNumber,IDirect3DVertexBuffer9* pStreamData,UINT OffsetInBytes,UINT Stride);
typedef HRESULT (__stdcall* DrawIndexedPrimitive_t)(LPDIRECT3DDEVICE9 pDevice,D3DPRIMITIVETYPE Type,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount);
SetStreamSource_t pSetStreamSource;
DrawIndexedPrimitive_t pDrawIndexedPrimitive;
ID3DXFont *pFont;
ID3DXFont *pFont2;
DWORD dwEndScene;
unsigned int myStride=NULL;
bool truecheck=true;
bool truecheck2=true;
bool chams=false;
bool crosshair=false;
bool draw=true;
bool test=true;
void DrawFont (int X, int Y, D3DCOLOR Color, char *format, ...)
{
char buffer[256];
va_list args; // deswegen: #include <cstdio>
va_start (args, format);
vsprintf (buffer,format, args);
RECT FontRect = { X, Y, X + 120, Y + 16 };
pFont->DrawText( NULL, buffer, -1, &FontRect, DT_NOCLIP , Color ); // Zeichnen
va_end (args);
}
void DrawFont2 (int X, int Y, D3DCOLOR Color, char *format, ...)
{
char buffer[256];
va_list args;
va_start (args, format);
vsprintf (buffer,format, args);
RECT FontRect = { X, Y, X + 120, Y + 16 };
pFont2->DrawText( NULL, buffer, -1, &FontRect, DT_NOCLIP , Color ); // Zeichnen
va_end (args);
}
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;
}
HRESULT __stdcall hkEndScene(LPDIRECT3DDEVICE9 pDevice)
{
if(truecheck2){
D3DXCreateFont(pDevice, 29, 0, FW_BOLD, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "IrisUPC", &pFont );
D3DXCreateFont(pDevice, 15, 0, FW_NORMAL, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &pFont2 );
truecheck2=false;
}
if(draw){
DrawRect (pDevice, 10, 10, 205, 75, txtBlue);
DrawRect (pDevice, 15,35,195,2, txtOrange);
DrawFont(15,10,txtBlack,"SiZeXtreme VIP-Hook v0.1a");
DrawFont2(15, 43, txtBlack, "WallHack (Chams)");
DrawFont2(150,43,txtBlack, "False");
DrawFont2(15, 58, txtBlack, "Crosshair-Hack");
DrawFont2(150,58, txtBlack, "Crosshair1");
}
if(GetAsyncKeyState(VK_INSERT)){
draw=!draw;
Sleep(100);
}
return pEndScene(pDevice);
}
HRESULT __stdcall hkDrawIndexedPrimitive(LPDIRECT3DDEVICE9 pDevice,D3DPRIMITIVETYPE Type,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount){
if(truecheck){
GenerateTexture(pDevice, &Green,D3DCOLOR_ARGB (255 , 0 , 255 , 0 ));
GenerateTexture(pDevice, &Red, D3DCOLOR_ARGB (255 , 255 , 0 , 0 ));
truecheck=false;
}
HRESULT hRet = pDrawIndexedPrimitive(pDevice, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
if(myStride==64){
pDevice->SetRenderState(D3DRS_ZENABLE,false);
pDevice->SetRenderState(D3DRS_FILLMODE,D3DFILL_SOLID);
pDevice->SetTexture(0,Green);
pDevice->DrawIndexedPrimitive(Type,BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
pDevice->SetRenderState(D3DRS_ZENABLE,true);
pDevice->SetRenderState(D3DRS_FILLMODE,D3DFILL_SOLID);
pDevice->SetTexture(0,Red);
//pDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); NoFog
}
//return S_OK;
//return pDrawIndexedPrimitive(pDevice, Type,BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
return hRet;
}
HRESULT __stdcall hkSetStreamSource(LPDIRECT3DDEVICE9 pDevice,UINT StreamNumber,IDirect3DVertexBuffer9* pStreamData,UINT OffsetInBytes,UINT Stride){
if(StreamNumber == 0){
myStride = Stride;
}
return pSetStreamSource(pDevice, StreamNumber, pStreamData,OffsetInBytes, Stride);
}
int WINAPI DllMain(HINSTANCE hInst,DWORD reason,LPVOID reserved)
{
switch(reason)
{
case DLL_PROCESS_ATTACH:
// Hier kommt unser Code rein
CreateThread(0, 0, (LPTHREAD_START_ROUTINE) InitHook, 0, 0, 0);
break;
}
return true;
}
bool bDataCompare(const BYTE* pData, const BYTE* bMask, const char* szMask)
{
for(;*szMask;++szMask,++pData,++bMask)
if(*szMask=='x' && *pData!=*bMask )
return false;
return (*szMask) == NULL;
}
DWORD dwFindPattern(DWORD dwAddress,DWORD dwLen,BYTE *bMask,char * szMask)
{
for(DWORD i=0; i < dwLen; i++)
if( bDataCompare( (BYTE*)( dwAddress+i ),bMask,szMask) )
return (DWORD)(dwAddress+i);
return 0;
}
void InitHook()
{ HMODULE hModule = NULL;
while( !hModule )
{
hModule = GetModuleHandleA( "d3d9.dll" ); // Handle zur DLL holen
Sleep( 100 ); // 100ms warten
}
DWORD dwDrawIndexedPrimitive;
DWORD dwSetStreamSource;
DWORD* VTableStart = 0;
DWORD FoundByGordon = dwFindPattern((DWORD)hModule, 0x128000,
(PBYTE)"\xC7\x06\x00\x00\x00\x00\x89\x86\x00\x00\x00\x00\x89\x86", "xx????xx????xx");
memcpy(&VTableStart, (void*)(FoundByGordon+2), 4);
dwDrawIndexedPrimitive = (DWORD)VTableStart[82]; // für mehr: blick in die d3d9.h werfen!
dwEndScene = (DWORD)VTableStart[42];
dwSetStreamSource =(DWORD)VTableStart[100];
pEndScene = ( EndScene_t )DetourFunc((PBYTE)dwEndScene,(PBYTE)hkEndScene, 5); //0x74A447AF|0x43A47AF
pDrawIndexedPrimitive = ( DrawIndexedPrimitive_t )DetourFunc((PBYTE)dwDrawIndexedPrimitive, (PBYTE)hkDrawIndexedPrimitive,5);
pSetStreamSource = ( SetStreamSource_t )DetourFunc((PBYTE)dwSetStreamSource,(PBYTE)hkSetStreamSource,5);
}
void DrawRect (LPDIRECT3DDEVICE9 Device_t, int X, int Y, int L, int H, D3DCOLOR color)
{
D3DRECT rect = {X, Y, X+L, Y+H};
Device_t->Clear(1, &rect, D3DCLEAR_TARGET, color, 0, 0);
}
void *DetourFunc(BYTE *src, const BYTE *dst, const int len) // credits to gamedeception
{
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] = 0xE9;
*(DWORD*)(src+1) = (DWORD)(dst - src) - 5;
VirtualProtect(src, len, dwback, &dwback);
return (jmp-5);
}
Mfg Gametester