Guest User

WallHack Source

a guest
Jul 31st, 2015
535
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.34 KB | None | 0 0
  1. //Credit : Midz - VHB
  2. //Blog : http://midz-vhb.blogspot.com
  3. //Base : D3D Menu Base.
  4.  
  5. #include <Windows.h>
  6. #include <cstdio>
  7.  
  8. #include "lib\d3d9.h"
  9. #include "lib\d3dx9.h"
  10. #pragma comment(lib,"lib\\d3d9.lib")
  11. #pragma comment(lib,"lib\\d3dx9.lib")
  12.  
  13. #include "lib\detours.h"
  14. #pragma comment(lib,"detours.lib")
  15.  
  16.  
  17. typedef HRESULT(WINAPI* tDIP)(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE Type, INT BaseVertexIndex, UINT MinIndex, UINT NumVertices, UINT StartIndex, UINT PrimitiveCount); // Define Type of data : DrawIndexPrimitive
  18. tDIP oDIP; //Declare oDIP
  19.  
  20. HRESULT WINAPI nDIP(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE Type, INT BaseVertexIndex, UINT MinIndex, UINT NumVertices, UINT StartIndex, UINT PrimitiveCount) //Hook Function
  21. {
  22.    
  23.     LPDIRECT3DVERTEXBUFFER9 Data_Stream; // Declare Data Stream with LPDIRECT3D
  24.     UINT Offset = 0;
  25.     UINT Stride = 0;
  26.  
  27.     if (pDevice->GetStreamSource(0, &Data_Stream, &Offset, &Stride)) Data_Stream->Release(); //GetStream put into DataStream, Offset, Stride and Release Data_Stream
  28.     // Note if you're not release data, memory will be larger.
  29.     if (Stride == 20) pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
  30.  
  31.     return oDIP(pDevice, Type, BaseVertexIndex, MinIndex, NumVertices, StartIndex, PrimitiveCount);
  32.  
  33. }
  34. boolean bCompare(const BYTE* pData, const BYTE* bMask, const char* szMask)
  35. {
  36.     for (; *szMask; ++szMask, ++pData, ++bMask)
  37.         if (*szMask == 'x' && *pData != *bMask )   return 0;
  38.     return (*szMask) == NULL;
  39. }
  40. DWORD FindPattern(DWORD dwAddress, DWORD dwLen, BYTE *bMask, char * szMask)
  41. {
  42.     for (DWORD i = 0; i<dwLen; i++)
  43.         if (bCompare((BYTE*)(dwAddress + i), bMask, szMask ))  return (DWORD)(dwAddress + i);
  44.     return 0;
  45. }
  46. void D3D_Hook(void)
  47. {
  48.     DWORD DIP = 82;
  49.     DWORD *vTable = NULL;
  50.     DWORD hD3D = 0;
  51.     do
  52.     {
  53.         hD3D = (DWORD)GetModuleHandleA("d3d9.dll");
  54.         Sleep(10);
  55.     } while (!hD3D);
  56.     DWORD adr = FindPattern(hD3D, 0x128000, (PBYTE)"\xC7\x06\x00\x00\x00\x00\x89\x86\x00\x00\x00\x00\x89\x86", "xx????xx????xx");
  57.     if (adr)
  58.         memcpy(&vTable, (void *)(adr + 2), 4);
  59.     oDIP = (tDIP)DetourFunction((PBYTE)vTable[DIP], (PBYTE)nDIP); //Hook DIP
  60.  
  61. }
  62.  
  63. BOOL APIENTRY DllMain(HMODULE hDll, DWORD  dwReason,    LPVOID lpReserved   )
  64. {
  65.     DisableThreadLibraryCalls(hDll);
  66.     if (dwReason == DLL_PROCESS_ATTACH)
  67.         CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)D3D_Hook, NULL, NULL, NULL);
  68.  
  69.     return TRUE;
  70. }
Add Comment
Please, Sign In to add comment