From 0d76400bf1b5fec8b729a76dfd47151d78db3933 Mon Sep 17 00:00:00 2001 From: ethanarbuckle Date: Sat, 23 May 2020 10:30:10 -0700 Subject: [PATCH] create vncserver daemon --- .gitignore | 3 + .../IOMobileFramebuffer.tbd | 67 +++++++++++++++++++ vncforios.xcodeproj/project.pbxproj | 4 +- vncserverd/Makefile | 14 ++++ vncserverd/control | 10 +++ vncserverd/layout/DEBIAN/postinst | 3 + .../com.ethanarbuckle.vncserverd.plist | 23 +++++++ vncserverd/memory_limit.m | 10 +++ 8 files changed, 132 insertions(+), 2 deletions(-) create mode 100755 privateframeworks/IOMobileFramebuffer.framework/IOMobileFramebuffer.tbd create mode 100644 vncserverd/Makefile create mode 100644 vncserverd/control create mode 100755 vncserverd/layout/DEBIAN/postinst create mode 100644 vncserverd/layout/Library/LaunchDaemons/com.ethanarbuckle.vncserverd.plist create mode 100644 vncserverd/memory_limit.m diff --git a/.gitignore b/.gitignore index 4dd49b9..53371bf 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ *.xcuserdatad/* /vncforios.xcodeproj/project.xcworkspace/xcuserdata /vncforios.xcodeproj/project.xcworkspace/contents.xcworkspacedata +*.theos +vncserverd/packages/* +vncforios.xcodeproj/xcuserdata diff --git a/privateframeworks/IOMobileFramebuffer.framework/IOMobileFramebuffer.tbd b/privateframeworks/IOMobileFramebuffer.framework/IOMobileFramebuffer.tbd new file mode 100755 index 0000000..fa387de --- /dev/null +++ b/privateframeworks/IOMobileFramebuffer.framework/IOMobileFramebuffer.tbd @@ -0,0 +1,67 @@ +--- +archs: [ armv7, armv7s, arm64 ] +platform: ios +install-name: /System/Library/PrivateFrameworks/IOMobileFramebuffer.framework/IOMobileFramebuffer +current-version: 1 +compatibility-version: 1 +exports: + - archs: [ armv7, armv7s, arm64 ] + symbols: [ _IOMobileFrameBufferEnableDebugTracing, _IOMobileFrameBufferEnableVBLTraces, + _IOMobileFrameBufferGetDebugTraces, _IOMobileFrameBufferGetMirroringCapability, + _IOMobileFrameBufferPrintDebugTraces, _IOMobileFrameBufferSetLogLevel, + _IOMobileFrameBufferprintDisplayRegs, _IOMobileFramebufferALSSEnableWindows, + _IOMobileFramebufferALSSGetRGBCoeffs, _IOMobileFramebufferALSSGetWindows, + _IOMobileFramebufferALSSGetWindowsSums, _IOMobileFramebufferALSSSetRGBCoeffs, + _IOMobileFramebufferALSSSetWindows, _IOMobileFramebufferChangeFrameInfo, + _IOMobileFramebufferCopyProperty, _IOMobileFramebufferCreateDisplayList, + _IOMobileFramebufferCreateStatistics, _IOMobileFramebufferDisableCRCNotifications, + _IOMobileFramebufferDisableHotPlugDetectNotifications, _IOMobileFramebufferDisablePowerNotifications, + _IOMobileFramebufferDisableVSyncNotifications, _IOMobileFramebufferEnableCRCNotifications, + _IOMobileFramebufferEnableDisableDithering, _IOMobileFramebufferEnableDisableVideoPowerSavings, + _IOMobileFramebufferEnableHotPlugDetectNotifications, _IOMobileFramebufferEnableMirroring, + _IOMobileFramebufferEnablePowerNotifications, _IOMobileFramebufferEnableStatistics, + _IOMobileFramebufferEnableVSyncNotifications, _IOMobileFramebufferFactoryPortal, + _IOMobileFramebufferFrameInfo, _IOMobileFramebufferGetBlock, + _IOMobileFramebufferGetCRCNotifyMessageCount, _IOMobileFramebufferGetCRCRunLoopSource, + _IOMobileFramebufferGetCanvasSizes, _IOMobileFramebufferGetColorRemapMode, + _IOMobileFramebufferGetCurrentAbsoluteTime, _IOMobileFramebufferGetDigitalOutState, + _IOMobileFramebufferGetDisplayArea, _IOMobileFramebufferGetDisplaySize, + _IOMobileFramebufferGetDotPitch, _IOMobileFramebufferGetDriverInstance, + _IOMobileFramebufferGetFrameworkInfo, _IOMobileFramebufferGetGammaTable, + _IOMobileFramebufferGetHDCPAuthenticationProtocol, _IOMobileFramebufferGetHDCPDownstreamState, + _IOMobileFramebufferGetHDCPRunLoopSource, _IOMobileFramebufferGetHotPlugRunLoopSource, + _IOMobileFramebufferGetID, _IOMobileFramebufferGetLayerDefaultSurface, + _IOMobileFramebufferGetMainDisplay, _IOMobileFramebufferGetMatrix, _IOMobileFramebufferGetMirrorError, + _IOMobileFramebufferGetRunLoopSource, _IOMobileFramebufferGetSecondaryDisplay, + _IOMobileFramebufferGetServiceObject, _IOMobileFramebufferGetSupportedDigitalOutModes, + _IOMobileFramebufferGetTypeID, _IOMobileFramebufferGetVSyncRunLoopSource, + _IOMobileFramebufferGetWirelessSurface, _IOMobileFramebufferGetWirelessSurfaceWithOptions, + _IOMobileFramebufferHDCPGetReply, _IOMobileFramebufferHDCPSendRequest, + _IOMobileFramebufferInstallVirtualDisplay, _IOMobileFramebufferInstallVirtualDisplays, + _IOMobileFramebufferIsMainDisplay, _IOMobileFramebufferKernelTests, _IOMobileFramebufferOpen, + _IOMobileFramebufferOpenByName, _IOMobileFramebufferReadyForSwap, + _IOMobileFramebufferRequestPowerChange, _IOMobileFramebufferSPLCGetBrightness, + _IOMobileFramebufferSPLCSetBrightness, _IOMobileFramebufferScheduleWithDispatchQueue, + _IOMobileFramebufferSetBlock, _IOMobileFramebufferSetBrightnessCorrection, + _IOMobileFramebufferSetCanvasSize, _IOMobileFramebufferSetColorRemapMode, + _IOMobileFramebufferSetContrast, _IOMobileFramebufferSetDebugFlags, + _IOMobileFramebufferSetDigitalOutMode, _IOMobileFramebufferSetDisplayDevice, + _IOMobileFramebufferSetDisplaySize, _IOMobileFramebufferSetFlags, _IOMobileFramebufferSetGammaTable, + _IOMobileFramebufferSetIdleBuffer, _IOMobileFramebufferSetLine21Data, _IOMobileFramebufferSetMatrix, + _IOMobileFramebufferSetMirrorContentRegion, _IOMobileFramebufferSetParameter, + _IOMobileFramebufferSetRenderingAngle, _IOMobileFramebufferSetTVOutMode, + _IOMobileFramebufferSetTVOutSignalType, _IOMobileFramebufferSetUnderrunColor, + _IOMobileFramebufferSetVideoDACGain, _IOMobileFramebufferSetWSSInfo, + _IOMobileFramebufferSetWhiteOnBlackMode, _IOMobileFramebufferSupportedFrameInfo, + _IOMobileFramebufferSwapActiveRegion, _IOMobileFramebufferSwapBegin, _IOMobileFramebufferSwapCancel, + _IOMobileFramebufferSwapDirtyRegion, _IOMobileFramebufferSwapEnd, + _IOMobileFramebufferSwapSetBackgroundColor, _IOMobileFramebufferSwapSetColorMatrix, + _IOMobileFramebufferSwapSetContributingImageSources, _IOMobileFramebufferSwapSetGammaTable, + _IOMobileFramebufferSwapSetLayer, _IOMobileFramebufferSwapSetTimestamp, + _IOMobileFramebufferSwapSetTimestamps, _IOMobileFramebufferSwapSetUISubRegion, + _IOMobileFramebufferSwapSetVideoDestEdgeAlpha, _IOMobileFramebufferSwapSignal, + _IOMobileFramebufferSwapSubtitleRegion, _IOMobileFramebufferSwapUIEdgeBlendMode, + _IOMobileFramebufferSwapWait, _IOMobileFramebufferSwapWaitWithTimeout, + _IOMobileFramebufferSwapWorkaroundSettings, _IOMobileFramebufferUnscheduleFromDispatchQueue, + _IOMobileFramebufferWaitSurface, _kIOMFB_TotalSwaps, _kIOMFB_TotalVBLs, _main ] +... diff --git a/vncforios.xcodeproj/project.pbxproj b/vncforios.xcodeproj/project.pbxproj index b63c6c3..307dccc 100644 --- a/vncforios.xcodeproj/project.pbxproj +++ b/vncforios.xcodeproj/project.pbxproj @@ -412,7 +412,7 @@ ENABLE_BITCODE = NO; EXECUTABLE_PREFIX = ""; EXECUTABLE_SUFFIX = ""; - FRAMEWORK_SEARCH_PATHS = "/Users/user/Downloads/sdks-master/iPhoneOS11.2.sdk/System/Library/PrivateFrameworks/"; + FRAMEWORK_SEARCH_PATHS = "${PROJECT_DIR}/privateframeworks"; GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO; HEADER_SEARCH_PATHS = ( "${PROJECT_DIR}/include/**", @@ -445,7 +445,7 @@ ENABLE_BITCODE = NO; EXECUTABLE_PREFIX = ""; EXECUTABLE_SUFFIX = ""; - FRAMEWORK_SEARCH_PATHS = "/Users/user/Downloads/sdks-master/iPhoneOS11.2.sdk/System/Library/PrivateFrameworks/"; + FRAMEWORK_SEARCH_PATHS = "${PROJECT_DIR}/privateframeworks"; GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO; HEADER_SEARCH_PATHS = ( "${PROJECT_DIR}/include/**", diff --git a/vncserverd/Makefile b/vncserverd/Makefile new file mode 100644 index 0000000..4a2580b --- /dev/null +++ b/vncserverd/Makefile @@ -0,0 +1,14 @@ +ARCHS=arm64 +TARGET=iphone:latest:9.0 + +include $(THEOS)/makefiles/common.mk + +TOOL_NAME = vncserverd +vncserverd_FILES = $(wildcard ../vncforios/*.m) memory_limit.m +vncserverd_FRAMEWORKS = IOMobileFramebuffer IOSurface IOKit +vncserverd_CFLAGS = -I../include -Wno-deprecated-declarations +vncserverd_LDFLAGS = -L../lib -F../privateframeworks -lssl -lcrypto -lvncserverstatic -ljpeg -lpng +vncserverd_INSTALL_PATH=/usr/libexec/ +vncserverd_CODESIGN_FLAGS = -S../entitlements.plist + +include $(THEOS_MAKE_PATH)/tool.mk diff --git a/vncserverd/control b/vncserverd/control new file mode 100644 index 0000000..3ddf8e2 --- /dev/null +++ b/vncserverd/control @@ -0,0 +1,10 @@ +Package: com.ethanarbuckle.vncserverd +Name: vncserverd +Depends: +Version: 0.0.1 +Architecture: all +Description: VNC server for iOS and tvOS (9.0+) +Maintainer: Ethan Arbuckle +Author: Ethan Arbuckle +Section: System +Tag: role::hacker diff --git a/vncserverd/layout/DEBIAN/postinst b/vncserverd/layout/DEBIAN/postinst new file mode 100755 index 0000000..f6e2906 --- /dev/null +++ b/vncserverd/layout/DEBIAN/postinst @@ -0,0 +1,3 @@ +chown root:wheel /Library/LaunchDaemons/com.ethanarbuckle.vncserverd.plist +launchctl unload /Library/LaunchDaemons/com.ethanarbuckle.vncserverd.plist || true +launchctl load /Library/LaunchDaemons/com.ethanarbuckle.vncserverd.plist || true \ No newline at end of file diff --git a/vncserverd/layout/Library/LaunchDaemons/com.ethanarbuckle.vncserverd.plist b/vncserverd/layout/Library/LaunchDaemons/com.ethanarbuckle.vncserverd.plist new file mode 100644 index 0000000..82b293f --- /dev/null +++ b/vncserverd/layout/Library/LaunchDaemons/com.ethanarbuckle.vncserverd.plist @@ -0,0 +1,23 @@ + + + + + ProgramArguments + + /usr/libexec/vncserverd + + RunAtLoad + + UserName + root + KeepAlive + + Label + com.ethanarbuckle.vncserverd + JetsamProperties + + JetsamPriority + 18 + + + \ No newline at end of file diff --git a/vncserverd/memory_limit.m b/vncserverd/memory_limit.m new file mode 100644 index 0000000..cce1a1c --- /dev/null +++ b/vncserverd/memory_limit.m @@ -0,0 +1,10 @@ + +#define MEMORYSTATUS_CMD_SET_JETSAM_TASK_LIMIT 6 +extern int memorystatus_control(int a, int b, int c, void *d, int e); + +static __attribute__((constructor)) void raise_memory_limit(void) { + NSLog(@"vncserverd bumping memory limit"); + if (memorystatus_control(MEMORYSTATUS_CMD_SET_JETSAM_TASK_LIMIT, getpid(), 100, NULL, 0) == -1) { + NSLog(@"vncserverd failed to increase memory limit. Process will likely die"); + } +} \ No newline at end of file