Reworked how renderers are hooked.

Some games doesn't initialise Steam before initalizing their Renderer (even if the doc says to) . So instead of waiting for the game to initialize it, hook to the rendering functions and deduce which implementation should be used.
This commit is contained in:
Nemirtingas 2019-08-16 10:36:44 +02:00
parent 4d3c355fcc
commit 40615d07a7
12 changed files with 497 additions and 190 deletions

View file

@ -96,19 +96,19 @@ void DX12_Hook::prepareForOverlay(IDXGISwapChain* pSwapChain)
/////////////////////////////////////////////////////////////////////////////////////
// DirectX 12 Initialization functions
HRESULT WINAPI DX12_Hook::MyD3D12CreateDevice(
_In_opt_ IUnknown* pAdapter,
D3D_FEATURE_LEVEL MinimumFeatureLevel,
_In_ REFIID riid, // Expected: ID3D12Device
_COM_Outptr_opt_ void** ppDevice)
{
auto res = hook->D3D12CreateDevice(pAdapter, MinimumFeatureLevel, riid, ppDevice);
if (SUCCEEDED(res))
hook->hook_dx12(MinimumFeatureLevel);
return res;
}
//HRESULT WINAPI DX12_Hook::MyD3D12CreateDevice(
// _In_opt_ IUnknown* pAdapter,
// D3D_FEATURE_LEVEL MinimumFeatureLevel,
// _In_ REFIID riid, // Expected: ID3D12Device
// _COM_Outptr_opt_ void** ppDevice)
//{
// auto res = hook->D3D12CreateDevice(pAdapter, MinimumFeatureLevel, riid, ppDevice);
//
// if (SUCCEEDED(res))
// hook->hook_dx12(MinimumFeatureLevel);
//
// return res;
//}
/////////////////////////////////////////////////////////////////////////////////////
HRESULT STDMETHODCALLTYPE DX12_Hook::MyPresent(IDXGISwapChain *_this, UINT SyncInterval, UINT Flags)
@ -166,6 +166,7 @@ void DX12_Hook::Create()
if (hook == nullptr)
{
hook = new DX12_Hook;
hook->start_hook();
// Register the hook to the Hook Manager
Hook_Manager::Inst().AddHook(hook);
}