mirror of
https://gitlab.com/Mr_Goldberg/goldberg_emulator.git
synced 2024-11-23 20:38:07 +01:00
Added preprocessor exclusion for linux
This commit is contained in:
parent
f9ee123a05
commit
56b4e6a7c7
14 changed files with 127 additions and 22 deletions
|
@ -1,6 +1,10 @@
|
||||||
#ifndef __INCLUDED_BASE_HOOK_H__
|
#ifndef __INCLUDED_BASE_HOOK_H__
|
||||||
#define __INCLUDED_BASE_HOOK_H__
|
#define __INCLUDED_BASE_HOOK_H__
|
||||||
|
|
||||||
|
#include "../dll/base.h"
|
||||||
|
|
||||||
|
#ifdef STEAM_WIN32
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#define VC_EXTRALEAN
|
#define VC_EXTRALEAN
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
@ -45,4 +49,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif//__INCLUDED_BASE_HOOK_H__
|
#endif//__INCLUDED_BASE_HOOK_H__
|
|
@ -1,4 +1,7 @@
|
||||||
#include "../dll/base.h"
|
#include "../dll/base.h"
|
||||||
|
|
||||||
|
#ifdef STEAM_WIN32
|
||||||
|
|
||||||
#include "DX10_Hook.h"
|
#include "DX10_Hook.h"
|
||||||
#include "Hook_Manager.h"
|
#include "Hook_Manager.h"
|
||||||
|
|
||||||
|
@ -71,6 +74,7 @@ void DX10_Hook::resetRenderState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try to make this function and overlay's proc as short as possible or it might affect game's fps.
|
||||||
void DX10_Hook::prepareForOverlay(IDXGISwapChain* pSwapChain)
|
void DX10_Hook::prepareForOverlay(IDXGISwapChain* pSwapChain)
|
||||||
{
|
{
|
||||||
DXGI_SWAP_CHAIN_DESC desc;
|
DXGI_SWAP_CHAIN_DESC desc;
|
||||||
|
@ -209,3 +213,5 @@ void DX10_Hook::loadFunctions(ID3D10Device *pDevice, IDXGISwapChain *pSwapChain)
|
||||||
LOAD_FUNC(ResizeTarget);
|
LOAD_FUNC(ResizeTarget);
|
||||||
#undef LOAD_FUNC
|
#undef LOAD_FUNC
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,9 +1,11 @@
|
||||||
#ifndef __INCLUDED_DX10_HOOK_H__
|
#ifndef __INCLUDED_DX10_HOOK_H__
|
||||||
#define __INCLUDED_DX10_HOOK_H__
|
#define __INCLUDED_DX10_HOOK_H__
|
||||||
|
|
||||||
|
#include "Base_Hook.h"
|
||||||
|
#ifdef STEAM_WIN32
|
||||||
|
|
||||||
#include <d3d10.h>
|
#include <d3d10.h>
|
||||||
#include "DirectX_VTables.h"
|
#include "DirectX_VTables.h"
|
||||||
#include "Base_Hook.h"
|
|
||||||
|
|
||||||
class DX10_Hook : public Base_Hook
|
class DX10_Hook : public Base_Hook
|
||||||
{
|
{
|
||||||
|
@ -46,4 +48,6 @@ public:
|
||||||
void loadFunctions(ID3D10Device *pDevice, IDXGISwapChain *pSwapChain);
|
void loadFunctions(ID3D10Device *pDevice, IDXGISwapChain *pSwapChain);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif//STEAM_WIN32
|
||||||
|
|
||||||
#endif//__INCLUDED_DX10_HOOK_H__
|
#endif//__INCLUDED_DX10_HOOK_H__
|
|
@ -1,4 +1,7 @@
|
||||||
#include "../dll/base.h"
|
#include "../dll/base.h"
|
||||||
|
|
||||||
|
#ifdef STEAM_WIN32
|
||||||
|
|
||||||
#include "DX11_Hook.h"
|
#include "DX11_Hook.h"
|
||||||
#include "Hook_Manager.h"
|
#include "Hook_Manager.h"
|
||||||
|
|
||||||
|
@ -83,6 +86,7 @@ void DX11_Hook::resetRenderState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try to make this function and overlay's proc as short as possible or it might affect game's fps.
|
||||||
void DX11_Hook::prepareForOverlay(IDXGISwapChain* pSwapChain)
|
void DX11_Hook::prepareForOverlay(IDXGISwapChain* pSwapChain)
|
||||||
{
|
{
|
||||||
DXGI_SWAP_CHAIN_DESC desc;
|
DXGI_SWAP_CHAIN_DESC desc;
|
||||||
|
@ -228,3 +232,5 @@ void DX11_Hook::loadFunctions(ID3D11Device *pDevice, IDXGISwapChain *pSwapChain)
|
||||||
LOAD_FUNC(ResizeTarget);
|
LOAD_FUNC(ResizeTarget);
|
||||||
#undef LOAD_FUNC
|
#undef LOAD_FUNC
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,9 +1,11 @@
|
||||||
#ifndef __INCLUDED_DX11_HOOK_H__
|
#ifndef __INCLUDED_DX11_HOOK_H__
|
||||||
#define __INCLUDED_DX11_HOOK_H__
|
#define __INCLUDED_DX11_HOOK_H__
|
||||||
|
|
||||||
|
#include "Base_Hook.h"
|
||||||
|
#ifdef STEAM_WIN32
|
||||||
|
|
||||||
#include <d3d11.h>
|
#include <d3d11.h>
|
||||||
#include "DirectX_VTables.h"
|
#include "DirectX_VTables.h"
|
||||||
#include "Base_Hook.h"
|
|
||||||
|
|
||||||
class DX11_Hook : public Base_Hook
|
class DX11_Hook : public Base_Hook
|
||||||
{
|
{
|
||||||
|
@ -46,4 +48,6 @@ public:
|
||||||
void loadFunctions(ID3D11Device *pDevice, IDXGISwapChain *pSwapChain);
|
void loadFunctions(ID3D11Device *pDevice, IDXGISwapChain *pSwapChain);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif//STEAM_WIN32
|
||||||
|
|
||||||
#endif//__INCLUDED_DX11_HOOK_H__
|
#endif//__INCLUDED_DX11_HOOK_H__
|
|
@ -1,4 +1,7 @@
|
||||||
#include "../dll/base.h"
|
#include "../dll/base.h"
|
||||||
|
|
||||||
|
#ifdef STEAM_WIN32
|
||||||
|
|
||||||
#include "DX12_Hook.h"
|
#include "DX12_Hook.h"
|
||||||
#include "Hook_Manager.h"
|
#include "Hook_Manager.h"
|
||||||
|
|
||||||
|
@ -33,6 +36,7 @@ void DX12_Hook::resetRenderState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try to make this function and overlay's proc as short as possible or it might affect game's fps.
|
||||||
void DX12_Hook::prepareForOverlay(IDXGISwapChain* pSwapChain)
|
void DX12_Hook::prepareForOverlay(IDXGISwapChain* pSwapChain)
|
||||||
{
|
{
|
||||||
DXGI_SWAP_CHAIN_DESC desc;
|
DXGI_SWAP_CHAIN_DESC desc;
|
||||||
|
@ -134,21 +138,23 @@ DX12_Hook::DX12_Hook():
|
||||||
{
|
{
|
||||||
_dll = GetModuleHandle(DLL_NAME);
|
_dll = GetModuleHandle(DLL_NAME);
|
||||||
_hooked = false;
|
_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.
|
|
||||||
D3D12CreateDevice = (decltype(D3D12CreateDevice))GetProcAddress(_dll, "D3D12CreateDevice");
|
|
||||||
|
|
||||||
BeginHook();
|
PRINT_DEBUG("Trying to hook DX12 but DX12_Hook is not implemented yet, please report to DEV with the game name.");
|
||||||
HookFuncs(
|
|
||||||
std::make_pair<void**, void*>(&(PVOID&)D3D12CreateDevice, &DX12_Hook::MyD3D12CreateDevice)
|
|
||||||
);
|
|
||||||
EndHook();
|
|
||||||
|
|
||||||
|
// Hook to D3D12CreateDevice and D3D12CreateDeviceAndSwapChain so we know when it gets called.
|
||||||
|
// If its called, then DX12 will be used to render the overlay.
|
||||||
|
//D3D12CreateDevice = (decltype(D3D12CreateDevice))GetProcAddress(_dll, "D3D12CreateDevice");
|
||||||
|
//
|
||||||
|
//BeginHook();
|
||||||
|
//HookFuncs(
|
||||||
|
// std::make_pair<void**, void*>(&(PVOID&)D3D12CreateDevice, &DX12_Hook::MyD3D12CreateDevice)
|
||||||
|
//);
|
||||||
|
//EndHook();
|
||||||
}
|
}
|
||||||
|
|
||||||
DX12_Hook::~DX12_Hook()
|
DX12_Hook::~DX12_Hook()
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("DX11 Hook removed\n");
|
PRINT_DEBUG("DX12 Hook removed\n");
|
||||||
|
|
||||||
if (_hooked)
|
if (_hooked)
|
||||||
resetRenderState();
|
resetRenderState();
|
||||||
|
@ -182,3 +188,5 @@ void DX12_Hook::loadFunctions(ID3D12Device *pDevice, IDXGISwapChain *pSwapChain)
|
||||||
LOAD_FUNC(ResizeTarget);
|
LOAD_FUNC(ResizeTarget);
|
||||||
#undef LOAD_FUNC
|
#undef LOAD_FUNC
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,9 +1,11 @@
|
||||||
#ifndef __INCLUDED_DX12_HOOK_H__
|
#ifndef __INCLUDED_DX12_HOOK_H__
|
||||||
#define __INCLUDED_DX12_HOOK_H__
|
#define __INCLUDED_DX12_HOOK_H__
|
||||||
|
|
||||||
|
#include "Base_Hook.h"
|
||||||
|
#ifdef STEAM_WIN32
|
||||||
|
|
||||||
#include <d3d12.h>
|
#include <d3d12.h>
|
||||||
#include "DirectX_VTables.h"
|
#include "DirectX_VTables.h"
|
||||||
#include "Base_Hook.h"
|
|
||||||
|
|
||||||
class DX12_Hook : public Base_Hook
|
class DX12_Hook : public Base_Hook
|
||||||
{
|
{
|
||||||
|
@ -46,4 +48,5 @@ public:
|
||||||
void loadFunctions(ID3D12Device *pDevice, IDXGISwapChain *pSwapChain);
|
void loadFunctions(ID3D12Device *pDevice, IDXGISwapChain *pSwapChain);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif//STEAM_WIN32
|
||||||
#endif//__INCLUDED_DX12_HOOK_H__
|
#endif//__INCLUDED_DX12_HOOK_H__
|
|
@ -1,5 +1,7 @@
|
||||||
#include "../dll/base.h"
|
|
||||||
#include "DX9_Hook.h"
|
#include "DX9_Hook.h"
|
||||||
|
|
||||||
|
#ifdef STEAM_WIN32
|
||||||
|
|
||||||
#include "Hook_Manager.h"
|
#include "Hook_Manager.h"
|
||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
@ -72,6 +74,7 @@ void DX9_Hook::resetRenderState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try to make this function and overlay's proc as short as possible or it might affect game's fps.
|
||||||
void DX9_Hook::prepareForOverlay(IDirect3DDevice9 *pDevice)
|
void DX9_Hook::prepareForOverlay(IDirect3DDevice9 *pDevice)
|
||||||
{
|
{
|
||||||
IDirect3DSwapChain9* pSwapChain;
|
IDirect3DSwapChain9* pSwapChain;
|
||||||
|
@ -83,6 +86,7 @@ void DX9_Hook::prepareForOverlay(IDirect3DDevice9 *pDevice)
|
||||||
D3DDEVICE_CREATION_PARAMETERS param;
|
D3DDEVICE_CREATION_PARAMETERS param;
|
||||||
pDevice->GetCreationParameters(¶m);
|
pDevice->GetCreationParameters(¶m);
|
||||||
|
|
||||||
|
// Workaround to detect if we changed window.
|
||||||
if (param.hFocusWindow != Hook_Manager::Inst().GetOverlay()->GetGameHwnd())
|
if (param.hFocusWindow != Hook_Manager::Inst().GetOverlay()->GetGameHwnd())
|
||||||
resetRenderState();
|
resetRenderState();
|
||||||
|
|
||||||
|
@ -222,3 +226,5 @@ void DX9_Hook::loadFunctions(IDirect3DDevice9Ex* pDeviceEx)
|
||||||
LOAD_FUNC(PresentEx);
|
LOAD_FUNC(PresentEx);
|
||||||
#undef LOAD_FUNC
|
#undef LOAD_FUNC
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,9 +1,11 @@
|
||||||
#ifndef __INCLUDED_DX9_HOOK_H__
|
#ifndef __INCLUDED_DX9_HOOK_H__
|
||||||
#define __INCLUDED_DX9_HOOK_H__
|
#define __INCLUDED_DX9_HOOK_H__
|
||||||
|
|
||||||
|
#include "Base_Hook.h"
|
||||||
|
#ifdef STEAM_WIN32
|
||||||
|
|
||||||
#include <d3d9.h>
|
#include <d3d9.h>
|
||||||
#include "DirectX_VTables.h"
|
#include "DirectX_VTables.h"
|
||||||
#include "Base_Hook.h"
|
|
||||||
|
|
||||||
class DX9_Hook : public Base_Hook
|
class DX9_Hook : public Base_Hook
|
||||||
{
|
{
|
||||||
|
@ -47,4 +49,6 @@ public:
|
||||||
void loadFunctions(IDirect3DDevice9Ex *pDeviceEx);
|
void loadFunctions(IDirect3DDevice9Ex *pDeviceEx);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif//STEAM_WIN32
|
||||||
|
|
||||||
#endif//__INCLUDED_DX9_HOOK_H__
|
#endif//__INCLUDED_DX9_HOOK_H__
|
|
@ -1,9 +1,12 @@
|
||||||
#ifndef __INCLUDED_HOOK_BASE_H__
|
#ifndef __INCLUDED_HOOK_BASE_H__
|
||||||
#define __INCLUDED_HOOK_BASE_H__
|
#define __INCLUDED_HOOK_BASE_H__
|
||||||
|
|
||||||
|
#include "Base_Hook.h"
|
||||||
|
|
||||||
|
#ifdef STEAM_WIN32
|
||||||
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "Base_Hook.h"
|
|
||||||
|
|
||||||
class Hook_Manager
|
class Hook_Manager
|
||||||
{
|
{
|
||||||
|
@ -42,5 +45,6 @@ public:
|
||||||
Steam_Overlay* GetOverlay() const { return overlay; }
|
Steam_Overlay* GetOverlay() const { return overlay; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif//STEAM_WIN32
|
||||||
|
|
||||||
#endif//__INCLUDED_HOOK_BASE_H__
|
#endif//__INCLUDED_HOOK_BASE_H__
|
|
@ -1,4 +1,7 @@
|
||||||
#include "../dll/base.h"
|
#include "../dll/base.h"
|
||||||
|
|
||||||
|
#ifdef STEAM_WIN32
|
||||||
|
|
||||||
#include "OpenGL_Hook.h"
|
#include "OpenGL_Hook.h"
|
||||||
#include "Hook_Manager.h"
|
#include "Hook_Manager.h"
|
||||||
|
|
||||||
|
@ -56,6 +59,7 @@ void OpenGL_Hook::resetRenderState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try to make this function and overlay's proc as short as possible or it might affect game's fps.
|
||||||
void OpenGL_Hook::prepareForOverlay(HDC hDC)
|
void OpenGL_Hook::prepareForOverlay(HDC hDC)
|
||||||
{
|
{
|
||||||
HWND hWnd = WindowFromDC(hDC);
|
HWND hWnd = WindowFromDC(hDC);
|
||||||
|
@ -147,3 +151,5 @@ void OpenGL_Hook::Create()
|
||||||
Hook_Manager::Inst().AddHook(hook);
|
Hook_Manager::Inst().AddHook(hook);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef __INCLUDED_OPENGL_HOOK_H__
|
#ifndef __INCLUDED_OPENGL_HOOK_H__
|
||||||
#define __INCLUDED_OPENGL_HOOK_H__
|
#define __INCLUDED_OPENGL_HOOK_H__
|
||||||
|
|
||||||
#include "DirectX_VTables.h"
|
|
||||||
#include "Base_Hook.h"
|
#include "Base_Hook.h"
|
||||||
|
#ifdef STEAM_WIN32
|
||||||
|
|
||||||
class OpenGL_Hook : public Base_Hook
|
class OpenGL_Hook : public Base_Hook
|
||||||
{
|
{
|
||||||
|
@ -38,4 +38,5 @@ public:
|
||||||
static void Create(); // Initialize OGL Hook.
|
static void Create(); // Initialize OGL Hook.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif//STEAM_WIN32
|
||||||
#endif//__INCLUDED_OPENGL_HOOK_H__
|
#endif//__INCLUDED_OPENGL_HOOK_H__
|
|
@ -1,5 +1,7 @@
|
||||||
#include "steam_overlay.h"
|
#include "steam_overlay.h"
|
||||||
|
|
||||||
|
#ifdef STEAM_WIN32
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -586,3 +588,11 @@ void Steam_Overlay::RunCallbacks()
|
||||||
has_friend_action.pop();
|
has_friend_action.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* TODO:
|
||||||
|
* Add here the code for Linux overlay
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif
|
|
@ -39,6 +39,8 @@ struct Friend_Less
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef STEAM_WIN32
|
||||||
|
|
||||||
class Steam_Overlay
|
class Steam_Overlay
|
||||||
{
|
{
|
||||||
Settings* settings;
|
Settings* settings;
|
||||||
|
@ -117,4 +119,39 @@ public:
|
||||||
void FriendDisconnect(Friend _friend);
|
void FriendDisconnect(Friend _friend);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
class Steam_Overlay
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Steam_Overlay(Settings* settings, SteamCallResults* callback_results, SteamCallBacks* callbacks, RunEveryRunCB* run_every_runcb, Networking *network);
|
||||||
|
~Steam_Overlay();
|
||||||
|
|
||||||
|
bool Ready() const { return false: }
|
||||||
|
|
||||||
|
bool NeedPresent() const { return false; }
|
||||||
|
|
||||||
|
void SetNotificationPosition(ENotificationPosition eNotificationPosition) {}
|
||||||
|
|
||||||
|
void SetNotificationInset(int nHorizontalInset, int nVerticalInset) {}
|
||||||
|
void SetupOverlay() {}
|
||||||
|
|
||||||
|
void HookReady(void* hWnd) {}
|
||||||
|
|
||||||
|
void OverlayProc(int width, int height) {}
|
||||||
|
|
||||||
|
void OpenOverlayInvite(CSteamID lobbyId) {}
|
||||||
|
void OpenOverlay(const char* pchDialog) {}
|
||||||
|
|
||||||
|
void ShowOverlay(bool state) {}
|
||||||
|
|
||||||
|
void SetLobbyInvite(Friend friendId, uint64 lobbyId) {}
|
||||||
|
void SetRichInvite(Friend friendId, const char* connect_str) {}
|
||||||
|
|
||||||
|
void FriendConnect(Friend _friend) {}
|
||||||
|
void FriendDisconnect(Friend _friend) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif//__INCLUDED_STEAM_OVERLAY_H__
|
#endif//__INCLUDED_STEAM_OVERLAY_H__
|
||||||
|
|
Loading…
Reference in a new issue