Skip to content

Commit

Permalink
create vncserver daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanArbuckle committed May 23, 2020
1 parent 8a6a5aa commit 0d76400
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
*.xcuserdatad/*
/vncforios.xcodeproj/project.xcworkspace/xcuserdata
/vncforios.xcodeproj/project.xcworkspace/contents.xcworkspacedata
*.theos
vncserverd/packages/*
vncforios.xcodeproj/xcuserdata
Original file line number Diff line number Diff line change
@@ -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 ]
...
4 changes: 2 additions & 2 deletions vncforios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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/**",
Expand Down Expand Up @@ -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/**",
Expand Down
14 changes: 14 additions & 0 deletions vncserverd/Makefile
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions vncserverd/control
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions vncserverd/layout/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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>ProgramArguments</key>
<array>
<string>/usr/libexec/vncserverd</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>root</string>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.ethanarbuckle.vncserverd</string>
<key>JetsamProperties</key>
<dict>
<key>JetsamPriority</key>
<integer>18</integer>
</dict>
</dict>
</plist>
10 changes: 10 additions & 0 deletions vncserverd/memory_limit.m
Original file line number Diff line number Diff line change
@@ -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");
}
}

0 comments on commit 0d76400

Please sign in to comment.