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 <UIKit/UIKit.h>
43 #include <objc/runtime.h>
45 static CFArrayRef (*$GSSystemCopyCapability)(CFStringRef);
46 static CFArrayRef (*$GSSystemGetCapability)(CFStringRef);
48 void OnGSCapabilityChanged(
49 CFNotificationCenterRef center,
55 CFRunLoopStop(CFRunLoopGetCurrent());
58 int main(int argc, char *argv[]) {
59 dlopen("/System/Library/Frameworks/Foundation.framework/Foundation", RTLD_GLOBAL | RTLD_LAZY);
60 dlopen("/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices", RTLD_GLOBAL | RTLD_LAZY);
62 NSAutoreleasePool *pool = [[objc_getClass("NSAutoreleasePool") alloc] init];
67 name = [objc_getClass("NSString") stringWithUTF8String:argv[0]];
69 fprintf(stderr, "usage: %s [capability]\n", argv[0]);
73 $GSSystemCopyCapability = reinterpret_cast<CFArrayRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemCopyCapability"));
74 $GSSystemGetCapability = reinterpret_cast<CFArrayRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemGetCapability"));
76 CFNotificationCenterAddObserver(
77 CFNotificationCenterGetDarwinNotifyCenter(),
79 &OnGSCapabilityChanged,
80 CFSTR("GSCapabilitiesChanged"),
86 const NSDictionary *capability;
88 if ($GSSystemCopyCapability != NULL) {
89 capability = reinterpret_cast<const NSDictionary *>((*$GSSystemCopyCapability)(reinterpret_cast<CFStringRef>(name)));
90 if (capability != nil)
91 capability = [capability autorelease];
92 } else if ($GSSystemGetCapability != NULL) {
93 capability = reinterpret_cast<const NSDictionary *>((*$GSSystemGetCapability)(reinterpret_cast<CFStringRef>(name)));
97 if (void *libMobileGestalt = dlopen("/usr/lib/libMobileGestalt.dylib", RTLD_GLOBAL | RTLD_LAZY))
98 if (CFTypeRef (*$MGCopyAnswer)(CFStringRef) = reinterpret_cast<CFTypeRef (*)(CFStringRef)>(dlsym(libMobileGestalt, "MGCopyAnswer"))) {
99 NSMutableDictionary *answers([NSMutableDictionary dictionary]);
100 for (NSString *name in [NSArray arrayWithObjects:
103 @"apple-internal-install",
104 @"cameraRestriction",
106 @"multitasking-gestures",
107 @"rear-facing-camera",
111 @"AirDropCapability",
112 @"CarrierInstallCapability",
113 @"CellularTelephonyCapability",
114 @"UIParallaxCapability",
115 @"ambient-light-sensor",
118 @"hall-effect-sensor",
121 @"ActiveWirelessTechnology",
123 @"AllDeviceCapabilities",
125 @"AllowYouTubePlugin",
127 //@"AppleInternalInstallCapability",
129 //@"BasebandBoardSnum",
132 //@"BasebandFirmwareManifestData",
133 @"BasebandFirmwareVersion",
134 //@"BasebandKeyHashInformation",
135 //@"BasebandRegionSKU",
136 //@"BasebandSerialNumber",
137 @"BatteryCurrentCapacity",
138 @"BatteryIsCharging",
139 @"BatteryIsFullyCharged",
140 //@"BluetoothAddress",
144 //@"CarrierBundleInfoArray",
145 @"CarrierInstallCapability",
148 //@"CompassCalibration",
149 //@"CompassCalibrationDictionary",
151 @"contains-cellular-radio",
153 @"DeviceClassNumber",
155 @"DeviceEnclosureColor",
157 @"DeviceSupports1080p",
158 @"DeviceSupports3DImagery",
159 @"DeviceSupports3DMaps",
161 @"DeviceSupports720p",
162 @"DeviceSupports9Pin",
163 @"DeviceSupportsFaceTime",
164 @"DeviceSupportsLineIn",
165 @"DeviceSupportsNavigation",
166 @"DeviceSupportsSimplisticRoadMesh",
167 @"DeviceSupportsTethering",
173 @"encrypted-data-partition",
174 //@"EthernetMacAddress",
175 @"ExternalChargeCapability",
176 @"ExternalPowerSourceConnected",
177 //@"FaceTimeBitRate2G",
178 //@"FaceTimeBitRate3G",
179 //@"FaceTimeBitRateLTE",
180 //@"FaceTimeBitRateWiFi",
181 //@"FaceTimeDecodings",
182 //@"FaceTimeEncodings",
183 //@"FaceTimePreferredDecoding",
184 //@"FaceTimePreferredEncoding",
186 //@"FirmwarePreflightInfo",
188 @"ForwardCameraCapability",
193 //@"HasAllFeaturesCapability",
195 @"HasInternalSettingsBundle",
197 //@"IntegratedCircuitCardIdentifier",
199 //@"InternationalMobileEquipmentIdentity",
200 //@"InverseDeviceID",
202 //@"IsThereEnoughBatteryLevelForSoftwareUpdate",
204 //@"MLBSerialNumber",
205 @"main-screen-class",
206 @"main-screen-height",
207 @"main-screen-orientation",
208 @"main-screen-pitch",
209 @"main-screen-scale",
210 @"main-screen-width",
211 @"MinimumSupportediTunesVersion",
212 //@"MobileEquipmentIdentifier",
213 //@"MobileSubscriberCountryCode",
214 //@"MobileSubscriberNetworkCode",
218 @"PanoramaCameraCapability",
223 //@"ProximitySensorCalibration",
224 @"RearCameraCapability",
227 //@"RegionalBehaviorAll",
228 @"RegionalBehaviorChinaBrick",
229 @"RegionalBehaviorEUVolumeLimit",
230 @"RegionalBehaviorGB18030",
231 @"RegionalBehaviorGoogleMail",
232 @"RegionalBehaviorNTSC",
233 @"RegionalBehaviorNoPasscodeLocationTiles",
234 @"RegionalBehaviorNoVOIP",
235 @"RegionalBehaviorNoWiFi",
236 @"RegionalBehaviorShutterClick",
237 @"RegionalBehaviorVolumeLimit",
238 @"RegulatoryIdentifiers",
240 @"RequiredBatteryLevelForSoftwareUpdate",
241 @"SBAllowSensitiveUI",
242 @"SBCanForceDebuggingInfo",
243 @"SDIOManufacturerTuple",
246 //@"ScreenDimensions",
247 //@"screen-dimensions",
251 //@"SoftwareBehavior",
252 //@"SoftwareBundleVersion",
253 @"SupportedDeviceFamilies",
254 //@"SupportedKeyboards",
258 //@"UniqueDeviceIDData",
259 //@"UserAssignedDeviceName",
261 //@"WifiAddressData",
263 //@"WirelessBoardSnum",
270 @"additional-text-tones",
274 @"application-installation",
278 @"auto-focus-camera",
283 @"contains-cellular-radio",
285 @"display-mirroring",
288 @"encrypted-data-partition",
289 @"fcc-logos-via-software",
290 @"front-facing-camera",
292 @"gas-gauge-battery",
296 @"hardware-keyboard",
298 @"hdr-image-capture",
299 @"hiccough-interval",
301 @"homescreen-wallpaper",
302 @"hw-encode-snapshots",
303 @"international-settings",
304 @"io-surface-backed-images",
305 @"load-thumbnails-while-scrolling",
306 @"location-services",
317 @"photo-adjustments",
323 @"stand-alone-contacts",
326 @"telephony-maximum-generation",
341 if (CFTypeRef answer = $MGCopyAnswer(reinterpret_cast<CFStringRef>(name))) {
342 [answers setObject:(id)answer forKey:name];
345 capability = answers;
349 if (capability != nil) {
350 printf("%s\n", capability == nil ? "(null)" : [[capability description] UTF8String]);