Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool HookD3D()
- {
- IDirect3D9* pD3D = Direct3DCreate9(D3D_SDK_VERSION);
- if (!pD3D)
- return false;
- D3DPRESENT_PARAMETERS d3dpp = { 0 };
- d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
- d3dpp.hDeviceWindow = GetForegroundWindow();
- d3dpp.Windowed = TRUE;
- IDirect3DDevice9 * pDummyDevice = nullptr;
- pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3dpp.hDeviceWindow, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pDummyDevice );
- if (!pDevice)
- {
- pD3D->Release();
- return false;
- }
- void ** VTable = *reinterpret_cast<void***>(pDummyDevice);
- DetourFunction(VTable[index], hook);
- pDevice->Release();
- pD3D->Release();
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement