-
Notifications
You must be signed in to change notification settings - Fork 3
/
init.c
59 lines (37 loc) · 1008 Bytes
/
init.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "all.h"
void* (*real_dlopen)(char const*, int);
void tf2mod_init(void)
{
static bool already_init = false;
if (already_init) {
return;
}
already_init = true;
pr_info("libtf2mod: initializing\n");
pr_info("libtf2mod: getting vtable info\n");
vtable_init();
pr_info("libtf2mod: getting entprop info\n");
entprop_init();
pr_info("libtf2mod: applying patches\n");
patch_all();
/* patches MUST be done BEFORE detours to avoid problems! */
pr_info("libtf2mod: enabling detours\n");
detour_all();
pr_info("libtf2mod: initializing convars\n");
convar_init();
#if DUMP
pr_info("libtf2mod: dumping ")
#endif
}
/* OVERRIDE: dlopen */
void* dlopen(const char* __file, int __mode)
{
if (real_dlopen == NULL) {
real_dlopen = dlsym(RTLD_NEXT, "dlopen");
}
void* handle = (*real_dlopen)(__file, __mode);
if (__file != NULL && handle != NULL) {
lib_hook(__file, handle);
}
return handle;
}