1 /* UIKit Tools - command-line utilities for UIKit
2 * Copyright (C) 2008-2012 Jay Freeman (saurik)
5 /* Modified BSD License {{{ */
7 * Redistribution and use in source and binary
8 * forms, with or without modification, are permitted
9 * provided that the following conditions are met:
11 * 1. Redistributions of source code must retain the
12 * above copyright notice, this list of conditions
13 * and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the
15 * above copyright notice, this list of conditions
16 * and the following disclaimer in the documentation
17 * and/or other materials provided with the
19 * 3. The name of the author may not be used to endorse
20 * or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS''
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
25 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
34 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
36 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 #import <GraphicsServices/GraphicsServices.h>
41 #import <UIKit/UIKit.h>
44 #include <objc/runtime.h>
46 static CFArrayRef (*$GSSystemCopyCapability)(CFStringRef);
47 static CFArrayRef (*$GSSystemGetCapability)(CFStringRef);
49 void OnGSCapabilityChanged(
50 CFNotificationCenterRef center,
56 CFRunLoopStop(CFRunLoopGetCurrent());
59 int main(int argc, char *argv[]) {
60 dlopen("/System/Library/Frameworks/Foundation.framework/Foundation", RTLD_GLOBAL | RTLD_LAZY);
61 dlopen("/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices", RTLD_GLOBAL | RTLD_LAZY);
63 NSAutoreleasePool *pool = [[objc_getClass("NSAutoreleasePool") alloc] init];
68 name = [objc_getClass("NSString") stringWithUTF8String:argv[0]];
70 fprintf(stderr, "usage: %s [capability]\n", argv[0]);
74 $GSSystemCopyCapability = reinterpret_cast<CFArrayRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemCopyCapability"));
75 $GSSystemGetCapability = reinterpret_cast<CFArrayRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemGetCapability"));
77 CFNotificationCenterAddObserver(
78 CFNotificationCenterGetDarwinNotifyCenter(),
80 &OnGSCapabilityChanged,
81 CFSTR("GSCapabilitiesChanged"),
87 const NSDictionary *capability;
89 if ($GSSystemCopyCapability != NULL) {
90 capability = reinterpret_cast<const NSDictionary *>((*$GSSystemCopyCapability)(reinterpret_cast<CFStringRef>(name)));
91 if (capability != nil)
92 capability = [capability autorelease];
93 } else if ($GSSystemGetCapability != NULL) {
94 capability = reinterpret_cast<const NSDictionary *>((*$GSSystemGetCapability)(reinterpret_cast<CFStringRef>(name)));
96 if (void *libMobileGestalt = dlopen("/usr/lib/libMobileGestalt.dylib", RTLD_GLOBAL | RTLD_LAZY))
97 if (CFTypeRef (*$MGCopyAnswer)(CFStringRef) = reinterpret_cast<CFTypeRef (*)(CFStringRef)>(dlsym(libMobileGestalt, "MGCopyAnswer"))) {
98 NSMutableDictionary *answers([NSMutableDictionary dictionary]);
99 for (NSString *name in [NSArray arrayWithObjects:
100 @"ActiveWirelessTechnology",
102 @"AllDeviceCapabilities",
104 @"AllowYouTubePlugin",
106 //@"AppleInternalInstallCapability",
108 //@"BasebandBoardSnum",
111 //@"BasebandFirmwareManifestData",
112 @"BasebandFirmwareVersion",
113 //@"BasebandKeyHashInformation",
114 //@"BasebandRegionSKU",
115 //@"BasebandSerialNumber",
116 @"BatteryCurrentCapacity",
117 @"BatteryIsCharging",
118 @"BatteryIsFullyCharged",
119 //@"BluetoothAddress",
123 //@"CarrierBundleInfoArray",
124 @"CarrierInstallCapability",
127 //@"CompassCalibration",
128 //@"CompassCalibrationDictionary",
130 @"contains-cellular-radio",
132 @"DeviceClassNumber",
134 @"DeviceEnclosureColor",
136 @"DeviceSupports1080p",
137 @"DeviceSupports3DImagery",
138 @"DeviceSupports3DMaps",
140 @"DeviceSupports720p",
141 @"DeviceSupports9Pin",
142 @"DeviceSupportsFaceTime",
143 @"DeviceSupportsLineIn",
144 @"DeviceSupportsNavigation",
145 @"DeviceSupportsSimplisticRoadMesh",
146 @"DeviceSupportsTethering",
152 @"encrypted-data-partition",
153 //@"EthernetMacAddress",
154 @"ExternalChargeCapability",
155 @"ExternalPowerSourceConnected",
156 //@"FaceTimeBitRate2G",
157 //@"FaceTimeBitRate3G",
158 //@"FaceTimeBitRateLTE",
159 //@"FaceTimeBitRateWiFi",
160 //@"FaceTimeDecodings",
161 //@"FaceTimeEncodings",
162 //@"FaceTimePreferredDecoding",
163 //@"FaceTimePreferredEncoding",
165 //@"FirmwarePreflightInfo",
167 @"ForwardCameraCapability",
172 //@"HasAllFeaturesCapability",
174 @"HasInternalSettingsBundle",
176 //@"IntegratedCircuitCardIdentifier",
178 //@"InternationalMobileEquipmentIdentity",
179 //@"InverseDeviceID",
181 //@"IsThereEnoughBatteryLevelForSoftwareUpdate",
183 //@"MLBSerialNumber",
184 @"main-screen-class",
185 @"main-screen-height",
186 @"main-screen-orientation",
187 @"main-screen-pitch",
188 @"main-screen-scale",
189 @"main-screen-width",
190 @"MinimumSupportediTunesVersion",
191 //@"MobileEquipmentIdentifier",
192 //@"MobileSubscriberCountryCode",
193 //@"MobileSubscriberNetworkCode",
197 @"PanoramaCameraCapability",
202 //@"ProximitySensorCalibration",
203 @"RearCameraCapability",
206 //@"RegionalBehaviorAll",
207 @"RegionalBehaviorChinaBrick",
208 @"RegionalBehaviorEUVolumeLimit",
209 @"RegionalBehaviorGB18030",
210 @"RegionalBehaviorGoogleMail",
211 @"RegionalBehaviorNTSC",
212 @"RegionalBehaviorNoPasscodeLocationTiles",
213 @"RegionalBehaviorNoVOIP",
214 @"RegionalBehaviorNoWiFi",
215 @"RegionalBehaviorShutterClick",
216 @"RegionalBehaviorVolumeLimit",
217 @"RegulatoryIdentifiers",
219 @"RequiredBatteryLevelForSoftwareUpdate",
220 @"SBAllowSensitiveUI",
221 @"SBCanForceDebuggingInfo",
222 @"SDIOManufacturerTuple",
225 //@"ScreenDimensions",
226 //@"screen-dimensions",
230 //@"SoftwareBehavior",
231 //@"SoftwareBundleVersion",
232 @"SupportedDeviceFamilies",
233 //@"SupportedKeyboards",
237 //@"UniqueDeviceIDData",
238 //@"UserAssignedDeviceName",
240 //@"WifiAddressData",
242 //@"WirelessBoardSnum",
249 @"additional-text-tones",
253 @"application-installation",
257 @"auto-focus-camera",
262 @"contains-cellular-radio",
264 @"display-mirroring",
267 @"encrypted-data-partition",
268 @"fcc-logos-via-software",
269 @"front-facing-camera",
271 @"gas-gauge-battery",
275 @"hardware-keyboard",
277 @"hdr-image-capture",
278 @"hiccough-interval",
280 @"homescreen-wallpaper",
281 @"hw-encode-snapshots",
282 @"international-settings",
283 @"io-surface-backed-images",
284 @"load-thumbnails-while-scrolling",
285 @"location-services",
296 @"photo-adjustments",
302 @"stand-alone-contacts",
305 @"telephony-maximum-generation",
320 if (CFTypeRef answer = $MGCopyAnswer(reinterpret_cast<CFStringRef>(name))) {
321 [answers setObject:(id)answer forKey:name];
324 capability = answers;
328 if (capability != nil) {
329 printf("%s\n", capability == nil ? "(null)" : [[capability description] UTF8String]);