Run a virtual iPhone on an Apple Silicon Mac.
Swift
userland: Add DSC hv_vmm_present byte-5 mangle with sign-in blacklist and slot reattest (EXP only)
zqxwceaf90c9a903e6
diff --git a/research/0_binary_patch_comparison.md b/research/0_binary_patch_comparison.mdindex 08d6d5b6..65d3ac6d 100644--- a/research/0_binary_patch_comparison.md+++ b/research/0_binary_patch_comparison.md@@ -1,4 +1,30 @@-# Patch Comparison: Regular / Development / Jailbreak+# Patch Comparison: Regular / Development / Jailbreak / Experimental++> **EXP is a JB superset.** Everything in the baseline tables below that is `Y`+> for JB is also `Y` for EXP. The columns are kept at three variants to avoid+> noise — the only place EXP and JB diverge is the **Experimental additions**+> below, all of which are EXP-only (JB and the other variants are deliberately+> unaffected). The EXP-only items, taken together:+>+> - **Kernel** — `KernelEXPPatcher` runs the `hv_vmm_present` sysctl OID rename+> plus kernel-internal caller cstring/sandbox-profile-token mangle (formerly+> wired into JB Group B as JB-26 — moved out).+> - **DeviceTree at fw_patch time** — 8 identity-rewrite property patches+> (Tier 1b + 1c) flipping userland-visible identity surfaces toward+> D47AP / iPhone17,3.+> - **DSC user-mode** — byte-5 cstring mangle of `kern.hv_vmm_present` with a+> sign-in blacklist + per-page slot re-attestation (`cfw_patch_hv_vmm_dsc.py`),+> companion to the kernel rename.+> - **watchdogd (EXP-JB-3.5)** — surgical 2-instruction patch + slot re-attest;+> forces the cached "am I a VM?" byte to `1` so watchdogd's clean-exit branch+> runs.+> - **Post-restore DT rewrite (EXP-JB-6)** — host-side rewrite of `devicetree.img4`+> on the ramdisk's mounted rootfs for the three restore-fatal identity+> properties (root `model`, `target-type`, `compatible[0]`) that broke+> restore when applied at fw_patch time.+> - **SystemVersion.plist `ProductBuildVersion` (EXP-JB-7, opt-in)** — gated on+> `SPOOF_BUILD=<id>`. Rewrites the build identifier in the rootfs and+> cryptex copies of `SystemVersion.plist`.## Boot Chain Patches@@ -103,6 +129,16 @@| JB-24 | B | `patch_vm_fault_enter_prepare` | `_vm_fault_enter_prepare` | Force `cs_bypass` fast path in runtime fault validation | Y || JB-25 | B | `patch_vm_map_protect` | `_vm_map_protect` | Skip upstream write-downgrade gate in `vm_map_protect` | Y |+### EXP-Only Kernel Methods (Reference List)++Runs in `KernelEXPPatcher.findAll()` (chained after `KernelPatcher` ++`KernelJBPatcher` for the `.exp` variant only — JB and other variants+do NOT execute these).++| # | Group | Method | Function | Purpose | EXP Enabled |+| ------ | ----- | --------------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------: |+| EXP-01 | B | `patch_hv_vmm_rename` | sysctl OID name cstring `"hv_vmm_present"` → `"Xv_vmm_present"` (Part A) + every kernel-internal occurrence of `kern.hv_vmm_present` cstring/sandbox-profile token mangled at byte 5 (Part B) | Rename the `kern.hv_vmm_present` OID's name in place (`'h' → 'X'` at offset 0 of the 14-byte cstring). After this: `sysctlbyname("kern.hv_vmm_present")` returns ENOENT; `sysctlbyname("kern.Xv_vmm_present")` returns the original int value (1). Part B mangles every kernel-internal caller — AMFI, IOCryptoAcceleratorFamily, sandbox-profile token, apfs — so they keep hitting the renamed OID. Companion to the user-mode blacklist-flip mangle in `cfw_patch_hv_vmm_dsc.py`. | Y |+## CFW Installation Patches### Binary Patches Applied Over SSH Ramdisk@@ -115,6 +151,8 @@| 4 | Plist injection | `launchd.plist` | bash/dropbear/trollvnc/vphoned daemons | Y | Y | Y || 5 | `b` (skip jetsam guard) | `launchd` | Prevent jetsam panic on boot | - | Y | Y || 6 | `LC_LOAD_DYLIB` injection | `launchd` | Load short alias `/b` (copy of `launchdhook.dylib`) at launch | - | - | Y |+| 7 | cstring byte 5 mangle `'h' → 'X'` (`"kern.hv_vmm_present"` → `"kern.Xv_vmm_present"`) + per-page slot-hash re-attestation, BLACKLIST semantics — **EXP only** | DSC dylibs | Companion to EXP kernel rename (`KernelEXPPatcher.patchHvVmmRename`). The mangle is applied to every DSC dylib EXCEPT those in `DONT_PATCH_INSTALL_NAMES` (sign-in / device-likeness consumers, ~15 entries). Patched dylibs query `kern.Xv_vmm_present` and get the truthful 1 (graphics / accel passthrough). Blacklisted dylibs keep the original cstring, hit ENOENT on the renamed kernel, cache 0, lie about VM presence. On `codeSigningMonitor == 2` hardware the byte-mangle alone causes `CODESIGNING/Invalid Page` SIGKILL because TXM enforces per-page hashes; the re-attestation pass recomputes the SHA-256 slot in the chunk's `CS_CodeDirectory` for every modified 16 KiB page. See `scripts/patchers/cfw_dsc_codesign.py` and `cfw_patch_hv_vmm_dsc.py`. | - | - | - |+| 8 | (removed — was: standalone-binary mangle in 6 rootfs Mach-Os via SSH) | n/a | Removed in the blacklist-flip redesign. With the EXP kernel rename in place, the 6 rootfs binaries (MobileActivationMigrator, CheckerBoard, StoreKitUISceneService, storekitd, appstored, CorePrescriptionService) get the desired "cache 0 / not in a VM" behavior for free: they keep their original cstring, hit ENOENT on the renamed kernel sysctl, defensive `cbnz w0, skip` leaves the cached byte at BSS-zero. No SSH-time standalone patch needed. | - | - | - |### Installed Components@@ -130,47 +168,385 @@| 8 | BaseBin hooks | `systemhook.dylib` / `launchdhook.dylib` / `libellekit.dylib` -> `/cores/` plus `/b` alias for `launchdhook.dylib` | - | - | Y || 9 | `TweakLoader.dylib` | Lean user-tweak loader built from source and installed to `/var/jb/usr/lib/TweakLoader.dylib` | - | - | Y |+### `kern.hv_vmm_present` user-mode patcher (EXP only)++Companion to the EXP kernel patcher (`KernelEXPPatcher.patchHvVmmRename`).+Mangles byte 5 of every `kern.hv_vmm_present` cstring inside DSC dylibs+EXCEPT those in `DONT_PATCH_INSTALL_NAMES` (sign-in / device-likeness+consumers, ~15 entries). Patched dylibs query the renamed OID and get the+truthful 1 (graphics + accel passthrough); blacklisted dylibs keep the+original cstring, hit ENOENT on the renamed kernel, and defensively cache 0+("not running on a VM") for sign-in / device-attestation surfaces.+Source-of-truth research: `research/hv_vmm_present_usermode_xrefs.md`.++JB and other variants are NOT affected by this patcher.++**Patch shape (every site)** — cstring mangle:++```+Before (cstring section bytes, 20 bytes total):+ "kern.hv_vmm_present\0"+ 6B 65 72 6E 2E 68 76 5F 76 6D 6D 5F 70 72 65 73 65 6E 74 00++After (1 byte change at offset 0):+ "Xern.hv_vmm_present\0"+ 58 65 72 6E 2E 68 76 5F 76 6D 6D 5F 70 72 65 73 65 6E 74 00+ ^^+```++The kernel's name-to-MIB translation fails with `ENOENT` when the+caller asks for `"Xern.hv_vmm_present"`, so `sysctlbyname` returns+-1. The canonical post-call check (`cbnz w0, skip` or+`cmp w0,#0 ; b.ne skip`) then takes the skip-cache path; the cached+"is_vmm" byte stays at its initial value (BSS-zero = 0).++We don't modify executable code at all — only one byte of read-only+string data. The kernel call still happens (with the wrong name), so+any sysctl-tracing infrastructure can still see activity.++Idempotent: a re-scan for the literal `"kern.hv_vmm_present\0"` finds+no occurrences in already-mangled dylibs, so the patcher does no work+on a re-run.++**DSC-side patches** — driven by an explicit whitelist+(`PATCH_INSTALL_NAMES` in `scripts/patchers/cfw_patch_hv_vmm_dsc.py`)+applied to chunks under+`SystemOS/System/Library/Caches/com.apple.dyld/`. Comment a line in+the whitelist to skip that dylib on the next install — useful for+bisecting which consumer is responsible for an observable change.++| Dylib | Component role (paraphrased) |+| --------------------------------------------------------- | ------------------------------------------------------------- |+| `usr/lib/libMobileGestalt.dylib` | Backs `MGCopyAnswer("hv-vmm-present")` — highest fan-in |+| `PrivateFrameworks/AAAFoundation.framework/AAAFoundation` | Apple ID anti-abuse plumbing |+| `PrivateFrameworks/AuthKit.framework/AuthKit` | Sign-in-with-Apple-ID / iCloud auth |+| `PrivateFrameworks/IDSFoundation.framework/IDSFoundation` | Apple Identity Service core (iMessage / FaceTime backbone) |+| `PrivateFrameworks/DeviceIdentity.framework/DeviceIdentity` | Device-binding / device class identity |+| `PrivateFrameworks/DeviceCheckInternal.framework/...` | DeviceCheck attestation |+| `PrivateFrameworks/MobileActivation.framework/...` | Activation flow |+| `PrivateFrameworks/ApplePushService.framework/...` | APNS client (claims device characteristics on connect) |+| `PrivateFrameworks/AppStoreUtilities.framework/...` | Store / IAP support |+| `PrivateFrameworks/CorePrescription.framework/...` | Health prescription store sync gate |+| `PrivateFrameworks/CoreCDP.framework/CoreCDP` | CDP (cloud key-vault / iCloud Drive plumbing) |+| `PrivateFrameworks/EmailFoundation.framework/...` | Mail account heuristics |+| `PrivateFrameworks/PhotoFoundation.framework/...` | Photos asset visibility heuristics |+| `PrivateFrameworks/FindMyBase.framework/FindMyBase` | Find My anti-spoof |+| `PrivateFrameworks/AirPlaySupport.framework/...` | AirPlay receiver gate |+| `PrivateFrameworks/TrialServer.framework/TrialServer` | A/B / trial-rollout exclude-VM gate |+| `PrivateFrameworks/VisionKitCore.framework/VisionKitCore` | VisionKit |+| `PrivateFrameworks/DVTInstrumentsUtilities.framework/...` | Xcode Instruments support |+| `PrivateFrameworks/WatchdogServiceManagement.framework/...` | Watchdog manager |+| `Frameworks/CoreVideo.framework/CoreVideo` | CoreVideo pipeline |++**Standalone-binary patches (6 files, applied to the device rootfs+over SSH)**++| Path | Role |+| ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |+| `/System/Library/DataClassMigrators/MobileActivationMigrator.migrator/MobileActivationMigrator` | Activation migration helper |+| `/Applications/CheckerBoard.app/CheckerBoard` | Apple internal accessibility test app |+| `/Applications/StoreKitUISceneService.app/StoreKitUISceneService` | StoreKit UI host |+| `/System/Library/Frameworks/StoreKit.framework/Support/storekitd` | StoreKit / IAP daemon |+| `/System/Library/PrivateFrameworks/AppStoreDaemon.framework/Support/appstored` | App Store daemon |+| `/System/Library/PrivateFrameworks/CorePrescription.framework/XPCServices/CorePrescriptionService.xpc/CorePrescriptionService` | CorePrescription XPC service |++**Explicitly NOT patched (compute / accel — patching here turns off+VM fast-paths that exist so the lib doesn't try to touch real silicon+ANE / AGX / hardware codecs):**++```+System/Library/Frameworks/CoreML.framework/CoreML+System/Library/PrivateFrameworks/Espresso.framework/Espresso+System/Library/PrivateFrameworks/AppleNeuralEngine.framework/AppleNeuralEngine+System/Library/PrivateFrameworks/CoreRE.framework/CoreRE+System/Library/PrivateFrameworks/RenderBox.framework/RenderBox+System/Library/PrivateFrameworks/WebGPU.framework/WebGPU+System/Library/PrivateFrameworks/caulk.framework/caulk+System/Library/PrivateFrameworks/IOSurfaceAccelerator.framework/IOSurfaceAccelerator+System/Library/ExtensionKit/Extensions/HostInferenceProviderService.appex/HostInferenceProviderService+```++**Wiring**++* `scripts/patchers/cfw_patch_hv_vmm.py` — standalone cstring patcher+ (used for the on-device files): finds the `"kern.hv_vmm_present\0"`+ cstring in the Mach-O's __cstring section and rewrites its first+ byte (`'k'` → `'X'`).+* `scripts/patchers/cfw_dsc_chunks.py` — chunked-DSC byte-level helper+ (`DSCChunks(chunks_dir)`): vmaddr↔chunk-fileoff mapping, cstring+ scan over executable mappings, byte read/write at a vmaddr, and+ Mach-O header walk-back to resolve a vmaddr to the dylib install+ name (LC_ID_DYLIB).+* `scripts/patchers/cfw_patch_hv_vmm_dsc.py` — DSC-native orchestrator.+ No external `ipsw` dependency. For every `"kern.hv_vmm_present\0"`+ occurrence in any executable mapping, walks back to the containing+ dylib's Mach-O header, reads `LC_ID_DYLIB`, and — if the install+ name is in the explicit `PATCH_INSTALL_NAMES` whitelist — rewrites+ the first byte of the cstring through `DSCChunks.write_at_vma`.+ Pure Python. Whitelist-based by design so an operator can comment+ out individual entries to bisect.+* `scripts/patchers/cfw.py patch-hv-vmm <binary>` —+ standalone-Mach-O subcommand (used for the 6 on-device files).+* `scripts/patchers/cfw.py patch-hv-vmm-dsc <chunks_dir>` —+ DSC subcommand (used while the SystemOS Cryptex DMG is still+ mounted on the host, before the device copy).+* `scripts/patch_hv_vmm_userland.sh` — thin wrapper used by the+ install scripts.+* `scripts/cfw_install_exp.sh` — EXP install script. Pre-step before+ invoking `cfw_install.sh`: decrypts the SysOS Cryptex into the cache+ location `cfw_install.sh` already uses, mounts it, applies the+ DSC patch, unmounts. The unmodified `cfw_install.sh` then sees the+ cached (already-patched) DMG. Standalone watchdogd is patched later+ via SSH at step `[EXP-JB-3.5]`.+* `scripts/cfw_install_jb.sh` and `scripts/cfw_install_dev.sh` —+ unchanged from pre-experimental baseline. Neither runs the DSC+ patcher.++### `kern.hv_vmm_present` kernel patcher — Part A + Part B (EXP only)++The `KernelEXPPatchHvVmmRename` Swift patcher (in `KernelEXPPatcher.findAll()`,+chained after `KernelPatcher` and `KernelJBPatcher` for the `.exp` variant only)+renames the sysctl OID and rewrites every kernel-internal occurrence of the+old name so kexts continue to find it under the new name. Two parts. JB and+other variants do NOT run this patcher.++**Part A — OID name rename.** Finds the OID's `oid_name` cstring as+the NUL-delimited bytes `\0hv_vmm_present\0` (exactly one match+required in the kernelcache; on iPhone17,3 / iOS 26.1 this lives at+file offset `0x964e0` inside `com.apple.kernel`). Flips byte 0 of the+cstring `'h'` (0x68) → `'X'` (0x58). After the patch, the kernel's+`sysctl_register_oid` keeps the OID's MIB and value (1) intact but+the name resolver returns `ENOENT` for `kern.hv_vmm_present` and+returns 1 for `kern.Xv_vmm_present`.++**Part B — kernel-internal caller mangle.** After Part A, any+kernel-side `sysctlbyname("kern.hv_vmm_present", …)` call gets+ENOENT and falls into the caller's "not in a VM" branch — which on+the bring-up build caused AMFI to panic with `AMFI: No PMGR?+(ConfigurationSettings.cpp:388)` during ramdisk boot. Part B mangles+every kernel-internal occurrence of the `kern.hv_vmm_present` name+so callers continue to find the renamed OID. The mangle flips byte+5 of the inner cstring (`'h'` after `kern.`) → `'X'`, producing+`kern.Xv_vmm_present`.++Two byte-aligned forms are searched, both anchored at the+`kern.hv_vmm_present` substring:++| Form | Needle | Where it lives | Mangle delta within needle |+|------|--------|----------------|----------------------------|+| (i) NUL-delimited cstring | `\0kern.hv_vmm_present\0` | `__TEXT,__cstring` of any kext that calls sysctlbyname by full name | +6 (skip leading NUL + 5) |+| (ii) Sandbox-profile name token | `kern.hv_vmm_present\x0f` | Inside a compiled sandbox-profile blob within `com.apple.security.sandbox`. The `\x0f` byte is the sandbox-profile end-of-name marker; the token has no leading NUL. | +5 |++On iPhone17,3 / iOS 26.1 / 23B85 the universe is 5 occurrences+(verified by raw substring scan over the kernelcache buffer):++| File offset | Fileset entry | Form |+|-------------|---------------|------|+| `0x541d56` | `com.apple.driver.AppleMobileFileIntegrity` | (i) cstring |+| `0x81bdc3` | `com.apple.iokit.IOCryptoAcceleratorFamily` | (i) cstring |+| `0xa6618b` | `com.apple.security.sandbox` | (ii) sandbox-profile name token |+| `0xbb0d55` | `com.apple.security.sandbox` | (i) cstring |+| `0xbce1f9` | `com.apple.filesystems.apfs` | (i) cstring |++Part B emits one patch record per match (5 total, plus Part A's 1)+under patch IDs `kernelcache_exp.hv_vmm_internal_caller_mangle` and+`kernelcache_exp.hv_vmm_oid_rename`. Idempotent: a re-run detects+already-mangled bytes (`kern.Xv_vmm_present` instead of+`kern.hv_vmm_present`) and reports the patch as already applied.++**Note on the sandbox-profile occurrence.** This was missed by the+original Part B because its needle required NUL on both sides. The+sandbox-profile blob stores OID names as TLV-framed tokens where the+trailing byte is `\x0f` (sandbox EOT) rather than a NUL. Without the+second needle, sandboxed callers that interpret the profile's+`kern.hv_vmm_present`-matching rule would still match against the+OLD name, while the OID itself has been renamed — so the rule's+ALLOW/DENY/audit action would never fire. With the second needle,+the rule's name token is rewritten to `kern.Xv_vmm_present` and+sandboxed callers that hit the renamed OID match the (rewritten)+rule as intended. Covered occurrence verified on+iPhone17,3 / iOS 26.1 / 23B85 at file offset `0xa6618b`.++### `watchdogd` surgical hv_vmm_present cache patch (EXP only)++**Why a dedicated patch.** After the EXP kernel-side OID rename+(`KernelEXPPatchHvVmmRename`), `sysctlbyname("kern.hv_vmm_present", ...)`+returns `ENOENT` on this image. `/usr/libexec/watchdogd` caches that+answer at startup. On `ENOENT` the cached byte stays at its BSS-zero+default (`0`) and the downstream `cbz w0, ...` at the IOWatchdog-lookup+site (`+0x58e0`) takes a branch into a `_os_crash` wrapper that does+`brk #1`. launchd's `_PanicOnCrash → PanicOnConsecutiveCrash = true`+flag in `com.apple.watchdogd.plist` escalates the SIGTRAP to a kernel+panic. The cstring-mangle approach used elsewhere doesn't apply here+because we want this binary to behave as if the sysctl returned `1`,+not as if it returned `ENOENT`.++**Patch shape.** Two-instruction surgical edit at every site in+watchdogd that has the canonical caching shape:++```+adrp x0, <page>+add x0, x0, #<off> ; "kern.hv_vmm_present"+...arg setup...+bl _sysctlbyname+cbnz w0, <skip> ; <-- patched: NOP+ldur w8, [x29, #-4]+cmp w8, #0+cset wN, ne ; <-- patched: mov wN, #1+adrp xM, <page>+strb wN, [xM, #<imm>] ; cached "am I a VM?" byte+```++Net effect: the cached byte is forced to `1` regardless of the sysctl+result, and watchdogd's pre-existing "detected virtual machine+environment, exiting..." clean-exit branch runs instead of the trap+path. Two functions in watchdogd match this shape on+`iPhone17,3 / iOS 26.1`; both are patched.++**Code signing.** The byte edit invalidates the SHA-256 slot hashes+for the 4 KiB pages containing the modifications in watchdogd's own+`CS_CodeDirectory`. The patcher recomputes those slot hashes in place+via `cfw_macho_codesign.reattest_modified_offsets` (4 KiB page size+read from the CD, correct tail-slot length, all present CDs). The+resulting CD mutation also changes the cdHash, but the existing JB+kernel patch `patch_amfi_cdhash_in_trustcache` accepts any cdHash, so+AMFI's trust-cache check still passes at execve. The patcher does NOT+re-sign with `ldid` — preserving the original Apple-issued code-signing+identifier (`com.apple.watchdogd`) is required for launchd's boot-task+identity validation; an earlier attempt to re-sign other rootfs+binaries with `ldid_sign` tripped this check on `mobile_obliterator`.++**Wiring.**++* `scripts/patchers/cfw_macho_codesign.py` — standalone-Mach-O+ page-hash re-attestation (parallel to `cfw_dsc_codesign.py` but+ parses `LC_CODE_SIGNATURE` directly, uses page size from the CD+ header, handles short tail slot, updates every present CD).+* `scripts/patchers/cfw_patch_watchdogd.py` — capstone-anchored+ pattern matcher + Keystone-assembled 2-insn patch + slot reattest.+ Idempotent.+* `scripts/patchers/cfw.py patch-watchdogd <binary>` — CLI subcommand.+* `scripts/patch_hv_vmm_userland.sh watchdogd <binary>` — thin shim+ used by the install script.+* `scripts/cfw_install_exp.sh` — invokes the patcher at step `[EXP-JB-3.5]`+ on the live `/mnt1/usr/libexec/watchdogd` (scp-down, patch, scp-up,+ chmod 0755). JB and DEV install scripts do NOT run this step.++### DeviceTree identity properties at fw_patch time (EXP only)++`DeviceTreePatcher` carries two property-patch lists: `basePropertyPatches`+(4 entries — `serial-number`, `home-button-type`, `artwork-device-subtype`,+`island-notch-location`) applied for every variant, and+`identityPropertyPatches` (8 entries) applied **only when `includeIdentityPatches`+is true**, which `FirmwarePipeline` sets exactly when `variant == .exp`.++The 8 EXP-only identity properties (no restore-fatal ones — those go through+EXP-JB-6 post-restore):++| # | Node path | Property | Old → New | Risk |+|---|----------------------------------------------------|-----------------------|-------------------------------|---------|+| 1 | `device-tree` | `target-sub-type` | `VPHONE600AP` → `D47AP` | HIGHER |+| 2 | `device-tree` | `compatible[1]` | `iPhone99,11` → `iPhone17,3` (slot-preserving) | LOW |+| 3 | `device-tree/product` | `fdr-product-type` | `iPhone99,11` → `iPhone17,3` | HIGHER |+| 4 | `device-tree/product` | `sub-product-type` | `iPhone99,11` → `iPhone17,3` | LOW |+| 5 | `device-tree/product` | `unique-model` | `VPHONE600AP` → `D47AP` | LOW |+| 6 | `device-tree/arm-io` | `device_type` | `vresearch1-io` → `t8140-io` | MEDIUM |+| 7 | `device-tree/arm-io` | `soc-generation` | `VResearch1` → `H17` | MEDIUM-LOW |+| 8 | `device-tree/product/vphone600-gestalt-variants` | `name` (node rename) | `vphone600-gestalt-variants` → `d47-gestalt-variants` | LOW-MEDIUM |++Root `model` and root `target-type` are deliberately NOT in this list —+both have been empirically shown to break restore. Those edits run+post-restore as EXP-JB-6.++### Post-restore DT identity rewrite (EXP-JB-6, EXP only)++After the restore daemon's BuildManifest identity check has passed,+`cfw_install_exp.sh` step `[EXP-JB-6]` scp's `devicetree.img4` down from the+mounted rootfs (`/mnt5/<boot-hash>/usr/standalone/firmware/`), runs+`scripts/patchers/cfw_patch_post_restore_dt.py`, and scp's the rewritten+img4 back. The Python patcher unwraps the IM4P via `pyimg4`, parses the+DT flat-binary, rewrites three restore-fatal root properties, and repacks+preserving the IMG4's original IM4M ticket. The iBSS/iBEC/LLB+`image4_validate_property_callback` bypass (existing JB patch) accepts+the modified payload at next boot.++| # | Property | Old → New |+|---|------------------|------------------------------------------------------------------------|+| 1 | root `model` | `iPhone99,11` → `iPhone17,3` |+| 2 | root `target-type` | `VPHONE600` → `D47` |+| 3 | root `compatible` | reorder `["VPHONE600AP", "iPhone99,11", "AVP-ARM"]` → `["D47AP", "VPHONE600AP", "AVP-ARM"]` (keeps `VPHONE600AP` in second slot so IOKit's `AppleVMApple1IO` kext binding still resolves; userland reads only the first entry for `hw.model`) |++Idempotent. Skipped if already-rewritten DT is detected.++### SystemVersion.plist `ProductBuildVersion` rewrite (EXP-JB-7, EXP only, opt-in)++Gated on the `SPOOF_BUILD` env var. When `cfw_install_exp.sh` is invoked+with e.g. `SPOOF_BUILD=23F77`, step `[EXP-JB-7]` runs+`scripts/patchers/cfw_patch_build_version.py` (plistlib-based,+format-preserving) on both the rootfs and cryptex copies of+`SystemVersion.plist` to rewrite the `ProductBuildVersion` key to the+specified id. Without `SPOOF_BUILD`, the step is skipped and the build+version stays at the original IPSW value.++| File | Touched if `SPOOF_BUILD=<id>` |+|-----------------------------------------------------------------------------------|:------------------------------:|+| `/mnt1/System/Library/CoreServices/SystemVersion.plist` (rootfs) | Y |+| `/mnt5/Cryptexes/OS/System/Library/CoreServices/SystemVersion.plist` (cryptex) | Y |++`kern.osversion` is unaffected — that comes from a kernel global+initialized from boot args, not from this plist. Userland MG cache+picks up the new build identifier on first boot after the gestalt+cache rebuild.+### CFW Installer Flow Matrix (Script-Level)-| Flow Item | Regular (`cfw_install.sh`) | Dev (`cfw_install_dev.sh`) | JB (`cfw_install_jb.sh`) |-| --------------------------------------------- | ------------------------------- | -------------------------- | --------------------------------------------- |-| Base CFW phases (1/7 -> 7/7) | Runs directly | Runs directly | Runs via `CFW_SKIP_HALT=1 zsh cfw_install.sh` |-| Dev overlay (`rpcserver_ios` replacement) | - | Y (`apply_dev_overlay`) | - |-| SSH readiness wait before install | Y (`wait_for_device_ssh_ready`) | - | Y (inherited from base run) |-| launchd jetsam patch (`patch-launchd-jetsam`) | - | Y (base-flow injection) | Y (JB-1) |-| launchd dylib injection (`inject-dylib /b`) | - | - | Y (JB-1) |--| Procursus bootstrap deployment | - | - | Y (JB-2) |-| BaseBin hook deployment (`*.dylib` -> `/mnt1/cores`) | - | - | Y (JB-3) |-| First-boot JB finalization (`vphone_jb_setup.sh`) | - | - | Y (post-boot; now fails before done marker if TrollStore Lite install does not complete) |-| Additional input resources | `cfw_input` | `cfw_input` + `resources/cfw_dev/rpcserver_ios` | `cfw_input` + `cfw_jb_input` |-| Extra tool requirement beyond base | - | - | `zstd` |-| Halt behavior | Halts unless `CFW_SKIP_HALT=1` | Halts unless `CFW_SKIP_HALT=1` | Always halts after JB phases |+| Flow Item | Regular (`cfw_install.sh`) | Dev (`cfw_install_dev.sh`) | JB (`cfw_install_jb.sh`) | EXP (`cfw_install_exp.sh`) |+| --------------------------------------------- | ------------------------------- | -------------------------- | --------------------------------------------- | ----------------------------------------------------- |+| Base CFW phases (1/7 -> 7/7) | Runs directly | Runs directly | Runs via `CFW_SKIP_HALT=1 zsh cfw_install.sh` | Runs via `CFW_SKIP_HALT=1 zsh cfw_install.sh` |+| Dev overlay (`rpcserver_ios` replacement) | - | Y (`apply_dev_overlay`) | - | - |+| SSH readiness wait before install | Y (`wait_for_device_ssh_ready`) | - | Y (inherited from base run) | Y (inherited from base run) |+| launchd jetsam patch (`patch-launchd-jetsam`) | - | Y (base-flow injection) | Y (JB-1) | Y (JB-1) |+| launchd dylib injection (`inject-dylib /b`) | - | - | Y (JB-1) | Y (JB-1) |+| Procursus bootstrap deployment | - | - | Y (JB-2) | Y (JB-2) |+| BaseBin hook deployment (`*.dylib` -> `/mnt1/cores`) | - | - | Y (JB-3) | Y (JB-3) |+| First-boot JB finalization (`vphone_jb_setup.sh`) | - | - | Y (post-boot) | Y (post-boot) |+| DSC pre-patch (`kern.hv_vmm_present` byte-5 mangle + slot reattest) | - | - | - | Y (pre-step, before base CFW) |+| `watchdogd` surgical 2-insn patch + slot reattest | - | - | - | Y (EXP-JB-3.5) |+| Post-restore DT identity rewrite (`devicetree.img4`)| - | - | - | Y (EXP-JB-6) |+| `SystemVersion.plist` `ProductBuildVersion` rewrite | - | - | - | Y (EXP-JB-7, opt-in via `SPOOF_BUILD`) |+| Additional input resources | `cfw_input` | `cfw_input` + `resources/cfw_dev/rpcserver_ios` | `cfw_input` + `cfw_jb_input` | `cfw_input` + `cfw_jb_input` |+| Extra tool requirement beyond base | - | - | `zstd` | `zstd` |+| Halt behavior | Halts unless `CFW_SKIP_HALT=1` | Halts unless `CFW_SKIP_HALT=1` | Always halts after JB phases | Always halts after EXP phases |## Summary-| Component | Regular | Dev | JB |-| ------------------------ | ------: | --: | --: |-| AVPBooter | 1 | 1 | 1 |-| iBSS | 2 | 2 | 3 |-| iBEC | 3 | 3 | 3 |-| LLB | 6 | 6 | 6 |-| TXM | 1 | 12 | 12 |-| Kernel (base) | 28 | 29 | 28 |-| Kernel (JB methods) | - | - | 59 |-| Boot chain total | 41 | 53 | 112 |-| CFW binary patches | 4 | 5 | 6 |-| CFW installed components | 6 | 7 | 9 |-| CFW total | 10 | 12 | 15 |-| Grand total | 51 | 65 | 127 |+| Component | Regular | Dev | JB | EXP |+| ---------------------------------- | ------: | --: | --: | --: |+| AVPBooter | 1 | 1 | 1 | 1 |+| iBSS | 2 | 2 | 3 | 3 |+| iBEC | 3 | 3 | 3 | 3 |+| LLB | 6 | 6 | 6 | 6 |+| TXM | 1 | 12 | 12 | 12 |+| Kernel (base) | 28 | 29 | 28 | 28 |+| Kernel (JB methods) | - | - | 59 | 59 |+| Kernel (EXP methods, `hv_vmm`) | - | - | - | 6 |+| DeviceTree base properties | 4 | 4 | 4 | 4 |+| DeviceTree EXP identity properties | - | - | - | 8 |+| Boot chain total | 45 | 57 | 116 | 130 |+| CFW binary patches (base) | 4 | 5 | 6 | 6 |+| CFW EXP-only steps | - | - | - | 4 (DSC pre-patch, watchdogd EXP-JB-3.5, post-restore DT EXP-JB-6, build-version EXP-JB-7 opt-in) |+| CFW installed components | 6 | 7 | 9 | 9 |+| CFW total | 10 | 12 | 15 | 19 |+| Grand total | 55 | 69 | 131 | 149 |## Ramdisk Variant Matrix-| Variant | Pre-step | `Ramdisk/txm.img4` | `Ramdisk/krnl.ramdisk.img4` | `Ramdisk/krnl.img4` | Effective kernel used by `ramdisk_send.sh` |-| ------------- | ------------------- | -------------------------------- | -------------------------------------------------------------------------------- | ----------------------------------------- | --------------------------------------------------- |-| `RAMDISK` | `make fw_patch` | release TXM + base TXM patch (1) | base kernel (28), legacy `*.ramdisk` preferred else derive from pristine CloudOS | restore kernel from `fw_patch` (28) | `krnl.ramdisk.img4` preferred, fallback `krnl.img4` |-| `DEV+RAMDISK` | `make fw_patch_dev` | release TXM + base TXM patch (1) | base kernel (28), same derivation rule | restore kernel from `fw_patch_dev` (29) | `krnl.ramdisk.img4` preferred, fallback `krnl.img4` |-| `JB+RAMDISK` | `make fw_patch_jb` | release TXM + base TXM patch (1) | base kernel (28), same derivation rule | restore kernel from `fw_patch_jb` (28+59) | `krnl.ramdisk.img4` preferred, fallback `krnl.img4` |+| Variant | Pre-step | `Ramdisk/txm.img4` | `Ramdisk/krnl.ramdisk.img4` | `Ramdisk/krnl.img4` | Effective kernel used by `ramdisk_send.sh` |+| -------------- | -------------------- | -------------------------------- | -------------------------------------------------------------------------------- | ---------------------------------------------- | --------------------------------------------------- |+| `RAMDISK` | `make fw_patch` | release TXM + base TXM patch (1) | base kernel (28), legacy `*.ramdisk` preferred else derive from pristine CloudOS | restore kernel from `fw_patch` (28) | `krnl.ramdisk.img4` preferred, fallback `krnl.img4` |+| `DEV+RAMDISK` | `make fw_patch_dev` | release TXM + base TXM patch (1) | base kernel (28), same derivation rule | restore kernel from `fw_patch_dev` (29) | `krnl.ramdisk.img4` preferred, fallback `krnl.img4` |+| `JB+RAMDISK` | `make fw_patch_jb` | release TXM + base TXM patch (1) | base kernel (28), same derivation rule | restore kernel from `fw_patch_jb` (28+59) | `krnl.ramdisk.img4` preferred, fallback `krnl.img4` |+| `EXP+RAMDISK` | `make fw_patch_exp` | release TXM + base TXM patch (1) | base kernel (28), same derivation rule | restore kernel from `fw_patch_exp` (28+59+6) | `krnl.ramdisk.img4` preferred, fallback `krnl.img4` |## Cross-Version Dynamic Snapshotdiff --git a/research/firmware_manifest_and_origins.md b/research/firmware_manifest_and_origins.mdindex 7c1074e6..aac06b6d 100644--- a/research/firmware_manifest_and_origins.md+++ b/research/firmware_manifest_and_origins.md@@ -318,3 +318,257 @@ The firmware is a PCC shell wrapping an iPhone core. The vresearch101 boot chainhandles DFU/TSS signing. The vphone600 device tree + SEP + kernel provide theruntime environment. The iPhone userland is patched post-install for activationbypass, jailbreak tools, and persistent SSH/VNC.++---++## 9. DeviceTree identity rewrite++The vphone600ap DT carries 13 properties whose values contain the literals+`vphone600` / `VPHONE600` / `iPhone99,11` / `vmapple` / `vresearch`. Most are+load-bearing (kernel kext-matching, restore-time identity, IORegistry path+structure) and cannot be rewritten without breaking boot or restore.+`DeviceTreePatcher` rewrites the 8 that are either userland-facing identity+fields or SoC-generation descriptors with non-binding semantics.++| # | Path | Property | Original | Patched | Slot | Risk |+|----|------------------------------------------------------|----------------------|-----------------------------------------------------------|----------------------------------------------------------|------|---------------|+| 2 | `device-tree` | `target-sub-type` | `"VPHONE600AP"` | `"D47AP"` | 12 | HIGHER |+| 3 | `device-tree` | `compatible[1]` | secondary `"iPhone99,11"` (multi-string) | `"iPhone17,3"` (multi-string, primary `"VPHONE600AP"` preserved) | 48 | LOW |+| 10 | `device-tree/product` | `fdr-product-type` | `"iPhone99,11"` | `"iPhone17,3"` | 12 | HIGHER |+| 11 | `device-tree/product` | `sub-product-type` | `"iPhone99,11"` | `"iPhone17,3"` | 12 | LOW |+| 12 | `device-tree/product` | `unique-model` | `"VPHONE600AP"` | `"D47AP"` | 12 | LOW |+| 6 | `device-tree/arm-io` | `device_type` | `"vresearch1-io"` | `"t8140-io"` (matches d47ap) | 14 | MEDIUM |+| 7 | `device-tree/arm-io` | `soc-generation` | `"VResearch1"` | `"H17"` (matches d47ap) | 11 | MEDIUM-LOW |+| 13 | `device-tree/product/vphone600-gestalt-variants` | `name` (node name) | `"vphone600-gestalt-variants"` | `"d47-gestalt-variants"` | 27 | LOW-MEDIUM |++**Properties intentionally left at vphone600 values** (with the empirical+reason for each):++- `device-tree.target-type` (`"VPHONE600"`) — Tier 2 attempt broke restore;+ iBoot / restored_external read this and reject the device when the value+ doesn't match the BuildManifest's signed identity.+- `device-tree.model` (`"iPhone99,11"`) — Tier 1 attempt broke restore;+ same reason as `target-type`.+- `device-tree.compatible[0]` (`"VPHONE600AP"`) — IOKit's platform-expert+ matching at boot binds against the FIRST entry of `compatible`. Rewriting+ it to `D47AP` forces `_PE_init_platform_expert` to look for a D47AP-claiming+ kext, which doesn't exist in our kernelcache. Panic guaranteed.+- `device-tree/arm-io.compatible` / `device_type` / `soc-generation`+ (vmapple1 / vresearch1-io / VResearch1) — bind the vmapple1 IO controller+ kext, GIC, and PCIe drivers. Rename → no kext claims the SoC IO → boot+ panic.+- `device-tree/arm-io/gic.compatible`, `device-tree/arm-io/pcie.compatible` —+ same family as arm-io entries.+- `device-tree/product/vphone600-gestalt-variants` (node name) — referenced+ by libMobileGestalt-equivalent code that looks up the subtree by literal+ node name. Rename breaks the lookup.++**Compatible multi-string surgical rewrite** (#3). The original blob is:++```+[0..10] "VPHONE600AP" (11 bytes)+[11] NUL+[12..22] "iPhone99,11" (11 bytes)+[23] NUL+[24..46] "AppleVirtualPlatformARM" (23 bytes)+[47] NUL+```++Patched (slot length preserved at 48):++```+[0..10] "VPHONE600AP" ← unchanged: platform-expert bind site+[11] NUL+[12..21] "iPhone17,3"+[22] NUL+[23..45] "AppleVirtualPlatformARM"+[46] NUL+[47] NUL (pad)+```++`AppleVirtualPlatformARM` shifts 1 byte earlier but every consumer walks+the blob by NUL-terminators, none depend on a fixed byte offset within+the property. IOKit's platform-expert match against `VPHONE600AP` (first+entry) is unaffected; the second entry, which userland walks of the+compatible[] list see when enumerating identifiers, now reports+`iPhone17,3`.++**Risk classification.**++- **LOW** (#3, #11, #12) — read only by userland identity APIs+ (libMobileGestalt, IORegistry queries, App Store device class).+ No iBoot / restored_external / TSS dependency.+- **HIGHER** (#2, #10) — `target-sub-type` is in the same restore-signed+ family as `target-type` (already proven to break restore);+ `fdr-product-type` is read by Factory-Data-Restore code paths that may+ check it against the BuildManifest. If restore fails after a build that+ enables these, remove them first and try the remaining LOW-risk three+ in isolation.++Wiring: all 5 patches are declared in+`sources/FirmwarePatcher/DeviceTree/DeviceTreePatcher.swift` under+`propertyPatches`. The serializer rebuilds the entire tree on every run,+so each new value is written at the same slot length as the original.+The `compatible` patch uses a new `PropertyValue.bytes(Data)` case that+takes a pre-built byte blob (necessary because the multi-string layout+contains embedded NULs).++## 10. Post-restore DT identity rewrite (EXP-JB-6)++The properties under "known-bad from prior rounds" (root `model`, root+`target-type`) cannot be edited at fw_patch time because+`restored_external` / iBoot's restore mode cross-checks them against the+BuildManifest's signed `SupportedProductTypes`. But that cross-check+fires **only during installation**. After restore completes, the boot+path is++```+AVPBooter (patched)+ → iBSS / iBEC (image4_validate_property_callback bypass patches)+ → LLB (image4 bypass + rootfs bypass patches)+ → iBoot (research) → DT loaded from disk+ → kernel → sysctls populated from DT+```++The image4 bypass patches we already ship are what allow every+fw_patch-time IM4P modification to boot at all — they make the IM4M's+stored digest irrelevant on subsequent boots. So an additional IM4P+modification applied **after** restore completes is in-policy with the+project's existing trust-chain bypass.++The **EXP-JB-6** install step exploits this (in `cfw_install_exp.sh`+only — JB and DEV variants do NOT run it). While the install pipeline+still has `/mnt5` (the preboot volume) mounted in ramdisk mode, it:++1. Pulls `/mnt5/<boot-hash>/usr/standalone/firmware/devicetree.img4` to+ the host.+2. Runs `scripts/patchers/cfw_patch_post_restore_dt.py`, which:+ - Unwraps img4 → IM4P → decompresses LZFSE → DT blob (via pyimg4).+ - Applies the three restore-unsafe edits (table below).+ - Re-compresses LZFSE → repacks IM4P → repacks IMG4 with the original+ IM4M.+3. Pushes the modified img4 back to the same path.+4. The device reboots out of ramdisk; iBoot loads the modified DT;+ kernel populates `machine_info` from the new property values.++| Property | Before (post-Tier-1b state on disk) | After (EXP-JB-6 rewrites to) | Slot |+|---------------------------|---------------------------------------------------------------------------|-------------------------------------------------------------------------|------|+| `device-tree.model` | `"iPhone99,11"` | `"iPhone17,3"` | 12 |+| `device-tree.target-type` | `"VPHONE600"` | `"D47"` | 10 |+| `device-tree.compatible` | `["VPHONE600AP", "iPhone17,3", "AppleVirtualPlatformARM"]` (post-Tier-1b) | `["D47AP", "VPHONE600AP", "AppleVirtualPlatformARM"]` (reordered) | 48 |++The `compatible` rewrite is a **reorder**, not a replacement: VPHONE600AP+stays in the list (now as the second entry), so IOKit's platform-expert+match against the AppleVMApple1IO kext still binds. `compatible[0]`+becomes D47AP, which is what userland's `hw.model` resolves to.++Userland-visible effects after the next boot:++- `sysctl hw.machine` → `"iPhone17,3"` (was `"iPhone99,11"`)+- `sysctl hw.product` → `"iPhone17,3"` (was `"iPhone99,11"`)+- `sysctl hw.model` → `"D47AP"` (was `"VPHONE600AP"`)+- Settings → General → About → Model Identifier reflects the new+ ProductType.+- Every `MGCopyAnswer` key backed by `IOPlatformExpertDevice` properties+ picks up the new values.++Idempotence: the patcher reads the existing DT, applies edits, and+writes back only if there's a difference. A second run on an+already-patched devicetree.img4 detects target-state-already-met and+exits without rewriting.++Wiring:++* `scripts/patchers/cfw_patch_post_restore_dt.py` — host-side patcher.+ Uses pyimg4 for img4↔IM4P+LZFSE round-trip; mirrors the DT format+ parser/serializer from `DeviceTreePatcher.swift`.+* `scripts/cfw_install_exp.sh [EXP-JB-6]` — install step that runs after+ JB-5 (LaunchDaemon deploy) and before the CLEANUP/umount block, in the+ EXP install script only. Discovers the boot-manifest-hash via the same+ `get_boot_manifest_hash` helper used by earlier install steps. Tolerates+ a missing devicetree.img4 with warn-and-skip rather than aborting the+ install. JB and DEV install scripts do NOT carry this step.++Why this is restore-safe (and the fw_patch-time version was not):++- **fw_patch-time path** modifies the IM4P bytes that are sent during+ restore. iBoot's restore mode reads each IM4P and (via the image4+ validation callback the iBSS/iBEC/LLB patches already neuter) accepts+ its digest mismatch — but some other path inside `restored_external`+ enforces the top-level `SupportedProductTypes` check independently and+ rejects DT.model values that don't appear in that list.+- **EXP-JB-6 post-restore path** never re-runs the BuildManifest check.+ Subsequent boots validate IM4P contents against the IM4M only — which+ the image4 bypass patches already wave through. So the same byte+ change that's fatal at restore is harmless after restore.++## 11. Build-version rewrite (EXP-JB-7, opt-in)++**Opt-in step**. EXP-JB-7 runs only when the `SPOOF_BUILD` environment+variable is set — e.g. `make setup_machine EXP=1 SPOOF_BUILD=23F77`, or+`make cfw_install_exp SPOOF_BUILD=23F77` if you're re-running just the+CFW phase. When omitted/empty the step is skipped entirely and the+build identifier stays at whatever the IPSW shipped. Only the EXP+install script runs this step; JB and DEV variants are not affected.++The iPhone IPSW we install from ships with build identifier `23B85` (iOS+26.1). iOS displays this string in Settings → General → About → "Build"+and exposes it through `MGCopyAnswer("BuildVersion")`, `CoreFoundation`'s+`_CFCopyServerVersionDictionary`, App Store telemetry, and every other+framework path that reads `/System/Library/CoreServices/SystemVersion.plist`.++The build identifier lives in exactly two on-device plist files. Both+are plain XML/binary plists (no Apple-side per-file signature), and+both live on volumes that are writable at install time:++| Path | Volume | Role |+|-------------------------------------------------------------------------------------|--------------|----------------------------------------------------------------------|+| `/System/Library/CoreServices/SystemVersion.plist` | rootfs | The canonical source. Read by every userland identity API. |+| `/private/preboot/Cryptexes/OS/System/Library/CoreServices/SystemVersion.plist` | preboot | Cryptex-side copy. Read by Cryptex-aware OS-version queries. |++The **EXP-JB-7** install step rewrites the `ProductBuildVersion` key in both+plists to a target value (currently `23F77`):++```+ProductBuildVersion: "23B85" → "23F77"+```++`ProductVersion` (`26.1`), `ProductName` (`iPhone OS`), `BuildID`,+`SystemImageID`, and `ProductCopyright` are left untouched.++Wiring:++* `scripts/patchers/cfw_patch_build_version.py` — host-side plistlib-based+ rewriter. Auto-detects XML vs binary plist format and preserves it on+ write. Idempotent — a re-run on an already-patched plist exits without+ rewriting.+* `scripts/cfw_install_exp.sh [EXP-JB-7]` — install step that runs after+ EXP-JB-6 (post-restore DT) and before CLEANUP, in the EXP install script+ only. For each of the two plist paths it scp_from's the file to host,+ runs the patcher with target `23F77`, scp_to's the file back. Tolerates+ missing-on-device with warn+continue. JB and DEV install scripts do NOT+ carry this step.++What this **does not** flip:++- `sysctl kern.osversion` — populated at boot from a kernel global+ initialized from boot args, not from `SystemVersion.plist`. The kernel+ image we ship was built against `23B78` (the PCC vphone600 /+ vresearch101 build identifier; visible in 621 kext-Info.plist+ embedded `DTPlatformBuild` / `DTSDKBuild` blobs inside the kernelcache+ but never read by `kern.osversion` at runtime). To flip+ `kern.osversion` we'd need to either rebuild the kernelcache with a+ different `OS_BUILD_VERSION` or patch the kernel boot args path — out+ of scope for this round.+- `SystemVersionCompat.plist` — carries `23B34a` / `19.1`, a legacy+ iOS-19 marker for `MacCatalyst`-style version queries. Not user-+ visible, deliberately untouched.+- DSC dylib internals — the apparent `23B85` byte sequence in DSC chunk+ `.21` is a Swift mangled-name UUID-uniquing substring+ (`_TtC11MediaCoreUIP33_98519F523B8515A67EEFBCB0824D82807Counter`), not+ a build identifier. Patching it would corrupt a Swift symbol name.++Order of operations: this step runs **after** EXP-JB-6 (the DT identity+rewrite) so that any post-restore identity work targeting `/mnt5` has+completed before we modify the Cryptex's SystemVersion.plist (which+lives on the same volume).diff --git a/research/hv_vmm_present_usermode_xrefs.md b/research/hv_vmm_present_usermode_xrefs.mdnew file mode 100644index 00000000..8ff68121--- /dev/null+++ b/research/hv_vmm_present_usermode_xrefs.md@@ -0,0 +1,487 @@+# `kern.hv_vmm_present` user-mode call sites — iPhone17,3 26.1 (23B85)++Source material: `ipsws/iPhone17,3_26.1_23B85_Restore` (raw IPSW; encrypted DMGs)+and `ipsws/iPhone17,3_26.1_23B85_Restore_extracted` (rebuilt rootfs with split DSC).++This document enumerates every place in user space that reads+`kern.hv_vmm_present` via the `sysctl` family on this firmware, what each+caller appears to do with the result, and what is reasonable to expect from+patching that specific reader instead of the kernel.++## Current shipping design — blacklist-flip + kernel rename++The current patch pipeline takes a **kernel-rename + user-mode-blacklist**+approach. Summary:++* The Swift kernel patch `patch_hv_vmm_rename` (JB-26, Group B) renames+ the kernel's `hv_vmm_present` sysctl OID name in place to+ `Xv_vmm_present` (single byte change at offset 0 of the 14-byte+ cstring `\0hv_vmm_present\0`). After this kernel patch:+ - `sysctlbyname("kern.hv_vmm_present", ...)` returns ENOENT.+ - `sysctlbyname("kern.Xv_vmm_present", ...)` returns 1, the OID's+ real int value.+* The user-mode mangle pattern moved from byte 0 (`'k' → 'X'`,+ producing `Xern.hv_vmm_present` — unroutable because `Xern` isn't a+ top-level namespace) to byte 5 (`'h' → 'X'`, producing+ `kern.Xv_vmm_present` — keeps `kern.` intact, routes to the renamed+ OID).+* `scripts/patchers/cfw_patch_hv_vmm_dsc.py` now applies the mangle as+ a BLACKLIST. The list `DONT_PATCH_INSTALL_NAMES` names dylibs whose+ cstring is LEFT untouched — they query the original (now+ ENOENT-returning) name and cache 0 ("not in a VM"). Every other DSC+ dylib with the cstring gets the byte-5 mangle, queries the new name,+ and caches 1 ("in a VM", same as stock) — keeping graphics ++ compute/accel fast paths intact.+* The standalone-binary patch step over SSH (originally `cfw_install_jb.sh`+ JB-3.5 and `cfw_install_dev.sh` 6.5/7) was removed. With the kernel+ rename in place, those 6 rootfs binaries fall into the "unpatched → ENOENT+ → cache 0" bucket automatically.++The earlier whitelist-only design (no kernel patch, mangle a chosen+subset to ENOENT) is preserved for reference in the section+"Pre-blacklist whitelist enumeration" below, since the per-caller+classification work is still the source-of-truth for what each+binary's cstring usage actually looks like.++## What the sysctl is++`kern.hv_vmm_present` is defined in XNU at+`bsd/kern/hvg_sysctl.c:176`:++> `static SYSCTL_PROC(_kern, OID_AUTO, hv_vmm_present,`+> ` CTLTYPE_INT | CTLFLAG_ANYBODY | CTLFLAG_KERN | CTLFLAG_LOCKED, …)`++Backing handler `sysctl_vmm_present` (line 136 in the same file) returns+an `int`, computed on arm64 from `IODTGetDefault("vmm-present", …)` —+i.e. a device-tree key that Apple's Virtualization.framework /+PCC bring-up plants in the guest. On real hardware the key is absent+and the read returns `0`; on PCC/research VMs it returns `1`. That is+exactly the path you are flipping today by patching the kernel.++Because this is a single named OID with `CTLFLAG_ANYBODY`, every user-mode+reader funnels through the canonical `sysctlbyname()` shape:++```+adrp x0, <page> ; x0 = "kern.hv_vmm_present"+add x0, x0, #<off>+sub x1, x29, #4 ; x1 = &result (int)+mov x2, sp ; x2 = &len (= 4)+mov x3, #0 ; newp+mov x4, #0 ; newlen+bl _sysctlbyname+```++This shape is the matcher I used to flag “real readers” below.++## Method++1. Located the literal `"kern.hv_vmm_present\0"` inside every Mach-O of the+ rebuilt rootfs (the split DSC dylibs and every executable). 56 binaries+ matched on bytes alone.+2. For each match, parsed the LC\_SEGMENT\_64 layout and located the+ actual section. Anything that wasn't in `__TEXT,__cstring` (or another+ section flagged `S_CSTRING_LITERALS`, flag `0x2`) was investigated+ separately.+3. For each cstring hit, looked for ADRP+ADD or ADRP+LDR pairs in any+ executable section that compute the string's vm address, then walked+ forward up to ~24 instructions tracking simple register propagation+ (`mov xN, xM`).+4. Classified each xref:+ * `CANONICAL` — string ends up in `x0`, `x3=x4=0`, BL within the window.+ Matches `sysctlbyname(name, oldp, oldlenp, NULL, 0)`.+ * `PROBABLE` — string in `x0` and a BL in window, but `x3`/`x4` zeroing+ not seen.+ * `REFERENCED` — xref exists but it is loaded into a non-x0 register or+ used as an address anchor for adjacent data, not handed to a syscall.+ * `STORED` — string written into a struct (i.e. a registry, not a+ direct caller).+ * `DEAD` — string lives in `__cstring` but no executable instruction+ points at its page.++The full per-binary results (snippets, addresses, classification) are+saved at `outputs/hv_vmm_present_xref.json`.++## Inventory by class++### A. CANONICAL `sysctlbyname("kern.hv_vmm_present", …)` callers — 35++Each line is `<binary> string@<vmaddr> xref@<vmaddr>`. The xref+address is the **`add` instruction** that finalizes the pointer value+in `x0`; immediately followed by the canonical 5-arg `sysctlbyname`+preamble and a `bl`.++```+usr/lib/libMobileGestalt.dylib string@0x1b0201c60 xref@0x1b0198d00+System/Library/Frameworks/CoreVideo.framework/CoreVideo string@0x19d17a4bb xref@0x19d122eb8+System/Library/Frameworks/CoreML.framework/CoreML string@0x1950ed0d0 xref@0x194c3c754+System/Library/Frameworks/StoreKit.framework/Support/storekitd string@0x10031a890 xref@0x100176f6c+System/Library/PrivateFrameworks/CoreRE.framework/CoreRE string@0x1e3171b20 xref@0x1e2790f28+System/Library/PrivateFrameworks/Espresso.framework/Espresso string@0x1949204e5 xref@0x193bef83c+System/Library/PrivateFrameworks/AppleNeuralEngine.framework/AppleNeuralEngine string@0x1ad297375 xref@0x1ad248248+System/Library/PrivateFrameworks/AppStoreDaemon.framework/Support/appstored string@0x10046dae6 xref@0x1003e25b8+System/Library/PrivateFrameworks/AppStoreUtilities.framework/AppStoreUtilities string@0x23ff916d7 xref@0x23ff8bfe4+System/Library/PrivateFrameworks/ApplePushService.framework/ApplePushService string@0x1b235fd50 xref@0x1b2358d10+System/Library/PrivateFrameworks/AuthKit.framework/AuthKit string@0x1933c11de xref@0x19322f7e8+System/Library/PrivateFrameworks/AAAFoundation.framework/AAAFoundation string@0x1c86581a1 xref@0x1c8650ee4+System/Library/PrivateFrameworks/AirPlaySupport.framework/AirPlaySupport string@0x2223618a0 xref@0x222306a28+System/Library/PrivateFrameworks/CorePrescription.framework/CorePrescription string@0x2471fe6ed xref@0x2471ebc18+System/Library/PrivateFrameworks/CorePrescription.framework/XPCServices/CorePrescriptionService.xpc/CorePrescriptionService string@0x100092175 xref@0x100005064+System/Library/PrivateFrameworks/CoreCDP.framework/CoreCDP string@0x1dedfa62d xref@0x1dedbb724+System/Library/PrivateFrameworks/DVTInstrumentsUtilities.framework/DVTInstrumentsUtilities string@0x247f42ad0 xref@0x247f1154c+System/Library/PrivateFrameworks/DeviceCheckInternal.framework/DeviceCheckInternal string@0x2487a018c xref@0x24878d10c+System/Library/PrivateFrameworks/DeviceIdentity.framework/DeviceIdentity string@0x2260a4b25 xref@0x2260862a4+System/Library/PrivateFrameworks/EmailFoundation.framework/EmailFoundation string@0x1c61cd1f7 xref@0x1c6165e88+System/Library/PrivateFrameworks/FindMyBase.framework/FindMyBase string@0x1df635420 xref@0x1df5fb8d4+System/Library/PrivateFrameworks/IDSFoundation.framework/IDSFoundation string@0x1a7ea0fe4 xref@0x1a7c65dc4+System/Library/PrivateFrameworks/IOSurfaceAccelerator.framework/IOSurfaceAccelerator string@0x2547cd71c xref@0x2547caa48+System/Library/PrivateFrameworks/MobileActivation.framework/MobileActivation string@0x2598f06c6 xref@0x2598e2618+System/Library/PrivateFrameworks/PhotoFoundation.framework/PhotoFoundation string@0x1d8ba907c xref@0x1d8b9e7fc+System/Library/PrivateFrameworks/RenderBox.framework/RenderBox string@0x195e54555 xref@0x195d344a0+System/Library/PrivateFrameworks/TrialServer.framework/TrialServer string@0x26f32471e xref@0x26f224120+System/Library/PrivateFrameworks/VisionKitCore.framework/VisionKitCore string@0x1b442d9cf xref@0x1b435f0a4+System/Library/PrivateFrameworks/WatchdogServiceManagement.framework/WatchdogServiceManagement string@0x272725b23 xref@0x272725114+System/Library/PrivateFrameworks/WebGPU.framework/WebGPU string@0x225722b6c xref@0x22552c2bc+System/Library/PrivateFrameworks/caulk.framework/caulk string@0x27512204f xref@0x275112808+System/Library/DataClassMigrators/MobileActivationMigrator.migrator/MobileActivationMigrator string@0x72aa xref@0x3024+System/Library/ExtensionKit/Extensions/HostInferenceProviderService.appex/HostInferenceProviderService string@0x1000112b0 xref@0x10000b890+Applications/CheckerBoard.app/CheckerBoard string@0x10006fb56 xref@0x1000192e8+Applications/StoreKitUISceneService.app/StoreKitUISceneService string@0x1000a2ca0 xref@0x100083f04+```++All 35 readers share the same five-argument shape. Most also share a+post-call idiom: store the boolean result into a static byte (cache),+and a sibling `getter()` reads the cached byte. libMobileGestalt is the+clearest exemplar:++```+0x1b0198cf0 stur wzr, [x29, #-4]+0x1b0198cf4 mov w8, #4+0x1b0198cf8 str x8, [sp]+0x1b0198cfc adrp x0, #0x1b0201000+0x1b0198d00 add x0, x0, #0xc60 ; "kern.hv_vmm_present"+0x1b0198d04 sub x1, x29, #4+0x1b0198d08 mov x2, sp+0x1b0198d0c mov x3, #0+0x1b0198d10 mov x4, #0+0x1b0198d14 bl #<sysctlbyname>+0x1b0198d18 cbnz w0, ...skip...+0x1b0198d1c ldur w8, [x29, #-4]+0x1b0198d24 cset w8, ne+0x1b0198d28 adrp x9, #0x1ed446000+0x1b0198d2c strb w8, [x9, #0xcf8] ; cached_is_vmm := (val != 0)+```++CoreML, CoreRE, Espresso, AppleNeuralEngine, MobileActivation,+caulk, RenderBox, etc. all do the same: one call, cached, sibling+accessor. That makes the patch surface for each one very small —+overwriting `cset w8, ne` with `mov w8, #0` (or NOPing the call and+zeroing the cached byte's accessor) is all that's needed per binary.++### B. False positives ruled out by xref analysis++15 of the 56 string-bearing binaries are **not** actual readers:++#### B.1 Embedded entitlement plist (the binary just declares it can read the OID)++These four embed a `com.apple.security.exception.sysctl.read-only` (or+`sysctl-read`) entitlement that names `kern.hv_vmm_present`. The+entitlement only authorises the sandbox; the actual `sysctlbyname` call+happens in libraries they link (almost certainly libMobileGestalt or+CoreFoundation). The binaries themselves contain no instruction+xref to the string.++```+Applications/Family.app/Family+Applications/PeopleMessageService.app/PeopleMessageService+Applications/PeopleViewService.app/PeopleViewService+System/Library/PrivateFrameworks/DataDetectorsUI.framework/PlugIns/com.apple.DataDetectorsUI.ActionsExtension.appex/com.apple.DataDetectorsUI.ActionsExtension+```++#### B.2 Compiled sandbox profile (the string lives inside an embedded SBPL blob)++The string is in `__TEXT,__const`, surrounded by high-entropy bytes that+match a compiled sandbox profile. No code reaches the string. As with+B.1, these only declare the OID is permitted — not that they read it.++```+usr/sbin/absd+usr/sbin/fairplayd.H2+System/Library/CoreServices/ClarityBoard.app/ClarityBoard+System/Library/PrivateFrameworks/CoreALD.framework/CoreALD+System/Library/PrivateFrameworks/IDS.framework/identityservicesd.app/identityservicesd+System/Library/PrivateFrameworks/SonicKit.framework/SonicKit+System/Library/PrivateFrameworks/VideosUI.framework/VideosUI+```++#### B.3 String present in `__cstring` but unreferenced (linker DCE leftover)++The string sits in the cstring section but no ADRP+ADD/LDR in any+executable section computes its vmaddr, and no 8-byte little-endian+encoding of the address (raw, image-relative, or 36-bit chained-fixup+shape) appears in any other section either.++```+usr/sbin/bluetoothd (verified: 0 ADRPs into the page; 0 byte-pointer matches)+System/Library/Frameworks/MediaToolbox.framework/MediaToolbox+System/Library/Frameworks/ManagedAppDistribution.framework/Support/managedappdistributiond+System/Library/PrivateFrameworks/ApplePushService.framework/apsd+System/Library/PrivateFrameworks/CMCapture.framework/CMCapture+System/Library/PrivateFrameworks/MagnifierSupport.framework/MagnifierSupport+System/Library/PrivateFrameworks/NeuralNetworks.framework/NeuralNetworks+System/Library/PrivateFrameworks/Recon3D.framework/Recon3D+System/Library/PrivateFrameworks/VFX.framework/VFX+```++#### B.4 Adjacent‑string anchor (REFERENCED but not a sysctl call)++```+System/Library/Frameworks/SoundAnalysis.framework/SoundAnalysis+```++The ADRP+ADD here computes `x8 = "kern.hv_vmm_present"`, then immediately+`x20 = x8 - 0x20`, i.e. it is using our string as a fixed offset to reach+a *different* sysctl name 32 bytes earlier in the cstring section. The+sysctlbyname call passes `x20`, not our string. No need to patch.++## What each CANONICAL caller is reasonable to expect to do++I am being literal here: I report what the framework path implies and+what the disassembly shows. Beyond what's listed I do not have direct+evidence of behaviour and would need runtime tracing to be sure.++| Component | Likely role of the check | Patching effect (only this caller) |+|---|---|---|+| `libMobileGestalt.dylib` | Implements `MGCopyAnswer("hv-vmm-present")` and similar — the answer most other Apple frameworks query through it. Single shared cache byte. | Many higher-level callers ask MobileGestalt instead of doing their own sysctl. Forcing MG's cache to 0 makes most “am I a VM?” checks throughout the system see "no" without further code changes. **Highest-leverage single patch.** |+| `CoreML.framework` / `Espresso.framework` / `AppleNeuralEngine.framework` / `CoreRE.framework` / `RenderBox.framework` / `WebGPU.framework` / `caulk.framework` | Compute / accel paths. Each independently caches a "running on VM" flag; their respective dispatchers gate ANE/Metal/HW codecs. | Disables their VM-aware fast-path bypasses. Practical effect: lets these libraries try the same code path they'd use on real silicon. On a research VM with PCC PV=3 they may now hit code that demands real ANE/SEP/etc. and fail — patch only if you specifically need them to take the silicon path. |+| `IOSurfaceAccelerator.framework` | Hardware surface allocation paths. | Same caveat — pushing it onto the silicon path may produce IOKit failures. |+| `RenderBox.framework`, `WebGPU.framework`, `Espresso.framework` | Already covered above (graphics/ML). | — |+| `CoreVideo.framework` | Video pipeline / capture surfaces. Caches a global. | Similar story to the accel libs. |+| `StoreKit.framework` (`storekitd`), `AppStoreDaemon` (`appstored`), `AppStoreUtilities`, `Applications/StoreKitUISceneService` | All of the App Store / IAP daemons and their host UI. They tag receipts with VM status. | Best candidate to patch *together*, because making the Store stop labelling sessions as "vm=1" while everything else stays the same is exactly the kind of selective lying the user asked for. Receipts and SKUI flow start looking like a real device. |+| `ApplePushService` (`ApplePushService`) | APNS client. APNS connection establishment includes a "device characteristics" payload. | Patching makes the APNS handshake claim the device is bare metal. Useful if push tokens are silently downgraded for VMs. |+| `AAAFoundation`, `AuthKit`, `IDSFoundation`, `DeviceIdentity`, `DeviceCheckInternal` | Apple ID / iCloud / iMessage attestation and DeviceCheck (anti-fraud) plumbing. Every one of them caches `is_vmm` to feed into device-binding/anti-abuse decisions. | Patching the AuthKit/IDS/DeviceCheck callers individually is the conservative way to make “Sign in with Apple ID”, iMessage activation, and DeviceCheck attestations stop self-flagging as VM, while leaving compute paths (CoreML, ANE) alone. **High-leverage for "make iMessage/iCloud trust this device" without disabling kernel-level VM behaviour.** |+| `MobileActivation.framework`, `MobileActivationMigrator` | Activation flow + migration tool. | Activation today uses kern.hv_vmm_present to decide whether to take the fastlane / dev path. Patching would normalise activation. |+| `CorePrescription.framework` (+ XPC service) | Health-data prescription store. | The check is almost certainly "don't sync prescriptions on a VM"; patching here gates Health/Rx data sync. |+| `EmailFoundation.framework` | Mail. | Likely a mail-account heuristic; patching is benign. |+| `PhotoFoundation.framework` | Photos. | Likely a "hide some assets on VMs" check. |+| `FindMyBase.framework` | Find My. | Anti-spoof gate. |+| `TrialServer.framework` | Internal A/B / trial-rollout client. | Trials' "exclude VMs" gate. |+| `WatchdogServiceManagement` | The watchdog manager. | Note `string@0x272725b23` lives in the same page as its own `__text`; this is a tiny binary with one and only one consumer. Patching is local and self-contained. |+| `VisionKitCore.framework`, `CoreCDP.framework` | Vision/CDP. Single sysctl, cached. | — |+| `AirPlaySupport.framework` | AirPlay. Cached flag. | Likely a "no AirPlay receiver on VM" gate. |+| `DVTInstrumentsUtilities.framework` | Xcode Instruments support library. | Dev-only; cosmetic. |+| `Applications/CheckerBoard.app` | Apple's internal CoreAccessibility test app — the build-time sample most likely link-imports the same telemetry helper as everyone else. | Cosmetic. |+| `HostInferenceProviderService.appex` | On-device generative-AI inference host. | Same family as the ML accel libs above; gate to compute paths. |++## Why the kernel-side patch breaks display while a user-side patch does not++The kernel-side patch (returning `0` from `sysctl_vmm_present` /+`IODTGetDefault("vmm-present")`) flips the answer for **every** consumer+in the boot pipeline, including kernel-internal users of `vmm-present`+(IOKit, IOSurface, display drivers, AGX). The display path consumes the+flag for its own paravirt routing — that's the symptom you observed.++A user-mode patch only changes what landed in the 35 dylib/exe call sites+above. None of them are on the display bring-up path; they all run+post-launchd, after the framebuffer/IOSurface plumbing is already up.+So the display works as VM, while the higher-level "this is a VM"+hints are suppressed wherever you choose.++## Recommended patch surface++Given the vphone-cli design intent ("VM-aware where it has to be,+device-like where it can be"), the smallest set that buys the most is:++1. **`libMobileGestalt.dylib`** — single biggest fan-in. Many other+ processes ask MG instead of calling `sysctlbyname` directly, so this+ one patch propagates.+2. **`CorePrescription`, `WatchdogServiceManagement`, `EmailFoundation`,+ `PhotoFoundation`, `FindMyBase`, `AirPlaySupport`, `TrialServer`,+ `CoreCDP`, `VisionKitCore`** — the consumer apps/services. Patching+ them gives the device-like surface for sync, mail, photos, find-my,+ etc.+3. **`AAAFoundation`, `AuthKit`, `IDSFoundation`, `DeviceIdentity`,+ `DeviceCheckInternal`, `MobileActivation`, `MobileActivationMigrator`,+ `ApplePushService`** — identity / push / activation. Patching here+ normalises the device's posture against Apple's anti-abuse signals.+4. **`StoreKit/storekitd`, `AppStoreDaemon/appstored`, `AppStoreUtilities`,+ `StoreKitUISceneService`** — App Store + IAP. Patch as a group.+5. **DO NOT patch (most likely):** `CoreML`, `CoreRE`, `Espresso`,+ `AppleNeuralEngine`, `RenderBox`, `WebGPU`, `caulk`, `CoreVideo`,+ `IOSurfaceAccelerator`, `HostInferenceProviderService`. These are the+ compute/accel libraries — pushing them onto the silicon path on a VM+ is the most likely way to cause new failures (no real ANE / no real+ AGX / no real H.265 hardware encoder available to take the call).+6. Ignore the false positives in section B entirely — they don't read+ the sysctl.++The exact byte-level patch shape that works for every CANONICAL site is+identical to what you already have in the kernel: turn the 1-bit boolean+that gets cached after the call into a constant 0. The ARM64 idiom+`cset wN, ne` (after `cmp wM, #0`) → `mov wN, #0` (3 byte-pattern+substitutions: `0x9f1f00b1` zero immediate move, etc.) is a one-instruction+patch per consumer.++If you'd rather skip the call entirely, replace the `bl <sysctlbyname>`+with `mov w0, #0` (success) and zero the result on the stack — also+one instruction, but now `w0=0` is read as the int result so the+post-call boolean naturally becomes 0.++## Files++* `outputs/hv_vmm_present_xref.json` — full per-binary xref dump+ (string addresses, xref addresses, classification, surrounding+ disassembly).+* `research/hv_vmm_present_xref.json` — same dump committed in-tree.++## Patcher implementation (Dev + JB only)++Implemented as part of the existing `cfw_install_dev.sh` /+`cfw_install_jb.sh` flows; the regular `cfw_install.sh` is left+untouched (per design — the regular variant stays "as honest as+possible", and the device-likeness layer is opt-in via the dev or+jb variants).++**Patch shape, every site** — 1-byte cstring mangle:++```+cstring "kern.hv_vmm_present\0" → "Xern.hv_vmm_present\0"+ ^ byte 0 = 'k' (0x6B) ^ byte 0 = 'X' (0x58)+```++The kernel returns `ENOENT` for the mangled name; the canonical+post-call error check (`cbnz w0, skip` / `cmp w0,#0 ; b.ne skip`)+takes the skip-cache path, so the cached "is_vmm" byte stays at its+initial 0 (stack pre-zeroed by `stur wzr` or BSS-zero for a global+`oldp`). Idempotent: a re-run can't find the unmangled cstring and+no-ops.++We don't touch executable code — only one byte of string data in+`__TEXT,__cstring`. The kernel call still happens (so sysctl+instrumentation still sees activity), it just fails the+name-to-MIB translation.++**What gets patched**++| Tier | Scope | Where applied |+| ---------------- | -------------------- | --------------------------------------------------------- |+| DSC dylibs (20) | Identity / store / consumer-services (see list above) | DSC chunks inside the SystemOS Cryptex DMG, while it is mounted on the host |+| Standalone (6) | MobileActivationMigrator, CheckerBoard, StoreKitUISceneService, storekitd, appstored, CorePrescriptionService.xpc | Pulled from the device rootfs over SSH, patched, ldid-signed, pushed back |+| Compute / accel (10) | CoreML, Espresso, ANE, CoreRE, RenderBox, WebGPU, caulk, IOSurfaceAccelerator, HostInferenceProviderService | **Not patched** — leaving these alone preserves their VM-aware fast-path bypasses |++**Source files**++* `scripts/patchers/cfw_patch_hv_vmm.py` — standalone cstring patcher+ (`patch_hv_vmm(filepath)`): finds occurrences of `"kern.hv_vmm_present\0"`+ in `__cstring` (and the objc method/class name pools, for safety) and+ rewrites byte 0 from `'k'` to `'X'`.+* `scripts/patchers/cfw_dsc_chunks.py` — chunked-DSC byte-level helper:+ vmaddr ↔ chunk-fileoff mapping, executable-mapping cstring scan,+ byte read/write at a vmaddr, and Mach-O header walk-back to resolve+ a vmaddr to the containing dylib's install name.+* `scripts/patchers/cfw_patch_hv_vmm_dsc.py` — DSC-native orchestrator.+ No external `ipsw` dependency. For every `"kern.hv_vmm_present\0"`+ occurrence found in any executable mapping, walks back to the+ containing dylib's Mach-O header, reads `LC_ID_DYLIB`, and — if the+ install name is in the explicit `PATCH_INSTALL_NAMES` whitelist —+ rewrites the first byte of the cstring through+ `DSCChunks.write_at_vma`. After all whitelisted byte-mangles, calls+ `cfw_dsc_codesign.reattest_modified_pages` to recompute the SHA-256+ slot hash in the containing DSC chunk's `CS_CodeDirectory` for every+ affected 16 KiB page (see below — this is required on hardware with+ `codeSigningMonitor == 2`). The whitelist is one entry per line in+ the source file so an operator can comment out individual dylibs+ during bisection. (An earlier draft used `bl _sysctlbyname` →+ `movn w0,#0` instruction patching and an `ipsw dyld extract` path;+ both were scrapped — the former because it modifies executable+ bytes which has the same per-page-hash risk as the cstring approach+ but a larger surface area, and the latter because `ipsw` returns a+ Mach-O whose load-command file offsets reference the original DSC+ chunk's file layout, making it unparseable as a standalone Mach-O.)+* `scripts/patchers/cfw_dsc_codesign.py` — page-hash re-attestation.+ Without this pass, every byte-mangle invalidates the affected 16 KiB+ page's SHA-256 slot hash in the chunk-level `CS_CodeDirectory`. On+ iPhone17,3 / iOS 26.1 (`codeSigningMonitor == 2`), TXM enforces+ per-page integrity at demand-page-in (XNU defers exec-page+ validation to TXM for `csm_associated` mappings —+ `research/reference/xnu/osfmk/vm/vm_fault.c:2763-2780`). Concrete+ repro before re-attestation: `lsd-2026-05-11-035240.ips` faults+ inside MobileActivation's __TEXT at offset `0x13DC0`, in the same+ 16 KiB page as the mangled cstring (offset `0x106C6`). The+ re-attestation rewrites only the 32-byte slot whose page contains+ a modified byte; the CDHash side-effect (CD blob hash changes+ when slots change) is accepted by TXM at DSC mount time+ (empirically verified — device boots with re-attested DSC).+* `scripts/patchers/cfw.py` — adds `patch-hv-vmm <binary>` and+ `patch-hv-vmm-dsc <chunks_dir>` subcommands.+* `scripts/patch_hv_vmm_userland.sh` — thin wrapper used by the+ install scripts.+* `scripts/cfw_install_dev.sh` — DSC patch is applied while the+ SystemOS Cryptex DMG is still mounted on the host (inside step+ `[1/7]`); standalone binaries are patched over SSH in new step+ `[6.5/7]`.+* `scripts/cfw_install_jb.sh` — pre-step before invoking the+ regular `cfw_install.sh`: decrypts the SysOS Cryptex into the+ same cache file `cfw_install.sh` would, mounts it, applies the+ DSC patch, unmounts. The unmodified `cfw_install.sh` then sees+ the cached (already-patched) DMG. Standalone binaries are patched+ in new step `[EXP-JB-3.5]` after the base install completes (EXP variant only).++## Dylibs that must keep seeing VM=1 (graphics + accel passthrough)++Empirically validated: lying to these dylibs about VM presence breaks+the boot graphics path or the compute/accel fast paths. They MUST+read 1 (or the original truthful value) at runtime to function. Under+the new blacklist-flip design they are therefore NOT in+`DONT_PATCH_INSTALL_NAMES` — which means the byte-5 mangle IS applied+to their cstrings, they query the renamed kernel sysctl+`kern.Xv_vmm_present`, and the kernel returns 1 to them just like a+stock device would.++| Dylib | Why a lie breaks it |+| -------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| `/usr/lib/libMobileGestalt.dylib` | Highest fan-in answer source. Forcing it to think "not a VM" sends the whole display-init chain into paths that demand real silicon display hardware. |+| `PrivateFrameworks/PhotoFoundation.framework/PhotoFoundation` | Photos / image pipeline ties into the boot display path (asset decode + thumbnail rendering touches the same Metal surfaces the boot UI uses). |+| `PrivateFrameworks/AirPlaySupport.framework/AirPlaySupport` | AirPlay screen-mirroring plumbing registers as a display source at boot; lying about VM mode flips the registration path. |+| `PrivateFrameworks/VisionKitCore.framework/VisionKitCore` | Camera / vision-intelligence stack hooks into the boot-time display chain on this device. |+| `Frameworks/CoreVideo.framework/CoreVideo` | Directly in the display pipeline — lying routes the boot display path through code that assumes physical capture surfaces. |+| `Frameworks/CoreML.framework/CoreML` | Compute fast-path. The VM-aware bypass is what prevents CoreML from trying to drive real ANE. |+| `PrivateFrameworks/Espresso.framework/Espresso` | Same — neural-net inference dispatch. |+| `PrivateFrameworks/AppleNeuralEngine.framework/AppleNeuralEngine` | ANE driver bring-up. |+| `PrivateFrameworks/CoreRE.framework/CoreRE` | Reality Engine dispatch. |+| `PrivateFrameworks/RenderBox.framework/RenderBox` | Graphics dispatch. |+| `PrivateFrameworks/WebGPU.framework/WebGPU` | GPU dispatch. |+| `PrivateFrameworks/caulk.framework/caulk` | HW codec dispatch. |+| `PrivateFrameworks/IOSurfaceAccelerator.framework/IOSurfaceAccelerator` | IOSurface accelerator dispatch. |+| `ExtensionKit/Extensions/HostInferenceProviderService.appex/HostInferenceProviderService` | On-device ML inference host. |++Under the new design these libs are not enumerated in code — they+implicitly fall into "not blacklisted → patched → sees VM=1" by+virtue of NOT being in `DONT_PATCH_INSTALL_NAMES`. To explicitly+exclude a different lib from the patch (force it to lie about VM+presence), add its install name to the blacklist. The build / install+flow is idempotent in re-attestation (`cfw_patch_hv_vmm_dsc.py` will+detect already-mangled cstrings on a re-run and re-sync slot hashes+for their pages), so toggling an entry in or out of the blacklist+doesn't require a fresh IPSW unpack — but doing so after a previous+install requires `rm -f vm/.cfw_temp/CryptexSystemOS.dmg` to force a+fresh DSC mount.++## What is verified vs. inferred++Verified by direct disassembly + Mach-O byte inspection:+* The 35 CANONICAL sites use `sysctlbyname("kern.hv_vmm_present", &int, &len, NULL, 0)`.+* The 4 entitlement-plist-only matches are pure plist substring hits.+* The 7 sandbox-profile-only matches are inside a compiled SBPL blob+ (string lives in `__TEXT,__const`, no executable xref, identical+ byte signature across the seven binaries).+* The 9 DEAD-string matches really are unreferenced (no ADRP/LDR+ computes the address; no 8-byte little-endian or 36-bit chained-fixup+ shape contains it).+* `SoundAnalysis` uses our string only as an offset anchor.++Inferred from framework / binary path and the canonical caching shape+(not from runtime tracing): the mapping in the table above of "what+each caller uses the result for". The disassembly proves *that* they+read the OID and how; it does not prove *what they branch on*. Every+"likely role" / "patching effect" claim above should be confirmed by+running the patched dylib and observing behaviour.diff --git a/research/hv_vmm_present_xref.json b/research/hv_vmm_present_xref.jsonnew file mode 100644index 00000000..2d910fee--- /dev/null+++ b/research/hv_vmm_present_xref.json@@ -0,0 +1,1351 @@+[+ {+ "path": "Applications/CheckerBoard.app/CheckerBoard",+ "consumers": [+ {+ "string_vma": "0x10006fb56",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x10006fb56",+ "sect": "__text",+ "xref_at": "0x1000192e8",+ "class": "CANONICAL",+ "snippet": [+ "0x1000192d8 stur wzr, [x29, #-4]",+ "0x1000192dc mov w8, #4",+ "0x1000192e0 str x8, [sp]",+ "0x1000192e4 adrp x0, #0x10006f000",+ "0x1000192e8 add x0, x0, #0xb56",+ "0x1000192ec sub x1, x29, #4",+ "0x1000192f0 mov x2, sp",+ "0x1000192f4 mov x3, #0",+ "0x1000192f8 mov x4, #0",+ "0x1000192fc bl #0x100048fa4"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "Applications/Family.app/Family",+ "consumers": []+ },+ {+ "path": "Applications/PeopleMessageService.app/PeopleMessageService",+ "consumers": []+ },+ {+ "path": "Applications/PeopleViewService.app/PeopleViewService",+ "consumers": []+ },+ {+ "path": "Applications/StoreKitUISceneService.app/StoreKitUISceneService",+ "consumers": [+ {+ "string_vma": "0x1000a2ca0",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x1000a2ca0",+ "sect": "__text",+ "xref_at": "0x100083f04",+ "class": "CANONICAL",+ "snippet": [+ "0x100083ef4 mov x1, #-1",+ "0x100083ef8 bl #0x100090090",+ "0x100083efc mov x21, x0",+ "0x100083f00 adrp x0, #0x1000a2000",+ "0x100083f04 add x0, x0, #0xca0",+ "0x100083f08 mov x1, x19",+ "0x100083f0c mov x2, x21",+ "0x100083f10 mov x3, #0",+ "0x100083f14 mov x4, #0",+ "0x100083f18 bl #0x100090200"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/CoreServices/ClarityBoard.app/ClarityBoard",+ "consumers": []+ },+ {+ "path": "System/Library/DataClassMigrators/MobileActivationMigrator.migrator/MobileActivationMigrator",+ "consumers": [+ {+ "string_vma": "0x72aa",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x72aa",+ "sect": "__text",+ "xref_at": "0x3024",+ "class": "CANONICAL",+ "snippet": [+ "0x3014 stur wzr, [x29, #-4]",+ "0x3018 mov w8, #4",+ "0x301c str x8, [sp]",+ "0x3020 adrp x0, #0x7000",+ "0x3024 add x0, x0, #0x2aa",+ "0x3028 sub x1, x29, #4",+ "0x302c mov x2, sp",+ "0x3030 mov x3, #0",+ "0x3034 mov x4, #0",+ "0x3038 bl #0x3788"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/ExtensionKit/Extensions/HostInferenceProviderService.appex/HostInferenceProviderService",+ "consumers": [+ {+ "string_vma": "0x1000112b0",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x1000112b0",+ "sect": "__text",+ "xref_at": "0x10000b890",+ "class": "CANONICAL",+ "snippet": [+ "0x10000b880 str x8, [sp, #0x18]",+ "0x10000b884 mov w8, #8",+ "0x10000b888 stp x8, xzr, [sp, #8]",+ "0x10000b88c adrp x0, #0x100011000",+ "0x10000b890 add x0, x0, #0x2b0",+ "0x10000b894 add x1, sp, #0x10",+ "0x10000b898 add x2, sp, #8",+ "0x10000b89c mov x3, #0",+ "0x10000b8a0 mov x4, #0",+ "0x10000b8a4 bl #0x1000103a4"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/Frameworks/CoreVideo.framework/CoreVideo",+ "consumers": [+ {+ "string_vma": "0x19d17a4bb",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x19d17a4bb",+ "sect": "__text",+ "xref_at": "0x19d122eb8",+ "class": "CANONICAL",+ "snippet": [+ "0x19d122ea8 add x29, sp, #0x10",+ "0x19d122eac mov w8, #4",+ "0x19d122eb0 str x8, [sp, #8]",+ "0x19d122eb4 adrp x0, #0x19d17a000",+ "0x19d122eb8 add x0, x0, #0x4bb",+ "0x19d122ebc adrp x1, #0x1ed568000",+ "0x19d122ec0 add x1, x1, #0x5bc",+ "0x19d122ec4 add x2, sp, #8",+ "0x19d122ec8 mov x3, #0",+ "0x19d122ecc mov x4, #0",+ "0x19d122ed0 bl #0x19eaf7f30"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/Frameworks/ManagedAppDistribution.framework/Support/managedappdistributiond",+ "consumers": [+ {+ "string_vma": "0x1006c25eb",+ "section": "__TEXT,__cstring",+ "class": "DEAD",+ "xrefs": []+ }+ ]+ },+ {+ "path": "System/Library/Frameworks/MediaToolbox.framework/MediaToolbox",+ "consumers": [+ {+ "string_vma": "0x196ee0991",+ "section": "__TEXT,__cstring",+ "class": "DEAD",+ "xrefs": []+ }+ ]+ },+ {+ "path": "System/Library/Frameworks/SoundAnalysis.framework/SoundAnalysis",+ "consumers": [+ {+ "string_vma": "0x1c9ad7cf0",+ "section": "__TEXT,__cstring",+ "class": "REFERENCED",+ "xrefs": [+ {+ "string_vma": "0x1c9ad7cf0",+ "sect": "__text",+ "xref_at": "0x1c989ba18",+ "class": "REFERENCED",+ "snippet": [+ "0x1c989ba08 stp x20, x19, [sp, #0x20]",+ "0x1c989ba0c stp x29, x30, [sp, #0x30]",+ "0x1c989ba10 add x29, sp, #0x30",+ "0x1c989ba14 adrp x8, #0x1c9ad7000",+ "0x1c989ba18 add x8, x8, #0xcf0",+ "0x1c989ba1c sub x20, x8, #0x20",+ "0x1c989ba20 mov w0, #4",+ "0x1c989ba24 mov x1, #-1",+ "0x1c989ba28 bl #0x1cca93270"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/Frameworks/StoreKit.framework/Support/storekitd",+ "consumers": [+ {+ "string_vma": "0x10031a890",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x10031a890",+ "sect": "__text",+ "xref_at": "0x100176f6c",+ "class": "CANONICAL",+ "snippet": [+ "0x100176f5c mov x1, #-1",+ "0x100176f60 bl #0x1002d586c",+ "0x100176f64 mov x21, x0",+ "0x100176f68 adrp x0, #0x10031a000",+ "0x100176f6c add x0, x0, #0x890",+ "0x100176f70 mov x1, x19",+ "0x100176f74 mov x2, x21",+ "0x100176f78 mov x3, #0",+ "0x100176f7c mov x4, #0",+ "0x100176f80 bl #0x1002d59ec"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/AAAFoundation.framework/AAAFoundation",+ "consumers": [+ {+ "string_vma": "0x1c86581a1",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x1c86581a1",+ "sect": "__text",+ "xref_at": "0x1c8650ee4",+ "class": "CANONICAL",+ "snippet": [+ "0x1c8650ed4 stur wzr, [x29, #-4]",+ "0x1c8650ed8 mov w8, #4",+ "0x1c8650edc str x8, [sp]",+ "0x1c8650ee0 adrp x0, #0x1c8658000",+ "0x1c8650ee4 add x0, x0, #0x1a1",+ "0x1c8650ee8 sub x1, x29, #4",+ "0x1c8650eec mov x2, sp",+ "0x1c8650ef0 mov x3, #0",+ "0x1c8650ef4 mov x4, #0",+ "0x1c8650ef8 bl #0x1cca79c30"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/AirPlaySupport.framework/AirPlaySupport",+ "consumers": [+ {+ "string_vma": "0x2223618a0",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x2223618a0",+ "sect": "__text",+ "xref_at": "0x222306a28",+ "class": "CANONICAL",+ "snippet": [+ "0x222306a18 stur wzr, [x29, #-0x14]",+ "0x222306a1c mov w8, #4",+ "0x222306a20 str x8, [sp, #0x10]",+ "0x222306a24 adrp x0, #0x222361000",+ "0x222306a28 add x0, x0, #0x8a0",+ "0x222306a2c sub x1, x29, #0x14",+ "0x222306a30 add x2, sp, #0x10",+ "0x222306a34 mov x3, #0",+ "0x222306a38 mov x4, #0",+ "0x222306a3c bl #0x223db21c0"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/AppStoreUtilities.framework/AppStoreUtilities",+ "consumers": [+ {+ "string_vma": "0x23ff916d7",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x23ff916d7",+ "sect": "__text",+ "xref_at": "0x23ff8bfe4",+ "class": "CANONICAL",+ "snippet": [+ "0x23ff8bfd4 str x8, [sp, #0x18]",+ "0x23ff8bfd8 mov w8, #4",+ "0x23ff8bfdc str x8, [sp, #8]",+ "0x23ff8bfe0 adrp x0, #0x23ff91000",+ "0x23ff8bfe4 add x0, x0, #0x6d7",+ "0x23ff8bfe8 adrp x1, #0x27e2bb000",+ "0x23ff8bfec add x1, x1, #0x2b8",+ "0x23ff8bff0 add x2, sp, #8",+ "0x23ff8bff4 mov x3, #0",+ "0x23ff8bff8 mov x4, #0",+ "0x23ff8bffc bl #0x245f81640"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/ApplePushService.framework/ApplePushService",+ "consumers": [+ {+ "string_vma": "0x1b235fd50",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x1b235fd50",+ "sect": "__text",+ "xref_at": "0x1b2358d10",+ "class": "CANONICAL",+ "snippet": [+ "0x1b2358d00 stur wzr, [x29, #-4]",+ "0x1b2358d04 mov w8, #4",+ "0x1b2358d08 str x8, [sp]",+ "0x1b2358d0c adrp x0, #0x1b235f000",+ "0x1b2358d10 add x0, x0, #0xd50",+ "0x1b2358d14 sub x1, x29, #4",+ "0x1b2358d18 mov x2, sp",+ "0x1b2358d1c mov x3, #0",+ "0x1b2358d20 mov x4, #0",+ "0x1b2358d24 bl #0x1b2746fb0"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/ApplePushService.framework/apsd",+ "consumers": [+ {+ "string_vma": "0x10015254a",+ "section": "__TEXT,__cstring",+ "class": "DEAD",+ "xrefs": []+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/AppleNeuralEngine.framework/AppleNeuralEngine",+ "consumers": [+ {+ "string_vma": "0x1ad297375",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x1ad297375",+ "sect": "__text",+ "xref_at": "0x1ad248248",+ "class": "CANONICAL",+ "snippet": [+ "0x1ad248238 stur wzr, [x29, #-4]",+ "0x1ad24823c mov w8, #4",+ "0x1ad248240 str x8, [sp]",+ "0x1ad248244 adrp x0, #0x1ad297000",+ "0x1ad248248 add x0, x0, #0x375",+ "0x1ad24824c sub x1, x29, #4",+ "0x1ad248250 mov x2, sp",+ "0x1ad248254 mov x3, #0",+ "0x1ad248258 mov x4, #0",+ "0x1ad24825c bl #0x1b26f3a40"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/CoreALD.framework/CoreALD",+ "consumers": []+ },+ {+ "path": "System/Library/PrivateFrameworks/CoreCDP.framework/CoreCDP",+ "consumers": [+ {+ "string_vma": "0x1dedfa62d",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x1dedfa62d",+ "sect": "__text",+ "xref_at": "0x1dedbb724",+ "class": "CANONICAL",+ "snippet": [+ "0x1dedbb714 stur wzr, [x29, #-4]",+ "0x1dedbb718 mov w8, #4",+ "0x1dedbb71c str x8, [sp]",+ "0x1dedbb720 adrp x0, #0x1dedfa000",+ "0x1dedbb724 add x0, x0, #0x62d",+ "0x1dedbb728 sub x1, x29, #4",+ "0x1dedbb72c mov x2, sp",+ "0x1dedbb730 mov x3, #0",+ "0x1dedbb734 mov x4, #0",+ "0x1dedbb738 bl #0x1e12ca690"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/CMCapture.framework/CMCapture",+ "consumers": [+ {+ "string_vma": "0x1ad0e79d1",+ "section": "__TEXT,__cstring",+ "class": "DEAD",+ "xrefs": []+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/AuthKit.framework/AuthKit",+ "consumers": [+ {+ "string_vma": "0x1933c11de",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x1933c11de",+ "sect": "__text",+ "xref_at": "0x19322f7e8",+ "class": "CANONICAL",+ "snippet": [+ "0x19322f7d8 mov x2, sp",+ "0x19322f7dc mov x8, #4",+ "0x19322f7e0 str x8, [sp]",+ "0x19322f7e4 adrp x0, #0x1933c1000",+ "0x19322f7e8 add x0, x0, #0x1de",+ "0x19322f7ec mov x3, #0",+ "0x19322f7f0 mov x4, #0",+ "0x19322f7f4 bl #0x193b16710"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/AppStoreDaemon.framework/Support/appstored",+ "consumers": [+ {+ "string_vma": "0x10046dae6",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x10046dae6",+ "sect": "__text",+ "xref_at": "0x1003e25b8",+ "class": "CANONICAL",+ "snippet": [+ "0x1003e25a8 str x8, [sp, #0x18]",+ "0x1003e25ac mov w8, #4",+ "0x1003e25b0 str x8, [sp, #8]",+ "0x1003e25b4 adrp x0, #0x10046d000",+ "0x1003e25b8 add x0, x0, #0xae6",+ "0x1003e25bc adrp x1, #0x1005aa000",+ "0x1003e25c0 add x1, x1, #0xfd0",+ "0x1003e25c4 add x2, sp, #8",+ "0x1003e25c8 mov x3, #0",+ "0x1003e25cc mov x4, #0",+ "0x1003e25d0 bl #0x1004115c8"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/CorePrescription.framework/CorePrescription",+ "consumers": [+ {+ "string_vma": "0x2471fe6ed",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x2471fe6ed",+ "sect": "__text",+ "xref_at": "0x2471ebc18",+ "class": "CANONICAL",+ "snippet": [+ "0x2471ebc08 stur wzr, [x29, #-4]",+ "0x2471ebc0c mov w8, #4",+ "0x2471ebc10 str x8, [sp]",+ "0x2471ebc14 adrp x0, #0x2471fe000",+ "0x2471ebc18 add x0, x0, #0x6ed",+ "0x2471ebc1c sub x1, x29, #4",+ "0x2471ebc20 mov x2, sp",+ "0x2471ebc24 mov x3, #0",+ "0x2471ebc28 mov x4, #0",+ "0x2471ebc2c bl #0x24c021520"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/DataDetectorsUI.framework/PlugIns/com.apple.DataDetectorsUI.ActionsExtension.appex/com.apple.DataDetectorsUI.ActionsExtension",+ "consumers": []+ },+ {+ "path": "System/Library/PrivateFrameworks/DeviceCheckInternal.framework/DeviceCheckInternal",+ "consumers": [+ {+ "string_vma": "0x2487a018c",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x2487a018c",+ "sect": "__text",+ "xref_at": "0x24878d10c",+ "class": "CANONICAL",+ "snippet": [+ "0x24878d0fc stur wzr, [x29, #-4]",+ "0x24878d100 mov w8, #4",+ "0x24878d104 str x8, [sp]",+ "0x24878d108 adrp x0, #0x2487a0000",+ "0x24878d10c add x0, x0, #0x18c",+ "0x24878d110 sub x1, x29, #4",+ "0x24878d114 mov x2, sp",+ "0x24878d118 mov x3, #0",+ "0x24878d11c mov x4, #0",+ "0x24878d120 bl #0x24c05d440"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/DVTInstrumentsUtilities.framework/DVTInstrumentsUtilities",+ "consumers": [+ {+ "string_vma": "0x247f42ad0",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x247f42ad0",+ "sect": "__text",+ "xref_at": "0x247f1154c",+ "class": "CANONICAL",+ "snippet": [+ "0x247f1153c stur wzr, [x29, #-4]",+ "0x247f11540 mov w8, #4",+ "0x247f11544 str x8, [sp]",+ "0x247f11548 adrp x0, #0x247f42000",+ "0x247f1154c add x0, x0, #0xad0",+ "0x247f11550 sub x1, x29, #4",+ "0x247f11554 mov x2, sp",+ "0x247f11558 mov x3, #0",+ "0x247f1155c mov x4, #0",+ "0x247f11560 bl #0x24c046270"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/DeviceIdentity.framework/DeviceIdentity",+ "consumers": [+ {+ "string_vma": "0x2260a4b25",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x2260a4b25",+ "sect": "__text",+ "xref_at": "0x2260862a4",+ "class": "CANONICAL",+ "snippet": [+ "0x226086294 stur wzr, [x29, #-4]",+ "0x226086298 mov w8, #4",+ "0x22608629c str x8, [sp]",+ "0x2260862a0 adrp x0, #0x2260a4000",+ "0x2260862a4 add x0, x0, #0xb25",+ "0x2260862a8 sub x1, x29, #4",+ "0x2260862ac mov x2, sp",+ "0x2260862b0 mov x3, #0",+ "0x2260862b4 mov x4, #0",+ "0x2260862b8 bl #0x22ac14380"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/CorePrescription.framework/XPCServices/CorePrescriptionService.xpc/CorePrescriptionService",+ "consumers": [+ {+ "string_vma": "0x100092175",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x100092175",+ "sect": "__text",+ "xref_at": "0x100005064",+ "class": "CANONICAL",+ "snippet": [+ "0x100005054 stur wzr, [x29, #-4]",+ "0x100005058 mov w8, #4",+ "0x10000505c str x8, [sp]",+ "0x100005060 adrp x0, #0x100092000",+ "0x100005064 add x0, x0, #0x175",+ "0x100005068 sub x1, x29, #4",+ "0x10000506c mov x2, sp",+ "0x100005070 mov x3, #0",+ "0x100005074 mov x4, #0",+ "0x100005078 bl #0x100082668"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/IDS.framework/identityservicesd.app/identityservicesd",+ "consumers": []+ },+ {+ "path": "System/Library/PrivateFrameworks/IOSurfaceAccelerator.framework/IOSurfaceAccelerator",+ "consumers": [+ {+ "string_vma": "0x2547cd71c",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x2547cd71c",+ "sect": "__text",+ "xref_at": "0x2547caa48",+ "class": "CANONICAL",+ "snippet": [+ "0x2547caa38 str wzr, [sp, #0xc]",+ "0x2547caa3c mov w8, #4",+ "0x2547caa40 str x8, [sp]",+ "0x2547caa44 adrp x0, #0x2547cd000",+ "0x2547caa48 add x0, x0, #0x71c",+ "0x2547caa4c add x1, sp, #0xc",+ "0x2547caa50 mov x2, sp",+ "0x2547caa54 mov x3, #0",+ "0x2547caa58 mov x4, #0",+ "0x2547caa5c bl #0x259aa0060"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/EmailFoundation.framework/EmailFoundation",+ "consumers": [+ {+ "string_vma": "0x1c61cd1f7",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x1c61cd1f7",+ "sect": "__text",+ "xref_at": "0x1c6165e88",+ "class": "CANONICAL",+ "snippet": [+ "0x1c6165e78 stur wzr, [x29, #-4]",+ "0x1c6165e7c mov w8, #4",+ "0x1c6165e80 str x8, [sp]",+ "0x1c6165e84 adrp x0, #0x1c61cd000",+ "0x1c6165e88 add x0, x0, #0x1f7",+ "0x1c6165e8c sub x1, x29, #4",+ "0x1c6165e90 mov x2, sp",+ "0x1c6165e94 mov x3, #0",+ "0x1c6165e98 mov x4, #0",+ "0x1c6165e9c bl #0x1c6957f00"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/FindMyBase.framework/FindMyBase",+ "consumers": [+ {+ "string_vma": "0x1df635420",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x1df635420",+ "sect": "__text",+ "xref_at": "0x1df5fb8d4",+ "class": "CANONICAL",+ "snippet": [+ "0x1df5fb8c4 stur wzr, [x29, #-0xc]",+ "0x1df5fb8c8 mov w8, #4",+ "0x1df5fb8cc str x8, [sp, #8]",+ "0x1df5fb8d0 adrp x0, #0x1df635000",+ "0x1df5fb8d4 add x0, x0, #0x420",+ "0x1df5fb8d8 sub x1, x29, #0xc",+ "0x1df5fb8dc add x2, sp, #8",+ "0x1df5fb8e0 mov x3, #0",+ "0x1df5fb8e4 mov x4, #0",+ "0x1df5fb8e8 bl #0x1e12d9f10"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/IDSFoundation.framework/IDSFoundation",+ "consumers": [+ {+ "string_vma": "0x1a7ea0fe4",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x1a7ea0fe4",+ "sect": "__text",+ "xref_at": "0x1a7c65dc4",+ "class": "CANONICAL",+ "snippet": [+ "0x1a7c65db4 str wzr, [sp, #0x1c]",+ "0x1a7c65db8 mov w8, #4",+ "0x1a7c65dbc str x8, [sp, #0x10]",+ "0x1a7c65dc0 adrp x0, #0x1a7ea0000",+ "0x1a7c65dc4 add x0, x0, #0xfe4",+ "0x1a7c65dc8 add x1, sp, #0x1c",+ "0x1a7c65dcc add x2, sp, #0x10",+ "0x1a7c65dd0 mov x3, #0",+ "0x1a7c65dd4 mov x4, #0",+ "0x1a7c65dd8 bl #0x1ac565650"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/MagnifierSupport.framework/MagnifierSupport",+ "consumers": [+ {+ "string_vma": "0x257d83670",+ "section": "__TEXT,__cstring",+ "class": "DEAD",+ "xrefs": []+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/MobileActivation.framework/MobileActivation",+ "consumers": [+ {+ "string_vma": "0x2598f06c6",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x2598f06c6",+ "sect": "__text",+ "xref_at": "0x2598e2618",+ "class": "CANONICAL",+ "snippet": [+ "0x2598e2608 stur wzr, [x29, #-4]",+ "0x2598e260c mov w8, #4",+ "0x2598e2610 str x8, [sp]",+ "0x2598e2614 adrp x0, #0x2598f0000",+ "0x2598e2618 add x0, x0, #0x6c6",+ "0x2598e261c sub x1, x29, #4",+ "0x2598e2620 mov x2, sp",+ "0x2598e2624 mov x3, #0",+ "0x2598e2628 mov x4, #0",+ "0x2598e262c bl #0x259b2a0d0"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/PhotoFoundation.framework/PhotoFoundation",+ "consumers": [+ {+ "string_vma": "0x1d8ba907c",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x1d8ba907c",+ "sect": "__text",+ "xref_at": "0x1d8b9e7fc",+ "class": "CANONICAL",+ "snippet": [+ "0x1d8b9e7ec stur wzr, [x29, #-4]",+ "0x1d8b9e7f0 mov w8, #4",+ "0x1d8b9e7f4 str x8, [sp]",+ "0x1d8b9e7f8 adrp x0, #0x1d8ba9000",+ "0x1d8b9e7fc add x0, x0, #0x7c",+ "0x1d8b9e800 sub x1, x29, #4",+ "0x1d8b9e804 mov x2, sp",+ "0x1d8b9e808 mov x3, #0",+ "0x1d8b9e80c mov x4, #0",+ "0x1d8b9e810 bl #0x1da721db0"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/Recon3D.framework/Recon3D",+ "consumers": [+ {+ "string_vma": "0x1cc912676",+ "section": "__TEXT,__cstring",+ "class": "DEAD",+ "xrefs": []+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/NeuralNetworks.framework/NeuralNetworks",+ "consumers": [+ {+ "string_vma": "0x25bb594c0",+ "section": "__TEXT,__cstring",+ "class": "DEAD",+ "xrefs": []+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/SonicKit.framework/SonicKit",+ "consumers": []+ },+ {+ "path": "System/Library/PrivateFrameworks/VideosUI.framework/VideosUI",+ "consumers": []+ },+ {+ "path": "System/Library/PrivateFrameworks/VFX.framework/VFX",+ "consumers": [+ {+ "string_vma": "0x1aff31940",+ "section": "__TEXT,__cstring",+ "class": "DEAD",+ "xrefs": []+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/RenderBox.framework/RenderBox",+ "consumers": [+ {+ "string_vma": "0x195e54555",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x195e54555",+ "sect": "__text",+ "xref_at": "0x195d344a0",+ "class": "CANONICAL",+ "snippet": [+ "0x195d34490 stur wzr, [x29, #-4]",+ "0x195d34494 mov w8, #4",+ "0x195d34498 str x8, [sp]",+ "0x195d3449c adrp x0, #0x195e54000",+ "0x195d344a0 add x0, x0, #0x555",+ "0x195d344a4 sub x1, x29, #4",+ "0x195d344a8 mov x2, sp",+ "0x195d344ac mov x3, #0",+ "0x195d344b0 mov x4, #0",+ "0x195d344b4 bl #0x19a8c1300"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/TrialServer.framework/TrialServer",+ "consumers": [+ {+ "string_vma": "0x26f32471e",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x26f32471e",+ "sect": "__text",+ "xref_at": "0x26f224120",+ "class": "CANONICAL",+ "snippet": [+ "0x26f224110 str wzr, [sp, #0xc]",+ "0x26f224114 mov w8, #4",+ "0x26f224118 str x8, [sp]",+ "0x26f22411c adrp x0, #0x26f324000",+ "0x26f224120 add x0, x0, #0x71e",+ "0x26f224124 add x1, sp, #0xc",+ "0x26f224128 mov x2, sp",+ "0x26f22412c mov x3, #0",+ "0x26f224130 mov x4, #0",+ "0x26f224134 bl #0x274313ed0"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/VisionKitCore.framework/VisionKitCore",+ "consumers": [+ {+ "string_vma": "0x1b442d9cf",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x1b442d9cf",+ "sect": "__text",+ "xref_at": "0x1b435f0a4",+ "class": "CANONICAL",+ "snippet": [+ "0x1b435f094 stur wzr, [x29, #-4]",+ "0x1b435f098 mov w8, #4",+ "0x1b435f09c str x8, [sp]",+ "0x1b435f0a0 adrp x0, #0x1b442d000",+ "0x1b435f0a4 add x0, x0, #0x9cf",+ "0x1b435f0a8 sub x1, x29, #4",+ "0x1b435f0ac mov x2, sp",+ "0x1b435f0b0 mov x3, #0",+ "0x1b435f0b4 mov x4, #0",+ "0x1b435f0b8 bl #0x1b8c77210"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/WatchdogServiceManagement.framework/WatchdogServiceManagement",+ "consumers": [+ {+ "string_vma": "0x272725b23",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x272725b23",+ "sect": "__text",+ "xref_at": "0x272725114",+ "class": "CANONICAL",+ "snippet": [+ "0x272725104 stur wzr, [x29, #-4]",+ "0x272725108 mov w8, #4",+ "0x27272510c str x8, [sp]",+ "0x272725110 adrp x0, #0x272725000",+ "0x272725114 add x0, x0, #0xb23",+ "0x272725118 sub x1, x29, #4",+ "0x27272511c mov x2, sp",+ "0x272725120 mov x3, #0",+ "0x272725124 mov x4, #0",+ "0x272725128 bl #0x274352f80"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "usr/sbin/absd",+ "consumers": []+ },+ {+ "path": "usr/lib/libMobileGestalt.dylib",+ "consumers": [+ {+ "string_vma": "0x1b0201c60",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x1b0201c60",+ "sect": "__text",+ "xref_at": "0x1b0198d00",+ "class": "CANONICAL",+ "snippet": [+ "0x1b0198cf0 stur wzr, [x29, #-4]",+ "0x1b0198cf4 mov w8, #4",+ "0x1b0198cf8 str x8, [sp]",+ "0x1b0198cfc adrp x0, #0x1b0201000",+ "0x1b0198d00 add x0, x0, #0xc60",+ "0x1b0198d04 sub x1, x29, #4",+ "0x1b0198d08 mov x2, sp",+ "0x1b0198d0c mov x3, #0",+ "0x1b0198d10 mov x4, #0",+ "0x1b0198d14 bl #0x1b27216f0"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "usr/sbin/fairplayd.H2",+ "consumers": []+ },+ {+ "path": "System/Library/PrivateFrameworks/caulk.framework/caulk",+ "consumers": [+ {+ "string_vma": "0x27512204f",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x27512204f",+ "sect": "__text",+ "xref_at": "0x275112808",+ "class": "CANONICAL",+ "snippet": [+ "0x2751127f8 stur wzr, [x29, #-4]",+ "0x2751127fc mov w8, #4",+ "0x275112800 str x8, [sp]",+ "0x275112804 adrp x0, #0x275122000",+ "0x275112808 add x0, x0, #0x4f",+ "0x27511280c sub x1, x29, #4",+ "0x275112810 mov x2, sp",+ "0x275112814 mov x3, #0",+ "0x275112818 mov x4, #0",+ "0x27511281c bl #0x277e067e0"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "usr/sbin/bluetoothd",+ "consumers": [+ {+ "string_vma": "0x1009c2a7f",+ "section": "__TEXT,__cstring",+ "class": "DEAD",+ "xrefs": []+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/WebGPU.framework/WebGPU",+ "consumers": [+ {+ "string_vma": "0x225722b6c",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x225722b6c",+ "sect": "__text",+ "xref_at": "0x22552c2bc",+ "class": "CANONICAL",+ "snippet": [+ "0x22552c2ac str wzr, [sp, #0xc]",+ "0x22552c2b0 mov w8, #4",+ "0x22552c2b4 str x8, [sp]",+ "0x22552c2b8 adrp x0, #0x225722000",+ "0x22552c2bc add x0, x0, #0xb6c",+ "0x22552c2c0 add x1, sp, #0xc",+ "0x22552c2c4 mov x2, sp",+ "0x22552c2c8 mov x3, #0",+ "0x22552c2cc mov x4, #0",+ "0x22552c2d0 bl #0x22ac033e0"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/Frameworks/CoreML.framework/CoreML",+ "consumers": [+ {+ "string_vma": "0x1950ed0d0",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x1950ed0d0",+ "xref_at": "0x194c3c754",+ "sect": "__text",+ "class": "CANONICAL",+ "snippet": [+ "0x194c3c744 stur wzr, [x29, #-0xc]",+ "0x194c3c748 mov w8, #4",+ "0x194c3c74c str x8, [sp, #8]",+ "0x194c3c750 adrp x0, #0x1950ed000",+ "0x194c3c754 add x0, x0, #0xd0",+ "0x194c3c758 sub x1, x29, #0xc",+ "0x194c3c75c add x2, sp, #8",+ "0x194c3c760 mov x3, #0",+ "0x194c3c764 mov x4, #0",+ "0x194c3c768 bl #0x19a8b2010",+ "0x194c3c76c cmp w0, #0",+ "0x194c3c770 ldur w8, [x29, #-0xc]",+ "0x194c3c774 ccmp w8, #0, #4, eq",+ "0x194c3c778 cset w8, ne",+ "0x194c3c77c adrp x9, #0x1eaec5000",+ "0x194c3c780 strb w8, [x9, #0x198]",+ "0x194c3c784 ldur x8, [x29, #-8]",+ "0x194c3c788 adrp x9, #0x1e69e9000",+ "0x194c3c78c ldr x9, [x9, #0x840]",+ "0x194c3c790 ldr x9, [x9]",+ "0x194c3c794 cmp x9, x8",+ "0x194c3c798 b.ne #0x194c3c7a8",+ "0x194c3c79c ldp x29, x30, [sp, #0x20]",+ "0x194c3c7a0 add sp, sp, #0x30",+ "0x194c3c7a4 retab ",+ "0x194c3c7a8 bl #0x19a8b0300",+ "0x194c3c7ac pacibsp ",+ "0x194c3c7b0 stp x20, x19, [sp, #-0x20]!"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/CoreRE.framework/CoreRE",+ "consumers": [+ {+ "string_vma": "0x1e3171b20",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x1e3171b20",+ "xref_at": "0x1e2790f28",+ "sect": "__text",+ "class": "CANONICAL",+ "snippet": [+ "0x1e2790f18 stur wzr, [x29, #-4]",+ "0x1e2790f1c mov w8, #4",+ "0x1e2790f20 str x8, [sp]",+ "0x1e2790f24 adrp x0, #0x1e3171000",+ "0x1e2790f28 add x0, x0, #0xb20",+ "0x1e2790f2c sub x1, x29, #4",+ "0x1e2790f30 mov x2, sp",+ "0x1e2790f34 mov x3, #0",+ "0x1e2790f38 mov x4, #0",+ "0x1e2790f3c bl #0x1e6908200",+ "0x1e2790f40 cbnz w0, #0x1e2790f58",+ "0x1e2790f44 ldur w8, [x29, #-4]",+ "0x1e2790f48 cmp w8, #0",+ "0x1e2790f4c cset w8, eq",+ "0x1e2790f50 adrp x9, #0x1ee186000",+ "0x1e2790f54 strb w8, [x9, #0xc8]",+ "0x1e2790f58 ldp x29, x30, [sp, #0x10]",+ "0x1e2790f5c add sp, sp, #0x20",+ "0x1e2790f60 retab ",+ "0x1e2790f64 pacibsp ",+ "0x1e2790f68 stp x20, x19, [sp, #-0x20]!",+ "0x1e2790f6c stp x29, x30, [sp, #0x10]",+ "0x1e2790f70 add x29, sp, #0x10",+ "0x1e2790f74 adrp x8, #0x1e6974000",+ "0x1e2790f78 ldr x0, [x8]",+ "0x1e2790f7c bl #0x1e323d4c0",+ "0x1e2790f80 bl #0x1e69076d0",+ "0x1e2790f84 mov x19, x0"+ ]+ }+ ]+ }+ ]+ },+ {+ "path": "System/Library/PrivateFrameworks/Espresso.framework/Espresso",+ "consumers": [+ {+ "string_vma": "0x1949204e5",+ "section": "__TEXT,__cstring",+ "class": "CANONICAL",+ "xrefs": [+ {+ "string_vma": "0x1949204e5",+ "xref_at": "0x193bef83c",+ "sect": "__text",+ "class": "CANONICAL",+ "snippet": [+ "0x193bef82c stur wzr, [x29, #-4]",+ "0x193bef830 mov w8, #4",+ "0x193bef834 str x8, [sp]",+ "0x193bef838 adrp x0, #0x194920000",+ "0x193bef83c add x0, x0, #0x4e5",+ "0x193bef840 sub x1, x29, #4",+ "0x193bef844 mov x2, sp",+ "0x193bef848 mov x3, #0",+ "0x193bef84c mov x4, #0",+ "0x193bef850 bl #0x19a8ac6e0",+ "0x193bef854 cbz w0, #0x193bef864",+ "0x193bef858 ldp x29, x30, [sp, #0x10]",+ "0x193bef85c add sp, sp, #0x20",+ "0x193bef860 retab ",+ "0x193bef864 ldur w8, [x29, #-4]",+ "0x193bef868 cmp w8, #0",+ "0x193bef86c cset w8, ne",+ "0x193bef870 adrp x9, #0x1eaeaf000",+ "0x193bef874 strb w8, [x9, #0x4f8]",+ "0x193bef878 ldp x29, x30, [sp, #0x10]",+ "0x193bef87c add sp, sp, #0x20",+ "0x193bef880 retab ",+ "0x193bef884 pacibsp ",+ "0x193bef888 sub sp, sp, #0x20",+ "0x193bef88c stp x29, x30, [sp, #0x10]",+ "0x193bef890 add x29, sp, #0x10",+ "0x193bef894 add x8, sp, #8",+ "0x193bef898 mov x1, #0"+ ]+ },+ {+ "string_vma": "0x1949204e5",+ "xref_at": "0x194236a24",+ "sect": "__text",+ "class": "CANONICAL",+ "snippet": [+ "0x194236a14 stur wzr, [x29, #-4]",+ "0x194236a18 mov w8, #4",+ "0x194236a1c str x8, [sp]",+ "0x194236a20 adrp x0, #0x194920000",+ "0x194236a24 add x0, x0, #0x4e5",+ "0x194236a28 sub x1, x29, #4",+ "0x194236a2c mov x2, sp",+ "0x194236a30 mov x3, #0",+ "0x194236a34 mov x4, #0",+ "0x194236a38 bl #0x19a8ac6e0",+ "0x194236a3c cbnz w0, #0x194236a4c",+ "0x194236a40 ldur w8, [x29, #-4]",+ "0x194236a44 adrp x9, #0x1ed6d6000",+ "0x194236a48 str w8, [x9, #0x350]",+ "0x194236a4c ldp x29, x30, [sp, #0x10]",+ "0x194236a50 add sp, sp, #0x20",+ "0x194236a54 retab ",+ "0x194236a58 pacibsp ",+ "0x194236a5c stp x29, x30, [sp, #-0x10]!",+ "0x194236a60 mov x29, sp",+ "0x194236a64 adrp x8, #0x1e698c000",+ "0x194236a68 ldr x0, [x8, #0xd58]",+ "0x194236a6c bl #0x1949b2400",+ "0x194236a70 adrp x8, #0x1ed6d6000",+ "0x194236a74 strb w0, [x8, #0x368]",+ "0x194236a78 ldp x29, x30, [sp], #0x10",+ "0x194236a7c retab ",+ "0x194236a80 adrp x8, #0x1ed6d6000"+ ]+ },+ {+ "string_vma": "0x1949204e5",+ "xref_at": "0x1942873cc",+ "sect": "__text",+ "class": "CANONICAL",+ "snippet": [+ "0x1942873bc stur wzr, [x29, #-4]",+ "0x1942873c0 mov w8, #4",+ "0x1942873c4 str x8, [sp]",+ "0x1942873c8 adrp x0, #0x194920000",+ "0x1942873cc add x0, x0, #0x4e5",+ "0x1942873d0 sub x1, x29, #4",+ "0x1942873d4 mov x2, sp",+ "0x1942873d8 mov x3, #0",+ "0x1942873dc mov x4, #0",+ "0x1942873e0 bl #0x19a8ac6e0",+ "0x1942873e4 cbnz w0, #0x1942873f4",+ "0x1942873e8 ldur w8, [x29, #-4]",+ "0x1942873ec adrp x9, #0x1ed6d6000",+ "0x1942873f0 str w8, [x9, #0x1d8]",+ "0x1942873f4 ldp x29, x30, [sp, #0x10]",+ "0x1942873f8 add sp, sp, #0x20",+ "0x1942873fc retab ",+ "0x194287400 b #0x19a8aad90",+ "0x194287404 b #0x19a8aad90",+ "0x194287408 b #0x19a8aad90",+ "0x19428740c b #0x19a8aad90",+ "0x194287410 b #0x19a8aad90",+ "0x194287414 pacibsp ",+ "0x194287418 sub sp, sp, #0x60",+ "0x19428741c stp x22, x21, [sp, #0x30]",+ "0x194287420 stp x20, x19, [sp, #0x40]",+ "0x194287424 stp x29, x30, [sp, #0x50]",+ "0x194287428 add x29, sp, #0x50"+ ]+ }+ ]+ }+ ]+ }+]\ No newline at end of filediff --git a/scripts/cfw_install_exp.sh b/scripts/cfw_install_exp.shold mode 100755new mode 100644index 4db72bf2..4c683dd0--- a/scripts/cfw_install_exp.sh+++ b/scripts/cfw_install_exp.sh@@ -2,11 +2,24 @@# cfw_install_exp.sh — Install base CFW + JB extensions + EXP experimental# patches on vphone via SSH ramdisk.#-# Currently runs the same set of phases as the JB install script (JB-1..JB-5):-# launchd jetsam patch, dylib injection, procursus bootstrap, BaseBin hook-# deployment, first-boot setup. Subsequent commits in this branch add the-# EXP-only experimental phases (DSC pre-step, EXP-JB-3.5 watchdogd, EXP-JB-6-# post-restore DT, EXP-JB-7 build-version) on top.+# Runs the base CFW installer first (phases 1-7), the JB-specific+# modifications (launchd jetsam patch, dylib injection, procursus bootstrap,+# BaseBin hook deployment, JB-1..JB-5), and additionally the experimental+# phases — labeled `EXP-JB-N` to make their EXP-only scope obvious:+# - Pre-step : byte-5 mangle of kern.hv_vmm_present in DSC dylibs+# (paired with KernelEXPPatcher's kernel-side rename).+# - EXP-JB-3.5 : surgical 2-insn patch of watchdogd's hv_vmm cache ++# slot re-attest of the standalone Mach-O.+# - EXP-JB-6 : post-restore DT identity rewrite (root model /+# target-type / compatible[0]) inside+# /mnt5/.../devicetree.img4.+# - EXP-JB-7 : optional ProductBuildVersion rewrite in+# SystemVersion.plist (gated on the SPOOF_BUILD env var).+#+# Stages JB-1..JB-5 remain genuine jailbreak phases (inherited from the JB+# pipeline). Stages prefixed EXP-JB-* are EXP-exclusive — they do NOT run+# when the JB or DEV install scripts are used. JB and DEV remain on their+# pre-experimental baseline.## Prerequisites (in addition to cfw_install.sh requirements):# - cfw_jb_input/ or resources/cfw_jb_input.tar.zst present@@ -38,6 +51,64 @@ PYTHON3="$(_resolve_python3)"# ════════════════════════════════════════════════════════════════echo "[*] cfw_install_exp.sh — Installing CFW + JB extensions + EXP experimental patches..."echo ""++# ────────────────────────────────────────────────────────────────────+# Pre-step: patch hv_vmm_present user-mode consumers in the SystemOS+# Cryptex's DSC chunks BEFORE running cfw_install.sh.+#+# cfw_install.sh decrypts the SystemOS Cryptex AEA into+# $TEMP_DIR/CryptexSystemOS.dmg and reuses it on subsequent runs. We+# pre-create that decrypted DMG here, mount it, patch the DSC chunks+# in place, unmount, and let cfw_install.sh pick up the cached+# (already-patched) DMG. cfw_install.sh itself is unmodified — this+# is the EXP variant's device-like user-mode patching, kept out of+# the JB install path so JB remains unaffected.+# ────────────────────────────────────────────────────────────────────+VM_DIR_ABS="$(cd "${VM_DIR:-.}" && pwd)"+JB_TEMP_DIR="$VM_DIR_ABS/.cfw_temp"+JB_SYSOS_DMG="$JB_TEMP_DIR/CryptexSystemOS.dmg"+JB_MNT_SYSOS="$JB_TEMP_DIR/mnt_sysos_hv_vmm"+mkdir -p "$JB_TEMP_DIR"++# Find the restore directory (same logic as cfw_install.sh)+JB_RESTORE_DIR=""+for d in "$VM_DIR_ABS"/iPhone*_Restore; do+ [[ -d "$d" ]] && { JB_RESTORE_DIR="$d"; break; }+done++if [[ -z "$JB_RESTORE_DIR" ]]; then+ echo "[!] hv_vmm DSC patch: no restore directory found, skipping"+elif [[ ! -f "$JB_SYSOS_DMG" ]]; then+ # Not yet decrypted — decrypt to the cache location cfw_install.sh expects.+ echo "[*] hv_vmm DSC patch: decrypting SystemOS into cache..."+ JB_CRYPTEX_SYSOS=$("$PYTHON3" "$SCRIPT_DIR/patchers/cfw.py" cryptex-paths "$JB_RESTORE_DIR/iPhone-BuildManifest.plist" | head -1)+ JB_AEA_KEY=$(ipsw fw aea --key "$JB_RESTORE_DIR/$JB_CRYPTEX_SYSOS")+ aea decrypt -i "$JB_RESTORE_DIR/$JB_CRYPTEX_SYSOS" -o "$JB_SYSOS_DMG" -key-value "$JB_AEA_KEY"+fi++if [[ -f "$JB_SYSOS_DMG" ]]; then+ # Mount, patch chunks, unmount. Idempotent: re-running on an already+ # patched DMG is a no-op (patcher detects already-patched form).+ echo "[*] hv_vmm DSC patch: mounting cached SystemOS DMG..."+ mkdir -p "$JB_MNT_SYSOS"+ sudo hdiutil detach "$JB_MNT_SYSOS" -force 2>/dev/null || true+ sudo hdiutil attach -mountpoint "$JB_MNT_SYSOS" "$JB_SYSOS_DMG" -nobrowse -owners off++ JB_DSC_CHUNKS_DIR="$JB_MNT_SYSOS/System/Library/Caches/com.apple.dyld"+ if [[ -d "$JB_DSC_CHUNKS_DIR" ]]; then+ echo "[*] hv_vmm DSC patch: patching chunks under $JB_DSC_CHUNKS_DIR..."+ "$SCRIPT_DIR/patch_hv_vmm_userland.sh" dsc "$JB_DSC_CHUNKS_DIR"+ echo "[+] hv_vmm DSC patch: chunks patched"+ else+ echo "[-] hv_vmm DSC patch: $JB_DSC_CHUNKS_DIR not found, skipping"+ fi++ sudo hdiutil detach "$JB_MNT_SYSOS" -force+fi++# Now run the regular CFW install. It will see the cached (patched)+# CryptexSystemOS.dmg and use it as-is, so the patched DSC chunks land+# in /mnt1/System/Cryptexes/OS on the device.CFW_SKIP_HALT=1 zsh "$SCRIPT_DIR/cfw_install.sh" "$VM_DIR"# ════════════════════════════════════════════════════════════════diff --git a/scripts/patch_hv_vmm_userland.sh b/scripts/patch_hv_vmm_userland.shnew file mode 100755index 00000000..f996e4c9--- /dev/null+++ b/scripts/patch_hv_vmm_userland.sh@@ -0,0 +1,66 @@+#!/bin/zsh+# patch_hv_vmm_userland.sh — Apply the user-mode hv_vmm_present patch.+#+# Two operations, chosen by the first arg:+#+# dsc <chunks_dir>+# Patch the canonical sysctlbyname("kern.hv_vmm_present", ...) sites+# inside the DSC chunks at <chunks_dir>. <chunks_dir> is the directory+# holding `dyld_shared_cache_arm64e[.NN]` files, typically the+# mounted SystemOS Cryptex's `System/Library/Caches/com.apple.dyld/`.+# Skips the compute/accel dylibs (CoreML, Espresso, ANE, CoreRE,+# RenderBox, WebGPU, caulk, IOSurfaceAccelerator).+#+# standalone <binary>+# Patch a single standalone Mach-O file in place. Idempotent.+# Caller is responsible for re-signing (ldid).+#+# This script is a thin wrapper around `scripts/patchers/cfw.py`. It+# exists so cfw_install_dev.sh and cfw_install_jb.sh can call a single+# entry point without duplicating Python venv/python3 resolution logic.+#+# Used by: cfw_install_dev.sh, cfw_install_jb.sh++set -euo pipefail++SCRIPT_DIR="${0:a:h}"++[[ -n "${_VPHONE_PATH:-}" ]] && export PATH="$_VPHONE_PATH"++_resolve_python3() {+ local venv_py="${SCRIPT_DIR:h}/.venv/bin/python3"+ if [[ -x "$venv_py" ]]; then+ echo "$venv_py"+ else+ command -v python3 || true+ fi+}+PYTHON3="$(_resolve_python3)"++usage() {+ cat <<EOF >&2+Usage:+ $0 dsc <chunks_dir>+ $0 standalone <binary>+EOF+ exit 2+}++(( $# >= 1 )) || usage+op="$1"; shift++case "$op" in+ dsc)+ (( $# >= 1 )) || usage+ echo "[*] Patching hv_vmm_present consumers in DSC chunks under: $1"+ "$PYTHON3" "$SCRIPT_DIR/patchers/cfw.py" patch-hv-vmm-dsc "$1"+ ;;+ standalone)+ (( $# >= 1 )) || usage+ echo "[*] Patching hv_vmm_present consumers in: $1"+ "$PYTHON3" "$SCRIPT_DIR/patchers/cfw.py" patch-hv-vmm "$1"+ ;;+ *)+ usage+ ;;+esacdiff --git a/scripts/patchers/cfw.py b/scripts/patchers/cfw.pyindex 116096ba..3aff4db4 100755--- a/scripts/patchers/cfw.py+++ b/scripts/patchers/cfw.py@@ -23,6 +23,12 @@ Commands:patch-launchd-jetsam <binary>Patch launchd jetsam panic guard to avoid initproc crash loop.+ patch-hv-vmm-dsc <chunks_dir> [--dry-run]+ Same patch, applied in place to the DSC chunks under+ <chunks_dir> (e.g. /System/Library/Caches/com.apple.dyld inside+ the mounted SystemOS Cryptex). Targets a fixed list of identity,+ store, and consumer-service dylibs; skips compute/accel libs.+inject-daemons <launchd.plist> <daemon_dir>Inject bash/dropbear/trollvnc into launchd.plist.@@ -32,6 +38,7 @@ Commands:Dependencies:pip install capstone keystone-engine+ ipsw CLI in $PATH (only required for patch-hv-vmm-dsc, experimental variant only)"""import os@@ -46,12 +53,14 @@ if __name__ == "__main__":from patchers.cfw_patch_cache_loader import patch_launchd_cache_loaderfrom patchers.cfw_patch_mobileactivationd import patch_mobileactivationdfrom patchers.cfw_patch_jetsam import patch_launchd_jetsam+ from patchers.cfw_patch_hv_vmm_dsc import patch_hv_vmm_in_dscfrom patchers.cfw_daemons import parse_cryptex_paths, inject_daemonselse:from .cfw_patch_seputil import patch_seputilfrom .cfw_patch_cache_loader import patch_launchd_cache_loaderfrom .cfw_patch_mobileactivationd import patch_mobileactivationdfrom .cfw_patch_jetsam import patch_launchd_jetsam+ from .cfw_patch_hv_vmm_dsc import patch_hv_vmm_in_dscfrom .cfw_daemons import parse_cryptex_paths, inject_daemons@@ -98,6 +107,14 @@ def main():if not patch_launchd_jetsam(sys.argv[2]):sys.exit(1)+ elif cmd == "patch-hv-vmm-dsc":+ if len(sys.argv) < 3:+ print("Usage: patch_cfw.py patch-hv-vmm-dsc <chunks_dir> [--dry-run]")+ sys.exit(1)+ dry_run = "--dry-run" in sys.argv[3:]+ results = patch_hv_vmm_in_dsc(sys.argv[2], dry_run=dry_run)+ sys.exit(0)+elif cmd == "inject-daemons":if len(sys.argv) < 4:print("Usage: patch_cfw.py inject-daemons <launchd.plist> <daemon_dir>")@@ -129,7 +146,7 @@ def main():print(f"Unknown command: {cmd}")print("Commands: cryptex-paths, patch-seputil, patch-launchd-cache-loader,")print(" patch-mobileactivationd, patch-launchd-jetsam,")- print(" inject-daemons, inject-dylib")+ print(" patch-hv-vmm-dsc, inject-daemons, inject-dylib")sys.exit(1)diff --git a/scripts/patchers/cfw_dsc_chunks.py b/scripts/patchers/cfw_dsc_chunks.pynew file mode 100644index 00000000..8ba10547--- /dev/null+++ b/scripts/patchers/cfw_dsc_chunks.py@@ -0,0 +1,361 @@+"""dyld shared cache (split / chunked) byte-level helper.++The iOS 26 SystemOS Cryptex ships the DSC as multiple files:++ /System/Library/Caches/com.apple.dyld/dyld_shared_cache_arm64e+ /System/Library/Caches/com.apple.dyld/dyld_shared_cache_arm64e.01+ /System/Library/Caches/com.apple.dyld/dyld_shared_cache_arm64e.02+ ...++The first file (no suffix) holds the cache header; suffixed files+(`.NN`) hold subcache regions. Together they map a contiguous virtual+address space.++This module gives us:++ chunks = DSCChunks(chunks_dir)+ chunks.bytes_at_vma(vma, length) -> bytes+ chunks.find_chunk_for_vma(vma) -> (chunk_path, file_offset)+ chunks.write_at_vma(vma, data) -> None # persists to chunk on disk++It does *not* extract dylibs. It treats the DSC as a flat virtual+address space and gives byte-level access. That's the minimum we need+to apply 4-byte instruction patches at known vmaddrs.++The dyld_cache_header layout we use is intentionally minimal:+ char magic[16];+ uint32_t mappingOffset;+ uint32_t mappingCount;+ ...+ uint64_t sharedRegionStart; (offset 0x60 in modern caches)+ uint64_t sharedRegionSize;+ ...++The dyld_cache_mapping_info entries (mappingCount of them) each look:+ uint64_t address;+ uint64_t size;+ uint64_t fileOffset;+ uint32_t maxProt;+ uint32_t initProt;++For chunked caches (.NN files), each chunk has its own header with its+own mappings; the mappings address ranges are non-overlapping across+chunks.++Reference: dyld project, dyld_cache_format.h.+"""++import os+import struct+import re+import glob+++CHUNK_GLOB_NAMES = (+ "dyld_shared_cache_arm64e",+ "dyld_shared_cache_arm64e.[0-9]",+ "dyld_shared_cache_arm64e.[0-9][0-9]",+ "dyld_shared_cache_arm64e.symbols",+)+++def _enumerate_chunks(chunks_dir):+ """Return list of chunk file paths in numeric order; the unsuffixed file+ first, then .01, .02, ... `.symbols` is excluded (it doesn't map code).+ """+ names = []+ for name in os.listdir(chunks_dir):+ if not name.startswith("dyld_shared_cache_arm64e"):+ continue+ if name.endswith(".symbols") or name.endswith(".map"):+ continue+ names.append(name)++ def sort_key(n):+ # base file (no suffix) first, then .01, .02, ...+ m = re.match(r"^dyld_shared_cache_arm64e(?:\.(\d+))?$", n)+ if m:+ return (0, int(m.group(1)) if m.group(1) else -1)+ return (1, n)++ names.sort(key=sort_key)+ return [os.path.join(chunks_dir, n) for n in names]+++def _parse_chunk_mappings(path):+ """Return list of dicts {addr, size, file_off, max_prot, init_prot}+ for one chunk file.++ Only the standard dyld_cache_mapping_info entries are used. Slide-info+ mappings (`mappingWithSlideOffset`) are ignored — for our purposes we+ only care about which virtual address comes from which file offset,+ and the standard mappings cover that.++ `init_prot` is the VM_PROT mask: VM_PROT_READ=1, VM_PROT_WRITE=2,+ VM_PROT_EXECUTE=4.+ """+ with open(path, "rb") as f:+ head = f.read(0x100)+ magic = head[:16].rstrip(b"\x00")+ # Modern arm64e caches start with "dyld_v1 arm64e"+ if not magic.startswith(b"dyld"):+ return []++ mapping_off = struct.unpack_from("<I", head, 16)[0]+ mapping_cnt = struct.unpack_from("<I", head, 20)[0]+ if mapping_cnt > 64 or mapping_off > 0x10000:+ # sanity bounds+ return []++ with open(path, "rb") as f:+ f.seek(mapping_off)+ raw = f.read(mapping_cnt * 32)++ out = []+ for i in range(mapping_cnt):+ off = i * 32+ addr, size, file_off, max_prot, init_prot = \+ struct.unpack_from("<QQQII", raw, off)+ out.append({+ "addr": addr, "size": size, "file_off": file_off,+ "max_prot": max_prot, "init_prot": init_prot,+ })+ return out+++class DSCChunks:+ """Lazy random-access byte view over a chunked dyld shared cache."""++ def __init__(self, chunks_dir):+ self.chunks_dir = chunks_dir+ self._chunk_paths = _enumerate_chunks(chunks_dir)+ if not self._chunk_paths:+ raise FileNotFoundError(+ f"No dyld_shared_cache_arm64e* chunks found under {chunks_dir!r}"+ )++ # Build (addr_start, addr_end, file_off, init_prot, chunk_path) ranges.+ ranges = []+ for cp in self._chunk_paths:+ for m in _parse_chunk_mappings(cp):+ if m["size"] == 0:+ continue+ ranges.append(+ (+ m["addr"],+ m["addr"] + m["size"],+ m["file_off"],+ m["init_prot"],+ cp,+ )+ )+ if not ranges:+ raise RuntimeError(+ f"No DSC mappings parsed under {chunks_dir!r} — "+ f"chunks present but headers unrecognised"+ )++ # Sort by addr_start for binary-search later.+ ranges.sort(key=lambda r: r[0])+ self._ranges = ranges++ def __repr__(self):+ return (+ f"DSCChunks({self.chunks_dir!r}, "+ f"{len(self._chunk_paths)} chunk(s), "+ f"{len(self._ranges)} mapping(s), "+ f"vm 0x{self._ranges[0][0]:X}..0x{self._ranges[-1][1]:X})"+ )++ def find_chunk_for_vma(self, vma):+ """Return (chunk_path, file_offset) for `vma`, or None if unmapped."""+ # Linear scan is fine; mapping count is < ~80.+ for addr_start, addr_end, file_off, _init_prot, cp in self._ranges:+ if addr_start <= vma < addr_end:+ return (cp, file_off + (vma - addr_start))+ return None++ def bytes_at_vma(self, vma, length):+ """Read `length` bytes starting at `vma`. Must be contained in one+ mapping (we don't stitch across mappings)."""+ loc = self.find_chunk_for_vma(vma)+ if loc is None:+ raise KeyError(f"vma 0x{vma:X} is not mapped by any chunk")+ cp, foff = loc+ with open(cp, "rb") as f:+ f.seek(foff)+ data = f.read(length)+ if len(data) != length:+ raise IOError(+ f"short read at vma 0x{vma:X} ({len(data)} of {length})"+ )+ return data++ def write_at_vma(self, vma, data):+ """Persist `data` bytes at `vma` to the right chunk file. The+ target span must lie within a single mapping."""+ loc = self.find_chunk_for_vma(vma)+ if loc is None:+ raise KeyError(f"vma 0x{vma:X} is not mapped by any chunk")+ # Verify the entire span is in this mapping.+ end_loc = self.find_chunk_for_vma(vma + len(data) - 1)+ if end_loc is None or end_loc[0] != loc[0]:+ raise ValueError(+ f"write at vma 0x{vma:X} length {len(data)} "+ f"crosses a chunk boundary — refusing"+ )+ cp, foff = loc+ with open(cp, "r+b") as f:+ f.seek(foff)+ f.write(data)++ # ---- additional helpers used by the DSC-native canonical-site finder ----++ VM_PROT_EXECUTE = 4++ def mappings(self):+ """Return [(vmaddr_start, vmaddr_end, file_offset, init_prot, chunk_path)]."""+ return list(self._ranges)++ def find_string_vmas(self, needle):+ """Return all vmaddrs where `needle` (bytes) appears within a single+ mapping, anchored either at the mapping start or after a NUL byte.++ Restricted to executable (RX) mappings — `__TEXT` segments where+ `__TEXT,__cstring` lives. This skips the giant LINKEDIT and+ __DATA/__DATA_CONST mappings entirely.+ """+ out = []+ for addr_start, addr_end, file_off, init_prot, cp in self._ranges:+ if not (init_prot & self.VM_PROT_EXECUTE):+ continue+ size = addr_end - addr_start+ with open(cp, "rb") as f:+ f.seek(file_off)+ buf = f.read(size)+ i = 0+ while True:+ p = buf.find(needle, i)+ if p < 0:+ break+ if p == 0 or buf[p - 1] == 0:+ out.append(addr_start + p)+ i = p + 1+ return out++ def iter_executable_mapping_bytes(self):+ """Yield (chunk_path, file_offset, vmaddr_start, mapping_bytes) for+ every mapping whose `initProt` includes VM_PROT_EXECUTE.++ Non-executable mappings (LINKEDIT, __DATA, __DATA_CONST) are+ skipped so we never try to disassemble them.+ """+ for addr_start, addr_end, file_off, init_prot, cp in self._ranges:+ if not (init_prot & self.VM_PROT_EXECUTE):+ continue+ size = addr_end - addr_start+ with open(cp, "rb") as f:+ f.seek(file_off)+ buf = f.read(size)+ yield cp, file_off, addr_start, buf++ def read_at_vma(self, vma, length, *, allow_short=False):+ """Read `length` bytes starting at `vma`, contained in a single+ mapping. With `allow_short=True`, returns whatever is available+ within the containing mapping instead of raising."""+ for addr_start, addr_end, file_off, _init_prot, cp in self._ranges:+ if addr_start <= vma < addr_end:+ avail = addr_end - vma+ want = length if avail >= length else (avail if allow_short else 0)+ if want == 0:+ raise IOError(+ f"read at vma 0x{vma:X} len {length} would cross "+ f"a chunk boundary"+ )+ with open(cp, "rb") as f:+ f.seek(file_off + (vma - addr_start))+ data = f.read(want)+ return data+ raise KeyError(f"vma 0x{vma:X} is not mapped by any chunk")++ _MH_MAGIC_64_LE = b"\xcf\xfa\xed\xfe"++ def find_macho_header_before(self, vma, *, max_walk=64 * 1024 * 1024):+ """Walk backwards from `vma` looking for a Mach-O 64 header+ (magic 0xfeedfacf) at a page boundary. Returns the magic's+ vmaddr, or None if not found within `max_walk` bytes inside the+ same mapping.++ Mach-O headers in the DSC are placed at page-aligned vmaddrs at+ the start of each dylib's __TEXT segment, and an arm64e iOS+ dylib's header is in the same mapping as its __text section, so+ we only have to search within the containing mapping.++ Implementation: read the relevant bytes from disk once and use+ `bytes.rfind` to locate the magic, then accept only page-aligned+ hits. Searching ~36 MiB takes <50 ms in pure Python.+ """+ for addr_start, addr_end, file_off, _init_prot, cp in self._ranges:+ if not (addr_start <= vma < addr_end):+ continue+ local_off = vma - addr_start+ scan_len = min(local_off, max_walk)+ scan_start = local_off - scan_len+ with open(cp, "rb") as f:+ f.seek(file_off + scan_start)+ buf = f.read(scan_len + 4) # +4 so a hit at end is captured+ i = len(buf)+ while True:+ found = buf.rfind(self._MH_MAGIC_64_LE, 0, i)+ if found < 0:+ return None+ candidate_vma = addr_start + scan_start + found+ if (candidate_vma & 0xFFF) == 0:+ return candidate_vma+ # Keep searching backwards.+ i = found+ # unreachable+ return None++ def read_install_name_at(self, header_vma):+ """Given the vmaddr of a Mach-O 64 header in the DSC, return the+ dylib's install name (LC_ID_DYLIB), or None if the file isn't a+ dylib or the LC isn't present.+ """+ # Read the first 64KB of LCs (more than enough).+ try:+ head = self.read_at_vma(header_vma, 64 * 1024, allow_short=True)+ except (KeyError, IOError):+ return None+ if struct.unpack_from("<I", head, 0)[0] != 0xFEEDFACF:+ return None+ ncmds = struct.unpack_from("<I", head, 16)[0]+ sizeofcmds = struct.unpack_from("<I", head, 20)[0]+ # Sanity-bound the LC walk.+ if ncmds > 4096 or sizeofcmds > 64 * 1024:+ return None+ o = 32+ for _ in range(ncmds):+ if o + 8 > len(head):+ return None+ cmd, cmdsize = struct.unpack_from("<II", head, o)+ if cmdsize < 8 or cmdsize > 64 * 1024:+ return None+ if cmd == 0xD: # LC_ID_DYLIB+ # struct dylib_command { cmd, cmdsize, dylib { name(uint32 offset),+ # timestamp, current_version, compatibility_version } }+ name_off_in_cmd = struct.unpack_from("<I", head, o + 8)[0]+ name_pos = o + name_off_in_cmd+ if name_pos >= len(head) or name_pos >= o + cmdsize:+ return None+ end = head.find(b"\x00", name_pos, o + cmdsize)+ if end < 0:+ return None+ try:+ return head[name_pos:end].decode("utf-8")+ except UnicodeDecodeError:+ return head[name_pos:end].decode("latin-1")+ o += cmdsize+ if o > sizeofcmds + 32:+ return None+ return Nonediff --git a/scripts/patchers/cfw_dsc_codesign.py b/scripts/patchers/cfw_dsc_codesign.pynew file mode 100644index 00000000..4390781b--- /dev/null+++ b/scripts/patchers/cfw_dsc_codesign.py@@ -0,0 +1,294 @@+"""DSC code-signature page-hash re-attestation.++Background+----------+On iPhone17,3 / iOS 26.1 with TXM (`codeSigningMonitor == 2`) enabled,+the kernel defers per-page hash validation to TXM (see source comments+in `research/reference/xnu/osfmk/vm/vm_fault.c:2763-2780`). TXM has+the original slot hashes baked in via the registered DSC signature, so+any byte-mangle inside an executable mapping causes+`KERN_PROTECTION_FAILURE` / `CODESIGNING / Invalid Page` SIGKILL on+the first demand-page-in of the affected 16 KiB page. (An earlier+XNU-side `_cs_validate_page` short-circuit kernel patch was attempted+and shipped, then removed — it never fires on this hardware because+the CSM-defer gate in `vm_fault_cs_check_violation` runs first.)++To make a byte-mangled DSC dylib executable again, we recompute the+SHA-256 slot hash for the 16 KiB page that contains the modification+and overwrite the matching entry in the chunk's `CS_CodeDirectory`.++DSC code-signature layout (verified empirically on+`iPhone17,3_26.1_23B85` chunked DSC):++ Each chunk file has a `dyld_cache_header`:+ u64 codeSignatureOffset @ 0x28 (chunk-file relative)+ u64 codeSignatureSize @ 0x30++ At `codeSignatureOffset` there's a `CS_SuperBlob` (big-endian):+ u32 magic = 0xFADE0CC0+ u32 length+ u32 count+ CS_BlobIndex blobs[count]:+ u32 type+ u32 offset (within SuperBlob)++ The CSSLOT_CODEDIRECTORY entry (type==0) points at a+ `CS_CodeDirectory` blob (also big-endian):+ u32 magic = 0xFADE0C02+ u32 length+ u32 version+ u32 flags+ u32 hashOffset (within blob — to slot[0])+ u32 identOffset+ u32 nSpecialSlots+ u32 nCodeSlots+ u32 codeLimit (chunk-file byte range covered)+ u8 hashSize (32 for SHA-256)+ u8 hashType (2 for SHA-256)+ u8 platform+ u8 pageSize (log2 — 14 == 16 KiB)+ u32 spare2+ ... (more in later versions)++ Slot N stores SHA-256 of chunk bytes [N*pageSize, (N+1)*pageSize)+ and lives at chunk-file offset:+ codeSignatureOffset + cd_offset_in_superblob+ + hashOffset + N * hashSize++DSC dylibs do NOT carry their own LC_CODE_SIGNATURE — only the+chunk-level signature applies. Page indexing is against the chunk+file offset, not the dylib's __TEXT offset.++CDHash side effect (empirically benign)+---------------------------------------+Modifying slot hashes changes the CodeDirectory's contents, which+changes its CDHash (SHA-256 of the CD blob). The existing JB kernel+patch `patch_amfi_cdhash_in_trustcache` bypasses AMFI's per-image+CDHash trust-cache lookup, and TXM accepts the modified-CDHash DSC+at cache-load time on iPhone17,3 / iOS 26.1 (verified: device boots+with re-attested chunks). If a future build introduces a stricter+CDHash check at DSC mount, the next step would be a TXM-side bypass+at cache load — at the time this module was written that wasn't+needed.++"""++import hashlib+import os+import struct+++# CS constants.+CSMAGIC_EMBEDDED_SIGNATURE = 0xFADE0CC0+CSMAGIC_CODEDIRECTORY = 0xFADE0C02+CSSLOT_CODEDIRECTORY = 0++CS_HASHTYPE_SHA256 = 2+++def _read_chunk_cd_blob(chunk_path):+ """Locate the chunk's CS_CodeDirectory.++ Returns a dict with the fields we need to write back slot hashes:+ cd_file_off (chunk-file offset of the CD blob)+ cd_length (total length of the CD blob in bytes)+ hash_offset (offset within the CD blob to slot[0])+ hash_size (bytes per slot — 32 for SHA-256)+ n_code_slots (number of slots)+ code_limit (chunk byte range covered)+ page_size (1 << pageSize_log2 — typically 16384)++ Returns None if the chunk file isn't recognised (header magic+ mismatch, no CodeDirectory in SuperBlob, etc.).+ """+ with open(chunk_path, "rb") as f:+ head = f.read(0x100)+ if not head.startswith(b"dyld_"):+ return None++ # codeSignatureOffset at 0x28, codeSignatureSize at 0x30 (both u64 LE).+ cs_off, cs_size = struct.unpack_from("<QQ", head, 0x28)+ if cs_off == 0 or cs_size == 0:+ return None++ # SuperBlob (big-endian).+ with open(chunk_path, "rb") as f:+ f.seek(cs_off)+ sb_head = f.read(12)+ if len(sb_head) != 12:+ return None+ sb_magic, sb_length, sb_count = struct.unpack(">III", sb_head)+ if sb_magic != CSMAGIC_EMBEDDED_SIGNATURE:+ return None+ if sb_length > cs_size or sb_count > 256:+ return None++ # Read the BlobIndex array.+ with open(chunk_path, "rb") as f:+ f.seek(cs_off + 12)+ idx_bytes = f.read(sb_count * 8)+ if len(idx_bytes) != sb_count * 8:+ return None++ cd_off_in_sb = None+ for i in range(sb_count):+ slot_type, slot_off = struct.unpack_from(">II", idx_bytes, i * 8)+ if slot_type == CSSLOT_CODEDIRECTORY:+ cd_off_in_sb = slot_off+ break+ if cd_off_in_sb is None:+ return None++ cd_file_off = cs_off + cd_off_in_sb++ # CD blob header (big-endian).+ with open(chunk_path, "rb") as f:+ f.seek(cd_file_off)+ cd_head = f.read(44)+ if len(cd_head) != 44:+ return None+ cd_magic, cd_length, _version, _flags = struct.unpack_from(">IIII", cd_head, 0)+ if cd_magic != CSMAGIC_CODEDIRECTORY:+ return None+ hash_offset, _ident_offset, _n_special, n_code_slots, code_limit = \+ struct.unpack_from(">IIIII", cd_head, 16)+ hash_size = cd_head[36]+ hash_type = cd_head[37]+ page_size_log2 = cd_head[39]+ if hash_type != CS_HASHTYPE_SHA256 or hash_size != 32:+ # We only know how to recompute SHA-256 slots. Other hash types+ # (SHA-1, SHA-256-truncated) would need additional code paths.+ return None+ page_size = 1 << page_size_log2+ if page_size == 0 or page_size > (1 << 20):+ return None++ return {+ "cd_file_off": cd_file_off,+ "cd_length": cd_length,+ "hash_offset": hash_offset,+ "hash_size": hash_size,+ "n_code_slots": n_code_slots,+ "code_limit": code_limit,+ "page_size": page_size,+ }+++def reattest_modified_pages(chunks, modified_vmas, *, dry_run=False, verbose=True):+ """Recompute and write SHA-256 slot hashes for every 16 KiB page+ that contains a `modified_vmas` entry.++ `chunks` a DSCChunks instance.+ `modified_vmas` iterable of vmaddrs we wrote to. Each is reduced+ to its containing chunk + page; duplicate pages+ are coalesced.+ `dry_run` if True, log only, do not write.++ Returns a list of dicts (one per page recomputed) for diagnostics:+ {chunk_path, page_index, chunk_off, sha256_before, sha256_after}+ """+ # Group vmas by chunk → set of page indices to recompute.+ chunks_pages = {} # chunk_path → set(page_index)+ chunk_meta = {} # chunk_path → cd metadata (lazy-loaded)++ for vma in modified_vmas:+ loc = chunks.find_chunk_for_vma(vma)+ if loc is None:+ if verbose:+ print(f" [-] re-attest: vma 0x{vma:X} not mapped in any chunk")+ continue+ cp, foff = loc+ meta = chunk_meta.get(cp)+ if meta is None:+ meta = _read_chunk_cd_blob(cp)+ if meta is None:+ if verbose:+ print(f" [-] re-attest: chunk {os.path.basename(cp)!r} "+ f"has no recognised CS_SuperBlob/CD — skipping")+ # Cache the None so we don't re-probe.+ chunk_meta[cp] = False+ continue+ chunk_meta[cp] = meta+ elif meta is False:+ continue+ page_size = meta["page_size"]+ page_index = foff // page_size+ if page_index >= meta["n_code_slots"]:+ if verbose:+ print(f" [-] re-attest: vma 0x{vma:X} -> page {page_index} "+ f"is past nCodeSlots ({meta['n_code_slots']}) in "+ f"{os.path.basename(cp)} — skipping")+ continue+ if (page_index + 1) * page_size > meta["code_limit"]:+ if verbose:+ print(f" [-] re-attest: vma 0x{vma:X} -> page {page_index} "+ f"overruns codeLimit (0x{meta['code_limit']:X}) in "+ f"{os.path.basename(cp)} — skipping")+ continue+ chunks_pages.setdefault(cp, set()).add(page_index)++ if not chunks_pages:+ if verbose:+ print(f" [.] re-attest: no eligible pages")+ return []++ diagnostics = []+ total = 0+ for cp, pages in chunks_pages.items():+ meta = chunk_meta[cp]+ cd_file_off = meta["cd_file_off"]+ hash_offset = meta["hash_offset"]+ hash_size = meta["hash_size"]+ page_size = meta["page_size"]++ # Open once per chunk for read/write.+ mode = "rb" if dry_run else "r+b"+ with open(cp, mode) as f:+ for page_index in sorted(pages):+ page_off = page_index * page_size+ slot_off = cd_file_off + hash_offset + page_index * hash_size++ f.seek(page_off)+ page_data = f.read(page_size)+ if len(page_data) != page_size:+ if verbose:+ print(f" [-] re-attest: short read at "+ f"page {page_index} of {os.path.basename(cp)} "+ f"(got {len(page_data)} of {page_size})")+ continue+ new_hash = hashlib.sha256(page_data).digest()++ f.seek(slot_off)+ old_hash = f.read(hash_size)++ if old_hash == new_hash:+ if verbose:+ print(f" [.] re-attest: page {page_index} of "+ f"{os.path.basename(cp)} slot already matches "+ f"(no-op)")+ continue++ if not dry_run:+ f.seek(slot_off)+ f.write(new_hash)++ if verbose:+ action = "would write" if dry_run else "wrote"+ print(f" [+] re-attest: {action} slot {page_index} of "+ f"{os.path.basename(cp)} "+ f"({old_hash.hex()[:8]}.. -> {new_hash.hex()[:8]}..)")+ diagnostics.append({+ "chunk_path": cp,+ "page_index": page_index,+ "chunk_off": page_off,+ "slot_off": slot_off,+ "sha256_before": old_hash.hex(),+ "sha256_after": new_hash.hex(),+ })+ total += 1++ if verbose:+ action = "would update" if dry_run else "updated"+ print(f" [+] re-attest: {action} {total} slot hash(es) across "+ f"{len(chunks_pages)} chunk(s)")+ return diagnosticsdiff --git a/scripts/patchers/cfw_patch_hv_vmm.py b/scripts/patchers/cfw_patch_hv_vmm.pynew file mode 100644index 00000000..9a4e881e--- /dev/null+++ b/scripts/patchers/cfw_patch_hv_vmm.py@@ -0,0 +1,142 @@+"""hv_vmm_present user-mode patch module — cstring-mangle approach.++Mangles the cstring "kern.hv_vmm_present\\0" in targeted user-mode+binaries so they query a kernel sysctl with a different name. On a+kernel patched by `KernelJBPatchHvVmmRename` (which renames the OID+from `hv_vmm_present` to `Xv_vmm_present`), the new design is:++ - Caller queries `kern.hv_vmm_present` (UNPATCHED binary):+ kernel returns ENOENT. The canonical defensive post-call check+ (`cbnz w0, skip` / `cmp w0,#0 ; b.ne skip`) takes the skip+ path; the cached `is_vmm` byte stays at BSS-zero (0). The+ binary thinks it is NOT running in a VM.++ - Caller queries `kern.Xv_vmm_present` (PATCHED binary):+ kernel returns 1 (the real value of the OID's int variable).+ The defensive check passes; the cache stores 1. The binary+ thinks it IS running in a VM — same as a stock device.++Patch shape (per cstring occurrence): byte 5 of the cstring+`'h'` (0x68) → `'X'` (0x58). The mangled cstring is+`"kern.Xv_vmm_present\\0"`. Byte 5 is chosen so the `kern.` top-level+sysctl namespace is preserved — without that, the kernel's+name-to-MIB resolver wouldn't route the call to any OID.++Public entrypoints:+ patch_hv_vmm(filepath, *, dry_run=False) -> int+ Patch a standalone Mach-O. Returns the number of cstring sites+ mangled.++ find_string_sites(data: bytes) -> list[dict]+ Find every cstring occurrence in an in-memory Mach-O.+"""++import struct++from .cfw_asm import parse_macho_sections, _log_asm+++NEEDLE = b"kern.hv_vmm_present\x00"+# Mangle byte offset (0-based within NEEDLE). Position 5 is the 'h' of+# "hv_vmm_present" — the first byte after the "kern." namespace prefix.+# Keeping the "kern." prefix intact ensures the kernel's sysctl name-to-MIB+# resolver routes the call to a real OID (registered as `Xv_vmm_present`+# under `kern` by the companion kernel patch). Byte 0 would have produced+# `Xern.hv_vmm_present`, which can never resolve because `Xern` isn't a+# registered top-level sysctl namespace.+MANGLE_OFFSET = 5+ORIGINAL_BYTE = b"h" # 0x68+MANGLED_BYTE = b"X" # 0x58+MANGLED_NEEDLE = NEEDLE[:MANGLE_OFFSET] + MANGLED_BYTE + NEEDLE[MANGLE_OFFSET + 1:]+++def find_string_sites(data):+ """Return all unmangled "kern.hv_vmm_present\\0" cstring occurrences.++ Each entry: {string_vma, file_offset, section}.++ Hits are anchored at a cstring boundary (preceded by a NUL byte or+ at the start of the section) so partial-match substrings inside+ longer cstrings won't be returned.+ """+ sections = parse_macho_sections(data)+ out = []+ for sec_name, (vma, size, foff) in sections.items():+ _, _, sect = sec_name.partition(",")+ # __cstring is where the linker puts unique C-string literals.+ # Some method-name / class-name pools could in principle hold+ # the same bytes too; we include them for safety.+ if sect not in ("__cstring", "__objc_methname", "__objc_classname"):+ continue+ buf = bytes(data[foff:foff + size])+ i = 0+ while True:+ p = buf.find(NEEDLE, i)+ if p < 0:+ break+ if p == 0 or buf[p - 1] == 0:+ out.append(+ {+ "string_vma": vma + p,+ "file_offset": foff + p,+ "section": sec_name,+ }+ )+ i = p + 1+ return out+++def is_already_mangled(data):+ """Detect whether the binary already contains the mangled form.++ Used purely for friendlier logging — `find_string_sites` already+ returns empty on a mangled binary, so the patch flow is idempotent+ regardless.+ """+ return bytes(data).find(MANGLED_NEEDLE) >= 0+++def patch_hv_vmm(filepath, *, dry_run=False):+ """Mangle the kern.hv_vmm_present cstring in a standalone Mach-O.++ Returns the count of mangled cstring sites. Idempotent.+ """+ data = bytearray(open(filepath, "rb").read())+ sites = find_string_sites(bytes(data))+ if not sites:+ if is_already_mangled(bytes(data)):+ print(f" [.] {filepath}: already mangled (no original "+ f"'kern.hv_vmm_present' cstring present)")+ else:+ print(f" [.] {filepath}: 'kern.hv_vmm_present' cstring not "+ f"present — nothing to do")+ return 0++ print(f" [+] {len(sites)} cstring occurrence(s) in {filepath}")+ n = 0+ for s in sites:+ foff = s["file_offset"]+ original = bytes(data[foff:foff + len(NEEDLE)])+ # Idempotence: if byte at MANGLE_OFFSET is already mangled, skip.+ if original[MANGLE_OFFSET:MANGLE_OFFSET + 1] == MANGLED_BYTE:+ print(f" [.] string@0x{s['string_vma']:X} already mangled "+ f"(byte {MANGLE_OFFSET} is already {MANGLED_BYTE.decode()!r})")+ continue+ if original != NEEDLE:+ print(f" [-] string@0x{s['string_vma']:X} bytes look unexpected "+ f"({original!r}); skipping")+ continue+ print(f" patching string@0x{s['string_vma']:X} (sect={s['section']}): "+ f"byte {MANGLE_OFFSET} {ORIGINAL_BYTE.decode()!r} -> "+ f"{MANGLED_BYTE.decode()!r} "+ f"('kern.hv_vmm_present' -> 'kern.Xv_vmm_present')")+ data[foff + MANGLE_OFFSET:foff + MANGLE_OFFSET + 1] = MANGLED_BYTE+ n += 1++ if dry_run:+ print(f" [.] dry-run — not writing back")+ return n+ if n > 0:+ open(filepath, "wb").write(data)+ print(f" [+] {filepath}: mangled {n} cstring occurrence(s)")+ return ndiff --git a/scripts/patchers/cfw_patch_hv_vmm_dsc.py b/scripts/patchers/cfw_patch_hv_vmm_dsc.pynew file mode 100644index 00000000..415f177c--- /dev/null+++ b/scripts/patchers/cfw_patch_hv_vmm_dsc.py@@ -0,0 +1,266 @@+"""DSC-side orchestrator for the hv_vmm_present user-mode patch+(blacklist-flip design).++Design summary+--------------+This module works in tandem with `KernelJBPatchHvVmmRename` (Swift+kernel patcher) which renames the kernel's sysctl OID from+`hv_vmm_present` to `Xv_vmm_present`. After the kernel patch:++ - `sysctlbyname("kern.hv_vmm_present", ...)` returns ENOENT.+ - `sysctlbyname("kern.Xv_vmm_present", ...)` returns 1 (the OID's+ real int value, since this device is in fact a VM).++This module's job is to selectively rewrite cstrings inside DSC+dylibs so each dylib queries either the original (now ENOENT-returning)+name or the new (truthful-1-returning) name. Byte 5 of the+`"kern.hv_vmm_present\\0"` cstring is flipped from `'h'` (0x68) to+`'X'` (0x58), producing `"kern.Xv_vmm_present\\0"` — the same name the+kernel OID now answers to. The `kern.` namespace prefix is preserved+(byte-0 mangle would have produced `Xern.hv_vmm_present` which can+never resolve because `Xern` isn't a registered top-level).++Blacklist semantics+-------------------+The `DONT_PATCH_INSTALL_NAMES` list names dylibs whose cstring stays+ORIGINAL — they query `kern.hv_vmm_present`, get ENOENT, and the+caller's defensive post-call check leaves the cached `is_vmm` byte+at BSS-zero (0). Those libs end up thinking "not in a VM" — which is+what we want for sign-in / device-likeness consumers.++Every OTHER dylib that contains the cstring gets the byte-5 mangle —+they query `kern.Xv_vmm_present`, get 1, cache 1, and think "in a VM"+— exactly the value they would have seen on a stock device. This+keeps the graphics path (libMobileGestalt, PhotoFoundation,+AirPlaySupport, VisionKitCore, CoreVideo) and compute/accel fast+paths (CoreML, Espresso, AppleNeuralEngine, …) intact, because they+keep getting their original answer.++"""++import os+import struct+import sys++from .cfw_patch_hv_vmm import (+ NEEDLE,+ MANGLED_NEEDLE,+ MANGLE_OFFSET,+ ORIGINAL_BYTE,+ MANGLED_BYTE,+)+from .cfw_dsc_chunks import DSCChunks+from .cfw_dsc_codesign import reattest_modified_pages+++# ─────────────────────────────────────────────────────────────────────+# Blacklist of DSC dylibs to LEAVE UNPATCHED.+#+# A dylib in this list keeps its cstring as `"kern.hv_vmm_present\0"`.+# With the kernel-rename patch in place, that name resolves to ENOENT,+# the dylib's defensive `cbnz w0, skip` takes the skip path, and the+# cached `is_vmm` byte stays at BSS-zero (0). The dylib thinks the+# device is not a VM.+#+# A dylib NOT in this list has its cstring rewritten to+# `"kern.Xv_vmm_present\0"` (byte 5 mangle, 'h' → 'X'). That name+# resolves to the renamed OID on the kernel side and returns 1. The+# dylib thinks the device IS a VM — same as stock.+#+# Comment a single line out (re-enabling the patch for that dylib —+# i.e., MOVING IT OUT of the blacklist) to bisect which consumer+# regressed an observable.+#+# Order is grouped by why each entry needs to lie about VM presence;+# the order itself doesn't affect patching.+# ─────────────────────────────────────────────────────────────────────+DONT_PATCH_INSTALL_NAMES = (+ # ── Identity / activation / anti-abuse.+ "/System/Library/PrivateFrameworks/AAAFoundation.framework/AAAFoundation",+ "/System/Library/PrivateFrameworks/AuthKit.framework/AuthKit",+ "/System/Library/PrivateFrameworks/IDSFoundation.framework/IDSFoundation",+ "/System/Library/PrivateFrameworks/DeviceIdentity.framework/DeviceIdentity",+ "/System/Library/PrivateFrameworks/DeviceCheckInternal.framework/DeviceCheckInternal",+ "/System/Library/PrivateFrameworks/MobileActivation.framework/MobileActivation",+ "/System/Library/PrivateFrameworks/ApplePushService.framework/ApplePushService",++ # ── Store / IAP.+ "/System/Library/PrivateFrameworks/AppStoreUtilities.framework/AppStoreUtilities",++ # ── Consumer services.+ "/System/Library/PrivateFrameworks/CorePrescription.framework/CorePrescription",+ "/System/Library/PrivateFrameworks/CoreCDP.framework/CoreCDP",+ "/System/Library/PrivateFrameworks/EmailFoundation.framework/EmailFoundation",+ "/System/Library/PrivateFrameworks/FindMyBase.framework/FindMyBase",+ "/System/Library/PrivateFrameworks/TrialServer.framework/TrialServer",+ "/System/Library/PrivateFrameworks/DVTInstrumentsUtilities.framework/DVTInstrumentsUtilities",+ "/System/Library/PrivateFrameworks/WatchdogServiceManagement.framework/WatchdogServiceManagement",+)+_DONT_PATCH_SET: frozenset[str] = frozenset(DONT_PATCH_INSTALL_NAMES)+++def _classify(chunks, string_vma):+ """Walk back from `string_vma` to find the containing Mach-O header+ and return its install name (LC_ID_DYLIB), or None if not found.+ """+ header_vma = chunks.find_macho_header_before(string_vma)+ if header_vma is None:+ return None+ return chunks.read_install_name_at(header_vma)+++def patch_hv_vmm_in_dsc(chunks_dir, *, dry_run=False):+ """Apply the blacklist-flip mangle inside the DSC chunks at+ `chunks_dir`.++ For every occurrence of `"kern.hv_vmm_present\\0"` in any+ executable DSC mapping, resolve the containing dylib's install+ name; if the install name is NOT in `DONT_PATCH_INSTALL_NAMES`,+ rewrite byte 5 of the cstring from 'h' to 'X'.++ Returns {install_name: count_of_cstring_sites_mangled}.+ """+ chunks = DSCChunks(chunks_dir)+ print(f" [.] {chunks!r}")++ print(f" [.] locating cstring \"kern.hv_vmm_present\\0\"...")+ string_vmas = chunks.find_string_vmas(NEEDLE)+ # Also pick up cstrings already mangled by a prior run — we still+ # need their 16 KiB pages added to the re-attestation set so a+ # re-run on a previously-patched DSC keeps slot hashes in sync.+ already_mangled_vmas = chunks.find_string_vmas(MANGLED_NEEDLE)+ if not string_vmas and not already_mangled_vmas:+ print(f" [-] cstring not present in any executable mapping; "+ f"nothing to do (either patched already or absent)")+ return {}+ print(f" [.] {len(string_vmas)} pristine + {len(already_mangled_vmas)} "+ f"already-mangled cstring occurrence(s) found")++ print(f" [.] resolving containing dylib for each occurrence "+ f"(blacklist has {len(_DONT_PATCH_SET)} entries — these stay "+ f"unpatched)...")+ results = {}+ patched_total = 0+ skipped_in_blacklist = 0+ skipped_unclassified = 0+ refused = 0+ # Track every vmaddr we actually mangled so the re-attestation pass+ # at the end recomputes exactly the affected 16 KiB pages.+ modified_vmas: list[int] = []++ for vma in sorted(string_vmas):+ try:+ install_name = _classify(chunks, vma)+ except Exception as e:+ print(f" [-] could not classify string@0x{vma:X}: "+ f"{type(e).__name__}: {e}")+ install_name = None+ label = install_name or "<unknown dylib>"++ if install_name is None:+ # Unknown dylibs are NOT in the blacklist → would normally+ # be patched. Refuse here because we can't audit them.+ print(f" [.] SKIP (no install name resolvable) "+ f"string@0x{vma:X}")+ skipped_unclassified += 1+ results[label] = results.get(label, 0)+ continue++ if install_name in _DONT_PATCH_SET:+ print(f" [.] SKIP (blacklisted — stays unpatched, "+ f"will hit ENOENT): {install_name} string@0x{vma:X}")+ skipped_in_blacklist += 1+ results[label] = results.get(label, 0)+ continue++ # Sanity: the byte at vma must currently look like the pristine cstring.+ try:+ current = chunks.read_at_vma(vma, len(NEEDLE))+ except (KeyError, IOError) as e:+ print(f" [-] read failed at 0x{vma:X}: {e}")+ refused += 1+ continue+ if current[MANGLE_OFFSET:MANGLE_OFFSET + 1] == MANGLED_BYTE:+ # Already mangled by a prior run; nothing to write, but+ # the re-attest pass below picks it up via already_mangled_vmas.+ print(f" [.] already mangled at byte {MANGLE_OFFSET}: "+ f"{label} string@0x{vma:X}")+ results[label] = results.get(label, 0)+ continue+ if current != NEEDLE:+ print(f" [-] unexpected bytes at 0x{vma:X} "+ f"({current!r}); refusing ({label})")+ refused += 1+ continue++ action = "would mangle" if dry_run else "mangled"+ if not dry_run:+ # Write the single byte at vma + MANGLE_OFFSET.+ chunks.write_at_vma(vma + MANGLE_OFFSET, MANGLED_BYTE)+ print(f" [+] {action} {label} string@0x{vma:X} "+ f"byte {MANGLE_OFFSET} "+ f"({ORIGINAL_BYTE.decode()} -> {MANGLED_BYTE.decode()}) "+ f"now queries kern.Xv_vmm_present, will see 1 (in a VM)")+ results[label] = results.get(label, 0) + 1+ patched_total += 1+ modified_vmas.append(vma)++ # Second pass: previously-mangled cstrings. Add their pages to the+ # re-attestation set so a re-run brings slot hashes into sync.+ # IMPORTANT: we INTENTIONALLY do not refuse a mangled cstring whose+ # install_name is in the blacklist — that's an out-of-band action+ # (someone re-enabled patching for that dylib in a prior run and+ # then commented it back into the blacklist). We log it loudly.+ reattest_only_count = 0+ blacklist_drift_count = 0+ for vma in sorted(already_mangled_vmas):+ try:+ install_name = _classify(chunks, vma)+ except Exception:+ install_name = None+ if install_name is None:+ continue+ if install_name in _DONT_PATCH_SET:+ # This dylib is supposed to be unpatched but appears mangled.+ # Most likely the operator mangled and then re-added it to+ # the blacklist; we surface this and still re-attest the+ # page so the slot hash matches the current bytes.+ print(f" [!] drift: {install_name} is in the blacklist "+ f"but already mangled at string@0x{vma:X} — slot will "+ f"be re-attested to current bytes; consider whether "+ f"you actually want this dylib re-patched")+ modified_vmas.append(vma)+ blacklist_drift_count += 1+ continue+ modified_vmas.append(vma)+ reattest_only_count += 1+ if reattest_only_count:+ print(f" [.] also queueing {reattest_only_count} already-mangled "+ f"cstring page(s) for re-attestation")+ if blacklist_drift_count:+ print(f" [.] {blacklist_drift_count} blacklisted dylib(s) found "+ f"mangled on disk — see drift warnings above")++ # Page-hash re-attestation. On hardware with TXM enforcement+ # (`codeSigningMonitor == 2` — iPhone17,3 / iOS 26.1), the kernel+ # defers per-page validation to TXM (vm_fault.c:2763-2780). TXM has+ # the original SHA-256 slot hashes baked in via the DSC's chunk-+ # level CS_CodeDirectory, so a byte-mangle alone causes+ # `KERN_PROTECTION_FAILURE` / `CODESIGNING / Invalid Page` SIGKILL+ # of any process that demand-pages the patched page. Recomputing+ # the slot hash makes the modified (content, hash) pair consistent.+ # The CDHash of the CD blob changes as a side-effect but TXM+ # accepts it at DSC mount time on this build (verified empirically).+ if modified_vmas and not dry_run:+ print(f" [.] re-attesting {len(modified_vmas)} modified page(s)...")+ reattest_modified_pages(chunks, modified_vmas, dry_run=False)+ elif modified_vmas and dry_run:+ print(f" [.] dry-run: would re-attest {len(modified_vmas)} "+ f"modified page(s)")+ reattest_modified_pages(chunks, modified_vmas, dry_run=True)++ print(f" [+] DSC patch complete: {patched_total} cstring(s) mangled, "+ f"{skipped_in_blacklist} in-blacklist (left unpatched), "+ f"{skipped_unclassified} unclassified, "+ f"{refused} refused/error")+ return resultsdiff --git a/scripts/patchers/cfw_patch_hv_vmm_rootfs.py b/scripts/patchers/cfw_patch_hv_vmm_rootfs.pynew file mode 100644index 00000000..d23c6cb6--- /dev/null+++ b/scripts/patchers/cfw_patch_hv_vmm_rootfs.py@@ -0,0 +1,216 @@+"""Rootfs-side orchestrator for the hv_vmm_present user-mode patch+(blacklist-flip design, standalone-binary side).++Companion to:+ - The kernel-side `KernelJBPatchHvVmmRename` (renames the OID name+ cstring from `hv_vmm_present` to `Xv_vmm_present` AND mangles+ every kernel-internal `\\0kern.hv_vmm_present\\0` cstring inside+ kexts so they query the new name and keep seeing 1).+ - The DSC-side `cfw_patch_hv_vmm_dsc.py` (same blacklist-flip,+ mangles every DSC dylib's cstring EXCEPT those in+ `DONT_PATCH_INSTALL_NAMES`).++This module covers the third domain: standalone Mach-O binaries on+the device's rootfs that hard-code `"kern.hv_vmm_present\\0"` in their+own `__TEXT,__cstring`. Under the new design every such binary needs+to either:++ - Be MANGLED (byte 5 of the cstring: 'h' -> 'X') so it queries+ `kern.Xv_vmm_present`, gets the truthful `1` back from the+ renamed OID, and behaves as it would on a real device. Default+ behaviour: most platform daemons (watchdogd, mobile_obliterator,+ DumpPanic, …) need this — without it they hit the renamed OID's+ ENOENT, interpret as "not in a VM", and take real-hardware code+ paths that don't exist on the VM (concrete repro: watchdogd+ SIGTRAP → kernel panic with `watchdogd[N] exited`).++ - Be LEFT ALONE (`DONT_PATCH_ROOTFS_PATHS` blacklist) so its+ cstring still says `kern.hv_vmm_present`, that query returns+ ENOENT after the kernel rename, the binary's defensive+ post-call check leaves the cached `is_vmm` byte at BSS-zero (0),+ and the binary thinks "not in a VM". Use this for the sign-in+ / activation / Apple-ID stack — the same role intent we apply+ to the DSC frameworks they link.++Data sources for ALL_KNOWN_ROOTFS_PATHS+---------------------------------------+The list below is taken verbatim from a `grep -rla 'kern\\.hv_vmm_present'+ipsws/iPhone17,3_26.1_23B85_Restore_extracted/ --exclude-dir='Cryptexes'`+on the extracted rootfs of iPhone17,3 26.1 23B85, minus+`/System/Library/Caches/com.apple.kernelcaches/kernelcache.release.iphone17`+which is the kernel itself and is patched by the firmware patcher+not this module. If future iOS builds add new daemons that reference+the cstring, re-run that grep and add the new paths here.+"""++import sys+++# ─────────────────────────────────────────────────────────────────────+# Complete list of rootfs Mach-Os that contain the cstring+# `kern.hv_vmm_present\0` somewhere in their __TEXT,__cstring.+#+# Established once by scanning the extracted rootfs of iPhone17,3 /+# iOS 26.1 / 23B85. Re-derive when porting to a new iOS build by:+# grep -rla 'kern\.hv_vmm_present' \+# ipsws/<new>_Restore_extracted/ \+# --exclude-dir='Cryptexes' 2>/dev/null+# ─────────────────────────────────────────────────────────────────────+ALL_KNOWN_ROOTFS_PATHS: tuple[str, ...] = (+ # /usr/libexec daemons+ "/usr/libexec/adid",+ "/usr/libexec/DumpPanic",+ "/usr/libexec/fairplaydeviceidentityd",+ "/usr/libexec/mmaintenanced",+ "/usr/libexec/modelmanagerd",+ "/usr/libexec/mobile_obliterator",+ "/usr/libexec/mobileactivationd",+ "/usr/libexec/networkserviceproxy",+ "/usr/libexec/promotedcontentd",+ "/usr/libexec/storagekitd",+ "/usr/libexec/terminusd",+ "/usr/libexec/transparencyd",+ "/usr/libexec/trustd",+ "/usr/libexec/watchdogd",++ # /usr/sbin+ "/usr/sbin/absd",+ "/usr/sbin/bluetoothd",+ "/usr/sbin/fairplayd.H2",++ # /usr/lib+ "/usr/lib/libMobileGestalt.dylib",++ # /System/Library/CoreServices+ "/System/Library/CoreServices/ClarityBoard.app/ClarityBoard",++ # /System/Library/DataClassMigrators+ "/System/Library/DataClassMigrators/MobileActivationMigrator.migrator/MobileActivationMigrator",++ # /System/Library/ExtensionKit+ "/System/Library/ExtensionKit/Extensions/HostInferenceProviderService.appex/HostInferenceProviderService",++ # /System/Library/Frameworks+ "/System/Library/Frameworks/CoreML.framework/CoreML",+ "/System/Library/Frameworks/CoreVideo.framework/CoreVideo",+ "/System/Library/Frameworks/ManagedAppDistribution.framework/Support/managedappdistributiond",+ "/System/Library/Frameworks/MediaToolbox.framework/MediaToolbox",+ "/System/Library/Frameworks/SoundAnalysis.framework/SoundAnalysis",+ "/System/Library/Frameworks/StoreKit.framework/Support/storekitd",++ # /System/Library/PrivateFrameworks+ "/System/Library/PrivateFrameworks/AAAFoundation.framework/AAAFoundation",+ "/System/Library/PrivateFrameworks/AirPlaySupport.framework/AirPlaySupport",+ "/System/Library/PrivateFrameworks/AppStoreDaemon.framework/Support/appstored",+ "/System/Library/PrivateFrameworks/AppStoreUtilities.framework/AppStoreUtilities",+ "/System/Library/PrivateFrameworks/AppleNeuralEngine.framework/AppleNeuralEngine",+ "/System/Library/PrivateFrameworks/ApplePushService.framework/ApplePushService",+ "/System/Library/PrivateFrameworks/ApplePushService.framework/apsd",+ "/System/Library/PrivateFrameworks/AuthKit.framework/AuthKit",+ "/System/Library/PrivateFrameworks/CMCapture.framework/CMCapture",+ "/System/Library/PrivateFrameworks/CoreALD.framework/CoreALD",+ "/System/Library/PrivateFrameworks/CoreCDP.framework/CoreCDP",+ "/System/Library/PrivateFrameworks/CorePrescription.framework/CorePrescription",+ "/System/Library/PrivateFrameworks/CorePrescription.framework/XPCServices/CorePrescriptionService.xpc/CorePrescriptionService",+ "/System/Library/PrivateFrameworks/CoreRE.framework/CoreRE",+ "/System/Library/PrivateFrameworks/DVTInstrumentsUtilities.framework/DVTInstrumentsUtilities",+ "/System/Library/PrivateFrameworks/DataDetectorsUI.framework/PlugIns/com.apple.DataDetectorsUI.ActionsExtension.appex/com.apple.DataDetectorsUI.ActionsExtension",+ "/System/Library/PrivateFrameworks/DeviceCheckInternal.framework/DeviceCheckInternal",+ "/System/Library/PrivateFrameworks/DeviceIdentity.framework/DeviceIdentity",+ "/System/Library/PrivateFrameworks/EmailFoundation.framework/EmailFoundation",+ "/System/Library/PrivateFrameworks/Espresso.framework/Espresso",+ "/System/Library/PrivateFrameworks/FindMyBase.framework/FindMyBase",+ "/System/Library/PrivateFrameworks/IDS.framework/identityservicesd.app/identityservicesd",+ "/System/Library/PrivateFrameworks/IDSFoundation.framework/IDSFoundation",+ "/System/Library/PrivateFrameworks/IOSurfaceAccelerator.framework/IOSurfaceAccelerator",+ "/System/Library/PrivateFrameworks/MagnifierSupport.framework/MagnifierSupport",+ "/System/Library/PrivateFrameworks/MobileActivation.framework/MobileActivation",+ "/System/Library/PrivateFrameworks/NeuralNetworks.framework/NeuralNetworks",+ "/System/Library/PrivateFrameworks/PhotoFoundation.framework/PhotoFoundation",+ "/System/Library/PrivateFrameworks/Recon3D.framework/Recon3D",+ "/System/Library/PrivateFrameworks/RenderBox.framework/RenderBox",+ "/System/Library/PrivateFrameworks/SonicKit.framework/SonicKit",+ "/System/Library/PrivateFrameworks/TrialServer.framework/TrialServer",+ "/System/Library/PrivateFrameworks/VFX.framework/VFX",+ "/System/Library/PrivateFrameworks/VideosUI.framework/VideosUI",+ "/System/Library/PrivateFrameworks/VisionKitCore.framework/VisionKitCore",+ "/System/Library/PrivateFrameworks/WatchdogServiceManagement.framework/WatchdogServiceManagement",+ "/System/Library/PrivateFrameworks/caulk.framework/caulk",++ # /Applications+ "/Applications/CheckerBoard.app/CheckerBoard",+ "/Applications/Family.app/Family",+ "/Applications/PeopleMessageService.app/PeopleMessageService",+ "/Applications/PeopleViewService.app/PeopleViewService",+ "/Applications/StoreKitUISceneService.app/StoreKitUISceneService",+)+++# ─────────────────────────────────────────────────────────────────────+# Rootfs binaries to LEAVE UNPATCHED.+#+# A path in this set keeps its `kern.hv_vmm_present\0` cstring as-is.+# After the kernel rename that sysctl name returns ENOENT, the caller's+# defensive post-call check leaves the cached `is_vmm` byte at BSS-zero+# (0), and the binary thinks "not in a VM". Use this for sign-in /+# Apple-ID / activation / Store consumers — mirrors the DSC blacklist.+#+# Starting set is intentionally conservative: only daemons we have a+# clear "is sign-in adjacent" reason to leave alone. Tighten / loosen+# by editing this list and re-running `make cfw_install_jb`.+# ─────────────────────────────────────────────────────────────────────+DONT_PATCH_ROOTFS_PATHS: frozenset[str] = frozenset((+ # Apple ID / activation / device-identity daemons+ "/usr/libexec/adid",+ "/usr/libexec/mobileactivationd",+ "/usr/libexec/fairplaydeviceidentityd",+ "/System/Library/DataClassMigrators/MobileActivationMigrator.migrator/MobileActivationMigrator",+ # APNS / iMessage daemons+ "/System/Library/PrivateFrameworks/ApplePushService.framework/apsd",+ "/System/Library/PrivateFrameworks/IDS.framework/identityservicesd.app/identityservicesd",+ # Store / IAP daemons + UI+ "/System/Library/Frameworks/StoreKit.framework/Support/storekitd",+ "/System/Library/PrivateFrameworks/AppStoreDaemon.framework/Support/appstored",+ "/Applications/StoreKitUISceneService.app/StoreKitUISceneService",+ "/Applications/CheckerBoard.app/CheckerBoard",+ # Health Rx+ "/System/Library/PrivateFrameworks/CorePrescription.framework/XPCServices/CorePrescriptionService.xpc/CorePrescriptionService",+ # Standalone copies of DSC-blacklisted frameworks. The rootfs files+ # may be stubs that redirect into the DSC at load time, in which+ # case mangling them has no effect — but blacklisting is defensive+ # and matches role intent.+ "/System/Library/PrivateFrameworks/AAAFoundation.framework/AAAFoundation",+ "/System/Library/PrivateFrameworks/AuthKit.framework/AuthKit",+ "/System/Library/PrivateFrameworks/IDSFoundation.framework/IDSFoundation",+ "/System/Library/PrivateFrameworks/DeviceIdentity.framework/DeviceIdentity",+ "/System/Library/PrivateFrameworks/DeviceCheckInternal.framework/DeviceCheckInternal",+ "/System/Library/PrivateFrameworks/MobileActivation.framework/MobileActivation",+ "/System/Library/PrivateFrameworks/ApplePushService.framework/ApplePushService",+ "/System/Library/PrivateFrameworks/AppStoreUtilities.framework/AppStoreUtilities",+ "/System/Library/PrivateFrameworks/CorePrescription.framework/CorePrescription",+ "/System/Library/PrivateFrameworks/CoreCDP.framework/CoreCDP",+ "/System/Library/PrivateFrameworks/EmailFoundation.framework/EmailFoundation",+ "/System/Library/PrivateFrameworks/FindMyBase.framework/FindMyBase",+ "/System/Library/PrivateFrameworks/TrialServer.framework/TrialServer",+ "/System/Library/PrivateFrameworks/DVTInstrumentsUtilities.framework/DVTInstrumentsUtilities",+ "/System/Library/PrivateFrameworks/WatchdogServiceManagement.framework/WatchdogServiceManagement",+))+++def get_patch_paths() -> list[str]:+ """Return the list of rootfs binary paths that should be byte-5+ mangled at install time. This is `ALL_KNOWN_ROOTFS_PATHS` minus+ `DONT_PATCH_ROOTFS_PATHS`, in stable sorted order.+ """+ return sorted(p for p in ALL_KNOWN_ROOTFS_PATHS if p not in DONT_PATCH_ROOTFS_PATHS)+++def main(argv: list[str]) -> int:+ """Print the patch paths, one per line, for shell consumption."""+ for p in get_patch_paths():+ print(p)+ return 0+++if __name__ == "__main__":+ raise SystemExit(main(sys.argv))