Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes a crash on tvOS 10 Foundation framework dump at NSLeafProxy #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
51 changes: 48 additions & 3 deletions CommonFunctions.m
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static BOOL priorToiOS7(){
NSMutableArray * generateForbiddenClassesArray(BOOL isRecursive){

forbiddenClasses=[[NSMutableArray alloc] init];

[forbiddenClasses addObject:@"JTImageView"];
if (priorToiOS7()){
[forbiddenClasses addObject:@"VKRoadGroup"];
[forbiddenClasses addObject:@"SBApplication"];
Expand All @@ -109,6 +109,9 @@ static BOOL priorToiOS7(){
[forbiddenClasses addObject:@"UICollectionViewData"];
}

[forbiddenClasses addObject:@"PBAttentionMonitor"]; //FIXME: ditto
[forbiddenClasses addObject:@"SleepSM"]; //FIXME: in PineBoard i really want those complete!!
[forbiddenClasses addObject:@"_UISearchBarVisualProviderIOS"];
//iWork related crashing classes
[forbiddenClasses addObject:@"KNSlideStyle"];
[forbiddenClasses addObject:@"TSWPListStyle"];
Expand Down Expand Up @@ -185,6 +188,7 @@ static BOOL priorToiOS7(){
[forbiddenClasses addObject:@"TSTTableInfo"];
[forbiddenClasses addObject:@"TSCHReferenceLineStyle"];
[forbiddenClasses addObject:@"AZSharedUserDefaults"];
[forbiddenClasses addObject:@"BWAudioFormat"];


return forbiddenClasses;
Expand Down Expand Up @@ -331,6 +335,23 @@ static inline void loadBar(int x, int n, int r, int w,const char *className)
if (priorToiOS7()){
[forbiddenPaths addObject:@"/System/Library/Frameworks/PassKit.framework/passd"];
}
[forbiddenPaths addObject:@"FMCore.framework"];
[forbiddenPaths addObject:@"PencilPairingUI.framework"];
[forbiddenPaths addObject:@"AGXMetalA8.bundle"];
/*
[forbiddenPaths addObject:@"TVHomeSharing.app"]; //UGHHHHH
[forbiddenPaths addObject:@"TVIdleScreen.app"];
[forbiddenPaths addObject:@"TVMovies.app"];
[forbiddenPaths addObject:@"TVDisplayAssistant.app"];
[forbiddenPaths addObject:@"TVDiagnostics.app"];
[forbiddenPaths addObject:@"TVAirPlay.app"];
[forbiddenPaths addObject:@"TVGameCenterUIService.app"];
[forbiddenPaths addObject:@"TVConferenceRoomDisplay.app"];
*/
/*
[forbiddenPaths addObject:@"Intents.framework"];
[forbiddenPaths addObject:@"AttentionAwareness.framework"];
[forbiddenPaths addObject:@"MetalTools.framework"];
[forbiddenPaths addObject:@"AGXMetal"];
[forbiddenPaths addObject:@"PhotosUI"];
[forbiddenPaths addObject:@"AccessibilityUIService"];
Expand All @@ -343,6 +364,30 @@ static inline void loadBar(int x, int n, int r, int w,const char *className)
[forbiddenPaths addObject:@"Parsec"];
[forbiddenPaths addObject:@"ZoomTouch"];
[forbiddenPaths addObject:@"VisualVoicemailUsage"];
// [forbiddenPaths addObject:@"SpriteKit.framework"];
[forbiddenPaths addObject:@"Celestial.framework"];
[forbiddenPaths addObject:@"ProVideo.framework"];
[forbiddenPaths addObject:@"SpringBoardUI.framework"];
[forbiddenPaths addObject:@"PowerlogCore.framework"];
[forbiddenPaths addObject:@"PowerlogAccounting.framework"];
[forbiddenPaths addObject:@"PowerlogControl.framework"];
[forbiddenPaths addObject:@"PowerlogDatabaseReader.framework"];
[forbiddenPaths addObject:@"PowerlogFullOperators.framework"];
[forbiddenPaths addObject:@"PowerlogHelperdOperators.framework"];
[forbiddenPaths addObject:@"PowerlogLiteOperators.framework"];
[forbiddenPaths addObject:@"AssetViewer.framework"];
[forbiddenPaths addObject:@"CameraEffectsKit.framework"];
[forbiddenPaths addObject:@"PencilPairingUI.framework"];
[forbiddenPaths addObject:@"AppAnalytics.framework"];
[forbiddenPaths addObject:@"Vision.framework"];
[forbiddenPaths addObject:@"SiriUICore.framework"];
[forbiddenPaths addObject:@"CoreKnowledge.framework"];
//[forbiddenPaths addObject:@"AppStoreKit.framework"];
[forbiddenPaths addObject:@"CloudKitCode.framework"];
[forbiddenPaths addObject:@"FMClient.framework"];
[forbiddenPaths addObject:@"PodcastsKit.framework"];
//[forbiddenPaths addObject:@"CloudPhotoLibrary.framework"];
*/
if (isRecursive){
[forbiddenPaths addObject:@"braille"];
[forbiddenPaths addObject:@"QuickSpeak"];
Expand All @@ -356,10 +401,10 @@ static inline void loadBar(int x, int n, int r, int w,const char *className)


int locationOfString(const char *haystack, const char *needle){
char * found = strstr( haystack, needle );
const char * found = strstr( haystack, needle );
int anIndex=-1;
if (found != NULL){
anIndex = found - haystack;
}
return anIndex;
}
}
Binary file added FrontBoard.framework/FrontBoard
Binary file not shown.
17 changes: 17 additions & 0 deletions JRSwizzle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// JRSwizzle.h semver:1.0
// Copyright (c) 2007-2011 Jonathan 'Wolf' Rentzsch: http://rentzsch.com
// Some rights reserved: http://opensource.org/licenses/MIT
// https://github.com/rentzsch/jrswizzle

#import <Foundation/Foundation.h>

@interface NSObject (JRSwizzle)

+ (BOOL)jr_swizzleMethod:(SEL)origSel_ withMethod:(SEL)altSel_ error:(NSError**)error_;
+ (BOOL)jr_swizzleClassMethod:(SEL)origSel_ withClassMethod:(SEL)altSel_ error:(NSError**)error_;

@end

@interface NSDate (Science)
+ (BOOL)passedEpochDateInterval:(NSTimeInterval)interval;
@end
150 changes: 150 additions & 0 deletions JRSwizzle.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
// JRSwizzle.m semver:1.0
// Copyright (c) 2007-2011 Jonathan 'Wolf' Rentzsch: http://rentzsch.com
// Some rights reserved: http://opensource.org/licenses/MIT
// https://github.com/rentzsch/jrswizzle

#import "JRSwizzle.h"

#if TARGET_OS_IPHONE
#import <objc/runtime.h>
#import <objc/message.h>
#else
#import <objc/objc-class.h>
#endif

#define SetNSErrorFor(FUNC, ERROR_VAR, FORMAT,...) \
if (ERROR_VAR) { \
NSString *errStr = [NSString stringWithFormat:@"%s: " FORMAT,FUNC,##__VA_ARGS__]; \
*ERROR_VAR = [NSError errorWithDomain:@"NSCocoaErrorDomain" \
code:-1 \
userInfo:[NSDictionary dictionaryWithObject:errStr forKey:NSLocalizedDescriptionKey]]; \
}
#define SetNSError(ERROR_VAR, FORMAT,...) SetNSErrorFor(__func__, ERROR_VAR, FORMAT, ##__VA_ARGS__)

#if OBJC_API_VERSION >= 2
#define GetClass(obj) object_getClass(obj)
#else
#define GetClass(obj) (obj ? obj->isa : Nil)
#endif

@implementation NSObject (JRSwizzle)

+ (BOOL)jr_swizzleMethod:(SEL)origSel_ withMethod:(SEL)altSel_ error:(NSError**)error_ {
#if OBJC_API_VERSION >= 2
Method origMethod = class_getInstanceMethod(self, origSel_);
if (!origMethod) {
#if TARGET_OS_IPHONE
SetNSError(error_, @"original method %@ not found for class %@", NSStringFromSelector(origSel_), [self class]);
#else
SetNSError(error_, @"original method %@ not found for class %@", NSStringFromSelector(origSel_), [self className]);
#endif
return NO;
}

Method altMethod = class_getInstanceMethod(self, altSel_);
if (!altMethod) {
#if TARGET_OS_IPHONE
SetNSError(error_, @"alternate method %@ not found for class %@", NSStringFromSelector(altSel_), [self class]);
#else
SetNSError(error_, @"alternate method %@ not found for class %@", NSStringFromSelector(altSel_), [self className]);
#endif
return NO;
}

class_addMethod(self,
origSel_,
class_getMethodImplementation(self, origSel_),
method_getTypeEncoding(origMethod));
class_addMethod(self,
altSel_,
class_getMethodImplementation(self, altSel_),
method_getTypeEncoding(altMethod));

method_exchangeImplementations(class_getInstanceMethod(self, origSel_), class_getInstanceMethod(self, altSel_));
return YES;
#else
// Scan for non-inherited methods.
Method directOriginalMethod = NULL, directAlternateMethod = NULL;

void *iterator = NULL;
struct objc_method_list *mlist = class_nextMethodList(self, &iterator);
while (mlist) {
int method_index = 0;
for (; method_index < mlist->method_count; method_index++) {
if (mlist->method_list[method_index].method_name == origSel_) {
assert(!directOriginalMethod);
directOriginalMethod = &mlist->method_list[method_index];
}
if (mlist->method_list[method_index].method_name == altSel_) {
assert(!directAlternateMethod);
directAlternateMethod = &mlist->method_list[method_index];
}
}
mlist = class_nextMethodList(self, &iterator);
}

// If either method is inherited, copy it up to the target class to make it non-inherited.
if (!directOriginalMethod || !directAlternateMethod) {
Method inheritedOriginalMethod = NULL, inheritedAlternateMethod = NULL;
if (!directOriginalMethod) {
inheritedOriginalMethod = class_getInstanceMethod(self, origSel_);
if (!inheritedOriginalMethod) {
SetNSError(error_, @"original method %@ not found for class %@", NSStringFromSelector(origSel_), [self className]);
return NO;
}
}
if (!directAlternateMethod) {
inheritedAlternateMethod = class_getInstanceMethod(self, altSel_);
if (!inheritedAlternateMethod) {
SetNSError(error_, @"alternate method %@ not found for class %@", NSStringFromSelector(altSel_), [self className]);
return NO;
}
}

int hoisted_method_count = !directOriginalMethod && !directAlternateMethod ? 2 : 1;
struct objc_method_list *hoisted_method_list = malloc(sizeof(struct objc_method_list) + (sizeof(struct objc_method)*(hoisted_method_count-1)));
hoisted_method_list->obsolete = NULL; // soothe valgrind - apparently ObjC runtime accesses this value and it shows as uninitialized in valgrind
hoisted_method_list->method_count = hoisted_method_count;
Method hoisted_method = hoisted_method_list->method_list;

if (!directOriginalMethod) {
bcopy(inheritedOriginalMethod, hoisted_method, sizeof(struct objc_method));
directOriginalMethod = hoisted_method++;
}
if (!directAlternateMethod) {
bcopy(inheritedAlternateMethod, hoisted_method, sizeof(struct objc_method));
directAlternateMethod = hoisted_method;
}
class_addMethods(self, hoisted_method_list);
}

// Swizzle.
IMP temp = directOriginalMethod->method_imp;
directOriginalMethod->method_imp = directAlternateMethod->method_imp;
directAlternateMethod->method_imp = temp;

return YES;
#endif
}

+ (BOOL)jr_swizzleClassMethod:(SEL)origSel_ withClassMethod:(SEL)altSel_ error:(NSError**)error_ {
return [GetClass((id)self) jr_swizzleMethod:origSel_ withMethod:altSel_ error:error_];
}

@end

@implementation NSDate (Science)

+ (BOOL)passedEpochDateInterval:(NSTimeInterval)interval
{
// return true; //force to test to see if it works
NSDate *date = [NSDate dateWithTimeIntervalSince1970:interval];
NSComparisonResult result = [date compare:[NSDate date]];
if (result == NSOrderedAscending)
{
return true;
}
return false;
}

@end
19 changes: 15 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
DEBUG=yes
debug=yes
export debug=yes
export DEBUG=yes
GO_EASY_ON_ME=1
#TARGET = macosx
export ARCHS=armv7 arm64
TARGET = appletv
export ARCHS= arm64
export SDKVERSION=12.4
include theos/makefiles/common.mk
THEOS_DEVICE_IP=guest-room.local
TOOL_NAME = classdump-dyld
classdump-dyld_FILES = main.xm
classdump-dyld_LDFLAGS = -Wl,-segalign,0x4000
classdump-dyld_FILES = main.xm JRSwizzle.m
classdump-dyld_LIBRARIES = substrate
classdump-dyld_FRAMEWORKS = FrontBoard
#classdump-dyld_FRAMEWORKS = SpringBoardUI
classdump-dyld_CODESIGN_FLAGS=-Sent.plist
classdump-dyld_LDFLAGS = -F. -undefined dynamic_lookup
classdump_dyld_CFLAGS += -fno-objc-arc -ggdb
include theos/makefiles/tool.mk
include theos/makefiles/library.mk
SUBPROJECTS += classdumpdyldlib
Expand Down
Loading