blob: 975520e6788cfde85bdbad01ccf812b8d1423a38 (
plain) (
blame)
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
|
#include "substitute.h"
#include "substitute-internal.h"
static uintptr_t patch_callback(UNUSED void *ctx, uintptr_t pc) {
printf("patch_callback: pc=%llx\n", (long long) pc);
return pc;
}
EXPORT
int substitute_hook_functions(const struct substitute_function_hook *hooks,
size_t nhooks,
int options) {
(void) hooks; (void) nhooks;
int ret = SUBSTITUTE_OK;
void *stop_token;
if (!(options & SUBSTITUTE_DONT_STOP_THREADS)) {
if ((ret = stop_other_threads(&stop_token)))
return ret;
}
if (!(options & SUBSTITUTE_DONT_STOP_THREADS)) {
if ((ret = apply_pc_patch_callback(stop_token, patch_callback, NULL)))
goto fail;
}
fail:
if (!(options & SUBSTITUTE_DONT_STOP_THREADS)) {
int r2 = resume_other_threads(stop_token);
if (!ret)
ret = r2;
}
return ret;
}
|