2022-04-13 01:25:33 +02:00
//=============================================================================
//
//
//=============================================================================
2021-12-25 22:36:38 +01:00
# include "core/stdafx.h"
/*****************************************************************************/
2022-04-09 16:16:40 +02:00
# include "tier1/cvar.h"
2022-01-10 02:47:19 +01:00
# include "tier0/commandline.h"
2022-04-09 16:16:40 +02:00
# include "tier1/IConVar.h"
2022-04-02 12:27:35 +02:00
# include "client/vengineclient_impl.h"
2021-12-25 22:36:38 +01:00
# include "client/cdll_engine_int.h"
# include "engine/net_chan.h"
2022-05-20 11:52:19 +02:00
# include "engine/client/cl_rcon.h"
2022-01-05 02:07:37 +01:00
# include "public/include/bansystem.h"
2021-12-25 22:36:38 +01:00
# include "vpc/keyvalues.h"
/*****************************************************************************/
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
2022-04-13 01:25:33 +02:00
void CHLClient : : FrameStageNotify ( CHLClient * pHLClient , ClientFrameStage_t frameStage )
2021-12-25 22:36:38 +01:00
{
switch ( frameStage )
{
case ClientFrameStage_t : : FRAME_START : // FrameStageNotify gets called every frame by CEngine::Frame with the stage being FRAME_START. We can use this to check/set global variables.
{
break ;
}
case ClientFrameStage_t : : FRAME_NET_UPDATE_POSTDATAUPDATE_END :
{
2022-04-14 19:18:59 +02:00
gHLClient - > PatchNetVarConVar ( ) ;
2021-12-25 22:36:38 +01:00
break ;
}
default :
{
break ;
}
}
2022-04-13 01:25:33 +02:00
CHLClient_FrameStageNotify ( pHLClient , frameStage ) ;
2021-12-25 22:36:38 +01:00
}
2022-05-02 23:53:26 +02:00
//-----------------------------------------------------------------------------
// Purpose: Get g_pClientClassHead Pointer for all ClientClasses.
// Input :
// Output : ClientClass*
//-----------------------------------------------------------------------------
ClientClass * CHLClient : : GetAllClasses ( )
{
return CHLClient_GetAllClasses ( ) ;
}
2021-12-25 22:36:38 +01:00
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
2022-04-13 01:25:33 +02:00
void CHLClient : : PatchNetVarConVar ( void ) const
2021-12-25 22:36:38 +01:00
{
2022-04-13 01:25:33 +02:00
# ifdef GAMEDLL_S3
static bool bASLR = true ;
static bool bInit = false ;
static void * pCVar = 0 ;
if ( ! bASLR & & ! bInit )
2021-12-25 22:36:38 +01:00
{
2022-04-13 01:25:33 +02:00
CHAR sConVarPtr [ ] = " \x72 \x3a \x73 \x76 \x72 \x75 \x73 \x7a \x7a \x03 \x04 " ;
PCHAR curr = sConVarPtr ;
while ( * curr )
{
* curr ^ = ' B ' ;
+ + curr ;
}
2021-12-25 22:36:38 +01:00
2022-04-13 01:25:33 +02:00
stringstream ss ;
ss < < std : : hex < < string ( sConVarPtr ) ;
ss > > pCVar ;
bInit = true ;
}
else if ( ! bInit )
{
CMemory mCVar = g_mGameDll . FindPatternSIMD ( reinterpret_cast < rsig_t > ( " \xF3 \x0F \x11 \x83 \x8C \x21 \x00 \x00 " ) , " xxxxxxxx " ) ;
pCVar = mCVar . RCast < void * > ( ) ;
bInit = true ;
}
2021-12-25 22:36:38 +01:00
2022-04-13 01:25:33 +02:00
if ( * reinterpret_cast < uint8_t * > ( pCVar ) = = 144 )
2021-12-25 22:36:38 +01:00
{
2022-04-13 01:25:33 +02:00
uint8_t padding [ ] =
2021-12-25 22:36:38 +01:00
{
2022-04-13 01:25:33 +02:00
0x48 , 0x8B , 0x45 ,
0x58 , 0xC7 , 0x00 ,
0x00 , 0x00 , 0x00 ,
0x00
2021-12-25 22:36:38 +01:00
} ;
void * pCallback = nullptr ;
VirtualAlloc ( pCallback , 10 , MEM_COMMIT | MEM_RESERVE , PAGE_EXECUTE_READWRITE ) ;
2022-04-13 01:25:33 +02:00
memcpy ( pCallback , reinterpret_cast < void * > ( padding ) , 9 ) ;
2021-12-25 22:36:38 +01:00
reinterpret_cast < void ( * ) ( ) > ( pCallback ) ( ) ;
}
2022-04-13 01:25:33 +02:00
# endif // GAMEDLL_S3
2021-12-25 22:36:38 +01:00
}
///////////////////////////////////////////////////////////////////////////////
void CHLClient_Attach ( )
{
2022-04-13 01:25:33 +02:00
DetourAttach ( ( LPVOID * ) & CHLClient_FrameStageNotify , & CHLClient : : FrameStageNotify ) ;
2021-12-25 22:36:38 +01:00
}
void CHLClient_Detach ( )
{
2022-04-13 01:25:33 +02:00
DetourDetach ( ( LPVOID * ) & CHLClient_FrameStageNotify , & CHLClient : : FrameStageNotify ) ;
2021-12-25 22:36:38 +01:00
}