+ baton->dyld = info.all_image_info_addr;
+ baton->pid = getpid();
+ memcpy(baton->library, library, length);
+
+ mach_vm_size_t size(depth + Stack_);
+ mach_vm_address_t stack;
+ _krncall(mach_vm_allocate(task, &stack, size, true));
+
+ mach_vm_address_t data(stack + Stack_);
+ _krncall(mach_vm_write(task, data, reinterpret_cast<mach_vm_address_t>(baton), depth));
+
+ mach_vm_address_t code;
+ _krncall(mach_vm_allocate(task, &code, trampoline->size_, true));
+ _krncall(mach_vm_write(task, code, reinterpret_cast<mach_vm_address_t>(trampoline->data_), trampoline->size_));
+ _krncall(mach_vm_protect(task, code, trampoline->size_, false, VM_PROT_READ | VM_PROT_EXECUTE));
+
+ uint32_t frame[push];
+ if (sizeof(frame) != 0)
+ memset(frame, 0, sizeof(frame));
+
+#if defined(__i386__) || defined(__x86_64__)
+ switch (state.tsh.flavor) {
+ case i386_THREAD_STATE:
+ frame[1] = data;
+ state.uts.ts32.__eip = code + trampoline->entry_;
+ state.uts.ts32.__esp = stack + Stack_ - sizeof(frame);
+ break;
+ case x86_THREAD_STATE64:
+ state.uts.ts64.__rdi = data;
+ state.uts.ts64.__rip = code + trampoline->entry_;
+ state.uts.ts64.__rsp = stack + Stack_ - sizeof(frame);
+ break;
+ default:
+ _assert(false);
+ }
+#elif defined(__arm__)
+ state.__r[0] = data;
+ state.__pc = code + trampoline->entry_;
+ state.__sp = stack + Stack_ - sizeof(frame);
+
+ if ((state.__pc & 0x1) != 0) {
+ state.__pc &= ~0x1;
+ state.__cpsr |= 0x20;