-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
78 lines (64 loc) · 1.81 KB
/
main.cpp
File metadata and controls
78 lines (64 loc) · 1.81 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#define _HXO_MOD
#include "imgui/imgui.h"
#include "open_gl.h"
#include "touch.h"
#include "ui.h"
#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
extern "C" {
#include "inlinehook.h"
#include "dynlib.h"
}
static void perform_setup() {
printf("[HXO] perform_setup: sleeping 4 seconds before initializing...\n");
sleep(4);
printf("[HXO] perform_setup: setting up OpenGL hooks...\n");
setup_opengl_hooks();
printf("[HXO] perform_setup: hooking touch...\n");
hook_touch();
printf("[HXO] perform_setup: setup completed.\n");
}
#ifdef HXO_CLEAN_BUILD
extern "C" size_t _init_hxo(struct HXOParam*) {
printf("[HXO] _init_hxo called (CLEAN_BUILD).\n");
pthread_t th;
if (pthread_create(&th, nullptr, [](void*)->void* {
printf("[HXO] setup thread started.\n");
perform_setup();
printf("[HXO] setup thread finished.\n");
return nullptr;
}, nullptr) != 0) {
printf("[HXO] ERROR: Failed to create setup thread!\n");
}
pthread_detach(th);
return 0;
}
#else
static void* setup_thread(void*) {
printf("[HXO] setup_thread: started.\n");
perform_setup();
printf("[HXO] setup_thread: finished.\n");
return nullptr;
}
__attribute__((constructor))
static void lib_main() {
printf("[HXO] lib_main constructor: creating setup thread...\n");
pthread_t th;
if (pthread_create(&th, nullptr, setup_thread, nullptr) != 0) {
printf("[HXO] ERROR: Failed to create setup_thread!\n");
}
pthread_detach(th);
}
extern "C" size_t _init_hxo(struct HXOParam*) {
printf("[HXO] _init_hxo called (constructor mode).\n");
lib_main();
return 0;
}
#endif
__attribute__((destructor))
static void cleanup() {
printf("[HXO] cleanup: cleaning up UI...\n");
cleanup_ui();
printf("[HXO] cleanup: complete.\n");
}