From 622c435cb71821eaeabfc1d0e87afa9ba5f61b7a Mon Sep 17 00:00:00 2001 From: Nemirtingas Date: Tue, 27 Aug 2019 17:40:44 +0200 Subject: [PATCH] Fixed typo in DX12 & reorder hook call. Should call the Present function before hooking DX cause DX also hook Present even if the hook is disabled by Renderer_Detector before initializing the DX hook. --- overlay_experimental/DX12_Hook.cpp | 5 +---- overlay_experimental/Renderer_Detector.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/overlay_experimental/DX12_Hook.cpp b/overlay_experimental/DX12_Hook.cpp index 2b3ae13d..5c8981b4 100644 --- a/overlay_experimental/DX12_Hook.cpp +++ b/overlay_experimental/DX12_Hook.cpp @@ -58,9 +58,6 @@ void DX12_Hook::resetRenderState() void DX12_Hook::prepareForOverlay(IDXGISwapChain* pSwapChain) { pSwapChain->GetDesc(&sc_desc); - - IDXGISwapChain3* pSwapChain3; - pSwapChain->QueryInterface(IID_PPV_ARGS(&pSwapChain3)); if (!initialized) { @@ -204,7 +201,7 @@ void DX12_Hook::loadFunctions(ID3D12CommandQueue* pCommandQueue, ID3D12GraphicsC { void** vTable; - vTable = *reinterpret_cast(pCommandList); + vTable = *reinterpret_cast(pCommandQueue); #define LOAD_FUNC(X) (void*&)X = vTable[(int)ID3D12CommandQueueVTable::X] LOAD_FUNC(ExecuteCommandLists); #undef LOAD_FUNC diff --git a/overlay_experimental/Renderer_Detector.cpp b/overlay_experimental/Renderer_Detector.cpp index a1828994..3de8478c 100644 --- a/overlay_experimental/Renderer_Detector.cpp +++ b/overlay_experimental/Renderer_Detector.cpp @@ -84,6 +84,8 @@ HRESULT STDMETHODCALLTYPE Renderer_Detector::MyIDXGISwapChain_Present(IDXGISwapC { Renderer_Detector& inst = Renderer_Detector::Inst(); Hook_Manager& hm = Hook_Manager::Inst(); + + auto res = (_this->*_IDXGISwapChain_Present)(SyncInterval, Flags); if (!inst.stop_retry()) { IUnknown* pDevice = nullptr; @@ -111,7 +113,7 @@ HRESULT STDMETHODCALLTYPE Renderer_Detector::MyIDXGISwapChain_Present(IDXGISwapC if (pDevice) pDevice->Release(); } - return (_this->*_IDXGISwapChain_Present)(SyncInterval, Flags); + return res; } HRESULT STDMETHODCALLTYPE Renderer_Detector::MyPresent(IDirect3DDevice9* _this, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion) @@ -433,7 +435,7 @@ void Renderer_Detector::hook_dx12() }//if (pDevice != nullptr) }//if (D3D12CreateDevice != nullptr) }//if (library != nullptr) - if (pSwapChain != nullptr && pCommandList != nullptr) + if (pCommandQueue != nullptr && pCommandList != nullptr && pSwapChain != nullptr) { PRINT_DEBUG("Hooked IDXGISwapChain::Present to detect DX Version\n");