22#include " SysUtils.h"
33#include < dxgi1_6.h>
44
5+ #include " Hook_Utils.h"
6+
57class FGHooks
68{
79 public:
@@ -14,19 +16,15 @@ class FGHooks
1416 IDXGIOutput* pRestrictToOutput, IDXGISwapChain1** ppSwapChain);
1517
1618 private:
17- typedef HRESULT (*PFN_Present)(void * This, UINT SyncInterval, UINT Flags);
18- typedef HRESULT (*PFN_Present1)(void * This, UINT SyncInterval, UINT Flags,
19- const DXGI_PRESENT_PARAMETERS* pPresentParameters);
20- typedef HRESULT (*PFN_GetFullscreenDesc)(IDXGISwapChain* This, DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pDesc);
21- typedef HRESULT (*PFN_SetFullscreenState)(IDXGISwapChain* This, BOOL Fullscreen, IDXGIOutput* pTarget);
22- typedef HRESULT (*PFN_GetFullscreenState)(IDXGISwapChain* This, BOOL* pFullscreen, IDXGIOutput** ppTarget);
23- typedef HRESULT (*PFN_ResizeBuffers)(IDXGISwapChain* This, UINT BufferCount, UINT Width, UINT Height,
24- DXGI_FORMAT NewFormat, UINT SwapChainFlags);
25- typedef HRESULT (*PFN_ResizeBuffers1)(IDXGISwapChain* This, UINT BufferCount, UINT Width, UINT Height,
26- DXGI_FORMAT Format, UINT SwapChainFlags, const UINT* pCreationNodeMask,
27- IUnknown* const * ppPresentQueue);
28- typedef HRESULT (*PFN_ResizeTarget)(IDXGISwapChain* This, DXGI_MODE_DESC* pNewTargetParameters);
29- typedef HRESULT (*PFN_Release)(IDXGISwapChain* This);
19+ using PFN_Present = rewrite_signature<decltype (&IDXGISwapChain::Present)>::type;
20+ using PFN_Present1 = rewrite_signature<decltype (&IDXGISwapChain1::Present1)>::type;
21+ using PFN_SetFullscreenState = rewrite_signature<decltype (&IDXGISwapChain::SetFullscreenState)>::type;
22+ using PFN_GetFullscreenState = rewrite_signature<decltype (&IDXGISwapChain::GetFullscreenState)>::type;
23+ using PFN_GetFullscreenDesc = rewrite_signature<decltype (&IDXGISwapChain1::GetFullscreenDesc)>::type;
24+ using PFN_ResizeBuffers = rewrite_signature<decltype (&IDXGISwapChain::ResizeBuffers)>::type;
25+ using PFN_ResizeBuffers1 = rewrite_signature<decltype (&IDXGISwapChain3::ResizeBuffers1)>::type;
26+ using PFN_ResizeTarget = rewrite_signature<decltype (&IDXGISwapChain::ResizeTarget)>::type;
27+ using PFN_Release = rewrite_signature<decltype (&IUnknown::Release)>::type;
3028
3129 inline static PFN_ResizeBuffers o_FGSCResizeBuffers = nullptr ;
3230 inline static PFN_ResizeTarget o_FGSCResizeTarget = nullptr ;
@@ -48,19 +46,31 @@ class FGHooks
4846 static void HookFGSwapchain (IDXGISwapChain* pSwapChain);
4947
5048 static HRESULT hkSetFullscreenState (IDXGISwapChain* This, BOOL Fullscreen, IDXGIOutput* pTarget);
51- static HRESULT hkGetFullscreenDesc (IDXGISwapChain * This, DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pDesc);
49+ static HRESULT hkGetFullscreenDesc (IDXGISwapChain1 * This, DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pDesc);
5250 static HRESULT hkGetFullscreenState (IDXGISwapChain* This, BOOL* pFullscreen, IDXGIOutput** ppTarget);
5351 static HRESULT hkResizeBuffers (IDXGISwapChain* This, UINT BufferCount, UINT Width, UINT Height,
5452 DXGI_FORMAT NewFormat, UINT SwapChainFlags);
55- static HRESULT hkResizeTarget (IDXGISwapChain* This, DXGI_MODE_DESC* pNewTargetParameters);
56- static HRESULT hkResizeBuffers1 (IDXGISwapChain * This, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT Format ,
57- UINT SwapChainFlags, const UINT* pCreationNodeMask,
53+ static HRESULT hkResizeTarget (IDXGISwapChain* This, const DXGI_MODE_DESC* pNewTargetParameters);
54+ static HRESULT hkResizeBuffers1 (IDXGISwapChain3 * This, UINT BufferCount, UINT Width, UINT Height,
55+ DXGI_FORMAT Format, UINT SwapChainFlags, const UINT* pCreationNodeMask,
5856 IUnknown* const * ppPresentQueue);
59- static HRESULT hkFGRelease (IDXGISwapChain * This);
57+ static HRESULT hkFGRelease (IUnknown * This);
6058
61- static HRESULT hkFGPresent (void * This, UINT SyncInterval, UINT Flags);
62- static HRESULT hkFGPresent1 (void * This, UINT SyncInterval, UINT Flags,
59+ static HRESULT hkFGPresent (IDXGISwapChain * This, UINT SyncInterval, UINT Flags);
60+ static HRESULT hkFGPresent1 (IDXGISwapChain1 * This, UINT SyncInterval, UINT Flags,
6361 const DXGI_PRESENT_PARAMETERS* pPresentParameters);
64- static HRESULT FGPresent (void * This, UINT SyncInterval, UINT Flags,
62+ static HRESULT FGPresent (IDXGISwapChain * This, UINT SyncInterval, UINT Flags,
6563 const DXGI_PRESENT_PARAMETERS* pPresentParameters);
64+
65+ VALIDATE_MEMBER_HOOK (hkFGPresent, PFN_Present)
66+ VALIDATE_MEMBER_HOOK (hkFGPresent1, PFN_Present1)
67+ VALIDATE_MEMBER_HOOK (hkSetFullscreenState, PFN_SetFullscreenState)
68+ VALIDATE_MEMBER_HOOK (hkGetFullscreenState, PFN_GetFullscreenState)
69+ VALIDATE_MEMBER_HOOK (hkGetFullscreenDesc, PFN_GetFullscreenDesc)
70+ VALIDATE_MEMBER_HOOK (hkResizeBuffers, PFN_ResizeBuffers)
71+ VALIDATE_MEMBER_HOOK (hkResizeBuffers1, PFN_ResizeBuffers1)
72+ VALIDATE_MEMBER_HOOK (hkResizeTarget, PFN_ResizeTarget)
73+
74+ // Don't understand why this is failing
75+ // VALIDATE_MEMBER_HOOK(hkFGRelease, PFN_Release)
6676};
0 commit comments