Advertisement
Broihon

Untitled

Jan 3rd, 2016
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bool HookD3D()
  2. {
  3.     IDirect3D9* pD3D = Direct3DCreate9(D3D_SDK_VERSION);
  4.     if (!pD3D)
  5.         return false;
  6.  
  7.     D3DPRESENT_PARAMETERS d3dpp = { 0 };
  8.     d3dpp.SwapEffect    = D3DSWAPEFFECT_DISCARD;
  9.     d3dpp.hDeviceWindow = GetForegroundWindow();
  10.     d3dpp.Windowed      = TRUE;
  11.  
  12.     IDirect3DDevice9 * pDummyDevice = nullptr;
  13.     pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3dpp.hDeviceWindow, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pDummyDevice );
  14.     if (!pDevice)
  15.     {
  16.         pD3D->Release();
  17.         return false;
  18.     }
  19.  
  20.     void ** VTable = *reinterpret_cast<void***>(pDummyDevice);
  21.  
  22.     DetourFunction(VTable[index], hook);
  23.  
  24.     pDevice->Release();
  25.     pD3D->Release();
  26.    
  27.     return true;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement