Browse Source

added sleep and wake files

Kevin Bradley 4 years ago
parent
commit
03e03f45ac
2 changed files with 90 additions and 0 deletions
  1. 45 0
      uicache/sleep.m
  2. 45 0
      uicache/wake.m

+ 45 - 0
uicache/sleep.m

@@ -0,0 +1,45 @@
+#import <dlfcn.h>
+#import <objc/runtime.h>
+#import <Foundation/Foundation.h>
+#include <TargetConditionals.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
+
+/* Set platform binary flag */
+#define FLAG_PLATFORMIZE (1 << 1)
+
+void platformizeme() {
+    void* handle = dlopen("/usr/lib/libjailbreak.dylib", RTLD_LAZY);
+    if (!handle) return;
+    
+    // Reset errors
+    dlerror();
+    typedef void (*fix_entitle_prt_t)(pid_t pid, uint32_t what);
+    fix_entitle_prt_t ptr = (fix_entitle_prt_t)dlsym(handle, "jb_oneshot_entitle_now");
+    
+    const char *dlsym_error = dlerror();
+    if (dlsym_error) {
+        return;
+    }
+    
+    ptr(getpid(), FLAG_PLATFORMIZE);
+}
+
+int main(){
+	@autoreleasepool {
+		platformizeme();
+
+        Class notecenter = objc_getClass("NSDistributedNotificationCenter");
+        id note = [notecenter defaultCenter];
+        [note postNotificationName:@"com.nitoTV.sleep" object:nil ];
+        sleep(3);
+	}
+	return 0;
+}

+ 45 - 0
uicache/wake.m

@@ -0,0 +1,45 @@
+#import <dlfcn.h>
+#import <objc/runtime.h>
+#import <Foundation/Foundation.h>
+#include <TargetConditionals.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
+
+/* Set platform binary flag */
+#define FLAG_PLATFORMIZE (1 << 1)
+
+void platformizeme() {
+    void* handle = dlopen("/usr/lib/libjailbreak.dylib", RTLD_LAZY);
+    if (!handle) return;
+    
+    // Reset errors
+    dlerror();
+    typedef void (*fix_entitle_prt_t)(pid_t pid, uint32_t what);
+    fix_entitle_prt_t ptr = (fix_entitle_prt_t)dlsym(handle, "jb_oneshot_entitle_now");
+    
+    const char *dlsym_error = dlerror();
+    if (dlsym_error) {
+        return;
+    }
+    
+    ptr(getpid(), FLAG_PLATFORMIZE);
+}
+
+int main(){
+	@autoreleasepool {
+		platformizeme();
+
+        Class notecenter = objc_getClass("NSDistributedNotificationCenter");
+        id note = [notecenter defaultCenter];
+        [note postNotificationName:@"com.nitoTV.wakeup" object:nil ];
+        sleep(3);
+	}
+	return 0;
+}