Run a virtual iPhone on an Apple Silicon Mac.
Swift
Inject SystemHook into launchd-started apps and log sandboxed loads
Lakr6b334a0f352b
diff --git a/Research/0_binary_patch_comparison.md b/Research/0_binary_patch_comparison.mdindex f3d3919d..7120a847 100644--- a/Research/0_binary_patch_comparison.md+++ b/Research/0_binary_patch_comparison.md@@ -31,13 +31,16 @@> jetsam limit and suppresses future fatal task-limit assignments for PID 1.> When a bootstrap and its ElleKit library exist, the launchd hook uses> `MSHookFunction` on PID 1's `posix_spawn` to add-> `DYLD_INSERT_LIBRARIES=/usr/lib/SystemHook-vphone.dylib` to `xpcproxy` and-> directly spawned bootstrap programs. `SystemHook-vphone.dylib` interposes+> `DYLD_INSERT_LIBRARIES=/usr/lib/SystemHook-vphone.dylib` to `xpcproxy`,+> directly spawned bootstrap programs, and app executables under the system+> or application bundle paths. `SystemHook-vphone.dylib` interposes> `posix_spawnp` inside `xpcproxy` to carry that environment into the final> executable. Both stages preserve an existing `DYLD_INSERT_LIBRARIES`, avoid> duplicate insertion, and honor `DISABLE_TWEAKS`, `_SafeMode`, and-> `_MSSafeMode` in the target environment. The dylib logs PID, executable path,-> xpcproxy label, and spawn decisions under `/var/mobile/Library/Caches`.+> `_MSSafeMode` in the target environment. PID 1 logs child PID, executable+> path, and spawn status under `/var/mobile/Library/Caches`. SystemHook logs+> there when permitted and falls back to the app's own `Library/Caches` under+> its sandboxed home directory.> It still does not load ElleKit, TweakLoader, or individual tweaks in target> processes. Tweak selection and sandbox behavior require separate validation.> On the rootless iOS 26.6.2 clone, `xpcproxy` called `posix_spawnp` for the@@ -54,6 +57,13 @@> daemon reported `systemhook_loaded=1` both at load and after its timed> restart. This validates path handling and injection through the randomized> root, not a complete RootHide bootstrap or a real tweak package.+> Apps use a separate direct launchd spawn path on this iOS 26.6.2 VM. On the+> rootless clone, launchd logged the Calculator app spawn with PID 454 and+> injection enabled; the app's own+> `Library/Caches/vphone-systemhook.log` recorded the same PID and Calculator+> executable path. The app reached the foreground and rendered normally.+> The previous central-log-only probe could not observe sandboxed apps even+> when SystemHook was loaded.> The cloned `vphone-launchdhook-lab-26.6.2` booted with the weak dylib and> retained a healthy vphoned API. Rootless and RootHide probes, each tested> after reboot, were imported and spawned by launchd. The RootHide probe'sdiff --git a/VPhoneGuestComponents/LaunchHook/launchdhook-vphone.c b/VPhoneGuestComponents/LaunchHook/launchdhook-vphone.cindex b419d2a7..59bb1bd7 100644--- a/VPhoneGuestComponents/LaunchHook/launchdhook-vphone.c+++ b/VPhoneGuestComponents/LaunchHook/launchdhook-vphone.c@@ -27,6 +27,26 @@ static void vpLogInjection(const char *event, const char *path, int status) {close(fd);}+static void vpLogSpawn(const char *event, const char *path, pid_t child, int status) {+ int fd = open("/var/mobile/Library/Caches/vphone-launchdhook-spawn.log",+ O_WRONLY | O_CREAT | O_APPEND | O_CLOEXEC, 0644);+ if (fd < 0)+ return;+ dprintf(fd, "event=%s child=%d path=%s status=%d\n", event, child,+ path ? path : "<null>", status);+ close(fd);+}++static int vpIsAppProgram(const char *path) {+ if (!path || !strstr(path, ".app/"))+ return 0;+ return strncmp(path, "/Applications/", sizeof("/Applications/") - 1) == 0 ||+ strncmp(path, "/var/containers/Bundle/Application/",+ sizeof("/var/containers/Bundle/Application/") - 1) == 0 ||+ strncmp(path, "/private/var/containers/Bundle/Application/",+ sizeof("/private/var/containers/Bundle/Application/") - 1) == 0;+}+static int vpSpawn(pid_t *restrict pid, const char *restrict path, const posix_spawn_file_actions_t *restrict actions,const posix_spawnattr_t *restrict attributes, char *const argv[restrict],char *const envp[restrict]) {@@ -34,12 +54,19 @@ static int vpSpawn(pid_t *restrict pid, const char *restrict path, const posix_sint bootstrapProgram =path && ((rootLength && strncmp(path, vpBootRoot, rootLength) == 0 && path[rootLength] == '/') ||strncmp(path, "/var/jb/", 8) == 0);- if (!path || (strcmp(path, "/usr/libexec/xpcproxy") != 0 && !bootstrapProgram) || vpInjectionDisabled(envp)) {- return vpOriginalSpawn(pid, path, actions, attributes, argv, envp);+ int appProgram = vpIsAppProgram(path);+ if (!path || (strcmp(path, "/usr/libexec/xpcproxy") != 0 && !bootstrapProgram && !appProgram) ||+ vpInjectionDisabled(envp)) {+ int status = vpOriginalSpawn(pid, path, actions, attributes, argv, envp);+ if (appProgram)+ vpLogSpawn("app-disabled", path, status == 0 && pid ? *pid : -1, status);+ return status;}VPInjectionEnvironment injected = vpInsertHook(envp);int status = vpOriginalSpawn(pid, path, actions, attributes, argv, injected.values ? injected.values : envp);vpLogInjection(injected.values ? "inserted" : "unchanged", path, status);+ vpLogSpawn(injected.values ? "inserted" : "unchanged", path, status == 0 && pid ? *pid : -1,+ status);vpFreeEnvironment(&injected);return status;}@@ -249,7 +276,7 @@ __attribute__((constructor)) static void vpLaunchHookInit(void) {}// This image is loaded by launchd's LC_LOAD_WEAK_DYLIB. The spawn hook handles-// xpcproxy and direct bootstrap executables; SystemHook owns xpcproxy's exec.+// xpcproxy, direct bootstrap executables, and apps; SystemHook owns xpcproxy's exec.__attribute__((used, section("__DATA,__interpose"))) static const struct {const void *replacement;const void *replacee;diff --git a/VPhoneGuestComponents/README.md b/VPhoneGuestComponents/README.mdindex 4a49dd98..e15721ff 100644--- a/VPhoneGuestComponents/README.md+++ b/VPhoneGuestComponents/README.md@@ -9,15 +9,18 @@ tweak filter plists, and the GPU provenance note:| Camera app hook | `camfix/libcamfix.dylib`, `camfix/libcamfix.plist` || Camera daemon hook | `vcamcaptured/libvcamcaptured.dylib`, `vcamcaptured/libvcamcaptured.plist` || Launchd hook | `launchhook/launchdhook-vphone.dylib` |-| Process-load probe | `systemhook/SystemHook-vphone.dylib` |+| Process injection bridge | `systemhook/SystemHook-vphone.dylib` || iOS 27 app registrar | `vpregister/vpregister` || PCC GPU driver | `gpu/README.md` (source and extraction flow; no Apple binary) |-The archive is a local build artifact, not a VM bootstrap. The launchd hook is-installed by `cfw install` to discover package daemons after reboot; the process-hook is staged but is not injected automatically. If loaded for diagnosis, its-constructor appends the PID and executable path to-`/var/mobile/Library/Caches/vphone-systemhook.log`; it does not load ElleKit.+The archive is a local build artifact, not a VM bootstrap. `cfw install` places+both hooks in `/usr/lib`. After a bootstrap installs ElleKit, the launchd hook+inserts SystemHook into `xpcproxy`, bootstrap executables, and apps started+directly by launchd. Inside `xpcproxy`, SystemHook carries itself into the+final executable through `posix_spawnp`. It logs PID and executable path to+`/var/mobile/Library/Caches/vphone-systemhook.log`, falling back to the app's+own `Library/Caches` when sandboxed. It does not load ElleKit or tweaks.+`DISABLE_TWEAKS=1` and the safe-mode flags skip injection.Irisin installs ElleKit's own `TweakLoader.dylib` in the selected bootstrap.The required GPU bundle is extracted from the selected PCC firmware by`vphone-cli fw prepare` and copied into the VM during JB installation. Nodiff --git a/VPhoneGuestComponents/SystemHook/SystemHook-vphone.c b/VPhoneGuestComponents/SystemHook/SystemHook-vphone.cindex 6e258d86..47b8cef5 100644--- a/VPhoneGuestComponents/SystemHook/SystemHook-vphone.c+++ b/VPhoneGuestComponents/SystemHook/SystemHook-vphone.c@@ -5,15 +5,35 @@#include <mach-o/dyld.h>#include <spawn.h>#include <stdio.h>+#include <stdlib.h>#include <string.h>#include <unistd.h>static int vpInXPCProxy;+static int vpOpenLog(const char *name) {+ char path[PATH_MAX];+ int used = snprintf(path, sizeof(path), "/var/mobile/Library/Caches/%s", name);+ int fd = used > 0 && (size_t)used < sizeof(path)+ ? open(path, O_WRONLY | O_CREAT | O_APPEND | O_CLOEXEC, 0644)+ : -1;+ if (fd >= 0)+ return fd;+ const char *home = getenv("CFFIXED_USER_HOME");+ if (!home)+ home = getenv("HOME");+ if (!home)+ return -1;+ used = snprintf(path, sizeof(path), "%s/Library/Caches/%s", home, name);+ return used > 0 && (size_t)used < sizeof(path)+ ? open(path, O_WRONLY | O_CREAT | O_APPEND | O_CLOEXEC, 0644)+ : -1;+}+static void vpLogSpawn(const char *path, const char *decision) {- int fd = open("/var/mobile/Library/Caches/vphone-systemhook-spawn.log",- O_WRONLY | O_CREAT | O_APPEND | O_CLOEXEC, 0644);- if (fd < 0) return;+ int fd = vpOpenLog("vphone-systemhook-spawn.log");+ if (fd < 0)+ return;dprintf(fd, "pid=%d path=%s decision=%s\n", getpid(), path ? path : "<null>", decision);close(fd);}@@ -42,7 +62,7 @@ __attribute__((constructor)) static void vpLogProcess(void) {return;vpInXPCProxy = strcmp(path, "/usr/libexec/xpcproxy") == 0;- int fd = open("/var/mobile/Library/Caches/vphone-systemhook.log", O_WRONLY | O_CREAT | O_APPEND | O_CLOEXEC, 0644);+ int fd = vpOpenLog("vphone-systemhook.log");if (fd < 0)return;char **arguments = *_NSGetArgv();