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:
101 @"ActiveWirelessTechnology",
103 @"AllDeviceCapabilities",
105 @"AllowYouTubePlugin",
107 //@"AppleInternalInstallCapability",
109 //@"BasebandBoardSnum",
112 //@"BasebandFirmwareManifestData",
113 @"BasebandFirmwareVersion",
114 //@"BasebandKeyHashInformation",
115 //@"BasebandRegionSKU",
116 //@"BasebandSerialNumber",
117 @"BatteryCurrentCapacity",
118 @"BatteryIsCharging",
119 @"BatteryIsFullyCharged",
120 //@"BluetoothAddress",
124 //@"CarrierBundleInfoArray",
125 @"CarrierInstallCapability",
128 //@"CompassCalibration",
129 //@"CompassCalibrationDictionary",
131 @"contains-cellular-radio",
133 @"DeviceClassNumber",
135 @"DeviceEnclosureColor",
137 @"DeviceSupports1080p",
138 @"DeviceSupports3DImagery",
139 @"DeviceSupports3DMaps",
141 @"DeviceSupports720p",
142 @"DeviceSupports9Pin",
143 @"DeviceSupportsFaceTime",
144 @"DeviceSupportsLineIn",
145 @"DeviceSupportsNavigation",
146 @"DeviceSupportsSimplisticRoadMesh",
147 @"DeviceSupportsTethering",
153 @"encrypted-data-partition",
154 //@"EthernetMacAddress",
155 @"ExternalChargeCapability",
156 @"ExternalPowerSourceConnected",
157 //@"FaceTimeBitRate2G",
158 //@"FaceTimeBitRate3G",
159 //@"FaceTimeBitRateLTE",
160 //@"FaceTimeBitRateWiFi",
161 //@"FaceTimeDecodings",
162 //@"FaceTimeEncodings",
163 //@"FaceTimePreferredDecoding",
164 //@"FaceTimePreferredEncoding",
166 //@"FirmwarePreflightInfo",
168 @"ForwardCameraCapability",
173 //@"HasAllFeaturesCapability",
175 @"HasInternalSettingsBundle",
177 //@"IntegratedCircuitCardIdentifier",
179 //@"InternationalMobileEquipmentIdentity",
180 //@"InverseDeviceID",
182 //@"IsThereEnoughBatteryLevelForSoftwareUpdate",
184 //@"MLBSerialNumber",
185 @"main-screen-class",
186 @"main-screen-height",
187 @"main-screen-orientation",
188 @"main-screen-pitch",
189 @"main-screen-scale",
190 @"main-screen-width",
191 @"MinimumSupportediTunesVersion",
192 //@"MobileEquipmentIdentifier",
193 //@"MobileSubscriberCountryCode",
194 //@"MobileSubscriberNetworkCode",
198 @"PanoramaCameraCapability",
203 //@"ProximitySensorCalibration",
204 @"RearCameraCapability",
207 //@"RegionalBehaviorAll",
208 @"RegionalBehaviorChinaBrick",
209 @"RegionalBehaviorEUVolumeLimit",
210 @"RegionalBehaviorGB18030",
211 @"RegionalBehaviorGoogleMail",
212 @"RegionalBehaviorNTSC",
213 @"RegionalBehaviorNoPasscodeLocationTiles",
214 @"RegionalBehaviorNoVOIP",
215 @"RegionalBehaviorNoWiFi",
216 @"RegionalBehaviorShutterClick",
217 @"RegionalBehaviorVolumeLimit",
218 @"RegulatoryIdentifiers",
220 @"RequiredBatteryLevelForSoftwareUpdate",
221 @"SBAllowSensitiveUI",
222 @"SBCanForceDebuggingInfo",
223 @"SDIOManufacturerTuple",
226 //@"ScreenDimensions",
227 //@"screen-dimensions",
231 //@"SoftwareBehavior",
232 //@"SoftwareBundleVersion",
233 @"SupportedDeviceFamilies",
234 //@"SupportedKeyboards",
238 //@"UniqueDeviceIDData",
239 //@"UserAssignedDeviceName",
241 //@"WifiAddressData",
243 //@"WirelessBoardSnum",
250 @"additional-text-tones",
254 @"application-installation",
258 @"auto-focus-camera",
263 @"contains-cellular-radio",
265 @"display-mirroring",
268 @"encrypted-data-partition",
269 @"fcc-logos-via-software",
270 @"front-facing-camera",
272 @"gas-gauge-battery",
276 @"hardware-keyboard",
278 @"hdr-image-capture",
279 @"hiccough-interval",
281 @"homescreen-wallpaper",
282 @"hw-encode-snapshots",
283 @"international-settings",
284 @"io-surface-backed-images",
285 @"load-thumbnails-while-scrolling",
286 @"location-services",
297 @"photo-adjustments",
303 @"stand-alone-contacts",
306 @"telephony-maximum-generation",
321 if (CFTypeRef answer = $MGCopyAnswer(reinterpret_cast<CFStringRef>(name))) {
322 [answers setObject:(id)answer forKey:name];
325 capability = answers;
329 if (capability != nil) {
330 printf("%s\n", capability == nil ? "(null)" : [[capability description] UTF8String]);