//#import "PBReloadHelper.h" #import #import //#import "rocketbootstrap.h" //#import "AppSupport/CPDistributedMessagingCenter.h" @interface NSDistributedNotificationCenter : NSNotificationCenter + (id)defaultCenter; - (void)addObserver:(id)arg1 selector:(SEL)arg2 name:(id)arg3 object:(id)arg4; - (void)postNotificationName:(id)arg1 object:(id)arg2 userInfo:(id)arg3; @end @interface MessageHandler : NSObject -(void)runAppEnabler:(id)a; - (void)swizzleMeTimbers; @end @implementation MessageHandler - (BOOL)originalIsEnabled { NSLog(@"originalIsEnabled"); return TRUE; } - (BOOL)ourIsEnabled { NSLog(@"ourIsEnabled"); BOOL orig = [(id)self ourIsEnabled]; if (orig) return orig; return TRUE; } - (void)swizzleMeTimbers { NSLog(@"swizzleMeTimbers2"); static dispatch_once_t onceToken2; Class mutableAppState = NSClassFromString(@"PBSMutableAppState"); NSLog(@"mutableAppState: %@", mutableAppState); Method sourceMutableAppState = class_getInstanceMethod(mutableAppState, @selector(isEnabled)); NSLog(@"mutableAppState: %@", sourceMutableAppState); dispatch_once(&onceToken2, ^{ // get the class definition responsible for populating the context menu Method ourEnabledReplacement = class_getInstanceMethod([self class], @selector(ourIsEnabled)); class_addMethod(mutableAppState, @selector(originalIsEnabled), method_getImplementation(ourEnabledReplacement), method_getTypeEncoding(ourEnabledReplacement)); Method sourceEnabledOriginal = class_getInstanceMethod(mutableAppState, @selector(originalIsEnabled)); method_exchangeImplementations(sourceMutableAppState, sourceEnabledOriginal); }); } -(void)runAppEnabler:(id)a { //NSLog(@"#### for luck!"); // [PBReloadHelper reloadApplications]; } @end __attribute__ ((__constructor__)) void pre_func(void) { NSLog(@"pre_func22\n"); MessageHandler *mh = [MessageHandler new]; [mh swizzleMeTimbers]; /* dispatch_async(dispatch_get_main_queue(), ^(void){ NSDistributedNotificationCenter* notificationCenter = [NSDistributedNotificationCenter defaultCenter]; [notificationCenter addObserver:[MessageHandler new] selector:@selector(runAppEnabler:) name:@"kjc.AppEnabler.recache" object:nil]; }); */ }