diff --git a/overlay_experimental/Base_Hook.cpp b/overlay_experimental/Base_Hook.cpp index 4c98310..b7913e5 100644 --- a/overlay_experimental/Base_Hook.cpp +++ b/overlay_experimental/Base_Hook.cpp @@ -7,6 +7,10 @@ #include "../detours/detours.h" +Base_Hook::Base_Hook(): + _hooked(false) +{} + Base_Hook::~Base_Hook() { UnhookAll(); diff --git a/overlay_experimental/Base_Hook.h b/overlay_experimental/Base_Hook.h index 47a04cd..6b5443b 100644 --- a/overlay_experimental/Base_Hook.h +++ b/overlay_experimental/Base_Hook.h @@ -26,7 +26,7 @@ protected: Base_Hook& operator =(Base_Hook&&) = delete; public: - Base_Hook() {} + Base_Hook(); virtual ~Base_Hook(); void BeginHook(); diff --git a/overlay_experimental/DX10_Hook.cpp b/overlay_experimental/DX10_Hook.cpp index 103079c..ceb3980 100644 --- a/overlay_experimental/DX10_Hook.cpp +++ b/overlay_experimental/DX10_Hook.cpp @@ -16,7 +16,7 @@ void DX10_Hook::hook_dx10(UINT SDKVersion) { if (!_hooked) { - _hooked = true; + Hook_Manager::Inst().FoundRenderer(this); Hook_Manager::Inst().FoundHook(this); IDXGISwapChain* pSwapChain; @@ -38,6 +38,7 @@ void DX10_Hook::hook_dx10(UINT SDKVersion) if (pDevice != nullptr && pSwapChain != nullptr) { + _hooked = true; PRINT_DEBUG("Hooked DirectX 10\n"); loadFunctions(pDevice, pSwapChain); @@ -53,7 +54,6 @@ void DX10_Hook::hook_dx10(UINT SDKVersion) else { PRINT_DEBUG("Failed to hook DirectX 10\n"); - _hooked = false; } if(pDevice)pDevice->Release(); if(pSwapChain)pSwapChain->Release(); @@ -164,7 +164,7 @@ DX10_Hook::DX10_Hook(): mainRenderTargetView(nullptr) { _dll = GetModuleHandle(DLL_NAME); - _hooked = false; + // Hook to D3D10CreateDevice and D3D10CreateDeviceAndSwapChain so we know when it gets called. // If its called, then DX10 will be used to render the overlay. //_D3D10CreateDevice = (decltype(_D3D10CreateDevice))GetProcAddress(_dll, "D3D10CreateDevice"); diff --git a/overlay_experimental/DX11_Hook.cpp b/overlay_experimental/DX11_Hook.cpp index 1073fbc..f5baa9c 100644 --- a/overlay_experimental/DX11_Hook.cpp +++ b/overlay_experimental/DX11_Hook.cpp @@ -26,7 +26,7 @@ void DX11_Hook::hook_dx11(UINT SDKVersion) { if (!_hooked) { - _hooked = true; + Hook_Manager::Inst().FoundRenderer(this); Hook_Manager::Inst().FoundHook(this); IDXGISwapChain* pSwapChain; @@ -48,6 +48,7 @@ void DX11_Hook::hook_dx11(UINT SDKVersion) if (pDevice != nullptr && pSwapChain != nullptr) { + _hooked = true; PRINT_DEBUG("Hooked DirectX 11\n"); loadFunctions(pDevice, pSwapChain); @@ -63,7 +64,6 @@ void DX11_Hook::hook_dx11(UINT SDKVersion) else { PRINT_DEBUG("Failed to hook DirectX 11\n"); - _hooked = false; } if(pDevice) pDevice->Release(); @@ -182,7 +182,7 @@ DX11_Hook::DX11_Hook(): mainRenderTargetView(nullptr) { _dll = GetModuleHandle(DLL_NAME); - _hooked = false; + // Hook to D3D11CreateDevice and D3D11CreateDeviceAndSwapChain so we know when it gets called. // If its called, then DX11 will be used to render the overlay. //D3D11CreateDevice = (decltype(D3D11CreateDevice))GetProcAddress(_dll, "D3D11CreateDevice"); diff --git a/overlay_experimental/DX12_Hook.cpp b/overlay_experimental/DX12_Hook.cpp index 5e117d3..5bdcbd4 100644 --- a/overlay_experimental/DX12_Hook.cpp +++ b/overlay_experimental/DX12_Hook.cpp @@ -137,7 +137,6 @@ DX12_Hook::DX12_Hook(): pDescriptorHeap(nullptr) { _dll = GetModuleHandle(DLL_NAME); - _hooked = false; PRINT_DEBUG("Trying to hook DX12 but DX12_Hook is not implemented yet, please report to DEV with the game name."); diff --git a/overlay_experimental/DX9_Hook.cpp b/overlay_experimental/DX9_Hook.cpp index 2d8dbf9..c9129a2 100644 --- a/overlay_experimental/DX9_Hook.cpp +++ b/overlay_experimental/DX9_Hook.cpp @@ -22,7 +22,7 @@ void DX9_Hook::hook_dx9(UINT SDKVersion) { if (!_hooked) { - _hooked = true; + Hook_Manager::Inst().FoundRenderer(this); Hook_Manager::Inst().FoundHook(this); IDirect3D9Ex* pD3D; @@ -39,6 +39,7 @@ void DX9_Hook::hook_dx9(UINT SDKVersion) if (pDeviceEx != nullptr) { + _hooked = true; PRINT_DEBUG("Hooked DirectX 9\n"); loadFunctions(pDeviceEx); @@ -55,7 +56,6 @@ void DX9_Hook::hook_dx9(UINT SDKVersion) else { PRINT_DEBUG("Failed to DirectX 9\n"); - _hooked = false; } if(pDeviceEx)pDeviceEx->Release(); @@ -175,7 +175,6 @@ DX9_Hook::DX9_Hook(): Reset(nullptr) { _dll = GetModuleHandle(DLL_NAME); - _hooked = false; // Hook to Direct3DCreate9 and Direct3DCreate9Ex so we know when it gets called. // If its called, then DX9 will be used to render the overlay. Direct3DCreate9 = (decltype(Direct3DCreate9))GetProcAddress(_dll, "Direct3DCreate9"); diff --git a/overlay_experimental/OpenGL_Hook.cpp b/overlay_experimental/OpenGL_Hook.cpp index ff77a35..a199b21 100644 --- a/overlay_experimental/OpenGL_Hook.cpp +++ b/overlay_experimental/OpenGL_Hook.cpp @@ -11,9 +11,7 @@ #include -#pragma comment(lib, "opengl32") -#pragma comment(lib, "glew32s") - +#include "steam_overlay.h" // This is created by OpenGL_Hook::Create, and deleted by the Hook_Manager if not used static OpenGL_Hook* hook; @@ -22,13 +20,14 @@ void OpenGL_Hook::hook_ogl() { if (!_hooked) { - _hooked = true; + Hook_Manager::Inst().FoundRenderer(this); Hook_Manager::Inst().FoundHook(this); GLenum err = glewInit(); if (err == GLEW_OK) { + _hooked = true; PRINT_DEBUG("Hooked OpenGL\n"); UnhookAll(); BeginHook(); @@ -42,7 +41,6 @@ void OpenGL_Hook::hook_ogl() PRINT_DEBUG("Failed to hook OpenGL\n"); /* Problem: glewInit failed, something is seriously wrong. */ PRINT_DEBUG("Error: %s\n", glewGetErrorString(err)); - _hooked = false; } } } @@ -115,7 +113,6 @@ OpenGL_Hook::OpenGL_Hook(): wglSwapBuffers(nullptr) { _dll = GetModuleHandle(DLL_NAME); - _hooked = false; // Hook to wglMakeCurrent so we know when it gets called. // If its called, then OpenGL will be used to render the overlay. wglMakeCurrent = (decltype(wglMakeCurrent))GetProcAddress(_dll, "wglMakeCurrent");