From 6766f5be620133064df80b8e74527902c59ab669 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 21 Jan 2024 17:34:22 +0100 Subject: [PATCH] Tier1: map out CCvar completely and get the ptr to the actual class instance Previously we had a ptr to just its vtable; get the ptr to the actual class instance. --- r5dev/public/tier1/cvar.h | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/r5dev/public/tier1/cvar.h b/r5dev/public/tier1/cvar.h index 9336be88..af1f37c4 100644 --- a/r5dev/public/tier1/cvar.h +++ b/r5dev/public/tier1/cvar.h @@ -18,6 +18,7 @@ #include "tier1/utlmap.h" #include "tier1/utlvector.h" #include "tier1/utlstring.h" +#include "tier1/utlbuffer.h" //----------------------------------------------------------------------------- // Forward declarations @@ -68,19 +69,19 @@ protected: friend class CCvarUtilities; private: - CUtlVector< FnChangeCallback_t > m_GlobalChangeCallbacks; - char pad0[30]; //!TODO: - int m_nNextDLLIdentifier; - ConCommandBase* m_pConCommandList; - CConCommandHash m_CommandHash; - CUtlVector m_Unknown; - char pad2[32]; - void* m_pCallbackStub; - void* m_pAllocFunc; - char pad3[16]; - CUtlVector< QueuedConVarSet_t > m_QueuedConVarSets; - bool m_bMaterialSystemThreadSetAllowed; + CUtlVector< FnChangeCallback_t > m_GlobalChangeCallbacks; + CUtlVector< IConsoleDisplayFunc* > m_DisplayFuncs; + int m_nNextDLLIdentifier; + + ConCommandBase* m_pConCommandList; + CConCommandHash m_CommandHash; + + // temporary console area so we can store prints before console display funs are installed + mutable CUtlBuffer m_TempConsoleBuffer; + CUtlVector< QueuedConVarSet_t > m_QueuedConVarSets; + bool m_bMaterialSystemThreadSetAllowed; }; +static_assert(sizeof(CCvar) == 360); extern CCvar* g_pCVar; /////////////////////////////////////////////////////////////////////////////// @@ -177,11 +178,8 @@ class VCVar : public IDetour } virtual void GetVar(void) const { - g_pCVar = g_GameDll.FindPatternSIMD("48 83 EC 28 48 8B 05 ?? ?? ?? ?? 48 8D 0D ?? ?? ?? ?? 48 85 C0 48 89 15") - .FindPatternSelf("48 8D 0D", CMemory::Direction::DOWN, 40).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); - - //g_pCVar = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 48 83 3D ?? ?? ?? ?? ?? 48 8B D9 74 09") // Actual CCvar, above is the vtable ptr. - //.FindPatternSelf("48 83 3D", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(0x3, 0x8).RCast(); + g_GameDll.FindPatternSIMD("48 83 EC 28 48 8B 05 ?? ?? ?? ?? 48 8D 0D ?? ?? ?? ?? 48 85 C0 48 0F 45 C8 FF 05 ?? ?? ?? ?? 48 89 0D ?? ?? ?? ??") + .FindPatternSelf("48 8D 0D").ResolveRelativeAddressSelf(3, 7).GetPtr(g_pCVar); } virtual void GetCon(void) const { } virtual void Detour(const bool bAttach) const;