]> git.saurik.com Git - cycript.git/blobdiff - Mach/Inject.cpp
Add an empty Execute.cpp for Java support backend.
[cycript.git] / Mach / Inject.cpp
index c70e83cc9c7432a90a66bcf0b2f291f92d622d41..a017a5bf7cecc256b54235511a370a1d75d6286e 100644 (file)
@@ -58,7 +58,7 @@ void InjectLibrary(pid_t pid) {
     library[flength] = '\0';
     _assert(strcmp(library + flength - 6, ".dylib") == 0);
 #if !TARGET_OS_IPHONE
-    strcpy(library + flength - 6, "-any.dylib");
+    strcpy(library + flength - 6, "-###.dylib");
 #endif
 
     mach_port_t self(mach_task_self()), task;
@@ -207,6 +207,7 @@ void InjectLibrary(pid_t pid) {
 
     baton->dyld = info.all_image_info_addr;
     baton->pid = getpid();
+    memset(baton->error, 0, sizeof(baton->error));
     memcpy(baton->library, library, length);
 
     mach_vm_size_t size(depth + Stack_);
@@ -291,8 +292,11 @@ void InjectLibrary(pid_t pid) {
     mach_vm_size_t error(sizeof(baton->error));
     _krncall(mach_vm_read_overwrite(task, data + offsetof(Baton, error), sizeof(baton->error), reinterpret_cast<mach_vm_address_t>(&baton->error), &error));
     _assert(error == sizeof(baton->error));
-    if (baton->error[0] != '\0')
+
+    if (baton->error[0] != '\0') {
+        baton->error[sizeof(baton->error) - 1] = '\0';
         CYThrow("%s", baton->error);
+    }
 
     _krncall(mach_vm_deallocate(task, code, trampoline->size_));
     _krncall(mach_vm_deallocate(task, stack, size));