Add hClientDLL handler and i_studiomodelrenderer

Fix error string
This commit is contained in:
8dcc 2023-07-24 15:57:48 +02:00
parent fee20bb1ec
commit c48c4164f2
2 changed files with 22 additions and 2 deletions

View File

@ -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;
}

View File

@ -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;