From ef5abd92fdcf9337e512de1ec541ca310eaaea06 Mon Sep 17 00:00:00 2001 From: comex Date: Sun, 25 Jan 2015 21:09:10 -0500 Subject: this is dumb --- test/test-inject.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/test-inject.c b/test/test-inject.c index 96ad46a..5d7bcff 100644 --- a/test/test-inject.c +++ b/test/test-inject.c @@ -4,6 +4,7 @@ #include #include #include +#include int main(int argc, char **argv) { if (argc <= 2) { @@ -11,7 +12,24 @@ int main(int argc, char **argv) { return 1; } int pid = atoi(argv[1]); - char *error = NULL; - int ret = substitute_dlopen_in_pid(pid, argv[2], 0, &error); + char *error; + mach_port_t port = 0; + assert(!mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &port)); + struct shuttle shuttles[] = { + {.type = SUBSTITUTE_SHUTTLE_MACH_PORT, + .u.mach.port = port, + .u.mach.right_type = MACH_MSG_TYPE_MAKE_SEND} + }; + int ret = substitute_dlopen_in_pid(pid, argv[2], 0, shuttles, 1, &error); printf("ret=%d err=%s\n", ret, error); + assert(!ret); + free(error); + static struct { + mach_msg_header_t hdr; + char body[5]; + } msg; + assert(!mach_msg_overwrite(NULL, MACH_RCV_MSG, 0, sizeof(msg), port, + MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL, &msg.hdr, 0)); + printf("received '%.5s'\n", msg.body); + } -- cgit v1.2.3