├── .gitignore ├── cr4shedgui ├── Resources │ ├── LaunchImage.png │ ├── LaunchImage@2x.png │ ├── LaunchImage-700-568h@2x.png │ ├── LaunchImage-800-667h@2x.png │ ├── LaunchImage-700-Landscape@2x~ipad.png │ ├── LaunchImage-700-Landscape~ipad.png │ ├── LaunchImage-700-Portrait@2x~ipad.png │ ├── LaunchImage-700-Portrait~ipad.png │ ├── LaunchImage-800-Landscape-736h@3x.png │ ├── LaunchImage-800-Portrait-736h@3x.png │ ├── AppIcon20x20@1x.png │ ├── AppIcon20x20@2x.png │ ├── AppIcon20x20@3x.png │ ├── AppIcon29x29@1x.png │ ├── AppIcon29x29@2x.png │ ├── AppIcon29x29@3x.png │ ├── AppIcon40x40@1x.png │ ├── AppIcon40x40@2x.png │ ├── AppIcon40x40@3x.png │ ├── AppIcon60x60@2x.png │ ├── AppIcon60x60@3x.png │ ├── AppIcon76x76@1x.png │ ├── AppIcon76x76@2x.png │ ├── AppIcon83.5x83.5@2x.png │ └── Info.plist ├── main.m ├── CRAProcessManager.h ├── CRALogController.h ├── UIImage+UIKitImage.h ├── CRAAppDelegate.h ├── CRASettingsViewController.h ├── CRAProcViewController.h ├── Process.h ├── Log.h ├── dpkgutils.h ├── CRABlacklistViewController.h ├── Makefile ├── CRARootViewController.h ├── CRALogInfoViewController.h ├── Log.m ├── Process.m ├── dpkgutils.m ├── UIImage+UIKitImage.m ├── NSString+HTML.h ├── CRAAppDelegate.m ├── ent.xml ├── CRAProcessManager.m ├── CRALogController.m ├── CRASettingsViewController.m ├── CRABlacklistViewController.m ├── CRAProcViewController.m ├── NSString+HTML.m └── CRARootViewController.m ├── 0Cr4shed.plist ├── .gitattributes ├── cr4shedmach ├── Cr4shedMach.plist ├── Makefile ├── cr4shed_mach.h ├── methods.txt ├── ivars.txt ├── mach_utils.h └── mach_utils.mm ├── cr4shedjetsam ├── Cr4shedJetsam.plist ├── Makefile ├── TweakJetsam.xm └── cr4shed_jetsam.h ├── Libraries ├── libmryipc.dylib ├── libnotifications.dylib └── libMobileGestalt.tbd ├── Frameworks ├── FRPreferences.framework │ ├── Info.plist │ ├── FRPreferences │ └── Headers │ │ ├── FRPValueCell.h │ │ ├── FRPDeveloperCell.h │ │ ├── FRPLinkCell.h │ │ ├── FRPViewSection.h │ │ ├── FRPSettings.h │ │ ├── FRPreferences.h │ │ ├── FRPrefs.h │ │ ├── FRPSwitchCell.h │ │ ├── FRPTextFieldCell.h │ │ ├── FRPViewCell.h │ │ ├── FRPSection.h │ │ ├── FRPListCell.h │ │ ├── FRPSelectListTable.h │ │ ├── FRPSliderCell.h │ │ ├── FRPCell.h │ │ └── FRPSegmentCell.h └── Cephei.framework │ ├── Headers │ ├── CompactConstraint.h │ ├── NSDictionary+HBAdditions.h │ ├── HBOutputForShellCommand.h │ ├── HBRespringController.h │ ├── NSString+HBAdditions.h │ ├── UIColor+HBAdditions.h │ ├── NSLayoutConstraint+CompactConstraint.h │ └── UIView+CompactConstraint.h │ └── Cephei.tbd ├── Include ├── Cephei │ ├── CompactConstraint.h │ ├── NSDictionary+HBAdditions.h │ ├── HBOutputForShellCommand.h │ ├── HBRespringController.h │ ├── NSString+HBAdditions.h │ ├── UIColor+HBAdditions.h │ ├── NSLayoutConstraint+CompactConstraint.h │ └── UIView+CompactConstraint.h ├── libnotifications.h ├── symbolication.h ├── MRYIPCCenter.h └── sharedutils.h ├── control ├── layout └── DEBIAN │ ├── postrm │ └── postinst ├── frpreferences ├── FRPValueCell.h ├── Makefile ├── FRPDeveloperCell.h ├── FRPLinkCell.h ├── FRPViewSection.h ├── FRPSettings.h ├── FRPreferences.h ├── FRPrefs.h ├── FRPSwitchCell.h ├── FRPTextFieldCell.h ├── FRPViewCell.h ├── FRPSection.h ├── FRPListCell.h ├── FRPValueCell.m ├── Resources │ └── Info.plist ├── FRPSelectListTable.h ├── FRPSliderCell.h ├── FRPCell.h ├── FRPSection.m ├── FRPCell.m ├── FRPSegmentCell.h ├── FRPLinkCell.m ├── FRPViewSection.m ├── FRPViewCell.m ├── FRPSwitchCell.m ├── FRPDeveloperCell.m ├── FRPSettings.m ├── FRPTextFieldCell.m ├── FRPSelectListTable.m ├── FRPListCell.m ├── FRPSegmentCell.m ├── FRPreferences.m └── FRPSliderCell.m ├── cr4shedd ├── ent.plist ├── Makefile ├── layout │ └── Library │ │ └── LaunchDaemons │ │ └── com.muirey03.cr4shedd.plist └── main.mm ├── Makefile ├── README.md ├── .travis.yml ├── Shared ├── symbolication.mm └── sharedutils.mm └── Tweak.xm /.gitignore: -------------------------------------------------------------------------------- 1 | .theos 2 | packages -------------------------------------------------------------------------------- /cr4shedgui/Resources/LaunchImage.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cr4shedgui/Resources/LaunchImage@2x.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cr4shedgui/Resources/LaunchImage-700-568h@2x.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cr4shedgui/Resources/LaunchImage-800-667h@2x.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cr4shedgui/Resources/LaunchImage-700-Landscape@2x~ipad.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cr4shedgui/Resources/LaunchImage-700-Landscape~ipad.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cr4shedgui/Resources/LaunchImage-700-Portrait@2x~ipad.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cr4shedgui/Resources/LaunchImage-700-Portrait~ipad.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cr4shedgui/Resources/LaunchImage-800-Landscape-736h@3x.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cr4shedgui/Resources/LaunchImage-800-Portrait-736h@3x.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /0Cr4shed.plist: -------------------------------------------------------------------------------- 1 | { Filter = { Bundles = ( "com.apple.Foundation" ); }; } 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /cr4shedmach/Cr4shedMach.plist: -------------------------------------------------------------------------------- 1 | { Filter = { Executables = ( "ReportCrash" ); }; } 2 | -------------------------------------------------------------------------------- /cr4shedjetsam/Cr4shedJetsam.plist: -------------------------------------------------------------------------------- 1 | { Filter = { Executables = ( "ReportMemoryException" ); }; } 2 | -------------------------------------------------------------------------------- /Libraries/libmryipc.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muirey03/Cr4shed/HEAD/Libraries/libmryipc.dylib -------------------------------------------------------------------------------- /Libraries/libnotifications.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muirey03/Cr4shed/HEAD/Libraries/libnotifications.dylib -------------------------------------------------------------------------------- /cr4shedgui/Resources/AppIcon20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muirey03/Cr4shed/HEAD/cr4shedgui/Resources/AppIcon20x20@1x.png -------------------------------------------------------------------------------- /cr4shedgui/Resources/AppIcon20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muirey03/Cr4shed/HEAD/cr4shedgui/Resources/AppIcon20x20@2x.png -------------------------------------------------------------------------------- /cr4shedgui/Resources/AppIcon20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muirey03/Cr4shed/HEAD/cr4shedgui/Resources/AppIcon20x20@3x.png -------------------------------------------------------------------------------- /cr4shedgui/Resources/AppIcon29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muirey03/Cr4shed/HEAD/cr4shedgui/Resources/AppIcon29x29@1x.png -------------------------------------------------------------------------------- /cr4shedgui/Resources/AppIcon29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muirey03/Cr4shed/HEAD/cr4shedgui/Resources/AppIcon29x29@2x.png -------------------------------------------------------------------------------- /cr4shedgui/Resources/AppIcon29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muirey03/Cr4shed/HEAD/cr4shedgui/Resources/AppIcon29x29@3x.png -------------------------------------------------------------------------------- /cr4shedgui/Resources/AppIcon40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muirey03/Cr4shed/HEAD/cr4shedgui/Resources/AppIcon40x40@1x.png -------------------------------------------------------------------------------- /cr4shedgui/Resources/AppIcon40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muirey03/Cr4shed/HEAD/cr4shedgui/Resources/AppIcon40x40@2x.png -------------------------------------------------------------------------------- /cr4shedgui/Resources/AppIcon40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muirey03/Cr4shed/HEAD/cr4shedgui/Resources/AppIcon40x40@3x.png -------------------------------------------------------------------------------- /cr4shedgui/Resources/AppIcon60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muirey03/Cr4shed/HEAD/cr4shedgui/Resources/AppIcon60x60@2x.png -------------------------------------------------------------------------------- /cr4shedgui/Resources/AppIcon60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muirey03/Cr4shed/HEAD/cr4shedgui/Resources/AppIcon60x60@3x.png -------------------------------------------------------------------------------- /cr4shedgui/Resources/AppIcon76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muirey03/Cr4shed/HEAD/cr4shedgui/Resources/AppIcon76x76@1x.png -------------------------------------------------------------------------------- /cr4shedgui/Resources/AppIcon76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muirey03/Cr4shed/HEAD/cr4shedgui/Resources/AppIcon76x76@2x.png -------------------------------------------------------------------------------- /Frameworks/FRPreferences.framework/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muirey03/Cr4shed/HEAD/Frameworks/FRPreferences.framework/Info.plist -------------------------------------------------------------------------------- /cr4shedgui/Resources/AppIcon83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muirey03/Cr4shed/HEAD/cr4shedgui/Resources/AppIcon83.5x83.5@2x.png -------------------------------------------------------------------------------- /Frameworks/FRPreferences.framework/FRPreferences: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muirey03/Cr4shed/HEAD/Frameworks/FRPreferences.framework/FRPreferences -------------------------------------------------------------------------------- /cr4shedgui/main.m: -------------------------------------------------------------------------------- 1 | #import "CRAAppDelegate.h" 2 | 3 | int main(int argc, char* argv[]) 4 | { 5 | @autoreleasepool 6 | { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass(CRAAppDelegate.class)); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Include/Cephei/CompactConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Marco Arment on 2014-04-06. 3 | // Copyright (c) 2014 Marco Arment. See included LICENSE file. 4 | // 5 | 6 | #import "NSLayoutConstraint+CompactConstraint.h" 7 | #import "UIView+CompactConstraint.h" 8 | -------------------------------------------------------------------------------- /Frameworks/Cephei.framework/Headers/CompactConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Marco Arment on 2014-04-06. 3 | // Copyright (c) 2014 Marco Arment. See included LICENSE file. 4 | // 5 | 6 | #import "NSLayoutConstraint+CompactConstraint.h" 7 | #import "UIView+CompactConstraint.h" 8 | -------------------------------------------------------------------------------- /cr4shedgui/CRAProcessManager.h: -------------------------------------------------------------------------------- 1 | @import Foundation; 2 | @class Process; 3 | 4 | @interface CRAProcessManager : NSObject 5 | @property (nonatomic, strong) NSMutableArray* processes; 6 | +(instancetype)sharedInstance; 7 | -(void)refresh; 8 | -(void)sortProcs; 9 | @end 10 | -------------------------------------------------------------------------------- /Include/libnotifications.h: -------------------------------------------------------------------------------- 1 | @interface CPNotification : NSObject 2 | +(void)showAlertWithTitle:(NSString*)title message:(NSString*)message userInfo:(NSDictionary*)userInfo badgeCount:(int)badgeCount soundName:(NSString*)soundName delay:(double)delay repeats:(BOOL)repeats bundleId:(NSString*)bundleId; 3 | @end -------------------------------------------------------------------------------- /control: -------------------------------------------------------------------------------- 1 | Package: com.muirey03.cr4shed 2 | Name: Cr4shed 3 | Depends: mobilesubstrate, com.muirey03.libmryipc, firmware (>= 9.0), ws.hbang.common (>= 1.11) 4 | Version: 4.3.0 5 | Architecture: iphoneos-arm 6 | Description: A modern crash reporter for iOS 7 | Maintainer: Muirey03 8 | Author: Muirey03 9 | Section: Tweaks 10 | -------------------------------------------------------------------------------- /cr4shedgui/CRALogController.h: -------------------------------------------------------------------------------- 1 | @import UIKit; 2 | @import WebKit; 3 | 4 | @class Log; 5 | @interface CRALogController : UIViewController 6 | { 7 | WKWebView* webView; 8 | NSString* logMessage; 9 | } 10 | @property (nonatomic, strong) Log* log; 11 | -(instancetype)initWithLog:(Log*)log; 12 | @end 13 | -------------------------------------------------------------------------------- /layout/DEBIAN/postrm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "Killing cr4shedd..." 3 | launchctl unload /Library/LaunchDaemons/com.muirey03.cr4shedd.plist 2> /dev/null 4 | echo "Killing ReportCrash..." 5 | killall -9 ReportCrash 2> /dev/null 6 | echo "Killing ReportMemoryException..." 7 | killall -9 ReportMemoryException 2> /dev/null 8 | echo "Done!" 9 | exit 0 10 | -------------------------------------------------------------------------------- /cr4shedgui/UIImage+UIKitImage.h: -------------------------------------------------------------------------------- 1 | @import UIKit; 2 | 3 | @interface UIImage (Private) 4 | +(UIImage*)imageNamed:(NSString*)name inBundle:(NSBundle*)bundle; 5 | @end 6 | 7 | @interface UIImage (UIKitImage) 8 | +(UIImage*)uikitImageNamed:(NSString*)name; 9 | -(UIImage*)resizeToWidth:(CGFloat)newWidth; 10 | -(UIImage*)resizeToHeight:(CGFloat)newHeight; 11 | @end 12 | -------------------------------------------------------------------------------- /frpreferences/FRPValueCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPValueCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/22/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | @interface FRPValueCell : FRPCell 12 | 13 | + (instancetype)cellWithTitle:(NSString *)title detail:(NSString *)detail; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /frpreferences/Makefile: -------------------------------------------------------------------------------- 1 | include $(THEOS)/makefiles/common.mk 2 | 3 | FRAMEWORK_NAME = FRPreferences 4 | 5 | FRPreferences_FILES = $(wildcard *.m) 6 | FRPreferences_PUBLIC_HEADERS = $(wildcard *.h) 7 | FRPreferences_INSTALL_PATH = /Library/Frameworks 8 | FRPreferences_CFLAGS = -fobjc-arc -Wno-deprecated-declarations 9 | 10 | include $(THEOS_MAKE_PATH)/framework.mk 11 | -------------------------------------------------------------------------------- /Frameworks/FRPreferences.framework/Headers/FRPValueCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPValueCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/22/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | @interface FRPValueCell : FRPCell 12 | 13 | + (instancetype)cellWithTitle:(NSString *)title detail:(NSString *)detail; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /cr4shedgui/CRAAppDelegate.h: -------------------------------------------------------------------------------- 1 | @import UIKit; 2 | @import UserNotifications; 3 | 4 | @interface CRAAppDelegate : UIResponder 5 | { 6 | UITabBarController* _tabBarVC; 7 | UINavigationController* _rootViewController; 8 | UINavigationController* _settingsViewController; 9 | } 10 | @property (nonatomic, strong) UIWindow* window; 11 | @end 12 | -------------------------------------------------------------------------------- /frpreferences/FRPDeveloperCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPDeveloperCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/3/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | @interface FRPDeveloperCell : FRPCell 12 | 13 | + (instancetype)cellWithTitle:(NSString *)title detail:(NSString *)detail image:(UIImage *)image url:(NSString *)url; 14 | 15 | @end -------------------------------------------------------------------------------- /Include/symbolication.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | NSString* nameForLocalSymbol(NSNumber* addrNum, uint64_t* outOffset); 4 | NSArray* symbolicatedStackSymbols(NSArray* callStackSymbols, NSArray* callStackReturnAddresses); 5 | NSArray* symbolicatedException(NSException* e); 6 | NSString* nameForRemoteSymbol(uint64_t addr, NSString* path, NSString* uuidStr, uint64_t imgAddr, CSArchitecture arch); 7 | -------------------------------------------------------------------------------- /cr4shedgui/CRASettingsViewController.h: -------------------------------------------------------------------------------- 1 | @import UIKit; 2 | #import 3 | 4 | @interface FRPreferences (Internal) 5 | -(instancetype)initTableWithSections:(NSArray*)sections; 6 | @end 7 | 8 | @class HBPreferences; 9 | @interface CRASettingsViewController : FRPreferences 10 | +(instancetype)newSettingsController; 11 | -(void)updatePrefsWithKey:(NSString*)key value:(id)value; 12 | @end 13 | -------------------------------------------------------------------------------- /cr4shedgui/CRAProcViewController.h: -------------------------------------------------------------------------------- 1 | @import UIKit; 2 | 3 | @class Process; 4 | @class CRAProcessManager; 5 | 6 | @interface CRAProcViewController : UITableViewController 7 | { 8 | UIRefreshControl* _refreshControl; 9 | CRAProcessManager* _processManager; 10 | } 11 | @property (nonatomic, strong) Process* proc; 12 | -(instancetype)initWithProcess:(Process*)proc; 13 | -(void)refreshLogs; 14 | @end 15 | -------------------------------------------------------------------------------- /cr4shedgui/Process.h: -------------------------------------------------------------------------------- 1 | @import Foundation; 2 | @class Log; 3 | 4 | @interface Process : NSObject 5 | @property (nonatomic, strong) NSString* name; 6 | @property (nonatomic, strong) NSDate* latestDate; 7 | @property (nonatomic, strong) NSMutableArray* logs; 8 | -(instancetype)initWithName:(NSString*)procName; 9 | -(void)deleteAllLogs; 10 | -(void)addToBlacklist; 11 | -(void)removeFromBlacklist; 12 | -(BOOL)isBlacklisted; 13 | @end 14 | -------------------------------------------------------------------------------- /Frameworks/FRPreferences.framework/Headers/FRPDeveloperCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPDeveloperCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/3/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | @interface FRPDeveloperCell : FRPCell 12 | 13 | + (instancetype)cellWithTitle:(NSString *)title detail:(NSString *)detail image:(UIImage *)image url:(NSString *)url; 14 | 15 | @end -------------------------------------------------------------------------------- /cr4shedd/ent.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | platform-application 5 | 6 | com.apple.private.security.container-required 7 | 8 | com.apple.private.security.no-container 9 | 10 | com.apple.private.skip-library-validation 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /frpreferences/FRPLinkCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPLinkCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | typedef void (^FRPLinkCellSelected)(UITableViewCell *sender); 12 | 13 | @interface FRPLinkCell : FRPCell 14 | 15 | + (instancetype)cellWithTitle:(NSString *)title selectedBlock:(FRPLinkCellSelected)block; 16 | 17 | @end 18 | 19 | -------------------------------------------------------------------------------- /cr4shedgui/Log.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface Log : NSObject 4 | @property (nonatomic, readonly) NSString* path; 5 | @property (nonatomic, readonly) NSDate* date; 6 | @property (nonatomic, readonly) NSString* processName; 7 | @property (nonatomic, readonly) NSString* dateName; 8 | @property (nonatomic, readonly) NSString* contents; 9 | @property (nonatomic, readonly) NSDictionary* info; 10 | -(instancetype)initWithPath:(NSString*)path; 11 | @end 12 | -------------------------------------------------------------------------------- /cr4shedgui/dpkgutils.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface NSTask : NSObject 4 | @property (copy) NSURL* executableURL; 5 | @property (copy) NSArray* arguments; 6 | @property (retain) id standardOutput; 7 | -(void)launch; 8 | -(void)waitUntilExit; 9 | @end 10 | 11 | NSString* outputOfCommand(NSString* cmd, NSArray* args); 12 | NSString* packageForFile(NSString* file); 13 | NSString* controlFieldForPackage(NSString* package, NSString* field); 14 | -------------------------------------------------------------------------------- /Frameworks/FRPreferences.framework/Headers/FRPLinkCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPLinkCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | typedef void (^FRPLinkCellSelected)(UITableViewCell *sender); 12 | 13 | @interface FRPLinkCell : FRPCell 14 | 15 | + (instancetype)cellWithTitle:(NSString *)title selectedBlock:(FRPLinkCellSelected)block; 16 | 17 | @end 18 | 19 | -------------------------------------------------------------------------------- /cr4shedd/Makefile: -------------------------------------------------------------------------------- 1 | include $(THEOS)/makefiles/common.mk 2 | 3 | TOOL_NAME = cr4shedd 4 | cr4shedd_FILES = $(wildcard *.mm) ../Shared/sharedutils.mm 5 | cr4shedd_INSTALL_PATH = /usr/libexec 6 | cr4shedd_CODESIGN_FLAGS = -Sent.plist 7 | cr4shedd_CFLAGS = -fobjc-arc -I../Include 8 | cr4shedd_LIBRARIES = mryipc MobileGestalt 9 | cr4shedd_LDFLAGS += -F../Frameworks/ -L../Libraries/ 10 | ADDITIONAL_CFLAGS += -DTHEOS_LEAN_AND_MEAN -Wno-shorten-64-to-32 11 | 12 | include $(THEOS_MAKE_PATH)/tool.mk 13 | -------------------------------------------------------------------------------- /cr4shedgui/CRABlacklistViewController.h: -------------------------------------------------------------------------------- 1 | @import UIKit; 2 | 3 | @interface CRABlacklistCell : UITableViewCell 4 | @property (nonatomic, readonly) UITextField* textField; 5 | @property (nonatomic, copy) void(^textChangedCallback)(NSString*); 6 | @end 7 | 8 | @interface CRABlacklistViewController : UITableViewController 9 | { 10 | NSMutableArray* _blacklist; 11 | } 12 | -(void)reloadBlacklist; 13 | -(void)updatePreferences; 14 | @end 15 | -------------------------------------------------------------------------------- /frpreferences/FRPViewSection.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPViewSection.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/3/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPViewCell.h" 10 | #import "FRPSection.h" 11 | 12 | @interface FRPViewSection : FRPSection 13 | 14 | @property (nonatomic, copy) FRPViewCellBlock cellBlock; 15 | 16 | + (instancetype)sectionWithHeight:(int)height initBlock:(FRPViewCellBlock)initBlock layoutBlock:(FRPViewCellBlock)layoutBlock; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /cr4shedmach/Makefile: -------------------------------------------------------------------------------- 1 | INSTALL_TARGET_PROCESSES = ReportCrash 2 | 3 | include $(THEOS)/makefiles/common.mk 4 | 5 | TWEAK_NAME = Cr4shedMach 6 | 7 | Cr4shedMach_FILES = $(wildcard *.xm *.mm ../Shared/*.mm) 8 | Cr4shedMach_CFLAGS = -fobjc-arc -I../Include 9 | Cr4shedMach_LDFLAGS += -F../Frameworks/ -L../Libraries/ 10 | Cr4shedMach_FRAMEWORKS = CoreSymbolication 11 | Cr4shedMach_LIBRARIES = MobileGestalt mryipc 12 | ADDITIONAL_CFLAGS += -DTHEOS_LEAN_AND_MEAN -Wno-shorten-64-to-32 13 | 14 | include $(THEOS_MAKE_PATH)/tweak.mk 15 | -------------------------------------------------------------------------------- /frpreferences/FRPSettings.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSettings.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 5/5/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FRPSettings : NSObject 12 | 13 | @property (nonatomic, strong) NSString *key; 14 | @property (nonatomic, strong) id value; 15 | @property (nonatomic, strong) NSString *fileSave; 16 | 17 | + (instancetype)settingsWithKey:(NSString *)key defaultValue:(id)defaultValue; 18 | @end 19 | -------------------------------------------------------------------------------- /frpreferences/FRPreferences.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPPreferences.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FRPreferences : UITableViewController 12 | 13 | @property (nonatomic, strong) NSArray *sections; 14 | @property (nonatomic, strong) NSString *plistPath; 15 | 16 | + (instancetype)tableWithSections:(NSArray *)sections title:(NSString *)title tintColor:(UIColor *)color; 17 | 18 | @end -------------------------------------------------------------------------------- /cr4shedd/layout/Library/LaunchDaemons/com.muirey03.cr4shedd.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Label 6 | com.muirey03.cr4shedd 7 | Program 8 | /usr/libexec/cr4shedd 9 | RunAtLoad 10 | 11 | UserName 12 | root 13 | KeepAlive 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Frameworks/FRPreferences.framework/Headers/FRPViewSection.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPViewSection.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/3/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPViewCell.h" 10 | #import "FRPSection.h" 11 | 12 | @interface FRPViewSection : FRPSection 13 | 14 | @property (nonatomic, copy) FRPViewCellBlock cellBlock; 15 | 16 | + (instancetype)sectionWithHeight:(int)height initBlock:(FRPViewCellBlock)initBlock layoutBlock:(FRPViewCellBlock)layoutBlock; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Frameworks/FRPreferences.framework/Headers/FRPSettings.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSettings.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 5/5/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FRPSettings : NSObject 12 | 13 | @property (nonatomic, strong) NSString *key; 14 | @property (nonatomic, strong) id value; 15 | @property (nonatomic, strong) NSString *fileSave; 16 | 17 | + (instancetype)settingsWithKey:(NSString *)key defaultValue:(id)defaultValue; 18 | @end 19 | -------------------------------------------------------------------------------- /Frameworks/FRPreferences.framework/Headers/FRPreferences.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPPreferences.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FRPreferences : UITableViewController 12 | 13 | @property (nonatomic, strong) NSArray *sections; 14 | @property (nonatomic, strong) NSString *plistPath; 15 | 16 | + (instancetype)tableWithSections:(NSArray *)sections title:(NSString *)title tintColor:(UIColor *)color; 17 | 18 | @end -------------------------------------------------------------------------------- /frpreferences/FRPrefs.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPrefs.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/3/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPreferences.h" 10 | #import "FRPSettings.h" 11 | 12 | #import "FRPViewSection.h" 13 | #import "FRPSection.h" 14 | 15 | #import "FRPSwitchCell.h" 16 | #import "FRPTextFieldCell.h" 17 | #import "FRPLinkCell.h" 18 | #import "FRPSliderCell.h" 19 | #import "FRPListCell.h" 20 | #import "FRPSegmentCell.h" 21 | #import "FRPValueCell.h" 22 | #import "FRPDeveloperCell.h" 23 | -------------------------------------------------------------------------------- /layout/DEBIAN/postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "Killing ReportCrash..." 3 | killall -9 ReportCrash 2> /dev/null 4 | echo "Killing ReportMemoryException..." 5 | killall -9 ReportMemoryException 2> /dev/null 6 | echo "Starting cr4shedd..." 7 | chown root:wheel /usr/libexec/cr4shedd 8 | chmod 755 /usr/libexec/cr4shedd 9 | chown root:wheel /Library/LaunchDaemons/com.muirey03.cr4shedd.plist 10 | chmod 644 /Library/LaunchDaemons/com.muirey03.cr4shedd.plist 11 | launchctl load /Library/LaunchDaemons/com.muirey03.cr4shedd.plist 2> /dev/null 12 | echo "Done!" 13 | exit 0 14 | -------------------------------------------------------------------------------- /frpreferences/FRPSwitchCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSwitchCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | typedef void (^FRPSwitchCellChanged)(UISwitch *sender); 12 | 13 | @interface FRPSwitchCell : FRPCell 14 | 15 | @property (nonatomic, strong) UISwitch *switchView; 16 | 17 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting postNotification:(NSString *)notification changeBlock:(FRPSwitchCellChanged)block; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Frameworks/FRPreferences.framework/Headers/FRPrefs.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPrefs.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/3/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPreferences.h" 10 | #import "FRPSettings.h" 11 | 12 | #import "FRPViewSection.h" 13 | #import "FRPSection.h" 14 | 15 | #import "FRPSwitchCell.h" 16 | #import "FRPTextFieldCell.h" 17 | #import "FRPLinkCell.h" 18 | #import "FRPSliderCell.h" 19 | #import "FRPListCell.h" 20 | #import "FRPSegmentCell.h" 21 | #import "FRPValueCell.h" 22 | #import "FRPDeveloperCell.h" 23 | -------------------------------------------------------------------------------- /frpreferences/FRPTextFieldCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSwitchCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | typedef void (^FRPTextFieldCellChanged)(UITextField *sender); 12 | 13 | @interface FRPTextFieldCell : FRPCell 14 | 15 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting placeholder:(NSString *)placeholder postNotification:(NSString *)notification changeBlock:(FRPTextFieldCellChanged)block; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /cr4shedjetsam/Makefile: -------------------------------------------------------------------------------- 1 | INSTALL_TARGET_PROCESSES = ReportMemoryException 2 | 3 | include $(THEOS)/makefiles/common.mk 4 | 5 | TWEAK_NAME = Cr4shedJetsam 6 | Cr4shedJetsam_FILES = $(wildcard *.xm *.mm ../Shared/*.mm) ../cr4shedmach/mach_utils.mm 7 | Cr4shedJetsam_CFLAGS = -fobjc-arc -I../Include -Wno-unused-variable 8 | Cr4shedJetsam_LDFLAGS += -F../Frameworks/ -L../Libraries/ 9 | Cr4shedJetsam_FRAMEWORKS = CoreSymbolication 10 | Cr4shedJetsam_LIBRARIES = MobileGestalt mryipc 11 | ADDITIONAL_CFLAGS += -DTHEOS_LEAN_AND_MEAN -Wno-shorten-64-to-32 12 | 13 | include $(THEOS_MAKE_PATH)/tweak.mk 14 | -------------------------------------------------------------------------------- /frpreferences/FRPViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPViewCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/3/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | typedef void (^FRPViewCellBlock)(UITableViewCell *cell); 12 | 13 | @interface FRPViewCell : FRPCell 14 | 15 | + (instancetype)cellWithHeight:(int)height initBlock:(FRPViewCellBlock)initBlock layoutBlock:(FRPViewCellBlock)layoutBlock; 16 | 17 | @property (nonatomic, strong) FRPViewCellBlock layoutBlock; 18 | @property (nonatomic, assign) BOOL hideSeperators; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Frameworks/FRPreferences.framework/Headers/FRPSwitchCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSwitchCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | typedef void (^FRPSwitchCellChanged)(UISwitch *sender); 12 | 13 | @interface FRPSwitchCell : FRPCell 14 | 15 | @property (nonatomic, strong) UISwitch *switchView; 16 | 17 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting postNotification:(NSString *)notification changeBlock:(FRPSwitchCellChanged)block; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Frameworks/FRPreferences.framework/Headers/FRPTextFieldCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSwitchCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | typedef void (^FRPTextFieldCellChanged)(UITextField *sender); 12 | 13 | @interface FRPTextFieldCell : FRPCell 14 | 15 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting placeholder:(NSString *)placeholder postNotification:(NSString *)notification changeBlock:(FRPTextFieldCellChanged)block; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Frameworks/FRPreferences.framework/Headers/FRPViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPViewCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/3/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | typedef void (^FRPViewCellBlock)(UITableViewCell *cell); 12 | 13 | @interface FRPViewCell : FRPCell 14 | 15 | + (instancetype)cellWithHeight:(int)height initBlock:(FRPViewCellBlock)initBlock layoutBlock:(FRPViewCellBlock)layoutBlock; 16 | 17 | @property (nonatomic, strong) FRPViewCellBlock layoutBlock; 18 | @property (nonatomic, assign) BOOL hideSeperators; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /cr4shedgui/Makefile: -------------------------------------------------------------------------------- 1 | include $(THEOS)/makefiles/common.mk 2 | 3 | APPLICATION_NAME = Cr4shed 4 | Cr4shed_FILES = $(wildcard *.m) ../Shared/sharedutils.mm 5 | Cr4shed_LDFLAGS += -F../Frameworks/ -L../Libraries/ 6 | Cr4shed_LIBRARIES = MobileGestalt 7 | Cr4shed_FRAMEWORKS = UIKit CoreGraphics WebKit UserNotifications FRPreferences Cephei MessageUI 8 | Cr4shed_CFLAGS = -fobjc-arc -I../Frameworks -I../Include -Wno-deprecated-declarations 9 | Cr4shed_CODESIGN_FLAGS = -Sent.xml 10 | ADDITIONAL_CFLAGS = -Wno-unguarded-availability 11 | 12 | include $(THEOS_MAKE_PATH)/application.mk 13 | 14 | after-install:: 15 | install.exec "killall \"Cr4shed\"" || true 16 | -------------------------------------------------------------------------------- /frpreferences/FRPSection.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSection.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | 12 | @interface FRPSection : UITableViewCell 13 | 14 | @property (nonatomic, strong) NSString *headerTitle; 15 | @property (nonatomic, strong) NSString *footerTitle; 16 | 17 | @property (nonatomic, strong) NSMutableArray *cells; 18 | 19 | @property (nonatomic, strong) UIColor *tintUIColor; 20 | 21 | + (instancetype)sectionWithTitle:(NSString *)title footer:(NSString *)footer; 22 | 23 | - (void)addCell:(UITableViewCell *)cell; 24 | - (void)addCells:(NSArray *)cells; 25 | 26 | @end -------------------------------------------------------------------------------- /frpreferences/FRPListCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRListCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | typedef void (^FRPListItemChange)(NSString *value); 12 | 13 | @interface FRPListCell : FRPCell 14 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting items:(NSArray *)items value:(NSArray *)values popViewOnSelect:(BOOL)pop postNotification:(NSString *)notification changedBlock:(FRPListItemChange)block; 15 | @property (nonatomic, strong) NSArray *items; 16 | @property (nonatomic, strong) NSArray *values; 17 | @property (nonatomic, assign) BOOL popView; 18 | @end 19 | -------------------------------------------------------------------------------- /Frameworks/FRPreferences.framework/Headers/FRPSection.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSection.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | 12 | @interface FRPSection : UITableViewCell 13 | 14 | @property (nonatomic, strong) NSString *headerTitle; 15 | @property (nonatomic, strong) NSString *footerTitle; 16 | 17 | @property (nonatomic, strong) NSMutableArray *cells; 18 | 19 | @property (nonatomic, strong) UIColor *tintUIColor; 20 | 21 | + (instancetype)sectionWithTitle:(NSString *)title footer:(NSString *)footer; 22 | 23 | - (void)addCell:(UITableViewCell *)cell; 24 | - (void)addCells:(NSArray *)cells; 25 | 26 | @end -------------------------------------------------------------------------------- /Frameworks/FRPreferences.framework/Headers/FRPListCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRListCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | typedef void (^FRPListItemChange)(NSString *value); 12 | 13 | @interface FRPListCell : FRPCell 14 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting items:(NSArray *)items value:(NSArray *)values popViewOnSelect:(BOOL)pop postNotification:(NSString *)notification changedBlock:(FRPListItemChange)block; 15 | @property (nonatomic, strong) NSArray *items; 16 | @property (nonatomic, strong) NSArray *values; 17 | @property (nonatomic, assign) BOOL popView; 18 | @end 19 | -------------------------------------------------------------------------------- /Include/MRYIPCCenter.h: -------------------------------------------------------------------------------- 1 | @interface MRYIPCCenter : NSObject 2 | @property (nonatomic, readonly) NSString* centerName; 3 | +(instancetype)centerNamed:(NSString*)name; 4 | -(void)addTarget:(id)target action:(SEL)action; 5 | //asynchronously call a void method 6 | -(void)callExternalVoidMethod:(SEL)method withArguments:(id)args; 7 | //synchronously call a method and recieve the return value 8 | -(id)callExternalMethod:(SEL)method withArguments:(id)args; 9 | //asynchronously call a method and receive the return value in the completion handler 10 | -(void)callExternalMethod:(SEL)method withArguments:(id)args completion:(void(^)(id))completionHandler; 11 | 12 | //deprecated 13 | -(void)registerMethod:(SEL)selector withTarget:(id)target; 14 | @end 15 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | export ARCHS = arm64 arm64e 2 | export TARGET = iphone:clang:latest:10.0 3 | 4 | include $(THEOS)/makefiles/common.mk 5 | 6 | TWEAK_NAME = 0Cr4shed 7 | 0Cr4shed_FILES = $(wildcard *.m *.mm *.xm Shared/*.mm) 8 | 0Cr4shed_CFLAGS = -fobjc-arc -std=c++11 -IInclude 9 | 0Cr4shed_FRAMEWORKS = CoreSymbolication 10 | 0Cr4shed_LIBRARIES = MobileGestalt mryipc 11 | 0Cr4shed_LDFLAGS += -FFrameworks/ -LLibraries/ 12 | ADDITIONAL_CFLAGS += -DTHEOS_LEAN_AND_MEAN -Wno-shorten-64-to-32 13 | 14 | include $(THEOS_MAKE_PATH)/tweak.mk 15 | 16 | after-install:: 17 | install.exec "ldrestart" 18 | SUBPROJECTS += cr4shedgui 19 | SUBPROJECTS += cr4shedmach 20 | SUBPROJECTS += cr4shedjetsam 21 | SUBPROJECTS += frpreferences 22 | SUBPROJECTS += cr4shedd 23 | include $(THEOS_MAKE_PATH)/aggregate.mk 24 | -------------------------------------------------------------------------------- /frpreferences/FRPValueCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPValueCell.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/22/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPValueCell.h" 10 | 11 | @implementation FRPValueCell 12 | 13 | + (instancetype)cellWithTitle:(NSString *)title detail:(NSString *)detail { 14 | return [[self alloc] cellWithTitle:title detail:detail]; 15 | } 16 | 17 | - (instancetype)cellWithTitle:(NSString *)title detail:(NSString *)detail { 18 | FRPValueCell *cell = [super initWithTitle:title setting:nil]; 19 | cell.accessoryType = UITableViewCellAccessoryNone; 20 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 21 | cell.detailTextLabel.text = detail; 22 | return cell; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /frpreferences/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | FRPreferences 9 | CFBundleIdentifier 10 | com.fouadraheb.frpreferences 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | FMWK 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Include/Cephei/NSDictionary+HBAdditions.h: -------------------------------------------------------------------------------- 1 | NS_ASSUME_NONNULL_BEGIN 2 | 3 | /** 4 | * NSDictionary (HBAdditions) is a class category in `Cephei` that provides some convenience methods. 5 | */ 6 | @interface NSDictionary (HBAdditions) 7 | 8 | /** 9 | * Constructs and returns an NSString object that is the result of joining the dictionary keys and 10 | * values into an HTTP query string. 11 | * 12 | * On iOS 8.0 and newer, this uses the built in NSURLComponents functionality to deserialize the 13 | * query string. On earlier versions, uses an approximation implemented within Cephei. This 14 | * implementation is simplistic and does not handle edge cases that NSURLComponents does support. 15 | * 16 | * @returns An NSString containing an HTTP query string. 17 | */ 18 | - (NSString *)hb_queryString; 19 | 20 | @end 21 | 22 | NS_ASSUME_NONNULL_END 23 | -------------------------------------------------------------------------------- /Include/Cephei/HBOutputForShellCommand.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | NS_ASSUME_NONNULL_BEGIN 4 | __BEGIN_DECLS 5 | 6 | /** 7 | * Executes a shell command and returns its output. 8 | * 9 | * @param command The shell command to run. 10 | * @param returnCode A pointer to an integer that will contain the return code of the command. 11 | * @returns The output of the provided command. 12 | */ 13 | NSString * _Nullable HBOutputForShellCommandWithReturnCode(NSString *command, int *returnCode); 14 | 15 | /** 16 | * Executes a shell command and returns its output. 17 | * 18 | * @param command The shell command to run. 19 | * @returns The output of the provided command, or nil if the command returned with a code other 20 | * than 0. 21 | */ 22 | NSString * _Nullable HBOutputForShellCommand(NSString *command); 23 | 24 | __END_DECLS 25 | NS_ASSUME_NONNULL_END 26 | -------------------------------------------------------------------------------- /cr4shedgui/CRARootViewController.h: -------------------------------------------------------------------------------- 1 | @import UIKit; 2 | 3 | @class Process; 4 | @class CRAProcessManager; 5 | 6 | @interface ProcessCell : UITableViewCell 7 | { 8 | UILabel* _countLbl; 9 | NSLayoutConstraint* _widthConstraint; 10 | NSLayoutConstraint* _heightConstraint; 11 | } 12 | @property (nonatomic, strong) Process* proc; 13 | -(void)updateLabels; 14 | @end 15 | 16 | @interface CRARootViewController : UITableViewController 17 | { 18 | UIRefreshControl* _refreshControl; 19 | CRAProcessManager* _processManager; 20 | NSMutableArray* _procs; 21 | } 22 | -(void)refreshTable:(UIRefreshControl*)control; 23 | -(void)deleteProcessAtIndexPath:(NSIndexPath*)indexPath; 24 | @end 25 | 26 | @interface UIColor (System) 27 | @property(class, nonatomic, readonly) UIColor* systemRedColor; 28 | @property(class, nonatomic, readonly) UIColor* systemBlueColor; 29 | @end 30 | -------------------------------------------------------------------------------- /Frameworks/Cephei.framework/Headers/NSDictionary+HBAdditions.h: -------------------------------------------------------------------------------- 1 | NS_ASSUME_NONNULL_BEGIN 2 | 3 | /** 4 | * NSDictionary (HBAdditions) is a class category in `Cephei` that provides some convenience methods. 5 | */ 6 | @interface NSDictionary (HBAdditions) 7 | 8 | /** 9 | * Constructs and returns an NSString object that is the result of joining the dictionary keys and 10 | * values into an HTTP query string. 11 | * 12 | * On iOS 8.0 and newer, this uses the built in NSURLComponents functionality to deserialize the 13 | * query string. On earlier versions, uses an approximation implemented within Cephei. This 14 | * implementation is simplistic and does not handle edge cases that NSURLComponents does support. 15 | * 16 | * @returns An NSString containing an HTTP query string. 17 | */ 18 | - (NSString *)hb_queryString; 19 | 20 | @end 21 | 22 | NS_ASSUME_NONNULL_END 23 | -------------------------------------------------------------------------------- /cr4shedgui/CRALogInfoViewController.h: -------------------------------------------------------------------------------- 1 | @import MessageUI; 2 | @import UIKit; 3 | @class Log; 4 | 5 | @interface UIImage (Internal) 6 | +(UIImage*)_applicationIconImageForBundleIdentifier:(NSString*)bundleID format:(int)format scale:(CGFloat)scale; 7 | @end 8 | 9 | @interface CRALogInfoViewController : UIViewController 10 | { 11 | NSDictionary* _info; 12 | } 13 | @property (nonatomic, readonly) UITableView* tableView; 14 | @property (nonatomic, strong) Log* log; 15 | -(instancetype)initWithLog:(Log*)log; 16 | -(void)displayErrorAlert:(NSString*)body; 17 | -(void)composeEmail; 18 | @end 19 | 20 | @interface UIColor (System) 21 | @property(class, nonatomic, readonly) UIColor* systemRedColor; 22 | @property(class, nonatomic, readonly) UIColor* systemBlueColor; 23 | @end 24 | -------------------------------------------------------------------------------- /Frameworks/Cephei.framework/Headers/HBOutputForShellCommand.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | NS_ASSUME_NONNULL_BEGIN 4 | __BEGIN_DECLS 5 | 6 | /** 7 | * Executes a shell command and returns its output. 8 | * 9 | * @param command The shell command to run. 10 | * @param returnCode A pointer to an integer that will contain the return code of the command. 11 | * @returns The output of the provided command. 12 | */ 13 | NSString * _Nullable HBOutputForShellCommandWithReturnCode(NSString *command, int *returnCode); 14 | 15 | /** 16 | * Executes a shell command and returns its output. 17 | * 18 | * @param command The shell command to run. 19 | * @returns The output of the provided command, or nil if the command returned with a code other 20 | * than 0. 21 | */ 22 | NSString * _Nullable HBOutputForShellCommand(NSString *command); 23 | 24 | __END_DECLS 25 | NS_ASSUME_NONNULL_END 26 | -------------------------------------------------------------------------------- /frpreferences/FRPSelectListTable.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSelectionListViewController.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 5/10/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "FRPListCell.h" 11 | 12 | @interface FRPSelectListTable : UITableViewController { 13 | NSArray *listItems; 14 | NSArray *listValues; 15 | NSString *currentValue; 16 | NSString *pageTitle; 17 | BOOL popView; 18 | } 19 | @property (nonatomic, copy) FRPListItemChange itemChanged; 20 | @property (nonatomic, copy) UIColor *tintUIColor; 21 | 22 | - (instancetype)initWithStyle:(UITableViewStyle)style title:(NSString *)title items:(NSArray *)items values:(NSArray *)values currentValue:(NSString *)value popViewOnSelect:(BOOL)back changeBlock:(FRPListItemChange)block; 23 | 24 | @end -------------------------------------------------------------------------------- /frpreferences/FRPSliderCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRSliderCellTableViewCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 6/14/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | typedef void (^FRPSliderCellChanged)(UISlider *sender); 12 | 13 | @interface FRPSliderCell : FRPCell 14 | 15 | @property (nonatomic, strong) UISlider *sliderCell; 16 | @property (nonatomic, strong) UILabel *lLabel; 17 | @property (nonatomic, strong) UILabel *rLabel; 18 | @property (nonatomic, strong) UILabel *cLabel; 19 | @property (nonatomic, strong) UILabel *vLabel; 20 | 21 | @property (nonatomic) float min; 22 | @property (nonatomic) float max; 23 | 24 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting min:(float)min max:(float)max postNotification:(NSString *)notification changeBlock:(FRPSliderCellChanged)block; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Frameworks/FRPreferences.framework/Headers/FRPSelectListTable.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSelectionListViewController.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 5/10/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "FRPListCell.h" 11 | 12 | @interface FRPSelectListTable : UITableViewController { 13 | NSArray *listItems; 14 | NSArray *listValues; 15 | NSString *currentValue; 16 | NSString *pageTitle; 17 | BOOL popView; 18 | } 19 | @property (nonatomic, copy) FRPListItemChange itemChanged; 20 | @property (nonatomic, copy) UIColor *tintUIColor; 21 | 22 | - (instancetype)initWithStyle:(UITableViewStyle)style title:(NSString *)title items:(NSArray *)items values:(NSArray *)values currentValue:(NSString *)value popViewOnSelect:(BOOL)back changeBlock:(FRPListItemChange)block; 23 | 24 | @end -------------------------------------------------------------------------------- /Frameworks/FRPreferences.framework/Headers/FRPSliderCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRSliderCellTableViewCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 6/14/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | typedef void (^FRPSliderCellChanged)(UISlider *sender); 12 | 13 | @interface FRPSliderCell : FRPCell 14 | 15 | @property (nonatomic, strong) UISlider *sliderCell; 16 | @property (nonatomic, strong) UILabel *lLabel; 17 | @property (nonatomic, strong) UILabel *rLabel; 18 | @property (nonatomic, strong) UILabel *cLabel; 19 | @property (nonatomic, strong) UILabel *vLabel; 20 | 21 | @property (nonatomic) float min; 22 | @property (nonatomic) float max; 23 | 24 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting min:(float)min max:(float)max postNotification:(NSString *)notification changeBlock:(FRPSliderCellChanged)block; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Frameworks/Cephei.framework/Cephei.tbd: -------------------------------------------------------------------------------- 1 | --- 2 | archs: [ armv7, arm64 ] 3 | platform: ios 4 | install-name: /Library/Frameworks/Cephei.framework/Cephei 5 | current-version: 0 6 | compatibility-version: 0 7 | objc-constraint: retain_release 8 | exports: 9 | - archs: [ armv7, arm64 ] 10 | symbols: [ _HBOutputForShellCommand, _HBOutputForShellCommandWithReturnCode, _HBPreferencesDidChangeNotification, 11 | _HBPreferencesNotMobileException, _KnownIdentifiers, __CFPreferencesCopyKeyListWithContainer, 12 | __CFPreferencesCopyMultipleWithContainer, __CFPreferencesCopyValueWithContainer, 13 | __CFPreferencesSetValueWithContainer, __CFPreferencesSynchronizeWithContainer, _globalBundle ] 14 | objc-classes: [ _HBPreferences, _HBPreferencesCore, _HBPreferencesIPC, _HBRespringController ] 15 | ... 16 | -------------------------------------------------------------------------------- /frpreferences/FRPCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPreferences.h" 10 | #import "FRPSettings.h" 11 | 12 | typedef void (^FRPValueChanged)(id sender); 13 | 14 | @interface FRPCell : UITableViewCell 15 | 16 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting; 17 | - (instancetype)initWithTitle:(NSString *)title setting:(FRPSettings *)setting; 18 | 19 | @property (nonatomic, strong) UIColor *tintUIColor; 20 | 21 | @property (nonatomic, strong) FRPSettings *setting; 22 | 23 | @property (nonatomic, strong) NSString *title; 24 | 25 | @property (nonatomic, strong) NSString *postNotification; 26 | 27 | @property (nonatomic, copy) FRPValueChanged valueChanged; 28 | 29 | @property (nonatomic, assign) int height; 30 | 31 | - (void)didSelectFromTable:(FRPreferences *)viewController; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /frpreferences/FRPSection.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSection.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPSection.h" 10 | 11 | @interface FRPSection () 12 | 13 | @end 14 | 15 | 16 | @implementation FRPSection 17 | 18 | + (instancetype)sectionWithTitle:(NSString *)title footer:(NSString *)footer { 19 | return [[self alloc] initWithTitle:title footer:footer]; 20 | } 21 | 22 | - (instancetype)initWithTitle:(NSString *)title footer:(NSString *)footer { 23 | if (self = [super init]) { 24 | self.headerTitle = title; 25 | self.footerTitle = footer; 26 | self.cells = [NSMutableArray new]; 27 | } 28 | 29 | return self; 30 | } 31 | 32 | - (void)addCell:(UITableViewCell *)cell { 33 | [self.cells addObject:cell]; 34 | } 35 | 36 | - (void)addCells:(NSArray *)cells { 37 | [self.cells addObjectsFromArray:cells]; 38 | } 39 | 40 | @end -------------------------------------------------------------------------------- /Include/Cephei/HBRespringController.h: -------------------------------------------------------------------------------- 1 | NS_ASSUME_NONNULL_BEGIN 2 | 3 | /** 4 | * The `HBRespringController` class in `Cephei` provides conveniences for restarting the system app 5 | * (usually SpringBoard). It also ensures battery usage statistics are not lost when performing the 6 | * restart. 7 | */ 8 | @interface HBRespringController : NSObject 9 | 10 | /** 11 | * Restart the system app. 12 | * 13 | * On iOS 8.0 and newer, fades out and then returns to the home screen (system remains unlocked). On 14 | * older iOS versions, a standard restart occurs. 15 | */ 16 | + (void)respring; 17 | 18 | /** 19 | * Restart the system app and immediately launch a URL. 20 | * 21 | * Requires iOS 8.0 or newer. On older iOS versions, a standard restart occurs and the URL is not 22 | * opened. 23 | * 24 | * @param returnURL The URL to launch after restarting. 25 | */ 26 | + (void)respringAndReturnTo:(nullable NSURL *)returnURL; 27 | 28 | @end 29 | 30 | NS_ASSUME_NONNULL_END 31 | -------------------------------------------------------------------------------- /frpreferences/FRPCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPCell.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | @implementation FRPCell 12 | 13 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting { 14 | return [[self alloc] initWithTitle:title setting:setting]; 15 | } 16 | 17 | - (instancetype)initWithTitle:(NSString *)title setting:(FRPSettings *)setting { 18 | if (self = [super initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil]) { 19 | self.clipsToBounds = YES; 20 | self.textLabel.text = title; 21 | self.setting = setting; 22 | } 23 | return self; 24 | } 25 | 26 | - (void)didSelectFromTable:(FRPreferences *)viewController { 27 | // NSIndexPath *indexPath = [viewController.tableView indexPathForCell:self]; 28 | // NSLog(@"Did Select Cell At Index: %@",indexPath); 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Frameworks/Cephei.framework/Headers/HBRespringController.h: -------------------------------------------------------------------------------- 1 | NS_ASSUME_NONNULL_BEGIN 2 | 3 | /** 4 | * The `HBRespringController` class in `Cephei` provides conveniences for restarting the system app 5 | * (usually SpringBoard). It also ensures battery usage statistics are not lost when performing the 6 | * restart. 7 | */ 8 | @interface HBRespringController : NSObject 9 | 10 | /** 11 | * Restart the system app. 12 | * 13 | * On iOS 8.0 and newer, fades out and then returns to the home screen (system remains unlocked). On 14 | * older iOS versions, a standard restart occurs. 15 | */ 16 | + (void)respring; 17 | 18 | /** 19 | * Restart the system app and immediately launch a URL. 20 | * 21 | * Requires iOS 8.0 or newer. On older iOS versions, a standard restart occurs and the URL is not 22 | * opened. 23 | * 24 | * @param returnURL The URL to launch after restarting. 25 | */ 26 | + (void)respringAndReturnTo:(nullable NSURL *)returnURL; 27 | 28 | @end 29 | 30 | NS_ASSUME_NONNULL_END 31 | -------------------------------------------------------------------------------- /Frameworks/FRPreferences.framework/Headers/FRPCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPreferences.h" 10 | #import "FRPSettings.h" 11 | 12 | typedef void (^FRPValueChanged)(id sender); 13 | 14 | @interface FRPCell : UITableViewCell 15 | 16 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting; 17 | - (instancetype)initWithTitle:(NSString *)title setting:(FRPSettings *)setting; 18 | 19 | @property (nonatomic, strong) UIColor *tintUIColor; 20 | 21 | @property (nonatomic, strong) FRPSettings *setting; 22 | 23 | @property (nonatomic, strong) NSString *title; 24 | 25 | @property (nonatomic, strong) NSString *postNotification; 26 | 27 | @property (nonatomic, copy) FRPValueChanged valueChanged; 28 | 29 | @property (nonatomic, assign) int height; 30 | 31 | - (void)didSelectFromTable:(FRPreferences *)viewController; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Cr4shed 2 | ##### A modern crash reporter for iOS 3 | 4 | Cr4shed is a useful crash reporting package designed to help developers identify and fix crashes that have been reported to them by their users, and to help users identify the culprits of crashes. It generates a crash log in `/var/mobile/Library/Cr4shed` (accessible from the Cr4shed application) including information such as the process that crashed, the exact reason for the crash, the dylib that caused the crash and the entire call stack when the crash occurred. 5 | 6 | This is extremely useful if someone reports a crash to you and you can't work out what the issue is purely from the system/CrashReporter crash log. (Is also extremely useful for identifying causes of crashes in development). This report should be everything you need to work out exactly why the crash occurred. 7 | 8 | Cr4shed is now at the stage where it should be able to function as a full replacement for CrashReporter, but I cannot (yet) recommend uninstalling CrashReporter. -------------------------------------------------------------------------------- /frpreferences/FRPSegmentCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSegmentCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/19/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | typedef void (^FRPSegmentValueChanged)(NSString *value); 12 | 13 | @interface FRPSegmentCell : FRPCell 14 | 15 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting items:(NSArray *)items postNotification:(NSString *)notification changeBlock:(FRPSegmentValueChanged)block __attribute__((deprecated("use instead +cellWithTitle:setting:values:displayedValues:postNotification:changeBlock"))); 16 | 17 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting values:(NSArray *)values displayedValues:(NSArray *)displayedValues postNotification:(NSString *)notification changeBlock:(FRPSegmentValueChanged)block; 18 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting values:(NSArray *)values postNotification:(NSString *)notification changeBlock:(FRPSegmentValueChanged)block; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Frameworks/FRPreferences.framework/Headers/FRPSegmentCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSegmentCell.h 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/19/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPCell.h" 10 | 11 | typedef void (^FRPSegmentValueChanged)(NSString *value); 12 | 13 | @interface FRPSegmentCell : FRPCell 14 | 15 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting items:(NSArray *)items postNotification:(NSString *)notification changeBlock:(FRPSegmentValueChanged)block __attribute__((deprecated("use instead +cellWithTitle:setting:values:displayedValues:postNotification:changeBlock"))); 16 | 17 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting values:(NSArray *)values displayedValues:(NSArray *)displayedValues postNotification:(NSString *)notification changeBlock:(FRPSegmentValueChanged)block; 18 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting values:(NSArray *)values postNotification:(NSString *)notification changeBlock:(FRPSegmentValueChanged)block; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /frpreferences/FRPLinkCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPLinkCell.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPLinkCell.h" 10 | 11 | @interface FRPLinkCell () 12 | @end 13 | 14 | @implementation FRPLinkCell 15 | 16 | + (instancetype)cellWithTitle:(NSString *)title selectedBlock:(FRPLinkCellSelected)block { 17 | return [[self alloc] cellWithTitle:title selectedBlock:block]; 18 | } 19 | 20 | - (instancetype)cellWithTitle:(NSString *)title selectedBlock:(FRPLinkCellSelected)block { 21 | FRPLinkCell *cell = [super initWithTitle:title setting:nil]; 22 | cell.valueChanged = block; 23 | cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 24 | return cell; 25 | } 26 | 27 | - (void)didSelectFromTable:(FRPreferences *)viewController { 28 | NSIndexPath *indexPath = [viewController.tableView indexPathForCell:self]; 29 | [viewController.tableView deselectRowAtIndexPath:indexPath animated:YES]; 30 | if (self.valueChanged) { 31 | self.valueChanged(self); 32 | } 33 | } 34 | 35 | - (void)layoutSubviews { 36 | [super layoutSubviews]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /cr4shedgui/Log.m: -------------------------------------------------------------------------------- 1 | #import "Log.h" 2 | #import 3 | 4 | @implementation Log 5 | { 6 | NSString* _contents; 7 | NSDictionary* _info; 8 | } 9 | 10 | -(instancetype)initWithPath:(NSString*)path 11 | { 12 | if ((self = [self init])) 13 | { 14 | _path = path; 15 | 16 | //get date: 17 | NSDictionary* fileAttribs = [[NSFileManager defaultManager] attributesOfItemAtPath:path error:nil]; 18 | _date = [fileAttribs objectForKey:NSFileCreationDate]; 19 | } 20 | return self; 21 | } 22 | 23 | -(NSString*)dateName 24 | { 25 | NSArray* comp = [[_path lastPathComponent] componentsSeparatedByString:@"@"]; 26 | return comp.count > 1 ? comp[1] : comp[0]; 27 | } 28 | 29 | -(NSString*)processName 30 | { 31 | NSDictionary* info = self.info; 32 | if (info[@"ProcessName"]) 33 | return info[@"ProcessName"]; 34 | NSArray* comp = [[_path lastPathComponent] componentsSeparatedByString:@"@"]; 35 | return comp.count ? comp[0] : nil; 36 | } 37 | 38 | -(NSString*)contents 39 | { 40 | if (!_contents) 41 | _contents = [NSString stringWithContentsOfFile:_path encoding:NSUTF8StringEncoding error:NULL]; 42 | return _contents; 43 | } 44 | 45 | -(NSDictionary*)info 46 | { 47 | if (!_info) 48 | _info = getInfoFromLog(self.contents); 49 | return _info; 50 | } 51 | @end -------------------------------------------------------------------------------- /frpreferences/FRPViewSection.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPViewSection.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/3/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPViewSection.h" 10 | 11 | @implementation FRPViewSection 12 | 13 | + (instancetype)sectionWithHeight:(int)height initBlock:(FRPViewCellBlock)initBlock layoutBlock:(FRPViewCellBlock)layoutBlock { 14 | return [[self alloc] initWithHeight:height initBlock:initBlock layoutBlock:layoutBlock]; 15 | } 16 | 17 | - (instancetype)initWithHeight:(int)height initBlock:(FRPViewCellBlock)initBlock layoutBlock:(FRPViewCellBlock)layoutBlock { 18 | FRPViewSection *section = [[super class] sectionWithTitle:nil footer:nil]; 19 | FRPViewCell *cell = [FRPViewCell cellWithHeight:height 20 | initBlock:^(UITableViewCell *cell) { 21 | initBlock(cell); 22 | } 23 | layoutBlock:^(UITableViewCell *cell) { 24 | layoutBlock(cell); 25 | }]; 26 | cell.hideSeperators = YES; 27 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 28 | [section addCell:cell]; 29 | return section; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Include/Cephei/NSString+HBAdditions.h: -------------------------------------------------------------------------------- 1 | NS_ASSUME_NONNULL_BEGIN 2 | 3 | /** 4 | * NSString (HBAdditions) is a class category in `Cephei` that provides some convenience methods. 5 | */ 6 | @interface NSString (HBAdditions) 7 | 8 | /** 9 | * Returns a string encoded for an HTTP query parameter. 10 | * 11 | * This method encodes a variety of symbols that can conflict with other portions of a URL, such as 12 | * `&` and `=`, and other similar symbols that could otherwise be misinterpreted by some 13 | * implementations. 14 | * 15 | * @returns A string encoded for an HTTP query parameter. 16 | */ 17 | - (NSString *)hb_stringByEncodingQueryPercentEscapes; 18 | 19 | /** 20 | * Returns a string decoded from an HTTP query parameter. 21 | * 22 | * This method decodes percent escapes, as well as spaces encoded with a `+`. 23 | * 24 | * @returns A string decoded from an HTTP query parameter. 25 | */ 26 | - (NSString *)hb_stringByDecodingQueryPercentEscapes; 27 | 28 | /** 29 | * Returns a dictionary containing the HTTP query parameters in the string. 30 | * 31 | * The string is expected to be in the format `key=value&key=value`, with both keys and values 32 | * encoded where necessary. 33 | * 34 | * @returns An NSDictionary object containing the keys and values from the query string. 35 | */ 36 | - (NSDictionary *)hb_queryStringComponents; 37 | 38 | @end 39 | 40 | NS_ASSUME_NONNULL_END 41 | -------------------------------------------------------------------------------- /Frameworks/Cephei.framework/Headers/NSString+HBAdditions.h: -------------------------------------------------------------------------------- 1 | NS_ASSUME_NONNULL_BEGIN 2 | 3 | /** 4 | * NSString (HBAdditions) is a class category in `Cephei` that provides some convenience methods. 5 | */ 6 | @interface NSString (HBAdditions) 7 | 8 | /** 9 | * Returns a string encoded for an HTTP query parameter. 10 | * 11 | * This method encodes a variety of symbols that can conflict with other portions of a URL, such as 12 | * `&` and `=`, and other similar symbols that could otherwise be misinterpreted by some 13 | * implementations. 14 | * 15 | * @returns A string encoded for an HTTP query parameter. 16 | */ 17 | - (NSString *)hb_stringByEncodingQueryPercentEscapes; 18 | 19 | /** 20 | * Returns a string decoded from an HTTP query parameter. 21 | * 22 | * This method decodes percent escapes, as well as spaces encoded with a `+`. 23 | * 24 | * @returns A string decoded from an HTTP query parameter. 25 | */ 26 | - (NSString *)hb_stringByDecodingQueryPercentEscapes; 27 | 28 | /** 29 | * Returns a dictionary containing the HTTP query parameters in the string. 30 | * 31 | * The string is expected to be in the format `key=value&key=value`, with both keys and values 32 | * encoded where necessary. 33 | * 34 | * @returns An NSDictionary object containing the keys and values from the query string. 35 | */ 36 | - (NSDictionary *)hb_queryStringComponents; 37 | 38 | @end 39 | 40 | NS_ASSUME_NONNULL_END 41 | -------------------------------------------------------------------------------- /Libraries/libMobileGestalt.tbd: -------------------------------------------------------------------------------- 1 | --- 2 | archs: [ armv7, armv7s, arm64 ] 3 | platform: ios 4 | install-name: /usr/lib/libMobileGestalt.dylib 5 | exports: 6 | - archs: [ armv7, armv7s, arm64 ] 7 | symbols: [ _MGCancelNotifications, _MGCopyAnswer, _MGCopyAnswerWithError, 8 | _MGCopyMultipleAnswers, _MGGetBoolAnswer, _MGGetFloat32Answer, 9 | _MGGetProductType, _MGGetSInt32Answer, _MGGetSInt64Answer, 10 | _MGIsDeviceOfType, _MGIsDeviceOneOfType, _MGIsQuestionValid, 11 | _MGRegisterForBulkUpdates, _MGRegisterForUpdates, 12 | _MGSetAnswer, _MGSetLogHandler, __MGCacheValid, 13 | __MGClearInProcessCache, __MGCopyDeviceDescription, 14 | __MGCopyIteratedDeviceDescription, __MGIterateDevices, 15 | __MGLog, __MGPrintIteratedDeviceDescription, __MGServerCopyAnswerWithError, 16 | __MGSetServer, __MGWaitForDevices, __MGWriteCache, 17 | _kMGQDiskUsageAmountDataAvailable, _kMGQDiskUsageAmountDataReserved, 18 | _kMGQDiskUsageTotalDataAvailable, _kMGQDiskUsageTotalDataCapacity, 19 | _kMGQDiskUsageTotalDiskCapacity, _kMGQDiskUsageTotalSystemAvailable, 20 | _kMGQDiskUsageTotalSystemCapacity ] 21 | ... 22 | -------------------------------------------------------------------------------- /frpreferences/FRPViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPViewCell.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/3/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPViewCell.h" 10 | 11 | @implementation FRPViewCell 12 | 13 | + (instancetype)cellWithHeight:(int)height initBlock:(FRPViewCellBlock)initBlock layoutBlock:(FRPViewCellBlock)layoutBlock { 14 | return [[self alloc] cellWithHeight:height initBlock:initBlock layoutBlock:layoutBlock]; 15 | } 16 | 17 | - (instancetype)cellWithHeight:(int)height initBlock:(FRPViewCellBlock)initBlock layoutBlock:(FRPViewCellBlock)layoutBlock { 18 | FRPViewCell *cell = [super initWithTitle:nil setting:nil]; 19 | if (layoutBlock) self.layoutBlock = layoutBlock; 20 | cell.accessoryType = UITableViewCellAccessoryNone; 21 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 22 | cell.height = height; 23 | initBlock(cell); 24 | return cell; 25 | } 26 | 27 | - (void)layoutSubviews { 28 | [super layoutSubviews]; 29 | if (self.layoutBlock) self.layoutBlock(self); 30 | } 31 | 32 | - (void)addSubview:(UIView *)view { 33 | // The separator has a height of 0.5pt on a retina display and 1pt on non-retina. 34 | // Prevent subviews with this height from being added. 35 | if (self.hideSeperators && CGRectGetHeight(view.frame)*[UIScreen mainScreen].scale == 1) { 36 | return; 37 | } 38 | [super addSubview:view]; 39 | } 40 | 41 | @end -------------------------------------------------------------------------------- /cr4shedgui/Process.m: -------------------------------------------------------------------------------- 1 | #import "Process.h" 2 | #import "Log.h" 3 | #import 4 | #import 5 | 6 | @implementation Process 7 | -(instancetype)initWithName:(NSString*)procName 8 | { 9 | if ((self = [self init])) 10 | { 11 | _name = procName; 12 | _logs = [NSMutableArray new]; 13 | } 14 | return self; 15 | } 16 | 17 | -(void)addToBlacklist 18 | { 19 | HBPreferences* prefs = sharedPreferences(); 20 | NSArray* blacklist = [prefs objectForKey:kProcessBlacklist]; 21 | NSMutableSet* blacklistSet = blacklist ? [NSMutableSet setWithArray:blacklist] : [NSMutableSet new]; 22 | [blacklistSet addObject:_name]; 23 | [prefs setObject:[blacklistSet allObjects] forKey:kProcessBlacklist]; 24 | } 25 | 26 | -(void)removeFromBlacklist 27 | { 28 | HBPreferences* prefs = sharedPreferences(); 29 | NSMutableArray* blacklist = [[prefs objectForKey:kProcessBlacklist] mutableCopy]; 30 | if (blacklist.count) 31 | { 32 | [blacklist removeObject:_name]; 33 | [prefs setObject:[blacklist copy] forKey:kProcessBlacklist]; 34 | } 35 | } 36 | 37 | -(BOOL)isBlacklisted 38 | { 39 | HBPreferences* prefs = sharedPreferences(); 40 | NSArray* blacklist = [prefs objectForKey:kProcessBlacklist]; 41 | return [blacklist containsObject:_name]; 42 | } 43 | 44 | -(void)deleteAllLogs 45 | { 46 | for (Log* log in _logs) 47 | [[NSFileManager defaultManager] removeItemAtPath:log.path error:NULL]; 48 | _logs = [NSMutableArray new]; 49 | } 50 | @end 51 | -------------------------------------------------------------------------------- /Include/Cephei/UIColor+HBAdditions.h: -------------------------------------------------------------------------------- 1 | NS_ASSUME_NONNULL_BEGIN 2 | 3 | /** 4 | * UIColor (HBAdditions) is a class category in `Cephei` that provides some 5 | * convenience methods. 6 | */ 7 | @interface UIColor (HBAdditions) 8 | 9 | /** 10 | * Creates and returns a color object using data from the specified object. 11 | * 12 | * The value is expected to either be an array of 3 or 4 integer RGB or RGBA 13 | * color components (respectively), with values between 0 and 255, or a CSS 14 | * hexadecimal color code string. 15 | * 16 | * @param value The object to retrieve data from. See the discussion for the 17 | * supported object types. 18 | * @returns The color object. The color information represented by this object 19 | * is in the device RGB colorspace. 20 | */ 21 | + (instancetype)hb_colorWithPropertyListValue:(id)value; 22 | 23 | /** 24 | * Initializes and returns a color object using data from the specified object. 25 | * 26 | * The value is expected to either be an array of 3 or 4 integer RGB or RGBA 27 | * color components (respectively), with values between 0 and 255, or a CSS 28 | * hexadecimal color code string. 29 | * 30 | * @param value The object to retrieve data from. See the discussion for the 31 | * supported object types. 32 | * @returns An initialized color object. The color information represented by 33 | * this object is in the device RGB colorspace. 34 | */ 35 | - (instancetype)hb_initWithPropertyListValue:(id)value; 36 | 37 | @end 38 | 39 | NS_ASSUME_NONNULL_END 40 | -------------------------------------------------------------------------------- /cr4shedgui/dpkgutils.m: -------------------------------------------------------------------------------- 1 | #import "dpkgutils.h" 2 | 3 | NSString* outputOfCommand(NSString* cmd, NSArray* args) 4 | { 5 | NSTask* task = [NSTask new]; 6 | task.executableURL = [NSURL fileURLWithPath:cmd]; 7 | task.arguments = args; 8 | 9 | NSPipe* p = [NSPipe pipe]; 10 | task.standardOutput = p; 11 | 12 | [task launch]; 13 | [task waitUntilExit]; 14 | 15 | NSFileHandle* handle = [p fileHandleForReading]; 16 | NSData* data = [handle readDataToEndOfFile]; 17 | return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; 18 | } 19 | 20 | NSString* packageForFile(NSString* file) 21 | { 22 | if (file) 23 | { 24 | NSArray* args = @[@"-S", file]; 25 | NSString* ret = outputOfCommand(@"/usr/bin/dpkg-query", args); 26 | ret = [ret stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; 27 | NSArray* comp = [ret componentsSeparatedByString:@":"]; 28 | NSString* package = comp.count ? comp[0] : nil; 29 | return package.length ? package : nil; 30 | } 31 | return nil; 32 | } 33 | 34 | NSString* controlFieldForPackage(NSString* package, NSString* field) 35 | { 36 | if (package && field) 37 | { 38 | NSString* format = [NSString stringWithFormat:@"-f=\'${%@}\'", field]; 39 | NSArray* args = @[@"-W", format, package]; 40 | NSString* ret = outputOfCommand(@"/usr/bin/dpkg-query", args); 41 | ret = [ret stringByReplacingOccurrencesOfString:@"\'" withString:@""]; 42 | return ret.length ? ret : nil; 43 | } 44 | return nil; 45 | } 46 | -------------------------------------------------------------------------------- /Frameworks/Cephei.framework/Headers/UIColor+HBAdditions.h: -------------------------------------------------------------------------------- 1 | NS_ASSUME_NONNULL_BEGIN 2 | 3 | /** 4 | * UIColor (HBAdditions) is a class category in `Cephei` that provides some 5 | * convenience methods. 6 | */ 7 | @interface UIColor (HBAdditions) 8 | 9 | /** 10 | * Creates and returns a color object using data from the specified object. 11 | * 12 | * The value is expected to either be an array of 3 or 4 integer RGB or RGBA 13 | * color components (respectively), with values between 0 and 255, or a CSS 14 | * hexadecimal color code string. 15 | * 16 | * @param value The object to retrieve data from. See the discussion for the 17 | * supported object types. 18 | * @returns The color object. The color information represented by this object 19 | * is in the device RGB colorspace. 20 | */ 21 | + (instancetype)hb_colorWithPropertyListValue:(id)value; 22 | 23 | /** 24 | * Initializes and returns a color object using data from the specified object. 25 | * 26 | * The value is expected to either be an array of 3 or 4 integer RGB or RGBA 27 | * color components (respectively), with values between 0 and 255, or a CSS 28 | * hexadecimal color code string. 29 | * 30 | * @param value The object to retrieve data from. See the discussion for the 31 | * supported object types. 32 | * @returns An initialized color object. The color information represented by 33 | * this object is in the device RGB colorspace. 34 | */ 35 | - (instancetype)hb_initWithPropertyListValue:(id)value; 36 | 37 | @end 38 | 39 | NS_ASSUME_NONNULL_END 40 | -------------------------------------------------------------------------------- /cr4shedgui/UIImage+UIKitImage.m: -------------------------------------------------------------------------------- 1 | #import "UIImage+UIKitImage.h" 2 | 3 | @implementation UIImage (UIKitImage) 4 | +(UIImage*)uikitImageNamed:(NSString*)name 5 | { 6 | NSString* artworkPath = @"/System/Library/PrivateFrameworks/UIKitCore.framework/Artwork.bundle"; 7 | NSBundle* artworkBundle = [NSBundle bundleWithPath:artworkPath]; 8 | if (!artworkBundle) 9 | { 10 | artworkPath = @"/System/Library/Frameworks/UIKit.framework/Artwork.bundle"; 11 | artworkBundle = [NSBundle bundleWithPath:artworkPath]; 12 | } 13 | UIImage* img = [UIImage imageNamed:name inBundle:artworkBundle]; 14 | return [img imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; 15 | } 16 | 17 | -(UIImage*)resizeToWidth:(CGFloat)newWidth 18 | { 19 | CGFloat aspectRatio = self.size.height / self.size.width; 20 | CGSize newSize = CGSizeMake(newWidth, newWidth * aspectRatio); 21 | UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0); 22 | [self drawInRect:CGRectMake(0, 0, newWidth, newSize.height)]; 23 | UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); 24 | UIGraphicsEndImageContext(); 25 | return newImage; 26 | } 27 | 28 | -(UIImage*)resizeToHeight:(CGFloat)newHeight 29 | { 30 | CGFloat aspectRatio = self.size.width / self.size.height; 31 | CGSize newSize = CGSizeMake(newHeight * aspectRatio, newHeight); 32 | UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0); 33 | [self drawInRect:CGRectMake(0, 0, newSize.width, newHeight)]; 34 | UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); 35 | UIGraphicsEndImageContext(); 36 | return newImage; 37 | } 38 | @end -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | os: osx 2 | language: objective-c 3 | osx_image: xcode11.7 4 | sudo: false 5 | env: 6 | global: 7 | - THEOS=~/theos 8 | before_install: 9 | - brew update 10 | - brew install dpkg ldid xz 11 | - git clone --recursive https://github.com/theos/theos.git $THEOS 12 | - curl -LO https://github.com/theos/sdks/archive/master.zip 13 | - TMP=$(mktemp -d) 14 | - unzip master.zip -d $TMP 15 | - mv $TMP/sdks-master/*.sdk $THEOS/sdks 16 | - rm -r master.zip $TMP 17 | - chmod 0775 ./layout/DEBIAN/postinst 18 | - chmod 0775 ./layout/DEBIAN/prerm 19 | script: 20 | - make clean package FINALPACKAGE=1 21 | before_deploy: 22 | - git config --local user.name "Muirey03" 23 | - git config --local user.email "tcmuir03@gmail.com" 24 | - export RELEASE_PKG_FILE=$(ls ./packages/*.deb) 25 | - export TRAVIS_TAG=${TRAVIS_TAG:-$(date +'%Y%m%d%H%M%S')-$(git log --format=%h -1)} 26 | - git tag $TRAVIS_TAG 27 | deploy: 28 | provider: releases 29 | skip_cleanup: true 30 | api_key: 31 | secure: HlvhOgtQwl9SQEHiZPbNIMLkmvmMcBblBUG0Rc4jxX6AHpSvRlULooAtaQIxMpfJ7uuIBByKMHe4TuXIhoNyAL4EiIgpzNMeEcdSFxCjSFGIbLeoE6bRvh0bHNkJXFl7By/PTfiDRgZ+aHaz0grTcdd8U1lu2dx3MFbVM1GJTMxFmhk6LGEUVS4/ThanAsbNWaDfSLKaSzPuk/gSQpP6/lSt+RumrcYj28r6vzDkL757+SjooTkBviNu0J03ly015euzod0xnobp+LhFqEmLw3aDSxW/FWPnka1ZN+sA8c4fIssUbkcFwv3ceXLnsSk2Ble+wjPHe6SocQIW9zQU8zA4kYgFEt5wJ4FFt+54vV1FNwimUQ5siT8PGgPe6SsOveTbyReAl7eLVZOlht3p44Ciawkv22sS3p0MsBM1Kq2nlS1Z3QXFNWrNEQfA2we2EM3hVSwuQCd2l2+Ln5yg8+vApZpUK68waOirEU/DzpNLDMoYMC6JABoSANg6NDtpSo6V2b5Kbqa8XrJ4zN4jyW7iv75AyIN+7lPFu4SLp3gs7QJ/Z/JKniRTJODtV3RqTn9xoPmSyleKclmeT2HJdWUTYqO4Eh2D1J2fZYcxwXaI1MT5Ey12Ukjh9X2QKjBgm52Zp2PfpuhSecqeykpgS3EH49vi52CrogS5MyKpj/c= 32 | file_glob: true 33 | file: "${RELEASE_PKG_FILE}" 34 | on: 35 | repo: Muirey03/Cr4shed 36 | branch: master 37 | -------------------------------------------------------------------------------- /cr4shedgui/NSString+HTML.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+HTML.h 3 | // Koolistov 4 | // 5 | // Created by Johan Kool on 13-11-09. 6 | // Copyright 2009-2011 Koolistov Pte. Ltd. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without modification, are 9 | // permitted provided that the following conditions are met: 10 | // 11 | // * Redistributions of source code must retain the above copyright notice, this list of 12 | // conditions and the following disclaimer. 13 | // * Neither the name of KOOLISTOV PTE. LTD. nor the names of its contributors may be used to 14 | // endorse or promote products derived from this software without specific prior written 15 | // permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 18 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 20 | // THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 22 | // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | // 27 | 28 | 29 | #import 30 | 31 | @interface NSString (HTML) 32 | 33 | - (NSString *)kv_decodeHTMLCharacterEntities; 34 | - (NSString *)kv_encodeHTMLCharacterEntities; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /Include/Cephei/NSLayoutConstraint+CompactConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Marco Arment on 2014-04-06. 3 | // Copyright (c) 2014 Marco Arment. See included LICENSE file. 4 | // 5 | 6 | /** 7 | * NSLayoutConstraint (CompactConstraint), a class category from Marco Arment’s 8 | * [CompactConstraint](https://github.com/marcoarment/CompactConstraint) 9 | * library, is integrated with Cephei. CompactConstraint provides an Auto Layout 10 | * grammar and methods that are easier to use and understand than UIKit’s built 11 | * in functions for programmatically adding constraints. 12 | * 13 | * Refer to 14 | * [its readme](https://github.com/marcoarment/CompactConstraint/blob/master/README.md) 15 | * to learn how to use it. There are two changes to note: most importantly, the 16 | * methods have an `hb_` prefix, and two methods that are marked as deprecated 17 | * in the original project have been removed. 18 | * 19 | * CompactConstraint is licensed under the MIT License. 20 | */ 21 | @interface NSLayoutConstraint (CompactConstraint) 22 | 23 | + (instancetype)hb_compactConstraint:(NSString *)relationship metrics:(NSDictionary *)metrics views:(NSDictionary *)views self:(id)selfView; 24 | + (NSArray *)hb_compactConstraints:(NSArray *)relationshipStrings metrics:(NSDictionary *)metrics views:(NSDictionary *)views self:(id)selfView; 25 | 26 | // And a convenient shortcut for creating constraints with the visualFormat string as the identifier 27 | + (NSArray *)hb_identifiedConstraintsWithVisualFormat:(NSString *)format options:(NSLayoutFormatOptions)opts metrics:(NSDictionary *)metrics views:(NSDictionary *)views; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /frpreferences/FRPSwitchCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSwitchCell.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPSwitchCell.h" 10 | 11 | @implementation FRPSwitchCell 12 | 13 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting postNotification:(NSString *)notification changeBlock:(FRPSwitchCellChanged)block { 14 | return [[self alloc] cellWithTitle:title setting:setting postNotification:notification changeBlock:block]; 15 | } 16 | 17 | - (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting postNotification:(NSString *)notification changeBlock:(FRPSwitchCellChanged)block { 18 | FRPSwitchCell *cell = [super initWithTitle:title setting:setting]; 19 | cell.postNotification = notification; 20 | cell.valueChanged = block; 21 | self.switchView = [[UISwitch alloc] initWithFrame:CGRectZero]; 22 | [self.switchView setOn:[self.setting.value boolValue] animated:NO]; 23 | [self.switchView addTarget:self action:@selector(switchChanged:) forControlEvents:UIControlEventValueChanged]; 24 | cell.accessoryView = self.switchView; 25 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 26 | return cell; 27 | } 28 | 29 | - (void)switchChanged:(UISwitch *)switchItem { 30 | self.setting.value = [NSNumber numberWithBool:[switchItem isOn]]; 31 | if (self.valueChanged) { 32 | self.valueChanged(switchItem); 33 | } 34 | [[NSNotificationCenter defaultCenter] postNotificationName:self.postNotification object:switchItem]; 35 | } 36 | 37 | - (void)layoutSubviews { 38 | [super layoutSubviews]; 39 | self.switchView.onTintColor = self.tintUIColor; 40 | // self.switchView.tintColor = self.tintUIColor; 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /Frameworks/Cephei.framework/Headers/NSLayoutConstraint+CompactConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Marco Arment on 2014-04-06. 3 | // Copyright (c) 2014 Marco Arment. See included LICENSE file. 4 | // 5 | 6 | /** 7 | * NSLayoutConstraint (CompactConstraint), a class category from Marco Arment’s 8 | * [CompactConstraint](https://github.com/marcoarment/CompactConstraint) 9 | * library, is integrated with Cephei. CompactConstraint provides an Auto Layout 10 | * grammar and methods that are easier to use and understand than UIKit’s built 11 | * in functions for programmatically adding constraints. 12 | * 13 | * Refer to 14 | * [its readme](https://github.com/marcoarment/CompactConstraint/blob/master/README.md) 15 | * to learn how to use it. There are two changes to note: most importantly, the 16 | * methods have an `hb_` prefix, and two methods that are marked as deprecated 17 | * in the original project have been removed. 18 | * 19 | * CompactConstraint is licensed under the MIT License. 20 | */ 21 | @interface NSLayoutConstraint (CompactConstraint) 22 | 23 | + (instancetype)hb_compactConstraint:(NSString *)relationship metrics:(NSDictionary *)metrics views:(NSDictionary *)views self:(id)selfView; 24 | + (NSArray *)hb_compactConstraints:(NSArray *)relationshipStrings metrics:(NSDictionary *)metrics views:(NSDictionary *)views self:(id)selfView; 25 | 26 | // And a convenient shortcut for creating constraints with the visualFormat string as the identifier 27 | + (NSArray *)hb_identifiedConstraintsWithVisualFormat:(NSString *)format options:(NSLayoutFormatOptions)opts metrics:(NSDictionary *)metrics views:(NSDictionary *)views; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Include/sharedutils.h: -------------------------------------------------------------------------------- 1 | #import 2 | #include 3 | 4 | #define CR4ProcsNeedRefreshNotificationName @"com.muirey03.cr4shed-procsNeedRefresh" 5 | #define CR4BlacklistDidChangeNotificationName @"com.muirey03.cr4shed-blacklistDidChange" 6 | #define kSortingMethod @"SortingMethod" 7 | #define kProcessBlacklist @"ProcessBlacklist" 8 | #define kEnableJetsam @"EnableJetsam" 9 | 10 | typedef NS_ENUM(NSInteger, CR4DateFormat) 11 | { 12 | CR4DateFormatPretty, 13 | CR4DateFormatTimeOnly, 14 | CR4DateFormatFilename 15 | }; 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | NSString* getImage(NSString* symbol); 21 | NSString* determineCulprit(NSArray* symbols); 22 | NSString* stringFromDate(NSDate* date, CR4DateFormat type); 23 | NSString* deviceVersion(); 24 | NSString* deviceName(); 25 | size_t rread(mach_port_t task, mach_vm_address_t where, void* p, size_t size); 26 | size_t rwrite(mach_port_t task, mach_vm_address_t where, const void* p, size_t size); 27 | char* rread_string(mach_port_t task, vm_address_t addr); 28 | uint64_t rread64(mach_port_t task, mach_vm_address_t where); 29 | uint32_t rread32(mach_port_t task, mach_vm_address_t where); 30 | mach_vm_address_t taskGetImageInfos(mach_port_t task); 31 | void markProcessAsHandled(void); 32 | bool processHasBeenHandled(mach_port_t task); 33 | @class HBPreferences; 34 | HBPreferences* sharedPreferences(void); 35 | @class NSString; 36 | @class NSDictionary; 37 | NSString* addInfoToLog(NSString* logContents, NSDictionary* info); 38 | NSDictionary* getInfoFromLog(NSString* logContents); 39 | #ifdef __cplusplus 40 | } 41 | 42 | bool isBlacklisted(NSString* procName = nil); 43 | bool wantsLogJetsam(); 44 | void lazyLoadBundle(NSString* const bundlePath); 45 | void showCr4shedNotification(NSString* notifContent, NSDictionary* notifUserInfo); 46 | #endif 47 | -------------------------------------------------------------------------------- /Include/Cephei/UIView+CompactConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Marco Arment on 2014-04-06. 3 | // Copyright (c) 2014 Marco Arment. See included LICENSE file. 4 | // 5 | 6 | #import "NSLayoutConstraint+CompactConstraint.h" 7 | 8 | /** 9 | * UIView (CompactConstraint), a class category from Marco Arment’s 10 | * [CompactConstraint](https://github.com/marcoarment/CompactConstraint) 11 | * library, is integrated with Cephei. CompactConstraint provides an Auto Layout 12 | * grammar and methods that are easier to use and understand than UIKit’s built 13 | * in functions for programmatically adding constraints. 14 | * 15 | * Refer to 16 | * [its readme](https://github.com/marcoarment/CompactConstraint/blob/master/README.md) 17 | * to learn how to use it. There are two changes to note: most importantly, the 18 | * methods have an `hb_` prefix, and two methods that are marked as deprecated 19 | * in the original project have been removed. 20 | * 21 | * CompactConstraint is licensed under the MIT License. 22 | */ 23 | @interface UIView (CompactConstraint) 24 | 25 | // Add a single constraint with the compact syntax 26 | - (NSLayoutConstraint *)hb_addCompactConstraint:(NSString *)relationship metrics:(NSDictionary *)metrics views:(NSDictionary *)views; 27 | 28 | // Add any number of constraints. Can also mix in Visual Format Language strings. 29 | - (NSArray *)hb_addCompactConstraints:(NSArray *)relationshipStrings metrics:(NSDictionary *)metrics views:(NSDictionary *)views; 30 | 31 | // And a convenient shortcut for what we always end up doing with the visualFormat call. 32 | - (void)hb_addConstraintsWithVisualFormat:(NSString *)format options:(NSLayoutFormatOptions)opts metrics:(NSDictionary *)metrics views:(NSDictionary *)views; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /frpreferences/FRPDeveloperCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPDeveloperCell.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/3/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPDeveloperCell.h" 10 | 11 | @interface FRPDeveloperCell () 12 | @property (nonatomic, strong) NSString *url; 13 | @property (nonatomic, strong) UIImage *image; 14 | @end 15 | 16 | @implementation FRPDeveloperCell 17 | 18 | + (instancetype)cellWithTitle:(NSString *)title detail:(NSString *)detail image:(UIImage *)image url:(NSString *)url { 19 | return [[self alloc] cellWithTitle:title detail:detail image:image url:url]; 20 | } 21 | 22 | - (instancetype)cellWithTitle:(NSString *)title detail:(NSString *)detail image:(UIImage *)image url:(NSString *)url { 23 | FRPDeveloperCell *cell = [super initWithTitle:title setting:nil]; 24 | cell.url = url; 25 | cell.image = image; 26 | cell.detailTextLabel.text = detail; 27 | cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 28 | 29 | CGSize size = CGSizeMake(35,35); 30 | UIGraphicsBeginImageContextWithOptions(size, NO, UIScreen.mainScreen.scale); 31 | [self.image drawInRect:CGRectMake(0, 0, size.width, size.height)]; 32 | UIImage *newThumbnail = UIGraphicsGetImageFromCurrentImageContext(); 33 | UIGraphicsEndImageContext(); 34 | cell.imageView.image = newThumbnail;; 35 | return cell; 36 | } 37 | 38 | - (void)layoutSubviews { 39 | [super layoutSubviews]; 40 | self.imageView.layer.cornerRadius = self.imageView.frame.size.width / 2; 41 | self.imageView.clipsToBounds = YES; 42 | } 43 | 44 | - (void)didSelectFromTable:(FRPreferences *)viewController { 45 | [viewController.tableView deselectRowAtIndexPath:[viewController.tableView indexPathForCell:self] animated:YES]; 46 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.url]]; 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /frpreferences/FRPSettings.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSettings.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 5/5/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPSettings.h" 10 | 11 | @interface FRPSettings () 12 | typedef void(^FRPSettingValueDidChangeBlock)(void); 13 | @property (nonatomic, copy) FRPSettingValueDidChangeBlock valueDidChangeBlock; 14 | @end 15 | 16 | @implementation FRPSettings 17 | 18 | + (instancetype)settingsWithKey:(NSString *)key defaultValue:(id)defaultValue { 19 | return [[self alloc] initWithKey:key defaultValue:defaultValue]; 20 | } 21 | 22 | - (instancetype)initWithKey:(NSString *)key defaultValue:(id)defaultValue { 23 | if (self = [super init]) { 24 | self.key = key; 25 | [[NSUserDefaults standardUserDefaults] registerDefaults:@{self.key: defaultValue}]; 26 | } 27 | 28 | return self; 29 | } 30 | 31 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 32 | if (self.valueDidChangeBlock) { 33 | self.valueDidChangeBlock(); 34 | } 35 | } 36 | 37 | - (id)value { 38 | return [[NSUserDefaults standardUserDefaults] objectForKey:self.key]; 39 | } 40 | 41 | - (void)setValue:(id)value { 42 | if (self.value != value) { 43 | [[NSUserDefaults standardUserDefaults] setObject:value forKey:self.key]; 44 | [[NSUserDefaults standardUserDefaults] synchronize]; 45 | if ([self.fileSave length] > 0) { 46 | [self saveValue:value]; 47 | } 48 | } 49 | } 50 | 51 | - (void)saveValue:(id)value { 52 | NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithContentsOfFile:self.fileSave]; 53 | if (dict == nil) dict = [NSMutableDictionary new]; 54 | [dict setObject:value forKey:self.key]; 55 | [dict writeToFile:self.fileSave atomically:YES]; 56 | } 57 | 58 | @end -------------------------------------------------------------------------------- /Frameworks/Cephei.framework/Headers/UIView+CompactConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Marco Arment on 2014-04-06. 3 | // Copyright (c) 2014 Marco Arment. See included LICENSE file. 4 | // 5 | 6 | #import "NSLayoutConstraint+CompactConstraint.h" 7 | 8 | /** 9 | * UIView (CompactConstraint), a class category from Marco Arment’s 10 | * [CompactConstraint](https://github.com/marcoarment/CompactConstraint) 11 | * library, is integrated with Cephei. CompactConstraint provides an Auto Layout 12 | * grammar and methods that are easier to use and understand than UIKit’s built 13 | * in functions for programmatically adding constraints. 14 | * 15 | * Refer to 16 | * [its readme](https://github.com/marcoarment/CompactConstraint/blob/master/README.md) 17 | * to learn how to use it. There are two changes to note: most importantly, the 18 | * methods have an `hb_` prefix, and two methods that are marked as deprecated 19 | * in the original project have been removed. 20 | * 21 | * CompactConstraint is licensed under the MIT License. 22 | */ 23 | @interface UIView (CompactConstraint) 24 | 25 | // Add a single constraint with the compact syntax 26 | - (NSLayoutConstraint *)hb_addCompactConstraint:(NSString *)relationship metrics:(NSDictionary *)metrics views:(NSDictionary *)views; 27 | 28 | // Add any number of constraints. Can also mix in Visual Format Language strings. 29 | - (NSArray *)hb_addCompactConstraints:(NSArray *)relationshipStrings metrics:(NSDictionary *)metrics views:(NSDictionary *)views; 30 | 31 | // And a convenient shortcut for what we always end up doing with the visualFormat call. 32 | - (void)hb_addConstraintsWithVisualFormat:(NSString *)format options:(NSLayoutFormatOptions)opts metrics:(NSDictionary *)metrics views:(NSDictionary *)views; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /cr4shedgui/CRAAppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "CRAAppDelegate.h" 2 | #import "CRARootViewController.h" 3 | #import "CRASettingsViewController.h" 4 | #import "CRALogController.h" 5 | #import "Log.h" 6 | 7 | @implementation CRAAppDelegate 8 | 9 | -(BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions 10 | { 11 | [UNUserNotificationCenter currentNotificationCenter].delegate = self; 12 | 13 | //create UI: 14 | _window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 15 | 16 | _rootViewController = [[UINavigationController alloc] initWithRootViewController:[CRARootViewController new]]; 17 | _settingsViewController = [[UINavigationController alloc] initWithRootViewController:[CRASettingsViewController newSettingsController]]; 18 | 19 | _tabBarVC = [UITabBarController new]; 20 | _tabBarVC.viewControllers = @[_rootViewController, _settingsViewController]; 21 | _window.rootViewController = _tabBarVC; 22 | [_window makeKeyAndVisible]; 23 | return YES; 24 | } 25 | 26 | -(void)applicationDidBecomeActive:(UIApplication*)application 27 | { 28 | //reset badge number: 29 | [application setApplicationIconBadgeNumber:0]; 30 | } 31 | 32 | -(void)userNotificationCenter:(UNUserNotificationCenter*)center didReceiveNotificationResponse:(UNNotificationResponse*)response withCompletionHandler:(void (^)(void))completionHandler 33 | { 34 | NSString* logPath = response.notification.request.content.userInfo[@"logPath"]; 35 | if (logPath.length) 36 | [self displayLog:logPath]; 37 | if (completionHandler) 38 | completionHandler(); 39 | } 40 | 41 | -(void)displayLog:(NSString*)logPath 42 | { 43 | Log* log = [[Log alloc] initWithPath:logPath]; 44 | CRALogController* logVC = [[CRALogController alloc] initWithLog:log]; 45 | _tabBarVC.selectedViewController = _rootViewController; 46 | [_rootViewController pushViewController:logVC animated:YES]; 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /cr4shedmach/cr4shed_mach.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct exception_info 5 | { 6 | NSString* processName; 7 | NSString* bundleID; 8 | NSString* exception_type; 9 | NSString* swiftErrorMessage; 10 | const char* exception_subtype; 11 | const char* vm_info; 12 | uint64_t thread_num; 13 | NSString* thread_name; 14 | char* exception_codes; 15 | std::vector register_info; 16 | NSArray* stackSymbols; 17 | }; 18 | 19 | @interface NSObject (Private) 20 | -(NSString*)_methodDescription; 21 | @end 22 | 23 | @interface CrashReport : NSObject 24 | @property (nonatomic, retain) NSString* procName; 25 | //%new properties 26 | @property (nonatomic, assign) time_t crashTime; 27 | @property (nonatomic, assign) uint64_t __far; 28 | @property (nonatomic, assign) struct exception_info* exceptionInfo; 29 | @property (nonatomic, assign) int realCrashedNumber; 30 | @property (nonatomic, assign) BOOL hasBeenHandled; 31 | -(void)cr4_sharedInitWithTask:(mach_port_t)task exceptionType:(exception_type_t)exception thread:(mach_port_t)thread threadStateFlavor:(int*)flavour threadState:(thread_state_t)old_state threadStateCount:(mach_msg_type_number_t)old_stateCnt; 32 | -(BOOL)isExceptionNonFatal; 33 | -(BOOL)cr4_isExceptionNonFatal; 34 | -(NSString*)signalName; 35 | -(NSString*)cr4_signalName:(int)sig; 36 | -(NSArray*)binaryImages; 37 | -(void)decodeBacktraceWithBlock:(void(^)(NSInteger, id))arg1; 38 | -(NSDictionary*)binaryImageDictionaryForAddress:(uint64_t)addr; 39 | -(void)generateCr4shedReport; 40 | -(NSString*)_readStringAtTaskAddress:(mach_vm_address_t)addr immutableOnly:(BOOL)imut maxLength:(NSUInteger)maxLen; 41 | -(NSString*)_readStringAtTaskAddress:(mach_vm_address_t)addr maxLength:(NSUInteger)maxLen immutableCheck:(BOOL)imut; 42 | -(NSString*)decode_signal; 43 | @end 44 | 45 | @interface OSASymbolInfo : NSObject 46 | @property (readonly) NSString* path; 47 | @property (assign) NSUInteger start; 48 | @property (assign) NSUInteger size; 49 | @end 50 | 51 | @interface OSABinaryImageSegment : NSObject 52 | -(OSASymbolInfo*)symbolInfo; 53 | @end 54 | -------------------------------------------------------------------------------- /frpreferences/FRPTextFieldCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSwitchCell.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPTextFieldCell.h" 10 | 11 | @interface FRPTextFieldCell () 12 | 13 | @property (nonatomic, strong) UITextField *textField; 14 | 15 | @end 16 | 17 | @implementation FRPTextFieldCell 18 | 19 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting placeholder:(NSString *)placeholder postNotification:(NSString *)notification changeBlock:(FRPTextFieldCellChanged)block { 20 | return [[self alloc] cellWithTitle:title setting:setting placeholder:placeholder postNotification:notification changeBlock:block]; 21 | } 22 | 23 | - (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting placeholder:(NSString *)placeholder postNotification:(NSString *)notification changeBlock:(FRPTextFieldCellChanged)block { 24 | FRPTextFieldCell *cell = [super initWithTitle:title setting:setting]; 25 | cell.setting = setting; 26 | cell.postNotification = notification; 27 | cell.valueChanged = block; 28 | self.textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 190, 30)]; 29 | [self.textField setDelegate:self]; 30 | [self.textField setTextAlignment:NSTextAlignmentRight]; 31 | [self.textField setClearButtonMode:UITextFieldViewModeWhileEditing]; 32 | [self.textField setText:setting.value]; 33 | [self.textField setPlaceholder:placeholder]; 34 | [self.textField addTarget:self action:@selector(textFieldChanged:) forControlEvents:UIControlEventEditingChanged]; 35 | self.textField.returnKeyType = UIReturnKeyDone; 36 | cell.accessoryView = self.textField; 37 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 38 | 39 | return cell; 40 | } 41 | 42 | - (void)textFieldChanged:(UITextField *)textField { 43 | self.setting.value = [textField text]; 44 | if (self.valueChanged) { 45 | self.valueChanged(textField); 46 | } 47 | [[NSNotificationCenter defaultCenter] postNotificationName:self.postNotification object:textField]; 48 | } 49 | 50 | - (BOOL)textFieldShouldReturn:(id)textField { 51 | [textField resignFirstResponder]; 52 | return NO; 53 | } 54 | 55 | - (void)layoutSubviews { 56 | [super layoutSubviews]; 57 | self.textField.tintColor = self.tintUIColor; 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /cr4shedmach/methods.txt: -------------------------------------------------------------------------------- 1 | stashStatus:note: 2 | initWithTask:exceptionType:thread:threadId:threadStateFlavor:threadState:threadStateCount: 3 | dealloc 4 | unpackExceptionCodes 5 | _extractWorkQueueLimitsFromData: 6 | inspectLivePid:exceptionCodes:count: 7 | extractThreadStateInfo: 8 | pathFromPid: 9 | nameFromPid: 10 | _getSymbolicator:forAutopsy: 11 | finishExtractionUsingCorpse: 12 | autopsyCorpse 13 | autopsyCorpse:size: 14 | _parseCorpse:size: 15 | problemType 16 | appleCareDetails 17 | reportNamePrefix 18 | isActionable 19 | additionalIPSMetadata 20 | slice_uuid 21 | _extractLastExceptionBacktraceUsingSymbolicator:usingCatalog: 22 | _readAddressFromMemory:atSymbol: 23 | _readAddressFromMemory:atAddress: 24 | _readStringAtTaskAddress:maxLength:immutableCheck: 25 | _copyStringFromTask:atAddress:maxLength:immutableCheck: 26 | _regionAtAddress:immutableCheck: 27 | _readDataAtAddress:size: 28 | _addASILine:fromOwner:isSafe: 29 | _extractCrashReporterAnnotationsFromSymbolOwner:withMemory: 30 | _extractBinaryImageInfoUsingSymbolicator: 31 | _objcSelectorAddressForMessenger:memory: 32 | _objcSelectorNameForMessenger: 33 | symbolicateFrame:adjusted:withSymbolicator:usingCatalog:andBlock: 34 | composeFrame:info: 35 | _extractBacktraceInfoUsingSymbolicator:usingCorpse:usingCatalog: 36 | _findContainingRegion:address: 37 | _findMallocZone:usingSymbolicator: 38 | _extractMallocTraceInfo:withSymbolicator:usingCatalog: 39 | _extractPGMReportUsingSymbolicator:usingCatalog: 40 | _extractQuarantineReportUsingSymbolicator:usingCatalog: 41 | setApplicationSpecificInformation: 42 | captureLSInfo 43 | loadBundleInfo 44 | _extractVMMap: 45 | _descriptionForException: 46 | decode_cpuType 47 | decode_signal 48 | decode_exceptionType 49 | captureDiagInfo: 50 | decode_exceptionCodes 51 | terminationReasonExceptionCode 52 | decode_reasonNamespace 53 | decode_reasonLibSystem 54 | decode_reasonCarousel 55 | decode_reasonDyldWithInfo: 56 | decode_versionCodes: 57 | decode_reasonBTC 58 | decode_reasonTcc 59 | decode_reasonExec 60 | decode_reasonCoreAnimation 61 | decode_reasonMetal 62 | decode_reasonWatchKit 63 | decode_reasonWatchdog 64 | decode_reasonLibxpc 65 | decode_reasonPortSpace 66 | decode_reasonBacklightServices 67 | decode_reason 68 | decode_ubsanCode: 69 | decode_esr 70 | decode_threadState:usingCatalog: 71 | _symbolicateRegister:inRange:withSymbolicator:usingCatalog: 72 | _getObjCReadOnlyRange: 73 | isExceptionNonFatal 74 | reduceToTwoSigFigures: 75 | getTrialCache 76 | generateLogAtLevel:withBlock: 77 | saveWithOptions: 78 | getNotificationInfo 79 | getObserverInfo 80 | sendToMetricKit 81 | sRouteID 82 | proc_id 83 | procName 84 | bundle_id 85 | short_vers 86 | responsibleProc 87 | is_beta 88 | is_simulated 89 | exceptionType 90 | crashingAddress 91 | sharedCacheAddress 92 | .cxx_destruct -------------------------------------------------------------------------------- /cr4shedgui/ent.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | platform-application 6 | 7 | com.apple.private.security.no-container 8 | 9 | com.apple.private.skip-library-validation 10 | 11 | dynamic-codesigning 12 | 13 | application-identifier 14 | com.muirey03.cr4shedgui 15 | com.apple.AutoWake-write-access 16 | 17 | com.apple.private.tcc.manager 18 | 19 | com.apple.private.tcc.allow 20 | 21 | kTCCServiceMediaLibrary 22 | 23 | com.apple.SystemConfiguration.SCDynamicStore-write-access 24 | 25 | com.apple.avfoundation.allow-still-image-capture-shutter-sound-manipulation 26 | 27 | com.apple.coreaudio.allow-amr-decode 28 | 29 | com.apple.coreaudio.allow-speex-codec 30 | 31 | com.apple.coremedia.allow-protected-content-playback 32 | 33 | com.apple.lsapplicationworkspace.rebuildappdatabases 34 | 35 | com.apple.private.MobileContainerManager.allowed 36 | 37 | com.apple.mediastream.mstreamd-access 38 | 39 | com.apple.messages.composeclient 40 | 41 | com.apple.mobile.deleted.AllowFreeSpace 42 | 43 | com.apple.private.network.socket-delegate 44 | 45 | com.apple.itunesstored.private 46 | 47 | com.apple.multitasking.systemappassertions 48 | 49 | com.apple.security.assets.music.read-write 50 | 51 | com.apple.multitasking.termination 52 | 53 | com.apple.SystemConfiguration.SCPreferences-write-access 54 | 55 | checklessPersistentURLTranslation 56 | 57 | com.apple.private.mobileinstall.allowedSPI 58 | 59 | Install 60 | Uninstall 61 | UninstallForLaunchServices 62 | SetCapabilities 63 | Lookup 64 | InstallForLaunchServices 65 | CopyInstalledAppsForLaunchServices 66 | UpdateSinfForLaunchServices 67 | 68 | keychain-access-groups 69 | 70 | apple 71 | 72 | com.apple.security.iokit-user-client-class 73 | 74 | IOUserClient 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /frpreferences/FRPSelectListTable.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSelectionListViewController.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 5/10/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPSelectListTable.h" 10 | 11 | @implementation FRPSelectListTable 12 | 13 | - (instancetype)initWithStyle:(UITableViewStyle)style title:(NSString *)title items:(NSArray *)items values:(NSArray *)values currentValue:(NSString *)value popViewOnSelect:(BOOL)back changeBlock:(FRPListItemChange)block { 14 | listItems = items; 15 | listValues = values; 16 | currentValue = value; 17 | popView = back; 18 | pageTitle = title; 19 | self.itemChanged = ^(id sender) { 20 | if (block) block(sender); 21 | }; 22 | return [self initWithStyle:style]; 23 | } 24 | 25 | - (void)viewDidLoad { 26 | [super viewDidLoad]; 27 | self.title = pageTitle; 28 | self.view.tintColor = self.tintUIColor; 29 | self.tableView.tintColor = self.tintUIColor; 30 | self.navigationController.navigationBar.tintColor = self.tintUIColor; 31 | } 32 | 33 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)theTableView { 34 | return 1; 35 | } 36 | 37 | - (NSInteger)tableView:(UITableView *)theTableView numberOfRowsInSection:(NSInteger)section { 38 | return [listItems count]; 39 | } 40 | 41 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 42 | static NSString *cellIdentifier = @"LinkCellIdentifier"; 43 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 44 | 45 | if (cell == nil) { 46 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; 47 | } 48 | cell.textLabel.text = [listItems objectAtIndex:[indexPath row]]; 49 | if ([[listValues objectAtIndex:[indexPath row]] isEqualToString:currentValue]) { 50 | cell.accessoryType = UITableViewCellAccessoryCheckmark; 51 | } 52 | else { 53 | cell.accessoryType = UITableViewCellAccessoryNone; 54 | } 55 | 56 | return cell; 57 | } 58 | 59 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 60 | self.itemChanged([listItems objectAtIndex:[indexPath row]]); 61 | 62 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 63 | for (UITableViewCell *cell in tableView.visibleCells) { 64 | cell.accessoryType = UITableViewCellAccessoryNone; 65 | } 66 | [tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark; 67 | if (popView) 68 | [self.navigationController popViewControllerAnimated:YES]; 69 | } 70 | 71 | - (void)didReceiveMemoryWarning { 72 | [super didReceiveMemoryWarning]; 73 | } 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /cr4shedmach/ivars.txt: -------------------------------------------------------------------------------- 1 | _task (I) 2 | _proc_starttime ({timeval="tv_sec"q"tv_usec"i}) 3 | _proc_start_abstime (Q) 4 | _proc_exit_abstime (Q) 5 | _procPath (@"NSString") 6 | _cpuType (i) 7 | _is64Bit (B) 8 | _taskImages (@"NSMutableArray") 9 | _usedImages (@"NSArray") 10 | _threadInfos (@"NSMutableArray") 11 | _applicationSpecificInfo (@"NSMutableDictionary") 12 | _applicationSpecificInfoFullSensitive (@"NSMutableDictionary") 13 | _maxBinaryIdentifierLength (i) 14 | _extraInfo (@"NSMutableDictionary") 15 | _cs_status (I) 16 | _uniqId (Q) 17 | _exceptionCode (^q) 18 | _exceptionCodeCount (I) 19 | _signal (i) 20 | _threadState ([1296I]) 21 | _threadStateFlavor (i) 22 | _threadStateCount (I) 23 | _threadStateDecoded (@"NSDictionary") 24 | _pageinState ([1296I]) 25 | _pageinStateCount (I) 26 | _exceptionState ([1296I]) 27 | _exceptionStateCount (I) 28 | _threadId (Q) 29 | _crashedThreadNumber (i) 30 | _parentProcessName (@"NSString") 31 | _ppid (i) 32 | _uid (I) 33 | _highlightedThreadNumber (i) 34 | _lastExceptionBacktrace (@"NSArray") 35 | _slice_uuid ([37c]) 36 | _is_first_party (B) 37 | _task_role (i) 38 | _coalition_id (Q) 39 | _coalition_name (@"NSString") 40 | _queue_serial_no (Q) 41 | _memgraph_filename (@"NSString") 42 | _spewage_diag (@"NSMutableDictionary") 43 | _spewage_diag_total_length (Q) 44 | _abort_cause (Q) 45 | _exit_snapshot_length (I) 46 | _exit_snapshot (^{exit_reason_snapshot=IQQ}) 47 | _exit_payload_length (I) 48 | _exit_payload (^v) 49 | _terminator_reason (@"NSString") 50 | _terminator_proc (@"NSString") 51 | _terminator_pid (i) 52 | _caller_name (@"NSString") 53 | _ktriage_info (@"NSString") 54 | _vmregion_info (@"NSString") 55 | _diagToolExtras (@"NSArray") 56 | _sig_frames (@"NSMutableString") 57 | _probGuardReport (@"NSDictionary") 58 | _quarantineReport (@"NSDictionary") 59 | _sroute_id (Q) 60 | _is_corpse (B) 61 | _awakeSystemUptime (Q) 62 | _workloop_id (Q) 63 | _responsible_pid (i) 64 | _workQueueLimits (@"NSDictionary") 65 | _bundle_info (@"NSDictionary") 66 | _build_info (@"NSDictionary") 67 | _store_info (@"NSDictionary") 68 | _bundle_url (@"NSURL") 69 | _adam_id (@"NSString") 70 | _lsAppType (@"NSString") 71 | _lsDisplayName (@"NSString") 72 | _suspected3rdPartyPlugin (@"NSString") 73 | _bundleVisibility (B) 74 | _fatalDyldErrorOnLaunch (B) 75 | _platform (I) 76 | _sharedCacheBase (Q) 77 | _sharedCacheSize (Q) 78 | _sharedCacheUuid ([16C]) 79 | _sandboxContainer (@"NSString") 80 | _sleepWakeUUID (@"NSString") 81 | _vmSummary (@"NSString") 82 | _rosettaRegions (@"NSMutableArray") 83 | _mxTerminationReason (@"NSString") 84 | _threadPortOriginal (I) 85 | _threadPortPedigree (@"NSMutableArray") 86 | _is_beta (B) 87 | _is_simulated (B) 88 | _proc_id (i) 89 | _exceptionType (i) 90 | _procName (@"NSString") 91 | _bundle_id (@"NSString") 92 | _short_vers (@"NSString") 93 | _responsibleProc (@"NSString") 94 | _crashingAddress (Q) 95 | _sharedCacheAddress (Q) 96 | -------------------------------------------------------------------------------- /cr4shedgui/CRAProcessManager.m: -------------------------------------------------------------------------------- 1 | #import "CRAProcessManager.h" 2 | #import "Process.h" 3 | #import "Log.h" 4 | #import 5 | 6 | @implementation CRAProcessManager 7 | +(instancetype)sharedInstance 8 | { 9 | static CRAProcessManager* instance = nil; 10 | static dispatch_once_t onceToken = 0; 11 | dispatch_once (&onceToken, ^{ 12 | instance = [CRAProcessManager new]; 13 | }); 14 | return instance; 15 | } 16 | 17 | -(instancetype)init 18 | { 19 | if ((self = [super init])) 20 | { 21 | [self refresh]; 22 | } 23 | return self; 24 | } 25 | 26 | -(void)refresh 27 | { 28 | _processes = [NSMutableArray new]; 29 | //loop through all logs 30 | NSString* const logsDirectory = @"/var/mobile/Library/Cr4shed"; 31 | NSMutableArray* files = [[[NSFileManager defaultManager] contentsOfDirectoryAtPath:logsDirectory error:nil] mutableCopy]; 32 | for (int i = 0; i < files.count; i++) 33 | { 34 | NSString* fileName = files[i]; 35 | NSString* filePath = [logsDirectory stringByAppendingPathComponent:fileName]; 36 | if (![[fileName pathExtension] isEqualToString:@"log"]) 37 | { 38 | [files removeObjectAtIndex:i]; 39 | i--; 40 | continue; 41 | } 42 | //file is a log 43 | Process* proc = nil; 44 | NSArray* comp = [fileName componentsSeparatedByString:@"@"]; 45 | NSString* procName = comp.count > 1 ? comp[0] : @"(null)"; 46 | 47 | //check if process is already in array 48 | for (Process* p in _processes) 49 | { 50 | if ([p.name isEqualToString:procName]) 51 | { 52 | proc = p; 53 | break; 54 | } 55 | } 56 | if (!proc) 57 | { 58 | //process isn't in array, add it 59 | proc = [[Process alloc] initWithName:procName]; 60 | [_processes addObject:proc]; 61 | } 62 | Log* log = [[Log alloc] initWithPath:filePath]; 63 | [proc.logs addObject:log]; 64 | 65 | NSDate* date = log.date; 66 | if (!proc.latestDate || [proc.latestDate compare:date] == NSOrderedAscending) 67 | { 68 | proc.latestDate = date; 69 | } 70 | } 71 | 72 | [self sortProcs]; 73 | } 74 | 75 | -(void)sortProcs 76 | { 77 | NSString* sortingMethod = [[NSUserDefaults standardUserDefaults] objectForKey:kSortingMethod]; 78 | [_processes sortUsingComparator:^NSComparisonResult(Process* a, Process* b) { 79 | /* 80 | Sorting method: 81 | Date = @"Date" or nil 82 | Name = @"Name" 83 | */ 84 | if ([sortingMethod isEqualToString:@"Name"]) 85 | return [[a.name lowercaseString] compare:[b.name lowercaseString]]; 86 | NSDate* first = a.latestDate; 87 | NSDate* second = b.latestDate; 88 | return [second compare:first]; 89 | }]; 90 | for (int i = 0; i < _processes.count; i++) 91 | { 92 | if (_processes[i].logs.count == 0) 93 | { 94 | [_processes removeObjectAtIndex:i]; 95 | i--; 96 | } 97 | } 98 | } 99 | @end 100 | -------------------------------------------------------------------------------- /frpreferences/FRPListCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRListCell.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPListCell.h" 10 | #import "FRPSelectListTable.h" 11 | 12 | @interface FRPListCell () 13 | @end 14 | 15 | @implementation FRPListCell 16 | 17 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting items:(NSArray *)items value:(NSArray *)values popViewOnSelect:(BOOL)pop postNotification:(NSString *)notification changedBlock:(FRPListItemChange)block { 18 | return [[self alloc] cellWithTitle:title setting:setting items:items value:values popViewOnSelect:pop postNotification:(NSString *)notification changedBlock:block]; 19 | } 20 | 21 | 22 | - (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting items:(NSArray *)items value:(NSArray *)values popViewOnSelect:(BOOL)pop postNotification:(NSString *)notification changedBlock:(FRPListItemChange)block { 23 | FRPListCell *cell = [super initWithTitle:title setting:setting]; 24 | [cell setValueChanged:block]; 25 | cell.items = items; 26 | cell.values = values; 27 | self.popView = pop; 28 | cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 29 | if ([self.values containsObject:setting.value]) 30 | cell.detailTextLabel.text = [self.items objectAtIndex:[self.values indexOfObject:setting.value]]; 31 | 32 | return cell; 33 | } 34 | 35 | - (void)didSelectFromTable:(FRPreferences *)viewController { 36 | NSIndexPath *indexPath = [viewController.tableView indexPathForCell:self]; 37 | [viewController.tableView deselectRowAtIndexPath:indexPath animated:YES]; 38 | UITableViewCell *cell = [viewController.tableView cellForRowAtIndexPath:indexPath]; 39 | 40 | FRPSelectListTable *selectionList = [[FRPSelectListTable alloc] initWithStyle:UITableViewStyleGrouped title:cell.textLabel.text items:self.items values:self.values currentValue:self.setting.value popViewOnSelect:self.popView changeBlock:^(NSString *item) { 41 | cell.detailTextLabel.text = item; 42 | NSString *valueOfItem = [self.values objectAtIndex:[self.items indexOfObject:item]]; 43 | self.setting.value = valueOfItem; 44 | if (self.valueChanged) { 45 | self.valueChanged(valueOfItem); 46 | } 47 | [[NSNotificationCenter defaultCenter] postNotificationName:self.postNotification object:valueOfItem]; 48 | }]; 49 | selectionList.tintUIColor = self.tintUIColor; 50 | if (viewController.navigationController) { 51 | [viewController.navigationController pushViewController:selectionList animated:YES]; 52 | } else { 53 | [viewController.navigationController presentViewController:selectionList animated:YES completion:nil]; 54 | } 55 | } 56 | 57 | - (void)layoutSubviews { 58 | [super layoutSubviews]; 59 | } 60 | @end 61 | -------------------------------------------------------------------------------- /cr4shedmach/mach_utils.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #import 4 | #import 5 | #include 6 | 7 | typedef struct 8 | { 9 | __uint64_t __x[29]; /* General purpose registers x0-x28 */ 10 | __uint64_t __fp; /* Frame pointer x29 */ 11 | __uint64_t __lr; /* Link register x30 */ 12 | __uint64_t __sp; /* Stack pointer x31 */ 13 | __uint64_t __pc; /* Program counter */ 14 | __uint32_t __cpsr; /* Current program status register */ 15 | __uint32_t __pad; /* Same size for 32-bit or 64-bit clients */ 16 | } _CR4_THREAD_STATE64; 17 | 18 | struct register_info 19 | { 20 | char* name; 21 | uint64_t value; 22 | }; 23 | 24 | struct crashreporter_annotations_t 25 | { 26 | uint64_t version; 27 | char* message; 28 | uint64_t signature_string; 29 | uint64_t backtrace; 30 | char* message2; 31 | uint64_t thread; 32 | uint64_t dialog_mode; 33 | uint64_t abort_cause; 34 | }; 35 | 36 | NSString* mach_exception_string(exception_type_t exception, NSString* signalName); 37 | const char* mach_code_string(exception_type_t type, mach_exception_data_t codes, mach_msg_type_number_t codeCnt); 38 | char* mach_exception_codes_string(mach_exception_data_t codes, mach_msg_type_number_t codeCnt); 39 | vm_prot_t vm_region_get_protection(mach_port_t task, vm_address_t address); 40 | const char* mach_exception_vm_info(mach_port_t task, exception_type_t type, mach_exception_data_t codes, mach_msg_type_number_t codeCnt); 41 | std::vector get_register_info(_CR4_THREAD_STATE64* thread_state); 42 | uint64_t thread_number(mach_port_t task, mach_port_t thread); 43 | exception_type_t mach_exception_type(int sig, mach_exception_data_type_t* exception_subtype); 44 | void freeThreadArray(thread_act_port_array_t threads, mach_msg_type_number_t thread_count); 45 | BOOL createDir(NSString* path); 46 | void writeStringToFile(NSString* str, NSString* path); 47 | NSString* stringFromTime(time_t time, CR4DateFormat type); 48 | mach_vm_address_t findSymbolInTask(mach_port_t task, const char* symbolName, NSString* lastPathComponent, NSString** imageName); 49 | template 50 | static inline Type CR4GetIvar(id self, const char* name) 51 | { 52 | Ivar ivar = class_getInstanceVariable(object_getClass(self), name); 53 | if (ivar == NULL) 54 | @throw [NSException exceptionWithName:@"IvarNotFoundException" reason:[NSString stringWithFormat:@"Unable to find Ivar with name: \"%s\". THIS IS A BUG IN CR4SHED. Please send this report to @Muirey03 on Twitter.", name] userInfo:nil]; 55 | 56 | #if __has_feature(objc_arc) 57 | void* pointer = ivar == NULL ? NULL : reinterpret_cast((__bridge void*)self) + ivar_getOffset(ivar); 58 | #else 59 | void* pointer = ivar == NULL ? NULL : reinterpret_cast(self) + ivar_getOffset(ivar); 60 | #endif 61 | return *reinterpret_cast(pointer); 62 | } 63 | static inline bool CR4IvarExists(id self, const char* name) 64 | { 65 | return !!class_getInstanceVariable(object_getClass(self), name); 66 | } 67 | -------------------------------------------------------------------------------- /frpreferences/FRPSegmentCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPSegmentCell.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/19/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPSegmentCell.h" 10 | 11 | @interface FRPSegmentCell () 12 | @property (nonatomic, strong) UISegmentedControl *segment; 13 | @property (nonatomic, strong) NSArray *values; 14 | @property (nonatomic, strong) NSArray *displayedValues; 15 | @end 16 | 17 | @implementation FRPSegmentCell 18 | 19 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting items:(NSArray *)items postNotification:(NSString *)notification changeBlock:(FRPSegmentValueChanged)block { 20 | return [[self alloc] cellWithTitle:title setting:setting values:items displayedValues:items postNotification:notification changeBlock:block]; 21 | } 22 | 23 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting values:(NSArray *)values displayedValues:(NSArray *)displayedValues postNotification:(NSString *)notification changeBlock:(FRPSegmentValueChanged)block { 24 | return [[self alloc] cellWithTitle:title setting:setting values:values displayedValues:displayedValues postNotification:notification changeBlock:block]; 25 | } 26 | 27 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting values:(NSArray *)values postNotification:(NSString *)notification changeBlock:(FRPSegmentValueChanged)block { 28 | return [[self alloc] cellWithTitle:title setting:setting values:values displayedValues:nil postNotification:notification changeBlock:block]; 29 | } 30 | 31 | - (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting values:(NSArray *)values displayedValues:(NSArray *)displayedValues postNotification:(NSString *)notification changeBlock:(FRPSegmentValueChanged)block { 32 | FRPSegmentCell *cell = [super initWithTitle:title setting:setting]; 33 | cell.setting = setting; 34 | cell.postNotification = notification; 35 | [cell setValueChanged:block]; 36 | self.values = values; 37 | self.displayedValues = displayedValues; 38 | if (!self.displayedValues) { 39 | self.displayedValues = values; 40 | } 41 | 42 | self.segment = [[UISegmentedControl alloc] initWithItems:self.displayedValues]; 43 | [self.segment addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged]; 44 | self.segment.selectedSegmentIndex = [self.values indexOfObject:cell.setting.value]; 45 | 46 | cell.accessoryView = self.segment; 47 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 48 | 49 | return cell; 50 | } 51 | 52 | - (void)segmentAction:(UISegmentedControl *)segment { 53 | NSString *selectedItem = [self.values objectAtIndex:segment.selectedSegmentIndex]; 54 | self.setting.value = selectedItem; 55 | if (self.valueChanged) { 56 | self.valueChanged(selectedItem); 57 | } 58 | [[NSNotificationCenter defaultCenter] postNotificationName:self.postNotification object:selectedItem]; 59 | } 60 | 61 | 62 | - (void)layoutSubviews { 63 | [super layoutSubviews]; 64 | self.segment.tintColor = self.tintUIColor; 65 | } 66 | @end 67 | -------------------------------------------------------------------------------- /cr4shedgui/CRALogController.m: -------------------------------------------------------------------------------- 1 | #import "CRALogController.h" 2 | #import "Log.h" 3 | #import "NSString+HTML.h" 4 | 5 | @implementation CRALogController 6 | -(instancetype)initWithLog:(Log*)log 7 | { 8 | if ((self = [self init])) 9 | { 10 | _log = log; 11 | self.title = log.dateName; 12 | } 13 | return self; 14 | } 15 | 16 | -(void)loadView 17 | { 18 | [super loadView]; 19 | 20 | if ([self.navigationItem respondsToSelector:@selector(setLargeTitleDisplayMode:)]) 21 | self.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeNever; 22 | 23 | if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){13,0,0}]) 24 | self.view.backgroundColor = [UIColor systemBackgroundColor]; 25 | else 26 | self.view.backgroundColor = [UIColor whiteColor]; 27 | 28 | UIBarButtonItem* shareButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(share:)]; 29 | self.navigationItem.rightBarButtonItem = shareButton; 30 | 31 | webView = [WKWebView new]; 32 | webView.opaque = NO; 33 | webView.backgroundColor = [UIColor clearColor]; 34 | logMessage = _log.contents; 35 | 36 | NSString* htmlString = @".
%@
"; 37 | NSString* styleString = @"body { font-size:8pt; } @media (prefers-color-scheme: dark) { body { color: white; } }"; 38 | NSString* formattedStr = [logMessage kv_encodeHTMLCharacterEntities]; 39 | htmlString = [NSString stringWithFormat:htmlString, styleString, formattedStr]; 40 | [self.view addSubview:webView]; 41 | 42 | webView.translatesAutoresizingMaskIntoConstraints = NO; 43 | [webView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor].active = YES; 44 | [webView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor].active = YES; 45 | [webView.topAnchor constraintEqualToAnchor:self.view.topAnchor].active = YES; 46 | [webView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor].active = YES; 47 | 48 | [webView loadHTMLString:htmlString baseURL:nil]; 49 | } 50 | 51 | -(void)viewDidAppear:(BOOL)arg1 52 | { 53 | [super viewDidAppear:arg1]; 54 | self.navigationController.interactivePopGestureRecognizer.delegate = self; 55 | self.navigationController.interactivePopGestureRecognizer.enabled = YES; 56 | } 57 | 58 | -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer 59 | { 60 | return YES; 61 | } 62 | 63 | -(void)share:(id)sender 64 | { 65 | NSArray* activityItems = @[logMessage]; 66 | UIActivityViewController* activityViewControntroller = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil]; 67 | activityViewControntroller.excludedActivityTypes = @[]; 68 | if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { 69 | activityViewControntroller.popoverPresentationController.sourceView = self.view; 70 | activityViewControntroller.popoverPresentationController.sourceRect = CGRectMake(self.view.bounds.size.width/2, self.view.bounds.size.height/4, 0, 0); 71 | } 72 | [self presentViewController:activityViewControntroller animated:YES completion:nil]; 73 | } 74 | @end 75 | -------------------------------------------------------------------------------- /cr4shedgui/CRASettingsViewController.m: -------------------------------------------------------------------------------- 1 | #import "CRASettingsViewController.h" 2 | #import "UIImage+UIKitImage.h" 3 | #import 4 | #import 5 | #import "CRABlacklistViewController.h" 6 | 7 | void openURL(NSString* urlStr) 8 | { 9 | NSURL* url = [NSURL URLWithString:urlStr]; 10 | UIApplication* app = [UIApplication sharedApplication]; 11 | #pragma clang diagnostic push 12 | #pragma clang diagnostic ignored "-Wdeprecated" 13 | if ([app respondsToSelector:@selector(openURL:options:completionHandler:)]) 14 | [app openURL:url options:@{} completionHandler:nil]; 15 | else 16 | [app openURL:url]; 17 | #pragma clang diagnostic pop 18 | } 19 | 20 | @implementation CRASettingsViewController 21 | +(instancetype)newSettingsController 22 | { 23 | __block CRASettingsViewController* settingsVC = nil; 24 | 25 | //main section: 26 | FRPSection* mainSection = [FRPSection sectionWithTitle:@"General" footer:@""]; 27 | FRPSegmentCell* segmentCell = [FRPSegmentCell 28 | cellWithTitle:@"Process sorting method" 29 | setting:[FRPSettings settingsWithKey:kSortingMethod defaultValue:@"Date"] 30 | values:@[@"Date", @"Name"] 31 | displayedValues:@[@"Date", @"Name"] 32 | postNotification:CR4ProcsNeedRefreshNotificationName 33 | changeBlock:^(NSString* value) { 34 | [settingsVC updatePrefsWithKey:kSortingMethod value:value]; 35 | } 36 | ]; 37 | [mainSection addCell:segmentCell]; 38 | [mainSection addCell:[FRPLinkCell cellWithTitle:@"Process blacklist" selectedBlock:^(id sender) { 39 | [settingsVC.navigationController pushViewController:[CRABlacklistViewController new] animated:YES]; 40 | }]]; 41 | FRPSwitchCell* jetsamCell = [FRPSwitchCell 42 | cellWithTitle:@"Log Jetsam Events" 43 | setting:[FRPSettings settingsWithKey:kEnableJetsam defaultValue:@YES] 44 | postNotification:CR4ProcsNeedRefreshNotificationName 45 | changeBlock:^(UISwitch* sender) { 46 | [settingsVC updatePrefsWithKey:kEnableJetsam value:@(sender.on)]; 47 | } 48 | ]; 49 | [mainSection addCell:jetsamCell]; 50 | 51 | //credits section 52 | FRPSection* creditsSection = [FRPSection sectionWithTitle:@"Credits" footer:@""]; 53 | [creditsSection addCell:[FRPLinkCell cellWithTitle:@"Follow @Muirey03 on Twitter" selectedBlock:^(id sender) { 54 | openURL(@"https://twitter.com/Muirey03"); 55 | }]]; 56 | [creditsSection addCell:[FRPLinkCell cellWithTitle:@"Donate to help development" selectedBlock:^(id sender) { 57 | openURL(@"https://paypal.me/Muirey03Dev"); 58 | }]]; 59 | 60 | settingsVC = [CRASettingsViewController tableWithSections:@[mainSection, creditsSection] title:@"Settings" tintColor:nil]; 61 | return settingsVC; 62 | } 63 | 64 | -(instancetype)initTableWithSections:(NSArray*)sections 65 | { 66 | if ((self = [super initTableWithSections:sections])) 67 | { 68 | //initialise tabbar item: 69 | UIImage* itemImg = [[UIImage uikitImageNamed:@"BackgroundTask_settings"] resizeToWidth:25.]; 70 | self.tabBarItem = [[UITabBarItem alloc] initWithTitle:self.title image:itemImg tag:0]; 71 | } 72 | return self; 73 | } 74 | 75 | -(void)updatePrefsWithKey:(NSString*)key value:(id)value 76 | { 77 | HBPreferences* prefs = sharedPreferences(); 78 | [prefs setObject:value forKey:key]; 79 | [prefs synchronize]; 80 | } 81 | 82 | -(void)loadView 83 | { 84 | [super loadView]; 85 | if ([self.navigationController.navigationBar respondsToSelector:@selector(setPrefersLargeTitles:)]) 86 | self.navigationController.navigationBar.prefersLargeTitles = YES; 87 | } 88 | 89 | -(void)viewDidAppear:(BOOL)arg1 90 | { 91 | [super viewDidAppear:arg1]; 92 | self.navigationController.interactivePopGestureRecognizer.delegate = nil; 93 | self.navigationController.interactivePopGestureRecognizer.enabled = NO; 94 | } 95 | @end 96 | -------------------------------------------------------------------------------- /frpreferences/FRPreferences.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRPPreferences.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 7/2/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPreferences.h" 10 | #import "FRPCell.h" 11 | #import "FRPSection.h" 12 | 13 | @interface FRPreferences () 14 | 15 | @property (nonatomic, strong) UIColor *tintUIColor; 16 | 17 | @end 18 | 19 | @implementation FRPreferences 20 | 21 | + (instancetype)tableWithSections:(NSArray *)sections title:(NSString *)title tintColor:(UIColor *)color { 22 | FRPreferences *table = [[self alloc] initTableWithSections:sections]; 23 | table.title = title; 24 | table.tintUIColor = color; 25 | return table; 26 | } 27 | 28 | - (instancetype)initTableWithSections:(NSArray *)sections { 29 | if (self = [super initWithStyle:UITableViewStyleGrouped]) { 30 | self.sections = sections; 31 | } 32 | return self; 33 | } 34 | 35 | - (void)updateTintColors { 36 | UIColor *tintUIColor = self.tintUIColor; 37 | for (FRPSection *section in self.sections) { 38 | for (FRPCell *cell in section.cells) { 39 | cell.tintUIColor = tintUIColor; 40 | if ([self.plistPath length] > 0 && cell.setting) { 41 | cell.setting.fileSave = self.plistPath; 42 | } 43 | } 44 | section.tintUIColor = tintUIColor; 45 | } 46 | self.view.tintColor = tintUIColor; 47 | self.tableView.tintColor = tintUIColor; 48 | } 49 | 50 | - (void)viewDidDisappear:(BOOL)animated { 51 | [super viewDidDisappear:animated]; 52 | } 53 | 54 | - (void)viewWillAppear:(BOOL)animated { 55 | [super viewWillAppear:animated]; 56 | [self updateTintColors]; 57 | 58 | NSIndexPath *selectedRowIndexPath = [self.tableView indexPathForSelectedRow]; 59 | 60 | if (selectedRowIndexPath) { 61 | [self.tableView deselectRowAtIndexPath:selectedRowIndexPath animated:YES]; 62 | 63 | [[self.navigationController transitionCoordinator] notifyWhenInteractionEndsUsingBlock:^(id context) { 64 | if ([context isCancelled]) { 65 | [self.tableView selectRowAtIndexPath:selectedRowIndexPath animated:YES scrollPosition:UITableViewScrollPositionNone]; 66 | } 67 | }]; 68 | } 69 | } 70 | 71 | - (FRPCell *)cellForIndexPath:(NSIndexPath *)indexPath { 72 | return [self.sections[indexPath.section] cells][indexPath.row]; 73 | } 74 | 75 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 76 | return self.sections.count; 77 | } 78 | 79 | - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { 80 | return [self.sections[section] headerTitle]; 81 | } 82 | 83 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)sectionIndex { 84 | FRPSection *section = self.sections[sectionIndex]; 85 | 86 | return section.cells.count; 87 | } 88 | 89 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 90 | FRPCell *cell = [self cellForIndexPath:indexPath]; 91 | 92 | return (cell.height > 0)?cell.height:UITableViewAutomaticDimension; 93 | } 94 | 95 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 96 | FRPCell *cell = [self cellForIndexPath:indexPath]; 97 | 98 | return cell; 99 | } 100 | 101 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 102 | FRPCell *cell = [self cellForIndexPath:indexPath]; 103 | if ([cell respondsToSelector:@selector(didSelectFromTable:)]) [cell didSelectFromTable:self]; 104 | } 105 | 106 | - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section { 107 | return [self.sections[section] footerTitle]; 108 | } 109 | 110 | @end -------------------------------------------------------------------------------- /cr4shedd/main.mm: -------------------------------------------------------------------------------- 1 | @import CoreFoundation; 2 | @import Foundation; 3 | 4 | #import 5 | #import 6 | #include 7 | #include 8 | 9 | @interface Cr4shedServer : NSObject 10 | -(BOOL)createDirectoryAtPath:(NSString*)path; 11 | @end 12 | 13 | @implementation Cr4shedServer 14 | { 15 | MRYIPCCenter* _ipcCenter; 16 | } 17 | 18 | +(void)load 19 | { 20 | [self sharedInstance]; 21 | } 22 | 23 | +(id)sharedInstance 24 | { 25 | static dispatch_once_t once = 0; 26 | __strong static id sharedInstance = nil; 27 | dispatch_once(&once, ^{ 28 | sharedInstance = [[self alloc] init]; 29 | }); 30 | return sharedInstance; 31 | } 32 | 33 | -(id)init 34 | { 35 | if ((self = [super init])) 36 | { 37 | _ipcCenter = [MRYIPCCenter centerNamed:@"com.muirey03.cr4sheddserver"]; 38 | [_ipcCenter addTarget:self action:@selector(writeString:)]; 39 | [_ipcCenter addTarget:self action:@selector(sendNotification:)]; 40 | [_ipcCenter addTarget:self action:@selector(stringFromTime:)]; 41 | [_ipcCenter addTarget:self action:@selector(isProcessBlacklisted:)]; 42 | } 43 | return self; 44 | } 45 | 46 | -(NSDictionary*)writeString:(NSDictionary*)userInfo 47 | { 48 | //get info from userInfo: 49 | NSString* str = userInfo[@"string"]; 50 | NSString* filename = [userInfo[@"filename"] lastPathComponent]; 51 | if (!filename) 52 | return nil; 53 | NSString* fullFilename = [filename stringByAppendingPathExtension:@"log"]; 54 | //validate filename is safe: 55 | if ([fullFilename pathComponents].count > 1) 56 | return nil; 57 | //formulate path: 58 | NSString* const cr4Dir = @"/var/mobile/Library/Cr4shed"; 59 | NSString* path = [cr4Dir stringByAppendingPathComponent:fullFilename]; 60 | //create cr4shed dir if neccessary: 61 | //(deleting it if it is a file not a dir) 62 | NSFileManager* manager = [NSFileManager defaultManager]; 63 | BOOL isDir = NO; 64 | BOOL exists = [manager fileExistsAtPath:cr4Dir isDirectory:&isDir]; 65 | if (!exists || !isDir) 66 | { 67 | if (exists) 68 | [manager removeItemAtPath:cr4Dir error:NULL]; 69 | exists = [self createDirectoryAtPath:cr4Dir]; 70 | if (!exists) 71 | return nil; 72 | } 73 | //change path so that it doesn't conflict: 74 | for (unsigned long long i = 1; [[NSFileManager defaultManager] fileExistsAtPath:path]; i++) 75 | path = [cr4Dir stringByAppendingPathComponent:[[NSString stringWithFormat:@"%@ (%llu)", filename, i] stringByAppendingPathExtension:@"log"]]; 76 | //create new file: 77 | NSDictionary* attributes = @{ 78 | NSFilePosixPermissions : @0666, 79 | NSFileOwnerAccountName : @"mobile", 80 | NSFileGroupOwnerAccountName : @"mobile" 81 | }; 82 | NSData* contentsData = [str dataUsingEncoding:NSUTF8StringEncoding]; 83 | [manager createFileAtPath:path contents:contentsData attributes:attributes]; 84 | return @{@"path" : path}; 85 | } 86 | 87 | -(BOOL)createDirectoryAtPath:(NSString*)path 88 | { 89 | NSDictionary* attributes = @{ 90 | NSFilePosixPermissions : @0755, 91 | NSFileOwnerAccountName : @"mobile", 92 | NSFileGroupOwnerAccountName : @"mobile" 93 | }; 94 | return [[NSFileManager defaultManager] createDirectoryAtURL:[NSURL fileURLWithPath:path] withIntermediateDirectories:YES attributes:attributes error:NULL]; 95 | } 96 | 97 | -(void)sendNotification:(NSDictionary*)userInfo 98 | { 99 | NSString* content = userInfo[@"content"]; 100 | NSDictionary* notifUserInfo = userInfo[@"userInfo"]; 101 | showCr4shedNotification(content, notifUserInfo); 102 | } 103 | 104 | -(NSDictionary*)stringFromTime:(NSDictionary*)userInfo 105 | { 106 | time_t t = (time_t)[userInfo[@"time"] integerValue]; 107 | CR4DateFormat type = (CR4DateFormat)[userInfo[@"type"] integerValue]; 108 | NSDate* date = [NSDate dateWithTimeIntervalSince1970:t]; 109 | NSString* ret = stringFromDate(date, type); 110 | return ret ? @{@"ret" : ret} : @{}; 111 | } 112 | 113 | -(NSNumber*)isProcessBlacklisted:(NSString*)procName 114 | { 115 | return @(isBlacklisted(procName)); 116 | } 117 | 118 | -(NSNumber*)shouldLogJetsam { 119 | return @(wantsLogJetsam()); 120 | } 121 | @end 122 | 123 | int main(int argc, char** argv, char** envp) 124 | { 125 | @autoreleasepool 126 | { 127 | [Cr4shedServer load]; 128 | 129 | NSRunLoop* runLoop = [NSRunLoop currentRunLoop]; 130 | for (;;) 131 | [runLoop run]; 132 | return 0; 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /cr4shedjetsam/TweakJetsam.xm: -------------------------------------------------------------------------------- 1 | @import Foundation; 2 | #import 3 | #import 4 | #import "../cr4shedmach/mach_utils.h" 5 | #import "cr4shed_jetsam.h" 6 | 7 | static NSString* serverWriteStringToFile(NSString* str, NSString* filename) 8 | { 9 | MRYIPCCenter* ipcCenter = [MRYIPCCenter centerNamed:@"com.muirey03.cr4sheddserver"]; 10 | NSDictionary* reply = [ipcCenter callExternalMethod:@selector(writeString:) withArguments:@{@"string" : str, @"filename" : filename}]; 11 | return reply[@"path"]; 12 | } 13 | 14 | %hook MemoryResourceException 15 | -(BOOL)extractCorpseInfo 16 | { 17 | BOOL ret = %orig; 18 | MRYIPCCenter* ipcCenter = [MRYIPCCenter centerNamed:@"com.muirey03.cr4sheddserver"]; 19 | 20 | BOOL shouldLogJetsam = [[ipcCenter callExternalMethod:@selector(shouldLogJetsam) withArguments:@{}] boolValue]; 21 | if (!shouldLogJetsam) 22 | { 23 | return ret; 24 | } 25 | 26 | NSNumber* blacklistedBool = [ipcCenter callExternalMethod:@selector(isProcessBlacklisted:) withArguments:self.execName]; 27 | if (!blacklistedBool.boolValue) 28 | { 29 | [self extractBacktraceInfo]; 30 | [self generateCr4shedReport]; 31 | } 32 | 33 | return ret; 34 | } 35 | 36 | %new 37 | -(void)generateCr4shedReport 38 | { 39 | time_t crashTime = [self.startTime timeIntervalSince1970]; 40 | NSString* dateString = stringFromTime(crashTime, CR4DateFormatPretty); 41 | NSString* device = [NSString stringWithFormat:@"%@, iOS %@", deviceName(), deviceVersion()]; 42 | NSString* const reason = @"The process was terminated for exceeding jetsam memory limits"; 43 | NSMutableString* logStr = [NSMutableString stringWithFormat:@"Date: %@\n" 44 | @"Process: %@\n" 45 | @"Bundle id: %@\n" 46 | @"Device: %@\n\n" 47 | @"Reason: %@\n" 48 | @"Uptime: %llds\n", 49 | dateString, 50 | self.execName, 51 | self.bundleID, 52 | device, 53 | reason, 54 | (long long)self.upTime]; 55 | 56 | [logStr appendFormat:@"%@", [self fetchMemoryInfo]]; 57 | if ([logStr characterAtIndex:logStr.length - 1] != '\n') 58 | [logStr appendString:@"\n"]; 59 | [logStr appendFormat:@"\n%@", [self prettyPrintBinaryImages]]; 60 | 61 | NSDictionary* extraInfo = @{ 62 | @"NSExceptionReason" : reason, 63 | @"ProcessName" : self.execName ?: @"", 64 | @"ProcessBundleID" : self.bundleID ?: @"" 65 | }; 66 | logStr = [addInfoToLog(logStr, extraInfo) mutableCopy]; 67 | 68 | // Get the date to use for the filename: 69 | NSString* filenameDateStr = stringFromTime(crashTime, CR4DateFormatFilename); 70 | 71 | // Get the path for the new crash log: 72 | NSString* path = [NSString stringWithFormat:@"%@@%@", self.execName, filenameDateStr]; 73 | 74 | // Create the crash log 75 | serverWriteStringToFile(logStr, path); 76 | } 77 | 78 | %new 79 | -(NSString*)fetchMemoryInfo 80 | { 81 | NSMutableString* memoryInfo = [NSMutableString new]; 82 | mach_port_t task = self.task; 83 | struct task_basic_info taskInfo; 84 | mach_msg_type_number_t count = TASK_BASIC_INFO_COUNT; 85 | kern_return_t kr = task_info(task, TASK_BASIC_INFO, (task_info_t)&taskInfo, &count); 86 | if (kr == KERN_SUCCESS) 87 | { 88 | [memoryInfo appendFormat:@"Virtual memory size: 0x%zx bytes\n", (size_t)taskInfo.virtual_size]; 89 | [memoryInfo appendFormat:@"Resident memory size: 0x%zx bytes\n", (size_t)taskInfo.resident_size]; 90 | 91 | thread_act_array_t threads = NULL; 92 | mach_msg_type_number_t threadCount = 0; 93 | kr = task_threads(task, &threads, &threadCount); 94 | if (kr == KERN_SUCCESS) 95 | { 96 | uint32_t cpuUsage = 0; 97 | for (uint i = 0; i < threadCount; i++) 98 | { 99 | struct thread_basic_info threadInfo; 100 | count = THREAD_BASIC_INFO_COUNT; 101 | kr = thread_info(threads[i], THREAD_BASIC_INFO, (thread_info_t)&threadInfo, &count); 102 | if (kr == KERN_SUCCESS) 103 | { 104 | cpuUsage += threadInfo.cpu_usage; 105 | } 106 | 107 | mach_port_deallocate(mach_task_self(), threads[i]); 108 | } 109 | 110 | vm_deallocate(mach_task_self(), (vm_address_t)threads, sizeof(*threads) * threadCount); 111 | 112 | [memoryInfo appendFormat:@"CPU usage: %u%%\n", cpuUsage]; 113 | [memoryInfo appendFormat:@"Thread count: %u\n", threadCount]; 114 | } 115 | } 116 | return memoryInfo; 117 | } 118 | %end 119 | -------------------------------------------------------------------------------- /cr4shedgui/CRABlacklistViewController.m: -------------------------------------------------------------------------------- 1 | #import "CRABlacklistViewController.h" 2 | #import 3 | #import 4 | 5 | @implementation CRABlacklistCell 6 | -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)reuseIdentifier 7 | { 8 | if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) 9 | { 10 | _textField = [[UITextField alloc] initWithFrame:CGRectZero]; 11 | _textField.delegate = self; 12 | _textField.placeholder = @"Process name (Case-sensitive)"; 13 | 14 | _textField.translatesAutoresizingMaskIntoConstraints = NO; 15 | [self.contentView addSubview:_textField]; 16 | [_textField.leadingAnchor constraintEqualToAnchor:self.contentView.leadingAnchor constant:15.].active = YES; 17 | [_textField.trailingAnchor constraintEqualToAnchor:self.contentView.trailingAnchor].active = YES; 18 | [_textField.topAnchor constraintEqualToAnchor:self.topAnchor].active = YES; 19 | [_textField.bottomAnchor constraintEqualToAnchor:self.bottomAnchor].active = YES; 20 | } 21 | return self; 22 | } 23 | 24 | -(BOOL)textFieldShouldReturn:(UITextField*)textField 25 | { 26 | [textField resignFirstResponder]; 27 | return YES; 28 | } 29 | 30 | -(void)textFieldDidEndEditing:(UITextField*)textField 31 | { 32 | _textChangedCallback(_textField.text); 33 | } 34 | @end 35 | 36 | @implementation CRABlacklistViewController 37 | 38 | -(instancetype)init 39 | { 40 | if ((self = [super initWithStyle:UITableViewStyleGrouped])) 41 | { 42 | self.title = @"Blacklist"; 43 | UIBarButtonItem* plusButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(plusButtonAction)]; 44 | self.navigationItem.rightBarButtonItem = plusButton; 45 | 46 | //CR4BlacklistDidChangeNotificationName 47 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadBlacklist) name:CR4BlacklistDidChangeNotificationName object:nil]; 48 | 49 | self.tableView.editing = YES; 50 | self.tableView.allowsSelection = NO; 51 | } 52 | return self; 53 | } 54 | 55 | -(void)reloadBlacklist 56 | { 57 | _blacklist = [[sharedPreferences() objectForKey:kProcessBlacklist] mutableCopy]; 58 | _blacklist = _blacklist ?: [NSMutableArray new]; 59 | [self.tableView reloadData]; 60 | } 61 | 62 | -(void)updatePreferences 63 | { 64 | [sharedPreferences() setObject:[_blacklist copy] forKey:kProcessBlacklist]; 65 | } 66 | 67 | -(void)plusButtonAction 68 | { 69 | [_blacklist addObject:@""]; 70 | [self.tableView insertRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:_blacklist.count - 1 inSection:0]] withRowAnimation:UITableViewRowAnimationAutomatic]; 71 | } 72 | 73 | -(void)loadView 74 | { 75 | [super loadView]; 76 | 77 | //load blacklist: 78 | [self reloadBlacklist]; 79 | } 80 | 81 | -(void)viewDidAppear:(BOOL)arg1 82 | { 83 | [super viewDidAppear:arg1]; 84 | self.navigationController.interactivePopGestureRecognizer.delegate = self; 85 | self.navigationController.interactivePopGestureRecognizer.enabled = YES; 86 | } 87 | 88 | #pragma mark - Table View Data Source 89 | 90 | -(NSInteger)numberOfSectionsInTableView:(UITableView*)tableView 91 | { 92 | return 1; 93 | } 94 | 95 | -(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section 96 | { 97 | return _blacklist.count; 98 | } 99 | 100 | -(NSString*)tableView:(UITableView*)tableView titleForHeaderInSection:(NSInteger)section 101 | { 102 | return @"Blacklisted Processes"; 103 | } 104 | 105 | -(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath 106 | { 107 | CRABlacklistCell* cell = [tableView dequeueReusableCellWithIdentifier:@"BlacklistCell"]; 108 | if (!cell) 109 | cell = [[CRABlacklistCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"BlacklistCell"]; 110 | 111 | cell.textField.text = _blacklist[indexPath.row]; 112 | cell.textChangedCallback = ^(NSString* text) { 113 | _blacklist[indexPath.row] = text; 114 | [self updatePreferences]; 115 | }; 116 | return cell; 117 | } 118 | 119 | -(void)tableView:(UITableView*)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath*)indexPath 120 | { 121 | [_blacklist removeObjectAtIndex:indexPath.row]; 122 | [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; 123 | [self updatePreferences]; 124 | } 125 | 126 | -(void)dealloc 127 | { 128 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 129 | } 130 | 131 | @end 132 | -------------------------------------------------------------------------------- /Shared/symbolication.mm: -------------------------------------------------------------------------------- 1 | @import Foundation; 2 | 3 | #include 4 | #include 5 | #import "symbolication.h" 6 | 7 | NSString* nameForRemoteSymbol(uint64_t addr, NSString* path, NSString* uuidStr, uint64_t imgAddr, CSArchitecture arch) 8 | { 9 | NSString* name = nil; 10 | if (path.length && uuidStr.length && addr && imgAddr) 11 | { 12 | CFUUIDRef uuid = CFUUIDCreateFromString(kCFAllocatorDefault, (__bridge CFStringRef)uuidStr); 13 | if (uuid) 14 | { 15 | CSSymbolicatorRef symbolicator = CSSymbolicatorCreateWithURLAndArchitecture((__bridge CFURLRef)[NSURL fileURLWithPath:path], arch); 16 | if (!CSIsNull(symbolicator)) 17 | { 18 | CSSymbolOwnerRef owner = CSSymbolicatorGetSymbolOwnerWithUUIDAtTime(symbolicator, uuid, kCSNow); 19 | if (!CSIsNull(owner)) 20 | { 21 | uint64_t base = CSSymbolOwnerGetBaseAddress(owner); 22 | uint64_t symOffset = addr - imgAddr + base; 23 | CSSymbolRef symbol = CSSymbolOwnerGetSymbolWithAddress(owner, symOffset); 24 | if (!CSIsNull(symbol)) 25 | { 26 | const char* c_name = CSSymbolGetName(symbol); 27 | if (c_name) 28 | name = [NSString stringWithUTF8String:c_name]; 29 | else 30 | name = [NSString stringWithFormat:@"func_%llx", CSSymbolGetRange(symbol).location]; 31 | } 32 | } 33 | CSRelease(symbolicator); 34 | } 35 | CFRelease(uuid); 36 | } 37 | } 38 | return name; 39 | } 40 | 41 | NSString* nameForLocalSymbol(NSNumber* addrNum, uint64_t* outOffset) 42 | { 43 | NSString* name = nil; 44 | void* symAddr = (void*)[addrNum unsignedLongLongValue]; 45 | Dl_info info = { NULL, NULL, NULL, NULL }; 46 | int success = dladdr(symAddr, &info); 47 | if (symAddr && success) 48 | { 49 | CSSymbolicatorRef symbolicator = CSSymbolicatorCreateWithTask(mach_task_self()); 50 | if (!CSIsNull(symbolicator)) 51 | { 52 | CSSymbolOwnerRef owner = CSSymbolicatorGetSymbolOwnerWithAddressAtTime(symbolicator, (vm_address_t)symAddr, kCSNow); 53 | if (!CSIsNull(owner)) 54 | { 55 | uint64_t imgAddr = (uint64_t)info.dli_fbase; 56 | if (outOffset) *outOffset = (uint64_t)symAddr - imgAddr; 57 | CSSymbolRef symbol = CSSymbolOwnerGetSymbolWithAddress(owner, (mach_vm_address_t)symAddr); 58 | if (!CSIsNull(symbol)) 59 | { 60 | const char* c_name = CSSymbolGetName(symbol); 61 | if (c_name) 62 | name = [NSString stringWithUTF8String:c_name]; 63 | else 64 | name = [NSString stringWithFormat:@"func_%llx", CSSymbolGetRange(symbol).location - imgAddr]; 65 | } 66 | } 67 | CSRelease(symbolicator); 68 | } 69 | } 70 | return name; 71 | } 72 | 73 | NSArray* symbolicatedStackSymbols(NSArray* callStackSymbols, NSArray* callStackReturnAddresses) 74 | { 75 | NSMutableArray* symArr = [callStackSymbols mutableCopy]; 76 | for (uint32_t i = 0; i < callStackSymbols.count; i++) 77 | { 78 | uint64_t offset = 0; 79 | NSString* symName = nameForLocalSymbol(callStackReturnAddresses[i], &offset); 80 | if (symName && symName.length) 81 | { 82 | NSMutableArray* components = [[symArr[i] componentsSeparatedByString:@" "] mutableCopy]; 83 | NSMutableArray* newComponents = [[NSMutableArray alloc] initWithCapacity:3]; 84 | for (uint32_t b = 0; b < components.count; b++) 85 | { 86 | if (components[b].length) 87 | { 88 | [newComponents addObject:components[b]]; 89 | if (newComponents.count >= 3) 90 | break; 91 | } 92 | } 93 | if (newComponents.count < 3) 94 | continue; 95 | NSString* newSym = [newComponents[0] stringByPaddingToLength:4 withString:@" " startingAtIndex:0]; 96 | newSym = [newSym stringByAppendingString:newComponents[1]]; 97 | newSym = [newSym stringByPaddingToLength:40 withString:@" " startingAtIndex:0]; 98 | newSym = [newSym stringByAppendingString:newComponents[2]]; 99 | NSUInteger padding = newSym.length + 30; 100 | newSym = [NSString stringWithFormat:@"%@ 0x%llx + 0x%llx", newSym, [callStackReturnAddresses[i] unsignedLongLongValue] - offset, offset]; 101 | newSym = [newSym stringByPaddingToLength:padding withString:@" " startingAtIndex:0]; 102 | if (symName) 103 | newSym = [newSym stringByAppendingFormat:@" // %@", symName]; 104 | symArr[i] = newSym; 105 | } 106 | } 107 | return symArr; 108 | } 109 | 110 | NSArray* symbolicatedException(NSException* e) 111 | { 112 | @autoreleasepool 113 | { 114 | NSArray* symArr = e.callStackSymbols; 115 | NSArray* addresses = e.callStackReturnAddresses; 116 | return symbolicatedStackSymbols(symArr, addresses); 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /cr4shedjetsam/cr4shed_jetsam.h: -------------------------------------------------------------------------------- 1 | /* 2 | Properties: 3 | version (Tq,R,V_version) 4 | task (TI,R,V_task) 5 | suspensionToken (TI,R,V_suspensionToken) 6 | footprintOutput (T@"NSDictionary",R,V_footprintOutput) 7 | pid (Ti,R,V_pid) 8 | ppid (Ti,R,V_ppid) 9 | cid (TQ,R,V_cid) 10 | startTime (T@"NSDate",R,V_startTime) 11 | currentTime (T@"NSDate",R,V_currentTime) 12 | dirtyFlags (TI,R,V_dirtyFlags) 13 | procFlags (TI,R,V_procFlags) 14 | exceptionCode0 (Tq,R,V_exceptionCode0) 15 | crashedThreadId (TQ,R,V_crashedThreadId) 16 | ledgerPhysFootprint (TQ,R,V_ledgerPhysFootprint) 17 | ledgerPhysFootprintPeak (TQ,R,V_ledgerPhysFootprintPeak) 18 | ledgerInternal (TQ,R,V_ledgerInternal) 19 | ledgerInternalCompressed (TQ,R,V_ledgerInternalCompressed) 20 | ledgerAlternateAccounting (TQ,R,V_ledgerAlternateAccounting) 21 | ledgerAlternateAccountingCompressed (TQ,R,V_ledgerAlternateAccountingCompressed) 22 | ledgerPurgeableNonvolatile (TQ,R,V_ledgerPurgeableNonvolatile) 23 | ledgerPurgeableNonvolatileCompressed (TQ,R,V_ledgerPurgeableNonvolatileCompressed) 24 | ledgerPageTable (TQ,R,V_ledgerPageTable) 25 | ledgerIOKitMapped (TQ,R,V_ledgerIOKitMapped) 26 | ledgerWiredMem (TQ,R,V_ledgerWiredMem) 27 | ledgerNetworkNonvolatile (TQ,R,V_ledgerNetworkNonvolatile) 28 | ledgerNetworkNonvolatileCompressed (TQ,R,V_ledgerNetworkNonvolatileCompressed) 29 | osLogs (T@"NSArray",R,V_osLogs) 30 | cachedMetaDataDict (T@"NSDictionary",R,V_cachedMetaDataDict) 31 | memoryGraph (T@"VMUProcessObjectGraph",R,V_memoryGraph) 32 | executionStack (T@"NSDictionary",R,V_executionStack) 33 | execName (T@"NSString",R,V_execName) 34 | execPath (T@"NSString",R,V_execPath) 35 | bundleID (T@"NSString",R,V_bundleID) 36 | coalitionBundleID (T@"NSString",R,V_coalitionBundleID) 37 | exceptionType (Tq,R,V_exceptionType) 38 | limitValue (TQ,R,V_limitValue) 39 | upTime (Tq,R,V_upTime) 40 | is64Bit (TB,R,V_is64Bit) 41 | hwModel (T@"NSString",R,V_hwModel) 42 | osVersion (T@"NSDictionary",R,V_osVersion) 43 | 44 | Instance methods: 45 | dealloc (v16@0:8) 46 | copyWithZone: (@24@0:8^{_NSZone=}16) 47 | .cxx_destruct (v16@0:8) 48 | version (q16@0:8) 49 | bundleID (@16@0:8) 50 | execPath (@16@0:8) 51 | pid (i16@0:8) 52 | task (I16@0:8) 53 | startTime (@16@0:8) 54 | currentTime (@16@0:8) 55 | osVersion (@16@0:8) 56 | procFlags (I16@0:8) 57 | limitValue (Q16@0:8) 58 | ppid (i16@0:8) 59 | exceptionType (q16@0:8) 60 | isFirstParty (B16@0:8) 61 | is64Bit (B16@0:8) 62 | hwModel (@16@0:8) 63 | extractCorpseInfoHandler: (v32@0:8{kcdata_iter=^{kcdata_item}^v}16) 64 | _symbolOwners (@16@0:8) 65 | createMetaDataDict (@16@0:8) 66 | releaseAnalyzedTask (v16@0:8) 67 | initUsingHostInfoWithTask:andSuspensionToken: (@24@0:8I16I20) 68 | extractCorpseInfo (B16@0:8) 69 | extractTaskInfo (B16@0:8) 70 | generateFootprint (v16@0:8) 71 | extractBacktraceInfo (v16@0:8) 72 | generateMemoryGraph (v16@0:8) 73 | initWithMetaDataDict:andMemoryGraph: (@32@0:8@16@24) 74 | prettyPrintBacktrace (@16@0:8) 75 | prettyPrintBinaryImages (@16@0:8) 76 | saveLogFileWithHandle:error: (B32@0:8@16^@24) 77 | extractSystemLogs:fromDate:toDate: (v40@0:8@16@24@32) 78 | populateVerboseDiagnostics: (v20@0:8B16) 79 | memoryGraph (@16@0:8) 80 | executionStack (@16@0:8) 81 | execName (@16@0:8) 82 | coalitionBundleID (@16@0:8) 83 | upTime (q16@0:8) 84 | suspensionToken (I16@0:8) 85 | footprintOutput (@16@0:8) 86 | cid (Q16@0:8) 87 | dirtyFlags (I16@0:8) 88 | exceptionCode0 (q16@0:8) 89 | crashedThreadId (Q16@0:8) 90 | ledgerPhysFootprint (Q16@0:8) 91 | ledgerPhysFootprintPeak (Q16@0:8) 92 | ledgerInternal (Q16@0:8) 93 | ledgerInternalCompressed (Q16@0:8) 94 | ledgerAlternateAccounting (Q16@0:8) 95 | ledgerAlternateAccountingCompressed (Q16@0:8) 96 | ledgerPurgeableNonvolatile (Q16@0:8) 97 | ledgerPurgeableNonvolatileCompressed (Q16@0:8) 98 | ledgerPageTable (Q16@0:8) 99 | ledgerIOKitMapped (Q16@0:8) 100 | ledgerWiredMem (Q16@0:8) 101 | ledgerNetworkNonvolatile (Q16@0:8) 102 | ledgerNetworkNonvolatileCompressed (Q16@0:8) 103 | osLogs (@16@0:8) 104 | cachedMetaDataDict (@16@0:8) 105 | 106 | Class methods: 107 | alloc (@16@0:8) 108 | resourceExceptionFromTask:error: (@28@0:8I16^@20) 109 | resourceExceptionFromLogFileHandle:error: (@32@0:8@16^@24) 110 | */ 111 | 112 | #include 113 | 114 | @interface MemoryResourceException : NSObject 115 | @property (nonatomic, readonly) int pid; 116 | @property (nonatomic, readonly) mach_port_t task; 117 | @property (nonatomic, readonly) NSString* execName; 118 | @property (nonatomic, readonly) NSString* bundleID; 119 | @property (nonatomic, readonly) NSDate* startTime; 120 | @property (nonatomic, readonly) NSInteger upTime; 121 | -(void)extractBacktraceInfo; 122 | -(NSString*)prettyPrintBinaryImages; 123 | //new 124 | -(void)generateCr4shedReport; 125 | -(NSString*)fetchMemoryInfo; 126 | @end 127 | -------------------------------------------------------------------------------- /cr4shedgui/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleExecutable 6 | Cr4shed 7 | CFBundleIcons 8 | 9 | CFBundlePrimaryIcon 10 | 11 | CFBundleIconFiles 12 | 13 | AppIcon29x29 14 | AppIcon40x40 15 | AppIcon57x57 16 | AppIcon60x60 17 | 18 | UIPrerenderedIcon 19 | 20 | 21 | 22 | CFBundleIcons~ipad 23 | 24 | CFBundlePrimaryIcon 25 | 26 | CFBundleIconFiles 27 | 28 | AppIcon29x29 29 | AppIcon40x40 30 | AppIcon57x57 31 | AppIcon60x60 32 | AppIcon50x50 33 | AppIcon72x72 34 | AppIcon76x76 35 | 36 | UIPrerenderedIcon 37 | 38 | 39 | 40 | CFBundleIdentifier 41 | com.muirey03.cr4shedgui 42 | CFBundleInfoDictionaryVersion 43 | 6.0 44 | CFBundlePackageType 45 | APPL 46 | CFBundleSignature 47 | ???? 48 | CFBundleSupportedPlatforms 49 | 50 | iPhoneOS 51 | 52 | CFBundleVersion 53 | 1.0 54 | LSRequiresIPhoneOS 55 | 56 | UIDeviceFamily 57 | 58 | 1 59 | 2 60 | 61 | UIRequiredDeviceCapabilities 62 | 63 | armv7 64 | 65 | UILaunchImageFile 66 | LaunchImage 67 | UILaunchImages 68 | 69 | 70 | UILaunchImageMinimumOSVersion 71 | 7.0 72 | UILaunchImageName 73 | LaunchImage 74 | UILaunchImageOrientation 75 | Portrait 76 | UILaunchImageSize 77 | {320, 480} 78 | 79 | 80 | UILaunchImageMinimumOSVersion 81 | 7.0 82 | UILaunchImageName 83 | LaunchImage-700-568h 84 | UILaunchImageOrientation 85 | Portrait 86 | UILaunchImageSize 87 | {320, 568} 88 | 89 | 90 | UILaunchImageMinimumOSVersion 91 | 7.0 92 | UILaunchImageName 93 | LaunchImage-Portrait 94 | UILaunchImageOrientation 95 | Portrait 96 | UILaunchImageSize 97 | {768, 1024} 98 | 99 | 100 | UILaunchImageMinimumOSVersion 101 | 7.0 102 | UILaunchImageName 103 | LaunchImage-Landscape 104 | UILaunchImageOrientation 105 | Landscape 106 | UILaunchImageSize 107 | {768, 1024} 108 | 109 | 110 | UILaunchImageMinimumOSVersion 111 | 8.0 112 | UILaunchImageName 113 | LaunchImage-800-667h 114 | UILaunchImageOrientation 115 | Portrait 116 | UILaunchImageSize 117 | {375, 667} 118 | 119 | 120 | UILaunchImageMinimumOSVersion 121 | 8.0 122 | UILaunchImageName 123 | LaunchImage-800-Portrait-736h 124 | UILaunchImageOrientation 125 | Portrait 126 | UILaunchImageSize 127 | {414, 736} 128 | 129 | 130 | UILaunchImageMinimumOSVersion 131 | 8.0 132 | UILaunchImageName 133 | LaunchImage-800-Landscape-736h 134 | UILaunchImageOrientation 135 | Landscape 136 | UILaunchImageSize 137 | {414, 736} 138 | 139 | 140 | UISupportedInterfaceOrientations 141 | 142 | UIInterfaceOrientationPortrait 143 | UIInterfaceOrientationLandscapeLeft 144 | UIInterfaceOrientationLandscapeRight 145 | 146 | UISupportedInterfaceOrientations~ipad 147 | 148 | UIInterfaceOrientationPortrait 149 | UIInterfaceOrientationPortraitUpsideDown 150 | UIInterfaceOrientationLandscapeLeft 151 | UIInterfaceOrientationLandscapeRight 152 | 153 | SBAppUsesLocalNotifications 154 | 155 | 156 | 157 | -------------------------------------------------------------------------------- /cr4shedgui/CRAProcViewController.m: -------------------------------------------------------------------------------- 1 | #import "CRAProcViewController.h" 2 | #import "Process.h" 3 | #import "CRALogInfoViewController.h" 4 | #import "Log.h" 5 | #import "CRAProcessManager.h" 6 | #import 7 | 8 | @implementation CRAProcViewController 9 | -(instancetype)initWithProcess:(Process*)proc 10 | { 11 | if ((self = [self initWithStyle:UITableViewStyleGrouped])) 12 | { 13 | _proc = proc; 14 | [_proc.logs sortUsingComparator:^NSComparisonResult(Log* a, Log* b) { 15 | return [b.date compare:a.date]; 16 | }]; 17 | self.title = _proc.name; 18 | _processManager = [CRAProcessManager sharedInstance]; 19 | } 20 | return self; 21 | } 22 | 23 | -(void)loadView 24 | { 25 | [super loadView]; 26 | 27 | self.navigationItem.rightBarButtonItem = self.editButtonItem; 28 | 29 | //pull to refresh: 30 | _refreshControl = [UIRefreshControl new]; 31 | [_refreshControl addTarget:self action:@selector(refreshTable:) forControlEvents:UIControlEventValueChanged]; 32 | if ([self.tableView respondsToSelector:@selector(setRefreshControl:)]) 33 | self.tableView.refreshControl = _refreshControl; 34 | else 35 | [self.tableView addSubview:_refreshControl]; 36 | } 37 | 38 | -(void)viewDidAppear:(BOOL)arg1 39 | { 40 | [super viewDidAppear:arg1]; 41 | self.navigationController.interactivePopGestureRecognizer.delegate = self; 42 | self.navigationController.interactivePopGestureRecognizer.enabled = YES; 43 | } 44 | 45 | -(void)refreshTable:(id)obj 46 | { 47 | [self refreshLogs]; 48 | if (_refreshControl.refreshing) 49 | [_refreshControl endRefreshing]; 50 | [self.tableView reloadData]; 51 | } 52 | 53 | -(void)refreshLogs 54 | { 55 | [[NSNotificationCenter defaultCenter] postNotificationName:CR4ProcsNeedRefreshNotificationName object:nil]; 56 | NSArray* procs = _processManager.processes; 57 | BOOL found = NO; 58 | for (Process* p in procs) 59 | { 60 | if ([p.name isEqualToString:_proc.name]) 61 | { 62 | _proc = p; 63 | found = YES; 64 | break; 65 | } 66 | } 67 | if (!found) 68 | [self.navigationController popViewControllerAnimated:YES]; 69 | } 70 | 71 | #pragma mark - Gesture Recognizer Delegate 72 | 73 | -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer 74 | { 75 | return YES; 76 | } 77 | 78 | #pragma mark - Table View Data Source 79 | 80 | -(NSInteger)numberOfSectionsInTableView:(UITableView*)tableView 81 | { 82 | return 1; 83 | } 84 | 85 | -(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section 86 | { 87 | return _proc.logs.count; 88 | } 89 | 90 | -(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath 91 | { 92 | UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"LogCell"]; 93 | if (!cell) 94 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"LogCell"]; 95 | 96 | Log* log = _proc.logs[indexPath.row]; 97 | NSString* logName = stringFromDate(log.date, CR4DateFormatPretty); 98 | cell.textLabel.text = logName; 99 | cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 100 | return cell; 101 | } 102 | 103 | -(void)tableView:(UITableView*)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath*)indexPath 104 | { 105 | if (indexPath.row == 0) 106 | { 107 | if (_proc.logs.count > 1) 108 | { 109 | //get new latestDate 110 | Log* newLog = _proc.logs[1]; 111 | _proc.latestDate = newLog.date; 112 | } 113 | else 114 | { 115 | _proc.latestDate = nil; 116 | } 117 | } 118 | NSString* path = _proc.logs[indexPath.row].path; 119 | [[NSFileManager defaultManager] removeItemAtPath:path error:nil]; 120 | [_proc.logs removeObjectAtIndex:indexPath.row]; 121 | [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; 122 | 123 | [[NSNotificationCenter defaultCenter] postNotificationName:CR4ProcsNeedRefreshNotificationName object:nil]; 124 | } 125 | 126 | #pragma mark - Table View Delegate 127 | 128 | -(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath 129 | { 130 | CRALogInfoViewController* logVC = [[CRALogInfoViewController alloc] initWithLog:_proc.logs[indexPath.row]]; 131 | [self.navigationController pushViewController:logVC animated:YES]; 132 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 133 | } 134 | 135 | -(void)setEditing:(BOOL)editing animated:(BOOL)animated 136 | { 137 | [super setEditing:editing animated:animated]; 138 | 139 | UIBarButtonItem* item = nil; 140 | if (editing) 141 | { 142 | item = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:self action:@selector(removeAllLogs)]; 143 | } 144 | [self.navigationItem setLeftBarButtonItem:item animated:animated]; 145 | } 146 | 147 | -(void)removeAllLogs 148 | { 149 | NSMutableArray* indexPaths = [[NSMutableArray alloc] initWithCapacity:_proc.logs.count]; 150 | for (NSUInteger i = 0; i < _proc.logs.count; i++) 151 | { 152 | NSIndexPath* indexPath = [NSIndexPath indexPathForRow:i inSection:0]; 153 | [indexPaths addObject:indexPath]; 154 | } 155 | [_proc deleteAllLogs]; 156 | [self.tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationAutomatic]; 157 | 158 | [[NSNotificationCenter defaultCenter] postNotificationName:CR4ProcsNeedRefreshNotificationName object:nil]; 159 | [self.navigationController popViewControllerAnimated:YES]; 160 | } 161 | 162 | @end 163 | -------------------------------------------------------------------------------- /frpreferences/FRPSliderCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // FRSliderCellTableViewCell.m 3 | // FRPreferences 4 | // 5 | // Created by Fouad Raheb on 6/14/15. 6 | // Copyright (c) 2015 F0u4d. All rights reserved. 7 | // 8 | 9 | #import "FRPSliderCell.h" 10 | 11 | @implementation FRPSliderCell 12 | 13 | + (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting min:(float)min max:(float)max postNotification:(NSString *)notification changeBlock:(FRPSliderCellChanged)block { 14 | return [[self alloc] cellWithTitle:title setting:setting min:min max:max postNotification:notification changeBlock:block]; 15 | } 16 | 17 | 18 | - (instancetype)cellWithTitle:(NSString *)title setting:(FRPSettings *)setting min:(float)min max:(float)max postNotification:(NSString *)notification changeBlock:(FRPSliderCellChanged)block { 19 | FRPSliderCell *cell = [super initWithTitle:nil setting:setting]; 20 | cell.postNotification = notification; 21 | cell.valueChanged = block; 22 | 23 | UISlider *sliderCell = [[UISlider alloc] initWithFrame:CGRectZero]; 24 | sliderCell.minimumValue = min; 25 | sliderCell.maximumValue = max; 26 | sliderCell.value = [setting.value floatValue]; 27 | [sliderCell addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged]; 28 | [cell.contentView addSubview:sliderCell]; 29 | cell.sliderCell = sliderCell; 30 | 31 | UILabel *lLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 32 | lLabel.text = [NSString stringWithFormat:@"%.2f",min]; 33 | lLabel.numberOfLines = 1; 34 | lLabel.baselineAdjustment = UIBaselineAdjustmentAlignBaselines; 35 | lLabel.adjustsFontSizeToFitWidth = YES; 36 | lLabel.clipsToBounds = YES; 37 | lLabel.backgroundColor = [UIColor clearColor]; 38 | lLabel.textColor = [UIColor blackColor]; 39 | lLabel.textAlignment = NSTextAlignmentCenter; 40 | [cell.contentView addSubview:lLabel]; 41 | cell.lLabel = lLabel; 42 | 43 | UILabel *rLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 44 | rLabel.text = [NSString stringWithFormat:@"%.2f",max]; 45 | rLabel.numberOfLines = 1; 46 | rLabel.baselineAdjustment = UIBaselineAdjustmentAlignBaselines; 47 | rLabel.adjustsFontSizeToFitWidth = YES; 48 | rLabel.clipsToBounds = YES; 49 | rLabel.backgroundColor = [UIColor clearColor]; 50 | rLabel.textColor = [UIColor blackColor]; 51 | rLabel.textAlignment = NSTextAlignmentCenter; 52 | [cell.contentView addSubview:rLabel]; 53 | cell.rLabel = rLabel; 54 | 55 | UILabel *cLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 56 | cLabel.text = title; 57 | cLabel.numberOfLines = 1; 58 | cLabel.baselineAdjustment = UIBaselineAdjustmentAlignBaselines; 59 | cLabel.adjustsFontSizeToFitWidth = YES; 60 | cLabel.clipsToBounds = YES; 61 | cLabel.backgroundColor = [UIColor clearColor]; 62 | cLabel.textColor = [UIColor blackColor]; 63 | cLabel.textAlignment = NSTextAlignmentLeft; 64 | [cell.contentView addSubview:cLabel]; 65 | cell.cLabel = cLabel; 66 | 67 | UILabel *vLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 68 | vLabel.text = [NSString stringWithFormat:@"%.2f",[setting.value floatValue]]; 69 | vLabel.numberOfLines = 1; 70 | vLabel.baselineAdjustment = UIBaselineAdjustmentAlignBaselines; 71 | vLabel.adjustsFontSizeToFitWidth = YES; 72 | vLabel.clipsToBounds = YES; 73 | vLabel.backgroundColor = [UIColor clearColor]; 74 | vLabel.textColor = [UIColor grayColor]; 75 | vLabel.textAlignment = NSTextAlignmentRight; 76 | [cell.contentView addSubview:vLabel]; 77 | cell.vLabel = vLabel; 78 | 79 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 80 | cell.height = 75; 81 | return cell; 82 | } 83 | 84 | - (void)layoutSubviews { 85 | [super layoutSubviews]; 86 | 87 | float sliderW = self.contentView.frame.size.width/1.8; 88 | float sliderH = 25; 89 | float sliderX = self.contentView.frame.size.width/2-sliderW/2; 90 | float sliderY = self.contentView.frame.size.height-sliderH-10; 91 | self.sliderCell.frame = CGRectMake(sliderX, sliderY, sliderW, sliderH); 92 | 93 | float lLabelW = (self.contentView.frame.size.width-(self.contentView.frame.size.width/1.8))/2-10; 94 | float lLabelH = 25; 95 | float lLabelX = sliderX-lLabelW-5; 96 | float lLabelY = self.contentView.frame.size.height-lLabelH-10; 97 | self.lLabel.frame = CGRectMake(lLabelX, lLabelY, lLabelW, lLabelH); 98 | 99 | float rLabelW = (self.contentView.frame.size.width-(self.contentView.frame.size.width/1.8))/2-10; 100 | float rLabelH = 25; 101 | float rLabelX = sliderX+sliderW+5; 102 | float rLabelY = self.contentView.frame.size.height-rLabelH-10; 103 | self.rLabel.frame = CGRectMake(rLabelX, rLabelY, rLabelW, rLabelH); 104 | 105 | float cLabelW = self.contentView.frame.size.width/1.8; 106 | float cLabelH = 25; 107 | float cLabelX = 17; 108 | float cLabelY = 8; 109 | self.cLabel.frame = CGRectMake(cLabelX, cLabelY, cLabelW, cLabelH); 110 | 111 | float vLabelW = self.contentView.frame.size.width-(self.contentView.frame.size.width/1.8); 112 | float vLabelH = 25; 113 | float vLabelX = self.contentView.frame.size.width-vLabelW-25; 114 | float vLabelY = 8; 115 | self.vLabel.frame = CGRectMake(vLabelX, vLabelY, vLabelW, vLabelH); 116 | } 117 | 118 | - (void)sliderChanged:(UISlider *)slider { 119 | self.vLabel.text = [NSString stringWithFormat:@"%.2f",[slider value]]; 120 | self.setting.value = [NSNumber numberWithFloat:[slider value]]; 121 | if (self.valueChanged) { 122 | self.valueChanged(slider); 123 | } 124 | [[NSNotificationCenter defaultCenter] postNotificationName:self.postNotification object:slider]; 125 | } 126 | 127 | @end 128 | -------------------------------------------------------------------------------- /cr4shedgui/NSString+HTML.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Koolistov.m 3 | // Koolistov 4 | // 5 | // Created by Johan Kool on 13-11-09. 6 | // Copyright 2009-2011 Koolistov Pte. Ltd. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without modification, are 9 | // permitted provided that the following conditions are met: 10 | // 11 | // * Redistributions of source code must retain the above copyright notice, this list of 12 | // conditions and the following disclaimer. 13 | // * Neither the name of KOOLISTOV PTE. LTD. nor the names of its contributors may be used to 14 | // endorse or promote products derived from this software without specific prior written 15 | // permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 18 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 20 | // THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 22 | // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | // 27 | 28 | 29 | #import "NSString+HTML.h" 30 | 31 | @implementation NSString (HTML) 32 | 33 | // Method based on code obtained from: 34 | // http://www.thinkmac.co.uk/blog/2005/05/removing-entities-from-html-in-cocoa.html 35 | // 36 | 37 | - (NSString *)kv_decodeHTMLCharacterEntities { 38 | if ([self rangeOfString:@"&"].location == NSNotFound) { 39 | return self; 40 | } else { 41 | NSMutableString *escaped = [NSMutableString stringWithString:self]; 42 | NSArray *codes = [NSArray arrayWithObjects: 43 | @" ", @"¡", @"¢", @"£", @"¤", @"¥", @"¦", 44 | @"§", @"¨", @"©", @"ª", @"«", @"¬", @"­", @"®", 45 | @"¯", @"°", @"±", @"²", @"³", @"´", @"µ", 46 | @"¶", @"·", @"¸", @"¹", @"º", @"»", @"¼", 47 | @"½", @"¾", @"¿", @"À", @"Á", @"Â", 48 | @"Ã", @"Ä", @"Å", @"Æ", @"Ç", @"È", 49 | @"É", @"Ê", @"Ë", @"Ì", @"Í", @"Î", @"Ï", 50 | @"Ð", @"Ñ", @"Ò", @"Ó", @"Ô", @"Õ", @"Ö", 51 | @"×", @"Ø", @"Ù", @"Ú", @"Û", @"Ü", @"Ý", 52 | @"Þ", @"ß", @"à", @"á", @"â", @"ã", @"ä", 53 | @"å", @"æ", @"ç", @"è", @"é", @"ê", @"ë", 54 | @"ì", @"í", @"î", @"ï", @"ð", @"ñ", @"ò", 55 | @"ó", @"ô", @"õ", @"ö", @"÷", @"ø", @"ù", 56 | @"ú", @"û", @"ü", @"ý", @"þ", @"ÿ", nil]; 57 | 58 | NSUInteger i, count = [codes count]; 59 | 60 | // Html 61 | for (i = 0; i < count; i++) { 62 | NSRange range = [self rangeOfString:[codes objectAtIndex:i]]; 63 | if (range.location != NSNotFound) { 64 | [escaped replaceOccurrencesOfString:[codes objectAtIndex:i] 65 | withString:[NSString stringWithFormat:@"%C", (unsigned short) (160 + i)] 66 | options:NSLiteralSearch 67 | range:NSMakeRange(0, [escaped length])]; 68 | } 69 | } 70 | 71 | // The following five are not in the 160+ range 72 | 73 | // @"&" 74 | NSRange range = [self rangeOfString:@"&"]; 75 | if (range.location != NSNotFound) { 76 | [escaped replaceOccurrencesOfString:@"&" 77 | withString:[NSString stringWithFormat:@"%C", (unsigned short) 38] 78 | options:NSLiteralSearch 79 | range:NSMakeRange(0, [escaped length])]; 80 | } 81 | 82 | // @"<" 83 | range = [self rangeOfString:@"<"]; 84 | if (range.location != NSNotFound) { 85 | [escaped replaceOccurrencesOfString:@"<" 86 | withString:[NSString stringWithFormat:@"%C", (unsigned short) 60] 87 | options:NSLiteralSearch 88 | range:NSMakeRange(0, [escaped length])]; 89 | } 90 | 91 | // @">" 92 | range = [self rangeOfString:@">"]; 93 | if (range.location != NSNotFound) { 94 | [escaped replaceOccurrencesOfString:@">" 95 | withString:[NSString stringWithFormat:@"%C", (unsigned short) 62] 96 | options:NSLiteralSearch 97 | range:NSMakeRange(0, [escaped length])]; 98 | } 99 | 100 | // @"'" 101 | range = [self rangeOfString:@"'"]; 102 | if (range.location != NSNotFound) { 103 | [escaped replaceOccurrencesOfString:@"'" 104 | withString:[NSString stringWithFormat:@"%C", (unsigned short) 39] 105 | options:NSLiteralSearch 106 | range:NSMakeRange(0, [escaped length])]; 107 | } 108 | 109 | // @""" 110 | range = [self rangeOfString:@"""]; 111 | if (range.location != NSNotFound) { 112 | [escaped replaceOccurrencesOfString:@""" 113 | withString:[NSString stringWithFormat:@"%C", (unsigned short) 34] 114 | options:NSLiteralSearch 115 | range:NSMakeRange(0, [escaped length])]; 116 | } 117 | 118 | // Decimal & Hex 119 | NSRange start, finish, searchRange = NSMakeRange(0, [escaped length]); 120 | i = 0; 121 | 122 | while (i < [escaped length]) { 123 | start = [escaped rangeOfString:@"&#" 124 | options:NSCaseInsensitiveSearch 125 | range:searchRange]; 126 | 127 | finish = [escaped rangeOfString:@";" 128 | options:NSCaseInsensitiveSearch 129 | range:searchRange]; 130 | 131 | if (start.location != NSNotFound && finish.location != NSNotFound && 132 | finish.location > start.location) { 133 | NSRange entityRange = NSMakeRange(start.location, (finish.location - start.location) + 1); 134 | NSString *entity = [escaped substringWithRange:entityRange]; 135 | NSString *value = [entity substringWithRange:NSMakeRange(2, [entity length] - 2)]; 136 | 137 | [escaped deleteCharactersInRange:entityRange]; 138 | 139 | if ([value hasPrefix:@"x"]) { 140 | unsigned tempInt = 0; 141 | NSScanner *scanner = [NSScanner scannerWithString:[value substringFromIndex:1]]; 142 | [scanner scanHexInt:&tempInt]; 143 | [escaped insertString:[NSString stringWithFormat:@"%C", (unsigned short) tempInt] atIndex:entityRange.location]; 144 | } else { 145 | [escaped insertString:[NSString stringWithFormat:@"%C", (unsigned short) [value intValue]] atIndex:entityRange.location]; 146 | } i = start.location; 147 | } else { i++; } 148 | searchRange = NSMakeRange(i, [escaped length] - i); 149 | } 150 | 151 | return escaped; // Note this is autoreleased 152 | } 153 | } 154 | 155 | - (NSString *)kv_encodeHTMLCharacterEntities { 156 | NSMutableString *encoded = [NSMutableString stringWithString:self]; 157 | 158 | // @"&" 159 | NSRange range = [self rangeOfString:@"&"]; 160 | if (range.location != NSNotFound) { 161 | [encoded replaceOccurrencesOfString:@"&" 162 | withString:@"&" 163 | options:NSLiteralSearch 164 | range:NSMakeRange(0, [encoded length])]; 165 | } 166 | 167 | // @"<" 168 | range = [self rangeOfString:@"<"]; 169 | if (range.location != NSNotFound) { 170 | [encoded replaceOccurrencesOfString:@"<" 171 | withString:@"<" 172 | options:NSLiteralSearch 173 | range:NSMakeRange(0, [encoded length])]; 174 | } 175 | 176 | // @">" 177 | range = [self rangeOfString:@">"]; 178 | if (range.location != NSNotFound) { 179 | [encoded replaceOccurrencesOfString:@">" 180 | withString:@">" 181 | options:NSLiteralSearch 182 | range:NSMakeRange(0, [encoded length])]; 183 | } 184 | 185 | return encoded; 186 | } 187 | 188 | @end 189 | -------------------------------------------------------------------------------- /Tweak.xm: -------------------------------------------------------------------------------- 1 | @import Foundation; 2 | 3 | #import 4 | #import 5 | #import "symbolication.h" 6 | #import 7 | #import 8 | #import 9 | 10 | @interface Cr4shedServer : NSObject 11 | + (id)sharedInstance; 12 | -(NSDictionary*)sendNotification:(NSDictionary*)userInfo; 13 | -(NSDictionary*)writeString:(NSDictionary*)userInfo; 14 | @end 15 | 16 | static NSString* writeStringToFile(NSString* str, NSString* filename) 17 | { 18 | NSDictionary* reply; 19 | if (%c(Cr4shedServer)) 20 | { 21 | reply = [[%c(Cr4shedServer) sharedInstance] writeString:@{@"string" : str, @"filename" : filename}]; 22 | } 23 | else 24 | { 25 | MRYIPCCenter* ipcCenter = [MRYIPCCenter centerNamed:@"com.muirey03.cr4sheddserver"]; 26 | reply = [ipcCenter callExternalMethod:@selector(writeString:) withArguments:@{@"string" : str, @"filename" : filename}]; 27 | } 28 | return reply[@"path"]; 29 | } 30 | 31 | static NSString* getCallStack(NSException* e) 32 | { 33 | NSArray* symbols = symbolicatedException(e); 34 | NSString* symbolStr = [symbols componentsJoinedByString:@"\n"]; 35 | return symbolStr; 36 | } 37 | 38 | static void sendNotification(NSString* content, NSDictionary* userInfo) 39 | { 40 | if (%c(Cr4shedServer)) 41 | { 42 | [[%c(Cr4shedServer) sharedInstance] sendNotification:@{@"content" : content}]; 43 | } 44 | else 45 | { 46 | MRYIPCCenter* ipcCenter = [MRYIPCCenter centerNamed:@"com.muirey03.cr4sheddserver"]; 47 | [ipcCenter callExternalMethod:@selector(sendNotification:) withArguments:@{@"content" : content, @"userInfo" : userInfo}]; 48 | } 49 | } 50 | 51 | static unsigned long getImageVersion(uint32_t img) 52 | { 53 | if (img < _dyld_image_count()) 54 | { 55 | const struct mach_header* header = _dyld_get_image_header(img); 56 | if (header) 57 | { 58 | BOOL is64bit = header->magic == MH_MAGIC_64 || header->magic == MH_CIGAM_64; 59 | uintptr_t cursor = (uintptr_t)header + (is64bit ? sizeof(struct mach_header_64) : sizeof(struct mach_header)); 60 | const struct segment_command* segmentCommand = NULL; 61 | for (uint32_t i = 0; i < header->ncmds; i++, cursor += segmentCommand->cmdsize) 62 | { 63 | segmentCommand = (struct segment_command *)cursor; 64 | if (segmentCommand->cmd == LC_ID_DYLIB) 65 | { 66 | const struct dylib_command* dylibCommand = (const struct dylib_command*)segmentCommand; 67 | return dylibCommand->dylib.current_version; 68 | } 69 | } 70 | } 71 | } 72 | return 0; 73 | } 74 | 75 | static void createCrashLog(NSString* specialisedInfo, NSMutableDictionary* extraInfo) 76 | { 77 | if (isBlacklisted()) return; 78 | 79 | markProcessAsHandled(); 80 | 81 | // Format the contents of the new crash log: 82 | NSDate* now = [NSDate date]; 83 | NSString* dateString = stringFromDate(now, CR4DateFormatPretty); 84 | 85 | NSString* processID = [NSBundle mainBundle].bundleIdentifier; 86 | NSString* processName = [[NSProcessInfo processInfo] processName]; 87 | NSString* device = [NSString stringWithFormat:@"%@, iOS %@", deviceName(), deviceVersion()]; 88 | NSBundle* bundle = [NSBundle mainBundle]; 89 | NSString* versionString = bundle.infoDictionary[@"CFBundleShortVersionString"]; 90 | if (!versionString) 91 | versionString = bundle.infoDictionary[@"CFBundleVersion"]; 92 | 93 | NSMutableString* errorMessage = [NSMutableString stringWithFormat: @"Date: %@\n" 94 | @"Process: %@\n" 95 | @"Bundle id: %@\n" 96 | @"Device: %@\n", 97 | dateString, 98 | processName, 99 | processID, 100 | device]; 101 | 102 | if (versionString.length) 103 | [errorMessage appendFormat:@"Bundle version: %@\n", versionString]; 104 | [errorMessage appendFormat: @"\n%@\n\n" 105 | @"Loaded images:\n", 106 | specialisedInfo]; 107 | 108 | //add image infos: 109 | uint32_t image_cnt = _dyld_image_count(); 110 | for (unsigned int i = 0; i < image_cnt; i++) 111 | { 112 | [errorMessage appendFormat:@"%u: %s (Version: %lu)\n", i, _dyld_get_image_name(i), getImageVersion(i)]; 113 | } 114 | 115 | //extra info for the GUI to parse easily: 116 | if (!extraInfo) extraInfo = [NSMutableDictionary new]; 117 | [extraInfo addEntriesFromDictionary:@{ 118 | @"ProcessName" : processName ?: @"", 119 | @"ProcessBundleID" : processID ?: @"" 120 | }]; 121 | errorMessage = [addInfoToLog(errorMessage, [extraInfo copy]) mutableCopy]; 122 | 123 | // Get the date to use for the filename: 124 | NSString* filenameDateStr = stringFromDate(now, CR4DateFormatFilename); 125 | 126 | // Get the filename for the new crash log: 127 | NSString* filename = [NSString stringWithFormat:@"%@@%@", processName, filenameDateStr]; 128 | 129 | // Create the crash log 130 | NSString* path = writeStringToFile(errorMessage, filename); 131 | if (!path) 132 | return; 133 | 134 | //show notification: 135 | NSDictionary* notifUserInfo = @{@"logPath" : path}; 136 | sendNotification([NSString stringWithFormat:@"%@ crashed at %@", processName, dateString], notifUserInfo); 137 | } 138 | 139 | /* add the exception handler: */ 140 | static NSUncaughtExceptionHandler* oldHandler = NULL; 141 | 142 | void createNSExceptionLog(NSException* e) 143 | { 144 | /* Remove false positives: */ 145 | if ([e.reason containsString:@"optimistic locking failure"]) 146 | return; 147 | if ([e.reason containsString:@"This NSPersistentStoreCoordinator has no persistent stores"]) 148 | return; 149 | 150 | NSString* culprit = determineCulprit(e.callStackSymbols); 151 | NSString* stackSymbols = getCallStack(e); 152 | NSMutableString* info = [NSMutableString stringWithFormat: @"Exception type: %@\n" 153 | @"Reason: %@\n" 154 | @"Culprit: %@\n\n", 155 | e.name, 156 | e.reason, 157 | culprit]; 158 | 159 | //user info (for Supercharge): 160 | NSDictionary* excUserInfo = e.userInfo; 161 | if (excUserInfo.allKeys.count) 162 | { 163 | NSMutableString* userInfoStr = [@"User info:\n" mutableCopy]; 164 | for (NSString* key in excUserInfo.allKeys) 165 | { 166 | NSString* objStr = [excUserInfo[key] description]; 167 | //if it is multi-line, insert a '\n' at the start 168 | if ([objStr componentsSeparatedByString:@"\n"].count > 1) 169 | objStr = [@"\n" stringByAppendingString:objStr]; 170 | if (!objStr.length) objStr = @"N/A"; 171 | [userInfoStr appendFormat:@"%@: %@\n", key, objStr]; 172 | } 173 | [userInfoStr appendString:@"\n"]; 174 | [info appendString:userInfoStr]; 175 | } 176 | 177 | [info appendFormat:@"Call stack:\n%@", stackSymbols]; 178 | 179 | NSMutableDictionary* extraInfo = [@{ 180 | @"Culprit" : culprit ?: @"Unknown", 181 | @"NSExceptionReason" : e.reason ?: @"" 182 | } mutableCopy]; 183 | createCrashLog([info copy], extraInfo); 184 | } 185 | 186 | void unhandledExceptionHandler(NSException* e) 187 | { 188 | @autoreleasepool 189 | { 190 | static BOOL hasCrashed = NO; 191 | if (hasCrashed) 192 | exit(EXIT_FAILURE); 193 | else 194 | hasCrashed = YES; 195 | @try 196 | { 197 | createNSExceptionLog(e); 198 | } 199 | @catch (NSException* e) 200 | { 201 | exit(EXIT_FAILURE); 202 | } 203 | if (oldHandler) 204 | oldHandler(e); 205 | } 206 | } 207 | 208 | %group Tweak 209 | %hookf (void, NSSetUncaughtExceptionHandler, NSUncaughtExceptionHandler* handler) 210 | { 211 | @autoreleasepool 212 | { 213 | if (handler != &unhandledExceptionHandler) 214 | { 215 | oldHandler = handler; 216 | return; 217 | } 218 | %orig; 219 | } 220 | } 221 | 222 | %hookf (NSUncaughtExceptionHandler*, NSGetUncaughtExceptionHandler) 223 | { 224 | @autoreleasepool 225 | { 226 | return oldHandler; 227 | } 228 | } 229 | %end 230 | 231 | inline BOOL isHardBlacklisted(NSString* procName) 232 | { 233 | if (!procName) 234 | return YES; 235 | 236 | NSArray* blacklisted = @[ 237 | @"ProtectedCloudKeySyncing", 238 | @"gssc", 239 | @"awdd", 240 | @"biometrickitd", 241 | @"spindump", 242 | @"keybagd", 243 | @"ReportMemoryException", 244 | @"nsurlsessiond", 245 | @"locationd", 246 | @"coreduetd", 247 | @"mDNSResponder", 248 | @"hangreporter", 249 | @"nanoregistrylaunchd", 250 | @"nanoregistryd", 251 | @"mobilewatchdog", 252 | @"misd", 253 | @"dasd", 254 | @"passd", 255 | @"CircleJoinRequested", 256 | @"suggestd" 257 | ]; 258 | for (NSString* bannedProc in blacklisted) 259 | { 260 | if (bannedProc && [procName isEqualToString:bannedProc]) 261 | return YES; 262 | } 263 | return NO; 264 | } 265 | 266 | %ctor 267 | { 268 | @autoreleasepool 269 | { 270 | if (!isHardBlacklisted([[NSProcessInfo processInfo] processName])) 271 | { 272 | oldHandler = NSGetUncaughtExceptionHandler(); 273 | NSSetUncaughtExceptionHandler(&unhandledExceptionHandler); 274 | %init(Tweak); 275 | } 276 | } 277 | } 278 | -------------------------------------------------------------------------------- /Shared/sharedutils.mm: -------------------------------------------------------------------------------- 1 | @import Foundation; 2 | 3 | #import 4 | #import 5 | #include 6 | #include 7 | #include 8 | #import 9 | #import 10 | #import 11 | #import 12 | #include 13 | 14 | extern "C" { 15 | 16 | NSString* getImage(NSString* symbol) 17 | { 18 | int startingI = -1; 19 | int endingI = -1; 20 | for (int i = 0; i < symbol.length - 1; i++) 21 | { 22 | char c = [symbol characterAtIndex:i]; 23 | char nextC = [symbol characterAtIndex:i+1]; 24 | if (startingI == -1) 25 | { 26 | if (c == ' ' && nextC != ' ') 27 | { 28 | startingI = i+1; 29 | } 30 | } 31 | else 32 | { 33 | if (nextC == ' ') 34 | { 35 | endingI = i+1; 36 | break; 37 | } 38 | } 39 | } 40 | return [symbol substringWithRange:NSMakeRange(startingI, endingI-startingI)]; 41 | } 42 | 43 | NSString* determineCulprit(NSArray* symbols) 44 | { 45 | for (int i = 0; i < symbols.count; i++) 46 | { 47 | NSString* symbol = symbols[i]; 48 | NSString* image = getImage(symbol); 49 | if (![image isEqualToString:@"Cr4shed.dylib"]) 50 | { 51 | if ([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/Library/MobileSubstrate/DynamicLibraries/%@", image]]) //TODO: fix for rootless jailbreaks 52 | return image; 53 | } 54 | } 55 | return @"Unknown"; 56 | } 57 | 58 | NSString* stringFromDate(NSDate* date, CR4DateFormat type) 59 | { 60 | BOOL needsLowercase = NO; 61 | NSDateFormatter* formatter = [NSDateFormatter new]; 62 | switch (type) 63 | { 64 | case CR4DateFormatPretty: 65 | [formatter setDateStyle:NSDateFormatterShortStyle]; 66 | [formatter setTimeStyle:NSDateFormatterShortStyle]; 67 | break; 68 | case CR4DateFormatTimeOnly: 69 | [formatter setDateStyle:NSDateFormatterNoStyle]; 70 | [formatter setTimeStyle:NSDateFormatterShortStyle]; 71 | break; 72 | default: 73 | case CR4DateFormatFilename: 74 | needsLowercase = YES; 75 | [formatter setDateFormat:@"yyyy-MM-dd_h:mm_a"]; 76 | break; 77 | } 78 | NSString* ret = [formatter stringFromDate:date]; 79 | return needsLowercase ? [ret lowercaseString] : ret; 80 | } 81 | 82 | NSString* deviceVersion() 83 | { 84 | return (__bridge NSString*)MGCopyAnswer(CFSTR("ProductVersion"), NULL) ?: @"Unknown"; 85 | } 86 | 87 | NSString* deviceName() 88 | { 89 | return (__bridge NSString*)MGCopyAnswer(CFSTR("marketing-name"), NULL) ?: @"Unknown"; 90 | } 91 | 92 | #define MAX_CHUNK_SIZE 0xFFF 93 | #ifdef __cplusplus 94 | extern "C" { 95 | #endif 96 | kern_return_t mach_vm_read_overwrite(vm_map_t target_task, mach_vm_address_t address, mach_vm_size_t size, mach_vm_address_t data, mach_vm_size_t *outsize); 97 | kern_return_t mach_vm_write(vm_map_t target_task, mach_vm_address_t address, vm_offset_t data, mach_msg_type_number_t dataCnt); 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | size_t rread(mach_port_t task, mach_vm_address_t where, void* p, size_t size) 103 | { 104 | kern_return_t rv; 105 | size_t offset = 0; 106 | while (offset < size) 107 | { 108 | mach_vm_size_t sz, chunk = MAX_CHUNK_SIZE; 109 | if (chunk > size - offset) 110 | chunk = size - offset; 111 | rv = mach_vm_read_overwrite(task, where + offset, chunk, (mach_vm_address_t)p + offset, &sz); 112 | if (rv || sz == 0) 113 | break; 114 | offset += sz; 115 | } 116 | return offset; 117 | } 118 | 119 | size_t rwrite(mach_port_t task, mach_vm_address_t where, const void* p, size_t size) 120 | { 121 | kern_return_t rv; 122 | size_t offset = 0; 123 | while (offset < size) 124 | { 125 | size_t chunk = MAX_CHUNK_SIZE; 126 | if (chunk > size - offset) 127 | chunk = size - offset; 128 | rv = mach_vm_write(task, where + offset, (mach_vm_offset_t)p + offset, chunk); 129 | if (rv) 130 | break; 131 | offset += chunk; 132 | } 133 | return offset; 134 | } 135 | 136 | char* rread_string(mach_port_t task, vm_address_t addr) 137 | { 138 | const size_t batchSz = 8; 139 | char* str = NULL; 140 | size_t sz = 0; 141 | for (;;) 142 | { 143 | str = (char*)realloc((void*)str, sz + batchSz); 144 | char* cursor = &str[sz]; 145 | rread(task, addr + sz, (void*)cursor, batchSz); 146 | if (strnlen(cursor, batchSz) != batchSz) 147 | break; 148 | sz += batchSz; 149 | } 150 | return str; 151 | } 152 | 153 | uint64_t rread64(mach_port_t task, mach_vm_address_t where) 154 | { 155 | uint64_t val; 156 | rread(task, where, (void*)&val, sizeof(val)); 157 | return val; 158 | } 159 | 160 | uint32_t rread32(mach_port_t task, mach_vm_address_t where) 161 | { 162 | uint32_t val; 163 | rread(task, where, (void*)&val, sizeof(val)); 164 | return val; 165 | } 166 | 167 | mach_vm_address_t taskGetImageInfos(mach_port_t task) 168 | { 169 | struct task_dyld_info dyld_info = {0}; 170 | mach_msg_type_number_t count = TASK_DYLD_INFO_COUNT; 171 | kern_return_t kr = task_info(task, TASK_DYLD_INFO, (task_info_t)&dyld_info, &count); 172 | if (kr == KERN_SUCCESS && dyld_info.all_image_info_addr && dyld_info.all_image_info_size) 173 | return dyld_info.all_image_info_addr; 174 | return 0; 175 | } 176 | 177 | //used to let Cr4shedMach know that this process' crash 178 | //has been dealt with 179 | const char* const flag = "com.muirey03.cr4shed-exceptionHandled"; 180 | 181 | void markProcessAsHandled() 182 | { 183 | struct dyld_all_image_infos* image_infos = (struct dyld_all_image_infos*)taskGetImageInfos(mach_task_self()); 184 | if (image_infos) 185 | image_infos->errorMessage = flag; 186 | } 187 | 188 | bool processHasBeenHandled(mach_port_t task) 189 | { 190 | bool handled = false; 191 | mach_vm_address_t image_infos = taskGetImageInfos(task); 192 | if (image_infos) 193 | { 194 | uint64_t errorMsgAddr = 0; 195 | rread(task, image_infos + offsetof(struct dyld_all_image_infos, errorMessage), (void*)&errorMsgAddr, sizeof(uint64_t)); 196 | if (errorMsgAddr) 197 | { 198 | void* mem = malloc(strlen(flag) + 1); 199 | if (mem) 200 | { 201 | rread(task, errorMsgAddr, mem, strlen(flag) + 1); 202 | handled = (memcmp(mem, flag, strlen(flag)) == 0); 203 | free(mem); 204 | } 205 | } 206 | } 207 | return handled; 208 | } 209 | 210 | HBPreferences* sharedPreferences() 211 | { 212 | static HBPreferences* prefs = nil; 213 | if (!prefs) 214 | { 215 | NSString* const frameworkPath = @"/usr/lib/Cephei.framework"; //TODO: fix for rootless jailbreaks 216 | lazyLoadBundle(frameworkPath); 217 | prefs = [[objc_getClass("HBPreferences") alloc] initWithIdentifier:@"com.muirey03.cr4shedprefs"]; 218 | } 219 | return prefs; 220 | } 221 | 222 | NSString* addInfoToLog(NSString* logContents, NSDictionary* info) 223 | { 224 | if ([NSJSONSerialization isValidJSONObject:info]) 225 | { 226 | NSData* jsonData = [NSJSONSerialization dataWithJSONObject:info options:0 error:NULL]; 227 | if (jsonData) 228 | { 229 | NSString* infoString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; 230 | return [logContents stringByAppendingFormat:@"\n\n%@", infoString]; 231 | } 232 | } 233 | return logContents; 234 | } 235 | 236 | NSDictionary* getInfoFromLog(NSString* logContents) 237 | { 238 | if (logContents.length) 239 | { 240 | NSRange lastLineRange = [logContents lineRangeForRange:NSMakeRange(logContents.length - 1, 1)]; 241 | NSString* jsonString = [logContents substringWithRange:lastLineRange]; 242 | NSDictionary* info = [NSJSONSerialization JSONObjectWithData:[jsonString dataUsingEncoding:NSUTF8StringEncoding] options:0 error:NULL]; 243 | if ([info isKindOfClass:[NSDictionary class]]) 244 | return info; 245 | } 246 | return nil; 247 | } 248 | 249 | } 250 | 251 | bool isBlacklisted(NSString* procName) 252 | { 253 | if (!procName) procName = [NSProcessInfo processInfo].processName; 254 | HBPreferences* prefs = sharedPreferences(); 255 | NSArray* blacklist = [prefs objectForKey:kProcessBlacklist]; 256 | return (blacklist && [blacklist containsObject:procName]); 257 | } 258 | 259 | bool wantsLogJetsam() 260 | { 261 | return [([sharedPreferences() objectForKey:kEnableJetsam] ?: @YES) boolValue]; 262 | } 263 | 264 | void lazyLoadBundle(NSString* const bundlePath) 265 | { 266 | NSBundle* bundle = [NSBundle bundleWithPath:bundlePath]; 267 | if (!bundle.loaded) 268 | [bundle load]; 269 | } 270 | 271 | void showCr4shedNotification(NSString* notifContent, NSDictionary* notifUserInfo) 272 | { 273 | void* handle = dlopen("/usr/lib/libnotifications.dylib", RTLD_NOW); //TODO: fix for rootless jailbreaks 274 | if (handle) { 275 | NSString* bundleID = @"com.muirey03.cr4shedgui"; 276 | NSString* title = @"Cr4shed"; 277 | [objc_getClass("CPNotification") showAlertWithTitle:title 278 | message:notifContent 279 | userInfo:notifUserInfo 280 | badgeCount:1 281 | soundName:nil 282 | delay:0. 283 | repeats:NO 284 | bundleId:bundleID]; 285 | } 286 | } 287 | -------------------------------------------------------------------------------- /cr4shedgui/CRARootViewController.m: -------------------------------------------------------------------------------- 1 | #import "CRARootViewController.h" 2 | #import "CRAProcViewController.h" 3 | #import "CRAProcessManager.h" 4 | #import "Process.h" 5 | #import "Log.h" 6 | #import 7 | #import "UIImage+UIKitImage.h" 8 | #import 9 | #include 10 | 11 | @implementation ProcessCell 12 | -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)reuseIdentifier 13 | { 14 | if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) 15 | { 16 | self.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 17 | 18 | _countLbl = [[UILabel alloc] initWithFrame:CGRectZero]; 19 | _countLbl.font = [UIFont systemFontOfSize:15.]; 20 | _countLbl.textColor = [UIColor whiteColor]; 21 | _countLbl.backgroundColor = [UIColor systemRedColor]; 22 | _countLbl.textAlignment = NSTextAlignmentCenter; 23 | _countLbl.numberOfLines = 1; 24 | _countLbl.clipsToBounds = YES; 25 | _countLbl.translatesAutoresizingMaskIntoConstraints = NO; 26 | 27 | [self.contentView addSubview:_countLbl]; 28 | 29 | [_countLbl.trailingAnchor constraintEqualToAnchor:self.contentView.trailingAnchor constant:-10.].active = YES; 30 | [_countLbl.centerYAnchor constraintEqualToAnchor:self.centerYAnchor].active = YES; 31 | } 32 | return self; 33 | } 34 | 35 | -(void)updateLabels 36 | { 37 | self.textLabel.text = _proc.name; 38 | self.detailTextLabel.text = stringFromDate(_proc.latestDate, CR4DateFormatPretty); 39 | _countLbl.text = [NSString stringWithFormat:@"%llu", (unsigned long long)_proc.logs.count]; 40 | 41 | const CGFloat badgeHeight = 20.; 42 | const CGFloat minBadgePadding = 10.; 43 | CGFloat minBadgeWidth = badgeHeight * 1.5; 44 | CGFloat badgeWidth = [_countLbl.text boundingRectWithSize:CGSizeZero options:NSStringDrawingUsesLineFragmentOrigin| NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName : _countLbl.font} context:nil].size.width + minBadgePadding; 45 | badgeWidth = MAX(badgeWidth, minBadgeWidth); 46 | 47 | if (_widthConstraint) _widthConstraint.active = NO; 48 | if (_heightConstraint) _heightConstraint.active = NO; 49 | _widthConstraint = [_countLbl.widthAnchor constraintEqualToConstant:badgeWidth]; 50 | _heightConstraint = [_countLbl.heightAnchor constraintEqualToConstant:badgeHeight]; 51 | [NSLayoutConstraint activateConstraints:@[_widthConstraint, _heightConstraint]]; 52 | _countLbl.layer.cornerRadius = MIN(badgeHeight, badgeWidth) / 2.; 53 | } 54 | @end 55 | 56 | @implementation CRARootViewController 57 | -(instancetype)init 58 | { 59 | if ((self = [super initWithStyle:UITableViewStyleGrouped])) 60 | { 61 | //UIApplicationDidBecomeActiveNotification 62 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshTable:) name:UIApplicationDidBecomeActiveNotification object:[UIApplication sharedApplication]]; 63 | //CR4ProcsNeedRefreshNotificationName 64 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshTable:) name:CR4ProcsNeedRefreshNotificationName object:nil]; 65 | 66 | self.title = @"Cr4shed"; 67 | UIImage* itemImg = [[UIImage uikitImageNamed:@"UIButtonBarBookmarks"] resizeToWidth:25.]; 68 | self.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Reports" image:itemImg tag:0]; 69 | _processManager = [CRAProcessManager sharedInstance]; 70 | } 71 | return self; 72 | } 73 | 74 | -(void)loadView 75 | { 76 | [super loadView]; 77 | 78 | if ([self.navigationController.navigationBar respondsToSelector:@selector(setPrefersLargeTitles:)]) 79 | self.navigationController.navigationBar.prefersLargeTitles = YES; 80 | 81 | self.navigationItem.rightBarButtonItem = self.editButtonItem; 82 | 83 | self.tableView.rowHeight = 50; 84 | 85 | //pull to refresh: 86 | _refreshControl = [UIRefreshControl new]; 87 | [_refreshControl addTarget:self action:@selector(refreshTable:) forControlEvents:UIControlEventValueChanged]; 88 | if ([self.tableView respondsToSelector:@selector(setRefreshControl:)]) 89 | self.tableView.refreshControl = _refreshControl; 90 | else 91 | [self.tableView addSubview:_refreshControl]; 92 | } 93 | 94 | -(void)viewDidLoad 95 | { 96 | [super viewDidLoad]; 97 | [self refreshTable:nil]; 98 | } 99 | 100 | -(void)refreshTable:(id)obj 101 | { 102 | [_processManager refresh]; 103 | _procs = _processManager.processes; 104 | if (_refreshControl.refreshing) 105 | [_refreshControl endRefreshing]; 106 | [self.tableView reloadData]; 107 | } 108 | 109 | -(void)viewDidAppear:(BOOL)arg1 110 | { 111 | [super viewDidAppear:arg1]; 112 | self.navigationController.interactivePopGestureRecognizer.delegate = nil; 113 | self.navigationController.interactivePopGestureRecognizer.enabled = NO; 114 | } 115 | 116 | -(void)deleteProcessAtIndexPath:(NSIndexPath*)indexPath 117 | { 118 | Process* proc = _procs[indexPath.row]; 119 | [proc deleteAllLogs]; 120 | [_procs removeObjectAtIndex:indexPath.row]; 121 | [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; 122 | } 123 | 124 | #pragma mark - Table View Data Source 125 | 126 | -(NSInteger)numberOfSectionsInTableView:(UITableView*)tableView 127 | { 128 | return 1; 129 | } 130 | 131 | -(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section 132 | { 133 | return _procs.count; 134 | } 135 | 136 | -(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath 137 | { 138 | ProcessCell* cell = [tableView dequeueReusableCellWithIdentifier:@"ProcessCell"]; 139 | if (!cell) 140 | { 141 | cell = [[ProcessCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"ProcessCell"]; 142 | } 143 | cell.proc = _procs[indexPath.row]; 144 | [cell updateLabels]; 145 | return cell; 146 | } 147 | 148 | -(void)tableView:(UITableView*)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath*)indexPath 149 | { 150 | [self deleteProcessAtIndexPath:indexPath]; 151 | } 152 | 153 | #pragma mark - Table View Delegate 154 | 155 | -(UISwipeActionsConfiguration*)tableView:(UITableView*)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath*)indexPath 156 | { 157 | Class $UIContextualAction = objc_getClass("UIContextualAction"); 158 | Class $UISwipeActionsConfiguration = objc_getClass("UISwipeActionsConfiguration"); 159 | Process* proc = _procs[indexPath.row]; 160 | UIContextualAction* deleteAction = [$UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"Delete" handler:^(UIContextualAction* action, UIView* sourceView, void (^completionHandler)(BOOL)){ 161 | [self deleteProcessAtIndexPath:indexPath]; 162 | completionHandler(YES); 163 | }]; 164 | BOOL isBlacklisted = [proc isBlacklisted]; 165 | NSString* blacklistTitle = isBlacklisted ? @"Un-blacklist" : @"Blacklist"; 166 | UIContextualAction* blacklistAction = [$UIContextualAction contextualActionWithStyle:UIContextualActionStyleNormal title:blacklistTitle handler:^(UIContextualAction* action, UIView* sourceView, void (^completionHandler)(BOOL)){ 167 | if (isBlacklisted) 168 | [proc removeFromBlacklist]; 169 | else 170 | [proc addToBlacklist]; 171 | [[NSNotificationCenter defaultCenter] postNotificationName:CR4BlacklistDidChangeNotificationName object:nil]; 172 | completionHandler(YES); 173 | }]; 174 | blacklistAction.backgroundColor = [UIColor systemBlueColor]; 175 | NSArray* actions = @[deleteAction, blacklistAction]; 176 | UISwipeActionsConfiguration* config = [$UISwipeActionsConfiguration configurationWithActions:actions]; 177 | return config; 178 | } 179 | 180 | -(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath 181 | { 182 | CRAProcViewController* procVC = [[CRAProcViewController alloc] initWithProcess:_procs[indexPath.row]]; 183 | [self.navigationController pushViewController:procVC animated:YES]; 184 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 185 | } 186 | 187 | -(void)setEditing:(BOOL)editing animated:(BOOL)animated 188 | { 189 | [super setEditing:editing animated:animated]; 190 | 191 | UIBarButtonItem* item = nil; 192 | if (editing) 193 | { 194 | item = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:self action:@selector(removeAllLogs)]; 195 | } 196 | [self.navigationItem setLeftBarButtonItem:item animated:animated]; 197 | } 198 | 199 | -(void)removeAllLogs 200 | { 201 | NSMutableArray* indexPaths = [[NSMutableArray alloc] initWithCapacity:_procs.count]; 202 | for (NSUInteger i = 0; i < _procs.count; i++) 203 | { 204 | NSIndexPath* indexPath = [NSIndexPath indexPathForRow:i inSection:0]; 205 | Process* proc = _procs[i]; 206 | [proc deleteAllLogs]; 207 | [indexPaths addObject:indexPath]; 208 | } 209 | _procs = [NSMutableArray new]; 210 | [self.tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationAutomatic]; 211 | } 212 | 213 | -(void)dealloc 214 | { 215 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 216 | } 217 | @end 218 | -------------------------------------------------------------------------------- /cr4shedmach/mach_utils.mm: -------------------------------------------------------------------------------- 1 | @import CoreFoundation; 2 | @import Foundation; 3 | 4 | #import "mach_utils.h" 5 | #import "symbolication.h" 6 | #include 7 | #include 8 | #include 9 | 10 | #define EXC_UNIX_BAD_SYSCALL 0x10000 11 | #define EXC_UNIX_BAD_PIPE 0x10001 12 | #define EXC_UNIX_ABORT 0x10002 13 | #define EXC_SOFT_SIGNAL 0x10003 14 | 15 | NSString* mach_exception_string(exception_type_t exception, NSString* signalName) 16 | { 17 | #define exc_case(type) case type: return [NSString stringWithFormat:@"%s (%@)", #type, signalName] 18 | switch (exception) 19 | { 20 | exc_case(EXC_BAD_ACCESS); 21 | exc_case(EXC_BAD_INSTRUCTION); 22 | exc_case(EXC_ARITHMETIC); 23 | exc_case(EXC_EMULATION); 24 | exc_case(EXC_SOFTWARE); 25 | exc_case(EXC_BREAKPOINT); 26 | exc_case(EXC_SYSCALL); 27 | exc_case(EXC_MACH_SYSCALL); 28 | exc_case(EXC_RPC_ALERT); 29 | exc_case(EXC_CRASH); 30 | exc_case(EXC_RESOURCE); 31 | exc_case(EXC_GUARD); 32 | exc_case(EXC_CORPSE_NOTIFY); 33 | default: 34 | return @"EXC_UNKNOWN"; 35 | } 36 | #undef exc_case 37 | } 38 | 39 | const char* mach_code_string(exception_type_t type, mach_exception_data_t codes, mach_msg_type_number_t codeCnt) 40 | { 41 | if (codeCnt < 1) 42 | return NULL; 43 | 44 | mach_exception_code_t code = codes[0]; 45 | mach_exception_subcode_t subcode = codeCnt > 1 ? codes[1] : 0; 46 | const char* code_str = NULL; 47 | bool has_subcode = false; 48 | 49 | //get code string if applicable: 50 | #define set_code(code_type) if (code == code_type) code_str = #code_type 51 | switch (type) 52 | { 53 | case EXC_BAD_ACCESS: 54 | set_code(KERN_INVALID_ADDRESS); 55 | set_code(KERN_PROTECTION_FAILURE); 56 | has_subcode = true; 57 | break; 58 | case EXC_SOFTWARE: 59 | set_code(EXC_UNIX_BAD_SYSCALL); 60 | set_code(EXC_UNIX_BAD_PIPE); 61 | set_code(EXC_UNIX_ABORT); 62 | set_code(EXC_SOFT_SIGNAL); 63 | } 64 | #undef set_code 65 | 66 | //format string: 67 | char* str = NULL; 68 | if (code_str) 69 | { 70 | if (has_subcode) 71 | { 72 | size_t str_size = snprintf(NULL, 0, "%s: %p", code_str, (void*)subcode); 73 | str = (char*)malloc(str_size + 1); 74 | snprintf(str, str_size + 1, "%s: %p", code_str, (void*)subcode); 75 | } 76 | else 77 | { 78 | size_t str_size = snprintf(NULL, 0, "%s", code_str); 79 | str = (char*)malloc(str_size + 1); 80 | snprintf(str, str_size + 1, "%s", code_str); 81 | } 82 | } 83 | return str; 84 | } 85 | 86 | char* mach_exception_codes_string(mach_exception_data_t codes, mach_msg_type_number_t codeCnt) 87 | { 88 | char* str = NULL; 89 | for (unsigned int i = 0; i < codeCnt; i++) 90 | { 91 | if (str) 92 | { 93 | size_t new_sz = snprintf(NULL, 0, "%s, 0x%016llx", str, codes[i]) + 1; 94 | char* tmp_str = (char*)malloc(new_sz); 95 | snprintf(tmp_str, new_sz, "%s, 0x%016llx", str, codes[i]); 96 | free(str); 97 | str = tmp_str; 98 | } 99 | else 100 | { 101 | size_t new_sz = snprintf(NULL, 0, "0x%016llx", codes[i]) + 1; 102 | str = (char*)malloc(new_sz); 103 | snprintf(str, new_sz, "0x%016llx", codes[i]); 104 | } 105 | } 106 | return str; 107 | } 108 | 109 | vm_prot_t vm_region_get_protection(mach_port_t task, vm_address_t address) 110 | { 111 | vm_address_t addr = address; 112 | vm_size_t size = 0; 113 | vm_region_basic_info_data_64_t info = { 0 }; 114 | mach_msg_type_number_t info_count = VM_REGION_BASIC_INFO_COUNT_64; 115 | mach_port_t vm_obj; 116 | vm_region_64(task, &addr, &size, VM_REGION_BASIC_INFO_64, (vm_region_info_t)&info, &info_count, &vm_obj); 117 | return info.protection; 118 | } 119 | 120 | const char* mach_exception_vm_info(mach_port_t task, exception_type_t type, mach_exception_data_t codes, mach_msg_type_number_t codeCnt) 121 | { 122 | char* str = NULL; 123 | if (codeCnt > 1 && type == EXC_BAD_ACCESS) 124 | { 125 | mach_exception_subcode_t addr = codes[1]; 126 | if (codes[0] == KERN_INVALID_ADDRESS) 127 | { 128 | const char* fmt = "%p is not in any region."; 129 | size_t str_size = snprintf(NULL, 0, fmt, addr); 130 | str = (char*)malloc(str_size + 1); 131 | snprintf(str, str_size + 1, fmt, addr); 132 | } 133 | else 134 | { 135 | //format protection string: 136 | vm_prot_t prot = vm_region_get_protection(task, addr); 137 | char rwx_str[4]; 138 | strcpy(rwx_str, "---"); 139 | if (prot & VM_PROT_READ) 140 | rwx_str[0] = 'r'; 141 | if (prot & VM_PROT_WRITE) 142 | rwx_str[1] = 'w'; 143 | if (prot & VM_PROT_EXECUTE) 144 | rwx_str[2] = 'x'; 145 | 146 | str = strdup(rwx_str); 147 | } 148 | } 149 | return str; 150 | } 151 | 152 | std::vector get_register_info(_CR4_THREAD_STATE64* thread_state) 153 | { 154 | std::vector info_vec; 155 | 156 | #define ADD_INFO(reg, name) do { \ 157 | struct register_info info = { strdup(name), thread_state->__##reg }; \ 158 | info_vec.push_back(info); \ 159 | } while (false) 160 | 161 | ADD_INFO(pc, "PC"); 162 | ADD_INFO(lr, "LR"); 163 | ADD_INFO(cpsr, "CPSR"); 164 | 165 | #define ARM64_REGISTER_COUNT 29 166 | for (unsigned int i = 0; i < ARM64_REGISTER_COUNT; i++) 167 | { 168 | size_t reg_name_size = snprintf(NULL, 0, "x%d", i) + 1; 169 | char* reg_name = (char*)malloc(reg_name_size); 170 | snprintf(reg_name, reg_name_size, "x%d", i); 171 | ADD_INFO(x[i], reg_name); 172 | free(reg_name); 173 | } 174 | 175 | return info_vec; 176 | } 177 | 178 | static uint64_t thread_get_id(mach_port_t thread) 179 | { 180 | thread_identifier_info_data_t identifier_info = {0}; 181 | mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT; 182 | kern_return_t kr = thread_info(thread, THREAD_IDENTIFIER_INFO, (thread_info_t)&identifier_info, &count); 183 | if (kr != KERN_SUCCESS) 184 | return 0; 185 | return identifier_info.thread_id; 186 | } 187 | 188 | uint64_t thread_number(mach_port_t task, mach_port_t thread) 189 | { 190 | uint64_t desired_id = thread_get_id(thread); 191 | thread_act_port_array_t threads; 192 | mach_msg_type_number_t thread_count; 193 | task_threads(task, &threads, &thread_count); 194 | for (unsigned int i = 0; i < thread_count; i++) 195 | { 196 | uint64_t tid = thread_get_id(threads[i]); 197 | if (tid == desired_id) 198 | return i; 199 | } 200 | freeThreadArray(threads, thread_count); 201 | return 0; 202 | } 203 | 204 | exception_type_t mach_exception_type(int sig, mach_exception_data_type_t* exception_subtype) 205 | { 206 | exception_type_t type = 0; 207 | exception_data_type_t subtype = 0; 208 | switch (sig) 209 | { 210 | case SIGSEGV: 211 | type = EXC_BAD_ACCESS; 212 | subtype = KERN_INVALID_ADDRESS; 213 | break; 214 | case SIGBUS: 215 | type = EXC_BAD_ACCESS; 216 | subtype = KERN_PROTECTION_FAILURE; 217 | break; 218 | case SIGILL: 219 | type = EXC_BAD_INSTRUCTION; 220 | break; 221 | case SIGFPE: 222 | type = EXC_ARITHMETIC; 223 | break; 224 | case SIGEMT: 225 | type = EXC_EMULATION; 226 | break; 227 | case SIGSYS: 228 | type = EXC_SOFTWARE; 229 | subtype = EXC_UNIX_BAD_SYSCALL; 230 | break; 231 | case SIGPIPE: 232 | type = EXC_SOFTWARE; 233 | subtype = EXC_UNIX_BAD_PIPE; 234 | break; 235 | case SIGABRT: 236 | type = EXC_SOFTWARE; 237 | subtype = EXC_UNIX_ABORT; 238 | break; 239 | case SIGKILL: 240 | type = EXC_SOFTWARE; 241 | subtype = EXC_SOFT_SIGNAL; 242 | break; 243 | case SIGTRAP: 244 | type = EXC_BREAKPOINT; 245 | break; 246 | } 247 | if (exception_subtype) 248 | *exception_subtype = subtype; 249 | return type; 250 | } 251 | 252 | void freeThreadArray(thread_act_port_array_t threads, mach_msg_type_number_t thread_count) 253 | { 254 | if (threads && thread_count) 255 | vm_deallocate(mach_task_self(), (vm_address_t)threads, sizeof(thread_act_port_t) * thread_count); 256 | } 257 | 258 | BOOL createDir(NSString* path) 259 | { 260 | NSDictionary* attributes = @{ 261 | NSFilePosixPermissions : @0755, 262 | NSFileOwnerAccountName : @"mobile", 263 | NSFileGroupOwnerAccountName : @"mobile" 264 | }; 265 | return [[NSFileManager defaultManager] createDirectoryAtURL:[NSURL fileURLWithPath:path] withIntermediateDirectories:YES attributes:attributes error:nil]; 266 | } 267 | 268 | void writeStringToFile(NSString* str, NSString* path) 269 | { 270 | NSFileManager* manager = [NSFileManager defaultManager]; 271 | if ([manager fileExistsAtPath:path]) 272 | [manager removeItemAtPath:path error:NULL]; 273 | NSDictionary* attributes = @{ 274 | NSFilePosixPermissions : @0666, 275 | NSFileOwnerAccountName : @"mobile", 276 | NSFileGroupOwnerAccountName : @"mobile" 277 | }; 278 | NSData* contentsData = [str dataUsingEncoding:NSUTF8StringEncoding]; 279 | [manager createFileAtPath:path contents:contentsData attributes:attributes]; 280 | } 281 | 282 | NSString* stringFromTime(time_t t, CR4DateFormat type) 283 | { 284 | if (!t) t = time(NULL); 285 | MRYIPCCenter* ipcCenter = [MRYIPCCenter centerNamed:@"com.muirey03.cr4sheddserver"]; 286 | NSDictionary* reply = [ipcCenter callExternalMethod:@selector(stringFromTime:) withArguments:@{@"time" : @(t), @"type" : @(type)}]; 287 | NSString* str = reply[@"ret"]; 288 | //fallback if cr4shedd is not available or failed for whatever reason 289 | if (!str) 290 | { 291 | NSDate* date = [NSDate dateWithTimeIntervalSince1970:t]; 292 | str = stringFromDate(date, type); 293 | } 294 | return str; 295 | } 296 | 297 | mach_vm_address_t findSymbolInTask(mach_port_t task, const char* symbolName, NSString* lastPathComponent, NSString** imageName) 298 | { 299 | CSSymbolicatorRef symbolicator = CSSymbolicatorCreateWithTask(task); 300 | if (CSIsNull(symbolicator)) 301 | return 0; 302 | 303 | __block mach_vm_address_t addr = 0; 304 | __block NSString* imagePath = nil; 305 | CSSymbolicatorForeachSymbolAtTime(symbolicator, kCSNow, ^int(CSSymbolRef symbol){ 306 | if (!CSIsNull(symbol)) 307 | { 308 | const char* name = CSSymbolGetMangledName(symbol); 309 | if (name && symbolName) 310 | { 311 | if (strcmp(name, symbolName) == 0) 312 | { 313 | mach_vm_address_t symAddr = CSSymbolGetRange(symbol).location; 314 | CSSymbolOwnerRef owner = CSSymbolGetSymbolOwner(symbol); 315 | if (!CSIsNull(owner)) 316 | { 317 | const char* c_path = CSSymbolOwnerGetPath(owner); 318 | NSString* path = c_path ? @(c_path) : nil; 319 | if ([path.lastPathComponent isEqualToString:lastPathComponent]) 320 | { 321 | addr = symAddr - CSSymbolOwnerGetBaseAddress(owner); 322 | imagePath = path; 323 | return 0; 324 | } 325 | } 326 | } 327 | } 328 | } 329 | return 1; 330 | }); 331 | CSRelease(symbolicator); 332 | if (imageName) 333 | *imageName = imagePath; 334 | return addr; 335 | } 336 | --------------------------------------------------------------------------------