Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

[Patchless] Add noVphone Flag

Maximilian Paßa6f0bf432661
diff --git a/Makefile b/Makefile
index 0c52c853..0f3f66ee 100644
--- a/Makefile
+++ b/Makefile
@@ -51,6 +51,7 @@ help:
@echo " NONE_INTERACTIVE=1 Auto-continue prompts + boot analysis"
@echo " SUDO_PASSWORD=... Preload sudo credential for setup flow"
@echo " NO_BINPACK=1 Excludes the SSH, VNC, ... binaries from being installed (patchless-only, currently)"
+ @echo " NO_VPHONED=1 Excludes vphoned from being installed (patchless-only, currently)"
@echo ""
@echo "Setup (one-time):"
@echo " make setup_tools Install all tools (brew, trustcache, insert_dylib, venv+pymobiledevice3)"
@@ -76,6 +77,7 @@ help:
@echo " make boot_host_preflight Diagnose whether host can launch signed PV=3 binary"
@echo " make boot Boot VM (reads from config.plist)"
@echo " make boot_less Boot VM in vphoned patchless compatibility"
+ @echo " Options: NO_VPHONED=1 Excludes vphoned from being installed"
@echo " make boot_dfu Boot VM in DFU mode (reads from config.plist)"
@echo ""
@echo "Firmware pipeline:"
@@ -89,6 +91,7 @@ help:
@echo " make fw_patch Patch boot chain with Swift pipeline (regular variant)"
@echo " make fw_patch_less Patch boot chain with Swift pipeline (less patches)"
@echo " Options: NO_BINPACK=1 Excludes the SSH, VNC, ... binaries from being installed"
+ @echo " NO_VPHONED=1 Excludes vphoned from being installed"
@echo " make fw_patch_dev Patch boot chain with Swift pipeline (dev mode TXM patches)"
@echo " make fw_patch_jb Patch boot chain with Swift pipeline (dev + JB extensions)"
@echo ""
@@ -125,6 +128,7 @@ setup_machine:
SUDO_PASSWORD="$(SUDO_PASSWORD)" \
NONE_INTERACTIVE="$(NONE_INTERACTIVE)" \
NO_BINPACK="$(NO_BINPACK)" \
+ NO_VPHONED="$(NO_VPHONED)" \
zsh $(SCRIPTS)/setup_machine.sh \
$(if $(filter 1 true yes YES TRUE,$(JB)),--jb,) \
$(if $(filter 1 true yes YES TRUE,$(DEV)),--dev,) \
@@ -276,7 +280,9 @@ boot: bundle vphoned boot_binary_check
boot_less: bundle vphoned boot_binary_check_less
cd $(VM_DIR) && "$(CURDIR)/$(BUNDLE_BIN)" \
- --config ./config.plist --variant less
+ --config ./config.plist \
+ --variant less \
+ $(if $(filter 1 true yes YES TRUE,$(NO_VPHONED)),--no-vphoned,)
boot_dfu: build boot_binary_check
cd $(VM_DIR) && "$(CURDIR)/$(BINARY)" \
@@ -301,6 +307,7 @@ fw_patch_less: patcher_build
"$(CURDIR)/$(PATCHER_BINARY)" patch-firmware --vm-directory "$(CURDIR)/$(VM_DIR)" \
--variant less \
$(if $(filter 1 true yes YES TRUE,$(NO_BINPACK)),--no-binpack,)
+ $(if $(filter 1 true yes YES TRUE,$(NO_VPHONED)),--no-vphoned,)
else
fw_patch_less:
@echo "fw_patch_less must be run via sudo"
diff --git a/scripts/setup_machine.sh b/scripts/setup_machine.sh
index 7940c96f..57da65bc 100755
--- a/scripts/setup_machine.sh
+++ b/scripts/setup_machine.sh
@@ -58,6 +58,8 @@ NONE_INTERACTIVE_RAW="${NONE_INTERACTIVE:-0}"
NONE_INTERACTIVE=0
NO_BINPACK_RAW="${NO_BINPACK:-0}"
NO_BINPACK=0
+NO_VPHONED_RAW="${NO_VPHONED:-0}"
+NO_VPHONED=0
JB_MODE=0
DEV_MODE=0
LESS_MODE=0
@@ -980,6 +982,7 @@ Environment:
NONE_INTERACTIVE=1 Auto-continue first-boot prompts + run final boot analysis.
SUDO_PASSWORD=... Preload sudo credential via askpass.
NO_BINPACK=1 Excludes the SSH, VNC, ... binaries from being installed (patchless-only, currently)
+ NO_VPHONED=1 Excludes vphoned from being installed (patchless-only, currently)
EOF
exit 0
;;
@@ -998,6 +1001,9 @@ main() {
if parse_bool "$NO_BINPACK_RAW"; then
NO_BINPACK=1
fi
+ if parse_bool "$NO_VPHONED_RAW"; then
+ NO_VPHONED=1
+ fi
setup_sudo_noninteractive
local fw_patch_target="fw_patch"
@@ -1022,7 +1028,7 @@ main() {
mode_label="less"
fi
- echo "[*] setup_machine mode: ${mode_label}, project_setup=$([[ "$SKIP_PROJECT_SETUP" -eq 1 ]] && echo "skip" || echo "run"), non_interactive=${NONE_INTERACTIVE}, no_binpack=${NO_BINPACK}"
+ echo "[*] setup_machine mode: ${mode_label}, project_setup=$([[ "$SKIP_PROJECT_SETUP" -eq 1 ]] && echo "skip" || echo "run"), non_interactive=${NONE_INTERACTIVE}, no_binpack=${NO_BINPACK}, no_vphoned=${NO_VPHONED}"
if [[ "$SKIP_PROJECT_SETUP" -eq 1 ]]; then
echo ""
diff --git a/sources/FirmwarePatcher/Filesystem/CryptexFilesystemPatcher.swift b/sources/FirmwarePatcher/Filesystem/CryptexFilesystemPatcher.swift
index 0b93e8dc..74b66834 100644
--- a/sources/FirmwarePatcher/Filesystem/CryptexFilesystemPatcher.swift
+++ b/sources/FirmwarePatcher/Filesystem/CryptexFilesystemPatcher.swift
@@ -43,6 +43,7 @@ public final class CryptexFilesystemPatcher: Patcher {
public let restoreDir: URL
public let verbose: Bool
public let noBinpack: Bool
+ public let noVphoned: Bool
let vphoneCliDirectory = URL(filePath: "./")
var buildManiest: Data
@@ -51,11 +52,12 @@ public final class CryptexFilesystemPatcher: Patcher {
// MARK: - Init
- public init(buildManiest: Data, restoreDir: URL, verbose: Bool = true, noBinpack: Bool = false) {
+ public init(buildManiest: Data, restoreDir: URL, verbose: Bool = true, noBinpack: Bool = false, noVphoned: Bool = false) {
self.buildManiest = buildManiest
self.restoreDir = restoreDir
self.verbose = verbose
self.noBinpack = noBinpack
+ self.noVphoned = noVphoned
}
deinit {
@@ -142,14 +144,18 @@ public final class CryptexFilesystemPatcher: Patcher {
print("- Patch Mobile Activation")
try patchMobileActivation(targetMount: targetMount, cfwInput: cfwInputPath)
- print("- Add vphoned")
- try addVphoned(targetMount: targetMount, cfwInput: cfwInputPath)
+ if !noVphoned {
+ print("- Add vphoned")
+ try addVphoned(targetMount: targetMount, cfwInput: cfwInputPath)
+ }
if !noBinpack {
print("- Add binpack")
try addExtraServices(targetMount: targetMount, cfwInput: cfwInputPath)
}
- try injectLaunchDaemons(targetMount: targetMount, cfwInput: cfwInputPath, vphoned: true, cfw: !noBinpack)
- try patchLaunchdCacheLoader(targetMount: targetMount, cfwInput: cfwInputPath)
+ if !noVphoned || !noBinpack {
+ try injectLaunchDaemons(targetMount: targetMount, cfwInput: cfwInputPath, vphoned: !noVphoned, cfw: !noBinpack)
+ try patchLaunchdCacheLoader(targetMount: targetMount, cfwInput: cfwInputPath)
+ }
}
print("- Finalizing merged image")
diff --git a/sources/FirmwarePatcher/Pipeline/FirmwarePipeline.swift b/sources/FirmwarePatcher/Pipeline/FirmwarePipeline.swift
index 4018e98a..3dde5671 100644
--- a/sources/FirmwarePatcher/Pipeline/FirmwarePipeline.swift
+++ b/sources/FirmwarePatcher/Pipeline/FirmwarePipeline.swift
@@ -75,6 +75,7 @@ public final class FirmwarePipeline {
let variant: Variant
let verbose: Bool
let noBinpack: Bool
+ let noVphoned: Bool
let loader: any FirmwareLoader
// MARK: - Init
@@ -84,12 +85,14 @@ public final class FirmwarePipeline {
variant: Variant = .regular,
verbose: Bool = true,
noBinpack: Bool = false,
+ noVphoned: Bool = false,
loader: (any FirmwareLoader)? = nil
) {
self.vmDirectory = vmDirectory
self.variant = variant
self.verbose = verbose
self.noBinpack = noBinpack
+ self.noVphoned = noVphoned
self.loader = loader ?? ContainerFirmwareLoader()
}
@@ -304,7 +307,7 @@ public final class FirmwarePipeline {
return switch variant {
case .less:
[{ data, verbose in
- CryptexFilesystemPatcher(buildManiest: data, restoreDir: try! self.findRestoreDirectory(), verbose: verbose, noBinpack: self.noBinpack)
+ CryptexFilesystemPatcher(buildManiest: data, restoreDir: try! self.findRestoreDirectory(), verbose: verbose, noBinpack: self.noBinpack, noVphoned: self.noVphoned)
}]
case .regular, .dev, .jb:
[]
diff --git a/sources/vphone-cli/VPhoneCLI.swift b/sources/vphone-cli/VPhoneCLI.swift
index 94622410..9fd7a714 100644
--- a/sources/vphone-cli/VPhoneCLI.swift
+++ b/sources/vphone-cli/VPhoneCLI.swift
@@ -52,6 +52,9 @@ struct VPhoneBootCLI: ParsableCommand {
transform: URL.init(fileURLWithPath:)
)
var installIPA: URL?
+
+ @Flag(name: .customLong("no-vphoned"), help: "Exclude vphoned usage (patchless-only).")
+ var noVphoned: Bool = false
/// DFU mode runs headless (no GUI).
var noGraphics: Bool {
@@ -103,7 +106,8 @@ struct VPhoneBootCLI: ParsableCommand {
screenPPI: manifest.screenConfig.pixelsPerInch,
screenScale: manifest.screenConfig.scale,
kernelDebugPort: kernelDebugPort,
- variant: variant.virtualMachineVariant
+ variant: variant.virtualMachineVariant,
+ noVphoned: self.noVphoned
)
}
@@ -163,12 +167,16 @@ struct PatchFirmwareCLI: ParsableCommand {
@Flag(name: .customLong("no-binpack"), help: "Exclude the SSH, VNC, ... binaries from being installed (patchless-only).")
var noBinpack: Bool = false
+ @Flag(name: .customLong("no-vphoned"), help: "Exclude vphoned from being installed (patchless-only).")
+ var noVphoned: Bool = false
+
mutating func run() throws {
let pipeline = FirmwarePipeline(
vmDirectory: vmDirectory,
variant: variant.pipelineVariant,
verbose: !quiet,
- noBinpack: noBinpack
+ noBinpack: noBinpack,
+ noVphoned: noVphoned
)
let records = try pipeline.patchAll()
diff --git a/sources/vphone-cli/VPhoneVirtualMachine.swift b/sources/vphone-cli/VPhoneVirtualMachine.swift
index 1bc469a6..adfd088d 100644
--- a/sources/vphone-cli/VPhoneVirtualMachine.swift
+++ b/sources/vphone-cli/VPhoneVirtualMachine.swift
@@ -35,6 +35,7 @@ class VPhoneVirtualMachine: NSObject, VZVirtualMachineDelegate {
var screenScale: Double = 3.0
var kernelDebugPort: Int?
var variant: Variant
+ var noVphoned: Bool
}
private struct DeviceIdentity {
@@ -234,8 +235,10 @@ class VPhoneVirtualMachine: NSObject, VZVirtualMachineDelegate {
config.keyboards = [VZUSBKeyboardConfiguration()]
- // Vsock (host <-> guest control channel, no IP/TCP involved)
- config.socketDevices = [VZVirtioSocketDeviceConfiguration()]
+ if !options.noVphoned {
+ // Vsock (host <-> guest control channel, no IP/TCP involved)
+ config.socketDevices = [VZVirtioSocketDeviceConfiguration()]
+ }
// Power source (synthetic battery - guest sees full charge, charging)
let source = Dynamic._VZMacSyntheticBatterySource()