Run a virtual iPhone on an Apple Silicon Mac.
Swift
Spell out virtual machine and firmware names
Lakr2b8e1efc56aa
diff --git a/AGENTS.md b/AGENTS.mdindex 2bfad794..62d189ec 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -49,23 +49,23 @@ sources/│ │ # Argument parsing + orchestration; spawns the others.│ ├── main.swift # Parses, and forwards `boot` to vphone-vm│ ├── VPhoneCLI.swift # Root command, patch-firmware/patch-component-│ ├── VPhoneFWCLI.swift # Firmware subcommands+│ ├── VPhoneFirmwareCLI.swift # Firmware subcommands│ ├── VPhoneSetupCLI.swift # Setup subcommands-│ ├── VPhoneRestoreCLI.swift # `restore` + the `cfw` subcommand group-│ ├── VPhoneCFWPatchCLI.swift # `cfw` verbs: cryptex-paths, inject-*, patch-*-│ ├── VPhoneCFWMachOVerbsCLI.swift # The six Mach-O `cfw patch-*` verbs-│ ├── VPhoneCFWDSCVerbsCLI.swift # The eight dyld-shared-cache `cfw patch-*` verbs+│ ├── VPhoneRestoreCLI.swift # Restore and recovery commands+│ ├── VPhoneCustomFirmwarePatchCLI.swift # `cfw` verbs: cryptex-paths, inject-*, patch-*+│ ├── VPhoneCustomFirmwareMachOVerbsCLI.swift # The six Mach-O `cfw patch-*` verbs+│ ├── VPhoneCustomFirmwareDyldSharedCacheVerbsCLI.swift # Dyld shared cache verbs│ ├── VPhoneSignCLI.swift # `sign` — VPhoneSign from the command line-│ ├── VPhoneVMCLI.swift # VM subcommand group-│ ├── VPhoneVMCreateCLI.swift # VM create-│ ├── VPhoneVMLaunchCLI.swift # VM launch-│ ├── VPhoneVMTransferCLI.swift # VM transfer-│ ├── VPhoneCreateOptions.swift # Create-flow option set-│ ├── VPhoneCreateOrchestrator.swift # Native `vm create` pipeline driver-│ ├── VPhoneCFWInstaller.swift # Native host-mount JB install+│ ├── VPhoneVirtualMachineCLI.swift # VM subcommand group+│ ├── VPhoneVirtualMachineCreateCLI.swift # VM create+│ ├── VPhoneVirtualMachineLaunchCLI.swift # VM launch+│ ├── VPhoneVirtualMachineTransferCLI.swift # VM transfer+│ ├── VPhoneVirtualMachineCreateOptions.swift # Create-flow option set+│ ├── VPhoneVirtualMachineCreator.swift # Native `vm create` pipeline driver+│ ├── VPhoneCustomFirmwareInstaller.swift # Native host-mount JB install│ ├── VPhoneHostPreflight.swift # Native host launch check-│ ├── VPhoneFirmwareSelection.swift # Interactive firmware picker-│ ├── VPhoneVMSelection.swift # Interactive VM picker+│ ├── VPhoneFirmwareSourceSelection.swift # Firmware source resolver+│ ├── VPhoneVirtualMachineSelection.swift # Interactive VM picker│ └── VPhoneProgressBar.swift # Terminal progress rendering│├── vphone-vm/ # The ONLY entitled binary — a parse and a run loop@@ -88,7 +88,7 @@ sources/│ ├── VPhoneArchivePaths.swift # realpath(3) — NOT the Foundation equivalents│ └── VPhoneTreeFingerprint.swift # Compare two extracted trees, field by field│-├── VPhoneKit/ # Public unentitled HTTP/WebSocket API client for vphone-ui+├── VPhoneAPIKit/ # Public unentitled HTTP/WebSocket API client for vphone-ui│ └── VPhoneAPIClient.swift # Typed JSON values, RPC, events, streaming file transfer│├── VPhoneSign/ # Mach-O code signing — replaces ldid, byte for byte@@ -114,45 +114,45 @@ sources/│├── VPhoneRestore/ # Swift over those two C targets — replaced the Python bridge│ ├── VPhoneRecoveryProbe.swift # irecv_open_with_ecid_and_attempts + timeout polling-│ ├── VPhoneRestoreBridge.swift # The three ported commands: probe, get-shsh, restore+│ ├── VPhoneRestoreService.swift # The three ported commands: probe, get-shsh, restore│ ├── VPhoneRestoreTicket.swift # Undoes idevicerestore's -t: gzipped binary plist → plain│ ├── VPhoneRestoreRunner.swift # Drives vphone_restore_run│ └── … # options, identity, restore-tree layout, events, errors│├── FirmwarePatcher/ # The Swift firmware pipeline (largest module)-│ ├── IBoot/ Kernel/ TXM/ # Boot-chain patches; Kernel/JBPatches/ is the JB set-│ ├── DeviceTree/ Filesystem/ # DT edits, cryptex/rootfs work-│ └── ARM64/ Binary/ Core/ Pipeline/ # Disassembly, Mach-O, driver+│ ├── IBoot/ Kernel/ TXM/ # Boot-chain patches; Kernel/JailbreakPatches/ is the JB set+│ ├── DeviceTree/ CryptexFilesystem/ # DT edits, cryptex/rootfs work+│ └── ARM64/ Binary/ PatchInfrastructure/ Pipeline/ # Disassembly, Mach-O, driver│-└── VPhoneVMKit/ # Everything that touches a running guest+└── VPhoneVirtualMachineKit/ # Everything that touches a running guest├── VPhoneGuestApp.swift # NSApplication wiring (keeps the entry point logic-free)- ├── VPhoneAppDelegate.swift # App lifecycle, SIGINT, VM start/stop- ├── VPhoneHostControl.swift # Unix-socket automation server (one JSON line in/out)+ ├── VPhoneVirtualMachineAppDelegate.swift # App lifecycle, SIGINT, VM start/stop+ ├── VPhoneHostAutomationServer.swift # Unix-socket automation server (one JSON line in/out)├── VPhoneBootCLI+VirtualMachine.swift # resolveOptions() — the half that needs Virtualization│- ├── VM/ # VM core+ ├── VirtualMachine/ # VM core│ ├── VPhoneVirtualMachine.swift # @MainActor VM configuration and lifecycle│ ├── VPhoneVirtualMachineView.swift # Touch-enabled VZVirtualMachineView + helpers- │ ├── VPhoneHardwareModel.swift # PV=3 hardware model via Dynamic- │ └── VPhoneError.swift # Error types+ │ ├── VPhoneVirtualMachineHardwareModel.swift # PV=3 hardware model via Dynamic+ │ └── VPhoneVirtualMachineError.swift # Error types│- ├── Guest/ # Guest daemon client (vsock)- │ ├── VPhoneControl.swift # Host-side HTTP client over direct VSOCK 1339+ ├── GuestCommunication/ # Guest daemon client (vsock)+ │ ├── VPhoneGuestControl.swift # Host-side HTTP client over direct VSOCK 1339│ ├── VPhoneAPIProxy.swift # Opt-in TCP to guest VSOCK 1339 transparent proxy- │ ├── VPhoneControlApps.swift # Installed apps — list and launch- │ ├── VPhoneControlKeychain.swift # Keychain dump- │ └── VPhoneControlSystem.swift # Device, battery, location, devmode+ │ ├── VPhoneGuestControlApps.swift # Installed apps — list and launch+ │ ├── VPhoneGuestControlKeychain.swift # Keychain dump+ │ └── VPhoneGuestControlSystem.swift # Device, battery, location, devmode│- ├── Interface/ # Window & UI- │ ├── VPhoneWindowController.swift # @MainActor VM window management + toolbar- │ ├── VPhoneKeyHelper.swift # Keyboard/hardware key event dispatch to VM+ ├── UserInterface/ # Window & UI+ │ ├── VPhoneVirtualMachineWindowController.swift # VM window + toolbar+ │ ├── VPhoneVirtualMachineKeySender.swift # Keyboard/hardware keys to VM│ ││ ├── Menu/ # Menu bar (extensions on VPhoneMenuController)│ │ ├── VPhoneMenuController.swift # Menu bar controller│ │ ├── VPhoneMenuApps.swift # Apps menu — installed app browser│ │ ├── VPhoneMenuBattery.swift # Battery menu — battery status display│ │ ├── VPhoneMenuCamera.swift # Camera menu — virtual camera source- │ │ ├── VPhoneMenuConnect.swift # Connect menu — devmode, ping, version, file browser+ │ │ ├── VPhoneMenuConnect.swift # Connect menu — devmode, ping, guest hash, file browser│ │ ├── VPhoneMenuKeys.swift # Keys menu — home, power, volume, spotlight│ │ ├── VPhoneMenuLocation.swift # Location menu — host location sync toggle│ │ └── VPhoneMenuRecord.swift # Record menu — screen recording controls@@ -171,7 +171,7 @@ sources/│ ├── VPhoneKeychainItem.swift # Keychain item data model│ └── VPhoneQuickLookController.swift # Quick Look preview panel│- └── Devices/ # Host capability bridges into the running VM+ └── HostDevices/ # Host capability bridges into the running VM├── VPhoneCameraServer.swift # Virtual-camera server (vsock port 1338)├── VPhoneFrameProducer.swift # BGRA frame sources for the camera server├── VPhoneLocationProvider.swift # CoreLocation → guest forwarding over vsock@@ -201,11 +201,11 @@ research/ # Detailed firmware/patch documentation- **Guest launches go through `VPhoneGuestLaunchPlanner`** (`VPhoneCore`). It resolves `vphone-vm` as a sibling of the running image — never through `PATH` — checks its two PV=3 entitlements, then probes with `vphone-vm --help` for SIGKILL. A refusal is reported with the exact command the user has to run; the planner never arranges a bypass itself. Never spawn the guest directly.- **Restore runs in `vphone-cli`'s own process.** `VPhoneRestore` calls `vphone_restore_run()` in `MobileRestoreCore`; there is no subprocess, no bridge script and no environment to resolve first. The three commands the old Python bridge exposed became `restore --get-shsh`, `restore` and `restore --offline`; its fourth, `usbmux-list`, had no call site and was not ported. `research/restore/p2_restore_off_python.md` has the decision and the behaviour table.- **Private API access:** Via [Dynamic](https://github.com/mhdhejazi/Dynamic) library (runtime method dispatch from pure Swift). No ObjC bridge.-- **App lifecycle:** `vphone-vm/main.swift` → `VPhoneGuestApp.run()` → `NSApplication` + `VPhoneAppDelegate`. Entry points hold no logic.+- **App lifecycle:** `vphone-vm/main.swift` → `VPhoneGuestApp.run()` → `NSApplication` + `VPhoneVirtualMachineAppDelegate`. Entry points hold no logic.- **Configuration:** `ArgumentParser` → `VPhoneBootCLI` (in `VPhoneCore`, parsed by both binaries) → `VPhoneVirtualMachine.Options` → `VZVirtualMachineConfiguration`.-- **Guest daemon (vphoned):** SwiftNIO HTTP/WebSocket API on VSOCK 1339, using IcliKit for common device operations. The complete pinned icli CLI is installed inside the guest and available through `icli.execute` with an argv array. `VPhoneControl` reaches HTTP directly over VSOCK; the former length-prefixed service on 1337 is removed. Camera data remains on 1338. The host exposes 1339 only when boot is given `--api-listen`.+- **Guest daemon (vphoned):** SwiftNIO HTTP/WebSocket API on VSOCK 1339, using IcliKit for common device operations. The complete pinned icli CLI is installed inside the guest and available through `icli.execute` with an argv array. `VPhoneGuestControl` reaches HTTP directly over VSOCK; the former length-prefixed service on 1337 is removed. Camera data remains on 1338. The host exposes 1339 only when boot is given `--api-listen`.- **Menu system:** `VPhoneMenuController` + per-menu extensions (Keys, Type, Location, Connect, Install, Record).-- **File browser:** SwiftUI (`VPhoneFileBrowserView` + `VPhoneFileBrowserModel`) in `NSHostingController`. Search, sort, upload/download, drag-drop via `VPhoneControl`.+- **File browser:** SwiftUI (`VPhoneFileBrowserView` + `VPhoneFileBrowserModel`) in `NSHostingController`. Search, sort, upload/download, drag-drop via `VPhoneGuestControl`.- **IPA installation:** `VPhoneIPAInstaller` extracts + re-signs via `VPhoneSigner` + installs over vsock.- **Screen recording:** `VPhoneScreenRecorder` captures VM display. Controls via Record menu.@@ -267,7 +267,7 @@ There is none, and adding any is a regression.- All replacement instruction bytes must come from Keystone-backed helpers already used by the project: `ARM64Encoder.encode*` and the `ARM64` constants, which were generated by keystone-engine, verified by Capstone round-trip, and are asserted word for word against keystone in `tests/FirmwarePatcherTests/ARM64EncoderTests.swift`. Never write a literal instruction word at a patch site. A new instruction means a new encoder plus its keystone-checked test case, not a raw `Data`. Keystone is deliberately **not** a project dependency any more — nothing at runtime or in the test suite calls it, and the expected words are frozen constants. To derive a new one, stand keystone up in a throwaway environment **outside this repository** (`brew install keystone`, plus `keystone-engine` in a scratch interpreter somewhere under `/tmp`) and run the one-liner in that test file's header against it. There is no dependency list here to add it to and no environment here to install it into; creating either is the regression the "Python" section above forbids. Do not invent an expected word without checking it.- Prefer source-backed semantic anchors: in-image symbol lookup, string xrefs, local call-flow, and XNU correlation. Do not depend on repo-exported per-kernel symbol dumps at runtime.- When retargeting a patch, write the reveal procedure and validation steps into the relevant research doc or commit notes before handing off for testing. Do not create `TODO.md`.-- For `patchBsdInitAuth` (`Kernel/JBPatches/Storage/KernelJBPatchBsdInitAuth.swift`, named `patch_bsd_init_auth` in the research docs) specifically, the allowed reveal flow is: recover `bsd_init` -> locate rootvp panic block -> find the unique in-function `call` -> `cbnz w0/x0, panic` -> `bl imageboot_needed` site -> patch the branch gate only.+- For `patchBsdInitAuth` (`Kernel/JailbreakPatches/Storage/KernelJailbreakPatchBsdInitAuth.swift`, named `patch_bsd_init_auth` in the research docs) specifically, the allowed reveal flow is: recover `bsd_init` -> locate rootvp panic block -> find the unique in-function `call` -> `cbnz w0/x0, panic` -> `bl imageboot_needed` site -> patch the branch gate only.## Build & Signdiff --git a/Package.swift b/Package.swiftindex 858b6aa4..cefd4d49 100644--- a/Package.swift+++ b/Package.swift@@ -8,8 +8,8 @@ let package = Package(.macOS(.v15),],products: [- .library(name: "VPhoneKit", targets: ["VPhoneKit"]),- .library(name: "VPhoneVMKit", targets: ["VPhoneVMKit"]),+ .library(name: "VPhoneAPIKit", targets: ["VPhoneAPIKit"]),+ .library(name: "VPhoneVirtualMachineKit", targets: ["VPhoneVirtualMachineKit"]),],// Resolved by SwiftPM, not carried as submodules. Every one of these was a// `.package(path: "vendor/…")` over a checkout this repository pinned by@@ -41,10 +41,9 @@ let package = Package(// 2.84+ links libswiftCompatibilitySpan when built with Swift 6.4.// 2.83 keeps the guest binary self-contained on older iOS bases..package(url: "https://github.com/apple/swift-nio.git", exact: "2.83.0"),- .package(url: "https://github.com/apple/swift-collections.git", exact: "1.3.0"),],targets: [- .target(name: "VPhoneKit", path: "sources/VPhoneKit"),+ .target(name: "VPhoneAPIKit", path: "sources/VPhoneAPIKit"),.target(name: "FirmwarePatcher",dependencies: [@@ -213,16 +212,14 @@ let package = Package(// entitlements can stay as small as an argument parse and an// NSApplication run loop..target(- name: "VPhoneVMKit",+ name: "VPhoneVirtualMachineKit",dependencies: [- .product(name: "ArgumentParser", package: "swift-argument-parser"),.product(name: "Dynamic", package: "Dynamic"),.product(name: "NIOCore", package: "swift-nio"),.product(name: "NIOPosix", package: "swift-nio"),"VPhoneCore",- "VPhoneKit",],- path: "sources/VPhoneVMKit",+ path: "sources/VPhoneVirtualMachineKit",linkerSettings: [.linkedFramework("Virtualization"),.linkedFramework("AppKit"),@@ -237,7 +234,7 @@ let package = Package(dependencies: [.product(name: "ArgumentParser", package: "swift-argument-parser"),"VPhoneCore",- "VPhoneVMKit",+ "VPhoneVirtualMachineKit",],path: "sources/vphone-vm",// Swift 6.4 may autolink compatibility dylibs for generic code in@@ -246,7 +243,7 @@ let package = Package(// independent of the build machine's Swift toolchain.linkerSettings: [.unsafeFlags(["-Xlinker", "-dead_strip_dylibs"])]),- // The user-facing entry point. Note it depends on neither VPhoneVMKit+ // The user-facing entry point. Note it depends on neither VPhoneVirtualMachineKit// nor any of the five frameworks above: it never builds a machine, it// starts vphone-vm. Adding a dependency on the kit here would quietly// undo the split, so don't. VPhoneArchive is fine and is why `vm export`diff --git a/README.md b/README.mdindex c123cb8a..c5280937 100644--- a/README.md+++ b/README.md@@ -21,7 +21,7 @@ vphone-cli vm launch myphone```To expose the guest HTTP and WebSocket API on the host for local tools or an-app using `VPhoneKit`, opt in when launching:+app using `VPhoneAPIKit`, opt in when launching:```shvphone-cli vm launch myphone --api-listen 127.0.0.1:8765diff --git a/research/0_binary_patch_comparison.md b/research/0_binary_patch_comparison.mdindex fdee544c..c3f874ff 100644--- a/research/0_binary_patch_comparison.md+++ b/research/0_binary_patch_comparison.md@@ -281,7 +281,7 @@ addresses (49 gates each, zero verdict differences).### Swift port status — the six independent Mach-O patchers (2026-09-23)Rows 1, 2, 3, 5 and 13 above, plus the EXP `watchdogd` patch, now have Swift-implementations under `sources/FirmwarePatcher/CFW/Patches/`. The patches did not+implementations under `sources/FirmwarePatcher/CustomFirmware/ExecutablePatches/`. The patches did notchange. Each was run against its Python on two `cp -c` clones of the real 24A435binary in `ipsws/ref_extract/macho_pristine/`, both with re-attestation off (whatthe Python emits) and on (against `cfw_macho_codesign.reattest_modified_offsets`).diff --git a/research/README.md b/research/README.mdindex 26004b37..f3a6b587 100644--- a/research/README.md+++ b/research/README.md@@ -8,7 +8,7 @@ This directory keeps the evidence behind firmware patches, restore and the self-1. [Patch comparison](0_binary_patch_comparison.md) is the canonical per-component inventory. Its regular/dev/exp columns are historical.2. [Firmware manifest and origins](firmware/firmware_manifest_and_origins.md) explains the hybrid firmware inputs.-3. [JB kernel patch notes](kernel/kernel_jb_patch_notes.md) and the [individual patch index](kernel_patch_jb/README.md) lead to the kernel evidence.+3. [JB kernel patch notes](kernel/kernel_jb_patch_notes.md) and the [individual patch index](kernel_jailbreak_patches/README.md) lead to the kernel evidence.4. [Native restore design](restore/p2_restore_off_python.md) and [self-contained runtime](host/d2_d3_self_containment.md) explain the host migration.## By subject@@ -16,11 +16,11 @@ This directory keeps the evidence behind firmware patches, restore and the self-| Subject | Notes || --- | --- || Firmware and boot chain | [Manifest and origins](firmware/firmware_manifest_and_origins.md), [iBoot patches](firmware/iboot_patches.md), [TXM full chain](firmware/txm_fullchain_analysis.md), [TXM JB patches](firmware/txm_jb_patches.md), [selector 24](firmware/txm_selector24_analysis.md), [variant differences](firmware/txm_variant_diff.md) |-| Kernel | [JB overview](kernel/kernel_jb_patch_notes.md), [patcher verification](kernel/kernel_patcher_verification.md), [FairPlay kexts](kernel/kernel_fairplay_kexts.md), [base validation 1–5](kernel/kernel_patch_base_first5_validation.md), [11–15](kernel/kernel_patch_base_11_15_validation.md), [16–20](kernel/kernel_patch_base_16_20_validation.md), [sandbox hooks](kernel/kernel_patch_sandbox_hooks_17_26_validation.md), [individual patch notes](kernel_patch_jb/README.md) |+| Kernel | [JB overview](kernel/kernel_jb_patch_notes.md), [patcher verification](kernel/kernel_patcher_verification.md), [FairPlay kexts](kernel/kernel_fairplay_kexts.md), [base validation 1–5](kernel/kernel_patch_base_first5_validation.md), [11–15](kernel/kernel_patch_base_11_15_validation.md), [16–20](kernel/kernel_patch_base_16_20_validation.md), [sandbox hooks](kernel/kernel_patch_sandbox_hooks_17_26_validation.md), [individual patch notes](kernel_jailbreak_patches/README.md) || Other patches and captures | [Launchd jetsam](patches/cfw_patch_launchd_jetsam.md), [user-mode hypervisor references](patches/hv_vmm_present_usermode_xrefs.md), [reference capture](patches/patch_reference_capture.md) || Restore | [DFU probe](restore/p2_dfu_spike.md), [in-process restore](restore/p2_restore_off_python.md) || Host and archives | [Binary split](host/host_binary_split.md), [runtime dependency tiers](host/d2_d3_self_containment.md), [archive extraction contracts](host/archive_extraction_contracts.md), [libarchive validation](host/libarchive_xcframework_validation.md) || Guest interaction and VM identity | [DevMode XPC](guest/devmode_xpc_protocol.md), [keyboard events](guest/keyboard_event_pipeline.md), [machine identifier](guest/machine_identifier_storage_analysis.md) || Historical project records | [Migration ledger](history/intg_update_status.md), [manifest refactoring summary](history/manifest_and_refactoring_summary.md) |-`kernel_info/` holds symbol datasets and indexes; `reference/` holds source references when present. They are evidence inputs, not steps for running the distributed app. The files in `history/` are preserved snapshots and may describe scripts or variants that have since been removed.+`kernel_symbols/` holds symbol datasets and indexes; `reference/` holds source references when present. They are evidence inputs, not steps for running the distributed app. The files in `history/` are preserved snapshots and may describe scripts or variants that have since been removed.diff --git a/research/guest/devmode_xpc_protocol.md b/research/guest/devmode_xpc_protocol.mdindex fa8509d8..58662ce9 100644--- a/research/guest/devmode_xpc_protocol.md+++ b/research/guest/devmode_xpc_protocol.md@@ -111,7 +111,11 @@ Added to `scripts/vphoned/entitlements.plist`:<true/>```-### Host-Side API (VPhoneControl.swift)+### Host-Side API (historical design)++The calls below record the earlier XPC design. The current guest API exposes+the status query as `VPhoneGuestControl.isDeveloperModeEnabled()`; there is no+host-side enable action in the current menu.```swiftlet status = try await control.sendDevModeStatus() // -> DevModeStatus (enabled: Bool)diff --git a/research/host/host_binary_split.md b/research/host/host_binary_split.mdindex 9757c1cc..a8b8f745 100644--- a/research/host/host_binary_split.md+++ b/research/host/host_binary_split.md@@ -31,7 +31,7 @@ the binary being refused.| binary | entitlements | what it is || --- | :---: | --- || `vphone-cli` | **none** | argument parsing and orchestration. Launches anywhere. |-| `vphone-vm` | **all 7** | a parse and an `NSApplication` run loop over `VPhoneVMKit`. |+| `vphone-vm` | **all 7** | a parse and an `NSApplication` run loop over `VPhoneVirtualMachineKit`. || `vphone-archive` | none | libarchive front end. Unrelated to amfid; listed for completeness. |`vphone-cli` is now always able to start, which is what lets it say somethingdiff --git a/research/host/naming_and_shared_module_review.md b/research/host/naming_and_shared_module_review.mdnew file mode 100644index 00000000..6f73130f--- /dev/null+++ b/research/host/naming_and_shared_module_review.md@@ -0,0 +1,78 @@+# Repository naming and shared module review++Scope: first-party Swift sources, SwiftPM targets, tests, scripts, and current+documentation. Vendored C, firmware format names, kernel symbols, wire keys,+command spellings, and historical evidence retain their established spelling.++## Names changed++| Former name | Current name | What it owns |+| --- | --- | --- |+| `VPhoneVMKit`, `VPhoneVM*` | `VPhoneVirtualMachineKit`, `VPhoneVirtualMachine*` | Running guest, VM commands, lifecycle, window, hardware and picker |+| `VPhoneFW*` | `VPhoneFirmware*` | Firmware CLI commands and source selection |+| `VPhoneCFW*`, `CFW*` | `VPhoneCustomFirmware*`, `CustomFirmware*` | Custom firmware installation and patches |+| `DSC*` | `DyldSharedCache*` | dyld shared cache readers and patchers |+| `KernelJB*`, `IBootJB*`, `KernelEXP*` | `KernelJailbreak*`, `IBootJailbreak*`, `KernelExperimental*` | Firmware patch variants |+| `VPhoneKit` | `VPhoneAPIKit` | Public HTTP and WebSocket client and typed JSON values |+| `VPhoneControl`, `VPhoneHostControl` | `VPhoneGuestControl`, `VPhoneHostAutomationServer` | Direct guest VSOCK client and host Unix socket automation, respectively |+| `VPhoneRestoreBridge` | `VPhoneRestoreService` | In-process probe, SHSH request, and restore API |+| `VPhoneBundleOps`, `VPhoneRestoreOps` | `VPhoneBundleOperations`, `VPhoneRestoreOperations` | Bundle and restore support in `VPhoneCore` |+| `VPhoneCreateOrchestrator` | `VPhoneVirtualMachineCreator` | Native `vm create` flow |+| `NewBundleSpec`, `PropertySpec`, `OpenAPISpec`, `FileOpError` | `NewBundleConfiguration`, `PropertyDefinition`, `OpenAPIDocument`, `CryptexFileOperationError` | Bundle input, device tree definition, API document, and cryptex errors |++The CLI's `VPhoneFirmwareSelection` also became+`VPhoneFirmwareSourceSelection`: the former conflicted with a core firmware+matrix result. `sendDevModeStatus()` became `isDeveloperModeEnabled()`;+`sendVersion()` became `guestBinaryHash()` because the endpoint returns a+SHA-256 hash. The matching menu label is now **Guest Agent Hash**.++Directory names follow their contents: `VPhoneVMKit` to+`VPhoneVirtualMachineKit` (including `VM` to `VirtualMachine`, `Interface` to+`UserInterface`, and `Devices` to `HostDevices`), `CFW` to `CustomFirmware`,+`DSC` to `DyldSharedCache`, `JBPatches` to `JailbreakPatches`, `EXPPatches` to+`ExperimentalPatches`, generic `Patches` to `BasePatches`, `Filesystem` to+`CryptexFilesystem`, custom firmware `Patches` to `ExecutablePatches`,+patcher `Core` to `PatchInfrastructure`, VM kit `Guest`+to `GuestCommunication`, and the guest `Swift` folder to `Daemon`. The research+folders `kernel_patch_jb` and `kernel_info` became+`kernel_jailbreak_patches` and `kernel_symbols`.++These source-level changes include **breaking Swift import and type names**+for external clients of `VPhoneKit` and `VPhoneVMKit`. Consumers such as+`vphone-ui` must update their package product/import references when taking+this version. CLI command names (`vm`, `fw`, `cfw`), option names, socket paths,+and guest JSON keys remain unchanged. Recognizable technical names such as+`API`, `HTTP`, `APFS`, `AEA`, `IPSW`, `TXM`, `MachO`, and kernel symbol spellings+remain abbreviated.++## Shared Kit decision++The useful extraction is a **guest API protocol** module. The public+`VPhoneAPIKit` client owns typed `VPhoneJSONValue`, response and event models;+the VM's direct `VPhoneGuestControl` and iOS `vphoned` each encode or decode the+same `/v1/rpc` envelope with `[String: Any]`. A shared Foundation-only target+should own request, response, error, and event envelopes and their validation.+The URLSession, VSOCK, and SwiftNIO transports would remain with their current+owners. The guest dispatcher and its IcliKit/native operations remain in+`vphoned`.++The extraction needs a coordinated wire migration and JSON compatibility tests+for both macOS and iOS before becoming a useful Kit. Moving the public model+alone would leave the duplicated decoders intact. No new shared target was+added in this naming pass. `VPhoneCore` also has broad contents, but its+firmware selection and bundle operations do not yet have a common external+consumer that justifies another public framework.++## Dependency cleanup++`VPhoneVirtualMachineKit` no longer declares unused direct dependencies on+`VPhoneAPIKit` and `ArgumentParser`; the root and guest packages no longer+declare unused direct `swift-collections` dependencies. Their transitive+dependencies remain owned by the packages that use them.++## Verification++- `swift test --jobs 4`: 340 tests in 74 suites passed.+- `zsh scripts/build.sh`: host binaries, signed app, and iOS guest built.+- `zsh scripts/check_aux.sh`: all admission gates passed.+- `vphone-cli --help`: public `vm`, `fw`, and `cfw` command names remain present.diff --git a/research/kernel/kernel_jb_patch_notes.md b/research/kernel/kernel_jb_patch_notes.mdindex 82da2f9c..246faa5d 100644--- a/research/kernel/kernel_jb_patch_notes.md+++ b/research/kernel/kernel_jb_patch_notes.md@@ -8,7 +8,7 @@ Last updated: 2026-03-07> XNU-backed ones — carried into the Swift port and are why this file is kept;> the commands are not runnable as written. There is no Python in this> repository and no environment to install any into. The port lives in-> `sources/FirmwarePatcher/Kernel/JBPatches/`; to run anything below, recover+> `sources/FirmwarePatcher/Kernel/JailbreakPatches/`; to run anything below, recover> the patchers from git history at `78cbeea`.## Overview@@ -375,7 +375,7 @@ Should have moderate caller count (hundreds).**Historical problem**: the earlier repo-side “fix” still matched the wrong place. Runtime verification later showed the old hit landed in `_profile_syscallmask_destroy` underflow handling, not the real syscallmask apply wrapper.**Current understanding**: faithful upstream C22 is a low-wrapper shellcode patch that mutates the effective Unix/Mach/KOBJ mask bytes to all `0xFF`, then continues into the normal setter. It is not a `NULL`-mask install and not an early-return patch.-**Current status**: rebuilt structurally as a 3-write retarget (`save selector`, `branch to cave`, `all-ones cave + setter tail`) and separately documented in `research/kernel_patch_jb/patch_syscallmask_apply_to_proc.md`; user reported boot success with the rebuilt C22 on `2026-03-06`.+**Current status**: rebuilt structurally as a 3-write retarget (`save selector`, `branch to cave`, `all-ones cave + setter tail`) and separately documented in `research/kernel_jailbreak_patches/patch_syscallmask_apply_to_proc.md`; user reported boot success with the rebuilt C22 on `2026-03-06`.### patch_iouc_failed_macf — RETARGETED@@ -402,19 +402,19 @@ Should have moderate caller count (hundreds).**Historical repo behavior**: matched `ldr x0,[xN,#0x2b8]; cbz x0; bl` pattern, which landed on `exec_handle_sugid` at `0xFFFFFE0007FB09DC` — a false positive caused by `/dev/null` string overlap in the heuristic scoring.**Problem**: the old matcher targeted the wrong function entirely; patching `exec_handle_sugid` instead of the real `bsd_init` rootauth gate could break boot by mutating an exec/credential path.-**Current status**: retargeted to the real `FSIOC_KERNEL_ROOTAUTH` return check in `bsd_init`. The new matcher recovers `bsd_init` via in-kernel string xrefs, locates the rootvp panic block (`"rootvp not authenticated after mounting"`), finds the unique in-function indirect call (`BLRAA`) preceded by the `0x80046833` (`FSIOC_KERNEL_ROOTAUTH`) literal, and NOPs the subsequent `CBNZ W0, panic`. Live patch hit: `0xFFFFFE0007F7B98C` / file offset `0x00F7798C`. See `research/kernel_patch_jb/patch_bsd_init_auth.md`.+**Current status**: retargeted to the real `FSIOC_KERNEL_ROOTAUTH` return check in `bsd_init`. The new matcher recovers `bsd_init` via in-kernel string xrefs, locates the rootvp panic block (`"rootvp not authenticated after mounting"`), finds the unique in-function indirect call (`BLRAA`) preceded by the `0x80046833` (`FSIOC_KERNEL_ROOTAUTH`) literal, and NOPs the subsequent `CBNZ W0, panic`. Live patch hit: `0xFFFFFE0007F7B98C` / file offset `0x00F7798C`. See `research/kernel_jailbreak_patches/patch_bsd_init_auth.md`.### patch_io_secure_bsd_root — RETARGETED (2026-03-06)**Historical repo behavior**: fallback heuristic selected the first `BL* + CBZ W0` site in `AppleARMPE::callPlatformFunction`, landing on the `"SecureRoot"` name-match gate at `0xFFFFFE000836E1F0` / file offset `0x0136A1F0`. This changed generic platform-function dispatch routing, not just the deny return.**Problem**: the patched branch was the `isEqualTo("SecureRoot")` check, not the `"SecureRootName"` policy result used by `IOSecureBSDRoot()`. The old `CBZ->B` rewrite could corrupt control flow for unrelated platform-function calls.-**Current status**: retargeted to the final `"SecureRootName"` deny-return selector: `CSEL W22, WZR, W9, NE` at `0xFFFFFE000836E464` / file offset `0x0136A464` is replaced with `MOV W22, #0`. This preserves the string comparison, callback synchronization, and state updates, and only forces the final policy return from `kIOReturnNotPrivileged` to success. See `research/kernel_patch_jb/patch_io_secure_bsd_root.md`.+**Current status**: retargeted to the final `"SecureRootName"` deny-return selector: `CSEL W22, WZR, W9, NE` at `0xFFFFFE000836E464` / file offset `0x0136A464` is replaced with `MOV W22, #0`. This preserves the string comparison, callback synchronization, and state updates, and only forces the final policy return from `kIOReturnNotPrivileged` to success. See `research/kernel_jailbreak_patches/patch_io_secure_bsd_root.md`.### patch_vm_fault_enter_prepare — RETARGETED (2026-03-06)**Historical repo behavior**: matcher looked for `BL(rare) + LDRB [xN,#0x2c] + TBZ` and NOPed the BL at `0xFFFFFE0007BB898C`, which was actually a `pmap_lock_phys_page()` call inside the `VM_PAGE_CONSUME_CLUSTERED` macro — breaking lock/unlock pairing in the VM fault path.**Problem**: the derived matcher overfit the wrong local shape. The upstream 26.1 patch targeted the `cs_bypass` fast-path gate (`TBZ W22, #3`), not the clustered-page lock helper. NOPing only the lock acquire while the unlock still ran caused unbalanced lock state, explaining boot failures.-**Current status**: retargeted to the upstream semantic site — `TBZ W22, #3, ...` (where W22 bit 3 = `fault_info->cs_bypass`) at file offset `0x00BA9E1C` / VA `0xFFFFFE0007BADE1C` is replaced with `NOP`, forcing the `cs_bypass` fast path unconditionally. This matches XNU's `vm_fault_cs_check_violation()` logic and preserves lock pairing and page accounting. See `research/kernel_patch_jb/patch_vm_fault_enter_prepare.md`.+**Current status**: retargeted to the upstream semantic site — `TBZ W22, #3, ...` (where W22 bit 3 = `fault_info->cs_bypass`) at file offset `0x00BA9E1C` / VA `0xFFFFFE0007BADE1C` is replaced with `NOP`, forcing the `cs_bypass` fast path unconditionally. This matches XNU's `vm_fault_cs_check_violation()` logic and preserves lock pairing and page accounting. See `research/kernel_jailbreak_patches/patch_vm_fault_enter_prepare.md`.---diff --git a/research/kernel_patch_jb/26.5_jb_hook_fixes.md b/research/kernel_jailbreak_patches/26.5_jb_hook_fixes.mdsimilarity index 98%rename from research/kernel_patch_jb/26.5_jb_hook_fixes.mdrename to research/kernel_jailbreak_patches/26.5_jb_hook_fixes.mdindex 9e83c89a..75d0ee7c 100644--- a/research/kernel_patch_jb/26.5_jb_hook_fixes.md+++ b/research/kernel_jailbreak_patches/26.5_jb_hook_fixes.md@@ -213,9 +213,9 @@ here:## Where to look in the code-- The hooks live in `sources/FirmwarePatcher/Kernel/JBPatches/` (one file per hook), grouped+- The hooks live in `sources/FirmwarePatcher/Kernel/JailbreakPatches/` (one file per hook), groupedby subsystem into `CodeSigning/`, `Sandbox/`, `Memory/`, `Process/`, `Storage/`, `Drivers/`and `Frida/`, with shared helpers in`sources/FirmwarePatcher/Kernel/KernelJBPatcherBase.swift`.-- Deeper, per-hook reverse-engineering notes are in `research/kernel_patch_jb/` and the+- Deeper, per-hook reverse-engineering notes are in `research/kernel_jailbreak_patches/` and thepatch inventory is `research/0_binary_patch_comparison.md`.diff --git a/research/kernel_patch_jb/PATCH_DOC_FRAMEWORK.md b/research/kernel_jailbreak_patches/PATCH_DOC_FRAMEWORK.mdsimilarity index 96%rename from research/kernel_patch_jb/PATCH_DOC_FRAMEWORK.mdrename to research/kernel_jailbreak_patches/PATCH_DOC_FRAMEWORK.mdindex 264427af..b30859bf 100644--- a/research/kernel_patch_jb/PATCH_DOC_FRAMEWORK.md+++ b/research/kernel_jailbreak_patches/PATCH_DOC_FRAMEWORK.md@@ -1,6 +1,6 @@# JB Kernel Patch Document Framework-Use this structure for every `research/kernel_patch_jb/patch_*.md` file.+Use this structure for every `research/kernel_jailbreak_patches/patch_*.md` file.## 1. Patch Metadatadiff --git a/research/kernel_patch_jb/README.md b/research/kernel_jailbreak_patches/README.mdsimilarity index 93%rename from research/kernel_patch_jb/README.mdrename to research/kernel_jailbreak_patches/README.mdindex 210933b7..7511e79e 100644--- a/research/kernel_patch_jb/README.md+++ b/research/kernel_jailbreak_patches/README.md@@ -2,7 +2,7 @@[Research library](../README.md) · [Patch comparison](../0_binary_patch_comparison.md) · [Document framework](PATCH_DOC_FRAMEWORK.md)-These notes explain the source anchors, binary matches and validation evidence for individual JB kernel patches. The Swift implementations live under `sources/FirmwarePatcher/Kernel/JBPatches/`; the notes are research records, not commands to apply a patch by hand.+These notes explain the source anchors, binary matches and validation evidence for individual JB kernel patches. The Swift implementations live under `sources/FirmwarePatcher/Kernel/JailbreakPatches/`; the notes are research records, not commands to apply a patch by hand.| Area | Patch notes || --- | --- |diff --git a/research/kernel_patch_jb/patch_amfi_cdhash_in_trustcache.md b/research/kernel_jailbreak_patches/patch_amfi_cdhash_in_trustcache.mdsimilarity index 95%rename from research/kernel_patch_jb/patch_amfi_cdhash_in_trustcache.mdrename to research/kernel_jailbreak_patches/patch_amfi_cdhash_in_trustcache.mdindex fa6e9e1b..85617df4 100644--- a/research/kernel_patch_jb/patch_amfi_cdhash_in_trustcache.md+++ b/research/kernel_jailbreak_patches/patch_amfi_cdhash_in_trustcache.md@@ -99,7 +99,7 @@## Symbol Consistency Audit (2026-03-05)- Status: `partial`-- `kernel_info` contains AMFI/trustcache symbols, but not all analysis labels used in this doc.+- `kernel_symbols` contains AMFI/trustcache symbols, but not all analysis labels used in this doc.- This doc uses analyst labels (`jb_*`) for readability; those labels should be treated as local reverse-engineering aliases unless explicitly present in recovered symbol JSON.## Patch Metadata@@ -165,7 +165,7 @@ return 1;## Validation (Static Evidence)- Verified with IDA-MCP disassembly/decompilation, xrefs, and callgraph context for the selected site.-- Cross-checked against recovered symbols in `research/kernel_info/json/kernelcache.research.vphone600.bin.symbols.json`.+- Cross-checked against recovered symbols in `research/kernel_symbols/json/kernelcache.research.vphone600.bin.symbols.json`.- Address-level evidence in this document is consistent with patcher matcher intent.## Expected Failure/Panic if Unpatched@@ -216,10 +216,10 @@ return 1;- `0xFFFFFE0008645B14` (`sub_FFFFFE0008645B10`): cbz x2,+8 [AMFIIsCDHashInTrustCache] | `ffc300d1 -> 420000b4`- `0xFFFFFE0008645B18` (`sub_FFFFFE0008645B10`): str x0,[x2] [AMFIIsCDHashInTrustCache] | `f44f01a9 -> 400000f9`- `0xFFFFFE0008645B1C` (`sub_FFFFFE0008645B10`): ret [AMFIIsCDHashInTrustCache] | `fd7b02a9 -> c0035fd6`-- Artifacts: `research/kernel_patch_jb/runtime_verification/runtime_verification_report.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_runtime_patch_points.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.md`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/runtime_verification_report.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_runtime_patch_points.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.md`<!-- END_RUNTIME_IDA_VERIFICATION_2026_03_05 -->## 2026-03-06 Upstream Rework Reviewdiff --git a/research/kernel_patch_jb/patch_amfi_execve_kill_path.md b/research/kernel_jailbreak_patches/patch_amfi_execve_kill_path.mdsimilarity index 95%rename from research/kernel_patch_jb/patch_amfi_execve_kill_path.mdrename to research/kernel_jailbreak_patches/patch_amfi_execve_kill_path.mdindex 628d3f3f..dfe41ab6 100644--- a/research/kernel_patch_jb/patch_amfi_execve_kill_path.md+++ b/research/kernel_jailbreak_patches/patch_amfi_execve_kill_path.md@@ -89,7 +89,7 @@ The earlier BL/CBZ-site patching hit vnode-type assertion checks near function s## Symbol Consistency Audit (2026-03-05)- Status: `partial`-- `_hook_cred_label_update_execve` and related execve symbols are recovered, but several AMFI callback wrapper addresses in this doc remain unlabeled in `kernel_info`.+- `_hook_cred_label_update_execve` and related execve symbols are recovered, but several AMFI callback wrapper addresses in this doc remain unlabeled in `kernel_symbols`.- Address-level control-flow evidence is still valid; symbol names are partially recovered only.## Scheduler Status (2026-03-06)@@ -168,7 +168,7 @@ if (kill_condition) {## Validation (Static Evidence)- Verified with IDA-MCP disassembly/decompilation, xrefs, and callgraph context for the selected site.-- Cross-checked against recovered symbols in `research/kernel_info/json/kernelcache.research.vphone600.bin.symbols.json`.+- Cross-checked against recovered symbols in `research/kernel_symbols/json/kernelcache.research.vphone600.bin.symbols.json`.- Address-level evidence in this document is consistent with patcher matcher intent.## Expected Failure/Panic if Unpatched@@ -216,8 +216,8 @@ if (kill_condition) {- Recommendation: Keep enabled for this kernel build; continue monitoring for pattern drift.- Key verified points:- `0xFFFFFE000864E38C` (`__Z25_cred_label_update_execveP5ucredS0_P4procP5vnodexS4_P5labelS6_S6_PjPvmPi`): mov w0,#0 [AMFI kill return → allow] | `20008052 -> 00008052`-- Artifacts: `research/kernel_patch_jb/runtime_verification/runtime_verification_report.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_runtime_patch_points.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.md`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/runtime_verification_report.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_runtime_patch_points.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.md`<!-- END_RUNTIME_IDA_VERIFICATION_2026_03_05 -->diff --git a/research/kernel_patch_jb/patch_bsd_init_auth.md b/research/kernel_jailbreak_patches/patch_bsd_init_auth.mdsimilarity index 100%rename from research/kernel_patch_jb/patch_bsd_init_auth.mdrename to research/kernel_jailbreak_patches/patch_bsd_init_auth.mddiff --git a/research/kernel_patch_jb/patch_convert_port_to_map.md b/research/kernel_jailbreak_patches/patch_convert_port_to_map.mdsimilarity index 92%rename from research/kernel_patch_jb/patch_convert_port_to_map.mdrename to research/kernel_jailbreak_patches/patch_convert_port_to_map.mdindex 11945545..b9afc3f2 100644--- a/research/kernel_patch_jb/patch_convert_port_to_map.md+++ b/research/kernel_jailbreak_patches/patch_convert_port_to_map.md@@ -98,7 +98,7 @@ goto normal_path; // unconditional branch## Validation (Static Evidence)- Verified with IDA-MCP disassembly/decompilation, xrefs, and callgraph context for the selected site.-- Cross-checked against recovered symbols in `research/kernel_info/json/kernelcache.research.vphone600.bin.symbols.json`.+- Cross-checked against recovered symbols in `research/kernel_symbols/json/kernelcache.research.vphone600.bin.symbols.json`.- Address-level evidence in this document is consistent with patcher matcher intent.## Expected Failure/Panic if Unpatched@@ -146,10 +146,10 @@ goto normal_path; // unconditional branch- Recommendation: Keep enabled for this kernel build; continue monitoring for pattern drift.- Key verified points:- `0xFFFFFE0007B12100` (`convert_port_to_map_with_flavor`): b 0xB0E154 [_convert_port_to_map skip panic] | `a1020054 -> 15000014`-- Artifacts: `research/kernel_patch_jb/runtime_verification/runtime_verification_report.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_runtime_patch_points.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.md`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/runtime_verification_report.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_runtime_patch_points.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.md`<!-- END_RUNTIME_IDA_VERIFICATION_2026_03_05 -->## 2026-03-06 Upstream Rework Reviewdiff --git a/research/kernel_patch_jb/patch_cred_label_update_execve.md b/research/kernel_jailbreak_patches/patch_cred_label_update_execve.mdsimilarity index 100%rename from research/kernel_patch_jb/patch_cred_label_update_execve.mdrename to research/kernel_jailbreak_patches/patch_cred_label_update_execve.mddiff --git a/research/kernel_patch_jb/patch_dounmount.md b/research/kernel_jailbreak_patches/patch_dounmount.mdsimilarity index 98%rename from research/kernel_patch_jb/patch_dounmount.mdrename to research/kernel_jailbreak_patches/patch_dounmount.mdindex 2e38440d..59c023b8 100644--- a/research/kernel_patch_jb/patch_dounmount.md+++ b/research/kernel_jailbreak_patches/patch_dounmount.md@@ -165,7 +165,7 @@ Both variants emit exactly one patch:## Files- Patcher: `scripts/patchers/kernel_jb_patch_dounmount.py`-- Analysis doc: `research/kernel_patch_jb/patch_dounmount.md`+- Analysis doc: `research/kernel_jailbreak_patches/patch_dounmount.md`## 2026-03-06 Reworkdiff --git a/research/kernel_patch_jb/patch_hook_cred_label_update_execve.md b/research/kernel_jailbreak_patches/patch_hook_cred_label_update_execve.mdsimilarity index 100%rename from research/kernel_patch_jb/patch_hook_cred_label_update_execve.mdrename to research/kernel_jailbreak_patches/patch_hook_cred_label_update_execve.mddiff --git a/research/kernel_patch_jb/patch_io_secure_bsd_root.md b/research/kernel_jailbreak_patches/patch_io_secure_bsd_root.mdsimilarity index 99%rename from research/kernel_patch_jb/patch_io_secure_bsd_root.mdrename to research/kernel_jailbreak_patches/patch_io_secure_bsd_root.mdindex 7dd025ac..e1e5d8bf 100644--- a/research/kernel_patch_jb/patch_io_secure_bsd_root.md+++ b/research/kernel_jailbreak_patches/patch_io_secure_bsd_root.md@@ -7,7 +7,7 @@- Base VA: `0xFFFFFE0007004000`- Ground-truth sources for this note:- IDA-MCP on the loaded research kernel- - recovered symbol datasets in `research/kernel_info/json/`+ - recovered symbol datasets in `research/kernel_symbols/json/`- open-source XNU in `research/reference/xnu`This document intentionally discards earlier B19 writeups as untrusted and restarts the analysis from first principles.diff --git a/research/kernel_patch_jb/patch_iouc_failed_macf.md b/research/kernel_jailbreak_patches/patch_iouc_failed_macf.mdsimilarity index 100%rename from research/kernel_patch_jb/patch_iouc_failed_macf.mdrename to research/kernel_jailbreak_patches/patch_iouc_failed_macf.mddiff --git a/research/kernel_patch_jb/patch_kcall10.md b/research/kernel_jailbreak_patches/patch_kcall10.mdsimilarity index 100%rename from research/kernel_patch_jb/patch_kcall10.mdrename to research/kernel_jailbreak_patches/patch_kcall10.mddiff --git a/research/kernel_patch_jb/patch_load_dylinker.md b/research/kernel_jailbreak_patches/patch_load_dylinker.mdsimilarity index 92%rename from research/kernel_patch_jb/patch_load_dylinker.mdrename to research/kernel_jailbreak_patches/patch_load_dylinker.mdindex af514284..79a72c5c 100644--- a/research/kernel_patch_jb/patch_load_dylinker.md+++ b/research/kernel_jailbreak_patches/patch_load_dylinker.md@@ -110,7 +110,7 @@ This gate executes early in image loading. Without bypassing it, binaries can fa## Validation (Static Evidence)- Verified with IDA-MCP disassembly/decompilation, xrefs, and callgraph context for the selected site.-- Cross-checked against recovered symbols in `research/kernel_info/json/kernelcache.research.vphone600.bin.symbols.json`.+- Cross-checked against recovered symbols in `research/kernel_symbols/json/kernelcache.research.vphone600.bin.symbols.json`.- Address-level evidence in this document is consistent with patcher matcher intent.## Expected Failure/Panic if Unpatched@@ -158,10 +158,10 @@ This gate executes early in image loading. Without bypassing it, binaries can fa- Recommendation: Hit is valid but patch is inactive in find_all(); enable only after staged validation.- Key verified points:- `0xFFFFFE000805FED0` (`load_dylinker`): b #0x44 [_load_dylinker policy bypass] | `d228ef97 -> 11000014`-- Artifacts: `research/kernel_patch_jb/runtime_verification/runtime_verification_report.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_runtime_patch_points.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.md`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/runtime_verification_report.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_runtime_patch_points.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.md`<!-- END_RUNTIME_IDA_VERIFICATION_2026_03_05 -->## 2026-03-06 Upstream Rework Reviewdiff --git a/research/kernel_patch_jb/patch_mac_mount.md b/research/kernel_jailbreak_patches/patch_mac_mount.mdsimilarity index 100%rename from research/kernel_patch_jb/patch_mac_mount.mdrename to research/kernel_jailbreak_patches/patch_mac_mount.mddiff --git a/research/kernel_patch_jb/patch_nvram_verify_permission.md b/research/kernel_jailbreak_patches/patch_nvram_verify_permission.mdsimilarity index 92%rename from research/kernel_patch_jb/patch_nvram_verify_permission.mdrename to research/kernel_jailbreak_patches/patch_nvram_verify_permission.mdindex 26318f4f..e2073dea 100644--- a/research/kernel_patch_jb/patch_nvram_verify_permission.md+++ b/research/kernel_jailbreak_patches/patch_nvram_verify_permission.md@@ -98,7 +98,7 @@ if ((perm_flags & BIT0) == 0) {## Validation (Static Evidence)- Verified with IDA-MCP disassembly/decompilation, xrefs, and callgraph context for the selected site.-- Cross-checked against recovered symbols in `research/kernel_info/json/kernelcache.research.vphone600.bin.symbols.json`.+- Cross-checked against recovered symbols in `research/kernel_symbols/json/kernelcache.research.vphone600.bin.symbols.json`.- Address-level evidence in this document is consistent with patcher matcher intent.## Expected Failure/Panic if Unpatched@@ -146,10 +146,10 @@ if ((perm_flags & BIT0) == 0) {- Recommendation: Hit is valid but patch is inactive in find_all(); enable only after staged validation.- Key verified points:- `0xFFFFFE0008240C24` (`__ZL16verifyPermission16IONVRAMOperationPKhPKcbb`): NOP [verifyPermission NVRAM] | `78151037 -> 1f2003d5`-- Artifacts: `research/kernel_patch_jb/runtime_verification/runtime_verification_report.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_runtime_patch_points.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.md`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/runtime_verification_report.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_runtime_patch_points.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.md`<!-- END_RUNTIME_IDA_VERIFICATION_2026_03_05 -->## 2026-03-06 Upstream Rework Reviewdiff --git a/research/kernel_patch_jb/patch_post_validation_additional.md b/research/kernel_jailbreak_patches/patch_post_validation_additional.mdsimilarity index 95%rename from research/kernel_patch_jb/patch_post_validation_additional.mdrename to research/kernel_jailbreak_patches/patch_post_validation_additional.mdindex 3131d3b8..7ba655c0 100644--- a/research/kernel_patch_jb/patch_post_validation_additional.md+++ b/research/kernel_jailbreak_patches/patch_post_validation_additional.md@@ -146,7 +146,7 @@ if (hash_type != hash_type) {## Validation (Static Evidence)- Verified with IDA-MCP disassembly/decompilation, xrefs, and callgraph context for the selected site.-- Cross-checked against recovered symbols in `research/kernel_info/json/kernelcache.research.vphone600.bin.symbols.json`.+- Cross-checked against recovered symbols in `research/kernel_symbols/json/kernelcache.research.vphone600.bin.symbols.json`.- Address-level evidence in this document is consistent with patcher matcher intent.## Expected Failure/Panic if Unpatched@@ -195,10 +195,10 @@ if (hash_type != hash_type) {- Policy note: method is in the low-risk optimized set (validated hit on this kernel).- Key verified points:- `0xFFFFFE0008640760` (`sub_FFFFFE00086406F0`): cmp w0,w0 [postValidation additional fallback] | `1f000071 -> 1f00006b`-- Artifacts: `research/kernel_patch_jb/runtime_verification/runtime_verification_report.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_runtime_patch_points.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.md`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/runtime_verification_report.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_runtime_patch_points.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.md`<!-- END_RUNTIME_IDA_VERIFICATION_2026_03_05 -->## 2026-03-06 Upstream Rework Reviewdiff --git a/research/kernel_patch_jb/patch_proc_pidinfo.md b/research/kernel_jailbreak_patches/patch_proc_pidinfo.mdsimilarity index 92%rename from research/kernel_patch_jb/patch_proc_pidinfo.mdrename to research/kernel_jailbreak_patches/patch_proc_pidinfo.mdindex 77c16c50..c837cee6 100644--- a/research/kernel_patch_jb/patch_proc_pidinfo.md+++ b/research/kernel_jailbreak_patches/patch_proc_pidinfo.md@@ -95,7 +95,7 @@ if (pid_or_flavor_guard == 0) return EINVAL;## Validation (Static Evidence)- Verified with IDA-MCP disassembly/decompilation, xrefs, and callgraph context for the selected site.-- Cross-checked against recovered symbols in `research/kernel_info/json/kernelcache.research.vphone600.bin.symbols.json`.+- Cross-checked against recovered symbols in `research/kernel_symbols/json/kernelcache.research.vphone600.bin.symbols.json`.- Address-level evidence in this document is consistent with patcher matcher intent.## Expected Failure/Panic if Unpatched@@ -144,10 +144,10 @@ if (pid_or_flavor_guard == 0) return EINVAL;- Key verified points:- `0xFFFFFE000806DF38` (`sub_FFFFFE000806DED8`): NOP [_proc_pidinfo pid-0 guard A] | `e04000b4 -> 1f2003d5`- `0xFFFFFE000806DF40` (`sub_FFFFFE000806DED8`): NOP [_proc_pidinfo pid-0 guard B] | `34410034 -> 1f2003d5`-- Artifacts: `research/kernel_patch_jb/runtime_verification/runtime_verification_report.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_runtime_patch_points.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.md`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/runtime_verification_report.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_runtime_patch_points.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.md`<!-- END_RUNTIME_IDA_VERIFICATION_2026_03_05 -->## 2026-03-06 Upstream Rework Reviewdiff --git a/research/kernel_patch_jb/patch_proc_security_policy.md b/research/kernel_jailbreak_patches/patch_proc_security_policy.mdsimilarity index 95%rename from research/kernel_patch_jb/patch_proc_security_policy.mdrename to research/kernel_jailbreak_patches/patch_proc_security_policy.mdindex 7abeca02..d233eaed 100644--- a/research/kernel_patch_jb/patch_proc_security_policy.md+++ b/research/kernel_jailbreak_patches/patch_proc_security_policy.md@@ -91,7 +91,7 @@ Inference from those facts:## Symbol Consistency Audit (2026-03-05)- Status: `partial`-- Direct recovered symbol `proc_security_policy` is not present in current `kernel_info` JSON.+- Direct recovered symbol `proc_security_policy` is not present in current `kernel_symbols` JSON.- However, anchor-chain symbols `proc_info` (`0xfffffe000806d4dc`) and `proc_info_internal` (`0xfffffe000806d520`) are recovered and consistent with this document's call-path placement.- Function labels in this doc remain analyst-derived for the inner policy helper layer.@@ -159,7 +159,7 @@ int proc_security_policy(...) {## Validation (Static Evidence)- Verified with IDA-MCP disassembly/decompilation, xrefs, and callgraph context for the selected site.-- Cross-checked against recovered symbols in `research/kernel_info/json/kernelcache.research.vphone600.bin.symbols.json`.+- Cross-checked against recovered symbols in `research/kernel_symbols/json/kernelcache.research.vphone600.bin.symbols.json`.- Address-level evidence in this document is consistent with patcher matcher intent.## Expected Failure/Panic if Unpatched@@ -208,10 +208,10 @@ int proc_security_policy(...) {- Key verified points:- `0xFFFFFE00080705F0` (`sub_FFFFFE00080705F0`): mov x0,#0 [_proc_security_policy] | `7f2303d5 -> 000080d2`- `0xFFFFFE00080705F4` (`sub_FFFFFE00080705F0`): ret [_proc_security_policy] | `f85fbca9 -> c0035fd6`-- Artifacts: `research/kernel_patch_jb/runtime_verification/runtime_verification_report.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_runtime_patch_points.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.md`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/runtime_verification_report.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_runtime_patch_points.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.md`<!-- END_RUNTIME_IDA_VERIFICATION_2026_03_05 -->## 2026-03-06 Upstream Rework Reviewdiff --git a/research/kernel_patch_jb/patch_sandbox_hooks_extended.md b/research/kernel_jailbreak_patches/patch_sandbox_hooks_extended.mdsimilarity index 94%rename from research/kernel_patch_jb/patch_sandbox_hooks_extended.mdrename to research/kernel_jailbreak_patches/patch_sandbox_hooks_extended.mdindex 911f87ae..bc94f744 100644--- a/research/kernel_patch_jb/patch_sandbox_hooks_extended.md+++ b/research/kernel_jailbreak_patches/patch_sandbox_hooks_extended.md@@ -104,7 +104,7 @@ int hook_X(args...) {## Validation (Static Evidence)- Verified with IDA-MCP disassembly/decompilation, xrefs, and callgraph context for the selected site.-- Cross-checked against recovered symbols in `research/kernel_info/json/kernelcache.research.vphone600.bin.symbols.json`.+- Cross-checked against recovered symbols in `research/kernel_symbols/json/kernelcache.research.vphone600.bin.symbols.json`.- Address-level evidence in this document is consistent with patcher matcher intent.## Expected Failure/Panic if Unpatched@@ -196,10 +196,10 @@ Interpretation:- `0xFFFFFE00093B5104` (`_hook_vnode_check_unlink`): ret [_hook_vnode_check_unlink] | `e923ba6d -> c0035fd6`- `0xFFFFFE00093B53D8` (`_hook_vnode_check_unlink`): mov x0,#0 [_hook_vnode_check_truncate] | `7f2303d5 -> 000080d2`- `0xFFFFFE00093B53DC` (`_hook_vnode_check_unlink`): ret [_hook_vnode_check_truncate] | `fc6fbea9 -> c0035fd6`-- Artifacts: `research/kernel_patch_jb/runtime_verification/runtime_verification_report.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_runtime_patch_points.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.md`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/runtime_verification_report.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_runtime_patch_points.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.md`<!-- END_RUNTIME_IDA_VERIFICATION_2026_03_05 -->## 2026-03-06 Upstream Rework Reviewdiff --git a/research/kernel_patch_jb/patch_shared_region_map.md b/research/kernel_jailbreak_patches/patch_shared_region_map.mdsimilarity index 98%rename from research/kernel_patch_jb/patch_shared_region_map.mdrename to research/kernel_jailbreak_patches/patch_shared_region_map.mdindex 7ea41dc7..3adbbafb 100644--- a/research/kernel_patch_jb/patch_shared_region_map.md+++ b/research/kernel_jailbreak_patches/patch_shared_region_map.md@@ -134,7 +134,7 @@ Both variants emit exactly one patch:## Files- Patcher: `scripts/patchers/kernel_jb_patch_shared_region.py`-- Analysis doc: `research/kernel_patch_jb/patch_shared_region_map.md`+- Analysis doc: `research/kernel_jailbreak_patches/patch_shared_region_map.md`## 2026-03-06 Reworkdiff --git a/research/kernel_patch_jb/patch_spawn_validate_persona.md b/research/kernel_jailbreak_patches/patch_spawn_validate_persona.mdsimilarity index 98%rename from research/kernel_patch_jb/patch_spawn_validate_persona.mdrename to research/kernel_jailbreak_patches/patch_spawn_validate_persona.mdindex 9e9a7c95..33ca23f0 100644--- a/research/kernel_patch_jb/patch_spawn_validate_persona.md+++ b/research/kernel_jailbreak_patches/patch_spawn_validate_persona.md@@ -95,7 +95,7 @@ The upstream pair is the correct semantic gate because:## Files- Patcher: `scripts/patchers/kernel_jb_patch_spawn_persona.py`-- Analysis doc: `research/kernel_patch_jb/patch_spawn_validate_persona.md`+- Analysis doc: `research/kernel_jailbreak_patches/patch_spawn_validate_persona.md`## 2026-03-06 Reworkdiff --git a/research/kernel_patch_jb/patch_syscallmask_apply_to_proc.md b/research/kernel_jailbreak_patches/patch_syscallmask_apply_to_proc.mdsimilarity index 100%rename from research/kernel_patch_jb/patch_syscallmask_apply_to_proc.mdrename to research/kernel_jailbreak_patches/patch_syscallmask_apply_to_proc.mddiff --git a/research/kernel_patch_jb/patch_task_conversion_eval_internal.md b/research/kernel_jailbreak_patches/patch_task_conversion_eval_internal.mdsimilarity index 92%rename from research/kernel_patch_jb/patch_task_conversion_eval_internal.mdrename to research/kernel_jailbreak_patches/patch_task_conversion_eval_internal.mdindex 788f52e8..43cd01d2 100644--- a/research/kernel_patch_jb/patch_task_conversion_eval_internal.md+++ b/research/kernel_jailbreak_patches/patch_task_conversion_eval_internal.md@@ -105,7 +105,7 @@ if (true) goto allow; // compare neutralized## Validation (Static Evidence)- Verified with IDA-MCP disassembly/decompilation, xrefs, and callgraph context for the selected site.-- Cross-checked against recovered symbols in `research/kernel_info/json/kernelcache.research.vphone600.bin.symbols.json`.+- Cross-checked against recovered symbols in `research/kernel_symbols/json/kernelcache.research.vphone600.bin.symbols.json`.- Address-level evidence in this document is consistent with patcher matcher intent.## Expected Failure/Panic if Unpatched@@ -153,10 +153,10 @@ if (true) goto allow; // compare neutralized- Recommendation: Keep enabled for this kernel build; continue monitoring for pattern drift.- Key verified points:- `0xFFFFFE0007B10400` (`sub_FFFFFE0007B10334`): cmp xzr,xzr [_task_conversion_eval_internal] | `3f0100eb -> ff031feb`-- Artifacts: `research/kernel_patch_jb/runtime_verification/runtime_verification_report.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_runtime_patch_points.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.md`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/runtime_verification_report.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_runtime_patch_points.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.md`<!-- END_RUNTIME_IDA_VERIFICATION_2026_03_05 -->## 2026-03-06 Upstream Rework Reviewdiff --git a/research/kernel_patch_jb/patch_task_for_pid.md b/research/kernel_jailbreak_patches/patch_task_for_pid.mdsimilarity index 98%rename from research/kernel_patch_jb/patch_task_for_pid.mdrename to research/kernel_jailbreak_patches/patch_task_for_pid.mdindex 6c6c14d4..143276a8 100644--- a/research/kernel_patch_jb/patch_task_for_pid.md+++ b/research/kernel_jailbreak_patches/patch_task_for_pid.md@@ -129,7 +129,7 @@ Both variants emit exactly one patch:## Files- Patcher: `scripts/patchers/kernel_jb_patch_task_for_pid.py`-- Analysis doc: `research/kernel_patch_jb/patch_task_for_pid.md`+- Analysis doc: `research/kernel_jailbreak_patches/patch_task_for_pid.md`## 2026-03-06 Reworkdiff --git a/research/kernel_patch_jb/patch_thid_should_crash.md b/research/kernel_jailbreak_patches/patch_thid_should_crash.mdsimilarity index 94%rename from research/kernel_patch_jb/patch_thid_should_crash.mdrename to research/kernel_jailbreak_patches/patch_thid_should_crash.mdindex 1de89407..31b80f19 100644--- a/research/kernel_patch_jb/patch_thid_should_crash.md+++ b/research/kernel_jailbreak_patches/patch_thid_should_crash.md@@ -77,7 +77,7 @@## Symbol Consistency Audit (2026-03-05)- Status: `partial`-- Direct recovered symbol `thid_should_crash` is not present in current `kernel_info` JSON.+- Direct recovered symbol `thid_should_crash` is not present in current `kernel_symbols` JSON.- However, related exception-port entry symbols are recovered (`_Xhost_set_exception_ports`, `_Xtask_set_exception_ports`, `_Xthread_set_exception_ports`), and they are consistent with the static call-path analyzed here.- Sysctl-string and data-pointer analysis remain valid; target-node naming is still analyst-derived.@@ -143,7 +143,7 @@ return 1;## Validation (Static Evidence)- Verified with IDA-MCP disassembly/decompilation, xrefs, and callgraph context for the selected site.-- Cross-checked against recovered symbols in `research/kernel_info/json/kernelcache.research.vphone600.bin.symbols.json`.+- Cross-checked against recovered symbols in `research/kernel_symbols/json/kernelcache.research.vphone600.bin.symbols.json`.- Address-level evidence in this document is consistent with patcher matcher intent.## Expected Failure/Panic if Unpatched@@ -187,10 +187,10 @@ return 1;- Recommendation: Hit is valid but patch is inactive in find_all(); enable only after staged validation.- Key verified points:- `0xFFFFFE000768EB48` (`code-cave/data`): zero [_thid_should_crash] | `01000000 -> 00000000`-- Artifacts: `research/kernel_patch_jb/runtime_verification/runtime_verification_report.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_runtime_patch_points.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.md`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/runtime_verification_report.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_runtime_patch_points.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.md`<!-- END_RUNTIME_IDA_VERIFICATION_2026_03_05 -->## 2026-03-06 Upstream Rework Reviewdiff --git a/research/kernel_patch_jb/patch_thread_set_state.md b/research/kernel_jailbreak_patches/patch_thread_set_state.mdsimilarity index 100%rename from research/kernel_patch_jb/patch_thread_set_state.mdrename to research/kernel_jailbreak_patches/patch_thread_set_state.mddiff --git a/research/kernel_patch_jb/patch_vm_fault_enter_prepare.md b/research/kernel_jailbreak_patches/patch_vm_fault_enter_prepare.mdsimilarity index 100%rename from research/kernel_patch_jb/patch_vm_fault_enter_prepare.mdrename to research/kernel_jailbreak_patches/patch_vm_fault_enter_prepare.mddiff --git a/research/kernel_patch_jb/patch_vm_map_delete_immutable_code.md b/research/kernel_jailbreak_patches/patch_vm_map_delete_immutable_code.mdsimilarity index 100%rename from research/kernel_patch_jb/patch_vm_map_delete_immutable_code.mdrename to research/kernel_jailbreak_patches/patch_vm_map_delete_immutable_code.mddiff --git a/research/kernel_patch_jb/patch_vm_map_protect.md b/research/kernel_jailbreak_patches/patch_vm_map_protect.mdsimilarity index 95%rename from research/kernel_patch_jb/patch_vm_map_protect.mdrename to research/kernel_jailbreak_patches/patch_vm_map_protect.mdindex 2733b41f..e21608e2 100644--- a/research/kernel_patch_jb/patch_vm_map_protect.md+++ b/research/kernel_jailbreak_patches/patch_vm_map_protect.md@@ -56,7 +56,7 @@- Release kernel used: extracted raw Mach-O `/tmp/vphone-kcache-release-26.1.raw`.- Release outcome: `hit` at `0x00B8424C`.- Release emitted patch: `b #0x28 [_vm_map_protect]`.-- Method: focused `KernelJBPatcher.patch_vm_map_protect()` dry-runs, in the Python environment this repository had on that date. Both the Python patcher and that environment are gone; the port is `sources/FirmwarePatcher/Kernel/JBPatches/`.+- Method: focused `KernelJBPatcher.patch_vm_map_protect()` dry-runs, in the Python environment this repository had on that date. Both the Python patcher and that environment are gone; the port is `sources/FirmwarePatcher/Kernel/JailbreakPatches/`.- Result: the reworked matcher hits the same semantic gate on both PCC 26.1 research and PCC 26.1 release, and the research hit **matches upstream exactly**.## Why This Should Generalize Beyond The Current Research Image@@ -178,7 +178,7 @@ goto guarded_path; // unconditional## Validation (Static Evidence)- Verified with IDA-MCP disassembly/decompilation, xrefs, and callgraph context for the selected site.-- Cross-checked against recovered symbols in `research/kernel_info/json/kernelcache.research.vphone600.bin.symbols.json`.+- Cross-checked against recovered symbols in `research/kernel_symbols/json/kernelcache.research.vphone600.bin.symbols.json`.- Address-level evidence in this document is consistent with patcher matcher intent.## Expected Failure/Panic if Unpatched@@ -228,10 +228,10 @@ goto guarded_path; // unconditional- Recommendation: Hit is valid but patch is inactive in find_all(); enable only after staged validation.- Key verified points:- `0xFFFFFE0007BD09A8` (`vm_map_protect`): b #0x48C [_vm_map_protect] | `782400b7 -> 23010014`-- Artifacts: `research/kernel_patch_jb/runtime_verification/runtime_verification_report.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_runtime_patch_points.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.json`-- Artifacts: `research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.md`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/runtime_verification_report.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_runtime_patch_points.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.json`+- Artifacts: `research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.md`<!-- END_RUNTIME_IDA_VERIFICATION_2026_03_05 -->## 2026-03-06 Reworkdiff --git a/research/kernel_patch_jb/runtime_verification/README.md b/research/kernel_jailbreak_patches/runtime_verification/README.mdsimilarity index 100%rename from research/kernel_patch_jb/runtime_verification/README.mdrename to research/kernel_jailbreak_patches/runtime_verification/README.mddiff --git a/research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.md b/research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.mdsimilarity index 100%rename from research/kernel_patch_jb/runtime_verification/ida_patch_chain_report.mdrename to research/kernel_jailbreak_patches/runtime_verification/ida_patch_chain_report.mddiff --git a/research/kernel_patch_jb/runtime_verification/runtime_verification_summary.md b/research/kernel_jailbreak_patches/runtime_verification/runtime_verification_summary.mdsimilarity index 100%rename from research/kernel_patch_jb/runtime_verification/runtime_verification_summary.mdrename to research/kernel_jailbreak_patches/runtime_verification/runtime_verification_summary.mddiff --git a/research/kernel_info/kernel_index.tsv b/research/kernel_symbols/kernel_index.tsvsimilarity index 100%rename from research/kernel_info/kernel_index.tsvrename to research/kernel_symbols/kernel_index.tsvdiff --git a/research/kernel_info/kernel_symbols.db b/research/kernel_symbols/kernel_symbols.dbsimilarity index 100%rename from research/kernel_info/kernel_symbols.dbrename to research/kernel_symbols/kernel_symbols.dbdiff --git a/research/kernel_info/summary.tsv b/research/kernel_symbols/summary.tsvsimilarity index 100%rename from research/kernel_info/summary.tsvrename to research/kernel_symbols/summary.tsvdiff --git a/research/restore/p2_restore_off_python.md b/research/restore/p2_restore_off_python.mdindex af1e691d..a7bc0e96 100644--- a/research/restore/p2_restore_off_python.md+++ b/research/restore/p2_restore_off_python.md@@ -121,8 +121,8 @@ the same two lines of output that scripts and people have been grepping for| Python command | now | note || --- | --- | --- || `recovery-probe` | `VPhoneRecoveryProbe.probe` | `irecv_open_with_ecid_and_attempts` + timeout polling |-| `restore-get-shsh` | `VPhoneRestoreBridge.fetchSHSH` | erase ticket, as Python's did |-| `restore-update` | `VPhoneRestoreBridge.restore` | `erase` defaults true; `ticketPath` for `--offline` |+| `restore-get-shsh` | `VPhoneRestoreService.fetchSHSH` | erase ticket, as Python's did |+| `restore-update` | `VPhoneRestoreService.restore` | `erase` defaults true; `ticketPath` for `--offline` || `usbmux-list` | **not ported** | no call site anywhere in this repository |Two things the Swift has to undo, because idevicerestore and the Python bridge@@ -175,7 +175,7 @@ gap between `VPhoneRestore` and `vphone-cli`, not inside either:- **Row 3's `--offline` path bypassed its own guard, destructively.** The CLIglobbed `iPhone*_Restore` itself, sorted, and took the first — Python's rule,the one "Deliberate divergences" below says was replaced — then decrypted that- tree's AEA images **in place** before `VPhoneRestoreBridge` got a chance to+ tree's AEA images **in place** before `VPhoneRestoreService` got a chance torefuse two trees. With two firmware trees in a bundle it irreversiblydecrypted one nobody chose and *then* aborted. It now calls`VPhoneRestoreLayout.findRestoreDirectory` like every other caller, so thediff --git a/research/vphoned_http_api.md b/research/vphoned_http_api.mdindex 6dd150f3..cf78b31c 100644--- a/research/vphoned_http_api.md+++ b/research/vphoned_http_api.md@@ -11,8 +11,8 @@ host:port`. Port `0` asks the OS for an available host port and the actualaddress is printed after the VM starts. The API is also usable from guest andhost code that connects to VSOCK 1339 directly.-The SwiftPM `VPhoneKit` product is an unentitled HTTP/WebSocket client for-`vphone-ui` and other macOS apps. The separate public `VPhoneVMKit` product+The SwiftPM `VPhoneAPIKit` product is an unentitled HTTP/WebSocket client for+`vphone-ui` and other macOS apps. The separate public `VPhoneVirtualMachineKit` productexposes `VPhoneAPIProxy` to an app that owns a `VZVirtioSocketDevice`. Thecommand-line executable remains unentitled and still launches `vphone-vm`.@@ -87,7 +87,7 @@ curl http://127.0.0.1:8765/openapi.json``````swift-import VPhoneKit+import VPhoneAPIKitlet client = VPhoneAPIClient(baseURL: URL(string: "http://127.0.0.1:8765")!)let device = try await client.call("device.snapshot")diff --git a/scripts/check_aux.sh b/scripts/check_aux.shindex a9ea4883..eeecb863 100755--- a/scripts/check_aux.sh+++ b/scripts/check_aux.sh@@ -362,7 +362,7 @@ check_sources() {# `Data(contentsOf:)` with no options reads the whole file into resident# memory. That is fine for a plist and ruinous for what this project actually# opens: `ManifestHashPatcher` hashes the `OS` component, which is a ten- # gigabyte filesystem image, and `DSCLocalSymbolTable` parses+ # gigabyte filesystem image, and `DyldSharedCacheLocalSymbolTable` parses# dyld_shared_cache_arm64e.symbols, which is 1.17 GB on iOS 27 — it read both# tables whole, so every symbol resolver cost over a gigabyte and a test run# that built several took the machine down.diff --git a/scripts/setup_tools.sh b/scripts/setup_tools.shindex 658f9964..b33f0075 100755--- a/scripts/setup_tools.sh+++ b/scripts/setup_tools.sh@@ -39,17 +39,17 @@ ensure_repo_submodule() {# ── insert_dylib (test reference only) ─────────────────────────#-# Nothing in the product runs this: `CFWInjectDylib` injects the weak load+# Nothing in the product runs this: `CustomFirmwareInjectDylib` injects the weak load# command in-process, and the last caller that shelled out was# scripts/patchers/cfw.py. It is still built because it is the independent-# reference CFWMachOTests.matchesInsertDylib compares the Swift injector+# reference the `CustomFirmwareInjectDylibTests` "matches insert dylib" test compares the Swift injector# against, byte for byte — that test skips silently when it is missing, which# is the worst possible way to lose the check.## It is one .c file and one system framework, so this needs clang and nothing# else. There is no `brew install` left in this script.-echo "insert_dylib (byte-parity reference for CFWMachOTests)"+echo "insert_dylib (byte-parity reference for CustomFirmwareInjectDylibTests)"INSERT_DYLIB_BIN="$TOOLS_PREFIX/bin/insert_dylib"if [[ -x "$INSERT_DYLIB_BIN" ]]; thendiff --git a/scripts/vphoned/Swift/APIWire.swift b/scripts/vphoned/Daemon/APIWire.swiftsimilarity index 100%rename from scripts/vphoned/Swift/APIWire.swiftrename to scripts/vphoned/Daemon/APIWire.swiftdiff --git a/scripts/vphoned/Swift/GuestAPI.swift b/scripts/vphoned/Daemon/GuestAPI.swiftsimilarity index 100%rename from scripts/vphoned/Swift/GuestAPI.swiftrename to scripts/vphoned/Daemon/GuestAPI.swiftdiff --git a/scripts/vphoned/Swift/GuestEventPublisher.swift b/scripts/vphoned/Daemon/GuestEventPublisher.swiftsimilarity index 100%rename from scripts/vphoned/Swift/GuestEventPublisher.swiftrename to scripts/vphoned/Daemon/GuestEventPublisher.swiftdiff --git a/scripts/vphoned/Swift/GuestFileTransfer.swift b/scripts/vphoned/Daemon/GuestFileTransfer.swiftsimilarity index 100%rename from scripts/vphoned/Swift/GuestFileTransfer.swiftrename to scripts/vphoned/Daemon/GuestFileTransfer.swiftdiff --git a/scripts/vphoned/Swift/GuestHTTPHandler.swift b/scripts/vphoned/Daemon/GuestHTTPHandler.swiftsimilarity index 99%rename from scripts/vphoned/Swift/GuestHTTPHandler.swiftrename to scripts/vphoned/Daemon/GuestHTTPHandler.swiftindex 49b93706..5f81c641 100644--- a/scripts/vphoned/Swift/GuestHTTPHandler.swift+++ b/scripts/vphoned/Daemon/GuestHTTPHandler.swift@@ -103,7 +103,7 @@ final class GuestHTTPHandler: ChannelInboundHandler, RemovableChannelHandler, @uprivate func handle(_ head: HTTPRequestHead, body: Data, channel: Channel) {let path = head.uri.split(separator: "?", maxSplits: 1).first.map(String.init) ?? head.uriif head.method == .GET && path == "/openapi.json" {- Self.send(APIReply(status: 200, data: OpenAPISpec.data), on: channel)+ Self.send(APIReply(status: 200, data: OpenAPIDocument.data), on: channel)return}if head.method == .GET && path == "/v1/health" {diff --git a/scripts/vphoned/Swift/GuestWebSocketHandler.swift b/scripts/vphoned/Daemon/GuestWebSocketHandler.swiftsimilarity index 100%rename from scripts/vphoned/Swift/GuestWebSocketHandler.swiftrename to scripts/vphoned/Daemon/GuestWebSocketHandler.swiftdiff --git a/scripts/vphoned/Swift/IcliCommand.swift b/scripts/vphoned/Daemon/IcliCommand.swiftsimilarity index 100%rename from scripts/vphoned/Swift/IcliCommand.swiftrename to scripts/vphoned/Daemon/IcliCommand.swiftdiff --git a/scripts/vphoned/Swift/OpenAPISpec.swift b/scripts/vphoned/Daemon/OpenAPIDocument.swiftsimilarity index 99%rename from scripts/vphoned/Swift/OpenAPISpec.swiftrename to scripts/vphoned/Daemon/OpenAPIDocument.swiftindex 31080a5b..ce35b32a 100644--- a/scripts/vphoned/Swift/OpenAPISpec.swift+++ b/scripts/vphoned/Daemon/OpenAPIDocument.swift@@ -1,6 +1,6 @@import Foundation-enum OpenAPISpec {+enum OpenAPIDocument {static let data = Data(spec.utf8)private static let spec = #"""diff --git a/scripts/vphoned/Swift/main.swift b/scripts/vphoned/Daemon/main.swiftsimilarity index 100%rename from scripts/vphoned/Swift/main.swiftrename to scripts/vphoned/Daemon/main.swiftdiff --git a/scripts/vphoned/Package.swift b/scripts/vphoned/Package.swiftindex b8fae5c3..4976370e 100644--- a/scripts/vphoned/Package.swift+++ b/scripts/vphoned/Package.swift@@ -12,7 +12,6 @@ let package = Package(dependencies: [.package(url: "https://github.com/owngoal-dev/icli.git", exact: "0.6.1"),.package(url: "https://github.com/apple/swift-nio.git", exact: "2.83.0"),- .package(url: "https://github.com/apple/swift-collections.git", exact: "1.3.0"),],targets: [.target(@@ -44,7 +43,7 @@ let package = Package(.product(name: "NIOPosix", package: "swift-nio"),.product(name: "NIOWebSocket", package: "swift-nio"),],- path: "Swift",+ path: "Daemon",linkerSettings: [.unsafeFlags(["-Xlinker", "-dead_strip_dylibs"])]),]diff --git a/skills/kernel-analysis-vphone600/SKILL.md b/skills/kernel-analysis-vphone600/SKILL.mdindex ead2eaf1..d6700622 100644--- a/skills/kernel-analysis-vphone600/SKILL.md+++ b/skills/kernel-analysis-vphone600/SKILL.md@@ -5,20 +5,20 @@ description: Analyze vphone600 kernel artifacts using the local symbol database# Kernel Analysis Vphone600-Use the local `research/kernel_info` dataset as the first source of truth for symbol lookup.+Use the local `research/kernel_symbols` dataset as the first source of truth for symbol lookup.Use `research/reference/xnu` as the source-level reference for semantics and structure.## Required Paths-- `research/kernel_info/kernel_symbols.db`-- `research/kernel_info/kernel_index.tsv` (plain-text `kernel_name → json_path` index with `json_sha256`)-- `research/kernel_info/json/` — the recovered symbol datasets:+- `research/kernel_symbols/kernel_symbols.db`+- `research/kernel_symbols/kernel_index.tsv` (plain-text `kernel_name → json_path` index with `json_sha256`)+- `research/kernel_symbols/json/` — the recovered symbol datasets:- `kernelcache.release.vphone600.bin.symbols.json`- `kernelcache.research.vphone600.bin.symbols.json`- `research/reference/xnu`The `json_path` column in both the database and `kernel_index.tsv` records the absolute path from symbolication-time and may not match this checkout; resolve the JSON files under `research/kernel_info/json/` instead.+time and may not match this checkout; resolve the JSON files under `research/kernel_symbols/json/` instead.If `research/reference/xnu` is missing, create it with a shallow clone:diff --git a/skills/kernel-analysis-vphone600/references/kernel-info-queries.md b/skills/kernel-analysis-vphone600/references/kernel-info-queries.mdindex 6d77f664..4a466481 100644--- a/skills/kernel-analysis-vphone600/references/kernel-info-queries.md+++ b/skills/kernel-analysis-vphone600/references/kernel-info-queries.md@@ -5,30 +5,30 @@ Use these commands from repo root (`vphone-cli`).## Database Introspection```bash-sqlite3 research/kernel_info/kernel_symbols.db ".schema kernel_symbols"-sqlite3 research/kernel_info/kernel_symbols.db "select count(*) from kernel_symbols;"-sqlite3 research/kernel_info/kernel_symbols.db "select kernel_name, matched, missed, percent, total from kernel_symbols order by kernel_name;"-sqlite3 research/kernel_info/kernel_symbols.db "select kernel_name, json_path from kernel_symbols order by kernel_name;"+sqlite3 research/kernel_symbols/kernel_symbols.db ".schema kernel_symbols"+sqlite3 research/kernel_symbols/kernel_symbols.db "select count(*) from kernel_symbols;"+sqlite3 research/kernel_symbols/kernel_symbols.db "select kernel_name, matched, missed, percent, total from kernel_symbols order by kernel_name;"+sqlite3 research/kernel_symbols/kernel_symbols.db "select kernel_name, json_path from kernel_symbols order by kernel_name;"```## Resolve JSON Path By Kernel Name```bash-sqlite3 research/kernel_info/kernel_symbols.db \+sqlite3 research/kernel_symbols/kernel_symbols.db \"select json_path from kernel_symbols where kernel_name='kernelcache.release.vphone600';"``````bash-sqlite3 research/kernel_info/kernel_symbols.db \+sqlite3 research/kernel_symbols/kernel_symbols.db \"select json_path from kernel_symbols where kernel_name='kernelcache.research.vphone600';"```## Fast Symbol Search```bash-rg -n 'panic' research/kernel_info/json/kernelcache.release.vphone600.bin.symbols.json-rg -n 'mach_trap' research/kernel_info/json/kernelcache.research.vphone600.bin.symbols.json-rg -n '0xfffffe00' research/kernel_info/json/kernelcache.release.vphone600.bin.symbols.json+rg -n 'panic' research/kernel_symbols/json/kernelcache.release.vphone600.bin.symbols.json+rg -n 'mach_trap' research/kernel_symbols/json/kernelcache.research.vphone600.bin.symbols.json+rg -n '0xfffffe00' research/kernel_symbols/json/kernelcache.release.vphone600.bin.symbols.json```## Use XNU Source Referencediff --git a/sources/FirmwarePatcher/ARM64/ARM64Inst.swift b/sources/FirmwarePatcher/ARM64/ARM64Inst.swiftindex c72db367..a8b4e4be 100644--- a/sources/FirmwarePatcher/ARM64/ARM64Inst.swift+++ b/sources/FirmwarePatcher/ARM64/ARM64Inst.swift@@ -3,8 +3,8 @@// These operate directly on a 4-byte little-endian instruction word so the kernel// patchers can scan megabytes of __TEXT_EXEC without paying Capstone's per-instruction// cost. They are the SINGLE SOURCE OF TRUTH for the opcode masks that were previously-// re-spelled inline in each JB patch file (KernelJBPatchTaskConversion, VmProtect,-// ProcPidinfo, HookCredLabel) and in KernelJBPatcherBase.findProcSecurityPolicy.+// re-spelled inline in each JB patch file (KernelJailbreakPatchTaskConversion, VmProtect,+// ProcPidinfo, HookCredLabel) and in KernelJailbreakPatcherBase.findProcSecurityPolicy.//// Every mask/value is documented against the ARM64 ISA encoding and round-trip// verified against Capstone in ARM64InstTests. When a Capstone `Instruction` isdiff --git a/sources/FirmwarePatcher/Filesystem/CryptexFilesystemPatcher.swift b/sources/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcher.swiftsimilarity index 100%rename from sources/FirmwarePatcher/Filesystem/CryptexFilesystemPatcher.swiftrename to sources/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcher.swiftdiff --git a/sources/FirmwarePatcher/Filesystem/CryptexFilesystemPatcherAEA.swift b/sources/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherAEA.swiftsimilarity index 100%rename from sources/FirmwarePatcher/Filesystem/CryptexFilesystemPatcherAEA.swiftrename to sources/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherAEA.swiftdiff --git a/sources/FirmwarePatcher/Filesystem/CryptexFilesystemPatcherDiskImage.swift b/sources/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherDiskImage.swiftsimilarity index 100%rename from sources/FirmwarePatcher/Filesystem/CryptexFilesystemPatcherDiskImage.swiftrename to sources/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherDiskImage.swiftdiff --git a/sources/FirmwarePatcher/Filesystem/CryptexFilesystemPatcherFileOps.swift b/sources/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherFileOps.swiftsimilarity index 95%rename from sources/FirmwarePatcher/Filesystem/CryptexFilesystemPatcherFileOps.swiftrename to sources/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherFileOps.swiftindex 2df91b65..b77e44a0 100644--- a/sources/FirmwarePatcher/Filesystem/CryptexFilesystemPatcherFileOps.swift+++ b/sources/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherFileOps.swift@@ -12,7 +12,7 @@import Foundation-enum FileOpError: Error, CustomStringConvertible {+enum CryptexFileOperationError: Error, CustomStringConvertible {case chown(path: String, code: Int32)case unlink(path: String, code: Int32)case symlinkOntoDirectory(path: String)@@ -52,7 +52,7 @@ extension CryptexFilesystemPatcher {func chownRecursively(uid: uid_t, gid: gid_t, at url: URL) throws {for entry in [url] + entriesBelow(url).map(\.url) {guard lchown(entry.path, uid, gid) == 0 else {- throw FileOpError.chown(path: entry.path, code: errno)+ throw CryptexFileOperationError.chown(path: entry.path, code: errno)}}}@@ -72,7 +72,7 @@ extension CryptexFilesystemPatcher {var info = stat()if lstat(link.path, &info) == 0 {guard info.st_mode & mode_t(S_IFMT) != mode_t(S_IFDIR) else {- throw FileOpError.symlinkOntoDirectory(path: link.path)+ throw CryptexFileOperationError.symlinkOntoDirectory(path: link.path)}try FileManager.default.removeItem(at: link)}@@ -102,7 +102,7 @@ extension CryptexFilesystemPatcher {// listings. unlink removes the directory entry, which is the job.let gone = entry.isDirectory ? rmdir(entry.url.path) : unlink(entry.url.path)guard gone == 0 else {- throw FileOpError.unlink(path: entry.url.path, code: errno)+ throw CryptexFileOperationError.unlink(path: entry.url.path, code: errno)}removed += 1}diff --git a/sources/FirmwarePatcher/Filesystem/CryptexFilesystemPatcherGuestPayload.swift b/sources/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherGuestPayload.swiftsimilarity index 96%rename from sources/FirmwarePatcher/Filesystem/CryptexFilesystemPatcherGuestPayload.swiftrename to sources/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherGuestPayload.swiftindex 893dbc76..707552b8 100644--- a/sources/FirmwarePatcher/Filesystem/CryptexFilesystemPatcherGuestPayload.swift+++ b/sources/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherGuestPayload.swift@@ -31,7 +31,7 @@ extension CryptexFilesystemPatcher {// Patched in place with no `.bak` to restore from, so this is the call// site that needs the port's idempotence. No re-attestation: the sign// below replaces the whole signature anyway.- try CFWCacheLoaderPatcher.patch(fileAt: launchdCacheLoaderPath)+ try CustomFirmwareCacheLoaderPatcher.patch(fileAt: launchdCacheLoaderPath)try setMode(0o755, at: launchdCacheLoaderPath)try VPhoneSigner.sign(@@ -57,7 +57,7 @@ extension CryptexFilesystemPatcher {at: vphonedLaunchdPlist,to: target.appending(path: "System/Library/LaunchDaemons/vphoned.plist"),)- try CFWDaemons.injectDaemon(into: launchdPath, name: "vphoned", from: vphonedLaunchdPlist)+ try CustomFirmwareDaemons.injectDaemon(into: launchdPath, name: "vphoned", from: vphonedLaunchdPlist)print(" [+] Injected vphoned")try FileManager.default.moveItem(at: launchdPath, to: launchdOgPath)try setMode(0o644, at: launchdOgPath)@@ -146,7 +146,7 @@ extension CryptexFilesystemPatcher {let mobileActivationdPath = target.appending(path: "/usr/libexec/mobileactivationd")// `resign: false` because the sign below replaces the signature, and// re-attesting would refuse an unsigned input the Python accepted.- try CFWMobileactivationd.patch(fileAt: mobileActivationdPath, resign: false)+ try CustomFirmwareMobileactivationd.patch(fileAt: mobileActivationdPath, resign: false)try setMode(0o755, at: mobileActivationdPath)try VPhoneSigner.sign(diff --git a/sources/FirmwarePatcher/Filesystem/CryptexFilesystemPatcherManifest.swift b/sources/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherManifest.swiftsimilarity index 100%rename from sources/FirmwarePatcher/Filesystem/CryptexFilesystemPatcherManifest.swiftrename to sources/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherManifest.swiftdiff --git a/sources/FirmwarePatcher/Filesystem/CryptexFilesystemPatcherProcess.swift b/sources/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherProcess.swiftsimilarity index 96%rename from sources/FirmwarePatcher/Filesystem/CryptexFilesystemPatcherProcess.swiftrename to sources/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherProcess.swiftindex 56c7b460..812b0ca4 100644--- a/sources/FirmwarePatcher/Filesystem/CryptexFilesystemPatcherProcess.swift+++ b/sources/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherProcess.swift@@ -8,7 +8,7 @@// There used to be a `sudo: Bool` parameter here that spawned `/usr/bin/whoami` and matched// "root" in its output. Nothing ever passed it — it was dead on every call site — and the// question it asked is `geteuid()`, which needs no process and no string match. The live root-// check is VPhoneCreateOrchestrator's, before any of this runs.+// check is VPhoneVirtualMachineCreator's, before any of this runs.import Foundationdiff --git a/sources/FirmwarePatcher/Filesystem/CryptexFilesystemPatcherSealing.swift b/sources/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherSealing.swiftsimilarity index 100%rename from sources/FirmwarePatcher/Filesystem/CryptexFilesystemPatcherSealing.swiftrename to sources/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherSealing.swiftdiff --git a/sources/FirmwarePatcher/CFW/CFWBuildVersion.swift b/sources/FirmwarePatcher/CustomFirmware/CustomFirmwareBuildVersion.swiftsimilarity index 97%rename from sources/FirmwarePatcher/CFW/CFWBuildVersion.swiftrename to sources/FirmwarePatcher/CustomFirmware/CustomFirmwareBuildVersion.swiftindex 34aa174b..67d07191 100644--- a/sources/FirmwarePatcher/CFW/CFWBuildVersion.swift+++ b/sources/FirmwarePatcher/CustomFirmware/CustomFirmwareBuildVersion.swift@@ -1,4 +1,4 @@-// CFWBuildVersion.swift — rewrite ProductBuildVersion in SystemVersion.plist.+// CustomFirmwareBuildVersion.swift — rewrite ProductBuildVersion in SystemVersion.plist.//// Swift port of scripts/patchers/cfw_patch_build_version.py (EXP-JB-7).//@@ -22,7 +22,7 @@ import Foundation/// Rewrites `ProductBuildVersion` in a `SystemVersion.plist`, preserving the/// file's original plist format (XML in, XML out; binary in, binary out).-public enum CFWBuildVersion {+public enum CustomFirmwareBuildVersion {/// The single key this patcher touches.public static let key = "ProductBuildVersion"diff --git a/sources/FirmwarePatcher/CFW/CFWDaemons.swift b/sources/FirmwarePatcher/CustomFirmware/CustomFirmwareDaemons.swiftsimilarity index 96%rename from sources/FirmwarePatcher/CFW/CFWDaemons.swiftrename to sources/FirmwarePatcher/CustomFirmware/CustomFirmwareDaemons.swiftindex 5cea931e..4ecc22f9 100644--- a/sources/FirmwarePatcher/CFW/CFWDaemons.swift+++ b/sources/FirmwarePatcher/CustomFirmware/CustomFirmwareDaemons.swift@@ -1,4 +1,4 @@-// CFWDaemons.swift — Cryptex path lookup and the plist I/O the CFW daemon rewrites share.+// CustomFirmwareDaemons.swift — Cryptex path lookup and the plist I/O the CFW daemon rewrites share.//// Translated from: scripts/patchers/cfw_daemons.py (cryptex-paths, inject-daemons,// patch-dropbear-plist). None of these three touch code or signatures — they are@@ -7,11 +7,11 @@import Foundation-// MARK: - CFWDaemons+// MARK: - CustomFirmwareDaemons/// The three non-disassembly CFW commands: Cryptex path lookup, LaunchDaemon/// injection into `launchd.plist`, and the dropbear `ProgramArguments` rewrite.-public enum CFWDaemons {+public enum CustomFirmwareDaemons {// MARK: - Errorspublic enum DaemonError: Error, CustomStringConvertible {diff --git a/sources/FirmwarePatcher/CFW/CFWDaemonsDropbear.swift b/sources/FirmwarePatcher/CustomFirmware/CustomFirmwareDaemonsDropbear.swiftsimilarity index 94%rename from sources/FirmwarePatcher/CFW/CFWDaemonsDropbear.swiftrename to sources/FirmwarePatcher/CustomFirmware/CustomFirmwareDaemonsDropbear.swiftindex fa398914..0a01671f 100644--- a/sources/FirmwarePatcher/CFW/CFWDaemonsDropbear.swift+++ b/sources/FirmwarePatcher/CustomFirmware/CustomFirmwareDaemonsDropbear.swift@@ -1,12 +1,12 @@-// CFWDaemonsDropbear.swift — dropbear's ProgramArguments rewrite.+// CustomFirmwareDaemonsDropbear.swift — dropbear's ProgramArguments rewrite.//// Translated from: scripts/patchers/cfw_daemons.py (patch_dropbear_daemon,-// patch_dropbear_plist). Covered by tests/FirmwarePatcherTests/CFWDaemonsTests.swift,+// patch_dropbear_plist). Covered by tests/FirmwarePatcherTests/CustomFirmwareDaemonsTests.swift,// which carries both cases of the retired tests/test_dropbear_plist.py.import Foundation-public extension CFWDaemons {+public extension CustomFirmwareDaemons {// MARK: - Host keys/// The host keys dropbear is pointed at instead of generating its own.diff --git a/sources/FirmwarePatcher/CFW/CFWDaemonsLaunchd.swift b/sources/FirmwarePatcher/CustomFirmware/CustomFirmwareDaemonsLaunchd.swiftsimilarity index 95%rename from sources/FirmwarePatcher/CFW/CFWDaemonsLaunchd.swiftrename to sources/FirmwarePatcher/CustomFirmware/CustomFirmwareDaemonsLaunchd.swiftindex 8d926ec6..3f07cf9c 100644--- a/sources/FirmwarePatcher/CFW/CFWDaemonsLaunchd.swift+++ b/sources/FirmwarePatcher/CustomFirmware/CustomFirmwareDaemonsLaunchd.swift@@ -1,4 +1,4 @@-// CFWDaemonsLaunchd.swift — LaunchDaemon injection into /System/Library/xpc/launchd.plist.+// CustomFirmwareDaemonsLaunchd.swift — LaunchDaemon injection into /System/Library/xpc/launchd.plist.//// Translated from: scripts/patchers/cfw_daemons.py (inject_daemons), and from the// inline plistlib snippets at cfw_install_jb.sh:460-469 and cfw_install_exp.sh:702-711.@@ -10,7 +10,7 @@import Foundation-public extension CFWDaemons {+public extension CustomFirmwareDaemons {// MARK: - Daemon/// One LaunchDaemon to merge, already loaded and already rewritten.@@ -135,8 +135,8 @@ public extension CFWDaemons {// MARK: - Scan convenience-public extension [CFWDaemons.StagedDaemon] {- var present: [CFWDaemons.Daemon] {+public extension [CustomFirmwareDaemons.StagedDaemon] {+ var present: [CustomFirmwareDaemons.Daemon] {compactMap {if case let .present(daemon) = $0 {daemondiff --git a/sources/FirmwarePatcher/CFW/CFWInjectDylib.swift b/sources/FirmwarePatcher/CustomFirmware/CustomFirmwareInjectDylib.swiftsimilarity index 96%rename from sources/FirmwarePatcher/CFW/CFWInjectDylib.swiftrename to sources/FirmwarePatcher/CustomFirmware/CustomFirmwareInjectDylib.swiftindex 1e4387d7..0b8ffae1 100644--- a/sources/FirmwarePatcher/CFW/CFWInjectDylib.swift+++ b/sources/FirmwarePatcher/CustomFirmware/CustomFirmwareInjectDylib.swift@@ -1,4 +1,4 @@-// CFWInjectDylib.swift — LC_LOAD_DYLIB / LC_LOAD_WEAK_DYLIB insertion.+// CustomFirmwareInjectDylib.swift — LC_LOAD_DYLIB / LC_LOAD_WEAK_DYLIB insertion.//// Replaces the `insert_dylib` binary built from `scripts/repos/insert_dylib`,// whose only caller is the launchdhook injection in `cfw_install_jb.sh` and@@ -71,7 +71,7 @@ private extension Data {// MARK: - Result/// What one injected load command ended up as, per architecture slice.-public struct CFWDylibInjection: Sendable {+public struct CustomFirmwareDylibInjection: Sendable {/// Slice start in the file. 0 for a thin binary.public let sliceOffset: Int/// Slice size after injection (smaller than before when the signature was stripped).@@ -85,12 +85,12 @@ public struct CFWDylibInjection: Sendable {/// True when LC_CODE_SIGNATURE and its blob were removed.public let removedCodeSignature: Bool/// Slots re-hashed under `.keepAndReattest`. Empty under `.strip`.- public let rehashedSlots: [CFWSlotRehash]+ public let rehashedSlots: [CustomFirmwareSlotRehash]}// MARK: - Injector-public enum CFWInjectDylib {+public enum CustomFirmwareInjectDylib {/// What to do about an existing LC_CODE_SIGNATURE.public enum CodeSignaturePolicy: Sendable {/// Drop the load command, the signature blob and the bytes it occupied,@@ -135,7 +135,7 @@ public enum CFWInjectDylib {weak: Bool = true,policy: CodeSignaturePolicy = .strip,allowNonEmptyPadding: Bool = false,- ) throws -> [CFWDylibInjection] {+ ) throws -> [CustomFirmwareDylibInjection] {guard FileManager.default.fileExists(atPath: url.path) else {throw PatcherError.fileNotFound(url.path)}@@ -159,7 +159,7 @@ public enum CFWInjectDylib {weak: Bool = true,policy: CodeSignaturePolicy = .strip,allowNonEmptyPadding: Bool = false,- ) throws -> [CFWDylibInjection] {+ ) throws -> [CustomFirmwareDylibInjection] {if data.startIndex != 0 {data = Data(data)}@@ -205,13 +205,13 @@ public enum CFWInjectDylib {/// order, slide each one down to its alignment boundary behind the previous/// slice, inject, and truncate. Slices move because `.strip` makes earlier/// ones shorter.- static func injectFat(into data: inout Data, options: Options) throws -> [CFWDylibInjection] {+ static func injectFat(into data: inout Data, options: Options) throws -> [CustomFirmwareDylibInjection] {let archCount = Int(data.loadBEValue(UInt32.self, at: 4))guard archCount > 0, data.holds(8, archCount * 20) else {throw PatcherError.invalidFormat("fat header declares \(archCount) architectures it does not have")}- var injections: [CFWDylibInjection] = []+ var injections: [CustomFirmwareDylibInjection] = []var fileSize = data.countvar cursor = Int(data.loadBEValue(UInt32.self, at: 8 + 8))@@ -268,7 +268,7 @@ public enum CFWInjectDylib {headerOffset: Int,sliceSize: inout Int,options: Options,- ) throws -> CFWDylibInjection {+ ) throws -> CustomFirmwareDylibInjection {guard data.holds(headerOffset, machHeader64Size) else {throw PatcherError.invalidFormat("Mach-O header at 0x\(String(headerOffset, radix: 16)) is truncated")}@@ -347,7 +347,7 @@ public enum CFWInjectDylib {data.storeLE(ncmds, at: headerOffset + 16)data.storeLE(UInt32(sizeofcmds), at: headerOffset + 20)- var rehashed: [CFWSlotRehash] = []+ var rehashed: [CustomFirmwareSlotRehash] = []if case .keepAndReattest = options.policy {rehashed = try reattestSlice(in: &data,@@ -360,7 +360,7 @@ public enum CFWInjectDylib {)}- return CFWDylibInjection(+ return CustomFirmwareDylibInjection(sliceOffset: headerOffset,sliceSize: sliceSize,cpuType: cpuType,@@ -513,10 +513,10 @@ public enum CFWInjectDylib {headerOffset: Int,sliceSize: Int,touched: [Range<Int>],- ) throws -> [CFWSlotRehash] {+ ) throws -> [CustomFirmwareSlotRehash] {var slice = Data(data[headerOffset ..< headerOffset + sliceSize])let offsets = touched.flatMap { range in range.map { $0 - headerOffset } }- let records = try CFWMachOCodeSignature.reattest(&slice, modifiedOffsets: offsets)+ let records = try CustomFirmwareMachOCodeSignature.reattest(&slice, modifiedOffsets: offsets)data.replaceSubrange(headerOffset ..< headerOffset + sliceSize, with: slice)return records}diff --git a/sources/FirmwarePatcher/CFW/CFWMachLookupExceptions.swift b/sources/FirmwarePatcher/CustomFirmware/CustomFirmwareMachLookupExceptions.swiftsimilarity index 97%rename from sources/FirmwarePatcher/CFW/CFWMachLookupExceptions.swiftrename to sources/FirmwarePatcher/CustomFirmware/CustomFirmwareMachLookupExceptions.swiftindex da270e5d..9bfe8e44 100644--- a/sources/FirmwarePatcher/CFW/CFWMachLookupExceptions.swift+++ b/sources/FirmwarePatcher/CustomFirmware/CustomFirmwareMachLookupExceptions.swift@@ -1,4 +1,4 @@-// CFWMachLookupExceptions.swift — Campo backboard/frontboard mach-lookups.+// CustomFirmwareMachLookupExceptions.swift — Campo backboard/frontboard mach-lookups.//// Swift port of scripts/patchers/campo_mach_lookup_exceptions.py (JB-3b).// See research/0_binary_patch_comparison.md #14.@@ -19,7 +19,7 @@ import Foundation/// Merges the mach-lookup global-name exceptions Campo needs into an/// entitlements plist, in place.-public enum CFWMachLookupExceptions {+public enum CustomFirmwareMachLookupExceptions {/// The entitlement array this patcher merges into.public static let exceptionKey = "com.apple.security.exception.mach-lookup.global-name"diff --git a/sources/FirmwarePatcher/CFW/CFWMachOCodeSignature.swift b/sources/FirmwarePatcher/CustomFirmware/CustomFirmwareMachOCodeSignature.swiftsimilarity index 95%rename from sources/FirmwarePatcher/CFW/CFWMachOCodeSignature.swiftrename to sources/FirmwarePatcher/CustomFirmware/CustomFirmwareMachOCodeSignature.swiftindex 26d7c250..b44c9875 100644--- a/sources/FirmwarePatcher/CFW/CFWMachOCodeSignature.swift+++ b/sources/FirmwarePatcher/CustomFirmware/CustomFirmwareMachOCodeSignature.swift@@ -1,4 +1,4 @@-// CFWMachOCodeSignature.swift — Standalone Mach-O code-signature page-hash re-attestation.+// CustomFirmwareMachOCodeSignature.swift — Standalone Mach-O code-signature page-hash re-attestation.//// Port of `scripts/patchers/cfw_macho_codesign.py` (344 lines). The DSC-chunk// half of the same technique lives elsewhere and deliberately does NOT share@@ -44,7 +44,7 @@ private extension Data {// MARK: - Code Directory/// One `CS_CodeDirectory` blob inside a Mach-O's embedded signature.-public struct CFWCodeDirectory: Sendable, Equatable {+public struct CustomFirmwareCodeDirectory: Sendable, Equatable {/// `CS_BlobIndex.type` this CD was reached through (0 = primary, 0x1000+ = alt).public let slotType: UInt32/// Absolute file offset of the CD blob.@@ -82,7 +82,7 @@ public struct CFWCodeDirectory: Sendable, Equatable {// MARK: - Slot Rehash Record/// One slot hash that re-attestation replaced.-public struct CFWSlotRehash: Sendable, Equatable {+public struct CustomFirmwareSlotRehash: Sendable, Equatable {public let codeDirectoryOffset: Intpublic let slotType: UInt32public let pageIndex: Int@@ -105,7 +105,7 @@ public struct CFWSlotRehash: Sendable, Equatable {}}-extension CFWSlotRehash: CustomStringConvertible {+extension CustomFirmwareSlotRehash: CustomStringConvertible {public var description: String {let tail = isTailSlot ? " [tail, \(hashedLength)B]" : ""return String(@@ -121,7 +121,7 @@ extension CFWSlotRehash: CustomStringConvertible {// MARK: - Re-attestation-public enum CFWMachOCodeSignature {+public enum CustomFirmwareMachOCodeSignature {// MARK: Constantsstatic let superBlobMagic: UInt32 = 0xFADE_0CC0@@ -170,7 +170,7 @@ public enum CFWMachOCodeSignature {/// Returns nil when there is no signature or it is unparsable — the caller/// decides whether that is fatal. An empty array means a signature exists/// but holds no CodeDirectory, which is malformed.- public static func codeDirectories(in data: Data) -> [CFWCodeDirectory]? {+ public static func codeDirectories(in data: Data) -> [CustomFirmwareCodeDirectory]? {let data = rebased(data)guard let signature = codeSignatureCommand(in: data) else { return nil }guard let blobs = superBlobEntries(in: data, at: signature.offset) else { return nil }@@ -203,7 +203,7 @@ public enum CFWMachOCodeSignature {return entries}- static func parseCodeDirectory(in data: Data, at offset: Int, slotType: UInt32) -> CFWCodeDirectory? {+ static func parseCodeDirectory(in data: Data, at offset: Int, slotType: UInt32) -> CustomFirmwareCodeDirectory? {guard data.fits(offset, codeDirectoryHeaderSize) else { return nil }guard data.loadBE(UInt32.self, at: offset) == codeDirectoryMagic else { return nil }@@ -224,7 +224,7 @@ public enum CFWMachOCodeSignature {guard data.fits(offset, length) else { return nil }guard data.fits(offset + hashOffset, codeSlotCount * hashSize) else { return nil }- return CFWCodeDirectory(+ return CustomFirmwareCodeDirectory(slotType: slotType,offset: offset,length: length,@@ -256,7 +256,7 @@ public enum CFWMachOCodeSignature {/// Code directories this module refuses to recompute, for the caller to warn/// about. A legacy SHA-1 alt-CD lands here: it is left byte-for-byte alone,/// so a consumer that trusts it will reject the patched binary.- public static func unsupportedCodeDirectories(in data: Data) -> [CFWCodeDirectory] {+ public static func unsupportedCodeDirectories(in data: Data) -> [CustomFirmwareCodeDirectory] {(codeDirectories(in: data) ?? []).filter { $0.hashType != hashTypeSHA256 }}@@ -273,7 +273,7 @@ public enum CFWMachOCodeSignature {_ data: inout Data,modifiedOffsets: some Sequence<Int>,dryRun: Bool = false,- ) throws -> [CFWSlotRehash] {+ ) throws -> [CustomFirmwareSlotRehash] {let offsets = Array(modifiedOffsets)if offsets.isEmpty {return []@@ -312,7 +312,7 @@ public enum CFWMachOCodeSignature {}}- var records: [CFWSlotRehash] = []+ var records: [CustomFirmwareSlotRehash] = []for (key, range) in work.sorted(by: { $0.key < $1.key }) {let directory = directories[key.cdIndex]let slotOffset = directory.slotHashOffset(key.pageIndex)@@ -329,7 +329,7 @@ public enum CFWMachOCodeSignature {if !dryRun {data.replaceSubrange(slotOffset ..< slotOffset + directory.hashSize, with: newHash)}- records.append(CFWSlotRehash(+ records.append(CustomFirmwareSlotRehash(codeDirectoryOffset: directory.offset,slotType: directory.slotType,pageIndex: key.pageIndex,@@ -350,7 +350,7 @@ public enum CFWMachOCodeSignature {fileAt url: URL,modifiedOffsets: some Sequence<Int>,dryRun: Bool = false,- ) throws -> [CFWSlotRehash] {+ ) throws -> [CustomFirmwareSlotRehash] {guard FileManager.default.fileExists(atPath: url.path) else {throw PatcherError.fileNotFound(url.path)}diff --git a/sources/FirmwarePatcher/CFW/CFWPostRestoreDeviceTree.swift b/sources/FirmwarePatcher/CustomFirmware/CustomFirmwarePostRestoreDeviceTree.swiftsimilarity index 99%rename from sources/FirmwarePatcher/CFW/CFWPostRestoreDeviceTree.swiftrename to sources/FirmwarePatcher/CustomFirmware/CustomFirmwarePostRestoreDeviceTree.swiftindex c34a832a..3a863179 100644--- a/sources/FirmwarePatcher/CFW/CFWPostRestoreDeviceTree.swift+++ b/sources/FirmwarePatcher/CustomFirmware/CustomFirmwarePostRestoreDeviceTree.swift@@ -1,4 +1,4 @@-// CFWPostRestoreDeviceTree.swift — post-restore DT identity rewrite.+// CustomFirmwarePostRestoreDeviceTree.swift — post-restore DT identity rewrite.//// Swift port of scripts/patchers/cfw_patch_post_restore_dt.py (EXP-JB-6).//@@ -33,7 +33,7 @@ import Img4tool/// Rewrites the three restore-fatal identity properties in a/// `devicetree.img4` (or bare `.im4p`), in place, preserving the container's/// compression, manifest and restore info.-public enum CFWPostRestoreDeviceTree {+public enum CustomFirmwarePostRestoreDeviceTree {// MARK: - Targetsstatic let targetModel = "iPhone17,3"@@ -361,7 +361,7 @@ public enum CFWPostRestoreDeviceTree {// MARK: - Image4 container-extension CFWPostRestoreDeviceTree {+extension CustomFirmwarePostRestoreDeviceTree {/// How the IM4P payload is stored. The raw values are pyimg4's/// `Compression` enum, so the log line reads the same either side.enum PayloadCompression: Int, Sendable {diff --git a/sources/FirmwarePatcher/CFW/Patches/CFWCacheloader.swift b/sources/FirmwarePatcher/CustomFirmware/ExecutablePatches/CustomFirmwareCacheloader.swiftsimilarity index 98%rename from sources/FirmwarePatcher/CFW/Patches/CFWCacheloader.swiftrename to sources/FirmwarePatcher/CustomFirmware/ExecutablePatches/CustomFirmwareCacheloader.swiftindex a764d241..84f920cd 100644--- a/sources/FirmwarePatcher/CFW/Patches/CFWCacheloader.swift+++ b/sources/FirmwarePatcher/CustomFirmware/ExecutablePatches/CustomFirmwareCacheloader.swift@@ -1,4 +1,4 @@-// CFWCacheloader.swift — open launchd_cache_loader's unsecure-cache gate.+// CustomFirmwareCacheloader.swift — open launchd_cache_loader's unsecure-cache gate.//// Swift port of `scripts/patchers/cfw_patch_cache_loader.py`, driven today by// `cfw.py patch-launchd-cache-loader <binary>`.@@ -57,7 +57,7 @@ import Capstoneimport Foundation/// NOPs the `launchd_unsecure_cache=` gate in `/usr/libexec/launchd_cache_loader`.-public enum CFWCacheLoaderPatcher {+public enum CustomFirmwareCacheLoaderPatcher {// MARK: - Identity/// Component name, matching the Python's `records.set_group`.@@ -156,7 +156,7 @@ public enum CFWCacheLoaderPatcher {/// `nil` unless bytes actually changed.public let record: PatchRecord?/// Slot hashes recomputed, empty unless `reattestsCodeSignature` was set.- public let reattestedSlots: [CFWSlotRehash]+ public let reattestedSlots: [CustomFirmwareSlotRehash]/// Sites whose bytes this run changed. The parity number: the Python/// writes exactly one, and so must this.@@ -252,9 +252,9 @@ public enum CFWCacheLoaderPatcher {// can repair it without rewriting an instruction. It returns nothing// when the stored hashes already match, so the idempotent case stays// byte-stable.- var slots: [CFWSlotRehash] = []+ var slots: [CustomFirmwareSlotRehash] = []if reattestsCodeSignature, !dryRun {- slots = try CFWMachOCodeSignature.reattest(&data, modifiedOffsets: [gate.fileOffset])+ slots = try CustomFirmwareMachOCodeSignature.reattest(&data, modifiedOffsets: [gate.fileOffset])for slot in slots {log?(" re-attested \(slot)")}@@ -297,9 +297,9 @@ public enum CFWCacheLoaderPatcher {)}- var slots: [CFWSlotRehash] = []+ var slots: [CustomFirmwareSlotRehash] = []if reattestsCodeSignature {- slots = try CFWMachOCodeSignature.reattest(&data, modifiedOffsets: [gate.fileOffset])+ slots = try CustomFirmwareMachOCodeSignature.reattest(&data, modifiedOffsets: [gate.fileOffset])for slot in slots {log?(" re-attested \(slot)")}diff --git a/sources/FirmwarePatcher/CFW/Patches/CFWDiskimagesiod.swift b/sources/FirmwarePatcher/CustomFirmware/ExecutablePatches/CustomFirmwareDiskimagesiod.swiftsimilarity index 98%rename from sources/FirmwarePatcher/CFW/Patches/CFWDiskimagesiod.swiftrename to sources/FirmwarePatcher/CustomFirmware/ExecutablePatches/CustomFirmwareDiskimagesiod.swiftindex bf46cfa0..44cda8bb 100644--- a/sources/FirmwarePatcher/CFW/Patches/CFWDiskimagesiod.swift+++ b/sources/FirmwarePatcher/CustomFirmware/ExecutablePatches/CustomFirmwareDiskimagesiod.swift@@ -1,4 +1,4 @@-// CFWDiskimagesiod.swift — force diskimagesiod's DDI mount-completion gate open.+// CustomFirmwareDiskimagesiod.swift — force diskimagesiod's DDI mount-completion gate open.//// Swift port of `scripts/patchers/cfw_patch_diskimagesiod.py`, driven by// `cfw.py patch-diskimagesiod <binary>` and, in the shipped installers, by@@ -58,7 +58,7 @@// caller's (unsigned) LR without ever having pushed a frame, so overwriting// `pacibsp; stp …` loses nothing that the new epilogue needs. Both words come// from the encoder — `ARM64Encoder.encodeMovzX` builds MOVZ from its ISA fields-// and `ARM64.ret` is the keystone-derived constant; `CFWDiskimagesiodTests`+// and `ARM64.ret` is the keystone-derived constant; `CustomFirmwareDiskimagesiodTests`// asserts the two agree with `ARM64.movX0_1`.//// Re-signing@@ -67,7 +67,7 @@// re-signs the patched binary with `ldid` under the extracted// `com.apple.diskimagesiod` entitlements, so a slot re-attest here would be// overwritten moments later. `reattest: true` recomputes the CodeDirectory slot-// hashes through `CFWMachOCodeSignature` instead, which is what a caller that+// hashes through `CustomFirmwareMachOCodeSignature` instead, which is what a caller that// drops the `ldid` step needs — and what makes `codesign -v` pass on the patched// file on its own.@@ -77,7 +77,7 @@ import Foundation/// Forces `-[DIDiskArb isMountCompleteWithExpectedCount:diskTracker:]` to/// return YES so MobileStorageMounter stops waiting on a mount that will never/// be reported.-public enum CFWDiskimagesiod {+public enum CustomFirmwareDiskimagesiod {// MARK: - Identity/// The component name the Python records this write under.@@ -103,7 +103,7 @@ public enum CFWDiskimagesiod {/// MOVZ is built from its ISA fields by ``ARM64Encoder/encodeMovzX(rd:imm16:shift:)``;/// the `?? ARM64.movX0_1` arm is unreachable (that encoder returns `nil`/// only for a shift above 48) and exists so this stays a plain `let` with- /// no trap in it. `CFWDiskimagesiodTests` asserts the two spellings are the+ /// no trap in it. `CustomFirmwareDiskimagesiodTests` asserts the two spellings are the/// same four bytes.public static let replacement: Data =(ARM64Encoder.encodeMovzX(rd: 0, imm16: 1) ?? ARM64.movX0_1) + ARM64.ret@@ -135,7 +135,7 @@ public enum CFWDiskimagesiod {/// True when the site already holds this patch's own output.public var isAlreadyPatched: Bool {- original == CFWDiskimagesiod.replacement+ original == CustomFirmwareDiskimagesiod.replacement}}@@ -159,7 +159,7 @@ public enum CFWDiskimagesiod {public let record: PatchRecord?/// CodeDirectory slots re-attested. Empty unless `reattest` was set,/// and empty on a second run because the stored hashes already match.- public let rehashes: [CFWSlotRehash]+ public let rehashes: [CustomFirmwareSlotRehash]/// The parity number: the Python writes exactly one site, and so must this.public var sitesWritten: Int {@@ -220,12 +220,12 @@ public enum CFWDiskimagesiod {log?(" After: \(disassemblyText(of: patched, at: site.virtualAddress))")}- var rehashes: [CFWSlotRehash] = []+ var rehashes: [CustomFirmwareSlotRehash] = []if reattest {// First and last byte of the write: an 8-byte span sits inside one// 4 KiB page here, but a page boundary between them would otherwise// leave the second page's slot stale.- rehashes = try CFWMachOCodeSignature.reattest(+ rehashes = try CustomFirmwareMachOCodeSignature.reattest(&data,modifiedOffsets: [site.fileOffset, site.fileOffset + patched.count - 1],)diff --git a/sources/FirmwarePatcher/CFW/Patches/CFWJetsam.swift b/sources/FirmwarePatcher/CustomFirmware/ExecutablePatches/CustomFirmwareJetsam.swiftsimilarity index 97%rename from sources/FirmwarePatcher/CFW/Patches/CFWJetsam.swiftrename to sources/FirmwarePatcher/CustomFirmware/ExecutablePatches/CustomFirmwareJetsam.swiftindex bf088da4..35cf569b 100644--- a/sources/FirmwarePatcher/CFW/Patches/CFWJetsam.swift+++ b/sources/FirmwarePatcher/CustomFirmware/ExecutablePatches/CustomFirmwareJetsam.swift@@ -1,4 +1,4 @@-// CFWJetsam.swift — Defuse the launchd jetsam panic guard in /sbin/launchd.+// CustomFirmwareJetsam.swift — Defuse the launchd jetsam panic guard in /sbin/launchd.//// WHY// ---@@ -28,7 +28,7 @@// diverges from `scripts/patchers/cfw_patch_jetsam.py`, which instead// scans a blind 0x300-byte window that can start inside the *previous*// function. Both pick the same instruction on iOS 27.0 / 24A435 (proven-// byte for byte in `CFWJetsamTests`); the function bound is what keeps+// byte for byte in `CustomFirmwareJetsamTests`); the function bound is what keeps// that true when the code around it moves. The blind window survives as// the fallback for a function with no PAC prologue.// 4. Gate — inside that function, take the earliest conditional branch whose@@ -65,13 +65,13 @@// over the result immediately afterwards, which rebuilds the signature whole.// Pass `reattest: true` when nothing downstream re-signs — it recomputes the// slot hash of the one page this patch dirties through-// `CFWMachOCodeSignature`, short tail slot included, and the result passes+// `CustomFirmwareMachOCodeSignature`, short tail slot included, and the result passes// `codesign -v`.import Capstoneimport Foundation-public enum CFWJetsamPatcher {+public enum CustomFirmwareJetsamPatcher {// MARK: - Anchors/// The jetsam guard's failure message, most specific first, exactly as the@@ -150,7 +150,7 @@ public enum CFWJetsamPatcher {public let record: PatchRecord?/// Slot hashes re-attestation replaced, on a run that wrote with/// `reattest: true`.- public let rehashes: [CFWSlotRehash]+ public let rehashes: [CustomFirmwareSlotRehash]public init(verdict: Verdict,@@ -160,7 +160,7 @@ public enum CFWJetsamPatcher {returnBlockOffset: Int,functionOffset: Int,record: PatchRecord? = nil,- rehashes: [CFWSlotRehash] = [],+ rehashes: [CustomFirmwareSlotRehash] = [],) {self.verdict = verdictself.anchor = anchor@@ -298,9 +298,9 @@ public enum CFWJetsamPatcher {)}- var rehashes: [CFWSlotRehash] = []+ var rehashes: [CustomFirmwareSlotRehash] = []if reattest {- rehashes = try CFWMachOCodeSignature.reattest(&data, modifiedOffsets: [site.gateOffset])+ rehashes = try CustomFirmwareMachOCodeSignature.reattest(&data, modifiedOffsets: [site.gateOffset])for rehash in rehashes {log?(" [.] re-attest \(rehash)")}diff --git a/sources/FirmwarePatcher/CFW/Patches/CFWMobileactivationd.swift b/sources/FirmwarePatcher/CustomFirmware/ExecutablePatches/CustomFirmwareMobileactivationd.swiftsimilarity index 97%rename from sources/FirmwarePatcher/CFW/Patches/CFWMobileactivationd.swiftrename to sources/FirmwarePatcher/CustomFirmware/ExecutablePatches/CustomFirmwareMobileactivationd.swiftindex ed39768e..41e98354 100644--- a/sources/FirmwarePatcher/CFW/Patches/CFWMobileactivationd.swift+++ b/sources/FirmwarePatcher/CustomFirmware/ExecutablePatches/CustomFirmwareMobileactivationd.swift@@ -1,4 +1,4 @@-// CFWMobileactivationd.swift — force `-[DeviceType should_hactivate]` to YES.+// CustomFirmwareMobileactivationd.swift — force `-[DeviceType should_hactivate]` to YES.//// Swift port of `scripts/patchers/cfw_patch_mobileactivationd.py`, driven by// `cfw.py patch-mobileactivationd <binary>` from `cfw_install{,_dev}.sh` and@@ -46,7 +46,7 @@// --------------// `codeSigningMonitor == 2` on this stack, so TXM holds the original per-page// slot hashes and any byte changed inside an executable mapping is a SIGKILL on-// first page-in. The touched page is re-hashed through `CFWMachOCodeSignature`.+// first page-in. The touched page is re-hashed through `CustomFirmwareMachOCodeSignature`.// The Python leaves that to the `ldid_sign` that follows it in the shell; doing// it here means the binary is runnable the moment it is written, and the later// `ldid_sign` stays a no-op-in-effect re-sign. Pass `resign: false` to get the@@ -57,7 +57,7 @@ import Foundation/// Forces `-[DeviceType should_hactivate]` to return YES, so the guest/// self-activates instead of waiting on Apple's activation service.-public enum CFWMobileactivationd {+public enum CustomFirmwareMobileactivationd {// MARK: - Identity/// The ObjC method whose result is forced.@@ -118,7 +118,7 @@ public enum CFWMobileactivationd {public let record: PatchRecord?/// Code-directory slots recomputed for the page the write landed in./// Empty on a dry run, and on a re-run whose slots already match.- public let slotRehashes: [CFWSlotRehash]+ public let slotRehashes: [CustomFirmwareSlotRehash]/// Sites whose bytes this run changed. The parity number: the Python/// writes exactly one, and so must this.@@ -201,7 +201,7 @@ public enum CFWMobileactivationd {+ "nothing to write")let rehashes = dryRun || !resign? []- : try CFWMachOCodeSignature.reattest(&data, modifiedOffsets: touchedOffsets(anchor, patched))+ : try CustomFirmwareMachOCodeSignature.reattest(&data, modifiedOffsets: touchedOffsets(anchor, patched))if !rehashes.isEmpty {log?(" [+] re-attested \(rehashes.count) stale slot(s): "+ rehashes.map(\.description).joined(separator: ", "))@@ -237,15 +237,15 @@ public enum CFWMobileactivationd {)}- var rehashes: [CFWSlotRehash] = []+ var rehashes: [CustomFirmwareSlotRehash] = []if resign {- rehashes = try CFWMachOCodeSignature.reattest(+ rehashes = try CustomFirmwareMachOCodeSignature.reattest(&data,modifiedOffsets: touchedOffsets(anchor, patched),)log?(" [.] re-attested \(rehashes.count) slot(s): "+ rehashes.map(\.description).joined(separator: ", "))- let unsupported = CFWMachOCodeSignature.unsupportedCodeDirectories(in: data)+ let unsupported = CustomFirmwareMachOCodeSignature.unsupportedCodeDirectories(in: data)if !unsupported.isEmpty {log?(" [-] \(unsupported.count) non-SHA256 CodeDirectory(ies) left alone")}diff --git a/sources/FirmwarePatcher/CFW/Patches/CFWSeputil.swift b/sources/FirmwarePatcher/CustomFirmware/ExecutablePatches/CustomFirmwareSeputil.swiftsimilarity index 96%rename from sources/FirmwarePatcher/CFW/Patches/CFWSeputil.swiftrename to sources/FirmwarePatcher/CustomFirmware/ExecutablePatches/CustomFirmwareSeputil.swiftindex 543d54c6..8cb9557d 100644--- a/sources/FirmwarePatcher/CFW/Patches/CFWSeputil.swift+++ b/sources/FirmwarePatcher/CustomFirmware/ExecutablePatches/CustomFirmwareSeputil.swift@@ -1,4 +1,4 @@-// CFWSeputil.swift — pin seputil's gigalocker file name to "AA".+// CustomFirmwareSeputil.swift — pin seputil's gigalocker file name to "AA".//// `seputil` keeps the SEP's "gigalocker" blob in a file named after the// device's own UUID, built with a two-field format string:@@ -33,7 +33,7 @@// 4. The field to rewrite is the one after the literal's own last `/`.//// Port of `scripts/patchers/cfw_patch_seputil.py`, which stays the independent-// reference: `CFWSeputilTests` runs the Python on one clone of a real seputil+// reference: `CustomFirmwareSeputilTests` runs the Python on one clone of a real seputil// and this on another and compares the files byte for byte.//// Two deliberate differences from the reference, both of them narrowing:@@ -46,14 +46,14 @@// it. All three are tightened here.// * The Python leaves the code signature stale, because `cfw_install*.sh`// runs `ldid_sign` over the binary immediately afterwards. This-// re-attests the page it dirtied through `CFWMachOCodeSignature`, so the+// re-attests the page it dirtied through `CustomFirmwareMachOCodeSignature`, so the// binary that leaves this function verifies on its own. Pass// `reattest: false` to reproduce the reference's bytes exactly.import Capstoneimport Foundation-public enum CFWSeputil {+public enum CustomFirmwareSeputil {// MARK: - Anchors/// Where the format string lives. A literal outside this section is not one@@ -106,7 +106,7 @@ public enum CFWSeputil {/// The offsets the write dirties. Two, not one: a literal can straddle/// a page boundary, and then two slots need re-attesting.public var modifiedOffsets: [Int] {- Array(fieldOffset ..< fieldOffset + CFWSeputil.uuidReplacement.utf8.count)+ Array(fieldOffset ..< fieldOffset + CustomFirmwareSeputil.uuidReplacement.utf8.count)}}@@ -140,14 +140,14 @@ public enum CFWSeputil {/// The record of the single write, on a run that wrote or would write.public let record: PatchRecord?/// Slot hashes re-attestation replaced. Empty when `reattest` was off.- public let rehashes: [CFWSlotRehash]+ public let rehashes: [CustomFirmwareSlotRehash]public init(verdict: Verdict,site: Site,references: [UInt64],record: PatchRecord? = nil,- rehashes: [CFWSlotRehash] = [],+ rehashes: [CustomFirmwareSlotRehash] = [],) {self.verdict = verdictself.site = site@@ -253,15 +253,15 @@ public enum CFWSeputil {+ "(\"\(site.literal)\" -> \"\(patchedLiteral(of: site))\")",)- var rehashes: [CFWSlotRehash] = []+ var rehashes: [CustomFirmwareSlotRehash] = []if reattest {- for directory in CFWMachOCodeSignature.unsupportedCodeDirectories(in: data) {+ for directory in CustomFirmwareMachOCodeSignature.unsupportedCodeDirectories(in: data) {log?(" [-] CodeDirectory @ 0x\(hex(directory.offset)) is hashType "+ "\(directory.hashType), not SHA-256 — left untouched",)}- rehashes = try CFWMachOCodeSignature.reattest(&data, modifiedOffsets: site.modifiedOffsets)+ rehashes = try CustomFirmwareMachOCodeSignature.reattest(&data, modifiedOffsets: site.modifiedOffsets)for rehash in rehashes {log?(" [+] \(rehash)")}diff --git a/sources/FirmwarePatcher/CFW/Patches/CFWWatchdogd.swift b/sources/FirmwarePatcher/CustomFirmware/ExecutablePatches/CustomFirmwareWatchdogd.swiftsimilarity index 98%rename from sources/FirmwarePatcher/CFW/Patches/CFWWatchdogd.swiftrename to sources/FirmwarePatcher/CustomFirmware/ExecutablePatches/CustomFirmwareWatchdogd.swiftindex c2175bfe..9a3b5f16 100644--- a/sources/FirmwarePatcher/CFW/Patches/CFWWatchdogd.swift+++ b/sources/FirmwarePatcher/CustomFirmware/ExecutablePatches/CustomFirmwareWatchdogd.swift@@ -1,11 +1,11 @@-// CFWWatchdogd.swift — force watchdogd's cached "am I a VM?" byte to 1.+// CustomFirmwareWatchdogd.swift — force watchdogd's cached "am I a VM?" byte to 1.//// Port of `scripts/patchers/cfw_patch_watchdogd.py` (453 lines). EXP only.//// Why the patch exists// --------------------// The EXP variant renames the kernel's `kern.hv_vmm_present` sysctl OID-// (`KernelEXPPatchHvVmmRename`), so every userland caller that still asks for+// (`KernelExperimentalPatchHvVmmRename`), so every userland caller that still asks for// that name gets ENOENT. `/usr/libexec/watchdogd` caches the answer at startup://// adrp x0, <page>@@ -81,7 +81,7 @@// Editing bytes inside `__TEXT,__text` invalidates the SHA-256 slot hash of// each containing 4 KiB page. On `codeSigningMonitor == 2` hardware TXM holds// those hashes and kills the process on the first demand page-in, so every-// written offset is handed to `CFWMachOCodeSignature` to re-hash its page.+// written offset is handed to `CustomFirmwareMachOCodeSignature` to re-hash its page.//// The binary is NOT re-signed with an identity. Re-signing would reset the// code-signing identifier to the local filename, which trips launchd's@@ -93,7 +93,7 @@import Capstoneimport Foundation-public enum CFWWatchdogd {+public enum CustomFirmwareWatchdogd {// MARK: - Anchors/// Component name carried by every ``PatchRecord`` this patcher emits.@@ -198,7 +198,7 @@ public enum CFWWatchdogd {/// site. Empty for `.alreadyPatched`.public let records: [PatchRecord]/// Code-directory slots re-hashed as a result.- public let rehashedSlots: [CFWSlotRehash]+ public let rehashedSlots: [CustomFirmwareSlotRehash]/// Sites whose bytes this run changed. The parity number against the/// Python, whose `patch_watchdogd()` returns exactly this.@@ -313,12 +313,12 @@ public enum CFWWatchdogd {return Report(outcome: .wouldPatch, sites: sites, records: records, rehashedSlots: [])}- for directory in CFWMachOCodeSignature.unsupportedCodeDirectories(in: data) {+ for directory in CustomFirmwareMachOCodeSignature.unsupportedCodeDirectories(in: data) {log?(" [!] CodeDirectory @0x\(hex(UInt64(directory.offset))) uses hashType "+ "\(directory.hashType); its slots are left stale")}- let rehashed = try CFWMachOCodeSignature.reattest(&data, modifiedOffsets: modifiedOffsets)+ let rehashed = try CustomFirmwareMachOCodeSignature.reattest(&data, modifiedOffsets: modifiedOffsets)for slot in rehashed {log?(" [+] re-attest: \(slot)")}@@ -348,7 +348,7 @@ public enum CFWWatchdogd {log?(" [.] cstring at va:0x\(hex(literal.address)) "+ "(foff:0x\(hex(UInt64(literal.fileOffset))), sect=\(literal.section))")- guard let symbols = CFWWatchdogdSymbolTargets(data: data) else {+ guard let symbols = CustomFirmwareWatchdogdSymbolTargets(data: data) else {throw PatcherError.invalidFormat("no LC_SYMTAB/LC_DYSYMTAB — \(sysctlFunction) cannot be resolved",)@@ -429,7 +429,7 @@ public enum CFWWatchdogd {literalVMA: UInt64,text: MachOSectionInfo,segments: [MachOSegmentInfo],- symbols: CFWWatchdogdSymbolTargets,+ symbols: CustomFirmwareWatchdogdSymbolTargets,) -> Site? {// Layer 3: the call, and the import it resolves to.guard let callIndex = firstIndex(@@ -752,7 +752,7 @@ public enum CFWWatchdogd {/// which that shared parser exposes. It carries this patcher's name because/// this patcher is its only caller — the first time a second one needs the same/// lookup, move it to `Binary/` under a neutral name rather than growing a copy.-struct CFWWatchdogdSymbolTargets {+struct CustomFirmwareWatchdogdSymbolTargets {/// A section of branch-island stubs, one per imported symbol.struct StubSection {let address: UInt64diff --git a/sources/FirmwarePatcher/DeviceTree/DeviceTreePatchSpecs.swift b/sources/FirmwarePatcher/DeviceTree/DeviceTreePatchDefinitions.swiftsimilarity index 91%rename from sources/FirmwarePatcher/DeviceTree/DeviceTreePatchSpecs.swiftrename to sources/FirmwarePatcher/DeviceTree/DeviceTreePatchDefinitions.swiftindex 05f3ca8e..78564d66 100644--- a/sources/FirmwarePatcher/DeviceTree/DeviceTreePatchSpecs.swift+++ b/sources/FirmwarePatcher/DeviceTree/DeviceTreePatchDefinitions.swift@@ -1,4 +1,4 @@-// DeviceTreePatchSpecs.swift — DeviceTree patch specification types.+// DeviceTreePatchDefinitions.swift — DeviceTree patch definition types.//// The shapes the DeviceTree patch catalogue is written in: a property// rewrite, a brand-new child node, and the value a property holds.@@ -30,11 +30,11 @@ extension DeviceTreePatcher {let nodeName: String/// Properties to place inside the new node. The `name` property is/// added automatically from `nodeName`; do not include it here.- let properties: [PropertySpec]+ let properties: [PropertyDefinition]let patchID: Stringlet description: String- struct PropertySpec {+ struct PropertyDefinition {let name: Stringlet length: Intlet flags: UInt16diff --git a/sources/FirmwarePatcher/DSC/DSCChunkSet.swift b/sources/FirmwarePatcher/DyldSharedCache/DyldSharedCacheChunkSet.swiftsimilarity index 91%rename from sources/FirmwarePatcher/DSC/DSCChunkSet.swiftrename to sources/FirmwarePatcher/DyldSharedCache/DyldSharedCacheChunkSet.swiftindex 1a2716b4..2280e557 100644--- a/sources/FirmwarePatcher/DSC/DSCChunkSet.swift+++ b/sources/FirmwarePatcher/DyldSharedCache/DyldSharedCacheChunkSet.swift@@ -1,4 +1,4 @@-// DSCChunkSet.swift — Flat virtual-address access over a chunked dyld shared cache.+// DyldSharedCacheChunkSet.swift — Flat virtual-address access over a chunked dyld shared cache.//// The iOS 26/27 SystemOS cryptex ships the shared cache as many files://@@ -19,7 +19,7 @@// symbol resolver's job.//// Port of `scripts/patchers/cfw_dsc_chunks.py`. The Python remains the-// independent reference for this layer — see `DSCFoundationTests`.+// independent reference for this layer — see `DyldSharedCacheFoundationTests`.//// Two places diverge from it on purpose, both pinned by tests://@@ -42,7 +42,7 @@ import Foundation/// started at leaves the second page's code slot stale — a/// `KERN_PROTECTION_FAILURE` on the first demand-page-in, with nothing pointing/// back at the patch. Carrying the length is what makes that unexpressible.-public struct DSCWriteSpan: Sendable, Hashable {+public struct DyldSharedCacheWriteSpan: Sendable, Hashable {/// First address the span covers.public let vma: UInt64/// Byte length. Always at least 1.@@ -56,8 +56,8 @@ public struct DSCWriteSpan: Sendable, Hashable {/// The single byte at `vma` — the only honest way to spell "just this/// address", and it has to be spelled out.- public static func byte(at vma: UInt64) -> DSCWriteSpan {- DSCWriteSpan(vma: vma, length: 1)+ public static func byte(at vma: UInt64) -> DyldSharedCacheWriteSpan {+ DyldSharedCacheWriteSpan(vma: vma, length: 1)}/// Last address the span covers.@@ -72,7 +72,7 @@ public struct DSCWriteSpan: Sendable, Hashable {}/// Random-access byte view over a chunked dyld shared cache.-public final class DSCChunkSet {+public final class DyldSharedCacheChunkSet {/// One `dyld_cache_mapping_info` entry, tagged with the chunk it came from.public struct Mapping: Sendable {/// First address the mapping covers.@@ -92,7 +92,7 @@ public final class DSCChunkSet {}public var isExecutable: Bool {- initProt & DSCChunkSet.vmProtExecute != 0+ initProt & DyldSharedCacheChunkSet.vmProtExecute != 0}}@@ -109,8 +109,8 @@ public final class DSCChunkSet {/// Guards the two pieces of lazily built state below.private let stateLock = NSLock()- private var writeLog: [DSCWriteSpan] = []- private var loadedLocalSymbols: DSCLocalSymbolTable?+ private var writeLog: [DyldSharedCacheWriteSpan] = []+ private var loadedLocalSymbols: DyldSharedCacheLocalSymbolTable?// MARK: - Construction@@ -125,7 +125,7 @@ public final class DSCChunkSet {self.architecture = architecturechunkURLs = try Self.enumerateChunks(in: directory, architecture: architecture)guard !chunkURLs.isEmpty else {- throw DSCError.noChunksFound(directory: directory.path)+ throw DyldSharedCacheError.noChunksFound(directory: directory.path)}var collected: [Mapping] = []@@ -135,7 +135,7 @@ public final class DSCChunkSet {}}guard !collected.isEmpty else {- throw DSCError.noMappingsParsed(directory: directory.path)+ throw DyldSharedCacheError.noMappingsParsed(directory: directory.path)}collected.sort { $0.address < $1.address }mappings = collected@@ -225,12 +225,12 @@ public final class DSCChunkSet {/// Throws when the first byte is unmapped, and when the span runs off the/// end of its contiguous run — the case where the following bytes in the/// file belong to some other virtual address, or to none at all.- public func fileRange(of span: DSCWriteSpan) throws -> (chunkURL: URL, range: Range<Int>) {+ public func fileRange(of span: DyldSharedCacheWriteSpan) throws -> (chunkURL: URL, range: Range<Int>) {guard let run = contiguousRun(from: span.vma) else {- throw DSCError.addressNotMapped(span.vma)+ throw DyldSharedCacheError.addressNotMapped(span.vma)}guard UInt64(span.length) <= run.available else {- throw DSCError.addressSpanCrossesChunk(vma: span.vma, length: span.length)+ throw DyldSharedCacheError.addressSpanCrossesChunk(vma: span.vma, length: span.length)}let start = Int(run.fileOffset)return (run.chunkURL, start ..< (start + span.length))@@ -249,10 +249,10 @@ public final class DSCChunkSet {/// API, so here it throws.public func bytesAtVMA(_ vma: UInt64, length: Int) throws -> Data {guard length > 0 else { return Data() }- let (chunkURL, range) = try fileRange(of: DSCWriteSpan(vma: vma, length: length))+ let (chunkURL, range) = try fileRange(of: DyldSharedCacheWriteSpan(vma: vma, length: length))let data = try Self.read(url: chunkURL, offset: UInt64(range.lowerBound), length: length)guard data.count == length else {- throw DSCError.shortRead(vma: vma, wanted: length, got: data.count)+ throw DyldSharedCacheError.shortRead(vma: vma, wanted: length, got: data.count)}return data}@@ -266,7 +266,7 @@ public final class DSCChunkSet {public func readAtVMA(_ vma: UInt64, length: Int, allowShort: Bool = false) throws -> Data {guard length > 0 else { return Data() }guard let run = contiguousRun(from: vma) else {- throw DSCError.addressNotMapped(vma)+ throw DyldSharedCacheError.addressNotMapped(vma)}let wanted: Intif run.available >= UInt64(length) {@@ -274,7 +274,7 @@ public final class DSCChunkSet {} else if allowShort {wanted = Int(run.available)} else {- throw DSCError.addressSpanCrossesChunk(vma: vma, length: length)+ throw DyldSharedCacheError.addressSpanCrossesChunk(vma: vma, length: length)}return try Self.read(url: run.chunkURL, offset: run.fileOffset, length: wanted)}@@ -291,15 +291,15 @@ public final class DSCChunkSet {/// it.////// - Returns: the span written, which is what- /// `DSCCodeSignature.reattest(in:modifiedSpans:)` consumes. The same span+ /// `DyldSharedCacheCodeSignature.reattest(in:modifiedSpans:)` consumes. The same span/// is appended to `recordedWrites`, so a patcher that just writes and/// then calls `reattestRecordedWrites(in:)` cannot under-attest. Empty/// `data` writes nothing and records nothing; the span it hands back is/// the single byte at `vma`, and re-attesting it is a no-op.@discardableResult- public func write(at vma: UInt64, _ data: Data) throws -> DSCWriteSpan {- guard !data.isEmpty else { return DSCWriteSpan.byte(at: vma) }- let span = DSCWriteSpan(vma: vma, length: data.count)+ public func write(at vma: UInt64, _ data: Data) throws -> DyldSharedCacheWriteSpan {+ guard !data.isEmpty else { return DyldSharedCacheWriteSpan.byte(at: vma) }+ let span = DyldSharedCacheWriteSpan(vma: vma, length: data.count)let (chunkURL, range) = try fileRange(of: span)let handle = try FileHandle(forUpdating: chunkURL)defer { try? handle.close() }@@ -311,7 +311,7 @@ public final class DSCChunkSet {/// Every span `write(at:_:)` has put on disk through this chunk set, oldest/// first.- public var recordedWrites: [DSCWriteSpan] {+ public var recordedWrites: [DyldSharedCacheWriteSpan] {stateLock.withLock { writeLog }}@@ -334,15 +334,15 @@ public final class DSCChunkSet {/// point of it throwing: "the symbol table is not there" and "that symbol/// is not in it" are different answers, and the previous `try?` spelled/// both of them `nil`.- public func localSymbolTable() throws -> DSCLocalSymbolTable {+ public func localSymbolTable() throws -> DyldSharedCacheLocalSymbolTable {try stateLock.withLock {if let loadedLocalSymbols {return loadedLocalSymbols}guard FileManager.default.fileExists(atPath: localSymbolsURL.path) else {- throw DSCError.localSymbolsMissing(path: localSymbolsURL.path)+ throw DyldSharedCacheError.localSymbolsMissing(path: localSymbolsURL.path)}- let table = try DSCLocalSymbolTable(url: localSymbolsURL)+ let table = try DyldSharedCacheLocalSymbolTable(url: localSymbolsURL)loadedLocalSymbols = tablereturn table}@@ -357,7 +357,7 @@ public final class DSCChunkSet {////// Returns the first match, matching the Python reference; local symbol/// names are not guaranteed unique across images, so callers that care- /// which image a symbol came from should use `DSCSymbolResolver` instead.+ /// which image a symbol came from should use `DyldSharedCacheSymbolResolver` instead.////// `nil` means "no symbol by that name". A missing or unreadable table/// throws instead, so a force-kern discovery run cannot report "zero pairs"diff --git a/sources/FirmwarePatcher/DSC/DSCCodeSignature.swift b/sources/FirmwarePatcher/DyldSharedCache/DyldSharedCacheCodeSignature.swiftsimilarity index 87%rename from sources/FirmwarePatcher/DSC/DSCCodeSignature.swiftrename to sources/FirmwarePatcher/DyldSharedCache/DyldSharedCacheCodeSignature.swiftindex a2f7d792..8938aa66 100644--- a/sources/FirmwarePatcher/DSC/DSCCodeSignature.swift+++ b/sources/FirmwarePatcher/DyldSharedCache/DyldSharedCacheCodeSignature.swift@@ -1,4 +1,4 @@-// DSCCodeSignature.swift — Page-hash re-signing for dyld shared cache chunks.+// DyldSharedCacheCodeSignature.swift — Page-hash re-signing for dyld shared cache chunks.//// Why this exists// ---------------@@ -28,7 +28,7 @@// ----------------------// Rewriting slot hashes changes the code directory's contents and therefore its// cdHash. That is only survivable because the JB kernel patch-// `patch_amfi_cdhash_in_trustcache` — `KernelJBPatchAmfiTrustcache` in this+// `patch_amfi_cdhash_in_trustcache` — `KernelJailbreakPatchAmfiTrustcache` in this// repo — short-circuits AMFI's per-image trust-cache lookup to return 1. This// file must not be used on a firmware that does not carry that patch.//@@ -42,14 +42,14 @@// 0x22AC0FFFC, which dirties pages 2563 and 2564 and gets 2563 re-signed. The// six sites `cfw_patch_camera_dsc.py` writes miss that by 1072 bytes, so the// reference is safe by margin rather than by construction. Here the page set is-// derived from the spans that were actually written, and `DSCChunkSet` records+// derived from the spans that were actually written, and `DyldSharedCacheChunkSet` records// those itself.import CryptoKitimport Foundation/// The `CS_CodeDirectory` of one chunk, reduced to what re-signing needs.-public struct DSCChunkCodeDirectory: Sendable {+public struct DyldSharedCacheChunkCodeDirectory: Sendable {/// Offset of the CD blob within the chunk file.public let blobOffset: Int/// Byte length of the CD blob.@@ -72,7 +72,7 @@ public struct DSCChunkCodeDirectory: Sendable {}/// One slot rewritten, for logging and for cross-checking against the Python.-public struct DSCSlotReattestation: Sendable {+public struct DyldSharedCacheSlotReattestation: Sendable {public let chunkURL: URLpublic let pageIndex: Int/// Offset of the page's first byte in the chunk file.@@ -84,7 +84,7 @@ public struct DSCSlotReattestation: Sendable {}/// One page of one chunk.-public struct DSCPageReference: Sendable, Hashable {+public struct DyldSharedCachePageReference: Sendable, Hashable {public let chunkURL: URLpublic let pageIndex: Int}@@ -96,7 +96,7 @@ public struct DSCPageReference: Sendable, Hashable {/// back looking exactly like "there was nothing to do". The Python reference/// prints each one, and so does this, but the caller also gets them as values/// rather than as text it would have to have been listening for.-public struct DSCReattestationSkip: Sendable {+public struct DyldSharedCacheReattestationSkip: Sendable {public enum Reason: Sendable, CustomStringConvertible {case addressNotMapped(vma: UInt64)case spanNotAddressable(vma: UInt64, length: Int)@@ -137,13 +137,13 @@ public struct DSCReattestationSkip: Sendable {/// pages were eligible, every page already matched, and some pages were/// skipped. A caller that wants "the patch is fully covered" should check/// `isFullyAttested`.-public struct DSCReattestation: Sendable {+public struct DyldSharedCacheReattestation: Sendable {/// Slots whose stored hash was changed (or, on a dry run, would have been).- public let updated: [DSCSlotReattestation]+ public let updated: [DyldSharedCacheSlotReattestation]/// Pages whose stored slot already matched what the page hashes to.- public let alreadyAttested: [DSCPageReference]+ public let alreadyAttested: [DyldSharedCachePageReference]/// Pages that could not be covered at all.- public let skipped: [DSCReattestationSkip]+ public let skipped: [DyldSharedCacheReattestationSkip]/// Pages the run actually reached — rewritten plus already-correct.public var pagesAttested: Int {@@ -162,7 +162,7 @@ public struct DSCReattestation: Sendable {}}-public enum DSCCodeSignature {+public enum DyldSharedCacheCodeSignature {static let superBlobMagic: UInt32 = 0xFADE_0CC0static let codeDirectoryMagic: UInt32 = 0xFADE_0C02static let codeDirectorySlot: UInt32 = 0@@ -175,8 +175,8 @@ public enum DSCCodeSignature {/// Returns `nil` — rather than throwing — when the chunk simply has no/// signature to update. Several chunks in a cache are like that, and a/// patch that lands in one of them is not an error.- public static func readCodeDirectory(ofChunk url: URL) throws -> DSCChunkCodeDirectory? {- let head = try DSCChunkSet.read(url: url, offset: 0, length: 0x100)+ public static func readCodeDirectory(ofChunk url: URL) throws -> DyldSharedCacheChunkCodeDirectory? {+ let head = try DyldSharedCacheChunkSet.read(url: url, offset: 0, length: 0x100)guard head.count >= 0x38, head.prefix(5) == Data("dyld_".utf8) else { return nil }let signatureOffset = head.loadLE(UInt64.self, at: 0x28)@@ -184,14 +184,14 @@ public enum DSCCodeSignature {guard signatureOffset != 0, signatureSize != 0 else { return nil }// CS_SuperBlob, big-endian.- let superHead = try DSCChunkSet.read(url: url, offset: signatureOffset, length: 12)+ let superHead = try DyldSharedCacheChunkSet.read(url: url, offset: signatureOffset, length: 12)guard superHead.count == 12 else { return nil }guard superHead.loadBE(UInt32.self, at: 0) == superBlobMagic else { return nil }let superLength = superHead.loadBE(UInt32.self, at: 4)let blobCount = superHead.loadBE(UInt32.self, at: 8)guard UInt64(superLength) <= signatureSize, blobCount <= 256 else { return nil }- let indexData = try DSCChunkSet.read(+ let indexData = try DyldSharedCacheChunkSet.read(url: url,offset: signatureOffset + 12,length: Int(blobCount) * 8,@@ -210,7 +210,7 @@ public enum DSCCodeSignature {let blobOffset = signatureOffset + UInt64(directoryOffsetInSuperBlob)// CS_CodeDirectory, big-endian.- let directoryHead = try DSCChunkSet.read(url: url, offset: blobOffset, length: 44)+ let directoryHead = try DyldSharedCacheChunkSet.read(url: url, offset: blobOffset, length: 44)guard directoryHead.count == 44 else { return nil }guard directoryHead.loadBE(UInt32.self, at: 0) == codeDirectoryMagic else { return nil }@@ -229,7 +229,7 @@ public enum DSCCodeSignature {let pageSize = 1 << Int(pageSizeLog2)guard pageSize > 0, pageSize <= (1 << 20) else { return nil }- return DSCChunkCodeDirectory(+ return DyldSharedCacheChunkCodeDirectory(blobOffset: Int(blobOffset),blobLength: blobLength,hashOffset: hashOffset,@@ -249,7 +249,7 @@ public enum DSCCodeSignature {/// port lost that: an unmapped address, an unsigned chunk and an empty/// input all came back as an empty array with nothing written anywhere./// Callers that really want silence pass `log: nil` and read the returned- /// `DSCReattestation` instead.+ /// `DyldSharedCacheReattestation` instead.public static let stderrLog: @Sendable (String) -> Void = { line inFileHandle.standardError.write(Data((line + "\n").utf8))}@@ -269,17 +269,17 @@ public enum DSCCodeSignature {/// run over an already-patched cache a no-op rather than a rewrite.@discardableResultpublic static func reattest(- in chunks: DSCChunkSet,- modifiedSpans: some Sequence<DSCWriteSpan>,+ in chunks: DyldSharedCacheChunkSet,+ modifiedSpans: some Sequence<DyldSharedCacheWriteSpan>,dryRun: Bool = false,log: ((String) -> Void)? = stderrLog,- ) throws -> DSCReattestation {+ ) throws -> DyldSharedCacheReattestation {var pagesByChunk: [URL: Set<Int>] = [:]- var directories: [URL: DSCChunkCodeDirectory?] = [:]- var skipped: [DSCReattestationSkip] = []+ var directories: [URL: DyldSharedCacheChunkCodeDirectory?] = [:]+ var skipped: [DyldSharedCacheReattestationSkip] = []- func skip(_ reason: DSCReattestationSkip.Reason) {- skipped.append(DSCReattestationSkip(reason: reason))+ func skip(_ reason: DyldSharedCacheReattestationSkip.Reason) {+ skipped.append(DyldSharedCacheReattestationSkip(reason: reason))log?(" [-] re-attest: \(reason) — skipping")}@@ -288,15 +288,15 @@ public enum DSCCodeSignature {let byteRange: Range<Int>do {(chunkURL, byteRange) = try chunks.fileRange(of: span)- } catch DSCError.addressNotMapped {+ } catch DyldSharedCacheError.addressNotMapped {skip(.addressNotMapped(vma: span.vma))continue- } catch DSCError.addressSpanCrossesChunk {+ } catch DyldSharedCacheError.addressSpanCrossesChunk {skip(.spanNotAddressable(vma: span.vma, length: span.length))continue}- let directory: DSCChunkCodeDirectory?+ let directory: DyldSharedCacheChunkCodeDirectory?if let cached = directories[chunkURL] {directory = cached} else {@@ -337,11 +337,11 @@ public enum DSCCodeSignature {" [.] re-attest: no eligible pages "+ "(\(skipped.count) skipped)",)- return DSCReattestation(updated: [], alreadyAttested: [], skipped: skipped)+ return DyldSharedCacheReattestation(updated: [], alreadyAttested: [], skipped: skipped)}- var records: [DSCSlotReattestation] = []- var alreadyAttested: [DSCPageReference] = []+ var records: [DyldSharedCacheSlotReattestation] = []+ var alreadyAttested: [DyldSharedCachePageReference] = []for chunkURL in pagesByChunk.keys.sorted(by: { $0.path < $1.path }) {guard let directory = directories[chunkURL] ?? nil else { continue }let handle = dryRun@@ -371,7 +371,7 @@ public enum DSCCodeSignature {guard oldHash != newHash else {alreadyAttested.append(- DSCPageReference(chunkURL: chunkURL, pageIndex: pageIndex),+ DyldSharedCachePageReference(chunkURL: chunkURL, pageIndex: pageIndex),)log?(" [.] re-attest: page \(pageIndex) of "@@ -390,7 +390,7 @@ public enum DSCCodeSignature {+ "(\(Data(oldHash.prefix(4)).hex).. -> \(Data(newHash.prefix(4)).hex)..)",)records.append(- DSCSlotReattestation(+ DyldSharedCacheSlotReattestation(chunkURL: chunkURL,pageIndex: pageIndex,chunkOffset: pageOffset,@@ -407,7 +407,7 @@ public enum DSCCodeSignature {+ "slot hash(es) across \(pagesByChunk.count) chunk(s), "+ "\(alreadyAttested.count) already correct, \(skipped.count) skipped",)- return DSCReattestation(+ return DyldSharedCacheReattestation(updated: records,alreadyAttested: alreadyAttested,skipped: skipped,@@ -416,15 +416,15 @@ public enum DSCCodeSignature {/// Re-attest every page that `chunks`'s own writes dirtied.///- /// The path a patcher should take: write through `DSCChunkSet.write(at:_:)`+ /// The path a patcher should take: write through `DyldSharedCacheChunkSet.write(at:_:)`/// as many times as it likes, then call this. Nothing has to be told which/// addresses were touched, so nothing can get it wrong.@discardableResultpublic static func reattestRecordedWrites(- in chunks: DSCChunkSet,+ in chunks: DyldSharedCacheChunkSet,dryRun: Bool = false,log: ((String) -> Void)? = stderrLog,- ) throws -> DSCReattestation {+ ) throws -> DyldSharedCacheReattestation {try reattest(in: chunks,modifiedSpans: chunks.recordedWrites,@@ -442,14 +442,14 @@ public enum DSCCodeSignature {public static func pageHashes(chunkURL: URL,pageIndex: Int,- directory: DSCChunkCodeDirectory,+ directory: DyldSharedCacheChunkCodeDirectory,) throws -> (computed: Data, stored: Data) {- let page = try DSCChunkSet.read(+ let page = try DyldSharedCacheChunkSet.read(url: chunkURL,offset: UInt64(pageIndex * directory.pageSize),length: directory.pageSize,)- let stored = try DSCChunkSet.read(+ let stored = try DyldSharedCacheChunkSet.read(url: chunkURL,offset: UInt64(directory.slotOffset(forPage: pageIndex)),length: directory.hashSize,@@ -460,7 +460,7 @@ public enum DSCCodeSignature {// MARK: - Big-endian load-// File-private: `CFWMachOCodeSignature` declares the same helper for the+// File-private: `CustomFirmwareMachOCodeSignature` declares the same helper for the// independent Mach-O path. The two signature paths are deliberately separate// implementations, and keeping their helpers file-scoped is what stops them// drifting into a shared one.diff --git a/sources/FirmwarePatcher/DSC/DSCError.swift b/sources/FirmwarePatcher/DyldSharedCache/DyldSharedCacheError.swiftsimilarity index 95%rename from sources/FirmwarePatcher/DSC/DSCError.swiftrename to sources/FirmwarePatcher/DyldSharedCache/DyldSharedCacheError.swiftindex 79dd3bec..e0b447b8 100644--- a/sources/FirmwarePatcher/DSC/DSCError.swift+++ b/sources/FirmwarePatcher/DyldSharedCache/DyldSharedCacheError.swift@@ -1,4 +1,4 @@-// DSCError.swift — Errors raised by the dyld shared cache foundation layer.+// DyldSharedCacheError.swift — Errors raised by the dyld shared cache foundation layer.import Foundation@@ -8,7 +8,7 @@ import Foundation/// statement about the cache on disk, not about a patch site: a caller that/// sees one of these has been handed a cache it cannot address, and no amount/// of retrying a different anchor will help.-public enum DSCError: Error, CustomStringConvertible, Sendable {+public enum DyldSharedCacheError: Error, CustomStringConvertible, Sendable {/// No `dyld_shared_cache_<arch>` chunk files under the given directory.case noChunksFound(directory: String)/// Chunks were present but not one of them had a parseable header.diff --git a/sources/FirmwarePatcher/DSC/DSCLocalSymbolTable.swift b/sources/FirmwarePatcher/DyldSharedCache/DyldSharedCacheLocalSymbolTable.swiftsimilarity index 95%rename from sources/FirmwarePatcher/DSC/DSCLocalSymbolTable.swiftrename to sources/FirmwarePatcher/DyldSharedCache/DyldSharedCacheLocalSymbolTable.swiftindex d4ac60bc..af1a4fbb 100644--- a/sources/FirmwarePatcher/DSC/DSCLocalSymbolTable.swift+++ b/sources/FirmwarePatcher/DyldSharedCache/DyldSharedCacheLocalSymbolTable.swift@@ -1,4 +1,4 @@-// DSCLocalSymbolTable.swift — The cache's stripped local symbol table.+// DyldSharedCacheLocalSymbolTable.swift — The cache's stripped local symbol table.//// dyld strips local symbols out of the images in the shared cache and parks// them in a side file, `dyld_shared_cache_<arch>.symbols`. That file is where@@ -29,7 +29,7 @@import Foundation/// Reader over `dyld_shared_cache_<arch>.symbols`.-public struct DSCLocalSymbolTable: Sendable {+public struct DyldSharedCacheLocalSymbolTable: Sendable {/// One image's slice of the nlist array.public struct ImageEntry: Sendable {/// The image's `__TEXT` address as an offset from the cache's@@ -46,7 +46,7 @@ public struct DSCLocalSymbolTable: Sendable {/// On an iOS 27 arm64e cache this file is 1.17 GB, and the string table and/// nlist array inside it are most of that. Reading them with/// `FileHandle.read(upToCount:)` — which is what this did — made every- /// `DSCSymbolResolver` cost well over a gigabyte of resident memory, and a+ /// `DyldSharedCacheSymbolResolver` cost well over a gigabyte of resident memory, and a/// test run that builds several in parallel took the machine down with it.////// `.mappedIfSafe` costs address space instead. Pages fault in only where a@@ -80,14 +80,14 @@ public struct DSCLocalSymbolTable: Sendable {guard file.count >= 0x50,file.prefix(7) == Data("dyld_v1".utf8)else {- throw DSCError.notADyldCache(url.path)+ throw DyldSharedCacheError.notADyldCache(url.path)}// Every read below goes through `at:` on the mapped file, so each one// is a page fault at most rather than a copy.let infoOffset = Int(file.at(UInt64.self, 0x48))guard infoOffset > 0, infoOffset + 24 <= file.count else {- throw DSCError.symbolNotFound(symbol: "<local symbols table>", image: nil)+ throw DyldSharedCacheError.symbolNotFound(symbol: "<local symbols table>", image: nil)}let nlistOffset = Int(file.at(UInt32.self, infoOffset))diff --git a/sources/FirmwarePatcher/DSC/DSCSymbolResolver.swift b/sources/FirmwarePatcher/DyldSharedCache/DyldSharedCacheSymbolResolver.swiftsimilarity index 92%rename from sources/FirmwarePatcher/DSC/DSCSymbolResolver.swiftrename to sources/FirmwarePatcher/DyldSharedCache/DyldSharedCacheSymbolResolver.swiftindex e63cb4e8..4dc005d2 100644--- a/sources/FirmwarePatcher/DSC/DSCSymbolResolver.swift+++ b/sources/FirmwarePatcher/DyldSharedCache/DyldSharedCacheSymbolResolver.swift@@ -1,4 +1,4 @@-// DSCSymbolResolver.swift — Symbol addresses in the shared cache, without `ipsw`.+// DyldSharedCacheSymbolResolver.swift — Symbol addresses in the shared cache, without `ipsw`.//// Three CFW patchers used to shell out to `ipsw dyld symaddr`:// `cfw_patch_camera_dsc.py`, `cfw_patch_iomfb_swapend.py` and@@ -18,7 +18,7 @@ import Foundationimport MachOKit/// Symbol lookup across the images of a chunked dyld shared cache.-public final class DSCSymbolResolver {+public final class DyldSharedCacheSymbolResolver {/// Where a resolved address came from. Worth reporting: a symbol found only/// in the local table is one `ipsw dyld symaddr` may also be slow to find,/// and a symbol found in both should agree.@@ -41,7 +41,7 @@ public final class DSCSymbolResolver {/// `DyldCache` opened on it alone reports no images past `.00` and no/// exported symbols at all.private let cache: FullDyldCache- private let localSymbols: DSCLocalSymbolTable?+ private let localSymbols: DyldSharedCacheLocalSymbolTable?private let localSymbolsURL: URLprivate let sharedRegionStart: UInt64/// image path → mach header address.@@ -76,13 +76,13 @@ public final class DSCSymbolResolver {let symbolsURL = mainCacheURL.deletingLastPathComponent().appendingPathComponent(mainCacheURL.lastPathComponent + ".symbols")localSymbols = FileManager.default.fileExists(atPath: symbolsURL.path)- ? try DSCLocalSymbolTable(url: symbolsURL)+ ? try DyldSharedCacheLocalSymbolTable(url: symbolsURL): nillocalSymbolsURL = symbolsURL}- /// Open the cache a `DSCChunkSet` already found.- public convenience init(chunks: DSCChunkSet) throws {+ /// Open the cache a `DyldSharedCacheChunkSet` already found.+ public convenience init(chunks: DyldSharedCacheChunkSet) throws {try self.init(mainCacheURL: chunks.mainCacheURL)}@@ -99,7 +99,7 @@ public final class DSCSymbolResolver {/// to look".public func requireLocalSymbols() throws {guard localSymbols != nil else {- throw DSCError.localSymbolsMissing(path: localSymbolsURL.path)+ throw DyldSharedCacheError.localSymbolsMissing(path: localSymbolsURL.path)}}@@ -111,7 +111,7 @@ public final class DSCSymbolResolver {/// The mach header address of `imagePath`.public func headerAddress(ofImage imagePath: String) throws -> UInt64 {guard let address = imageAddresses[imagePath] else {- throw DSCError.imageNotFound(imagePath)+ throw DyldSharedCacheError.imageNotFound(imagePath)}return address}@@ -171,7 +171,7 @@ public final class DSCSymbolResolver {public func address(of symbol: String, inImage imagePath: String) throws -> UInt64 {guard let resolution = try symbols(inImage: imagePath)[symbol] else {try requireLocalSymbols()- throw DSCError.symbolNotFound(symbol: symbol, image: imagePath)+ throw DyldSharedCacheError.symbolNotFound(symbol: symbol, image: imagePath)}return resolution.address}@@ -196,7 +196,7 @@ public final class DSCSymbolResolver {}guard missing.isEmpty else {try requireLocalSymbols()- throw DSCError.symbolNotFound(+ throw DyldSharedCacheError.symbolNotFound(symbol: missing.joined(separator: ", "),image: imagePath,)diff --git a/sources/FirmwarePatcher/DSC/Patchers/DSCCameraPatcher.swift b/sources/FirmwarePatcher/DyldSharedCache/Patchers/DyldSharedCacheCameraPatcher.swiftsimilarity index 96%rename from sources/FirmwarePatcher/DSC/Patchers/DSCCameraPatcher.swiftrename to sources/FirmwarePatcher/DyldSharedCache/Patchers/DyldSharedCacheCameraPatcher.swiftindex d697fc05..7583c7ff 100644--- a/sources/FirmwarePatcher/DSC/Patchers/DSCCameraPatcher.swift+++ b/sources/FirmwarePatcher/DyldSharedCache/Patchers/DyldSharedCacheCameraPatcher.swift@@ -1,4 +1,4 @@-// DSCCameraPatcher.swift — The two camera DSC patch families, EXP only.+// DyldSharedCacheCameraPatcher.swift — The two camera DSC patch families, EXP only.//// Port of `scripts/patchers/cfw_patch_camera_dsc.py`, which stays the// independent reference: the parity gate is the Python run on one clone of the@@ -29,8 +29,8 @@// -------------------------------//// * **`ipsw dyld symaddr`.** The Python shells out to the Go tool and parses-// its coloured output. Here the six symbols come from `DSCSymbolResolver`,-// which reads the cache's own `.symbols` table. `DSCSymbolResolverTests`+// its coloured output. Here the six symbols come from `DyldSharedCacheSymbolResolver`,+// which reads the cache's own `.symbols` table. `DyldSharedCacheSymbolResolverTests`// pins all six against `ipsw` on the real cache, so the addresses are the// same addresses.// * **The raw-byte prologue test.** The Python compares the first four bytes@@ -38,7 +38,7 @@// mnemonic checked, per the patcher guardrails — an encoding of `pacibsp`// is recognised as `pacibsp`, not as four bytes.// * **Re-attesting per family.** The Python re-attests after each family, off-// a list of bare addresses. Here every write is recorded by `DSCChunkSet`+// a list of bare addresses. Here every write is recorded by `DyldSharedCacheChunkSet`// and `reattestRecordedWrites` runs once at the end, off spans. Same pages// on this cache — the six sites are 8 bytes each and none is within 8 bytes// of a 16 KiB boundary — but a site that did straddle one would be fully@@ -73,7 +73,7 @@ import Capstoneimport Foundation/// The camera-related patches applied to the SystemOS cryptex's shared cache.-public enum DSCCameraPatcher {+public enum DyldSharedCacheCameraPatcher {// MARK: - Targets/// Which of the two patch families a site belongs to.@@ -94,8 +94,8 @@ public enum DSCCameraPatcher {/// The symbols the family rewrites, in the Python's order.public var symbols: [String] {switch self {- case .neutrinoStyleTransfer: DSCCameraPatcher.styleTransferSymbols- case .avfAuthorization: [DSCCameraPatcher.authorizationStatusSymbol]+ case .neutrinoStyleTransfer: DyldSharedCacheCameraPatcher.styleTransferSymbols+ case .avfAuthorization: [DyldSharedCacheCameraPatcher.authorizationStatusSymbol]}}@@ -165,7 +165,7 @@ public enum DSCCameraPatcher {public let sites: [Site]/// The re-attestation pass, or `nil` on a dry run, which does not write/// and so has nothing to re-attest.- public let reattestation: DSCReattestation?+ public let reattestation: DyldSharedCacheReattestation?public let dryRun: Boolpublic var siteCount: Int {@@ -246,8 +246,8 @@ public enum DSCCameraPatcher {force: Bool,log: ((String) -> Void)?,) throws -> Result {- let chunks = try DSCChunkSet(directory: chunksDirectory)- let resolver = try DSCSymbolResolver(+ let chunks = try DyldSharedCacheChunkSet(directory: chunksDirectory)+ let resolver = try DyldSharedCacheSymbolResolver(mainCacheURL: symbolCacheURL ?? chunks.mainCacheURL,)// Every symbol here is an ObjC class method, and those live only in the@@ -336,7 +336,7 @@ public enum DSCCameraPatcher {// One pass, off the spans the writes recorded. Nothing has to tell it// which addresses were touched, so nothing can under-attest.- let reattestation = try DSCCodeSignature.reattestRecordedWrites(+ let reattestation = try DyldSharedCacheCodeSignature.reattestRecordedWrites(in: chunks,log: log,)diff --git a/sources/FirmwarePatcher/DSC/Patchers/DSCHVVMMPatcher.swift b/sources/FirmwarePatcher/DyldSharedCache/Patchers/DyldSharedCacheHVVMMPatcher.swiftsimilarity index 94%rename from sources/FirmwarePatcher/DSC/Patchers/DSCHVVMMPatcher.swiftrename to sources/FirmwarePatcher/DyldSharedCache/Patchers/DyldSharedCacheHVVMMPatcher.swiftindex 594b25ce..b47859f7 100644--- a/sources/FirmwarePatcher/DSC/Patchers/DSCHVVMMPatcher.swift+++ b/sources/FirmwarePatcher/DyldSharedCache/Patchers/DyldSharedCacheHVVMMPatcher.swift@@ -1,4 +1,4 @@-// DSCHVVMMPatcher.swift — the `kern.hv_vmm_present` user-mode cstring mangle.+// DyldSharedCacheHVVMMPatcher.swift — the `kern.hv_vmm_present` user-mode cstring mangle.//// Port of BOTH `scripts/patchers/cfw_patch_hv_vmm_dsc.py` (the DSC orchestrator)// and `scripts/patchers/cfw_patch_hv_vmm.py` (the cstring definition and the@@ -13,8 +13,8 @@// What the patch is// -----------------// This is the user-mode half of the EXP blacklist-flip. The kernel half —-// `KernelEXPPatcher.patchHvVmmRename`, in-// `Kernel/EXPPatches/KernelEXPPatchHvVmmRename.swift` — renames the sysctl OID+// `KernelExperimentalPatcher.patchHvVmmRename`, in+// `Kernel/EXPPatches/KernelExperimentalPatchHvVmmRename.swift` — renames the sysctl OID// from `hv_vmm_present` to `Xv_vmm_present`. After it://// * `sysctlbyname("kern.hv_vmm_present", …)` returns ENOENT, and the canonical@@ -56,9 +56,9 @@// own: TXM holds the SHA-256 slot hash the page was registered with, and the// first process to demand-page that 16 KiB page dies with// `KERN_PROTECTION_FAILURE` / `CODESIGNING / Invalid Page`. Every site written-// here is therefore followed by `DSCCodeSignature`, which re-hashes the pages+// here is therefore followed by `DyldSharedCacheCodeSignature`, which re-hashes the pages// that were actually dirtied. This patcher never names those pages itself —-// `DSCChunkSet` records each write and the re-attestation pass consumes the+// `DyldSharedCacheChunkSet` records each write and the re-attestation pass consumes the// record, so a site cannot be written and left unattested.//// One deliberate divergence from the reference@@ -75,7 +75,7 @@ import Foundation/// The user-mode `kern.hv_vmm_present` cstring mangle, over a chunked dyld/// shared cache and over standalone Mach-Os.-public enum DSCHVVMMPatcher {+public enum DyldSharedCacheHVVMMPatcher {// MARK: - The cstring and its mangle//@@ -101,7 +101,7 @@ public enum DSCHVVMMPatcher {/// What that byte is before the patch.public static let originalByte = UInt8(ascii: "h")- /// What it becomes — the same letter `KernelEXPPatchHvVmmRename` renames the+ /// What it becomes — the same letter `KernelExperimentalPatchHvVmmRename` renames the/// OID to, which is the only reason the mangled name resolves at all.public static let mangledByte = UInt8(ascii: "X")@@ -200,7 +200,7 @@ public enum DSCHVVMMPatcher {/// edit, reported loudly and re-attested rather than reverted.public let blacklistDrift: Int/// The re-attestation pass, or `nil` when there were no pages to cover.- public let reattestation: DSCReattestation?+ public let reattestation: DyldSharedCacheReattestation?/// True when nothing was left in a state the guest would fault on: every/// page this run touched carries a slot hash that matches its bytes.@@ -233,9 +233,9 @@ public enum DSCHVVMMPatcher {public static func patch(chunksDirectory: URL,dryRun: Bool = false,- log: ((String) -> Void)? = DSCCodeSignature.stderrLog,+ log: ((String) -> Void)? = DyldSharedCacheCodeSignature.stderrLog,) throws -> Result {- let chunks = try DSCChunkSet(directory: chunksDirectory)+ let chunks = try DyldSharedCacheChunkSet(directory: chunksDirectory)log?(" [.] \(chunksDirectory.path): \(chunks.chunkURLs.count) chunk(s), "+ "\(chunks.mappings.count) mapping(s), "@@ -257,9 +257,9 @@ public enum DSCHVVMMPatcher {/// this patch's own spans, is how a page ends up written and unattested.@discardableResultpublic static func patch(- in chunks: DSCChunkSet,+ in chunks: DyldSharedCacheChunkSet,dryRun: Bool = false,- log: ((String) -> Void)? = DSCCodeSignature.stderrLog,+ log: ((String) -> Void)? = DyldSharedCacheCodeSignature.stderrLog,) throws -> Result {log?(" [.] locating cstring \"kern.hv_vmm_present\\0\"…")let pristineSites = try chunks.findStringVMAs(needle).sorted()@@ -290,12 +290,12 @@ public enum DSCHVVMMPatcher {var skippedInBlacklist = 0var skippedUnclassified = 0var refused = 0- // Stand-ins for the writes, used on a dry run where `DSCChunkSet` has no+ // Stand-ins for the writes, used on a dry run where `DyldSharedCacheChunkSet` has no// record because nothing was written. On a live run the record is the// authority and these are not consulted.- var plannedSpans: [DSCWriteSpan] = []+ var plannedSpans: [DyldSharedCacheWriteSpan] = []// Pages that need re-hashing although this run wrote nothing to them.- var reattestOnlySpans: [DSCWriteSpan] = []+ var reattestOnlySpans: [DyldSharedCacheWriteSpan] = []for vma in pristineSites {let installName = classify(vma, in: chunks)@@ -352,7 +352,7 @@ public enum DSCHVVMMPatcher {let writeVMA = vma &+ UInt64(mangleOffset)if dryRun {- plannedSpans.append(DSCWriteSpan.byte(at: writeVMA))+ plannedSpans.append(DyldSharedCacheWriteSpan.byte(at: writeVMA))} else {try chunks.write(at: writeVMA, Data([mangledByte]))}@@ -384,7 +384,7 @@ public enum DSCHVVMMPatcher {// The whole cstring, not just the mangled byte: nothing was written// this run, so there is no write span to inherit, and a literal that// straddles a page boundary needs both of its pages.- let span = DSCWriteSpan(vma: vma, length: needle.count)+ let span = DyldSharedCacheWriteSpan(vma: vma, length: needle.count)if dontPatchSet.contains(installName) {log?(" [!] drift: \(installName) is in the blacklist but "@@ -417,19 +417,19 @@ public enum DSCHVVMMPatcher {// without a re-hash is a SIGKILL on the first demand-page-in of that// page, with nothing pointing back at this patch. The CD blob's own// cdHash changes as a side effect; that is survivable only because the- // JB kernel patch `KernelJBPatchAmfiTrustcache` short-circuits AMFI's+ // JB kernel patch `KernelJailbreakPatchAmfiTrustcache` short-circuits AMFI's// per-image trust-cache lookup.//- // The write spans come from `DSCChunkSet` itself rather than from a list+ // The write spans come from `DyldSharedCacheChunkSet` itself rather than from a list// this function keeps, so a site cannot be written and left out.let spans = (dryRun ? plannedSpans : chunks.recordedWrites) + reattestOnlySpans- var reattestation: DSCReattestation?+ var reattestation: DyldSharedCacheReattestation?if !spans.isEmpty {log?(" [.] \(dryRun ? "dry-run: would re-attest" : "re-attesting") "+ "\(spans.count) modified page span(s)…",)- reattestation = try DSCCodeSignature.reattest(+ reattestation = try DyldSharedCacheCodeSignature.reattest(in: chunks,modifiedSpans: spans,dryRun: dryRun,@@ -463,7 +463,7 @@ public enum DSCHVVMMPatcher {/// what the reference's blanket `except Exception` does: a site whose dylib/// cannot be named is left alone either way, so the two cases lead to the/// same place.- static func classify(_ vma: UInt64, in chunks: DSCChunkSet) -> String? {+ static func classify(_ vma: UInt64, in chunks: DyldSharedCacheChunkSet) -> String? {let headerVMA: UInt64?do {headerVMA = try chunks.findMachOHeaderBefore(vma)@@ -566,7 +566,7 @@ public enum DSCHVVMMPatcher {public static func patchStandaloneMachO(at url: URL,dryRun: Bool = false,- log: ((String) -> Void)? = DSCCodeSignature.stderrLog,+ log: ((String) -> Void)? = DyldSharedCacheCodeSignature.stderrLog,) throws -> Int {guard FileManager.default.fileExists(atPath: url.path) else {throw PatcherError.fileNotFound(url.path)diff --git a/sources/FirmwarePatcher/DSC/Patchers/DSCIOMFBForceKernPatcher.swift b/sources/FirmwarePatcher/DyldSharedCache/Patchers/DyldSharedCacheIOMFBForceKernPatcher.swiftsimilarity index 93%rename from sources/FirmwarePatcher/DSC/Patchers/DSCIOMFBForceKernPatcher.swiftrename to sources/FirmwarePatcher/DyldSharedCache/Patchers/DyldSharedCacheIOMFBForceKernPatcher.swiftindex c1e6c2d8..ace03eed 100644--- a/sources/FirmwarePatcher/DSC/Patchers/DSCIOMFBForceKernPatcher.swift+++ b/sources/FirmwarePatcher/DyldSharedCache/Patchers/DyldSharedCacheIOMFBForceKernPatcher.swift@@ -1,4 +1,4 @@-// DSCIOMFBForceKernPatcher.swift — Force IOMobileFramebuffer's present onto the+// DyldSharedCacheIOMFBForceKernPatcher.swift — Force IOMobileFramebuffer's present onto the// kernel (userclient method-5) path instead of the virt (in-process callback) one.//// Why@@ -33,21 +33,21 @@// selected the kern fp — every present call now routes through the kern/method-5// implementation regardless of how iOS 27 classified the display.//-// Companion kernel patch: `KernelJBPatcher.patchIomfbSwapEndVariableSize` /+// Companion kernel patch: `KernelJailbreakPatcher.patchIomfbSwapEndVariableSize` /// `…HandlerSize`, which make the 26.4 userclient accept iOS 27's native 0x6e0// SwapEnd struct (26.x sent 0x588). Both halves are required together — forcing// kern without the kernel size-accept makes method 5 return// `kIOReturnBadArgument`.//// Nothing is hardcoded. The public entry points and their `_kern_` counterparts-// are resolved by NAME through `DSCSymbolResolver` (export trie plus the cache's+// are resolved by NAME through `DyldSharedCacheSymbolResolver` (export trie plus the cache's// own `.symbols` table — no `ipsw` subprocess), the trampoline shape is verified// by Capstone decode of typed operands rather than operand text, the replacement// branch comes from `ARM64Encoder.encodeB`, and every DSC page the writes-// dirtied is re-attested through the span log `DSCChunkSet` keeps.+// dirtied is re-attested through the span log `DyldSharedCacheChunkSet` keeps.//// Port of `scripts/patchers/cfw_patch_iomfb_force_kern.py`, which stays the-// independent reference — `DSCIOMFBForceKernTests` runs the Python on one clone+// independent reference — `DyldSharedCacheIOMFBForceKernTests` runs the Python on one clone// of the real cache and this on another, and compares the two byte for byte.//// One place diverges from the reference on purpose. The Python writes every site@@ -64,7 +64,7 @@ import Foundation/// Retargets IOMobileFramebuffer's public swap trampolines at their `_kern_`/// implementations, inside a chunked dyld shared cache.-public enum DSCIOMFBForceKernPatcher {+public enum DyldSharedCacheIOMFBForceKernPatcher {/// The image that carries both halves of every pair.public static let imagePath ="/System/Library/PrivateFrameworks/IOMobileFramebuffer.framework/IOMobileFramebuffer"@@ -131,7 +131,7 @@ public enum DSCIOMFBForceKernPatcher {/// One record per site written, for the Python/Swift record comparison.public let records: [PatchRecord]/// The re-attestation pass, or `nil` when nothing was written.- public let reattestation: DSCReattestation?+ public let reattestation: DyldSharedCacheReattestation?public var forced: [Site] {sites.filter { $0.disposition == .forced }@@ -170,8 +170,8 @@ public enum DSCIOMFBForceKernPatcher {dryRun: Bool = false,log: ((String) -> Void)? = stdoutLog,) throws -> Outcome {- let chunks = try DSCChunkSet(directory: chunksDirectory)- let resolver = try DSCSymbolResolver(chunks: chunks)+ let chunks = try DyldSharedCacheChunkSet(directory: chunksDirectory)+ let resolver = try DyldSharedCacheSymbolResolver(chunks: chunks)return try patch(chunks: chunks, resolver: resolver, dryRun: dryRun, log: log)}@@ -183,8 +183,8 @@ public enum DSCIOMFBForceKernPatcher {/// SHA-256, under-attesting one is a page fault the guest dies on.@discardableResultpublic static func patch(- chunks: DSCChunkSet,- resolver: DSCSymbolResolver,+ chunks: DyldSharedCacheChunkSet,+ resolver: DyldSharedCacheSymbolResolver,dryRun: Bool = false,log: ((String) -> Void)? = stdoutLog,) throws -> Outcome {@@ -242,7 +242,7 @@ public enum DSCIOMFBForceKernPatcher {try records.append(force(site, chunks: chunks))}- var reattestation: DSCReattestation?+ var reattestation: DyldSharedCacheReattestation?if records.isEmpty {log?(" [=] all \(sites.count { $0.disposition == .alreadyForced }) entrypoint(s) "@@ -250,7 +250,7 @@ public enum DSCIOMFBForceKernPatcher {)} else {log?(" [.] re-attesting the pages \(records.count) write(s) dirtied...")- let result = try DSCCodeSignature.reattestRecordedWrites(in: chunks, log: log)+ let result = try DyldSharedCacheCodeSignature.reattestRecordedWrites(in: chunks, log: log)guard result.isFullyAttested else {throw PatcherError.patchVerificationFailed("re-attestation skipped \(result.skipped.count) page(s): "@@ -279,7 +279,7 @@ public enum DSCIOMFBForceKernPatcher {/// and which of them kept a kern implementation, is a property of the cache/// being patched and changes between OS versions.public static func discoverEntryPoints(- resolver: DSCSymbolResolver,+ resolver: DyldSharedCacheSymbolResolver,) throws -> [EntryPoint] {let all = try resolver.symbols(inImage: imagePath)let publicEntries = try resolver.symbols(inImage: imagePath, withPrefix: publicPrefix)@@ -307,7 +307,7 @@ public enum DSCIOMFBForceKernPatcher {private static func classify(_ entry: EntryPoint,- chunks: DSCChunkSet,+ chunks: DyldSharedCacheChunkSet,disassembler: ARM64Disassembler,) throws -> Site {let instructions = try disassembler.disassemble(@@ -373,7 +373,7 @@ public enum DSCIOMFBForceKernPatcher {// MARK: - Writing- private static func force(_ site: Site, chunks: DSCChunkSet) throws -> PatchRecord {+ private static func force(_ site: Site, chunks: DyldSharedCacheChunkSet) throws -> PatchRecord {let entry = site.entryguard let branch = ARM64Encoder.encodeB(from: Int(entry.publicAddress),@@ -385,7 +385,7 @@ public enum DSCIOMFBForceKernPatcher {)}- let span = DSCWriteSpan(vma: entry.publicAddress, length: 4)+ let span = DyldSharedCacheWriteSpan(vma: entry.publicAddress, length: 4)let (chunkURL, range) = try chunks.fileRange(of: span)let original = try chunks.bytesAtVMA(entry.publicAddress, length: 4)try chunks.write(at: entry.publicAddress, branch)@@ -408,7 +408,7 @@ public enum DSCIOMFBForceKernPatcher {/// branch, which is what the reference's post-write verify checks.private static func verify(_ sites: [Site],- chunks: DSCChunkSet,+ chunks: DyldSharedCacheChunkSet,disassembler: ARM64Disassembler,) throws {for site in sites {diff --git a/sources/FirmwarePatcher/DSC/Patchers/DSCIOMFBSwapEndPatcher.swift b/sources/FirmwarePatcher/DyldSharedCache/Patchers/DyldSharedCacheIOMFBSwapEndPatcher.swiftsimilarity index 91%rename from sources/FirmwarePatcher/DSC/Patchers/DSCIOMFBSwapEndPatcher.swiftrename to sources/FirmwarePatcher/DyldSharedCache/Patchers/DyldSharedCacheIOMFBSwapEndPatcher.swiftindex 3e4ba917..3c5ca2ce 100644--- a/sources/FirmwarePatcher/DSC/Patchers/DSCIOMFBSwapEndPatcher.swift+++ b/sources/FirmwarePatcher/DyldSharedCache/Patchers/DyldSharedCacheIOMFBSwapEndPatcher.swift@@ -1,4 +1,4 @@-// DSCIOMFBSwapEndPatcher.swift — Make IOMobileFramebuffer's SwapEnd payload+// DyldSharedCacheIOMFBSwapEndPatcher.swift — Make IOMobileFramebuffer's SwapEnd payload// size match what the base kernel's userclient will accept.//// The SwapEnd input-state size is enforced kernel-side, not negotiated: the PCC@@ -43,11 +43,11 @@// `ARM64Encoder`.//// Port of `scripts/patchers/cfw_patch_iomfb_swapend.py`, which stays the-// independent reference — `DSCIOMFBSwapEndTests` runs the Python on one clone of+// independent reference — `DyldSharedCacheIOMFBSwapEndTests` runs the Python on one clone of// the real cache and this on another, and compares the two byte for byte.//// One thing is deliberately not ported: the Python resolves `_kern_SwapEnd` by-// shelling out to `ipsw dyld symaddr`. Here that is `DSCSymbolResolver`, which+// shelling out to `ipsw dyld symaddr`. Here that is `DyldSharedCacheSymbolResolver`, which// reads the cache's export tries and its `.symbols` side file directly — same// addresses, no Go tool on the patch path.@@ -55,7 +55,7 @@ import Capstoneimport Foundation/// What one run of the SwapEnd size patch did.-public struct DSCIOMFBSwapEndPatch: Sendable {+public struct DyldSharedCacheIOMFBSwapEndPatch: Sendable {/// Address `_kern_SwapEnd` resolved to.public let functionVMA: UInt64/// Address of the `mov w3, #imm` that carries the payload size.@@ -71,7 +71,7 @@ public struct DSCIOMFBSwapEndPatch: Sendable {/// explicit so a parity run can compare it.public let sitesWritten: Int/// Re-attestation of the pages the write dirtied; `nil` on a dry run.- public let reattestation: DSCReattestation?+ public let reattestation: DyldSharedCacheReattestation?/// The Python's return value: one site *considered*, patched or not.public var sitesConsidered: Int {@@ -79,7 +79,7 @@ public struct DSCIOMFBSwapEndPatch: Sendable {}}-public enum DSCIOMFBSwapEndPatcher {+public enum DyldSharedCacheIOMFBSwapEndPatcher {/// The image that carries `_kern_SwapEnd`.public static let imagePath ="/System/Library/PrivateFrameworks/IOMobileFramebuffer.framework/IOMobileFramebuffer"@@ -125,15 +125,15 @@ public enum DSCIOMFBSwapEndPatcher {chunksDirectory: URL,targetSize: UInt32 = defaultTargetSize,dryRun: Bool = false,- log: ((String) -> Void)? = DSCCodeSignature.stderrLog,- ) throws -> DSCIOMFBSwapEndPatch {+ log: ((String) -> Void)? = DyldSharedCacheCodeSignature.stderrLog,+ ) throws -> DyldSharedCacheIOMFBSwapEndPatch {// Before opening a 6.7 GB cache and its 1.2 GB symbol table: a target// size that cannot be encoded is an argument error, and it should read// as one rather than as whatever the cache happens to say first._ = try replacement(forTargetSize: targetSize)- let chunks = try DSCChunkSet(directory: chunksDirectory)- let resolver = try DSCSymbolResolver(chunks: chunks)+ let chunks = try DyldSharedCacheChunkSet(directory: chunksDirectory)+ let resolver = try DyldSharedCacheSymbolResolver(chunks: chunks)return try patch(chunks: chunks,resolver: resolver,@@ -147,16 +147,16 @@ public enum DSCIOMFBSwapEndPatcher {////// The re-attestation at the end covers only the writes this call made:/// `recordedWrites` is cleared first, so a caller that runs several DSC- /// patchers over one `DSCChunkSet` does not re-hash the previous one's+ /// patchers over one `DyldSharedCacheChunkSet` does not re-hash the previous one's/// pages on every subsequent patch.@discardableResultpublic static func patch(- chunks: DSCChunkSet,- resolver: DSCSymbolResolver,+ chunks: DyldSharedCacheChunkSet,+ resolver: DyldSharedCacheSymbolResolver,targetSize: UInt32 = defaultTargetSize,dryRun: Bool = false,- log: ((String) -> Void)? = DSCCodeSignature.stderrLog,- ) throws -> DSCIOMFBSwapEndPatch {+ log: ((String) -> Void)? = DyldSharedCacheCodeSignature.stderrLog,+ ) throws -> DyldSharedCacheIOMFBSwapEndPatch {let replacement = try replacement(forTargetSize: targetSize)log?(" [.] \(chunks.chunkURLs.count) chunk(s), \(chunks.mappings.count) mapping(s)")@@ -197,7 +197,7 @@ public enum DSCIOMFBSwapEndPatcher {)}- var reattestation: DSCReattestation?+ var reattestation: DyldSharedCacheReattestation?if dryRun {log?(" [.] dry-run: would re-attest the page holding 0x\(hex(siteVMA))")} else {@@ -206,7 +206,7 @@ public enum DSCIOMFBSwapEndPatcher {try chunks.write(at: siteVMA, replacement)}log?(" [.] re-attesting modified page(s)...")- reattestation = try DSCCodeSignature.reattestRecordedWrites(in: chunks, log: log)+ reattestation = try DyldSharedCacheCodeSignature.reattestRecordedWrites(in: chunks, log: log)let readBack = try chunks.bytesAtVMA(siteVMA, length: replacement.count)guard readBack == replacement else {@@ -218,7 +218,7 @@ public enum DSCIOMFBSwapEndPatcher {}log?(" [+] IOMFB SwapEnd patch complete")- return DSCIOMFBSwapEndPatch(+ return DyldSharedCacheIOMFBSwapEndPatch(functionVMA: functionVMA,siteVMA: siteVMA,originalSize: originalSize,@@ -331,7 +331,7 @@ public enum DSCIOMFBSwapEndPatcher {/// still disassembles as far as it goes, rather than throwing because the/// full instruction budget would overrun the mapping.static func disassembleFunction(- in chunks: DSCChunkSet,+ in chunks: DyldSharedCacheChunkSet,at vma: UInt64,maximumInstructions: Int,disassembler: ARM64Disassembler,diff --git a/sources/FirmwarePatcher/DSC/Patchers/DSCLSDEmbeddedRegPatcher.swift b/sources/FirmwarePatcher/DyldSharedCache/Patchers/DyldSharedCacheLSDEmbeddedRegPatcher.swiftsimilarity index 96%rename from sources/FirmwarePatcher/DSC/Patchers/DSCLSDEmbeddedRegPatcher.swiftrename to sources/FirmwarePatcher/DyldSharedCache/Patchers/DyldSharedCacheLSDEmbeddedRegPatcher.swiftindex 797b1ac2..c80731b5 100644--- a/sources/FirmwarePatcher/DSC/Patchers/DSCLSDEmbeddedRegPatcher.swift+++ b/sources/FirmwarePatcher/DyldSharedCache/Patchers/DyldSharedCacheLSDEmbeddedRegPatcher.swift@@ -1,4 +1,4 @@-// DSCLSDEmbeddedRegPatcher.swift — open lsd's embedded-registration gate.+// DyldSharedCacheLSDEmbeddedRegPatcher.swift — open lsd's embedded-registration gate.//// Swift port of `scripts/patchers/cfw_patch_lsd_embedded_reg.py`, driven by// `cfw.py patch-lsd-embedded-reg <chunks_dir> [--dry-run]`.@@ -48,7 +48,7 @@ import Foundation/// Forces `-[_LSDModifyClient clientIsEntitledForEmbeddedRegistrationOperations]`/// to return YES, by NOP'ing the branch that skips its YES result.-public enum DSCLSDEmbeddedRegPatcher {+public enum DyldSharedCacheLSDEmbeddedRegPatcher {/// The image the method lives in. Reported only — the symbol is resolved/// through the cache-wide local table, exactly as the Python does, because/// `ipsw dyld symaddr -a` times out on a cache this size.@@ -155,7 +155,7 @@ public enum DSCLSDEmbeddedRegPatcher {dryRun: Bool = false,log: ((String) -> Void)? = stdoutLog,) throws -> Report {- let chunks = try DSCChunkSet(directory: chunksDirectory)+ let chunks = try DyldSharedCacheChunkSet(directory: chunksDirectory)log?(" [.] \(chunksDirectory.path): \(chunks.chunkURLs.count) chunk(s), "+ "\(chunks.mappings.count) mapping(s)")@@ -193,12 +193,12 @@ public enum DSCLSDEmbeddedRegPatcher {// not, and re-attestation here consumes the chunk set's own write log// rather than an address a caller hands it — so the idempotent case has// to go through the same door. The bytes on disk are identical either- // way, and `DSCCodeSignature` leaves a page whose stored slot already+ // way, and `DyldSharedCacheCodeSignature` leaves a page whose stored slot already// matches alone.try chunks.write(at: gate.vma, nop)log?(" [.] re-attesting modified page...")- try DSCCodeSignature.reattestRecordedWrites(in: chunks, log: log)+ try DyldSharedCacheCodeSignature.reattestRecordedWrites(in: chunks, log: log)let written = try chunks.bytesAtVMA(gate.vma, length: nop.count)guard written == nop else {@@ -226,7 +226,7 @@ public enum DSCLSDEmbeddedRegPatcher {/// Returns `nil` when the method is absent, which is the pre-iOS-27 no-op/// case rather than an error.public static func locateGate(- in chunks: DSCChunkSet,+ in chunks: DyldSharedCacheChunkSet,) throws -> (functionVMA: UInt64, gate: Gate)? {guard let functionVMA = try chunks.resolveLocalSymbol(method) else { return nil }@@ -246,7 +246,7 @@ public enum DSCLSDEmbeddedRegPatcher {/// claim about what is mapped: a method that ends near the tail of its/// mapping must not turn into an unmapped-span error.static func disassembleFunction(- in chunks: DSCChunkSet,+ in chunks: DyldSharedCacheChunkSet,at vma: UInt64,) throws -> [Instruction] {let buffer = try chunks.readAtVMA(@@ -333,11 +333,11 @@ public enum DSCLSDEmbeddedRegPatcher {/// virtual address rides along.private static func record(for gate: Gate,- in chunks: DSCChunkSet,+ in chunks: DyldSharedCacheChunkSet,original: Data,patched: Data,) throws -> PatchRecord {- let span = DSCWriteSpan(vma: gate.vma, length: patched.count)+ let span = DyldSharedCacheWriteSpan(vma: gate.vma, length: patched.count)let (chunkURL, range) = try chunks.fileRange(of: span)return PatchRecord(patchID: patchID,diff --git a/sources/FirmwarePatcher/DSC/Patchers/DSCLockdownModePatcher.swift b/sources/FirmwarePatcher/DyldSharedCache/Patchers/DyldSharedCacheLockdownModePatcher.swiftsimilarity index 90%rename from sources/FirmwarePatcher/DSC/Patchers/DSCLockdownModePatcher.swiftrename to sources/FirmwarePatcher/DyldSharedCache/Patchers/DyldSharedCacheLockdownModePatcher.swiftindex 3b667e14..7440d575 100644--- a/sources/FirmwarePatcher/DSC/Patchers/DSCLockdownModePatcher.swift+++ b/sources/FirmwarePatcher/DyldSharedCache/Patchers/DyldSharedCacheLockdownModePatcher.swift@@ -1,4 +1,4 @@-// DSCLockdownModePatcher.swift — Stop libSystem's `os_lockdown_mode_enabled`+// DyldSharedCacheLockdownModePatcher.swift — Stop libSystem's `os_lockdown_mode_enabled`// from crashing on the vphone kernel.//// iOS 27's `os_lockdown_mode_enabled()` resolves Lockdown Mode once, from a@@ -22,10 +22,10 @@//// Anchored on the in-image local symbol; the sysctl-error idiom is located by// control-flow shape through Capstone; the NOP comes from `ARM64.nop`; the-// modified page is re-attested through `DSCCodeSignature`.+// modified page is re-attested through `DyldSharedCacheCodeSignature`.//// Port of `scripts/patchers/cfw_patch_lockdown_mode.py`, which stays the-// independent reference — `DSCLockdownModePatcherTests` runs the Python on one+// independent reference — `DyldSharedCacheLockdownModePatcherTests` runs the Python on one// clone of the real cache and this on another, and compares the two byte for// byte.//@@ -38,7 +38,7 @@import Capstoneimport Foundation-public enum DSCLockdownModePatcher {+public enum DyldSharedCacheLockdownModePatcher {// MARK: - Anchors/// The block the sysctl lives in, under both manglings seen across@@ -94,7 +94,7 @@ public enum DSCLockdownModePatcher {/// The record of the single write, on a run that wrote or would write.public let record: PatchRecord?/// What re-attestation did, on a run that wrote.- public let reattestation: DSCReattestation?+ public let reattestation: DyldSharedCacheReattestation?public init(verdict: Verdict,@@ -102,7 +102,7 @@ public enum DSCLockdownModePatcher {functionVMA: UInt64? = nil,gateVMA: UInt64? = nil,record: PatchRecord? = nil,- reattestation: DSCReattestation? = nil,+ reattestation: DyldSharedCacheReattestation? = nil,) {self.verdict = verdictself.symbolName = symbolName@@ -132,23 +132,23 @@ public enum DSCLockdownModePatcher {public static func patch(chunksDirectory: URL,dryRun: Bool = false,- log: ((String) -> Void)? = DSCCodeSignature.stderrLog,+ log: ((String) -> Void)? = DyldSharedCacheCodeSignature.stderrLog,) throws -> Outcome {- try patch(in: DSCChunkSet(directory: chunksDirectory), dryRun: dryRun, log: log)+ try patch(in: DyldSharedCacheChunkSet(directory: chunksDirectory), dryRun: dryRun, log: log)}/// Patch an already-open cache.///- /// Writes go through `DSCChunkSet.write(at:_:)`, so the span is recorded+ /// Writes go through `DyldSharedCacheChunkSet.write(at:_:)`, so the span is recorded/// and `reattestRecordedWrites` cannot be handed the wrong address. A/// caller sharing one chunk set across patchers therefore also gets any/// earlier patcher's pages re-attested here, which is a no-op for pages/// that are already correct.@discardableResultpublic static func patch(- in chunks: DSCChunkSet,+ in chunks: DyldSharedCacheChunkSet,dryRun: Bool = false,- log: ((String) -> Void)? = DSCCodeSignature.stderrLog,+ log: ((String) -> Void)? = DyldSharedCacheCodeSignature.stderrLog,) throws -> Outcome {log?(" [.] \(chunks.directory.path) "@@ -204,7 +204,7 @@ public enum DSCLockdownModePatcher {}try chunks.write(at: gate.address, nop)- let reattestation = try DSCCodeSignature.reattestRecordedWrites(in: chunks, log: log)+ let reattestation = try DyldSharedCacheCodeSignature.reattestRecordedWrites(in: chunks, log: log)guard try chunks.bytesAtVMA(gate.address, length: nop.count) == nop else {throw PatcherError.patchVerificationFailed("lockdown_mode: post-write verify failed at 0x\(hex(gate.address))",@@ -229,7 +229,7 @@ public enum DSCLockdownModePatcher {/// A missing symbol is `nil` — the pre-iOS-27 case. A missing or/// unparseable symbol table throws, because "there is nothing to look in"/// must not be reported as "this userland does not have the block".- static func resolveBlockInvoke(in chunks: DSCChunkSet) throws -> (name: String, vma: UInt64)? {+ static func resolveBlockInvoke(in chunks: DyldSharedCacheChunkSet) throws -> (name: String, vma: UInt64)? {for name in symbolCandidates {if let vma = try chunks.resolveLocalSymbol(name) {return (name, vma)@@ -258,9 +258,9 @@ public enum DSCLockdownModePatcher {/// the block and — if a `bl` / `cmn wR,#1` / `b.eq` triple happened to/// appear there — NOP a branch in unrelated code and re-attest that page./// A wrong patch that passes its own signature check is worse than a- /// failed install. `DSCLSDEmbeddedRegPatcher.disassembleFunction` breaks on+ /// failed install. `DyldSharedCacheLSDEmbeddedRegPatcher.disassembleFunction` breaks on/// the same condition for the same reason.- static func disassembleBlock(in chunks: DSCChunkSet, at vma: UInt64) throws -> [Instruction] {+ static func disassembleBlock(in chunks: DyldSharedCacheChunkSet, at vma: UInt64) throws -> [Instruction] {let window = try chunks.readAtVMA(vma, length: maxInstructions * 4, allowShort: true)var decoded: [Instruction] = []for insn in disassembler.disassemble(window, at: vma, count: maxInstructions) {@@ -318,9 +318,9 @@ public enum DSCLockdownModePatcher {for gate: Instruction,original: Data,replacement: Data,- in chunks: DSCChunkSet,+ in chunks: DyldSharedCacheChunkSet,) throws -> PatchRecord {- let span = DSCWriteSpan(vma: gate.address, length: replacement.count)+ let span = DyldSharedCacheWriteSpan(vma: gate.address, length: replacement.count)let (chunkURL, range) = try chunks.fileRange(of: span)return PatchRecord(patchID: "lockdown_mode.sysctl_error_gate",diff --git a/sources/FirmwarePatcher/DSC/Patchers/DSCMaxSlidePatcher.swift b/sources/FirmwarePatcher/DyldSharedCache/Patchers/DyldSharedCacheMaxSlidePatcher.swiftsimilarity index 94%rename from sources/FirmwarePatcher/DSC/Patchers/DSCMaxSlidePatcher.swiftrename to sources/FirmwarePatcher/DyldSharedCache/Patchers/DyldSharedCacheMaxSlidePatcher.swiftindex deb4aac5..8e9e25c6 100644--- a/sources/FirmwarePatcher/DSC/Patchers/DSCMaxSlidePatcher.swift+++ b/sources/FirmwarePatcher/DyldSharedCache/Patchers/DyldSharedCacheMaxSlidePatcher.swift@@ -1,4 +1,4 @@-// DSCMaxSlidePatcher.swift — Clamp the dyld shared cache's recorded maxSlide so+// DyldSharedCacheMaxSlidePatcher.swift — Clamp the dyld shared cache's recorded maxSlide so// a large userland cache fits the PCC vphone600 26.x kernel's fixed 6 GiB// shared region.//@@ -40,13 +40,13 @@// panics, and `research/0_binary_patch_comparison.md` row 10 records the// on-device validation on `17,3_27.0_24A5380h` + cloudOS 26.4.//-// So `DSCCodeSignature.reattestRecordedWrites(in:)` is *not* called here, and+// So `DyldSharedCacheCodeSignature.reattestRecordedWrites(in:)` is *not* called here, and// after this patcher runs the main chunk's page 0 hashes to something its code-// slot no longer claims. `DSCMaxSlidePatcherTests` pins that state rather than+// slot no longer claims. `DyldSharedCacheMaxSlidePatcherTests` pins that state rather than// leaving it as a thing someone has to remember.//// To keep a later batch re-attestation from silently undoing that decision,-// this patcher opens its own `DSCChunkSet` over the directory instead of+// this patcher opens its own `DyldSharedCacheChunkSet` over the directory instead of// borrowing the caller's. Its write is recorded in a chunk set that goes out of// scope with the call, so no caller's `reattestRecordedWrites(in:)` can sweep// the header page up with the code pages it legitimately owns.@@ -67,7 +67,7 @@ import Foundation/// Zeroes `dyld_cache_header.maxSlide` when the cache would otherwise overflow/// the kernel's fixed shared region.-public enum DSCMaxSlidePatcher {+public enum DyldSharedCacheMaxSlidePatcher {// MARK: - Constants/// `SHARED_REGION_SIZE_ARM64` as baked into the PCC vphone600 26.x kernel.@@ -127,11 +127,11 @@ public enum DSCMaxSlidePatcher {case .fits, .alreadyZero:nilcase let .overflow(combined, region):- "overflow: span+maxSlide \(DSCMaxSlidePatcher.hex(combined)) > "- + "region \(DSCMaxSlidePatcher.hex(region))"+ "overflow: span+maxSlide \(DyldSharedCacheMaxSlidePatcher.hex(combined)) > "+ + "region \(DyldSharedCacheMaxSlidePatcher.hex(region))"case let .forced(combined, region):- "forced: span+maxSlide \(DSCMaxSlidePatcher.hex(combined)) fits "- + "region \(DSCMaxSlidePatcher.hex(region)) but --force set"+ "forced: span+maxSlide \(DyldSharedCacheMaxSlidePatcher.hex(combined)) fits "+ + "region \(DyldSharedCacheMaxSlidePatcher.hex(region)) but --force set"}}}@@ -150,7 +150,7 @@ public enum DSCMaxSlidePatcher {/// returns 1 in that case, meaning "this cache needs the patch".public let record: PatchRecord?/// The span that landed on disk, or `nil` on a dry run or a no-op.- public let writtenSpan: DSCWriteSpan?+ public let writtenSpan: DyldSharedCacheWriteSpan?/// Sites patched — the Python function's return value, which is 0 or 1.public var siteCount: Int {@@ -202,7 +202,7 @@ public enum DSCMaxSlidePatcher {// The patcher's own chunk set: see the note at the top of the file about// why its write log must not be the caller's.- let chunks = try DSCChunkSet(directory: chunksDirectory, architecture: architecture)+ let chunks = try DyldSharedCacheChunkSet(directory: chunksDirectory, architecture: architecture)let headerVMA = try headerVMA(of: chunks)let header = try readHeader(from: chunks, at: headerVMA, chunkName: mainChunkName)@@ -311,7 +311,7 @@ public enum DSCMaxSlidePatcher {)}- // No `DSCCodeSignature.reattestRecordedWrites(in: chunks)` here. See the+ // No `DyldSharedCacheCodeSignature.reattestRecordedWrites(in: chunks)` here. See the// file header: this field is kernel-read cache metadata, not a// cs_validate'd code page, and leaving the slot alone is the behaviour// that was validated on device.@@ -343,7 +343,7 @@ public enum DSCMaxSlidePatcher {/// Derived from the mapping table rather than written down: the header lives/// at file offset 0 of the unsuffixed chunk, so the mapping that carries/// file offset 0 of that chunk is the one that carries the header.- static func headerVMA(of chunks: DSCChunkSet) throws -> UInt64 {+ static func headerVMA(of chunks: DyldSharedCacheChunkSet) throws -> UInt64 {let main = chunks.mainCacheURLguard let mapping = chunks.mappings.first(where: {$0.chunkURL == main && $0.fileOffset == 0@@ -370,7 +370,7 @@ public enum DSCMaxSlidePatcher {/// 0x17D500000 span). If they did not, the offsets would be describing/// some other struct and the write would land in an unknown field.static func readHeader(- from chunks: DSCChunkSet,+ from chunks: DyldSharedCacheChunkSet,at headerVMA: UInt64,chunkName: String,) throws -> Header {diff --git a/sources/FirmwarePatcher/DSC/Patchers/DSCXPCLWCRPatcher.swift b/sources/FirmwarePatcher/DyldSharedCache/Patchers/DyldSharedCacheXPCLWCRPatcher.swiftsimilarity index 96%rename from sources/FirmwarePatcher/DSC/Patchers/DSCXPCLWCRPatcher.swiftrename to sources/FirmwarePatcher/DyldSharedCache/Patchers/DyldSharedCacheXPCLWCRPatcher.swiftindex cf1d1935..4413910a 100644--- a/sources/FirmwarePatcher/DSC/Patchers/DSCXPCLWCRPatcher.swift+++ b/sources/FirmwarePatcher/DyldSharedCache/Patchers/DyldSharedCacheXPCLWCRPatcher.swift@@ -1,4 +1,4 @@-// DSCXPCLWCRPatcher.swift — libxpc's Lightweight Code Requirement self-check.+// DyldSharedCacheXPCLWCRPatcher.swift — libxpc's Lightweight Code Requirement self-check.//// Swift port of `scripts/patchers/cfw_patch_xpc_lwcr.py` (`cfw.py// patch-xpc-lwcr`). See research/0_binary_patch_comparison.md #15.@@ -45,7 +45,7 @@// cache's own local-symbol table, the function is disassembled with Capstone,// the check is located by the shape of its control flow, and every replacement// word comes from `ARM64Encoder` / `ARM64`. The pages the writes dirty are-// re-attested through `DSCCodeSignature`, because TXM validates the shared+// re-attested through `DyldSharedCacheCodeSignature`, because TXM validates the shared// cache per 16 KiB page; the resulting cdHash change is accepted by the JB's// always-true AMFI cdhash-trust patch.@@ -53,7 +53,7 @@ import Capstoneimport Foundation/// Patches `_xpc_token_satisfies_lwcr` in the shared cache's libxpc.-public enum DSCXPCLWCRPatcher {+public enum DyldSharedCacheXPCLWCRPatcher {/// The source-level name of the function this patches.public static let symbol = "_xpc_token_satisfies_lwcr"@@ -116,9 +116,9 @@ public enum DSCXPCLWCRPatcher {public static func apply(directory: URL,dryRun: Bool = false,- log: ((String) -> Void)? = DSCCodeSignature.stderrLog,+ log: ((String) -> Void)? = DyldSharedCacheCodeSignature.stderrLog,) throws -> Outcome {- let chunks = try DSCChunkSet(directory: directory)+ let chunks = try DyldSharedCacheChunkSet(directory: directory)return try apply(chunks: chunks, dryRun: dryRun, log: log)}@@ -131,9 +131,9 @@ public enum DSCXPCLWCRPatcher {/// patcher calls `clearRecordedWrites()` between them.@discardableResultpublic static func apply(- chunks: DSCChunkSet,+ chunks: DyldSharedCacheChunkSet,dryRun: Bool = false,- log: ((String) -> Void)? = DSCCodeSignature.stderrLog,+ log: ((String) -> Void)? = DyldSharedCacheCodeSignature.stderrLog,) throws -> Outcome {log?(" [.] \(chunks.directory.path) — \(chunks.chunkURLs.count) chunk(s), "+ "\(chunks.mappings.count) mapping(s)")@@ -226,7 +226,7 @@ public enum DSCXPCLWCRPatcher {if wrote {log?(" [.] re-attesting modified page(s)...")- try DSCCodeSignature.reattestRecordedWrites(in: chunks, dryRun: false, log: log)+ try DyldSharedCacheCodeSignature.reattestRecordedWrites(in: chunks, dryRun: false, log: log)for edit in edits {let readBack = try chunks.bytesAtVMA(edit.address, length: edit.bytes.count)guard readBack == edit.bytes else {@@ -364,7 +364,7 @@ public enum DSCXPCLWCRPatcher {/// end of its mapping still disassembles as far as the mapping goes,/// instead of failing the whole patch on a window that overshoots.static func disassembleFunction(- in chunks: DSCChunkSet,+ in chunks: DyldSharedCacheChunkSet,at vma: UInt64,disassembler: ARM64Disassembler,) throws -> [Instruction] {diff --git a/sources/FirmwarePatcher/IBoot/Patches/IBootPatchBootArgs.swift b/sources/FirmwarePatcher/IBoot/BasePatches/IBootPatchBootArgs.swiftsimilarity index 100%rename from sources/FirmwarePatcher/IBoot/Patches/IBootPatchBootArgs.swiftrename to sources/FirmwarePatcher/IBoot/BasePatches/IBootPatchBootArgs.swiftdiff --git a/sources/FirmwarePatcher/IBoot/Patches/IBootPatchBootxPrecondition.swift b/sources/FirmwarePatcher/IBoot/BasePatches/IBootPatchBootxPrecondition.swiftsimilarity index 100%rename from sources/FirmwarePatcher/IBoot/Patches/IBootPatchBootxPrecondition.swiftrename to sources/FirmwarePatcher/IBoot/BasePatches/IBootPatchBootxPrecondition.swiftdiff --git a/sources/FirmwarePatcher/IBoot/Patches/IBootPatchImage4Callback.swift b/sources/FirmwarePatcher/IBoot/BasePatches/IBootPatchImage4Callback.swiftsimilarity index 100%rename from sources/FirmwarePatcher/IBoot/Patches/IBootPatchImage4Callback.swiftrename to sources/FirmwarePatcher/IBoot/BasePatches/IBootPatchImage4Callback.swiftdiff --git a/sources/FirmwarePatcher/IBoot/Patches/IBootPatchPanicBypass.swift b/sources/FirmwarePatcher/IBoot/BasePatches/IBootPatchPanicBypass.swiftsimilarity index 100%rename from sources/FirmwarePatcher/IBoot/Patches/IBootPatchPanicBypass.swiftrename to sources/FirmwarePatcher/IBoot/BasePatches/IBootPatchPanicBypass.swiftdiff --git a/sources/FirmwarePatcher/IBoot/Patches/IBootPatchRootfsBypass.swift b/sources/FirmwarePatcher/IBoot/BasePatches/IBootPatchRootfsBypass.swiftsimilarity index 100%rename from sources/FirmwarePatcher/IBoot/Patches/IBootPatchRootfsBypass.swiftrename to sources/FirmwarePatcher/IBoot/BasePatches/IBootPatchRootfsBypass.swiftdiff --git a/sources/FirmwarePatcher/IBoot/Patches/IBootPatchSerialLabels.swift b/sources/FirmwarePatcher/IBoot/BasePatches/IBootPatchSerialLabels.swiftsimilarity index 100%rename from sources/FirmwarePatcher/IBoot/Patches/IBootPatchSerialLabels.swiftrename to sources/FirmwarePatcher/IBoot/BasePatches/IBootPatchSerialLabels.swiftdiff --git a/sources/FirmwarePatcher/IBoot/IBootJBPatcher.swift b/sources/FirmwarePatcher/IBoot/IBootJailbreakPatcher.swiftsimilarity index 98%rename from sources/FirmwarePatcher/IBoot/IBootJBPatcher.swiftrename to sources/FirmwarePatcher/IBoot/IBootJailbreakPatcher.swiftindex 1a0d686f..72e404a8 100644--- a/sources/FirmwarePatcher/IBoot/IBootJBPatcher.swift+++ b/sources/FirmwarePatcher/IBoot/IBootJailbreakPatcher.swift@@ -1,4 +1,4 @@-// IBootJBPatcher.swift — JB-variant iBoot patcher (nonce bypass).+// IBootJailbreakPatcher.swift — JB-variant iBoot patcher (nonce bypass).//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.@@ -10,7 +10,7 @@ import Foundation/// Adds iBSS-only patches:/// 1. patchSkipGenerateNonce — locate "boot-nonce" ADRP+ADD refs, find/// tbz w0, #0, <target> / mov w0, #0 / bl pattern, convert tbz → b <target>-public final class IBootJBPatcher: IBootPatcher {+public final class IBootJailbreakPatcher: IBootPatcher {override public func findAll() throws -> [PatchRecord] {patches = []if mode == .ibss {diff --git a/sources/FirmwarePatcher/Kernel/Patches/KernelPatchApfsGraft.swift b/sources/FirmwarePatcher/Kernel/BasePatches/KernelPatchApfsGraft.swiftsimilarity index 100%rename from sources/FirmwarePatcher/Kernel/Patches/KernelPatchApfsGraft.swiftrename to sources/FirmwarePatcher/Kernel/BasePatches/KernelPatchApfsGraft.swiftdiff --git a/sources/FirmwarePatcher/Kernel/Patches/KernelPatchApfsMount.swift b/sources/FirmwarePatcher/Kernel/BasePatches/KernelPatchApfsMount.swiftsimilarity index 100%rename from sources/FirmwarePatcher/Kernel/Patches/KernelPatchApfsMount.swiftrename to sources/FirmwarePatcher/Kernel/BasePatches/KernelPatchApfsMount.swiftdiff --git a/sources/FirmwarePatcher/Kernel/Patches/KernelPatchApfsSeal.swift b/sources/FirmwarePatcher/Kernel/BasePatches/KernelPatchApfsSeal.swiftsimilarity index 100%rename from sources/FirmwarePatcher/Kernel/Patches/KernelPatchApfsSeal.swiftrename to sources/FirmwarePatcher/Kernel/BasePatches/KernelPatchApfsSeal.swiftdiff --git a/sources/FirmwarePatcher/Kernel/Patches/KernelPatchApfsSnapshot.swift b/sources/FirmwarePatcher/Kernel/BasePatches/KernelPatchApfsSnapshot.swiftsimilarity index 100%rename from sources/FirmwarePatcher/Kernel/Patches/KernelPatchApfsSnapshot.swiftrename to sources/FirmwarePatcher/Kernel/BasePatches/KernelPatchApfsSnapshot.swiftdiff --git a/sources/FirmwarePatcher/Kernel/Patches/KernelPatchBsdInit.swift b/sources/FirmwarePatcher/Kernel/BasePatches/KernelPatchBsdInit.swiftsimilarity index 100%rename from sources/FirmwarePatcher/Kernel/Patches/KernelPatchBsdInit.swiftrename to sources/FirmwarePatcher/Kernel/BasePatches/KernelPatchBsdInit.swiftdiff --git a/sources/FirmwarePatcher/Kernel/Patches/KernelPatchDebugger.swift b/sources/FirmwarePatcher/Kernel/BasePatches/KernelPatchDebugger.swiftsimilarity index 100%rename from sources/FirmwarePatcher/Kernel/Patches/KernelPatchDebugger.swiftrename to sources/FirmwarePatcher/Kernel/BasePatches/KernelPatchDebugger.swiftdiff --git a/sources/FirmwarePatcher/Kernel/Patches/KernelPatchDyldPolicy.swift b/sources/FirmwarePatcher/Kernel/BasePatches/KernelPatchDyldPolicy.swiftsimilarity index 100%rename from sources/FirmwarePatcher/Kernel/Patches/KernelPatchDyldPolicy.swiftrename to sources/FirmwarePatcher/Kernel/BasePatches/KernelPatchDyldPolicy.swiftdiff --git a/sources/FirmwarePatcher/Kernel/Patches/KernelPatchExcGuard.swift b/sources/FirmwarePatcher/Kernel/BasePatches/KernelPatchExcGuard.swiftsimilarity index 100%rename from sources/FirmwarePatcher/Kernel/Patches/KernelPatchExcGuard.swiftrename to sources/FirmwarePatcher/Kernel/BasePatches/KernelPatchExcGuard.swiftdiff --git a/sources/FirmwarePatcher/Kernel/Patches/KernelPatchLaunchConstraints.swift b/sources/FirmwarePatcher/Kernel/BasePatches/KernelPatchLaunchConstraints.swiftsimilarity index 100%rename from sources/FirmwarePatcher/Kernel/Patches/KernelPatchLaunchConstraints.swiftrename to sources/FirmwarePatcher/Kernel/BasePatches/KernelPatchLaunchConstraints.swiftdiff --git a/sources/FirmwarePatcher/Kernel/Patches/KernelPatchPostValidation.swift b/sources/FirmwarePatcher/Kernel/BasePatches/KernelPatchPostValidation.swiftsimilarity index 100%rename from sources/FirmwarePatcher/Kernel/Patches/KernelPatchPostValidation.swiftrename to sources/FirmwarePatcher/Kernel/BasePatches/KernelPatchPostValidation.swiftdiff --git a/sources/FirmwarePatcher/Kernel/Patches/KernelPatchSandbox.swift b/sources/FirmwarePatcher/Kernel/BasePatches/KernelPatchSandbox.swiftsimilarity index 100%rename from sources/FirmwarePatcher/Kernel/Patches/KernelPatchSandbox.swiftrename to sources/FirmwarePatcher/Kernel/BasePatches/KernelPatchSandbox.swiftdiff --git a/sources/FirmwarePatcher/Kernel/EXPPatches/KernelEXPPatchHvVmmRename.swift b/sources/FirmwarePatcher/Kernel/ExperimentalPatches/KernelExperimentalPatchHvVmmRename.swiftsimilarity index 99%rename from sources/FirmwarePatcher/Kernel/EXPPatches/KernelEXPPatchHvVmmRename.swiftrename to sources/FirmwarePatcher/Kernel/ExperimentalPatches/KernelExperimentalPatchHvVmmRename.swiftindex fcffd9e6..3ce05dd3 100644--- a/sources/FirmwarePatcher/Kernel/EXPPatches/KernelEXPPatchHvVmmRename.swift+++ b/sources/FirmwarePatcher/Kernel/ExperimentalPatches/KernelExperimentalPatchHvVmmRename.swift@@ -1,4 +1,4 @@-// KernelEXPPatchHvVmmRename.swift — EXP kernel patch: rename the+// KernelExperimentalPatchHvVmmRename.swift — EXP kernel patch: rename the// `hv_vmm_present` sysctl OID name AND mangle every kernel-internal// `kern.hv_vmm_present` caller cstring so they keep working after the// rename.@@ -76,7 +76,7 @@import Foundation-extension KernelEXPPatcher {+extension KernelExperimentalPatcher {/// Apply Part A (OID rename) + Part B (kernel-internal caller/// byte-5 mangle). Returns true if any byte was modified.@discardableResultdiff --git a/sources/FirmwarePatcher/Kernel/JBPatches/CodeSigning/KernelJBPatchAmfiExecve.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/CodeSigning/KernelJailbreakPatchAmfiExecve.swiftsimilarity index 96%rename from sources/FirmwarePatcher/Kernel/JBPatches/CodeSigning/KernelJBPatchAmfiExecve.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/CodeSigning/KernelJailbreakPatchAmfiExecve.swiftindex e71cea9b..3362c7e2 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/CodeSigning/KernelJBPatchAmfiExecve.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/CodeSigning/KernelJailbreakPatchAmfiExecve.swift@@ -1,4 +1,4 @@-// KernelJBPatchAmfiExecve.swift — JB kernel patch: AMFI execve kill path bypass (disabled)+// KernelJailbreakPatchAmfiExecve.swift — JB kernel patch: AMFI execve kill path bypass (disabled)//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.//@@ -13,7 +13,7 @@import Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {// MARK: - AMFI execve kill-path bypass (disabled)/// Bypass AMFI execve kill by patching the shared MOV W0,#1 → MOV W0,#0.diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/CodeSigning/KernelJBPatchAmfiTrustcache.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/CodeSigning/KernelJailbreakPatchAmfiTrustcache.swiftsimilarity index 97%rename from sources/FirmwarePatcher/Kernel/JBPatches/CodeSigning/KernelJBPatchAmfiTrustcache.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/CodeSigning/KernelJailbreakPatchAmfiTrustcache.swiftindex 024c05b3..816331c7 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/CodeSigning/KernelJBPatchAmfiTrustcache.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/CodeSigning/KernelJailbreakPatchAmfiTrustcache.swift@@ -1,4 +1,4 @@-// KernelJBPatchAmfiTrustcache.swift — JB kernel patch: AMFI trustcache gate bypass+// KernelJailbreakPatchAmfiTrustcache.swift — JB kernel patch: AMFI trustcache gate bypass//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.//@@ -17,7 +17,7 @@import Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {/// AMFI trustcache gate bypass: rewrite AMFIIsCDHashInTrustCache to always return 1.@discardableResultfunc patchAmfiCdhashInTrustcache() -> Bool {diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/CodeSigning/KernelJBPatchCredLabel.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/CodeSigning/KernelJailbreakPatchCredLabel.swiftsimilarity index 99%rename from sources/FirmwarePatcher/Kernel/JBPatches/CodeSigning/KernelJBPatchCredLabel.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/CodeSigning/KernelJailbreakPatchCredLabel.swiftindex 72ed9938..9435e458 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/CodeSigning/KernelJBPatchCredLabel.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/CodeSigning/KernelJailbreakPatchCredLabel.swift@@ -1,4 +1,4 @@-// KernelJBPatchCredLabel.swift — JB kernel patch: _cred_label_update_execve C21-v3+// KernelJailbreakPatchCredLabel.swift — JB kernel patch: _cred_label_update_execve C21-v3//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.//@@ -16,7 +16,7 @@import Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {// MARK: - Constantsprivate static let retInsns: Set<UInt32> = [0xD65F_0FFF, 0xD65F_0BFF, 0xD65F_03C0]diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/CodeSigning/KernelJBPatchHookCredLabel.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/CodeSigning/KernelJailbreakPatchHookCredLabel.swiftsimilarity index 99%rename from sources/FirmwarePatcher/Kernel/JBPatches/CodeSigning/KernelJBPatchHookCredLabel.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/CodeSigning/KernelJailbreakPatchHookCredLabel.swiftindex e8b14e22..4505c481 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/CodeSigning/KernelJBPatchHookCredLabel.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/CodeSigning/KernelJailbreakPatchHookCredLabel.swift@@ -1,4 +1,4 @@-// KernelJBPatchHookCredLabel.swift — JB kernel patch: Faithful upstream C23 hook+// KernelJailbreakPatchHookCredLabel.swift — JB kernel patch: Faithful upstream C23 hook//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.//@@ -17,7 +17,7 @@import Capstoneimport Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {// MARK: - Constantsprivate static let hookCredLabelIndex = 18diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/CodeSigning/KernelJBPatchLoadDylinker.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/CodeSigning/KernelJailbreakPatchLoadDylinker.swiftsimilarity index 95%rename from sources/FirmwarePatcher/Kernel/JBPatches/CodeSigning/KernelJBPatchLoadDylinker.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/CodeSigning/KernelJailbreakPatchLoadDylinker.swiftindex c050e913..fcb44ad9 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/CodeSigning/KernelJBPatchLoadDylinker.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/CodeSigning/KernelJailbreakPatchLoadDylinker.swift@@ -1,4 +1,4 @@-// KernelJBPatchLoadDylinker.swift — JB: bypass load_dylinker policy gate in the dyld path.+// KernelJailbreakPatchLoadDylinker.swift — JB: bypass load_dylinker policy gate in the dyld path.//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.//@@ -8,7 +8,7 @@import Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {/// Bypass the load_dylinker policy gate in the dyld path.@discardableResultfunc patchLoadDylinker() -> Bool {diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/CodeSigning/KernelJBPatchPostValidation.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/CodeSigning/KernelJailbreakPatchPostValidation.swiftsimilarity index 97%rename from sources/FirmwarePatcher/Kernel/JBPatches/CodeSigning/KernelJBPatchPostValidation.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/CodeSigning/KernelJailbreakPatchPostValidation.swiftindex 971396ac..b69a8882 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/CodeSigning/KernelJBPatchPostValidation.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/CodeSigning/KernelJailbreakPatchPostValidation.swift@@ -1,4 +1,4 @@-// KernelJBPatchPostValidation.swift — JB: additional post-validation cmp w0,w0 bypass.+// KernelJailbreakPatchPostValidation.swift — JB: additional post-validation cmp w0,w0 bypass.//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.//@@ -9,7 +9,7 @@import Capstoneimport Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {/// Patch: rewrite the SHA256-only reject compare in AMFI's post-validation path.@discardableResultfunc patchPostValidationAdditional() -> Bool {diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Drivers/KernelJBPatchIomfbSwap.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Drivers/KernelJailbreakPatchIomfbSwap.swiftsimilarity index 98%rename from sources/FirmwarePatcher/Kernel/JBPatches/Drivers/KernelJBPatchIomfbSwap.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Drivers/KernelJailbreakPatchIomfbSwap.swiftindex 66cd9ed6..c74f77b7 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Drivers/KernelJBPatchIomfbSwap.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Drivers/KernelJailbreakPatchIomfbSwap.swift@@ -1,4 +1,4 @@-// KernelJBPatchIomfbSwap.swift — JB kernel patch: make the IOMobileFramebuffer+// KernelJailbreakPatchIomfbSwap.swift — JB kernel patch: make the IOMobileFramebuffer// SwapEnd userclient accept the caller's native swap-struct size.//// Background: iOS 27's `_kern_SwapEnd` sends a 0x6e0-byte IOMFBSwapRec, but the@@ -28,7 +28,7 @@import Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {private static let swapEndExpectedSize: UInt32 = 0x588 // 26.4 kernel's native SwapEnd struct sizeprivate static let swapEndIOS27Size: UInt32 = 0x6E0 // iOS 27's native IOMFBSwapRec sizeprivate static let kIOUCVariableStructureSize: UInt32 = 0xFFFF_FFFFdiff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Drivers/KernelJBPatchNvram.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Drivers/KernelJailbreakPatchNvram.swiftsimilarity index 95%rename from sources/FirmwarePatcher/Kernel/JBPatches/Drivers/KernelJBPatchNvram.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Drivers/KernelJailbreakPatchNvram.swiftindex 59603f5c..decfacea 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Drivers/KernelJBPatchNvram.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Drivers/KernelJailbreakPatchNvram.swift@@ -1,10 +1,10 @@-// KernelJBPatchNvram.swift — JB kernel patch: NVRAM permission bypass+// KernelJailbreakPatchNvram.swift — JB kernel patch: NVRAM permission bypass//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.import Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {/// NOP the verifyPermission gate in the `krn.` key-prefix path.////// Runtime reveal is string-anchored only: enumerate code refs to `"krn."`,diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Frida/KernelJBPatchThreadSetState.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Frida/KernelJailbreakPatchThreadSetState.swiftsimilarity index 96%rename from sources/FirmwarePatcher/Kernel/JBPatches/Frida/KernelJBPatchThreadSetState.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Frida/KernelJailbreakPatchThreadSetState.swiftindex ee654abb..23032921 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Frida/KernelJBPatchThreadSetState.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Frida/KernelJailbreakPatchThreadSetState.swift@@ -1,14 +1,14 @@-// KernelJBPatchThreadSetState.swift — optional Frida Stalker support (--frida).+// KernelJailbreakPatchThreadSetState.swift — optional Frida Stalker support (--frida).//// Frida follows an existing thread via thread_set_state_from_user, whose flags// carry TSSF_CHECK_ENTITLEMENT and trip GUARD_TYPE_MACH_PORT. Clear that bit in the// user setters (`mov w6,#0x201` → `mov w6,#0x1`) rather than the check itself.-// Reveal + validation: research/kernel_patch_jb/patch_thread_set_state.md.+// Reveal + validation: research/kernel_jailbreak_patches/patch_thread_set_state.md.import Capstoneimport Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {private static let tssEntitlement = "com.apple.private.thread-set-state"// TSSF_TRANSLATE_TO_USER (0x1) | TSSF_CHECK_ENTITLEMENT (0x200).private static let tssFlagsFromUser: Int64 = 0x201diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Frida/KernelJBPatchVmMapDelete.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Frida/KernelJailbreakPatchVmMapDelete.swiftsimilarity index 97%rename from sources/FirmwarePatcher/Kernel/JBPatches/Frida/KernelJBPatchVmMapDelete.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Frida/KernelJailbreakPatchVmMapDelete.swiftindex bea567d7..9a418aa4 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Frida/KernelJBPatchVmMapDelete.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Frida/KernelJailbreakPatchVmMapDelete.swift@@ -1,15 +1,15 @@-// KernelJBPatchVmMapDelete.swift — optional Frida Stalker support (--frida).+// KernelJailbreakPatchVmMapDelete.swift — optional Frida Stalker support (--frida).//// Frida's write-then-flip leaves a permanent CSM mapping at current RW / max RWX;// vm_map_delete's immutable-code exception tests current-protection EXECUTE, which// is clear, so re-instrumentation fails with KERN_PROTECTION_FAILURE. Retarget the// test from current-X (packed [entry,#0x38] bit 9) to max-X (bit 13).-// Reveal + validation: research/kernel_patch_jb/patch_vm_map_delete_immutable_code.md.+// Reveal + validation: research/kernel_jailbreak_patches/patch_vm_map_delete_immutable_code.md.import Capstoneimport Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {private struct VmMapDeleteGate {let offset: Intlet register: UInt32diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Memory/KernelJBPatchPortToMap.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Memory/KernelJailbreakPatchPortToMap.swiftsimilarity index 94%rename from sources/FirmwarePatcher/Kernel/JBPatches/Memory/KernelJBPatchPortToMap.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Memory/KernelJailbreakPatchPortToMap.swiftindex 3f001e20..24ea93ba 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Memory/KernelJBPatchPortToMap.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Memory/KernelJailbreakPatchPortToMap.swift@@ -1,4 +1,4 @@-// KernelJBPatchPortToMap.swift — JB: skip kernel-map panic in _convert_port_to_map_with_flavor.+// KernelJailbreakPatchPortToMap.swift — JB: skip kernel-map panic in _convert_port_to_map_with_flavor.//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.//@@ -8,7 +8,7 @@import Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {/// Skip kernel-map panic in _convert_port_to_map_with_flavor.@discardableResultfunc patchConvertPortToMap() -> Bool {diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Memory/KernelJBPatchSharedRegion.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Memory/KernelJailbreakPatchSharedRegion.swiftsimilarity index 96%rename from sources/FirmwarePatcher/Kernel/JBPatches/Memory/KernelJBPatchSharedRegion.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Memory/KernelJailbreakPatchSharedRegion.swiftindex 1477088a..b8a66a21 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Memory/KernelJBPatchSharedRegion.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Memory/KernelJailbreakPatchSharedRegion.swift@@ -1,11 +1,11 @@-// KernelJBPatchSharedRegion.swift — JB kernel patch: Shared region map bypass+// KernelJailbreakPatchSharedRegion.swift — JB kernel patch: Shared region map bypass//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.import Capstoneimport Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {/// Force `cmp x0, x0` in the root-vs-preboot gate of/// `_shared_region_map_and_slide_setup`.///diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Memory/KernelJBPatchVmFault.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Memory/KernelJailbreakPatchVmFault.swiftsimilarity index 97%rename from sources/FirmwarePatcher/Kernel/JBPatches/Memory/KernelJBPatchVmFault.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Memory/KernelJailbreakPatchVmFault.swiftindex 6e270ee6..7d6aed3d 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Memory/KernelJBPatchVmFault.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Memory/KernelJailbreakPatchVmFault.swift@@ -1,11 +1,11 @@-// KernelJBPatchVmFault.swift — JB kernel patch: VM fault enter prepare bypass+// KernelJailbreakPatchVmFault.swift — JB kernel patch: VM fault enter prepare bypass//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.import Capstoneimport Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {/// Force the upstream cs_bypass fast-path in `_vm_fault_enter_prepare`.////// Expected semantic shape:diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Memory/KernelJBPatchVmProtect.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Memory/KernelJailbreakPatchVmProtect.swiftsimilarity index 99%rename from sources/FirmwarePatcher/Kernel/JBPatches/Memory/KernelJBPatchVmProtect.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Memory/KernelJailbreakPatchVmProtect.swiftindex bb2a4d73..5ebe5851 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Memory/KernelJBPatchVmProtect.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Memory/KernelJailbreakPatchVmProtect.swift@@ -1,4 +1,4 @@-// KernelJBPatchVmProtect.swift — JB kernel patch: VM map protect W^X bypass+// KernelJailbreakPatchVmProtect.swift — JB kernel patch: VM map protect W^X bypass//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.//@@ -39,7 +39,7 @@import Capstoneimport Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {/// Bypass the vm_map_protect W^X downgrade so write+execute protections are honored.@discardableResultfunc patchVmMapProtect() -> Bool {diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Process/KernelJBPatchKcall10.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Process/KernelJailbreakPatchKcall10.swiftsimilarity index 99%rename from sources/FirmwarePatcher/Kernel/JBPatches/Process/KernelJBPatchKcall10.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Process/KernelJailbreakPatchKcall10.swiftindex 1ee74762..f84b60b6 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Process/KernelJBPatchKcall10.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Process/KernelJailbreakPatchKcall10.swift@@ -1,4 +1,4 @@-// KernelJBPatchKcall10.swift — JB kernel patch: kcall10 ABI-correct sysent[439] cave+// KernelJailbreakPatchKcall10.swift — JB kernel patch: kcall10 ABI-correct sysent[439] cave//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.//@@ -13,7 +13,7 @@import Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {// MARK: - Constantsprivate static let sysent_max_entries = 558diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Process/KernelJBPatchProcPidinfo.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Process/KernelJailbreakPatchProcPidinfo.swiftsimilarity index 96%rename from sources/FirmwarePatcher/Kernel/JBPatches/Process/KernelJBPatchProcPidinfo.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Process/KernelJailbreakPatchProcPidinfo.swiftindex a7450452..84c867d6 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Process/KernelJBPatchProcPidinfo.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Process/KernelJailbreakPatchProcPidinfo.swift@@ -1,4 +1,4 @@-// KernelJBPatchProcPidinfo.swift — JB: NOP the two early pid-0 guards in proc_pidinfo.+// KernelJailbreakPatchProcPidinfo.swift — JB: NOP the two early pid-0 guards in proc_pidinfo.//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.//@@ -19,7 +19,7 @@import Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {/// Bypass the two early pid-0 guards in the inlined proc_pidinfo path.@discardableResultfunc patchProcPidinfo() -> Bool {diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Process/KernelJBPatchSpawnPersona.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Process/KernelJailbreakPatchSpawnPersona.swiftsimilarity index 98%rename from sources/FirmwarePatcher/Kernel/JBPatches/Process/KernelJBPatchSpawnPersona.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Process/KernelJailbreakPatchSpawnPersona.swiftindex e85bd238..319c2188 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Process/KernelJBPatchSpawnPersona.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Process/KernelJailbreakPatchSpawnPersona.swift@@ -1,11 +1,11 @@-// KernelJBPatchSpawnPersona.swift — JB kernel patch: Spawn validate persona bypass+// KernelJailbreakPatchSpawnPersona.swift — JB kernel patch: Spawn validate persona bypass//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.import Capstoneimport Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {/// NOP the upstream dual-CBZ bypass in the persona helper.////// 1. Recover the outer spawn policy function fromdiff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Process/KernelJBPatchSyscallmask.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Process/KernelJailbreakPatchSyscallmask.swiftsimilarity index 99%rename from sources/FirmwarePatcher/Kernel/JBPatches/Process/KernelJBPatchSyscallmask.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Process/KernelJailbreakPatchSyscallmask.swiftindex cf8a9eac..6d76229d 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Process/KernelJBPatchSyscallmask.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Process/KernelJailbreakPatchSyscallmask.swift@@ -1,4 +1,4 @@-// KernelJBPatchSyscallmask.swift — JB kernel patch: syscallmask C22 apply-to-proc+// KernelJailbreakPatchSyscallmask.swift — JB kernel patch: syscallmask C22 apply-to-proc//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.//@@ -17,7 +17,7 @@import Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {// MARK: - Constantsprivate static let syscallmaskFFBlobSize = 0x100diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Process/KernelJBPatchTaskConversion.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Process/KernelJailbreakPatchTaskConversion.swiftsimilarity index 97%rename from sources/FirmwarePatcher/Kernel/JBPatches/Process/KernelJBPatchTaskConversion.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Process/KernelJailbreakPatchTaskConversion.swiftindex 863b1bdc..901d050a 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Process/KernelJBPatchTaskConversion.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Process/KernelJailbreakPatchTaskConversion.swift@@ -1,4 +1,4 @@-// KernelJBPatchTaskConversion.swift — JB kernel patch: Task conversion eval bypass+// KernelJailbreakPatchTaskConversion.swift — JB kernel patch: Task conversion eval bypass//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.//@@ -23,7 +23,7 @@import Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {/// Task conversion eval bypass: patch the guard CMP to always be equal.@discardableResultfunc patchTaskConversionEvalInternal() -> Bool {diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Process/KernelJBPatchTaskForPid.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Process/KernelJailbreakPatchTaskForPid.swiftsimilarity index 98%rename from sources/FirmwarePatcher/Kernel/JBPatches/Process/KernelJBPatchTaskForPid.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Process/KernelJailbreakPatchTaskForPid.swiftindex 9431aa40..a38e3953 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Process/KernelJBPatchTaskForPid.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Process/KernelJailbreakPatchTaskForPid.swift@@ -1,11 +1,11 @@-// KernelJBPatchTaskForPid.swift — JB kernel patch: task_for_pid bypass+// KernelJailbreakPatchTaskForPid.swift — JB kernel patch: task_for_pid bypass//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.import Capstoneimport Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {/// NOP the upstream early `pid == 0` reject gate in `task_for_pid`.////// Anchor: `proc_ro_ref_task` string → enclosing function.diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Process/KernelJBPatchThidCrash.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Process/KernelJailbreakPatchThidCrash.swiftsimilarity index 95%rename from sources/FirmwarePatcher/Kernel/JBPatches/Process/KernelJBPatchThidCrash.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Process/KernelJailbreakPatchThidCrash.swiftindex 82e69a40..57d61c7a 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Process/KernelJBPatchThidCrash.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Process/KernelJailbreakPatchThidCrash.swift@@ -1,10 +1,10 @@-// KernelJBPatchThidCrash.swift — JB kernel patch: thid_should_crash bypass+// KernelJailbreakPatchThidCrash.swift — JB kernel patch: thid_should_crash bypass//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.import Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {/// Zero out `_thid_should_crash` via the nearby sysctl metadata.////// The raw PCC 26.1 kernels do not provide a usable runtime symbol table,diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Sandbox/KernelJBPatchContainerUpcall.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Sandbox/KernelJailbreakPatchContainerUpcall.swiftsimilarity index 97%rename from sources/FirmwarePatcher/Kernel/JBPatches/Sandbox/KernelJBPatchContainerUpcall.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Sandbox/KernelJailbreakPatchContainerUpcall.swiftindex 6e690734..3db782d6 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Sandbox/KernelJBPatchContainerUpcall.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Sandbox/KernelJailbreakPatchContainerUpcall.swift@@ -1,4 +1,4 @@-// KernelJBPatchContainerUpcall.swift — JB kernel patch: force the sandbox exec-time+// KernelJailbreakPatchContainerUpcall.swift — JB kernel patch: force the sandbox exec-time// container-manager upcall onto its success path (neutralize the autobox / kill).//// At exec, the sandbox hook `_hook_cred_label_update_execve` resolves each process's@@ -39,7 +39,7 @@import Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {@discardableResultfunc patchContainerManagerUpcall() -> Bool {log("\n[JB] container-manager exec upcall: cbz w0 -> b (force success; skip autobox/temporary-sandbox)")diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Sandbox/KernelJBPatchExecPolicyKill.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Sandbox/KernelJailbreakPatchExecPolicyKill.swiftsimilarity index 97%rename from sources/FirmwarePatcher/Kernel/JBPatches/Sandbox/KernelJBPatchExecPolicyKill.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Sandbox/KernelJailbreakPatchExecPolicyKill.swiftindex f35f5965..055c5e9d 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Sandbox/KernelJBPatchExecPolicyKill.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Sandbox/KernelJailbreakPatchExecPolicyKill.swift@@ -1,4 +1,4 @@-// KernelJBPatchExecPolicyKill.swift — JB kernel patch: neutralize the exec-time+// KernelJailbreakPatchExecPolicyKill.swift — JB kernel patch: neutralize the exec-time// MAC-verdict (ip_mac_return) security-policy kill.//// After the MAC exec hooks run, XNU's exec path (kern_exec.c) checks:@@ -30,7 +30,7 @@import Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {@discardableResultfunc patchExecSecurityPolicyKill() -> Bool {log("\n[JB] exec ip_mac_return SECURITY_POLICY kill: cbz -> b (allow)")diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Sandbox/KernelJBPatchFpfsScopedOpen.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Sandbox/KernelJailbreakPatchFpfsScopedOpen.swiftsimilarity index 96%rename from sources/FirmwarePatcher/Kernel/JBPatches/Sandbox/KernelJBPatchFpfsScopedOpen.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Sandbox/KernelJailbreakPatchFpfsScopedOpen.swiftindex ab09ea70..8d55aa78 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Sandbox/KernelJBPatchFpfsScopedOpen.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Sandbox/KernelJailbreakPatchFpfsScopedOpen.swift@@ -1,15 +1,15 @@-// KernelJBPatchFpfsScopedOpen.swift — iOS 27 only.+// KernelJailbreakPatchFpfsScopedOpen.swift — iOS 27 only.//// The JB neuters Sandbox vnode_check_open globally so processes can reach /var/jb. But// FileProvider's fpfs parent-walk needs the stock check to deny at the domain-container// boundary; without it the walk climbs unbounded and ResolverService balloons → jetsam →-// respring. KernelJBPatchSandboxExtended therefore leaves ops[267] un-neutered on 27, and+// respring. KernelJailbreakPatchSandboxExtended therefore leaves ops[267] un-neutered on 27, and// this patch retargets it to a trampoline that runs the real check only for the FileProvider// daemons (matched by p_comm) and returns allow for everyone else — preserving the bypass.import Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {private static let vnodeCheckOpenIndex = 267@discardableResultdiff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Sandbox/KernelJBPatchIoucMacf.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Sandbox/KernelJailbreakPatchIoucMacf.swiftsimilarity index 98%rename from sources/FirmwarePatcher/Kernel/JBPatches/Sandbox/KernelJBPatchIoucMacf.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Sandbox/KernelJailbreakPatchIoucMacf.swiftindex e07c09e4..93cb5409 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Sandbox/KernelJBPatchIoucMacf.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Sandbox/KernelJailbreakPatchIoucMacf.swift@@ -1,4 +1,4 @@-// KernelJBPatchIoucMacf.swift — JB kernel patch: IOUC MACF gate bypass+// KernelJailbreakPatchIoucMacf.swift — JB kernel patch: IOUC MACF gate bypass//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.//@@ -17,7 +17,7 @@import Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {/// IOUC MACF gate bypass: replace CBZ W0, <allow> with B <allow>.@discardableResultfunc patchIoucFailedMacf() -> Bool {diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Sandbox/KernelJBPatchIoucSandbox.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Sandbox/KernelJailbreakPatchIoucSandbox.swiftsimilarity index 97%rename from sources/FirmwarePatcher/Kernel/JBPatches/Sandbox/KernelJBPatchIoucSandbox.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Sandbox/KernelJailbreakPatchIoucSandbox.swiftindex 80e9e5fe..c6c1d631 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Sandbox/KernelJBPatchIoucSandbox.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Sandbox/KernelJailbreakPatchIoucSandbox.swift@@ -1,4 +1,4 @@-// KernelJBPatchIoucSandbox.swift — JB kernel patch: IOUC *sandbox* gate bypass.+// KernelJailbreakPatchIoucSandbox.swift — JB kernel patch: IOUC *sandbox* gate bypass.//// Sibling to patchIoucFailedMacf. The IOKit user-client open path runs TWO// independent MAC gates: a MACF-aggregator check ("IOUC %s failed MACF in@@ -33,7 +33,7 @@import Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {@discardableResultfunc patchIoucFailedSandbox() -> Bool {log("\n[JB] IOUC sandbox gate: deny-block → allow redirect")diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Sandbox/KernelJBPatchMacMount.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Sandbox/KernelJailbreakPatchMacMount.swiftsimilarity index 98%rename from sources/FirmwarePatcher/Kernel/JBPatches/Sandbox/KernelJBPatchMacMount.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Sandbox/KernelJailbreakPatchMacMount.swiftindex 52f2a8e7..4fc94bcc 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Sandbox/KernelJBPatchMacMount.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Sandbox/KernelJailbreakPatchMacMount.swift@@ -1,11 +1,11 @@-// KernelJBPatchMacMount.swift — JB kernel patch: MAC mount bypass+// KernelJailbreakPatchMacMount.swift — JB kernel patch: MAC mount bypass//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.import Capstoneimport Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {/// Apply the upstream twin bypasses in the mount-role wrapper.////// Patches two sites in the wrapper that decides whether execution candiff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Sandbox/KernelJBPatchProcSecurity.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Sandbox/KernelJailbreakPatchProcSecurity.swiftsimilarity index 87%rename from sources/FirmwarePatcher/Kernel/JBPatches/Sandbox/KernelJBPatchProcSecurity.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Sandbox/KernelJailbreakPatchProcSecurity.swiftindex a23c4849..d149a73e 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Sandbox/KernelJBPatchProcSecurity.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Sandbox/KernelJailbreakPatchProcSecurity.swift@@ -1,4 +1,4 @@-// KernelJBPatchProcSecurity.swift — JB: stub _proc_security_policy with mov x0,#0; ret.+// KernelJailbreakPatchProcSecurity.swift — JB: stub _proc_security_policy with mov x0,#0; ret.//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.//@@ -6,13 +6,13 @@// authorization gate (bsd/kern/proc_info.c). It is located by its unique// reference to PRIV_GLOBAL_PROC_INFO (1002 = 0x3EA, bsd/sys/priv.h) — the// privilege id handed to priv_check_cred(my_cred, PRIV_GLOBAL_PROC_INFO, 0).-// See KernelJBPatcherBase.findProcSecurityPolicy(). Stubbing its entry to+// See KernelJailbreakPatcherBase.findProcSecurityPolicy(). Stubbing its entry to// `mov x0,#0; ret` forces the gate to allow, so proc-info/proc-control paths// used by jailbreak userland never hit cross-identity authorization denials.import Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {/// Stub _proc_security_policy: mov x0,#0; ret.@discardableResultfunc patchProcSecurityPolicy() -> Bool {diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Sandbox/KernelJBPatchSandboxExtended.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Sandbox/KernelJailbreakPatchSandboxExtended.swiftsimilarity index 97%rename from sources/FirmwarePatcher/Kernel/JBPatches/Sandbox/KernelJBPatchSandboxExtended.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Sandbox/KernelJailbreakPatchSandboxExtended.swiftindex 8f5620a4..46d336ea 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Sandbox/KernelJBPatchSandboxExtended.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Sandbox/KernelJailbreakPatchSandboxExtended.swift@@ -1,4 +1,4 @@-// KernelJBPatchSandboxExtended.swift — JB kernel patch: Extended sandbox hooks bypass+// KernelJailbreakPatchSandboxExtended.swift — JB kernel patch: Extended sandbox hooks bypass//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.//@@ -14,7 +14,7 @@import Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {/// Extended sandbox hooks bypass: retarget ops entries to the allow stub.@discardableResultfunc patchSandboxHooksExtended() -> Bool {@@ -82,7 +82,7 @@ extension KernelJBPatcher {hookIndices.append(("proc_check_syscall_unix", 124))}- // On iOS 27, leave ops[267] real so KernelJBPatchFpfsScopedOpen can retarget it to a+ // On iOS 27, leave ops[267] real so KernelJailbreakPatchFpfsScopedOpen can retarget it to a// FileProvider-scoped trampoline (the fpfs walk needs the stock check as its terminus,// else ResolverService balloons → respring). Neuter it as usual on every other base.if !applyIOS27 {diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Storage/KernelJBPatchBsdInitAuth.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Storage/KernelJailbreakPatchBsdInitAuth.swiftsimilarity index 98%rename from sources/FirmwarePatcher/Kernel/JBPatches/Storage/KernelJBPatchBsdInitAuth.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Storage/KernelJailbreakPatchBsdInitAuth.swiftindex 2667b0fc..e3cea1d5 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Storage/KernelJBPatchBsdInitAuth.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Storage/KernelJailbreakPatchBsdInitAuth.swift@@ -1,4 +1,4 @@-// KernelJBPatchBsdInitAuth.swift — JB: bypass FSIOC_KERNEL_ROOTAUTH failure in _bsd_init.+// KernelJailbreakPatchBsdInitAuth.swift — JB: bypass FSIOC_KERNEL_ROOTAUTH failure in _bsd_init.//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.//@@ -16,7 +16,7 @@import Capstoneimport Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {private static let rootvpAuthNeedle = "rootvp not authenticated after mounting"private static let rootvpAltNeedle = "rootvp not authenticated after mounting @%s:%d"diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Storage/KernelJBPatchDiskImages2.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Storage/KernelJailbreakPatchDiskImages2.swiftsimilarity index 97%rename from sources/FirmwarePatcher/Kernel/JBPatches/Storage/KernelJBPatchDiskImages2.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Storage/KernelJailbreakPatchDiskImages2.swiftindex 2edf9189..e8f9aee2 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Storage/KernelJBPatchDiskImages2.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Storage/KernelJailbreakPatchDiskImages2.swift@@ -1,4 +1,4 @@-// KernelJBPatchDiskImages2.swift — JB kernel patch: DiskImages2 ABI acceptance.+// KernelJailbreakPatchDiskImages2.swift — JB kernel patch: DiskImages2 ABI acceptance.//// Productionizes the known-good DiskImages2 pokes that make the 26.4 vphone600// kernel accept the iOS-27 userland's DiskImages2 client (kernel driver ABI v9 vs@@ -7,7 +7,7 @@// "DIDeviceCreatorUserClient::CreateDevice: Incompatible client: expected ABI// version 9 actual 11"), so `pymobiledevice3 mounter auto-mount` fails at attach.//-// Pairs with the sandbox mac_policy_ops[124] allow (KernelJBPatchSandboxExtended)+// Pairs with the sandbox mac_policy_ops[124] allow (KernelJailbreakPatchSandboxExtended)// and the diskimagesiod isMountComplete→YES userland patch (cfw_install) that// together let the attached DDI actually mount at /System/Developer.//@@ -35,8 +35,8 @@import Capstoneimport Foundation-extension KernelJBPatcher {- /// Apply all DiskImages2 ABI pokes. Wired into KernelJBPatcher.findAll().+extension KernelJailbreakPatcher {+ /// Apply all DiskImages2 ABI pokes. Wired into KernelJailbreakPatcher.findAll().@discardableResultfunc patchDiskImages2ClientAbi() -> Bool {var ok = truediff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Storage/KernelJBPatchDounmount.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Storage/KernelJailbreakPatchDounmount.swiftsimilarity index 97%rename from sources/FirmwarePatcher/Kernel/JBPatches/Storage/KernelJBPatchDounmount.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Storage/KernelJailbreakPatchDounmount.swiftindex b45eaa28..bfd33812 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Storage/KernelJBPatchDounmount.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Storage/KernelJailbreakPatchDounmount.swift@@ -1,4 +1,4 @@-// KernelJBPatchDounmount.swift — JB: NOP the upstream cleanup call in dounmount.+// KernelJailbreakPatchDounmount.swift — JB: NOP the upstream cleanup call in dounmount.//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.//@@ -9,7 +9,7 @@import Capstoneimport Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {/// NOP the upstream cleanup call in _dounmount.@discardableResultfunc patchDounmount() -> Bool {diff --git a/sources/FirmwarePatcher/Kernel/JBPatches/Storage/KernelJBPatchSecureRoot.swift b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Storage/KernelJailbreakPatchSecureRoot.swiftsimilarity index 98%rename from sources/FirmwarePatcher/Kernel/JBPatches/Storage/KernelJBPatchSecureRoot.swiftrename to sources/FirmwarePatcher/Kernel/JailbreakPatches/Storage/KernelJailbreakPatchSecureRoot.swiftindex 2a9c045d..ecc7dd17 100644--- a/sources/FirmwarePatcher/Kernel/JBPatches/Storage/KernelJBPatchSecureRoot.swift+++ b/sources/FirmwarePatcher/Kernel/JailbreakPatches/Storage/KernelJailbreakPatchSecureRoot.swift@@ -1,4 +1,4 @@-// KernelJBPatchSecureRoot.swift — JB: force the SecureRootName policy to return success.+// KernelJailbreakPatchSecureRoot.swift — JB: force the SecureRootName policy to return success.//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.//@@ -17,7 +17,7 @@import Capstoneimport Foundation-extension KernelJBPatcher {+extension KernelJailbreakPatcher {/// Force SecureRootName policy return to success in AppleARMPE::callPlatformFunction.@discardableResultfunc patchIoSecureBsdRoot() -> Bool {diff --git a/sources/FirmwarePatcher/Kernel/KernelEXPPatcher.swift b/sources/FirmwarePatcher/Kernel/KernelExperimentalPatcher.swiftsimilarity index 71%rename from sources/FirmwarePatcher/Kernel/KernelEXPPatcher.swiftrename to sources/FirmwarePatcher/Kernel/KernelExperimentalPatcher.swiftindex 596521dd..fb646201 100644--- a/sources/FirmwarePatcher/Kernel/KernelEXPPatcher.swift+++ b/sources/FirmwarePatcher/Kernel/KernelExperimentalPatcher.swift@@ -1,12 +1,12 @@-// KernelEXPPatcher.swift — Experimental kernel patcher orchestrator.+// KernelExperimentalPatcher.swift — Experimental kernel patcher orchestrator.//-// Runs after KernelPatcher + KernelJBPatcher for the `.exp` firmware variant+// Runs after KernelPatcher + KernelJailbreakPatcher for the `.exp` firmware variant// only. JB and other variants are NOT affected by patches owned here.//// Current contents:// - patchHvVmmRename (Part A + Part B): rename the kern.hv_vmm_present// sysctl OID cstring AND mangle every kernel-internal caller. See-// EXPPatches/KernelEXPPatchHvVmmRename.swift for the implementation.+// EXPPatches/KernelExperimentalPatchHvVmmRename.swift for the implementation.import Foundation@@ -14,9 +14,9 @@ import Foundation////// Inherits the JB infrastructure (symbol table, ADRP/BL indices, branch/// encoders, code-cave finder, string-anchored function finders, etc.) from-/// `KernelJBPatcherBase` so EXP-specific patches can use the same helpers+/// `KernelJailbreakPatcherBase` so EXP-specific patches can use the same helpers/// as JB ones without duplicating them.-public final class KernelEXPPatcher: KernelJBPatcherBase, Patcher {+public final class KernelExperimentalPatcher: KernelJailbreakPatcherBase, Patcher {public let component = "kernelcache_exp"public func findAll() throws -> [PatchRecord] {diff --git a/sources/FirmwarePatcher/Kernel/KernelJBPatcher.swift b/sources/FirmwarePatcher/Kernel/KernelJailbreakPatcher.swiftsimilarity index 97%rename from sources/FirmwarePatcher/Kernel/KernelJBPatcher.swiftrename to sources/FirmwarePatcher/Kernel/KernelJailbreakPatcher.swiftindex 7494e914..974fa4fe 100644--- a/sources/FirmwarePatcher/Kernel/KernelJBPatcher.swift+++ b/sources/FirmwarePatcher/Kernel/KernelJailbreakPatcher.swift@@ -1,4 +1,4 @@-// KernelJBPatcher.swift — JB kernel patcher orchestrator.+// KernelJailbreakPatcher.swift — JB kernel patcher orchestrator.//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.@@ -11,7 +11,7 @@ import Foundation/// Group A: Core gate-bypass methods/// Group B: Pattern/string anchored methods/// Group C: Shellcode/trampoline heavy methods-public final class KernelJBPatcher: KernelJBPatcherBase, Patcher {+public final class KernelJailbreakPatcher: KernelJailbreakPatcherBase, Patcher {public let component = "kernelcache_jb"/// Gates the iOS-27-only kernel patches. These target an iOS-27 userland runningdiff --git a/sources/FirmwarePatcher/Kernel/KernelJBPatcherBase.swift b/sources/FirmwarePatcher/Kernel/KernelJailbreakPatcherBase.swiftsimilarity index 98%rename from sources/FirmwarePatcher/Kernel/KernelJBPatcherBase.swiftrename to sources/FirmwarePatcher/Kernel/KernelJailbreakPatcherBase.swiftindex e8f65b18..0b6169c0 100644--- a/sources/FirmwarePatcher/Kernel/KernelJBPatcherBase.swift+++ b/sources/FirmwarePatcher/Kernel/KernelJailbreakPatcherBase.swift@@ -1,4 +1,4 @@-// KernelJBPatcherBase.swift — JB kernel patcher base with extended infrastructure.+// KernelJailbreakPatcherBase.swift — JB kernel patcher base with extended infrastructure.//// Historical note: derived from the legacy Python firmware patcher during the Swift migration.@@ -11,7 +11,7 @@ import Foundation/// - Function boundary finders (findFuncEnd)/// - String-anchored function finders/// - proc_info anchor cache-public class KernelJBPatcherBase: KernelPatcherBase {+public class KernelJailbreakPatcherBase: KernelPatcherBase {/// Symbol name → file offset map, built from nlist64 entries.var symbols: [String: Int] = [:]diff --git a/sources/FirmwarePatcher/Core/PatchRecord.swift b/sources/FirmwarePatcher/PatchInfrastructure/PatchRecord.swiftsimilarity index 100%rename from sources/FirmwarePatcher/Core/PatchRecord.swiftrename to sources/FirmwarePatcher/PatchInfrastructure/PatchRecord.swiftdiff --git a/sources/FirmwarePatcher/Core/PatcherError.swift b/sources/FirmwarePatcher/PatchInfrastructure/PatcherError.swiftsimilarity index 100%rename from sources/FirmwarePatcher/Core/PatcherError.swiftrename to sources/FirmwarePatcher/PatchInfrastructure/PatcherError.swiftdiff --git a/sources/FirmwarePatcher/Core/PatcherProtocol.swift b/sources/FirmwarePatcher/PatchInfrastructure/PatcherProtocol.swiftsimilarity index 100%rename from sources/FirmwarePatcher/Core/PatcherProtocol.swiftrename to sources/FirmwarePatcher/PatchInfrastructure/PatcherProtocol.swiftdiff --git a/sources/FirmwarePatcher/Pipeline/FirmwarePipeline.swift b/sources/FirmwarePatcher/Pipeline/FirmwarePipeline.swiftindex b5577aa2..ef0af443 100644--- a/sources/FirmwarePatcher/Pipeline/FirmwarePipeline.swift+++ b/sources/FirmwarePatcher/Pipeline/FirmwarePipeline.swift@@ -7,8 +7,8 @@// Internal variant selection:// .regular — base patchers only// .dev — TXMDevPatcher instead of TXMPatcher-// .jb — TXMDevPatcher + IBootJBPatcher (iBSS) + KernelJBPatcher-// .exp — JB + experimental: KernelEXPPatcher (hv_vmm rename) ++// .jb — TXMDevPatcher + IBootJailbreakPatcher (iBSS) + KernelJailbreakPatcher+// .exp — JB + experimental: KernelExperimentalPatcher (hv_vmm rename) +// DeviceTreePatcher identity properties (D47AP/iPhone17,3).// Other variants are NOT affected by experimental patches.//@@ -227,10 +227,10 @@ public final class FirmwarePipeline {if let kp = patcher as? KernelPatcher {return kp.buffer.data}- if let kjb = patcher as? KernelJBPatcher {+ if let kjb = patcher as? KernelJailbreakPatcher {return kjb.buffer.data}- if let kexp = patcher as? KernelEXPPatcher {+ if let kexp = patcher as? KernelExperimentalPatcher {return kexp.buffer.data}if let dt = patcher as? DeviceTreePatcher {diff --git a/sources/FirmwarePatcher/Pipeline/FirmwarePipelineComponents.swift b/sources/FirmwarePatcher/Pipeline/FirmwarePipelineComponents.swiftindex d085ca6a..65850f29 100644--- a/sources/FirmwarePatcher/Pipeline/FirmwarePipelineComponents.swift+++ b/sources/FirmwarePatcher/Pipeline/FirmwarePipelineComponents.swift@@ -20,7 +20,7 @@ extension FirmwarePipeline {/// `iPhone-BuildManifest.plist`). Gates the skywalk-netagent boot-arg workaround/// (18.x-specific mDNSResponder crash-loop)./// - iosBaseIs27: True when the iPhone base is iOS 27.x. Gates the iOS-27-only JB- /// kernel patches (`KernelJBPatcher.applyIOS27`); false for 18.x/26.x so those+ /// kernel patches (`KernelJailbreakPatcher.applyIOS27`); false for 18.x/26.x so those/// bases are byte-identical to pre-branch./// - cloudOSIsFridaCapable: True when the cloudOS kernel is 26.4+; gates the opt-in/// Frida kernel patches.@@ -95,7 +95,7 @@ extension FirmwarePipeline {IBootPatcher(data: data, mode: .ibss, verbose: verbose)},{ data, verbose in- IBootJBPatcher(data: data, mode: .ibss, verbose: verbose)+ IBootJailbreakPatcher(data: data, mode: .ibss, verbose: verbose)},]}@@ -171,7 +171,7 @@ extension FirmwarePipeline {KernelPatcher(data: data, verbose: verbose, isDev: false, applyExcGuard: applyExcGuard)},{ data, verbose in- let p = KernelJBPatcher(data: data, verbose: verbose)+ let p = KernelJailbreakPatcher(data: data, verbose: verbose)p.applyIOS27 = applyIOS27p.applyFrida = applyFridareturn p@@ -183,13 +183,13 @@ extension FirmwarePipeline {KernelPatcher(data: data, verbose: verbose, isDev: false, applyExcGuard: applyExcGuard)},{ data, verbose in- let p = KernelJBPatcher(data: data, verbose: verbose)+ let p = KernelJailbreakPatcher(data: data, verbose: verbose)p.applyIOS27 = applyIOS27p.applyFrida = applyFridareturn p},{ data, verbose in- KernelEXPPatcher(data: data, verbose: verbose)+ KernelExperimentalPatcher(data: data, verbose: verbose)},]}diff --git a/sources/VPhoneKit/VPhoneAPIClient.swift b/sources/VPhoneAPIKit/VPhoneAPIClient.swiftsimilarity index 100%rename from sources/VPhoneKit/VPhoneAPIClient.swiftrename to sources/VPhoneAPIKit/VPhoneAPIClient.swiftdiff --git a/sources/VPhoneArchive/VPhoneBundleTransfer.swift b/sources/VPhoneArchive/VPhoneBundleTransfer.swiftindex 285c1dff..9386ee25 100644--- a/sources/VPhoneArchive/VPhoneBundleTransfer.swift+++ b/sources/VPhoneArchive/VPhoneBundleTransfer.swift@@ -84,7 +84,7 @@ public enum VPhoneBundleTransfer {: outFilelet bundleDir = library.url(forName: name)- var excludes = VPhoneBundleOps.exportExcludePatterns+ var excludes = VPhoneBundleOperations.exportExcludePatternsif !includeIPSW {excludes.append("*_Restore*")}@@ -135,7 +135,7 @@ public enum VPhoneBundleTransfer {if !includeIPSW, rel.contains("_Restore") {en.skipDescendants(); continue}- if VPhoneBundleOps.exportExcludePatterns.contains(where: { fnmatch($0, rel, 0) == 0 }) {+ if VPhoneBundleOperations.exportExcludePatterns.contains(where: { fnmatch($0, rel, 0) == 0 }) {continue}guard let vals = try? url.resourceValues(forKeys: Set(keys)),@@ -183,7 +183,7 @@ public enum VPhoneBundleTransfer {let fm = FileManager.default// Fail fast when the destination name is already known (explicit rename).if let name {- try VPhoneBundleOps.requireValidName(name)+ try VPhoneBundleOperations.requireValidName(name)if fm.fileExists(atPath: library.url(forName: name).path) {throw VPhoneLibraryError.alreadyExists(name: name)}@@ -222,7 +222,7 @@ public enum VPhoneBundleTransfer {)}let finalName = name ?? archived- try VPhoneBundleOps.requireValidName(finalName)+ try VPhoneBundleOperations.requireValidName(finalName)let dst = library.url(forName: finalName)if fm.fileExists(atPath: dst.path) {throw VPhoneLibraryError.alreadyExists(name: finalName)diff --git a/sources/VPhoneCore/VPhoneBootPatterns.swift b/sources/VPhoneCore/VPhoneBootPatterns.swiftindex 066b7164..6a35ccbb 100644--- a/sources/VPhoneCore/VPhoneBootPatterns.swift+++ b/sources/VPhoneCore/VPhoneBootPatterns.swift@@ -32,6 +32,6 @@ public enum VPhoneBootPatterns {// `parseHVVmmPresent` lived here: the string form of `sysctl -n// kern.hv_vmm_present`, trimmed and compared to "1". It went when its one- // caller stopped spawning sysctl — `VPhoneCreateOrchestrator.isNestedVMHost`+ // caller stopped spawning sysctl — `VPhoneVirtualMachineCreator.isNestedVMHost`// reads the int with `sysctlbyname` now, so there is no text to parse.}diff --git a/sources/VPhoneCore/VPhoneBundleOps.swift b/sources/VPhoneCore/VPhoneBundleOperations.swiftsimilarity index 97%rename from sources/VPhoneCore/VPhoneBundleOps.swiftrename to sources/VPhoneCore/VPhoneBundleOperations.swiftindex cf91381c..7729d071 100644--- a/sources/VPhoneCore/VPhoneBundleOps.swift+++ b/sources/VPhoneCore/VPhoneBundleOperations.swift@@ -1,8 +1,8 @@import Darwinimport Foundation-public enum VPhoneBundleOps {- public struct NewBundleSpec: Sendable {+public enum VPhoneBundleOperations {+ public struct NewBundleConfiguration: Sendable {public let name: Stringpublic let cpuCount: UIntpublic let memoryMB: UInt64@@ -42,7 +42,7 @@ public enum VPhoneBundleOps {}}- public static func create(_ spec: NewBundleSpec, in library: VPhoneLibrary) throws -> VPhoneBundle {+ public static func create(_ spec: NewBundleConfiguration, in library: VPhoneLibrary) throws -> VPhoneBundle {try requireValidName(spec.name)let fm = FileManager.defaultlet dir = library.url(forName: spec.name)diff --git a/sources/VPhoneCore/VPhoneBundleReport.swift b/sources/VPhoneCore/VPhoneBundleReport.swiftindex 3c5f3de7..c0890c35 100644--- a/sources/VPhoneCore/VPhoneBundleReport.swift+++ b/sources/VPhoneCore/VPhoneBundleReport.swift@@ -16,6 +16,6 @@ public struct VPhoneBundleReport: Codable, Equatable, Sendable {diskSizeBytes = bundle.diskSizeBytesnetwork = bundle.manifest.networkConfigrestoreInfo = VPhoneRestoreInfo.load(fromBundle: bundle)- udid = VPhoneRestoreOps.resolveUDID(bundle: bundle)+ udid = VPhoneRestoreOperations.resolveUDID(bundle: bundle)}}diff --git a/sources/VPhoneCore/VPhoneFirmwarePicker.swift b/sources/VPhoneCore/VPhoneFirmwarePicker.swiftindex 7cbfd425..834969f3 100644--- a/sources/VPhoneCore/VPhoneFirmwarePicker.swift+++ b/sources/VPhoneCore/VPhoneFirmwarePicker.swift@@ -123,7 +123,7 @@ public enum VPhoneFirmwarePicker {return c}- /// Show a numbered menu and read a 1-based index (mirrors VPhoneVMPicker).+ /// Show a numbered menu and read a 1-based index (mirrors VPhoneVirtualMachinePicker).static func choose(_ prompt: String,_ labels: [String],diff --git a/sources/VPhoneCore/VPhoneNetworking.swift b/sources/VPhoneCore/VPhoneNetworking.swiftindex 2fda26e3..ab200758 100644--- a/sources/VPhoneCore/VPhoneNetworking.swift+++ b/sources/VPhoneCore/VPhoneNetworking.swift@@ -46,7 +46,7 @@ extension VPhoneNetworkingError: CustomStringConvertible, LocalizedError {// MARK: - Networking helpers/// Host-side helpers for validating and realizing a VM's `NetworkConfig`.-/// Shared between config-time editing (`VPhoneBundleOps.updateConfig`) and boot-time+/// Shared between config-time editing (`VPhoneBundleOperations.updateConfig`) and boot-time/// device construction so both agree on validation and interface resolution.public enum VPhoneNetworking {public typealias NetworkConfig = VPhoneVirtualMachineManifest.NetworkConfigdiff --git a/sources/VPhoneCore/VPhoneRestoreOps.swift b/sources/VPhoneCore/VPhoneRestoreOperations.swiftsimilarity index 99%rename from sources/VPhoneCore/VPhoneRestoreOps.swiftrename to sources/VPhoneCore/VPhoneRestoreOperations.swiftindex 209ad54c..14576c6c 100644--- a/sources/VPhoneCore/VPhoneRestoreOps.swift+++ b/sources/VPhoneCore/VPhoneRestoreOperations.swift@@ -31,7 +31,7 @@ extension VPhoneRestoreError: LocalizedError {}}-public enum VPhoneRestoreOps {+public enum VPhoneRestoreOperations {// MARK: - ECID/// ECID from `--ecid`, else the `ECID=` line of the bundle's udid-prediction.txt.diff --git a/sources/VPhoneCore/VPhoneVMPicker.swift b/sources/VPhoneCore/VPhoneVirtualMachinePicker.swiftsimilarity index 80%rename from sources/VPhoneCore/VPhoneVMPicker.swiftrename to sources/VPhoneCore/VPhoneVirtualMachinePicker.swiftindex 225d4e6b..67f4b3ef 100644--- a/sources/VPhoneCore/VPhoneVMPicker.swift+++ b/sources/VPhoneCore/VPhoneVirtualMachinePicker.swift@@ -1,6 +1,6 @@import Foundation-public enum VPhoneVMPickerError: Error, CustomStringConvertible, Equatable {+public enum VPhoneVirtualMachinePickerError: Error, CustomStringConvertible, Equatable {case emptyLibrary(root: String)case notInteractivecase aborted@@ -20,7 +20,7 @@ public enum VPhoneVMPickerError: Error, CustomStringConvertible, Equatable {}}-public enum VPhoneVMPicker {+public enum VPhoneVirtualMachinePicker {/// Resolve an existing-VM name. Returns `provided` unchanged when given;/// otherwise shows a numbered menu of `names` and reads a 1-based index or an/// exact name. All output goes through `write` (caller routes to stderr); input@@ -37,8 +37,8 @@ public enum VPhoneVMPicker {if let provided, !provided.isEmpty {return provided}- guard isInteractive else { throw VPhoneVMPickerError.notInteractive }- guard !names.isEmpty else { throw VPhoneVMPickerError.emptyLibrary(root: libraryRoot) }+ guard isInteractive else { throw VPhoneVirtualMachinePickerError.notInteractive }+ guard !names.isEmpty else { throw VPhoneVirtualMachinePickerError.emptyLibrary(root: libraryRoot) }write("Select a VM:")for (i, name) in names.enumerated() {@@ -47,7 +47,7 @@ public enum VPhoneVMPicker {for _ in 0 ..< maxRetries {write("Enter number or name: ")- guard let line = read() else { throw VPhoneVMPickerError.aborted }+ guard let line = read() else { throw VPhoneVirtualMachinePickerError.aborted }let choice = line.trimmingCharacters(in: .whitespacesAndNewlines)if choice.isEmpty {continue@@ -60,6 +60,6 @@ public enum VPhoneVMPicker {}write(" '\(choice)' is not a valid selection.")}- throw VPhoneVMPickerError.invalidSelection+ throw VPhoneVirtualMachinePickerError.invalidSelection}}diff --git a/sources/VPhoneRestore/VPhoneRestoreRunner.swift b/sources/VPhoneRestore/VPhoneRestoreRunner.swiftindex 06a7f9c1..38517cff 100644--- a/sources/VPhoneRestore/VPhoneRestoreRunner.swift+++ b/sources/VPhoneRestore/VPhoneRestoreRunner.swift@@ -6,7 +6,7 @@ import MobileRestoreCore/// The thin layer over `vphone_restore_run`: closures in, C function pointers/// out, a result code turned into a typed error.///-/// Everything above this — `VPhoneRestoreBridge` — is about which directory and+/// Everything above this — `VPhoneRestoreService` — is about which directory and/// which ticket; everything below it is idevicerestore.public enum VPhoneRestoreRunner {/// Runs one restore to completion.diff --git a/sources/VPhoneRestore/VPhoneRestoreBridge.swift b/sources/VPhoneRestore/VPhoneRestoreService.swiftsimilarity index 99%rename from sources/VPhoneRestore/VPhoneRestoreBridge.swiftrename to sources/VPhoneRestore/VPhoneRestoreService.swiftindex e98f6c0d..e2587767 100644--- a/sources/VPhoneRestore/VPhoneRestoreBridge.swift+++ b/sources/VPhoneRestore/VPhoneRestoreService.swift@@ -1,6 +1,6 @@import Foundation-// MARK: - VPhoneRestoreBridge+// MARK: - VPhoneRestoreService/// What `scripts/pymobiledevice3_bridge.py` did, in process.///@@ -11,7 +11,7 @@ import Foundation////// Everything below blocks for as long as the work takes and reports through/// `onEvent`, which idevicerestore calls from its worker threads.-public enum VPhoneRestoreBridge {+public enum VPhoneRestoreService {// MARK: recovery-probe/// `recovery-probe`. See `VPhoneRecoveryProbe.probe`.diff --git a/sources/VPhoneVMKit/Guest/VPhoneAPIProxy.swift b/sources/VPhoneVirtualMachineKit/GuestCommunication/VPhoneAPIProxy.swiftsimilarity index 100%rename from sources/VPhoneVMKit/Guest/VPhoneAPIProxy.swiftrename to sources/VPhoneVirtualMachineKit/GuestCommunication/VPhoneAPIProxy.swiftdiff --git a/sources/VPhoneVMKit/Guest/VPhoneControl.swift b/sources/VPhoneVirtualMachineKit/GuestCommunication/VPhoneGuestControl.swiftsimilarity index 93%rename from sources/VPhoneVMKit/Guest/VPhoneControl.swiftrename to sources/VPhoneVirtualMachineKit/GuestCommunication/VPhoneGuestControl.swiftindex 5696ba1c..e03f87f2 100644--- a/sources/VPhoneVMKit/Guest/VPhoneControl.swift+++ b/sources/VPhoneVirtualMachineKit/GuestCommunication/VPhoneGuestControl.swift@@ -6,7 +6,7 @@ import Virtualization/// The VM UI's direct HTTP client over VSOCK. It does not open a host TCP/// listener; only --api-listen creates one through VPhoneAPIProxy.@MainActor-final class VPhoneControl {+final class VPhoneGuestControl {enum ControlError: Error, CustomStringConvertible {case notConnectedcase unsupportedCapability(String)@@ -35,15 +35,15 @@ final class VPhoneControl {private var monitor: Task<Void, Never>?private var orderedInput: Task<Void, Never>?private(set) var isConnected = false- private(set) var guestCaps: [String] = []- private(set) var guestIP: String?+ private(set) var guestCapabilities: [String] = []+ private(set) var guestIPAddress: String?private(set) var guestIOSVersion: String?var guestBinaryURL: URL?var onConnect: (([String]) -> Void)?var onDisconnect: (() -> Void)?var useGuestTouchInjection: Bool {- guard isConnected, guestCaps.contains("touch"),+ guard isConnected, guestCapabilities.contains("touch"),let major = guestIOSVersion.flatMap({ Int($0.split(separator: ".").first ?? "") })else { return false }return major < 26@@ -89,13 +89,13 @@ final class VPhoneControl {return}}- guestCaps = info["capabilities"] as? [String] ?? []- guestIP = info["ip"] as? String+ guestCapabilities = info["capabilities"] as? [String] ?? []+ guestIPAddress = info["ip"] as? StringguestIOSVersion = info["ios"] as? Stringif !isConnected {isConnected = trueprint("[control] connected to vphoned HTTP API (iOS \(guestIOSVersion ?? "?"))")- onConnect?(guestCaps)+ onConnect?(guestCapabilities)}} catch {if !isConnected { print("[control] probe failed: \(error)") }@@ -106,8 +106,8 @@ final class VPhoneControl {private func setDisconnected() {let wasConnected = isConnectedisConnected = false- guestCaps = []- guestIP = nil+ guestCapabilities = []+ guestIPAddress = nilguestIOSVersion = nilif wasConnected { onDisconnect?() }}@@ -137,13 +137,13 @@ final class VPhoneControl {}}- func sendDevModeStatus() async throws -> Bool {+ func isDeveloperModeEnabled() async throws -> Bool {try await call("developer_mode.status")["enabled"] as? Bool ?? false}func sendPing() async throws { _ = try await http(method: "GET", path: "/v1/health") }- func sendVersion() async throws -> String {+ func guestBinaryHash() async throws -> String {let response = try await http(method: "GET", path: "/v1/health")let value = try JSONSerialization.jsonObject(with: response.body) as? [String: Any]return value?["binary_hash"] as? String ?? "unknown"@@ -349,14 +349,14 @@ private final class VPhoneHTTPTransaction: @unchecked Sendable {func run() throws -> VPhoneHTTPResponse {let fd = connection.fileDescriptorguard fcntl(fd, F_SETNOSIGPIPE, 1) != -1 else {- throw VPhoneControl.ControlError.notConnected+ throw VPhoneGuestControl.ControlError.notConnected}var timeout = timeval(tv_sec: 120, tv_usec: 0)guard setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout,socklen_t(MemoryLayout<timeval>.size)) == 0,setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &timeout,socklen_t(MemoryLayout<timeval>.size)) == 0 else {- throw VPhoneControl.ControlError.notConnected+ throw VPhoneGuestControl.ControlError.notConnected}let headers = "\(method) \(path) HTTP/1.1\r\nHost: vphoned\r\nConnection: close\r\nContent-Type: \(contentType)\r\nContent-Length: \(body.count)\r\n\r\n"try write(fd, data: Data(headers.utf8))@@ -365,24 +365,24 @@ private final class VPhoneHTTPTransaction: @unchecked Sendable {var received = Data()let marker = Data("\r\n\r\n".utf8)while received.range(of: marker) == nil {- guard received.count < 64 * 1024 else { throw VPhoneControl.ControlError.protocolError("HTTP headers too large") }+ guard received.count < 64 * 1024 else { throw VPhoneGuestControl.ControlError.protocolError("HTTP headers too large") }try readMore(fd, into: &received)}let boundary = received.range(of: marker)!let header = String(decoding: received[..<boundary.lowerBound], as: UTF8.self)let lines = header.components(separatedBy: "\r\n")guard let first = lines.first, let status = Int(first.split(separator: " ").dropFirst().first ?? "") else {- throw VPhoneControl.ControlError.protocolError("invalid HTTP status")+ throw VPhoneGuestControl.ControlError.protocolError("invalid HTTP status")}guard let lengthLine = lines.first(where: { $0.lowercased().hasPrefix("content-length:") }),let length = Int(lengthLine.split(separator: ":", maxSplits: 1)[1].trimmingCharacters(in: .whitespaces)),length >= 0, length <= 2_147_483_647 else {- throw VPhoneControl.ControlError.protocolError("missing HTTP content length")+ throw VPhoneGuestControl.ControlError.protocolError("missing HTTP content length")}var payload = Data(received[boundary.upperBound...])while payload.count < length { try readMore(fd, into: &payload) }guard payload.count == length else {- throw VPhoneControl.ControlError.protocolError("HTTP body length mismatch")+ throw VPhoneGuestControl.ControlError.protocolError("HTTP body length mismatch")}return VPhoneHTTPResponse(status: status, body: payload)}@@ -394,7 +394,7 @@ private final class VPhoneHTTPTransaction: @unchecked Sendable {while offset < bytes.count {let sent = Darwin.write(fd, base + offset, bytes.count - offset)if sent < 0 && errno == EINTR { continue }- if sent <= 0 { throw VPhoneControl.ControlError.notConnected }+ if sent <= 0 { throw VPhoneGuestControl.ControlError.notConnected }offset += sent}}@@ -404,7 +404,7 @@ private final class VPhoneHTTPTransaction: @unchecked Sendable {var bytes = [UInt8](repeating: 0, count: 32 * 1024)var count = 0repeat { count = Darwin.read(fd, &bytes, bytes.count) } while count < 0 && errno == EINTR- guard count > 0 else { throw VPhoneControl.ControlError.notConnected }+ guard count > 0 else { throw VPhoneGuestControl.ControlError.notConnected }data.append(contentsOf: bytes[..<count])}}diff --git a/sources/VPhoneVMKit/Guest/VPhoneControlApps.swift b/sources/VPhoneVirtualMachineKit/GuestCommunication/VPhoneGuestControlApps.swiftsimilarity index 98%rename from sources/VPhoneVMKit/Guest/VPhoneControlApps.swiftrename to sources/VPhoneVirtualMachineKit/GuestCommunication/VPhoneGuestControlApps.swiftindex 47e57e5a..d3b5e1d2 100644--- a/sources/VPhoneVMKit/Guest/VPhoneControlApps.swift+++ b/sources/VPhoneVirtualMachineKit/GuestCommunication/VPhoneGuestControlApps.swift@@ -1,6 +1,6 @@import Foundation-extension VPhoneControl {+extension VPhoneGuestControl {// MARK: - App Managementstruct AppInfo {diff --git a/sources/VPhoneVMKit/Guest/VPhoneControlKeychain.swift b/sources/VPhoneVirtualMachineKit/GuestCommunication/VPhoneGuestControlKeychain.swiftsimilarity index 97%rename from sources/VPhoneVMKit/Guest/VPhoneControlKeychain.swiftrename to sources/VPhoneVirtualMachineKit/GuestCommunication/VPhoneGuestControlKeychain.swiftindex 12efafc0..107a0e39 100644--- a/sources/VPhoneVMKit/Guest/VPhoneControlKeychain.swift+++ b/sources/VPhoneVirtualMachineKit/GuestCommunication/VPhoneGuestControlKeychain.swift@@ -1,6 +1,6 @@import Foundation-extension VPhoneControl {+extension VPhoneGuestControl {// MARK: - Keychain Operationsstruct KeychainResult {diff --git a/sources/VPhoneVMKit/Guest/VPhoneControlSystem.swift b/sources/VPhoneVirtualMachineKit/GuestCommunication/VPhoneGuestControlSystem.swiftsimilarity index 94%rename from sources/VPhoneVMKit/Guest/VPhoneControlSystem.swiftrename to sources/VPhoneVirtualMachineKit/GuestCommunication/VPhoneGuestControlSystem.swiftindex 22f7fd69..a62886b0 100644--- a/sources/VPhoneVMKit/Guest/VPhoneControlSystem.swift+++ b/sources/VPhoneVirtualMachineKit/GuestCommunication/VPhoneGuestControlSystem.swift@@ -1,6 +1,6 @@import Foundation-extension VPhoneControl {+extension VPhoneGuestControl {// MARK: - URLfunc openURL(_ url: String) async throws {@@ -42,7 +42,7 @@ extension VPhoneControl {// MARK: - Accessibilityfunc accessibilityTree(depth: Int = -1) async throws -> [String: Any] {- guard guestCaps.contains("accessibility_tree") else {+ guard guestCapabilities.contains("accessibility_tree") else {throw ControlError.unsupportedCapability("accessibility_tree")}let (resp, _) = try await sendRequest(["t": "accessibility_tree", "depth": depth])diff --git a/sources/VPhoneVMKit/Devices/VPhoneCameraServer.swift b/sources/VPhoneVirtualMachineKit/HostDevices/VPhoneCameraServer.swiftsimilarity index 100%rename from sources/VPhoneVMKit/Devices/VPhoneCameraServer.swiftrename to sources/VPhoneVirtualMachineKit/HostDevices/VPhoneCameraServer.swiftdiff --git a/sources/VPhoneVMKit/Devices/VPhoneFrameProducer.swift b/sources/VPhoneVirtualMachineKit/HostDevices/VPhoneFrameProducer.swiftsimilarity index 100%rename from sources/VPhoneVMKit/Devices/VPhoneFrameProducer.swiftrename to sources/VPhoneVirtualMachineKit/HostDevices/VPhoneFrameProducer.swiftdiff --git a/sources/VPhoneVMKit/Devices/VPhoneLocationProvider.swift b/sources/VPhoneVirtualMachineKit/HostDevices/VPhoneLocationProvider.swiftsimilarity index 99%rename from sources/VPhoneVMKit/Devices/VPhoneLocationProvider.swiftrename to sources/VPhoneVirtualMachineKit/HostDevices/VPhoneLocationProvider.swiftindex 5b58e2ad..4f438a7e 100644--- a/sources/VPhoneVMKit/Devices/VPhoneLocationProvider.swift+++ b/sources/VPhoneVirtualMachineKit/HostDevices/VPhoneLocationProvider.swift@@ -37,7 +37,7 @@ class VPhoneLocationProvider: NSObject {}}- private let control: VPhoneControl+ private let control: VPhoneGuestControlprivate var hostModeStarted = falseprivate var locationManager: CLLocationManager?@@ -50,7 +50,7 @@ class VPhoneLocationProvider: NSObject {replayTask != nil}- init(control: VPhoneControl) {+ init(control: VPhoneGuestControl) {self.control = controlsuper.init()diff --git a/sources/VPhoneVMKit/Devices/VPhoneScreenRecorder.swift b/sources/VPhoneVirtualMachineKit/HostDevices/VPhoneScreenRecorder.swiftsimilarity index 100%rename from sources/VPhoneVMKit/Devices/VPhoneScreenRecorder.swiftrename to sources/VPhoneVirtualMachineKit/HostDevices/VPhoneScreenRecorder.swiftdiff --git a/sources/VPhoneVMKit/Devices/VPhoneTouchIDMonitor.swift b/sources/VPhoneVirtualMachineKit/HostDevices/VPhoneTouchIDMonitor.swiftsimilarity index 98%rename from sources/VPhoneVMKit/Devices/VPhoneTouchIDMonitor.swiftrename to sources/VPhoneVirtualMachineKit/HostDevices/VPhoneTouchIDMonitor.swiftindex 9a51a665..0cd8e413 100644--- a/sources/VPhoneVMKit/Devices/VPhoneTouchIDMonitor.swift+++ b/sources/VPhoneVirtualMachineKit/HostDevices/VPhoneTouchIDMonitor.swift@@ -106,7 +106,7 @@ private final class VPhoneBiometricDelegate: NSObject {/// Requires the com.apple.private.bmk.allow entitlement.@MainActorfinal class VPhoneTouchIDMonitor {- private weak var control: VPhoneControl?+ private weak var control: VPhoneGuestControl?private weak var window: NSWindow?/// Enables or disables Touch ID forwarding. Setting to false cancels the active@@ -142,7 +142,7 @@ final class VPhoneTouchIDMonitor {// MARK: - Lifecycle- func start(control: VPhoneControl, window: NSWindow) {+ func start(control: VPhoneGuestControl, window: NSWindow) {self.control = controlself.window = windowif isEnabled {diff --git a/sources/VPhoneVMKit/Interface/Browsers/VPhoneAppBrowserModel.swift b/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneAppBrowserModel.swiftsimilarity index 83%rename from sources/VPhoneVMKit/Interface/Browsers/VPhoneAppBrowserModel.swiftrename to sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneAppBrowserModel.swiftindex 37cc61ac..cceec438 100644--- a/sources/VPhoneVMKit/Interface/Browsers/VPhoneAppBrowserModel.swift+++ b/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneAppBrowserModel.swift@@ -3,9 +3,9 @@ import Foundation@MainActor@Observableclass VPhoneAppBrowserModel {- let control: VPhoneControl+ let control: VPhoneGuestControl- var apps: [VPhoneControl.AppInfo] = []+ var apps: [VPhoneGuestControl.AppInfo] = []var filter: AppFilter = .installedvar searchText = ""var isLoading = false@@ -18,7 +18,7 @@ class VPhoneAppBrowserModel {case system}- var filteredApps: [VPhoneControl.AppInfo] {+ var filteredApps: [VPhoneGuestControl.AppInfo] {guard !searchText.isEmpty else { return apps }let query = searchText.lowercased()return apps.filter {@@ -27,7 +27,7 @@ class VPhoneAppBrowserModel {}}- init(control: VPhoneControl) {+ init(control: VPhoneGuestControl) {self.control = control}diff --git a/sources/VPhoneVMKit/Interface/Browsers/VPhoneAppBrowserView.swift b/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneAppBrowserView.swiftsimilarity index 98%rename from sources/VPhoneVMKit/Interface/Browsers/VPhoneAppBrowserView.swiftrename to sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneAppBrowserView.swiftindex 8fc01717..f659a719 100644--- a/sources/VPhoneVMKit/Interface/Browsers/VPhoneAppBrowserView.swift+++ b/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneAppBrowserView.swift@@ -93,7 +93,7 @@ struct VPhoneAppBrowserView: View {}}- private func appRow(_ app: VPhoneControl.AppInfo) -> some View {+ private func appRow(_ app: VPhoneGuestControl.AppInfo) -> some View {HStack(spacing: 10) {VStack(alignment: .leading, spacing: 2) {HStack(spacing: 6) {diff --git a/sources/VPhoneVMKit/Interface/Browsers/VPhoneAppWindowController.swift b/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneAppWindowController.swiftsimilarity index 96%rename from sources/VPhoneVMKit/Interface/Browsers/VPhoneAppWindowController.swiftrename to sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneAppWindowController.swiftindex 066a1356..8347896d 100644--- a/sources/VPhoneVMKit/Interface/Browsers/VPhoneAppWindowController.swift+++ b/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneAppWindowController.swift@@ -6,7 +6,7 @@ class VPhoneAppWindowController {private var window: NSWindow?private var model: VPhoneAppBrowserModel?- func showWindow(control: VPhoneControl) {+ func showWindow(control: VPhoneGuestControl) {if let window {window.makeKeyAndOrderFront(nil)returndiff --git a/sources/VPhoneVMKit/Interface/Browsers/VPhoneFileBrowserModel.swift b/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneFileBrowserModel.swiftsimilarity index 98%rename from sources/VPhoneVMKit/Interface/Browsers/VPhoneFileBrowserModel.swiftrename to sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneFileBrowserModel.swiftindex c552e215..ff74cc74 100644--- a/sources/VPhoneVMKit/Interface/Browsers/VPhoneFileBrowserModel.swift+++ b/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneFileBrowserModel.swift@@ -4,7 +4,7 @@ import Observation@Observable@MainActorclass VPhoneFileBrowserModel {- let control: VPhoneControl+ let control: VPhoneGuestControlprivate let quickLookController: VPhoneQuickLookController/// Tracks an in-flight Quick Look download so it can be cancelled on selection change.private var quickLookTask: Task<Void, Never>?@@ -29,7 +29,7 @@ class VPhoneFileBrowserModel {private var pathHistory: [String] = []private var forwardHistory: [String] = []- init(control: VPhoneControl, quickLookController: VPhoneQuickLookController) {+ init(control: VPhoneGuestControl, quickLookController: VPhoneQuickLookController) {self.control = controlself.quickLookController = quickLookController}diff --git a/sources/VPhoneVMKit/Interface/Browsers/VPhoneFileBrowserView.swift b/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneFileBrowserView.swiftsimilarity index 99%rename from sources/VPhoneVMKit/Interface/Browsers/VPhoneFileBrowserView.swiftrename to sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneFileBrowserView.swiftindex 1e57500d..ff4a6cb3 100644--- a/sources/VPhoneVMKit/Interface/Browsers/VPhoneFileBrowserView.swift+++ b/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneFileBrowserView.swift@@ -371,7 +371,7 @@ struct VPhoneFileBrowserView: View {private struct FileDragItem: Transferable {let file: VPhoneRemoteFile- let control: VPhoneControl+ let control: VPhoneGuestControlstatic var transferRepresentation: some TransferRepresentation {FileRepresentation(exportedContentType: .data) { item indiff --git a/sources/VPhoneVMKit/Interface/Browsers/VPhoneFileWindowController.swift b/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneFileWindowController.swiftsimilarity index 97%rename from sources/VPhoneVMKit/Interface/Browsers/VPhoneFileWindowController.swiftrename to sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneFileWindowController.swiftindex 09ed9620..e14bd32e 100644--- a/sources/VPhoneVMKit/Interface/Browsers/VPhoneFileWindowController.swift+++ b/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneFileWindowController.swift@@ -7,7 +7,7 @@ class VPhoneFileWindowController {private var model: VPhoneFileBrowserModel?private let quickLookController = VPhoneQuickLookController()- func showWindow(control: VPhoneControl) {+ func showWindow(control: VPhoneGuestControl) {if let window {window.makeKeyAndOrderFront(nil)returndiff --git a/sources/VPhoneVMKit/Interface/Browsers/VPhoneKeychainBrowserModel.swift b/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneKeychainBrowserModel.swiftsimilarity index 97%rename from sources/VPhoneVMKit/Interface/Browsers/VPhoneKeychainBrowserModel.swiftrename to sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneKeychainBrowserModel.swiftindex 8a41b1d5..6a4c0cad 100644--- a/sources/VPhoneVMKit/Interface/Browsers/VPhoneKeychainBrowserModel.swift+++ b/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneKeychainBrowserModel.swift@@ -4,7 +4,7 @@ import Observation@Observable@MainActorclass VPhoneKeychainBrowserModel {- let control: VPhoneControl+ let control: VPhoneGuestControlvar items: [VPhoneKeychainItem] = []var isLoading = false@@ -16,7 +16,7 @@ class VPhoneKeychainBrowserModel {var filterClass: String?var showDiagnostics = false- init(control: VPhoneControl) {+ init(control: VPhoneGuestControl) {self.control = control}diff --git a/sources/VPhoneVMKit/Interface/Browsers/VPhoneKeychainBrowserView.swift b/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneKeychainBrowserView.swiftsimilarity index 100%rename from sources/VPhoneVMKit/Interface/Browsers/VPhoneKeychainBrowserView.swiftrename to sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneKeychainBrowserView.swiftdiff --git a/sources/VPhoneVMKit/Interface/Browsers/VPhoneKeychainItem.swift b/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneKeychainItem.swiftsimilarity index 100%rename from sources/VPhoneVMKit/Interface/Browsers/VPhoneKeychainItem.swiftrename to sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneKeychainItem.swiftdiff --git a/sources/VPhoneVMKit/Interface/Browsers/VPhoneKeychainWindowController.swift b/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneKeychainWindowController.swiftsimilarity index 96%rename from sources/VPhoneVMKit/Interface/Browsers/VPhoneKeychainWindowController.swiftrename to sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneKeychainWindowController.swiftindex ab29e435..a303f4e0 100644--- a/sources/VPhoneVMKit/Interface/Browsers/VPhoneKeychainWindowController.swift+++ b/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneKeychainWindowController.swift@@ -6,7 +6,7 @@ class VPhoneKeychainWindowController {private var window: NSWindow?private var model: VPhoneKeychainBrowserModel?- func showWindow(control: VPhoneControl) {+ func showWindow(control: VPhoneGuestControl) {if let window {window.makeKeyAndOrderFront(nil)returndiff --git a/sources/VPhoneVMKit/Interface/Browsers/VPhoneQuickLookController.swift b/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneQuickLookController.swiftsimilarity index 100%rename from sources/VPhoneVMKit/Interface/Browsers/VPhoneQuickLookController.swiftrename to sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneQuickLookController.swiftdiff --git a/sources/VPhoneVMKit/Interface/Browsers/VPhoneRemoteFile.swift b/sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneRemoteFile.swiftsimilarity index 100%rename from sources/VPhoneVMKit/Interface/Browsers/VPhoneRemoteFile.swiftrename to sources/VPhoneVirtualMachineKit/UserInterface/Browsers/VPhoneRemoteFile.swiftdiff --git a/sources/VPhoneVMKit/Interface/Menu/VPhoneMenuApps.swift b/sources/VPhoneVirtualMachineKit/UserInterface/Menu/VPhoneMenuApps.swiftsimilarity index 100%rename from sources/VPhoneVMKit/Interface/Menu/VPhoneMenuApps.swiftrename to sources/VPhoneVirtualMachineKit/UserInterface/Menu/VPhoneMenuApps.swiftdiff --git a/sources/VPhoneVMKit/Interface/Menu/VPhoneMenuBattery.swift b/sources/VPhoneVirtualMachineKit/UserInterface/Menu/VPhoneMenuBattery.swiftsimilarity index 100%rename from sources/VPhoneVMKit/Interface/Menu/VPhoneMenuBattery.swiftrename to sources/VPhoneVirtualMachineKit/UserInterface/Menu/VPhoneMenuBattery.swiftdiff --git a/sources/VPhoneVMKit/Interface/Menu/VPhoneMenuCamera.swift b/sources/VPhoneVirtualMachineKit/UserInterface/Menu/VPhoneMenuCamera.swiftsimilarity index 100%rename from sources/VPhoneVMKit/Interface/Menu/VPhoneMenuCamera.swiftrename to sources/VPhoneVirtualMachineKit/UserInterface/Menu/VPhoneMenuCamera.swiftdiff --git a/sources/VPhoneVMKit/Interface/Menu/VPhoneMenuConnect.swift b/sources/VPhoneVirtualMachineKit/UserInterface/Menu/VPhoneMenuConnect.swiftsimilarity index 95%rename from sources/VPhoneVMKit/Interface/Menu/VPhoneMenuConnect.swiftrename to sources/VPhoneVirtualMachineKit/UserInterface/Menu/VPhoneMenuConnect.swiftindex df92097c..3f86cb85 100644--- a/sources/VPhoneVMKit/Interface/Menu/VPhoneMenuConnect.swift+++ b/sources/VPhoneVirtualMachineKit/UserInterface/Menu/VPhoneMenuConnect.swift@@ -32,10 +32,10 @@ extension VPhoneMenuController {connectPingItem = pingmenu.addItem(ping)- let guestVersion = makeItem("Guest Version", action: #selector(queryGuestVersion))- guestVersion.isEnabled = false- connectGuestVersionItem = guestVersion- menu.addItem(guestVersion)+ let guestHash = makeItem("Guest Agent Hash", action: #selector(queryGuestHash))+ guestHash.isEnabled = false+ connectGuestHashItem = guestHash+ menu.addItem(guestHash)menu.addItem(NSMenuItem.separator())@@ -81,7 +81,7 @@ extension VPhoneMenuController {connectKeychainBrowserItem?.isEnabled = availableconnectDevModeStatusItem?.isEnabled = availableconnectPingItem?.isEnabled = available- connectGuestVersionItem?.isEnabled = available+ connectGuestHashItem?.isEnabled = available}@objc func openFiles() {@@ -95,7 +95,7 @@ extension VPhoneMenuController {@objc func devModeStatus() {Task {do {- let enabled = try await control.sendDevModeStatus()+ let enabled = try await control.isDeveloperModeEnabled()showAlert(title: "Developer Mode",message: enabled ? "Developer Mode is enabled." : "Developer Mode is disabled.",@@ -127,15 +127,15 @@ extension VPhoneMenuController {}}- @objc func queryGuestVersion() {+ @objc func queryGuestHash() {Task {do {- let hash = try await control.sendVersion()- showAlert(title: "Guest Version", message: "Build \(hash)", style: .informational)+ let hash = try await control.guestBinaryHash()+ showAlert(title: "Guest Agent Hash", message: "SHA-256: \(hash)", style: .informational)} catch {showAlert(- title: "Guest Version",- message: "Unable to read the guest version. Check that the guest agent is connected, "+ title: "Guest Agent Hash",+ message: "Unable to read the guest agent hash. Check that the guest agent is connected, "+ "then try again.",style: .warning,)diff --git a/sources/VPhoneVMKit/Interface/Menu/VPhoneMenuController.swift b/sources/VPhoneVirtualMachineKit/UserInterface/Menu/VPhoneMenuController.swiftsimilarity index 94%rename from sources/VPhoneVMKit/Interface/Menu/VPhoneMenuController.swiftrename to sources/VPhoneVirtualMachineKit/UserInterface/Menu/VPhoneMenuController.swiftindex 09dc3c23..6eae0c36 100644--- a/sources/VPhoneVMKit/Interface/Menu/VPhoneMenuController.swift+++ b/sources/VPhoneVirtualMachineKit/UserInterface/Menu/VPhoneMenuController.swift@@ -5,8 +5,8 @@ import Foundation@MainActorclass VPhoneMenuController {- let keyHelper: VPhoneKeyHelper- let control: VPhoneControl+ let keySender: VPhoneVirtualMachineKeySender+ let control: VPhoneGuestControlweak var vm: VPhoneVirtualMachine?var onFilesPressed: (() -> Void)?@@ -16,7 +16,7 @@ class VPhoneMenuController {var connectKeychainBrowserItem: NSMenuItem?var connectDevModeStatusItem: NSMenuItem?var connectPingItem: NSMenuItem?- var connectGuestVersionItem: NSMenuItem?+ var connectGuestHashItem: NSMenuItem?var installPackageItem: NSMenuItem?var clipboardGetItem: NSMenuItem?var clipboardSetItem: NSMenuItem?@@ -51,8 +51,8 @@ class VPhoneMenuController {var powerSourceRetainedPtr: UnsafeMutableRawPointer?var lowPowerObserver: (any NSObjectProtocol)?- init(keyHelper: VPhoneKeyHelper, control: VPhoneControl) {- self.keyHelper = keyHelper+ init(keySender: VPhoneVirtualMachineKeySender, control: VPhoneGuestControl) {+ self.keySender = keySenderself.control = controlsetupMenuBar()}diff --git a/sources/VPhoneVMKit/Interface/Menu/VPhoneMenuKeys.swift b/sources/VPhoneVirtualMachineKit/UserInterface/Menu/VPhoneMenuKeys.swiftsimilarity index 91%rename from sources/VPhoneVMKit/Interface/Menu/VPhoneMenuKeys.swiftrename to sources/VPhoneVirtualMachineKit/UserInterface/Menu/VPhoneMenuKeys.swiftindex c5f259a3..f7abfba1 100644--- a/sources/VPhoneVMKit/Interface/Menu/VPhoneMenuKeys.swift+++ b/sources/VPhoneVirtualMachineKit/UserInterface/Menu/VPhoneMenuKeys.swift@@ -31,27 +31,27 @@ extension VPhoneMenuController {}@objc func sendHome() {- keyHelper.sendHome()+ keySender.sendHome()}@objc func sendPower() {- keyHelper.sendPower()+ keySender.sendPower()}@objc func sendVolumeUp() {- keyHelper.sendVolumeUp()+ keySender.sendVolumeUp()}@objc func sendVolumeDown() {- keyHelper.sendVolumeDown()+ keySender.sendVolumeDown()}@objc func sendSpotlight() {- keyHelper.sendSpotlight()+ keySender.sendSpotlight()}@objc func typeFromClipboard() {- keyHelper.typeFromClipboard()+ keySender.typeFromClipboard()}@objc func toggleTouchIDForwarding() {diff --git a/sources/VPhoneVMKit/Interface/Menu/VPhoneMenuLocation.swift b/sources/VPhoneVirtualMachineKit/UserInterface/Menu/VPhoneMenuLocation.swiftsimilarity index 100%rename from sources/VPhoneVMKit/Interface/Menu/VPhoneMenuLocation.swiftrename to sources/VPhoneVirtualMachineKit/UserInterface/Menu/VPhoneMenuLocation.swiftdiff --git a/sources/VPhoneVMKit/Interface/Menu/VPhoneMenuRecord.swift b/sources/VPhoneVirtualMachineKit/UserInterface/Menu/VPhoneMenuRecord.swiftsimilarity index 96%rename from sources/VPhoneVMKit/Interface/Menu/VPhoneMenuRecord.swiftrename to sources/VPhoneVirtualMachineKit/UserInterface/Menu/VPhoneMenuRecord.swiftindex 47164783..0c5d7328 100644--- a/sources/VPhoneVMKit/Interface/Menu/VPhoneMenuRecord.swift+++ b/sources/VPhoneVirtualMachineKit/UserInterface/Menu/VPhoneMenuRecord.swift@@ -120,7 +120,7 @@ extension VPhoneMenuController {panel.contentView?.addSubview(ok)// Use a custom approach: reveal button stops modal with code 100- class RevealHelper: NSObject {+ class RecordingRevealAction: NSObject {var action: () -> Voidinit(_ action: @escaping () -> Void) {self.action = action@@ -130,11 +130,11 @@ extension VPhoneMenuController {action()}}- let helper = RevealHelper {+ let helper = RecordingRevealAction {NSApp.stopModal(withCode: NSApplication.ModalResponse(rawValue: 100))}reveal.target = helper- reveal.action = #selector(RevealHelper.clicked)+ reveal.action = #selector(RecordingRevealAction.clicked)let response = NSApp.runModal(for: panel)panel.orderOut(nil)diff --git a/sources/VPhoneVMKit/Interface/VPhoneKeyHelper.swift b/sources/VPhoneVirtualMachineKit/UserInterface/VPhoneVirtualMachineKeySender.swiftsimilarity index 98%rename from sources/VPhoneVMKit/Interface/VPhoneKeyHelper.swiftrename to sources/VPhoneVirtualMachineKit/UserInterface/VPhoneVirtualMachineKeySender.swiftindex 796dbce0..2d5d91ff 100644--- a/sources/VPhoneVMKit/Interface/VPhoneKeyHelper.swift+++ b/sources/VPhoneVirtualMachineKit/UserInterface/VPhoneVirtualMachineKeySender.swift@@ -6,9 +6,9 @@ import Virtualization// MARK: - Key Helper@MainActor-class VPhoneKeyHelper {+class VPhoneVirtualMachineKeySender {private let vm: VZVirtualMachine- private let control: VPhoneControl+ private let control: VPhoneGuestControlweak var window: NSWindow?/// First _VZKeyboard from the VM's internal keyboard array (used by typeString).@@ -17,7 +17,7 @@ class VPhoneKeyHelper {return arr.object(at: 0) as AnyObject}- init(vm: VPhoneVirtualMachine, control: VPhoneControl) {+ init(vm: VPhoneVirtualMachine, control: VPhoneGuestControl) {self.vm = vm.virtualMachineself.control = control}diff --git a/sources/VPhoneVMKit/Interface/VPhoneWindowController.swift b/sources/VPhoneVirtualMachineKit/UserInterface/VPhoneVirtualMachineWindowController.swiftsimilarity index 93%rename from sources/VPhoneVMKit/Interface/VPhoneWindowController.swiftrename to sources/VPhoneVirtualMachineKit/UserInterface/VPhoneVirtualMachineWindowController.swiftindex bb23b13d..839c1608 100644--- a/sources/VPhoneVMKit/Interface/VPhoneWindowController.swift+++ b/sources/VPhoneVirtualMachineKit/UserInterface/VPhoneVirtualMachineWindowController.swift@@ -3,10 +3,10 @@ import Foundationimport Virtualization@MainActor-class VPhoneWindowController: NSObject, NSToolbarDelegate {+class VPhoneVirtualMachineWindowController: NSObject, NSToolbarDelegate {private var windowController: NSWindowController?private var statusTimer: Timer?- private weak var control: VPhoneControl?+ private weak var control: VPhoneGuestControl?private weak var virtualMachineView: VPhoneVirtualMachineView?private(set) var touchIDMonitor: VPhoneTouchIDMonitor?private var ecid: String?@@ -22,8 +22,8 @@ class VPhoneWindowController: NSObject, NSToolbarDelegate {screenWidth: Int,screenHeight: Int,screenScale: Double,- keyHelper: VPhoneKeyHelper,- control: VPhoneControl,+ keySender: VPhoneVirtualMachineKeySender,+ control: VPhoneGuestControl,ecid: String?,) {self.control = control@@ -32,7 +32,7 @@ class VPhoneWindowController: NSObject, NSToolbarDelegate {let view = VPhoneVirtualMachineView()view.virtualMachine = vmview.capturesSystemKeys = true- view.keyHelper = keyHelper+ view.keySender = keySenderview.control = controlvirtualMachineView = viewlet vmView: NSView = view@@ -74,7 +74,7 @@ class VPhoneWindowController: NSObject, NSToolbarDelegate {controller.showWindow(nil)windowController = controller- keyHelper.window = window+ keySender.window = windowwindow.makeKeyAndOrderFront(nil)window.makeFirstResponder(view)NSApp.activate(ignoringOtherApps: true)@@ -89,7 +89,7 @@ class VPhoneWindowController: NSObject, NSToolbarDelegate {Task { @MainActor inguard let self, let window, let control = self.control else { return }window.title = control.isConnected ? "vphone — Connected" : "vphone — Disconnected"- window.subtitle = self.makeSubtitle(ip: control.isConnected ? control.guestIP : nil)+ window.subtitle = self.makeSubtitle(ip: control.isConnected ? control.guestIPAddress : nil)}}}diff --git a/sources/VPhoneVMKit/VPhoneBootCLI+VirtualMachine.swift b/sources/VPhoneVirtualMachineKit/VPhoneBootCLI+VirtualMachine.swiftsimilarity index 100%rename from sources/VPhoneVMKit/VPhoneBootCLI+VirtualMachine.swiftrename to sources/VPhoneVirtualMachineKit/VPhoneBootCLI+VirtualMachine.swiftdiff --git a/sources/VPhoneVMKit/VPhoneGuestApp.swift b/sources/VPhoneVirtualMachineKit/VPhoneGuestApp.swiftsimilarity index 87%rename from sources/VPhoneVMKit/VPhoneGuestApp.swiftrename to sources/VPhoneVirtualMachineKit/VPhoneGuestApp.swiftindex 18ca90f9..66893696 100644--- a/sources/VPhoneVMKit/VPhoneGuestApp.swift+++ b/sources/VPhoneVirtualMachineKit/VPhoneGuestApp.swift@@ -7,7 +7,7 @@ import VPhoneCore/// This exists so `vphone-vm`'s `main.swift` stays a parse and a call. The/// NSApplication wiring is an implementation detail of running a guest, not/// something an entry point should be spelling out, and keeping it here means-/// `VPhoneAppDelegate` does not have to be public — which in turn keeps every+/// `VPhoneVirtualMachineAppDelegate` does not have to be public — which in turn keeps every/// `NSApplicationDelegate` method it implements internal.public enum VPhoneGuestApp {/// Run the guest. Returns only when the application terminates.@@ -17,7 +17,7 @@ public enum VPhoneGuestApp {@MainActorpublic static func run(_ boot: VPhoneBootCLI) -> Never {let app = NSApplication.shared- let delegate = VPhoneAppDelegate(cli: boot)+ let delegate = VPhoneVirtualMachineAppDelegate(cli: boot)app.delegate = delegateapp.run()// NSApplication.run() does not return through here in practice: thediff --git a/sources/VPhoneVMKit/VPhoneHostControl.swift b/sources/VPhoneVirtualMachineKit/VPhoneHostAutomationServer.swiftsimilarity index 98%rename from sources/VPhoneVMKit/VPhoneHostControl.swiftrename to sources/VPhoneVirtualMachineKit/VPhoneHostAutomationServer.swiftindex beaafca9..bb4064ce 100644--- a/sources/VPhoneVMKit/VPhoneHostControl.swift+++ b/sources/VPhoneVirtualMachineKit/VPhoneHostAutomationServer.swift@@ -24,14 +24,14 @@ import ImageIO/// image returned as `"image":"<base64>"` in the response. Pass `"screen":false`/// to skip the capture.@MainActor-class VPhoneHostControl {+class VPhoneHostAutomationServer {private let socketPath: Stringprivate var listenFD: Int32 = -1private let acceptQueue = DispatchQueue(label: "vphone.hostcontrol.accept")private weak var captureView: VPhoneVirtualMachineView?private var screenRecorder: VPhoneScreenRecorder?- private weak var control: VPhoneControl?+ private weak var control: VPhoneGuestControl?/// Thread-safe box for passing results between main actor and accept queue.private final class ResultBox: @unchecked Sendable {@@ -55,7 +55,7 @@ class VPhoneHostControl {func start(captureView: VPhoneVirtualMachineView,screenRecorder: VPhoneScreenRecorder,- control: VPhoneControl,+ control: VPhoneGuestControl,screenWidth: Int,screenHeight: Int) {@@ -173,7 +173,7 @@ class VPhoneHostControl {// MARK: - Accept Loop- private nonisolated static func acceptLoop(listenFD: Int32, controller: VPhoneHostControl?) {+ private nonisolated static func acceptLoop(listenFD: Int32, controller: VPhoneHostAutomationServer?) {while true {let clientFD = accept(listenFD, nil, nil)guard clientFD >= 0 else { break }@@ -193,7 +193,7 @@ class VPhoneHostControl {}}- private nonisolated static func handleClient(_ fd: Int32, controller: VPhoneHostControl?) {+ private nonisolated static func handleClient(_ fd: Int32, controller: VPhoneHostAutomationServer?) {defer { close(fd) }guard let line = readLine(from: fd) else { return }diff --git a/sources/VPhoneVMKit/VPhoneAppDelegate.swift b/sources/VPhoneVirtualMachineKit/VPhoneVirtualMachineAppDelegate.swiftsimilarity index 92%rename from sources/VPhoneVMKit/VPhoneAppDelegate.swiftrename to sources/VPhoneVirtualMachineKit/VPhoneVirtualMachineAppDelegate.swiftindex bab2a4d3..4dac6f34 100644--- a/sources/VPhoneVMKit/VPhoneAppDelegate.swift+++ b/sources/VPhoneVirtualMachineKit/VPhoneVirtualMachineAppDelegate.swift@@ -3,17 +3,17 @@ import Foundationimport Virtualizationimport VPhoneCore-class VPhoneAppDelegate: NSObject, NSApplicationDelegate {+class VPhoneVirtualMachineAppDelegate: NSObject, NSApplicationDelegate {private let cli: VPhoneBootCLIprivate var vm: VPhoneVirtualMachine?- private var control: VPhoneControl?- private var windowController: VPhoneWindowController?+ private var control: VPhoneGuestControl?+ private var windowController: VPhoneVirtualMachineWindowController?private var menuController: VPhoneMenuController?private var fileWindowController: VPhoneFileWindowController?private var keychainWindowController: VPhoneKeychainWindowController?private var appWindowController: VPhoneAppWindowController?private var locationProvider: VPhoneLocationProvider?- private var hostControl: VPhoneHostControl?+ private var hostAutomationServer: VPhoneHostAutomationServer?private var cameraServer: VPhoneCameraServer?private var apiProxy: VPhoneAPIProxy?private var sigintSource: DispatchSourceSignal?@@ -51,7 +51,7 @@ class VPhoneAppDelegate: NSObject, NSApplicationDelegate {let options = try cli.resolveOptions()guard options.romURL == nil || FileManager.default.fileExists(atPath: options.romURL!.path) else {- throw VPhoneError.romNotFound(options.romURL!.path)+ throw VPhoneVirtualMachineError.romNotFound(options.romURL!.path)}print("=== vphone-cli ===")@@ -79,7 +79,7 @@ class VPhoneAppDelegate: NSObject, NSApplicationDelegate {try await vm.start(forceDFU: cli.dfu)- let control = VPhoneControl()+ let control = VPhoneGuestControl()self.control = controlif !cli.dfu {let vphonedURL = URL(fileURLWithPath: cli.vphonedBin)@@ -104,19 +104,19 @@ class VPhoneAppDelegate: NSObject, NSApplicationDelegate {print("[api] OpenAPI: \(url.appending(path: "openapi.json").absoluteString)")}} else if cli.apiListen != nil {- throw VPhoneError.apiSocketUnavailable+ throw VPhoneVirtualMachineError.apiSocketUnavailable}}if !cli.noGraphics {- let keyHelper = VPhoneKeyHelper(vm: vm, control: control)- let wc = VPhoneWindowController()+ let keySender = VPhoneVirtualMachineKeySender(vm: vm, control: control)+ let wc = VPhoneVirtualMachineWindowController()wc.showWindow(for: vm.virtualMachine,screenWidth: options.screenWidth,screenHeight: options.screenHeight,screenScale: options.screenScale,- keyHelper: keyHelper,+ keySender: keySender,control: control,ecid: vm.ecidHex,)@@ -131,7 +131,7 @@ class VPhoneAppDelegate: NSObject, NSApplicationDelegate {let appWC = VPhoneAppWindowController()appWindowController = appWC- let mc = VPhoneMenuController(keyHelper: keyHelper, control: control)+ let mc = VPhoneMenuController(keySender: keySender, control: control)mc.vm = vmmc.captureView = wc.captureViewmc.touchIDMonitor = wc.touchIDMonitor@@ -165,15 +165,15 @@ class VPhoneAppDelegate: NSObject, NSApplicationDelegate {let socketPath = options.configURL.deletingLastPathComponent().appendingPathComponent("vphone.sock").path- let hc = VPhoneHostControl(socketPath: socketPath)- hc.start(+ let server = VPhoneHostAutomationServer(socketPath: socketPath)+ server.start(captureView: wc.captureView!,screenRecorder: recorder,control: control,screenWidth: options.screenWidth,screenHeight: options.screenHeight,)- hostControl = hc+ hostAutomationServer = server// Wire location toggle through onConnect/onDisconnectcontrol.onConnect = { [weak mc, weak provider = locationProvider] caps in@@ -265,7 +265,7 @@ class VPhoneAppDelegate: NSObject, NSApplicationDelegate {}func applicationWillTerminate(_: Notification) {- hostControl?.stop()+ hostAutomationServer?.stop()apiProxy?.stop()control?.stop()}diff --git a/sources/VPhoneVMKit/VM/VPhoneVirtualMachine.swift b/sources/VPhoneVirtualMachineKit/VirtualMachine/VPhoneVirtualMachine.swiftsimilarity index 98%rename from sources/VPhoneVMKit/VM/VPhoneVirtualMachine.swiftrename to sources/VPhoneVirtualMachineKit/VirtualMachine/VPhoneVirtualMachine.swiftindex e6162fb6..929806be 100644--- a/sources/VPhoneVMKit/VM/VPhoneVirtualMachine.swift+++ b/sources/VPhoneVirtualMachineKit/VirtualMachine/VPhoneVirtualMachine.swift@@ -155,7 +155,7 @@ class VPhoneVirtualMachine: NSObject, VZVirtualMachineDelegate {// Storageguard FileManager.default.fileExists(atPath: options.diskURL.path) else {- throw VPhoneError.diskNotFound(options.diskURL.path)+ throw VPhoneVirtualMachineError.diskNotFound(options.diskURL.path)}let attachment = try VZDiskImageStorageDeviceAttachment(url: options.diskURL, readOnly: false)config.storageDevices = [VZVirtioBlockDeviceConfiguration(attachment: attachment)]@@ -237,7 +237,7 @@ class VPhoneVirtualMachine: NSObject, VZVirtualMachineDelegate {// Kernel GDB debug stub (auto-assigned by default; fixed when explicitly requested)if let kernelDebugPort = options.kernelDebugPort {guard (6000 ... 65535).contains(kernelDebugPort) else {- throw VPhoneError.invalidKernelDebugPort(kernelDebugPort)+ throw VPhoneVirtualMachineError.invalidKernelDebugPort(kernelDebugPort)}if let kernelDebugStub = Dynamic._VZGDBDebugStubConfiguration(port: kernelDebugPort).asObjectdiff --git a/sources/VPhoneVMKit/VM/VPhoneError.swift b/sources/VPhoneVirtualMachineKit/VirtualMachine/VPhoneVirtualMachineError.swiftsimilarity index 93%rename from sources/VPhoneVMKit/VM/VPhoneError.swiftrename to sources/VPhoneVirtualMachineKit/VirtualMachine/VPhoneVirtualMachineError.swiftindex 36e43ca3..beef5bba 100644--- a/sources/VPhoneVMKit/VM/VPhoneError.swift+++ b/sources/VPhoneVirtualMachineKit/VirtualMachine/VPhoneVirtualMachineError.swift@@ -1,6 +1,6 @@import Foundation-enum VPhoneError: Error, CustomStringConvertible {+enum VPhoneVirtualMachineError: Error, CustomStringConvertible {case hardwareModelNotSupportedcase romNotFound(String)case diskNotFound(String)diff --git a/sources/VPhoneVMKit/VM/VPhoneHardwareModel.swift b/sources/VPhoneVirtualMachineKit/VirtualMachine/VPhoneVirtualMachineHardwareModel.swiftsimilarity index 94%rename from sources/VPhoneVMKit/VM/VPhoneHardwareModel.swiftrename to sources/VPhoneVirtualMachineKit/VirtualMachine/VPhoneVirtualMachineHardwareModel.swiftindex e61d335d..63c3bb54 100644--- a/sources/VPhoneVMKit/VM/VPhoneHardwareModel.swift+++ b/sources/VPhoneVirtualMachineKit/VirtualMachine/VPhoneVirtualMachineHardwareModel.swift@@ -29,7 +29,7 @@ enum VPhoneHardware {.asObject as! VZMacHardwareModelguard model.isSupported else {- throw VPhoneError.hardwareModelNotSupported+ throw VPhoneVirtualMachineError.hardwareModelNotSupported}return model}diff --git a/sources/VPhoneVMKit/VM/VPhoneVirtualMachineView.swift b/sources/VPhoneVirtualMachineKit/VirtualMachine/VPhoneVirtualMachineView.swiftsimilarity index 98%rename from sources/VPhoneVMKit/VM/VPhoneVirtualMachineView.swiftrename to sources/VPhoneVirtualMachineKit/VirtualMachine/VPhoneVirtualMachineView.swiftindex 046458e3..48b1dbcd 100644--- a/sources/VPhoneVMKit/VM/VPhoneVirtualMachineView.swift+++ b/sources/VPhoneVirtualMachineKit/VirtualMachine/VPhoneVirtualMachineView.swift@@ -5,8 +5,8 @@ import Virtualizationimport VPhoneCoreclass VPhoneVirtualMachineView: VZVirtualMachineView {- var keyHelper: VPhoneKeyHelper?- weak var control: VPhoneControl?+ var keySender: VPhoneVirtualMachineKeySender?+ weak var control: VPhoneGuestControl?private var currentTouchSwipeAim: Int = 0private var isDragHighlightVisible = false@@ -76,15 +76,15 @@ class VPhoneVirtualMachineView: VZVirtualMachineView {}override func rightMouseDown(with _: NSEvent) {- guard let keyHelper else { return }- keyHelper.sendHome()+ guard let keySender else { return }+ keySender.sendHome()}override func performKeyEquivalent(with event: NSEvent) -> Bool {if event.modifierFlags.contains(.command),event.charactersIgnoringModifiers == "h"{- keyHelper?.sendHome()+ keySender?.sendHome()return true}return super.performKeyEquivalent(with: event)diff --git a/sources/vphone-cli/VPhoneCLI.swift b/sources/vphone-cli/VPhoneCLI.swiftindex d3612abd..01ad9dfe 100644--- a/sources/vphone-cli/VPhoneCLI.swift+++ b/sources/vphone-cli/VPhoneCLI.swift@@ -8,9 +8,9 @@ struct VPhoneCLI: ParsableCommand {commandName: "vphone-cli",abstract: "Boot a virtual iPhone or patch firmware with the Swift pipeline",subcommands: [- VPhoneBootCLI.self, PatchFirmwareCLI.self, PatchComponentCLI.self, VPhoneVMCommand.self,- VPhoneFWCommand.self, VPhoneRestoreCommand.self, VPhoneRecoveryProbeCommand.self,- VPhoneCFWCommand.self,+ VPhoneBootCLI.self, PatchFirmwareCLI.self, PatchComponentCLI.self, VPhoneVirtualMachineCommand.self,+ VPhoneFirmwareCommand.self, VPhoneRestoreCommand.self, VPhoneRecoveryProbeCommand.self,+ VPhoneCustomFirmwareCommand.self,VPhoneHostCommand.self,VPhoneSignCommand.self, VPhoneDumpEntitlementsCommand.self,],@@ -154,9 +154,9 @@ struct PatchComponentCLI: ParsableCommand {case .kernelJB:// Mirrors the pipeline's jb kernel layer. In FirmwarePipeline each kernel// patcher runs on the *original* payload independently, so running- // KernelJBPatcher standalone faithfully reproduces JB hook behavior+ // KernelJailbreakPatcher standalone faithfully reproduces JB hook behavior// without the base patcher or the rest of the boot chain.- let patcher = KernelJBPatcher(data: payload, verbose: !quiet)+ let patcher = KernelJailbreakPatcher(data: payload, verbose: !quiet)// Mirror the pipeline's per-base gating: apply the iOS-27-only patches when// --target-os is 27.x, skip them for an explicit non-27 target. With no// --target-os, default to applying them so the dev/test tool exercises thediff --git a/sources/vphone-cli/VPhoneCFWDSCVerbsCLI.swift b/sources/vphone-cli/VPhoneCustomFirmwareDyldSharedCacheVerbsCLI.swiftsimilarity index 86%rename from sources/vphone-cli/VPhoneCFWDSCVerbsCLI.swiftrename to sources/vphone-cli/VPhoneCustomFirmwareDyldSharedCacheVerbsCLI.swiftindex 32a15209..dffd3dea 100644--- a/sources/vphone-cli/VPhoneCFWDSCVerbsCLI.swift+++ b/sources/vphone-cli/VPhoneCustomFirmwareDyldSharedCacheVerbsCLI.swift@@ -1,4 +1,4 @@-// VPhoneCFWDSCVerbsCLI.swift — `cfw` verbs for the dyld-shared-cache patchers.+// VPhoneCustomFirmwareDyldSharedCacheVerbsCLI.swift — `cfw` verbs for the dyld-shared-cache patchers.//// Each command here is a thin face over a type in `FirmwarePatcher/DSC/Patchers/`,// and each one answers to the same verb name, the same positional arguments and@@ -21,17 +21,17 @@ import ArgumentParserimport FirmwarePatcherimport Foundation-enum VPhoneCFWDSCVerbs {- /// Registered into `vphone-cli cfw` by `VPhoneCFWCommand`.+enum VPhoneCustomFirmwareDyldSharedCacheVerbs {+ /// Registered into `vphone-cli cfw` by `VPhoneCustomFirmwareCommand`.static let all: [ParsableCommand.Type] = [- VPhoneCFWPatchHVVMMDSCCommand.self,- VPhoneCFWPatchIOMFBSwapEndCommand.self,- VPhoneCFWPatchIOMFBForceKernCommand.self,- VPhoneCFWPatchDSCMaxSlideCommand.self,- VPhoneCFWPatchLSDEmbeddedRegCommand.self,- VPhoneCFWPatchXPCLWCRCommand.self,- VPhoneCFWPatchLockdownModeCommand.self,- VPhoneCFWPatchCameraDSCCommand.self,+ VPhoneCustomFirmwarePatchHVVMMDyldSharedCacheCommand.self,+ VPhoneCustomFirmwarePatchIOMFBSwapEndCommand.self,+ VPhoneCustomFirmwarePatchIOMFBForceKernCommand.self,+ VPhoneCustomFirmwarePatchDyldSharedCacheMaxSlideCommand.self,+ VPhoneCustomFirmwarePatchLSDEmbeddedRegCommand.self,+ VPhoneCustomFirmwarePatchXPCLWCRCommand.self,+ VPhoneCustomFirmwarePatchLockdownModeCommand.self,+ VPhoneCustomFirmwarePatchCameraDyldSharedCacheCommand.self,]/// Where the patchers' progress lines go.@@ -64,7 +64,7 @@ enum VPhoneCFWDSCVerbs {// MARK: - patch-hv-vmm-dsc-struct VPhoneCFWPatchHVVMMDSCCommand: ParsableCommand {+struct VPhoneCustomFirmwarePatchHVVMMDyldSharedCacheCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "patch-hv-vmm-dsc",abstract: "Mangle the \"kern.hv_vmm_present\" sysctl name in the userland dyld cache",@@ -100,17 +100,17 @@ struct VPhoneCFWPatchHVVMMDSCCommand: ParsableCommand {var dryRun = falsefunc run() throws {- try DSCHVVMMPatcher.patch(+ try DyldSharedCacheHVVMMPatcher.patch(chunksDirectory: chunksDirectory,dryRun: dryRun,- log: VPhoneCFWDSCVerbs.stdout,+ log: VPhoneCustomFirmwareDyldSharedCacheVerbs.stdout,)}}// MARK: - patch-iomfb-swapend-struct VPhoneCFWPatchIOMFBSwapEndCommand: ParsableCommand {+struct VPhoneCustomFirmwarePatchIOMFBSwapEndCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "patch-iomfb-swapend",abstract: "Shrink IOMobileFramebuffer's _kern_SwapEnd payload to what the base userclient accepts",@@ -144,26 +144,26 @@ struct VPhoneCFWPatchIOMFBSwapEndCommand: ParsableCommand {@Option(name: .customLong("target-size"),help: "Payload size the base kernel's userclient accepts (hex or decimal)",- transform: VPhoneCFWDSCVerbs.parseCInteger,+ transform: VPhoneCustomFirmwareDyldSharedCacheVerbs.parseCInteger,)- var targetSize: UInt32 = DSCIOMFBSwapEndPatcher.defaultTargetSize+ var targetSize: UInt32 = DyldSharedCacheIOMFBSwapEndPatcher.defaultTargetSize@Flag(name: .customLong("dry-run"), help: "Report the site and the rewrite, and write nothing")var dryRun = falsefunc run() throws {- try DSCIOMFBSwapEndPatcher.patch(+ try DyldSharedCacheIOMFBSwapEndPatcher.patch(chunksDirectory: chunksDirectory,targetSize: targetSize,dryRun: dryRun,- log: VPhoneCFWDSCVerbs.stdout,+ log: VPhoneCustomFirmwareDyldSharedCacheVerbs.stdout,)}}// MARK: - patch-iomfb-force-kern-struct VPhoneCFWPatchIOMFBForceKernCommand: ParsableCommand {+struct VPhoneCustomFirmwarePatchIOMFBForceKernCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "patch-iomfb-force-kern",abstract: "Retarget IOMobileFramebuffer's public Swap* trampolines onto their _kern_Swap* siblings",@@ -184,7 +184,7 @@ struct VPhoneCFWPatchIOMFBForceKernCommand: ParsableCommand {side file has to be present; without it there would be zero pairs tofind, which would read as "this userland has none".- Pairs with the KernelJBPatchIomfbSwap kernel patches, which make the+ Pairs with the KernelJailbreakPatchIomfbSwap kernel patches, which make theuserclient accept 27's native 0x6e0 SwapEnd struct. Modified pages arere-attested; an already-forced cache is a no-op.""",@@ -200,17 +200,17 @@ struct VPhoneCFWPatchIOMFBForceKernCommand: ParsableCommand {var dryRun = falsefunc run() throws {- try DSCIOMFBForceKernPatcher.patch(+ try DyldSharedCacheIOMFBForceKernPatcher.patch(chunksDirectory: chunksDirectory,dryRun: dryRun,- log: VPhoneCFWDSCVerbs.stdout,+ log: VPhoneCustomFirmwareDyldSharedCacheVerbs.stdout,)}}// MARK: - patch-dsc-maxslide-struct VPhoneCFWPatchDSCMaxSlideCommand: ParsableCommand {+struct VPhoneCustomFirmwarePatchDyldSharedCacheMaxSlideCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "patch-dsc-maxslide",abstract: "Zero dyld_cache_header.maxSlide when the cache would overflow the kernel's shared region",@@ -247,7 +247,7 @@ struct VPhoneCFWPatchDSCMaxSlideCommand: ParsableCommand {var force = falsefunc run() throws {- try DSCMaxSlidePatcher.patch(+ try DyldSharedCacheMaxSlidePatcher.patch(chunksDirectory: chunksDirectory,dryRun: dryRun,force: force,@@ -257,7 +257,7 @@ struct VPhoneCFWPatchDSCMaxSlideCommand: ParsableCommand {// MARK: - patch-lsd-embedded-reg-struct VPhoneCFWPatchLSDEmbeddedRegCommand: ParsableCommand {+struct VPhoneCustomFirmwarePatchLSDEmbeddedRegCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "patch-lsd-embedded-reg",abstract: "Open lsd's embedded-registration path so JB app installs can register",@@ -291,17 +291,17 @@ struct VPhoneCFWPatchLSDEmbeddedRegCommand: ParsableCommand {var dryRun = falsefunc run() throws {- try DSCLSDEmbeddedRegPatcher.patch(+ try DyldSharedCacheLSDEmbeddedRegPatcher.patch(chunksDirectory: chunksDirectory,dryRun: dryRun,- log: VPhoneCFWDSCVerbs.stdout,+ log: VPhoneCustomFirmwareDyldSharedCacheVerbs.stdout,)}}// MARK: - patch-xpc-lwcr-struct VPhoneCFWPatchXPCLWCRCommand: ParsableCommand {+struct VPhoneCustomFirmwarePatchXPCLWCRCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "patch-xpc-lwcr",abstract: "Stop libxpc's Lightweight Code Requirement self-check from brk-aborting",@@ -333,17 +333,17 @@ struct VPhoneCFWPatchXPCLWCRCommand: ParsableCommand {var dryRun = falsefunc run() throws {- try DSCXPCLWCRPatcher.apply(+ try DyldSharedCacheXPCLWCRPatcher.apply(directory: chunksDirectory,dryRun: dryRun,- log: VPhoneCFWDSCVerbs.stdout,+ log: VPhoneCustomFirmwareDyldSharedCacheVerbs.stdout,)}}// MARK: - patch-lockdown-mode-struct VPhoneCFWPatchLockdownModeCommand: ParsableCommand {+struct VPhoneCustomFirmwarePatchLockdownModeCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "patch-lockdown-mode",abstract: "Stop os_lockdown_mode_enabled() aborting when the Lockdown Mode sysctl is missing",@@ -373,17 +373,17 @@ struct VPhoneCFWPatchLockdownModeCommand: ParsableCommand {var dryRun = falsefunc run() throws {- try DSCLockdownModePatcher.patch(+ try DyldSharedCacheLockdownModePatcher.patch(chunksDirectory: chunksDirectory,dryRun: dryRun,- log: VPhoneCFWDSCVerbs.stdout,+ log: VPhoneCustomFirmwareDyldSharedCacheVerbs.stdout,)}}// MARK: - patch-camera-dsc-struct VPhoneCFWPatchCameraDSCCommand: ParsableCommand {+struct VPhoneCustomFirmwarePatchCameraDyldSharedCacheCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "patch-camera-dsc",abstract: "Stub the AVFoundation init-time validation that crashes Camera.app on a VM",@@ -426,12 +426,12 @@ struct VPhoneCFWPatchCameraDSCCommand: ParsableCommand {var force = falsefunc run() throws {- try DSCCameraPatcher.applyAll(+ try DyldSharedCacheCameraPatcher.applyAll(chunksDirectory: chunksDirectory,symbolCacheURL: dscHeader,dryRun: dryRun,force: force,- log: VPhoneCFWDSCVerbs.stdout,+ log: VPhoneCustomFirmwareDyldSharedCacheVerbs.stdout,)}}diff --git a/sources/vphone-cli/VPhoneCFWInstaller.swift b/sources/vphone-cli/VPhoneCustomFirmwareInstaller.swiftsimilarity index 96%rename from sources/vphone-cli/VPhoneCFWInstaller.swiftrename to sources/vphone-cli/VPhoneCustomFirmwareInstaller.swiftindex f349baf9..9385324a 100644--- a/sources/vphone-cli/VPhoneCFWInstaller.swift+++ b/sources/vphone-cli/VPhoneCustomFirmwareInstaller.swift@@ -7,10 +7,10 @@ import VPhoneSign/// Host-side JB system installation. The VM must be off: all writes go to its/// mounted Disk.img, while the source IPSWs and any other VM stay untouched.-struct VPhoneCFWInstaller {+struct VPhoneCustomFirmwareInstaller {let bundle: URLlet resources: VPhoneResources- let forceDSCMaxSlide: Bool+ let forceDyldSharedCacheMaxSlide: Boolprivate var executable: URL {VPhoneResources.runningExecutable()@@ -23,19 +23,19 @@ struct VPhoneCFWInstaller {static func elevate(bundle: URL,resources: VPhoneResources,- forceDSCMaxSlide: Bool,+ forceDyldSharedCacheMaxSlide: Bool,rootPopup: Bool,environment: [String: String] = [:],verbose: Bool = true,) throws -> Int32 {let exe = VPhoneResources.runningExecutable()var args = ["cfw", "install-root", bundle.path, "--resources", resources.base.path]- if forceDSCMaxSlide {+ if forceDyldSharedCacheMaxSlide {args.append("--force-dsc-maxslide")}if geteuid() == 0 {- try VPhoneCFWInstaller(bundle: bundle, resources: resources,- forceDSCMaxSlide: forceDSCMaxSlide).run()+ try VPhoneCustomFirmwareInstaller(bundle: bundle, resources: resources,+ forceDyldSharedCacheMaxSlide: forceDyldSharedCacheMaxSlide).run()return 0}if rootPopup {@@ -142,7 +142,7 @@ struct VPhoneCFWInstaller {try patch("patch-lockdown-mode", [dsc.path])} else if version.hasPrefix("26.0") || version.hasPrefix("18.") {try patch("patch-iomfb-swapend", [dsc.path, "--target-size", "0x560"])- } else if forceDSCMaxSlide {+ } else if forceDyldSharedCacheMaxSlide {try patch("patch-dsc-maxslide", [dsc.path, "--force"])}try patchMachO(system: system, work: work,@@ -199,7 +199,7 @@ struct VPhoneCFWInstaller {if !((try? fm.contentsOfDirectory(atPath: os.path))?.isEmpty == false &&(try? fm.contentsOfDirectory(atPath: app.path))?.isEmpty == false){- let paths = try CFWDaemons.cryptexPaths(+ let paths = try CustomFirmwareDaemons.cryptexPaths(buildManifest: restore.appendingPathComponent("iPhone-BuildManifest.plist"),)let encrypted = restore.appendingPathComponent(paths.systemOS)@@ -262,7 +262,7 @@ struct VPhoneCFWInstaller {}let temp = work.appendingPathComponent("launchd.plist")try fm.copyItem(at: backup, to: temp)- try CFWDaemons.injectDaemon(into: temp, name: "vphoned", from: daemon)+ try CustomFirmwareDaemons.injectDaemon(into: temp, name: "vphoned", from: daemon)try replace(temp, at: launchd, mode: 0o644)}@@ -399,7 +399,7 @@ struct VPhoneCFWInstaller {}}-struct VPhoneCFWInstallRootCommand: ParsableCommand {+struct VPhoneCustomFirmwareInstallRootCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "install-root", abstract: "Internal privileged JB disk install",shouldDisplay: false,@@ -407,13 +407,13 @@ struct VPhoneCFWInstallRootCommand: ParsableCommand {@Argument(help: "VM bundle path") var bundle: String@Option(help: "Resource base") var resources: String- @Flag(name: .customLong("force-dsc-maxslide")) var forceDSCMaxSlide = false+ @Flag(name: .customLong("force-dsc-maxslide")) var forceDyldSharedCacheMaxSlide = falsefunc run() throws {- try VPhoneCFWInstaller(+ try VPhoneCustomFirmwareInstaller(bundle: URL(fileURLWithPath: bundle),resources: VPhoneResources(base: URL(fileURLWithPath: resources)),- forceDSCMaxSlide: forceDSCMaxSlide,+ forceDyldSharedCacheMaxSlide: forceDyldSharedCacheMaxSlide,).run()}}diff --git a/sources/vphone-cli/VPhoneCFWMachOVerbsCLI.swift b/sources/vphone-cli/VPhoneCustomFirmwareMachOVerbsCLI.swiftsimilarity index 88%rename from sources/vphone-cli/VPhoneCFWMachOVerbsCLI.swiftrename to sources/vphone-cli/VPhoneCustomFirmwareMachOVerbsCLI.swiftindex 73a11fc5..fb11f28a 100644--- a/sources/vphone-cli/VPhoneCFWMachOVerbsCLI.swift+++ b/sources/vphone-cli/VPhoneCustomFirmwareMachOVerbsCLI.swift@@ -1,6 +1,6 @@-// VPhoneCFWMachOVerbsCLI.swift — `cfw` verbs for the standalone Mach-O patchers.+// VPhoneCustomFirmwareMachOVerbsCLI.swift — `cfw` verbs for the standalone Mach-O patchers.//-// Six faces over `FirmwarePatcher/CFW/Patches/`, replacing+// Six faces over `FirmwarePatcher/CustomFirmware/ExecutablePatches/`, replacing// `"$PYTHON3" scripts/patchers/cfw.py <verb> <binary>` in `cfw_install*.sh`,// `cfw-kit/` and `scripts/patch_hv_vmm_userland.sh`. The verb names, their// positional arguments and their flags are exactly the Python's — `cfw.py`@@ -23,7 +23,7 @@// the binary on the next line, which rebuilds the signature whole.//// STDOUT. Each library type already prints its own progress, so — as with-// `patch-build-version` and friends in VPhoneCFWPatchCLI.swift — these commands+// `patch-build-version` and friends in VPhoneCustomFirmwarePatchCLI.swift — these commands// print nothing of their own. The Python writes every line to stdout, so the// log closure is `print` even for the two types whose default is stderr.//@@ -90,7 +90,7 @@ private func requireUntruncatedMachO(at url: URL) throws {// MARK: - patch-seputil-struct VPhoneCFWPatchSeputilCommand: ParsableCommand {+struct VPhoneCustomFirmwarePatchSeputilCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "patch-seputil",abstract: "Pin seputil's gigalocker path to /AA.gl instead of the device UUID",@@ -118,13 +118,13 @@ struct VPhoneCFWPatchSeputilCommand: ParsableCommand {try requireUntruncatedMachO(at: binary)// reattest: false — the Python leaves the signature stale and// `cfw_install*.sh` re-signs on the next line. Parity in bytes.- try CFWSeputil.patch(fileAt: binary, reattest: false, log: machOVerbLog)+ try CustomFirmwareSeputil.patch(fileAt: binary, reattest: false, log: machOVerbLog)}}// MARK: - patch-launchd-cache-loader-struct VPhoneCFWPatchLaunchdCacheLoaderCommand: ParsableCommand {+struct VPhoneCustomFirmwarePatchLaunchdCacheLoaderCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "patch-launchd-cache-loader",abstract: "Open the launchd_unsecure_cache gate so a modified launchd.plist loads",@@ -153,7 +153,7 @@ struct VPhoneCFWPatchLaunchdCacheLoaderCommand: ParsableCommand {try requireUntruncatedMachO(at: binary)// Off by default in the library and off in the Python: the caller// re-signs. Spelled out so the parity choice is readable here.- try CFWCacheLoaderPatcher.patch(+ try CustomFirmwareCacheLoaderPatcher.patch(fileAt: binary,reattestsCodeSignature: false,log: machOVerbLog,@@ -163,7 +163,7 @@ struct VPhoneCFWPatchLaunchdCacheLoaderCommand: ParsableCommand {// MARK: - patch-mobileactivationd-struct VPhoneCFWPatchMobileactivationdCommand: ParsableCommand {+struct VPhoneCustomFirmwarePatchMobileactivationdCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "patch-mobileactivationd",abstract: "Force -[DeviceType should_hactivate] to return YES",@@ -189,13 +189,13 @@ struct VPhoneCFWPatchMobileactivationdCommand: ParsableCommand {func run() throws {try requireUntruncatedMachO(at: binary)// resign: false — the Python's bytes, for the `ldid_sign` that follows.- try CFWMobileactivationd.patch(fileAt: binary, resign: false, log: machOVerbLog)+ try CustomFirmwareMobileactivationd.patch(fileAt: binary, resign: false, log: machOVerbLog)}}// MARK: - patch-launchd-jetsam-struct VPhoneCFWPatchLaunchdJetsamCommand: ParsableCommand {+struct VPhoneCustomFirmwarePatchLaunchdJetsamCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "patch-launchd-jetsam",abstract: "Bypass the jetsam panic guard in /sbin/launchd",@@ -223,13 +223,13 @@ struct VPhoneCFWPatchLaunchdJetsamCommand: ParsableCommand {try requireUntruncatedMachO(at: binary)// Off in the library and off in the Python: cfw_install_{dev,jb,exp}.sh// and cfw-kit/jb/install.sh all run ldid over the result.- try CFWJetsamPatcher.patch(fileAt: binary, reattest: false, log: machOVerbLog)+ try CustomFirmwareJetsamPatcher.patch(fileAt: binary, reattest: false, log: machOVerbLog)}}// MARK: - patch-watchdogd-struct VPhoneCFWPatchWatchdogdCommand: ParsableCommand {+struct VPhoneCustomFirmwarePatchWatchdogdCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "patch-watchdogd",abstract: "Stop watchdogd caching kern.hv_vmm_present as true",@@ -260,13 +260,13 @@ struct VPhoneCFWPatchWatchdogdCommand: ParsableCommand {func run() throws {try requireUntruncatedMachO(at: binary)- try CFWWatchdogd.patch(at: binary, dryRun: dryRun, log: machOVerbLog)+ try CustomFirmwareWatchdogd.patch(at: binary, dryRun: dryRun, log: machOVerbLog)}}// MARK: - patch-diskimagesiod-struct VPhoneCFWPatchDiskimagesiodCommand: ParsableCommand {+struct VPhoneCustomFirmwarePatchDiskimagesiodCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "patch-diskimagesiod",abstract: "Force -[DIDiskArb isMountCompleteWithExpectedCount:diskTracker:] to return YES",@@ -291,23 +291,23 @@ struct VPhoneCFWPatchDiskimagesiodCommand: ParsableCommand {try requireUntruncatedMachO(at: binary)// Off in the library and off in the Python: cfw_install.sh re-signs// with the extracted com.apple.diskimagesiod entitlements right after.- try CFWDiskimagesiod.patch(fileAt: binary, reattest: false, log: machOVerbLog)+ try CustomFirmwareDiskimagesiod.patch(fileAt: binary, reattest: false, log: machOVerbLog)}}// MARK: - Registration-enum VPhoneCFWMachOVerbs {- /// Registered into `vphone-cli cfw` by `VPhoneCFWCommand`.+enum VPhoneCustomFirmwareMachOVerbs {+ /// Registered into `vphone-cli cfw` by `VPhoneCustomFirmwareCommand`.////// Ordered as `cfw.py`'s dispatch table lists them, so `--help` and the/// Python's usage block read in the same order.static let all: [ParsableCommand.Type] = [- VPhoneCFWPatchSeputilCommand.self,- VPhoneCFWPatchLaunchdCacheLoaderCommand.self,- VPhoneCFWPatchMobileactivationdCommand.self,- VPhoneCFWPatchLaunchdJetsamCommand.self,- VPhoneCFWPatchWatchdogdCommand.self,- VPhoneCFWPatchDiskimagesiodCommand.self,+ VPhoneCustomFirmwarePatchSeputilCommand.self,+ VPhoneCustomFirmwarePatchLaunchdCacheLoaderCommand.self,+ VPhoneCustomFirmwarePatchMobileactivationdCommand.self,+ VPhoneCustomFirmwarePatchLaunchdJetsamCommand.self,+ VPhoneCustomFirmwarePatchWatchdogdCommand.self,+ VPhoneCustomFirmwarePatchDiskimagesiodCommand.self,]}diff --git a/sources/vphone-cli/VPhoneCFWPatchCLI.swift b/sources/vphone-cli/VPhoneCustomFirmwarePatchCLI.swiftsimilarity index 87%rename from sources/vphone-cli/VPhoneCFWPatchCLI.swiftrename to sources/vphone-cli/VPhoneCustomFirmwarePatchCLI.swiftindex 659322e0..d5166828 100644--- a/sources/vphone-cli/VPhoneCFWPatchCLI.swift+++ b/sources/vphone-cli/VPhoneCustomFirmwarePatchCLI.swift@@ -1,6 +1,6 @@-// VPhoneCFWPatchCLI.swift — the `cfw` subcommands that replace the Python patchers.+// VPhoneCustomFirmwarePatchCLI.swift — the `cfw` subcommands that replace the Python patchers.//-// Each one is a thin face over a type in `FirmwarePatcher/CFW/`. The Python they+// Each one is a thin face over a type in `FirmwarePatcher/CustomFirmware/`. The Python they// replace (`scripts/patchers/cfw.py` and friends) was removed once the// installers switched to these verbs — `git show 78cbeea:scripts/patchers` to// read it. The bar every command here had to clear is that its stdout is the@@ -16,7 +16,7 @@ import Foundation// MARK: - cryptex-paths-struct VPhoneCFWCryptexPathsCommand: ParsableCommand {+struct VPhoneCustomFirmwareCryptexPathsCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "cryptex-paths",abstract: "Print the SystemOS and AppOS Cryptex DMG paths from a BuildManifest",@@ -37,7 +37,7 @@ struct VPhoneCFWCryptexPathsCommand: ParsableCommand {var buildManifest: URLfunc run() throws {- let paths = try CFWDaemons.cryptexPaths(buildManifest: buildManifest)+ let paths = try CustomFirmwareDaemons.cryptexPaths(buildManifest: buildManifest)print(paths.systemOS)print(paths.appOS)}@@ -45,7 +45,7 @@ struct VPhoneCFWCryptexPathsCommand: ParsableCommand {// MARK: - inject-daemons-struct VPhoneCFWInjectDaemonsCommand: ParsableCommand {+struct VPhoneCustomFirmwareInjectDaemonsCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "inject-daemons",abstract: "Merge the staged LaunchDaemons into a launchd.plist",@@ -73,7 +73,7 @@ struct VPhoneCFWInjectDaemonsCommand: ParsableCommand {var daemonDirectory: URLfunc run() throws {- for entry in try CFWDaemons.injectDaemons(into: launchdPlist, fromDirectory: daemonDirectory) {+ for entry in try CustomFirmwareDaemons.injectDaemons(into: launchdPlist, fromDirectory: daemonDirectory) {switch entry {case let .present(daemon): print(" [+] Injected \(daemon.name)")case let .absent(source): print(" [!] Missing \(source), skipping")@@ -84,7 +84,7 @@ struct VPhoneCFWInjectDaemonsCommand: ParsableCommand {// MARK: - inject-daemon-struct VPhoneCFWInjectDaemonCommand: ParsableCommand {+struct VPhoneCustomFirmwareInjectDaemonCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "inject-daemon",abstract: "Merge one LaunchDaemon plist into a launchd.plist under a given label",@@ -111,13 +111,13 @@ struct VPhoneCFWInjectDaemonCommand: ParsableCommand {var name: Stringfunc run() throws {- try CFWDaemons.injectDaemon(into: launchdPlist, name: name, from: source)+ try CustomFirmwareDaemons.injectDaemon(into: launchdPlist, name: name, from: source)}}// MARK: - patch-dropbear-plist-struct VPhoneCFWPatchDropbearPlistCommand: ParsableCommand {+struct VPhoneCustomFirmwarePatchDropbearPlistCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "patch-dropbear-plist",abstract: "Point dropbear at the /var/dropbear host keys instead of generating its own",@@ -136,13 +136,13 @@ struct VPhoneCFWPatchDropbearPlistCommand: ParsableCommand {var plist: URLfunc run() throws {- try CFWDaemons.patchDropbearPlist(at: plist)+ try CustomFirmwareDaemons.patchDropbearPlist(at: plist)}}// MARK: - inject-dylib-struct VPhoneCFWInjectDylibCommand: ParsableCommand {+struct VPhoneCustomFirmwareInjectDylibCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "inject-dylib",abstract: "Insert a weak LC_LOAD_DYLIB into every slice of a Mach-O",@@ -165,7 +165,7 @@ struct VPhoneCFWInjectDylibCommand: ParsableCommand {var dylibPath: Stringfunc run() throws {- let injections = try CFWInjectDylib.inject(dylibPath: dylibPath, into: binary, weak: true, policy: .strip)+ let injections = try CustomFirmwareInjectDylib.inject(dylibPath: dylibPath, into: binary, weak: true, policy: .strip)for injection in injections {let stripped = injection.removedCodeSignature ? ", signature stripped" : ""print(" [+] LC_LOAD_WEAK_DYLIB \(dylibPath) -> \(binary.lastPathComponent) "@@ -176,7 +176,7 @@ struct VPhoneCFWInjectDylibCommand: ParsableCommand {// MARK: - patch-build-version-struct VPhoneCFWPatchBuildVersionCommand: ParsableCommand {+struct VPhoneCustomFirmwarePatchBuildVersionCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "patch-build-version",abstract: "Rewrite ProductBuildVersion in a SystemVersion.plist",@@ -207,13 +207,13 @@ struct VPhoneCFWPatchBuildVersionCommand: ParsableCommand {var dryRun = falsefunc run() throws {- try CFWBuildVersion.patch(at: plist, to: buildID, dryRun: dryRun, verbose: true)+ try CustomFirmwareBuildVersion.patch(at: plist, to: buildID, dryRun: dryRun, verbose: true)}}// MARK: - patch-campo-entitlements-struct VPhoneCFWPatchCampoEntitlementsCommand: ParsableCommand {+struct VPhoneCustomFirmwarePatchCampoEntitlementsCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "patch-campo-entitlements",abstract: "Merge the backboard/frontboard mach-lookup exceptions Campo needs",@@ -237,13 +237,13 @@ struct VPhoneCFWPatchCampoEntitlementsCommand: ParsableCommand {var plist: URLfunc run() throws {- try CFWMachLookupExceptions.merge(at: plist, verbose: true)+ try CustomFirmwareMachLookupExceptions.merge(at: plist, verbose: true)}}// MARK: - patch-post-restore-dt-struct VPhoneCFWPatchPostRestoreDTCommand: ParsableCommand {+struct VPhoneCustomFirmwarePatchPostRestoreDeviceTreeCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "patch-post-restore-dt",abstract: "Rewrite the restore-fatal identity properties in a device tree",@@ -270,6 +270,6 @@ struct VPhoneCFWPatchPostRestoreDTCommand: ParsableCommand {var dryRun = falsefunc run() throws {- try CFWPostRestoreDeviceTree.patch(at: deviceTree, dryRun: dryRun, verbose: true)+ try CustomFirmwarePostRestoreDeviceTree.patch(at: deviceTree, dryRun: dryRun, verbose: true)}}diff --git a/sources/vphone-cli/VPhoneFWAEACLI.swift b/sources/vphone-cli/VPhoneFirmwareAEACLI.swiftsimilarity index 93%rename from sources/vphone-cli/VPhoneFWAEACLI.swiftrename to sources/vphone-cli/VPhoneFirmwareAEACLI.swiftindex 5d7794fa..e6f4e565 100644--- a/sources/vphone-cli/VPhoneFWAEACLI.swift+++ b/sources/vphone-cli/VPhoneFirmwareAEACLI.swift@@ -1,4 +1,4 @@-// VPhoneFWAEACLI.swift — `fw aea-key` and the two `fw im4p` verbs.+// VPhoneFirmwareAEACLI.swift — `fw aea-key` and the two `fw im4p` verbs.//// These are the shapes `ipsw` was called in from the CFW installers and from// fw_prepare.sh, and they are the last of them. `ipsw` is a fine program —@@ -19,7 +19,7 @@ import VPhoneCore// MARK: - aea-key-struct VPhoneFWAEAKeyCommand: ParsableCommand {+struct VPhoneFirmwareAEAKeyCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "aea-key",abstract: "Print an .aea archive's symmetric key (replaces `ipsw fw aea --key`)",@@ -47,7 +47,7 @@ struct VPhoneFWAEAKeyCommand: ParsableCommand {// MARK: - im4p-struct VPhoneFWIM4PCreateCommand: ParsableCommand {+struct VPhoneFirmwareIM4PCreateCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "im4p-create",abstract: "Wrap a file in an IM4P container (replaces `ipsw img4 im4p create`)",@@ -80,7 +80,7 @@ struct VPhoneFWIM4PCreateCommand: ParsableCommand {}}-struct VPhoneFWIM4PExtractCommand: ParsableCommand {+struct VPhoneFirmwareIM4PExtractCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "im4p-extract",abstract: "Unwrap an IM4P's payload (replaces `ipsw img4 im4p extract`)",diff --git a/sources/vphone-cli/VPhoneFWCLI.swift b/sources/vphone-cli/VPhoneFirmwareCLI.swiftsimilarity index 89%rename from sources/vphone-cli/VPhoneFWCLI.swiftrename to sources/vphone-cli/VPhoneFirmwareCLI.swiftindex 167a572e..d7337275 100644--- a/sources/vphone-cli/VPhoneFWCLI.swift+++ b/sources/vphone-cli/VPhoneFirmwareCLI.swift@@ -3,30 +3,30 @@ import FirmwarePatcherimport Foundationimport VPhoneCore-struct VPhoneFWCommand: ParsableCommand {+struct VPhoneFirmwareCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "fw",abstract: "Firmware pipeline: prepare (download/merge IPSWs) and patch",subcommands: [- VPhoneFWCatalogCommand.self,- VPhoneFWInspectCommand.self,- VPhoneFWPrepareCommand.self,- VPhoneFWPatchCommand.self,- VPhoneFWManifestCommand.self,- VPhoneFWListCommand.self,- VPhoneFWResolveCommand.self,- VPhoneFWAEAKeyCommand.self,- VPhoneFWIM4PCreateCommand.self,- VPhoneFWIM4PExtractCommand.self,- VPhoneFWURLsCommand.self,- VPhoneFWSealToolCommand.self,+ VPhoneFirmwareCatalogCommand.self,+ VPhoneFirmwareInspectCommand.self,+ VPhoneFirmwarePrepareCommand.self,+ VPhoneFirmwarePatchCommand.self,+ VPhoneFirmwareManifestCommand.self,+ VPhoneFirmwareListCommand.self,+ VPhoneFirmwareResolveCommand.self,+ VPhoneFirmwareAEAKeyCommand.self,+ VPhoneFirmwareIM4PCreateCommand.self,+ VPhoneFirmwareIM4PExtractCommand.self,+ VPhoneFirmwareURLsCommand.self,+ VPhoneFirmwareSealToolCommand.self,],)}/// Check a PCC IPSW's build identities using HTTP ranges before committing/// space to a full download. The hybrid restore requires both device classes.-struct VPhoneFWInspectCommand: ParsableCommand {+struct VPhoneFirmwareInspectCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "inspect",abstract: "Inspect a remote IPSW manifest without downloading the archive",@@ -67,7 +67,7 @@ struct VPhoneFWInspectCommand: ParsableCommand {////// Neither writes through `print`: `list` styles stdout and `resolve` styles/// stderr, and colour is only right if each descriptor is asked separately.-struct VPhoneFWListCommand: ParsableCommand {+struct VPhoneFirmwareListCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "list",abstract: "Print the downloadable-firmware support matrix for a device",@@ -88,7 +88,7 @@ struct VPhoneFWListCommand: ParsableCommand {}}-struct VPhoneFWResolveCommand: ParsableCommand {+struct VPhoneFirmwareResolveCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "resolve",abstract: "Resolve a version/build selector to a downloadable IPSW URL",@@ -123,7 +123,7 @@ struct VPhoneFWResolveCommand: ParsableCommand {// MARK: - manifest/// Generates the hybrid manifest after both IPSWs are extracted and merged.-struct VPhoneFWManifestCommand: ParsableCommand {+struct VPhoneFirmwareManifestCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "manifest",abstract: "Write the hybrid BuildManifest.plist and Restore.plist into the iPhone directory",@@ -163,7 +163,7 @@ struct VPhoneFWManifestCommand: ParsableCommand {// MARK: - catalog-struct VPhoneFWCatalogCommand: ParsableCommand {+struct VPhoneFirmwareCatalogCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "catalog",abstract: "Show the known iOS ↔ cloudOS firmware pairings (recommended per iOS build)",@@ -190,7 +190,7 @@ struct VPhoneFWCatalogCommand: ParsableCommand {// MARK: - prepare-struct VPhoneFWPrepareCommand: ParsableCommand {+struct VPhoneFirmwarePrepareCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "prepare",abstract: "Download + merge IPSWs into a VM bundle",@@ -250,11 +250,11 @@ struct VPhoneFWPrepareCommand: ParsableCommand {}}- let selected = try VPhoneFirmwareSelection.resolve(iphone: source, cloudos: cloudosSource)+ let selected = try VPhoneFirmwareSourceSelection.resolve(iphone: source, cloudos: cloudosSource)guard let phone = selected.iphoneSource, let cloud = selected.cloudosSource else {throw ValidationError("Specify both --iphone-source and --cloudos-source when running without a terminal.")}- let name = try VPhoneVMSelection.resolveExisting(name, in: lib.library)+ let name = try VPhoneVirtualMachineSelection.resolveExisting(name, in: lib.library)let bundle = try lib.library.bundle(named: name)try VPhoneFirmwarePreparer.prepare(iPhoneSource: phone, cloudOSSource: cloud,@@ -266,7 +266,7 @@ struct VPhoneFWPrepareCommand: ParsableCommand {// MARK: - patch-struct VPhoneFWPatchCommand: ParsableCommand {+struct VPhoneFirmwarePatchCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "patch",abstract: "Patch the boot chain (native Swift FirmwarePipeline)",@@ -280,7 +280,7 @@ struct VPhoneFWPatchCommand: ParsableCommand {@Flag(name: .shortAndLong, help: "Suppress per-component progress") var quiet = falsefunc run() throws {- let name = try VPhoneVMSelection.resolveExisting(name, in: lib.library)+ let name = try VPhoneVirtualMachineSelection.resolveExisting(name, in: lib.library)let bundle = try lib.library.bundle(named: name)// In-process pipeline (no subprocess) — CryptexFilesystemPatcher'sdiff --git a/sources/vphone-cli/VPhoneFWDownloadCLI.swift b/sources/vphone-cli/VPhoneFirmwareDownloadCLI.swiftsimilarity index 97%rename from sources/vphone-cli/VPhoneFWDownloadCLI.swiftrename to sources/vphone-cli/VPhoneFirmwareDownloadCLI.swiftindex 0d9e3c03..cdb6addf 100644--- a/sources/vphone-cli/VPhoneFWDownloadCLI.swift+++ b/sources/vphone-cli/VPhoneFirmwareDownloadCLI.swift@@ -1,4 +1,4 @@-// VPhoneFWDownloadCLI.swift — `fw urls` and `fw seal-tool`.+// VPhoneFirmwareDownloadCLI.swift — `fw urls` and `fw seal-tool`.//// The last two shapes `ipsw` was called in from scripts/fw_prepare.sh://@@ -21,7 +21,7 @@ import VPhoneCore// MARK: - urls-struct VPhoneFWURLsCommand: ParsableCommand {+struct VPhoneFirmwareURLsCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "urls",abstract: "List downloadable restore URLs for a device (replaces `ipsw download ipsw --urls`)",@@ -46,7 +46,7 @@ struct VPhoneFWURLsCommand: ParsableCommand {// MARK: - seal-tool-struct VPhoneFWSealToolCommand: ParsableCommand {+struct VPhoneFirmwareSealToolCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "seal-tool",abstract: "Fetch apfs_sealvolume for an OS version out of the matching macOS restore ramdisk",diff --git a/sources/vphone-cli/VPhoneFirmwareSelection.swift b/sources/vphone-cli/VPhoneFirmwareSourceSelection.swiftsimilarity index 95%rename from sources/vphone-cli/VPhoneFirmwareSelection.swiftrename to sources/vphone-cli/VPhoneFirmwareSourceSelection.swiftindex a885f81c..88293055 100644--- a/sources/vphone-cli/VPhoneFirmwareSelection.swift+++ b/sources/vphone-cli/VPhoneFirmwareSourceSelection.swift@@ -1,7 +1,7 @@import Foundationimport VPhoneCore-enum VPhoneFirmwareSelection {+enum VPhoneFirmwareSourceSelection {private static var isTTY: Bool {isatty(FileHandle.standardInput.fileDescriptor) != 0}diff --git a/sources/vphone-cli/VPhoneHostControlProbe.swift b/sources/vphone-cli/VPhoneHostAutomationProbe.swiftsimilarity index 98%rename from sources/vphone-cli/VPhoneHostControlProbe.swiftrename to sources/vphone-cli/VPhoneHostAutomationProbe.swiftindex cc2c4bb6..a0100dfd 100644--- a/sources/vphone-cli/VPhoneHostControlProbe.swift+++ b/sources/vphone-cli/VPhoneHostAutomationProbe.swift@@ -3,7 +3,7 @@ import Foundation/// Ask the GUI VM's local control socket to perform a real vphoned ping./// `vm create` uses this instead of parsing the VM process's buffered stdout.-enum VPhoneHostControlProbe {+enum VPhoneHostAutomationProbe {static func ping(socketPath: String) -> Bool {let path = socketPath.utf8CStringvar address = sockaddr_un()diff --git a/sources/vphone-cli/VPhonePCCGPURecovery.swift b/sources/vphone-cli/VPhonePCCGPURecovery.swiftindex 67f4e32e..3e2a2588 100644--- a/sources/vphone-cli/VPhonePCCGPURecovery.swift+++ b/sources/vphone-cli/VPhonePCCGPURecovery.swift@@ -32,10 +32,10 @@ enum VPhonePCCGPURecovery {.appending(path: ".pcc-restoration")let library = VPhoneLibrary(root: temporaryLibrary)let name = "pcc-\(UUID().uuidString.lowercased())"- let vm = try VPhoneBundleOps.create(.init(+ let vm = try VPhoneBundleOperations.create(.init(name: name, cpuCount: 8, memoryMB: 8192, diskSizeGB: 64,- romSource: VPhoneBundleOps.defaultROMSource(),- sepromSource: VPhoneBundleOps.defaultSEPROMSource(),+ romSource: VPhoneBundleOperations.defaultROMSource(),+ sepromSource: VPhoneBundleOperations.defaultSEPROMSource(),), in: library)defer { try? fm.removeItem(at: temporaryLibrary) }@@ -54,7 +54,7 @@ enum VPhonePCCGPURecovery {let deadline = Date().addingTimeInterval(30)var ecid: UInt64?while Date() < deadline {- if let value = VPhoneRestoreOps.resolveECID(explicit: nil, bundle: vm),+ if let value = VPhoneRestoreOperations.resolveECID(explicit: nil, bundle: vm),let parsed = try VPhoneRestoreIdentity.parseECID(value) {ecid = parsedbreak@@ -64,7 +64,7 @@ enum VPhonePCCGPURecovery {guard let ecid else { throw Error.identityTimedOut }var reachable = falsefor _ in 1 ... 90 {- if (try? VPhoneRestoreBridge.recoveryProbe(ecid: ecid, timeout: 2)) != nil {+ if (try? VPhoneRestoreService.recoveryProbe(ecid: ecid, timeout: 2)) != nil {reachable = truebreak}@@ -73,8 +73,8 @@ enum VPhonePCCGPURecovery {guard reachable else { throw Error.recoveryTimedOut }print("[*] Restoring cloudOS to temporary vphone VM (ECID 0x\(VPhoneRestoreIdentity.formatECID(ecid)))...")- try VPhoneRestoreBridge.restore(- vmDir: vm.url, ecid: ecid, udid: VPhoneRestoreOps.resolveUDID(bundle: vm),+ try VPhoneRestoreService.restore(+ vmDir: vm.url, ecid: ecid, udid: VPhoneRestoreOperations.resolveUDID(bundle: vm),erase: true, ticketPath: nil,onEvent: VPhoneRestoreConsole.handler(level: .info),)diff --git a/sources/vphone-cli/VPhoneRestoreCLI.swift b/sources/vphone-cli/VPhoneRestoreCLI.swiftindex 73acfe95..98fac57e 100644--- a/sources/vphone-cli/VPhoneRestoreCLI.swift+++ b/sources/vphone-cli/VPhoneRestoreCLI.swift@@ -54,9 +54,9 @@ struct VPhoneRestoreCommand: ParsableCommand {/// `restore-info.json` staying unwritten.func run() throws {let v = max(VPhoneVerbosity.info, VPhoneVerbosity(count: verboseCount))- let name = try VPhoneVMSelection.resolveExisting(name, in: lib.library)+ let name = try VPhoneVirtualMachineSelection.resolveExisting(name, in: lib.library)let bundle = try lib.library.bundle(named: name)- guard let ecidText = VPhoneRestoreOps.resolveECID(explicit: ecid, bundle: bundle) else {+ guard let ecidText = VPhoneRestoreOperations.resolveECID(explicit: ecid, bundle: bundle) else {throw VPhoneRestoreError.ecidUnresolved}let ecidValue = try VPhoneRestoreIdentity.parseECID(ecidText)@@ -67,7 +67,7 @@ struct VPhoneRestoreCommand: ParsableCommand {}if getShsh {- try VPhoneRestoreBridge.fetchSHSH(+ try VPhoneRestoreService.fetchSHSH(vmDir: bundle.url,ecid: ecidValue,udid: udid,@@ -93,11 +93,11 @@ struct VPhoneRestoreCommand: ParsableCommand {// refusal has to come before anything is written.let restoreDir = try VPhoneRestoreLayout.findRestoreDirectory(in: bundle.url)print("[restore] decrypting AEA images in \(restoreDir.lastPathComponent)...")- try VPhoneRestoreOps.decryptAEAImages(inRestoreDir: restoreDir)+ try VPhoneRestoreOperations.decryptAEAImages(inRestoreDir: restoreDir)ticket = shsh}- try VPhoneRestoreBridge.restore(+ try VPhoneRestoreService.restore(vmDir: bundle.url,ecid: ecidValue,udid: udid,@@ -134,7 +134,7 @@ struct VPhoneRestoreCommand: ParsableCommand {/// The Python bridge's `recovery-probe`, under the same name.////// A standalone DFU probe. `vm create` does the same waiting in process-/// (`VPhoneCreateOrchestrator.waitForRecovery`).+/// (`VPhoneVirtualMachineCreator.waitForRecovery`).struct VPhoneRecoveryProbeCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "recovery-probe",@@ -146,7 +146,7 @@ struct VPhoneRecoveryProbeCommand: ParsableCommand {@Option(name: .shortAndLong, help: "Seconds to keep probing before giving up") var timeout: Int = 2func run() throws {- let device = try VPhoneRestoreBridge.recoveryProbe(+ let device = try VPhoneRestoreService.recoveryProbe(ecid: VPhoneRestoreIdentity.parseECID(ecid),timeout: timeout,)@@ -160,31 +160,31 @@ struct VPhoneRecoveryProbeCommand: ParsableCommand {// MARK: - cfw-struct VPhoneCFWCommand: ParsableCommand {+struct VPhoneCustomFirmwareCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "cfw",abstract: "Custom-firmware install (host-mount; VM must be off; re-execs sudo)",subcommands: [- VPhoneCFWInstallCommand.self,- VPhoneCFWInstallRootCommand.self,- VPhoneCFWFlipSnapshotCommand.self,+ VPhoneCustomFirmwareInstallCommand.self,+ VPhoneCustomFirmwareInstallRootCommand.self,+ VPhoneCustomFirmwareFlipSnapshotCommand.self,// The per-step patchers the installers used to reach through- // scripts/patchers/cfw.py for — see VPhoneCFWPatchCLI.swift.- VPhoneCFWCryptexPathsCommand.self,- VPhoneCFWInjectDaemonsCommand.self,- VPhoneCFWInjectDaemonCommand.self,- VPhoneCFWPatchDropbearPlistCommand.self,- VPhoneCFWInjectDylibCommand.self,- VPhoneCFWPatchBuildVersionCommand.self,- VPhoneCFWPatchCampoEntitlementsCommand.self,- VPhoneCFWPatchPostRestoreDTCommand.self,- ] + VPhoneCFWMachOVerbs.all + VPhoneCFWDSCVerbs.all,+ // scripts/patchers/cfw.py for — see VPhoneCustomFirmwarePatchCLI.swift.+ VPhoneCustomFirmwareCryptexPathsCommand.self,+ VPhoneCustomFirmwareInjectDaemonsCommand.self,+ VPhoneCustomFirmwareInjectDaemonCommand.self,+ VPhoneCustomFirmwarePatchDropbearPlistCommand.self,+ VPhoneCustomFirmwareInjectDylibCommand.self,+ VPhoneCustomFirmwarePatchBuildVersionCommand.self,+ VPhoneCustomFirmwarePatchCampoEntitlementsCommand.self,+ VPhoneCustomFirmwarePatchPostRestoreDeviceTreeCommand.self,+ ] + VPhoneCustomFirmwareMachOVerbs.all + VPhoneCustomFirmwareDyldSharedCacheVerbs.all,)}/// Replaces `tools/apfs_snap_rename.py`, called from `cfw_install_host.sh`/// once the install is done.-struct VPhoneCFWFlipSnapshotCommand: ParsableCommand {+struct VPhoneCustomFirmwareFlipSnapshotCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "flip-snapshot",abstract: "Rename the APFS root snapshot in a Disk.img so the guest boots the live volume",@@ -218,7 +218,7 @@ struct VPhoneCFWFlipSnapshotCommand: ParsableCommand {}}-struct VPhoneCFWInstallCommand: ParsableCommand {+struct VPhoneCustomFirmwareInstallCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "install",abstract: "Install CFW into a VM bundle via host mount",@@ -230,7 +230,7 @@ struct VPhoneCFWInstallCommand: ParsableCommand {name: .customLong("force-dsc-maxslide"),help: "Zero the dyld cache maxSlide on non-27 bases (opt-in DSC-map fit)",)- var forceDSCMaxSlide = false+ var forceDyldSharedCacheMaxSlide = false@Flag(name: .customLong("root-popup"),help: "Elevate via macOS's native authentication dialog (osascript) instead of the sudo re-exec",@@ -248,13 +248,13 @@ struct VPhoneCFWInstallCommand: ParsableCommand {func run() throws {let v = max(VPhoneVerbosity.info, VPhoneVerbosity(count: verboseCount))- let name = try VPhoneVMSelection.resolveExisting(name, in: lib.library)+ let name = try VPhoneVirtualMachineSelection.resolveExisting(name, in: lib.library)let bundle = try lib.library.bundle(named: name)let resources = projectRoot.map { VPhoneResources(base: URL(fileURLWithPath: $0)) } ?? .resolve()- let code = try VPhoneCFWInstaller.elevate(+ let code = try VPhoneCustomFirmwareInstaller.elevate(bundle: bundle.url, resources: resources,- forceDSCMaxSlide: forceDSCMaxSlide, rootPopup: rootPopup,+ forceDyldSharedCacheMaxSlide: forceDyldSharedCacheMaxSlide, rootPopup: rootPopup,verbose: v.showsToolDetail,)if code == 0 {diff --git a/sources/vphone-cli/VPhoneVMCLI.swift b/sources/vphone-cli/VPhoneVirtualMachineCLI.swiftsimilarity index 80%rename from sources/vphone-cli/VPhoneVMCLI.swiftrename to sources/vphone-cli/VPhoneVirtualMachineCLI.swiftindex de8263ab..64d9afb2 100644--- a/sources/vphone-cli/VPhoneVMCLI.swift+++ b/sources/vphone-cli/VPhoneVirtualMachineCLI.swift@@ -4,31 +4,31 @@ import VPhoneCore// MARK: - Command group-struct VPhoneVMCommand: ParsableCommand {+struct VPhoneVirtualMachineCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "vm",abstract: "Manage vphone VM bundles",subcommands: [- VPhoneVMListCommand.self,- VPhoneVMInfoCommand.self,- VPhoneVMNewCommand.self,- VPhoneVMConfigCommand.self,- VPhoneVMRenameCommand.self,- VPhoneVMDeleteCommand.self,- VPhoneVMCloneCommand.self,- VPhoneVMExportCommand.self,- VPhoneVMImportCommand.self,- VPhoneVMLaunchCommand.self,- VPhoneVMStopCommand.self,- VPhoneVMCreateCommand.self,- VPhoneVMWriteManifestCommand.self,+ VPhoneVirtualMachineListCommand.self,+ VPhoneVirtualMachineInfoCommand.self,+ VPhoneVirtualMachineNewCommand.self,+ VPhoneVirtualMachineConfigCommand.self,+ VPhoneVirtualMachineRenameCommand.self,+ VPhoneVirtualMachineDeleteCommand.self,+ VPhoneVirtualMachineCloneCommand.self,+ VPhoneVirtualMachineExportCommand.self,+ VPhoneVirtualMachineImportCommand.self,+ VPhoneVirtualMachineLaunchCommand.self,+ VPhoneVirtualMachineStopCommand.self,+ VPhoneVirtualMachineCreateCommand.self,+ VPhoneVirtualMachineWriteManifestCommand.self,],)}/// Writes configuration for an existing bundle directory. New bundles should/// normally use `vm new`, which owns all initial storage files.-struct VPhoneVMWriteManifestCommand: ParsableCommand {+struct VPhoneVirtualMachineWriteManifestCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "write-manifest",abstract: "Write a fresh config.plist into a VM directory",@@ -87,7 +87,7 @@ struct VPhoneLibraryOption: ParsableArguments {// MARK: - list-struct VPhoneVMListCommand: ParsableCommand {+struct VPhoneVirtualMachineListCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "list", abstract: "List VM bundles")@OptionGroup var lib: VPhoneLibraryOption@@ -119,7 +119,7 @@ struct VPhoneVMListCommand: ParsableCommand {// MARK: - info-struct VPhoneVMInfoCommand: ParsableCommand {+struct VPhoneVirtualMachineInfoCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "info", abstract: "Show one VM bundle")@OptionGroup var lib: VPhoneLibraryOption@@ -127,7 +127,7 @@ struct VPhoneVMInfoCommand: ParsableCommand {@Flag(name: .shortAndLong, help: "Emit JSON") var json = falsefunc run() throws {- let name = try VPhoneVMSelection.resolveExisting(name, in: lib.library)+ let name = try VPhoneVirtualMachineSelection.resolveExisting(name, in: lib.library)let bundle = try lib.library.bundle(named: name)let report = VPhoneBundleReport(bundle: bundle)if json {@@ -157,7 +157,7 @@ struct VPhoneVMInfoCommand: ParsableCommand {// MARK: - new-struct VPhoneVMNewCommand: ParsableCommand {+struct VPhoneVirtualMachineNewCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "new", abstract: "Create a VM bundle")@OptionGroup var lib: VPhoneLibraryOption@@ -169,22 +169,22 @@ struct VPhoneVMNewCommand: ParsableCommand {@Option(name: .shortAndLong, help: "AVPSEPBooter ROM (default: framework built-in)") var seprom: String?func run() throws {- let spec = VPhoneBundleOps.NewBundleSpec(+ let spec = VPhoneBundleOperations.NewBundleConfiguration(name: name,cpuCount: cpu,memoryMB: memory,diskSizeGB: diskSize,- romSource: rom.map { URL(fileURLWithPath: $0) } ?? VPhoneBundleOps.defaultROMSource(),- sepromSource: seprom.map { URL(fileURLWithPath: $0) } ?? VPhoneBundleOps.defaultSEPROMSource(),+ romSource: rom.map { URL(fileURLWithPath: $0) } ?? VPhoneBundleOperations.defaultROMSource(),+ sepromSource: seprom.map { URL(fileURLWithPath: $0) } ?? VPhoneBundleOperations.defaultSEPROMSource(),)- let bundle = try VPhoneBundleOps.create(spec, in: lib.library)+ let bundle = try VPhoneBundleOperations.create(spec, in: lib.library)print("created \(bundle.url.path)")}}// MARK: - config-struct VPhoneVMConfigCommand: ParsableCommand {+struct VPhoneVirtualMachineConfigCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "config",abstract: "Edit VM manifest fields (cpu/memory/network)",@@ -200,8 +200,8 @@ struct VPhoneVMConfigCommand: ParsableCommand {func run() throws {let mode = try network.map(Self.parseMode)- let name = try VPhoneVMSelection.resolveExisting(name, in: lib.library)- let updated = try VPhoneBundleOps.updateConfig(+ let name = try VPhoneVirtualMachineSelection.resolveExisting(name, in: lib.library)+ let updated = try VPhoneBundleOperations.updateConfig(bundleNamed: name,in: lib.library,cpuCount: cpu,@@ -239,7 +239,7 @@ private func describeNetwork(_ net: VPhoneVirtualMachineManifest.NetworkConfig)// MARK: - rename-struct VPhoneVMRenameCommand: ParsableCommand {+struct VPhoneVirtualMachineRenameCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "rename", abstract: "Rename a VM bundle")@OptionGroup var lib: VPhoneLibraryOption@@ -247,16 +247,16 @@ struct VPhoneVMRenameCommand: ParsableCommand {@Argument(help: "new name") var newName: String?func run() throws {- let name = try VPhoneVMSelection.resolveExisting(name, in: lib.library)- let newName = try VPhoneVMSelection.resolveNewName(newName, prompt: "New VM name:")- let b = try VPhoneBundleOps.rename(bundleNamed: name, to: newName, in: lib.library)+ let name = try VPhoneVirtualMachineSelection.resolveExisting(name, in: lib.library)+ let newName = try VPhoneVirtualMachineSelection.resolveNewName(newName, prompt: "New VM name:")+ let b = try VPhoneBundleOperations.rename(bundleNamed: name, to: newName, in: lib.library)print("renamed to \(b.name)")}}// MARK: - delete-struct VPhoneVMDeleteCommand: ParsableCommand {+struct VPhoneVirtualMachineDeleteCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "delete", abstract: "Delete a VM bundle")@OptionGroup var lib: VPhoneLibraryOption@@ -264,12 +264,12 @@ struct VPhoneVMDeleteCommand: ParsableCommand {@Flag(name: .shortAndLong, help: "Do not prompt") var force = falsefunc run() throws {- let name = try VPhoneVMSelection.resolveExisting(name, in: lib.library)+ let name = try VPhoneVirtualMachineSelection.resolveExisting(name, in: lib.library)if !force {print("Delete '\(name)' and all its files? [y/N] ", terminator: "")guard (readLine() ?? "").lowercased() == "y" else { print("aborted"); return }}- try VPhoneBundleOps.delete(bundleNamed: name, in: lib.library)+ try VPhoneBundleOperations.delete(bundleNamed: name, in: lib.library)print("deleted \(name)")}}diff --git a/sources/vphone-cli/VPhoneVMCreateCLI.swift b/sources/vphone-cli/VPhoneVirtualMachineCreateCLI.swiftsimilarity index 90%rename from sources/vphone-cli/VPhoneVMCreateCLI.swiftrename to sources/vphone-cli/VPhoneVirtualMachineCreateCLI.swiftindex b532068e..ba61c98f 100644--- a/sources/vphone-cli/VPhoneVMCreateCLI.swift+++ b/sources/vphone-cli/VPhoneVirtualMachineCreateCLI.swift@@ -2,7 +2,7 @@ import ArgumentParserimport Foundationimport VPhoneCore-struct VPhoneVMCreateCommand: ParsableCommand {+struct VPhoneVirtualMachineCreateCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "create",abstract: "Create a VM end-to-end (prepare → patch → restore → CFW → first boot)",@@ -23,7 +23,7 @@ struct VPhoneVMCreateCommand: ParsableCommand {name: .customLong("force-dsc-maxslide"),help: "Zero the dyld cache maxSlide on non-27 bases (opt-in DSC-map fit)",)- var forceDSCMaxSlide = false+ var forceDyldSharedCacheMaxSlide = false@Flag(name: .customLong("frida"),help: "Opt in to Frida Stalker kernel relaxations",@@ -51,11 +51,11 @@ struct VPhoneVMCreateCommand: ParsableCommand {// long-running download and patch work, not after it.let launcher = try VPhoneGuestLaunchPlanner()// Prompt for any firmware component not supplied on the command line.- let sources = try VPhoneFirmwareSelection.resolve(iphone: iphoneSource, cloudos: cloudosSource)+ let sources = try VPhoneFirmwareSourceSelection.resolve(iphone: iphoneSource, cloudos: cloudosSource)guard sources.iphoneSource != nil, sources.cloudosSource != nil else {throw ValidationError("Specify both --iphone-source and --cloudos-source when running without a terminal.")}- let orchestrator = VPhoneCreateOrchestrator(+ let orchestrator = VPhoneVirtualMachineCreator(library: lib.library,resources: resources,launcher: launcher,@@ -66,7 +66,7 @@ struct VPhoneVMCreateCommand: ParsableCommand {cloudosSource: sources.cloudosSource,gpuDriverBundle: gpuDriverBundle.map { URL(fileURLWithPath: ($0 as NSString).expandingTildeInPath) },sudoPassword: sudoPassword,- forceDSCMaxSlide: forceDSCMaxSlide,+ forceDyldSharedCacheMaxSlide: forceDyldSharedCacheMaxSlide,enableFrida: frida,rootPopup: rootPopup,diskSizeGB: diskSize,diff --git a/sources/vphone-cli/VPhoneCreateOptions.swift b/sources/vphone-cli/VPhoneVirtualMachineCreateOptions.swiftsimilarity index 86%rename from sources/vphone-cli/VPhoneCreateOptions.swiftrename to sources/vphone-cli/VPhoneVirtualMachineCreateOptions.swiftindex 1c1a96c4..99dfe5f6 100644--- a/sources/vphone-cli/VPhoneCreateOptions.swift+++ b/sources/vphone-cli/VPhoneVirtualMachineCreateOptions.swift@@ -3,14 +3,14 @@ import VPhoneCore// MARK: - Create Options-public extension VPhoneCreateOrchestrator {+public extension VPhoneVirtualMachineCreator {struct Options {public var name: Stringpublic var iphoneSource: String?public var cloudosSource: String?public var gpuDriverBundle: URL?public var sudoPassword: String?- public var forceDSCMaxSlide: Bool+ public var forceDyldSharedCacheMaxSlide: Boolpublic var enableFrida: Boolpublic var rootPopup: Boolpublic var cpuCount: UInt@@ -25,7 +25,7 @@ public extension VPhoneCreateOrchestrator {cloudosSource: String? = nil,gpuDriverBundle: URL? = nil,sudoPassword: String? = nil,- forceDSCMaxSlide: Bool = false,+ forceDyldSharedCacheMaxSlide: Bool = false,enableFrida: Bool = false,rootPopup: Bool = false,cpuCount: UInt = 8,@@ -39,7 +39,7 @@ public extension VPhoneCreateOrchestrator {self.cloudosSource = cloudosSourceself.gpuDriverBundle = gpuDriverBundleself.sudoPassword = sudoPassword- self.forceDSCMaxSlide = forceDSCMaxSlide+ self.forceDyldSharedCacheMaxSlide = forceDyldSharedCacheMaxSlideself.enableFrida = enableFridaself.rootPopup = rootPopupself.cpuCount = cpuCountdiff --git a/sources/vphone-cli/VPhoneCreateOrchestrator.swift b/sources/vphone-cli/VPhoneVirtualMachineCreator.swiftsimilarity index 88%rename from sources/vphone-cli/VPhoneCreateOrchestrator.swiftrename to sources/vphone-cli/VPhoneVirtualMachineCreator.swiftindex a8dc2d06..48ba1c34 100644--- a/sources/vphone-cli/VPhoneCreateOrchestrator.swift+++ b/sources/vphone-cli/VPhoneVirtualMachineCreator.swift@@ -4,10 +4,10 @@ import Foundationimport VPhoneCoreimport VPhoneRestore-// MARK: - VPhoneCreateError+// MARK: - VPhoneVirtualMachineCreationError/// Failure points across the native `vm create` pipeline.-private enum VPhoneCreateError: Error, CustomStringConvertible {+private enum VPhoneVirtualMachineCreationError: Error, CustomStringConvertible {case nestedVirtualizationcase identityTimedOut(URL)case invalidUDID(String)@@ -55,13 +55,13 @@ private enum VPhoneCreateError: Error, CustomStringConvertible {}}-extension VPhoneCreateError: LocalizedError {+extension VPhoneVirtualMachineCreationError: LocalizedError {var errorDescription: String? {description}}-// MARK: - VPhoneCreateOrchestrator+// MARK: - VPhoneVirtualMachineCreator/// Native `vm create` pipeline: prepare, patch, restore, install JB system/// files, and verify that the guest daemon connects on first boot.@@ -73,7 +73,7 @@ extension VPhoneCreateError: LocalizedError {/// needs to be independently unit-testable live in VPhoneCore instead, as/// `VPhoneBootPatterns`, where `VPhoneCoreTests` (which depends only on/// VPhoneCore) can reach them.-public struct VPhoneCreateOrchestrator {+public struct VPhoneVirtualMachineCreator {private let library: VPhoneLibraryprivate let resources: VPhoneResources/// How to start the guest. A create boots in DFU and once for verification,@@ -100,7 +100,7 @@ public struct VPhoneCreateOrchestrator {// create pipeline (download + patch + restore) is wasted otherwise. Mirrors// the host preflight that precedes VM launch.if Self.isNestedVMHost() {- throw VPhoneCreateError.nestedVirtualization+ throw VPhoneVirtualMachineCreationError.nestedVirtualization}let bundleURL = library.url(forName: options.name)@@ -114,7 +114,7 @@ public struct VPhoneCreateOrchestrator {// the CFW-install step runs as a foreground job (runForeground) so sudo's// process group owns the tty and reads the password directly; our code// never sees it.- var sudoEnvExtras: [String: String] = [:]+ var sudoEnvironmentExtras: [String: String] = [:]var askpassScript: URL?defer {if let askpassScript {@@ -124,8 +124,8 @@ public struct VPhoneCreateOrchestrator {if let password = options.sudoPassword, !password.isEmpty {let script = try makeSudoAskpassScript()askpassScript = script- sudoEnvExtras = ["SUDO_ASKPASS": script.path, "SUDO_PASSWORD": password]- if preloadSudoCredential(env: sudoEnvExtras, verbosity: v) {+ sudoEnvironmentExtras = ["SUDO_ASKPASS": script.path, "SUDO_PASSWORD": password]+ if preloadSudoCredential(env: sudoEnvironmentExtras, verbosity: v) {print("[+] sudo credential preloaded via --sudo-password")} else {print("[!] --sudo-password failed validation; will still try at CFW-install time")@@ -137,20 +137,20 @@ public struct VPhoneCreateOrchestrator {URL(fileURLWithPath: "/usr/bin/sudo"), ["-n", "/usr/bin/true"],)if sudo?.succeeded != true {- throw VPhoneCreateError.sudoPasswordRequired+ throw VPhoneVirtualMachineCreationError.sudoPasswordRequired}}print("\n=== vm new ===")- let spec = VPhoneBundleOps.NewBundleSpec(+ let spec = VPhoneBundleOperations.NewBundleConfiguration(name: options.name,cpuCount: options.cpuCount,memoryMB: options.memoryMB,diskSizeGB: options.diskSizeGB,- romSource: VPhoneBundleOps.defaultROMSource(),- sepromSource: VPhoneBundleOps.defaultSEPROMSource(),+ romSource: VPhoneBundleOperations.defaultROMSource(),+ sepromSource: VPhoneBundleOperations.defaultSEPROMSource(),)- let bundle = try VPhoneBundleOps.create(spec, in: library)+ let bundle = try VPhoneBundleOperations.create(spec, in: library)print("created \(bundle.url.path)")print("\n=== fw prepare ===")@@ -165,7 +165,7 @@ public struct VPhoneCreateOrchestrator {print("[*] Waiting 5s for cleanup before CFW install...")Thread.sleep(forTimeInterval: 5)print("\n=== CFW install (host-mount) ===")- try runCFWInstall(options: options, bundleURL: bundleURL, sudoEnvExtras: sudoEnvExtras)+ try runCustomFirmwareInstall(options: options, bundleURL: bundleURL, sudoEnvironmentExtras: sudoEnvironmentExtras)// CFW install is the last consumer of the built restore tree (it copies// the SystemOS/AppOS cryptexes from it onto Disk.img); reclaim it now.@@ -304,9 +304,9 @@ public struct VPhoneCreateOrchestrator {// ticket file is needed for an offline restore.let onEvent = VPhoneRestoreConsole.handler(level: v.restoreLogLevel)print("[*] Restoring...")- trace("in-process VPhoneRestoreBridge.restore udid=\(udid) ecid=0x\(ecid) erase=true", v)+ trace("in-process VPhoneRestoreService.restore udid=\(udid) ecid=0x\(ecid) erase=true", v)do {- try VPhoneRestoreBridge.restore(+ try VPhoneRestoreService.restore(vmDir: bundleURL,ecid: ecidValue,udid: udid,@@ -316,7 +316,7 @@ public struct VPhoneCreateOrchestrator {onEvent: onEvent,)} catch {- throw VPhoneCreateError.restoreUpdateFailed("\(error)")+ throw VPhoneVirtualMachineCreationError.restoreUpdateFailed("\(error)")}recordRestoreVersions(bundleURL: bundleURL)@@ -363,7 +363,7 @@ public struct VPhoneCreateOrchestrator {Thread.sleep(forTimeInterval: 1)}guard FileManager.default.fileExists(atPath: predictionFile.path) else {- throw VPhoneCreateError.identityTimedOut(predictionFile)+ throw VPhoneVirtualMachineCreationError.identityTimedOut(predictionFile)}let text = (try? String(contentsOf: predictionFile, encoding: .utf8)) ?? ""@@ -382,17 +382,17 @@ public struct VPhoneCreateOrchestrator {}guard udid.range(of: "^[0-9A-F]{8}-[0-9A-F]{16}$", options: .regularExpression) != nil else {- throw VPhoneCreateError.invalidUDID(udid)+ throw VPhoneVirtualMachineCreationError.invalidUDID(udid)}if ecid.isEmpty {ecid = udid.split(separator: "-", maxSplits: 1).last.map(String.init) ?? ""}guard ecid.range(of: "^[0-9A-F]{16}$", options: .regularExpression) != nil else {- throw VPhoneCreateError.invalidECID(ecid)+ throw VPhoneVirtualMachineCreationError.invalidECID(ecid)}let udidSuffix = udid.split(separator: "-", maxSplits: 1).last.map(String.init) ?? ""guard udidSuffix == ecid else {- throw VPhoneCreateError.udidECIDMismatch(udid: udid, ecid: ecid)+ throw VPhoneVirtualMachineCreationError.udidECIDMismatch(udid: udid, ecid: ecid)}return (udid, ecid)}@@ -404,7 +404,7 @@ public struct VPhoneCreateOrchestrator {private func waitForRecovery(ecid: UInt64?, verbosity v: VPhoneVerbosity) throws {print("[*] Waiting for recovery/DFU endpoint...")for _ in 1 ... 90 {- if let device = try? VPhoneRestoreBridge.recoveryProbe(ecid: ecid, timeout: 2) {+ if let device = try? VPhoneRestoreService.recoveryProbe(ecid: ecid, timeout: 2) {print("[+] Device endpoint is reachable")trace("recovery-probe: \(device.productType ?? "device") in \(device.mode)", v)return@@ -412,22 +412,22 @@ public struct VPhoneCreateOrchestrator {Thread.sleep(forTimeInterval: 2)}trace("recovery-probe: exhausted 90 retries", v)- throw VPhoneCreateError.recoveryTimeout+ throw VPhoneVirtualMachineCreationError.recoveryTimeout}// MARK: - CFW install- private func runCFWInstall(options: Options, bundleURL: URL, sudoEnvExtras: [String: String]) throws {+ private func runCustomFirmwareInstall(options: Options, bundleURL: URL, sudoEnvironmentExtras: [String: String]) throws {let v = options.verbosity// --sudo-password (askpass) wins over --root-popup.- let usePopup = options.rootPopup && sudoEnvExtras["SUDO_ASKPASS"] == nil+ let usePopup = options.rootPopup && sudoEnvironmentExtras["SUDO_ASKPASS"] == niltrace("native JB CFW install for \(bundleURL.path)", v)- let code = try VPhoneCFWInstaller.elevate(+ let code = try VPhoneCustomFirmwareInstaller.elevate(bundle: bundleURL, resources: resources,- forceDSCMaxSlide: options.forceDSCMaxSlide,- rootPopup: usePopup, environment: sudoEnvExtras,+ forceDyldSharedCacheMaxSlide: options.forceDyldSharedCacheMaxSlide,+ rootPopup: usePopup, environment: sudoEnvironmentExtras,)- guard code == 0 else { throw VPhoneCreateError.cfwInstallFailed(code) }+ guard code == 0 else { throw VPhoneVirtualMachineCreationError.cfwInstallFailed(code) }print("[+] JB CFW installed.")if let bundle = try? VPhoneBundle.load(at: bundleURL),let info = try? VPhoneRestoreInfo.recordVariant("jb", toBundle: bundle), info.variant != nil@@ -456,20 +456,20 @@ public struct VPhoneCreateOrchestrator {switch vm.waitForOutput(matching: "(?i:\(VPhoneBootPatterns.panicRegex))", timeout: 0) {case .matched:print("[-] Boot analysis: panic detected, stopping VM.")- throw VPhoneCreateError.bootAnalysisPanic+ throw VPhoneVirtualMachineCreationError.bootAnalysisPaniccase let .exited(code):print("[-] Boot analysis: VM process exited before success marker.")- throw VPhoneCreateError.bootAnalysisExited(code)+ throw VPhoneVirtualMachineCreationError.bootAnalysisExited(code)case .timedOut:break}- if VPhoneHostControlProbe.ping(socketPath: socketPath) {+ if VPhoneHostAutomationProbe.ping(socketPath: socketPath) {print("[+] First boot: vphoned ping succeeded.")return}Thread.sleep(forTimeInterval: 1)}print("[-] Boot analysis timeout (300s); stopping VM.")- throw VPhoneCreateError.bootAnalysisTimeout+ throw VPhoneVirtualMachineCreationError.bootAnalysisTimeout}}diff --git a/sources/vphone-cli/VPhoneVMLaunchCLI.swift b/sources/vphone-cli/VPhoneVirtualMachineLaunchCLI.swiftsimilarity index 93%rename from sources/vphone-cli/VPhoneVMLaunchCLI.swiftrename to sources/vphone-cli/VPhoneVirtualMachineLaunchCLI.swiftindex f1b4d3bd..47d612be 100644--- a/sources/vphone-cli/VPhoneVMLaunchCLI.swift+++ b/sources/vphone-cli/VPhoneVirtualMachineLaunchCLI.swift@@ -2,7 +2,7 @@ import ArgumentParserimport Foundationimport VPhoneCore-struct VPhoneVMLaunchCommand: ParsableCommand {+struct VPhoneVirtualMachineLaunchCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "launch",abstract: "Boot a VM bundle (runs host preflight first)"@@ -29,7 +29,7 @@ struct VPhoneVMLaunchCommand: ParsableCommand {func run() throws {let v = VPhoneVerbosity(count: verboseCount)- let name = try VPhoneVMSelection.resolveExisting(name, in: lib.library)+ let name = try VPhoneVirtualMachineSelection.resolveExisting(name, in: lib.library)let bundle = try lib.library.bundle(named: name)let resources = projectRoot.map { VPhoneResources(base: URL(fileURLWithPath: $0)) } ?? .resolve()let layout = VPhoneLaunchLayout(resources: resources)@@ -69,7 +69,7 @@ struct VPhoneVMLaunchCommand: ParsableCommand {// MARK: - vm stop-struct VPhoneVMStopCommand: ParsableCommand {+struct VPhoneVirtualMachineStopCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "stop",abstract: "Stop a running VM bundle"@@ -80,7 +80,7 @@ struct VPhoneVMStopCommand: ParsableCommand {@Option(name: .shortAndLong, help: "Seconds to wait for graceful shutdown before SIGKILL") var timeout: Int = 20func run() throws {- let name = try VPhoneVMSelection.resolveExisting(name, in: lib.library)+ let name = try VPhoneVirtualMachineSelection.resolveExisting(name, in: lib.library)let bundle = try lib.library.bundle(named: name)let disk = bundle.url.appendingPathComponent(bundle.manifest.diskImage)diff --git a/sources/vphone-cli/VPhoneVMSelection.swift b/sources/vphone-cli/VPhoneVirtualMachineSelection.swiftsimilarity index 85%rename from sources/vphone-cli/VPhoneVMSelection.swiftrename to sources/vphone-cli/VPhoneVirtualMachineSelection.swiftindex 58dff902..92c270e5 100644--- a/sources/vphone-cli/VPhoneVMSelection.swift+++ b/sources/vphone-cli/VPhoneVirtualMachineSelection.swift@@ -1,7 +1,7 @@import Foundationimport VPhoneCore-enum VPhoneVMSelection {+enum VPhoneVirtualMachineSelection {private static var isTTY: Bool {isatty(FileHandle.standardInput.fileDescriptor) != 0}@@ -16,7 +16,7 @@ enum VPhoneVMSelection {return provided} // supplied name → no library scanlet names = try library.bundles().map(\.name).sorted() // no-name path: propagate real scan errors- return try VPhoneVMPicker.resolve(+ return try VPhoneVirtualMachinePicker.resolve(provided: nil,names: names,libraryRoot: library.root.path,@@ -31,12 +31,12 @@ enum VPhoneVMSelection {if let provided, !provided.isEmpty {return provided}- guard isTTY else { throw VPhoneVMPickerError.notInteractive }+ guard isTTY else { throw VPhoneVirtualMachinePickerError.notInteractive }FileHandle.standardError.write(Data((prompt + " ").utf8))guard let line = readLine(strippingNewline: true)?.trimmingCharacters(in: .whitespacesAndNewlines), !line.isEmptyelse {- throw VPhoneVMPickerError.aborted+ throw VPhoneVirtualMachinePickerError.aborted}return line}diff --git a/sources/vphone-cli/VPhoneVMTransferCLI.swift b/sources/vphone-cli/VPhoneVirtualMachineTransferCLI.swiftsimilarity index 82%rename from sources/vphone-cli/VPhoneVMTransferCLI.swiftrename to sources/vphone-cli/VPhoneVirtualMachineTransferCLI.swiftindex 3b73acb0..c0ddf966 100644--- a/sources/vphone-cli/VPhoneVMTransferCLI.swift+++ b/sources/vphone-cli/VPhoneVirtualMachineTransferCLI.swift@@ -3,7 +3,7 @@ import Foundationimport VPhoneArchiveimport VPhoneCore-struct VPhoneVMCloneCommand: ParsableCommand {+struct VPhoneVirtualMachineCloneCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "clone",abstract: "Clone a VM bundle (fast APFS clone; resets device identity)",@@ -16,14 +16,14 @@ struct VPhoneVMCloneCommand: ParsableCommand {@Argument(help: "new VM name") var newName: String?func run() throws {- let name = try VPhoneVMSelection.resolveExisting(name, in: lib.library)- let newName = try VPhoneVMSelection.resolveNewName(newName, prompt: "New VM name:")- let clone = try VPhoneBundleOps.clone(bundleNamed: name, to: newName, in: lib.library)+ let name = try VPhoneVirtualMachineSelection.resolveExisting(name, in: lib.library)+ let newName = try VPhoneVirtualMachineSelection.resolveNewName(newName, prompt: "New VM name:")+ let clone = try VPhoneBundleOperations.clone(bundleNamed: name, to: newName, in: lib.library)print("cloned \(name) → \(clone.name)")}}-struct VPhoneVMExportCommand: ParsableCommand {+struct VPhoneVirtualMachineExportCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "export",abstract: "Export a VM bundle to a compressed archive (.tzst, or .txz with --max)",@@ -36,7 +36,7 @@ struct VPhoneVMExportCommand: ParsableCommand {@Flag(help: "include the *_Restore* IPSW directory") var includeIpsw = falsefunc run() throws {- let name = try VPhoneVMSelection.resolveExisting(name, in: lib.library)+ let name = try VPhoneVirtualMachineSelection.resolveExisting(name, in: lib.library)let compression: VPhoneBundleTransfer.ExportCompression = max ? .max : .fastlet bar = VPhoneProgressBar(label: "exporting \(name)")let outURL = try VPhoneBundleTransfer.export(@@ -52,7 +52,7 @@ struct VPhoneVMExportCommand: ParsableCommand {}}-struct VPhoneVMImportCommand: ParsableCommand {+struct VPhoneVirtualMachineImportCommand: ParsableCommand {static let configuration = CommandConfiguration(commandName: "import",abstract: "Import a VM bundle from a compressed archive (compressor auto-detected)",diff --git a/sources/vphone-vm/main.swift b/sources/vphone-vm/main.swiftindex aa1aa03b..729d534c 100644--- a/sources/vphone-vm/main.swift+++ b/sources/vphone-vm/main.swift@@ -3,7 +3,7 @@// This is the only binary in the project signed with the private// virtualization entitlements (sources/vphone.entitlements), and it is// deliberately the smallest thing that can hold them: it parses the boot-// options, becomes an NSApplication, and hands off to VPhoneAppDelegate.+// options, becomes an NSApplication, and hands off to VPhoneVirtualMachineAppDelegate.// Everything a user types goes through vphone-cli, which carries no// entitlements at all and starts this binary for the boot.//@@ -12,6 +12,6 @@import ArgumentParserimport VPhoneCore-import VPhoneVMKit+import VPhoneVirtualMachineKitVPhoneGuestApp.run(VPhoneBootCLI.parseOrExit())diff --git a/tests/FirmwarePatcherTests/CryptexFileOpsTests.swift b/tests/FirmwarePatcherTests/CryptexFileOpsTests.swiftindex e88c61a2..7c9457cb 100644--- a/tests/FirmwarePatcherTests/CryptexFileOpsTests.swift+++ b/tests/FirmwarePatcherTests/CryptexFileOpsTests.swift@@ -152,7 +152,7 @@ struct CryptexFileOpsTests {// This is the one place the port deliberately differs from ln(1), which// would have created the link *inside* the directory and left the guest// with a dyld path resolving to nothing.- #expect(throws: FileOpError.self) {+ #expect(throws: CryptexFileOperationError.self) {try patcher.createSymlink(at: link, to: "../elsewhere")}var isDirectory: ObjCBool = falsediff --git a/tests/FirmwarePatcherTests/CFWCacheloaderTests.swift b/tests/FirmwarePatcherTests/CustomFirmwareCacheloaderTests.swiftsimilarity index 92%rename from tests/FirmwarePatcherTests/CFWCacheloaderTests.swiftrename to tests/FirmwarePatcherTests/CustomFirmwareCacheloaderTests.swiftindex 791aa8aa..a5a99f7f 100644--- a/tests/FirmwarePatcherTests/CFWCacheloaderTests.swift+++ b/tests/FirmwarePatcherTests/CustomFirmwareCacheloaderTests.swift@@ -1,4 +1,4 @@-// CFWCacheloaderTests.swift — parity for the launchd_cache_loader unsecure-cache gate.+// CustomFirmwareCacheloaderTests.swift — parity for the launchd_cache_loader unsecure-cache gate.//// The patch is one instruction in a boot-critical binary, and a wrong one is a// guest that will not start rather than a failing assertion, so the reference@@ -234,13 +234,13 @@ private enum ByteComparison {"launchd_cache_loader gate discovery",.enabled(if: CacheLoaderFixture.runs, CacheLoaderFixture.missing),)-struct CFWCacheLoaderGateTests {+struct CustomFirmwareCacheLoaderGateTests {@Testfunc `the anchor is the whole launchd_unsecure_cache= literal, found in __cstring`() throws {let data = try CacheLoaderFixture.bytes(of: #require(CacheLoaderFixture.pristine, CacheLoaderFixture.missing),)- let located = try CFWCacheLoaderPatcher.locateGate(in: data)+ let located = try CustomFirmwareCacheLoaderPatcher.locateGate(in: data)let anchor = located.anchor#expect(anchor.token == "unsecure_cache")@@ -261,7 +261,7 @@ struct CFWCacheLoaderGateTests {let data = try CacheLoaderFixture.bytes(of: #require(CacheLoaderFixture.pristine, CacheLoaderFixture.missing),)- let anchor = try CFWCacheLoaderPatcher.locateGate(in: data).anchor+ let anchor = try CustomFirmwareCacheLoaderPatcher.locateGate(in: data).anchorlet sections = MachOParser.parseSections(from: data)let text = try #require(sections["__TEXT,__text"])let disassembler = ARM64Disassembler()@@ -292,7 +292,7 @@ struct CFWCacheLoaderGateTests {let data = try CacheLoaderFixture.bytes(of: #require(CacheLoaderFixture.pristine, CacheLoaderFixture.missing),)- let located = try CFWCacheLoaderPatcher.locateGate(in: data)+ let located = try CustomFirmwareCacheLoaderPatcher.locateGate(in: data)let gate = located.gate#expect(gate.mnemonic == "cbz")@@ -312,11 +312,11 @@ struct CFWCacheLoaderGateTests {let data = try CacheLoaderFixture.bytes(of: #require(CacheLoaderFixture.pristine, CacheLoaderFixture.missing),)- let directories = try #require(CFWMachOCodeSignature.codeDirectories(in: data))+ let directories = try #require(CustomFirmwareMachOCodeSignature.codeDirectories(in: data))let directory = try #require(directories.first)#expect(directories.count == 1)- #expect(directory.hashType == CFWMachOCodeSignature.hashTypeSHA256)+ #expect(directory.hashType == CustomFirmwareMachOCodeSignature.hashTypeSHA256)#expect(directory.pageSize == 4096)// codeLimit is NOT page aligned here, so the last slot is short — the// case that regressed independent Mach-O re-signing once already.@@ -325,8 +325,8 @@ struct CFWCacheLoaderGateTests {#expect(tail.count < directory.pageSize)// The gate lands in slot 0, well inside the covered region.- let gate = try CFWCacheLoaderPatcher.locateGate(in: data).gate- let bounds = try #require(CFWMachOCodeSignature.pageBounds(+ let gate = try CustomFirmwareCacheLoaderPatcher.locateGate(in: data).gate+ let bounds = try #require(CustomFirmwareMachOCodeSignature.pageBounds(fileOffset: gate.fileOffset,pageSize: directory.pageSize,codeLimit: directory.codeLimit,@@ -342,7 +342,7 @@ struct CFWCacheLoaderGateTests {.enabled(if: CacheLoaderFixture.runs, CacheLoaderFixture.missing),.serialized,)-struct CFWCacheLoaderParityTests {+struct CustomFirmwareCacheLoaderParityTests {/// The fixture the frozen digests were taken over. Without this a digest/// mismatch below would read as a patcher bug when the real cause is a/// different firmware's `launchd_cache_loader`.@@ -364,7 +364,7 @@ struct CFWCacheLoaderParityTests {let swiftClone = try CacheLoaderFixture.clone(named: "swift")defer { CacheLoaderFixture.discard(swiftClone) }- let report = try CFWCacheLoaderPatcher.patch(fileAt: swiftClone, log: nil)+ let report = try CustomFirmwareCacheLoaderPatcher.patch(fileAt: swiftClone, log: nil)#expect(report.outcome == .patched)#expect(report.sitesWritten == 1)// Off by default, because every shipped caller re-signs afterwards.@@ -386,7 +386,7 @@ struct CFWCacheLoaderParityTests {let pristine = try CacheLoaderFixture.bytes(of: #require(CacheLoaderFixture.pristine, CacheLoaderFixture.missing),)- let report = try CFWCacheLoaderPatcher.patch(fileAt: clone, log: nil)+ let report = try CustomFirmwareCacheLoaderPatcher.patch(fileAt: clone, log: nil)let patched = try CacheLoaderFixture.bytes(of: clone)let differing = ByteComparison.differingOffsets(pristine, patched)@@ -399,7 +399,7 @@ struct CFWCacheLoaderParityTests {let clone = try CacheLoaderFixture.clone(named: "record")defer { CacheLoaderFixture.discard(clone) }- let report = try CFWCacheLoaderPatcher.patch(fileAt: clone, log: nil)+ let report = try CustomFirmwareCacheLoaderPatcher.patch(fileAt: clone, log: nil)let record = try #require(report.record)#expect(record.patchID == "launchd_cache_loader.unsecure_cache_gate")@@ -431,7 +431,7 @@ struct CFWCacheLoaderParityTests {final class Lines: @unchecked Sendable { var all: [String] = [] }let lines = Lines()- let report = try CFWCacheLoaderPatcher.patch(fileAt: clone, log: { lines.all.append($0) })+ let report = try CustomFirmwareCacheLoaderPatcher.patch(fileAt: clone, log: { lines.all.append($0) })let text = lines.all.joined(separator: "\n")#expect(text.contains("Before:"))@@ -448,16 +448,16 @@ struct CFWCacheLoaderParityTests {.enabled(if: CacheLoaderFixture.runs, CacheLoaderFixture.missing),.serialized,)-struct CFWCacheLoaderRerunTests {+struct CustomFirmwareCacheLoaderRerunTests {@Testfunc `a second run is a byte-for-byte no-op`() throws {let clone = try CacheLoaderFixture.clone(named: "twice")defer { CacheLoaderFixture.discard(clone) }- let first = try CFWCacheLoaderPatcher.patch(fileAt: clone, log: nil)+ let first = try CustomFirmwareCacheLoaderPatcher.patch(fileAt: clone, log: nil)let afterFirst = try CacheLoaderFixture.bytes(of: clone)- let second = try CFWCacheLoaderPatcher.patch(fileAt: clone, log: nil)+ let second = try CustomFirmwareCacheLoaderPatcher.patch(fileAt: clone, log: nil)let afterSecond = try CacheLoaderFixture.bytes(of: clone)#expect(second.outcome == .alreadyPatched)@@ -472,7 +472,7 @@ struct CFWCacheLoaderRerunTests {#expect(second.anchor == first.anchor)// A third run, for the same reason the second exists.- let third = try CFWCacheLoaderPatcher.patch(fileAt: clone, log: nil)+ let third = try CustomFirmwareCacheLoaderPatcher.patch(fileAt: clone, log: nil)#expect(third.outcome == .alreadyPatched)#expect(try CacheLoaderFixture.bytes(of: clone) == afterFirst)}@@ -495,8 +495,8 @@ struct CFWCacheLoaderRerunTests {)// The Swift half, measured: two runs land exactly on one reference run.- try CFWCacheLoaderPatcher.patch(fileAt: swiftClone, log: nil)- try CFWCacheLoaderPatcher.patch(fileAt: swiftClone, log: nil)+ try CustomFirmwareCacheLoaderPatcher.patch(fileAt: swiftClone, log: nil)+ try CustomFirmwareCacheLoaderPatcher.patch(fileAt: swiftClone, log: nil)let swiftTwice = try CacheLoaderFixture.digest(of: swiftClone)#expect(swiftTwice == CacheLoaderGolden.patched, "one Swift run twice must equal one reference run once")#expect(swiftTwice != CacheLoaderGolden.patchedTwice)@@ -520,7 +520,7 @@ struct CFWCacheLoaderRerunTests {let pristine = try CacheLoaderFixture.bytes(of: #require(CacheLoaderFixture.pristine, CacheLoaderFixture.missing),)- let report = try CFWCacheLoaderPatcher.patch(fileAt: clone, dryRun: true, log: nil)+ let report = try CustomFirmwareCacheLoaderPatcher.patch(fileAt: clone, dryRun: true, log: nil)#expect(report.outcome == .wouldPatch)#expect(report.sitesWritten == 0)@@ -536,13 +536,13 @@ struct CFWCacheLoaderRerunTests {.enabled(if: CacheLoaderFixture.runs, CacheLoaderFixture.missing),.serialized,)-struct CFWCacheLoaderSignatureTests {+struct CustomFirmwareCacheLoaderSignatureTests {@Testfunc `the default output fails codesign, exactly as the reference's did`() throws {let swiftClone = try CacheLoaderFixture.clone(named: "unattested-swift")defer { CacheLoaderFixture.discard(swiftClone) }- try CFWCacheLoaderPatcher.patch(fileAt: swiftClone, log: nil)+ try CustomFirmwareCacheLoaderPatcher.patch(fileAt: swiftClone, log: nil)// Both leave a stale slot hash, because both rely on the caller// re-signing the binary wholesale afterwards (`ldid_sign` in@@ -562,7 +562,7 @@ struct CFWCacheLoaderSignatureTests {let swiftClone = try CacheLoaderFixture.clone(named: "attested-swift")defer { CacheLoaderFixture.discard(swiftClone) }- let report = try CFWCacheLoaderPatcher.patch(+ let report = try CustomFirmwareCacheLoaderPatcher.patch(fileAt: swiftClone,reattestsCodeSignature: true,log: nil,@@ -593,11 +593,11 @@ struct CFWCacheLoaderSignatureTests {defer { CacheLoaderFixture.discard(clone) }// The shape the reference left behind: patched, stale slot hash.- try CFWCacheLoaderPatcher.patch(fileAt: clone, log: nil)+ try CustomFirmwareCacheLoaderPatcher.patch(fileAt: clone, log: nil)try #require(try CacheLoaderFixture.digest(of: clone) == CacheLoaderGolden.patched)let beforeRepair = try CacheLoaderFixture.bytes(of: clone)- let report = try CFWCacheLoaderPatcher.patch(+ let report = try CustomFirmwareCacheLoaderPatcher.patch(fileAt: clone,reattestsCodeSignature: true,log: nil,diff --git a/tests/FirmwarePatcherTests/CFWDaemonsTests.swift b/tests/FirmwarePatcherTests/CustomFirmwareDaemonsTests.swiftsimilarity index 76%rename from tests/FirmwarePatcherTests/CFWDaemonsTests.swiftrename to tests/FirmwarePatcherTests/CustomFirmwareDaemonsTests.swiftindex 33d7532e..197ed283 100644--- a/tests/FirmwarePatcherTests/CFWDaemonsTests.swift+++ b/tests/FirmwarePatcherTests/CustomFirmwareDaemonsTests.swift@@ -82,7 +82,7 @@ enum PlistSemantics {// MARK: - Fixtures-enum CFWDaemonsFixtures {+enum CustomFirmwareDaemonsFixtures {/// The repository root, from this file's own path.static let repositoryRoot = URL(filePath: #filePath).deletingLastPathComponent()@@ -108,7 +108,7 @@ enum CFWDaemonsFixtures {static func temporaryDirectory() throws -> URL {let url = URL(filePath: NSTemporaryDirectory())- .appending(path: "CFWDaemonsTests-\(UUID().uuidString)")+ .appending(path: "CustomFirmwareDaemonsTests-\(UUID().uuidString)")try FileManager.default.createDirectory(at: url, withIntermediateDirectories: true)return url}@@ -157,7 +157,7 @@ enum CFWDaemonsFixtures {// MARK: - Unit tests@Suite("CFW daemon plist rewrites")-struct CFWDaemonsTests {+struct CustomFirmwareDaemonsTests {// MARK: - dropbear ProgramArguments//@@ -180,12 +180,12 @@ struct CFWDaemonsTests {],]- CFWDaemons.patchDropbearDaemon(&daemon)+ CustomFirmwareDaemons.patchDropbearDaemon(&daemon)let arguments = daemon["ProgramArguments"] as? [Any] ?? []let strings = arguments.compactMap { $0 as? String }#expect(!strings.contains("-R"))- #expect(Array(strings.suffix(CFWDaemons.dropbearKeyArguments.count)) == CFWDaemons.dropbearKeyArguments)+ #expect(Array(strings.suffix(CustomFirmwareDaemons.dropbearKeyArguments.count)) == CustomFirmwareDaemons.dropbearKeyArguments)}@Test@@ -203,26 +203,26 @@ struct CFWDaemonsTests {],]- CFWDaemons.patchDropbearDaemon(&daemon)+ CustomFirmwareDaemons.patchDropbearDaemon(&daemon)let strings = (daemon["ProgramArguments"] as? [Any] ?? []).compactMap { $0 as? String }#expect(!strings.contains("/etc/dropbear/dropbear_rsa_host_key"))#expect(!strings.contains("/tmp/old_ecdsa_key"))- #expect(strings == ["dropbear", "-E", "-p", "22222"] + CFWDaemons.dropbearKeyArguments)+ #expect(strings == ["dropbear", "-E", "-p", "22222"] + CustomFirmwareDaemons.dropbearKeyArguments)}@Testfunc `an empty argument list is left alone — there is nothing to point at a key`() {var daemon: PlistDict = ["ProgramArguments": [String]()]- CFWDaemons.patchDropbearDaemon(&daemon)+ CustomFirmwareDaemons.patchDropbearDaemon(&daemon)#expect((daemon["ProgramArguments"] as? [Any])?.isEmpty == true)}@Testfunc `a trailing -r with no path does not read past the end`() {#expect(- CFWDaemons.patchedDropbearArguments(["dropbear", "-r"]).compactMap { $0 as? String }- == ["dropbear"] + CFWDaemons.dropbearKeyArguments,+ CustomFirmwareDaemons.patchedDropbearArguments(["dropbear", "-r"]).compactMap { $0 as? String }+ == ["dropbear"] + CustomFirmwareDaemons.dropbearKeyArguments,)}@@ -230,7 +230,7 @@ struct CFWDaemonsTests {@Testfunc `Cryptex paths are found in a later identity, not just the first`() throws {- let directory = try CFWDaemonsFixtures.temporaryDirectory()+ let directory = try CustomFirmwareDaemonsFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }// vResearch IPSWs put the Cryptex entries somewhere other than identity 0,@@ -245,16 +245,16 @@ struct CFWDaemonsTests {],]let url = directory.appending(path: "BuildManifest.plist")- try CFWDaemons.savePlist(manifest, to: url)+ try CustomFirmwareDaemons.savePlist(manifest, to: url)- let paths = try CFWDaemons.cryptexPaths(buildManifest: url)+ let paths = try CustomFirmwareDaemons.cryptexPaths(buildManifest: url)#expect(paths.systemOS == "043-70113-702.dmg.aea")#expect(paths.appOS == "043-69297-784.dmg")}@Testfunc `an identity carrying only one of the two is not a match`() throws {- let directory = try CFWDaemonsFixtures.temporaryDirectory()+ let directory = try CustomFirmwareDaemonsFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let manifest: PlistDict = [@@ -263,10 +263,10 @@ struct CFWDaemonsTests {],]let url = directory.appending(path: "BuildManifest.plist")- try CFWDaemons.savePlist(manifest, to: url)+ try CustomFirmwareDaemons.savePlist(manifest, to: url)- #expect(throws: CFWDaemons.DaemonError.self) {- try CFWDaemons.cryptexPaths(buildManifest: url)+ #expect(throws: CustomFirmwareDaemons.DaemonError.self) {+ try CustomFirmwareDaemons.cryptexPaths(buildManifest: url)}}@@ -274,18 +274,18 @@ struct CFWDaemonsTests {@Testfunc `injection creates LaunchDaemons when the target has none`() throws {- let directory = try CFWDaemonsFixtures.temporaryDirectory()+ let directory = try CustomFirmwareDaemonsFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let launchd = directory.appending(path: "launchd.plist")- try CFWDaemons.savePlist(["VersionNumber": 1], to: launchd)+ try CustomFirmwareDaemons.savePlist(["VersionNumber": 1], to: launchd)- try CFWDaemons.inject(- [CFWDaemons.Daemon(name: "vphoned", contents: ["Label": "vphoned"])],+ try CustomFirmwareDaemons.inject(+ [CustomFirmwareDaemons.Daemon(name: "vphoned", contents: ["Label": "vphoned"])],into: launchd,)- let result = try CFWDaemons.loadPlist(launchd)+ let result = try CustomFirmwareDaemons.loadPlist(launchd)let daemons = result["LaunchDaemons"] as? PlistDict#expect(daemons?["/System/Library/LaunchDaemons/vphoned.plist"] != nil)#expect(result["VersionNumber"] as? Int == 1)@@ -293,17 +293,17 @@ struct CFWDaemonsTests {@Testfunc `injecting twice replaces rather than duplicates, so a re-run is safe`() throws {- let directory = try CFWDaemonsFixtures.temporaryDirectory()+ let directory = try CustomFirmwareDaemonsFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let launchd = directory.appending(path: "launchd.plist")- try CFWDaemons.savePlist(["LaunchDaemons": PlistDict()], to: launchd)+ try CustomFirmwareDaemons.savePlist(["LaunchDaemons": PlistDict()], to: launchd)- let daemon = CFWDaemons.Daemon(name: "bash", contents: ["Label": "bash"])- try CFWDaemons.inject([daemon], into: launchd)- let first = try CFWDaemonsFixtures.loadPlist(launchd)- try CFWDaemons.inject([daemon], into: launchd)- let second = try CFWDaemonsFixtures.loadPlist(launchd)+ let daemon = CustomFirmwareDaemons.Daemon(name: "bash", contents: ["Label": "bash"])+ try CustomFirmwareDaemons.inject([daemon], into: launchd)+ let first = try CustomFirmwareDaemonsFixtures.loadPlist(launchd)+ try CustomFirmwareDaemons.inject([daemon], into: launchd)+ let second = try CustomFirmwareDaemonsFixtures.loadPlist(launchd)#expect(PlistSemantics.differences(first, second).isEmpty)#expect((second["LaunchDaemons"] as? PlistDict)?.count == 1)@@ -311,22 +311,22 @@ struct CFWDaemonsTests {@Testfunc `a daemon absent from the staging directory is reported, not fatal`() throws {- let directory = try CFWDaemonsFixtures.temporaryDirectory()+ let directory = try CustomFirmwareDaemonsFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let staging = directory.appending(path: "LaunchDaemons")try FileManager.default.createDirectory(at: staging, withIntermediateDirectories: true)- try CFWDaemons.savePlist(["Label": "bash"], to: staging.appending(path: "bash.plist"))+ try CustomFirmwareDaemons.savePlist(["Label": "bash"], to: staging.appending(path: "bash.plist"))let launchd = directory.appending(path: "launchd.plist")- try CFWDaemons.savePlist(PlistDict(), to: launchd)+ try CustomFirmwareDaemons.savePlist(PlistDict(), to: launchd)- let staged = try CFWDaemons.injectDaemons(into: launchd, fromDirectory: staging)+ let staged = try CustomFirmwareDaemons.injectDaemons(into: launchd, fromDirectory: staging)#expect(staged.injectedNames == ["bash"])- #expect(staged.missingSources.count == CFWDaemons.defaultDaemonNames.count - 1)+ #expect(staged.missingSources.count == CustomFirmwareDaemons.defaultDaemonNames.count - 1)// Scan order, not injected-then-missing: the caller logs one line each,// and those lines have always come out in the order the names are tried.- #expect(staged.count == CFWDaemons.defaultDaemonNames.count)+ #expect(staged.count == CustomFirmwareDaemons.defaultDaemonNames.count)if case .present = staged[0] {} else {Issue.record("bash should be first in scan order")}@@ -334,25 +334,25 @@ struct CFWDaemonsTests {@Testfunc `the directory loader applies the dropbear rewrite on its way through`() throws {- let directory = try CFWDaemonsFixtures.temporaryDirectory()+ let directory = try CustomFirmwareDaemonsFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let staging = directory.appending(path: "LaunchDaemons")try FileManager.default.createDirectory(at: staging, withIntermediateDirectories: true)- try CFWDaemons.savePlist(+ try CustomFirmwareDaemons.savePlist(["ProgramArguments": ["dropbear", "-R"]],to: staging.appending(path: "dropbear.plist"),)- let staged = try CFWDaemons.loadDaemons(inDirectory: staging, names: ["dropbear"])+ let staged = try CustomFirmwareDaemons.loadDaemons(inDirectory: staging, names: ["dropbear"])let arguments = (staged.present[0].contents["ProgramArguments"] as? [Any] ?? []).compactMap { $0 as? String }- #expect(arguments == ["dropbear"] + CFWDaemons.dropbearKeyArguments)+ #expect(arguments == ["dropbear"] + CustomFirmwareDaemons.dropbearKeyArguments)}@Testfunc `the installed label, not the source filename, is what launchd keys on`() {- let daemon = CFWDaemons.Daemon(name: "com.vphone.jb-setup", contents: [:])+ let daemon = CustomFirmwareDaemons.Daemon(name: "com.vphone.jb-setup", contents: [:])#expect(daemon.launchdKey == "/System/Library/LaunchDaemons/com.vphone.jb-setup.plist")}@@ -399,7 +399,7 @@ struct CFWDaemonsTests {/// Python's output by diffing it against its own input. Each constant says/// which command it came from, and the transform assertions below are exactly/// the ones that diff reported.-enum CFWDaemonsGolden {+enum CustomFirmwareDaemonsGolden {/// `.venv/bin/python3 scripts/patchers/cfw.py cryptex-paths \/// ipsws/ref_extract/iphone/BuildManifest.plist`/// printed these two lines, in this order.@@ -467,36 +467,36 @@ enum CFWDaemonsGolden {/// out of an IPSW, and `ipsws/` is not in the repo.@Suite("CFW daemon rewrites match the Python they replaced",- .enabled(if: CFWDaemonsFixtures.referenceInputsAvailable),+ .enabled(if: CustomFirmwareDaemonsFixtures.referenceInputsAvailable),)-struct CFWDaemonsReferenceEquivalenceTests {+struct CustomFirmwareDaemonsReferenceEquivalenceTests {@Testfunc `cryptex-paths on a real BuildManifest`() throws {- let swift = try CFWDaemons.cryptexPaths(buildManifest: CFWDaemonsFixtures.buildManifest)- #expect(swift.systemOS == CFWDaemonsGolden.cryptexSystemOS)- #expect(swift.appOS == CFWDaemonsGolden.cryptexAppOS)+ let swift = try CustomFirmwareDaemons.cryptexPaths(buildManifest: CustomFirmwareDaemonsFixtures.buildManifest)+ #expect(swift.systemOS == CustomFirmwareDaemonsGolden.cryptexSystemOS)+ #expect(swift.appOS == CustomFirmwareDaemonsGolden.cryptexAppOS)}@Testfunc `patch-dropbear-plist on the installer's real dropbear.plist`() throws {- let directory = try CFWDaemonsFixtures.temporaryDirectory()+ let directory = try CustomFirmwareDaemonsFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }- let staging = try CFWDaemonsFixtures.unpackLaunchDaemons(into: directory)+ let staging = try CustomFirmwareDaemonsFixtures.unpackLaunchDaemons(into: directory)let source = staging.appending(path: "dropbear.plist")try #require(- try CFWDaemonsGolden.digest(of: source) == CFWDaemonsGolden.dropbearSource,+ try CustomFirmwareDaemonsGolden.digest(of: source) == CustomFirmwareDaemonsGolden.dropbearSource,"the archive's dropbear.plist is not the one the golden was recorded over",)- let before = try CFWDaemonsFixtures.loadPlist(source)+ let before = try CustomFirmwareDaemonsFixtures.loadPlist(source)- let swiftCopy = try CFWDaemonsFixtures.writableCopy(of: source, in: directory, named: "swift.plist")- try CFWDaemons.patchDropbearPlist(at: swiftCopy)- let after = try CFWDaemonsFixtures.loadPlist(swiftCopy)+ let swiftCopy = try CustomFirmwareDaemonsFixtures.writableCopy(of: source, in: directory, named: "swift.plist")+ try CustomFirmwareDaemons.patchDropbearPlist(at: swiftCopy)+ let after = try CustomFirmwareDaemonsFixtures.loadPlist(swiftCopy)#expect((after["ProgramArguments"] as? [Any])?.compactMap { $0 as? String }- == CFWDaemonsGolden.dropbearProgramArguments,+ == CustomFirmwareDaemonsGolden.dropbearProgramArguments,)// …and nothing but that key moved, which is the other half of what the// Python's own output diff said.@@ -508,38 +508,38 @@ struct CFWDaemonsReferenceEquivalenceTests {@Testfunc `inject-daemons on a real launchd.plist and the real staging directory`() throws {- let directory = try CFWDaemonsFixtures.temporaryDirectory()+ let directory = try CustomFirmwareDaemonsFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }- let staging = try CFWDaemonsFixtures.unpackLaunchDaemons(into: directory)- let swiftCopy = try CFWDaemonsFixtures.writableCopy(- of: CFWDaemonsFixtures.hostLaunchdPlist, in: directory, named: "swift-launchd.plist",+ let staging = try CustomFirmwareDaemonsFixtures.unpackLaunchDaemons(into: directory)+ let swiftCopy = try CustomFirmwareDaemonsFixtures.writableCopy(+ of: CustomFirmwareDaemonsFixtures.hostLaunchdPlist, in: directory, named: "swift-launchd.plist",)- let before = try CFWDaemonsFixtures.loadPlist(swiftCopy)+ let before = try CustomFirmwareDaemonsFixtures.loadPlist(swiftCopy)- let staged = try CFWDaemons.injectDaemons(into: swiftCopy, fromDirectory: staging)- #expect(staged.injectedNames == CFWDaemonsGolden.injectedDaemonNames)+ let staged = try CustomFirmwareDaemons.injectDaemons(into: swiftCopy, fromDirectory: staging)+ #expect(staged.injectedNames == CustomFirmwareDaemonsGolden.injectedDaemonNames)// vphoned is staged separately by the Swift installer, so the archive's// directory really is missing it — the skip path is exercised for free.- #expect(staged.missingSources.count == CFWDaemonsGolden.missingDaemonCount)+ #expect(staged.missingSources.count == CustomFirmwareDaemonsGolden.missingDaemonCount)- let after = try CFWDaemonsFixtures.loadPlist(swiftCopy)+ let after = try CustomFirmwareDaemonsFixtures.loadPlist(swiftCopy)try assertOnlyAdded(- CFWDaemonsGolden.injectedDaemonNames.map(CFWDaemonsGolden.launchdKey),+ CustomFirmwareDaemonsGolden.injectedDaemonNames.map(CustomFirmwareDaemonsGolden.launchdKey),to: before, in: after,)// Each added value is the staged plist verbatim — dropbear with the// rewrite applied — which is what the reference's output diff showed.let daemons = try #require(after["LaunchDaemons"] as? [String: Any])- for name in CFWDaemonsGolden.injectedDaemonNames {- var source = try CFWDaemonsFixtures.loadPlist(staging.appending(path: "\(name).plist"))+ for name in CustomFirmwareDaemonsGolden.injectedDaemonNames {+ var source = try CustomFirmwareDaemonsFixtures.loadPlist(staging.appending(path: "\(name).plist"))if name == "dropbear" {var patched: PlistDict = source- CFWDaemons.patchDropbearDaemon(&patched)+ CustomFirmwareDaemons.patchDropbearDaemon(&patched)source = patched}- let injected = try #require(daemons[CFWDaemonsGolden.launchdKey(name)])+ let injected = try #require(daemons[CustomFirmwareDaemonsGolden.launchdKey(name)])let differences = PlistSemantics.differences(source, injected)#expect(differences.isEmpty, "\(name): \(differences.prefix(10))")}@@ -551,32 +551,32 @@ struct CFWDaemonsReferenceEquivalenceTests {/// sites" has to mean: the inline snippet was not a second behaviour.@Testfunc `the installers' inline jb-setup merge is the same merge`() throws {- let directory = try CFWDaemonsFixtures.temporaryDirectory()+ let directory = try CustomFirmwareDaemonsFixtures.temporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }try #require(- try CFWDaemonsGolden.digest(of: CFWDaemonsFixtures.jbSetupPlist)- == CFWDaemonsGolden.jbSetupSource,+ try CustomFirmwareDaemonsGolden.digest(of: CustomFirmwareDaemonsFixtures.jbSetupPlist)+ == CustomFirmwareDaemonsGolden.jbSetupSource,"vphone_jb_setup.plist is not the one the golden was recorded over",)- let swiftCopy = try CFWDaemonsFixtures.writableCopy(- of: CFWDaemonsFixtures.hostLaunchdPlist, in: directory, named: "swift-launchd.plist",+ let swiftCopy = try CustomFirmwareDaemonsFixtures.writableCopy(+ of: CustomFirmwareDaemonsFixtures.hostLaunchdPlist, in: directory, named: "swift-launchd.plist",)- let before = try CFWDaemonsFixtures.loadPlist(swiftCopy)+ let before = try CustomFirmwareDaemonsFixtures.loadPlist(swiftCopy)- try CFWDaemons.injectDaemon(+ try CustomFirmwareDaemons.injectDaemon(into: swiftCopy,name: "com.vphone.jb-setup",- from: CFWDaemonsFixtures.jbSetupPlist,+ from: CustomFirmwareDaemonsFixtures.jbSetupPlist,)- let after = try CFWDaemonsFixtures.loadPlist(swiftCopy)- try assertOnlyAdded([CFWDaemonsGolden.jbSetupKey], to: before, in: after)+ let after = try CustomFirmwareDaemonsFixtures.loadPlist(swiftCopy)+ try assertOnlyAdded([CustomFirmwareDaemonsGolden.jbSetupKey], to: before, in: after)let daemons = try #require(after["LaunchDaemons"] as? [String: Any])- let injected = try #require(daemons[CFWDaemonsGolden.jbSetupKey])- let source = try CFWDaemonsFixtures.loadPlist(CFWDaemonsFixtures.jbSetupPlist)+ let injected = try #require(daemons[CustomFirmwareDaemonsGolden.jbSetupKey])+ let source = try CustomFirmwareDaemonsFixtures.loadPlist(CustomFirmwareDaemonsFixtures.jbSetupPlist)let differences = PlistSemantics.differences(source, injected)#expect(differences.isEmpty, "\(differences.prefix(10))")}diff --git a/tests/FirmwarePatcherTests/CFWDiskimagesiodTests.swift b/tests/FirmwarePatcherTests/CustomFirmwareDiskimagesiodTests.swiftsimilarity index 88%rename from tests/FirmwarePatcherTests/CFWDiskimagesiodTests.swiftrename to tests/FirmwarePatcherTests/CustomFirmwareDiskimagesiodTests.swiftindex a676b8d3..72515f3b 100644--- a/tests/FirmwarePatcherTests/CFWDiskimagesiodTests.swift+++ b/tests/FirmwarePatcherTests/CustomFirmwareDiskimagesiodTests.swift@@ -1,4 +1,4 @@-// CFWDiskimagesiodTests.swift — parity for the diskimagesiod DDI mount gate.+// CustomFirmwareDiskimagesiodTests.swift — parity for the diskimagesiod DDI mount gate.//// The patch is eight bytes over an ObjC method prologue, and a wrong eight// bytes is a daemon that crashes on first call rather than a failing@@ -302,7 +302,7 @@ private enum DiskImagesComparison {// MARK: - The replacement bytes@Suite("diskimagesiod replacement encoding")-struct CFWDiskimagesiodEncodingTests {+struct CustomFirmwareDiskimagesiodEncodingTests {@Testfunc `mov x0, #1 built from ISA fields is the keystone-verified constant`() throws {let encoded = try #require(ARM64Encoder.encodeMovzX(rd: 0, imm16: 1))@@ -313,10 +313,10 @@ struct CFWDiskimagesiodEncodingTests {@Testfunc `the patch writes exactly mov x0, #1 ; ret`() {- #expect(CFWDiskimagesiod.replacement.count == 8)- #expect(CFWDiskimagesiod.replacement == ARM64.movX0_1 + ARM64.ret)+ #expect(CustomFirmwareDiskimagesiod.replacement.count == 8)+ #expect(CustomFirmwareDiskimagesiod.replacement == ARM64.movX0_1 + ARM64.ret)#expect(- CFWDiskimagesiod.disassemblyText(of: CFWDiskimagesiod.replacement, at: nil)+ CustomFirmwareDiskimagesiod.disassemblyText(of: CustomFirmwareDiskimagesiod.replacement, at: nil)== "mov x0, #1; ret",)}@@ -329,17 +329,17 @@ struct CFWDiskimagesiodEncodingTests {.enabled(if: DiskImagesFixture.runs, DiskImagesFixture.missing),.serialized,)-struct CFWDiskimagesiodAnchorTests {+struct CustomFirmwareDiskimagesiodAnchorTests {@Testfunc `the IMP resolves through the relative method list, into __TEXT,__text`() throws {let pristine = try #require(DiskImagesFixture.pristine, DiskImagesFixture.missing)let data = try Data(contentsOf: pristine)- let site = try CFWDiskimagesiod.locate(in: data)+ let site = try CustomFirmwareDiskimagesiod.locate(in: data)// Shipped diskimagesiod is stripped, so the symbol-table anchor misses// and the ObjC metadata walk is what answers.#expect(site.anchor == .relativeMethodList)- #expect(MachOParser.findSymbol(containing: CFWDiskimagesiod.symbolFragment, in: data) == nil)+ #expect(MachOParser.findSymbol(containing: CustomFirmwareDiskimagesiod.symbolFragment, in: data) == nil)let sections = MachOParser.parseSections(from: data)let text = try #require(sections["__TEXT,__text"])@@ -353,7 +353,7 @@ struct CFWDiskimagesiodAnchorTests {// A real ObjC method prologue, not yet patched.#expect(!site.isAlreadyPatched)- #expect(CFWDiskimagesiod.disassemblyText(of: site.original, at: va)+ #expect(CustomFirmwareDiskimagesiod.disassemblyText(of: site.original, at: va).hasPrefix("pacibsp; stp"))}@@ -373,7 +373,7 @@ struct CFWDiskimagesiodAnchorTests {@Testfunc `the reference's own anchor walk agreed on the same offset`() throws {let pristine = try #require(DiskImagesFixture.pristine, DiskImagesFixture.missing)- let site = try CFWDiskimagesiod.locate(in: Data(contentsOf: pristine))+ let site = try CustomFirmwareDiskimagesiod.locate(in: Data(contentsOf: pristine))// The offset the Python printed; both walks must land on it.#expect(site.fileOffset == DiskImagesGolden.impFileOffset)@@ -387,24 +387,24 @@ struct CFWDiskimagesiodAnchorTests {let sections = MachOParser.parseSections(from: data)let selectorVA = try #require(- CFWDiskimagesiod.selectorStringVA(in: data, sections: sections),+ CustomFirmwareDiskimagesiod.selectorStringVA(in: data, sections: sections),)let selrefs = try #require(sections["__DATA,__objc_selrefs"])- let selrefVA = try #require(CFWDiskimagesiod.selectorReferenceVA(+ let selrefVA = try #require(CustomFirmwareDiskimagesiod.selectorReferenceVA(in: data,selrefs: selrefs,selectorVA: selectorVA,- imageBase: CFWDiskimagesiod.imageBase(sections),+ imageBase: CustomFirmwareDiskimagesiod.imageBase(sections),))let methlist = try #require(sections["__TEXT,__objc_methlist"])- let imps = CFWDiskimagesiod.relativeMethodListIMPs(+ let imps = CustomFirmwareDiskimagesiod.relativeMethodListIMPs(in: data,section: methlist,naming: [selectorVA, selrefVA],)#expect(imps.count == 1)- #expect(try imps.first == (CFWDiskimagesiod.locate(in: data)).virtualAddress)+ #expect(try imps.first == (CustomFirmwareDiskimagesiod.locate(in: data)).virtualAddress)}@Test@@ -414,14 +414,14 @@ struct CFWDiskimagesiodAnchorTests {let sections = MachOParser.parseSections(from: data)let selectorVA = try #require(- CFWDiskimagesiod.selectorStringVA(in: data, sections: sections),+ CustomFirmwareDiskimagesiod.selectorStringVA(in: data, sections: sections),)let selrefs = try #require(sections["__DATA,__objc_selrefs"])- let selrefVA = try #require(CFWDiskimagesiod.selectorReferenceVA(+ let selrefVA = try #require(CustomFirmwareDiskimagesiod.selectorReferenceVA(in: data,selrefs: selrefs,selectorVA: selectorVA,- imageBase: CFWDiskimagesiod.imageBase(sections),+ imageBase: CustomFirmwareDiskimagesiod.imageBase(sections),))let methlist = try #require(sections["__TEXT,__objc_methlist"])let targets: Set<UInt64> = [selectorVA, selrefVA]@@ -430,12 +430,12 @@ struct CFWDiskimagesiodAnchorTests {// section have to name the same single implementation, or the two// implementations would have diverged on some other firmware even// though they agreed on this one.- let structural = CFWDiskimagesiod.relativeMethodListIMPs(+ let structural = CustomFirmwareDiskimagesiod.relativeMethodListIMPs(in: data,section: methlist,naming: targets,)- let strided = CFWDiskimagesiod.scanRelativeMethodEntryIMPs(+ let strided = CustomFirmwareDiskimagesiod.scanRelativeMethodEntryIMPs(in: data,section: methlist,naming: targets,@@ -449,7 +449,7 @@ struct CFWDiskimagesiodAnchorTests {let unrelated = try #require(DiskImagesFixture.unrelated, DiskImagesFixture.missing)let data = try Data(contentsOf: unrelated)#expect(throws: PatcherError.self) {- try CFWDiskimagesiod.locate(in: data)+ try CustomFirmwareDiskimagesiod.locate(in: data)}}}@@ -461,13 +461,13 @@ struct CFWDiskimagesiodAnchorTests {.enabled(if: DiskImagesFixture.runs, DiskImagesFixture.missing),.serialized,)-struct CFWDiskimagesiodParityTests {+struct CustomFirmwareDiskimagesiodParityTests {@Testfunc `Swift reproduces the reference's bytes, one site each`() throws {let swiftClone = try DiskImagesFixture.clone(named: "swift")defer { DiskImagesFixture.discard(swiftClone) }- let report = try CFWDiskimagesiod.patch(fileAt: swiftClone, log: nil)+ let report = try CustomFirmwareDiskimagesiod.patch(fileAt: swiftClone, log: nil)#expect(report.outcome == .patched)#expect(report.sitesWritten == 1)// Off by default: `cfw_install.sh` re-signs with ldid straight after,@@ -486,7 +486,7 @@ struct CFWDiskimagesiodParityTests {let clone = try DiskImagesFixture.clone(named: "record")defer { DiskImagesFixture.discard(clone) }- let report = try CFWDiskimagesiod.patch(fileAt: clone, log: nil)+ let report = try CustomFirmwareDiskimagesiod.patch(fileAt: clone, log: nil)let record = try #require(report.record)#expect(record.patchID == "diskimagesiod.is_mount_complete")@@ -494,7 +494,7 @@ struct CFWDiskimagesiodParityTests {#expect(record.fileOffset == report.site.fileOffset)#expect(record.virtualAddress == report.site.virtualAddress)#expect(record.originalBytes == report.site.original)- #expect(record.patchedBytes == CFWDiskimagesiod.replacement)+ #expect(record.patchedBytes == CustomFirmwareDiskimagesiod.replacement)#expect(record.afterDisasm == "mov x0, #1; ret")#expect(record.beforeDisasm.hasPrefix("pacibsp"))#expect(record.patchDescription.contains("isMountCompleteWithExpectedCount:diskTracker:"))@@ -511,7 +511,7 @@ struct CFWDiskimagesiodParityTests {defer { DiskImagesFixture.discard(clone) }let pristine = try #require(DiskImagesFixture.pristine, DiskImagesFixture.missing)- let report = try CFWDiskimagesiod.patch(fileAt: clone, log: nil)+ let report = try CustomFirmwareDiskimagesiod.patch(fileAt: clone, log: nil)let differences = try DiskImagesComparison.differences(between: pristine,and: clone,@@ -531,15 +531,15 @@ struct CFWDiskimagesiodParityTests {.enabled(if: DiskImagesFixture.runs, DiskImagesFixture.missing),.serialized,)-struct CFWDiskimagesiodReattestTests {+struct CustomFirmwareDiskimagesiodReattestTests {@Testfunc `the fixture really does have the short tail slot this path regressed on`() throws {let pristine = try #require(DiskImagesFixture.pristine, DiskImagesFixture.missing)let data = try Data(contentsOf: pristine)- let directories = try #require(CFWMachOCodeSignature.codeDirectories(in: data))+ let directories = try #require(CustomFirmwareMachOCodeSignature.codeDirectories(in: data))let directory = try #require(directories.first)- #expect(directory.hashType == CFWMachOCodeSignature.hashTypeSHA256)+ #expect(directory.hashType == CustomFirmwareMachOCodeSignature.hashTypeSHA256)#expect(directory.pageSize == 4096)#expect(directory.codeLimit % directory.pageSize != 0, "expected a non-page-aligned codeLimit")@@ -554,10 +554,10 @@ struct CFWDiskimagesiodReattestTests {let attested = try DiskImagesFixture.clone(named: "attested")defer { DiskImagesFixture.discard(bare, attested) }- try CFWDiskimagesiod.patch(fileAt: bare, log: nil)+ try CustomFirmwareDiskimagesiod.patch(fileAt: bare, log: nil)#expect(try DiskImagesFixture.codesignVerify(bare).status != 0)- let report = try CFWDiskimagesiod.patch(fileAt: attested, reattest: true, log: nil)+ let report = try CustomFirmwareDiskimagesiod.patch(fileAt: attested, reattest: true, log: nil)#expect(report.outcome == .patched)#expect(report.rehashes.count == 1)@@ -575,7 +575,7 @@ struct CFWDiskimagesiodReattestTests {let swiftClone = try DiskImagesFixture.clone(named: "swift-attested")defer { DiskImagesFixture.discard(swiftClone) }- let report = try CFWDiskimagesiod.patch(fileAt: swiftClone, reattest: true, log: nil)+ let report = try CustomFirmwareDiskimagesiod.patch(fileAt: swiftClone, reattest: true, log: nil)#expect(report.rehashes.first?.pageIndex == DiskImagesGolden.reattestedSlot)#expect(try DiskImagesFixture.digest(of: swiftClone) == DiskImagesGolden.patchedAndReattested,@@ -594,7 +594,7 @@ struct CFWDiskimagesiodReattestTests {// is derived, not typed in, and then checked against the offset the// frozen run used so both sides really are the same experiment.var data = try Data(contentsOf: swiftClone)- let directory = try #require(CFWMachOCodeSignature.codeDirectories(in: data)?.first)+ let directory = try #require(CustomFirmwareMachOCodeSignature.codeDirectories(in: data)?.first)let tail = try #require(directory.slotRange(directory.codeSlotCount - 1))let victim = tail.lowerBound + tail.count / 2#expect(victim == DiskImagesGolden.tailVictimOffset)@@ -603,7 +603,7 @@ struct CFWDiskimagesiodReattestTests {data[victim] = data[victim] ^ 0xFFtry data.write(to: swiftClone)- let rehashes = try CFWMachOCodeSignature.reattest(fileAt: swiftClone, modifiedOffsets: [victim])+ let rehashes = try CustomFirmwareMachOCodeSignature.reattest(fileAt: swiftClone, modifiedOffsets: [victim])let slot = try #require(rehashes.first)#expect(slot.isTailSlot)#expect(slot.hashedLength == tail.count)@@ -624,17 +624,17 @@ struct CFWDiskimagesiodReattestTests {.enabled(if: DiskImagesFixture.runs, DiskImagesFixture.missing),.serialized,)-struct CFWDiskimagesiodIdempotenceTests {+struct CustomFirmwareDiskimagesiodIdempotenceTests {@Testfunc `a second Swift run recognises its own output and writes nothing`() throws {let clone = try DiskImagesFixture.clone(named: "twice")defer { DiskImagesFixture.discard(clone) }- try CFWDiskimagesiod.patch(fileAt: clone, log: nil)+ try CustomFirmwareDiskimagesiod.patch(fileAt: clone, log: nil)let afterFirst = try Data(contentsOf: clone)let attributes = try FileManager.default.attributesOfItem(atPath: clone.path)- let second = try CFWDiskimagesiod.patch(fileAt: clone, log: nil)+ let second = try CustomFirmwareDiskimagesiod.patch(fileAt: clone, log: nil)#expect(second.outcome == .alreadyPatched)#expect(second.sitesWritten == 0)#expect(second.record == nil)@@ -651,10 +651,10 @@ struct CFWDiskimagesiodIdempotenceTests {let clone = try DiskImagesFixture.clone(named: "twice-attested")defer { DiskImagesFixture.discard(clone) }- try CFWDiskimagesiod.patch(fileAt: clone, reattest: true, log: nil)+ try CustomFirmwareDiskimagesiod.patch(fileAt: clone, reattest: true, log: nil)let afterFirst = try Data(contentsOf: clone)- let second = try CFWDiskimagesiod.patch(fileAt: clone, reattest: true, log: nil)+ let second = try CustomFirmwareDiskimagesiod.patch(fileAt: clone, reattest: true, log: nil)#expect(second.outcome == .alreadyPatched)#expect(second.sitesWritten == 0)#expect(second.rehashes.isEmpty, "the stored slot hashes were already current")@@ -677,13 +677,13 @@ struct CFWDiskimagesiodIdempotenceTests {defer { DiskImagesFixture.discard(referenceOutput) }// Reproduce the reference's output, and prove it is that, by digest.- try CFWDiskimagesiod.patch(fileAt: referenceOutput, log: nil)+ try CustomFirmwareDiskimagesiod.patch(fileAt: referenceOutput, log: nil)try #require(try DiskImagesFixture.digest(of: referenceOutput) == DiskImagesGolden.patched,)#expect(DiskImagesGolden.patchedTwice == DiskImagesGolden.patched)- let report = try CFWDiskimagesiod.patch(fileAt: referenceOutput, log: nil)+ let report = try CustomFirmwareDiskimagesiod.patch(fileAt: referenceOutput, log: nil)#expect(report.outcome == .alreadyPatched)#expect(try DiskImagesFixture.digest(of: referenceOutput) == DiskImagesGolden.patched)}@@ -694,7 +694,7 @@ struct CFWDiskimagesiodIdempotenceTests {defer { DiskImagesFixture.discard(clone) }let pristine = try #require(DiskImagesFixture.pristine, DiskImagesFixture.missing)- let report = try CFWDiskimagesiod.patch(fileAt: clone, reattest: true, dryRun: true, log: nil)+ let report = try CustomFirmwareDiskimagesiod.patch(fileAt: clone, reattest: true, dryRun: true, log: nil)#expect(report.outcome == .wouldPatch)#expect(report.sitesWritten == 0)#expect(report.rehashes.isEmpty)diff --git a/tests/FirmwarePatcherTests/CFWJetsamTests.swift b/tests/FirmwarePatcherTests/CustomFirmwareJetsamTests.swiftsimilarity index 83%rename from tests/FirmwarePatcherTests/CFWJetsamTests.swiftrename to tests/FirmwarePatcherTests/CustomFirmwareJetsamTests.swiftindex 883b6e09..fb14fa58 100644--- a/tests/FirmwarePatcherTests/CFWJetsamTests.swift+++ b/tests/FirmwarePatcherTests/CustomFirmwareJetsamTests.swift@@ -1,4 +1,4 @@-// CFWJetsamTests.swift — `CFWJetsamPatcher` against the reference it replaces.+// CustomFirmwareJetsamTests.swift — `CustomFirmwareJetsamPatcher` against the reference it replaces.//// The bar for this port is not "the test passes". It is that the Swift patcher// and `scripts/patchers/cfw_patch_jetsam.py` produce the same bytes from the@@ -63,7 +63,7 @@ enum JetsamFixture {static func workDirectory(_ name: String) throws -> URL {let base = ProcessInfo.processInfo.environment["VPHONE_JETSAM_ARTIFACTS"].map { URL(filePath: $0) } ?? URL(filePath: NSTemporaryDirectory())- let directory = base.appending(path: "CFWJetsamTests-\(name)")+ let directory = base.appending(path: "CustomFirmwareJetsamTests-\(name)")try? FileManager.default.removeItem(at: directory)try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true)return directory@@ -157,7 +157,7 @@ enum JetsamGolden {// MARK: - Against the frozen reference@Suite("launchd jetsam guard — against the frozen reference")-struct CFWJetsamReferenceTests {+struct CustomFirmwareJetsamReferenceTests {/// The fixture the frozen digests were taken over. Without this a digest/// mismatch below would read as a patcher bug when the real cause is a/// different firmware's `launchd`.@@ -178,7 +178,7 @@ struct CFWJetsamReferenceTests {let work = try JetsamFixture.workDirectory("byte-equivalence")let swiftTarget = try JetsamFixture.launchdCopy(named: "launchd.swift", in: work)- let outcome = try CFWJetsamPatcher.patch(fileAt: swiftTarget, log: nil)+ let outcome = try CustomFirmwareJetsamPatcher.patch(fileAt: swiftTarget, log: nil)#expect(outcome.verdict == .patched)#expect(try JetsamFixture.digest(of: swiftTarget) == JetsamGolden.patched,@@ -206,13 +206,13 @@ struct CFWJetsamReferenceTests {@Test(.enabled(if: JetsamFixture.hasLaunchd))func `agrees with the frozen reference on the site`() throws {let data = try Data(contentsOf: JetsamFixture.pristineLaunchd)- let image = try CFWJetsamPatcher.Image(data: data)- let site = try #require(try CFWJetsamPatcher.locate(in: image))+ let image = try CustomFirmwareJetsamPatcher.Image(data: data)+ let site = try #require(try CustomFirmwareJetsamPatcher.locate(in: image))#expect(site.xrefOffset == JetsamGolden.xrefOffset)#expect(site.gateOffset == JetsamGolden.gateOffset)var patchable = data- let outcome = try CFWJetsamPatcher.patch(&patchable, dryRun: true, log: nil)+ let outcome = try CustomFirmwareJetsamPatcher.patch(&patchable, dryRun: true, log: nil)#expect(outcome.gateOffset == JetsamGolden.gateOffset)#expect(outcome.verdict == .wouldPatch)}@@ -221,7 +221,7 @@ struct CFWJetsamReferenceTests {// MARK: - Idempotence@Suite("launchd jetsam guard — idempotence")-struct CFWJetsamIdempotenceTests {+struct CustomFirmwareJetsamIdempotenceTests {/// The bug this patcher must not have. The reference re-patches a second,/// different branch on an already-patched binary; this one recognises its/// own work and stops.@@ -230,11 +230,11 @@ struct CFWJetsamIdempotenceTests {let work = try JetsamFixture.workDirectory("idempotence")let target = try JetsamFixture.launchdCopy(named: "launchd", in: work)- let first = try CFWJetsamPatcher.patch(fileAt: target, log: nil)+ let first = try CustomFirmwareJetsamPatcher.patch(fileAt: target, log: nil)#expect(first.verdict == .patched)let afterFirst = try Data(contentsOf: target)- let second = try CFWJetsamPatcher.patch(fileAt: target, log: nil)+ let second = try CustomFirmwareJetsamPatcher.patch(fileAt: target, log: nil)#expect(second.verdict == .alreadyPatched)#expect(second.gateOffset == first.gateOffset)#expect(second.returnBlockOffset == first.returnBlockOffset)@@ -244,7 +244,7 @@ struct CFWJetsamIdempotenceTests {#expect(JetsamFixture.firstDifference(afterFirst, afterSecond) == nil)// A third pass must not drift either.- let third = try CFWJetsamPatcher.patch(fileAt: target, log: nil)+ let third = try CustomFirmwareJetsamPatcher.patch(fileAt: target, log: nil)#expect(third.verdict == .alreadyPatched)let afterThird = try Data(contentsOf: target)#expect(JetsamFixture.firstDifference(afterFirst, afterThird) == nil)@@ -268,11 +268,11 @@ struct CFWJetsamIdempotenceTests {// The Swift half, measured: run once, land on the reference's one-run// bytes; run again, and nothing moves.- try CFWJetsamPatcher.patch(fileAt: swiftTarget, log: nil)+ try CustomFirmwareJetsamPatcher.patch(fileAt: swiftTarget, log: nil)let swiftOnce = try Data(contentsOf: swiftTarget)#expect(Data(SHA256.hash(data: swiftOnce)).hex == JetsamGolden.patched)- try CFWJetsamPatcher.patch(fileAt: swiftTarget, log: nil)+ try CustomFirmwareJetsamPatcher.patch(fileAt: swiftTarget, log: nil)let swiftTwice = try Data(contentsOf: swiftTarget)#expect(JetsamFixture.firstDifference(swiftOnce, swiftTwice) == nil)#expect(Data(SHA256.hash(data: swiftTwice)).hex != JetsamGolden.patchedTwice)@@ -288,7 +288,7 @@ struct CFWJetsamIdempotenceTests {// MARK: - Re-attestation@Suite("launchd jetsam guard — signature re-attestation")-struct CFWJetsamSignatureTests {+struct CustomFirmwareJetsamSignatureTests {/// Default is the reference's behaviour: the four bytes and nothing else,/// because every call site re-signs with `ldid` straight afterwards.@Test(.enabled(if: JetsamFixture.hasLaunchdAndCodesign))@@ -296,7 +296,7 @@ struct CFWJetsamSignatureTests {let work = try JetsamFixture.workDirectory("stale-signature")let target = try JetsamFixture.launchdCopy(named: "launchd", in: work)- let outcome = try CFWJetsamPatcher.patch(fileAt: target, log: nil)+ let outcome = try CustomFirmwareJetsamPatcher.patch(fileAt: target, log: nil)#expect(outcome.rehashes.isEmpty)let verify = try JetsamFixture.run(JetsamFixture.codesign, ["-v", target.path])@@ -310,15 +310,15 @@ struct CFWJetsamSignatureTests {let work = try JetsamFixture.workDirectory("reattested")let target = try JetsamFixture.launchdCopy(named: "launchd", in: work)- let outcome = try CFWJetsamPatcher.patch(fileAt: target, reattest: true, log: nil)+ let outcome = try CustomFirmwareJetsamPatcher.patch(fileAt: target, reattest: true, log: nil)#expect(outcome.verdict == .patched)#expect(outcome.rehashes.count == 1)let rehash = try #require(outcome.rehashes.first)let patched = try Data(contentsOf: target)let directory = try #require(- CFWMachOCodeSignature.codeDirectories(in: patched)?- .first { $0.hashType == CFWMachOCodeSignature.hashTypeSHA256 },+ CustomFirmwareMachOCodeSignature.codeDirectories(in: patched)?+ .first { $0.hashType == CustomFirmwareMachOCodeSignature.hashTypeSHA256 },)#expect(rehash.pageIndex == outcome.gateOffset / directory.pageSize)@@ -334,7 +334,7 @@ struct CFWJetsamSignatureTests {let work = try JetsamFixture.workDirectory("slot-hash")let swiftTarget = try JetsamFixture.launchdCopy(named: "launchd.swift", in: work)- let outcome = try CFWJetsamPatcher.patch(fileAt: swiftTarget, reattest: true, log: nil)+ let outcome = try CustomFirmwareJetsamPatcher.patch(fileAt: swiftTarget, reattest: true, log: nil)#expect(outcome.verdict == .patched)#expect(outcome.gateOffset == JetsamGolden.gateOffset)#expect(outcome.rehashes.first?.pageIndex == JetsamGolden.reattestedSlot)@@ -348,29 +348,29 @@ struct CFWJetsamSignatureTests {// MARK: - Anchoring, without a reference@Suite("launchd jetsam guard — anchoring")-struct CFWJetsamAnchoringTests {+struct CustomFirmwareJetsamAnchoringTests {/// Every step of the reveal lands where the disassembly says it should:/// the xref is inside the function, the gate is inside the function and/// before the xref, and the gate's target really does return.@Test(.enabled(if: JetsamFixture.hasLaunchd))func `reveal steps are self consistent`() throws {let data = try Data(contentsOf: JetsamFixture.pristineLaunchd)- let image = try CFWJetsamPatcher.Image(data: data)- let site = try #require(try CFWJetsamPatcher.locate(in: image))+ let image = try CustomFirmwareJetsamPatcher.Image(data: data)+ let site = try #require(try CustomFirmwareJetsamPatcher.locate(in: image))- #expect(CFWJetsamPatcher.panicStringAnchors.contains(site.anchor))+ #expect(CustomFirmwareJetsamPatcher.panicStringAnchors.contains(site.anchor))#expect(!site.isAlreadyPatched)#expect(site.functionOffset <= site.gateOffset)#expect(site.gateOffset < site.xrefOffset)#expect(image.isInText(site.xrefOffset))#expect(image.isInText(site.returnBlockOffset))- #expect(CFWJetsamPatcher.isReturnBlock(site.returnBlockOffset, in: image))+ #expect(CustomFirmwareJetsamPatcher.isReturnBlock(site.returnBlockOffset, in: image))// The function bound is a real prologue, not the blind fallback.#expect(data.loadLE(UInt32.self, at: site.functionOffset) == ARM64.pacibspU32)// The anchor string starts where the xref computes it to start.- let page = CFWJetsamPatcher.adrpPage(+ let page = CustomFirmwareJetsamPatcher.adrpPage(data.loadLE(UInt32.self, at: site.xrefOffset),at: image.virtualAddress(ofTextOffset: site.xrefOffset),)@@ -379,8 +379,8 @@ struct CFWJetsamAnchoringTests {// The gate is a conditional branch, and it branches to the return block.let disassembler = ARM64Disassembler()let gate = try #require(disassembler.disassembleOne(in: data, at: site.gateOffset))- #expect(CFWJetsamPatcher.conditionalBranchMnemonics.contains(gate.mnemonic))- #expect(CFWJetsamPatcher.branchTarget(gate) == site.returnBlockOffset)+ #expect(CustomFirmwareJetsamPatcher.conditionalBranchMnemonics.contains(gate.mnemonic))+ #expect(CustomFirmwareJetsamPatcher.branchTarget(gate) == site.returnBlockOffset)}/// The gate is the *earliest* qualifying branch in the function — any later@@ -388,19 +388,19 @@ struct CFWJetsamAnchoringTests {@Test(.enabled(if: JetsamFixture.hasLaunchd))func `gate is the earliest qualifying branch`() throws {let data = try Data(contentsOf: JetsamFixture.pristineLaunchd)- let image = try CFWJetsamPatcher.Image(data: data)- let site = try #require(try CFWJetsamPatcher.locate(in: image))+ let image = try CustomFirmwareJetsamPatcher.Image(data: data)+ let site = try #require(try CustomFirmwareJetsamPatcher.locate(in: image))let disassembler = ARM64Disassembler()for offset in stride(from: site.functionOffset, to: site.gateOffset, by: 4) {guard let insn = disassembler.disassembleOne(in: data, at: offset),- CFWJetsamPatcher.conditionalBranchMnemonics.contains(insn.mnemonic)+ CustomFirmwareJetsamPatcher.conditionalBranchMnemonics.contains(insn.mnemonic)|| insn.mnemonic == "b",- let target = CFWJetsamPatcher.branchTarget(insn),+ let target = CustomFirmwareJetsamPatcher.branchTarget(insn),image.isInText(target)else { continue }#expect(- !CFWJetsamPatcher.isReturnBlock(target, in: image),+ !CustomFirmwareJetsamPatcher.isReturnBlock(target, in: image),"0x\(String(offset, radix: 16)) qualifies and is earlier than the chosen gate",)}@@ -413,11 +413,11 @@ struct CFWJetsamAnchoringTests {@Test(.enabled(if: JetsamFixture.hasLaunchd))func `patched shape is recognised in place`() throws {var data = try Data(contentsOf: JetsamFixture.pristineLaunchd)- let outcome = try CFWJetsamPatcher.patch(&data, log: nil)+ let outcome = try CustomFirmwareJetsamPatcher.patch(&data, log: nil)#expect(outcome.verdict == .patched)- let image = try CFWJetsamPatcher.Image(data: data)- let site = try #require(try CFWJetsamPatcher.locate(in: image))+ let image = try CustomFirmwareJetsamPatcher.Image(data: data)+ let site = try #require(try CustomFirmwareJetsamPatcher.locate(in: image))#expect(site.isAlreadyPatched)#expect(site.gateOffset == outcome.gateOffset)#expect(site.returnBlockOffset == outcome.returnBlockOffset)@@ -425,7 +425,7 @@ struct CFWJetsamAnchoringTests {// And the later branch the reference would fall back to really is// there, live, into the same return block — which is why the check has// to live inside the scan.- let gate = try #require(CFWJetsamPatcher.findReturnGate(+ let gate = try #require(CustomFirmwareJetsamPatcher.findReturnGate(from: site.gateOffset + 4,to: site.xrefOffset,in: image,@@ -439,7 +439,7 @@ struct CFWJetsamAnchoringTests {// MARK: - Decoders and encoders@Suite("launchd jetsam guard — instruction decoding")-struct CFWJetsamDecodeTests {+struct CustomFirmwareJetsamDecodeTests {/// `ADD Xd, Xn, #imm12, LSL #0` only — an `LSL #12` form or a/// shifted-register add would make the xref land on the wrong string.@Test@@ -450,13 +450,13 @@ struct CFWJetsamDecodeTests {let addImm = try #require(ARM64Encoder.encodeAddImm12(rd: 0, rn: 0, imm12: 0xA09))let decoded = try #require(disassembler.disassembleOne(addImm, at: 0))#expect(decoded.mnemonic == "add")- #expect(CFWJetsamPatcher.isAddImm64(addImm.loadLE(UInt32.self, at: 0)))+ #expect(CustomFirmwareJetsamPatcher.isAddImm64(addImm.loadLE(UInt32.self, at: 0)))// And the neighbours it must not accept.- #expect(!CFWJetsamPatcher.isAddImm64(0x9140_0000)) // add x0, x0, #0, lsl #12- #expect(!CFWJetsamPatcher.isAddImm64(0x1100_0000)) // add w0, w0, #0 (32-bit)- #expect(!CFWJetsamPatcher.isAddImm64(0x8B08_1534)) // add x20, x9, x8, lsl #5- #expect(!CFWJetsamPatcher.isAddImm64(0xD100_0000)) // sub x0, x0, #0+ #expect(!CustomFirmwareJetsamPatcher.isAddImm64(0x9140_0000)) // add x0, x0, #0, lsl #12+ #expect(!CustomFirmwareJetsamPatcher.isAddImm64(0x1100_0000)) // add w0, w0, #0 (32-bit)+ #expect(!CustomFirmwareJetsamPatcher.isAddImm64(0x8B08_1534)) // add x20, x9, x8, lsl #5+ #expect(!CustomFirmwareJetsamPatcher.isAddImm64(0xD100_0000)) // sub x0, x0, #0}/// `adrpPage` against Capstone, which resolves the page for us. The inputs@@ -475,8 +475,8 @@ struct CFWJetsamDecodeTests {#expect(insn.mnemonic == "adrp")#expect(operands.count >= 2 && operands[1].type == AARCH64_OP_IMM)let word = encoded.loadLE(UInt32.self, at: 0)- #expect(CFWJetsamPatcher.adrpPage(word, at: pc) == UInt64(operands[1].imm))- #expect(CFWJetsamPatcher.adrpPage(word, at: pc) == target & ~0xFFF)+ #expect(CustomFirmwareJetsamPatcher.adrpPage(word, at: pc) == UInt64(operands[1].imm))+ #expect(CustomFirmwareJetsamPatcher.adrpPage(word, at: pc) == target & ~0xFFF)}}@@ -489,7 +489,7 @@ struct CFWJetsamDecodeTests {let encoded = try #require(ARM64Encoder.encodeB(from: site, to: target))let insn = try #require(disassembler.disassembleOne(encoded, at: UInt64(site)))#expect(insn.mnemonic == "b")- #expect(CFWJetsamPatcher.branchTarget(insn) == target)+ #expect(CustomFirmwareJetsamPatcher.branchTarget(insn) == target)}}@@ -508,7 +508,7 @@ struct CFWJetsamDecodeTests {// Returns, from the project's own pre-encoded constants.for bytes in [ARM64.ret, ARM64.retaa, ARM64.retab] {let insn = try decode(bytes)- #expect(CFWJetsamPatcher.isReturn(insn))+ #expect(CustomFirmwareJetsamPatcher.isReturn(insn))}// Control leaves: an unconditional relative jump and a relative call,@@ -518,8 +518,8 @@ struct CFWJetsamDecodeTests {#require(ARM64Encoder.encodeBL(from: 0, to: 8)),] {let insn = try decode(bytes)- #expect(CFWJetsamPatcher.leavesBlock(insn))- #expect(!CFWJetsamPatcher.isReturn(insn))+ #expect(CustomFirmwareJetsamPatcher.leavesBlock(insn))+ #expect(!CustomFirmwareJetsamPatcher.isReturn(insn))}// The register-indirect forms, and the breakpoint that a `hasPrefix("br")`@@ -534,8 +534,8 @@ struct CFWJetsamDecodeTests {for (word, mnemonic, ends) in indirect {let insn = try decode(ARM64.encodeU32(word))#expect(insn.mnemonic == mnemonic)- #expect(CFWJetsamPatcher.leavesBlock(insn) == ends)- #expect(!CFWJetsamPatcher.isReturn(insn))+ #expect(CustomFirmwareJetsamPatcher.leavesBlock(insn) == ends)+ #expect(!CustomFirmwareJetsamPatcher.isReturn(insn))}// Conditional branches fall through, so they end nothing — this is what@@ -547,9 +547,9 @@ struct CFWJetsamDecodeTests {]for word in conditional {let insn = try decode(ARM64.encodeU32(word))- #expect(CFWJetsamPatcher.conditionalBranchMnemonics.contains(insn.mnemonic))- #expect(!CFWJetsamPatcher.leavesBlock(insn))- #expect(!CFWJetsamPatcher.isReturn(insn))+ #expect(CustomFirmwareJetsamPatcher.conditionalBranchMnemonics.contains(insn.mnemonic))+ #expect(!CustomFirmwareJetsamPatcher.leavesBlock(insn))+ #expect(!CustomFirmwareJetsamPatcher.isReturn(insn))}}@@ -565,7 +565,7 @@ struct CFWJetsamDecodeTests {))let tbzInsn = try #require(disassembler.disassembleOne(tbz, at: 0))#expect(tbzInsn.mnemonic == "tbz")- #expect(CFWJetsamPatcher.branchTarget(tbzInsn) == 8)+ #expect(CustomFirmwareJetsamPatcher.branchTarget(tbzInsn) == 8)// cbz w0, #8 and b.eq #8 — two and one operand. Neither has an encoder// in `ARM64Encoder` (no patch writes one), so the words are built here@@ -574,8 +574,8 @@ struct CFWJetsamDecodeTests {let beq: UInt32 = 0x5400_0000 | (2 << 5) // imm19 = 8 / 4, cond = EQfor word in [cbz, beq] {let insn = try #require(disassembler.disassembleOne(ARM64.encodeU32(word), at: 0))- #expect(CFWJetsamPatcher.conditionalBranchMnemonics.contains(insn.mnemonic))- #expect(CFWJetsamPatcher.branchTarget(insn) == 8)+ #expect(CustomFirmwareJetsamPatcher.conditionalBranchMnemonics.contains(insn.mnemonic))+ #expect(CustomFirmwareJetsamPatcher.branchTarget(insn) == 8)}}@@ -585,11 +585,11 @@ struct CFWJetsamDecodeTests {func `c string start widens to the whole string`() throws {var bytes = Data("first\u{0}jetsam property category (%s) is not initialized\u{0}".utf8)var hit = try #require(bytes.range(of: Data("property".utf8))?.lowerBound)- #expect(CFWJetsamPatcher.cStringStart(in: bytes, containing: hit, sectionStart: 0) == 6)+ #expect(CustomFirmwareJetsamPatcher.cStringStart(in: bytes, containing: hit, sectionStart: 0) == 6)// A string that starts at the section's first byte has no NUL in front.bytes = Data("jetsam property category\u{0}".utf8)hit = try #require(bytes.range(of: Data("property".utf8))?.lowerBound)- #expect(CFWJetsamPatcher.cStringStart(in: bytes, containing: hit, sectionStart: 0) == 0)+ #expect(CustomFirmwareJetsamPatcher.cStringStart(in: bytes, containing: hit, sectionStart: 0) == 0)}}diff --git a/tests/FirmwarePatcherTests/CFWMachOTests.swift b/tests/FirmwarePatcherTests/CustomFirmwareMachOTests.swiftsimilarity index 88%rename from tests/FirmwarePatcherTests/CFWMachOTests.swiftrename to tests/FirmwarePatcherTests/CustomFirmwareMachOTests.swiftindex d1ab5168..a8b4eae7 100644--- a/tests/FirmwarePatcherTests/CFWMachOTests.swift+++ b/tests/FirmwarePatcherTests/CustomFirmwareMachOTests.swift@@ -1,11 +1,11 @@-// CFWMachOTests.swift — Mach-O load-command insertion and code-signature re-attestation.+// CustomFirmwareMachOTests.swift — Mach-O load-command insertion and code-signature re-attestation.//// Both modules replace something outside this code, so both are tested against// it rather than against expectations written down by hand://-// * `CFWInjectDylib` against `.tools/bin/insert_dylib`, byte for byte, while+// * `CustomFirmwareInjectDylib` against `.tools/bin/insert_dylib`, byte for byte, while// that submodule build is still in the tree.-// * `CFWMachOCodeSignature` against `scripts/patchers/cfw_macho_codesign.py`,+// * `CustomFirmwareMachOCodeSignature` against `scripts/patchers/cfw_macho_codesign.py`,// byte for byte. That Python is gone, so what it wrote is frozen in// ``MachOCodeSignGolden`` below — over the real 24A435 `seputil` rather// than a local build product, because a golden is only worth what its@@ -114,7 +114,7 @@ enum MachOFixture {static func scratchCopy(_ name: String, of source: URL? = nil) throws -> URL {let origin = try source ?? signedBinary()let directory = URL(filePath: NSTemporaryDirectory())- .appending(path: "CFWMachOTests-\(UUID().uuidString)")+ .appending(path: "CustomFirmwareMachOTests-\(UUID().uuidString)")try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true)let destination = directory.appending(path: name)try FileManager.default.copyItem(at: origin, to: destination)@@ -170,7 +170,7 @@ enum MachOFixture {// MARK: - Code Signature@Suite("Standalone Mach-O code-signature re-attestation")-struct CFWMachOCodeSignatureTests {+struct CustomFirmwareMachOCodeSignatureTests {// MARK: Tail slot/// The regression this module exists to not repeat.@@ -182,7 +182,7 @@ struct CFWMachOCodeSignatureTests {@Test(.enabled(if: MachOFixture.runs, MachOFixture.missing))func `tail slot hashes only up to code limit`() throws {let data = try Data(contentsOf: MachOFixture.signedBinary())- let directory = try #require(CFWMachOCodeSignature.codeDirectories(in: data)?.first)+ let directory = try #require(CustomFirmwareMachOCodeSignature.codeDirectories(in: data)?.first)let lastSlot = directory.codeSlotCount - 1let range = try #require(directory.slotRange(lastSlot))@@ -194,7 +194,7 @@ struct CFWMachOCodeSignatureTests {// in the slot against one computed here from the short range.let file = try MachOFixture.scratchCopy("tail")try MachOFixture.flipByte(at: directory.codeLimit - 1, in: file)- let records = try CFWMachOCodeSignature.reattest(+ let records = try CustomFirmwareMachOCodeSignature.reattest(fileAt: file,modifiedOffsets: [directory.codeLimit - 1],)@@ -225,7 +225,7 @@ struct CFWMachOCodeSignatureTests {/// machine reliably has a page-aligned codeLimit, so the boundary maths is/// pinned directly.@Test func `slot ranges follow code limit alignment`() {- let aligned = CFWCodeDirectory(+ let aligned = CustomFirmwareCodeDirectory(slotType: 0, offset: 0, length: 0, hashOffset: 0, hashSize: 32,hashType: 2, pageSize: 4096, pageSizeLog2: 12,codeSlotCount: 2, codeLimit: 8192,@@ -234,7 +234,7 @@ struct CFWMachOCodeSignatureTests {#expect(aligned.slotRange(1) == 4096 ..< 8192)#expect(aligned.slotRange(2) == nil)- let short = CFWCodeDirectory(+ let short = CustomFirmwareCodeDirectory(slotType: 0, offset: 0, length: 0, hashOffset: 0, hashSize: 32,hashType: 2, pageSize: 4096, pageSizeLog2: 12,codeSlotCount: 2, codeLimit: 5000,@@ -244,9 +244,9 @@ struct CFWMachOCodeSignatureTests {}@Test func `offsets past code limit belong to no slot`() {- #expect(CFWMachOCodeSignature.pageBounds(fileOffset: 4095, pageSize: 4096, codeLimit: 5000)?.index == 0)- #expect(CFWMachOCodeSignature.pageBounds(fileOffset: 4999, pageSize: 4096, codeLimit: 5000)?.end == 5000)- #expect(CFWMachOCodeSignature.pageBounds(fileOffset: 5000, pageSize: 4096, codeLimit: 5000) == nil)+ #expect(CustomFirmwareMachOCodeSignature.pageBounds(fileOffset: 4095, pageSize: 4096, codeLimit: 5000)?.index == 0)+ #expect(CustomFirmwareMachOCodeSignature.pageBounds(fileOffset: 4999, pageSize: 4096, codeLimit: 5000)?.end == 5000)+ #expect(CustomFirmwareMachOCodeSignature.pageBounds(fileOffset: 5000, pageSize: 4096, codeLimit: 5000) == nil)}// MARK: Page size@@ -263,10 +263,10 @@ struct CFWMachOCodeSignatureTests {@Test(.enabled(if: MachOFixture.runs, MachOFixture.missing))func `page size comes from the code directory`() throws {let shipped = try Data(contentsOf: MachOFixture.signedBinary())- let directory = try #require(CFWMachOCodeSignature.codeDirectories(in: shipped)?.first)+ let directory = try #require(CustomFirmwareMachOCodeSignature.codeDirectories(in: shipped)?.first)#expect(directory.pageSize == 1 << Int(directory.pageSizeLog2))#expect(directory.pageSize == 4096, "the shipped iOS signature uses 4 KiB pages")- #expect(directory.hashType == CFWMachOCodeSignature.hashTypeSHA256)+ #expect(directory.hashType == CustomFirmwareMachOCodeSignature.hashTypeSHA256)#expect(directory.hashSize == SHA256.byteCount)}@@ -275,7 +275,7 @@ struct CFWMachOCodeSignatureTests {@Test(.enabled(if: MachOFixture.runs && MachOFixture.hasCodesign, MachOFixture.missing))func `page size follows whoever signed the file`() throws {let shipped = try Data(contentsOf: MachOFixture.signedBinary())- let iOSDirectory = try #require(CFWMachOCodeSignature.codeDirectories(in: shipped)?.first)+ let iOSDirectory = try #require(CustomFirmwareMachOCodeSignature.codeDirectories(in: shipped)?.first)let file = try MachOFixture.scratchCopy("pagesize")defer { try? FileManager.default.removeItem(at: file.deletingLastPathComponent()) }@@ -286,7 +286,7 @@ struct CFWMachOCodeSignatureTests {try #require(signing.status == 0, "could not re-sign the fixture: \(signing.output)")let hostDirectory = try #require(- try CFWMachOCodeSignature.codeDirectories(in: Data(contentsOf: file))?.first,+ try CustomFirmwareMachOCodeSignature.codeDirectories(in: Data(contentsOf: file))?.first,)#expect(hostDirectory.pageSize == 1 << Int(hostDirectory.pageSizeLog2))#expect(hostDirectory.pageSize == 16384, "the host signer uses 16 KiB pages")@@ -302,20 +302,20 @@ struct CFWMachOCodeSignatureTests {@Test func `unsigned data is rejected`() {var data = Data(repeating: 0, count: 4096)#expect(throws: PatcherError.self) {- try CFWMachOCodeSignature.reattest(&data, modifiedOffsets: [0])+ try CustomFirmwareMachOCodeSignature.reattest(&data, modifiedOffsets: [0])}}@Test func `no offsets is A no op`() throws {var data = Data(repeating: 0, count: 16)- #expect(try CFWMachOCodeSignature.reattest(&data, modifiedOffsets: []).isEmpty)+ #expect(try CustomFirmwareMachOCodeSignature.reattest(&data, modifiedOffsets: []).isEmpty)}@Test(.enabled(if: MachOFixture.runs, MachOFixture.missing))func `unchanged pages are not rewritten`() throws {let file = try MachOFixture.scratchCopy("untouched")// Nothing was modified, so every slot already matches and no write happens.- let records = try CFWMachOCodeSignature.reattest(fileAt: file, modifiedOffsets: [0, 4096, 8192])+ let records = try CustomFirmwareMachOCodeSignature.reattest(fileAt: file, modifiedOffsets: [0, 4096, 8192])#expect(records.isEmpty)#expect(try Data(contentsOf: file) == Data(contentsOf: MachOFixture.signedBinary()))}@@ -335,14 +335,14 @@ struct CFWMachOCodeSignatureTests {try #require(signing.status == 0, "could not build a dual-CD fixture: \(signing.output)")let before = try Data(contentsOf: file)- let directories = try #require(CFWMachOCodeSignature.codeDirectories(in: before))+ let directories = try #require(CustomFirmwareMachOCodeSignature.codeDirectories(in: before))try #require(directories.count == 2)- let legacy = try #require(directories.first { $0.hashType == CFWMachOCodeSignature.hashTypeSHA1 })- let modern = try #require(directories.first { $0.hashType == CFWMachOCodeSignature.hashTypeSHA256 })- #expect(CFWMachOCodeSignature.unsupportedCodeDirectories(in: before).map(\.offset) == [legacy.offset])+ let legacy = try #require(directories.first { $0.hashType == CustomFirmwareMachOCodeSignature.hashTypeSHA1 })+ let modern = try #require(directories.first { $0.hashType == CustomFirmwareMachOCodeSignature.hashTypeSHA256 })+ #expect(CustomFirmwareMachOCodeSignature.unsupportedCodeDirectories(in: before).map(\.offset) == [legacy.offset])try MachOFixture.flipByte(at: 16, in: file)- let records = try CFWMachOCodeSignature.reattest(fileAt: file, modifiedOffsets: [16])+ let records = try CustomFirmwareMachOCodeSignature.reattest(fileAt: file, modifiedOffsets: [16])#expect(records.allSatisfy { $0.codeDirectoryOffset == modern.offset })let after = try Data(contentsOf: file)@@ -371,7 +371,7 @@ struct CFWMachOCodeSignatureTests {)let data = try Data(contentsOf: pristine)- let directory = try #require(CFWMachOCodeSignature.codeDirectories(in: data)?.first)+ let directory = try #require(CustomFirmwareMachOCodeSignature.codeDirectories(in: data)?.first)// First page, a middle page, the short tail page, and one offset past// codeLimit that both implementations must ignore.let offsets = [@@ -393,7 +393,7 @@ struct CFWMachOCodeSignatureTests {try MachOFixture.flipByte(at: offset, in: swiftFile)}- let records = try CFWMachOCodeSignature.reattest(fileAt: swiftFile, modifiedOffsets: offsets)+ let records = try CustomFirmwareMachOCodeSignature.reattest(fileAt: swiftFile, modifiedOffsets: offsets)#expect(records.contains { $0.isTailSlot }, "the offset set must exercise the tail slot")#expect(records.map(\.pageIndex).sorted() == MachOCodeSignGolden.rewrittenSlots)@@ -446,14 +446,14 @@ private enum MachOCodeSignGolden {// MARK: - Dylib Injection@Suite("LC_LOAD_DYLIB injection")-struct CFWInjectDylibTests {+struct CustomFirmwareInjectDylibTests {/// What `cfw_install_jb.sh` does to launchd, minus ldid: the weak load of/// `/b` has to appear and the header has to grow to match.@Test(.enabled(if: MachOFixture.runs, MachOFixture.missing))func `inserts A weak load command`() throws {let file = try MachOFixture.scratchCopy("weak")let before = try Data(contentsOf: file)- let injections = try CFWInjectDylib.inject(dylibPath: "/b", into: file)+ let injections = try CustomFirmwareInjectDylib.inject(dylibPath: "/b", into: file)let injection = try #require(injections.first)#expect(injections.count == 1)#expect(injection.isWeak)@@ -486,7 +486,7 @@ struct CFWInjectDylibTests {func `keeping the signature rehashes the header page`() throws {let file = try MachOFixture.scratchCopy("keep")let before = try Data(contentsOf: file)- let injection = try #require(try CFWInjectDylib.inject(+ let injection = try #require(try CustomFirmwareInjectDylib.inject(dylibPath: "/b",into: file,policy: .keepAndReattest,@@ -498,7 +498,7 @@ struct CFWInjectDylibTests {#expect(after.count == before.count, "keeping the signature must not resize the file")#expect(MachOFixture.dylibLoadCommands(in: after).contains { $0.path == "/b" })- let directory = try #require(CFWMachOCodeSignature.codeDirectories(in: after)?.first)+ let directory = try #require(CustomFirmwareMachOCodeSignature.codeDirectories(in: after)?.first)let range = try #require(directory.slotRange(0))let slot = directory.slotHashOffset(0)#expect(after[slot ..< slot + directory.hashSize] == Data(SHA256.hash(data: after[range])))@@ -516,22 +516,22 @@ struct CFWInjectDylibTests {try data.write(to: file)#expect(throws: PatcherError.self) {- try CFWInjectDylib.inject(dylibPath: "/b", into: file)+ try CustomFirmwareInjectDylib.inject(dylibPath: "/b", into: file)}// …and the opt-out still works, for a caller that knows better.#expect(throws: Never.self) {- try CFWInjectDylib.inject(dylibPath: "/b", into: file, allowNonEmptyPadding: true)+ try CustomFirmwareInjectDylib.inject(dylibPath: "/b", into: file, allowNonEmptyPadding: true)}}@Test func `rejects what it cannot handle`() {var empty = Data([0xCA, 0xFE, 0xBA, 0xBF, 0, 0, 0, 1])#expect(throws: PatcherError.self) {- try CFWInjectDylib.inject(dylibPath: "/b", into: &empty)+ try CustomFirmwareInjectDylib.inject(dylibPath: "/b", into: &empty)}var garbage = Data(repeating: 0xAB, count: 512)#expect(throws: PatcherError.self) {- try CFWInjectDylib.inject(dylibPath: "/b", into: &garbage)+ try CustomFirmwareInjectDylib.inject(dylibPath: "/b", into: &garbage)}}@@ -543,7 +543,7 @@ struct CFWInjectDylibTests {let referenceFile = swiftFile.deletingLastPathComponent().appending(path: "reference")try FileManager.default.copyItem(at: MachOFixture.signedBinary(), to: referenceFile)- try CFWInjectDylib.inject(dylibPath: "/b", into: swiftFile)+ try CustomFirmwareInjectDylib.inject(dylibPath: "/b", into: swiftFile)let reference = try MachOFixture.run(MachOFixture.insertDylib,["--weak", "--inplace", "--all-yes", "/b", referenceFile.path],diff --git a/tests/FirmwarePatcherTests/CFWMobileactivationdTests.swift b/tests/FirmwarePatcherTests/CustomFirmwareMobileactivationdTests.swiftsimilarity index 89%rename from tests/FirmwarePatcherTests/CFWMobileactivationdTests.swiftrename to tests/FirmwarePatcherTests/CustomFirmwareMobileactivationdTests.swiftindex c4343ce5..3ea205e0 100644--- a/tests/FirmwarePatcherTests/CFWMobileactivationdTests.swift+++ b/tests/FirmwarePatcherTests/CustomFirmwareMobileactivationdTests.swift@@ -1,4 +1,4 @@-// CFWMobileactivationdTests.swift — `-[DeviceType should_hactivate]` -> YES.+// CustomFirmwareMobileactivationdTests.swift — `-[DeviceType should_hactivate]` -> YES.//// The bar here is not "the Swift patcher did something". It is that this port// and `scripts/patchers/cfw_patch_mobileactivationd.py` produce the same bytes@@ -52,9 +52,9 @@ enum MobileactivationdFixture {if let override = ProcessInfo.processInfo.environment["VPHONE_TEST_ARTIFACTS"],!override.isEmpty{- return URL(filePath: override).appending(path: "CFWMobileactivationdTests")+ return URL(filePath: override).appending(path: "CustomFirmwareMobileactivationdTests")}- return FileManager.default.temporaryDirectory.appending(path: "CFWMobileactivationdTests")+ return FileManager.default.temporaryDirectory.appending(path: "CustomFirmwareMobileactivationdTests")}()static func exists(_ url: URL) -> Bool {@@ -158,14 +158,14 @@ enum MobileactivationdGolden {/// `VPHONE_PATCH_RESIGN=0` skips re-attestation, which is what reproduces/// ``MobileactivationdGolden/patched`` exactly.@Suite("mobileactivationd should_hactivate — shell runner")-struct CFWMobileactivationdRunnerTests {+struct CustomFirmwareMobileactivationdRunnerTests {@Test(.enabled(if: ProcessInfo.processInfo.environment["VPHONE_PATCH_FILE"] != nil))func `run patcher from environment`() throws {let environment = ProcessInfo.processInfo.environmentlet path = try #require(environment["VPHONE_PATCH_FILE"])let resign = environment["VPHONE_PATCH_RESIGN"] != "0"- let report = try CFWMobileactivationd.patch(fileAt: URL(filePath: path), resign: resign)+ let report = try CustomFirmwareMobileactivationd.patch(fileAt: URL(filePath: path), resign: resign)print("RUNNER outcome=\(report.outcome.rawValue)"@@ -187,7 +187,7 @@ struct CFWMobileactivationdRunnerTests {// MARK: - Anchoring@Suite("mobileactivationd should_hactivate — anchoring")-struct CFWMobileactivationdAnchorTests {+struct CustomFirmwareMobileactivationdAnchorTests {/// The two routes are independent — `LC_SYMTAB` on one side, the/// `__objc_methname` -> `__objc_selrefs` -> relative method list walk on the/// other — and they agree. That agreement is the evidence the anchor is the@@ -198,16 +198,16 @@ struct CFWMobileactivationdAnchorTests {let segments = MachOParser.parseSegments(from: data)let bySymbol = try #require(- CFWMobileactivationd.symbolVirtualAddress(in: data),+ CustomFirmwareMobileactivationd.symbolVirtualAddress(in: data),"LC_SYMTAB should carry -[DeviceType should_hactivate]",)let byMetadata = try #require(- CFWMobileactivationd.objcMetadataVirtualAddress(in: data, segments: segments),+ CustomFirmwareMobileactivationd.objcMetadataVirtualAddress(in: data, segments: segments),"the ObjC method lists should carry the same IMP",)#expect(bySymbol == byMetadata)- let anchor = try CFWMobileactivationd.locateIMP(in: data)+ let anchor = try CustomFirmwareMobileactivationd.locateIMP(in: data)#expect(anchor.source == .symbolTableAndObjCMetadata)#expect(anchor.virtualAddress == bySymbol)#expect(anchor.section == "__TEXT,__text", "the IMP must be code, not data")@@ -229,7 +229,7 @@ struct CFWMobileactivationdAnchorTests {let data = try Data(contentsOf: MobileactivationdFixture.pristine)let sections = MachOParser.parseSections(from: data)let selectorVA = try #require(- CFWMobileactivationd.selectorVirtualAddress(in: data, sections: sections),+ CustomFirmwareMobileactivationd.selectorVirtualAddress(in: data, sections: sections),)let methname = try #require(sections["__TEXT,__objc_methname"])@@ -239,7 +239,7 @@ struct CFWMobileactivationdAnchorTests {// That naive search finds an earlier, wrong offset on this binary — so// this is not an assertion that passes either way.- let needle = Data(CFWMobileactivationd.selector.utf8) + Data([0])+ let needle = Data(CustomFirmwareMobileactivationd.selector.utf8) + Data([0])let naive = try #require(data.range(of: needle)?.lowerBound)#expect(naive < offset)#expect(data[naive - 1] == UInt8(ascii: "_"))@@ -251,7 +251,7 @@ struct CFWMobileactivationdAnchorTests {func `missing method throws`() throws {let data = try Data(contentsOf: MobileactivationdFixture.launchd)#expect(throws: PatcherError.self) {- try CFWMobileactivationd.locateIMP(in: data)+ try CustomFirmwareMobileactivationd.locateIMP(in: data)}}@@ -260,7 +260,7 @@ struct CFWMobileactivationdAnchorTests {/// patch asks it for the right instruction, and that the pair reads back as/// `mov x0, #1 ; ret`.@Test func `replacement is mov X 0 one then ret`() throws {- let bytes = try CFWMobileactivationd.replacementBytes()+ let bytes = try CustomFirmwareMobileactivationd.replacementBytes()#expect(bytes.count == 8)#expect(bytes == ARM64.movX0_1 + ARM64.ret)@@ -278,14 +278,14 @@ struct CFWMobileactivationdAnchorTests {/// Both words of the getter are re-hashed, so a getter that straddles a/// page boundary does not leave the second page's slot stale.@Test func `touched offsets cover both words`() throws {- let anchor = CFWMobileactivationd.Anchor(+ let anchor = CustomFirmwareMobileactivationd.Anchor(virtualAddress: 0x1_0000_0FFC,fileOffset: 0xFFC,source: .symbolTable,section: "__TEXT,__text",)- let bytes = try CFWMobileactivationd.replacementBytes()- let offsets = CFWMobileactivationd.touchedOffsets(anchor, bytes)+ let bytes = try CustomFirmwareMobileactivationd.replacementBytes()+ let offsets = CustomFirmwareMobileactivationd.touchedOffsets(anchor, bytes)#expect(offsets == [0xFFC, 0x1000])#expect(Set(offsets.map { $0 / 4096 }).count == 2, "the two words are on different pages")}@@ -294,7 +294,7 @@ struct CFWMobileactivationdAnchorTests {// MARK: - Byte parity with the frozen reference@Suite("mobileactivationd should_hactivate — parity and idempotence")-struct CFWMobileactivationdParityTests {+struct CustomFirmwareMobileactivationdParityTests {/// The fixture the frozen digests were taken over. Without this a digest/// mismatch below would read as a patcher bug when the real cause is a/// different firmware's `mobileactivationd`.@@ -320,7 +320,7 @@ struct CFWMobileactivationdParityTests {func `matches the frozen reference bytes`() throws {let swiftFile = try MobileactivationdFixture.copyOfPristine(named: "swift.bin")- let report = try CFWMobileactivationd.patch(fileAt: swiftFile, resign: false, log: nil)+ let report = try CustomFirmwareMobileactivationd.patch(fileAt: swiftFile, resign: false, log: nil)#expect(report.outcome == .patched)#expect(report.sitesWritten == 1)@@ -354,7 +354,7 @@ struct CFWMobileactivationdParityTests {func `reattested output matches the frozen reference and verifies`() throws {let swiftFile = try MobileactivationdFixture.copyOfPristine(named: "swift-resigned.bin")- let report = try CFWMobileactivationd.patch(fileAt: swiftFile, resign: true, log: nil)+ let report = try CustomFirmwareMobileactivationd.patch(fileAt: swiftFile, resign: true, log: nil)let rehash = try #require(report.slotRehashes.first)#expect(report.slotRehashes.count == 1)#expect(rehash.pageIndex == MobileactivationdGolden.reattestedSlot)@@ -376,7 +376,7 @@ struct CFWMobileactivationdParityTests {// The contrast: without re-attestation it is rejected.let unsigned = try MobileactivationdFixture.copyOfPristine(named: "swift-unsigned.bin")- try CFWMobileactivationd.patch(fileAt: unsigned, resign: false, log: nil)+ try CustomFirmwareMobileactivationd.patch(fileAt: unsigned, resign: false, log: nil)let rejected = try MobileactivationdFixture.run(MobileactivationdFixture.codesign, ["-v", unsigned.path],)@@ -390,11 +390,11 @@ struct CFWMobileactivationdParityTests {func `second run changes nothing`() throws {let file = try MobileactivationdFixture.copyOfPristine(named: "swift-idempotent.bin")- let first = try CFWMobileactivationd.patch(fileAt: file, log: nil)+ let first = try CustomFirmwareMobileactivationd.patch(fileAt: file, log: nil)#expect(first.outcome == .patched)let afterFirst = try Data(contentsOf: file)- let second = try CFWMobileactivationd.patch(fileAt: file, log: nil)+ let second = try CustomFirmwareMobileactivationd.patch(fileAt: file, log: nil)#expect(second.outcome == .alreadyPatched)#expect(second.sitesWritten == 0)#expect(second.record == nil)@@ -402,7 +402,7 @@ struct CFWMobileactivationdParityTests {#expect(second.anchor == first.anchor)#expect(try Data(contentsOf: file) == afterFirst)- let third = try CFWMobileactivationd.patch(fileAt: file, log: nil)+ let third = try CustomFirmwareMobileactivationd.patch(fileAt: file, log: nil)#expect(third.outcome == .alreadyPatched)#expect(try Data(contentsOf: file) == afterFirst)}@@ -414,9 +414,9 @@ struct CFWMobileactivationdParityTests {@Test(.enabled(if: MobileactivationdFixture.hasPristine))func `rerun repairs A stale slot`() throws {let file = try MobileactivationdFixture.copyOfPristine(named: "swift-stale-slot.bin")- try CFWMobileactivationd.patch(fileAt: file, resign: false, log: nil)+ try CustomFirmwareMobileactivationd.patch(fileAt: file, resign: false, log: nil)- let repaired = try CFWMobileactivationd.patch(fileAt: file, resign: true, log: nil)+ let repaired = try CustomFirmwareMobileactivationd.patch(fileAt: file, resign: true, log: nil)#expect(repaired.outcome == .alreadyPatched)#expect(repaired.slotRehashes.count == 1, "the stale slot must be recomputed")#expect(repaired.record == nil, "no code bytes changed the second time")@@ -428,7 +428,7 @@ struct CFWMobileactivationdParityTests {let file = try MobileactivationdFixture.copyOfPristine(named: "swift-dry-run.bin")let before = try Data(contentsOf: file)- let report = try CFWMobileactivationd.patch(fileAt: file, dryRun: true, log: nil)+ let report = try CustomFirmwareMobileactivationd.patch(fileAt: file, dryRun: true, log: nil)#expect(report.outcome == .wouldPatch)#expect(report.sitesWritten == 0)#expect(report.anchor.section == "__TEXT,__text")diff --git a/tests/FirmwarePatcherTests/CFWPlistPatchTests.swift b/tests/FirmwarePatcherTests/CustomFirmwarePlistPatchTests.swiftsimilarity index 77%rename from tests/FirmwarePatcherTests/CFWPlistPatchTests.swiftrename to tests/FirmwarePatcherTests/CustomFirmwarePlistPatchTests.swiftindex 14576c12..11a2c7a6 100644--- a/tests/FirmwarePatcherTests/CFWPlistPatchTests.swift+++ b/tests/FirmwarePatcherTests/CustomFirmwarePlistPatchTests.swift@@ -1,10 +1,10 @@-// CFWPlistPatchTests.swift — the three P1.4 CFW patchers, against the Python+// CustomFirmwarePlistPatchTests.swift — the three P1.4 CFW patchers, against the Python// they replaced.//// Unit tests cover the behaviour each patcher is supposed to have. The// equivalence tests are the ones that matter: `scripts/patchers/<name>.py` was// run over the same real input the Swift gets, and what it produced is frozen-// in ``CFWPlistPatchGolden`` below — semantically for the two plist patchers,+// in ``CustomFirmwarePlistPatchGolden`` below — semantically for the two plist patchers,// byte for byte for the device tree.//// Real input, never a hand-made stand-in:@@ -32,7 +32,7 @@ import Testing/// What `scripts/patchers/` produced on these inputs, recorded before it was/// deleted. Measured at repo commit `78cbeea` with `.venv/bin/python3`.-enum CFWPlistPatchGolden {+enum CustomFirmwarePlistPatchGolden {/// `.venv/bin/python3 scripts/patchers/cfw_patch_build_version.py \/// <copy of /System/Library/CoreServices/SystemVersion.plist> 23F77`///@@ -86,7 +86,7 @@ enum CFWPlistPatchGolden {// MARK: - Fixtures-enum CFWPatchFixtures {+enum CustomFirmwarePatchFixtures {/// tests/FirmwarePatcherTests/<this file> → repo root.static let repoRoot = URL(filePath: #filePath).deletingLastPathComponent()@@ -142,11 +142,11 @@ enum CFWPatchFixtures {/// Extract the device tree IM4P into `directory` and return its path.static func extractDeviceTree(into directory: URL) throws -> URL {guard let ipsw = ipswWithDeviceTree() else {- throw CFWTestError.missingFixture("no IPSW in ipsws/ contains \(deviceTreeEntry)")+ throw CustomFirmwareTestError.missingFixture("no IPSW in ipsws/ contains \(deviceTreeEntry)")}let result = try run("/usr/bin/unzip", ["-o", "-j", ipsw.path, deviceTreeEntry, "-d", directory.path])guard result.status == 0 else {- throw CFWTestError.commandFailed("unzip exited \(result.status): \(result.output)")+ throw CustomFirmwareTestError.commandFailed("unzip exited \(result.status): \(result.output)")}return directory.appending(path: "DeviceTree.vphone600ap.im4p")}@@ -157,7 +157,7 @@ enum CFWPatchFixtures {static func dumpEntitlements(of binary: URL, to url: URL) throws {let result = try run("/usr/bin/codesign", ["-d", "--entitlements", ":-", "--xml", binary.path])guard result.status == 0, !result.outputData.isEmpty else {- throw CFWTestError.commandFailed("codesign exited \(result.status): \(result.combined)")+ throw CustomFirmwareTestError.commandFailed("codesign exited \(result.status): \(result.combined)")}try result.outputData.write(to: url)}@@ -214,7 +214,7 @@ enum CFWPatchFixtures {}}-enum CFWTestError: Error, CustomStringConvertible {+enum CustomFirmwareTestError: Error, CustomStringConvertible {case missingFixture(String)case commandFailed(String)@@ -309,18 +309,18 @@ enum PlistComparison {}}-// MARK: - CFWBuildVersion+// MARK: - CustomFirmwareBuildVersion-struct CFWBuildVersionTests {+struct CustomFirmwareBuildVersionTests {@Test func `detects XML and binary formats`() {- #expect(CFWBuildVersion.detectFormat(Data("<?xml version=\"1.0\"?>".utf8)) == .xml)- #expect(CFWBuildVersion.detectFormat(Data("\n\t <plist>".utf8)) == .xml)- #expect(CFWBuildVersion.detectFormat(Data("bplist00".utf8)) == .binary)- #expect(CFWBuildVersion.detectFormat(Data()) == .binary)+ #expect(CustomFirmwareBuildVersion.detectFormat(Data("<?xml version=\"1.0\"?>".utf8)) == .xml)+ #expect(CustomFirmwareBuildVersion.detectFormat(Data("\n\t <plist>".utf8)) == .xml)+ #expect(CustomFirmwareBuildVersion.detectFormat(Data("bplist00".utf8)) == .binary)+ #expect(CustomFirmwareBuildVersion.detectFormat(Data()) == .binary)}@Test func `rewrites the key and leaves everything else alone`() throws {- let directory = try CFWPatchFixtures.makeTemporaryDirectory()+ let directory = try CustomFirmwarePatchFixtures.makeTemporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let url = directory.appending(path: "SystemVersion.plist")let original: [String: Any] = [@@ -332,7 +332,7 @@ struct CFWBuildVersionTests {.data(fromPropertyList: original, format: .xml, options: 0).write(to: url)- let outcome = try CFWBuildVersion.patch(at: url, to: "23F77", verbose: false)+ let outcome = try CustomFirmwareBuildVersion.patch(at: url, to: "23F77", verbose: false)#expect(outcome == .rewritten(from: "23B85", to: "23F77"))let patched = try PlistComparison.load(url) as? [String: Any]@@ -342,7 +342,7 @@ struct CFWBuildVersionTests {}@Test func `is idempotent and honours dry run`() throws {- let directory = try CFWPatchFixtures.makeTemporaryDirectory()+ let directory = try CustomFirmwarePatchFixtures.makeTemporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let url = directory.appending(path: "SystemVersion.plist")try PropertyListSerialization@@ -350,53 +350,53 @@ struct CFWBuildVersionTests {.write(to: url)let before = try Data(contentsOf: url)- #expect(try CFWBuildVersion.patch(at: url, to: "23F77", verbose: false) == .alreadyTarget("23F77"))+ #expect(try CustomFirmwareBuildVersion.patch(at: url, to: "23F77", verbose: false) == .alreadyTarget("23F77"))#expect(try Data(contentsOf: url) == before)- let dry = try CFWBuildVersion.patch(at: url, to: "24A100", dryRun: true, verbose: false)+ let dry = try CustomFirmwareBuildVersion.patch(at: url, to: "24A100", dryRun: true, verbose: false)#expect(dry == .dryRun(from: "23F77", to: "24A100"))#expect(try Data(contentsOf: url) == before)}@Test func `refuses A plist without the key`() throws {- let directory = try CFWPatchFixtures.makeTemporaryDirectory()+ let directory = try CustomFirmwarePatchFixtures.makeTemporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let url = directory.appending(path: "SystemVersion.plist")try PropertyListSerialization.data(fromPropertyList: ["ProductVersion": "26.1"], format: .xml, options: 0).write(to: url)#expect(throws: PatcherError.self) {- try CFWBuildVersion.patch(at: url, to: "23F77", verbose: false)+ try CustomFirmwareBuildVersion.patch(at: url, to: "23F77", verbose: false)}}@Test func `refuses A non dictionary root`() throws {- let directory = try CFWPatchFixtures.makeTemporaryDirectory()+ let directory = try CustomFirmwarePatchFixtures.makeTemporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let url = directory.appending(path: "root-array.plist")try PropertyListSerialization.data(fromPropertyList: ["a", "b"], format: .xml, options: 0).write(to: url)#expect(throws: PatcherError.self) {- try CFWBuildVersion.patch(at: url, to: "23F77", verbose: false)+ try CustomFirmwareBuildVersion.patch(at: url, to: "23F77", verbose: false)}}- @Test(.enabled(if: CFWPatchFixtures.systemVersionAvailable))+ @Test(.enabled(if: CustomFirmwarePatchFixtures.systemVersionAvailable))func `matches the frozen reference on A real system version plist`() throws {- let directory = try CFWPatchFixtures.makeTemporaryDirectory()+ let directory = try CustomFirmwarePatchFixtures.makeTemporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }- let target = CFWPlistPatchGolden.buildVersionTarget+ let target = CustomFirmwarePlistPatchGolden.buildVersionTarget// Both plist encodings of the same real file: the rootfs copy is XML,// the Cryptex copy on a device can be binary.for format in ["xml1", "binary1"] {let swiftOutput = directory.appending(path: "swift-\(format).plist")- try CFWPatchFixtures.copyContents(of: CFWPatchFixtures.systemVersionPlist, to: swiftOutput)- try CFWPatchFixtures.run("/usr/bin/plutil", ["-convert", format, swiftOutput.path])+ try CustomFirmwarePatchFixtures.copyContents(of: CustomFirmwarePatchFixtures.systemVersionPlist, to: swiftOutput)+ try CustomFirmwarePatchFixtures.run("/usr/bin/plutil", ["-convert", format, swiftOutput.path])let before = try #require(try PlistComparison.load(swiftOutput) as? [String: Any])- try CFWBuildVersion.patch(at: swiftOutput, to: target, verbose: false)+ try CustomFirmwareBuildVersion.patch(at: swiftOutput, to: target, verbose: false)let after = try #require(try PlistComparison.load(swiftOutput) as? [String: Any])// The transform the reference applied: that one key's value, and@@ -409,14 +409,14 @@ struct CFWBuildVersionTests {// The format the file went in as is the format it comes back as.let swiftBytes = try Data(contentsOf: swiftOutput)- #expect(CFWBuildVersion.detectFormat(swiftBytes) == (format == "xml1" ? .xml : .binary))+ #expect(CustomFirmwareBuildVersion.detectFormat(swiftBytes) == (format == "xml1" ? .xml : .binary))}}}-// MARK: - CFWMachLookupExceptions+// MARK: - CustomFirmwareMachLookupExceptions-struct CFWMachLookupExceptionTests {+struct CustomFirmwareMachLookupExceptionTests {private func write(_ plist: [String: Any], to url: URL) throws {try PropertyListSerialization.data(fromPropertyList: plist, format: .xml, options: 0)@@ -424,87 +424,87 @@ struct CFWMachLookupExceptionTests {}@Test func `adds every service when the key is absent`() throws {- let directory = try CFWPatchFixtures.makeTemporaryDirectory()+ let directory = try CustomFirmwarePatchFixtures.makeTemporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let url = directory.appending(path: "Campo.entitlements")try write(["platform-application": true], to: url)- let outcome = try CFWMachLookupExceptions.merge(at: url, verbose: false)- #expect(outcome.added == CFWMachLookupExceptions.services.count)- #expect(outcome.total == CFWMachLookupExceptions.services.count)+ let outcome = try CustomFirmwareMachLookupExceptions.merge(at: url, verbose: false)+ #expect(outcome.added == CustomFirmwareMachLookupExceptions.services.count)+ #expect(outcome.total == CustomFirmwareMachLookupExceptions.services.count)let patched = try PlistComparison.load(url) as? [String: Any]- #expect(patched?[CFWMachLookupExceptions.exceptionKey] as? [String]- == CFWMachLookupExceptions.services)+ #expect(patched?[CustomFirmwareMachLookupExceptions.exceptionKey] as? [String]+ == CustomFirmwareMachLookupExceptions.services)#expect(patched?["platform-application"] as? Bool == true)}@Test func `keeps existing entries first and does not duplicate`() throws {- let directory = try CFWPatchFixtures.makeTemporaryDirectory()+ let directory = try CustomFirmwarePatchFixtures.makeTemporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let url = directory.appending(path: "Campo.entitlements")let preexisting = ["com.apple.some.other.service", "com.apple.CARenderServer"]- try write([CFWMachLookupExceptions.exceptionKey: preexisting], to: url)+ try write([CustomFirmwareMachLookupExceptions.exceptionKey: preexisting], to: url)- let outcome = try CFWMachLookupExceptions.merge(at: url, verbose: false)- #expect(outcome.added == CFWMachLookupExceptions.services.count - 1)+ let outcome = try CustomFirmwareMachLookupExceptions.merge(at: url, verbose: false)+ #expect(outcome.added == CustomFirmwareMachLookupExceptions.services.count - 1)let patched = try PlistComparison.load(url) as? [String: Any]- let merged = patched?[CFWMachLookupExceptions.exceptionKey] as? [String] ?? []+ let merged = patched?[CustomFirmwareMachLookupExceptions.exceptionKey] as? [String] ?? []#expect(Array(merged.prefix(2)) == preexisting)#expect(merged.filter { $0 == "com.apple.CARenderServer" }.count == 1)- #expect(Set(merged).isSuperset(of: CFWMachLookupExceptions.services))+ #expect(Set(merged).isSuperset(of: CustomFirmwareMachLookupExceptions.services))}@Test func `is idempotent`() throws {- let directory = try CFWPatchFixtures.makeTemporaryDirectory()+ let directory = try CustomFirmwarePatchFixtures.makeTemporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let url = directory.appending(path: "Campo.entitlements")try write(["get-task-allow": true], to: url)- try CFWMachLookupExceptions.merge(at: url, verbose: false)+ try CustomFirmwareMachLookupExceptions.merge(at: url, verbose: false)let once = try Data(contentsOf: url)- let second = try CFWMachLookupExceptions.merge(at: url, verbose: false)+ let second = try CustomFirmwareMachLookupExceptions.merge(at: url, verbose: false)#expect(second.added == 0)#expect(try Data(contentsOf: url) == once)}@Test func `refuses an exception key that is not an array`() throws {- let directory = try CFWPatchFixtures.makeTemporaryDirectory()+ let directory = try CustomFirmwarePatchFixtures.makeTemporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let url = directory.appending(path: "Campo.entitlements")- try write([CFWMachLookupExceptions.exceptionKey: "com.apple.CARenderServer"], to: url)+ try write([CustomFirmwareMachLookupExceptions.exceptionKey: "com.apple.CARenderServer"], to: url)#expect(throws: PatcherError.self) {- try CFWMachLookupExceptions.merge(at: url, verbose: false)+ try CustomFirmwareMachLookupExceptions.merge(at: url, verbose: false)}}- @Test(.enabled(if: CFWPatchFixtures.entitlementsDonorAvailable))+ @Test(.enabled(if: CustomFirmwarePatchFixtures.entitlementsDonorAvailable))func `matches the frozen reference on real entitlements`() throws {- let directory = try CFWPatchFixtures.makeTemporaryDirectory()+ let directory = try CustomFirmwarePatchFixtures.makeTemporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }- let key = CFWPlistPatchGolden.exceptionKey- #expect(CFWMachLookupExceptions.exceptionKey == key)+ let key = CustomFirmwarePlistPatchGolden.exceptionKey+ #expect(CustomFirmwareMachLookupExceptions.exceptionKey == key)- for donor in CFWPatchFixtures.availableEntitlementsDonors {+ for donor in CustomFirmwarePatchFixtures.availableEntitlementsDonors {let name = donor.lastPathComponentlet swiftOutput = directory.appending(path: "swift-\(name).entitlements")- try CFWPatchFixtures.dumpEntitlements(of: donor, to: swiftOutput)+ try CustomFirmwarePatchFixtures.dumpEntitlements(of: donor, to: swiftOutput)let before = try #require(try PlistComparison.load(swiftOutput) as? [String: Any])let existing = (before[key] as? [String]) ?? []- let outcome = try CFWMachLookupExceptions.merge(at: swiftOutput, verbose: false)+ let outcome = try CustomFirmwareMachLookupExceptions.merge(at: swiftOutput, verbose: false)let after = try #require(try PlistComparison.load(swiftOutput) as? [String: Any])// The transform the reference applied: the existing array, then// every service it did not already carry, in SERVICES order.let expectedServices = existing- + CFWMachLookupExceptions.services.filter { !existing.contains($0) }+ + CustomFirmwareMachLookupExceptions.services.filter { !existing.contains($0) }#expect(after[key] as? [String] == expectedServices, "\(name)")// …and its own count line agreed with that arithmetic.#expect(- CFWPlistPatchGolden.countLine(total: outcome.total, added: outcome.added)- == CFWPlistPatchGolden.countLine(+ CustomFirmwarePlistPatchGolden.countLine(total: outcome.total, added: outcome.added)+ == CustomFirmwarePlistPatchGolden.countLine(total: expectedServices.count,added: expectedServices.count - existing.count,),@@ -560,7 +560,7 @@ enum DERTestEncoder {static func children(of data: Data) throws -> [Data] {var offset = 0func readHeader() throws -> (tag: UInt8, valueStart: Int, valueCount: Int) {- guard offset + 2 <= data.count else { throw CFWTestError.commandFailed("short DER") }+ guard offset + 2 <= data.count else { throw CustomFirmwareTestError.commandFailed("short DER") }let tag = data[offset]let first = data[offset + 1]var cursor = offset + 2@@ -588,34 +588,34 @@ enum DERTestEncoder {}}-// MARK: - CFWPostRestoreDeviceTree+// MARK: - CustomFirmwarePostRestoreDeviceTree-struct CFWPostRestoreDeviceTreeTests {- @Test(.enabled(if: CFWPatchFixtures.deviceTreeAvailable))+struct CustomFirmwarePostRestoreDeviceTreeTests {+ @Test(.enabled(if: CustomFirmwarePatchFixtures.deviceTreeAvailable))func `parse and serialize round trips A real device tree`() throws {- let directory = try CFWPatchFixtures.makeTemporaryDirectory()+ let directory = try CustomFirmwarePatchFixtures.makeTemporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }- let im4p = try CFWPatchFixtures.extractDeviceTree(into: directory)+ let im4p = try CustomFirmwarePatchFixtures.extractDeviceTree(into: directory)let blob = try IM4P(Data(contentsOf: im4p)).payload()// Patching to the values already there is a no-op, which is the only// way to see the parse/serialize pair on its own.- let (patched, changes) = try CFWPostRestoreDeviceTree.patchedDeviceTree(blob)+ let (patched, changes) = try CustomFirmwarePostRestoreDeviceTree.patchedDeviceTree(blob)#expect(changes.count == 3)#expect(patched.count == blob.count)- let (again, noChanges) = try CFWPostRestoreDeviceTree.patchedDeviceTree(patched)+ let (again, noChanges) = try CustomFirmwarePostRestoreDeviceTree.patchedDeviceTree(patched)#expect(noChanges.isEmpty)#expect(again == patched)}- @Test(.enabled(if: CFWPatchFixtures.deviceTreeAvailable))+ @Test(.enabled(if: CustomFirmwarePatchFixtures.deviceTreeAvailable))func `rewrites exactly the three restore fatal properties`() throws {- let directory = try CFWPatchFixtures.makeTemporaryDirectory()+ let directory = try CustomFirmwarePatchFixtures.makeTemporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }- let im4p = try CFWPatchFixtures.extractDeviceTree(into: directory)+ let im4p = try CustomFirmwarePatchFixtures.extractDeviceTree(into: directory)let blob = try IM4P(Data(contentsOf: im4p)).payload()- let (patched, changes) = try CFWPostRestoreDeviceTree.patchedDeviceTree(blob)+ let (patched, changes) = try CustomFirmwarePostRestoreDeviceTree.patchedDeviceTree(blob)#expect(changes.map(\.property) == ["model", "target-type", "compatible"])#expect(changes[0].before == "iPhone99,11")@@ -633,21 +633,21 @@ struct CFWPostRestoreDeviceTreeTests {#expect(patched.range(of: Data("iPhone17,3\0".utf8)) != nil)}- @Test(.enabled(if: CFWPatchFixtures.deviceTreeAvailable))+ @Test(.enabled(if: CustomFirmwarePatchFixtures.deviceTreeAvailable))func `matches the frozen reference byte for byte on A real device tree`() throws {- let directory = try CFWPatchFixtures.makeTemporaryDirectory()+ let directory = try CustomFirmwarePatchFixtures.makeTemporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }- let source = try CFWPatchFixtures.extractDeviceTree(into: directory)+ let source = try CustomFirmwarePatchFixtures.extractDeviceTree(into: directory)// Two cloudOS IPSWs carry this device tree and they are different// files, so the golden is looked up by the input's own digest rather// than by which IPSW the directory listing happened to hand back.- let input = try CFWPlistPatchGolden.digest(of: source)+ let input = try CustomFirmwarePlistPatchGolden.digest(of: source)let expected = try #require(- CFWPlistPatchGolden.deviceTree[input],+ CustomFirmwarePlistPatchGolden.deviceTree[input],"""no frozen reference output for a DeviceTree.vphone600ap.im4p with \- digest \(input) — re-derive CFWPlistPatchGolden.deviceTree for this \+ digest \(input) — re-derive CustomFirmwarePlistPatchGolden.deviceTree for this \IPSW before reading a failure here as a patcher bug""",)@@ -655,19 +655,19 @@ struct CFWPostRestoreDeviceTreeTests {let swiftOutput = directory.appending(path: "swift.im4p")try FileManager.default.copyItem(at: source, to: swiftOutput)- let outcome = try CFWPostRestoreDeviceTree.patch(at: swiftOutput, verbose: false)+ let outcome = try CustomFirmwarePostRestoreDeviceTree.patch(at: swiftOutput, verbose: false)#expect(outcome.wrote)#expect(outcome.changes.count == 3)#expect(- try CFWPlistPatchGolden.digest(of: swiftOutput) == expected,+ try CustomFirmwarePlistPatchGolden.digest(of: swiftOutput) == expected,"IM4P differs from the frozen reference output",)// And the re-run is a no-op, as the reference's was: it printed// `DT already in target state — no change` and the digest held.- let swiftRerun = try CFWPostRestoreDeviceTree.patch(at: swiftOutput, verbose: false)+ let swiftRerun = try CustomFirmwarePostRestoreDeviceTree.patch(at: swiftOutput, verbose: false)#expect(!swiftRerun.wrote)- #expect(try CFWPlistPatchGolden.digest(of: swiftOutput) == expected)+ #expect(try CustomFirmwarePlistPatchGolden.digest(of: swiftOutput) == expected)}/// The IMG4 path, as far as it can be checked here.@@ -679,11 +679,11 @@ struct CFWPostRestoreDeviceTreeTests {/// new: the IM4P inside must come out identical to the bare-IM4P run, and/// every element around it must come back byte for byte, because the/// manifest and restore info are carried, never re-encoded.- @Test(.enabled(if: CFWPatchFixtures.deviceTreeAvailable))+ @Test(.enabled(if: CustomFirmwarePatchFixtures.deviceTreeAvailable))func `preserves everything around the IM 4 P in an IMG 4`() throws {- let directory = try CFWPatchFixtures.makeTemporaryDirectory()+ let directory = try CustomFirmwarePatchFixtures.makeTemporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }- let source = try CFWPatchFixtures.extractDeviceTree(into: directory)+ let source = try CustomFirmwarePatchFixtures.extractDeviceTree(into: directory)let im4pBytes = try Data(contentsOf: source)// Stand-ins for the manifest and restore info: this test never looks@@ -699,14 +699,14 @@ struct CFWPostRestoreDeviceTreeTests {let img4URL = directory.appending(path: "devicetree.img4")try img4.write(to: img4URL)- let outcome = try CFWPostRestoreDeviceTree.patch(at: img4URL, verbose: false)+ let outcome = try CustomFirmwarePostRestoreDeviceTree.patch(at: img4URL, verbose: false)#expect(outcome.changes.count == 3)#expect(outcome.wrote)// The bare-IM4P run, for comparison.let bareURL = directory.appending(path: "bare.im4p")try im4pBytes.write(to: bareURL)- try CFWPostRestoreDeviceTree.patch(at: bareURL, verbose: false)+ try CustomFirmwarePostRestoreDeviceTree.patch(at: bareURL, verbose: false)let patchedIM4P = try Data(contentsOf: bareURL)let children = try DERTestEncoder.children(of: Data(contentsOf: img4URL))@@ -717,16 +717,16 @@ struct CFWPostRestoreDeviceTreeTests {#expect(children[3] == DERTestEncoder.element(tag: 0xA1, value: restoreInfo))}- @Test(.enabled(if: CFWPatchFixtures.deviceTreeAvailable))+ @Test(.enabled(if: CustomFirmwarePatchFixtures.deviceTreeAvailable))func `refuses A payload that is not A device tree`() throws {- let directory = try CFWPatchFixtures.makeTemporaryDirectory()+ let directory = try CustomFirmwarePatchFixtures.makeTemporaryDirectory()defer { try? FileManager.default.removeItem(at: directory) }let url = directory.appending(path: "not-a-dt.im4p")try IM4P(fourcc: "krnl", description: "test", payload: Data(repeating: 0, count: 64)).data.write(to: url)#expect(throws: PatcherError.self) {- try CFWPostRestoreDeviceTree.patch(at: url, verbose: false)+ try CustomFirmwarePostRestoreDeviceTree.patch(at: url, verbose: false)}}}diff --git a/tests/FirmwarePatcherTests/CFWSeputilTests.swift b/tests/FirmwarePatcherTests/CustomFirmwareSeputilTests.swiftsimilarity index 87%rename from tests/FirmwarePatcherTests/CFWSeputilTests.swiftrename to tests/FirmwarePatcherTests/CustomFirmwareSeputilTests.swiftindex b5f705a6..ae632993 100644--- a/tests/FirmwarePatcherTests/CFWSeputilTests.swift+++ b/tests/FirmwarePatcherTests/CustomFirmwareSeputilTests.swift@@ -1,4 +1,4 @@-// CFWSeputilTests.swift — Parity cross-checks for `CFWSeputil`.+// CustomFirmwareSeputilTests.swift — Parity cross-checks for `CustomFirmwareSeputil`.//// Two independent references, and every claim below is measured against one of// them rather than against a number written down by hand:@@ -23,7 +23,7 @@// `VPHONE_MACHO_PRISTINE` at a directory of pristine Mach-O binaries or leave// the default `ipsws/ref_extract/macho_pristine` in place.//-// Without it these FAIL, following `DSCFoundationTests`: a `guard … else+// Without it these FAIL, following `DyldSharedCacheFoundationTests`: a `guard … else// { return }` is reported by Swift Testing as a pass, so a green run on a// machine with no fixture would be indistinguishable from a green run that// proved something. Set `VPHONE_MACHO_FIXTURE_OPTIONAL=1` to turn that failure@@ -203,7 +203,7 @@ private enum SeputilGolden {// MARK: - Parity against the reference implementations@Suite("seputil gigalocker name", .enabled(if: SeputilFixture.runs, SeputilFixture.skipReason))-struct CFWSeputilParityTests {+struct CustomFirmwareSeputilParityTests {/// The fixture the frozen digests were taken over. Without this the two/// tests below would report a digest mismatch when the real cause is a/// different firmware's `seputil`.@@ -229,7 +229,7 @@ struct CFWSeputilParityTests {let swiftFile = try SeputilFixture.clone(named: "swift-plain")defer { SeputilFixture.discard(swiftFile) }- let outcome = try CFWSeputil.patch(fileAt: swiftFile, reattest: false, log: nil)+ let outcome = try CustomFirmwareSeputil.patch(fileAt: swiftFile, reattest: false, log: nil)#expect(outcome.verdict == .patched)#expect(@@ -255,7 +255,7 @@ struct CFWSeputilParityTests {let swiftFile = try SeputilFixture.clone(named: "swift-full")defer { SeputilFixture.discard(swiftFile) }- let outcome = try CFWSeputil.patch(fileAt: swiftFile, log: nil)+ let outcome = try CustomFirmwareSeputil.patch(fileAt: swiftFile, log: nil)#expect(outcome.rehashes.count == 1, "one page was dirtied, so one slot is rewritten")#expect(outcome.rehashes.first?.pageIndex == SeputilGolden.reattestedSlot)@@ -279,8 +279,8 @@ struct CFWSeputilParityTests {let before = try Subprocess.run(executable: codesign, arguments: ["-v", pristine.path])try #require(before.status == 0, "the pristine fixture must verify: \(before.stderr)")- try CFWSeputil.patch(fileAt: reattested, log: nil)- try CFWSeputil.patch(fileAt: stale, reattest: false, log: nil)+ try CustomFirmwareSeputil.patch(fileAt: reattested, log: nil)+ try CustomFirmwareSeputil.patch(fileAt: stale, reattest: false, log: nil)let good = try Subprocess.run(executable: codesign, arguments: ["-v", reattested.path])let bad = try Subprocess.run(executable: codesign, arguments: ["-v", stale.path])@@ -300,10 +300,10 @@ struct CFWSeputilParityTests {let file = try SeputilFixture.clone(named: "twice")defer { SeputilFixture.discard(file) }- let first = try CFWSeputil.patch(fileAt: file, log: nil)+ let first = try CustomFirmwareSeputil.patch(fileAt: file, log: nil)let afterFirst = try Data(contentsOf: file)- let second = try CFWSeputil.patch(fileAt: file, log: nil)+ let second = try CustomFirmwareSeputil.patch(fileAt: file, log: nil)let afterSecond = try Data(contentsOf: file)#expect(first.verdict == .patched)@@ -325,7 +325,7 @@ struct CFWSeputilParityTests {defer { SeputilFixture.discard(file) }let before = try Data(contentsOf: file)- let outcome = try CFWSeputil.patch(fileAt: file, dryRun: true, log: nil)+ let outcome = try CustomFirmwareSeputil.patch(fileAt: file, dryRun: true, log: nil)#expect(outcome.verdict == .wouldPatch)#expect(outcome.record != nil)#expect(outcome.rehashes.isEmpty)@@ -341,8 +341,8 @@ struct CFWSeputilParityTests {defer { SeputilFixture.discard(file) }let data = try Data(contentsOf: file)- let (cstring, text) = try CFWSeputil.sections(in: data)- let site = try CFWSeputil.findSite(in: data, cstring: cstring)+ let (cstring, text) = try CustomFirmwareSeputil.sections(in: data)+ let site = try CustomFirmwareSeputil.findSite(in: data, cstring: cstring)#expect(site.literal == "%s/%s.gl")#expect(site.isPristine)@@ -358,7 +358,7 @@ struct CFWSeputilParityTests {#expect(site.literalVMA == cstring.address + UInt64(site.literalOffset - Int(cstring.fileOffset)))// And something in __text actually forms that address.- let references = CFWSeputil.references(to: site.literalVMA, in: data, text: text)+ let references = CustomFirmwareSeputil.references(to: site.literalVMA, in: data, text: text)#expect(!references.isEmpty)for reference in references {#expect(reference >= text.address && reference < text.address + text.size)@@ -371,7 +371,7 @@ struct CFWSeputilParityTests {let file = try SeputilFixture.clone(named: "record")defer { SeputilFixture.discard(file) }- let outcome = try CFWSeputil.patch(fileAt: file, dryRun: true, log: nil)+ let outcome = try CustomFirmwareSeputil.patch(fileAt: file, dryRun: true, log: nil)let record = try #require(outcome.record)#expect(record.patchID == "seputil.gigalocker_uuid")#expect(record.component == "seputil")@@ -393,13 +393,13 @@ struct CFWSeputilParityTests {defer { SeputilFixture.discard(file) }let before = try Data(contentsOf: file)- let directory = try #require(CFWMachOCodeSignature.codeDirectories(in: before)?.first)+ let directory = try #require(CustomFirmwareMachOCodeSignature.codeDirectories(in: before)?.first)try #require(directory.codeLimit % directory.pageSize != 0,"this fixture is supposed to have a short tail slot",)- let outcome = try CFWSeputil.patch(fileAt: file, log: nil)+ let outcome = try CustomFirmwareSeputil.patch(fileAt: file, log: nil)let rehash = try #require(outcome.rehashes.first)#expect(outcome.rehashes.count == 1)#expect(rehash.pageIndex == outcome.site.fieldOffset / directory.pageSize)@@ -434,9 +434,9 @@ struct CFWSeputilParityTests {defer { SeputilFixture.discard(file) }var data = try Data(contentsOf: file)- let (cstring, text) = try CFWSeputil.sections(in: data)- let site = try CFWSeputil.findSite(in: data, cstring: cstring)- let references = CFWSeputil.references(to: site.literalVMA, in: data, text: text)+ let (cstring, text) = try CustomFirmwareSeputil.sections(in: data)+ let site = try CustomFirmwareSeputil.findSite(in: data, cstring: cstring)+ let references = CustomFirmwareSeputil.references(to: site.literalVMA, in: data, text: text)try #require(!references.isEmpty)let segments = MachOParser.parseSegments(from: data)@@ -444,10 +444,10 @@ struct CFWSeputilParityTests {let offset = try #require(MachOParser.vaToFileOffset(reference, segments: segments))data.replaceSubrange(offset ..< offset + ARM64.nop.count, with: ARM64.nop)}- #expect(CFWSeputil.references(to: site.literalVMA, in: data, text: text).isEmpty)+ #expect(CustomFirmwareSeputil.references(to: site.literalVMA, in: data, text: text).isEmpty)#expect(throws: PatcherError.self) {- try CFWSeputil.patch(&data, log: nil)+ try CustomFirmwareSeputil.patch(&data, log: nil)}}}@@ -455,7 +455,7 @@ struct CFWSeputilParityTests {// MARK: - Shape rules, with no fixture@Suite("seputil anchor shape")-struct CFWSeputilShapeTests {+struct CustomFirmwareSeputilShapeTests {/// A synthetic `__cstring` is enough to pin the field rule, and it is the/// only way to present cases the real binary does not contain.private func section(at offset: UInt32, size: Int, address: UInt64) -> MachOSectionInfo {@@ -480,28 +480,28 @@ struct CFWSeputilShapeTests {@Test func `reads the field after the last separator`() {// The mountpoint field is left alone; the one after the last "/" moves.- let field = try? #require(CFWSeputil.fileField(of: Array("%s/%s.gl".utf8)))+ let field = try? #require(CustomFirmwareSeputil.fileField(of: Array("%s/%s.gl".utf8)))#expect(field == 3 ..< 5)- #expect(CFWSeputil.fileField(of: Array("/mnt7/%s.gl".utf8)) == 6 ..< 8)+ #expect(CustomFirmwareSeputil.fileField(of: Array("/mnt7/%s.gl".utf8)) == 6 ..< 8)// No separator, wrong suffix, or a field that is not two bytes wide:// none of these is the site this patch knows how to rewrite.- #expect(CFWSeputil.fileField(of: Array("%s.gl".utf8)) == nil)- #expect(CFWSeputil.fileField(of: Array("%s/%s.plist".utf8)) == nil)- #expect(CFWSeputil.fileField(of: Array("%s/%llu.gl".utf8)) == nil)- #expect(CFWSeputil.fileField(of: Array(".gl".utf8)) == nil)+ #expect(CustomFirmwareSeputil.fileField(of: Array("%s.gl".utf8)) == nil)+ #expect(CustomFirmwareSeputil.fileField(of: Array("%s/%s.plist".utf8)) == nil)+ #expect(CustomFirmwareSeputil.fileField(of: Array("%s/%llu.gl".utf8)) == nil)+ #expect(CustomFirmwareSeputil.fileField(of: Array(".gl".utf8)) == nil)}@Test func `classifies only the two spellings it writes`() {- #expect(CFWSeputil.pristineness(of: ArraySlice("%s".utf8)) == true)- #expect(CFWSeputil.pristineness(of: ArraySlice("AA".utf8)) == false)- #expect(CFWSeputil.pristineness(of: ArraySlice("BB".utf8)) == nil)+ #expect(CustomFirmwareSeputil.pristineness(of: ArraySlice("%s".utf8)) == true)+ #expect(CustomFirmwareSeputil.pristineness(of: ArraySlice("AA".utf8)) == false)+ #expect(CustomFirmwareSeputil.pristineness(of: ArraySlice("BB".utf8)) == nil)}@Test func `matches whole literals only`() throws {// "%s.gl" is the next literal after "%s/%s.gl" on the real binary, and// also its tail; a substring search sees both, a literal search one.let data = cstrings(["%s/%s.gl", "%s.gl", "/mnt7"])- let site = try CFWSeputil.findSite(+ let site = try CustomFirmwareSeputil.findSite(in: data,cstring: section(at: 0, size: data.count, address: 0x1_0000_0000),)@@ -513,7 +513,7 @@ struct CFWSeputilShapeTests {@Test func `finds the already patched spelling`() throws {let data = cstrings(["%s/AA.gl"])- let site = try CFWSeputil.findSite(+ let site = try CustomFirmwareSeputil.findSite(in: data,cstring: section(at: 0, size: data.count, address: 0x1_0000_0000),)@@ -524,7 +524,7 @@ struct CFWSeputilShapeTests {@Test func `refuses when there is no candidate`() {let data = cstrings(["%s.gl", "/mnt7", "/private/xarts"])#expect(throws: PatcherError.self) {- try CFWSeputil.findSite(+ try CustomFirmwareSeputil.findSite(in: data,cstring: section(at: 0, size: data.count, address: 0x1_0000_0000),)@@ -536,7 +536,7 @@ struct CFWSeputilShapeTests {@Test func `refuses when there are two candidates`() {let data = cstrings(["%s/%s.gl", "/mnt7", "%s/%s.gl"])#expect(throws: PatcherError.self) {- try CFWSeputil.findSite(+ try CustomFirmwareSeputil.findSite(in: data,cstring: section(at: 0, size: data.count, address: 0x1_0000_0000),)@@ -561,9 +561,9 @@ struct CFWSeputilShapeTests {var code = try #require(ARM64Encoder.encodeADRP(rd: 2, pc: pc, target: target))try code.append(#require(ARM64Encoder.encodeAddImm12(rd: 2, rn: 2, imm12: 0xDCF)))- #expect(CFWSeputil.references(to: target, in: code, text: text(size: 8, address: pc)) == [pc + 4])+ #expect(CustomFirmwareSeputil.references(to: target, in: code, text: text(size: 8, address: pc)) == [pc + 4])// A different literal on the same page is a different address.- #expect(CFWSeputil.references(to: target + 1, in: code, text: text(size: 8, address: pc)).isEmpty)+ #expect(CustomFirmwareSeputil.references(to: target + 1, in: code, text: text(size: 8, address: pc)).isEmpty)}@Test func `rejects an add into another register`() throws {@@ -571,7 +571,7 @@ struct CFWSeputilShapeTests {let target: UInt64 = 0x1_0001_BDCFvar code = try #require(ARM64Encoder.encodeADRP(rd: 2, pc: pc, target: target))try code.append(#require(ARM64Encoder.encodeAddImm12(rd: 3, rn: 3, imm12: 0xDCF)))- #expect(CFWSeputil.references(to: target, in: code, text: text(size: 8, address: pc)).isEmpty)+ #expect(CustomFirmwareSeputil.references(to: target, in: code, text: text(size: 8, address: pc)).isEmpty)}/// `add xD, xN, #imm, lsl #12` forms `page + (imm << 12)`, not `page + imm`.@@ -595,10 +595,10 @@ struct CFWSeputilShapeTests {let lsl = try #require(disassembler.disassembleOne(shifted))#expect(plain.mnemonic == "add")#expect(lsl.mnemonic == "add")- #expect(CFWSeputil.isShiftedAddImmediate(plain) == false)- #expect(CFWSeputil.isShiftedAddImmediate(lsl) == true)+ #expect(CustomFirmwareSeputil.isShiftedAddImmediate(plain) == false)+ #expect(CustomFirmwareSeputil.isShiftedAddImmediate(lsl) == true)- #expect(CFWSeputil.references(to: target, in: adrp + shifted, text: text(size: 8, address: pc)).isEmpty)- #expect(CFWSeputil.references(to: target, in: adrp + add, text: text(size: 8, address: pc)) == [pc + 4])+ #expect(CustomFirmwareSeputil.references(to: target, in: adrp + shifted, text: text(size: 8, address: pc)).isEmpty)+ #expect(CustomFirmwareSeputil.references(to: target, in: adrp + add, text: text(size: 8, address: pc)) == [pc + 4])}}diff --git a/tests/FirmwarePatcherTests/CFWWatchdogdTests.swift b/tests/FirmwarePatcherTests/CustomFirmwareWatchdogdTests.swiftsimilarity index 91%rename from tests/FirmwarePatcherTests/CFWWatchdogdTests.swiftrename to tests/FirmwarePatcherTests/CustomFirmwareWatchdogdTests.swiftindex 6ed1b0aa..94220d9f 100644--- a/tests/FirmwarePatcherTests/CFWWatchdogdTests.swift+++ b/tests/FirmwarePatcherTests/CustomFirmwareWatchdogdTests.swift@@ -1,4 +1,4 @@-// CFWWatchdogdTests.swift — parity, anchoring and idempotence for the+// CustomFirmwareWatchdogdTests.swift — parity, anchoring and idempotence for the// watchdogd hv_vmm_present cache patch.//// Two independent references were available for this patch and both are used:@@ -6,7 +6,7 @@// * `scripts/patchers/cfw_patch_watchdogd.py`, driven exactly as// `cfw_install_exp.sh` drove it (`cfw.py patch-watchdogd <binary>`). That// Python is gone; what it wrote over the pristine binary is frozen in-// ``WatchdogdGolden`` below, and the central test grades `CFWWatchdogd`+// ``WatchdogdGolden`` below, and the central test grades `CustomFirmwareWatchdogd`// against it byte for byte — patched instructions and re-attested code// slots alike, because that verb re-attested on its own.// * `/usr/bin/codesign`, which recomputes the slot hashes itself. It has no@@ -68,7 +68,7 @@ enum WatchdogdFixture {/// outside the working tree.static func scratchCopy(of source: URL, named name: String) throws -> URL {let directory = URL(filePath: NSTemporaryDirectory())- .appending(path: "CFWWatchdogdTests-\(UUID().uuidString)")+ .appending(path: "CustomFirmwareWatchdogdTests-\(UUID().uuidString)")try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true)let destination = directory.appending(path: name)try FileManager.default.copyItem(at: source, to: destination)@@ -103,7 +103,7 @@ enum WatchdogdFixture {/// calls" is measured against an independent count.static func sysctlCallSites(in data: Data) throws -> [UInt64] {let text = try text(in: data)- guard let symbols = CFWWatchdogdSymbolTargets(data: data) else {+ guard let symbols = CustomFirmwareWatchdogdSymbolTargets(data: data) else {throw PatcherError.invalidFormat("fixture has no symbol table")}let start = Int(text.fileOffset)@@ -114,7 +114,7 @@ enum WatchdogdFixture {where instruction.mnemonic == "bl"{guard let target = ARM64Encoder.decodeBranchTarget(- insn: CFWWatchdogd.word(of: instruction), pc: instruction.address,+ insn: CustomFirmwareWatchdogd.word(of: instruction), pc: instruction.address,) else { continue }if symbols.name(forBranchTarget: target) == "_sysctlbyname" {found.append(instruction.address)@@ -159,12 +159,12 @@ enum WatchdogdGolden {// MARK: - Anchoring@Suite("watchdogd hv_vmm_present cache — anchoring")-struct CFWWatchdogdAnchorTests {+struct CustomFirmwareWatchdogdAnchorTests {/// The shape the patch is written against, read off the real binary.@Test(.enabled(if: WatchdogdFixture.hasWatchdogd))func `locates both cache sites`() throws {let data = try Data(contentsOf: WatchdogdFixture.watchdogd)- let sites = try CFWWatchdogd.locateSites(in: data)+ let sites = try CustomFirmwareWatchdogd.locateSites(in: data)#expect(sites.count == 2, "24A435 watchdogd caches the answer in two functions")for site in sites {@@ -190,7 +190,7 @@ struct CFWWatchdogdAnchorTests {@Test(.enabled(if: WatchdogdFixture.hasWatchdogd))func `cached byte lives in zero filled data`() throws {let data = try Data(contentsOf: WatchdogdFixture.watchdogd)- let sites = try CFWWatchdogd.locateSites(in: data)+ let sites = try CustomFirmwareWatchdogd.locateSites(in: data)let sections = MachOParser.parseSections(from: data)let zeroFilled = ["__DATA,__bss", "__DATA,__common"].compactMap { sections[$0] }#expect(!zeroFilled.isEmpty)@@ -211,7 +211,7 @@ struct CFWWatchdogdAnchorTests {func `rejects the other sysctl call sites`() throws {let data = try Data(contentsOf: WatchdogdFixture.watchdogd)let calls = try WatchdogdFixture.sysctlCallSites(in: data)- let sites = try CFWWatchdogd.locateSites(in: data)+ let sites = try CustomFirmwareWatchdogd.locateSites(in: data)#expect(calls.count == 5, "24A435 watchdogd calls sysctlbyname five times")#expect(sites.count == 2)@@ -226,8 +226,8 @@ struct CFWWatchdogdAnchorTests {@Test(.enabled(if: WatchdogdFixture.hasWatchdogd))func `resolves the import through the indirect symbol table`() throws {let data = try Data(contentsOf: WatchdogdFixture.watchdogd)- let symbols = try #require(CFWWatchdogdSymbolTargets(data: data))- let sites = try CFWWatchdogd.locateSites(in: data)+ let symbols = try #require(CustomFirmwareWatchdogdSymbolTargets(data: data))+ let sites = try CustomFirmwareWatchdogd.locateSites(in: data)let call = try #require(sites.first)let target = try #require(ARM64Encoder.decodeBranchTarget(@@ -269,19 +269,19 @@ struct CFWWatchdogdAnchorTests {}// add x9, … ; mov x0, x9 ; bl — the literal is the call's argument.- #expect(try CFWWatchdogd.passesLiteral(+ #expect(try CustomFirmwareWatchdogd.passesLiteral(inRegister: "x9", from: 1, toCallAt: 3, in: stream(movingInto: 0),))// The same shape moving into x1 is some other call's argument.- #expect(try !CFWWatchdogd.passesLiteral(+ #expect(try !CustomFirmwareWatchdogd.passesLiteral(inRegister: "x9", from: 1, toCallAt: 3, in: stream(movingInto: 1),))// No move at all, and the pointer never reaches x0.- #expect(try !CFWWatchdogd.passesLiteral(+ #expect(try !CustomFirmwareWatchdogd.passesLiteral(inRegister: "x9", from: 1, toCallAt: 3, in: stream(movingInto: nil),))// The direct form the shipped binary uses needs no move.- #expect(try CFWWatchdogd.passesLiteral(+ #expect(try CustomFirmwareWatchdogd.passesLiteral(inRegister: "x0", from: 1, toCallAt: 3, in: stream(movingInto: nil),))}@@ -293,7 +293,7 @@ struct CFWWatchdogdAnchorTests {func `rejects A binary without the cache site`() throws {let data = try Data(contentsOf: WatchdogdFixture.seputil)#expect(throws: PatcherError.self) {- try CFWWatchdogd.locateSites(in: data)+ try CustomFirmwareWatchdogd.locateSites(in: data)}}}@@ -301,13 +301,13 @@ struct CFWWatchdogdAnchorTests {// MARK: - Patching@Suite("watchdogd hv_vmm_present cache — patching")-struct CFWWatchdogdPatchTests {+struct CustomFirmwareWatchdogdPatchTests {/// Both instructions, and nothing else in `__TEXT`.@Test(.enabled(if: WatchdogdFixture.hasWatchdogd))func `rewrites two instructions per site`() throws {let original = try Data(contentsOf: WatchdogdFixture.watchdogd)var data = original- let report = try CFWWatchdogd.patch(&data, log: nil)+ let report = try CustomFirmwareWatchdogd.patch(&data, log: nil)#expect(report.outcome == .patched)#expect(report.sitesWritten == 2)@@ -338,8 +338,8 @@ struct CFWWatchdogdPatchTests {@Test(.enabled(if: WatchdogdFixture.hasWatchdogd))func `reattests the page of every written instruction`() throws {var data = try Data(contentsOf: WatchdogdFixture.watchdogd)- let report = try CFWWatchdogd.patch(&data, log: nil)- let directory = try #require(CFWMachOCodeSignature.codeDirectories(in: data)?.first)+ let report = try CustomFirmwareWatchdogd.patch(&data, log: nil)+ let directory = try #require(CustomFirmwareMachOCodeSignature.codeDirectories(in: data)?.first)let writtenPages = Set(report.records.map { $0.fileOffset / directory.pageSize })#expect(Set(report.rehashedSlots.map(\.pageIndex)) == writtenPages)@@ -362,11 +362,11 @@ struct CFWWatchdogdPatchTests {@Test(.enabled(if: WatchdogdFixture.hasWatchdogd))func `second run changes nothing`() throws {var data = try Data(contentsOf: WatchdogdFixture.watchdogd)- let first = try CFWWatchdogd.patch(&data, log: nil)+ let first = try CustomFirmwareWatchdogd.patch(&data, log: nil)#expect(first.outcome == .patched)let afterFirst = data- let second = try CFWWatchdogd.patch(&data, log: nil)+ let second = try CustomFirmwareWatchdogd.patch(&data, log: nil)#expect(second.outcome == .alreadyPatched)#expect(second.sitesWritten == 0)#expect(second.records.isEmpty)@@ -385,7 +385,7 @@ struct CFWWatchdogdPatchTests {func `dry run writes nothing`() throws {let original = try Data(contentsOf: WatchdogdFixture.watchdogd)var data = original- let report = try CFWWatchdogd.patch(&data, dryRun: true, log: nil)+ let report = try CustomFirmwareWatchdogd.patch(&data, dryRun: true, log: nil)#expect(report.outcome == .wouldPatch)#expect(report.records.count == 4)#expect(data == original)@@ -400,11 +400,11 @@ struct CFWWatchdogdPatchTests {let attributes = FileManager.default.attributesOfItem(atPath:)let modeBefore = try attributes(file.path)[.posixPermissions] as? NSNumber- let report = try CFWWatchdogd.patch(at: file, log: nil)+ let report = try CustomFirmwareWatchdogd.patch(at: file, log: nil)#expect(report.outcome == .patched)var expected = try Data(contentsOf: WatchdogdFixture.watchdogd)- try CFWWatchdogd.patch(&expected, log: nil)+ try CustomFirmwareWatchdogd.patch(&expected, log: nil)#expect(try Data(contentsOf: file) == expected)// watchdogd is installed executable and stays that way: the patch@@ -420,12 +420,12 @@ struct CFWWatchdogdPatchTests {let file = try WatchdogdFixture.scratchCopy(of: WatchdogdFixture.watchdogd, named: "watchdogd")defer { try? FileManager.default.removeItem(at: file.deletingLastPathComponent()) }- try CFWWatchdogd.patch(at: file, log: nil)+ try CustomFirmwareWatchdogd.patch(at: file, log: nil)let afterFirst = try Data(contentsOf: file)let stampAfterFirst = try FileManager.default.attributesOfItem(atPath: file.path)[.modificationDate] as? Date- let second = try CFWWatchdogd.patch(at: file, log: nil)+ let second = try CustomFirmwareWatchdogd.patch(at: file, log: nil)#expect(second.outcome == .alreadyPatched)#expect(try Data(contentsOf: file) == afterFirst)#expect(try FileManager.default@@ -436,7 +436,7 @@ struct CFWWatchdogdPatchTests {// MARK: - Independent references@Suite("watchdogd hv_vmm_present cache — independent references")-struct CFWWatchdogdReferenceTests {+struct CustomFirmwareWatchdogdReferenceTests {/// The fixture the frozen digests were taken over. Without this a digest/// mismatch below would read as a patcher bug when the real cause is a/// different firmware's `watchdogd`.@@ -458,7 +458,7 @@ struct CFWWatchdogdReferenceTests {@Test(.enabled(if: WatchdogdFixture.hasWatchdogd))func `matches the frozen reference byte for byte`() throws {var mine = try Data(contentsOf: WatchdogdFixture.watchdogd)- let report = try CFWWatchdogd.patch(&mine, log: nil)+ let report = try CustomFirmwareWatchdogd.patch(&mine, log: nil)// Printed so the parity claim is checkable from outside this process:// `shasum -a 256` over this patcher's output has to read the same.@@ -485,14 +485,14 @@ struct CFWWatchdogdReferenceTests {)defer { try? FileManager.default.removeItem(at: file.deletingLastPathComponent()) }- try CFWWatchdogd.patch(at: file, log: nil)+ try CustomFirmwareWatchdogd.patch(at: file, log: nil)let afterFirst = try Data(contentsOf: file)#expect(WatchdogdFixture.digest(afterFirst) == WatchdogdGolden.patched)// The frozen half: the reference, handed this exact file, reported// `all 2 matching site(s) already patched — nothing to do` and wrote// nothing. This port lands on the same bytes when it re-runs.- let second = try CFWWatchdogd.patch(at: file, log: nil)+ let second = try CustomFirmwareWatchdogd.patch(at: file, log: nil)#expect(second.outcome == .alreadyPatched)#expect(try WatchdogdFixture.digest(Data(contentsOf: file)) == WatchdogdGolden.patchedTwice)}@@ -510,7 +510,7 @@ struct CFWWatchdogdReferenceTests {let before = try WatchdogdFixture.run(WatchdogdFixture.codesign, ["-v", "-v", file.path])#expect(before.status == 0, "fixture must verify before patching: \(before.output)")- try CFWWatchdogd.patch(at: file, log: nil)+ try CustomFirmwareWatchdogd.patch(at: file, log: nil)let after = try WatchdogdFixture.run(WatchdogdFixture.codesign, ["-v", "-v", file.path])#expect(after.status == 0, "patched binary must still verify: \(after.output)")diff --git a/tests/FirmwarePatcherTests/DSCCameraPatcherTests.swift b/tests/FirmwarePatcherTests/DyldSharedCacheCameraPatcherTests.swiftsimilarity index 88%rename from tests/FirmwarePatcherTests/DSCCameraPatcherTests.swiftrename to tests/FirmwarePatcherTests/DyldSharedCacheCameraPatcherTests.swiftindex 9389f8ca..9f6ec5c6 100644--- a/tests/FirmwarePatcherTests/DSCCameraPatcherTests.swift+++ b/tests/FirmwarePatcherTests/DyldSharedCacheCameraPatcherTests.swift@@ -1,7 +1,7 @@-// DSCCameraPatcherTests.swift — Parity gate for the camera DSC patcher.+// DyldSharedCacheCameraPatcherTests.swift — Parity gate for the camera DSC patcher.//// The claim these tests exist to defend is narrow and checkable: running-// `DSCCameraPatcher` over a clone of the real shared cache leaves exactly the+// `DyldSharedCacheCameraPatcher` over a clone of the real shared cache leaves exactly the// bytes `scripts/patchers/cfw_patch_camera_dsc.py` left — patched instructions,// rewritten code slots and everything neither touched.//@@ -100,7 +100,7 @@ private enum FrozenReference {]/// `_sym_slug` from `cfw_patch_camera_dsc`, for the five style-transfer- /// symbols and the AVF one, in `DSCCameraPatcher`'s declaration order.+ /// symbols and the AVF one, in `DyldSharedCacheCameraPatcher`'s declaration order./// These key `cfw_records`, so a port that renames them writes records that/// line up with nothing.static let symbolSlugs: [String] = [@@ -267,7 +267,7 @@ private enum CameraSubprocess {// MARK: - The parity gate@Suite(.serialized, .enabled(if: CameraFixture.runs, CameraFixture.skipReason))-struct DSCCameraPatcherParityTests {+struct DyldSharedCacheCameraPatcherParityTests {/// The gate. One clone, one run, one byte-for-byte comparison against the/// digests the reference left on every chunk file in the cache.@Test@@ -278,7 +278,7 @@ struct DSCCameraPatcherParityTests {defer { CameraFixture.discard(swiftSide) }var log: [String] = []- let result = try DSCCameraPatcher.applyAll(+ let result = try DyldSharedCacheCameraPatcher.applyAll(chunksDirectory: swiftSide,log: { log.append($0) },)@@ -331,7 +331,7 @@ struct DSCCameraPatcherParityTests {let swiftSide = try CameraFixture.cloneCache(named: "camera_pages_swift")defer { CameraFixture.discard(swiftSide) }- let result = try DSCCameraPatcher.applyAll(chunksDirectory: swiftSide, log: nil)+ let result = try DyldSharedCacheCameraPatcher.applyAll(chunksDirectory: swiftSide, log: nil)let minePages = Set((result.reattestation?.updated ?? []).map {"\($0.chunkURL.lastPathComponent):\($0.pageIndex)"@@ -348,9 +348,9 @@ struct DSCCameraPatcherParityTests {/// keyed on. A port that renames them writes records nothing lines up with.@Testfunc `Patch ids match the reference's _sym_slug`() {- let symbols = DSCCameraPatcher.styleTransferSymbols- + [DSCCameraPatcher.authorizationStatusSymbol]- let mine = symbols.map(DSCCameraPatcher.symbolSlug)+ let symbols = DyldSharedCacheCameraPatcher.styleTransferSymbols+ + [DyldSharedCacheCameraPatcher.authorizationStatusSymbol]+ let mine = symbols.map(DyldSharedCacheCameraPatcher.symbolSlug)#expect(mine == FrozenReference.symbolSlugs)print("[camera slugs] \(mine.count) ids agreed, e.g. camera_dsc.nu_styletransfer.\(mine[0])")}@@ -359,11 +359,11 @@ struct DSCCameraPatcherParityTests {/// have to be what keystone itself assembled.@Testfunc `Both replacements are the bytes keystone assembled`() throws {- let styleTransfer = try DSCCameraPatcher.replacement(- returning: DSCCameraPatcher.Family.neutrinoStyleTransfer.returnValue,+ let styleTransfer = try DyldSharedCacheCameraPatcher.replacement(+ returning: DyldSharedCacheCameraPatcher.Family.neutrinoStyleTransfer.returnValue,)- let authorization = try DSCCameraPatcher.replacement(- returning: DSCCameraPatcher.Family.avfAuthorization.returnValue,+ let authorization = try DyldSharedCacheCameraPatcher.replacement(+ returning: DyldSharedCacheCameraPatcher.Family.avfAuthorization.returnValue,)#expect(styleTransfer.hex == FrozenReference.keystoneReturningZero)#expect(authorization.hex == FrozenReference.keystoneReturningThree)@@ -376,7 +376,7 @@ struct DSCCameraPatcherParityTests {// MARK: - Behaviour the reference does not pin@Suite(.serialized, .enabled(if: CameraFixture.runs, CameraFixture.skipReason))-struct DSCCameraPatcherBehaviourTests {+struct DyldSharedCacheCameraPatcherBehaviourTests {@Testfunc `A dry run finds every site and writes nothing`() throws {let pristine = try #require(CameraFixture.pristine, CameraFixture.missing)@@ -384,7 +384,7 @@ struct DSCCameraPatcherBehaviourTests {let clone = try CameraFixture.cloneCache(named: "camera_dryrun")defer { CameraFixture.discard(clone) }- let result = try DSCCameraPatcher.applyAll(+ let result = try DyldSharedCacheCameraPatcher.applyAll(chunksDirectory: clone,dryRun: true,log: nil,@@ -407,13 +407,13 @@ struct DSCCameraPatcherBehaviourTests {let clone = try CameraFixture.cloneCache(named: "camera_avf_only")defer { CameraFixture.discard(clone) }- let result = try DSCCameraPatcher.applyAVFAuthorizationOnly(+ let result = try DyldSharedCacheCameraPatcher.applyAVFAuthorizationOnly(chunksDirectory: clone,log: nil,)#expect(result.siteCount == 1)#expect(result.sites.first?.family == .avfAuthorization)- #expect(result.sites.first?.symbol == DSCCameraPatcher.authorizationStatusSymbol)+ #expect(result.sites.first?.symbol == DyldSharedCacheCameraPatcher.authorizationStatusSymbol)#expect(result.isComplete)// Exactly one chunk moved — the one AVFCapture lives in.@@ -423,11 +423,11 @@ struct DSCCameraPatcherBehaviourTests {#expect(changed.count == 1, "avf-only changed \(changed)")// And the NeutrinoCore entry points still carry their signed prologue.- let chunks = try DSCChunkSet(directory: clone)- let resolver = try DSCSymbolResolver(chunks: chunks)+ let chunks = try DyldSharedCacheChunkSet(directory: clone)+ let resolver = try DyldSharedCacheSymbolResolver(chunks: chunks)let untouched = try resolver.addresses(- of: DSCCameraPatcher.styleTransferSymbols,- inImage: DSCCameraPatcher.Family.neutrinoStyleTransfer.imagePath,+ of: DyldSharedCacheCameraPatcher.styleTransferSymbols,+ inImage: DyldSharedCacheCameraPatcher.Family.neutrinoStyleTransfer.imagePath,)for (symbol, vma) in untouched {let head = try chunks.bytesAtVMA(vma, length: 4)@@ -445,12 +445,12 @@ struct DSCCameraPatcherBehaviourTests {let clone = try CameraFixture.cloneCache(named: "camera_idempotent")defer { CameraFixture.discard(clone) }- let first = try DSCCameraPatcher.applyAll(chunksDirectory: clone, log: nil)+ let first = try DyldSharedCacheCameraPatcher.applyAll(chunksDirectory: clone, log: nil)#expect(first.siteCount == 6)#expect(first.sites.allSatisfy { !$0.wasAlreadyPatched })let afterFirst = try CameraFixture.digests(of: clone)- let second = try DSCCameraPatcher.applyAll(chunksDirectory: clone, log: nil)+ let second = try DyldSharedCacheCameraPatcher.applyAll(chunksDirectory: clone, log: nil)#expect(second.siteCount == 6)let allAlreadyPatched = second.sites.allSatisfy { $0.wasAlreadyPatched }#expect(allAlreadyPatched, "a re-run did not recognise its own output")@@ -487,19 +487,19 @@ struct DSCCameraPatcherBehaviourTests {// Break only the AVF entry point — the family that runs second. The// five NeutrinoCore sites are pristine and would patch cleanly, which// is what makes this a half-patch rather than a no-op.- let chunks = try DSCChunkSet(directory: clone)- let resolver = try DSCSymbolResolver(chunks: chunks)+ let chunks = try DyldSharedCacheChunkSet(directory: clone)+ let resolver = try DyldSharedCacheSymbolResolver(chunks: chunks)let avf = try resolver.address(- of: DSCCameraPatcher.authorizationStatusSymbol,- inImage: DSCCameraPatcher.Family.avfAuthorization.imagePath,+ of: DyldSharedCacheCameraPatcher.authorizationStatusSymbol,+ inImage: DyldSharedCacheCameraPatcher.Family.avfAuthorization.imagePath,)try chunks.write(at: avf, ARM64.nop)- try DSCCodeSignature.reattestRecordedWrites(in: chunks, log: nil)+ try DyldSharedCacheCodeSignature.reattestRecordedWrites(in: chunks, log: nil)let before = try CameraFixture.digests(of: clone)#expect(throws: PatcherError.self) {- _ = try DSCCameraPatcher.applyAll(chunksDirectory: clone, log: nil)+ _ = try DyldSharedCacheCameraPatcher.applyAll(chunksDirectory: clone, log: nil)}let after = try CameraFixture.digests(of: clone)@@ -522,24 +522,24 @@ struct DSCCameraPatcherBehaviourTests {// Put something that is neither pacibsp nor the replacement at one of// the six entry points, without going through the patcher.- let chunks = try DSCChunkSet(directory: clone)- let resolver = try DSCSymbolResolver(chunks: chunks)+ let chunks = try DyldSharedCacheChunkSet(directory: clone)+ let resolver = try DyldSharedCacheSymbolResolver(chunks: chunks)let vma = try resolver.address(- of: DSCCameraPatcher.authorizationStatusSymbol,- inImage: DSCCameraPatcher.Family.avfAuthorization.imagePath,+ of: DyldSharedCacheCameraPatcher.authorizationStatusSymbol,+ inImage: DyldSharedCacheCameraPatcher.Family.avfAuthorization.imagePath,)try chunks.write(at: vma, ARM64.nop)- try DSCCodeSignature.reattestRecordedWrites(in: chunks, log: nil)+ try DyldSharedCacheCodeSignature.reattestRecordedWrites(in: chunks, log: nil)#expect(throws: PatcherError.self) {- _ = try DSCCameraPatcher.applyAVFAuthorizationOnly(+ _ = try DyldSharedCacheCameraPatcher.applyAVFAuthorizationOnly(chunksDirectory: clone,log: nil,)}var log: [String] = []- let forced = try DSCCameraPatcher.applyAVFAuthorizationOnly(+ let forced = try DyldSharedCacheCameraPatcher.applyAVFAuthorizationOnly(chunksDirectory: clone,force: true,log: { log.append($0) },@@ -548,9 +548,9 @@ struct DSCCameraPatcherBehaviourTests {#expect(forced.sites.first?.wasAlreadyPatched == false)#expect(log.contains { $0.contains("forced") })- let fresh = try DSCChunkSet(directory: clone)+ let fresh = try DyldSharedCacheChunkSet(directory: clone)let written = try fresh.bytesAtVMA(vma, length: 8)- let expected = try DSCCameraPatcher.replacement(returning: 3)+ let expected = try DyldSharedCacheCameraPatcher.replacement(returning: 3)#expect(written == expected)print("[camera force] a nop prologue was refused, then accepted under force")}@@ -561,10 +561,10 @@ struct DSCCameraPatcherBehaviourTests {@Testfunc `The prologue classifier reads instructions, not bytes`() throws {let disassembler = ARM64Disassembler()- let replacement = try DSCCameraPatcher.replacement(returning: 3)+ let replacement = try DyldSharedCacheCameraPatcher.replacement(returning: 3)func classify(_ bytes: Data, force: Bool = false) throws -> Bool {- try DSCCameraPatcher.classifyPrologue(+ try DyldSharedCacheCameraPatcher.classifyPrologue(bytes,at: 0x1_0000_0000,symbol: "test",@@ -585,7 +585,7 @@ struct DSCCameraPatcherBehaviourTests {// The *other* family's replacement returns a different constant, so it// is not this family's output and must not pass as one.- let otherFamily = try DSCCameraPatcher.replacement(returning: 0)+ let otherFamily = try DyldSharedCacheCameraPatcher.replacement(returning: 0)#expect(throws: PatcherError.self) { _ = try classify(otherFamily) }// `mov w0, #3` without the `ret` is not the replacement either.@@ -617,8 +617,8 @@ struct DSCCameraPatcherBehaviourTests {at: clone.appendingPathComponent("dyld_shared_cache_arm64e.symbols"),)- #expect(throws: DSCError.self) {- _ = try DSCCameraPatcher.applyAll(chunksDirectory: clone, dryRun: true, log: nil)+ #expect(throws: DyldSharedCacheError.self) {+ _ = try DyldSharedCacheCameraPatcher.applyAll(chunksDirectory: clone, dryRun: true, log: nil)}print("[camera symbols] a cache with no .symbols table is refused, not silently empty")}diff --git a/tests/FirmwarePatcherTests/DSCFoundationTests.swift b/tests/FirmwarePatcherTests/DyldSharedCacheFoundationTests.swiftsimilarity index 85%rename from tests/FirmwarePatcherTests/DSCFoundationTests.swiftrename to tests/FirmwarePatcherTests/DyldSharedCacheFoundationTests.swiftindex 65708573..36b3d2b4 100644--- a/tests/FirmwarePatcherTests/DSCFoundationTests.swift+++ b/tests/FirmwarePatcherTests/DyldSharedCacheFoundationTests.swift@@ -1,4 +1,4 @@-// DSCFoundationTests.swift — Cross-checks for the DSC foundation layer.+// DyldSharedCacheFoundationTests.swift — Cross-checks for the DSC foundation layer.//// `codesign -v` does not apply to a dyld shared cache chunk, so the only// independent reference for any of this was the Python in `scripts/patchers/`@@ -43,7 +43,7 @@ import Testingprivate enum FrozenReference {// MARK: Layout- /// `len(_enumerate_chunks(dir))` and `len(DSCChunks(dir).mappings())`.+ /// `len(_enumerate_chunks(dir))` and `len(DyldSharedCacheChunks(dir).mappings())`.static let chunkCount = 79static let mappingCount = 103@@ -76,7 +76,7 @@ private enum FrozenReference {/// 64-byte read correspond to no virtual address.static let overrunVMA: UInt64 = 0x1_800B_BFFC- /// `DSCChunks.bytes_at_vma(0x1800BBFFC, 64).hex()`. The reference+ /// `DyldSharedCacheChunks.bytes_at_vma(0x1800BBFFC, 64).hex()`. The reference/// bounds-checked only the first byte, so it returned all 64 without/// complaint — bytes 4.. are the chunk's own `CS_SuperBlob` (`fade0cc0`),/// presented as if they lived at those addresses. The Swift refuses the@@ -91,7 +91,7 @@ private enum FrozenReference {/// `resolve_local_symbol(dir, "_kern_SwapEnd")`.static let kernSwapEndVMA: UInt64 = 0x2_2AC0_C334- /// `DSCChunks.find_string_vmas(b"kern.hv_vmm_present")`: 44 hits across the+ /// `DyldSharedCacheChunks.find_string_vmas(b"kern.hv_vmm_present")`: 44 hits across the/// executable mappings, first and last as spelled here, all of them frozen/// together as the SHA-256 of `Canonical.addresses`.static let hvVMMStringCount = 44@@ -202,7 +202,7 @@ private enum Canonical {}/// `address end file_offset init_prot chunk`, in mapping-table order.- static func mappings(_ chunks: DSCChunkSet) -> String {+ static func mappings(_ chunks: DyldSharedCacheChunkSet) -> String {chunks.mappings.map {"\(hex($0.address)) \(hex($0.endAddress)) \(hex($0.fileOffset)) "+ "\($0.initProt) \($0.chunkURL.lastPathComponent)"@@ -211,7 +211,7 @@ private enum Canonical {/// `vma length chunk file_offset bytes`, in request order.static func probes(- _ chunks: DSCChunkSet,+ _ chunks: DyldSharedCacheChunkSet,_ requests: [(UInt64, Int)],) throws -> String {try requests.map { vma, length in@@ -229,10 +229,10 @@ private enum Canonical {/// `chunk blobOffset blobLength hashOffset hashSize codeSlotCount/// codeLimit pageSize`, or `chunk none`, in chunk order.- static func codeDirectories(_ chunks: DSCChunkSet) throws -> [String] {+ static func codeDirectories(_ chunks: DyldSharedCacheChunkSet) throws -> [String] {try chunks.chunkURLs.map { url inlet name = url.lastPathComponent- guard let directory = try DSCCodeSignature.readCodeDirectory(ofChunk: url) else {+ guard let directory = try DyldSharedCacheCodeSignature.readCodeDirectory(ofChunk: url) else {return "\(name) none"}return "\(name) \(directory.blobOffset) \(directory.blobLength) "@@ -244,7 +244,7 @@ private enum Canonical {// MARK: - Fixture discovery-private enum DSCFixture {+private enum DyldSharedCacheFixture {static let repoRoot = URL(fileURLWithPath: #filePath).deletingLastPathComponent().deletingLastPathComponent()@@ -387,10 +387,10 @@ private enum SlotState {) throws -> (computed: String, stored: String, isAttested: Bool) {let url = directory.appendingPathComponent(chunk)let cd = try #require(- try DSCCodeSignature.readCodeDirectory(ofChunk: url),+ try DyldSharedCacheCodeSignature.readCodeDirectory(ofChunk: url),"\(chunk) carries no code directory",)- let (computed, stored) = try DSCCodeSignature.pageHashes(+ let (computed, stored) = try DyldSharedCacheCodeSignature.pageHashes(chunkURL: url,pageIndex: page,directory: cd,@@ -401,13 +401,13 @@ private enum SlotState {// MARK: - 3.1 · Flat addressing-@Suite(.serialized, .enabled(if: DSCFixture.runs, DSCFixture.skipReason))-struct DSCFlatAddressingTests {+@Suite(.serialized, .enabled(if: DyldSharedCacheFixture.runs, DyldSharedCacheFixture.skipReason))+struct DyldSharedCacheFlatAddressingTests {@Testfunc `Chunk enumeration and mapping table match the reference`() throws {- let pristine = try #require(DSCFixture.pristine, DSCFixture.missing)+ let pristine = try #require(DyldSharedCacheFixture.pristine, DyldSharedCacheFixture.missing)- let chunks = try DSCChunkSet(directory: pristine)+ let chunks = try DyldSharedCacheChunkSet(directory: pristine)#expect(chunks.chunkURLs.count == FrozenReference.chunkCount)#expect(chunks.mappings.count == FrozenReference.mappingCount)@@ -429,7 +429,7 @@ struct DSCFlatAddressingTests {/// Reads spread across every mapping, including the first and last bytes of/// each one — the spots where an off-by-one in the boundary test would/// silently read out of the neighbouring chunk.- private func probeRequests(for chunks: DSCChunkSet) -> [(UInt64, Int)] {+ private func probeRequests(for chunks: DyldSharedCacheChunkSet) -> [(UInt64, Int)] {var requests: [(UInt64, Int)] = []for mapping in chunks.mappings {requests.append((mapping.address, 16))@@ -449,9 +449,9 @@ struct DSCFlatAddressingTests {@Testfunc `bytesAtVMA matches the reference across every mapping and boundary`() throws {- let pristine = try #require(DSCFixture.pristine, DSCFixture.missing)+ let pristine = try #require(DyldSharedCacheFixture.pristine, DyldSharedCacheFixture.missing)- let chunks = try DSCChunkSet(directory: pristine)+ let chunks = try DyldSharedCacheChunkSet(directory: pristine)let requests = probeRequests(for: chunks)#expect(requests.count == FrozenReference.probeCount)@@ -477,28 +477,28 @@ struct DSCFlatAddressingTests {@Testfunc `A read or write that leaves its chunk is refused, not truncated`() throws {- let pristine = try #require(DSCFixture.pristine, DSCFixture.missing)- let chunks = try DSCChunkSet(directory: pristine)+ let pristine = try #require(DyldSharedCacheFixture.pristine, DyldSharedCacheFixture.missing)+ let chunks = try DyldSharedCacheChunkSet(directory: pristine)let mapping = try #require(chunks.mappings.first { $0.size > 64 })let lastFour = mapping.endAddress - 4// Reading past the end of a mapping is not a short read, it is a// different chunk's bytes. Every API has to say so.- #expect(throws: DSCError.self) {+ #expect(throws: DyldSharedCacheError.self) {_ = try chunks.readAtVMA(lastFour, length: 64)}let short = try chunks.readAtVMA(lastFour, length: 64, allowShort: true)#expect(short.count == 4)- #expect(throws: DSCError.self) {+ #expect(throws: DyldSharedCacheError.self) {_ = try chunks.write(at: lastFour, Data(repeating: 0, count: 64))}- #expect(throws: DSCError.self) {+ #expect(throws: DyldSharedCacheError.self) {_ = try chunks.bytesAtVMA(chunks.addressRange.upperBound + 0x1000, length: 4)}// And `bytesAtVMA` itself, at the same boundary — the case the suite// used to name but never exercise.- #expect(throws: DSCError.self) {+ #expect(throws: DyldSharedCacheError.self) {_ = try chunks.bytesAtVMA(lastFour, length: 64)}#expect(try chunks.bytesAtVMA(lastFour, length: 4).count == 4)@@ -512,14 +512,14 @@ struct DSCFlatAddressingTests {/// returned, and that the Swift refuses it.@Testfunc `An over-running read returned the chunk's signature; here it throws`() throws {- let pristine = try #require(DSCFixture.pristine, DSCFixture.missing)+ let pristine = try #require(DyldSharedCacheFixture.pristine, DyldSharedCacheFixture.missing)- let chunks = try DSCChunkSet(directory: pristine)+ let chunks = try DyldSharedCacheChunkSet(directory: pristine)let overrun = FrozenReference.overrunVMAlet mapping = try #require(chunks.mapping(forVMA: overrun))#expect(mapping.endAddress == overrun + 4)- #expect(throws: DSCError.self) {+ #expect(throws: DyldSharedCacheError.self) {_ = try chunks.bytesAtVMA(overrun, length: 64)}@@ -537,9 +537,9 @@ struct DSCFlatAddressingTests {@Testfunc `resolveLocalSymbol matches the reference and ipsw`() throws {- let pristine = try #require(DSCFixture.pristine, DSCFixture.missing)+ let pristine = try #require(DyldSharedCacheFixture.pristine, DyldSharedCacheFixture.missing)- let chunks = try DSCChunkSet(directory: pristine)+ let chunks = try DyldSharedCacheChunkSet(directory: pristine)let name = "_kern_SwapEnd"let mine = try #require(try chunks.resolveLocalSymbol(name))#expect(mine == FrozenReference.kernSwapEndVMA)@@ -556,30 +556,30 @@ struct DSCFlatAddressingTests {/// `FileNotFoundError`; so does this, in its own vocabulary.@Testfunc `A missing local symbol table is not the same answer as a missing symbol`() throws {- _ = try #require(DSCFixture.pristine, DSCFixture.missing)+ _ = try #require(DyldSharedCacheFixture.pristine, DyldSharedCacheFixture.missing)- let clone = try DSCFixture.cloneCache(named: "symbols_removed")- defer { DSCFixture.discard(clone) }+ let clone = try DyldSharedCacheFixture.cloneCache(named: "symbols_removed")+ defer { DyldSharedCacheFixture.discard(clone) }try FileManager.default.removeItem(at: clone.appendingPathComponent("dyld_shared_cache_arm64e.symbols"),)- let chunks = try DSCChunkSet(directory: clone)- #expect(throws: DSCError.self) {+ let chunks = try DyldSharedCacheChunkSet(directory: clone)+ #expect(throws: DyldSharedCacheError.self) {_ = try chunks.resolveLocalSymbol("_kern_SwapEnd")}- #expect(throws: DSCError.self) {+ #expect(throws: DyldSharedCacheError.self) {_ = try chunks.resolveLocalSymbol("_definitely_not_a_symbol_xyz")}// And the resolver built on the same cache says so rather than// reporting entry points with no siblings.- let resolver = try DSCSymbolResolver(+ let resolver = try DyldSharedCacheSymbolResolver(mainCacheURL: clone.appendingPathComponent("dyld_shared_cache_arm64e"),)#expect(!resolver.hasLocalSymbols)- #expect(throws: DSCError.self) { try resolver.requireLocalSymbols() }- #expect(throws: DSCError.self) {+ #expect(throws: DyldSharedCacheError.self) { try resolver.requireLocalSymbols() }+ #expect(throws: DyldSharedCacheError.self) {_ = try resolver.address(of: "_kern_SwapEnd",inImage: "/System/Library/PrivateFrameworks/IOMobileFramebuffer.framework/IOMobileFramebuffer",@@ -593,9 +593,9 @@ struct DSCFlatAddressingTests {/// address to the image that owns it.@Testfunc `String search and image lookup match the reference`() throws {- let pristine = try #require(DSCFixture.pristine, DSCFixture.missing)+ let pristine = try #require(DyldSharedCacheFixture.pristine, DyldSharedCacheFixture.missing)- let chunks = try DSCChunkSet(directory: pristine)+ let chunks = try DyldSharedCacheChunkSet(directory: pristine)let needle = "kern.hv_vmm_present"let mine = try chunks.findStringVMAs(Data(needle.utf8)).sorted()@@ -622,17 +622,17 @@ struct DSCFlatAddressingTests {// MARK: - 3.2 · Code-signature page-hash re-signing, DSC path-@Suite(.serialized, .enabled(if: DSCFixture.runs, DSCFixture.skipReason))-struct DSCCodeSignatureTests {+@Suite(.serialized, .enabled(if: DyldSharedCacheFixture.runs, DyldSharedCacheFixture.skipReason))+struct DyldSharedCacheCodeSignatureTests {/// A site inside `IOMobileFramebuffer`'s `__text` — a real executable page/// whose slot a real patch would have to re-sign.private let patchSite = FrozenReference.patchSite@Testfunc `Chunk code directories match the reference`() throws {- let pristine = try #require(DSCFixture.pristine, DSCFixture.missing)+ let pristine = try #require(DyldSharedCacheFixture.pristine, DyldSharedCacheFixture.missing)- let chunks = try DSCChunkSet(directory: pristine)+ let chunks = try DyldSharedCacheChunkSet(directory: pristine)let rows = try Canonical.codeDirectories(chunks)let found = rows.filter { !$0.hasSuffix(" none") }.count#expect(found == FrozenReference.codeDirectoryCount)@@ -649,11 +649,11 @@ struct DSCCodeSignatureTests {/// directory, and no short tail slot.@Testfunc `Every signed chunk is 16 KiB paged, SHA-256, and chunk-aligned`() throws {- let pristine = try #require(DSCFixture.pristine, DSCFixture.missing)- let chunks = try DSCChunkSet(directory: pristine)+ let pristine = try #require(DyldSharedCacheFixture.pristine, DyldSharedCacheFixture.missing)+ let chunks = try DyldSharedCacheChunkSet(directory: pristine)var checked = 0for url in chunks.chunkURLs {- guard let directory = try DSCCodeSignature.readCodeDirectory(ofChunk: url) else {+ guard let directory = try DyldSharedCacheCodeSignature.readCodeDirectory(ofChunk: url) else {continue}#expect(directory.pageSize == 16384, "\(url.lastPathComponent) page size")@@ -675,10 +675,10 @@ struct DSCCodeSignatureTests {/// and its slot to come out as the reference's did.@Testfunc `Re-signing produces the reference's slot hashes`() throws {- _ = try #require(DSCFixture.pristine, DSCFixture.missing)+ _ = try #require(DyldSharedCacheFixture.pristine, DyldSharedCacheFixture.missing)- let swiftSide = try DSCFixture.cloneCache(named: "resign_swift")- defer { DSCFixture.discard(swiftSide) }+ let swiftSide = try DyldSharedCacheFixture.cloneCache(named: "resign_swift")+ defer { DyldSharedCacheFixture.discard(swiftSide) }// The replacement is a real instruction shape — `mov w3, #0x588`, the// immediate `cfw_patch_iomfb_swapend` writes — not a byte pattern@@ -687,15 +687,15 @@ struct DSCCodeSignatureTests {// Same write, same re-sign — and the re-sign is driven by what the// write itself recorded, not by an address repeated by hand.- let chunks = try DSCChunkSet(directory: swiftSide)+ let chunks = try DyldSharedCacheChunkSet(directory: swiftSide)let originalBytes = try chunks.bytesAtVMA(patchSite, length: replacement.count)#expect(originalBytes.hex == FrozenReference.patchSiteOriginalBytes)let span = try chunks.write(at: patchSite, replacement)- #expect(span == DSCWriteSpan(vma: patchSite, length: 4))+ #expect(span == DyldSharedCacheWriteSpan(vma: patchSite, length: 4))#expect(chunks.recordedWrites == [span])var log: [String] = []- let result = try DSCCodeSignature.reattestRecordedWrites(+ let result = try DyldSharedCacheCodeSignature.reattestRecordedWrites(in: chunks,log: { log.append($0) },)@@ -716,9 +716,9 @@ struct DSCCodeSignatureTests {// stored slot has to be the digest of the page as it now stands.let chunkName = mine.chunkURL.lastPathComponentlet directory = try #require(- try DSCCodeSignature.readCodeDirectory(ofChunk: mine.chunkURL),+ try DyldSharedCacheCodeSignature.readCodeDirectory(ofChunk: mine.chunkURL),)- let (computed, stored) = try DSCCodeSignature.pageHashes(+ let (computed, stored) = try DyldSharedCacheCodeSignature.pageHashes(chunkURL: mine.chunkURL,pageIndex: mine.pageIndex,directory: directory,@@ -744,10 +744,10 @@ struct DSCCodeSignatureTests {/// this checks the Swift no longer can.@Testfunc `A write across a page boundary re-attests both pages, where the reference attested one`() throws {- _ = try #require(DSCFixture.pristine, DSCFixture.missing)+ _ = try #require(DyldSharedCacheFixture.pristine, DyldSharedCacheFixture.missing)- let swiftSide = try DSCFixture.cloneCache(named: "straddle_swift")- defer { DSCFixture.discard(swiftSide) }+ let swiftSide = try DyldSharedCacheFixture.cloneCache(named: "straddle_swift")+ defer { DyldSharedCacheFixture.discard(swiftSide) }let straddle = FrozenReference.straddleVMAlet stub = Data([0x00, 0x00, 0x80, 0x52, 0xC0, 0x03, 0x5F, 0xD6])@@ -756,7 +756,7 @@ struct DSCCodeSignatureTests {let secondPage = FrozenReference.straddleSecondPage// Swift: write, then re-attest from what the write recorded.- let chunks = try DSCChunkSet(directory: swiftSide)+ let chunks = try DyldSharedCacheChunkSet(directory: swiftSide)let span = try chunks.write(at: straddle, stub)#expect(span.length == 8)let (writtenChunk, writtenRange) = try chunks.fileRange(of: span)@@ -764,7 +764,7 @@ struct DSCCodeSignatureTests {#expect(writtenRange == 0x280FFFC ..< 0x2810004)var log: [String] = []- let result = try DSCCodeSignature.reattestRecordedWrites(+ let result = try DyldSharedCacheCodeSignature.reattestRecordedWrites(in: chunks,log: { log.append($0) },)@@ -802,7 +802,7 @@ struct DSCCodeSignatureTests {// The bytes themselves are the stub, at the file offset the reference// wrote them to.- let swiftBytes = try DSCChunkSet.read(+ let swiftBytes = try DyldSharedCacheChunkSet.read(url: swiftSide.appendingPathComponent(chunkName),offset: 0x280FFFC,length: 8,@@ -821,23 +821,23 @@ struct DSCCodeSignatureTests {/// landed; the case where the file offsets break is still refused.@Testfunc `A write across contiguous mappings of one chunk lands where the reference put it`() throws {- _ = try #require(DSCFixture.pristine, DSCFixture.missing)+ _ = try #require(DyldSharedCacheFixture.pristine, DyldSharedCacheFixture.missing)- let swiftSide = try DSCFixture.cloneCache(named: "seam_swift")- defer { DSCFixture.discard(swiftSide) }+ let swiftSide = try DyldSharedCacheFixture.cloneCache(named: "seam_swift")+ defer { DyldSharedCacheFixture.discard(swiftSide) }let seam = FrozenReference.seamVMAlet value = Data([0x11, 0x22, 0x33, 0x44])let chunkName = FrozenReference.seamChunk- let chunks = try DSCChunkSet(directory: swiftSide)+ let chunks = try DyldSharedCacheChunkSet(directory: swiftSide)let mapping = try #require(chunks.mapping(forVMA: seam))let next = try #require(chunks.mapping(forVMA: mapping.endAddress))#expect(next.chunkURL.lastPathComponent == chunkName)#expect(next.fileOffset == mapping.fileOffset + mapping.size)let span = try chunks.write(at: seam, value)- let result = try DSCCodeSignature.reattestRecordedWrites(in: chunks, log: nil)+ let result = try DyldSharedCacheCodeSignature.reattestRecordedWrites(in: chunks, log: nil)#expect(span.length == 4)#expect(result.isFullyAttested)// 0x3FFE..0x4001 spans pages 0 and 1 of the chunk.@@ -845,7 +845,7 @@ struct DSCCodeSignatureTests {// The reference's `write_at_vma` put these four bytes at file offset// 0x3FFE of this chunk. So must this one.- let mine = try DSCChunkSet.read(+ let mine = try DyldSharedCacheChunkSet.read(url: swiftSide.appendingPathComponent(chunkName),offset: FrozenReference.seamFileOffset,length: 4,@@ -866,7 +866,7 @@ struct DSCCodeSignatureTests {return next.chunkURL != mapping.chunkURL},)- #expect(throws: DSCError.self) {+ #expect(throws: DyldSharedCacheError.self) {_ = try chunks.write(at: crossChunk.endAddress - 2, Data([0, 0, 0, 0]))}}@@ -876,27 +876,27 @@ struct DSCCodeSignatureTests {/// to be a no-op, not a rewrite and not an error.@Testfunc `Re-signing twice is a no-op the second time`() throws {- _ = try #require(DSCFixture.pristine, DSCFixture.missing)+ _ = try #require(DyldSharedCacheFixture.pristine, DyldSharedCacheFixture.missing)- let clone = try DSCFixture.cloneCache(named: "resign_idempotent")- defer { DSCFixture.discard(clone) }+ let clone = try DyldSharedCacheFixture.cloneCache(named: "resign_idempotent")+ defer { DyldSharedCacheFixture.discard(clone) }- let chunks = try DSCChunkSet(directory: clone)+ let chunks = try DyldSharedCacheChunkSet(directory: clone)let span = try chunks.write(at: patchSite, Data([0x03, 0xB1, 0x80, 0x52]))- let first = try DSCCodeSignature.reattest(in: chunks, modifiedSpans: [span], log: nil)+ let first = try DyldSharedCacheCodeSignature.reattest(in: chunks, modifiedSpans: [span], log: nil)#expect(first.updated.count == 1)#expect(first.alreadyAttested.isEmpty)- let second = try DSCCodeSignature.reattest(in: chunks, modifiedSpans: [span], log: nil)+ let second = try DyldSharedCacheCodeSignature.reattest(in: chunks, modifiedSpans: [span], log: nil)#expect(second.updated.isEmpty, "a second re-sign rewrote a slot that already matched")#expect(second.alreadyAttested.count == 1, "and it has to say so, not just return nothing")#expect(second.isFullyAttested)// Several addresses inside one page still cost exactly one slot.- let third = try DSCCodeSignature.reattest(+ let third = try DyldSharedCacheCodeSignature.reattest(in: chunks,- modifiedSpans: [patchSite, patchSite + 4, patchSite + 8].map(DSCWriteSpan.byte(at:)),+ modifiedSpans: [patchSite, patchSite + 4, patchSite + 8].map(DyldSharedCacheWriteSpan.byte(at:)),log: nil,)#expect(third.updated.isEmpty)@@ -910,12 +910,12 @@ struct DSCCodeSignatureTests {/// values now, and the default log is no longer silent.@Testfunc `A skipped page is distinguishable from nothing to do`() throws {- let pristine = try #require(DSCFixture.pristine, DSCFixture.missing)- let chunks = try DSCChunkSet(directory: pristine)+ let pristine = try #require(DyldSharedCacheFixture.pristine, DyldSharedCacheFixture.missing)+ let chunks = try DyldSharedCacheChunkSet(directory: pristine)- let stray = try DSCCodeSignature.reattest(+ let stray = try DyldSharedCacheCodeSignature.reattest(in: chunks,- modifiedSpans: [DSCWriteSpan.byte(at: 0xDEAD_0000_0000)],+ modifiedSpans: [DyldSharedCacheWriteSpan.byte(at: 0xDEAD_0000_0000)],dryRun: true,log: nil,)@@ -928,9 +928,9 @@ struct DSCCodeSignatureTests {Issue.record("wrong skip reason: \(stray.skipped[0].reason)")}- let nothing = try DSCCodeSignature.reattest(+ let nothing = try DyldSharedCacheCodeSignature.reattest(in: chunks,- modifiedSpans: [] as [DSCWriteSpan],+ modifiedSpans: [] as [DyldSharedCacheWriteSpan],dryRun: true,log: nil,)@@ -939,9 +939,9 @@ struct DSCCodeSignatureTests {// A span that runs off the end of its chunk is its own reason.let mapping = try #require(chunks.mappings.first { $0.size > 64 })- let overrun = try DSCCodeSignature.reattest(+ let overrun = try DyldSharedCacheCodeSignature.reattest(in: chunks,- modifiedSpans: [DSCWriteSpan(vma: mapping.endAddress - 2, length: 64)],+ modifiedSpans: [DyldSharedCacheWriteSpan(vma: mapping.endAddress - 2, length: 64)],dryRun: true,log: nil,)@@ -953,9 +953,9 @@ struct DSCCodeSignatureTests {// And the default log says all of it out loud, as the reference's// verbose=True did.var spoken: [String] = []- _ = try DSCCodeSignature.reattest(+ _ = try DyldSharedCacheCodeSignature.reattest(in: chunks,- modifiedSpans: [DSCWriteSpan.byte(at: 0xDEAD_0000_0000)],+ modifiedSpans: [DyldSharedCacheWriteSpan.byte(at: 0xDEAD_0000_0000)],dryRun: true,log: { spoken.append($0) },)@@ -967,15 +967,15 @@ struct DSCCodeSignatureTests {@Testfunc `A dry run computes the same hash it would have written, and writes nothing`() throws {- _ = try #require(DSCFixture.pristine, DSCFixture.missing)+ _ = try #require(DyldSharedCacheFixture.pristine, DyldSharedCacheFixture.missing)- let clone = try DSCFixture.cloneCache(named: "resign_dryrun")- defer { DSCFixture.discard(clone) }+ let clone = try DyldSharedCacheFixture.cloneCache(named: "resign_dryrun")+ defer { DyldSharedCacheFixture.discard(clone) }- let chunks = try DSCChunkSet(directory: clone)+ let chunks = try DyldSharedCacheChunkSet(directory: clone)try chunks.write(at: patchSite, Data([0x03, 0xB1, 0x80, 0x52]))- let dry = try DSCCodeSignature.reattestRecordedWrites(+ let dry = try DyldSharedCacheCodeSignature.reattestRecordedWrites(in: chunks,dryRun: true,log: nil,@@ -984,24 +984,24 @@ struct DSCCodeSignatureTests {let record = try #require(dry.updated.first)let directory = try #require(- try DSCCodeSignature.readCodeDirectory(ofChunk: record.chunkURL),+ try DyldSharedCacheCodeSignature.readCodeDirectory(ofChunk: record.chunkURL),)- let (_, storedAfterDryRun) = try DSCCodeSignature.pageHashes(+ let (_, storedAfterDryRun) = try DyldSharedCacheCodeSignature.pageHashes(chunkURL: record.chunkURL,pageIndex: record.pageIndex,directory: directory,)#expect(storedAfterDryRun == record.hashBefore, "a dry run must not touch the slot")- let wet = try DSCCodeSignature.reattestRecordedWrites(in: chunks, log: nil)+ let wet = try DyldSharedCacheCodeSignature.reattestRecordedWrites(in: chunks, log: nil)#expect(wet.updated.first?.hashAfter == record.hashAfter)}}// MARK: - 3.3 · Symbol resolution-@Suite(.serialized, .enabled(if: DSCFixture.runs, DSCFixture.skipReason))-struct DSCSymbolResolverTests {+@Suite(.serialized, .enabled(if: DyldSharedCacheFixture.runs, DyldSharedCacheFixture.skipReason))+struct DyldSharedCacheSymbolResolverTests {private static let neutrinoCore ="/System/Library/PrivateFrameworks/NeutrinoCore.framework/NeutrinoCore"private static let avfCapture =@@ -1042,7 +1042,7 @@ struct DSCSymbolResolverTests {/// name → address. The per-symbol form of that command is what times out on/// this cache; the whole-image dump answers in under a second.private func ipswSymbols(image: String, cache: URL) throws -> [String: UInt64] {- guard let ipsw = DSCFixture.ipsw else { return [:] }+ guard let ipsw = DyldSharedCacheFixture.ipsw else { return [:] }let result = try Subprocess.run(executable: ipsw,arguments: [@@ -1078,8 +1078,8 @@ struct DSCSymbolResolverTests {@Testfunc `Every symbol the three DSC patchers look up resolves, and agrees with ipsw`() throws {- let pristine = try #require(DSCFixture.pristine, DSCFixture.missing)- let resolver = try DSCSymbolResolver(+ let pristine = try #require(DyldSharedCacheFixture.pristine, DyldSharedCacheFixture.missing)+ let resolver = try DyldSharedCacheSymbolResolver(mainCacheURL: pristine.appendingPathComponent("dyld_shared_cache_arm64e"),)#expect(resolver.hasLocalSymbols)@@ -1113,8 +1113,8 @@ struct DSCSymbolResolverTests {@Testfunc `The force-kern discovery shape is reproduced without ipsw`() throws {- let pristine = try #require(DSCFixture.pristine, DSCFixture.missing)- let resolver = try DSCSymbolResolver(+ let pristine = try #require(DyldSharedCacheFixture.pristine, DyldSharedCacheFixture.missing)+ let resolver = try DyldSharedCacheSymbolResolver(mainCacheURL: pristine.appendingPathComponent("dyld_shared_cache_arm64e"),)try resolver.requireLocalSymbols()@@ -1149,17 +1149,17 @@ struct DSCSymbolResolverTests {@Testfunc `A missing symbol and a missing image both fail loudly`() throws {- let pristine = try #require(DSCFixture.pristine, DSCFixture.missing)- let resolver = try DSCSymbolResolver(+ let pristine = try #require(DyldSharedCacheFixture.pristine, DyldSharedCacheFixture.missing)+ let resolver = try DyldSharedCacheSymbolResolver(mainCacheURL: pristine.appendingPathComponent("dyld_shared_cache_arm64e"),)- #expect(throws: DSCError.self) {+ #expect(throws: DyldSharedCacheError.self) {_ = try resolver.address(of: "_this_symbol_does_not_exist",inImage: Self.ioMobileFramebuffer,)}- #expect(throws: DSCError.self) {+ #expect(throws: DyldSharedCacheError.self) {_ = try resolver.symbols(inImage: "/System/Library/Nope.framework/Nope")}}diff --git a/tests/FirmwarePatcherTests/DSCHVVMMPatcherTests.swift b/tests/FirmwarePatcherTests/DyldSharedCacheHVVMMPatcherTests.swiftsimilarity index 90%rename from tests/FirmwarePatcherTests/DSCHVVMMPatcherTests.swiftrename to tests/FirmwarePatcherTests/DyldSharedCacheHVVMMPatcherTests.swiftindex 21c80778..991ecc4e 100644--- a/tests/FirmwarePatcherTests/DSCHVVMMPatcherTests.swift+++ b/tests/FirmwarePatcherTests/DyldSharedCacheHVVMMPatcherTests.swift@@ -1,4 +1,4 @@-// DSCHVVMMPatcherTests.swift — parity for the hv_vmm_present user-mode cstring+// DyldSharedCacheHVVMMPatcherTests.swift — parity for the hv_vmm_present user-mode cstring// mangle.//// There is no external oracle for this patch. `codesign -v` does not apply to a@@ -479,35 +479,35 @@ private enum Digest {/// No fixture needed: these are the reference modules' own constants, which the/// port has to carry verbatim for anything else here to mean anything.@Suite(.serialized)-struct DSCHVVMMConstantsTests {+struct DyldSharedCacheHVVMMConstantsTests {@Testfunc `The cstring, its mangle and the blacklist match the reference modules`() {- #expect(DSCHVVMMPatcher.needle.hex == FrozenReference.needleHex)- #expect(DSCHVVMMPatcher.mangledNeedle.hex == FrozenReference.mangledNeedleHex)- #expect(DSCHVVMMPatcher.mangleOffset == FrozenReference.mangleOffset)- #expect(Data([DSCHVVMMPatcher.originalByte]).hex == FrozenReference.originalByteHex)- #expect(Data([DSCHVVMMPatcher.mangledByte]).hex == FrozenReference.mangledByteHex)- #expect(DSCHVVMMPatcher.dontPatchInstallNames == FrozenReference.blacklist)+ #expect(DyldSharedCacheHVVMMPatcher.needle.hex == FrozenReference.needleHex)+ #expect(DyldSharedCacheHVVMMPatcher.mangledNeedle.hex == FrozenReference.mangledNeedleHex)+ #expect(DyldSharedCacheHVVMMPatcher.mangleOffset == FrozenReference.mangleOffset)+ #expect(Data([DyldSharedCacheHVVMMPatcher.originalByte]).hex == FrozenReference.originalByteHex)+ #expect(Data([DyldSharedCacheHVVMMPatcher.mangledByte]).hex == FrozenReference.mangledByteHex)+ #expect(DyldSharedCacheHVVMMPatcher.dontPatchInstallNames == FrozenReference.blacklist)// The mangle has to preserve the namespace prefix, or the name cannot// resolve to any OID — see the patcher's file comment. This is the one// property of the patch that is not a transcription of the reference.- let prefix = Data(DSCHVVMMPatcher.sysctlNamespace.utf8)- #expect(DSCHVVMMPatcher.needle.prefix(prefix.count) == prefix)- #expect(DSCHVVMMPatcher.mangledNeedle.prefix(prefix.count) == prefix)- #expect(DSCHVVMMPatcher.needle.count == DSCHVVMMPatcher.mangledNeedle.count)- let differing = zip(DSCHVVMMPatcher.needle, DSCHVVMMPatcher.mangledNeedle)+ let prefix = Data(DyldSharedCacheHVVMMPatcher.sysctlNamespace.utf8)+ #expect(DyldSharedCacheHVVMMPatcher.needle.prefix(prefix.count) == prefix)+ #expect(DyldSharedCacheHVVMMPatcher.mangledNeedle.prefix(prefix.count) == prefix)+ #expect(DyldSharedCacheHVVMMPatcher.needle.count == DyldSharedCacheHVVMMPatcher.mangledNeedle.count)+ let differing = zip(DyldSharedCacheHVVMMPatcher.needle, DyldSharedCacheHVVMMPatcher.mangledNeedle).enumerated().filter { $0.element.0 != $0.element.1 }.map(\.offset)- #expect(differing == [DSCHVVMMPatcher.mangleOffset])+ #expect(differing == [DyldSharedCacheHVVMMPatcher.mangleOffset])}}// MARK: - The real cache@Suite(.serialized, .enabled(if: HVVMMFixture.runs, HVVMMFixture.skipReason))-struct DSCHVVMMCacheParityTests {+struct DyldSharedCacheHVVMMCacheParityTests {/// The parity gate.////// One clone, one run, then require the tree to hold exactly the chunks the@@ -526,7 +526,7 @@ struct DSCHVVMMCacheParityTests {let swiftClone = try HVVMMFixture.cloneCache(named: "swift")defer { HVVMMFixture.discard(swiftClone) }- let result = try DSCHVVMMPatcher.patch(chunksDirectory: swiftClone, log: nil)+ let result = try DyldSharedCacheHVVMMPatcher.patch(chunksDirectory: swiftClone, log: nil)// Same verdict per dylib, including the zero-count entries that record// "seen and deliberately left alone".@@ -534,7 +534,7 @@ struct DSCHVVMMCacheParityTests {#expect(result.mangled == FrozenReference.totalMangled)#expect(result.mangled > 0, "the reference patched nothing — wrong fixture?")- #expect(result.skippedInBlacklist == DSCHVVMMPatcher.dontPatchInstallNames.count)+ #expect(result.skippedInBlacklist == DyldSharedCacheHVVMMPatcher.dontPatchInstallNames.count)#expect(result.skippedUnclassified == 0)#expect(result.refused == 0)#expect(result.isFullyAttested)@@ -556,7 +556,7 @@ struct DSCHVVMMCacheParityTests {// finds no pristine cstring left, queues the mangled ones so their slots// stay in sync, and must not move a byte. The reference behaved the same// way, so the frozen digests have to survive it.- let second = try DSCHVVMMPatcher.patch(chunksDirectory: swiftClone, log: nil)+ let second = try DyldSharedCacheHVVMMPatcher.patch(chunksDirectory: swiftClone, log: nil)#expect(second.mangled == 0)#expect(second.pristineSiteCount == result.skippedInBlacklist)#expect(second.alreadyMangledSiteCount == result.mangled)@@ -568,25 +568,25 @@ struct DSCHVVMMCacheParityTests {// The blacklist is the whole point of the design, so check it against// the bytes rather than against the run's own bookkeeping: every// blacklisted dylib in the cache must still hold the pristine cstring.- let chunks = try DSCChunkSet(directory: swiftClone)+ let chunks = try DyldSharedCacheChunkSet(directory: swiftClone)var blacklistedSitesSeen = 0- for vma in try chunks.findStringVMAs(DSCHVVMMPatcher.needle) {+ for vma in try chunks.findStringVMAs(DyldSharedCacheHVVMMPatcher.needle) {let installName = try #require(- DSCHVVMMPatcher.classify(vma, in: chunks),+ DyldSharedCacheHVVMMPatcher.classify(vma, in: chunks),"a pristine cstring survived in a dylib that cannot be named",)#expect(- DSCHVVMMPatcher.dontPatchSet.contains(installName),+ DyldSharedCacheHVVMMPatcher.dontPatchSet.contains(installName),"\(installName) is not blacklisted but kept the original cstring",)blacklistedSitesSeen += 1}#expect(blacklistedSitesSeen == result.skippedInBlacklist)- for vma in try chunks.findStringVMAs(DSCHVVMMPatcher.mangledNeedle) {- let installName = try #require(DSCHVVMMPatcher.classify(vma, in: chunks))+ for vma in try chunks.findStringVMAs(DyldSharedCacheHVVMMPatcher.mangledNeedle) {+ let installName = try #require(DyldSharedCacheHVVMMPatcher.classify(vma, in: chunks))#expect(- !DSCHVVMMPatcher.dontPatchSet.contains(installName),+ !DyldSharedCacheHVVMMPatcher.dontPatchSet.contains(installName),"\(installName) is blacklisted but was mangled",)}@@ -599,7 +599,7 @@ struct DSCHVVMMCacheParityTests {let clone = try HVVMMFixture.cloneCache(named: "dryrun")defer { HVVMMFixture.discard(clone) }- let result = try DSCHVVMMPatcher.patch(+ let result = try DyldSharedCacheHVVMMPatcher.patch(chunksDirectory: clone,dryRun: true,log: nil,@@ -639,43 +639,43 @@ struct DSCHVVMMCacheParityTests {// The lowest-addressed site inside a blacklisted dylib, so the choice is// the same on every run — and the same one the reference was given.- let probe = try DSCChunkSet(directory: swiftClone)+ let probe = try DyldSharedCacheChunkSet(directory: swiftClone)let driftVMA = try #require(- try probe.findStringVMAs(DSCHVVMMPatcher.needle).sorted().first {- guard let name = DSCHVVMMPatcher.classify($0, in: probe) else { return false }- return DSCHVVMMPatcher.dontPatchSet.contains(name)+ try probe.findStringVMAs(DyldSharedCacheHVVMMPatcher.needle).sorted().first {+ guard let name = DyldSharedCacheHVVMMPatcher.classify($0, in: probe) else { return false }+ return DyldSharedCacheHVVMMPatcher.dontPatchSet.contains(name)},"no blacklisted dylib carries the cstring in this cache",)- let driftedDylib = try #require(DSCHVVMMPatcher.classify(driftVMA, in: probe))+ let driftedDylib = try #require(DyldSharedCacheHVVMMPatcher.classify(driftVMA, in: probe))#expect(driftVMA == FrozenReference.driftVMA)#expect(driftedDylib == FrozenReference.driftedInstallName)// Mangle it by hand, without re-attesting — exactly the state a prior// out-of-band run would have left behind, and what the reference saw.- let chunks = try DSCChunkSet(directory: swiftClone)+ let chunks = try DyldSharedCacheChunkSet(directory: swiftClone)try chunks.write(- at: driftVMA &+ UInt64(DSCHVVMMPatcher.mangleOffset),- Data([DSCHVVMMPatcher.mangledByte]),+ at: driftVMA &+ UInt64(DyldSharedCacheHVVMMPatcher.mangleOffset),+ Data([DyldSharedCacheHVVMMPatcher.mangledByte]),)- let result = try DSCHVVMMPatcher.patch(chunksDirectory: swiftClone, log: nil)+ let result = try DyldSharedCacheHVVMMPatcher.patch(chunksDirectory: swiftClone, log: nil)#expect(result.blacklistDrift == 1)#expect(result.alreadyMangledSiteCount == 1)#expect(result.reattestOnly == 0)#expect(result.refused == 0)#expect(- result.skippedInBlacklist == DSCHVVMMPatcher.dontPatchInstallNames.count - 1,+ result.skippedInBlacklist == DyldSharedCacheHVVMMPatcher.dontPatchInstallNames.count - 1,"the drifted site is no longer pristine, so it is not counted as skipped",)#expect(result.mangledCountByInstallName[driftedDylib] == nil)#expect(result.isFullyAttested)// Not reverted: the byte is still mangled afterwards.- let after = try DSCChunkSet(directory: swiftClone)- .bytesAtVMA(driftVMA, length: DSCHVVMMPatcher.needle.count)- #expect(after == DSCHVVMMPatcher.mangledNeedle)+ let after = try DyldSharedCacheChunkSet(directory: swiftClone)+ .bytesAtVMA(driftVMA, length: DyldSharedCacheHVVMMPatcher.needle.count)+ #expect(after == DyldSharedCacheHVVMMPatcher.mangledNeedle)// The same 17 chunks as the ordinary run, differing only in the one the// drifted dylib lives in — which is what the reference left behind.@@ -687,7 +687,7 @@ struct DSCHVVMMCacheParityTests {// MARK: - Standalone Mach-O@Suite(.serialized, .enabled(if: HVVMMFixture.machORuns, HVVMMFixture.machOSkipReason))-struct DSCHVVMMStandaloneTests {+struct DyldSharedCacheHVVMMStandaloneTests {/// The other half of `cfw_patch_hv_vmm.py`, against the binaries the repo/// keeps pristine copies of. Each carries one occurrence of the cstring on/// this build.@@ -714,7 +714,7 @@ struct DSCHVVMMStandaloneTests {defer { HVVMMFixture.discard(swiftCopy) }// Same sites, in the same order, before anything is written.- let sites = try DSCHVVMMPatcher.findStringSites(+ let sites = try DyldSharedCacheHVVMMPatcher.findStringSites(inMachO: Data(contentsOf: pristine),)#expect(sites.count == reference.sites.count)@@ -725,13 +725,13 @@ struct DSCHVVMMStandaloneTests {#expect(mine.section == theirs.section)}- let count = try DSCHVVMMPatcher.patchStandaloneMachO(at: swiftCopy, log: nil)+ let count = try DyldSharedCacheHVVMMPatcher.patchStandaloneMachO(at: swiftCopy, log: nil)#expect(count == sites.count)#expect(try Digest.sha256(of: swiftCopy) == reference.patchedSHA256)// Idempotent: the pristine literal is gone, so a second pass is a no-op.// The reference's own second pass returned 0 and left its digest alone.- let rerun = try DSCHVVMMPatcher.patchStandaloneMachO(at: swiftCopy, log: nil)+ let rerun = try DyldSharedCacheHVVMMPatcher.patchStandaloneMachO(at: swiftCopy, log: nil)#expect(rerun == 0)#expect(try Digest.sha256(of: swiftCopy) == reference.patchedSHA256)print("[hv_vmm] \(name): \(count) standalone cstring site(s), bytes match")diff --git a/tests/FirmwarePatcherTests/DSCIOMFBForceKernTests.swift b/tests/FirmwarePatcherTests/DyldSharedCacheIOMFBForceKernTests.swiftsimilarity index 93%rename from tests/FirmwarePatcherTests/DSCIOMFBForceKernTests.swiftrename to tests/FirmwarePatcherTests/DyldSharedCacheIOMFBForceKernTests.swiftindex 4908d2a9..68ba6361 100644--- a/tests/FirmwarePatcherTests/DSCIOMFBForceKernTests.swift+++ b/tests/FirmwarePatcherTests/DyldSharedCacheIOMFBForceKernTests.swift@@ -1,4 +1,4 @@-// DSCIOMFBForceKernTests.swift — Parity for the IOMFB force-kern DSC patcher.+// DyldSharedCacheIOMFBForceKernTests.swift — Parity for the IOMFB force-kern DSC patcher.//// There is no independent oracle for a patched dyld shared cache: `codesign -v`// does not apply to a cache chunk, and nothing but the guest kernel reads the@@ -383,7 +383,7 @@ private enum Digest {// MARK: - Parity against the frozen reference@Suite(.serialized, .enabled(if: ForceKernFixture.runs, ForceKernFixture.skipReason))-struct DSCIOMFBForceKernParityTests {+struct DyldSharedCacheIOMFBForceKernParityTests {/// The one test that decides whether this port is done.@Testfunc `Swift force-kern reproduces the reference cache byte for byte`() throws {@@ -392,7 +392,7 @@ struct DSCIOMFBForceKernParityTests {let swiftClone = try ForceKernFixture.cloneCache(named: "swift")defer { ForceKernFixture.discard(swiftClone) }- let outcome = try DSCIOMFBForceKernPatcher.patch(+ let outcome = try DyldSharedCacheIOMFBForceKernPatcher.patch(chunksDirectory: swiftClone,log: nil,)@@ -423,11 +423,11 @@ struct DSCIOMFBForceKernParityTests {let clone = try ForceKernFixture.cloneCache(named: "idempotence")defer { ForceKernFixture.discard(clone) }- let first = try DSCIOMFBForceKernPatcher.patch(chunksDirectory: clone, log: nil)+ let first = try DyldSharedCacheIOMFBForceKernPatcher.patch(chunksDirectory: clone, log: nil)#expect(first.writtenSiteCount == FrozenReference.newlyForced)let hashesBefore = try Digest.chunkDigests(of: clone)- let second = try DSCIOMFBForceKernPatcher.patch(chunksDirectory: clone, log: nil)+ let second = try DyldSharedCacheIOMFBForceKernPatcher.patch(chunksDirectory: clone, log: nil)#expect(second.writtenSiteCount == 0, "a second pass rewrote \(second.writtenSiteCount) site(s)")#expect(second.reattestation == nil, "a second pass re-attested pages it did not dirty")@@ -447,7 +447,7 @@ struct DSCIOMFBForceKernParityTests {defer { ForceKernFixture.discard(clone) }let hashesBefore = try Digest.chunkDigests(of: clone)- let dry = try DSCIOMFBForceKernPatcher.patch(+ let dry = try DyldSharedCacheIOMFBForceKernPatcher.patch(chunksDirectory: clone,dryRun: true,log: nil,@@ -458,7 +458,7 @@ struct DSCIOMFBForceKernParityTests {let hashesAfter = try Digest.chunkDigests(of: clone)#expect(hashesAfter == hashesBefore, "a dry run wrote to the cache")- let wet = try DSCIOMFBForceKernPatcher.patch(chunksDirectory: clone, log: nil)+ let wet = try DyldSharedCacheIOMFBForceKernPatcher.patch(chunksDirectory: clone, log: nil)#expect(wet.writtenSiteCount == dry.writtenSiteCount)}}@@ -466,7 +466,7 @@ struct DSCIOMFBForceKernParityTests {// MARK: - Discovery and classification@Suite(.serialized, .enabled(if: ForceKernFixture.runs, ForceKernFixture.skipReason))-struct DSCIOMFBForceKernDiscoveryTests {+struct DyldSharedCacheIOMFBForceKernDiscoveryTests {/// Discovery has to agree with the reference's, which read the same image/// through `ipsw dyld symaddr`. Compared here without `ipsw`: the pairs the/// resolver finds are the pairs the reference logged.@@ -474,11 +474,11 @@ struct DSCIOMFBForceKernDiscoveryTests {func `Every discovered pair matches the reference's, name and address`() throws {let pristine = try #require(ForceKernFixture.pristine, ForceKernFixture.missing)- let resolver = try DSCSymbolResolver(+ let resolver = try DyldSharedCacheSymbolResolver(mainCacheURL: pristine.appendingPathComponent("dyld_shared_cache_arm64e"),)- let entries = try DSCIOMFBForceKernPatcher.discoverEntryPoints(resolver: resolver)- #expect(entries.count >= DSCIOMFBForceKernPatcher.requiredSuffixes.count)+ let entries = try DyldSharedCacheIOMFBForceKernPatcher.discoverEntryPoints(resolver: resolver)+ #expect(entries.count >= DyldSharedCacheIOMFBForceKernPatcher.requiredSuffixes.count)let discovered = Set(entries.map(\.publicName))let expected = FrozenReference.discoveredNames@@ -507,12 +507,12 @@ struct DSCIOMFBForceKernDiscoveryTests {@Testfunc `The required entry points are present and forcible`() throws {let pristine = try #require(ForceKernFixture.pristine, ForceKernFixture.missing)- let chunks = try DSCChunkSet(directory: pristine)- let resolver = try DSCSymbolResolver(chunks: chunks)- let entries = try DSCIOMFBForceKernPatcher.discoverEntryPoints(resolver: resolver)+ let chunks = try DyldSharedCacheChunkSet(directory: pristine)+ let resolver = try DyldSharedCacheSymbolResolver(chunks: chunks)+ let entries = try DyldSharedCacheIOMFBForceKernPatcher.discoverEntryPoints(resolver: resolver)let disassembler = ARM64Disassembler()- for required in DSCIOMFBForceKernPatcher.requiredSuffixes {+ for required in DyldSharedCacheIOMFBForceKernPatcher.requiredSuffixes {let entry = try #require(entries.first { $0.suffix == required },"no entry point discovered for \(required)",@@ -523,7 +523,7 @@ struct DSCIOMFBForceKernDiscoveryTests {count: 4,)#expect(- DSCIOMFBForceKernPatcher.isDispatchTrampoline(instructions),+ DyldSharedCacheIOMFBForceKernPatcher.isDispatchTrampoline(instructions),"\(entry.publicName) is not a thin dispatch trampoline",)}@@ -539,7 +539,7 @@ struct DSCIOMFBForceKernDiscoveryTests {let clone = try ForceKernFixture.cloneCache(named: "shapes")defer { ForceKernFixture.discard(clone) }- let dry = try DSCIOMFBForceKernPatcher.patch(+ let dry = try DyldSharedCacheIOMFBForceKernPatcher.patch(chunksDirectory: clone,dryRun: true,log: nil,@@ -554,7 +554,7 @@ struct DSCIOMFBForceKernDiscoveryTests {// And each rejection is a real one: its first instruction is not the// trampoline's `cbz x0`, or the three that follow are not the load,// null-check and tail-call.- let chunks = try DSCChunkSet(directory: pristine)+ let chunks = try DyldSharedCacheChunkSet(directory: pristine)let disassembler = ARM64Disassembler()for site in dry.notTrampolines {let instructions = try disassembler.disassemble(@@ -562,7 +562,7 @@ struct DSCIOMFBForceKernDiscoveryTests {at: site.entry.publicAddress,count: 4,)- #expect(!DSCIOMFBForceKernPatcher.isDispatchTrampoline(instructions))+ #expect(!DyldSharedCacheIOMFBForceKernPatcher.isDispatchTrampoline(instructions))print("[force-kern] left on virt: \(site.entry.publicName) — \(site.originalDisassembly)")}}@@ -576,16 +576,16 @@ struct DSCIOMFBForceKernDiscoveryTests {let clone = try ForceKernFixture.cloneCache(named: "records")defer { ForceKernFixture.discard(clone) }- let outcome = try DSCIOMFBForceKernPatcher.patch(chunksDirectory: clone, log: nil)+ let outcome = try DyldSharedCacheIOMFBForceKernPatcher.patch(chunksDirectory: clone, log: nil)#expect(outcome.records.count == outcome.writtenSiteCount)let kernAddresses = Dictionary(uniqueKeysWithValues: FrozenReference.forcedPairs.map { ($0.publicAddress, $0.kernAddress) },)- let chunks = try DSCChunkSet(directory: clone)+ let chunks = try DyldSharedCacheChunkSet(directory: clone)let disassembler = ARM64Disassembler()for record in outcome.records {- #expect(record.patchID.hasPrefix("\(DSCIOMFBForceKernPatcher.recordGroup)."))+ #expect(record.patchID.hasPrefix("\(DyldSharedCacheIOMFBForceKernPatcher.recordGroup)."))#expect(record.patchedBytes.count == 4)#expect(record.originalBytes.count == 4)#expect(record.originalBytes != record.patchedBytes)diff --git a/tests/FirmwarePatcherTests/DSCIOMFBSwapEndTests.swift b/tests/FirmwarePatcherTests/DyldSharedCacheIOMFBSwapEndTests.swiftsimilarity index 91%rename from tests/FirmwarePatcherTests/DSCIOMFBSwapEndTests.swiftrename to tests/FirmwarePatcherTests/DyldSharedCacheIOMFBSwapEndTests.swiftindex 62e17ee9..faa15b6f 100644--- a/tests/FirmwarePatcherTests/DSCIOMFBSwapEndTests.swift+++ b/tests/FirmwarePatcherTests/DyldSharedCacheIOMFBSwapEndTests.swift@@ -1,4 +1,4 @@-// DSCIOMFBSwapEndTests.swift — Parity for the IOMFB SwapEnd payload-size patch.+// DyldSharedCacheIOMFBSwapEndTests.swift — Parity for the IOMFB SwapEnd payload-size patch.//// There is no independent checker for a patched dyld shared cache: `codesign -v`// does not apply to a cache chunk, and the only other implementation of this@@ -7,7 +7,7 @@// invoked it. That Python has been removed, so what it produced on the real// 24A435 arm64e cache — at each of the three target sizes — is frozen in// `FrozenReference` below: the site it landed on, the size it found there, and-// the SHA-256 of the one chunk it changed. `DSCIOMFBSwapEndPatcher` runs on a+// the SHA-256 of the one chunk it changed. `DyldSharedCacheIOMFBSwapEndPatcher` runs on a// clone and is graded against those. A patch that lands in the right place but// re-attests a different page lands on a different digest.//@@ -302,7 +302,7 @@ private enum SwapEndCallSetup {// MARK: - 1 · The anchor, with no cache in sight-struct DSCIOMFBSwapEndShapeTests {+struct DyldSharedCacheIOMFBSwapEndShapeTests {@Testfunc `The finder lands on the size move of the external-method call set-up`() throws {let disassembler = ARM64Disassembler()@@ -311,7 +311,7 @@ struct DSCIOMFBSwapEndShapeTests {#expect(instructions.count == 7)let site = try #require(- DSCIOMFBSwapEndPatcher.findSizeInstruction(+ DyldSharedCacheIOMFBSwapEndPatcher.findSizeInstruction(in: instructions,disassembler: disassembler,),@@ -323,12 +323,12 @@ struct DSCIOMFBSwapEndShapeTests {)let decoded = try #require(- DSCIOMFBSwapEndPatcher.movRegisterImmediate(+ DyldSharedCacheIOMFBSwapEndPatcher.movRegisterImmediate(site.instruction,disassembler: disassembler,),)- #expect(decoded.register == DSCIOMFBSwapEndPatcher.sizeRegister)+ #expect(decoded.register == DyldSharedCacheIOMFBSwapEndPatcher.sizeRegister)#expect(decoded.immediate == Int64(SwapEndCallSetup.sourceSize))print("[shape] size move at index \(site.index): \(site.instruction)")}@@ -341,7 +341,7 @@ struct DSCIOMFBSwapEndShapeTests {let code = try #require(SwapEndCallSetup.assemble(selector: 6))let instructions = SwapEndCallSetup.disassemble(code, disassembler)#expect(- DSCIOMFBSwapEndPatcher.findSizeInstruction(+ DyldSharedCacheIOMFBSwapEndPatcher.findSizeInstruction(in: instructions,disassembler: disassembler,) == nil,@@ -354,7 +354,7 @@ struct DSCIOMFBSwapEndShapeTests {let code = try #require(SwapEndCallSetup.assemble(terminator: ARM64.nop))let instructions = SwapEndCallSetup.disassemble(code, disassembler)#expect(- DSCIOMFBSwapEndPatcher.findSizeInstruction(+ DyldSharedCacheIOMFBSwapEndPatcher.findSizeInstruction(in: instructions,disassembler: disassembler,) == nil,@@ -372,12 +372,12 @@ struct DSCIOMFBSwapEndShapeTests {ARM64Disassembler().disassembleOne(encoded, at: SwapEndCallSetup.baseAddress),)let move = try #require(- DSCIOMFBSwapEndPatcher.movRegisterImmediate(+ DyldSharedCacheIOMFBSwapEndPatcher.movRegisterImmediate(decoded,disassembler: ARM64Disassembler(),),)- #expect(move.register == DSCIOMFBSwapEndPatcher.sizeRegister)+ #expect(move.register == DyldSharedCacheIOMFBSwapEndPatcher.sizeRegister)#expect(move.immediate == Int64(size))}}@@ -385,15 +385,15 @@ struct DSCIOMFBSwapEndShapeTests {@Testfunc `A size that will not fit a MOVZ immediate is refused, not truncated`() throws {#expect(throws: PatcherError.self) {- _ = try DSCIOMFBSwapEndPatcher.replacement(forTargetSize: 0x10000)+ _ = try DyldSharedCacheIOMFBSwapEndPatcher.replacement(forTargetSize: 0x10000)}// And it is refused before the 6.7 GB cache is opened, so the caller// gets "that size cannot be encoded" rather than whatever the cache// would have said first. A path that does not exist proves the order:- // if the guard moved after the open, this would throw a DSCError.+ // if the guard moved after the open, this would throw a DyldSharedCacheError.var thrown: (any Error)?do {- _ = try DSCIOMFBSwapEndPatcher.patch(+ _ = try DyldSharedCacheIOMFBSwapEndPatcher.patch(chunksDirectory: URL(fileURLWithPath: "/nonexistent-dyld-cache"),targetSize: 0x10000,dryRun: true,@@ -410,7 +410,7 @@ struct DSCIOMFBSwapEndShapeTests {// MARK: - 2 · Parity against the frozen reference, on the real cache@Suite(.serialized, .enabled(if: SwapEndFixture.runs, SwapEndFixture.skipReason))-struct DSCIOMFBSwapEndParityTests {+struct DyldSharedCacheIOMFBSwapEndParityTests {/// The three sizes that matter: the 26.4 base's, the 26.1 base's, and the/// size this cache's own userland already sends — which is the case where/// the right answer is to write nothing at all.@@ -434,7 +434,7 @@ struct DSCIOMFBSwapEndParityTests {let swiftClone = try SwapEndFixture.cloneCache(named: "swift_\(suffix)")defer { SwapEndFixture.discard(swiftClone) }- let mine = try DSCIOMFBSwapEndPatcher.patch(+ let mine = try DyldSharedCacheIOMFBSwapEndPatcher.patch(chunksDirectory: swiftClone,targetSize: targetSize,log: nil,@@ -481,7 +481,7 @@ struct DSCIOMFBSwapEndParityTests {let clone = try SwapEndFixture.cloneCache(named: "dry")defer { SwapEndFixture.discard(clone) }- let mine = try DSCIOMFBSwapEndPatcher.patch(+ let mine = try DyldSharedCacheIOMFBSwapEndPatcher.patch(chunksDirectory: clone,targetSize: 0x588,dryRun: true,@@ -508,7 +508,7 @@ struct DSCIOMFBSwapEndParityTests {let afterFirst = try SwapEndFixture.cloneCache(named: "idempotent_snapshot")defer { SwapEndFixture.discard(clone, afterFirst) }- let first = try DSCIOMFBSwapEndPatcher.patch(+ let first = try DyldSharedCacheIOMFBSwapEndPatcher.patch(chunksDirectory: clone,targetSize: 0x588,log: nil,@@ -524,7 +524,7 @@ struct DSCIOMFBSwapEndParityTests {)#expect(copy.status == 0)- let second = try DSCIOMFBSwapEndPatcher.patch(+ let second = try DyldSharedCacheIOMFBSwapEndPatcher.patch(chunksDirectory: clone,targetSize: 0x588,log: nil,@@ -549,45 +549,45 @@ struct DSCIOMFBSwapEndParityTests {@Testfunc `The symbol and the site are found without ipsw on the patch path`() throws {let pristine = try #require(SwapEndFixture.pristine, SwapEndFixture.missing)- let chunks = try DSCChunkSet(directory: pristine)- let resolver = try DSCSymbolResolver(chunks: chunks)+ let chunks = try DyldSharedCacheChunkSet(directory: pristine)+ let resolver = try DyldSharedCacheSymbolResolver(chunks: chunks)try resolver.requireLocalSymbols()let functionVMA = try resolver.address(- of: DSCIOMFBSwapEndPatcher.symbolName,- inImage: DSCIOMFBSwapEndPatcher.imagePath,+ of: DyldSharedCacheIOMFBSwapEndPatcher.symbolName,+ inImage: DyldSharedCacheIOMFBSwapEndPatcher.imagePath,)#expect(functionVMA == FrozenReference.functionVMA)let disassembler = ARM64Disassembler()- let instructions = try DSCIOMFBSwapEndPatcher.disassembleFunction(+ let instructions = try DyldSharedCacheIOMFBSwapEndPatcher.disassembleFunction(in: chunks,at: functionVMA,- maximumInstructions: DSCIOMFBSwapEndPatcher.maximumInstructions,+ maximumInstructions: DyldSharedCacheIOMFBSwapEndPatcher.maximumInstructions,disassembler: disassembler,)#expect(!instructions.isEmpty)let site = try #require(- DSCIOMFBSwapEndPatcher.findSizeInstruction(+ DyldSharedCacheIOMFBSwapEndPatcher.findSizeInstruction(in: instructions,disassembler: disassembler,),- "the SwapEnd call set-up was not found in \(DSCIOMFBSwapEndPatcher.symbolName)",+ "the SwapEnd call set-up was not found in \(DyldSharedCacheIOMFBSwapEndPatcher.symbolName)",)// The shape, on the real function: selector, size, two zeros, the call.let selector = try #require(- DSCIOMFBSwapEndPatcher.movRegisterImmediate(+ DyldSharedCacheIOMFBSwapEndPatcher.movRegisterImmediate(instructions[site.index - 1],disassembler: disassembler,),)#expect(selector.register == "w1")- #expect(selector.immediate == DSCIOMFBSwapEndPatcher.selector)+ #expect(selector.immediate == DyldSharedCacheIOMFBSwapEndPatcher.selector)#expect(instructions[site.index + 3].mnemonic == "bl")let size = try #require(- DSCIOMFBSwapEndPatcher.movRegisterImmediate(+ DyldSharedCacheIOMFBSwapEndPatcher.movRegisterImmediate(site.instruction,disassembler: disassembler,),@@ -596,7 +596,7 @@ struct DSCIOMFBSwapEndParityTests {#expect(site.instruction.address == FrozenReference.siteVMA)#expect(size.immediate == Int64(FrozenReference.originalSize))print(- "[resolve] \(DSCIOMFBSwapEndPatcher.symbolName) @ "+ "[resolve] \(DyldSharedCacheIOMFBSwapEndPatcher.symbolName) @ "+ "0x\(String(functionVMA, radix: 16, uppercase: true)), size move "+ "0x\(String(size.immediate, radix: 16, uppercase: true)) @ "+ "0x\(String(site.instruction.address, radix: 16, uppercase: true))",diff --git a/tests/FirmwarePatcherTests/DSCLSDEmbeddedRegTests.swift b/tests/FirmwarePatcherTests/DyldSharedCacheLSDEmbeddedRegTests.swiftsimilarity index 92%rename from tests/FirmwarePatcherTests/DSCLSDEmbeddedRegTests.swiftrename to tests/FirmwarePatcherTests/DyldSharedCacheLSDEmbeddedRegTests.swiftindex e60436ed..1d63a386 100644--- a/tests/FirmwarePatcherTests/DSCLSDEmbeddedRegTests.swift+++ b/tests/FirmwarePatcherTests/DyldSharedCacheLSDEmbeddedRegTests.swift@@ -1,4 +1,4 @@-// DSCLSDEmbeddedRegTests.swift — parity for the lsd embedded-registration gate.+// DyldSharedCacheLSDEmbeddedRegTests.swift — parity for the lsd embedded-registration gate.//// The patch is one instruction in a 6.7 GB cache, and a wrong one is a boot// panic rather than a failing assertion, so the reference these tests grade@@ -270,14 +270,14 @@ private enum CacheComparison {.enabled(if: LSDRegFixture.runs, LSDRegFixture.missing),.serialized,)-struct DSCLSDEmbeddedRegGateTests {+struct DyldSharedCacheLSDEmbeddedRegGateTests {@Testfunc `the gate is a cbz/cbnz on w0 whose fall-through sets a w register to 1`() throws {let pristine = try #require(LSDRegFixture.pristine, LSDRegFixture.missing)- let chunks = try DSCChunkSet(directory: pristine)+ let chunks = try DyldSharedCacheChunkSet(directory: pristine)let located = try #require(- try DSCLSDEmbeddedRegPatcher.locateGate(in: chunks),- "the iOS 27 fixture must carry \(DSCLSDEmbeddedRegPatcher.method)",+ try DyldSharedCacheLSDEmbeddedRegPatcher.locateGate(in: chunks),+ "the iOS 27 fixture must carry \(DyldSharedCacheLSDEmbeddedRegPatcher.method)",)#expect(["cbz", "cbnz"].contains(located.gate.mnemonic))@@ -287,7 +287,7 @@ struct DSCLSDEmbeddedRegGateTests {// The gate is inside the disassembly window, by construction.#expect(located.gate.vma- < located.functionVMA + UInt64(DSCLSDEmbeddedRegPatcher.maxInstructions * 4),+ < located.functionVMA + UInt64(DyldSharedCacheLSDEmbeddedRegPatcher.maxInstructions * 4),)// …and it is the exact site the reference Python reported.@@ -300,10 +300,10 @@ struct DSCLSDEmbeddedRegGateTests {@Testfunc `the symbol resolves through the cache's own local symbol table`() throws {let pristine = try #require(LSDRegFixture.pristine, LSDRegFixture.missing)- let chunks = try DSCChunkSet(directory: pristine)+ let chunks = try DyldSharedCacheChunkSet(directory: pristine)let address = try #require(- try chunks.resolveLocalSymbol(DSCLSDEmbeddedRegPatcher.method),- "\(DSCLSDEmbeddedRegPatcher.method) must be in the .symbols table",+ try chunks.resolveLocalSymbol(DyldSharedCacheLSDEmbeddedRegPatcher.method),+ "\(DyldSharedCacheLSDEmbeddedRegPatcher.method) must be in the .symbols table",)#expect(address == FrozenReference.methodVMA)// It has to live in an executable mapping, or it is not the method.@@ -319,13 +319,13 @@ struct DSCLSDEmbeddedRegGateTests {.enabled(if: LSDRegFixture.runs, LSDRegFixture.missing),.serialized,)-struct DSCLSDEmbeddedRegParityTests {+struct DyldSharedCacheLSDEmbeddedRegParityTests {@Testfunc `Swift reproduces the reference cache byte for byte, one site`() throws {let swiftClone = try LSDRegFixture.cloneCache(named: "swift")defer { LSDRegFixture.discard(swiftClone) }- let report = try DSCLSDEmbeddedRegPatcher.patch(+ let report = try DyldSharedCacheLSDEmbeddedRegPatcher.patch(chunksDirectory: swiftClone,log: nil,)@@ -349,11 +349,11 @@ struct DSCLSDEmbeddedRegParityTests {let clone = try LSDRegFixture.cloneCache(named: "record")defer { LSDRegFixture.discard(clone) }- let report = try DSCLSDEmbeddedRegPatcher.patch(chunksDirectory: clone, log: nil)+ let report = try DyldSharedCacheLSDEmbeddedRegPatcher.patch(chunksDirectory: clone, log: nil)let record = try #require(report.record)let gate = try #require(report.gate)- #expect(record.patchID == DSCLSDEmbeddedRegPatcher.patchID)+ #expect(record.patchID == DyldSharedCacheLSDEmbeddedRegPatcher.patchID)#expect(record.component.hasPrefix("dyld_shared_cache_arm64e"))#expect(record.virtualAddress == gate.vma)#expect(record.patchedBytes == ARM64.nop)@@ -384,17 +384,17 @@ struct DSCLSDEmbeddedRegParityTests {.enabled(if: LSDRegFixture.runs, LSDRegFixture.missing),.serialized,)-struct DSCLSDEmbeddedRegRerunTests {+struct DyldSharedCacheLSDEmbeddedRegRerunTests {@Testfunc `a second Swift run is idempotent and leaves the bytes alone`() throws {let clone = try LSDRegFixture.cloneCache(named: "idempotent")defer { LSDRegFixture.discard(clone) }- let first = try DSCLSDEmbeddedRegPatcher.patch(chunksDirectory: clone, log: nil)+ let first = try DyldSharedCacheLSDEmbeddedRegPatcher.patch(chunksDirectory: clone, log: nil)#expect(first.outcome == .patched)let afterFirst = try CacheComparison.changedFiles(in: clone)- let second = try DSCLSDEmbeddedRegPatcher.patch(chunksDirectory: clone, log: nil)+ let second = try DyldSharedCacheLSDEmbeddedRegPatcher.patch(chunksDirectory: clone, log: nil)#expect(second.outcome == .alreadyPatched)#expect(second.sitesWritten == 0)#expect(second.gate?.wasAlreadyNOP == true)@@ -416,7 +416,7 @@ struct DSCLSDEmbeddedRegRerunTests {let clone = try LSDRegFixture.cloneCache(named: "dryrun")defer { LSDRegFixture.discard(clone) }- let report = try DSCLSDEmbeddedRegPatcher.patch(+ let report = try DyldSharedCacheLSDEmbeddedRegPatcher.patch(chunksDirectory: clone,dryRun: true,log: nil,diff --git a/tests/FirmwarePatcherTests/DSCLockdownModePatcherTests.swift b/tests/FirmwarePatcherTests/DyldSharedCacheLockdownModePatcherTests.swiftsimilarity index 88%rename from tests/FirmwarePatcherTests/DSCLockdownModePatcherTests.swiftrename to tests/FirmwarePatcherTests/DyldSharedCacheLockdownModePatcherTests.swiftindex 72758932..ef5f62fe 100644--- a/tests/FirmwarePatcherTests/DSCLockdownModePatcherTests.swift+++ b/tests/FirmwarePatcherTests/DyldSharedCacheLockdownModePatcherTests.swift@@ -1,4 +1,4 @@-// DSCLockdownModePatcherTests.swift — Parity for the lockdown-mode DSC patch.+// DyldSharedCacheLockdownModePatcherTests.swift — Parity for the lockdown-mode DSC patch.//// The only independent reference for this patch was// `scripts/patchers/cfw_patch_lockdown_mode.py`, driven exactly as@@ -6,7 +6,7 @@// Python has been removed, so what it produced on the real cache is frozen in// `FrozenReference` below — the block and gate addresses, the instruction word// on each side of the write, and the SHA-256 of the one chunk it changed. The-// central test clones the cache, runs `DSCLockdownModePatcher` on the clone and+// central test clones the cache, runs `DyldSharedCacheLockdownModePatcher` on the clone and// grades it against those, chunk bytes and re-attested code slot alike.//// The tests need the real cache. Point `VPHONE_DSC_PRISTINE` at a directory of@@ -294,7 +294,7 @@ private enum DirectoryComparison {// MARK: - Parity against the frozen reference@Suite(.serialized, .enabled(if: LockdownFixture.runs, LockdownFixture.skipReason))-struct DSCLockdownModeParityTests {+struct DyldSharedCacheLockdownModeParityTests {/// The one that matters: the real cache in, the reference's bytes out.@Testfunc `Swift reproduces the reference's patched cache byte for byte`() throws {@@ -303,7 +303,7 @@ struct DSCLockdownModeParityTests {let swiftClone = try LockdownFixture.cloneCache(named: "swift")defer { LockdownFixture.discard(swiftClone) }- let outcome = try DSCLockdownModePatcher.patch(chunksDirectory: swiftClone, log: nil)+ let outcome = try DyldSharedCacheLockdownModePatcher.patch(chunksDirectory: swiftClone, log: nil)#expect(outcome.verdict == .patched)#expect(outcome.sitesWritten == FrozenReference.sitesWritten)@@ -327,7 +327,7 @@ struct DSCLockdownModeParityTests {let clone = try LockdownFixture.cloneCache(named: "reattest")defer { LockdownFixture.discard(clone) }- let outcome = try DSCLockdownModePatcher.patch(chunksDirectory: clone, log: nil)+ let outcome = try DyldSharedCacheLockdownModePatcher.patch(chunksDirectory: clone, log: nil)let reattestation = try #require(outcome.reattestation)#expect(reattestation.updated.count == 1)#expect(reattestation.isFullyAttested)@@ -344,11 +344,11 @@ struct DSCLockdownModeParityTests {let clone = try LockdownFixture.cloneCache(named: "idempotence")defer { LockdownFixture.discard(clone) }- let first = try DSCLockdownModePatcher.patch(chunksDirectory: clone, log: nil)+ let first = try DyldSharedCacheLockdownModePatcher.patch(chunksDirectory: clone, log: nil)#expect(first.verdict == .patched)let afterFirst = try DirectoryComparison.fingerprint(of: clone)- let second = try DSCLockdownModePatcher.patch(chunksDirectory: clone, log: nil)+ let second = try DyldSharedCacheLockdownModePatcher.patch(chunksDirectory: clone, log: nil)#expect(second.verdict == .alreadyPatched)#expect(second.sitesWritten == 0)#expect(second.sitesFound == 1)@@ -372,7 +372,7 @@ struct DSCLockdownModeParityTests {let clone = try LockdownFixture.cloneCache(named: "dryrun")defer { LockdownFixture.discard(clone) }- let outcome = try DSCLockdownModePatcher.patch(+ let outcome = try DyldSharedCacheLockdownModePatcher.patch(chunksDirectory: clone,dryRun: true,log: nil,@@ -391,22 +391,22 @@ struct DSCLockdownModeParityTests {func `Symbol and gate resolve to the reference's addresses`() throws {let pristine = try #require(LockdownFixture.pristine, LockdownFixture.missing)- let chunks = try DSCChunkSet(directory: pristine)- let resolved = try DSCLockdownModePatcher.resolveBlockInvoke(in: chunks)+ let chunks = try DyldSharedCacheChunkSet(directory: pristine)+ let resolved = try DyldSharedCacheLockdownModePatcher.resolveBlockInvoke(in: chunks)let block = try #require(resolved,"the cache must carry an os_lockdown_mode_enabled block to compare against",)#expect(block.vma == FrozenReference.functionVMA)- #expect(block.name == DSCLockdownModePatcher.symbolCandidates.first)+ #expect(block.name == DyldSharedCacheLockdownModePatcher.symbolCandidates.first)- let instructions = try DSCLockdownModePatcher.disassembleBlock(in: chunks, at: block.vma)- let gate = try #require(DSCLockdownModePatcher.findErrorGate(instructions))+ let instructions = try DyldSharedCacheLockdownModePatcher.disassembleBlock(in: chunks, at: block.vma)+ let gate = try #require(DyldSharedCacheLockdownModePatcher.findErrorGate(instructions))#expect(gate.address == FrozenReference.gateVMA)#expect(gate.mnemonic == FrozenReference.gateMnemonic)// The decode stops at the block's own return, not at the ceiling.- #expect(instructions.count < DSCLockdownModePatcher.maxInstructions)+ #expect(instructions.count < DyldSharedCacheLockdownModePatcher.maxInstructions)let last = try #require(instructions.last)#expect(last.mnemonic == "ret" || last.mnemonic == "retab")}@@ -415,7 +415,7 @@ struct DSCLockdownModeParityTests {// MARK: - What the gate search must and must not match@Suite(.serialized, .enabled(if: LockdownFixture.runs, LockdownFixture.skipReason))-struct DSCLockdownModeGateTests {+struct DyldSharedCacheLockdownModeGateTests {/// The real instruction stream, and the index of the real gate in it.private struct Stream {let instructions: [Instruction]@@ -425,11 +425,11 @@ struct DSCLockdownModeGateTests {private func realStream() throws -> Stream {let pristine = try #require(LockdownFixture.pristine, LockdownFixture.missing)- let chunks = try DSCChunkSet(directory: pristine)- let resolved = try DSCLockdownModePatcher.resolveBlockInvoke(in: chunks)+ let chunks = try DyldSharedCacheChunkSet(directory: pristine)+ let resolved = try DyldSharedCacheLockdownModePatcher.resolveBlockInvoke(in: chunks)let block = try #require(resolved)- let instructions = try DSCLockdownModePatcher.disassembleBlock(in: chunks, at: block.vma)- let gate = try #require(DSCLockdownModePatcher.findErrorGate(instructions))+ let instructions = try DyldSharedCacheLockdownModePatcher.disassembleBlock(in: chunks, at: block.vma)+ let gate = try #require(DyldSharedCacheLockdownModePatcher.findErrorGate(instructions))let gateIndex = try #require(instructions.firstIndex { $0.address == gate.address })#expect(gateIndex > 0)return Stream(@@ -458,7 +458,7 @@ struct DSCLockdownModeGateTests {let stream = try realStream()let comparison = stream.instructions[stream.comparisonIndex]#expect(comparison.mnemonic == "cmn")- #expect(DSCLockdownModePatcher.immediate(of: comparison, at: 1) == 1)+ #expect(DyldSharedCacheLockdownModePatcher.immediate(of: comparison, at: 1) == 1)#expect(stream.instructions[stream.gateIndex].mnemonic == "b.eq")// Something before the comparison has to be the sysctl call.#expect(stream.instructions[..<stream.comparisonIndex].contains { $0.mnemonic == "bl" })@@ -468,7 +468,7 @@ struct DSCLockdownModeGateTests {func `A cmn with no preceding call is not a gate`() throws {let stream = try realStream()let withoutCalls = stream.instructions.filter { $0.mnemonic != "bl" }- #expect(DSCLockdownModePatcher.findErrorGate(withoutCalls) == nil)+ #expect(DyldSharedCacheLockdownModePatcher.findErrorGate(withoutCalls) == nil)}@Test@@ -481,11 +481,11 @@ struct DSCLockdownModeGateTests {at: comparison.address,))#expect(mutated.mnemonic == "cmn")- #expect(DSCLockdownModePatcher.immediate(of: mutated, at: 1) == 2)+ #expect(DyldSharedCacheLockdownModePatcher.immediate(of: mutated, at: 1) == 2)var instructions = stream.instructionsinstructions[stream.comparisonIndex] = mutated- #expect(DSCLockdownModePatcher.findErrorGate(instructions) == nil)+ #expect(DyldSharedCacheLockdownModePatcher.findErrorGate(instructions) == nil)}@Test@@ -497,14 +497,14 @@ struct DSCLockdownModeGateTests {)var instructions = stream.instructionsinstructions[stream.gateIndex] = filler- #expect(DSCLockdownModePatcher.findErrorGate(instructions) == nil)+ #expect(DyldSharedCacheLockdownModePatcher.findErrorGate(instructions) == nil)}@Testfunc `A truncated stream that ends on the cmn is not a gate`() throws {let stream = try realStream()let truncated = Array(stream.instructions[...stream.comparisonIndex])- #expect(DSCLockdownModePatcher.findErrorGate(truncated) == nil)+ #expect(DyldSharedCacheLockdownModePatcher.findErrorGate(truncated) == nil)}/// The already-patched shape, read off a cache this code actually patched@@ -515,14 +515,14 @@ struct DSCLockdownModeGateTests {let clone = try LockdownFixture.cloneCache(named: "nopedgate")defer { LockdownFixture.discard(clone) }- let outcome = try DSCLockdownModePatcher.patch(chunksDirectory: clone, log: nil)+ let outcome = try DyldSharedCacheLockdownModePatcher.patch(chunksDirectory: clone, log: nil)let gateVMA = try #require(outcome.gateVMA)- let chunks = try DSCChunkSet(directory: clone)- let resolved = try DSCLockdownModePatcher.resolveBlockInvoke(in: chunks)+ let chunks = try DyldSharedCacheChunkSet(directory: clone)+ let resolved = try DyldSharedCacheLockdownModePatcher.resolveBlockInvoke(in: chunks)let block = try #require(resolved)- let instructions = try DSCLockdownModePatcher.disassembleBlock(in: chunks, at: block.vma)- let gate = try #require(DSCLockdownModePatcher.findErrorGate(instructions))+ let instructions = try DyldSharedCacheLockdownModePatcher.disassembleBlock(in: chunks, at: block.vma)+ let gate = try #require(DyldSharedCacheLockdownModePatcher.findErrorGate(instructions))#expect(gate.address == gateVMA)#expect(gate.mnemonic == "nop")}diff --git a/tests/FirmwarePatcherTests/DSCMaxSlidePatcherTests.swift b/tests/FirmwarePatcherTests/DyldSharedCacheMaxSlidePatcherTests.swiftsimilarity index 91%rename from tests/FirmwarePatcherTests/DSCMaxSlidePatcherTests.swiftrename to tests/FirmwarePatcherTests/DyldSharedCacheMaxSlidePatcherTests.swiftindex 6f68991a..ec007a8d 100644--- a/tests/FirmwarePatcherTests/DSCMaxSlidePatcherTests.swift+++ b/tests/FirmwarePatcherTests/DyldSharedCacheMaxSlidePatcherTests.swift@@ -1,4 +1,4 @@-// DSCMaxSlidePatcherTests.swift — Parity cross-checks for `DSCMaxSlidePatcher`.+// DyldSharedCacheMaxSlidePatcherTests.swift — Parity cross-checks for `DyldSharedCacheMaxSlidePatcher`.//// There is no `codesign -v` for a dyld shared cache chunk and no second// implementation of this patch anywhere. The only independent reference was@@ -14,7 +14,7 @@// `dyld_shared_cache_arm64e*` chunks, or leave the default// `ipsws/ref_extract/dsc_pristine` in place.//-// Without it they FAIL, following `DSCFoundationTests`: a `guard … else+// Without it they FAIL, following `DyldSharedCacheFoundationTests`: a `guard … else// { return }` is reported by Swift Testing as a pass, so a green run on a// machine with no fixture would be indistinguishable from a green run that// proved something. A machine that genuinely cannot carry the 5.3 GB cache sets@@ -40,7 +40,7 @@ import Testing////// The real-cache input was a clone of `ipsws/ref_extract/dsc_pristine`. The/// synthetic inputs were rebuilt byte for byte from-/// `DSCMaxSlideGateTests.writeCache`, which is why each case carries the digest+/// `DyldSharedCacheMaxSlideGateTests.writeCache`, which is why each case carries the digest/// of its input as well as of its output: a test that fed the Swift something/// else would fail on the input digest rather than quietly compare nothing.private enum FrozenReference {@@ -132,7 +132,7 @@ private enum FrozenReference {// deliberately disagree, so it has no `GateCase` above. The reference// patched it (`overflow: … set maxSlide 0x20000000 -> 0x0`, the field// reading back as 0 afterwards); the Swift refuses it, because every write- // here goes through `DSCChunkSet`, which has nothing to address such a+ // here goes through `DyldSharedCacheChunkSet`, which has nothing to address such a// file with. See `noMappingTableIsRefused`.}@@ -214,7 +214,7 @@ private enum MaxSlideFixture {}/// Clone only the chunk this patcher touches — enough for a- /// `DSCChunkSet`, and cheap enough for the gate-logic tests to make many.+ /// `DyldSharedCacheChunkSet`, and cheap enough for the gate-logic tests to make many.static func cloneMainChunk(named name: String) throws -> URL {guard let pristine else { throw CocoaError(.fileNoSuchFile) }let destination = scratchRoot.appendingPathComponent(name)@@ -327,12 +327,12 @@ private enum Bytes {}static func read(_ url: URL, offset: UInt64, length: Int) throws -> Data {- try DSCChunkSet.read(url: url, offset: offset, length: length)+ try DyldSharedCacheChunkSet.read(url: url, offset: offset, length: length)}/// The `maxSlide` field of a chunk on disk.static func maxSlide(of chunk: URL) throws -> UInt64 {- try read(chunk, offset: UInt64(DSCMaxSlidePatcher.HeaderField.maxSlide), length: 8)+ try read(chunk, offset: UInt64(DyldSharedCacheMaxSlidePatcher.HeaderField.maxSlide), length: 8).loadLE(UInt64.self, at: 0)}}@@ -340,7 +340,7 @@ private enum Bytes {// MARK: - The real cache@Suite(.serialized, .enabled(if: MaxSlideFixture.runs, MaxSlideFixture.skipReason))-struct DSCMaxSlideRealCacheTests {+struct DyldSharedCacheMaxSlideRealCacheTests {/// The gate this cache trips, stated once: 24A435's arm64e cache records a/// 0x17D504000 span and a 0x20000000 slide, which together overrun the/// kernel's 0x180000000 region by 0x1D504000.@@ -348,9 +348,9 @@ struct DSCMaxSlideRealCacheTests {func `The pristine cache is one that overflows the kernel's shared region`() throws {let pristine = try #require(MaxSlideFixture.pristine, MaxSlideFixture.missing)- let chunks = try DSCChunkSet(directory: pristine)- let headerVMA = try DSCMaxSlidePatcher.headerVMA(of: chunks)- let header = try DSCMaxSlidePatcher.readHeader(+ let chunks = try DyldSharedCacheChunkSet(directory: pristine)+ let headerVMA = try DyldSharedCacheMaxSlidePatcher.headerVMA(of: chunks)+ let header = try DyldSharedCacheMaxSlidePatcher.readHeader(from: chunks,at: headerVMA,chunkName: MaxSlideFixture.mainChunkName,@@ -359,7 +359,7 @@ struct DSCMaxSlideRealCacheTests {#expect(header.sharedRegionStart == chunks.addressRange.lowerBound)#expect(header.maxSlide != 0, "the fixture is already patched; re-extract it")#expect(- header.sharedRegionSize + header.maxSlide > DSCMaxSlidePatcher.kernelSharedRegionSize,+ header.sharedRegionSize + header.maxSlide > DyldSharedCacheMaxSlidePatcher.kernelSharedRegionSize,"this fixture does not exercise the patch: it fits the region as it stands",)// The three numbers the reference read out of this same header.@@ -384,12 +384,12 @@ struct DSCMaxSlideRealCacheTests {let swiftSide = try MaxSlideFixture.cloneCache(named: "parity_swift")defer { MaxSlideFixture.discard(swiftSide) }- let mine = try DSCMaxSlidePatcher.patch(chunksDirectory: swiftSide)+ let mine = try DyldSharedCacheMaxSlidePatcher.patch(chunksDirectory: swiftSide)#expect(mine.siteCount == 1, "the Swift did not patch the real cache")#expect(mine.didWrite)#expect(mine.outcome == .overflow(combined: mine.sharedRegionSize + mine.maxSlide,- region: DSCMaxSlidePatcher.kernelSharedRegionSize,+ region: DyldSharedCacheMaxSlidePatcher.kernelSharedRegionSize,))#expect(mine.writtenSpan?.length == 8, "one site, one u64")@@ -405,7 +405,7 @@ struct DSCMaxSlideRealCacheTests {// …and the change is the eight bytes of the field and nothing else.let pristineMain = pristine.appendingPathComponent(MaxSlideFixture.mainChunkName)- let head = DSCMaxSlidePatcher.HeaderField.maxSlide+ let head = DyldSharedCacheMaxSlidePatcher.HeaderField.maxSlidelet tailOffset = UInt64(head + 8)let tailLength = 0x100 - head - 8let main = swiftSide.appendingPathComponent(MaxSlideFixture.mainChunkName)@@ -430,17 +430,17 @@ struct DSCMaxSlideRealCacheTests {let pristineMain = pristine.appendingPathComponent(MaxSlideFixture.mainChunkName)let directory = try #require(- try DSCCodeSignature.readCodeDirectory(ofChunk: main),+ try DyldSharedCacheCodeSignature.readCodeDirectory(ofChunk: main),"the main chunk should carry a code directory",)- let before = try DSCCodeSignature.pageHashes(+ let before = try DyldSharedCacheCodeSignature.pageHashes(chunkURL: main,pageIndex: 0,directory: directory,)#expect(before.computed == before.stored, "page 0 was not attested before the patch")- let result = try DSCMaxSlidePatcher.patch(chunksDirectory: clone)+ let result = try DyldSharedCacheMaxSlidePatcher.patch(chunksDirectory: clone)#expect(result.siteCount == 1)// The blob itself: byte-identical to pristine, so no slot moved.@@ -456,7 +456,7 @@ struct DSCMaxSlideRealCacheTests {)#expect(mineBlob == pristineBlob, "the patch rewrote a code slot it must not rewrite")- let after = try DSCCodeSignature.pageHashes(+ let after = try DyldSharedCacheCodeSignature.pageHashes(chunkURL: main,pageIndex: 0,directory: directory,@@ -479,10 +479,10 @@ struct DSCMaxSlideRealCacheTests {let swiftSide = try MaxSlideFixture.cloneMainChunk(named: "dryrun_swift")defer { MaxSlideFixture.discard(swiftSide) }- let mine = try DSCMaxSlidePatcher.patch(chunksDirectory: swiftSide, dryRun: true)+ let mine = try DyldSharedCacheMaxSlidePatcher.patch(chunksDirectory: swiftSide, dryRun: true)#expect(mine.siteCount == 1, "a dry run still reports the site, as the reference did")#expect(!mine.didWrite)- #expect(mine.record?.patchID == DSCMaxSlidePatcher.patchID)+ #expect(mine.record?.patchID == DyldSharedCacheMaxSlidePatcher.patchID)#expect(mine.record?.patchedBytes == Data(count: 8))#expect(mine.record?.originalBytes.loadLE(UInt64.self, at: 0) == mine.maxSlide)#expect(mine.maxSlide == FrozenReference.realMaxSlide)@@ -504,12 +504,12 @@ struct DSCMaxSlideRealCacheTests {let swiftSide = try MaxSlideFixture.cloneMainChunk(named: "idem_swift")defer { MaxSlideFixture.discard(swiftSide) }- let first = try DSCMaxSlidePatcher.patch(chunksDirectory: swiftSide)+ let first = try DyldSharedCacheMaxSlidePatcher.patch(chunksDirectory: swiftSide)let afterFirst = try Digest.sha256(of: swiftSide.appendingPathComponent(MaxSlideFixture.mainChunkName),)- let mineAgain = try DSCMaxSlidePatcher.patch(chunksDirectory: swiftSide)+ let mineAgain = try DyldSharedCacheMaxSlidePatcher.patch(chunksDirectory: swiftSide)#expect(mineAgain.siteCount == 0)#expect(!mineAgain.didWrite)// Which gate stops the second pass is worth being precise about. Once@@ -520,14 +520,14 @@ struct DSCMaxSlideRealCacheTests {// second run printed "fits: … no change", not "maxSlide already 0".#expect(mineAgain.outcome == .fits(combined: first.sharedRegionSize,- region: DSCMaxSlidePatcher.kernelSharedRegionSize,+ region: DyldSharedCacheMaxSlidePatcher.kernelSharedRegionSize,))// `--force` skips the fits gate, so it is the one path that does reach// the already-zero check — and it still writes nothing. The reference's// third run printed "maxSlide already 0; no change" and left its file// alone, which is what the unchanged digest below has to show.- let mineForced = try DSCMaxSlidePatcher.patch(chunksDirectory: swiftSide, force: true)+ let mineForced = try DyldSharedCacheMaxSlidePatcher.patch(chunksDirectory: swiftSide, force: true)#expect(mineForced.siteCount == 0)#expect(mineForced.outcome == .alreadyZero)@@ -550,7 +550,7 @@ struct DSCMaxSlideRealCacheTests {/// the self-gate exists to protect — cannot be demonstrated with the fixture on/// hand, so it is built.@Suite(.serialized, .enabled(if: MaxSlideFixture.runs, MaxSlideFixture.skipReason))-struct DSCMaxSlideGateTests {+struct DyldSharedCacheMaxSlideGateTests {/// A minimal but *real* cache: header plus a one-entry mapping table that/// covers it. The Python's own self-test fixture has no mapping table at/// all, which the Swift refuses — see `noMappingTableIsRefused`.@@ -621,7 +621,7 @@ struct DSCMaxSlideGateTests {force: Bool = false,reference: FrozenReference.GateCase,expectedSites: Int,- expectedOutcome: DSCMaxSlidePatcher.Outcome,+ expectedOutcome: DyldSharedCacheMaxSlidePatcher.Outcome,expectedMaxSlideAfter: UInt64,) throws {let swiftSide = MaxSlideFixture.scratchRoot.appendingPathComponent("\(name)_swift")@@ -635,7 +635,7 @@ struct DSCMaxSlideGateTests {"\(name): this is not the cache the reference saw — \(inputDigest)",)- let mine = try DSCMaxSlidePatcher.patch(chunksDirectory: swiftSide, force: force)+ let mine = try DyldSharedCacheMaxSlidePatcher.patch(chunksDirectory: swiftSide, force: force)#expect(mine.siteCount == expectedSites)#expect(mine.outcome == expectedOutcome)@@ -660,7 +660,7 @@ struct DSCMaxSlideGateTests {expectedSites: 1,expectedOutcome: .overflow(combined: 0x1_9C83_0000,- region: DSCMaxSlidePatcher.kernelSharedRegionSize,+ region: DyldSharedCacheMaxSlidePatcher.kernelSharedRegionSize,),expectedMaxSlideAfter: 0,)@@ -677,7 +677,7 @@ struct DSCMaxSlideGateTests {expectedSites: 0,expectedOutcome: .fits(combined: 0x1_6090_4000,- region: DSCMaxSlidePatcher.kernelSharedRegionSize,+ region: DyldSharedCacheMaxSlidePatcher.kernelSharedRegionSize,),expectedMaxSlideAfter: 0x2000_0000,)@@ -694,7 +694,7 @@ struct DSCMaxSlideGateTests {expectedSites: 1,expectedOutcome: .forced(combined: 0x1_6090_4000,- region: DSCMaxSlidePatcher.kernelSharedRegionSize,+ region: DyldSharedCacheMaxSlidePatcher.kernelSharedRegionSize,),expectedMaxSlideAfter: 0,)@@ -744,7 +744,7 @@ struct DSCMaxSlideGateTests {defer { MaxSlideFixture.discard(empty) }#expect(throws: PatcherError.self) {- _ = try DSCMaxSlidePatcher.patch(chunksDirectory: empty, verbose: false)+ _ = try DyldSharedCacheMaxSlidePatcher.patch(chunksDirectory: empty, verbose: false)}}@@ -763,7 +763,7 @@ struct DSCMaxSlideGateTests {)#expect(throws: PatcherError.self) {- _ = try DSCMaxSlidePatcher.patch(chunksDirectory: directory, verbose: false)+ _ = try DyldSharedCacheMaxSlidePatcher.patch(chunksDirectory: directory, verbose: false)}}@@ -787,7 +787,7 @@ struct DSCMaxSlideGateTests {)#expect(throws: PatcherError.self) {- _ = try DSCMaxSlidePatcher.patch(chunksDirectory: directory, verbose: false)+ _ = try DyldSharedCacheMaxSlidePatcher.patch(chunksDirectory: directory, verbose: false)}}@@ -813,14 +813,14 @@ struct DSCMaxSlideGateTests {try handle.close()#expect(throws: PatcherError.self) {- _ = try DSCMaxSlidePatcher.patch(chunksDirectory: directory, verbose: false)+ _ = try DyldSharedCacheMaxSlidePatcher.patch(chunksDirectory: directory, verbose: false)}}/// The Python's own self-test fixture: a bare 0x100-byte header with no/// mapping table. The reference patched it — it printed `overflow: … set/// maxSlide 0x20000000 -> 0x0` and the field read back as 0. This refuses- /// it, because every write here goes through `DSCChunkSet`, which has+ /// it, because every write here goes through `DyldSharedCacheChunkSet`, which has/// nothing to address such a file with. A documented divergence, and a/// strictly safer one — the input is not a shared cache.@Test@@ -847,8 +847,8 @@ struct DSCMaxSlideGateTests {to: swiftSide.appendingPathComponent(MaxSlideFixture.mainChunkName),)- #expect(throws: DSCError.self) {- _ = try DSCMaxSlidePatcher.patch(chunksDirectory: swiftSide, verbose: false)+ #expect(throws: DyldSharedCacheError.self) {+ _ = try DyldSharedCacheMaxSlidePatcher.patch(chunksDirectory: swiftSide, verbose: false)}let untouchedSlide = try Bytes.maxSlide(of: swiftSide.appendingPathComponent(MaxSlideFixture.mainChunkName),diff --git a/tests/FirmwarePatcherTests/DSCXPCLWCRPatcherTests.swift b/tests/FirmwarePatcherTests/DyldSharedCacheXPCLWCRPatcherTests.swiftsimilarity index 85%rename from tests/FirmwarePatcherTests/DSCXPCLWCRPatcherTests.swiftrename to tests/FirmwarePatcherTests/DyldSharedCacheXPCLWCRPatcherTests.swiftindex c03ff2c2..01c09188 100644--- a/tests/FirmwarePatcherTests/DSCXPCLWCRPatcherTests.swift+++ b/tests/FirmwarePatcherTests/DyldSharedCacheXPCLWCRPatcherTests.swift@@ -1,10 +1,10 @@-// DSCXPCLWCRPatcherTests.swift — Parity for the libxpc LWCR patch.+// DyldSharedCacheXPCLWCRPatcherTests.swift — Parity for the libxpc LWCR patch.//// The only independent reference for this patch was// `scripts/patchers/cfw_patch_xpc_lwcr.py`, driven through `cfw.py// patch-xpc-lwcr`. That Python is gone, so what it produced on the real cache// is frozen in `FrozenReference` below — the three sites, the six instruction-// words, and the SHA-256 of the one chunk it changed. `DSCXPCLWCRPatcher` runs+// words, and the SHA-256 of the one chunk it changed. `DyldSharedCacheXPCLWCRPatcher` runs// on a clone and is graded against those. A port that writes the right// instruction at the wrong address, or re-attests a different page, lands on a// different digest.@@ -264,7 +264,7 @@ private enum Shell {// MARK: - Parity against the frozen reference, on the real cache@Suite(.serialized, .enabled(if: LWCRFixture.runs, LWCRFixture.skipReason))-struct DSCXPCLWCRParityTests {+struct DyldSharedCacheXPCLWCRParityTests {@Testfunc `Swift patches the reference's three sites, to the reference's bytes`() throws {_ = try #require(LWCRFixture.pristine, LWCRFixture.missing)@@ -272,7 +272,7 @@ struct DSCXPCLWCRParityTests {let swiftClone = try LWCRFixture.cloneCache(named: "swift")defer { LWCRFixture.discard(swiftClone) }- let outcome = try DSCXPCLWCRPatcher.apply(directory: swiftClone, log: nil)+ let outcome = try DyldSharedCacheXPCLWCRPatcher.apply(directory: swiftClone, log: nil)#expect(outcome.status == .patched)#expect(outcome.siteCount == 3, "swift wrote \(outcome.siteCount) sites")#expect(outcome.records.compactMap(\.virtualAddress) == FrozenReference.writtenVMAs)@@ -288,7 +288,7 @@ struct DSCXPCLWCRParityTests {let clone = try LWCRFixture.cloneCache(named: "words")defer { LWCRFixture.discard(clone) }- let outcome = try DSCXPCLWCRPatcher.apply(directory: clone, log: nil)+ let outcome = try DyldSharedCacheXPCLWCRPatcher.apply(directory: clone, log: nil)#expect(outcome.siteCount == 3)let expectedCset = try #require(ARM64Encoder.encodeCsetW(rd: 0, condition: .eq))@@ -314,7 +314,7 @@ struct DSCXPCLWCRParityTests {let clone = try LWCRFixture.cloneCache(named: "dry")defer { LWCRFixture.discard(clone) }- let outcome = try DSCXPCLWCRPatcher.apply(directory: clone, dryRun: true, log: nil)+ let outcome = try DyldSharedCacheXPCLWCRPatcher.apply(directory: clone, dryRun: true, log: nil)#expect(outcome.status == .patched)#expect(outcome.siteCount == 3)// The reference's own dry run named these three and changed no chunk.@@ -331,12 +331,12 @@ struct DSCXPCLWCRParityTests {let swiftClone = try LWCRFixture.cloneCache(named: "swift_twice")defer { LWCRFixture.discard(swiftClone) }- _ = try DSCXPCLWCRPatcher.apply(directory: swiftClone, log: nil)+ _ = try DyldSharedCacheXPCLWCRPatcher.apply(directory: swiftClone, log: nil)// Second pass. It may not raise, and it may not write — the reference// printed `already patched … nothing to patch/re-attest` here and left// its own digest standing, so the bytes must still be the frozen ones.- let outcome = try DSCXPCLWCRPatcher.apply(directory: swiftClone, log: nil)+ let outcome = try DyldSharedCacheXPCLWCRPatcher.apply(directory: swiftClone, log: nil)#expect(outcome.status == .alreadyPatched)#expect(outcome.siteCount == 0)@@ -349,13 +349,13 @@ struct DSCXPCLWCRParityTests {let clone = try LWCRFixture.cloneCache(named: "attest")defer { LWCRFixture.discard(clone) }- let chunks = try DSCChunkSet(directory: clone)- let outcome = try DSCXPCLWCRPatcher.apply(chunks: chunks, log: nil)+ let chunks = try DyldSharedCacheChunkSet(directory: clone)+ let outcome = try DyldSharedCacheXPCLWCRPatcher.apply(chunks: chunks, log: nil)#expect(outcome.siteCount == 3)// Re-attesting again must find every touched page already correct —// which is only true if the patcher's own call covered all of them.- let again = try DSCCodeSignature.reattestRecordedWrites(in: chunks, log: nil)+ let again = try DyldSharedCacheCodeSignature.reattestRecordedWrites(in: chunks, log: nil)#expect(again.updated.isEmpty, "a page was left stale: \(again.updated.count) slots")#expect(!again.alreadyAttested.isEmpty)#expect(again.skipped.isEmpty)@@ -370,8 +370,8 @@ struct DSCXPCLWCRParityTests {try FileManager.default.removeItem(at: clone.appendingPathComponent("dyld_shared_cache_arm64e.symbols"),)- #expect(throws: DSCError.self) {- try DSCXPCLWCRPatcher.apply(directory: clone, dryRun: true, log: nil)+ #expect(throws: DyldSharedCacheError.self) {+ try DyldSharedCacheXPCLWCRPatcher.apply(directory: clone, dryRun: true, log: nil)}}}@@ -379,19 +379,19 @@ struct DSCXPCLWCRParityTests {// MARK: - The two shape detectors, on real instruction streams@Suite(.serialized, .enabled(if: LWCRFixture.runs, LWCRFixture.skipReason))-struct DSCXPCLWCRShapeTests {+struct DyldSharedCacheXPCLWCRShapeTests {/// `_xpc_token_satisfies_lwcr` as it is disassembled out of a cache.private func functionStream(in directory: URL) throws -> [Instruction] {- let chunks = try DSCChunkSet(directory: directory)+ let chunks = try DyldSharedCacheChunkSet(directory: directory)var address: UInt64?- for candidate in DSCXPCLWCRPatcher.symbolCandidates {+ for candidate in DyldSharedCacheXPCLWCRPatcher.symbolCandidates {if let found = try chunks.resolveLocalSymbol(candidate) {address = foundbreak}}- let vma = try #require(address, "\(DSCXPCLWCRPatcher.symbol) is not in this cache")- return try DSCXPCLWCRPatcher.disassembleFunction(+ let vma = try #require(address, "\(DyldSharedCacheXPCLWCRPatcher.symbol) is not in this cache")+ return try DyldSharedCacheXPCLWCRPatcher.disassembleFunction(in: chunks,at: vma,disassembler: ARM64Disassembler(),@@ -401,7 +401,7 @@ struct DSCXPCLWCRShapeTests {@Testfunc `The symbol resolves under its mangled spelling, at a function prologue`() throws {let pristine = try #require(LWCRFixture.pristine, LWCRFixture.missing)- let chunks = try DSCChunkSet(directory: pristine)+ let chunks = try DyldSharedCacheChunkSet(directory: pristine)let mangledAddress = try chunks.resolveLocalSymbol("__xpc_token_satisfies_lwcr")let mangled = try #require(@@ -412,17 +412,17 @@ struct DSCXPCLWCRShapeTests {#expect(mangled == FrozenReference.functionVMA)// The single-underscore source spelling is a miss, which is why the// patcher tries both rather than only the obvious one.- let sourceSpelling = try chunks.resolveLocalSymbol(DSCXPCLWCRPatcher.symbol)+ let sourceSpelling = try chunks.resolveLocalSymbol(DyldSharedCacheXPCLWCRPatcher.symbol)#expect(sourceSpelling == nil)- let stream = try DSCXPCLWCRPatcher.disassembleFunction(+ let stream = try DyldSharedCacheXPCLWCRPatcher.disassembleFunction(in: chunks,at: mangled,disassembler: ARM64Disassembler(),)#expect(stream.first?.mnemonic == "pacibsp")#expect(stream.last?.mnemonic == "retab")- #expect(stream.count < DSCXPCLWCRPatcher.maxInstructions)+ #expect(stream.count < DyldSharedCacheXPCLWCRPatcher.maxInstructions)}@Test@@ -432,7 +432,7 @@ struct DSCXPCLWCRShapeTests {let stream = try functionStream(in: pristine)let site = try #require(- DSCXPCLWCRPatcher.findConsistencyCheck(in: stream, disassembler: disassembler),+ DyldSharedCacheXPCLWCRPatcher.findConsistencyCheck(in: stream, disassembler: disassembler),)#expect(site.cset.mnemonic == "cset")#expect(site.cset.aarch64?.conditionCode == AArch64CC_NE)@@ -449,13 +449,13 @@ struct DSCXPCLWCRShapeTests {// The xor's left operand is the matcher's return register, and its// right operand is what the cset wrote — the dataflow that makes the// match unambiguous.- #expect(DSCXPCLWCRPatcher.register(site.eor, 1, disassembler) == "w0")+ #expect(DyldSharedCacheXPCLWCRPatcher.register(site.eor, 1, disassembler) == "w0")#expect(- DSCXPCLWCRPatcher.register(site.eor, 2, disassembler)- == DSCXPCLWCRPatcher.register(site.cset, 0, disassembler),+ DyldSharedCacheXPCLWCRPatcher.register(site.eor, 2, disassembler)+ == DyldSharedCacheXPCLWCRPatcher.register(site.cset, 0, disassembler),)- #expect(DSCXPCLWCRPatcher.findPatchedShape(in: stream, disassembler: disassembler) == nil)+ #expect(DyldSharedCacheXPCLWCRPatcher.findPatchedShape(in: stream, disassembler: disassembler) == nil)}@Test@@ -465,14 +465,14 @@ struct DSCXPCLWCRShapeTests {defer { LWCRFixture.discard(clone) }let disassembler = ARM64Disassembler()- let outcome = try DSCXPCLWCRPatcher.apply(directory: clone, log: nil)+ let outcome = try DyldSharedCacheXPCLWCRPatcher.apply(directory: clone, log: nil)#expect(outcome.siteCount == 3)let stream = try functionStream(in: clone)- #expect(DSCXPCLWCRPatcher.findConsistencyCheck(in: stream, disassembler: disassembler) == nil)+ #expect(DyldSharedCacheXPCLWCRPatcher.findConsistencyCheck(in: stream, disassembler: disassembler) == nil)let already = try #require(- DSCXPCLWCRPatcher.findPatchedShape(in: stream, disassembler: disassembler),+ DyldSharedCacheXPCLWCRPatcher.findPatchedShape(in: stream, disassembler: disassembler),)#expect(already.mnemonic == "cset")#expect(already.aarch64?.conditionCode == AArch64CC_EQ)@@ -485,19 +485,19 @@ struct DSCXPCLWCRShapeTests {let disassembler = ARM64Disassembler()let stream = try functionStream(in: pristine)let site = try #require(- DSCXPCLWCRPatcher.findConsistencyCheck(in: stream, disassembler: disassembler),+ DyldSharedCacheXPCLWCRPatcher.findConsistencyCheck(in: stream, disassembler: disassembler),)let csetIndex = try #require(stream.firstIndex { $0.address == site.cset.address })// Everything before the `cset` — the prologue and the matcher call.let truncated = Array(stream[..<csetIndex])- #expect(DSCXPCLWCRPatcher.findConsistencyCheck(in: truncated, disassembler: disassembler) == nil)- #expect(DSCXPCLWCRPatcher.findPatchedShape(in: truncated, disassembler: disassembler) == nil)+ #expect(DyldSharedCacheXPCLWCRPatcher.findConsistencyCheck(in: truncated, disassembler: disassembler) == nil)+ #expect(DyldSharedCacheXPCLWCRPatcher.findPatchedShape(in: truncated, disassembler: disassembler) == nil)// And an empty stream, which is what a symbol pointing into data looks// like. Both detectors index backwards, so this is the bounds check.- #expect(DSCXPCLWCRPatcher.findConsistencyCheck(in: [], disassembler: disassembler) == nil)- #expect(DSCXPCLWCRPatcher.findPatchedShape(in: [], disassembler: disassembler) == nil)+ #expect(DyldSharedCacheXPCLWCRPatcher.findConsistencyCheck(in: [], disassembler: disassembler) == nil)+ #expect(DyldSharedCacheXPCLWCRPatcher.findPatchedShape(in: [], disassembler: disassembler) == nil)}@Test@@ -506,7 +506,7 @@ struct DSCXPCLWCRShapeTests {let disassembler = ARM64Disassembler()let stream = try functionStream(in: pristine)let site = try #require(- DSCXPCLWCRPatcher.findConsistencyCheck(in: stream, disassembler: disassembler),+ DyldSharedCacheXPCLWCRPatcher.findConsistencyCheck(in: stream, disassembler: disassembler),)let csetIndex = try #require(stream.firstIndex { $0.address == site.cset.address })@@ -516,7 +516,7 @@ struct DSCXPCLWCRShapeTests {var withoutCset = streamwithoutCset.remove(at: csetIndex)#expect(- DSCXPCLWCRPatcher.findConsistencyCheck(in: withoutCset, disassembler: disassembler) == nil,+ DyldSharedCacheXPCLWCRPatcher.findConsistencyCheck(in: withoutCset, disassembler: disassembler) == nil,)}}diff --git a/tests/FirmwarePatcherTests/FirmwarePatcherTests.swift b/tests/FirmwarePatcherTests/FirmwarePatcherTests.swiftindex 6c310715..3dc9a952 100644--- a/tests/FirmwarePatcherTests/FirmwarePatcherTests.swift+++ b/tests/FirmwarePatcherTests/FirmwarePatcherTests.swift@@ -445,7 +445,7 @@ struct IM4PPayloadParityTests {#expect(im4pPayload == rawIBSS)- let patcher = IBootJBPatcher(data: im4pPayload, mode: .ibss, verbose: false)+ let patcher = IBootJailbreakPatcher(data: im4pPayload, mode: .ibss, verbose: false)let records = try patcher.findAll()#expect(records.count == 1)}diff --git a/tests/FirmwarePatcherTests/PatchComparisonTests.swift b/tests/FirmwarePatcherTests/PatchComparisonTests.swiftindex f0ae5d43..e6442ee5 100644--- a/tests/FirmwarePatcherTests/PatchComparisonTests.swift+++ b/tests/FirmwarePatcherTests/PatchComparisonTests.swift@@ -13,7 +13,7 @@// So the suites below run when someone still has the JSON and skip when they// do not, rather than erroring on a missing file and reading as a regression.// What still guards the patchers without them is the frozen-digest work-// elsewhere in this directory — `FrozenReference` in DSCHVVMMPatcherTests and+// elsewhere in this directory — `FrozenReference` in DyldSharedCacheHVVMMPatcherTests and// the `matchesTheFrozenReference*` tests — which carry the reference values in// the source instead of in a file nobody has.@@ -211,11 +211,11 @@ struct KernelcacheComparisonTests {// MARK: - JB Tests@Suite(.enabled(if: hasReferencePatches, referenceMissing))-struct IBSSJBComparisonTests {- @Test func `compare IBSSJB`() throws {+struct IBSSJailbreakComparisonTests {+ @Test func `compare IBSSJailbreak`() throws {let data = try loadRawPayload("ibss.bin")- let patcher = IBootJBPatcher(data: data, mode: .ibss, verbose: false)- // IBootJBPatcher only adds JB-specific patches on top of base+ let patcher = IBootJailbreakPatcher(data: data, mode: .ibss, verbose: false)+ // IBootJailbreakPatcher only adds JB-specific patches on top of base// We need to run findAll() first (base patches), then add JB patchpatcher.patches = []patcher.patchSkipGenerateNonce()@@ -225,10 +225,10 @@ struct IBSSJBComparisonTests {}@Suite(.enabled(if: hasReferencePatches, referenceMissing))-struct KernelcacheJBComparisonTests {+struct KernelcacheJailbreakComparisonTests {@Test func `compare kernelcache JB`() throws {let data = try loadRawPayload("kernelcache.bin")- let patcher = KernelJBPatcher(data: data, verbose: false)+ let patcher = KernelJailbreakPatcher(data: data, verbose: false)let swiftPatches = try patcher.findAll()let refPatches = try loadReference("kernelcache_jb")comparePatchRecords(swift: swiftPatches, reference: refPatches, component: "kernelcache_jb")diff --git a/tests/FirmwarePatcherTests/VerboseJBDebug.swift b/tests/FirmwarePatcherTests/VerboseJailbreakDebug.swiftsimilarity index 92%rename from tests/FirmwarePatcherTests/VerboseJBDebug.swiftrename to tests/FirmwarePatcherTests/VerboseJailbreakDebug.swiftindex b4039bf9..b93d8353 100644--- a/tests/FirmwarePatcherTests/VerboseJBDebug.swift+++ b/tests/FirmwarePatcherTests/VerboseJailbreakDebug.swift@@ -2,7 +2,7 @@import Foundationimport Testing-struct VerboseJBDebug {+struct VerboseJailbreakDebug {@Test func `debug failing patches`() throws {let baseDir = URL(fileURLWithPath: #filePath).deletingLastPathComponent()@@ -10,7 +10,7 @@ struct VerboseJBDebug {.deletingLastPathComponent().appendingPathComponent("ipsws/patch_refactor_input")let data = try Data(contentsOf: baseDir.appendingPathComponent("raw_payloads/kernelcache.bin"))- let patcher = KernelJBPatcher(data: data, verbose: true)+ let patcher = KernelJailbreakPatcher(data: data, verbose: true)// Initialize patcher state (same as findAll() but without running patches)try patcher.parseMachO()diff --git a/tests/VPhoneArchiveTests/BundleTransferTests.swift b/tests/VPhoneArchiveTests/BundleTransferTests.swiftindex 472de401..69344cb6 100644--- a/tests/VPhoneArchiveTests/BundleTransferTests.swift+++ b/tests/VPhoneArchiveTests/BundleTransferTests.swift@@ -39,7 +39,7 @@ struct BundleTransferTests {try? FileManager.default.removeItem(at: rom)try? FileManager.default.removeItem(at: seprom)}- return try VPhoneBundleOps.create(+ return try VPhoneBundleOperations.create(.init(name: name,cpuCount: cpuCount,diff --git a/tests/VPhoneCoreTests/CreateOrchestratorTests.swift b/tests/VPhoneCoreTests/BootPatternsTests.swiftsimilarity index 95%rename from tests/VPhoneCoreTests/CreateOrchestratorTests.swiftrename to tests/VPhoneCoreTests/BootPatternsTests.swiftindex 7b3204d7..ccc1cbb1 100644--- a/tests/VPhoneCoreTests/CreateOrchestratorTests.swift+++ b/tests/VPhoneCoreTests/BootPatternsTests.swift@@ -3,9 +3,9 @@ import Testing@testable import VPhoneCore/// Tests for `VPhoneBootPatterns` — the pure, device-independent pieces of the-/// native `vm create` pipeline (`VPhoneCreateOrchestrator`, executable target).+/// native `vm create` pipeline (`VPhoneVirtualMachineCreator`, executable target)./// The orchestrator's live stages (DFU/restore/CFW/boot check) require a VM.-struct CreateOrchestratorTests {+struct BootPatternsTests {// MARK: - first-boot panic markersprivate func matches(_ pattern: String, _ line: String) throws -> Bool {diff --git a/tests/VPhoneCoreTests/BundleOpsTests.swift b/tests/VPhoneCoreTests/BundleOperationsTests.swiftsimilarity index 88%rename from tests/VPhoneCoreTests/BundleOpsTests.swiftrename to tests/VPhoneCoreTests/BundleOperationsTests.swiftindex 199cac37..4766249a 100644--- a/tests/VPhoneCoreTests/BundleOpsTests.swift+++ b/tests/VPhoneCoreTests/BundleOperationsTests.swift@@ -5,7 +5,7 @@ import Testing/// Creating, editing, renaming and cloning a bundle. Export and import moved to/// `VPhoneArchiveTests/BundleTransferTests` with the implementation, which needs/// libarchive; this half does not.-struct BundleOpsTests {+struct BundleOperationsTests {private func makeRoot() throws -> URL {let dir = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)@@ -24,7 +24,7 @@ struct BundleOpsTests {let rom = try fakeROM(); let seprom = try fakeROM()defer { try? FileManager.default.removeItem(at: rom); try? FileManager.default.removeItem(at: seprom) }- let spec = VPhoneBundleOps.NewBundleSpec(+ let spec = VPhoneBundleOperations.NewBundleConfiguration(name: "newvm",cpuCount: 8,memoryMB: 8192,@@ -32,7 +32,7 @@ struct BundleOpsTests {romSource: rom,sepromSource: seprom,)- let bundle = try VPhoneBundleOps.create(spec, in: VPhoneLibrary(root: root))+ let bundle = try VPhoneBundleOperations.create(spec, in: VPhoneLibrary(root: root))#expect(bundle.manifest.cpuCount == 8)#expect(bundle.manifest.memorySize == 8192 * 1024 * 1024)@@ -50,7 +50,7 @@ struct BundleOpsTests {defer { try? FileManager.default.removeItem(at: root) }let rom = try fakeROM(); let seprom = try fakeROM()defer { try? FileManager.default.removeItem(at: rom); try? FileManager.default.removeItem(at: seprom) }- let spec = VPhoneBundleOps.NewBundleSpec(+ let spec = VPhoneBundleOperations.NewBundleConfiguration(name: "dup",cpuCount: 2,memoryMB: 2048,@@ -58,9 +58,9 @@ struct BundleOpsTests {romSource: rom,sepromSource: seprom,)- _ = try VPhoneBundleOps.create(spec, in: VPhoneLibrary(root: root))+ _ = try VPhoneBundleOperations.create(spec, in: VPhoneLibrary(root: root))#expect(throws: VPhoneLibraryError.self) {- _ = try VPhoneBundleOps.create(spec, in: VPhoneLibrary(root: root))+ _ = try VPhoneBundleOperations.create(spec, in: VPhoneLibrary(root: root))}}@@ -72,7 +72,7 @@ struct BundleOpsTests {let lib = VPhoneLibrary(root: root)for bad in ["", "a/b", ".hidden"] {#expect(throws: VPhoneLibraryError.self) {- _ = try VPhoneBundleOps.create(+ _ = try VPhoneBundleOperations.create(.init(name: bad,cpuCount: 2,@@ -95,7 +95,7 @@ struct BundleOpsTests {let missingRom = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString + ".bin")#expect(throws: (any Error).self) {- _ = try VPhoneBundleOps.create(+ _ = try VPhoneBundleOperations.create(.init(name: "partial",cpuCount: 2,@@ -117,7 +117,7 @@ struct BundleOpsTests {let rom = try fakeROM(); let seprom = try fakeROM()defer { try? FileManager.default.removeItem(at: rom); try? FileManager.default.removeItem(at: seprom) }let lib = VPhoneLibrary(root: root)- _ = try VPhoneBundleOps.create(+ _ = try VPhoneBundleOperations.create(.init(name: "cfg",cpuCount: 8,@@ -129,7 +129,7 @@ struct BundleOpsTests {in: lib,)- let updated = try VPhoneBundleOps.updateConfig(bundleNamed: "cfg", in: lib, cpuCount: 4, memoryMB: nil)+ let updated = try VPhoneBundleOperations.updateConfig(bundleNamed: "cfg", in: lib, cpuCount: 4, memoryMB: nil)#expect(updated.manifest.cpuCount == 4)#expect(updated.manifest.memorySize == 8192 * 1024 * 1024)@@ -145,7 +145,7 @@ struct BundleOpsTests {let rom = try fakeROM(); let seprom = try fakeROM()defer { try? FileManager.default.removeItem(at: rom); try? FileManager.default.removeItem(at: seprom) }let lib = VPhoneLibrary(root: root)- _ = try VPhoneBundleOps.create(+ _ = try VPhoneBundleOperations.create(.init(name: "net",cpuCount: 8,@@ -157,7 +157,7 @@ struct BundleOpsTests {in: lib,)- let updated = try VPhoneBundleOps.updateConfig(+ let updated = try VPhoneBundleOperations.updateConfig(bundleNamed: "net",in: lib,cpuCount: nil,@@ -177,7 +177,7 @@ struct BundleOpsTests {let rom = try fakeROM(); let seprom = try fakeROM()defer { try? FileManager.default.removeItem(at: rom); try? FileManager.default.removeItem(at: seprom) }let lib = VPhoneLibrary(root: root)- _ = try VPhoneBundleOps.create(+ _ = try VPhoneBundleOperations.create(.init(name: "bad",cpuCount: 2,@@ -190,7 +190,7 @@ struct BundleOpsTests {)#expect(throws: VPhoneNetworkingError.hostOnlyUnsupported) {- _ = try VPhoneBundleOps.updateConfig(+ _ = try VPhoneBundleOperations.updateConfig(bundleNamed: "bad",in: lib,cpuCount: nil,@@ -208,7 +208,7 @@ struct BundleOpsTests {let rom = try fakeROM(); let seprom = try fakeROM()defer { try? FileManager.default.removeItem(at: rom); try? FileManager.default.removeItem(at: seprom) }let lib = VPhoneLibrary(root: root)- _ = try VPhoneBundleOps.create(+ _ = try VPhoneBundleOperations.create(.init(name: "old",cpuCount: 2,@@ -220,11 +220,11 @@ struct BundleOpsTests {in: lib,)- let renamed = try VPhoneBundleOps.rename(bundleNamed: "old", to: "shiny", in: lib)+ let renamed = try VPhoneBundleOperations.rename(bundleNamed: "old", to: "shiny", in: lib)#expect(renamed.name == "shiny")#expect(throws: VPhoneLibraryError.self) { _ = try lib.bundle(named: "old") }- try VPhoneBundleOps.delete(bundleNamed: "shiny", in: lib)+ try VPhoneBundleOperations.delete(bundleNamed: "shiny", in: lib)#expect(try lib.bundles().isEmpty)}@@ -235,7 +235,7 @@ struct BundleOpsTests {defer { try? FileManager.default.removeItem(at: rom); try? FileManager.default.removeItem(at: seprom) }let lib = VPhoneLibrary(root: root)for n in ["a", "b"] {- _ = try VPhoneBundleOps.create(+ _ = try VPhoneBundleOperations.create(.init(name: n,cpuCount: 2,@@ -248,7 +248,7 @@ struct BundleOpsTests {)}#expect(throws: VPhoneLibraryError.alreadyExists(name: "b")) {- _ = try VPhoneBundleOps.rename(bundleNamed: "a", to: "b", in: lib)+ _ = try VPhoneBundleOperations.rename(bundleNamed: "a", to: "b", in: lib)}}@@ -258,7 +258,7 @@ struct BundleOpsTests {let rom = try fakeROM(); let seprom = try fakeROM()defer { try? FileManager.default.removeItem(at: rom); try? FileManager.default.removeItem(at: seprom) }let lib = VPhoneLibrary(root: root)- let src = try VPhoneBundleOps.create(+ let src = try VPhoneBundleOperations.create(.init(name: "src",cpuCount: 8,@@ -277,7 +277,7 @@ struct BundleOpsTests {let withID = src.manifest.updating(machineIdentifier: Data([9, 9]))try withID.write(to: src.configURL)- let clone = try VPhoneBundleOps.clone(bundleNamed: "src", to: "dst", in: lib)+ let clone = try VPhoneBundleOperations.clone(bundleNamed: "src", to: "dst", in: lib)// Copy happened (disk + ROMs present in the clone).#expect(fm.fileExists(atPath: clone.url.appendingPathComponent("Disk.img").path))@@ -299,7 +299,7 @@ struct BundleOpsTests {defer { try? FileManager.default.removeItem(at: rom); try? FileManager.default.removeItem(at: seprom) }let lib = VPhoneLibrary(root: root)for n in ["a", "b"] {- _ = try VPhoneBundleOps.create(+ _ = try VPhoneBundleOperations.create(.init(name: n,cpuCount: 2,@@ -312,7 +312,7 @@ struct BundleOpsTests {)}#expect(throws: VPhoneLibraryError.alreadyExists(name: "b")) {- _ = try VPhoneBundleOps.clone(bundleNamed: "a", to: "b", in: lib)+ _ = try VPhoneBundleOperations.clone(bundleNamed: "a", to: "b", in: lib)}}}diff --git a/tests/VPhoneCoreTests/NewVMManifestTests.swift b/tests/VPhoneCoreTests/NewVirtualMachineManifestTests.swiftsimilarity index 99%rename from tests/VPhoneCoreTests/NewVMManifestTests.swiftrename to tests/VPhoneCoreTests/NewVirtualMachineManifestTests.swiftindex 056d2e8d..fdd2b6b8 100644--- a/tests/VPhoneCoreTests/NewVMManifestTests.swift+++ b/tests/VPhoneCoreTests/NewVirtualMachineManifestTests.swift@@ -13,7 +13,7 @@ import Testing/// `--cpu 4 --memory 4096 --platform-fusing dev`. What is pinned below is the/// result of that comparison, so it cannot drift once the Python is gone.@Suite("Fresh VM manifest")-struct NewVMManifestTests {+struct NewVirtualMachineManifestTests {@Testfunc `defaults match the Python's`() {let m = VPhoneVirtualMachineManifest.newVM()diff --git a/tests/VPhoneCoreTests/RestoreInfoTests.swift b/tests/VPhoneCoreTests/RestoreInfoTests.swiftindex bbd5e6d7..d95d3b38 100644--- a/tests/VPhoneCoreTests/RestoreInfoTests.swift+++ b/tests/VPhoneCoreTests/RestoreInfoTests.swift@@ -180,7 +180,7 @@ struct RestoreInfoTests {@Test func `not excluded from export`() {let name = VPhoneRestoreInfo.fileName#expect(fnmatch("*_Restore*", name, 0) != 0)- for pattern in VPhoneBundleOps.exportExcludePatterns {+ for pattern in VPhoneBundleOperations.exportExcludePatterns {#expect(fnmatch(pattern, name, 0) != 0)}}diff --git a/tests/VPhoneCoreTests/RestoreOpsTests.swift b/tests/VPhoneCoreTests/RestoreOperationsTests.swiftsimilarity index 81%rename from tests/VPhoneCoreTests/RestoreOpsTests.swiftrename to tests/VPhoneCoreTests/RestoreOperationsTests.swiftindex 76f605b2..4e624dc1 100644--- a/tests/VPhoneCoreTests/RestoreOpsTests.swift+++ b/tests/VPhoneCoreTests/RestoreOperationsTests.swift@@ -2,7 +2,7 @@ import Foundationimport Testing@testable import VPhoneCore-struct RestoreOpsTests {+struct RestoreOperationsTests {private func bundle(in root: URL) throws -> VPhoneBundle {try FileManager.default.createDirectory(at: root, withIntermediateDirectories: true)let manifest = VPhoneVirtualMachineManifest(@@ -17,7 +17,7 @@ struct RestoreOpsTests {let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)defer { try? FileManager.default.removeItem(at: root) }let b = try bundle(in: root)- #expect(VPhoneRestoreOps.resolveECID(explicit: "0xABCD", bundle: b) == "0xABCD")+ #expect(VPhoneRestoreOperations.resolveECID(explicit: "0xABCD", bundle: b) == "0xABCD")}@Test func `resolve ECID from prediction file`() throws {@@ -26,14 +26,14 @@ struct RestoreOpsTests {let b = try bundle(in: root)try "UDID=AAAA-1122334455667788\nECID=1122334455667788\n".write(to: root.appendingPathComponent("udid-prediction.txt"), atomically: true, encoding: .utf8)- #expect(VPhoneRestoreOps.resolveECID(explicit: nil, bundle: b) == "1122334455667788")+ #expect(VPhoneRestoreOperations.resolveECID(explicit: nil, bundle: b) == "1122334455667788")}@Test func `resolve ECID nil when missing`() throws {let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)defer { try? FileManager.default.removeItem(at: root) }let b = try bundle(in: root)- #expect(VPhoneRestoreOps.resolveECID(explicit: nil, bundle: b) == nil)+ #expect(VPhoneRestoreOperations.resolveECID(explicit: nil, bundle: b) == nil)}@Test func `resolve UDID from prediction file`() throws {@@ -42,14 +42,14 @@ struct RestoreOpsTests {let b = try bundle(in: root)try "UDID=AAAABBBB-1122334455667788\nECID=1122334455667788\n".write(to: root.appendingPathComponent("udid-prediction.txt"), atomically: true, encoding: .utf8)- #expect(VPhoneRestoreOps.resolveUDID(bundle: b) == "AAAABBBB-1122334455667788")+ #expect(VPhoneRestoreOperations.resolveUDID(bundle: b) == "AAAABBBB-1122334455667788")}@Test func `resolve UDID nil when missing`() throws {let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)defer { try? FileManager.default.removeItem(at: root) }let b = try bundle(in: root)- #expect(VPhoneRestoreOps.resolveUDID(bundle: b) == nil)+ #expect(VPhoneRestoreOperations.resolveUDID(bundle: b) == nil)}@Test func `is AEA encrypted detects magic`() throws {@@ -60,7 +60,7 @@ struct RestoreOpsTests {try (Data([0x41, 0x45, 0x41, 0x31]) + Data([0, 1, 2])).write(to: enc)let plain = dir.appendingPathComponent("b.dmg")try Data([0, 0, 0, 0, 9]).write(to: plain)- #expect(try VPhoneRestoreOps.isAEAEncrypted(enc) == true)- #expect(try VPhoneRestoreOps.isAEAEncrypted(plain) == false)+ #expect(try VPhoneRestoreOperations.isAEAEncrypted(enc) == true)+ #expect(try VPhoneRestoreOperations.isAEAEncrypted(plain) == false)}}diff --git a/tests/VPhoneCoreTests/VMPickerTests.swift b/tests/VPhoneCoreTests/VirtualMachinePickerTests.swiftsimilarity index 77%rename from tests/VPhoneCoreTests/VMPickerTests.swiftrename to tests/VPhoneCoreTests/VirtualMachinePickerTests.swiftindex fc42ca8d..4bf79d77 100644--- a/tests/VPhoneCoreTests/VMPickerTests.swift+++ b/tests/VPhoneCoreTests/VirtualMachinePickerTests.swift@@ -1,7 +1,7 @@import Testing@testable import VPhoneCore-struct VMPickerTests {+struct VirtualMachinePickerTests {/// A scripted stdin: pops one line per `read()` call.private func reader(_ lines: [String?]) -> () -> String? {var i = 0@@ -9,7 +9,7 @@ struct VMPickerTests {}@Test func `returns provided name unchanged`() throws {- let out = try VPhoneVMPicker.resolve(+ let out = try VPhoneVirtualMachinePicker.resolve(provided: "myvm",names: ["a", "b"],libraryRoot: "/r",@@ -21,8 +21,8 @@ struct VMPickerTests {}@Test func `non interactive without name throws`() {- #expect(throws: VPhoneVMPickerError.notInteractive) {- _ = try VPhoneVMPicker.resolve(+ #expect(throws: VPhoneVirtualMachinePickerError.notInteractive) {+ _ = try VPhoneVirtualMachinePicker.resolve(provided: nil,names: ["a"],libraryRoot: "/r",@@ -34,8 +34,8 @@ struct VMPickerTests {}@Test func `empty library throws`() {- #expect(throws: VPhoneVMPickerError.emptyLibrary(root: "/r")) {- _ = try VPhoneVMPicker.resolve(+ #expect(throws: VPhoneVirtualMachinePickerError.emptyLibrary(root: "/r")) {+ _ = try VPhoneVirtualMachinePicker.resolve(provided: nil,names: [],libraryRoot: "/r",@@ -47,7 +47,7 @@ struct VMPickerTests {}@Test func `selects by index`() throws {- let out = try VPhoneVMPicker.resolve(+ let out = try VPhoneVirtualMachinePicker.resolve(provided: nil,names: ["alpha", "beta", "gamma"],libraryRoot: "/r",@@ -59,7 +59,7 @@ struct VMPickerTests {}@Test func `selects by exact name`() throws {- let out = try VPhoneVMPicker.resolve(+ let out = try VPhoneVirtualMachinePicker.resolve(provided: nil,names: ["alpha", "beta"],libraryRoot: "/r",@@ -72,7 +72,7 @@ struct VMPickerTests {@Test func `retries then succeeds`() throws {// blank, out-of-range, bad-name, then a good index.- let out = try VPhoneVMPicker.resolve(+ let out = try VPhoneVirtualMachinePicker.resolve(provided: nil,names: ["alpha", "beta"],libraryRoot: "/r",@@ -84,8 +84,8 @@ struct VMPickerTests {}@Test func `eof aborts`() {- #expect(throws: VPhoneVMPickerError.aborted) {- _ = try VPhoneVMPicker.resolve(+ #expect(throws: VPhoneVirtualMachinePickerError.aborted) {+ _ = try VPhoneVirtualMachinePicker.resolve(provided: nil,names: ["alpha"],libraryRoot: "/r",@@ -97,8 +97,8 @@ struct VMPickerTests {}@Test func `too many invalid throws`() {- #expect(throws: VPhoneVMPickerError.invalidSelection) {- _ = try VPhoneVMPicker.resolve(+ #expect(throws: VPhoneVirtualMachinePickerError.invalidSelection) {+ _ = try VPhoneVirtualMachinePicker.resolve(provided: nil,names: ["alpha"],libraryRoot: "/r",diff --git a/tests/VPhoneRestoreTests/RestoreRunnerTests.swift b/tests/VPhoneRestoreTests/RestoreRunnerTests.swiftindex 30336836..1afd4121 100644--- a/tests/VPhoneRestoreTests/RestoreRunnerTests.swift+++ b/tests/VPhoneRestoreTests/RestoreRunnerTests.swift@@ -137,11 +137,11 @@ struct RestoreRunnerTests {// MARK: - The facade@Test func `fetching ASHSH stops at the missing restore tree`() throws {- // `VPhoneRestoreBridge` finds the restore tree BEFORE it starts a run,+ // `VPhoneRestoreService` finds the restore tree BEFORE it starts a run,// so an empty bundle never reaches idevicerestore at all.try withTemporaryDirectory { root in#expect(throws: VPhoneRestoreBackendError.noRestoreDirectory(root)) {- try VPhoneRestoreBridge.fetchSHSH(vmDir: root, ecid: nil, udid: nil, out: nil)+ try VPhoneRestoreService.fetchSHSH(vmDir: root, ecid: nil, udid: nil, out: nil)}}}@@ -149,7 +149,7 @@ struct RestoreRunnerTests {@Test func `restoring stops at the missing restore tree`() throws {try withTemporaryDirectory { root in#expect(throws: VPhoneRestoreBackendError.noRestoreDirectory(root)) {- try VPhoneRestoreBridge.restore(+ try VPhoneRestoreService.restore(vmDir: root,ecid: nil,udid: nil,@@ -172,7 +172,7 @@ struct RestoreRunnerTests {let collector = Collector()#expect(throws: VPhoneRestoreBackendError.ticketUnreadable(ticket)) {- try VPhoneRestoreBridge.restore(+ try VPhoneRestoreService.restore(vmDir: root,ecid: 0x0000_0001_1A2B_3C4D,udid: nil,