2023-07-19 19:44:20 -04:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <dlfcn.h>
|
|
|
|
|
|
|
|
#include "include/globals.h"
|
|
|
|
#include "include/sdk.h"
|
|
|
|
|
|
|
|
void* hw;
|
2023-07-20 10:38:02 -04:00
|
|
|
DECL_INTF(cl_enginefunc_t, engine);
|
|
|
|
DECL_INTF(cl_clientfunc_t, client);
|
2023-07-19 19:44:20 -04:00
|
|
|
|
|
|
|
bool globals_init(void) {
|
|
|
|
/*
|
|
|
|
* Get handler for hw.so
|
|
|
|
* RTLD_LAZY: If the symbol is never referenced, then it is never resolved.
|
|
|
|
* RTLD_NOLOAD: Don't load the shared object.
|
|
|
|
*/
|
|
|
|
hw = dlopen("hw.so", RTLD_LAZY | RTLD_NOLOAD);
|
|
|
|
|
|
|
|
/* Make sure it's a valid handler */
|
|
|
|
if (!hw) {
|
2023-07-20 11:31:16 -04:00
|
|
|
printf("hl-cheat: globals_init: can't open hw.so\n");
|
2023-07-19 19:44:20 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get symbol addresses using dlsym and the handler we just opened */
|
2023-07-20 14:25:49 -04:00
|
|
|
i_engine = (cl_enginefunc_t*)dlsym(hw, "cl_enginefuncs");
|
|
|
|
i_client = (cl_clientfunc_t*)dlsym(hw, "cl_funcs");
|
2023-07-19 19:44:20 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|