From 7c5736352228c607a0ea79bea7284ffc5f7abfad Mon Sep 17 00:00:00 2001 From: Sharat M R Date: Tue, 23 Apr 2019 02:55:53 +0530 Subject: [PATCH] Add Pref --- Makefile | 3 + Tweak.xm | 68 ++++++++------------ screendumpprefs/CCSRootListController.h | 5 ++ screendumpprefs/CCSRootListController.m | 13 ++++ screendumpprefs/Makefile | 15 +++++ screendumpprefs/Resources/Info.plist | 24 +++++++ screendumpprefs/Resources/Root.plist | 31 +++++++++ screendumpprefs/Resources/ScreenDump@2x.png | Bin 0 -> 1141 bytes screendumpprefs/entry.plist | 21 ++++++ 9 files changed, 138 insertions(+), 42 deletions(-) create mode 100644 screendumpprefs/CCSRootListController.h create mode 100644 screendumpprefs/CCSRootListController.m create mode 100644 screendumpprefs/Makefile create mode 100644 screendumpprefs/Resources/Info.plist create mode 100644 screendumpprefs/Resources/Root.plist create mode 100644 screendumpprefs/Resources/ScreenDump@2x.png create mode 100644 screendumpprefs/entry.plist diff --git a/Makefile b/Makefile index 3641bcc..0c8b633 100644 --- a/Makefile +++ b/Makefile @@ -10,5 +10,8 @@ screendump_PRIVATE_FRAMEWORKS := IOMobileFramebuffer include $(THEOS_MAKE_PATH)/tweak.mk +SUBPROJECTS += screendumpprefs +include $(THEOS_MAKE_PATH)/aggregate.mk + after-install:: install.exec "killall -9 backboardd" diff --git a/Tweak.xm b/Tweak.xm index d9bb676..abe1ecd 100644 --- a/Tweak.xm +++ b/Tweak.xm @@ -1,38 +1,4 @@ -/* How to Hook with Logos -Hooks are written with syntax similar to that of an Objective-C @implementation. -You don't need to #include , it will be done automatically, as will -the generation of a class list and an automatic constructor. - -%hook ClassName - -// Hooking a class method -+ (id)sharedInstance { - return %orig; -} - -// Hooking an instance method with an argument. -- (void)messageName:(int)argument { - %log; // Write a message about this call, including its class, name and arguments, to the system log. - - %orig; // Call through to the original function with its original arguments. - %orig(nil); // Call through to the original function with a custom argument. - - // If you use %orig(), you MUST supply all arguments (except for self and _cmd, the automatically generated ones.) -} - -// Hooking an instance method with no arguments. -- (id)noArguments { - %log; - id awesome = %orig; - [awesome doSomethingElse]; - - return awesome; -} - -// Always make sure you clean up after yourself; Not doing so could have grave consequences! -%end -*/ - +static BOOL CCSisEnabled = YES; #include typedef void *IOMobileFramebufferRef; @@ -122,19 +88,37 @@ int write_to_file(const void *image, size_t xsize, size_t ysize, size_t pixel_si size_t height = IOSurfaceGetHeight(buffer); size_t byte_per_pixel = IOSurfaceGetBytesPerElement(buffer); NSLog(@"sharat %ld, %ld, %ld, %ld, %ld", width_, height_, width, height, byte_per_pixel); - NSString *path = @"/tmp/test.bmp"; - void *bytes = IOSurfaceGetBaseAddress(buffer); + // NSString *path = @"/tmp/test.bmp"; + // void *bytes = IOSurfaceGetBaseAddress(buffer); // if(width) { // int ret; // ret = bmp_write(bytes, width, height, [path UTF8String]); // NSLog(@"sharat %d", ret); // } - IOSurfaceLock(buffer, kIOSurfaceLockReadOnly, NULL); - IOSurfaceFlushProcessorCaches(buffer); - write_to_file(bytes, width, height, byte_per_pixel, [path UTF8String]); - IOSurfaceUnlock(buffer, kIOSurfaceLockReadOnly, NULL); - + // IOSurfaceLock(buffer, kIOSurfaceLockReadOnly, NULL); + // IOSurfaceFlushProcessorCaches(buffer); + // write_to_file(bytes, width, height, byte_per_pixel, [path UTF8String]); + // IOSurfaceUnlock(buffer, kIOSurfaceLockReadOnly, NULL); + NSLog(@"sharat %d", CCSisEnabled); return %orig; } +static void loadPrefs() +{ + NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.cosmosgenius.screendumpprefs.plist"]; + if(prefs) { + CCSisEnabled = ([prefs objectForKey:@"CCSisEnabled"]) ? [[prefs objectForKey:@"CCSisEnabled"] boolValue] : CCSisEnabled; + } + [prefs release]; +} + +%ctor +{ + CFNotificationCenterAddObserver( + CFNotificationCenterGetDarwinNotifyCenter(), + NULL, (CFNotificationCallback)loadPrefs, + CFSTR("com.cosmosgenius.screendumpprefs/settingschanged"), + NULL, CFNotificationSuspensionBehaviorCoalesce); + loadPrefs(); +} diff --git a/screendumpprefs/CCSRootListController.h b/screendumpprefs/CCSRootListController.h new file mode 100644 index 0000000..7ea8e12 --- /dev/null +++ b/screendumpprefs/CCSRootListController.h @@ -0,0 +1,5 @@ +#import + +@interface CCSRootListController : PSListController + +@end diff --git a/screendumpprefs/CCSRootListController.m b/screendumpprefs/CCSRootListController.m new file mode 100644 index 0000000..b186f62 --- /dev/null +++ b/screendumpprefs/CCSRootListController.m @@ -0,0 +1,13 @@ +#include "CCSRootListController.h" + +@implementation CCSRootListController + +- (NSArray *)specifiers { + if (!_specifiers) { + _specifiers = [[self loadSpecifiersFromPlistName:@"Root" target:self] retain]; + } + + return _specifiers; +} + +@end diff --git a/screendumpprefs/Makefile b/screendumpprefs/Makefile new file mode 100644 index 0000000..fc4d38a --- /dev/null +++ b/screendumpprefs/Makefile @@ -0,0 +1,15 @@ +ARCHS := arm64 + +include $(THEOS)/makefiles/common.mk + +BUNDLE_NAME = ScreenDumpprefs +ScreenDumpprefs_FILES = CCSRootListController.m +ScreenDumpprefs_INSTALL_PATH = /Library/PreferenceBundles +ScreenDumpprefs_FRAMEWORKS = UIKit +ScreenDumpprefs_PRIVATE_FRAMEWORKS = Preferences + +include $(THEOS_MAKE_PATH)/bundle.mk + +internal-stage:: + $(ECHO_NOTHING)mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences$(ECHO_END) + $(ECHO_NOTHING)cp entry.plist $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/ScreenDumpprefs.plist$(ECHO_END) diff --git a/screendumpprefs/Resources/Info.plist b/screendumpprefs/Resources/Info.plist new file mode 100644 index 0000000..927b05c --- /dev/null +++ b/screendumpprefs/Resources/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ScreenDumpprefs + CFBundleIdentifier + com.cosmosgenius.screendumpprefs + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + NSPrincipalClass + CCSRootListController + + diff --git a/screendumpprefs/Resources/Root.plist b/screendumpprefs/Resources/Root.plist new file mode 100644 index 0000000..d559d6f --- /dev/null +++ b/screendumpprefs/Resources/Root.plist @@ -0,0 +1,31 @@ + + + + + items + + + cell + PSGroupCell + label + General + + + cell + PSSwitchCell + default + + defaults + com.cosmosgenius.screendumpprefs + key + CCSisEnabled + label + Enabled + PostNotification + com.cosmosgenius.screendumpprefs/settingschanged + + + title + ScreenDump + + diff --git a/screendumpprefs/Resources/ScreenDump@2x.png b/screendumpprefs/Resources/ScreenDump@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..bb776e2728e60fad47a953a420649bc895ee9a0a GIT binary patch literal 1141 zcmV-*1d98KP)(_`g8%^e{{R4h=>PzAFaQARU;qF*m;eA5Z<1fd zMgRZ<`$Lpi*rtO$;bBra$}yfhH1qgH^Pk^aUCp zYGM>Iq(%t@LtiQe)P|Hk5J5_9j06HGRcOQ*sMzvg(x?S*TN4eC5@;#6WPD&*cJG}Cl6KN&?OqoWC3%v-8{A{_`BQ6QHh2xW%8h(3g~Q6Os& zr%m?P)hi7c}kK!Wf@Sjc=O zco+F>QuJ}|2?IHve~i#A&KlCLV80Fndddj9-nC8OvVyI=TjXvdt&jNZg$i_-0wYcy z)x6KkObN1<2ttBp3YbqVyZDTC%mbiG!CqmUC(2mrJ+@z=hiah2Ea+M1R!T=3a5u<`loJ0^>8AY>#Z31AuPj|qV0Y$nz&fWZt zFv#m<`+Q0`h7hNSP6fM`t-kY(>7M2~k8?dO2wiTCFqto@a6LapI769lX*1g(vGhae zyzBlNg$#3n`(4{h2;U{u3!k#`HptUbOj={BGnml|-Y2UK+sXp34p-@vYPGc$zn005O-Pw}=E*h61MXjSy3 zH1mveT#oRgJ3pna701~^vl&E~bz7ga2svcanx=yK!M?9m2z`u6Y2S{pgGu~mQMlFF zW4}S@;33tv8Q~8$r?kunki1CGwVR6+N1zT?qT|=*1Y}b-&dDY~kLj6WtWsl8dIW@#myq~FL zp*o=QqyA9&o&x=gtf;XE73|^YKg#wh*bkz{=BZD%G-|B20ZA}DYV0R>J5}77oHVvr zh0#O(pGX=<>gPhSi+p1w|7pC9&`${?EH&PlJLA9j8T9V}544$7J#kCe00000NkvXX Hu0mjfBFqJ) literal 0 HcmV?d00001 diff --git a/screendumpprefs/entry.plist b/screendumpprefs/entry.plist new file mode 100644 index 0000000..9d6b139 --- /dev/null +++ b/screendumpprefs/entry.plist @@ -0,0 +1,21 @@ + + + + + entry + + bundle + ScreenDumpprefs + cell + PSLinkCell + detail + CCSRootListController + icon + ScreenDump.png + isController + + label + ScreenDump + + +