diff options
author | comex | 2015-02-18 02:22:36 -0500 |
---|---|---|
committer | comex | 2015-02-18 02:22:36 -0500 |
commit | 7c26a1964d2d2e54f87d9c42735f6c99b546abd4 (patch) | |
tree | f50838e492aa101a4d87e6ef01d1dc2611f32f97 /test/test-pc-patch.c | |
parent | more fixes (diff) | |
download | substitute-7c26a1964d2d2e54f87d9c42735f6c99b546abd4.tar.gz |
Fix hook-function:
- Thread stoppage is now complemented by sigaction to catch injected
threads (sigaction is not used exclusively because the rest of the
program could be trying to use sigaction itself in the meantime - this
is a real thing, ask Dolphin)
- mprotect is no longer used due to max_protection possibly getting in
the way; instead, a copy is created and mapped onto the original.
Diffstat (limited to '')
-rw-r--r-- | test/test-pc-patch.c (renamed from test/test-stop-threads.c) | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/test/test-stop-threads.c b/test/test-pc-patch.c index d53d8cd..5ae3570 100644 --- a/test/test-stop-threads.c +++ b/test/test-pc-patch.c @@ -1,7 +1,8 @@ #include "substitute-internal.h" -#include "stop-other-threads.h" +#include "execmem.h" #include <stdio.h> #include <unistd.h> +#include <stdlib.h> #include <pthread.h> #include <assert.h> /* printf without taking any locks - because they might be taken at stop time */ @@ -32,14 +33,17 @@ int main() { for (long i = 0; i < 10; i++) pthread_create(&pts[i], NULL, some_thread, (void *) i); sleep(1); - void *stop_token; - ulprintf("stopping\n"); - assert(!stop_other_threads(&stop_token)); - ulprintf("stopped\n"); - assert(!apply_pc_patch_callback(stop_token, patch_callback, NULL)); - ulprintf("resuming\n"); - assert(!resume_other_threads(stop_token)); - ulprintf("resumed\n"); + char *foo = malloc(0x10000); + static char bar[16]; + struct execmem_foreign_write writes[] = { + {foo, bar, 5}, + {foo + 7, bar + 7, 3}, + }; + int ret = execmem_foreign_write_with_pc_patch(writes, + sizeof(writes)/sizeof(*writes), + patch_callback, + NULL); + ulprintf("==> %d\n", ret); void *out; for (long i = 0; i < 10; i++) assert(!pthread_join(pts[i], &out)); |