Advertisement
vovan333

usage

Nov 3rd, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma once
  2. #include "Include.hpp"
  3. #include "VMTHook.hpp"
  4.  
  5. namespace asmjs
  6. {
  7.     class Hooks
  8.     {
  9.         public:
  10.  
  11.         static D3D11PresentFn oPresent;
  12.  
  13.         static void InstallD3D11Present(D3D11PresentFn hook)
  14.         {
  15.             printf("Hooking IDXGISwapChain::Present... \n");
  16.  
  17.             HWND hWnd = Util::GetGameWindow();
  18.             if (!hWnd)
  19.             {
  20.                 printf("Couldn't find game window. \n");
  21.                 return;
  22.             }
  23.             printf("Found game window \n");
  24.  
  25.             IDXGISwapChain* pSwapChain;
  26.             ID3D11DeviceContext *pContext;
  27.             ID3D11Device *pDevice;
  28.  
  29.             D3D_FEATURE_LEVEL featureLevel = D3D_FEATURE_LEVEL_11_0;
  30.             DXGI_SWAP_CHAIN_DESC swapChainDesc;
  31.             ZeroMemory(&swapChainDesc, sizeof(swapChainDesc));
  32.             swapChainDesc.BufferCount = 1;
  33.             swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
  34.             swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
  35.             swapChainDesc.OutputWindow = hWnd;
  36.             swapChainDesc.SampleDesc.Count = 1;
  37.             swapChainDesc.Windowed = TRUE;
  38.             swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
  39.             swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
  40.             swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
  41.  
  42.             printf("Going to call D3D11CreateDeviceAndSwapChain \n");
  43.  
  44.             if (FAILED(D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, NULL, &featureLevel, 1,
  45.                 D3D11_SDK_VERSION, &swapChainDesc, &pSwapChain, &pDevice, NULL, &pContext)))
  46.             {
  47.                 printf("D3D11CreateDeviceAndSwapChain failed \n");
  48.                 return;
  49.             }
  50.             printf("D3D11CreateDeviceAndSwapChain succeeded \n");
  51.             printf("Going to hook now ... \n");
  52.             oPresent = (D3D11PresentFn)VMTHook::Install(pSwapChain, hook, 8);
  53.             printf("Hooked! \n\n");
  54.         }
  55.     };
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement