Join Date: Dec 2009
Posts: 10
|
Hallo liebe Forumuser, Nachdem ich schon Probleme mit der EndScene-Funktion hatte, die ich aber erfolgreich lösen konnte, habe ich wieder ein Problem mit meinen D3D Chams .In SetStreamSource wird irgendwie nichts in m_Stride geschrieben, ich weiß aber nicht warum und ob es wirklich der Grund ist das es nicht funktioniert. Ich hoffe jemand kann mir auf die "Sprünge" helfen
Hier der Code:
TEXT 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; unsigned int m_Stride; bool truecheck=true; bool truecheck2=true; bool draw=true; void InitHook(); void *DetourFunc(BYTE *src, const BYTE *dst, const int len); void DrawRect (LPDIRECT3DDEVICE9 pDevice, int X, int Y, int L, int H, D3DCOLOR color); typedef HRESULT (__stdcall* SetStreamSource_t)(LPDIRECT3DDEVICE9 pDevice,UINT StreamNumber,IDirect3DVertexBuffer9* pStreamData,UINT OffsetInBytes,UINT Stride); SetStreamSource_t pSetStreamSource; typedef HRESULT(__stdcall* EndScene_t)(LPDIRECT3DDEVICE9); EndScene_t pEndScene; typedef HRESULT (__stdcall* DrawIndexedPrimitive_t)(LPDIRECT3DDEVICE9 pDevice,D3DPRIMITIVETYPE Type,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount); DrawIndexedPrimitive_t pDrawIndexedPrimitive; ID3DXFont *pFont; ID3DXFont *pFont2; void DrawFont (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 }; pFont->DrawText( NULL, buffer, -1, &FontRect, DT_NOCLIP , Color ); 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 ); 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; } //Das nicht ferige Menu 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); //Counterstrike Source if(m_Stride==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 pDrawIndexedPrimitive(pDevice, Type,BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); } HRESULT __stdcall hkSetStreamSource(LPDIRECT3DDEVICE9 pDevice,UINT StreamNumber,IDirect3DVertexBuffer9* pStreamData,UINT OffsetInBytes,UINT Stride) { if( StreamNumber == 0 ){m_Stride = Stride;} return pSetStreamSource(pDevice, StreamNumber, pStreamData,OffsetInBytes, Stride); } int WINAPI DllMain(HINSTANCE hInst,DWORD reason,LPVOID reserved) { switch(reason) { case DLL_PROCESS_ATTACH: 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 ); } DWORD dwEndScene; 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]; dwEndScene = (DWORD)VTableStart[42]; dwSetStreamSource =(DWORD)VTableStart[100]; pEndScene = ( EndScene_t )DetourFunc((PBYTE)dwEndScene,(PBYTE)hkEndScene, 5); pDrawIndexedPrimitive = ( DrawIndexedPrimitive_t )DetourFunc((PBYTE)dwDrawIndexedPrimitive, (PBYTE)hkDrawIndexedPrimitive,5); pSetStreamSource = ( SetStreamSource_t )DetourFunc((PBYTE)dwSetStreamSource,(PBYTE)hkSetStreamSource,5); } void DrawRect (LPDIRECT3DDEVICE9 pDevice, int X, int Y, int L, int H, D3DCOLOR color) { D3DRECT rect = {X, Y, X+L, Y+H}; pDevice->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); }
Der Stride stimmt zu 100%, da ich ihn mit einem Stride-Logger selbst geloggt habe.
Danke schonmal im vorraus
Mfg SiZeXtreme
__________________
Wer zuerst malt, malt zuerst.
|