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.
This commit is contained in:
Kawe Mazidjatari 2024-01-21 17:34:22 +01:00
parent 184365f135
commit f8107622ff

View File

@ -18,6 +18,7 @@
#include "tier1/utlmap.h" #include "tier1/utlmap.h"
#include "tier1/utlvector.h" #include "tier1/utlvector.h"
#include "tier1/utlstring.h" #include "tier1/utlstring.h"
#include "tier1/utlbuffer.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Forward declarations // Forward declarations
@ -68,19 +69,19 @@ protected:
friend class CCvarUtilities; friend class CCvarUtilities;
private: private:
CUtlVector< FnChangeCallback_t > m_GlobalChangeCallbacks; CUtlVector< FnChangeCallback_t > m_GlobalChangeCallbacks;
char pad0[30]; //!TODO: CUtlVector< IConsoleDisplayFunc* > m_DisplayFuncs;
int m_nNextDLLIdentifier; int m_nNextDLLIdentifier;
ConCommandBase* m_pConCommandList;
CConCommandHash m_CommandHash; ConCommandBase* m_pConCommandList;
CUtlVector<void*> m_Unknown; CConCommandHash m_CommandHash;
char pad2[32];
void* m_pCallbackStub; // temporary console area so we can store prints before console display funs are installed
void* m_pAllocFunc; mutable CUtlBuffer m_TempConsoleBuffer;
char pad3[16]; CUtlVector< QueuedConVarSet_t > m_QueuedConVarSets;
CUtlVector< QueuedConVarSet_t > m_QueuedConVarSets; bool m_bMaterialSystemThreadSetAllowed;
bool m_bMaterialSystemThreadSetAllowed;
}; };
static_assert(sizeof(CCvar) == 360);
extern CCvar* g_pCVar; extern CCvar* g_pCVar;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -177,11 +178,8 @@ class VCVar : public IDetour
} }
virtual void GetVar(void) const 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") 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", CMemory::Direction::DOWN, 40).ResolveRelativeAddressSelf(0x3, 0x7).RCast<CCvar*>(); .FindPatternSelf("48 8D 0D").ResolveRelativeAddressSelf(3, 7).GetPtr(g_pCVar);
//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<CCvar*>();
} }
virtual void GetCon(void) const { } virtual void GetCon(void) const { }
virtual void Detour(const bool bAttach) const; virtual void Detour(const bool bAttach) const;