Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "Include.hpp"
- #include "VMTHook.hpp"
- namespace asmjs
- {
- class Hooks
- {
- public:
- static D3D11PresentFn oPresent;
- static void InstallD3D11Present(D3D11PresentFn hook)
- {
- printf("Hooking IDXGISwapChain::Present... \n");
- HWND hWnd = Util::GetGameWindow();
- if (!hWnd)
- {
- printf("Couldn't find game window. \n");
- return;
- }
- printf("Found game window \n");
- IDXGISwapChain* pSwapChain;
- ID3D11DeviceContext *pContext;
- ID3D11Device *pDevice;
- D3D_FEATURE_LEVEL featureLevel = D3D_FEATURE_LEVEL_11_0;
- DXGI_SWAP_CHAIN_DESC swapChainDesc;
- ZeroMemory(&swapChainDesc, sizeof(swapChainDesc));
- swapChainDesc.BufferCount = 1;
- swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
- swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
- swapChainDesc.OutputWindow = hWnd;
- swapChainDesc.SampleDesc.Count = 1;
- swapChainDesc.Windowed = TRUE;
- swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
- swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
- swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
- printf("Going to call D3D11CreateDeviceAndSwapChain \n");
- if (FAILED(D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, NULL, &featureLevel, 1,
- D3D11_SDK_VERSION, &swapChainDesc, &pSwapChain, &pDevice, NULL, &pContext)))
- {
- printf("D3D11CreateDeviceAndSwapChain failed \n");
- return;
- }
- printf("D3D11CreateDeviceAndSwapChain succeeded \n");
- printf("Going to hook now ... \n");
- oPresent = (D3D11PresentFn)VMTHook::Install(pSwapChain, hook, 8);
- printf("Hooked! \n\n");
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement