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 0000000..bb776e2 Binary files /dev/null and b/screendumpprefs/Resources/ScreenDump@2x.png differ 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 + + +