wake.m 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #import <dlfcn.h>
  2. #import <objc/runtime.h>
  3. #import <Foundation/Foundation.h>
  4. #include <TargetConditionals.h>
  5. @interface PBSSystemService : NSObject
  6. +(id)sharedInstance;
  7. -(void)deactivateScreenSaver;
  8. @end
  9. @interface PBSPowerManager : NSObject
  10. +(id)sharedInstance;
  11. +(void)load;
  12. +(void)setupPowerManagement;
  13. -(void)_performUserEventWakeDevice;
  14. -(void)wakeDeviceWithOptions:(id)arg1;
  15. -(void)setNeedsDisplayWakeOnPowerOn:(BOOL)arg1;
  16. - (void)sleepDeviceWithOptions:(id)arg1;
  17. -(void)_registerForPowerNotifications;
  18. -(void)_registerForThermalNotifications;
  19. -(void)_enableIdleSleepAndWatchdog;
  20. -(void)_registerForBackBoardNotifications;
  21. -(void)_updateIdleTimer;
  22. @end
  23. @interface NSDistributedNotificationCenter : NSNotificationCenter
  24. + (id)defaultCenter;
  25. - (void)addObserver:(id)arg1 selector:(SEL)arg2 name:(id)arg3 object:(id)arg4;
  26. - (void)postNotificationName:(id)arg1 object:(id)arg2 userInfo:(id)arg3;
  27. @end
  28. /* Set platform binary flag */
  29. #define FLAG_PLATFORMIZE (1 << 1)
  30. void platformizeme() {
  31. void* handle = dlopen("/usr/lib/libjailbreak.dylib", RTLD_LAZY);
  32. if (!handle) return;
  33. // Reset errors
  34. dlerror();
  35. typedef void (*fix_entitle_prt_t)(pid_t pid, uint32_t what);
  36. fix_entitle_prt_t ptr = (fix_entitle_prt_t)dlsym(handle, "jb_oneshot_entitle_now");
  37. const char *dlsym_error = dlerror();
  38. if (dlsym_error) {
  39. return;
  40. }
  41. ptr(getpid(), FLAG_PLATFORMIZE);
  42. }
  43. int main(){
  44. @autoreleasepool {
  45. platformizeme();
  46. NSString *pineBoardServices = @"/System/Library/PrivateFrameworks/PineBoardServices.framework/";
  47. NSBundle *pbs = [NSBundle bundleWithPath:pineBoardServices];
  48. [pbs load];
  49. Class powermanager = objc_getClass("PBSPowerManager");
  50. [powermanager setupPowerManagement];
  51. [powermanager load];
  52. id power = [powermanager sharedInstance];
  53. if ([power respondsToSelector:@selector(_performUserEventWakeDevice)]){
  54. [power _performUserEventWakeDevice];
  55. }
  56. [power wakeDeviceWithOptions:@{@"WakeReason":@"UserActivity"}];
  57. /*
  58. Class notecenter = objc_getClass("NSDistributedNotificationCenter");
  59. id note = [notecenter defaultCenter];
  60. [note postNotificationName:@"com.nitoTV.wakeup" object:nil ];
  61. sleep(3);
  62. */
  63. }
  64. return 0;
  65. }