Created
October 10, 2026 03:39
-
-
Save dashboarded/fb0dfd95db735625a88f2cfd89d03cdf to your computer and use it in GitHub Desktop.
the two git commits
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/App/main.c b/App/main.c | |
| index c7a51a6..4611ef1 100644 | |
| --- a/App/main.c | |
| +++ b/App/main.c | |
| @@ -4,6 +4,7 @@ | |
| #include <libroot.h> | |
| #include <limits.h> | |
| #include <mach-o/loader.h> | |
| +#include <mach-o/dyld.h> | |
| #include <stdbool.h> | |
| #include <stddef.h> | |
| #include <stdio.h> | |
| @@ -20,6 +21,10 @@ __attribute__((used, section("__TEXT,__lc32shim"))) | |
| static const char LC32InjectedShimMarker[] = | |
| "LiveExec32InjectedShim:1"; | |
| +/* The standalone packager rejects launchers predating bundled RootFS support. */ | |
| +__attribute__((used, section("__TEXT,__lc32standalone"))) | |
| +static const char LC32StandaloneMarker[] = "LiveExec32Standalone:1"; | |
| + | |
| static bool FormatFrameworkPath( | |
| char *path, size_t capacity, | |
| const char *base, const char *name) { | |
| @@ -106,7 +111,7 @@ static void ConfigureDynarmicCodeMemoryMode(void) { | |
| } | |
| static bool ConfigureInjectedEnvironment( | |
| - char installedLauncherPath[PATH_MAX]) { | |
| + char runtimeLauncherPath[PATH_MAX]) { | |
| char guestHome[PATH_MAX]; | |
| const char *currentHome = getenv("HOME"); | |
| if(currentHome == NULL || currentHome[0] != '/' || | |
| @@ -115,26 +120,45 @@ static bool ConfigureInjectedEnvironment( | |
| snprintf(guestHome, sizeof(guestHome), "%s", "/var/mobile"); | |
| } | |
| - const char *resolvedLauncherPath = libroot_dyn_jbrootpath( | |
| - "/Applications/LiveExec32.app/LiveExec32", | |
| - installedLauncherPath); | |
| - if(resolvedLauncherPath == NULL || resolvedLauncherPath[0] == '\0') { | |
| + /* A self-contained bundle must not depend on the jailbreak installation. | |
| + * Resolve the actual process executable, not a possibly relative argv[0]. */ | |
| + char executablePath[PATH_MAX]; | |
| + uint32_t executablePathSize = sizeof(executablePath); | |
| + char rootPath[PATH_MAX]; | |
| + char frameworkPath[PATH_MAX]; | |
| + bool bundledRuntime = false; | |
| + if(_NSGetExecutablePath(executablePath, &executablePathSize) == 0 && | |
| + realpath(executablePath, runtimeLauncherPath) != NULL) { | |
| + const char *slash = strrchr(runtimeLauncherPath, '/'); | |
| + if(slash != NULL) { | |
| + const int directoryLength = (int)(slash - runtimeLauncherPath); | |
| + const int rootLength = snprintf(rootPath, sizeof(rootPath), | |
| + "%.*s/RootFS", directoryLength, runtimeLauncherPath); | |
| + const int frameworkLength = snprintf(frameworkPath, sizeof(frameworkPath), | |
| + "%.*s/Frameworks/LiveExec32Shared.framework/LiveExec32Shared", | |
| + directoryLength, runtimeLauncherPath); | |
| + bundledRuntime = rootLength >= 0 && (size_t)rootLength < sizeof(rootPath) && | |
| + frameworkLength >= 0 && (size_t)frameworkLength < sizeof(frameworkPath) && | |
| + access(rootPath, R_OK | X_OK) == 0 && access(frameworkPath, R_OK) == 0; | |
| + } | |
| + } | |
| + if(!bundledRuntime && libroot_dyn_jbrootpath( | |
| + "/Applications/LiveExec32.app/LiveExec32", runtimeLauncherPath) == NULL) { | |
| fprintf(stderr, | |
| "LC32: could not resolve the installed launcher path\n"); | |
| return false; | |
| } | |
| - const char *lastSlash = strrchr(installedLauncherPath, '/'); | |
| - if(lastSlash == NULL || lastSlash == installedLauncherPath) { | |
| - fprintf(stderr, "LC32: installed launcher path is invalid\n"); | |
| + const char *lastSlash = strrchr(runtimeLauncherPath, '/'); | |
| + if(lastSlash == NULL || lastSlash == runtimeLauncherPath) { | |
| + fprintf(stderr, "LC32: runtime launcher path is invalid\n"); | |
| return false; | |
| } | |
| - char rootPath[PATH_MAX]; | |
| const int rootPathLength = snprintf( | |
| rootPath, sizeof(rootPath), "%.*s/RootFS", | |
| - (int)(lastSlash - installedLauncherPath), installedLauncherPath); | |
| + (int)(lastSlash - runtimeLauncherPath), runtimeLauncherPath); | |
| if(rootPathLength < 0 || (size_t)rootPathLength >= sizeof(rootPath)) { | |
| - fprintf(stderr, "LC32: installed RootFS path is too long\n"); | |
| + fprintf(stderr, "LC32: runtime RootFS path is too long\n"); | |
| return false; | |
| } | |
| @@ -175,9 +199,9 @@ int main(int argc, char *argv[], char *envp[]) { | |
| const bool injectedLauncher = | |
| strncmp(executableName, "LiveExec32", 10) != 0; | |
| - char installedLauncherPath[PATH_MAX] = {0}; | |
| + char runtimeLauncherPath[PATH_MAX] = {0}; | |
| if(injectedLauncher && | |
| - !ConfigureInjectedEnvironment(installedLauncherPath)) { | |
| + !ConfigureInjectedEnvironment(runtimeLauncherPath)) { | |
| return 1; | |
| } | |
| @@ -228,7 +252,9 @@ int main(int argc, char *argv[], char *envp[]) { | |
| /* | |
| * The injected arm64 slice is byte-for-byte LiveExec32's launcher, but | |
| * argv[0] names the installed 32-bit application's executable. Supply | |
| - * the installed launcher as argv[0] so LiveExec32Shared finds its RootFS, | |
| + * the runtime launcher as argv[0] so LiveExec32Shared finds its RootFS | |
| + * (the current executable for standalone apps, the installed launcher | |
| + * for jailbreak-injected apps), | |
| * and the current universal executable as argv[1] so its ARM32 slice is | |
| * the guest program. Preserve arguments passed to the application. | |
| */ | |
| @@ -240,7 +266,7 @@ int main(int argc, char *argv[], char *envp[]) { | |
| "LC32: could not allocate injected application arguments\n"); | |
| return 1; | |
| } | |
| - guestArguments[0] = installedLauncherPath; | |
| + guestArguments[0] = runtimeLauncherPath; | |
| for(int index = 0; index < argc; index++) { | |
| guestArguments[index + 1] = argv[index]; | |
| } | |
| diff --git a/Resources/Info.plist b/Resources/Info.plist | |
| index 5aa0602..fafcb4e 100644 | |
| --- a/Resources/Info.plist | |
| +++ b/Resources/Info.plist | |
| @@ -61,7 +61,7 @@ | |
| <key>LSSupportsOpeningDocumentsInPlace</key> | |
| <true/> | |
| <key>MinimumOSVersion</key> | |
| - <string>16.0</string> | |
| + <string>15.0</string> | |
| <key>SBAppTags</key> | |
| <array> | |
| <string>hidden</string> | |
| diff --git a/Scripts/inject-standalone.m b/Scripts/inject-standalone.m | |
| new file mode 100644 | |
| index 0000000..55e1f51 | |
| --- /dev/null | |
| +++ b/Scripts/inject-standalone.m | |
| @@ -0,0 +1,111 @@ | |
| +// Packaging helper: the Mach-O transformation itself is shared with the tweak. | |
| +#import <Foundation/Foundation.h> | |
| +#include <fcntl.h> | |
| +#include <mach-o/loader.h> | |
| +#include <unistd.h> | |
| +#include "FatMachO.h" | |
| +#include "MachOImage.h" | |
| + | |
| +static void Fail(NSString *message) { | |
| + fprintf(stderr, "inject-standalone: %s\n", message.UTF8String); | |
| + exit(1); | |
| +} | |
| + | |
| +static NSString *ExecutableName(NSDictionary *info) { | |
| + id name = info[@"CFBundleExecutable"]; | |
| + if(![name isKindOfClass:NSString.class] || ![name length] || | |
| + [name containsString:@"/"] || [name isEqual:@"."] || [name isEqual:@".."]) { | |
| + Fail(@"CFBundleExecutable must be a nonempty filename"); | |
| + } | |
| + return name; | |
| +} | |
| + | |
| +static LC32MachOImage ReadImage(NSString *path) { | |
| + LC32MachOImage image = {0}; | |
| + char error[512] = {0}; | |
| + int fd = open(path.fileSystemRepresentation, O_RDONLY | O_NOFOLLOW); | |
| + if(fd < 0) Fail([@"cannot open regular executable: " stringByAppendingString:path]); | |
| + BOOL parsed = LC32MachOImageParseFD(fd, &image, error, sizeof(error)); | |
| + close(fd); | |
| + if(!parsed) Fail([NSString stringWithUTF8String:error]); | |
| + return image; | |
| +} | |
| + | |
| +static BOOL IsVersion(id version) { | |
| + if(![version isKindOfClass:NSString.class] || ![version length]) return NO; | |
| + NSArray *parts = [version componentsSeparatedByString:@"."]; | |
| + if(parts.count > 3) return NO; | |
| + for(NSString *part in parts) { | |
| + if(!part.length || [part rangeOfCharacterFromSet: | |
| + NSCharacterSet.decimalDigitCharacterSet.invertedSet].location != NSNotFound) return NO; | |
| + } | |
| + return YES; | |
| +} | |
| + | |
| +int main(int argc, const char *argv[]) { | |
| + if(argc != 3) return 2; | |
| + @autoreleasepool { | |
| + NSString *app = [NSString stringWithUTF8String:argv[1]]; | |
| + NSString *runtime = [NSString stringWithUTF8String:argv[2]]; | |
| + NSString *plist = [app stringByAppendingPathComponent:@"Info.plist"]; | |
| + NSMutableDictionary *info = [NSMutableDictionary dictionaryWithContentsOfFile:plist]; | |
| + NSDictionary *runtimeInfo = [NSDictionary dictionaryWithContentsOfFile: | |
| + [runtime stringByAppendingPathComponent:@"Info.plist"]]; | |
| + if(!info || !runtimeInfo) Fail(@"cannot read app/runtime Info.plist"); | |
| + NSString *name = ExecutableName(info); | |
| + if([name hasPrefix:@"LiveExec32"]) Fail(@"game executable uses the launcher's reserved LiveExec32 prefix"); | |
| + NSString *target = [app stringByAppendingPathComponent:name]; | |
| + NSString *shim = [runtime stringByAppendingPathComponent:ExecutableName(runtimeInfo)]; | |
| + NSString *identifier = info[@"CFBundleIdentifier"]; | |
| + if(![identifier isKindOfClass:NSString.class] || !identifier.length) Fail(@"missing game bundle identifier"); | |
| + LC32MachOImage guest = ReadImage(target); | |
| + for(uint32_t i = 0; i < guest.count; ++i) { | |
| + const LC32MachOSlice *slice = &guest.slices[i]; | |
| + if(slice->cpuType != CPU_TYPE_ARM || slice->fileType != MH_EXECUTE) | |
| + Fail(@"input must contain only ARM32 executable slices; native or already-injected apps are not supported"); | |
| + if(slice->encrypted) Fail(@"encrypted ARM32 executable; provide a decrypted app"); | |
| + } | |
| + LC32MachOImage host = ReadImage(shim); | |
| + const LC32MachOSlice *arm64 = LC32MachOImageFindSlice(&host, CPU_TYPE_ARM64, CPU_SUBTYPE_ARM64_ALL); | |
| + if(!arm64 || !arm64->hasBuildVersion || arm64->buildVersionPlatform != PLATFORM_IOS) | |
| + Fail(@"runtime must be a device iOS build, not a Catalyst or simulator build"); | |
| + NSData *launcher = [NSData dataWithContentsOfFile:shim]; | |
| + NSData *marker = [@"LiveExec32Standalone:1" dataUsingEncoding:NSUTF8StringEncoding]; | |
| + if(!launcher || [launcher rangeOfData:marker options:0 | |
| + range:NSMakeRange((NSUInteger)arm64->offset, (NSUInteger)arm64->size)].location == NSNotFound) | |
| + Fail(@"launcher lacks bundled RootFS support; rebuild LiveExec32 with the current sources"); | |
| + | |
| + NSString *minimum = runtimeInfo[@"MinimumOSVersion"]; | |
| + if(!IsVersion(minimum)) Fail(@"invalid runtime MinimumOSVersion"); | |
| + id originalMinimum = info[@"MinimumOSVersion"]; | |
| + if(originalMinimum && !IsVersion(originalMinimum)) Fail(@"invalid game MinimumOSVersion"); | |
| + if(!originalMinimum || [originalMinimum compare:minimum options:NSNumericSearch] == NSOrderedAscending) | |
| + info[@"MinimumOSVersion"] = minimum; | |
| + id capabilities = info[@"UIRequiredDeviceCapabilities"]; | |
| + NSArray *architectureCapabilities = @[@"armv6", @"armv7", @"armv7s", @"arm64", @"arm64e"]; | |
| + if([capabilities isKindOfClass:NSDictionary.class]) { | |
| + NSMutableDictionary *updated = [capabilities mutableCopy]; | |
| + [updated removeObjectsForKeys:architectureCapabilities]; | |
| + updated[@"arm64"] = @YES; | |
| + info[@"UIRequiredDeviceCapabilities"] = updated; | |
| + } else if(!capabilities || [capabilities isKindOfClass:NSArray.class]) { | |
| + NSMutableArray *updated = capabilities ? [capabilities mutableCopy] : [NSMutableArray array]; | |
| + [updated removeObjectsInArray:architectureCapabilities]; | |
| + [updated addObject:@"arm64"]; | |
| + info[@"UIRequiredDeviceCapabilities"] = updated; | |
| + } else { | |
| + Fail(@"UIRequiredDeviceCapabilities must be an array or dictionary"); | |
| + } | |
| + info[@"CFBundleSupportedPlatforms"] = @[@"iPhoneOS"]; | |
| + char error[512] = {0}; | |
| + if(LC32InjectArm64ExecutableSlice(target.fileSystemRepresentation, | |
| + shim.fileSystemRepresentation, identifier.UTF8String, error, sizeof(error)) != | |
| + LC32MachOInjectionSucceeded) Fail([NSString stringWithUTF8String:error]); | |
| + NSError *plistError = nil; | |
| + NSData *data = [NSPropertyListSerialization dataWithPropertyList:info | |
| + format:NSPropertyListBinaryFormat_v1_0 options:0 error:&plistError]; | |
| + if(!data || ![data writeToFile:plist options:NSDataWritingAtomic error:&plistError]) | |
| + Fail(plistError.localizedDescription ?: @"could not update Info.plist"); | |
| + } | |
| + return 0; | |
| +} | |
| diff --git a/Scripts/inject-standalone.sh b/Scripts/inject-standalone.sh | |
| new file mode 100755 | |
| index 0000000..6638719 | |
| --- /dev/null | |
| +++ b/Scripts/inject-standalone.sh | |
| @@ -0,0 +1,168 @@ | |
| +#!/bin/bash | |
| +# Bundle LiveExec32 into a decrypted ARM32 iOS app or IPA. Run on macOS. | |
| +set -euo pipefail | |
| +export LC_ALL=C | |
| + | |
| +usage() { | |
| + echo "Usage: $0 [--output OUTPUT.app|OUTPUT.ipa] GAME.app|GAME.ipa LiveExec32.app|LiveExec32.ipa" | |
| + echo "Output uses the input game format; signing, JIT enablement and installation are separate." | |
| + echo "Without --output, replaces the input and keeps INPUT.lc32-backup (must not exist)." | |
| +} | |
| +fail() { echo "inject-standalone: $*" >&2; exit 1; } | |
| + | |
| +output= | |
| +in_place=0 | |
| +while [[ $# -gt 0 ]]; do | |
| + case "$1" in | |
| + --output) | |
| + [[ $# -ge 2 && -n "$2" && -z "$output" ]] || { usage >&2; exit 2; } | |
| + output=$2; shift 2 ;; | |
| + --in-place) in_place=1; shift ;; | |
| + --help|-h) usage; exit 0 ;; | |
| + --) shift; break ;; | |
| + -*) usage >&2; exit 2 ;; | |
| + *) break ;; | |
| + esac | |
| +done | |
| +[[ $# -eq 2 ]] || { usage >&2; exit 2; } | |
| +if [[ $in_place -eq 1 ]]; then | |
| + [[ -z "$output" ]] || fail "choose either --output or --in-place" | |
| +else | |
| + [[ -n "$output" ]] || in_place=1 | |
| +fi | |
| +[[ $(uname -s) == Darwin ]] || fail "macOS with Xcode Command Line Tools is required" | |
| +for tool in xcrun rsync; do | |
| + command -v "$tool" >/dev/null || fail "missing required tool: $tool" | |
| +done | |
| +repo=$(cd -- "$(dirname -- "$0")/.." && pwd -P) | |
| +[[ ! -L "${1%/}" ]] || fail "the input must not be a symlink" | |
| +input=$(cd -- "$(dirname -- "${1%/}")" && printf '%s/%s\n' "$(pwd -P)" "$(basename -- "${1%/}")") | |
| +runtime_input=$(cd -- "$(dirname -- "${2%/}")" && printf '%s/%s\n' "$(pwd -P)" "$(basename -- "${2%/}")") | |
| +case "$input" in | |
| + *.app) [[ -d "$input" ]] || fail "game .app directory is missing"; format=app ;; | |
| + *.ipa) [[ -f "$input" ]] || fail "game .ipa file is missing"; format=ipa ;; | |
| + *) fail "input must be an .app directory or .ipa file" ;; | |
| +esac | |
| +case "$runtime_input" in | |
| + *.app) [[ -d "$runtime_input" ]] || fail "runtime .app directory is missing" ;; | |
| + *.ipa) [[ -f "$runtime_input" ]] || fail "runtime .ipa file is missing" ;; | |
| + *) fail "runtime must be an .app directory or .ipa file" ;; | |
| +esac | |
| +if [[ $format == ipa || "$runtime_input" == *.ipa ]]; then | |
| + for tool in unzip zip; do | |
| + command -v "$tool" >/dev/null || fail "missing required tool: $tool" | |
| + done | |
| + # Do not inherit options that follow links, change filenames or allow traversal. | |
| + unset ZIPOPT UNZIP UNZIPOPT ZIPINFO ZIPINFOOPT | |
| +fi | |
| + | |
| +backup= | |
| +if [[ $in_place -eq 1 ]]; then | |
| + output=$input | |
| + backup="$input.lc32-backup" | |
| + [[ ! -e "$backup" && ! -L "$backup" ]] || fail "backup already exists: $backup" | |
| +else | |
| + [[ "$output" == *."$format" ]] || fail "output must end in .$format to match the input" | |
| + parent=$(cd -- "$(dirname -- "$output")" && pwd -P) || fail "output parent must exist" | |
| + output="$parent/$(basename -- "$output")" | |
| + [[ ! -e "$output" && ! -L "$output" ]] || fail "output already exists: $output" | |
| +fi | |
| +case "$output" in "$input"/*|"$runtime_input"|"$runtime_input"/*) fail "output must be outside both inputs" ;; esac | |
| +parent=$(dirname -- "$output") | |
| +work=$(mktemp -d "$parent/.lc32-standalone.XXXXXX") | |
| +cleanup() { | |
| + result=$? | |
| + trap - EXIT | |
| + if [[ -n "$backup" && -e "$backup" && ! -e "$input" && ! -L "$input" ]]; then | |
| + mv -- "$backup" "$input" || echo "Original input remains at: $backup" >&2 | |
| + fi | |
| + rm -rf -- "$work" | |
| + exit "$result" | |
| +} | |
| +trap cleanup EXIT | |
| +trap 'exit 130' INT | |
| +trap 'exit 143' TERM | |
| + | |
| +shopt -s nullglob dotglob | |
| +extract_ipa() { | |
| + local entry | |
| + unzip -Z1 "$1" > "$work/archive-entries" | |
| + while IFS= read -r entry; do | |
| + case "/$entry/" in | |
| + //*|*/../*) fail "unsafe IPA entry: $entry" ;; | |
| + esac | |
| + done < "$work/archive-entries" | |
| + # A fresh directory and -n prevent overwrites; unzip defers symlinks until | |
| + # after files, so archived links cannot redirect extraction outside it. | |
| + mkdir "$2" | |
| + unzip -q -n -P '' "$1" -d "$2" < /dev/null | |
| +} | |
| +ipa_app() { | |
| + [[ -d "$1/Payload" && ! -L "$1/Payload" ]] || fail "IPA is missing a real Payload directory" | |
| + local apps=("$1/Payload/"*.app) | |
| + [[ ${#apps[@]} -eq 1 && -d "${apps[0]}" && ! -L "${apps[0]}" ]] || | |
| + fail "IPA must contain exactly one app directory directly under Payload" | |
| + printf '%s\n' "${apps[0]}" | |
| +} | |
| +game=$input | |
| +runtime=$runtime_input | |
| +if [[ $format == ipa ]]; then | |
| + extract_ipa "$input" "$work/game-archive" | |
| + game=$(ipa_app "$work/game-archive") | |
| +fi | |
| +if [[ "$runtime_input" == *.ipa ]]; then | |
| + extract_ipa "$runtime_input" "$work/runtime-archive" | |
| + runtime=$(ipa_app "$work/runtime-archive") | |
| +fi | |
| +[[ -f "$game/Info.plist" && ! -L "$game/Info.plist" ]] || fail "missing or symlinked game Info.plist" | |
| +[[ -f "$runtime/Info.plist" && ! -L "$runtime/Info.plist" ]] || fail "missing or symlinked runtime Info.plist" | |
| +[[ ! -L "$runtime/RootFS" && ! -L "$runtime/Frameworks" && | |
| + -f "$runtime/RootFS/usr/lib/dyld" && | |
| + -f "$runtime/RootFS/System/Library/Frameworks/LC32.framework/LC32" && | |
| + -f "$runtime/Frameworks/LiveExec32Shared.framework/LiveExec32Shared" ]] || | |
| + fail "runtime is incomplete; pack the guest RootFS and build LiveExec32 first" | |
| +[[ ! -e "$game/RootFS" && ! -L "$game/RootFS" ]] || fail "input already contains RootFS" | |
| +[[ ! -L "$game/Frameworks" ]] || fail "game Frameworks must not be a symlink" | |
| +[[ ! -e "$game/Frameworks" || -d "$game/Frameworks" ]] || fail "game Frameworks is not a directory" | |
| +for entry in "$runtime/Frameworks/"*; do | |
| + name=${entry##*/} | |
| + [[ ! -e "$game/Frameworks/$name" && ! -L "$game/Frameworks/$name" ]] || | |
| + fail "framework collision: $name" | |
| +done | |
| + | |
| +# Reuse the jailbreak injector's validated Mach-O parser, SDK preservation, | |
| +# entitlement merge and atomic executable replacement instead of a second lipo implementation. | |
| +xcrun --sdk macosx clang -fobjc-arc -Wall -Wextra -Werror \ | |
| + -DLC32_PRESERVE_GUEST_SDK=1 -I"$repo/Tweak" \ | |
| + "$repo/Scripts/inject-standalone.m" "$repo/Tweak/FatMachO.c" \ | |
| + "$repo/Tweak/MachOImage.c" "$repo/Tweak/AdHocSigner.c" \ | |
| + -framework Foundation -framework Security -o "$work/inject" | |
| +staged=$game | |
| +if [[ $format == app ]]; then | |
| + staged="$work/Standalone.app" | |
| + mkdir "$staged" | |
| + rsync -aH "$game/" "$staged/" | |
| +fi | |
| +"$work/inject" "$staged" "$runtime" | |
| +mkdir -p "$staged/Frameworks" | |
| +rsync -aH "$runtime/Frameworks/" "$staged/Frameworks/" | |
| +rsync -aH "$runtime/RootFS/" "$staged/RootFS/" | |
| +# Existing resource seals no longer describe this bundle. Do not alter the | |
| +# preserved ARM32 slice or pretend the injector's arm64 ad-hoc signature signs the app. | |
| +rm -rf -- "$staged/_CodeSignature" | |
| +if [[ $format == ipa ]]; then | |
| + # -y stores symlinks as links instead of following RootFS links on the Mac. | |
| + (cd "$work/game-archive" && zip -qry "$work/Standalone.ipa" .) | |
| + staged="$work/Standalone.ipa" | |
| +fi | |
| +if [[ $in_place -eq 1 ]]; then | |
| + [[ ! -e "$backup" && ! -L "$backup" ]] || fail "backup appeared while preparing the app" | |
| + mv -n -- "$input" "$backup" | |
| + [[ ! -e "$input" && ! -L "$input" ]] || fail "could not move the original to its backup" | |
| +fi | |
| +[[ ! -e "$output" && ! -L "$output" ]] || fail "output appeared while preparing the app" | |
| +mv -n -- "$staged" "$output" | |
| +[[ ! -e "$staged" ]] || fail "output was not published" | |
| +echo "Prepared: $output" | |
| +[[ -z "$backup" ]] || echo "Original backup: $backup" | |
| +echo "Re-sign the complete bundle and provide JIT before launching on a compatible iOS version." | |
| diff --git a/docs/standalone.md b/docs/standalone.md | |
| new file mode 100644 | |
| index 0000000..129c828 | |
| --- /dev/null | |
| +++ b/docs/standalone.md | |
| @@ -0,0 +1,78 @@ | |
| +# Standalone runtime | |
| + | |
| +[Back to the README](../README.md) · [Building](building.md) | |
| + | |
| +Bundle LiveExec32 with a **decrypted ARM32 iOS app** to prepare it for launching | |
| +without LiveContainer or a separately installed LiveExec32. This is an | |
| +experimental packaging workflow: it does not enable JIT, sign the complete app, | |
| +or install it. The resulting app requires an iOS version supported by the bundled | |
| +runtime, a compatible signing and installation method, and working JIT access. | |
| + | |
| +## Requirements | |
| + | |
| +Run from this repository on macOS with Xcode Command Line Tools and `rsync`. | |
| +IPA handling uses the system `unzip` and `zip`; packaging does not require Python. | |
| +First [build the normal iOS runtime](building.md) (not `LC32_BUILD_CATALYST=1`), | |
| +or use a built LiveExec32 `.app` or `.ipa` containing standalone support. | |
| +Theos is not required to package an already built runtime. Older launchers | |
| +without bundled RootFS support are rejected with a rebuild message. | |
| + | |
| +## Usage | |
| + | |
| +Both the game and runtime inputs can independently be `.app` directories or | |
| +`.ipa` archives. Run the following commands from the repository root: | |
| + | |
| +```bash | |
| +# Default: replace the input, saving the original as Game.app.lc32-backup. | |
| +bash Scripts/inject-standalone.sh "/path/to/Game.app" ".theos/obj/LiveExec32.app" | |
| + | |
| +# IPA input is automatically extracted, patched, and archived back to an IPA. | |
| +# The original archive is saved as Game.ipa.lc32-backup. | |
| +bash Scripts/inject-standalone.sh "/path/to/Game.ipa" "/path/to/LiveExec32.ipa" | |
| + | |
| +# Or leave the input untouched and create a new output (which must not exist). | |
| +bash Scripts/inject-standalone.sh --output "/path/to/Standalone.ipa" \ | |
| + "/path/to/Game.ipa" ".theos/obj/LiveExec32.app" | |
| +``` | |
| + | |
| +`--output` is optional. Without it, the script replaces the input only after | |
| +preparation succeeds, keeping an adjacent `.lc32-backup` of the original. | |
| +An existing backup is never overwritten. `--in-place` is accepted but unnecessary. | |
| +With `--output`, its parent directory must exist and its extension must match | |
| +the game input: `.app` produces `.app`, and `.ipa` produces `.ipa`. | |
| +Each IPA must contain exactly one app directly under `Payload/`. | |
| + | |
| +The script reuses the jailbreak injector to add the ARM64 launcher while | |
| +preserving the original ARM32 slices and their SDK behavior. It embeds the | |
| +runtime's `Frameworks` and `RootFS`, preserves existing nonconflicting game | |
| +frameworks, and updates the minimum OS and CPU requirements. The launcher then | |
| +uses the bundled RootFS and the app's own data container. IPA repacking keeps | |
| +the original archive's other files, Unix permissions, and symbolic links; | |
| +hard links become separate files in the ZIP archive. | |
| + | |
| +## Signing and limitations | |
| + | |
| +Re-sign the **complete modified bundle**, including embedded native frameworks, | |
| +using your installation method. The injector's ad-hoc ARM64 signature alone is | |
| +not an installable app signature, and ordinary sideloading alone does not grant | |
| +JIT. An output IPA is repackaged, not fully signed; use an installer/signing tool | |
| +that signs its contents, or extract it, sign the app, and rearchive it under | |
| +`Payload/`. Keep the original backup outside that archive. | |
| + | |
| +This script does not download games or decrypt executables. It refuses encrypted, | |
| +native ARM64, or already-injected inputs, existing output/backup paths, and | |
| +runtime-framework collisions. To repackage with a newer runtime, start with the | |
| +untouched original or a backup copied back to a `.app` directory or `.ipa` file. | |
| +Quit the app before replacing its bundle. | |
| + | |
| +## Local tests | |
| + | |
| +Run `gmake -C test check-standalone` for local packaging and launcher-path | |
| +regressions (the test harness requires Python 3). To also test with your built | |
| +runtime: | |
| + | |
| +```bash | |
| +LC32_TEST_RUNTIME_APP="$PWD/.theos/obj/LiveExec32.app" gmake -C test check-standalone | |
| +``` | |
| + | |
| +These tests do not certify device signing, JIT, or game compatibility. | |
| diff --git a/test/Makefile b/test/Makefile | |
| index 5bf3be9..16ff079 100644 | |
| --- a/test/Makefile | |
| +++ b/test/Makefile | |
| @@ -1,5 +1,5 @@ | |
| LC32_HOST_TEST_GOALS := check-guest-bootstrap check-memory-hash \ | |
| - check-coremedia-time-values-host check-debug-logging check-objc-trace check-build-info \ | |
| + check-coremedia-time-values-host check-debug-logging check-objc-trace check-build-info check-standalone \ | |
| check-guest-thumb-linker check-uikit-legacy-rootless-rotation-build \ | |
| check-scalar-callback-signature check-guest-timer-queue check-legacy-nib-loading \ | |
| check-mach-exception-ports check-uikit-background-tasks check-mediaplayer-stop \ | |
| @@ -33,13 +33,16 @@ BUILD_INFO_LOGGING_HOST_TESTS := $(addprefix $(HOST_TEST_OUTPUT_DIR)/build-info- | |
| present missing) | |
| .PHONY: check-guest-bootstrap check-memory-hash \ | |
| - check-coremedia-time-values-host check-debug-logging check-objc-trace check-build-info \ | |
| + check-coremedia-time-values-host check-debug-logging check-objc-trace check-build-info check-standalone \ | |
| check-guest-thumb-linker check-uikit-legacy-rootless-rotation-build \ | |
| check-scalar-callback-signature check-guest-timer-queue check-legacy-nib-loading \ | |
| check-mach-exception-ports check-uikit-background-tasks check-mediaplayer-stop \ | |
| check-foundation-ports-host check-uikit-compatibility-switch check-uikit-status-bar-orientation \ | |
| check-guest-install check-host-selector-hooks check-uikit-screen-metrics-host | |
| +check-standalone: | |
| + python3 ./standalone.py -v | |
| + | |
| check-uikit-screen-metrics-host: | |
| sh ./uikit_screen_metrics_host.sh | |
| diff --git a/test/standalone-stubs/libroot.h b/test/standalone-stubs/libroot.h | |
| new file mode 100644 | |
| index 0000000..318dce3 | |
| --- /dev/null | |
| +++ b/test/standalone-stubs/libroot.h | |
| @@ -0,0 +1,13 @@ | |
| +#pragma once | |
| +#include <limits.h> | |
| +#include <stdlib.h> | |
| +#include <string.h> | |
| + | |
| +#define JBROOT_PATH_CSTRING(path) getenv("LC32_TEST_INSTALLED_FRAMEWORKS") | |
| +static inline const char *libroot_dyn_jbrootpath(const char *path, char *output) { | |
| + (void)path; | |
| + const char *installed = getenv("LC32_TEST_INSTALLED_LAUNCHER"); | |
| + if(!installed || strlen(installed) >= PATH_MAX) return NULL; | |
| + strcpy(output, installed); | |
| + return output; | |
| +} | |
| diff --git a/test/standalone.py b/test/standalone.py | |
| new file mode 100644 | |
| index 0000000..d1f23b3 | |
| --- /dev/null | |
| +++ b/test/standalone.py | |
| @@ -0,0 +1,441 @@ | |
| +#!/usr/bin/env python3 | |
| +"""Local packaging and launcher-contract tests; no game, device, or JIT needed.""" | |
| +import os | |
| +from pathlib import Path | |
| +import plistlib | |
| +import shutil | |
| +import stat | |
| +import struct | |
| +import subprocess | |
| +import tempfile | |
| +import unittest | |
| +import zipfile | |
| + | |
| +REPO = Path(__file__).resolve().parents[1] | |
| +SCRIPT = REPO / "Scripts/inject-standalone.sh" | |
| + | |
| + | |
| +def run(*args, **kwargs): | |
| + return subprocess.run([str(arg) for arg in args], check=True, | |
| + capture_output=True, text=True, **kwargs) | |
| + | |
| + | |
| +def arm32(subtype=9, encrypted=False): | |
| + commands = struct.pack("<II16sIIIIiiII", 1, 56, b"__TEXT", 0x1000, | |
| + 0x1000, 0, 512, 5, 5, 0, 0) | |
| + commands += struct.pack("<IIII", 0x25, 16, 0x70000, 0x70000) | |
| + if encrypted: | |
| + commands += struct.pack("<IIIII", 0x21, 20, 256, 128, 1) | |
| + header = struct.pack("<7I", 0xFEEDFACE, 12, subtype, 2, | |
| + 3 if encrypted else 2, len(commands), 0) | |
| + return (header + commands).ljust(512, b"\0") | |
| + | |
| + | |
| +def slices(binary): | |
| + magic, count = struct.unpack_from(">II", binary) | |
| + assert magic == 0xCAFEBABE | |
| + return {cpu: binary[offset:offset + size] for cpu, _, offset, size, _ in | |
| + (struct.unpack_from(">5I", binary, 8 + 20 * i) for i in range(count))} | |
| + | |
| + | |
| +class StandaloneTests(unittest.TestCase): | |
| + @classmethod | |
| + def setUpClass(cls): | |
| + cls.build = tempfile.TemporaryDirectory(prefix="lc32-standalone-build-") | |
| + cls.addClassCleanup(cls.build.cleanup) | |
| + cls.build_path = Path(cls.build.name) | |
| + cls.launcher = cls.build_path / "launcher" | |
| + cls.framework = cls.build_path / "LiveExec32Shared" | |
| + run("xcrun", "--sdk", "macosx", "clang", "-arch", "arm64", "-Wall", "-Wextra", "-Werror", | |
| + "-Wl,-headerpad,0x1000", "-Wl,-rpath,@executable_path/Frameworks", | |
| + "-I" + str(REPO / "test/standalone-stubs"), REPO / "App/main.c", "-o", cls.launcher) | |
| + run("xcrun", "--sdk", "macosx", "clang", "-arch", "arm64", "-dynamiclib", | |
| + REPO / "test/standalone_runtime_stub.c", "-o", cls.framework) | |
| + | |
| + def setUp(self): | |
| + self.temp = tempfile.TemporaryDirectory(prefix="lc32-standalone-test-") | |
| + self.addCleanup(self.temp.cleanup) | |
| + self.root = Path(self.temp.name).resolve() | |
| + self.game = self.root / "Game With Spaces.app" | |
| + self.runtime = self.root / "LiveExec32.app" | |
| + self.output = self.root / "Standalone Output.app" | |
| + self.game.mkdir() | |
| + self.runtime.mkdir() | |
| + self.original = arm32() | |
| + (self.game / "Game").write_bytes(self.original) | |
| + (self.game / "Game").chmod(0o751) | |
| + self.info = {"CFBundleExecutable": "Game", "CFBundleIdentifier": "org.liveexec32.test.game", | |
| + "CFBundleDisplayName": "Original Game", "MinimumOSVersion": "7.0", | |
| + "UIRequiredDeviceCapabilities": ["armv7", "opengles-1"], | |
| + "UISupportedInterfaceOrientations": ["UIInterfaceOrientationLandscapeLeft"]} | |
| + self.write_info(self.game, self.info) | |
| + self.write_info(self.runtime, {"CFBundleExecutable": "LiveExec32", "MinimumOSVersion": "15.0"}) | |
| + run("xcrun", "vtool", "-set-build-version", "2", "15.0", "27.0", "-replace", | |
| + "-output", self.runtime / "LiveExec32", self.launcher) | |
| + run("codesign", "--force", "--sign", "-", self.runtime / "LiveExec32") | |
| + for relative in ("RootFS/usr/lib/dyld", "RootFS/System/Library/Frameworks/LC32.framework/LC32", | |
| + "Frameworks/LiveExec32Shared.framework/LiveExec32Shared"): | |
| + path = self.runtime / relative | |
| + path.parent.mkdir(parents=True, exist_ok=True) | |
| + path.write_bytes(b"fixture") | |
| + os.link(self.runtime / "RootFS/usr/lib/dyld", self.runtime / "RootFS/usr/lib/dyld-hardlink") | |
| + (self.runtime / "RootFS/lib").symlink_to("usr/lib") | |
| + (self.game / "Frameworks/Original.framework").mkdir(parents=True) | |
| + (self.game / "Frameworks/Original.framework/asset").write_bytes(b"keep") | |
| + (self.game / "_CodeSignature").mkdir() | |
| + (self.game / "_CodeSignature/CodeResources").write_bytes(b"stale seal") | |
| + | |
| + def write_info(self, app, info): | |
| + (app / "Info.plist").write_bytes(plistlib.dumps(info)) | |
| + | |
| + def package(self, *options, ok=True): | |
| + result = subprocess.run(["/bin/bash", str(SCRIPT), *map(str, options), str(self.game), | |
| + str(self.runtime)], capture_output=True, text=True) | |
| + self.assertEqual(result.returncode == 0, ok, result.stdout + result.stderr) | |
| + self.assertFalse(list(self.root.glob(".lc32-standalone.*")), "staging directories leaked") | |
| + return result | |
| + | |
| + def archive_app(self, app): | |
| + ipa = self.root / (app.stem + ".ipa") | |
| + # Make fixtures independently of the packager's zip command. | |
| + with zipfile.ZipFile(ipa, "w", zipfile.ZIP_DEFLATED) as archive: | |
| + prefix = Path("Payload") / app.name | |
| + archive.write(app, str(prefix)) | |
| + for directory, directories, files in os.walk(app, followlinks=False): | |
| + for name in directories + files: | |
| + path = Path(directory) / name | |
| + relative = str(prefix / path.relative_to(app)) | |
| + if path.is_symlink(): | |
| + entry = zipfile.ZipInfo(relative) | |
| + entry.create_system = 3 | |
| + entry.external_attr = path.lstat().st_mode << 16 | |
| + archive.writestr(entry, os.readlink(path)) | |
| + else: | |
| + archive.write(path, relative) | |
| + archive.writestr("iTunesMetadata.plist", b"original metadata") | |
| + archive.writestr(".hidden-asset", b"keep hidden files") | |
| + return ipa | |
| + | |
| + def extract_app(self, ipa): | |
| + destination = self.root / "unpacked" | |
| + run("/usr/bin/unzip", "-q", ipa, "-d", destination) | |
| + return next((destination / "Payload").glob("*.app")) | |
| + | |
| + def verify(self, app, hardlinks=True, minimum="15.0"): | |
| + images = slices((app / "Game").read_bytes()) | |
| + self.assertEqual(images[12], self.original) | |
| + self.assertEqual(stat.S_IMODE((app / "Game").stat().st_mode), 0o751) | |
| + header = struct.unpack_from("<8I", images[0x100000C]) | |
| + offset = 32 | |
| + sdk = None | |
| + for _ in range(header[4]): | |
| + command, size = struct.unpack_from("<II", images[0x100000C], offset) | |
| + if command == 0x32: | |
| + sdk = struct.unpack_from("<6I", images[0x100000C], offset)[4] | |
| + offset += size | |
| + self.assertEqual(sdk, 0x70000, "guest SDK changed") | |
| + info = plistlib.loads((app / "Info.plist").read_bytes()) | |
| + self.assertEqual(info["MinimumOSVersion"], minimum) | |
| + self.assertEqual(info["CFBundleExecutable"], "Game") | |
| + self.assertEqual(info["CFBundleIdentifier"], self.info["CFBundleIdentifier"]) | |
| + self.assertEqual(info["UISupportedInterfaceOrientations"], self.info["UISupportedInterfaceOrientations"]) | |
| + self.assertEqual((app / "Frameworks/Original.framework/asset").read_bytes(), b"keep") | |
| + self.assertEqual(os.readlink(app / "RootFS/lib"), "usr/lib") | |
| + self.assertEqual((app / "RootFS/usr/lib/dyld").read_bytes(), | |
| + (app / "RootFS/usr/lib/dyld-hardlink").read_bytes()) | |
| + if hardlinks: | |
| + self.assertEqual((app / "RootFS/usr/lib/dyld").stat().st_ino, | |
| + (app / "RootFS/usr/lib/dyld-hardlink").stat().st_ino) | |
| + self.assertFalse((app / "_CodeSignature").exists()) | |
| + return info | |
| + | |
| + def test_output_preserves_input_and_guest_sdk(self): | |
| + self.package("--output", self.output) | |
| + info = self.verify(self.output) | |
| + self.assertEqual(info["UIRequiredDeviceCapabilities"], ["opengles-1", "arm64"]) | |
| + self.assertEqual((self.game / "Game").read_bytes(), self.original) | |
| + self.assertTrue((self.game / "_CodeSignature/CodeResources").exists()) | |
| + | |
| + def test_default_is_in_place_with_backup(self): | |
| + self.package() | |
| + self.verify(self.game) | |
| + backup = Path(str(self.game) + ".lc32-backup") | |
| + self.assertEqual((backup / "Game").read_bytes(), self.original) | |
| + self.assertEqual(plistlib.loads((backup / "Info.plist").read_bytes()), self.info) | |
| + | |
| + def test_backported_runtime_minimum_is_respected(self): | |
| + for minimum in ("11.0", "12.0", "14.0"): | |
| + with self.subTest(minimum=minimum): | |
| + self.write_info(self.runtime, {"CFBundleExecutable": "LiveExec32", | |
| + "MinimumOSVersion": minimum}) | |
| + run("xcrun", "vtool", "-set-build-version", "2", minimum, "27.0", "-replace", | |
| + "-output", self.runtime / "LiveExec32", self.launcher) | |
| + run("codesign", "--force", "--sign", "-", self.runtime / "LiveExec32") | |
| + output = self.root / ("Standalone-" + minimum + ".app") | |
| + self.package("--output", output) | |
| + self.verify(output, minimum=minimum) | |
| + | |
| + def test_higher_game_minimum_is_preserved(self): | |
| + self.info["MinimumOSVersion"] = "16.0" | |
| + self.write_info(self.game, self.info) | |
| + self.package("--output", self.output) | |
| + self.verify(self.output, minimum="16.0") | |
| + | |
| + def test_invalid_runtime_minimum_is_rejected(self): | |
| + for minimum in (None, "", "14.invalid", 14): | |
| + with self.subTest(minimum=minimum): | |
| + info = {"CFBundleExecutable": "LiveExec32"} | |
| + if minimum is not None: | |
| + info["MinimumOSVersion"] = minimum | |
| + self.write_info(self.runtime, info) | |
| + self.assertIn("invalid runtime MinimumOSVersion", self.package(ok=False).stderr) | |
| + self.assertEqual((self.game / "Game").read_bytes(), self.original) | |
| + self.assertFalse(Path(str(self.game) + ".lc32-backup").exists()) | |
| + | |
| + def test_ipa_output_preserves_input_metadata_and_links(self): | |
| + (self.game / "asset-link").symlink_to("Frameworks/Original.framework/asset") | |
| + (self.runtime / "RootFS/guest-only-link").symlink_to("/lc32-guest-only/lib") | |
| + self.game = self.archive_app(self.game) | |
| + original = self.game.read_bytes() | |
| + self.output = self.output.with_suffix(".ipa") | |
| + self.package("--output", self.output) | |
| + app = self.extract_app(self.output) | |
| + self.verify(app, hardlinks=False) | |
| + self.assertEqual(os.readlink(app / "asset-link"), "Frameworks/Original.framework/asset") | |
| + self.assertEqual(os.readlink(app / "RootFS/guest-only-link"), "/lc32-guest-only/lib") | |
| + self.assertEqual(self.game.read_bytes(), original) | |
| + with zipfile.ZipFile(self.output) as archive: | |
| + self.assertEqual(archive.testzip(), None) | |
| + self.assertEqual(archive.read("iTunesMetadata.plist"), b"original metadata") | |
| + self.assertEqual(archive.read(".hidden-asset"), b"keep hidden files") | |
| + self.assertFalse(any("lc32-backup" in name for name in archive.namelist())) | |
| + | |
| + def test_ipa_default_with_runtime_ipa_and_backup(self): | |
| + self.game = self.archive_app(self.game) | |
| + self.runtime = self.archive_app(self.runtime) | |
| + original = self.game.read_bytes() | |
| + runtime_original = self.runtime.read_bytes() | |
| + self.package() | |
| + self.verify(self.extract_app(self.game), hardlinks=False) | |
| + self.assertEqual(Path(str(self.game) + ".lc32-backup").read_bytes(), original) | |
| + self.assertEqual(self.runtime.read_bytes(), runtime_original) | |
| + | |
| + def test_app_accepts_runtime_ipa(self): | |
| + self.runtime = self.archive_app(self.runtime) | |
| + self.package("--output", self.output) | |
| + self.verify(self.output, hardlinks=False) | |
| + | |
| + def test_output_format_must_match_input(self): | |
| + self.package("--output", self.output.with_suffix(".ipa"), ok=False) | |
| + self.game = self.archive_app(self.game) | |
| + original = self.game.read_bytes() | |
| + self.package("--output", self.output, ok=False) | |
| + self.assertEqual(self.game.read_bytes(), original) | |
| + | |
| + def test_invalid_and_ambiguous_ipas_are_rejected(self): | |
| + self.game = self.archive_app(self.game) | |
| + with zipfile.ZipFile(self.game, "a") as archive: | |
| + archive.writestr("Payload/Other.app/Info.plist", b"other app") | |
| + original = self.game.read_bytes() | |
| + self.assertIn("exactly one app", self.package(ok=False).stderr) | |
| + self.assertEqual(self.game.read_bytes(), original) | |
| + self.game.write_bytes(b"not a zip") | |
| + self.package(ok=False) | |
| + self.assertEqual(self.game.read_bytes(), b"not a zip") | |
| + self.assertFalse(Path(str(self.game) + ".lc32-backup").exists()) | |
| + | |
| + def test_ipa_traversal_and_symlink_payload_are_rejected(self): | |
| + app = self.game | |
| + self.game = self.root / "Unsafe.ipa" | |
| + for path in ("../outside", "/absolute", "Payload/../../outside"): | |
| + with self.subTest(path=path): | |
| + with zipfile.ZipFile(self.game, "w") as archive: | |
| + archive.writestr(path, b"must not extract") | |
| + self.assertIn("unsafe IPA entry", self.package(ok=False).stderr) | |
| + with zipfile.ZipFile(self.game, "w") as archive: | |
| + link = zipfile.ZipInfo("Payload") | |
| + link.create_system = 3 | |
| + link.external_attr = (stat.S_IFLNK | 0o777) << 16 | |
| + archive.writestr(link, str(self.root)) | |
| + self.assertIn("real Payload directory", self.package(ok=False).stderr) | |
| + self.assertEqual((app / "Game").read_bytes(), self.original) | |
| + | |
| + def test_ipa_symlink_cannot_redirect_extraction(self): | |
| + app = self.game | |
| + self.game = self.root / "Symlink.ipa" | |
| + with zipfile.ZipFile(self.game, "w") as archive: | |
| + link = zipfile.ZipInfo("Payload/Redirect.app") | |
| + link.create_system = 3 | |
| + link.external_attr = (stat.S_IFLNK | 0o777) << 16 | |
| + archive.writestr(link, str(app)) | |
| + archive.writestr("Payload/Redirect.app/Game", b"must not overwrite the original") | |
| + self.package(ok=False) | |
| + self.assertEqual((app / "Game").read_bytes(), self.original) | |
| + | |
| + def test_ipa_archive_failure_leaves_original_untouched(self): | |
| + self.game = self.archive_app(self.game) | |
| + original = self.game.read_bytes() | |
| + utilities = self.root / "utilities" | |
| + utilities.mkdir() | |
| + zipper = utilities / "zip" | |
| + zipper.write_text('#!/bin/bash\nexit 97\n') | |
| + zipper.chmod(0o755) | |
| + environment = dict(os.environ, PATH=str(utilities) + ":" + os.environ["PATH"]) | |
| + result = subprocess.run(["/bin/bash", str(SCRIPT), str(self.game), str(self.runtime)], | |
| + env=environment, capture_output=True, text=True) | |
| + self.assertEqual(result.returncode, 97, result.stderr) | |
| + self.assertEqual(self.game.read_bytes(), original) | |
| + self.assertFalse(Path(str(self.game) + ".lc32-backup").exists()) | |
| + self.assertFalse(list(self.root.glob(".lc32-standalone.*"))) | |
| + | |
| + def test_all_arm32_slices_are_preserved(self): | |
| + armv6 = arm32(subtype=6) | |
| + payload = struct.pack(">II", 0xCAFEBABE, 2) | |
| + payload += struct.pack(">5I", 12, 6, 4096, len(armv6), 12) | |
| + payload += struct.pack(">5I", 12, 9, 8192, len(self.original), 12) | |
| + payload = payload.ljust(4096, b"\0") + armv6 | |
| + payload = payload.ljust(8192, b"\0") + self.original | |
| + (self.game / "Game").write_bytes(payload) | |
| + self.package("--output", self.output) | |
| + result = (self.output / "Game").read_bytes() | |
| + self.assertEqual(struct.unpack_from(">II", result)[1], 3) | |
| + for i, expected in ((1, armv6), (2, self.original)): | |
| + _, _, offset, size, _ = struct.unpack_from(">5I", result, 8 + i * 20) | |
| + self.assertEqual(result[offset:offset + size], expected) | |
| + | |
| + def test_copy_failure_does_not_replace_the_app(self): | |
| + utilities = self.root / "utilities" | |
| + utilities.mkdir() | |
| + # Fail the final RootFS copy, after successful executable injection. | |
| + rsync = utilities / "rsync" | |
| + rsync.write_text('#!/bin/bash\ncase "$*" in *RootFS*) exit 99 ;; esac\n' | |
| + 'exec /usr/bin/rsync "$@"\n') | |
| + rsync.chmod(0o755) | |
| + environment = dict(os.environ, PATH=str(utilities) + ":" + os.environ["PATH"]) | |
| + result = subprocess.run(["/bin/bash", str(SCRIPT), str(self.game), str(self.runtime)], | |
| + env=environment, capture_output=True, text=True) | |
| + self.assertEqual(result.returncode, 99, result.stderr) | |
| + self.assertEqual((self.game / "Game").read_bytes(), self.original) | |
| + self.assertTrue((self.game / "_CodeSignature/CodeResources").exists()) | |
| + self.assertFalse(Path(str(self.game) + ".lc32-backup").exists()) | |
| + self.assertFalse(list(self.root.glob(".lc32-standalone.*"))) | |
| + | |
| + def test_publish_failure_restores_the_original(self): | |
| + utilities = self.root / "utilities" | |
| + utilities.mkdir() | |
| + move = utilities / "mv" | |
| + move.write_text('#!/bin/bash\ncase "$*" in *Standalone.app*) exit 98 ;; esac\n' | |
| + 'exec /bin/mv "$@"\n') | |
| + move.chmod(0o755) | |
| + environment = dict(os.environ, PATH=str(utilities) + ":" + os.environ["PATH"]) | |
| + result = subprocess.run(["/bin/bash", str(SCRIPT), str(self.game), str(self.runtime)], | |
| + env=environment, capture_output=True, text=True) | |
| + self.assertEqual(result.returncode, 98, result.stderr) | |
| + self.assertEqual((self.game / "Game").read_bytes(), self.original) | |
| + self.assertEqual(plistlib.loads((self.game / "Info.plist").read_bytes()), self.info) | |
| + self.assertFalse(Path(str(self.game) + ".lc32-backup").exists()) | |
| + self.assertFalse(list(self.root.glob(".lc32-standalone.*"))) | |
| + | |
| + def test_explicit_in_place_and_dictionary_capabilities(self): | |
| + self.info["UIRequiredDeviceCapabilities"] = {"armv7": True, "arm64": False, "gps": False} | |
| + self.write_info(self.game, self.info) | |
| + self.package("--in-place") | |
| + self.assertEqual(self.verify(self.game)["UIRequiredDeviceCapabilities"], {"arm64": True, "gps": False}) | |
| + | |
| + def test_existing_output_and_conflicting_options_are_rejected(self): | |
| + self.output.mkdir() | |
| + sentinel = self.output / "keep" | |
| + sentinel.write_text("unchanged") | |
| + self.package("--output", self.output, ok=False) | |
| + self.package("--in-place", "--output", self.output, ok=False) | |
| + self.assertEqual(sentinel.read_text(), "unchanged") | |
| + self.assertEqual((self.game / "Game").read_bytes(), self.original) | |
| + | |
| + def test_framework_collision_and_existing_backup_are_rejected(self): | |
| + collision = self.game / "Frameworks/LiveExec32Shared.framework" | |
| + collision.mkdir() | |
| + self.package(ok=False) | |
| + collision.rmdir() | |
| + Path(str(self.game) + ".lc32-backup").mkdir() | |
| + self.package(ok=False) | |
| + self.assertEqual((self.game / "Game").read_bytes(), self.original) | |
| + | |
| + def test_invalid_encrypted_and_native_inputs_leave_source_untouched(self): | |
| + for payload in (b"not Mach-O", arm32(encrypted=True), self.launcher.read_bytes()): | |
| + with self.subTest(payload_size=len(payload)): | |
| + (self.game / "Game").write_bytes(payload) | |
| + self.package(ok=False) | |
| + self.assertEqual((self.game / "Game").read_bytes(), payload) | |
| + self.assertFalse(Path(str(self.game) + ".lc32-backup").exists()) | |
| + | |
| + def test_unsafe_executable_and_nested_output_are_rejected(self): | |
| + self.info["CFBundleExecutable"] = "../outside" | |
| + self.write_info(self.game, self.info) | |
| + self.package(ok=False) | |
| + self.package("--output", self.game / "Nested.app", ok=False) | |
| + self.assertEqual((self.game / "Game").read_bytes(), self.original) | |
| + | |
| + def test_old_and_non_ios_launchers_are_rejected(self): | |
| + launcher = self.runtime / "LiveExec32" | |
| + launcher.write_bytes(launcher.read_bytes().replace(b"LiveExec32Standalone:1", b"LiveExec32Standalone:0")) | |
| + result = self.package(ok=False) | |
| + self.assertIn("lacks bundled RootFS support", result.stderr) | |
| + shutil.copyfile(self.launcher, launcher) | |
| + result = self.package(ok=False) | |
| + self.assertIn("device iOS build", result.stderr) | |
| + | |
| + @unittest.skipUnless(os.environ.get("LC32_TEST_RUNTIME_APP"), "optional built-runtime smoke test") | |
| + def test_built_runtime(self): | |
| + self.runtime = Path(os.environ["LC32_TEST_RUNTIME_APP"]).resolve() | |
| + self.package("--output", self.output) | |
| + self.assertEqual(slices((self.output / "Game").read_bytes())[12], self.original) | |
| + for relative in ("RootFS/usr/lib/dyld", "RootFS/System/Library/Frameworks/LC32.framework/LC32", | |
| + "Frameworks/LiveExec32Shared.framework/LiveExec32Shared"): | |
| + self.assertEqual((self.output / relative).read_bytes(), (self.runtime / relative).read_bytes()) | |
| + | |
| + @unittest.skipUnless(os.environ.get("LC32_TEST_RUNTIME_APP"), "optional built-runtime IPA smoke test") | |
| + def test_built_runtime_ipa(self): | |
| + runtime = Path(os.environ["LC32_TEST_RUNTIME_APP"]).resolve() | |
| + self.runtime = self.archive_app(runtime) | |
| + self.game = self.archive_app(self.game) | |
| + self.package() | |
| + app = self.extract_app(self.game) | |
| + self.assertEqual(slices((app / "Game").read_bytes())[12], self.original) | |
| + for relative in ("RootFS/usr/lib/dyld", "RootFS/System/Library/Frameworks/LC32.framework/LC32", | |
| + "Frameworks/LiveExec32Shared.framework/LiveExec32Shared"): | |
| + self.assertEqual((app / relative).read_bytes(), (runtime / relative).read_bytes()) | |
| + | |
| + def test_real_launcher_prefers_bundled_runtime_and_preserves_arguments(self): | |
| + shutil.copyfile(self.launcher, self.game / "Game") | |
| + (self.game / "Game").chmod(0o755) | |
| + (self.game / "RootFS").mkdir() | |
| + framework = self.game / "Frameworks/LiveExec32Shared.framework/LiveExec32Shared" | |
| + framework.parent.mkdir() | |
| + shutil.copyfile(self.framework, framework) | |
| + environment = dict(os.environ, HOME=str(self.root), ROOT_PATH="/wrong", | |
| + NATIVE_GUEST_THREADS="0", DYLD_PATH="/wrong", | |
| + LC32_TEST_INSTALLED_LAUNCHER="/missing/LiveExec32.app/LiveExec32") | |
| + result = run(self.game / "Game", "level 1", "--flag", env=environment) | |
| + self.assertIn(f"root={self.game}/RootFS\n", result.stdout) | |
| + self.assertIn(f"argv0={self.game}/Game\n", result.stdout) | |
| + self.assertIn(f"argv1={self.game}/Game\n", result.stdout) | |
| + self.assertIn("argv2=level 1\nargv3=--flag\n", result.stdout) | |
| + self.assertIn("native-threads=unset\ndyld=unset\n", result.stdout) | |
| + self.assertIn(f"home={self.root}\n", result.stdout) | |
| + # Without bundled RootFS, retain the jailbreak-injected launch contract. | |
| + (self.game / "RootFS").rmdir() | |
| + environment["LC32_TEST_INSTALLED_LAUNCHER"] = str(self.runtime / "LiveExec32") | |
| + result = run(self.game / "Game", env=environment) | |
| + self.assertIn(f"root={self.runtime}/RootFS\n", result.stdout) | |
| + self.assertIn(f"argv0={self.runtime}/LiveExec32\n", result.stdout) | |
| + # The ordinary CLI path must still forward the caller's argv unchanged. | |
| + cli = self.game / "LiveExec32" | |
| + shutil.copyfile(self.launcher, cli) | |
| + cli.chmod(0o755) | |
| + result = run(cli, "/guest/program", env=environment) | |
| + self.assertIn(f"argc=2\nargv0={cli}\nargv1=/guest/program\n", result.stdout) | |
| + self.assertIn("root=/wrong\n", result.stdout) | |
| + | |
| + | |
| +if __name__ == "__main__": | |
| + unittest.main() | |
| diff --git a/test/standalone_runtime_stub.c b/test/standalone_runtime_stub.c | |
| new file mode 100644 | |
| index 0000000..0e3a7a6 | |
| --- /dev/null | |
| +++ b/test/standalone_runtime_stub.c | |
| @@ -0,0 +1,14 @@ | |
| +// Host-only endpoint for testing the real launcher's path/argument contract. | |
| +#include <stdio.h> | |
| +#include <stdlib.h> | |
| + | |
| +int LC32RunGuest(int argc, char *argv[], char *envp[]) { | |
| + (void)envp; | |
| + printf("argc=%d\n", argc); | |
| + for(int i = 0; i < argc; ++i) printf("argv%d=%s\n", i, argv[i]); | |
| + printf("root=%s\n", getenv("ROOT_PATH")); | |
| + printf("home=%s\n", getenv("LC32_GUEST_HOME")); | |
| + printf("native-threads=%s\n", getenv("NATIVE_GUEST_THREADS") ?: "unset"); | |
| + printf("dyld=%s\n", getenv("DYLD_PATH") ?: "unset"); | |
| + return 0; | |
| +} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml | |
| index e85ef61..eb8fe15 100644 | |
| --- a/.github/workflows/nightly.yml | |
| +++ b/.github/workflows/nightly.yml | |
| @@ -107,6 +107,14 @@ jobs: | |
| run: | | |
| printf 'subject=%s\n' "$(git log -1 --pretty=%s)" >> "$GITHUB_OUTPUT" | |
| + - name: Generate nightly app source | |
| + env: | |
| + COMMIT_SUBJECT: ${{ steps.metadata.outputs.subject }} | |
| + NIGHTLY_LINK: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }} | |
| + run: >- | |
| + python3 Scripts/generate-nightly-source.py packages/*.ipa | |
| + --output packages/source.json | |
| + | |
| - name: Upload packages | |
| id: artifact | |
| uses: actions/upload-artifact@v7 | |
| @@ -114,6 +122,7 @@ jobs: | |
| path: | | |
| packages/*.ipa | |
| packages/*.deb | |
| + packages/source.json | |
| if-no-files-found: error | |
| release: | |
| @@ -149,3 +158,4 @@ jobs: | |
| files: | | |
| packages/*.ipa | |
| packages/*.deb | |
| + packages/source.json | |
| diff --git a/README.md b/README.md | |
| index 3c872d9..d709c78 100644 | |
| --- a/README.md | |
| +++ b/README.md | |
| @@ -4,7 +4,7 @@ Run 32-bit binaries on 64-bit iOS by passing through syscalls. | |
| Not all apps will work and will mostly run into missing symbols issue. Please open an issue for that. | |
| > [!NOTE] | |
| -> Some further work in this branch is done by LLM, mainly GPT-5.6 Sol; notable for implementing GDB Stub, Native Threads, more shims, etc. | |
| +> Some further work in this branch is done by LLM, mainly with Codex; notable for implementing GDB Stub, Native Threads, more shims, etc. | |
| > Its commit history is kept for later reference. | |
| > Last commit before LLM is [dbd36e3](https://github.com/LiveContainer/LiveExec32/commit/dbd36e3e42e4e675e6fd542d4a487b61dbdc755d) | |
| > | |
| @@ -30,12 +30,57 @@ gmake -C GuestMakefile install | |
| gmake | |
| ``` | |
| -On the iOS device, launch an ARM32 binary with the installed app's executable: | |
| +### IPA build | |
| +The IPA build is only meant to be used in LiveContainer, since it provides existing app/container management and convenient JIT enabler options. | |
| +<table> | |
| + <tr> | |
| + <td> Stable </td> | |
| + <td align="center"> | |
| + Not yet available | |
| + </td> | |
| + <td align="center"> | |
| + Not yet available | |
| + </td> | |
| + </tr> | |
| + <tr> | |
| + <td> Nightly </td> | |
| + <td> | |
| + <a href="https://altdirect.app/?url=https://github.com/LiveContainer/LiveExec32/releases/download/nightly/source.json&r=livecontainer" target="_blank"> | |
| + <img src="https://raw.githubusercontent.com/StikStore/altdirect/refs/heads/main/assets/png/AltSource_Blue.png" alt="Add AltSource" width="200" /> | |
| + </a> | |
| + </td> | |
| + <td> | |
| + <a href="https://github.com/LiveContainer/LiveExec32/releases/download/nightly/com.kdt.liveexec32_0.0.1.ipa" target="_blank"> | |
| + <img src="https://raw.githubusercontent.com/StikStore/altdirect/refs/heads/main/assets/png/Download_Blue.png" alt="Download .ipa" width="200" /> | |
| + </a> | |
| + </td> | |
| + </tr> | |
| +</table> | |
| + | |
| +### Jailbreak tweak | |
| +The jailbreak tweak lets you sideload decrypted 32-bit apps directly to the system and launch just like any other apps. | |
| +During install, LiveExec32 shim is injected to 32-bit app so installd doesn't reject it and makes everything easier to handle. | |
| + | |
| +Releases only include iOS 15+ rootless build for now. Jailbreak repo will be added later. | |
| + | |
| +### Standalone runtime | |
| + | |
| +You can bundle LiveExec32 with a decrypted ARM32 `.app` or `.ipa` to run without | |
| +LiveContainer or a separately installed runtime. See [Standalone runtime](docs/standalone.md) | |
| +for instructions. Use your signer and bring your own JIT enabler method. | |
| + | |
| +### Command line | |
| +Launch an ARM32 binary with the installed app's executable: | |
| ```bash | |
| /path/to/LiveExec32.app/LiveExec32 /path/to/arm32-binary | |
| ``` | |
| +You can also launch with the 32-bit dyld_shared_cache, for example: | |
| +```bash | |
| +NATIVE_GUEST_THREADS=1 ROOT_PATH=/Volumes/Greensburg14G60.N41N42N48N49OS /path/to/LiveExec32.app/LiveExec32 /Volumes/Greensburg14G60.N41N42N48N49OS/usr/libexec/backboardd | |
| +``` | |
| + | |
| - [Building](docs/building.md): prerequisites, downloads, guest RootFS, and macOS testing. | |
| - [Configuration and diagnostics](docs/configuration.md): logging, guest environment, and SDK/UIKit compatibility. | |
| - [Objective-C proxy bridge](docs/ObjCProxy.md): architecture, ownership, and ABI details. | |
| @@ -60,15 +105,7 @@ host-dependent until their iOS 10 signatures are captured in the tracked | |
| templates. | |
| ## FAQ | |
| -### Can this be used to run 32-bit apps & integrate to LiveContainer? | |
| -Yes. The bundled Dynarmic revision includes the dual-mapping/TXM JIT path | |
| -required by iOS 26+, while non-iOS hosts remain single-mapped by default. | |
| - | |
| -### Will this be available as a jailbreak tweak? | |
| -Yes eta now. During install, LiveExec32 shim is injected to the pending 32-bit | |
| -app so installd doesn't reject it and makes everything easier to handle. | |
| - | |
| -## Will this allow running encrypted 32-bit apps (ie directly installed from App Store)? | |
| +### Will this allow running encrypted 32-bit apps (ie directly installed from App Store)? | |
| Idk, need to research into this next | |
| ## License | |
| diff --git a/Scripts/generate-nightly-source.py b/Scripts/generate-nightly-source.py | |
| new file mode 100644 | |
| index 0000000..f808309 | |
| --- /dev/null | |
| +++ b/Scripts/generate-nightly-source.py | |
| @@ -0,0 +1,111 @@ | |
| +#!/usr/bin/env python3 | |
| +"""Generate the nightly app source from the IPA being released (no network).""" | |
| + | |
| +import argparse | |
| +from datetime import datetime, timezone | |
| +import json | |
| +import os | |
| +from pathlib import Path | |
| +import plistlib | |
| +from urllib.parse import quote | |
| +import zipfile | |
| + | |
| + | |
| +def main(): | |
| + parser = argparse.ArgumentParser(description=__doc__) | |
| + parser.add_argument("ipa", type=Path) | |
| + parser.add_argument("--output", required=True, type=Path) | |
| + args = parser.parse_args() | |
| + | |
| + with zipfile.ZipFile(args.ipa) as archive: | |
| + plists = [name for name in archive.namelist() | |
| + if name.startswith("Payload/") | |
| + and name.endswith(".app/Info.plist") | |
| + and name.count("/") == 2] | |
| + if len(plists) != 1: | |
| + parser.error("IPA must contain exactly one top-level app Info.plist") | |
| + info = plistlib.loads(archive.read(plists[0])) | |
| + | |
| + root = Path(__file__).resolve().parents[1] | |
| + with (root / "entitlements.plist").open("rb") as file: | |
| + entitlements = plistlib.load(file) | |
| + | |
| + repository = os.environ["GITHUB_REPOSITORY"] | |
| + server = os.environ.get("GITHUB_SERVER_URL", "https://github.com").rstrip("/") | |
| + website = f"{server}/{repository}" | |
| + sha = os.environ["GITHUB_SHA"] | |
| + commit = sha[:7] | |
| + headline = os.environ["COMMIT_SUBJECT"].strip() | |
| + description = ( | |
| + f"Nightly build from [{commit}]({website}/commit/{sha}): {headline}\n\n" | |
| + "This is a nightly release " | |
| + "[created automatically with GitHub Actions workflow]" | |
| + f"({os.environ['NIGHTLY_LINK']})." | |
| + ) | |
| + date = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") | |
| + release_url = f"{website}/releases/download/nightly" | |
| + download_url = f"{release_url}/{quote(args.ipa.name)}" | |
| + json_url = f"{release_url}/source.json" | |
| + # LiveExec32 has no standalone icon asset; use the repository owner's avatar. | |
| + icon_url = f"{server}/{repository.split('/')[0]}.png" | |
| + version = { | |
| + "version": info["CFBundleShortVersionString"], | |
| + "buildVersion": info["CFBundleVersion"], | |
| + "date": date, | |
| + "localizedDescription": description, | |
| + "downloadURL": download_url, | |
| + "size": args.ipa.stat().st_size, | |
| + "minOSVersion": info["MinimumOSVersion"], | |
| + "commit": commit, | |
| + "headline": headline, | |
| + } | |
| + app = { | |
| + "name": "LiveExec32 (nightly)", | |
| + "bundleIdentifier": info["CFBundleIdentifier"], | |
| + "developerName": "LiveContainer Team", | |
| + "localizedDescription": "Run 32-bit iOS applications on 64-bit devices.", | |
| + "iconURL": icon_url, | |
| + "category": "utilities", | |
| + "appPermissions": { | |
| + "entitlements": list(entitlements), | |
| + "privacy": {key: value for key, value in info.items() | |
| + if "UsageDescription" in key}, | |
| + }, | |
| + "versions": [version], | |
| + # Keep the legacy fields and LiveContainer's nightly commit metadata. | |
| + "version": version["version"], | |
| + "buildVersion": version["buildVersion"], | |
| + "versionDate": date, | |
| + "versionDescription": description, | |
| + "downloadURL": download_url, | |
| + "size": version["size"], | |
| + "minOSVersion": version["minOSVersion"], | |
| + "commit": commit, | |
| + "headline": headline, | |
| + # AltStore Classic and SideStore reject this as a notarized source. | |
| + # A nonnumeric ID also blocks AltStore PAL. LiveContainer ignores it. | |
| + "marketplaceID": "LiveContainer", | |
| + } | |
| + source = { | |
| + "name": "LiveExec32 (nightly)", | |
| + "identifier": "com.kdt.LiveExec32.source.nightly", | |
| + "website": website, | |
| + "iconURL": icon_url, | |
| + "apps": [app], | |
| + "news": [ | |
| + { | |
| + "title": "LiveExec32", | |
| + "identifier": "NeedLC", | |
| + "tintColor": "FF0F0F", | |
| + "caption": "Cannot use it here! This LiveExec32 repo is only meant to be installed in LiveContainer. Tap here to add it to LiveContainer.", | |
| + "url": f"https://altdirect.app/?url={json_url}&r=livecontainer", | |
| + "date": "2026-10-04T00:00", | |
| + "notify": False | |
| + }, | |
| + ], | |
| + } | |
| + args.output.write_text(json.dumps(source, indent=2) + "\n", encoding="utf-8") | |
| + | |
| + | |
| +if __name__ == "__main__": | |
| + main() | |
| diff --git a/docs/building.md b/docs/building.md | |
| index f2fae36..a1fd205 100644 | |
| --- a/docs/building.md | |
| +++ b/docs/building.md | |
| @@ -157,3 +157,10 @@ Startup logs include that release version, the 7-character Git commit | |
| Detached CI checkouts use `GITHUB_HEAD_REF`/`GITHUB_REF_NAME` for the branch; | |
| source archives without Git metadata use `unknown` for the commit. | |
| Run `gmake -C test check-build-info` for the metadata/logging regressions. | |
| + | |
| +Nightly builds generate `packages/source.json` with | |
| +`Scripts/generate-nightly-source.py` and publish it alongside the IPA and Debian | |
| +package. The source uses the packaged app's version, build number, bundle ID, | |
| +minimum iOS version, and IPA size, plus the current commit and workflow link. | |
| +The nightly source is available as | |
| +[source.json](https://github.com/LiveContainer/LiveExec32/releases/download/nightly/source.json). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment