/* UIKit Tools - command-line utilities for UIKit * Copyright (C) 2018-2019 Sam Bingner * Copyright (C) 2008-2012 Jay Freeman (saurik) */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /* Modified BSD License {{{ */ /* * Redistribution and use in source and binary * forms, with or without modification, are permitted * provided that the following conditions are met: * * 1. Redistributions of source code must retain the * above copyright notice, this list of conditions * and the following disclaimer. * 2. Redistributions in binary form must reproduce the * above copyright notice, this list of conditions * and the following disclaimer in the documentation * and/or other materials provided with the * distribution. * 3. The name of the author may not be used to endorse * or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* }}} */ #import #include #include #include static CFArrayRef (*$GSSystemCopyCapability)(CFStringRef); static CFArrayRef (*$GSSystemGetCapability)(CFStringRef); static CFTypeRef (*$MGCopyAnswer)(CFStringRef); void OnGSCapabilityChanged( CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef info ) { CFRunLoopStop(CFRunLoopGetCurrent()); } int main(int argc, char *argv[]) { dlopen("/System/Library/Frameworks/Foundation.framework/Foundation", RTLD_GLOBAL | RTLD_LAZY); dlopen("/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices", RTLD_GLOBAL | RTLD_LAZY); if (getenv("OS_ACTIVITY_DT_MODE")) { // This would make a bunch of random NSLogs print unsetenv("OS_ACTIVITY_DT_MODE"); execvp(argv[0], argv); exit(1); } NSAutoreleasePool *pool = [[objc_getClass("NSAutoreleasePool") alloc] init]; NSString *name = nil; if (argc == 2) name = [objc_getClass("NSString") stringWithUTF8String:argv[1]]; else if (argc > 2) { fprintf(stderr, "usage: %s [capability]\n", argv[0]); exit(1); } $GSSystemCopyCapability = reinterpret_cast(dlsym(RTLD_DEFAULT, "GSSystemCopyCapability")); $GSSystemGetCapability = reinterpret_cast(dlsym(RTLD_DEFAULT, "GSSystemGetCapability")); CFNotificationCenterAddObserver( CFNotificationCenterGetDarwinNotifyCenter(), NULL, &OnGSCapabilityChanged, CFSTR("GSCapabilitiesChanged"), NULL, 0 ); for (;;) { const NSDictionary *capability; if ($GSSystemCopyCapability != NULL) { capability = reinterpret_cast((*$GSSystemCopyCapability)(reinterpret_cast(name))); if (capability != nil) capability = [capability autorelease]; } else if ($GSSystemGetCapability != NULL) { capability = reinterpret_cast((*$GSSystemGetCapability)(reinterpret_cast(name))); } else { capability = nil; void *libMobileGestalt = dlopen("/usr/lib/libMobileGestalt.dylib", RTLD_GLOBAL | RTLD_LAZY); if (libMobileGestalt && ($MGCopyAnswer = reinterpret_cast(dlsym(libMobileGestalt, "MGCopyAnswer")))) { if (name) { capability = reinterpret_cast($MGCopyAnswer(reinterpret_cast(name))); if (capability != nil) capability = [capability autorelease]; } else { NSMutableDictionary *answers([NSMutableDictionary dictionary]); for (NSString *name in [NSArray arrayWithObjects: @"1080p", @"3GProximityCapability", @"3Gvenice", @"3d-imagery", @"3d-maps", @"64-bit", @"720p", @"ASTC", @"AWDID", @"AWDLCapability", @"ActivationProtocol", @"ActiveWirelessTechnology", @"AggregateDevicePhotoZoomFactor", @"AggregateDeviceVideoZoomFactor", @"AirDropCapability", @"AirplayMirroringCapability", @"AllDeviceCapabilities", @"Allow32BitApps", @"AllowOnlyATVCPSDKApps", @"AllowYouTube", @"AllowYouTubePlugin", @"AppCapacityTVOS", @"AppStore", @"AudioPlaybackCapability", @"AutoFocusCameraCapability", @"BacklightCapability", @"BasebandChipId", @"BasebandChipset", @"BasebandClass", @"BasebandFirmwareManifestData", @"BasebandFirmwareVersion", @"BasebandPostponementStatus", @"BasebandStatus", @"BatteryCurrentCapacity", @"BatteryIsCharging", @"BatteryIsFullyCharged", @"BlueLightReductionSupported", @"BoardId", @"BridgeBuild", @"BridgeRestoreVersion", @"BuddyLanguagesAnimationRequiresOptimization", @"BuildID", @"BuildVersion", @"CPUArchitecture", @"CPUSubType", @"CPUType", @"CameraFlashCapability", @"CameraFrontFlashCapability", @"CameraHDR2Capability", @"CameraLiveEffectsCapability", @"CameraMaxBurstLength", @"CarrierInstallCapability", @"CellularTelephonyCapability", @"ChipID", @"CloudPhotoLibraryCapability", @"CoastlineGlowRenderingCapability", @"CompassType", @"ContinuityCapability", @"CoreRoutineCapability", @"DMin", @"DebugBoardRevision", @"DesenseBuild", @"DeviceBackGlassMaterial", @"DeviceBackingColor", @"DeviceBrand", @"DeviceClass", @"DeviceClassNumber", @"DeviceColor", @"DeviceColorMapPolicy", @"DeviceCornerRadius", @"DeviceCoverGlassColor", @"DeviceCoverGlassMaterial", @"DeviceCoverMaterial", @"DeviceEnclosureColor", @"DeviceEnclosureMaterial", @"DeviceEnclosureRGBColor", @"DeviceHasAggregateCamera", @"DeviceHousingColor", @"DeviceLaunchTimeLimitScale", @"DeviceName", @"DevicePrefers3DBuildingStrokes", @"DevicePrefersBuildingStrokes", @"DevicePrefersCheapTrafficShaders", @"DevicePrefersProceduralAntiAliasing", @"DevicePrefersTrafficAlpha", @"DeviceRGBColor", @"DeviceRequiresPetalOptimization", @"DeviceRequiresProximityAmeliorations", @"DeviceRequiresSoftwareBrightnessCalculations", @"DeviceSceneUpdateTimeLimitScale", @"DeviceSubBrand", @"DeviceSupports1080p", @"DeviceSupports3DImagery", @"DeviceSupports3DMaps", @"DeviceSupports4G", @"DeviceSupports4k", @"DeviceSupports720p", @"DeviceSupports9Pin", @"DeviceSupportsAOP", @"DeviceSupportsASTC", @"DeviceSupportsAdaptiveMapsUI", @"DeviceSupportsAlwaysListening", @"DeviceSupportsAlwaysOnCompass", @"DeviceSupportsApplePencil", @"DeviceSupportsAutoLowLightVideo", @"DeviceSupportsBatteryModuleAuthentication", @"DeviceSupportsBerkelium2", @"DeviceSupportsCCK", @"DeviceSupportsCameraCaptureOnTouchDown", @"DeviceSupportsCameraHaptics", @"DeviceSupportsCarIntegration", @"DeviceSupportsCinnamon", @"DeviceSupportsClosedLoopHaptics", @"DeviceSupportsCrudeProx", @"DeviceSupportsDClr", @"DeviceSupportsDoNotDisturbWhileDriving", @"DeviceSupportsELabel", @"DeviceSupportsEnhancedAC3", @"DeviceSupportsFaceTime", @"DeviceSupportsFloorCounting", @"DeviceSupportsHaptics", @"DeviceSupportsHeartHealthAlerts", @"DeviceSupportsHeartRateVariability", @"DeviceSupportsHiResBuildings", @"DeviceSupportsLineIn", @"DeviceSupportsLiquidDetection_CorrosionMitigation", @"DeviceSupportsLivePhotoAuto", @"DeviceSupportsMapsBlurredUI", @"DeviceSupportsNavigation", @"DeviceSupportsNewton", @"DeviceSupportsPeriodicALSUpdates", @"DeviceSupportsPortraitLightEffectFilters", @"DeviceSupportsRGB10", @"DeviceSupportsRaiseToSpeak", @"DeviceSupportsSiDP", @"DeviceSupportsSimplisticRoadMesh", @"DeviceSupportsSingleCameraPortrait", @"DeviceSupportsSiriSpeaks", @"DeviceSupportsStereoAudioRecording", @"DeviceSupportsStudioLightPortraitPreview", @"DeviceSupportsSwimmingWorkouts", @"DeviceSupportsTapToWake", @"DeviceSupportsTethering", @"DeviceSupportsToneMapping", @"DeviceSupportsUSBTypeC", @"DeviceSupportsWebkit", @"DeviceSupportsYCbCr10", @"DeviceVariant", @"DeviceVariantGuess", @"DisplayMirroringCapability", @"ExternalChargeCapability", @"ExternalPowerSourceConnected", @"FDRSealingStatus", @"FMFAllowed", @"FaceTimeBackCameraTemporalNoiseReductionMode", @"FaceTimeCameraRequiresFastSwitchOptions", @"FaceTimeCameraSupportsHardwareFaceDetection", @"FaceTimeFrontCameraTemporalNoiseReductionMode", @"FaceTimePhotosOptIn", @"FirmwareVersion", @"FirstPartyLaunchTimeLimitScale", @"ForwardCameraCapability", @"FrontCameraOffsetFromDisplayCenter", @"FrontFacingCameraAutoHDRCapability", @"FrontFacingCameraBurstCapability", @"FrontFacingCameraHDRCapability", @"FrontFacingCameraHDROnCapability", @"FrontFacingCameraHFRCapability", @"FrontFacingCameraMaxVideoZoomFactor", @"FrontFacingCameraStillDurationForBurst", @"FrontFacingCameraVideoCapture1080pMaxFPS", @"FrontFacingCameraVideoCapture4kMaxFPS", @"FrontFacingCameraVideoCapture720pMaxFPS", @"GPSCapability", @"GSDeviceName", @"H264EncoderCapability", @"HEVCDecoder10bitSupported", @"HEVCDecoder12bitSupported", @"HEVCDecoder8bitSupported", @"HEVCEncodingCapability", @"HWModelStr", @"HallEffectSensorCapability", @"HardwarePlatform", @"HasAppleNeuralEngine", @"HasBaseband", @"HasBattery", @"HasDaliMode", @"HasExtendedColorDisplay", @"HasIcefall", @"HasInternalSettingsBundle", @"HasMesa", @"HasPKA", @"HasSEP", @"HasSpringBoard", @"HasThinBezel", @"HearingAidAudioEqualizationCapability", @"HearingAidLowEnergyAudioCapability", @"HearingAidPowerReductionCapability", @"HighestSupportedVideoMode", @"HomeButtonType", @"IDAMCapability", @"IcefallInRestrictedMode", @"Image4CryptoHashMethod", @"Image4Supported", @"IsEmulatedDevice", @"IsLargeFormatPhone", @"IsPwrOpposedVol", @"IsSimulator", @"IsUIBuild", @"LaunchTimeLimitScaleSupported", @"LisaCapability", @"LocationRemindersCapability", @"LynxPublicKey", @"MainDisplayRotation", @"MarketingProductName", @"MarketingVersion", @"MaxH264PlaybackLevel", @"MaximumScreenScale", @"MedusaFloatingLiveAppCapability", @"MedusaOverlayAppCapability", @"MedusaPIPCapability", @"MedusaPinnedAppCapability", @"MicrophoneCount", @"MinimumSupportediTunesVersion", @"MixAndMatchPrevention", @"MobileDeviceMinimumVersion", @"ModelNumber", @"MonarchLowEndHardware", @"MusicStore", @"N78aHack", @"NFCRadioCalibrationDataPresent", @"NavajoFusingState", @"NikeIpodCapability", @"OLEDDisplay", @"OfflineDictationCapability", @"OpenGLESVersion", @"PTPLargeFilesCapability", @"PanoramaCameraCapability", @"PartitionType", @"PearlIDCapability", @"PeekUICapability", @"PeekUIWidth", @"PersonalHotspotCapability", @"PhoneNumber", @"PhosphorusCapability", @"PhotoCapability", @"PhotoSharingCapability", @"PhotosPostEffectsCapability", @"PipelinedStillImageProcessingCapability", @"PlatinumCapability", @"ProductName", @"ProductType", @"ProductVersion", @"RF-exposure-separation-distance", @"RFExposureSeparationDistance", @"RearCameraCapability", @"RearCameraOffsetFromDisplayCenter", @"RearFacingCamera60fpsVideoCaptureCapability", @"RearFacingCameraAutoHDRCapability", @"RearFacingCameraBurstCapability", @"RearFacingCameraHDRCapability", @"RearFacingCameraHDROnCapability", @"RearFacingCameraHFRCapability", @"RearFacingCameraHFRVideoCapture1080pMaxFPS", @"RearFacingCameraHFRVideoCapture720pMaxFPS", @"RearFacingCameraMaxVideoZoomFactor", @"RearFacingCameraStillDurationForBurst", @"RearFacingCameraVideoCapture1080pMaxFPS", @"RearFacingCameraVideoCapture4kMaxFPS", @"RearFacingCameraVideoCapture720pMaxFPS", @"RearFacingCameraVideoCaptureFPS", @"RearFacingTelephotoCameraCapability", @"RegionCode", @"RegionInfo", @"RegionalBehaviorChinaBrick", @"RegionalBehaviorEUVolumeLimit", @"RegionalBehaviorGB18030", @"RegionalBehaviorGoogleMail", @"RegionalBehaviorNTSC", @"RegionalBehaviorNoPasscodeLocationTiles", @"RegionalBehaviorNoVOIP", @"RegionalBehaviorNoWiFi", @"RegionalBehaviorShutterClick", @"RegionalBehaviorValid", @"RegionalBehaviorVolumeLimit", @"RegulatoryIdentifiers", @"RegulatoryModelNumber", @"ReleaseType", @"RenderWideGamutImagesAtDisplayTime", @"RendersLetterPressSlowly", @"RequiredBatteryLevelForSoftwareUpdate", @"RestoreOSBuild", @"RestrictedCountryCodes", @"RingerSwitchCapability", @"RotateToWakeStatus", @"SBAllowSensitiveUI", @"SBCanForceDebuggingInfo", @"SDIOManufacturerTuple", @"SDIOProductInfo", @"SavageUID", @"ScreenRecorderCapability", @"SecureElement", @"ShouldHactivate", @"SiKACapability", @"SigningFuse", @"SiliconBringupBoard", @"SiriGestureCapability", @"SiriOfflineCapability", @"Skey", @"SoftwareBundleVersion", @"SoftwareDimmingAlpha", @"SphereCapability", @"StarkCapability", @"StrictWakeKeyboardCases", @"SupportedDeviceFamilies", @"SupportsBurninMitigation", @"SupportsEDUMU", @"SupportsForceTouch", @"SupportsIrisCapture", @"SupportsLowPowerMode", @"SupportsPerseus", @"SupportsRotateToWake", @"SupportsSOS", @"SupportsSSHBButtonType", @"SupportsTouchRemote", @"TimeSyncCapability", @"TouchDelivery120Hz", @"UIBackgroundQuality", @"UIParallaxCapability", @"UIProceduralWallpaperCapability", @"UIReachability", @"UserIntentPhysicalButtonCGRect", @"UserIntentPhysicalButtonCGRectString", @"UserIntentPhysicalButtonNormalizedCGRect", @"VibratorCapability", @"VideoStillsCapability", @"WAGraphicQuality", @"WLANBkgScanCache", @"WSKU", @"WiFiCallingCapability", @"WifiAntennaSKUVersion", @"WifiCallingSecondaryDeviceCapability", @"WifiChipset", @"WifiFirmwareVersion", @"WifiVendor", @"WirelessChargingCapability", @"YonkersUID", @"accelerometer", @"accessibility", @"additional-text-tones", @"aggregate-cam-photo-zoom", @"aggregate-cam-video-zoom", @"airDropRestriction", @"airplay-mirroring", @"airplay-no-mirroring", @"all-features", @"allow-32bit-apps", @"ambient-light-sensor", @"ane", @"any-telephony", @"apn", @"app-store", @"apple-internal-install", @"application-installation", @"applicationInstallation", @"arkit", @"arm64", @"armv6", @"armv7", @"armv7s", @"assistant", @"auto-focus", @"auto-focus-camera", @"baseband-chipset", @"bluetooth", @"bluetooth-le", @"builtin-mics", @"c2k-device", @"call-forwarding", @"call-waiting", @"caller-id", @"camera-flash", @"camera-front", @"camera-front-flash", @"camera-rear", @"cameraRestriction", @"car-integration", @"cell-broadcast", @"cellular-data", @"class", @"closed-loop", @"contains-cellular-radio", @"crypto-hash-method", @"data-plan", @"debug-board-revision", @"delay-sleep-for-headset-click", @"device-color-policy", @"device-colors", @"device-name", @"device-name-localized", @"dictation", @"display-mirroring", @"display-rotation", @"displayport", @"does-not-support-gamekit", @"enc-top-type", @"encode-aac", @"encrypted-data-partition", @"enforce-googlemail", @"enforce-shutter-click", @"explicitContentRestriction", @"face-detection-support", @"fast-switch-options", @"fcc-logos-via-software", @"fcm-type", @"firmware-version", @"flash", @"front-auto-hdr", @"front-burst", @"front-burst-image-duration", @"front-facing-camera", @"front-flash-capability", @"front-hdr", @"front-hdr-on", @"front-max-video-fps-1080p", @"front-max-video-fps-4k", @"front-max-video-fps-720p", @"front-max-video-zoom", @"front-slowmo", @"full-6", @"function-button_halleffect", @"function-button_ringerab", @"gamekit", @"gas-gauge-battery", @"gps", @"gps-capable", @"green-tea", @"gyroscope", @"h264-encoder", @"hall-effect-sensor", @"haptics", @"hardware-keyboard", @"has-sphere", @"hd-video-capture", @"hdr-image-capture", @"healthkit", @"hearingaid-audio-equalization", @"hearingaid-low-energy-audio", @"hearingaid-power-reduction", @"hiccough-interval", @"hide-non-default-apps", @"hidpi", @"home-button-type", @"homescreen-wallpaper", @"hw-encode-snapshots", @"hw-snapshots-need-purplegfx", @"iAP2Capability", @"iTunesFamilyID", @"iap2-protocol-supported", @"image4-supported", @"international-settings", @"io-surface-backed-images", @"ipad", @"kConferenceCallType", @"kSimultaneousCallAndDataCurrentlySupported", @"kSimultaneousCallAndDataSupported", @"large-format-phone", @"live-effects", @"live-photo-capture", @"load-thumbnails-while-scrolling", @"location-reminders", @"location-services", @"lte-device", @"magnetometer", @"main-screen-class", @"main-screen-height", @"main-screen-orientation", @"main-screen-pitch", @"main-screen-scale", @"main-screen-width", @"marketing-name", @"mesa", @"metal", @"microphone", @"mix-n-match-prevention-status", @"mms", @"modelIdentifier", @"multi-touch", @"multitasking", @"multitasking-gestures", @"music-store", @"n78a-mode", @"name", @"navigation", @"nfc", @"nfcWithRadio", @"nike-ipod", @"nike-support", @"no-coreroutine", @"no-hi-res-buildings", @"no-simplistic-road-mesh", @"not-green-tea", @"offline-dictation", @"opal", @"opengles-1", @"opengles-2", @"opengles-3", @"opposed-power-vol-buttons", @"ota-activation", @"panorama", @"peek-ui-width", @"peer-peer", @"personal-hotspot", @"photo-adjustments", @"photo-stream", @"piezo-clicker", @"pipelined-stillimage-capability", @"platinum", @"post-effects", @"pressure", @"prox-sensor", @"proximity-sensor", @"ptp-large-files", @"public-key-accelerator", @"rear-auto-hdr", @"rear-burst", @"rear-burst-image-duration", @"rear-cam-telephoto-capability", @"rear-facing-camera", @"rear-hdr", @"rear-hdr-on", @"rear-max-slomo-video-fps-1080p", @"rear-max-slomo-video-fps-720p", @"rear-max-video-fps-1080p", @"rear-max-video-fps-4k", @"rear-max-video-fps-720p", @"rear-max-video-frame_rate", @"rear-max-video-zoom", @"rear-slowmo", @"regulatory-model-number", @"ringer-switch", @"role", @"sandman-support", @"screen-dimensions", @"sensitive-ui", @"shoebox", @"sika-support", @"sim", @"sim-phonebook", @"siri-gesture", @"slow-letterpress-rendering", @"sms", @"software-bundle-version", @"software-dimming-alpha", @"stand-alone-contacts", @"still-camera", @"stockholm", @"supports-always-listening", @"telephony", @"telephony-maximum-generation", @"thin-bezel", @"tnr-mode-back", @"tnr-mode-front", @"touch-id", @"tv-out-crossfade", @"tv-out-settings", @"ui-background-quality", @"ui-no-parallax", @"ui-no-procedural-wallpaper", @"ui-pip", @"ui-reachability", @"ui-traffic-cheap-shaders", @"ui-weather-quality", @"umts-device", @"unified-ipod", @"venice", @"video-camera", @"video-cap", @"video-stills", @"voice-control", @"voip", @"volume-buttons", @"wapi", @"watch-companion", @"wi-fi", @"wifi", @"wifi-chipset", @"wifi-module-sn", @"wildcat", @"wlan", @"youtube", @"youtube-plugin", @"youtubePlugin", nil]) if (CFTypeRef answer = $MGCopyAnswer(reinterpret_cast(name))) { [answers setObject:(id)answer forKey:name]; CFRelease(answer); } capability = answers; } } } if (capability != nil) { if ([capability isKindOfClass:[NSString class]]) { printf("%s\n", [(NSString*)capability UTF8String]); } else { printf("%s\n", capability == nil ? "(null)" : [[capability description] UTF8String]); } break; } CFRunLoopRun(); } [pool release]; return 0; }