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/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<void*> 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<CCvar*>();
//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*>();
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;