Hook 'ConVar_PrintDescription'

This commit is contained in:
Kawe Mazidjatari 2022-09-12 23:59:32 +02:00
parent 577a8760cd
commit 88fcec1e69
2 changed files with 28 additions and 19 deletions

View File

@ -26,7 +26,7 @@ ConVar* ConVar::Create(const char* pszName, const char* pszDefaultValue, int nFl
pNewConVar->m_pConCommandBaseVFTable = g_pConVarVFTable.RCast<IConCommandBase*>();
pNewConVar->m_pIConVarVFTable = g_pIConVarVFTable.RCast<IConVar*>();
ConVar_Register(pNewConVar, pszName, pszDefaultValue, nFlags, pszHelpString, bMin, fMin, bMax, fMax, pCallback, pszUsageString);
v_ConVar_Register(pNewConVar, pszName, pszDefaultValue, nFlags, pszHelpString, bMin, fMin, bMax, fMax, pCallback, pszUsageString);
return pNewConVar;
}
@ -922,17 +922,6 @@ bool ConVar::IsFlagSetInternal(const ConVar* pConVar, int nFlags)
return pConVar->HasFlags(nFlags) != 0;
}
///////////////////////////////////////////////////////////////////////////////
void IConVar_Attach()
{
DetourAttach((LPVOID*)&IConVar_IsFlagSet, &ConVar::IsFlagSetInternal);
}
void IConVar_Detach()
{
DetourDetach((LPVOID*)&IConVar_IsFlagSet, &ConVar::IsFlagSetInternal);
}
///////////////////////////////////////////////////////////////////////////////
struct PrintConVarFlags_t
{
@ -1060,5 +1049,18 @@ void ConVar_PrintDescription(ConCommandBase* pVar)
}
}
///////////////////////////////////////////////////////////////////////////////
void IConVar_Attach()
{
DetourAttach((LPVOID*)&v_ConVar_IsFlagSet, &ConVar::IsFlagSetInternal);
DetourAttach((LPVOID*)&v_ConVar_PrintDescription, &ConVar_PrintDescription);
}
void IConVar_Detach()
{
DetourDetach((LPVOID*)&v_ConVar_IsFlagSet, &ConVar::IsFlagSetInternal);
DetourDetach((LPVOID*)&v_ConVar_PrintDescription, &ConVar_PrintDescription);
}
///////////////////////////////////////////////////////////////////////////////
ConVar* g_pConVar = new ConVar();

View File

@ -94,11 +94,14 @@ public:
static_assert(sizeof(ConVar) == 0xA0);
/* ==== ICONVAR ========================================================================================================================================================= */
inline CMemory p_IConVar_IsFlagSet;
inline auto IConVar_IsFlagSet = p_IConVar_IsFlagSet.RCast<bool (*)(ConVar* pConVar, int nFlag)>();
inline CMemory p_ConVar_IsFlagSet;
inline auto v_ConVar_IsFlagSet = p_ConVar_IsFlagSet.RCast<bool (*)(ConVar* pConVar, int nFlag)>();
inline CMemory p_ConVar_Register;
inline auto ConVar_Register = p_ConVar_Register.RCast<void* (*)(ConVar* thisptr, const char* szName, const char* szDefaultValue, int nFlags, const char* szHelpString, bool bMin, float fMin, bool bMax, float fMax, FnChangeCallback_t pCallback, const char* pszUsageString)>();
inline auto v_ConVar_Register = p_ConVar_Register.RCast<void* (*)(ConVar* thisptr, const char* szName, const char* szDefaultValue, int nFlags, const char* szHelpString, bool bMin, float fMin, bool bMax, float fMax, FnChangeCallback_t pCallback, const char* pszUsageString)>();
inline CMemory p_ConVar_PrintDescription;
inline auto v_ConVar_PrintDescription = p_ConVar_PrintDescription.RCast<void* (*)(ConCommandBase* pVar)>();
inline CMemory g_pConVarVFTable;
inline CMemory g_pIConVarVFTable;
@ -116,22 +119,26 @@ class VConVar : public IDetour
{
virtual void GetAdr(void) const
{
spdlog::debug("| FUN: ConVar::IsFlagSet : {:#18x} |\n", p_IConVar_IsFlagSet.GetPtr());
spdlog::debug("| FUN: ConVar::IsFlagSet : {:#18x} |\n", p_ConVar_IsFlagSet.GetPtr());
spdlog::debug("| FUN: ConVar::Register : {:#18x} |\n", p_ConVar_Register.GetPtr());
spdlog::debug("| FUN: ConVar_PrintDescription : {:#18x} |\n", p_ConVar_PrintDescription.GetPtr());
spdlog::debug("| VAR: g_pConVarVFTable : {:#18x} |\n", g_pConVarVFTable.GetPtr());
spdlog::debug("| VAR: g_pIConVarVFTable : {:#18x} |\n", g_pIConVarVFTable.GetPtr());
spdlog::debug("+----------------------------------------------------------------+\n");
}
virtual void GetFun(void) const
{
p_IConVar_IsFlagSet = g_GameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x8B\x41\x48\x85\x50\x38"), "xxxxxxx");
p_ConVar_IsFlagSet = g_GameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x8B\x41\x48\x85\x50\x38"), "xxxxxxx");
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
p_ConVar_Register = g_GameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x41\x56\x48\x83\xEC\x30\xF3\x0F\x10\x44\x24\x00"), "xxxx?xxxx?xxxx?xxxx?xxxxxxxxxxx?");
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
p_ConVar_Register = g_GameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x40\xF3\x0F\x10\x84\x24\x00\x00\x00\x00"), "xxxx?xxxx?xxxx?xxxxxxxxxx????");
#endif
IConVar_IsFlagSet = p_IConVar_IsFlagSet.RCast<bool (*)(ConVar*, int)>(); /*48 8B 41 48 85 50 38*/
ConVar_Register = p_ConVar_Register.RCast<void* (*)(ConVar*, const char*, const char*, int, const char*, bool, float, bool, float, FnChangeCallback_t, const char*)>(); /*48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 48 83 EC 40 F3 0F 10 84 24 ? ? ? ?*/
p_ConVar_PrintDescription = g_GameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\xB8\x00\x00\x00\x00\xE8\x00\x00\x00\x00\x48\x2B\xE0\x48\x8B\x01\x48\x89\x9C\x24\x00\x00\x00\x00"), "x????x????xxxxxxxxxx????");
v_ConVar_IsFlagSet = p_ConVar_IsFlagSet.RCast<bool (*)(ConVar*, int)>(); /*48 8B 41 48 85 50 38*/
v_ConVar_Register = p_ConVar_Register.RCast<void* (*)(ConVar*, const char*, const char*, int, const char*, bool, float, bool, float, FnChangeCallback_t, const char*)>(); /*48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 48 83 EC 40 F3 0F 10 84 24 ? ? ? ?*/
v_ConVar_PrintDescription = p_ConVar_PrintDescription.RCast<void* (*)(ConCommandBase*)>(); /*B8 ? ? ? ? E8 ? ? ? ? 48 2B E0 48 8B 01 48 89 9C 24 ? ? ? ?*/
}
virtual void GetVar(void) const { }
virtual void GetCon(void) const