Compare commits

...

22 Commits

Author SHA1 Message Date
Levent Duivel 456470fb7d optional garbage tuning 2024-11-11 03:22:39 +05:00
Levent Duivel ae72f62025 Bump version to 0.1.1 2024-11-10 03:43:46 +05:00
Levent Duivel 22f3e44ad9 Revert "cursor ai garbage tuning"
This reverts commit b88f0b7151.
2024-11-10 03:39:37 +05:00
Levent Duivel b88f0b7151 cursor ai garbage tuning 2024-11-08 02:15:45 +05:00
Levent Duivel 07296e74cb small fix 2024-11-08 01:30:55 +05:00
Levent Duivel fd0d659772 refactored into ObjC without C++ 2024-11-08 00:40:14 +05:00
Levent Duivel 45e8471411 sd: Bump version to 0.0.5.2 2024-11-07 18:31:20 +05:00
Levent Duivel 2e703d1225 remap ctrl/cmd/alt keys for windows user 2024-11-07 18:23:20 +05:00
Levent Duivel 486c150d93 fix low frame 2024-11-07 18:20:17 +05:00
Levent Duivel 7d509b3a44 fix 2024-11-07 07:45:20 +05:00
Levent Duivel feda8cc7a1 rework a bit 2024-11-07 07:32:03 +05:00
Levent Duivel ac972bbedc small edits to sd og 2024-11-07 07:10:55 +05:00
Levent Duivel 8a7ae31775 rework screendumpLowFrame - now works 2024-11-07 06:46:11 +05:00
m1337 6c6e43abc0 fix 2024-08-29 23:49:57 +07:00
m1337 9855510d95 fix 2024-08-29 23:38:42 +07:00
Michael 2d9baadcac update 2024-08-29 23:34:09 +07:00
m1337v d94d23ebc2
Update ci.yaml 2024-08-29 23:27:23 +07:00
m1337 d107b21d5f fix 2024-08-29 23:24:03 +07:00
m1337 6f80ce9993 fix 2024-08-29 23:19:52 +07:00
m1337 26f21ff693 update 2024-08-29 23:12:03 +07:00
m1337v 0ed9b9063c
Update ci.yaml 2024-08-29 22:13:52 +07:00
m1337v cf34c3e385
Update ci.yaml 2024-08-29 22:10:14 +07:00
47 changed files with 887 additions and 746 deletions

View File

@ -26,35 +26,39 @@ jobs:
fetch-depth: 0
submodules: recursive
- name: Theos Setup (Setup)
- name: Theos Setup
uses: NyaMisty/theos-action@master
- name: Get tag
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
id: tag
uses: dawidd6/action-get-tag@v1
- name: Build Release package - Rootful
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
- name: Determine Tag or Default
id: determine_tag
run: |
cd screendumpLowFrame
make clean
TAGNAME=${{ steps.tag.outputs.tag || '0.0.5' }} # Default value for manual run
make package FINALPACKAGE=1 PACKAGE_VERSION=${TAGNAME#v}-rootful
# Check if the current ref is a tag
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
TAG_NAME="${GITHUB_REF#refs/tags/}"
else
TAG_NAME="0.0.5" # Fallback tag version
fi
echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV
- name: Create Tag
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git tag ${{ env.TAG_NAME }} || echo "Tag already exists."
git push origin ${{ env.TAG_NAME }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build Release package - Rootless
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
run: |
cd screendumpLowFrame
make clean
TAGNAME=${{ steps.tag.outputs.tag || '0.0.5' }} # Default value for manual run
make package THEOS_PACKAGE_SCHEME=rootless FINALPACKAGE=1 PACKAGE_VERSION=${TAGNAME#v}-rootless
make package THEOS_PACKAGE_SCHEME=rootless FINALPACKAGE=1 PACKAGE_VERSION=${{ env.TAG_NAME }}-rootless
- name: Release
uses: softprops/action-gh-release@v1
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
with:
files: |
${{ github.workspace }}/screendumpLowFrame/packages/*.deb
files: screendumpLowFrame/packages/*.deb
tag_name: ${{ env.TAG_NAME }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

10
screendump/FrameUpdater.h Normal file
View File

@ -0,0 +1,10 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <rfb/rfb.h>
#import "IOMobileFramebuffer.h"
@interface FrameUpdater : NSObject
-(instancetype)initWithSurfaceInfo:(IOSurfaceRef)screenSurface rfbScreenInfo:(rfbScreenInfoPtr)rfbScreenInfo accelerator:(IOSurfaceAcceleratorRef)accelerator staticBuffer:(IOSurfaceRef)staticBuffer width:(size_t)width height:(size_t)height;
- (void)startFrameLoop;
- (void)stopFrameLoop;
@end

88
screendump/FrameUpdater.m Normal file
View File

@ -0,0 +1,88 @@
#import "FrameUpdater.h"
@implementation FrameUpdater {
// Process
NSOperationQueue *_q;
BOOL _updatingFrames;
uint32_t _lastUpdatedSeed;
NSTimer* _updateFrameTimer;
// Shared from ScreenDumpVNC
IOSurfaceRef _screenSurface;
rfbScreenInfoPtr _rfbScreenInfo;
IOSurfaceAcceleratorRef _accelerator;
IOSurfaceRef _staticBuffer;
size_t _width;
size_t _height;
BOOL _useCADisplayLink;
}
-(instancetype)initWithSurfaceInfo:(IOSurfaceRef)screenSurface rfbScreenInfo:(rfbScreenInfoPtr)rfbScreenInfo accelerator:(IOSurfaceAcceleratorRef)accelerator staticBuffer:(IOSurfaceRef)staticBuffer width:(size_t)width height:(size_t)height useCADisplayLink:(BOOL)useCADisplayLink {
if ((self = [super init])) {
_q = [[NSOperationQueue alloc] init];
_updatingFrames = NO;
_lastUpdatedSeed = 0;
_updateFrameTimer = nil;
_screenSurface = screenSurface;
_rfbScreenInfo = rfbScreenInfo;
_accelerator = accelerator;
_staticBuffer = staticBuffer;
_width = width;
_height = height;
_useCADisplayLink = useCADisplayLink;
}
return self;
}
-(void)_updateFrame {
if (!_updatingFrames) {
[self stopFrameLoop];
return;
}
// check if screen changed
uint32_t currentFrameSeed = IOSurfaceGetSeed(_screenSurface);
if (_lastUpdatedSeed != currentFrameSeed && rfbIsActive(_rfbScreenInfo)) {
_lastUpdatedSeed = currentFrameSeed;
[_q addOperationWithBlock: ^{
IOSurfaceAcceleratorTransferSurface(_accelerator, _screenSurface, _staticBuffer, NULL, NULL, NULL, NULL);
rfbMarkRectAsModified(_rfbScreenInfo, 0, 0, _width, _height);
}];
}
}
-(void)stopFrameLoop {
if (_updateFrameTimer == nil || ![_updateFrameTimer isValid]) return;
dispatch_async(dispatch_get_main_queue(), ^(void){
[_updateFrameTimer invalidate];
_updateFrameTimer = nil;
_updatingFrames = NO;
});
}
-(void)startFrameLoop {
[self stopFrameLoop];
_updatingFrames = YES;
if (_useCADisplayLink) {
CADisplayLink *displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(_updateFrame)];
displayLink.preferredFramesPerSecond = 60; // Adjust as needed
[displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
_updateFrameTimer = (NSTimer *)displayLink;
} else {
dispatch_async(dispatch_get_main_queue(), ^(void){
_updateFrameTimer = [NSTimer scheduledTimerWithTimeInterval:1/400 target:self selector:@selector(_updateFrame) userInfo:nil repeats:YES];
});
}
}
-(void)dealloc {
[self stopFrameLoop];
}
@end

30
screendump/IOHID.h Normal file
View File

@ -0,0 +1,30 @@
#import "./include/IOKit/hid/IOHIDEventTypes.h"
#import "./include/IOKit/hidsystem/IOHIDUsageTables.h"
typedef uint32_t IOHIDDigitizerTransducerType;
#ifdef __LP64__
typedef double IOHIDFloat;
#else
typedef float IOHIDFloat;
#endif
typedef UInt32 IOOptionBits;
typedef uint32_t IOHIDEventField;
typedef uint32_t IOHIDEventOptionBits;
typedef struct __IOHIDEvent *IOHIDEventRef;
typedef struct CF_BRIDGED_TYPE(id) __IOHIDEventSystemClient * IOHIDEventSystemClientRef;
IOHIDEventRef IOHIDEventCreateKeyboardEvent(
CFAllocatorRef allocator,
uint64_t time, uint16_t page, uint16_t usage,
Boolean down, IOHIDEventOptionBits flags
);
IOHIDEventRef IOHIDEventCreateDigitizerEvent(CFAllocatorRef allocator, uint64_t timeStamp, IOHIDDigitizerTransducerType type, uint32_t index, uint32_t identity, uint32_t eventMask, uint32_t buttonMask, IOHIDFloat x, IOHIDFloat y, IOHIDFloat z, IOHIDFloat tipPressure, IOHIDFloat barrelPressure, Boolean range, Boolean touch, IOOptionBits options);
IOHIDEventRef IOHIDEventCreateDigitizerFingerEvent(CFAllocatorRef allocator, uint64_t timeStamp, uint32_t index, uint32_t identity, uint32_t eventMask, IOHIDFloat x, IOHIDFloat y, IOHIDFloat z, IOHIDFloat tipPressure, IOHIDFloat twist, Boolean range, Boolean touch, IOOptionBits options);
IOHIDEventSystemClientRef IOHIDEventSystemClientCreate(CFAllocatorRef allocator);
void IOHIDEventAppendEvent(IOHIDEventRef parent, IOHIDEventRef child);
void IOHIDEventSetIntegerValue(IOHIDEventRef event, IOHIDEventField field, int value);
void IOHIDEventSetSenderID(IOHIDEventRef event, uint64_t sender);
void IOHIDEventSystemClientDispatchEvent(IOHIDEventSystemClientRef client, IOHIDEventRef event);
// void IOHIDEventSystemConnectionDispatchEvent(IOHIDEventSystemConnectionRef connection, IOHIDEventRef event);

View File

@ -0,0 +1,37 @@
#import <UIKit/UIKit.h>
typedef void *IOMobileFramebufferRef;
typedef void *IOSurfaceAcceleratorRef;
typedef struct __IOMobileFramebuffer *IOMobileFramebufferConnection;
extern CFStringRef kIOSurfaceMemoryRegion;
extern const CFStringRef kIOSurfaceIsGlobal;
extern void IOMobileFramebufferGetDisplaySize(IOMobileFramebufferRef connect, CGSize *size);
extern int IOSurfaceAcceleratorCreate(CFAllocatorRef allocator, int type, IOSurfaceAcceleratorRef *accel);
extern unsigned int IOSurfaceAcceleratorTransferSurface(IOSurfaceAcceleratorRef accelerator, IOSurfaceRef dest, IOSurfaceRef src, void *, void *, void *, void *);
extern kern_return_t IOMobileFramebufferSwapSetLayer(
IOMobileFramebufferRef fb,
int layer,
IOSurfaceRef buffer,
CGRect bounds,
CGRect frame,
int flags
);
typedef mach_port_t io_service_t;
typedef kern_return_t IOReturn;
typedef IOReturn IOMobileFramebufferReturn;
typedef io_service_t IOMobileFramebufferService;
extern void IOSurfaceFlushProcessorCaches(IOSurfaceRef buffer);
extern int IOSurfaceLock(IOSurfaceRef surface, uint32_t options, uint32_t *seed);
extern int IOSurfaceUnlock(IOSurfaceRef surface, uint32_t options, uint32_t *seed);
extern Boolean IOSurfaceIsInUse(IOSurfaceRef buffer);
extern CFMutableDictionaryRef IOServiceMatching(const char *name);
extern const mach_port_t kIOMasterPortDefault;
extern io_service_t IOServiceGetMatchingService(mach_port_t masterPort, CFDictionaryRef matching);
extern IOMobileFramebufferReturn IOMobileFramebufferGetLayerDefaultSurface(IOMobileFramebufferRef pointer, int surface, IOSurfaceRef *buffer);
extern IOMobileFramebufferReturn IOMobileFramebufferCopyLayerDisplayedSurface(IOMobileFramebufferRef pointer, int surface, IOSurfaceRef *buffer);
extern IOMobileFramebufferReturn IOMobileFramebufferOpen(IOMobileFramebufferService service, mach_port_t owningTask, unsigned int type, IOMobileFramebufferRef *pointer);
extern IOMobileFramebufferReturn IOMobileFramebufferGetMainDisplay(IOMobileFramebufferRef *pointer);
extern mach_port_t mach_task_self();

View File

@ -1,18 +1,23 @@
TARGET = iphone:14.4:10.0
export THEOS_PACKAGE_SCHEME = rootless
export ARCHS = arm64
export TARGET = iphone:16.5:14.0
export GO_EASY_ON_ME = 1
export COPYFILE_DISABLE=1
include $(THEOS)/makefiles/common.mk
TOOL_NAME = screendumpd
export ARCHS = arm64
$(TOOL_NAME)_ARCHS = arm64
$(TOOL_NAME)_FILES = main.mm
$(TOOL_NAME)_FILES = $(wildcard *.m)
$(TOOL_NAME)_FRAMEWORKS := IOSurface IOKit
$(TOOL_NAME)_PRIVATE_FRAMEWORKS := IOMobileFramebuffer IOSurface
$(TOOL_NAME)_OBJCFLAGS += -Ivncbuild/include -Iinclude
$(TOOL_NAME)_LDFLAGS += -Wl,-segalign,4000 -Lvncbuild/lib -lvncserver -lpng -llzo2 -ljpeg -lssl -lcrypto -lz
$(TOOL_NAME)_OBJCFLAGS += -I./vncbuild/include -Iinclude
$(TOOL_NAME)_LDFLAGS += -Wl,-segalign,4000 -L./vncbuild/lib -lvncserver -lpng -llzo2 -ljpeg -lssl -lcrypto -lz
$(TOOL_NAME)_CFLAGS = -w
$(TOOL_NAME)_CODESIGN_FLAGS = "-Sen.plist"
$(TOOL_NAME)_INSTALL_PATH = /usr/libexec
before-stage::
$(ECHO_NOTHING)find . -name '.DS_Store' -type f -delete$(ECHO_END)
$(ECHO_NOTHING)chmod 0775 layout/DEBIAN/*$(ECHO_END)
include $(THEOS_MAKE_PATH)/tool.mk

View File

@ -0,0 +1,12 @@
#import <Foundation/Foundation.h>
#import <rfb/rfb.h>
#define kVNCServerName "ScreenDumpVNC"
@interface ScreenDumpVNC : NSObject
+(void)load;
+(instancetype)sharedInstance;
-(rfbBool)handleVNCAuthorization:(rfbClientPtr)client data:(const char *)data size:(int)size;
-(size_t)width;
-(size_t)height;
@end

175
screendump/ScreenDumpVNC.m Normal file
View File

@ -0,0 +1,175 @@
#import "ScreenDumpVNC.h"
#import "FrameUpdater.h"
#import "utils.h"
#import "vnc.h"
#import <UIKit/UIKit.h>
#import <rfb/rfb.h>
#import "IOMobileFramebuffer.h"
@implementation ScreenDumpVNC {
int _prefsHeight;
int _prefsWidth;
bool _enabled;
NSString *_password;
rfbScreenInfoPtr _rfbScreenInfo;
bool _vncIsRunning;
// sent to FrameUpdater
IOSurfaceRef _screenSurface;
size_t _sizeImage;
IOSurfaceAcceleratorRef _accelerator;
IOSurfaceRef _staticBuffer;
size_t _width;
size_t _height;
FrameUpdater *_frameUpdater;
}
+(void)load {
ScreenDumpVNC* sharedInstance = [self sharedInstance];
if (![sharedInstance enabled]) return;
[sharedInstance setupScreenInfo];
[sharedInstance startVNCServer];
}
+(instancetype)sharedInstance {
static dispatch_once_t onceToken = 0;
__strong static ScreenDumpVNC* sharedInstance = nil;
dispatch_once(&onceToken, ^{
sharedInstance = [[self alloc] init];
});
return sharedInstance;
}
-(instancetype)init {
if ((self = [super init])) {
// TODO: init procedures
[self loadPrefs];
}
return self;
}
-(void)loadPrefs {
NSDictionary* defaults = getPrefsForAppId(@"ru.mostmodest.screendump");
NSNumber *height = [defaults objectForKey:@"height"];
_prefsHeight = height ? [height intValue] : 0;
NSNumber *width = [defaults objectForKey:@"width"];
_prefsWidth = width ? [width intValue] : 0;
NSNumber *enabled = [defaults objectForKey:@"enabled"];
_enabled = enabled ? [enabled boolValue] : NO;
_password = [defaults objectForKey:@"password"];
}
-(void)setupVNCAuthentication {
if (_rfbScreenInfo == nil) return;
_rfbScreenInfo->authPasswdData = nil;
if (_password && _password.length) {
_rfbScreenInfo->authPasswdData = (void *)_password;
}
}
-(void)startVNCServer {
if (_rfbScreenInfo == nil || _vncIsRunning == YES) return;
[self setupVNCAuthentication];
rfbInitServer(_rfbScreenInfo);
rfbRunEventLoop(_rfbScreenInfo, -1, YES);
[_frameUpdater startFrameLoop];
}
-(void)shutdownVNCServer {
// unused
if (_rfbScreenInfo == nil || _vncIsRunning == NO) return;
[_frameUpdater stopFrameLoop];
rfbShutdownServer(_rfbScreenInfo, YES);
}
-(void)setupScreenInfo {
size_t bytesPerPixel;
size_t bitsPerSample;
if (!_screenSurface) {
IOMobileFramebufferRef framebufferConnection;
IOSurfaceAcceleratorCreate(kCFAllocatorDefault, 0, &_accelerator);
IOMobileFramebufferGetMainDisplay(&framebufferConnection);
IOMobileFramebufferGetLayerDefaultSurface(framebufferConnection, 0, &_screenSurface);
if (_screenSurface == NULL) IOMobileFramebufferCopyLayerDisplayedSurface(framebufferConnection, 0, &_screenSurface);
_width = _prefsWidth == 0 ? IOSurfaceGetWidth(_screenSurface) : _prefsWidth;
_height = _prefsHeight == 0 ? IOSurfaceGetHeight(_screenSurface) : _prefsHeight;
_sizeImage = IOSurfaceGetAllocSize(_screenSurface);
// TODO: do these change at all? this might have been done for perf reasons
// bytesPerRow = IOSurfaceGetBytesPerRow(_screenSurface);
// pixelF = IOSurfaceGetPixelFormat(_screenSurface);
bytesPerPixel = 4; // IOSurfaceGetBytesPerElement(_screenSurface);
bitsPerSample = 8;
_staticBuffer = IOSurfaceCreate((CFDictionaryRef) [NSDictionary dictionaryWithObjectsAndKeys:
@"PurpleEDRAM", kIOSurfaceMemoryRegion,
// [NSNumber numberWithBool:YES], kIOSurfaceIsGlobal,
[NSNumber numberWithInt:bytesPerPixel*_width], kIOSurfaceBytesPerRow,
[NSNumber numberWithInt:bytesPerPixel], kIOSurfaceBytesPerElement,
[NSNumber numberWithInt:_width], kIOSurfaceWidth,
[NSNumber numberWithInt:_height], kIOSurfaceHeight,
[NSNumber numberWithInt:'BGRA'], kIOSurfacePixelFormat,
[NSNumber numberWithInt:(_width*_height*bytesPerPixel)], kIOSurfaceAllocSize,
nil]);
}
int argc = 1;
char *arg0 = strdup(kVNCServerName);
char *argv[] = {arg0, NULL};
int samplesPerPixel = 3;
_rfbScreenInfo = rfbGetScreen(&argc, argv, _width, _height, bitsPerSample, samplesPerPixel, bytesPerPixel);
_rfbScreenInfo->frameBuffer = (char *)IOSurfaceGetBaseAddress((IOSurfaceRef)CFRetain(_staticBuffer));
_rfbScreenInfo->serverFormat.redShift = bitsPerSample * 2;
_rfbScreenInfo->serverFormat.greenShift = bitsPerSample * 1;
_rfbScreenInfo->serverFormat.blueShift = bitsPerSample * 0;
_rfbScreenInfo->kbdAddEvent = &handleVNCKeyboard;
_rfbScreenInfo->ptrAddEvent = &handleVNCPointer;
_rfbScreenInfo->passwordCheck = &handleVNCAuthorization;
free(arg0);
NSDictionary* defaults = getPrefsForAppId(@"ru.mostmodest.screendump");
bool useCADisplayLink = [[defaults objectForKey:@"displaysync"]?:@NO boolValue];
_frameUpdater = [[FrameUpdater alloc] initWithSurfaceInfo:_screenSurface rfbScreenInfo:_rfbScreenInfo accelerator:_accelerator staticBuffer:_staticBuffer width:_width height:_height useCADisplayLink:useCADisplayLink];
}
-(rfbBool)handleVNCAuthorization:(rfbClientPtr)client data:(const char *)data size:(int)size {
NSString *password = (__bridge NSString *)(_rfbScreenInfo->authPasswdData);
if (!password) {
return TRUE;
}
if ([password length] == 0) {
return TRUE;
}
rfbEncryptBytes(client->authChallenge, (char *)[password UTF8String]);
bool good = (memcmp(client->authChallenge, data, size) == 0);
return good;
}
-(size_t)width {
return _width;
}
-(size_t)height {
return _height;
}
-(bool)enabled {
return _enabled;
}
@end

11
screendump/control Normal file
View File

@ -0,0 +1,11 @@
Package: ru.mostmodest.screendump
Name: screendump
Architecture: iphoneos-arm
Description: VNC for iOS15+ (rootless/Ellekit)
Maintainer: mostm
Author: cosmosgenius
Section: Tweaks
Conflicts: ru.mostmodest.screendump.lowframe
Depends: mobilesubstrate, preferenceloader
Icon: file:///Library/PreferenceLoader/Preferences/screendump/ScreenDump@2x.png
Version: 0.1.1

1
screendump/en.plist Normal file → Executable file
View File

@ -7,6 +7,7 @@
<string>IOSurfaceAcceleratorClient</string>
<string>IOMobileFramebufferUserClient</string>
<string>IOSurfaceRootUserClient</string>
<string>IOHIDLibUserClient</string>
</array>
<key>platform-application</key>
<true/>

View File

@ -1,12 +0,0 @@
Package: com.julioverne.screendump13
Name: screendump (iOS 13)
Depends: mobilesubstrate, preferenceloader
Conflicts: com.cosmosgenius.screendump
Architecture: iphoneos-arm
Description: VNC for ios
Maintainer: Julio
Author: julioverne, Sharat M R
Section: Tweaks
Version: 0.0.3e
Depiction: http://julioverne.github.io/description.html?id=com.julioverne.screendump13
Icon: file:///Library/PreferenceLoader/Preferences/screendump/ScreenDump@2x.png

View File

@ -1,6 +1,3 @@
#!/bin/sh
launchctl unload /Library/LaunchDaemons/com.julioverne.screendumpd.plist
launchctl load /Library/LaunchDaemons/com.julioverne.screendumpd.plist
exit 0;
launchctl load /var/jb/Library/LaunchDaemons/ru.mostmodest.screendumpd.plist 2> /dev/null
exit 0;

View File

@ -1,5 +1,2 @@
#!/bin/sh
launchctl unload /Library/LaunchDaemons/com.julioverne.screendumpd.plist
exit 0;
exit 0;

View File

@ -0,0 +1,3 @@
#!/bin/sh
launchctl unload /var/jb/Library/LaunchDaemons/ru.mostmodest.screendumpd.plist 2> /dev/null
exit 0;

3
screendump/layout/DEBIAN/prerm Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
launchctl unload /var/jb/Library/LaunchDaemons/ru.mostmodest.screendumpd.plist 2> /dev/null
exit 0;

View File

@ -1,16 +0,0 @@
<?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>Label</key>
<string>com.julioverne.screendumpd</string>
<key>ProgramArguments</key>
<array>
<string>/usr/libexec/screendumpd</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,26 @@
<?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>Label</key>
<string>ru.mostmodest.screendumpd</string>
<key>ProgramArguments</key>
<array>
<string>/var/jb/usr/libexec/screendumpd</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>SoftResourceLimits</key>
<dict>
<key>Core</key>
<integer>9223372036854775807</integer>
</dict>
<key>HardResourceLimits</key>
<dict>
<key>Core</key>
<integer>9223372036854775807</integer>
</dict>
</dict>
</plist>

View File

@ -21,27 +21,27 @@
</dict>
<dict>
<key>PostNotification</key>
<string>com.cosmosgenius.screendump/restart</string>
<string>ru.mostmodest.screendump/restart</string>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
<false/>
<key>defaults</key>
<string>com.cosmosgenius.screendump</string>
<string>ru.mostmodest.screendump</string>
<key>key</key>
<string>CCSisEnabled</string>
<string>enabled</string>
<key>label</key>
<string>Enabled</string>
</dict>
<dict>
<key>PostNotification</key>
<string>com.cosmosgenius.screendump/restart</string>
<string>ru.mostmodest.screendump/restart</string>
<key>cell</key>
<string>PSSecureEditTextCell</string>
<key>defaults</key>
<string>com.cosmosgenius.screendump</string>
<string>ru.mostmodest.screendump</string>
<key>key</key>
<string>CCSPassword</string>
<string>password</string>
<key>label</key>
<string>Password</string>
</dict>
@ -55,11 +55,11 @@
</dict>
<dict>
<key>PostNotification</key>
<string>com.cosmosgenius.screendump/restart</string>
<string>ru.mostmodest.screendump/restart</string>
<key>cell</key>
<string>PSEditTextCell</string>
<key>defaults</key>
<string>com.cosmosgenius.screendump</string>
<string>ru.mostmodest.screendump</string>
<key>key</key>
<string>height</string>
<key>label</key>
@ -69,11 +69,11 @@
</dict>
<dict>
<key>PostNotification</key>
<string>com.cosmosgenius.screendump/restart</string>
<string>ru.mostmodest.screendump/restart</string>
<key>cell</key>
<string>PSEditTextCell</string>
<key>defaults</key>
<string>com.cosmosgenius.screendump</string>
<string>ru.mostmodest.screendump</string>
<key>key</key>
<string>width</string>
<key>label</key>
@ -81,6 +81,26 @@
<key>isNumeric</key>
<true/>
</dict>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>label</key>
<string>Tuning</string>
</dict>
<dict>
<key>PostNotification</key>
<string>ru.mostmodest.screendump/restart</string>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
<false/>
<key>defaults</key>
<string>ru.mostmodest.screendump</string>
<key>key</key>
<string>displaysync</string>
<key>label</key>
<string>Update screen using CADisplayLink</string>
</dict>
</array>
</dict>
</plist>

17
screendump/main.m Normal file
View File

@ -0,0 +1,17 @@
#import <Foundation/Foundation.h>
#import <stdio.h>
#import "ScreenDumpVNC.h"
#import "utils.h"
#define kPreferencesNotify "ru.mostmodest.screendump/restart"
int main(int argc, char *argv[], char *envp[]) {
@autoreleasepool {
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)exitProcess, CFSTR(kPreferencesNotify), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
[ScreenDumpVNC load];
[[NSRunLoop currentRunLoop] run];
CFRunLoopRun();
return 0;
}
}

View File

@ -1,530 +0,0 @@
#include <errno.h>
#include <substrate.h>
#include <rfb/rfb.h>
#define kSettingsPath @"//var/mobile/Library/Preferences/com.cosmosgenius.screendump.plist"
static bool CCSisEnabled = true;
static NSString *CCSPassword = nil;
static rfbScreenInfoPtr screen;
static bool isVNCRunning;
// static NSCondition *condition_;
static NSLock *lock;
static size_t width;
static size_t height;
static size_t byte_per_pixel;
static size_t bytesPerRow;
static size_t pixelF;
static size_t bits_per_sample = 8;
static size_t size_image;
static size_t prefferH;
static size_t prefferW;
static CFTypeRef (*$GSSystemCopyCapability)(CFStringRef);
static CFTypeRef (*$GSSystemGetCapability)(CFStringRef);
static BOOL (*$MGGetBoolAnswer)(CFStringRef);
typedef void *IOMobileFramebufferRef;
typedef void *IOSurfaceAcceleratorRef;
typedef struct __IOMobileFramebuffer *IOMobileFramebufferConnection;
extern CFStringRef kIOSurfaceMemoryRegion;
extern const CFStringRef kIOSurfaceIsGlobal;
extern "C" void IOMobileFramebufferGetDisplaySize(IOMobileFramebufferRef connect, CGSize *size);
extern "C" int IOSurfaceAcceleratorCreate(CFAllocatorRef allocator, int type, IOSurfaceAcceleratorRef *accel);
extern "C" unsigned int IOSurfaceAcceleratorTransferSurface(IOSurfaceAcceleratorRef accelerator, IOSurfaceRef dest, IOSurfaceRef src, void *, void *, void *, void *);
extern "C" kern_return_t IOMobileFramebufferSwapSetLayer(
IOMobileFramebufferRef fb,
int layer,
IOSurfaceRef buffer,
CGRect bounds,
CGRect frame,
int flags
);
typedef mach_port_t io_service_t;
typedef kern_return_t IOReturn;
typedef IOReturn IOMobileFramebufferReturn;
typedef io_service_t IOMobileFramebufferService;
extern "C" mach_port_t mach_task_self(void);
extern "C" void IOSurfaceFlushProcessorCaches(IOSurfaceRef buffer);
extern "C" int IOSurfaceLock(IOSurfaceRef surface, uint32_t options, uint32_t *seed);
extern "C" int IOSurfaceUnlock(IOSurfaceRef surface, uint32_t options, uint32_t *seed);
extern "C" Boolean IOSurfaceIsInUse(IOSurfaceRef buffer);
extern "C" CFMutableDictionaryRef IOServiceMatching(const char *name);
extern "C" const mach_port_t kIOMasterPortDefault;
extern "C" io_service_t IOServiceGetMatchingService(mach_port_t masterPort, CFDictionaryRef matching);
extern "C" IOMobileFramebufferReturn IOMobileFramebufferGetLayerDefaultSurface(IOMobileFramebufferRef pointer, int surface, IOSurfaceRef *buffer);
extern "C" IOMobileFramebufferReturn IOMobileFramebufferOpen(IOMobileFramebufferService service, mach_port_t owningTask, unsigned int type, IOMobileFramebufferRef *pointer);
extern "C" IOMobileFramebufferReturn IOMobileFramebufferGetMainDisplay(IOMobileFramebufferRef *pointer);
static IOSurfaceAcceleratorRef accelerator;
static IOSurfaceRef static_buffer;
static void VNCSettings(bool shouldStart, NSString *password);
static void VNCUpdateRunState(bool shouldStart);
static void handleVNCKeyboard(rfbBool down, rfbKeySym key, rfbClientPtr client);
static void handleVNCPointer(int buttons, int x, int y, rfbClientPtr client);
static BOOL isLoopFrame;
static rfbBool VNCCheck(rfbClientPtr client, const char *data, int size)
{
NSString *password = reinterpret_cast<NSString *>(screen->authPasswdData);
if(!password) {
return TRUE;
}
if ([password length] == 0) {
return TRUE;
}
NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
rfbEncryptBytes(client->authChallenge, const_cast<char *>([password UTF8String]));
bool good(memcmp(client->authChallenge, data, size) == 0);
[pool release];
return good;
}
static IOSurfaceRef screenSurface = NULL;
static IOMobileFramebufferRef framebufferConnection = NULL;
@interface FrameUpdater : NSObject
@property (nonatomic, retain) NSTimer* myTimer;
- (void)startFrameLoop;
- (void)stopFrameLoop;
@end
static void VNCSetup()
{
if(!screenSurface) {
IOSurfaceAcceleratorCreate(kCFAllocatorDefault, 0, &accelerator);
IOMobileFramebufferGetMainDisplay(&framebufferConnection);
IOMobileFramebufferGetLayerDefaultSurface(framebufferConnection, 0, &screenSurface);
//CGSize size;
//IOMobileFramebufferGetDisplaySize(framebufferConnection, &size);
//width = size.width/2;
//height = size.height/2;
width = prefferW==0?IOSurfaceGetWidth(screenSurface):prefferW;
height = prefferW==0?IOSurfaceGetHeight(screenSurface):prefferH;
size_image = IOSurfaceGetAllocSize(screenSurface);
bytesPerRow = IOSurfaceGetBytesPerRow(screenSurface);
pixelF = IOSurfaceGetPixelFormat(screenSurface);
byte_per_pixel = 4;//IOSurfaceGetBytesPerElement(screenSurface);
bits_per_sample = 8;
static_buffer = IOSurfaceCreate((CFDictionaryRef) [NSDictionary dictionaryWithObjectsAndKeys:
@"PurpleEDRAM", kIOSurfaceMemoryRegion,
//[NSNumber numberWithBool:YES], kIOSurfaceIsGlobal,
[NSNumber numberWithInt:byte_per_pixel*width], kIOSurfaceBytesPerRow,
[NSNumber numberWithInt:byte_per_pixel], kIOSurfaceBytesPerElement,
[NSNumber numberWithInt:width], kIOSurfaceWidth,
[NSNumber numberWithInt:height], kIOSurfaceHeight,
[NSNumber numberWithInt:'BGRA'], kIOSurfacePixelFormat,
[NSNumber numberWithInt:(width*height*byte_per_pixel)], kIOSurfaceAllocSize,
nil]);
}
int argc(1);
char *arg0(strdup("ScreenDumpVNC"));
char *argv[] = {arg0, NULL};
screen = rfbGetScreen(&argc, argv, width, height, bits_per_sample, 3, byte_per_pixel);
screen->frameBuffer = reinterpret_cast<char *>(IOSurfaceGetBaseAddress((IOSurfaceRef)CFRetain(static_buffer)));
screen->serverFormat.redShift = bits_per_sample * 2;
screen->serverFormat.greenShift = bits_per_sample * 1;
screen->serverFormat.blueShift = bits_per_sample * 0;
screen->kbdAddEvent = &handleVNCKeyboard;
screen->ptrAddEvent = &handleVNCPointer;
screen->passwordCheck = &VNCCheck;
free(arg0);
VNCUpdateRunState(CCSisEnabled);
}
static void VNCSettings(bool shouldStart, NSString* password)
{
CCSisEnabled = shouldStart;
if(password) {
CCSPassword = password;
}
NSString *sEnabled = CCSisEnabled ? @"YES": @"NO";
VNCUpdateRunState(CCSisEnabled);
}
static void VNCUpdateRunState(bool shouldStart)
{
if(screen == NULL) {
return;
}
if(CCSPassword && CCSPassword.length) {
screen->authPasswdData = (void *) CCSPassword;
} else {
screen->authPasswdData = NULL;
}
if(shouldStart == isVNCRunning) {
return;
}
if(shouldStart) {
rfbInitServer(screen);
rfbRunEventLoop(screen, -1, true);
isLoopFrame = YES;
[[FrameUpdater shared] startFrameLoop];
} else {
isLoopFrame = NO;
[[FrameUpdater shared] stopFrameLoop];
rfbShutdownServer(screen, true);
}
isVNCRunning = shouldStart;
}
static void loadPrefs(void)
{
@autoreleasepool {
NSDictionary* defaults = nil;
CFStringRef appID = CFSTR("com.cosmosgenius.screendump");
CFArrayRef keyList = CFPreferencesCopyKeyList(appID, CFSTR("mobile"), kCFPreferencesAnyHost);
if(keyList) {
defaults = (NSDictionary *)CFPreferencesCopyMultiple(keyList, appID, CFSTR("mobile"), kCFPreferencesAnyHost)?:@{};
CFRelease(keyList);
}
prefferH = [[defaults objectForKey:@"height"]?:@(0) intValue];
prefferW = [[defaults objectForKey:@"width"]?:@(0) intValue];
BOOL isEnabled = [[defaults objectForKey:@"CCSisEnabled"]?:@NO boolValue];
NSString *password = [defaults objectForKey:@"CCSPassword"];
VNCSettings(isEnabled, password);
}
}
static uint32_t oldSeed;
@implementation FrameUpdater
{
NSOperationQueue *q;
}
@synthesize myTimer;
+ (id)shared
{
static __strong FrameUpdater* initFrame;
if(!initFrame) {
initFrame = [[[self class] alloc] init];
}
return initFrame;
}
- (id)init
{
self = [super init];
q = [[NSOperationQueue alloc] init];
return self;
}
- (void)_upFrameLoop
{
if(isLoopFrame && CCSisEnabled) {
//check if screen changed
uint32_t newSeed = IOSurfaceGetSeed(screenSurface);
if(oldSeed != newSeed && rfbIsActive(screen)) {
oldSeed = newSeed;
[q addOperationWithBlock: ^{
IOSurfaceAcceleratorTransferSurface(accelerator, screenSurface, static_buffer, NULL, NULL, NULL, NULL);
rfbMarkRectAsModified(screen, 0, 0, width, height);
}];
}
} else {
[self stopFrameLoop];
}
}
- (void)stopFrameLoop
{
if(myTimer && [myTimer isValid]) {
dispatch_async(dispatch_get_main_queue(), ^(void){
[myTimer invalidate];
});
}
}
- (void)startFrameLoop
{
if(size_image == 0) {
VNCSetup();
}
[self stopFrameLoop];
dispatch_async(dispatch_get_main_queue(), ^(void){
myTimer = [NSTimer scheduledTimerWithTimeInterval:1/400 target:self selector:@selector(_upFrameLoop) userInfo:nil repeats:YES];
});
}
-(void)dealloc
{
[self stopFrameLoop];
}
@end
static void restartServer()
{
exit(0);
}
int main(int argc, const char *argv[])
{
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)loadPrefs, CFSTR("com.cosmosgenius.screendump/preferences.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)restartServer, CFSTR("com.cosmosgenius.screendump/restart"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
loadPrefs();
VNCSetup();
//VNCBlack();
[[NSRunLoop currentRunLoop] run];
return EXIT_SUCCESS;
}
#include <mach/mach.h>
#include <mach/mach_time.h>
#include <rfb/rfb.h>
#include <rfb/keysym.h>
#include "./include/IOKit/hid/IOHIDEventTypes.h"
#include "./include/IOKit/hidsystem/IOHIDUsageTables.h"
typedef uint32_t IOHIDDigitizerTransducerType;
#ifdef __LP64__
typedef double IOHIDFloat;
#else
typedef float IOHIDFloat;
#endif
typedef UInt32 IOOptionBits;
typedef uint32_t IOHIDEventField;
extern "C" {
typedef uint32_t IOHIDEventOptionBits;
typedef struct __IOHIDEvent *IOHIDEventRef;
typedef struct CF_BRIDGED_TYPE(id) __IOHIDEventSystemClient * IOHIDEventSystemClientRef;
IOHIDEventRef IOHIDEventCreateKeyboardEvent(
CFAllocatorRef allocator,
uint64_t time, uint16_t page, uint16_t usage,
Boolean down, IOHIDEventOptionBits flags
);
IOHIDEventRef IOHIDEventCreateDigitizerEvent(CFAllocatorRef allocator, uint64_t timeStamp, IOHIDDigitizerTransducerType type, uint32_t index, uint32_t identity, uint32_t eventMask, uint32_t buttonMask, IOHIDFloat x, IOHIDFloat y, IOHIDFloat z, IOHIDFloat tipPressure, IOHIDFloat barrelPressure, Boolean range, Boolean touch, IOOptionBits options);
IOHIDEventRef IOHIDEventCreateDigitizerFingerEvent(CFAllocatorRef allocator, uint64_t timeStamp, uint32_t index, uint32_t identity, uint32_t eventMask, IOHIDFloat x, IOHIDFloat y, IOHIDFloat z, IOHIDFloat tipPressure, IOHIDFloat twist, Boolean range, Boolean touch, IOOptionBits options);
IOHIDEventSystemClientRef IOHIDEventSystemClientCreate(CFAllocatorRef allocator);
void IOHIDEventAppendEvent(IOHIDEventRef parent, IOHIDEventRef child);
void IOHIDEventSetIntegerValue(IOHIDEventRef event, IOHIDEventField field, int value);
void IOHIDEventSetSenderID(IOHIDEventRef event, uint64_t sender);
void IOHIDEventSystemClientDispatchEvent(IOHIDEventSystemClientRef client, IOHIDEventRef event);
// void IOHIDEventSystemConnectionDispatchEvent(IOHIDEventSystemConnectionRef connection, IOHIDEventRef event);
}
static void VNCPointerNew(int buttons, int x, int y, CGPoint location, int diff, bool twas, bool tis);
static void SendHIDEvent(IOHIDEventRef event)
{
static IOHIDEventSystemClientRef client_(NULL);
if (client_ == NULL) {
client_ = IOHIDEventSystemClientCreate(kCFAllocatorDefault);
}
IOHIDEventSetSenderID(event, 0x8000000817319372);
IOHIDEventSystemClientDispatchEvent(client_, event);
CFRelease(event);
}
static void VNCKeyboard(rfbBool down, rfbKeySym key, rfbClientPtr client)
{
uint16_t usage;
switch (key) {
case XK_exclam: case XK_1: usage = kHIDUsage_Keyboard1; break;
case XK_at: case XK_2: usage = kHIDUsage_Keyboard2; break;
case XK_numbersign: case XK_3: usage = kHIDUsage_Keyboard3; break;
case XK_dollar: case XK_4: usage = kHIDUsage_Keyboard4; break;
case XK_percent: case XK_5: usage = kHIDUsage_Keyboard5; break;
case XK_asciicircum: case XK_6: usage = kHIDUsage_Keyboard6; break;
case XK_ampersand: case XK_7: usage = kHIDUsage_Keyboard7; break;
case XK_asterisk: case XK_8: usage = kHIDUsage_Keyboard8; break;
case XK_parenleft: case XK_9: usage = kHIDUsage_Keyboard9; break;
case XK_parenright: case XK_0: usage = kHIDUsage_Keyboard0; break;
case XK_A: case XK_a: usage = kHIDUsage_KeyboardA; break;
case XK_B: case XK_b: usage = kHIDUsage_KeyboardB; break;
case XK_C: case XK_c: usage = kHIDUsage_KeyboardC; break;
case XK_D: case XK_d: usage = kHIDUsage_KeyboardD; break;
case XK_E: case XK_e: usage = kHIDUsage_KeyboardE; break;
case XK_F: case XK_f: usage = kHIDUsage_KeyboardF; break;
case XK_G: case XK_g: usage = kHIDUsage_KeyboardG; break;
case XK_H: case XK_h: usage = kHIDUsage_KeyboardH; break;
case XK_I: case XK_i: usage = kHIDUsage_KeyboardI; break;
case XK_J: case XK_j: usage = kHIDUsage_KeyboardJ; break;
case XK_K: case XK_k: usage = kHIDUsage_KeyboardK; break;
case XK_L: case XK_l: usage = kHIDUsage_KeyboardL; break;
case XK_M: case XK_m: usage = kHIDUsage_KeyboardM; break;
case XK_N: case XK_n: usage = kHIDUsage_KeyboardN; break;
case XK_O: case XK_o: usage = kHIDUsage_KeyboardO; break;
case XK_P: case XK_p: usage = kHIDUsage_KeyboardP; break;
case XK_Q: case XK_q: usage = kHIDUsage_KeyboardQ; break;
case XK_R: case XK_r: usage = kHIDUsage_KeyboardR; break;
case XK_S: case XK_s: usage = kHIDUsage_KeyboardS; break;
case XK_T: case XK_t: usage = kHIDUsage_KeyboardT; break;
case XK_U: case XK_u: usage = kHIDUsage_KeyboardU; break;
case XK_V: case XK_v: usage = kHIDUsage_KeyboardV; break;
case XK_W: case XK_w: usage = kHIDUsage_KeyboardW; break;
case XK_X: case XK_x: usage = kHIDUsage_KeyboardX; break;
case XK_Y: case XK_y: usage = kHIDUsage_KeyboardY; break;
case XK_Z: case XK_z: usage = kHIDUsage_KeyboardZ; break;
case XK_underscore: case XK_minus: usage = kHIDUsage_KeyboardHyphen; break;
case XK_plus: case XK_equal: usage = kHIDUsage_KeyboardEqualSign; break;
case XK_braceleft: case XK_bracketleft: usage = kHIDUsage_KeyboardOpenBracket; break;
case XK_braceright: case XK_bracketright: usage = kHIDUsage_KeyboardCloseBracket; break;
case XK_bar: case XK_backslash: usage = kHIDUsage_KeyboardBackslash; break;
case XK_colon: case XK_semicolon: usage = kHIDUsage_KeyboardSemicolon; break;
case XK_quotedbl: case XK_apostrophe: usage = kHIDUsage_KeyboardQuote; break;
case XK_asciitilde: case XK_grave: usage = kHIDUsage_KeyboardGraveAccentAndTilde; break;
case XK_less: case XK_comma: usage = kHIDUsage_KeyboardComma; break;
case XK_greater: case XK_period: usage = kHIDUsage_KeyboardPeriod; break;
case XK_question: case XK_slash: usage = kHIDUsage_KeyboardSlash; break;
case XK_Return: usage = kHIDUsage_KeyboardReturnOrEnter; break;
case XK_BackSpace: usage = kHIDUsage_KeyboardDeleteOrBackspace; break;
case XK_Tab: usage = kHIDUsage_KeyboardTab; break;
case XK_space: usage = kHIDUsage_KeyboardSpacebar; break;
case XK_Shift_L: usage = kHIDUsage_KeyboardLeftShift; break;
case XK_Shift_R: usage = kHIDUsage_KeyboardRightShift; break;
case XK_Control_L: usage = kHIDUsage_KeyboardLeftControl; break;
case XK_Control_R: usage = kHIDUsage_KeyboardRightControl; break;
case XK_Meta_L: usage = kHIDUsage_KeyboardLeftAlt; break;
case XK_Meta_R: usage = kHIDUsage_KeyboardRightAlt; break;
case XK_Alt_L: usage = kHIDUsage_KeyboardLeftGUI; break;
case XK_Alt_R: usage = kHIDUsage_KeyboardRightGUI; break;
case XK_Up: usage = kHIDUsage_KeyboardUpArrow; break;
case XK_Down: usage = kHIDUsage_KeyboardDownArrow; break;
case XK_Left: usage = kHIDUsage_KeyboardLeftArrow; break;
case XK_Right: usage = kHIDUsage_KeyboardRightArrow; break;
case XK_Home: case XK_Begin: usage = kHIDUsage_KeyboardHome; break;
case XK_End: usage = kHIDUsage_KeyboardEnd; break;
case XK_Page_Up: usage = kHIDUsage_KeyboardPageUp; break;
case XK_Page_Down: usage = kHIDUsage_KeyboardPageDown; break;
default: return;
}
SendHIDEvent(IOHIDEventCreateKeyboardEvent(kCFAllocatorDefault, mach_absolute_time(), kHIDPage_KeyboardOrKeypad, usage, down, 0));
}
static int buttons_;
static int x_, y_;
static void VNCPointer(int buttons, int x, int y, rfbClientPtr client) {
// if (ratio_ == 0)
// return;
CGPoint location = {static_cast<CGFloat>(x), static_cast<CGFloat>(y)};
// if (width_ > height_) {
// int t(x);
// x = height_ - 1 - y;
// y = t;
// if (!iPad1_) {
// x = height_ - 1 - x;
// y = width_ - 1 - y;
// }
// }
// x /= ratio_;
// y /= ratio_;
// x_ = x; y_ = y;
int diff = buttons_ ^ buttons;
bool twas((buttons_ & 0x1) != 0);
bool tis((buttons & 0x1) != 0);
buttons_ = buttons;
rfbDefaultPtrAddEvent(buttons, x, y, client);
// if (Ashikase(false)) {
// AshikaseSendEvent(x, y, buttons);
// return;
// }
return VNCPointerNew(buttons, x, y, location, diff, twas, tis);
}
static void VNCPointerNew(int buttons, int x, int y, CGPoint location, int diff, bool twas, bool tis) {
if ((diff & 0x10) != 0)
SendHIDEvent(IOHIDEventCreateKeyboardEvent(kCFAllocatorDefault, mach_absolute_time(), kHIDPage_Telephony, kHIDUsage_Tfon_Flash, (buttons & 0x10) != 0, 0));
if ((diff & 0x04) != 0)
SendHIDEvent(IOHIDEventCreateKeyboardEvent(kCFAllocatorDefault, mach_absolute_time(), kHIDPage_Consumer, kHIDUsage_Csmr_Menu, (buttons & 0x04) != 0, 0));
if ((diff & 0x02) != 0)
SendHIDEvent(IOHIDEventCreateKeyboardEvent(kCFAllocatorDefault, mach_absolute_time(), kHIDPage_Consumer, kHIDUsage_Csmr_Power, (buttons & 0x02) != 0, 0));
uint32_t handm;
uint32_t fingerm;
if (twas == 0 && tis == 1) {
handm = kIOHIDDigitizerEventRange | kIOHIDDigitizerEventTouch | kIOHIDDigitizerEventIdentity;
fingerm = kIOHIDDigitizerEventRange | kIOHIDDigitizerEventTouch;
} else if (twas == 1 && tis == 1) {
handm = kIOHIDDigitizerEventPosition;
fingerm = kIOHIDDigitizerEventPosition;
} else if (twas == 1 && tis == 0) {
handm = kIOHIDDigitizerEventRange | kIOHIDDigitizerEventTouch | kIOHIDDigitizerEventIdentity | kIOHIDDigitizerEventPosition;
fingerm = kIOHIDDigitizerEventRange | kIOHIDDigitizerEventTouch;
} else return;
// XXX: avoid division in VNCPointer()
// x *= ratio_;
// y *= ratio_;
IOHIDFloat xf(x);
IOHIDFloat yf(y);
xf /= width;
yf /= height;
IOHIDEventRef hand(IOHIDEventCreateDigitizerEvent(kCFAllocatorDefault, mach_absolute_time(), kIOHIDDigitizerTransducerTypeHand, 1<<22, 1, handm, 0, xf, yf, 0, 0, 0, 0, 0, 0));
IOHIDEventSetIntegerValue(hand, kIOHIDEventFieldIsBuiltIn, true);
IOHIDEventSetIntegerValue(hand, kIOHIDEventFieldDigitizerIsDisplayIntegrated, true);
IOHIDEventRef finger(IOHIDEventCreateDigitizerFingerEvent(kCFAllocatorDefault, mach_absolute_time(), 3, 2, fingerm, xf, yf, 0, 0, 0, tis, tis, 0));
IOHIDEventAppendEvent(hand, finger);
CFRelease(finger);
SendHIDEvent(hand);
}
static void handleVNCKeyboard(rfbBool down, rfbKeySym key, rfbClientPtr client) {
VNCKeyboard(down, key, client);
}
static void handleVNCPointer(int buttons, int x, int y, rfbClientPtr client) {
VNCPointer(buttons, x, y, client);
}

7
screendump/update_repo.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
rm -rf packages/*
export FINALPACKAGE=1
make clean package
# ssh mostm@denver.lan "rm -rf /home/mostm/projects/repo/data/secure/debs/ru.mostmodest.screendump_*"
scp packages/* mostm@denver.lan:/home/mostm/projects/repo/data/secure/debs/
ssh mostm@denver.lan "bash /home/mostm/projects/repo/data/secure/updaterepo.sh"

4
screendump/utils.h Normal file
View File

@ -0,0 +1,4 @@
#import <Foundation/Foundation.h>
extern NSDictionary* getPrefsForAppId(NSString *appID);
extern void exitProcess();

15
screendump/utils.m Normal file
View File

@ -0,0 +1,15 @@
#import "utils.h"
NSDictionary* getPrefsForAppId(NSString *appID) {
NSDictionary* defaults = nil;
CFArrayRef keyList = CFPreferencesCopyKeyList((CFStringRef)appID, CFSTR("mobile"), kCFPreferencesAnyHost);
if (keyList) {
defaults = (NSDictionary *)CFPreferencesCopyMultiple(keyList, (CFStringRef)appID, CFSTR("mobile"), kCFPreferencesAnyHost) ? : @{};
CFRelease(keyList);
}
return defaults;
}
void exitProcess() {
exit(0);
}

8
screendump/vnc.h Normal file
View File

@ -0,0 +1,8 @@
#import <Foundation/Foundation.h>
#import <rfb/rfb.h>
#import <rfb/keysym.h>
#import "IOHID.h"
extern void handleVNCKeyboard(rfbBool down, rfbKeySym key, rfbClientPtr client);
extern void handleVNCPointer(int buttons, int x, int y, rfbClientPtr client);
extern rfbBool handleVNCAuthorization(rfbClientPtr client, const char *data, int size);

195
screendump/vnc.m Normal file
View File

@ -0,0 +1,195 @@
#import "vnc.h"
#import "ScreenDumpVNC.h"
static IOHIDEventSystemClientRef client_ = nil;
void SendHIDEvent(IOHIDEventRef event) {
if (client_ == nil) {
client_ = IOHIDEventSystemClientCreate(kCFAllocatorDefault);
}
IOHIDEventSetSenderID(event, 0x8000000817319372);
IOHIDEventSystemClientDispatchEvent(client_, event);
CFRelease(event);
}
rfbBool handleVNCAuthorization(rfbClientPtr client, const char *data, int size) {
ScreenDumpVNC *sharedInstance = [ScreenDumpVNC sharedInstance];
return [sharedInstance handleVNCAuthorization:client data:data size:size];
}
void VNCKeyboard(rfbBool down, rfbKeySym key, rfbClientPtr client) {
uint16_t usage;
switch (key) {
case XK_exclam: case XK_1: usage = kHIDUsage_Keyboard1; break;
case XK_at: case XK_2: usage = kHIDUsage_Keyboard2; break;
case XK_numbersign: case XK_3: usage = kHIDUsage_Keyboard3; break;
case XK_dollar: case XK_4: usage = kHIDUsage_Keyboard4; break;
case XK_percent: case XK_5: usage = kHIDUsage_Keyboard5; break;
case XK_asciicircum: case XK_6: usage = kHIDUsage_Keyboard6; break;
case XK_ampersand: case XK_7: usage = kHIDUsage_Keyboard7; break;
case XK_asterisk: case XK_8: usage = kHIDUsage_Keyboard8; break;
case XK_parenleft: case XK_9: usage = kHIDUsage_Keyboard9; break;
case XK_parenright: case XK_0: usage = kHIDUsage_Keyboard0; break;
case XK_A: case XK_a: usage = kHIDUsage_KeyboardA; break;
case XK_B: case XK_b: usage = kHIDUsage_KeyboardB; break;
case XK_C: case XK_c: usage = kHIDUsage_KeyboardC; break;
case XK_D: case XK_d: usage = kHIDUsage_KeyboardD; break;
case XK_E: case XK_e: usage = kHIDUsage_KeyboardE; break;
case XK_F: case XK_f: usage = kHIDUsage_KeyboardF; break;
case XK_G: case XK_g: usage = kHIDUsage_KeyboardG; break;
case XK_H: case XK_h: usage = kHIDUsage_KeyboardH; break;
case XK_I: case XK_i: usage = kHIDUsage_KeyboardI; break;
case XK_J: case XK_j: usage = kHIDUsage_KeyboardJ; break;
case XK_K: case XK_k: usage = kHIDUsage_KeyboardK; break;
case XK_L: case XK_l: usage = kHIDUsage_KeyboardL; break;
case XK_M: case XK_m: usage = kHIDUsage_KeyboardM; break;
case XK_N: case XK_n: usage = kHIDUsage_KeyboardN; break;
case XK_O: case XK_o: usage = kHIDUsage_KeyboardO; break;
case XK_P: case XK_p: usage = kHIDUsage_KeyboardP; break;
case XK_Q: case XK_q: usage = kHIDUsage_KeyboardQ; break;
case XK_R: case XK_r: usage = kHIDUsage_KeyboardR; break;
case XK_S: case XK_s: usage = kHIDUsage_KeyboardS; break;
case XK_T: case XK_t: usage = kHIDUsage_KeyboardT; break;
case XK_U: case XK_u: usage = kHIDUsage_KeyboardU; break;
case XK_V: case XK_v: usage = kHIDUsage_KeyboardV; break;
case XK_W: case XK_w: usage = kHIDUsage_KeyboardW; break;
case XK_X: case XK_x: usage = kHIDUsage_KeyboardX; break;
case XK_Y: case XK_y: usage = kHIDUsage_KeyboardY; break;
case XK_Z: case XK_z: usage = kHIDUsage_KeyboardZ; break;
case XK_underscore: case XK_minus: usage = kHIDUsage_KeyboardHyphen; break;
case XK_plus: case XK_equal: usage = kHIDUsage_KeyboardEqualSign; break;
case XK_braceleft: case XK_bracketleft: usage = kHIDUsage_KeyboardOpenBracket; break;
case XK_braceright: case XK_bracketright: usage = kHIDUsage_KeyboardCloseBracket; break;
case XK_bar: case XK_backslash: usage = kHIDUsage_KeyboardBackslash; break;
case XK_colon: case XK_semicolon: usage = kHIDUsage_KeyboardSemicolon; break;
case XK_quotedbl: case XK_apostrophe: usage = kHIDUsage_KeyboardQuote; break;
case XK_asciitilde: case XK_grave: usage = kHIDUsage_KeyboardGraveAccentAndTilde; break;
case XK_less: case XK_comma: usage = kHIDUsage_KeyboardComma; break;
case XK_greater: case XK_period: usage = kHIDUsage_KeyboardPeriod; break;
case XK_question: case XK_slash: usage = kHIDUsage_KeyboardSlash; break;
case XK_Return: usage = kHIDUsage_KeyboardReturnOrEnter; break;
case XK_BackSpace: usage = kHIDUsage_KeyboardDeleteOrBackspace; break;
case XK_Tab: usage = kHIDUsage_KeyboardTab; break;
case XK_space: usage = kHIDUsage_KeyboardSpacebar; break;
case XK_Shift_L: usage = kHIDUsage_KeyboardLeftShift; break;
case XK_Shift_R: usage = kHIDUsage_KeyboardRightShift; break;
case XK_Control_L: usage = kHIDUsage_KeyboardLeftGUI; break;
case XK_Control_R: usage = kHIDUsage_KeyboardRightGUI; break;
case XK_Meta_L: usage = kHIDUsage_KeyboardLeftControl; break;
case XK_Meta_R: usage = kHIDUsage_KeyboardRightControl; break;
case XK_Alt_L: usage = kHIDUsage_KeyboardLeftAlt; break;
case XK_Alt_R: usage = kHIDUsage_KeyboardRightAlt; break;
case XK_Up: usage = kHIDUsage_KeyboardUpArrow; break;
case XK_Down: usage = kHIDUsage_KeyboardDownArrow; break;
case XK_Left: usage = kHIDUsage_KeyboardLeftArrow; break;
case XK_Right: usage = kHIDUsage_KeyboardRightArrow; break;
case XK_Home: case XK_Begin: usage = kHIDUsage_KeyboardHome; break;
case XK_End: usage = kHIDUsage_KeyboardEnd; break;
case XK_Page_Up: usage = kHIDUsage_KeyboardPageUp; break;
case XK_Page_Down: usage = kHIDUsage_KeyboardPageDown; break;
default: return;
}
SendHIDEvent(IOHIDEventCreateKeyboardEvent(kCFAllocatorDefault, mach_absolute_time(), kHIDPage_KeyboardOrKeypad, usage, down, 0));
}
void VNCPointerNew(int buttons, int x, int y, CGPoint location, int diff, bool twas, bool tis) {
if ((diff & 0x10) != 0)
SendHIDEvent(IOHIDEventCreateKeyboardEvent(kCFAllocatorDefault, mach_absolute_time(), kHIDPage_Telephony, kHIDUsage_Tfon_Flash, (buttons & 0x10) != 0, 0));
if ((diff & 0x04) != 0)
SendHIDEvent(IOHIDEventCreateKeyboardEvent(kCFAllocatorDefault, mach_absolute_time(), kHIDPage_Consumer, kHIDUsage_Csmr_Menu, (buttons & 0x04) != 0, 0));
if ((diff & 0x02) != 0)
SendHIDEvent(IOHIDEventCreateKeyboardEvent(kCFAllocatorDefault, mach_absolute_time(), kHIDPage_Consumer, kHIDUsage_Csmr_Power, (buttons & 0x02) != 0, 0));
uint32_t handm;
uint32_t fingerm;
if (twas == 0 && tis == 1) {
handm = kIOHIDDigitizerEventRange | kIOHIDDigitizerEventTouch | kIOHIDDigitizerEventIdentity;
fingerm = kIOHIDDigitizerEventRange | kIOHIDDigitizerEventTouch;
} else if (twas == 1 && tis == 1) {
handm = kIOHIDDigitizerEventPosition;
fingerm = kIOHIDDigitizerEventPosition;
} else if (twas == 1 && tis == 0) {
handm = kIOHIDDigitizerEventRange | kIOHIDDigitizerEventTouch | kIOHIDDigitizerEventIdentity | kIOHIDDigitizerEventPosition;
fingerm = kIOHIDDigitizerEventRange | kIOHIDDigitizerEventTouch;
} else return;
// XXX: avoid division in VNCPointer()
// x *= ratio_;
// y *= ratio_;
IOHIDFloat xf = (IOHIDFloat)x;
IOHIDFloat yf = (IOHIDFloat)y;
ScreenDumpVNC *sharedInstance = [ScreenDumpVNC sharedInstance];
xf /= [sharedInstance width];
yf /= [sharedInstance height];
IOHIDEventRef hand = IOHIDEventCreateDigitizerEvent(kCFAllocatorDefault, mach_absolute_time(), kIOHIDDigitizerTransducerTypeHand, 1<<22, 1, handm, 0, xf, yf, 0, 0, 0, 0, 0, 0);
IOHIDEventSetIntegerValue(hand, kIOHIDEventFieldIsBuiltIn, true);
IOHIDEventSetIntegerValue(hand, kIOHIDEventFieldDigitizerIsDisplayIntegrated, true);
IOHIDEventRef finger = IOHIDEventCreateDigitizerFingerEvent(kCFAllocatorDefault, mach_absolute_time(), 3, 2, fingerm, xf, yf, 0, 0, 0, tis, tis, 0);
IOHIDEventAppendEvent(hand, finger);
CFRelease(finger);
SendHIDEvent(hand);
}
static int buttons_;
void VNCPointer(int buttons, int x, int y, rfbClientPtr client) {
// if (ratio_ == 0)
// return;
CGPoint location = {(CGFloat)x, (CGFloat)y};
// if (width_ > height_) {
// int t(x);
// x = height_ - 1 - y;
// y = t;
// if (!iPad1_) {
// x = height_ - 1 - x;
// y = width_ - 1 - y;
// }
// }
// x /= ratio_;
// y /= ratio_;
// x_ = x; y_ = y;
int diff = buttons_ ^ buttons;
bool twas = (buttons_ & 0x1) != 0;
bool tis = (buttons & 0x1) != 0;
buttons_ = buttons;
rfbDefaultPtrAddEvent(buttons, x, y, client);
// if (Ashikase(false)) {
// AshikaseSendEvent(x, y, buttons);
// return;
// }
return VNCPointerNew(buttons, x, y, location, diff, twas, tis);
}
void handleVNCKeyboard(rfbBool down, rfbKeySym key, rfbClientPtr client) {
VNCKeyboard(down, key, client);
}
void handleVNCPointer(int buttons, int x, int y, rfbClientPtr client) {
VNCPointer(buttons, x, y, client);
}

BIN
screendumpLowFrame/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,15 @@
INSTALL_TARGET_PROCESSES = SpringBoard
include $(THEOS)/makefiles/common.mk
TWEAK_NAME = screendumpbb
$(TWEAK_NAME)_FILES = Tweak.xm
#$(TWEAK_NAME)_ARCHS = arm64
#$(TWEAK_NAME)_FRAMEWORKS := IOSurface IOKit
#$(TWEAK_NAME)_PRIVATE_FRAMEWORKS := IOMobileFramebuffer IOSurface
#ADDITIONAL_OBJCFLAGS += -I../vncbuild/include -Iinclude
#ADDITIONAL_LDFLAGS += -Wl,-segalign,4000 -L../vncbuild/lib -lvncserver -lpng -llzo2 -ljpeg -lssl -lcrypto -lz
#ADDITIONAL_CFLAGS = -w
include $(THEOS_MAKE_PATH)/tweak.mk

View File

@ -1,11 +1,10 @@
#include <errno.h>
#include <substrate.h>
#include <rfb/rfb.h>
#import <errno.h>
#import <substrate.h>
#import <notify.h>
#import <UIKit/UIKit.h>
#import <rootless.h>
#undef NSLog
#define kSettingsPath @"/var/mobile/Library/Preferences/ru.mostmodest.screendump.plist"
extern "C" UIImage* _UICreateScreenUIImage();
@ -17,13 +16,32 @@ static BOOL isBlackScreen;
@end
@implementation CapturerScreen
- (id)init
-(id)init
{
NSLog(@"screendump bb: CapturerScreen init");
self = [super init];
// [self start];
return self;
}
- (unsigned char *)pixelBRGABytesFromImageRef:(CGImageRef)imageRef
+(void)load
{
CapturerScreen* instance = [self sharedInstance];
[instance start];
}
+(instancetype)sharedInstance
{
static dispatch_once_t onceToken = 0;
__strong static CapturerScreen* sharedInstance = nil;
dispatch_once(&onceToken, ^{
sharedInstance = [[self alloc] init];
});
return sharedInstance;
}
-(unsigned char *)pixelBRGABytesFromImageRef:(CGImageRef)imageRef
{
NSUInteger iWidth = CGImageGetWidth(imageRef);
@ -51,17 +69,18 @@ static BOOL isBlackScreen;
return imageBytes;
}
- (unsigned char *)pixelBRGABytesFromImage:(UIImage *)image
-(unsigned char *)pixelBRGABytesFromImage:(UIImage *)image
{
return [self pixelBRGABytesFromImageRef:image.CGImage];
}
- (void)start
-(void)start
{
dispatch_async(dispatch_get_main_queue(), ^(void){
NSLog(@"screendumpbb: setting capture timer every 0.4f");
[NSTimer scheduledTimerWithTimeInterval:0.4f target:self selector:@selector(capture) userInfo:nil repeats:YES];
});
}
- (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize
-(UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize
{
//UIGraphicsBeginImageContext(newSize);
UIGraphicsBeginImageContextWithOptions(newSize, NO, 1.0f);
@ -71,15 +90,19 @@ static BOOL isBlackScreen;
[image release];
return newImage;
}
- (void)capture
-(void)capture
{
NSLog(@"screendumpbb: capture");
@autoreleasepool {
NSLog(@"screendumpbb: capture - isBlackScreen: %d", isBlackScreen);
NSLog(@"screendumpbb: capture - isEnabled: %d", isEnabled);
if(isBlackScreen || !isEnabled) {
return;
}
UIImage* image = _UICreateScreenUIImage();
NSLog(@"screendumpbb: capture - got frame, now resizing...");
CGSize newS = CGSizeMake(image.size.width, image.size.height);
@ -94,19 +117,24 @@ static BOOL isBlackScreen;
size_t size = iWidth * iHeight * iBytesPerPixel;
unsigned char * bytes = [self pixelBRGABytesFromImageRef:imageRef];
NSLog(@"screendumpbb: capture - resize complete, got bytes");
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
@autoreleasepool {
NSLog(@"screendumpbb: capture - writing buffer...");
NSData *imageData = [NSData dataWithBytesNoCopy:bytes length:size freeWhenDone:YES];
[imageData writeToFile:@"//tmp/screendump_Buff.tmp" atomically:YES];
[@{@"width":@(iWidth), @"height":@(iHeight), @"size":@(size),} writeToFile:@"//tmp/screendump_Info.tmp" atomically:YES];
notify_post("com.julioverne.screendump/frameChanged");
NSLog(@"screendumpbb: capture - notifying daemon");
notify_post("ru.mostmodest.screendump/frameChanged");
}
});
}
}
@end
/*
%hook SpringBoard
- (void)applicationDidFinishLaunching:(id)application
{
@ -115,7 +143,7 @@ static BOOL isBlackScreen;
[cap start];
}
%end
*/
static void screenDisplayStatus(CFNotificationCenterRef center, void* observer, CFStringRef name, const void* object, CFDictionaryRef userInfo)
{
@ -129,21 +157,29 @@ static void screenDisplayStatus(CFNotificationCenterRef center, void* observer,
} else {
isBlackScreen = NO;
}
NSLog(@"screendumpbb: screenDisplayStatus - isBlackScreen: %d", isBlackScreen);
}
static void loadPrefs(CFNotificationCenterRef center, void* observer, CFStringRef name, const void* object, CFDictionaryRef userInfo)
{
NSLog(@"screendumpbb: loadPrefs");
@autoreleasepool {
NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:@"com.cosmosgenius.screendump"];
NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:@"ru.mostmodest.screendump"];
isEnabled = [[defaults objectForKey:@"CCSisEnabled"]?:@NO boolValue];
NSLog(@"screendumpbb: loadPrefs - isEnabled: %d", isEnabled);
}
}
%ctor
{
NSLog(@"screendumpbb: ctor");
isEnabled = NO;
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, screenDisplayStatus, CFSTR("com.apple.iokit.hid.displayStatus"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
NSLog(@"screendumpbb: ctor 1");
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, loadPrefs, CFSTR("com.cosmosgenius.screendump/preferences.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, loadPrefs, CFSTR("ru.mostmodest.screendump/preferences.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
NSLog(@"screendumpbb: ctor 2");
loadPrefs(NULL, NULL, NULL, NULL, NULL);
NSLog(@"screendumpbb: ctor 3");
}

View File

@ -0,0 +1,5 @@
{
Filter = {
Bundles = ( "com.apple.springboard" );
};
}

View File

@ -1,41 +1,14 @@
TARGET = iphone:16.5:14.0
export THEOS_PACKAGE_SCHEME = rootless
export ARCHS = arm64 arm64e
export TARGET = iphone:16.5:14.0
export GO_EASY_ON_ME = 1
export COPYFILE_DISABLE=1
include $(THEOS)/makefiles/common.mk
ifeq ($(THEOS_PACKAGE_SCHEME),rootless)
PACKAGE_BUILDNAME := rootless
else
PACKAGE_BUILDNAME := rootful
endif
TOOL_NAME = screendumpd
$(TOOL_NAME)_FILES = main.mm
export ARCHS = arm64
$(TOOL_NAME)_ARCHS = arm64
ARCHS = arm64
$(TOOL_NAME)_VALID_ARCHS = arm64
$(TOOL_NAME)_FRAMEWORKS := IOSurface IOKit
$(TOOL_NAME)_PRIVATE_FRAMEWORKS := IOMobileFramebuffer IOSurface
$(TOOL_NAME)_OBJCFLAGS += -Ivncbuild/include -Iinclude
$(TOOL_NAME)_LDFLAGS += -Wl,-segalign,4000 -Lvncbuild/lib -lvncserver -lpng -llzo2 -ljpeg -lssl -lcrypto -lz
$(TOOL_NAME)_CFLAGS = -w
$(TOOL_NAME)_CODESIGN_FLAGS = "-Sen.plist"
$(TOOL_NAME)_INSTALL_PATH = /usr/libexec
include $(THEOS_MAKE_PATH)/tool.mk
SUBPROJECTS += hooks
SUBPROJECTS += Capturer Server
include $(THEOS_MAKE_PATH)/aggregate.mk
ifeq ($(THEOS_PACKAGE_SCHEME),rootless)
after-screendumpd-stage::
$(ECHO_NOTHING) rm $(THEOS_STAGING_DIR)/Library/LaunchDaemons/com.julioverne.screendumpd.plist$(ECHO_END)
$(ECHO_NOTHING) mv $(THEOS_STAGING_DIR)/Library/LaunchDaemons/com.julioverne.screendumpd.rootless.plist $(THEOS_STAGING_DIR)/Library/LaunchDaemons/com.julioverne.screendumpd.plist$(ECHO_END)
$(ECHO_NOTHING)$(FAKEROOT) chown root:wheel $(THEOS_STAGING_DIR)/Library/LaunchDaemons/com.julioverne.screendumpd.plist$(ECHO_END)
else
after-screendumpd-stage::
$(ECHO_NOTHING) rm $(THEOS_STAGING_DIR)/Library/LaunchDaemons/com.julioverne.screendumpd.rootless.plist$(ECHO_END)
$(ECHO_NOTHING)$(FAKEROOT) chown root:wheel $(THEOS_STAGING_DIR)/Library/LaunchDaemons/com.julioverne.screendumpd.plist$(ECHO_END)
endif
$(ECHO_NOTHING)$(FAKEROOT) chown root:wheel $(THEOS_STAGING_DIR)/Library/LaunchDaemons/ru.mostmodest.screendumpd.plist$(ECHO_END)

View File

@ -0,0 +1,17 @@
include $(THEOS)/makefiles/common.mk
TOOL_NAME = screendumpd
$(TOOL_NAME)_FILES = main.mm
$(TOOL_NAME)_ARCHS = arm64
$(TOOL_NAME)_FRAMEWORKS := IOSurface IOKit
$(TOOL_NAME)_PRIVATE_FRAMEWORKS := IOMobileFramebuffer IOSurface
$(TOOL_NAME)_OBJCFLAGS += -I../vncbuild/include -Iinclude
$(TOOL_NAME)_LDFLAGS += -Wl,-segalign,4000 -L../vncbuild/lib -lvncserver -lpng -llzo2 -ljpeg -lssl -lcrypto -lz
$(TOOL_NAME)_INSTALL_PATH = /usr/libexec
$(TOOL_NAME)_CFLAGS = -w
$(TOOL_NAME)_CODESIGN_FLAGS = -Sentitlements.plist
include $(THEOS_MAKE_PATH)/tool.mk
after-screendumpd-stage::
$(ECHO_NOTHING)$(FAKEROOT) chown root:wheel $(THEOS_STAGING_DIR)/Library/LaunchDaemons/ru.mostmodest.screendumpd.plist$(ECHO_END)

View File

@ -1,4 +1,3 @@
<?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>
@ -47,4 +46,4 @@
<key>com.apple.private.security.disk-device-access</key>
<true/>
</dict>
</plist>
</plist>

View File

@ -1,10 +1,12 @@
#include <errno.h>
#include <substrate.h>
#include <rfb/rfb.h>
#import <errno.h>
#import <substrate.h>
#import <rfb/rfb.h>
#import <Foundation/Foundation.h>
#import <IOSurface/IOSurfaceRef.h>
#import <rootless.h>
#define kSettingsPath @"/var/mobile/Library/Preferences/ru.mostmodest.screendump.plist"
static bool CCSisEnabled = true;
static NSString *CCSPassword = nil;
static rfbScreenInfoPtr screen;
@ -45,7 +47,7 @@ typedef mach_port_t io_service_t;
typedef kern_return_t IOReturn;
typedef IOReturn IOMobileFramebufferReturn;
typedef io_service_t IOMobileFramebufferService;
extern "C" mach_port_t mach_task_self(void);
extern "C" mach_port_t mach_task_self();
extern "C" void IOSurfaceFlushProcessorCaches(IOSurfaceRef buffer);
extern "C" int IOSurfaceLock(IOSurfaceRef surface, uint32_t options, uint32_t *seed);
extern "C" int IOSurfaceUnlock(IOSurfaceRef surface, uint32_t options, uint32_t *seed);
@ -64,6 +66,7 @@ static void handleVNCPointer(int buttons, int x, int y, rfbClientPtr client);
static rfbBool VNCCheck(rfbClientPtr client, const char *data, int size)
{
NSLog(@"screendumpd: VNCCheck");
NSString *password = reinterpret_cast<NSString *>(screen->authPasswdData);
if(!password) {
return TRUE;
@ -80,6 +83,7 @@ static rfbBool VNCCheck(rfbClientPtr client, const char *data, int size)
static void VNCSetup()
{
NSLog(@"screendumpd: VNCSetup");
@autoreleasepool {
NSDictionary* frameInfo = [NSDictionary dictionaryWithContentsOfFile:@"//tmp/screendump_Info.tmp"]?:@{};
width = [frameInfo[@"width"]?:@(0) intValue];
@ -114,43 +118,59 @@ static void VNCSettings(bool shouldStart, NSString* password)
CCSPassword = password;
}
NSString *sEnabled = CCSisEnabled ? @"YES": @"NO";
NSLog(@"screendumpd: VNCSettings - is enabled - %@", sEnabled);
NSLog(@"screendumpd: VNCSettings - password - %@", CCSPassword);
VNCUpdateRunState(CCSisEnabled);
}
static void VNCUpdateRunState(bool shouldStart)
{
NSLog(@"screendumpd: VNCUpdateRunState");
if(screen == NULL) {
NSLog(@"screendumpd: VNCUpdateRunState - screen is nil");
return;
}
if(CCSPassword && CCSPassword.length) {
NSLog(@"screendumpd: VNCUpdateRunState - configured password");
screen->authPasswdData = (void *) CCSPassword;
} else {
NSLog(@"screendumpd: VNCUpdateRunState - set password to nil");
screen->authPasswdData = NULL;
}
NSLog(@"screendumpd: VNCUpdateRunState - vnc is running?");
if(shouldStart == isVNCRunning) {
NSLog(@"screendumpd: VNCUpdateRunState - vnc is running");
return;
}
NSLog(@"screendumpd: VNCUpdateRunState - vnc is not running");
if(shouldStart) {
NSLog(@"screendumpd: VNCUpdateRunState - rfbInitServer");
rfbInitServer(screen);
NSLog(@"screendumpd: VNCUpdateRunState - rfbRunEventLoop");
rfbRunEventLoop(screen, -1, true);
} else {
NSLog(@"screendumpd: VNCUpdateRunState - rfbShutdownServer");
rfbShutdownServer(screen, true);
}
isVNCRunning = shouldStart;
NSLog(@"screendumpd: VNCUpdateRunState - isVNCRunning: %d", isVNCRunning);
}
static void loadPrefs(void)
{
NSLog(@"screendumpd: load prefs");
@autoreleasepool {
NSDictionary* defaults = nil;
CFStringRef appID = CFSTR("com.cosmosgenius.screendump");
CFStringRef appID = CFSTR("ru.mostmodest.screendump");
CFArrayRef keyList = CFPreferencesCopyKeyList(appID, CFSTR("mobile"), kCFPreferencesAnyHost);
if(keyList) {
defaults = (NSDictionary *)CFPreferencesCopyMultiple(keyList, appID, CFSTR("mobile"), kCFPreferencesAnyHost)?:@{};
CFRelease(keyList);
}
BOOL isEnabled = [[defaults objectForKey:@"CCSisEnabled"]?:@NO boolValue];
NSLog(@"screendumpd: prefs - is enabled - %d", isEnabled);
NSString *password = [defaults objectForKey:@"CCSPassword"];
NSLog(@"screendumpd: prefs - password - %@", password);
VNCSettings(isEnabled, password);
}
}
@ -162,22 +182,28 @@ static void VNCBlack()
static void upFrame()
{
NSLog(@"screendumpd: upFrame");
if(size_image == 0) {
NSLog(@"screendumpd: upFrame - size_image = 0");
VNCSetup();
}
if(screen == NULL) {
NSLog(@"screendumpd: upFrame - screen is nil");
return;
}
@try {
@autoreleasepool {
NSLog(@"screendumpd: upFrame - updating buffer...");
NSData *data = [[NSFileManager defaultManager] contentsAtPath:@"//tmp/screendump_Buff.tmp"];
memcpy(screen->frameBuffer, (void*)data.bytes, data.length);
NSLog(@"screendumpd: upFrame - updated buffer");
}
}@catch(NSException*e){
}
NSLog(@"screendumpd: upFrame - requesting to send a new frame");
rfbMarkRectAsModified(screen, 0, 0, width, height);
}
@ -186,34 +212,40 @@ extern "C" IOMobileFramebufferReturn IOMobileFramebufferGetMainDisplay(IOMobileF
int main(int argc, const char *argv[])
{
isVNCRunning = NO;
NSLog(@"screendumpd: main start");
CFNotificationCenterAddObserver(
CFNotificationCenterGetDarwinNotifyCenter(),
NULL, (CFNotificationCallback)loadPrefs,
CFSTR("com.cosmosgenius.screendump/preferences.changed"),
CFSTR("ru.mostmodest.screendump/preferences.changed"),
NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
CFNotificationCenterAddObserver(
CFNotificationCenterGetDarwinNotifyCenter(),
NULL, (CFNotificationCallback)upFrame,
CFSTR("com.julioverne.screendump/frameChanged"),
CFSTR("ru.mostmodest.screendump/frameChanged"),
NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
loadPrefs();
NSLog(@"screendumpd: main - vnc setup");
VNCSetup();
//VNCBlack();
NSLog(@"screendumpd: main - load prefs");
loadPrefs();
NSLog(@"screendumpd: main - loop");
[[NSRunLoop currentRunLoop] run];
NSLog(@"screendumpd: main - end");
return EXIT_SUCCESS;
}
#include <mach/mach.h>
#include <mach/mach_time.h>
#include <rfb/rfb.h>
#include <rfb/keysym.h>
#include "./include/IOKit/hid/IOHIDEventTypes.h"
#include "./include/IOKit/hidsystem/IOHIDUsageTables.h"
#import <mach/mach.h>
#import <mach/mach_time.h>
#import <rfb/rfb.h>
#import <rfb/keysym.h>
#import "./include/IOKit/hid/IOHIDEventTypes.h"
#import "./include/IOKit/hidsystem/IOHIDUsageTables.h"
typedef uint32_t IOHIDDigitizerTransducerType;

View File

@ -1,11 +0,0 @@
#!/bin/bash
echo "Building package for ROOTFUL Jailbreak"
make clean
make package FINALPACKAGE=1
echo "Building package for ROOTLESS Jailbreak"
make clean
make package FINALPACKAGE=1 THEOS_PACKAGE_SCHEME=rootless

View File

@ -0,0 +1,11 @@
Package: ru.mostmodest.screendump.lowframe
Name: screendumpLowFrame
Architecture: iphoneos-arm
Description: VNC for iOS15+ (rootless/Ellekit)
Maintainer: mostm
Author: julioverne
Section: Tweaks
Conflicts: ru.mostmodest.screendump
Depends: mobilesubstrate, preferenceloader
Icon: file:///Library/PreferenceLoader/Preferences/screendump/ScreenDump@2x.png
Version: 0.0.5

View File

@ -1,18 +0,0 @@
TARGET = iphone:16.5:14.0
include $(THEOS)/makefiles/common.mk
TWEAK_NAME = screendumpbb
$(TWEAK_NAME)_FILES = Tweak.xm
$(TWEAK_NAME)_FRAMEWORKS := IOSurface IOKit
$(TWEAK_NAME)_PRIVATE_FRAMEWORKS := IOMobileFramebuffer IOSurface
ADDITIONAL_OBJCFLAGS += -I../vncbuild/include -Iinclude
ADDITIONAL_LDFLAGS += -Wl,-segalign,4000
ADDITIONAL_CFLAGS = -w
export ARCHS = arm64
$(TWEAK_NAME)_ARCHS = arm64
include $(THEOS_MAKE_PATH)/tweak.mk

View File

@ -1,7 +0,0 @@
{
Filter = {
Executables = (
"SpringBoard",
);
};
}

View File

@ -1,9 +0,0 @@
Package: com.cosmosgenius.screendump13
Name: screendump
Depends: preferenceloader
Architecture: iphoneos-arm
Description: VNC for ios
Maintainer: Sharat M R <cosmosgenius@gmail.com>
Author: Sharat M R <cosmosgenius@gmail.com>
Section: Tweaks
Version: 0.0.4

View File

@ -1,11 +1,9 @@
#!/bin/sh
if [ -L "/var/jb" ]; then
launchctl unload /var/jb/Library/LaunchDaemons/com.julioverne.screendumpd.plist
launchctl load /var/jb/Library/LaunchDaemons/com.julioverne.screendumpd.plist
launchctl load /var/jb/Library/LaunchDaemons/ru.mostmodest.screendumpd.plist
else
launchctl unload /Library/LaunchDaemons/com.julioverne.screendumpd.plist
launchctl load /Library/LaunchDaemons/com.julioverne.screendumpd.plist
launchctl load /Library/LaunchDaemons/ru.mostmodest.screendumpd.plist
fi
exit 0;

View File

@ -0,0 +1,9 @@
#!/bin/sh
if [ -L "/var/jb" ]; then
launchctl unload /var/jb/Library/LaunchDaemons/ru.mostmodest.screendumpd.plist
else
launchctl unload /Library/LaunchDaemons/ru.mostmodest.screendumpd.plist
fi
exit 0;

View File

@ -1,9 +1,9 @@
#!/bin/bash
#!/bin/sh
if [ -L "/var/jb" ]; then
launchctl unload /var/jb/Library/LaunchDaemons/com.julioverne.screendumpd.plist
launchctl unload /var/jb/Library/LaunchDaemons/ru.mostmodest.screendumpd.plist
else
launchctl unload /Library/LaunchDaemons/com.julioverne.screendumpd.plist
launchctl unload /Library/LaunchDaemons/ru.mostmodest.screendumpd.plist
fi
exit 0;
exit 0;

View File

@ -1,16 +0,0 @@
<?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>Label</key>
<string>com.julioverne.screendumpd</string>
<key>ProgramArguments</key>
<array>
<string>/usr/libexec/screendumpd</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>

View File

@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.julioverne.screendumpd</string>
<string>ru.mostmodest.screendumpd</string>
<key>ProgramArguments</key>
<array>
<string>/var/jb/usr/libexec/screendumpd</string>

View File

@ -1,7 +0,0 @@
{
Filter = {
Executables = (
"SpringBoard",
);
};
}

View File

@ -0,0 +1,7 @@
#!/bin/sh
rm -rf packages/*
export FINALPACKAGE=1
make clean package
# ssh mostm@denver.lan "rm -rf /home/mostm/projects/repo/data/secure/debs/ru.mostmodest.screendump_*"
scp packages/* mostm@denver.lan:/home/mostm/projects/repo/data/secure/debs/
ssh mostm@denver.lan "bash /home/mostm/projects/repo/data/secure/updaterepo.sh"

2
screendumpLowFrame/vncbuild/include/rfb/rfbclient.h Normal file → Executable file
View File

@ -81,7 +81,7 @@
#define TUNNEL_PORT_OFFSET 5500
#define SERVER_PORT_OFFSET 5900
#define DEFAULT_SSH_CMD "/usr/bin/ssh"
#define DEFAULT_SSH_CMD "/var/jb/usr/bin/ssh"
#define DEFAULT_TUNNEL_CMD \
(DEFAULT_SSH_CMD " -f -L %L:localhost:%R %H sleep 20")
#define DEFAULT_VIA_CMD \