Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <iostream>
- #include <d3d11.h>
- #pragma comment(lib, "d3d11.lib")
- bool _stdcall CreateSwapChain() {
- // Gets handle of game
- HWND window = FindWindow(NULL, L"WARFRAME");
- if (window == NULL) return false;
- DXGI_SWAP_CHAIN_DESC swap_desc;
- memset(&swap_desc, 0, sizeof(struct DXGI_SWAP_CHAIN_DESC));
- swap_desc.BufferDesc.Width = NULL; // Output window width
- swap_desc.BufferDesc.Height = NULL; // Output window height
- swap_desc.BufferDesc.Format = DXGI_FORMAT_UNKNOWN; // No idea what the right value is here
- swap_desc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; // No specific scanline method
- swap_desc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED; // Seems to be the best option
- swap_desc.SampleDesc.Count = 1; // Multisampling count (default)
- swap_desc.SampleDesc.Quality = 0; // Multisampling quality (default
- swap_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; // Dont need anything to do with the window
- swap_desc.BufferCount = 1; // Only one (the window)
- swap_desc.OutputWindow = window; // Output window
- swap_desc.Windowed = TRUE; // Game is windowed
- swap_desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; // Discard backbuffer after Present call
- swap_desc.Flags = NULL;
- D3D_FEATURE_LEVEL feature_level[1];
- feature_level[0] = D3D_FEATURE_LEVEL_11_0;
- IDXGISwapChain** swapchain_result = nullptr;
- HRESULT swapchain = D3D11CreateDeviceAndSwapChain(
- NULL, // Adapter. NULL because default adapter
- D3D_DRIVER_TYPE_HARDWARE, // Driver. Hardware because it provides the best performance
- NULL, // Software. NULL because driver is not software
- D3D11_CREATE_DEVICE_DEBUG, // Flags. No Flags because none are needed
- feature_level, // Feature level. Features supported by Direct3D 11.0
- 1, // Number of feature levels
- D3D11_SDK_VERSION, // SDK Version. Default
- &swap_desc, // Swapchain description defined above
- swapchain_result, // Swapchain output
- NULL, // Return feature level
- NULL, // Discard feature level result
- NULL // Discard device context result
- );
- std::cout << "Swapchain result: " << std::hex << swapchain << std::endl;
- std::cout << "Swapchain pointer: " << std::hex << swapchain_result << std::endl;
- return true;
- }
- FILE* pCout;
- BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdReason, LPVOID lpvReserved) {
- if (fwdReason == DLL_PROCESS_ATTACH) {
- AllocConsole();
- freopen_s(&pCout, "CONOUT$", "w", stdout);
- std::cout << "DLL attached" << std::endl;
- // Create swapchain
- std::cout << "Swapchain function result: " << CreateSwapChain() << std::endl;
- }
- else if (fwdReason == DLL_PROCESS_DETACH) {
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement