Created
December 15, 2016 08:46
-
-
Save dopcn/3ce7d562cfae32ad0dba85a8c24f1f71 to your computer and use it in GitHub Desktop.
fishhook hook NSSetUncaughtExceptionHandler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "AppDelegate.h" | |
#import "fishhook.h" | |
#import <dlfcn.h> | |
static NSUncaughtExceptionHandler *g_vaildUncaughtExceptionHandler; | |
static void (*ori_NSSetUncaughtExceptionHandler)( NSUncaughtExceptionHandler * ); | |
void my_NSSetUncaughtExceptionHandler( NSUncaughtExceptionHandler * handler) | |
{ | |
g_vaildUncaughtExceptionHandler = NSGetUncaughtExceptionHandler(); | |
if (g_vaildUncaughtExceptionHandler != NULL) { | |
NSLog(@"UncaughtExceptionHandler=%p",g_vaildUncaughtExceptionHandler); | |
} | |
ori_NSSetUncaughtExceptionHandler(handler); | |
NSLog(@"%@",[NSThread callStackSymbols]); | |
g_vaildUncaughtExceptionHandler = NSGetUncaughtExceptionHandler(); | |
NSLog(@"UncaughtExceptionHandler=%p",g_vaildUncaughtExceptionHandler); | |
} | |
int main(int argc, char *argv[]) | |
{ | |
@autoreleasepool { | |
ori_NSSetUncaughtExceptionHandler = dlsym(RTLD_DEFAULT, "NSSetUncaughtExceptionHandler"); | |
rebind_symbols((struct rebinding[1]){{"NSSetUncaughtExceptionHandler", my_NSSetUncaughtExceptionHandler, (void **)&ori_NSSetUncaughtExceptionHandler}}, 1); | |
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment