]> git.saurik.com Git - cycript.git/blobdiff - Mach/Inject.cpp
Support having multiple language hooks registered.
[cycript.git] / Mach / Inject.cpp
index 6ca0378b85075411ac5d2d4591173b6c57003679..d109cddb243cd6fadba749791841f736066a18d7 100644 (file)
@@ -1,21 +1,21 @@
 /* Cycript - Optimizing JavaScript Compiler/Runtime
 /* Cycript - Optimizing JavaScript Compiler/Runtime
- * Copyright (C) 2009-2013  Jay Freeman (saurik)
+ * Copyright (C) 2009-2014  Jay Freeman (saurik)
 */
 
 */
 
-/* GNU General Public License, Version 3 {{{ */
+/* GNU Affero General Public License, Version 3 {{{ */
 /*
 /*
- * Cycript is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation, either version 3 of the License,
- * or (at your option) any later version.
- *
- * Cycript is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Cycript.  If not, see <http://www.gnu.org/licenses/>.
+ * GNU Affero General Public License for more details.
+
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 **/
 /* }}} */
 
 **/
 /* }}} */
 
@@ -58,7 +58,7 @@ void InjectLibrary(pid_t pid) {
     library[flength] = '\0';
     _assert(strcmp(library + flength - 6, ".dylib") == 0);
 #if !TARGET_OS_IPHONE
     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;
 #endif
 
     mach_port_t self(mach_task_self()), task;
@@ -292,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));
     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);
         CYThrow("%s", baton->error);
+    }
 
     _krncall(mach_vm_deallocate(task, code, trampoline->size_));
     _krncall(mach_vm_deallocate(task, stack, size));
 
     _krncall(mach_vm_deallocate(task, code, trampoline->size_));
     _krncall(mach_vm_deallocate(task, stack, size));