1 #import <GraphicsServices/GraphicsServices.h>
2 #import <UIKit/UIKit.h>
5 #include <objc/runtime.h>
7 static CFArrayRef (*$GSSystemCopyCapability)(CFStringRef);
8 static CFArrayRef (*$GSSystemGetCapability)(CFStringRef);
10 void OnGSCapabilityChanged(
11 CFNotificationCenterRef center,
17 CFRunLoopStop(CFRunLoopGetCurrent());
20 int main(int argc, char *argv[]) {
21 dlopen("/System/Library/Frameworks/Foundation.framework/Foundation", RTLD_GLOBAL | RTLD_LAZY);
22 dlopen("/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices", RTLD_GLOBAL | RTLD_LAZY);
24 NSAutoreleasePool *pool = [[objc_getClass("NSAutoreleasePool") alloc] init];
29 name = [objc_getClass("NSString") stringWithUTF8String:argv[0]];
31 fprintf(stderr, "usage: %s [capability]\n", argv[0]);
35 $GSSystemCopyCapability = reinterpret_cast<CFArrayRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemCopyCapability"));
36 $GSSystemGetCapability = reinterpret_cast<CFArrayRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemGetCapability"));
38 CFNotificationCenterAddObserver(
39 CFNotificationCenterGetDarwinNotifyCenter(),
41 &OnGSCapabilityChanged,
42 CFSTR("GSCapabilitiesChanged"),
47 const NSArray *capability;
50 if ($GSSystemCopyCapability != NULL) {
51 capability = reinterpret_cast<const NSArray *>((*$GSSystemCopyCapability)(reinterpret_cast<CFStringRef>(name)));
52 if (capability != nil)
53 capability = [capability autorelease];
54 } else if ($GSSystemGetCapability != NULL) {
55 capability = reinterpret_cast<const NSArray *>((*$GSSystemGetCapability)(reinterpret_cast<CFStringRef>(name)));
61 if (capability != nil)
67 printf("%s\n", capability == nil ? "(null)" : [[capability description] UTF8String]);