]> git.saurik.com Git - veency.git/blob - Tweak.mm
d2a10d2776dcc53bb74e06236917e7a0824af56b
[veency.git] / Tweak.mm
1 /* Veency - VNC Remote Access Server for iPhoneOS
2 * Copyright (C) 2008-2010 Jay Freeman (saurik)
3 */
4
5 /*
6 * Redistribution and use in source and binary
7 * forms, with or without modification, are permitted
8 * provided that the following conditions are met:
9 *
10 * 1. Redistributions of source code must retain the
11 * above copyright notice, this list of conditions
12 * and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the
14 * above copyright notice, this list of conditions
15 * and the following disclaimer in the documentation
16 * and/or other materials provided with the
17 * distribution.
18 * 3. The name of the author may not be used to endorse
19 * or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS''
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
24 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
33 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
35 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38 #define _trace() \
39 fprintf(stderr, "_trace()@%s:%u[%s]\n", __FILE__, __LINE__, __FUNCTION__)
40 #define _unlikely(expr) \
41 __builtin_expect(expr, 0)
42
43 #include <substrate.h>
44
45 #include <rfb/rfb.h>
46 #include <rfb/keysym.h>
47
48 #include <mach/mach_port.h>
49 #include <sys/mman.h>
50
51 #import <QuartzCore/CAWindowServer.h>
52 #import <QuartzCore/CAWindowServerDisplay.h>
53
54 #import <CoreGraphics/CGGeometry.h>
55 #import <GraphicsServices/GraphicsServices.h>
56 #import <Foundation/Foundation.h>
57 #import <IOMobileFramebuffer/IOMobileFramebuffer.h>
58 #import <IOKit/IOKitLib.h>
59 #import <UIKit/UIKit.h>
60
61 #import <SpringBoard/SBAlertItemsController.h>
62 #import <SpringBoard/SBDismissOnlyAlertItem.h>
63 #import <SpringBoard/SBStatusBarController.h>
64
65 extern "C" void CoreSurfaceBufferFlushProcessorCaches(CoreSurfaceBufferRef buffer);
66
67 static size_t width_;
68 static size_t height_;
69
70 static const size_t BytesPerPixel = 4;
71 static const size_t BitsPerSample = 8;
72
73 static CoreSurfaceAcceleratorRef accelerator_;
74 static CoreSurfaceBufferRef buffer_;
75 static CFDictionaryRef options_;
76
77 static NSMutableSet *handlers_;
78 static rfbScreenInfoPtr screen_;
79 static bool running_;
80 static int buttons_;
81 static int x_, y_;
82
83 static unsigned clients_;
84
85 static CFMessagePortRef ashikase_;
86 static bool cursor_;
87
88 static bool Ashikase(bool always) {
89 if (!always && !cursor_)
90 return false;
91
92 if (ashikase_ == NULL)
93 ashikase_ = CFMessagePortCreateRemote(kCFAllocatorDefault, CFSTR("jp.ashikase.mousesupport"));
94 if (ashikase_ != NULL)
95 return true;
96
97 cursor_ = false;
98 return false;
99 }
100
101 static CFDataRef cfTrue_;
102 static CFDataRef cfFalse_;
103
104 typedef struct {
105 float x, y;
106 int buttons;
107 BOOL absolute;
108 } MouseEvent;
109
110 static MouseEvent event_;
111 static CFDataRef cfEvent_;
112
113 typedef enum {
114 MouseMessageTypeEvent,
115 MouseMessageTypeSetEnabled
116 } MouseMessageType;
117
118 static void AshikaseSendEvent(float x, float y, int buttons = 0) {
119 event_.x = x;
120 event_.y = y;
121 event_.buttons = buttons;
122 event_.absolute = true;
123
124 CFMessagePortSendRequest(ashikase_, MouseMessageTypeEvent, cfEvent_, 0, 0, NULL, NULL);
125 }
126
127 static void AshikaseSetEnabled(bool enabled, bool always) {
128 if (!Ashikase(always))
129 return;
130
131 CFMessagePortSendRequest(ashikase_, MouseMessageTypeSetEnabled, enabled ? cfTrue_ : cfFalse_, 0, 0, NULL, NULL);
132
133 if (enabled)
134 AshikaseSendEvent(x_, y_);
135 }
136
137 MSClassHook(SBAlertItemsController)
138 MSClassHook(SBStatusBarController)
139
140 @class VNCAlertItem;
141 static Class $VNCAlertItem;
142
143 static rfbNewClientAction action_ = RFB_CLIENT_ON_HOLD;
144 static NSCondition *condition_;
145 static NSLock *lock_;
146
147 static rfbClientPtr client_;
148
149 @interface VNCBridge : NSObject {
150 }
151
152 + (void) askForConnection;
153 + (void) removeStatusBarItem;
154 + (void) registerClient;
155
156 @end
157
158 @implementation VNCBridge
159
160 + (void) askForConnection {
161 [[$SBAlertItemsController sharedInstance] activateAlertItem:[[[$VNCAlertItem alloc] init] autorelease]];
162 }
163
164 + (void) removeStatusBarItem {
165 AshikaseSetEnabled(false, false);
166 [[$SBStatusBarController sharedStatusBarController] removeStatusBarItem:@"Veency"];
167 }
168
169 + (void) registerClient {
170 ++clients_;
171 AshikaseSetEnabled(true, false);
172 [[$SBStatusBarController sharedStatusBarController] addStatusBarItem:@"Veency"];
173 }
174
175 @end
176
177 MSInstanceMessage2(void, VNCAlertItem, alertSheet,buttonClicked, id, sheet, int, button) {
178 [condition_ lock];
179
180 switch (button) {
181 case 1:
182 action_ = RFB_CLIENT_ACCEPT;
183
184 @synchronized (condition_) {
185 [VNCBridge registerClient];
186 }
187 break;
188
189 case 2:
190 action_ = RFB_CLIENT_REFUSE;
191 break;
192 }
193
194 [condition_ signal];
195 [condition_ unlock];
196 [self dismiss];
197 }
198
199 MSInstanceMessage2(void, VNCAlertItem, configure,requirePasscodeForActions, BOOL, configure, BOOL, require) {
200 UIModalView *sheet([self alertSheet]);
201 [sheet setDelegate:self];
202 [sheet setTitle:@"Remote Access Request"];
203 [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]];
204 [sheet addButtonWithTitle:@"Accept"];
205 [sheet addButtonWithTitle:@"Reject"];
206 }
207
208 MSInstanceMessage0(void, VNCAlertItem, performUnlockAction) {
209 [[$SBAlertItemsController sharedInstance] activateAlertItem:self];
210 }
211
212 static mach_port_t (*GSTakePurpleSystemEventPort)(void);
213 static bool PurpleAllocated;
214 static int Level_;
215
216 static void FixRecord(GSEventRecord *record) {
217 if (Level_ < 1)
218 memmove(&record->windowContextId, &record->windowContextId + 1, sizeof(*record) - (reinterpret_cast<uint8_t *>(&record->windowContextId + 1) - reinterpret_cast<uint8_t *>(record)) + record->size);
219 }
220
221 static void VNCSettings() {
222 NSDictionary *settings([NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/Library/Preferences/com.saurik.Veency.plist", NSHomeDirectory()]]);
223
224 @synchronized (lock_) {
225 for (NSValue *handler in handlers_)
226 rfbUnregisterSecurityHandler(reinterpret_cast<rfbSecurityHandler *>([handler pointerValue]));
227 [handlers_ removeAllObjects];
228 }
229
230 @synchronized (condition_) {
231 if (screen_ == NULL)
232 return;
233
234 [reinterpret_cast<NSString *>(screen_->authPasswdData) release];
235 screen_->authPasswdData = NULL;
236
237 if (settings != nil)
238 if (NSString *password = [settings objectForKey:@"Password"])
239 if ([password length] != 0)
240 screen_->authPasswdData = [password retain];
241
242 NSNumber *cursor = [settings objectForKey:@"ShowCursor"];
243 cursor_ = cursor == nil ? true : [cursor boolValue];
244
245 if (clients_ != 0)
246 AshikaseSetEnabled(cursor_, true);
247 }
248 }
249
250 static void VNCNotifySettings(
251 CFNotificationCenterRef center,
252 void *observer,
253 CFStringRef name,
254 const void *object,
255 CFDictionaryRef info
256 ) {
257 VNCSettings();
258 }
259
260 static rfbBool VNCCheck(rfbClientPtr client, const char *data, int size) {
261 @synchronized (condition_) {
262 if (NSString *password = reinterpret_cast<NSString *>(screen_->authPasswdData)) {
263 NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
264 rfbEncryptBytes(client->authChallenge, const_cast<char *>([password UTF8String]));
265 bool good(memcmp(client->authChallenge, data, size) == 0);
266 [pool release];
267 return good;
268 } return TRUE;
269 }
270 }
271
272 static void VNCPointer(int buttons, int x, int y, rfbClientPtr client) {
273 if (Level_ == 2) {
274 int t(x);
275 x = height_ - 1 - y;
276 y = t;
277 }
278
279 x_ = x; y_ = y;
280 int diff = buttons_ ^ buttons;
281 bool twas((buttons_ & 0x1) != 0);
282 bool tis((buttons & 0x1) != 0);
283 buttons_ = buttons;
284
285 rfbDefaultPtrAddEvent(buttons, x, y, client);
286
287 if (Ashikase(false)) {
288 AshikaseSendEvent(x, y, buttons);
289 return;
290 }
291
292 mach_port_t purple(0);
293
294 if ((diff & 0x10) != 0) {
295 struct GSEventRecord record;
296
297 memset(&record, 0, sizeof(record));
298
299 record.type = (buttons & 0x4) != 0 ?
300 GSEventTypeHeadsetButtonDown :
301 GSEventTypeHeadsetButtonUp;
302
303 record.timestamp = GSCurrentEventTimestamp();
304
305 FixRecord(&record);
306 GSSendSystemEvent(&record);
307 }
308
309 if ((diff & 0x04) != 0) {
310 struct GSEventRecord record;
311
312 memset(&record, 0, sizeof(record));
313
314 record.type = (buttons & 0x4) != 0 ?
315 GSEventTypeMenuButtonDown :
316 GSEventTypeMenuButtonUp;
317
318 record.timestamp = GSCurrentEventTimestamp();
319
320 FixRecord(&record);
321 GSSendSystemEvent(&record);
322 }
323
324 if ((diff & 0x02) != 0) {
325 struct GSEventRecord record;
326
327 memset(&record, 0, sizeof(record));
328
329 record.type = (buttons & 0x2) != 0 ?
330 GSEventTypeLockButtonDown :
331 GSEventTypeLockButtonUp;
332
333 record.timestamp = GSCurrentEventTimestamp();
334
335 FixRecord(&record);
336 GSSendSystemEvent(&record);
337 }
338
339 if (twas != tis || tis) {
340 struct {
341 struct GSEventRecord record;
342 struct {
343 struct GSEventRecordInfo info;
344 struct GSPathInfo path;
345 } data;
346 } event;
347
348 memset(&event, 0, sizeof(event));
349
350 event.record.type = GSEventTypeMouse;
351 event.record.locationInWindow.x = x;
352 event.record.locationInWindow.y = y;
353 event.record.timestamp = GSCurrentEventTimestamp();
354 event.record.size = sizeof(event.data);
355
356 event.data.info.handInfo.type = twas == tis ?
357 GSMouseEventTypeDragged :
358 tis ?
359 GSMouseEventTypeDown :
360 GSMouseEventTypeUp;
361
362 event.data.info.handInfo.x34 = 0x1;
363 event.data.info.handInfo.x38 = tis ? 0x1 : 0x0;
364
365 event.data.info.pathPositions = 1;
366
367 event.data.path.x00 = 0x01;
368 event.data.path.x01 = 0x02;
369 event.data.path.x02 = tis ? 0x03 : 0x00;
370 event.data.path.position = event.record.locationInWindow;
371
372 mach_port_t port(0);
373
374 if (CAWindowServer *server = [CAWindowServer serverIfRunning]) {
375 NSArray *displays([server displays]);
376 if (displays != nil && [displays count] != 0)
377 if (CAWindowServerDisplay *display = [displays objectAtIndex:0])
378 port = [display clientPortAtPosition:event.record.locationInWindow];
379 }
380
381 if (port == 0) {
382 if (purple == 0)
383 purple = (*GSTakePurpleSystemEventPort)();
384 port = purple;
385 }
386
387 FixRecord(&event.record);
388 GSSendEvent(&event.record, port);
389 }
390
391 if (purple != 0 && PurpleAllocated)
392 mach_port_deallocate(mach_task_self(), purple);
393 }
394
395 static void VNCKeyboard(rfbBool down, rfbKeySym key, rfbClientPtr client) {
396 if (!down)
397 return;
398
399 switch (key) {
400 case XK_Return: key = '\r'; break;
401 case XK_BackSpace: key = 0x7f; break;
402 }
403
404 if (key > 0xfff)
405 return;
406
407 GSEventRef event(_GSCreateSyntheticKeyEvent(key, YES, YES));
408 GSEventRecord *record(_GSEventGetGSEventRecord(event));
409 record->type = GSEventTypeKeyDown;
410
411 mach_port_t port(0);
412
413 if (CAWindowServer *server = [CAWindowServer serverIfRunning]) {
414 NSArray *displays([server displays]);
415 if (displays != nil && [displays count] != 0)
416 if (CAWindowServerDisplay *display = [displays objectAtIndex:0])
417 port = [display clientPortAtPosition:CGPointMake(x_, y_)];
418 }
419
420 mach_port_t purple(0);
421
422 if (port == 0) {
423 if (purple == 0)
424 purple = (*GSTakePurpleSystemEventPort)();
425 port = purple;
426 }
427
428 if (port != 0)
429 GSSendEvent(record, port);
430
431 if (purple != 0 && PurpleAllocated)
432 mach_port_deallocate(mach_task_self(), purple);
433
434 CFRelease(event);
435 }
436
437 static void VNCDisconnect(rfbClientPtr client) {
438 @synchronized (condition_) {
439 if (--clients_ == 0)
440 [VNCBridge performSelectorOnMainThread:@selector(removeStatusBarItem) withObject:nil waitUntilDone:YES];
441 }
442 }
443
444 static rfbNewClientAction VNCClient(rfbClientPtr client) {
445 @synchronized (condition_) {
446 if (screen_->authPasswdData != NULL) {
447 [VNCBridge performSelectorOnMainThread:@selector(registerClient) withObject:nil waitUntilDone:YES];
448 client->clientGoneHook = &VNCDisconnect;
449 return RFB_CLIENT_ACCEPT;
450 }
451 }
452
453 [condition_ lock];
454 client_ = client;
455 [VNCBridge performSelectorOnMainThread:@selector(askForConnection) withObject:nil waitUntilDone:NO];
456 while (action_ == RFB_CLIENT_ON_HOLD)
457 [condition_ wait];
458 rfbNewClientAction action(action_);
459 action_ = RFB_CLIENT_ON_HOLD;
460 [condition_ unlock];
461
462 if (action == RFB_CLIENT_ACCEPT)
463 client->clientGoneHook = &VNCDisconnect;
464 return action;
465 }
466
467 static void VNCSetup() {
468 rfbLogEnable(false);
469
470 @synchronized (condition_) {
471 int argc(1);
472 char *arg0(strdup("VNCServer"));
473 char *argv[] = {arg0, NULL};
474 screen_ = rfbGetScreen(&argc, argv, width_, height_, BitsPerSample, 3, BytesPerPixel);
475 free(arg0);
476
477 VNCSettings();
478 }
479
480 screen_->desktopName = strdup([[[NSProcessInfo processInfo] hostName] UTF8String]);
481
482 screen_->alwaysShared = TRUE;
483 screen_->handleEventsEagerly = TRUE;
484 screen_->deferUpdateTime = 1000 / 25;
485
486 screen_->serverFormat.redShift = BitsPerSample * 2;
487 screen_->serverFormat.greenShift = BitsPerSample * 1;
488 screen_->serverFormat.blueShift = BitsPerSample * 0;
489
490 buffer_ = CoreSurfaceBufferCreate((CFDictionaryRef) [NSDictionary dictionaryWithObjectsAndKeys:
491 @"PurpleEDRAM", kCoreSurfaceBufferMemoryRegion,
492 [NSNumber numberWithBool:YES], kCoreSurfaceBufferGlobal,
493 [NSNumber numberWithInt:(width_ * BytesPerPixel)], kCoreSurfaceBufferPitch,
494 [NSNumber numberWithInt:width_], kCoreSurfaceBufferWidth,
495 [NSNumber numberWithInt:height_], kCoreSurfaceBufferHeight,
496 [NSNumber numberWithInt:'BGRA'], kCoreSurfaceBufferPixelFormat,
497 [NSNumber numberWithInt:(width_ * height_ * BytesPerPixel)], kCoreSurfaceBufferAllocSize,
498 nil]);
499
500 //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));
501
502 CoreSurfaceBufferLock(buffer_, 3);
503 screen_->frameBuffer = reinterpret_cast<char *>(CoreSurfaceBufferGetBaseAddress(buffer_));
504 CoreSurfaceBufferUnlock(buffer_);
505
506 screen_->kbdAddEvent = &VNCKeyboard;
507 screen_->ptrAddEvent = &VNCPointer;
508
509 screen_->newClientHook = &VNCClient;
510 screen_->passwordCheck = &VNCCheck;
511
512 screen_->cursor = NULL;
513 }
514
515 static void VNCEnabled() {
516 [lock_ lock];
517
518 bool enabled(true);
519 if (NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/Library/Preferences/com.saurik.Veency.plist", NSHomeDirectory()]])
520 if (NSNumber *number = [settings objectForKey:@"Enabled"])
521 enabled = [number boolValue];
522
523 if (enabled != running_)
524 if (enabled) {
525 running_ = true;
526 screen_->socketState = RFB_SOCKET_INIT;
527 rfbInitServer(screen_);
528 rfbRunEventLoop(screen_, -1, true);
529 } else {
530 rfbShutdownServer(screen_, true);
531 running_ = false;
532 }
533
534 [lock_ unlock];
535 }
536
537 static void VNCNotifyEnabled(
538 CFNotificationCenterRef center,
539 void *observer,
540 CFStringRef name,
541 const void *object,
542 CFDictionaryRef info
543 ) {
544 VNCEnabled();
545 }
546
547 MSHook(kern_return_t, IOMobileFramebufferSwapSetLayer,
548 IOMobileFramebufferRef fb,
549 int layer,
550 CoreSurfaceBufferRef buffer,
551 CGRect bounds,
552 CGRect frame,
553 int flags
554 ) {
555 if (_unlikely(screen_ == NULL)) {
556 CGSize size;
557 IOMobileFramebufferGetDisplaySize(fb, &size);
558
559 width_ = size.width;
560 height_ = size.height;
561
562 NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
563 VNCSetup();
564 VNCEnabled();
565 [pool release];
566 } else if (_unlikely(clients_ != 0)) {
567 if (buffer == NULL) {
568 //CoreSurfaceBufferLock(buffer_, 3);
569 memset(screen_->frameBuffer, 0, sizeof(rfbPixel) * width_ * height_);
570 //CoreSurfaceBufferUnlock(buffer_);
571 } else {
572 //CoreSurfaceBufferLock(buffer_, 3);
573 //CoreSurfaceBufferLock(buffer, 2);
574
575 //rfbPixel *data(reinterpret_cast<rfbPixel *>(CoreSurfaceBufferGetBaseAddress(buffer)));
576
577 /*rfbPixel corner(data[0]);
578 data[0] = 0;
579 data[0] = corner;*/
580
581 CoreSurfaceAcceleratorTransferSurface(accelerator_, buffer, buffer_, options_);
582
583 //CoreSurfaceBufferUnlock(buffer);
584 //CoreSurfaceBufferUnlock(buffer_);
585 }
586
587 //CoreSurfaceBufferFlushProcessorCaches(buffer);
588 rfbMarkRectAsModified(screen_, 0, 0, width_, height_);
589 }
590
591 return _IOMobileFramebufferSwapSetLayer(fb, layer, buffer, bounds, frame, flags);
592 }
593
594 MSHook(void, rfbRegisterSecurityHandler, rfbSecurityHandler *handler) {
595 NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
596
597 @synchronized (lock_) {
598 [handlers_ addObject:[NSValue valueWithPointer:handler]];
599 _rfbRegisterSecurityHandler(handler);
600 }
601
602 [pool release];
603 }
604
605 MSInitialize {
606 NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
607
608 MSHookSymbol(GSTakePurpleSystemEventPort, "GSGetPurpleSystemEventPort");
609 if (GSTakePurpleSystemEventPort == NULL) {
610 MSHookSymbol(GSTakePurpleSystemEventPort, "GSCopyPurpleSystemEventPort");
611 PurpleAllocated = true;
612 }
613
614 if (dlsym(RTLD_DEFAULT, "GSKeyboardCreate") != NULL)
615 Level_ = 2;
616 else if (dlsym(RTLD_DEFAULT, "GSEventGetWindowContextId") != NULL)
617 Level_ = 1;
618 else
619 Level_ = 0;
620
621 MSHookFunction(&IOMobileFramebufferSwapSetLayer, MSHake(IOMobileFramebufferSwapSetLayer));
622 MSHookFunction(&rfbRegisterSecurityHandler, MSHake(rfbRegisterSecurityHandler));
623
624 $VNCAlertItem = objc_allocateClassPair(objc_getClass("SBAlertItem"), "VNCAlertItem", 0);
625 MSAddMessage2(VNCAlertItem, "v@:@i", alertSheet,buttonClicked);
626 MSAddMessage2(VNCAlertItem, "v@:cc", configure,requirePasscodeForActions);
627 MSAddMessage0(VNCAlertItem, "v@:", performUnlockAction);
628 objc_registerClassPair($VNCAlertItem);
629
630 CFNotificationCenterAddObserver(
631 CFNotificationCenterGetDarwinNotifyCenter(),
632 NULL, &VNCNotifyEnabled, CFSTR("com.saurik.Veency-Enabled"), NULL, 0
633 );
634
635 CFNotificationCenterAddObserver(
636 CFNotificationCenterGetDarwinNotifyCenter(),
637 NULL, &VNCNotifySettings, CFSTR("com.saurik.Veency-Settings"), NULL, 0
638 );
639
640 condition_ = [[NSCondition alloc] init];
641 lock_ = [[NSLock alloc] init];
642 handlers_ = [[NSMutableSet alloc] init];
643
644 bool value;
645
646 value = true;
647 cfTrue_ = CFDataCreate(kCFAllocatorDefault, reinterpret_cast<UInt8 *>(&value), sizeof(value));
648
649 value = false;
650 cfFalse_ = CFDataCreate(kCFAllocatorDefault, reinterpret_cast<UInt8 *>(&value), sizeof(value));
651
652 cfEvent_ = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<UInt8 *>(&event_), sizeof(event_), kCFAllocatorNull);
653
654 CoreSurfaceAcceleratorCreate(NULL, NULL, &accelerator_);
655
656 options_ = (CFDictionaryRef) [[NSDictionary dictionaryWithObjectsAndKeys:
657 nil] retain];
658
659 [pool release];
660 }