1 /* Veency - VNC Remote Access Server for iPhoneOS
2 * Copyright (C) 2008-2012 Jay Freeman (saurik)
5 /* GNU Affero General Public License, Version 3 {{{ */
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 fprintf(stderr, "_trace()@%s:%u[%s]\n", __FILE__, __LINE__, __FUNCTION__)
24 #define _likely(expr) \
25 __builtin_expect(expr, 1)
26 #define _unlikely(expr) \
27 __builtin_expect(expr, 0)
29 #include <CydiaSubstrate.h>
32 #include <rfb/keysym.h>
34 #include <mach/mach_port.h>
36 #include <sys/sysctl.h>
38 #import <QuartzCore/CAWindowServer.h>
39 #import <QuartzCore/CAWindowServerDisplay.h>
41 #import <CoreGraphics/CGGeometry.h>
42 #import <GraphicsServices/GraphicsServices.h>
43 #import <Foundation/Foundation.h>
44 #import <IOMobileFramebuffer/IOMobileFramebuffer.h>
45 #import <IOKit/IOKitLib.h>
46 #import <UIKit/UIKit.h>
48 #import <SpringBoard/SBAlertItemsController.h>
49 #import <SpringBoard/SBDismissOnlyAlertItem.h>
50 #import <SpringBoard/SBStatusBarController.h>
52 #include "SpringBoardAccess.h"
54 extern "C" void CoreSurfaceBufferFlushProcessorCaches(CoreSurfaceBufferRef buffer);
57 static size_t height_;
58 static NSUInteger ratio_ = 0;
60 static const size_t BytesPerPixel = 4;
61 static const size_t BitsPerSample = 8;
63 static CoreSurfaceAcceleratorRef accelerator_;
64 static CoreSurfaceBufferRef buffer_;
65 static CFDictionaryRef options_;
67 static NSMutableSet *handlers_;
68 static rfbScreenInfoPtr screen_;
73 static unsigned clients_;
75 static CFMessagePortRef ashikase_;
78 static rfbPixel *black_;
80 static void VNCBlack() {
81 if (_unlikely(black_ == NULL))
82 black_ = reinterpret_cast<rfbPixel *>(mmap(NULL, sizeof(rfbPixel) * width_ * height_, PROT_READ, MAP_ANON | MAP_PRIVATE | MAP_NOCACHE, VM_FLAGS_PURGABLE, 0));
83 screen_->frameBuffer = reinterpret_cast<char *>(black_);
86 static bool Ashikase(bool always) {
87 if (!always && !cursor_)
90 if (ashikase_ == NULL)
91 ashikase_ = CFMessagePortCreateRemote(kCFAllocatorDefault, CFSTR("jp.ashikase.mousesupport"));
92 if (ashikase_ != NULL)
99 static CFDataRef cfTrue_;
100 static CFDataRef cfFalse_;
108 static MouseEvent event_;
109 static CFDataRef cfEvent_;
112 MouseMessageTypeEvent,
113 MouseMessageTypeSetEnabled
116 static void AshikaseSendEvent(float x, float y, int buttons = 0) {
119 event_.buttons = buttons;
120 event_.absolute = true;
122 CFMessagePortSendRequest(ashikase_, MouseMessageTypeEvent, cfEvent_, 0, 0, NULL, NULL);
125 static void AshikaseSetEnabled(bool enabled, bool always) {
126 if (!Ashikase(always))
129 CFMessagePortSendRequest(ashikase_, MouseMessageTypeSetEnabled, enabled ? cfTrue_ : cfFalse_, 0, 0, NULL, NULL);
132 AshikaseSendEvent(x_, y_);
135 MSClassHook(SBAlertItemsController)
136 MSClassHook(SBStatusBarController)
139 static Class $VNCAlertItem;
141 static rfbNewClientAction action_ = RFB_CLIENT_ON_HOLD;
142 static NSCondition *condition_;
143 static NSLock *lock_;
145 static rfbClientPtr client_;
147 static void VNCSetup();
148 static void VNCEnabled();
150 @interface VNCBridge : NSObject {
153 + (void) askForConnection;
154 + (void) removeStatusBarItem;
155 + (void) registerClient;
159 @implementation VNCBridge
161 + (void) askForConnection {
162 [[$SBAlertItemsController sharedInstance] activateAlertItem:[[[$VNCAlertItem alloc] init] autorelease]];
165 + (void) removeStatusBarItem {
166 AshikaseSetEnabled(false, false);
169 SBA_removeStatusBarImage(const_cast<char *>("Veency"));
170 else if ($SBStatusBarController != nil)
171 [[$SBStatusBarController sharedStatusBarController] removeStatusBarItem:@"Veency"];
172 else if (UIApplication *app = [UIApplication sharedApplication])
173 [app removeStatusBarImageNamed:@"Veency"];
176 + (void) registerClient {
177 // XXX: this could find a better home
179 UIScreen *screen([UIScreen mainScreen]);
180 if ([screen respondsToSelector:@selector(scale)])
181 ratio_ = [screen scale];
187 AshikaseSetEnabled(true, false);
190 SBA_addStatusBarImage(const_cast<char *>("Veency"));
191 else if ($SBStatusBarController != nil)
192 [[$SBStatusBarController sharedStatusBarController] addStatusBarItem:@"Veency"];
193 else if (UIApplication *app = [UIApplication sharedApplication])
194 [app addStatusBarImageNamed:@"Veency"];
197 + (void) performSetup:(NSThread *)thread {
198 NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
199 [thread autorelease];
207 MSInstanceMessage2(void, VNCAlertItem, alertSheet,buttonClicked, id, sheet, int, button) {
212 action_ = RFB_CLIENT_ACCEPT;
214 @synchronized (condition_) {
215 [VNCBridge registerClient];
220 action_ = RFB_CLIENT_REFUSE;
229 MSInstanceMessage2(void, VNCAlertItem, configure,requirePasscodeForActions, BOOL, configure, BOOL, require) {
230 UIModalView *sheet([self alertSheet]);
231 [sheet setDelegate:self];
232 [sheet setTitle:@"Remote Access Request"];
233 [sheet setBodyText:[NSString stringWithFormat:@"Accept connection from\n%s?\n\nVeency VNC Server\nby Jay Freeman (saurik)\nsaurik@saurik.com\nhttp://www.saurik.com/\n\nSet a VNC password in Settings!", client_->host]];
234 [sheet addButtonWithTitle:@"Accept"];
235 [sheet addButtonWithTitle:@"Reject"];
238 MSInstanceMessage0(void, VNCAlertItem, performUnlockAction) {
239 [[$SBAlertItemsController sharedInstance] activateAlertItem:self];
242 static mach_port_t (*GSTakePurpleSystemEventPort)(void);
243 static bool PurpleAllocated;
246 static void FixRecord(GSEventRecord *record) {
248 memmove(&record->windowContextId, &record->windowContextId + 1, sizeof(*record) - (reinterpret_cast<uint8_t *>(&record->windowContextId + 1) - reinterpret_cast<uint8_t *>(record)) + record->size);
251 static void VNCSettings() {
252 NSDictionary *settings([NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/Library/Preferences/com.saurik.Veency.plist", NSHomeDirectory()]]);
254 @synchronized (lock_) {
255 for (NSValue *handler in handlers_)
256 rfbUnregisterSecurityHandler(reinterpret_cast<rfbSecurityHandler *>([handler pointerValue]));
257 [handlers_ removeAllObjects];
260 @synchronized (condition_) {
264 [reinterpret_cast<NSString *>(screen_->authPasswdData) release];
265 screen_->authPasswdData = NULL;
268 if (NSString *password = [settings objectForKey:@"Password"])
269 if ([password length] != 0)
270 screen_->authPasswdData = [password retain];
272 NSNumber *cursor = [settings objectForKey:@"ShowCursor"];
273 cursor_ = cursor == nil ? true : [cursor boolValue];
276 AshikaseSetEnabled(cursor_, true);
280 static void VNCNotifySettings(
281 CFNotificationCenterRef center,
290 static rfbBool VNCCheck(rfbClientPtr client, const char *data, int size) {
291 @synchronized (condition_) {
292 if (NSString *password = reinterpret_cast<NSString *>(screen_->authPasswdData)) {
293 NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
294 rfbEncryptBytes(client->authChallenge, const_cast<char *>([password UTF8String]));
295 bool good(memcmp(client->authChallenge, data, size) == 0);
305 struct GSEventRecord record;
307 struct GSEventRecordInfo info;
308 struct GSPathInfo path;
312 static void VNCPointer(int buttons, int x, int y, rfbClientPtr client) {
316 CGPoint location = {x, y};
318 if (width_ > height_) {
333 int diff = buttons_ ^ buttons;
334 bool twas((buttons_ & 0x1) != 0);
335 bool tis((buttons & 0x1) != 0);
338 rfbDefaultPtrAddEvent(buttons, x, y, client);
340 if (Ashikase(false)) {
341 AshikaseSendEvent(x, y, buttons);
345 mach_port_t purple(0);
347 if ((diff & 0x10) != 0) {
348 struct GSEventRecord record;
350 memset(&record, 0, sizeof(record));
352 record.type = (buttons & 0x10) != 0 ?
353 GSEventTypeHeadsetButtonDown :
354 GSEventTypeHeadsetButtonUp;
356 record.timestamp = GSCurrentEventTimestamp();
359 GSSendSystemEvent(&record);
362 if ((diff & 0x04) != 0) {
363 struct GSEventRecord record;
365 memset(&record, 0, sizeof(record));
367 record.type = (buttons & 0x04) != 0 ?
368 GSEventTypeMenuButtonDown :
369 GSEventTypeMenuButtonUp;
371 record.timestamp = GSCurrentEventTimestamp();
374 GSSendSystemEvent(&record);
377 if ((diff & 0x02) != 0) {
378 struct GSEventRecord record;
380 memset(&record, 0, sizeof(record));
382 record.type = (buttons & 0x02) != 0 ?
383 GSEventTypeLockButtonDown :
384 GSEventTypeLockButtonUp;
386 record.timestamp = GSCurrentEventTimestamp();
389 GSSendSystemEvent(&record);
392 if (twas != tis || tis) {
393 struct VeencyEvent event;
395 memset(&event, 0, sizeof(event));
397 event.record.type = GSEventTypeMouse;
398 event.record.locationInWindow.x = x;
399 event.record.locationInWindow.y = y;
400 event.record.timestamp = GSCurrentEventTimestamp();
401 event.record.size = sizeof(event.data);
403 event.data.info.handInfo.type = twas == tis ?
404 GSMouseEventTypeDragged :
406 GSMouseEventTypeDown :
409 event.data.info.handInfo.x34 = 0x1;
410 event.data.info.handInfo.x38 = tis ? 0x1 : 0x0;
413 event.data.info.pathPositions = 1;
415 event.data.info.x52 = 1;
417 event.data.path.x00 = 0x01;
418 event.data.path.x01 = 0x02;
419 event.data.path.x02 = tis ? 0x03 : 0x00;
420 event.data.path.position = event.record.locationInWindow;
424 if (CAWindowServer *server = [CAWindowServer serverIfRunning]) {
425 NSArray *displays([server displays]);
426 if (displays != nil && [displays count] != 0)
427 if (CAWindowServerDisplay *display = [displays objectAtIndex:0])
428 port = [display clientPortAtPosition:location];
433 purple = (*GSTakePurpleSystemEventPort)();
437 FixRecord(&event.record);
438 GSSendEvent(&event.record, port);
441 if (purple != 0 && PurpleAllocated)
442 mach_port_deallocate(mach_task_self(), purple);
445 GSEventRef (*$GSEventCreateKeyEvent)(int, CGPoint, CFStringRef, CFStringRef, id, UniChar, short, short);
446 GSEventRef (*$GSCreateSyntheticKeyEvent)(UniChar, BOOL, BOOL);
448 static void VNCKeyboard(rfbBool down, rfbKeySym key, rfbClientPtr client) {
453 case XK_Return: key = '\r'; break;
454 case XK_BackSpace: key = 0x7f; break;
460 CGPoint point(CGPointMake(x_, y_));
462 UniChar unicode(key);
463 CFStringRef string(NULL);
465 GSEventRef event0, event1(NULL);
466 if ($GSEventCreateKeyEvent != NULL) {
467 string = CFStringCreateWithCharacters(kCFAllocatorDefault, &unicode, 1);
468 event0 = (*$GSEventCreateKeyEvent)(10, point, string, string, nil, 0, 0, 1);
469 event1 = (*$GSEventCreateKeyEvent)(11, point, string, string, nil, 0, 0, 1);
470 } else if ($GSCreateSyntheticKeyEvent != NULL) {
471 event0 = (*$GSCreateSyntheticKeyEvent)(unicode, YES, YES);
472 GSEventRecord *record(_GSEventGetGSEventRecord(event0));
473 record->type = GSEventTypeKeyDown;
478 if (CAWindowServer *server = [CAWindowServer serverIfRunning]) {
479 NSArray *displays([server displays]);
480 if (displays != nil && [displays count] != 0)
481 if (CAWindowServerDisplay *display = [displays objectAtIndex:0])
482 port = [display clientPortAtPosition:point];
485 mach_port_t purple(0);
489 purple = (*GSTakePurpleSystemEventPort)();
494 GSSendEvent(_GSEventGetGSEventRecord(event0), port);
496 GSSendEvent(_GSEventGetGSEventRecord(event1), port);
499 if (purple != 0 && PurpleAllocated)
500 mach_port_deallocate(mach_task_self(), purple);
509 static void VNCDisconnect(rfbClientPtr client) {
510 @synchronized (condition_) {
512 [VNCBridge performSelectorOnMainThread:@selector(removeStatusBarItem) withObject:nil waitUntilDone:YES];
516 static rfbNewClientAction VNCClient(rfbClientPtr client) {
517 @synchronized (condition_) {
518 if (screen_->authPasswdData != NULL) {
519 [VNCBridge performSelectorOnMainThread:@selector(registerClient) withObject:nil waitUntilDone:YES];
520 client->clientGoneHook = &VNCDisconnect;
521 return RFB_CLIENT_ACCEPT;
527 [VNCBridge performSelectorOnMainThread:@selector(askForConnection) withObject:nil waitUntilDone:NO];
528 while (action_ == RFB_CLIENT_ON_HOLD)
530 rfbNewClientAction action(action_);
531 action_ = RFB_CLIENT_ON_HOLD;
534 if (action == RFB_CLIENT_ACCEPT)
535 client->clientGoneHook = &VNCDisconnect;
539 extern "C" bool GSSystemHasCapability(NSString *);
541 static CFTypeRef (*$GSSystemCopyCapability)(CFStringRef);
542 static CFTypeRef (*$GSSystemGetCapability)(CFStringRef);
544 static void VNCSetup() {
547 @synchronized (condition_) {
549 char *arg0(strdup("VNCServer"));
550 char *argv[] = {arg0, NULL};
551 screen_ = rfbGetScreen(&argc, argv, width_, height_, BitsPerSample, 3, BytesPerPixel);
557 screen_->desktopName = strdup([[[NSProcessInfo processInfo] hostName] UTF8String]);
559 screen_->alwaysShared = TRUE;
560 screen_->handleEventsEagerly = TRUE;
561 screen_->deferUpdateTime = 1000 / 25;
563 screen_->serverFormat.redShift = BitsPerSample * 2;
564 screen_->serverFormat.greenShift = BitsPerSample * 1;
565 screen_->serverFormat.blueShift = BitsPerSample * 0;
567 $GSSystemCopyCapability = reinterpret_cast<CFTypeRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemCopyCapability"));
568 $GSSystemGetCapability = reinterpret_cast<CFTypeRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemGetCapability"));
572 if ($GSSystemCopyCapability != NULL) {
573 opengles2 = (*$GSSystemCopyCapability)(CFSTR("opengles-2"));
574 } else if ($GSSystemGetCapability != NULL) {
575 opengles2 = (*$GSSystemGetCapability)(CFSTR("opengles-2"));
576 if (opengles2 != NULL)
581 bool accelerated(opengles2 != NULL && [(NSNumber *)opengles2 boolValue]);
584 CoreSurfaceAcceleratorCreate(NULL, NULL, &accelerator_);
586 if (opengles2 != NULL)
587 CFRelease(opengles2);
589 if (accelerator_ != NULL)
590 buffer_ = CoreSurfaceBufferCreate((CFDictionaryRef) [NSDictionary dictionaryWithObjectsAndKeys:
591 @"PurpleEDRAM", kCoreSurfaceBufferMemoryRegion,
592 [NSNumber numberWithBool:YES], kCoreSurfaceBufferGlobal,
593 [NSNumber numberWithInt:(width_ * BytesPerPixel)], kCoreSurfaceBufferPitch,
594 [NSNumber numberWithInt:width_], kCoreSurfaceBufferWidth,
595 [NSNumber numberWithInt:height_], kCoreSurfaceBufferHeight,
596 [NSNumber numberWithInt:'BGRA'], kCoreSurfaceBufferPixelFormat,
597 [NSNumber numberWithInt:(width_ * height_ * BytesPerPixel)], kCoreSurfaceBufferAllocSize,
602 //screen_->frameBuffer = reinterpret_cast<char *>(mmap(NULL, sizeof(rfbPixel) * width_ * height_, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_NOCACHE, VM_FLAGS_PURGABLE, 0));
604 CoreSurfaceBufferLock(buffer_, 3);
605 screen_->frameBuffer = reinterpret_cast<char *>(CoreSurfaceBufferGetBaseAddress(buffer_));
606 CoreSurfaceBufferUnlock(buffer_);
608 screen_->kbdAddEvent = &VNCKeyboard;
609 screen_->ptrAddEvent = &VNCPointer;
611 screen_->newClientHook = &VNCClient;
612 screen_->passwordCheck = &VNCCheck;
614 screen_->cursor = NULL;
617 static void VNCEnabled() {
621 if (NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/Library/Preferences/com.saurik.Veency.plist", NSHomeDirectory()]])
622 if (NSNumber *number = [settings objectForKey:@"Enabled"])
623 enabled = [number boolValue];
625 if (enabled != running_)
628 screen_->socketState = RFB_SOCKET_INIT;
629 rfbInitServer(screen_);
630 rfbRunEventLoop(screen_, -1, true);
632 rfbShutdownServer(screen_, true);
639 static void VNCNotifyEnabled(
640 CFNotificationCenterRef center,
649 void (*$IOMobileFramebufferIsMainDisplay)(IOMobileFramebufferRef, int *);
651 static IOMobileFramebufferRef main_;
652 static CoreSurfaceBufferRef layer_;
654 static void OnLayer(IOMobileFramebufferRef fb, CoreSurfaceBufferRef layer) {
655 if (_unlikely(width_ == 0 || height_ == 0)) {
657 IOMobileFramebufferGetDisplaySize(fb, &size);
660 height_ = size.height;
662 if (width_ == 0 || height_ == 0)
665 NSThread *thread([NSThread alloc]);
668 initWithTarget:[VNCBridge class]
669 selector:@selector(performSetup:)
674 } else if (_unlikely(clients_ != 0)) {
676 if (accelerator_ != NULL)
677 memset(screen_->frameBuffer, 0, sizeof(rfbPixel) * width_ * height_);
681 if (accelerator_ != NULL)
682 CoreSurfaceAcceleratorTransferSurface(accelerator_, layer, buffer_, options_);
684 CoreSurfaceBufferLock(layer, 2);
685 rfbPixel *data(reinterpret_cast<rfbPixel *>(CoreSurfaceBufferGetBaseAddress(layer)));
687 CoreSurfaceBufferFlushProcessorCaches(layer);
689 /*rfbPixel corner(data[0]);
693 screen_->frameBuffer = const_cast<char *>(reinterpret_cast<volatile char *>(data));
694 CoreSurfaceBufferUnlock(layer);
698 rfbMarkRectAsModified(screen_, 0, 0, width_, height_);
702 static bool wait_ = false;
704 MSHook(kern_return_t, IOMobileFramebufferSwapSetLayer,
705 IOMobileFramebufferRef fb,
707 CoreSurfaceBufferRef buffer,
714 if (_unlikely(buffer == NULL))
716 else if (_unlikely(fb == NULL))
718 else if ($IOMobileFramebufferIsMainDisplay == NULL)
721 (*$IOMobileFramebufferIsMainDisplay)(fb, &main);
731 return _IOMobileFramebufferSwapSetLayer(fb, layer, buffer, bounds, frame, flags);
734 // XXX: beg rpetrich for the type of this function
735 extern "C" void *IOMobileFramebufferSwapWait(IOMobileFramebufferRef, void *, unsigned);
737 MSHook(void *, IOMobileFramebufferSwapWait, IOMobileFramebufferRef fb, void *arg1, unsigned flags) {
738 void *value(_IOMobileFramebufferSwapWait(fb, arg1, flags));
744 MSHook(void, rfbRegisterSecurityHandler, rfbSecurityHandler *handler) {
745 NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
747 @synchronized (lock_) {
748 [handlers_ addObject:[NSValue valueWithPointer:handler]];
749 _rfbRegisterSecurityHandler(handler);
755 template <typename Type_>
756 static void dlset(Type_ &function, const char *name) {
757 function = reinterpret_cast<Type_>(dlsym(RTLD_DEFAULT, name));
761 NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
763 MSHookSymbol(GSTakePurpleSystemEventPort, "_GSGetPurpleSystemEventPort");
764 if (GSTakePurpleSystemEventPort == NULL) {
765 MSHookSymbol(GSTakePurpleSystemEventPort, "_GSCopyPurpleSystemEventPort");
766 PurpleAllocated = true;
769 if (dlsym(RTLD_DEFAULT, "GSLibraryCopyGenerationInfoValueForKey") != NULL)
771 else if (dlsym(RTLD_DEFAULT, "GSKeyboardCreate") != NULL)
773 else if (dlsym(RTLD_DEFAULT, "GSEventGetWindowContextId") != NULL)
779 sysctlbyname("hw.machine", NULL, &size, NULL, 0);
781 sysctlbyname("hw.machine", machine, &size, NULL, 0);
782 iPad1_ = strcmp(machine, "iPad1,1") == 0;
784 dlset($GSEventCreateKeyEvent, "GSEventCreateKeyEvent");
785 dlset($GSCreateSyntheticKeyEvent, "_GSCreateSyntheticKeyEvent");
786 dlset($IOMobileFramebufferIsMainDisplay, "IOMobileFramebufferIsMainDisplay");
788 MSHookFunction(&IOMobileFramebufferSwapSetLayer, MSHake(IOMobileFramebufferSwapSetLayer));
789 MSHookFunction(&rfbRegisterSecurityHandler, MSHake(rfbRegisterSecurityHandler));
792 MSHookFunction(&IOMobileFramebufferSwapWait, MSHake(IOMobileFramebufferSwapWait));
794 $VNCAlertItem = objc_allocateClassPair(objc_getClass("SBAlertItem"), "VNCAlertItem", 0);
795 MSAddMessage2(VNCAlertItem, "v@:@i", alertSheet,buttonClicked);
796 MSAddMessage2(VNCAlertItem, "v@:cc", configure,requirePasscodeForActions);
797 MSAddMessage0(VNCAlertItem, "v@:", performUnlockAction);
798 objc_registerClassPair($VNCAlertItem);
800 CFNotificationCenterAddObserver(
801 CFNotificationCenterGetDarwinNotifyCenter(),
802 NULL, &VNCNotifyEnabled, CFSTR("com.saurik.Veency-Enabled"), NULL, 0
805 CFNotificationCenterAddObserver(
806 CFNotificationCenterGetDarwinNotifyCenter(),
807 NULL, &VNCNotifySettings, CFSTR("com.saurik.Veency-Settings"), NULL, 0
810 condition_ = [[NSCondition alloc] init];
811 lock_ = [[NSLock alloc] init];
812 handlers_ = [[NSMutableSet alloc] init];
817 cfTrue_ = CFDataCreate(kCFAllocatorDefault, reinterpret_cast<UInt8 *>(&value), sizeof(value));
820 cfFalse_ = CFDataCreate(kCFAllocatorDefault, reinterpret_cast<UInt8 *>(&value), sizeof(value));
822 cfEvent_ = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<UInt8 *>(&event_), sizeof(event_), kCFAllocatorNull);
824 options_ = (CFDictionaryRef) [[NSDictionary dictionaryWithObjectsAndKeys: