前言
Flipswitch/Switches/Autolock.x
Flipswitch/Switches/Wifi.x
Flipswitch/Switches/WifiProxy.x
Flipswitch/Switches/VPN.x
正文
可以考虑加上签名
[Release] Disable autolock on AC - Disables Auto-lock when plugged-in (BigBoss, free)
- iPhone:/Library/MobileSubstrate/DynamicLibraries root# ls -lrt
-rw-r--r-- 1 root wheel 57 Oct 17 2015 DisableautolockonACpower.plist
-rwxr-xr-x 1 root wheel 132096 Oct 17 2015 DisableautolockonACpower.dylib*
- com.pawelgil.disableautolockonacpower
- iPhone:/Library/MobileSubstrate/DynamicLibraries root# find / -amin -1
<!-- http://moreinfo.thebigboss.org/moreinfo/depiction.php?file=disableautolockonacpowerDp -->
/private/etc/apt/sources.list.d/cydia.list
/private/var/mobile/Library/Caches/com.saurik.Cydia/sources.list
/private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles/Library/ConfigurationProfiles/UserSettings.plist
/private/var/containers/Shared/SystemGroup/systemgroup.com.apple.lsd.iconscache/Library/Caches/com.apple.IconsCache/F6DF118A-51FB-36BB-9951-E4A53E4A47F2-8C96354F-D66E-379A-A4D9-B3C2A1FBE01D
/private/var/db/stash/_.UmC91h/DynamicLibraries/DisableautolockonACpower.dylib
/private/var/db/stash/_.UmC91h/DynamicLibraries/DisableautolockonACpower.plist
/private/var/installd/Library/MobileInstallation/DiskImagesInfo.plist
/private/var/keybags/systembag.kb
/private/var/lib/apt/extended_states
/private/var/lib/dpkg/info/com.pawelgil.disableautolockonacpower.list
/private/var/lib/dpkg/info/com.pawelgil.disableautolockonacpower.md5sums
/private/var/lib/dpkg/status
/private/var/lib/dpkg/status-old
/private/var/mobile/Library/Preferences/com.apple.WebUI.plist
/private/var/mobile/Library/Preferences/com.apple.aggregated.plist
/private/var/mobile/Library/SpringBoard/DesiredIconState.plist
/private/var/mobile/Library/SpringBoard/IconState.plist
/private/var/mobile/Library/SpringBoard/LockBackgroundThumbnail.jpg
/private/var/mobile/Library/UserConfigurationProfiles/EffectiveUserSettings.plist
/private/var/mobile/Library/UserConfigurationProfiles/PublicInfo/PublicEffectiveUserSettings.plist
/private/var/mobile/Library/UserConfigurationProfiles/UserSettings.plist
/private/var/root/Library/Caches/locationd/clients.plist
/private/var/tmp/SBLastRestoreIdentifier.KwfK2S
- /private/var/lib/dpkg/info/com.pawelgil.disableautolockonacpower.list
iPhone:~ root# cat /private/var/lib/dpkg/info/com.pawelgil.disableautolockonacpower.list
/.
/Library
/Library/MobileSubstrate
/Library/MobileSubstrate/DynamicLibraries
/Library/MobileSubstrate/DynamicLibraries/DisableautolockonACpower.dylib
/Library/MobileSubstrate/DynamicLibraries/DisableautolockonACpower.plist
<!-- iPhone:/private/var/lib/dpkg/info root# ls -lrt com.pawelgil*
-rw-r--r-- 1 root wheel 212 Mar 31 19:03 com.pawelgil.disableautolockonacpower.md5sums
-rw-r--r-- 1 root wheel 225 Mar 31 19:03 com.pawelgil.disableautolockonacpower.list
-->
- /Library/MobileSubstrate/DynamicLibraries/DisableautolockonACpower.plist
{ Filter = { Bundles = ( "com.apple.springboard" ); }; }
- EntryPoint
int EntryPoint() {
objc_getClass("SBUIController");
r0 = MSHookMessageEx();
return r0;
}
- iPhone:~ root# ls -lrt /var/mobile/Library/Preferences
autoLockValue
[[r0 sharedConnection] setValue:r6 forSetting:@"maxInactivity"];
- sub_7c60
int sub_7c60(int arg0) {
stack[2043] = r4;
*((sp - 0x14) + 0xfffffffffffffffc) = r8;
(*0x8078)(arg0);
r6 = [arg0 isOnAC];
r0 = *0x807c;
if (r0 == 0x0) {
r0 = objc_getClass("MCProfileConnection");
*0x807c = r0;
}
r5 = [[r0 sharedConnection] effectiveValueForSetting:@"maxInactivity"];
if ((r6 & 0xff) != 0x0) {
[[NSUserDefaults standardUserDefaults] setObject:r5 forKey:@"com.pawelgil.disableautolockonacpower"];
[r5 release];
r0 = *0x807c;
if (r0 == 0x0) {
r0 = objc_getClass("MCProfileConnection");
*0x807c = r0;
}
r4 = [r0 sharedConnection];
[NSNumber numberWithInt:0x80000000 ^ 0xffffffff];
r1 = @selector(setValue:forSetting:);
r0 = r4;
}
else {
if ([r5 integerValue] != (0x80000000 ^ 0xffffffff)) {
[[NSUserDefaults standardUserDefaults] setValue:r5 forKey:@"com.pawelgil.disableautolockonacpower"];
}
r6 = [[NSUserDefaults standardUserDefaults] objectForKey:@"com.pawelgil.disableautolockonacpower"];
r0 = *0x807c;
if (r0 == 0x0) {
r0 = objc_getClass("MCProfileConnection");
*0x807c = r0;
}
[[r0 sharedConnection] setValue:r6 forSetting:@"maxInactivity"];
[r6 release];
r0 = r5;
r1 = @selector(release);
}
r0 = objc_msgSend(r0, r1);
return r0;
}
MCProfileConnection
- cydia 分析MCProfileConnection
iPhone:/Library/MobileSubstrate/DynamicLibraries root# cycript -p SpringBoard
cy# objc_getClass("MCProfileConnection")
MCProfileConnection
cy# ÆMCProfileConnection sharedConnectionÅ
#"<MCProfileConnection: 0x1700d7c30>"
cy# [0x1700d7c30 _ivarDescription].toString()
`<__NSCFNumber: 0xb000001700d7c305>:
in __NSCFNumber:
in NSNumber:
in NSValue:
in NSObject:
\tisa (Class): __NSCFNumber (isa, 0x0)`
cy#
- iOS10-Runtime-Headers/PrivateFrameworks/ManagedConfiguration.framework/MCProfileConnection.h
#import <ManagedConfiguration/ManagedConfiguration.h>
Image: /System/Library/PrivateFrameworks/ManagedConfiguration.framework/ManagedConfiguration
int currentAutoLockValue = [[[[MCProfileConnection sharedConnection] effectiveParametersForValueSetting:@"maxInactivity"] objectForKey:@"value"] intValue];
toggledValue = [NSNumber numberWithInt:INT_MAX];
[[MCProfileConnection sharedConnection] setValue:toggledValue forSetting:@"maxInactivity"];
- iOS10-Runtime-Headers/PrivateFrameworks/ManagedConfiguration.framework/MCProfileConnection.h
+ (id)sharedConnection;
- (void)_passcodeDidChange;
- (id)managedAppIDs;
- (id)managedWiFiNetworkNames;
- (void)lockDevice;
- (void)lockDeviceImmediately:(bool)arg1;
- screen is locked
UserEventAgent : screen is locked
identityservicesd :System did lock
sharingd : Screen state changed to on
MSHookMessageEx
replace Objective-C message implementations
- void MSHookMessageEx(Class _class, SEL message, IMP hook, IMP *old);
NSString *(*oldDescription)(id self, SEL _cmd);
// implicit self and _cmd are explicit with IMP ABI
NSString *newDescription(id self, SEL _cmd) {
NSString *description = (*oldDescription)(self, _cmd);
description = [description stringByAppendingString:@"!"];
return description;
}
MSHookMessageEx(
[NSObject class], @selector(description),
&newDescription, &oldDescription
);
DisplayController
- DisplayController.h
#import <Preferences/Preferences.h>
%hook DisplayController
- (NSMutableArray *)specifiers
{
NSMutableArray *specifiers = %orig();
for (PSSpecifier *spec in specifiers) {
identifier = [spec propertyForKey:@"id"];
if ([identifier isEqualToString:@"AUTO_BRIGHTNESS"]) {
shouldMove = NO;
}
if ([identifier isEqualToString:@"DISPLAY_ZOOM_GROUP"]) {
index1 = [specifiers indexOfObject:spec];
}
else if ([identifier isEqualToString:@"MAGNIFY"]) {
index2 = [specifiers indexOfObject:spec];
}
}
}
%end
%ctor
{
const char *pref = "/System/Library/PrivateFrameworks/Preferences.framework/Preferences";
MSHookFunction(MGCopyAnswer, MSHake(MGCopyAnswer));
MSImageRef ref = MSGetImageByName(pref);
const char *func1 = "___PSGetMagnifyModes_block_invoke";
PSGetMagnifyModes = (NSArray *(*)())MSFindSymbol(ref, func1);
MSHookFunction((void *)PSGetMagnifyModes, (void *)hax_PSGetMagnifyModes, (void **)&original_PSGetMagnifyModes);
%init;
}
cycript 分析Preferences
- UIApp
iPhone:/System/Library/PreferenceBundles root# cycript -p Preferences
cy# [UIApp description]
@"<PreferencesAppController: 0x151d34c20>"
<!-- https://github.com/coolstar/iOS-8.3-Preferences-Headers/blob/master/PreferencesAppController.h -->
<!-- https://github.com/coolstar/iOS-8.3-Preferences-Headers/blob/master/Preferences.h -->
#import "DisplayController.h"
- cy# UIApp.keyWindow.recursiveDescription().toString()
- [[[UIWindow keyWindow] rootViewController] _printHierarchy].toString()
cy# [[[UIWindow keyWindow] rootViewController] _printHierarchy].toString()
`<PSSplitViewController 0x10023e680>, state: appeared, view: <UILayoutContainerView 0x10023eef0>
| <UINavigationController 0x101019c00>, state: appeared, view: <UILayoutContainerView 0x1003446f0>
| | <PSUIPrefsListController 0x101023000>, state: disappeared, view: <PSListContainerView 0x100358540> not in the window
| | <PSUIPrefsRootController 0x101016800>, state: appeared, view: <UILayoutContainerView 0x10026b9b0>
| | | <PSUIDisplayController 0x10090c200>, state: disappeared, view: <PSListContainerView 0x10027d7e0> not in the window
| | | <PSListItemsController 0x100820200>, state: appeared, view: <PSListContainerView 0x100247220>`
- cy# [#0x100820200 _ivarDescription].toString()
\t_sceneSettingsGeometryMutationDiffInspector (UIApplicationSceneSettingsDiffInspector*): <UIApplicationSceneSettingsDiffInspector: 0x170032f20>
see also
转载请注明:张坤楠的博客 > com.apple.Preferences
在操作过程或者文章有问题的话欢迎在 原文 里提问或指正。