Skip to content

Instantly share code, notes, and snippets.

@steipete
Last active December 21, 2017 17:49
Show Gist options
  • Save steipete/77fb424e370402b7a270 to your computer and use it in GitHub Desktop.
Save steipete/77fb424e370402b7a270 to your computer and use it in GitHub Desktop.
#import "Aspects.h"
#import "fishhook.h"
#import <dlfcn.h>
// UIAnimationDragCoefficient
// UISimulatedApplicationResizeGestureEnabled
// UIExternalTouchSloppinessFactor
// UIEnableParallaxEffects
// UIDeviceUsesLowQualityGraphics
// UIMotionEffectsEnabled
// UIMotionEffectMotionUpdateFrequency
// UIMotionEffectMotionUpdateSlowFrequency
// UIMotionEffectMinimumBacklightLevel
// UIMotionEffectHysteresisExitThreshold
// UIMotionEffectHysteresisEntranceThreshold
// UIMotionEffectUIUpdateFrequency
// UIMotionEffectUIUpdateSlowFrequency
// UIDocumentConsoleLogLevel
// UIDocumentFileLogLevel
// GestureFailureMapLogging
// UIPopoverControllerForceAttemptsToAvoidKeyboard
// _UISiriAnimationSpeed ...
// UIBackdropViewNoBlur
// UIBackdropViewNoComputedColorSettingsKey
static NSDictionary *UIKitOverrides() {
return @{@"UIPopoverControllerPaintsTargetRect" : @YES, // only works on iOS 7
@"TouchLogging" : @YES,
@"AnimationLogging" : @YES,
@"UIUseAugmentedPopGesture" : @YES,
@"UIKitDecorateFallbackImagesFromScale" : @YES,
@"UIScreenEdgePanRecognizerShouldLog" : @YES,
@"SystemGestureGateLogging" : @YES,
@"GestureLogging" : @YES,
@"GestureFailureMapLogging" : @YES,
@"UIKeyboardTypingSpeedLogger" : @YES,
@"UICatchCAPackageDecodingExceptions" : @YES
};
}
static BOOL (*GetBoolAnswer)(NSString *capability);
static BOOL PSTGetBoolAnswer(NSString *capability) {
return [capability isEqual:@"InternalBuild"] ? YES : GetBoolAnswer(capability);
}
__attribute__((constructor)) static void PSTEnableUIKitDebugMode() {
// Enable Internal Build mode.
GetBoolAnswer = dlsym(dlopen("/usr/lib/libMobileGestalt.dylib", RTLD_LAZY), "MGGetBoolAnswer");
rebind_symbols((struct rebinding[1]){{"MGGetBoolAnswer", PSTGetBoolAnswer}}, 1);
// Install custom overrides.
NSDictionary *overrides = UIKitOverrides();
[[NSUserDefaults standardUserDefaults] aspect_hookSelector:@selector(persistentDomainForName:) withOptions:0 usingBlock:^(id<AspectInfo> info, NSString *domainName) {
if ([domainName hasSuffix:@"com.apple.UIKit"]) {
__autoreleasing NSDictionary *dictionary;
[[info originalInvocation] getReturnValue:&dictionary];
NSMutableDictionary *mutable = [NSMutableDictionary dictionaryWithDictionary:dictionary];
[mutable addEntriesFromDictionary:overrides];
dictionary = [mutable copy];
[[info originalInvocation] setReturnValue:&dictionary];
}
} error:NULL];
[NSUserDefaults aspect_hookSelector:@selector(objectForKey:) withOptions:0 usingBlock:^(id<AspectInfo> info, NSString *key) {
if (overrides[key]) {
__autoreleasing id value = overrides[key];
[[info originalInvocation] setReturnValue:&value];
}
} error:NULL];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment