-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathkerninfra.mm
executable file
·43 lines (36 loc) · 1.15 KB
/
kerninfra.mm
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
#include "kerninfra.hpp"
#include <string>
void kernVPrintf(const char *fmtstr, va_list args) {
std::string fmtstr_ = fmtstr;
fmtstr_ += "\n";
vprintf(fmtstr_.c_str(), args);
}
KernInfraContext kerninfra_context = {
.vDoLog = (decltype(kerninfra_context.vDoLog))kernVPrintf,
.logLevel = KERNLOG_NONE,
};
void kerninfra_log(int ll, const char * format, ...) {
if (ll <= kerninfra_context.logLevel) {
va_list ap;
va_start(ap, format);
kerninfra_context.vDoLog(format, ap);
va_end(ap);
}
}
//int init_kerninfra(int logLevel, void (*vDoLog)(const char *, va_list args) = (decltype(vDoLog))vprintf) {
int init_kerninfra(int logLevel, void (*vDoLog)(const char *, va_list args)) {
kerninfra_context.logLevel = (decltype(kerninfra_context.logLevel))logLevel;
if (!!vDoLog) {
kerninfra_context.vDoLog = vDoLog;
}
if (rw_prov_init() != 0) {
printf("failed rw provider's init!\n");
return 1;
}
if (patchfinder_init() != KERN_SUCCESS) {
printf("failed patchfinder dimentio's init!\n");
return 1;
}
prepare_rw_wrap(&kerninfra_context);
return 0;
}