mirror of
https://gitlab.com/Mr_Goldberg/goldberg_emulator.git
synced 2025-12-05 11:44:53 +01:00
Added class Renderer_Detector.
Hook_Manager now only manages hooks. Renderer_Detector is used to detect the game's renderer. There will be 2 version of it. 1 for windows and 1 for Linux.
This commit is contained in:
parent
ff25f294f0
commit
44d583ee7d
19 changed files with 865 additions and 759 deletions
|
|
@ -6,15 +6,6 @@
|
|||
#ifndef NO_OVERLAY
|
||||
|
||||
#include <set>
|
||||
#include <thread>
|
||||
|
||||
#if defined(_WIN32) || defined(WIN32)
|
||||
#include <Windows.h>
|
||||
|
||||
struct IDXGISwapChain;
|
||||
struct IDirect3DDevice9;
|
||||
struct IDirect3DDevice9Ex;
|
||||
#endif
|
||||
|
||||
/*
|
||||
*
|
||||
|
|
@ -22,9 +13,6 @@ struct IDirect3DDevice9Ex;
|
|||
class Hook_Manager
|
||||
{
|
||||
friend class Base_Hook;
|
||||
public:
|
||||
using overlayProc_t = void(*)(int,int);
|
||||
using hookReady_t = void(*)(void*);
|
||||
|
||||
protected:
|
||||
// TODO: If needed, create a second vector with only the renderers hook
|
||||
|
|
@ -32,75 +20,14 @@ protected:
|
|||
// 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::thread *_hook_thread;
|
||||
unsigned int _hook_retries;
|
||||
bool _renderer_found; // Is the renderer hooked ?
|
||||
bool _ogl_hooked; // wglMakeCurrent is hooked ? (opengl)
|
||||
Base_Hook* rendererdetect_hook;
|
||||
Base_Hook* game_renderer;
|
||||
class Steam_Overlay* overlay;
|
||||
|
||||
Hook_Manager();
|
||||
virtual ~Hook_Manager();
|
||||
|
||||
// Setup opengl device
|
||||
void hook_opengl();
|
||||
|
||||
bool stop_retry();
|
||||
//void HookLoadLibrary();
|
||||
|
||||
#if defined(_WIN32) || defined(WIN32) || defined(_WIN64) || defined(WIN64)
|
||||
bool _loadlibrary_hooked; // Are the LoadLibrary functions hooked ?
|
||||
bool _dx9_hooked; // DX9 Present and PresentEx Hooked ?
|
||||
bool _dxgi_hooked; // DXGI Present is hooked ? (DX10, DX11, DX12)
|
||||
|
||||
// DXGIPresent will be used to detect if DX10, DX11 or DX12 should be used for overlay
|
||||
void HookDXGIPresent(IDXGISwapChain* pSwapChain);
|
||||
// DX9 Present and PresentEx will be used to detect if DX9 should be used for overlay
|
||||
void HookDX9Present(IDirect3DDevice9* pDevice, bool ex);
|
||||
// wglMakeCurrent will be used to detect if OpenGL3 should be used for overlay
|
||||
void HookwglMakeCurrent(BOOL (WINAPI *wglMakeCurrent)(HDC, HGLRC));
|
||||
// Setup DX9 Device and get vtable
|
||||
void hook_dx9();
|
||||
// Setup DX10 Device and get vtable
|
||||
void hook_dx10();
|
||||
// Setup DX11 Device and get vtable
|
||||
void hook_dx11();
|
||||
// Setup DX12 Device and get vtable
|
||||
void hook_dx12();
|
||||
|
||||
void create_hook(const char* libname);
|
||||
//void create_hookW(const wchar_t* libname);
|
||||
|
||||
static void find_renderer(Hook_Manager* _this);
|
||||
|
||||
//static HMODULE WINAPI MyLoadLibraryA(LPCTSTR lpLibFileName);
|
||||
//static HMODULE WINAPI MyLoadLibraryW(LPCWSTR lpLibFileName);
|
||||
//static HMODULE WINAPI MyLoadLibraryExA(LPCTSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
|
||||
//static HMODULE WINAPI MyLoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
|
||||
// If this is called, then DX10, DX11 or DX12 will be used to render overlay
|
||||
static HRESULT STDMETHODCALLTYPE MyIDXGISwapChain_Present(IDXGISwapChain* _this, UINT SyncInterval, UINT Flags);
|
||||
// If any of theses is called, then DX9 will be used to render overlay
|
||||
static HRESULT STDMETHODCALLTYPE MyPresent(IDirect3DDevice9* _this, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion);
|
||||
static HRESULT STDMETHODCALLTYPE MyPresentEx(IDirect3DDevice9Ex* _this, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion, DWORD dwFlags);
|
||||
// If this is called, then OpenGL 3 will be used to render overlay
|
||||
static BOOL WINAPI MywglMakeCurrent(HDC hDC, HGLRC hGLRC);
|
||||
|
||||
#elif defined(__linux__)
|
||||
|
||||
#endif
|
||||
|
||||
public:
|
||||
static Hook_Manager& Inst();
|
||||
|
||||
void HookRenderer();
|
||||
|
||||
// Set the found hook and free all other hooks
|
||||
void FoundRenderer(Base_Hook *hook);
|
||||
|
||||
inline void AddHook(Base_Hook* hook) { _hooks.insert(hook); }
|
||||
|
||||
inline Base_Hook* get_renderer() const { return game_renderer; }
|
||||
void AddHook(Base_Hook* hook);
|
||||
void RemoveHook(Base_Hook* hook);
|
||||
};
|
||||
|
||||
#endif//NO_OVERLAY
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue