Call the true function before initializing hook.

This commit is contained in:
Nemirtingas 2019-08-27 19:56:41 +02:00
parent 3c265596a9
commit 4f7e42a905
2 changed files with 6 additions and 9 deletions

View file

@ -7,17 +7,11 @@
#include <set> #include <set>
/*
*
*/
class Hook_Manager class Hook_Manager
{ {
friend class Base_Hook; friend class Base_Hook;
protected: protected:
// TODO: If needed, create a second vector with only the renderers hook
// Cause actually, a call to FoundRenderer will unhook everything registered except the renderer hook
// If you do that, you should consider moving the renderer hooks to its own class and keep this one generic ?
std::set<Base_Hook*> _hooks; std::set<Base_Hook*> _hooks;
Hook_Manager(); Hook_Manager();

View file

@ -120,33 +120,36 @@ HRESULT STDMETHODCALLTYPE Renderer_Detector::MyPresent(IDirect3DDevice9* _this,
{ {
Renderer_Detector& inst = Renderer_Detector::Inst(); Renderer_Detector& inst = Renderer_Detector::Inst();
Hook_Manager& hm = Hook_Manager::Inst(); Hook_Manager& hm = Hook_Manager::Inst();
auto res = (_this->*_IDirect3DDevice9_Present)(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
if (!inst.stop_retry()) if (!inst.stop_retry())
{ {
DX9_Hook::Inst()->start_hook(); DX9_Hook::Inst()->start_hook();
} }
return (_this->*_IDirect3DDevice9_Present)(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion); return res;
} }
HRESULT STDMETHODCALLTYPE Renderer_Detector::MyPresentEx(IDirect3DDevice9Ex* _this, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion, DWORD dwFlags) HRESULT STDMETHODCALLTYPE Renderer_Detector::MyPresentEx(IDirect3DDevice9Ex* _this, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion, DWORD dwFlags)
{ {
Renderer_Detector& inst = Renderer_Detector::Inst(); Renderer_Detector& inst = Renderer_Detector::Inst();
Hook_Manager& hm = Hook_Manager::Inst(); Hook_Manager& hm = Hook_Manager::Inst();
auto res = (_this->*_IDirect3DDevice9Ex_PresentEx)(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags);
if (!inst.stop_retry()) if (!inst.stop_retry())
{ {
DX9_Hook::Inst()->start_hook(); DX9_Hook::Inst()->start_hook();
} }
return (_this->*_IDirect3DDevice9Ex_PresentEx)(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags); return res;
} }
BOOL WINAPI Renderer_Detector::MywglMakeCurrent(HDC hDC, HGLRC hGLRC) BOOL WINAPI Renderer_Detector::MywglMakeCurrent(HDC hDC, HGLRC hGLRC)
{ {
Renderer_Detector& inst = Renderer_Detector::Inst(); Renderer_Detector& inst = Renderer_Detector::Inst();
Hook_Manager& hm = Hook_Manager::Inst(); Hook_Manager& hm = Hook_Manager::Inst();
auto res = _wglMakeCurrent(hDC, hGLRC);
if (!inst.stop_retry()) if (!inst.stop_retry())
{ {
OpenGL_Hook::Inst()->start_hook(); OpenGL_Hook::Inst()->start_hook();
} }
return _wglMakeCurrent(hDC, hGLRC); return res;
} }
void Renderer_Detector::HookDXGIPresent(IDXGISwapChain* pSwapChain) void Renderer_Detector::HookDXGIPresent(IDXGISwapChain* pSwapChain)