]> git.saurik.com Git - cycript.git/blobdiff - Mach/Inject.cpp
Finish new build environment, relocatable objects.
[cycript.git] / Mach / Inject.cpp
index 74e5b308ec0579da634f2cd40fc206501f56a92c..feb2c3c7cb6c696b848a06dd61fb63ff059c9d7b 100644 (file)
@@ -53,7 +53,13 @@ extern "C" void CYHandleServer(pid_t);
 void InjectLibrary(pid_t pid) {
     Dl_info addr;
     _assert(dladdr(reinterpret_cast<void *>(&CYHandleServer), &addr) != 0);
 void InjectLibrary(pid_t pid) {
     Dl_info addr;
     _assert(dladdr(reinterpret_cast<void *>(&CYHandleServer), &addr) != 0);
-    const char *library(addr.dli_fname);
+
+    size_t flength(strlen(addr.dli_fname));
+    char library[flength + 4 + 1];
+    memcpy(library, addr.dli_fname, flength);
+    library[flength] = '\0';
+    _assert(strcmp(library + flength - 6, ".dylib") == 0);
+    strcpy(library + flength - 6, "-any.dylib");
 
     mach_port_t self(mach_task_self()), task;
     _krncall(task_for_pid(self, pid, &task));
 
     mach_port_t self(mach_task_self()), task;
     _krncall(task_for_pid(self, pid, &task));