]> git.saurik.com Git - cycript.git/commitdiff
Generalized fix for injector. v0.9.437
authorJay Freeman (saurik) <saurik@saurik.com>
Fri, 20 May 2011 06:59:08 +0000 (06:59 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Fri, 20 May 2011 06:59:08 +0000 (06:59 +0000)
Baton.hpp
Mach/Inject.cpp
Trampoline.t.cpp

index cde04d23e2efe7789733f137faef28cb80344802..bf048bad2215783bf815093d864d43c20cc77197 100644 (file)
--- a/Baton.hpp
+++ b/Baton.hpp
 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 **);
+
+    mach_port_t (*mach_thread_self)();
+    kern_return_t (*thread_terminate)(thread_act_t);
+
     char *(*dlerror)();
     void *(*dlsym)(void *, const char *);
 
index 29d1848664645e18c4b8be328c85d5bfd60ff764..3f91398a899ee4ac4ae2de89f135a01986a70c26 100644 (file)
@@ -48,6 +48,12 @@ void InjectLibrary(pid_t pid) {
 
     baton->__pthread_set_self = &__pthread_set_self;
 
+    baton->pthread_create = &pthread_create;
+    baton->pthread_join = &pthread_join;
+
+    baton->mach_thread_self = &mach_thread_self;
+    baton->thread_terminate = &thread_terminate;
+
     baton->dlerror = &dlerror;
     baton->dlsym = &dlsym;
 
index a0f5aef27425d908085f05258ac810dbccdad2ac..5bf77cea2339d6c969452da851fcd40ffd9daa31 100644 (file)
@@ -59,7 +59,8 @@ void *Routine(void *arg) {
     void (*CYHandleServer)(pid_t);
     dlset(baton, CYHandleServer, "CYHandleServer", handle);
 
-    CYHandleServer(baton->pid);
+    if (CYHandleServer != NULL)
+        CYHandleServer(baton->pid);
 
     return NULL;
 }
@@ -78,23 +79,23 @@ extern "C" void Start(Baton *baton) {
     self.tsd[0] = &self;
     baton->__pthread_set_self(&self);
 
-    int (*pthread_create)(pthread_t *, const pthread_attr_t *, void *(*)(void *), void *);
-    dlset(baton, pthread_create, "pthread_create");
+    //int (*pthread_create)(pthread_t *, const pthread_attr_t *, void *(*)(void *), void *);
+    //dlset(baton, pthread_create, "pthread_create");
 
     pthread_t thread;
-    pthread_create(&thread, NULL, &Routine, baton);
+    baton->pthread_create(&thread, NULL, &Routine, baton);
 
-    int (*pthread_join)(pthread_t, void **);
-    dlset(baton, pthread_join, "pthread_join");
+    //int (*pthread_join)(pthread_t, void **);
+    //dlset(baton, pthread_join, "pthread_join");
 
-    void *result;
-    pthread_join(thread, &result);
+    //void *result;
+    //baton->pthread_join(thread, &result);
 
-    mach_port_t (*mach_thread_self)();
-    dlset(baton, mach_thread_self, "mach_thread_self");
+    //mach_port_t (*mach_thread_self)();
+    //dlset(baton, mach_thread_self, "mach_thread_self");
 
-    kern_return_t (*thread_terminate)(thread_act_t);
-    dlset(baton, thread_terminate, "thread_terminate");
+    //kern_return_t (*thread_terminate)(thread_act_t);
+    //dlset(baton, thread_terminate, "thread_terminate");
 
-    thread_terminate(mach_thread_self());
+    baton->thread_terminate(baton->mach_thread_self());
 }