From d336c0247563c5a1a95fb205386945fc76251e7e Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Fri, 20 May 2011 06:58:54 +0000 Subject: [PATCH] Use dlsym(), not struct Baton. --- Baton.hpp | 7 ------- Mach/Inject.cpp | 7 ------- Trampoline.t.cpp | 6 +++--- 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/Baton.hpp b/Baton.hpp index 3ce4e62..cde04d2 100644 --- a/Baton.hpp +++ b/Baton.hpp @@ -26,16 +26,9 @@ struct Baton { void (*__pthread_set_self)(pthread_t); - int (*pthread_create)(pthread_t *, const pthread_attr_t *, void *(*)(void *), void *); - int (*pthread_join)(pthread_t, void **); - - void *(*dlopen)(const char *, int); char *(*dlerror)(); void *(*dlsym)(void *, const char *); - mach_port_t (*mach_thread_self)(); - kern_return_t (*thread_terminate)(thread_act_t); - pid_t pid; char library[]; }; diff --git a/Mach/Inject.cpp b/Mach/Inject.cpp index 45c33be..ec1f1f5 100644 --- a/Mach/Inject.cpp +++ b/Mach/Inject.cpp @@ -48,16 +48,9 @@ void InjectLibrary(pid_t pid) { baton->__pthread_set_self = &__pthread_set_self; - baton->pthread_create = &pthread_create; - baton->pthread_join = &pthread_join; - - baton->dlopen = &dlopen; baton->dlerror = &dlerror; baton->dlsym = &dlsym; - baton->mach_thread_self = &mach_thread_self; - baton->thread_terminate = &thread_terminate; - baton->pid = getpid(); memcpy(baton->library, library, length); diff --git a/Trampoline.t.cpp b/Trampoline.t.cpp index e52962a..a0f5aef 100644 --- a/Trampoline.t.cpp +++ b/Trampoline.t.cpp @@ -82,13 +82,13 @@ extern "C" void Start(Baton *baton) { dlset(baton, pthread_create, "pthread_create"); pthread_t thread; - baton->pthread_create(&thread, NULL, &Routine, baton); + pthread_create(&thread, NULL, &Routine, baton); int (*pthread_join)(pthread_t, void **); dlset(baton, pthread_join, "pthread_join"); void *result; - baton->pthread_join(thread, &result); + pthread_join(thread, &result); mach_port_t (*mach_thread_self)(); dlset(baton, mach_thread_self, "mach_thread_self"); @@ -96,5 +96,5 @@ extern "C" void Start(Baton *baton) { kern_return_t (*thread_terminate)(thread_act_t); dlset(baton, thread_terminate, "thread_terminate"); - baton->thread_terminate(baton->mach_thread_self()); + thread_terminate(mach_thread_self()); } -- 2.45.2