]> git.saurik.com Git - cycript.git/blobdiff - Mach/Inject.cpp
Drop -sys distinction and stabilize Xcode build.
[cycript.git] / Mach / Inject.cpp
index c629939610469954275a80094e52b64bbc226fe6..46f61be2459a34cec03763f003f6650180b3e4ca 100644 (file)
 #include <dlfcn.h>
 
 #include <mach/mach.h>
+
+#ifdef __APPLE__
+#include "TargetConditionals.h"
+#endif
+
+#ifdef TARGET_OS_IPHONE
+#include <mach/vm_map.h>
+#define mach_vm_allocate vm_allocate
+#define mach_vm_protect vm_protect
+#define mach_vm_write vm_write
+#define mach_vm_address_t vm_address_t
+#else
 #include <mach/mach_vm.h>
+#endif
 
 #include <mach/machine/thread_status.h>
 
 #include "Pooling.hpp"
 #include "Trampoline.t.hpp"
 
+extern "C" void CYHandleServer(pid_t);
+
 void InjectLibrary(pid_t pid) {
-    const char *library(CY_LIBRARY);
+    Dl_info addr;
+    _assert(dladdr(reinterpret_cast<void *>(&CYHandleServer), &addr) != 0);
+    const char *library(addr.dli_fname);
 
     mach_port_t self(mach_task_self()), task;
     _krncall(task_for_pid(self, pid, &task));