+template <typename Type_>
+static _finline void cyset(Type_ &function, const char *name, const mach_header_xx *mach) {
+ function = reinterpret_cast<Type_>(Symbol(mach, name));
+}
+
+static _finline const mach_header_xx *Library(Baton *baton, const char *name) {
+ struct dyld_all_image_infos *infos(reinterpret_cast<struct dyld_all_image_infos *>(baton->dyld));
+ return Library(infos, name);
+}
+
+void *Routine(void *arg) {
+ Baton *baton(reinterpret_cast<Baton *>(arg));
+
+ const mach_header_xx *dyld(NULL);
+ if (dyld == NULL)
+ dyld = Library(baton, "/usr/lib/system/libdyld.dylib");
+ if (dyld == NULL)
+ dyld = Library(baton, "/usr/lib/libSystem.B.dylib");
+
+ char *(*$dlerror)();
+ cyset($dlerror, "_dlerror", dyld);
+
+ void *(*$dlopen)(const char *, int);
+ cyset($dlopen, "_dlopen", dyld);
+
+ void *handle($dlopen(baton->library, RTLD_LAZY | RTLD_LOCAL));
+ if (handle == NULL) {
+ $strlcpy(baton->error, $dlerror(), sizeof(baton->error));
+ return NULL;
+ }
+
+ void *(*$dlsym)(void *, const char *);
+ cyset($dlsym, "_dlsym", dyld);
+
+ void (*CYHandleServer)(pid_t, char *, size_t);
+ CYHandleServer = reinterpret_cast<void (*)(pid_t, char *, size_t)>($dlsym(handle, "CYHandleServer"));
+ if (CYHandleServer == NULL) {
+ $strlcpy(baton->error, $dlerror(), sizeof(baton->error));
+ return NULL;
+ }
+
+ CYHandleServer(baton->pid, baton->error, sizeof(baton->error));
+ return NULL;