Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.71 KB | None | 0 0
  1. #include <Windows.h>
  2. #include <iostream>
  3.  
  4. #include <d3d11.h>
  5. #pragma comment(lib, "d3d11.lib")
  6.  
  7.  
  8. bool _stdcall CreateSwapChain() {
  9.  
  10.     // Gets handle of game
  11.     HWND window = FindWindow(NULL, L"WARFRAME");
  12.     if (window == NULL) return false;
  13.  
  14.     DXGI_SWAP_CHAIN_DESC swap_desc;
  15.     memset(&swap_desc, 0, sizeof(struct DXGI_SWAP_CHAIN_DESC));
  16.     swap_desc.BufferDesc.Width = NULL;  // Output window width
  17.     swap_desc.BufferDesc.Height = NULL; // Output window height
  18.     swap_desc.BufferDesc.Format = DXGI_FORMAT_UNKNOWN;  // No idea what the right value is here
  19.     swap_desc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;   // No specific scanline method
  20.     swap_desc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;   // Seems to be the best option
  21.     swap_desc.SampleDesc.Count = 1;     // Multisampling count (default)
  22.     swap_desc.SampleDesc.Quality = 0;   // Multisampling quality (default
  23.     swap_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;    // Dont need anything to do with the window
  24.     swap_desc.BufferCount = 1;                      // Only one (the window)
  25.     swap_desc.OutputWindow = window;    // Output window
  26.     swap_desc.Windowed = TRUE;          // Game is windowed
  27.     swap_desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;    // Discard backbuffer after Present call
  28.     swap_desc.Flags = NULL;
  29.  
  30.     D3D_FEATURE_LEVEL feature_level[1];
  31.     feature_level[0] = D3D_FEATURE_LEVEL_11_0;
  32.  
  33.     IDXGISwapChain** swapchain_result = nullptr;
  34.  
  35.     HRESULT swapchain = D3D11CreateDeviceAndSwapChain(
  36.         NULL,                       // Adapter. NULL because default adapter
  37.         D3D_DRIVER_TYPE_HARDWARE,   // Driver. Hardware because it provides the best performance
  38.         NULL,                       // Software. NULL because driver is not software
  39.         D3D11_CREATE_DEVICE_DEBUG,  // Flags. No Flags because none are needed
  40.         feature_level,              // Feature level. Features supported by Direct3D 11.0
  41.         1,                          // Number of feature levels
  42.         D3D11_SDK_VERSION,          // SDK Version. Default
  43.         &swap_desc,                 // Swapchain description defined above
  44.         swapchain_result,           // Swapchain output
  45.         NULL,                       // Return feature level
  46.         NULL,                       // Discard feature level result
  47.         NULL                        // Discard device context result
  48.     );
  49.  
  50.     std::cout << "Swapchain result: " << std::hex << swapchain << std::endl;
  51.     std::cout << "Swapchain pointer: " << std::hex << swapchain_result << std::endl;
  52.  
  53.     return true;
  54. }
  55.  
  56.  
  57. FILE* pCout;
  58.  
  59. BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdReason, LPVOID lpvReserved) {
  60.  
  61.     if (fwdReason == DLL_PROCESS_ATTACH) {
  62.         AllocConsole();
  63.         freopen_s(&pCout, "CONOUT$", "w", stdout);
  64.         std::cout << "DLL attached" << std::endl;
  65.  
  66.         // Create swapchain
  67.         std::cout << "Swapchain function result: " << CreateSwapChain() << std::endl;
  68.     }
  69.  
  70.     else if (fwdReason == DLL_PROCESS_DETACH) {
  71.  
  72.     }
  73.  
  74.     return true;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement