9
9
#include < iomanip>
10
10
#include < sstream>
11
11
12
- AUTOHOOK_INIT ()
13
-
14
12
ConVar* Cvar_spewlog_enable;
15
13
ConVar* Cvar_cl_showtextmsg;
16
14
@@ -70,10 +68,8 @@ const std::unordered_map<SpewType_t, const char> PrintSpewTypes_Short = {
70
68
71
69
ICenterPrint* pInternalCenterPrint = NULL ;
72
70
73
- // clang-format off
74
- AUTOHOOK (TextMsg, client.dll + 0x198710 ,
75
- void ,, (BFRead* msg))
76
- // clang-format on
71
+ static void (*o_pTextMsg)(BFRead* msg) = nullptr;
72
+ static void h_TextMsg (BFRead* msg)
77
73
{
78
74
TextMsgPrintType_t msg_dest = (TextMsgPrintType_t)msg->ReadByte ();
79
75
@@ -103,10 +99,8 @@ void,, (BFRead* msg))
103
99
}
104
100
}
105
101
106
- // clang-format off
107
- AUTOHOOK (Hook_fprintf, engine.dll + 0x51B1F0 ,
108
- int ,, (void * const stream, const char * const format, ...))
109
- // clang-format on
102
+ static int (*o_pfprintf)(void * const stream, const char * const format, ...) = nullptr;
103
+ static int h_fprintf (void * const stream, const char * const format, ...)
110
104
{
111
105
NOTE_UNUSED (stream);
112
106
@@ -127,19 +121,15 @@ int,, (void* const stream, const char* const format, ...))
127
121
return 0 ;
128
122
}
129
123
130
- // clang-format off
131
- AUTOHOOK (ConCommand_echo, engine.dll + 0x123680 ,
132
- void ,, (const CCommand& arg))
133
- // clang-format on
124
+ static void (*o_pConCommand_echo)(const CCommand& arg) = nullptr;
125
+ static void h_ConCommand_echo (const CCommand& arg)
134
126
{
135
127
if (arg.ArgC () >= 2 )
136
128
NS::log ::echo->info (" {}" , arg.ArgS ());
137
129
}
138
130
139
- // clang-format off
140
- AUTOHOOK (EngineSpewFunc, engine.dll + 0x11CA80 ,
141
- void , __fastcall, (void * pEngineServer, SpewType_t type, const char * format, va_list args))
142
- // clang-format on
131
+ static void (__fastcall* o_pEngineSpewFunc)(void * pEngineServer, SpewType_t type, const char * format, va_list args) = nullptr;
132
+ static void __fastcall h_EngineSpewFunc (void * pEngineServer, SpewType_t type, const char * format, va_list args)
143
133
{
144
134
NOTE_UNUSED (pEngineServer);
145
135
if (!Cvar_spewlog_enable->GetBool ())
@@ -214,10 +204,8 @@ void, __fastcall, (void* pEngineServer, SpewType_t type, const char* format, va_
214
204
}
215
205
216
206
// used for printing the output of status
217
- // clang-format off
218
- AUTOHOOK (Status_ConMsg, engine.dll + 0x15ABD0 ,
219
- void ,, (const char * text, ...))
220
- // clang-format on
207
+ static void (*o_pStatus_ConMsg)(const char * text, ...) = nullptr;
208
+ static void h_Status_ConMsg (const char * text, ...)
221
209
{
222
210
char formatted[2048 ];
223
211
va_list list;
@@ -233,10 +221,8 @@ void,, (const char* text, ...))
233
221
spdlog::info (formatted);
234
222
}
235
223
236
- // clang-format off
237
- AUTOHOOK (CClientState_ProcessPrint, engine.dll + 0x1A1530 ,
238
- bool ,, (void * thisptr, uintptr_t msg))
239
- // clang-format on
224
+ static bool (*o_pCClientState_ProcessPrint)(void * thisptr, uintptr_t msg) = nullptr;
225
+ static bool h_CClientState_ProcessPrint (void * thisptr, uintptr_t msg)
240
226
{
241
227
NOTE_UNUSED (thisptr);
242
228
@@ -252,14 +238,28 @@ bool,, (void* thisptr, uintptr_t msg))
252
238
253
239
ON_DLL_LOAD_RELIESON (" engine.dll" , EngineSpewFuncHooks, ConVar, (CModule module))
254
240
{
255
- AUTOHOOK_DISPATCH_MODULE (engine.dll )
241
+ o_pfprintf = module.Offset (0x51B1F0 ).RCast <decltype (o_pfprintf)>();
242
+ HookAttach (&(PVOID&)o_pfprintf, (PVOID)h_fprintf);
243
+
244
+ o_pConCommand_echo = module.Offset (0x123680 ).RCast <decltype (o_pConCommand_echo)>();
245
+ HookAttach (&(PVOID&)o_pConCommand_echo, (PVOID)h_ConCommand_echo);
246
+
247
+ o_pEngineSpewFunc = module.Offset (0x11CA80 ).RCast <decltype (o_pEngineSpewFunc)>();
248
+ HookAttach (&(PVOID&)o_pEngineSpewFunc, (PVOID)h_EngineSpewFunc);
249
+
250
+ o_pStatus_ConMsg = module.Offset (0x15ABD0 ).RCast <decltype (o_pStatus_ConMsg)>();
251
+ HookAttach (&(PVOID&)o_pStatus_ConMsg, (PVOID)h_Status_ConMsg);
252
+
253
+ o_pCClientState_ProcessPrint = module.Offset (0x1A1530 ).RCast <decltype (o_pCClientState_ProcessPrint)>();
254
+ HookAttach (&(PVOID&)o_pCClientState_ProcessPrint, (PVOID)h_CClientState_ProcessPrint);
256
255
257
256
Cvar_spewlog_enable = new ConVar (" spewlog_enable" , " 0" , FCVAR_NONE, " Enables/disables whether the engine spewfunc should be logged" );
258
257
}
259
258
260
259
ON_DLL_LOAD_CLIENT_RELIESON (" client.dll" , ClientPrintHooks, ConVar, (CModule module))
261
260
{
262
- AUTOHOOK_DISPATCH_MODULE (client.dll )
261
+ o_pTextMsg = module.Offset (0x198710 ).RCast <decltype (o_pTextMsg)>();
262
+ HookAttach (&(PVOID&)o_pTextMsg, (PVOID)h_TextMsg);
263
263
264
264
Cvar_cl_showtextmsg = new ConVar (" cl_showtextmsg" , " 1" , FCVAR_NONE, " Enable/disable text messages printing on the screen." );
265
265
pInternalCenterPrint = module.Offset (0x216E940 ).RCast <ICenterPrint*>();
0 commit comments