From d4f9e68930d5ce5cea79299adc171c74ed913361 Mon Sep 17 00:00:00 2001
From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com>
Date: Thu, 21 Jul 2022 16:56:25 +0200
Subject: [PATCH] 'g_ppGameDevice' confirmed compatible with earlier builds

---
 r5dev/windows/id3dx.cpp | 13 +++++++------
 r5dev/windows/id3dx.h   |  8 +++-----
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/r5dev/windows/id3dx.cpp b/r5dev/windows/id3dx.cpp
index 526cc499..2f4cd242 100644
--- a/r5dev/windows/id3dx.cpp
+++ b/r5dev/windows/id3dx.cpp
@@ -531,14 +531,15 @@ void DirectX_Shutdown()
 	}
 }
 
-void HIDXGI::GetAdr(void) const
+void VDXGI::GetAdr(void) const
 {
 	///////////////////////////////////////////////////////////////////////////////
-	spdlog::debug("| VAR: ID3D11DeviceContext                  : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pDeviceContext)         );
-	spdlog::debug("| VAR: ID3D11Device                         : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pDevice)                );
-	spdlog::debug("| VAR: ID3D11RenderTargetView               : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pRenderTargetView)      );
-	spdlog::debug("| VAR: IDXGISwapChain                       : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pSwapChain)             );
-	spdlog::debug("| VAR: IDXGISwapChainPresent                : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_fnIDXGISwapChainPresent));
+	spdlog::debug("| FUN: IDXGISwapChain::Present              : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_fnIDXGISwapChainPresent));
+	spdlog::debug("| VAR: g_pSwapChain                         : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pSwapChain)             );
+	spdlog::debug("| VAR: g_pRenderTargetView                  : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pRenderTargetView)      );
+	spdlog::debug("| VAR: g_pDeviceContext                     : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pDeviceContext)         );
+	spdlog::debug("| VAR: g_pDevice                            : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pDevice)                );
+	spdlog::debug("| VAR: g_ppGameDevice                       : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_ppGameDevice)           );
 	spdlog::debug("+----------------------------------------------------------------+\n");
 }
 
diff --git a/r5dev/windows/id3dx.h b/r5dev/windows/id3dx.h
index 918cc1aa..f41047e4 100644
--- a/r5dev/windows/id3dx.h
+++ b/r5dev/windows/id3dx.h
@@ -115,21 +115,19 @@ enum class DXGISwapChainVTbl : short
 inline CMemory p_gGameDevice;
 inline ID3D11Device** g_ppGameDevice = nullptr;
 
-class HIDXGI : public IDetour
+class VDXGI : public IDetour
 {
 	virtual void GetAdr(void) const;
 	virtual void GetFun(void) const { }
 	virtual void GetVar(void) const
 	{
-#ifdef GAMEDLL_S3
-		p_gGameDevice = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\xD3\xEA\x48\x8B\x0D\x00\x00\x00\x00"), "xxxxx????").OffsetSelf(0x2).ResolveRelativeAddressSelf(0x3, 0x7);
+		p_gGameDevice = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\xD3\xEA\x48\x8B\x0D\x00\x00\x00\x00"), "xxxxx????").FindPatternSelf("48 8B").ResolveRelativeAddressSelf(0x3, 0x7);
 		g_ppGameDevice = p_gGameDevice.RCast<ID3D11Device**>(); /*D3 EA 48 8B 0D ? ? ? ?*/
-#endif
 	}
 	virtual void GetCon(void) const { }
 	virtual void Attach(void) const { }
 	virtual void Detach(void) const { }
 	///////////////////////////////////////////////////////////////////////////////
 };
-REGISTER(HIDXGI);
+REGISTER(VDXGI);
 #endif // !DEDICATED