From c48c4164f243a853d2d64472317fe232d19c9160 Mon Sep 17 00:00:00 2001 From: 8dcc <8dcc.git@gmail.com> Date: Mon, 24 Jul 2023 15:57:48 +0200 Subject: [PATCH] Add hClientDLL handler and i_studiomodelrenderer Fix error string --- src/globals.c | 22 ++++++++++++++++++++-- src/include/globals.h | 2 ++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/globals.c b/src/globals.c index 0c6593e..4d2d330 100644 --- a/src/globals.c +++ b/src/globals.c @@ -5,11 +5,14 @@ #include "include/globals.h" #include "include/sdk.h" +#include "include/util.h" void* hw; +void** h_client; DECL_INTF(cl_enginefunc_t, engine); DECL_INTF(cl_clientfunc_t, client); DECL_INTF(playermove_t, pmove); +DECL_INTF(StudioModelRenderer_t, studiomodelrenderer); /* Updated in CL_CreateMove hook */ cl_entity_t* localplayer = NULL; @@ -28,13 +31,28 @@ bool globals_init(void) { return false; } + h_client = (void**)dlsym(hw, "hClientDLL"); + + if (!h_client) { + printf("hl-cheat: globals_init: can't find hClientDLL\n"); + return false; + } + /* Get symbol addresses using dlsym and the handler we just opened */ i_engine = (cl_enginefunc_t*)dlsym(hw, "cl_enginefuncs"); i_client = (cl_clientfunc_t*)dlsym(hw, "cl_funcs"); i_pmove = *(playermove_t**)dlsym(hw, "pmove"); - if (!i_engine || !i_client || !i_pmove) { - printf("hl-cheat: globals_init: could't load some symbols.\n"); + const char* SMR_STR = "g_StudioRenderer"; /* For clang-format */ + i_studiomodelrenderer = *(StudioModelRenderer_t**)dlsym(*h_client, SMR_STR); + + if (!i_engine || !i_client || !i_pmove || !i_studiomodelrenderer) { + printf("hl-cheat: globals_init: couldn't load some symbols\n"); + return false; + } + + if (!unprotect_addr(i_studiomodelrenderer)) { + printf("hl-cheat: globals_init: couldn't unprotect address of SMR\n"); return false; } diff --git a/src/include/globals.h b/src/include/globals.h index 7119461..6b43425 100644 --- a/src/include/globals.h +++ b/src/include/globals.h @@ -26,9 +26,11 @@ /*----------------------------------------------------------------------------*/ extern void* hw; +extern void** h_client; /* hClientDLL hander */ DECL_INTF_EXTERN(cl_enginefunc_t, engine); DECL_INTF_EXTERN(cl_clientfunc_t, client); DECL_INTF_EXTERN(playermove_t, pmove); +DECL_INTF_EXTERN(StudioModelRenderer_t, studiomodelrenderer); extern cl_entity_t* localplayer;