Fixed everything that I've forgot

merge-requests/28/head
Nemirtingas 5 years ago
parent d06fbba104
commit 5d4b4371f3

@ -9,8 +9,7 @@
#include <impls/imgui_impl_win32.h> #include <impls/imgui_impl_win32.h>
#include <impls/imgui_impl_dx10.h> #include <impls/imgui_impl_dx10.h>
// This is created by DX10_Hook::Create, and deleted by the Hook_Manager if not used DX10_Hook* DX10_Hook::_inst = nullptr;
static DX10_Hook* hook;
bool DX10_Hook::start_hook() bool DX10_Hook::start_hook()
{ {
@ -146,20 +145,20 @@ void DX10_Hook::prepareForOverlay(IDXGISwapChain* pSwapChain)
HRESULT STDMETHODCALLTYPE DX10_Hook::MyPresent(IDXGISwapChain *_this, UINT SyncInterval, UINT Flags) HRESULT STDMETHODCALLTYPE DX10_Hook::MyPresent(IDXGISwapChain *_this, UINT SyncInterval, UINT Flags)
{ {
hook->prepareForOverlay(_this); DX10_Hook::Inst()->prepareForOverlay(_this);
return (_this->*hook->Present)(SyncInterval, Flags); return (_this->*DX10_Hook::Inst()->Present)(SyncInterval, Flags);
} }
HRESULT STDMETHODCALLTYPE DX10_Hook::MyResizeTarget(IDXGISwapChain* _this, const DXGI_MODE_DESC* pNewTargetParameters) HRESULT STDMETHODCALLTYPE DX10_Hook::MyResizeTarget(IDXGISwapChain* _this, const DXGI_MODE_DESC* pNewTargetParameters)
{ {
hook->resetRenderState(); DX10_Hook::Inst()->resetRenderState();
return (_this->*hook->ResizeTarget)(pNewTargetParameters); return (_this->*DX10_Hook::Inst()->ResizeTarget)(pNewTargetParameters);
} }
HRESULT STDMETHODCALLTYPE DX10_Hook::MyResizeBuffers(IDXGISwapChain* _this, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags) HRESULT STDMETHODCALLTYPE DX10_Hook::MyResizeBuffers(IDXGISwapChain* _this, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags)
{ {
hook->resetRenderState(); DX10_Hook::Inst()->resetRenderState();
return (_this->*hook->ResizeBuffers)(BufferCount, Width, Height, NewFormat, SwapChainFlags); return (_this->*DX10_Hook::Inst()->ResizeBuffers)(BufferCount, Width, Height, NewFormat, SwapChainFlags);
} }
DX10_Hook::DX10_Hook(): DX10_Hook::DX10_Hook():
@ -189,18 +188,15 @@ DX10_Hook::~DX10_Hook()
if (_hooked) if (_hooked)
resetRenderState(); resetRenderState();
hook = nullptr; _inst = nullptr;
} }
void DX10_Hook::Create() DX10_Hook* DX10_Hook::Inst()
{ {
if (hook == nullptr) if (_inst == nullptr)
{ _inst = new DX10_Hook;
hook = new DX10_Hook;
hook->start_hook(); return _inst;
// Register the hook to the Hook Manager
Hook_Manager::Inst().AddHook(hook);
}
} }
void DX10_Hook::loadFunctions(ID3D10Device *pDevice, IDXGISwapChain *pSwapChain) void DX10_Hook::loadFunctions(ID3D10Device *pDevice, IDXGISwapChain *pSwapChain)

@ -13,6 +13,8 @@ public:
static constexpr const char *DLL_NAME = "d3d10.dll"; static constexpr const char *DLL_NAME = "d3d10.dll";
private: private:
static DX10_Hook* _inst;
// Variables // Variables
bool initialized; bool initialized;
ID3D10Device* pDevice; ID3D10Device* pDevice;

@ -9,8 +9,7 @@
#include <impls/imgui_impl_win32.h> #include <impls/imgui_impl_win32.h>
#include <impls/imgui_impl_dx11.h> #include <impls/imgui_impl_dx11.h>
// This is created by DX11_Hook::Create, and deleted by the Hook_Manager if not used DX11_Hook* DX11_Hook::_inst = nullptr;
static DX11_Hook* hook;
HRESULT GetDeviceAndCtxFromSwapchain(IDXGISwapChain* pSwapChain, ID3D11Device** ppDevice, ID3D11DeviceContext** ppContext) HRESULT GetDeviceAndCtxFromSwapchain(IDXGISwapChain* pSwapChain, ID3D11Device** ppDevice, ID3D11DeviceContext** ppContext)
{ {
@ -163,21 +162,21 @@ void DX11_Hook::prepareForOverlay(IDXGISwapChain* pSwapChain)
HRESULT STDMETHODCALLTYPE DX11_Hook::MyPresent(IDXGISwapChain *_this, UINT SyncInterval, UINT Flags) HRESULT STDMETHODCALLTYPE DX11_Hook::MyPresent(IDXGISwapChain *_this, UINT SyncInterval, UINT Flags)
{ {
hook->prepareForOverlay(_this); DX11_Hook::Inst()->prepareForOverlay(_this);
return (_this->*hook->Present)(SyncInterval, Flags); return (_this->*DX11_Hook::Inst()->Present)(SyncInterval, Flags);
} }
HRESULT STDMETHODCALLTYPE DX11_Hook::MyResizeTarget(IDXGISwapChain* _this, const DXGI_MODE_DESC* pNewTargetParameters) HRESULT STDMETHODCALLTYPE DX11_Hook::MyResizeTarget(IDXGISwapChain* _this, const DXGI_MODE_DESC* pNewTargetParameters)
{ {
hook->resetRenderState(); DX11_Hook::Inst()->resetRenderState();
return (_this->*hook->ResizeTarget)(pNewTargetParameters); return (_this->*DX11_Hook::Inst()->ResizeTarget)(pNewTargetParameters);
} }
HRESULT STDMETHODCALLTYPE DX11_Hook::MyResizeBuffers(IDXGISwapChain* _this, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags) HRESULT STDMETHODCALLTYPE DX11_Hook::MyResizeBuffers(IDXGISwapChain* _this, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags)
{ {
hook->resetRenderState(); DX11_Hook::Inst()->resetRenderState();
return (_this->*hook->ResizeBuffers)(BufferCount, Width, Height, NewFormat, SwapChainFlags); return (_this->*DX11_Hook::Inst()->ResizeBuffers)(BufferCount, Width, Height, NewFormat, SwapChainFlags);
} }
DX11_Hook::DX11_Hook(): DX11_Hook::DX11_Hook():
@ -207,18 +206,15 @@ DX11_Hook::~DX11_Hook()
if (_hooked) if (_hooked)
resetRenderState(); resetRenderState();
hook = nullptr; _inst = nullptr;
} }
void DX11_Hook::Create() DX11_Hook* DX11_Hook::Inst()
{ {
if (hook == nullptr) if (_inst == nullptr)
{ _inst = new DX11_Hook;
hook = new DX11_Hook;
hook->start_hook(); return _inst;
// Register the hook to the Hook Manager
Hook_Manager::Inst().AddHook(hook);
}
} }
void DX11_Hook::loadFunctions(ID3D11Device *pDevice, IDXGISwapChain *pSwapChain) void DX11_Hook::loadFunctions(ID3D11Device *pDevice, IDXGISwapChain *pSwapChain)

@ -13,6 +13,8 @@ public:
static constexpr const char *DLL_NAME = "d3d11.dll"; static constexpr const char *DLL_NAME = "d3d11.dll";
private: private:
static DX11_Hook* _inst;
// Variables // Variables
bool initialized; bool initialized;
ID3D11DeviceContext* pContext; ID3D11DeviceContext* pContext;

@ -9,6 +9,8 @@
#include <impls/imgui_impl_win32.h> #include <impls/imgui_impl_win32.h>
#include <impls/imgui_impl_dx12.h> #include <impls/imgui_impl_dx12.h>
DX12_Hook* DX12_Hook::_inst = nullptr;
bool DX12_Hook::start_hook() bool DX12_Hook::start_hook()
{ {
if (!_hooked) if (!_hooked)
@ -112,21 +114,21 @@ void DX12_Hook::prepareForOverlay(IDXGISwapChain* pSwapChain)
HRESULT STDMETHODCALLTYPE DX12_Hook::MyPresent(IDXGISwapChain *_this, UINT SyncInterval, UINT Flags) HRESULT STDMETHODCALLTYPE DX12_Hook::MyPresent(IDXGISwapChain *_this, UINT SyncInterval, UINT Flags)
{ {
hook->prepareForOverlay(_this); DX12_Hook::Inst()->prepareForOverlay(_this);
return (_this->*hook->Present)(SyncInterval, Flags); return (_this->*DX12_Hook::Inst()->Present)(SyncInterval, Flags);
} }
HRESULT STDMETHODCALLTYPE DX12_Hook::MyResizeTarget(IDXGISwapChain* _this, const DXGI_MODE_DESC* pNewTargetParameters) HRESULT STDMETHODCALLTYPE DX12_Hook::MyResizeTarget(IDXGISwapChain* _this, const DXGI_MODE_DESC* pNewTargetParameters)
{ {
hook->resetRenderState(); DX12_Hook::Inst()->resetRenderState();
return (_this->*hook->ResizeTarget)(pNewTargetParameters); return (_this->*DX12_Hook::Inst()->ResizeTarget)(pNewTargetParameters);
} }
HRESULT STDMETHODCALLTYPE DX12_Hook::MyResizeBuffers(IDXGISwapChain* _this, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags) HRESULT STDMETHODCALLTYPE DX12_Hook::MyResizeBuffers(IDXGISwapChain* _this, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags)
{ {
hook->resetRenderState(); DX12_Hook::Inst()->resetRenderState();
return (_this->*hook->ResizeBuffers)(BufferCount, Width, Height, NewFormat, SwapChainFlags); return (_this->*DX12_Hook::Inst()->ResizeBuffers)(BufferCount, Width, Height, NewFormat, SwapChainFlags);
} }
DX12_Hook::DX12_Hook(): DX12_Hook::DX12_Hook():
@ -157,18 +159,15 @@ DX12_Hook::~DX12_Hook()
if (_hooked) if (_hooked)
resetRenderState(); resetRenderState();
hook = nullptr; _inst = nullptr;
} }
void DX12_Hook::Create() DX12_Hook* DX12_Hook::Inst()
{ {
if (hook == nullptr) if (_inst == nullptr)
{ _inst = new DX12_Hook();
hook = new DX12_Hook;
hook->start_hook(); return _inst;
// Register the hook to the Hook Manager
Hook_Manager::Inst().AddHook(hook);
}
} }
void DX12_Hook::loadFunctions(ID3D12Device *pDevice, IDXGISwapChain *pSwapChain) void DX12_Hook::loadFunctions(ID3D12Device *pDevice, IDXGISwapChain *pSwapChain)

@ -13,6 +13,8 @@ public:
static constexpr const char *DLL_NAME = "d3d12.dll"; static constexpr const char *DLL_NAME = "d3d12.dll";
private: private:
static DX12_Hook* _inst;
// Variables // Variables
bool initialized; bool initialized;
ID3D12CommandAllocator* pCmdAlloc; ID3D12CommandAllocator* pCmdAlloc;

@ -10,13 +10,7 @@
#include "steam_overlay.h" #include "steam_overlay.h"
static DX9_Hook* hook; DX9_Hook* DX9_Hook::_inst = nullptr;
//////////////////////////////////////////////////////////////////
///////// /////////
///////// This hook doesn't support game resize for now /////////
///////// /////////
//////////////////////////////////////////////////////////////////
bool DX9_Hook::start_hook() bool DX9_Hook::start_hook()
{ {
@ -144,29 +138,29 @@ void DX9_Hook::prepareForOverlay(IDirect3DDevice9 *pDevice)
HRESULT STDMETHODCALLTYPE DX9_Hook::MyReset(IDirect3DDevice9* _this, D3DPRESENT_PARAMETERS* pPresentationParameters) HRESULT STDMETHODCALLTYPE DX9_Hook::MyReset(IDirect3DDevice9* _this, D3DPRESENT_PARAMETERS* pPresentationParameters)
{ {
hook->resetRenderState(); DX9_Hook::Inst()->resetRenderState();
return (_this->*hook->Reset)(pPresentationParameters); return (_this->*DX9_Hook::Inst()->Reset)(pPresentationParameters);
} }
HRESULT STDMETHODCALLTYPE DX9_Hook::MyEndScene(IDirect3DDevice9* _this) HRESULT STDMETHODCALLTYPE DX9_Hook::MyEndScene(IDirect3DDevice9* _this)
{ {
if( !hook->uses_present ) if( !DX9_Hook::Inst()->uses_present )
hook->prepareForOverlay(_this); DX9_Hook::Inst()->prepareForOverlay(_this);
return (_this->*hook->EndScene)(); return (_this->*DX9_Hook::Inst()->EndScene)();
} }
HRESULT STDMETHODCALLTYPE DX9_Hook::MyPresent(IDirect3DDevice9* _this, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion) HRESULT STDMETHODCALLTYPE DX9_Hook::MyPresent(IDirect3DDevice9* _this, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion)
{ {
hook->uses_present = true; DX9_Hook::Inst()->uses_present = true;
hook->prepareForOverlay(_this); DX9_Hook::Inst()->prepareForOverlay(_this);
return (_this->*hook->Present)(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion); return (_this->*DX9_Hook::Inst()->Present)(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
} }
HRESULT STDMETHODCALLTYPE DX9_Hook::MyPresentEx(IDirect3DDevice9Ex* _this, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion, DWORD dwFlags) HRESULT STDMETHODCALLTYPE DX9_Hook::MyPresentEx(IDirect3DDevice9Ex* _this, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion, DWORD dwFlags)
{ {
hook->uses_present = true; DX9_Hook::Inst()->uses_present = true;
hook->prepareForOverlay(_this); DX9_Hook::Inst()->prepareForOverlay(_this);
return (_this->*hook->PresentEx)(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags); return (_this->*DX9_Hook::Inst()->PresentEx)(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags);
} }
DX9_Hook::DX9_Hook(): DX9_Hook::DX9_Hook():
@ -204,18 +198,15 @@ DX9_Hook::~DX9_Hook()
ImGui::DestroyContext(); ImGui::DestroyContext();
} }
hook = nullptr; _inst = nullptr;
} }
void DX9_Hook::Create() DX9_Hook* DX9_Hook::Inst()
{ {
if( hook == nullptr ) if( _inst == nullptr )
{ _inst = new DX9_Hook;
hook = new DX9_Hook;
hook->start_hook(); return _inst;
// Register the hook to the Hook Manager
Hook_Manager::Inst().AddHook(hook);
}
} }
void DX9_Hook::loadFunctions(IDirect3DDevice9Ex* pDeviceEx) void DX9_Hook::loadFunctions(IDirect3DDevice9Ex* pDeviceEx)

@ -13,6 +13,8 @@ public:
static constexpr const char *DLL_NAME = "d3d9.dll"; static constexpr const char *DLL_NAME = "d3d9.dll";
private: private:
static DX9_Hook* _inst;
// Variables // Variables
bool initialized; bool initialized;
bool uses_present; bool uses_present;

Loading…
Cancel
Save