diff options
author | comex | 2015-01-21 18:24:08 -0500 |
---|---|---|
committer | comex | 2015-01-21 18:24:08 -0500 |
commit | 2795a1a5b34bffc350f9366fcf05a6165067eafa (patch) | |
tree | 23d2a31654b4306637fc56796d82962abec3a337 /lib/hook-functions.c | |
parent | add substitute_strerror (diff) | |
download | substitute-2795a1a5b34bffc350f9366fcf05a6165067eafa.tar.gz |
stopping other threads.
Diffstat (limited to '')
-rw-r--r-- | lib/hook-functions.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/hook-functions.c b/lib/hook-functions.c new file mode 100644 index 0000000..975520e --- /dev/null +++ b/lib/hook-functions.c @@ -0,0 +1,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; +} |