This commit is contained in:
Sharat M R 2019-04-23 02:55:53 +05:30
parent 0ec8d1a621
commit 7c57363522
No known key found for this signature in database
GPG Key ID: E450A6E45DAE1B94
9 changed files with 138 additions and 42 deletions

View File

@ -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"

View File

@ -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 <substrate.h>, 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 <errno.h>
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();
}

View File

@ -0,0 +1,5 @@
#import <Preferences/PSListController.h>
@interface CCSRootListController : PSListController
@end

View File

@ -0,0 +1,13 @@
#include "CCSRootListController.h"
@implementation CCSRootListController
- (NSArray *)specifiers {
if (!_specifiers) {
_specifiers = [[self loadSpecifiersFromPlistName:@"Root" target:self] retain];
}
return _specifiers;
}
@end

15
screendumpprefs/Makefile Normal file
View File

@ -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)

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>ScreenDumpprefs</string>
<key>CFBundleIdentifier</key>
<string>com.cosmosgenius.screendumpprefs</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>NSPrincipalClass</key>
<string>CCSRootListController</string>
</dict>
</plist>

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>label</key>
<string>General</string>
</dict>
<dict>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
<true/>
<key>defaults</key>
<string>com.cosmosgenius.screendumpprefs</string>
<key>key</key>
<string>CCSisEnabled</string>
<key>label</key>
<string>Enabled</string>
<key>PostNotification</key>
<string>com.cosmosgenius.screendumpprefs/settingschanged<string>
</dict>
</array>
<key>title</key>
<string>ScreenDump</string>
</dict>
</plist>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>entry</key>
<dict>
<key>bundle</key>
<string>ScreenDumpprefs</string>
<key>cell</key>
<string>PSLinkCell</string>
<key>detail</key>
<string>CCSRootListController</string>
<key>icon</key>
<string>ScreenDump.png</string>
<key>isController</key>
<true/>
<key>label</key>
<string>ScreenDump</string>
</dict>
</dict>
</plist>