]>
Commit | Line | Data |
---|---|---|
a4ccf03b JF |
1 | /* UIKit Tools - command-line utilities for UIKit |
2 | * Copyright (C) 2008-2012 Jay Freeman (saurik) | |
3 | */ | |
4 | ||
5 | /* Modified BSD License {{{ */ | |
6 | /* | |
7 | * Redistribution and use in source and binary | |
8 | * forms, with or without modification, are permitted | |
9 | * provided that the following conditions are met: | |
10 | * | |
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 | |
18 | * distribution. | |
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. | |
22 | * | |
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. | |
37 | */ | |
38 | /* }}} */ | |
39 | ||
020dfc54 JF |
40 | #import <UIKit/UIKit.h> |
41 | #include <stdio.h> | |
42 | #include <dlfcn.h> | |
7141b425 | 43 | #include <objc/runtime.h> |
020dfc54 JF |
44 | |
45 | static CFArrayRef (*$GSSystemCopyCapability)(CFStringRef); | |
46 | static CFArrayRef (*$GSSystemGetCapability)(CFStringRef); | |
47 | ||
04ee9f37 JF |
48 | void OnGSCapabilityChanged( |
49 | CFNotificationCenterRef center, | |
50 | void *observer, | |
51 | CFStringRef name, | |
52 | const void *object, | |
53 | CFDictionaryRef info | |
54 | ) { | |
55 | CFRunLoopStop(CFRunLoopGetCurrent()); | |
56 | } | |
57 | ||
020dfc54 | 58 | int main(int argc, char *argv[]) { |
7141b425 JF |
59 | dlopen("/System/Library/Frameworks/Foundation.framework/Foundation", RTLD_GLOBAL | RTLD_LAZY); |
60 | dlopen("/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices", RTLD_GLOBAL | RTLD_LAZY); | |
61 | ||
62 | NSAutoreleasePool *pool = [[objc_getClass("NSAutoreleasePool") alloc] init]; | |
020dfc54 JF |
63 | |
64 | NSString *name = nil; | |
65 | ||
66 | if (argc == 2) | |
7141b425 | 67 | name = [objc_getClass("NSString") stringWithUTF8String:argv[0]]; |
020dfc54 JF |
68 | else if (argc > 2) { |
69 | fprintf(stderr, "usage: %s [capability]\n", argv[0]); | |
70 | exit(1); | |
71 | } | |
72 | ||
73 | $GSSystemCopyCapability = reinterpret_cast<CFArrayRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemCopyCapability")); | |
74 | $GSSystemGetCapability = reinterpret_cast<CFArrayRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemGetCapability")); | |
75 | ||
04ee9f37 JF |
76 | CFNotificationCenterAddObserver( |
77 | CFNotificationCenterGetDarwinNotifyCenter(), | |
78 | NULL, | |
79 | &OnGSCapabilityChanged, | |
80 | CFSTR("GSCapabilitiesChanged"), | |
81 | NULL, | |
a830525c | 82 | 0 |
04ee9f37 JF |
83 | ); |
84 | ||
04ee9f37 | 85 | for (;;) { |
250d7de5 JF |
86 | const NSDictionary *capability; |
87 | ||
04ee9f37 | 88 | if ($GSSystemCopyCapability != NULL) { |
250d7de5 | 89 | capability = reinterpret_cast<const NSDictionary *>((*$GSSystemCopyCapability)(reinterpret_cast<CFStringRef>(name))); |
04ee9f37 JF |
90 | if (capability != nil) |
91 | capability = [capability autorelease]; | |
92 | } else if ($GSSystemGetCapability != NULL) { | |
250d7de5 | 93 | capability = reinterpret_cast<const NSDictionary *>((*$GSSystemGetCapability)(reinterpret_cast<CFStringRef>(name))); |
04ee9f37 | 94 | } else { |
a830525c JF |
95 | capability = nil; |
96 | ||
250d7de5 JF |
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", | |
102 | //@"AirplaneMode", | |
103 | @"AllDeviceCapabilities", | |
104 | @"AllowYouTube", | |
105 | @"AllowYouTubePlugin", | |
106 | //@"ApNonce", | |
107 | //@"AppleInternalInstallCapability", | |
108 | @"assistant", | |
109 | //@"BasebandBoardSnum", | |
110 | //@"BasebandCertId", | |
111 | //@"BasebandChipId", | |
112 | //@"BasebandFirmwareManifestData", | |
113 | @"BasebandFirmwareVersion", | |
114 | //@"BasebandKeyHashInformation", | |
115 | //@"BasebandRegionSKU", | |
116 | //@"BasebandSerialNumber", | |
117 | @"BatteryCurrentCapacity", | |
118 | @"BatteryIsCharging", | |
119 | @"BatteryIsFullyCharged", | |
120 | //@"BluetoothAddress", | |
121 | @"BoardId", | |
122 | @"BuildVersion", | |
123 | @"CPUArchitecture", | |
124 | //@"CarrierBundleInfoArray", | |
125 | @"CarrierInstallCapability", | |
126 | @"cellular-data", | |
127 | @"ChipID", | |
128 | //@"CompassCalibration", | |
129 | //@"CompassCalibrationDictionary", | |
130 | //@"ComputerName", | |
131 | @"contains-cellular-radio", | |
132 | @"DeviceClass", | |
133 | @"DeviceClassNumber", | |
134 | @"DeviceColor", | |
135 | @"DeviceEnclosureColor", | |
136 | //@"DeviceName", | |
137 | @"DeviceSupports1080p", | |
138 | @"DeviceSupports3DImagery", | |
139 | @"DeviceSupports3DMaps", | |
140 | @"DeviceSupports4G", | |
141 | @"DeviceSupports720p", | |
142 | @"DeviceSupports9Pin", | |
143 | @"DeviceSupportsFaceTime", | |
144 | @"DeviceSupportsLineIn", | |
145 | @"DeviceSupportsNavigation", | |
146 | @"DeviceSupportsSimplisticRoadMesh", | |
147 | @"DeviceSupportsTethering", | |
148 | @"DeviceVariant", | |
149 | //@"DiagData", | |
150 | @"dictation", | |
151 | //@"DieId", | |
152 | //@"DiskUsage", | |
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", | |
165 | //@"FirmwareNonce", | |
166 | //@"FirmwarePreflightInfo", | |
167 | @"FirmwareVersion", | |
168 | @"ForwardCameraCapability", | |
169 | @"gps", | |
170 | @"green-tea", | |
171 | @"HWModelStr", | |
172 | @"HardwarePlatform", | |
173 | //@"HasAllFeaturesCapability", | |
174 | @"HasBaseband", | |
175 | @"HasInternalSettingsBundle", | |
176 | @"HasSpringBoard", | |
177 | //@"IntegratedCircuitCardIdentifier", | |
178 | //@"InternalBuild", | |
179 | //@"InternationalMobileEquipmentIdentity", | |
180 | //@"InverseDeviceID", | |
181 | //@"IsSimulator", | |
182 | //@"IsThereEnoughBatteryLevelForSoftwareUpdate", | |
183 | //@"IsUIBuild", | |
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", | |
195 | @"wi-fi", | |
196 | @"ModelNumber", | |
197 | @"not-green-tea", | |
198 | @"PanoramaCameraCapability", | |
199 | @"PartitionType", | |
200 | @"ProductName", | |
201 | @"ProductType", | |
202 | @"ProductVersion", | |
203 | //@"ProximitySensorCalibration", | |
204 | @"RearCameraCapability", | |
205 | @"RegionCode", | |
206 | @"RegionInfo", | |
207 | //@"RegionalBehaviorAll", | |
208 | @"RegionalBehaviorChinaBrick", | |
209 | @"RegionalBehaviorEUVolumeLimit", | |
210 | @"RegionalBehaviorGB18030", | |
211 | @"RegionalBehaviorGoogleMail", | |
212 | @"RegionalBehaviorNTSC", | |
213 | @"RegionalBehaviorNoPasscodeLocationTiles", | |
214 | @"RegionalBehaviorNoVOIP", | |
215 | @"RegionalBehaviorNoWiFi", | |
216 | @"RegionalBehaviorShutterClick", | |
217 | @"RegionalBehaviorVolumeLimit", | |
218 | @"RegulatoryIdentifiers", | |
219 | //@"ReleaseType", | |
220 | @"RequiredBatteryLevelForSoftwareUpdate", | |
221 | @"SBAllowSensitiveUI", | |
222 | @"SBCanForceDebuggingInfo", | |
223 | @"SDIOManufacturerTuple", | |
224 | @"SDIOProductInfo", | |
225 | //@"SIMTrayStatus", | |
226 | //@"ScreenDimensions", | |
227 | //@"screen-dimensions", | |
228 | //@"SerialNumber", | |
229 | @"ShouldHactivate", | |
230 | @"SigningFuse", | |
231 | //@"SoftwareBehavior", | |
232 | //@"SoftwareBundleVersion", | |
233 | @"SupportedDeviceFamilies", | |
234 | //@"SupportedKeyboards", | |
235 | //@"SysCfg", | |
236 | //@"UniqueChipID", | |
237 | //@"UniqueDeviceID", | |
238 | //@"UniqueDeviceIDData", | |
239 | //@"UserAssignedDeviceName", | |
240 | //@"WifiAddress", | |
241 | //@"WifiAddressData", | |
242 | //@"WifiVendor", | |
243 | //@"WirelessBoardSnum", | |
244 | @"iTunesFamilyID", | |
245 | ||
246 | @"720p", | |
247 | @"1080p", | |
248 | @"accelerometer", | |
249 | @"accessibility", | |
250 | @"additional-text-tones", | |
251 | @"all-features", | |
252 | @"any-telephony", | |
253 | @"app-store", | |
254 | @"application-installation", | |
255 | @"armv6", | |
256 | @"armv7", | |
257 | @"assistant", | |
258 | @"auto-focus-camera", | |
259 | @"bluetooth", | |
260 | @"bluetooth-le", | |
261 | @"camera-flash", | |
262 | @"cellular-data", | |
263 | @"contains-cellular-radio", | |
264 | @"dictation", | |
265 | @"display-mirroring", | |
266 | @"displayport", | |
267 | @"encode-aac", | |
268 | @"encrypted-data-partition", | |
269 | @"fcc-logos-via-software", | |
270 | @"front-facing-camera", | |
271 | @"gamekit", | |
272 | @"gas-gauge-battery", | |
273 | @"gps", | |
274 | @"gyroscope", | |
275 | @"h264-encoder", | |
276 | @"hardware-keyboard", | |
277 | @"hd-video-capture", | |
278 | @"hdr-image-capture", | |
279 | @"hiccough-interval", | |
280 | @"hidpi", | |
281 | @"homescreen-wallpaper", | |
282 | @"hw-encode-snapshots", | |
283 | @"international-settings", | |
284 | @"io-surface-backed-images", | |
285 | @"load-thumbnails-while-scrolling", | |
286 | @"location-services", | |
287 | @"magnetometer", | |
288 | @"microphone", | |
289 | @"mms", | |
290 | @"multitasking", | |
291 | @"music-store", | |
292 | @"nike-ipod", | |
293 | @"not-green-tea", | |
294 | @"opengles-1", | |
295 | @"opengles-2", | |
296 | @"peer-peer", | |
297 | @"photo-adjustments", | |
298 | @"photo-stream", | |
299 | @"proximity-sensor", | |
300 | @"ptp-large-files", | |
301 | @"ringer-switch", | |
302 | @"sms", | |
303 | @"stand-alone-contacts", | |
304 | @"still-camera", | |
305 | @"telephony", | |
306 | @"telephony-maximum-generation", | |
307 | @"tv-out-crossfade", | |
308 | @"tv-out-settings", | |
309 | @"unified-ipod", | |
310 | @"venice", | |
311 | @"video-camera", | |
312 | @"voice-control", | |
313 | @"voip", | |
314 | @"volume-buttons", | |
315 | @"wifi", | |
316 | @"youtube", | |
317 | @"youtube-plugin", | |
318 | @"ipad", | |
319 | @"wildcat", | |
320 | nil]) | |
321 | if (CFTypeRef answer = $MGCopyAnswer(reinterpret_cast<CFStringRef>(name))) { | |
322 | [answers setObject:(id)answer forKey:name]; | |
323 | CFRelease(answer); | |
324 | } | |
325 | capability = answers; | |
326 | } | |
04ee9f37 JF |
327 | } |
328 | ||
8317830b JF |
329 | if (capability != nil) { |
330 | printf("%s\n", capability == nil ? "(null)" : [[capability description] UTF8String]); | |
04ee9f37 | 331 | break; |
8317830b | 332 | } |
04ee9f37 JF |
333 | |
334 | CFRunLoopRun(); | |
335 | } | |
020dfc54 | 336 | |
020dfc54 JF |
337 | [pool release]; |
338 | ||
339 | return 0; | |
340 | } |