Run a virtual iPhone on an Apple Silicon Mac.
Swift
Record how the device name reaches the guest and what was measured
Jacky3d4a9d024fb1
diff --git a/Documents/Guides/create-and-run.md b/Documents/Guides/create-and-run.mdindex d95dd60c..6a6ab42a 100644--- a/Documents/Guides/create-and-run.md+++ b/Documents/Guides/create-and-run.md@@ -34,7 +34,7 @@ Closing the VM window, ⌘Q, `vm stop` and Control-C in the `vm launch` terminal## Device name-The guest shows the VM's name as its device name, in Xcode's device list and `xcrun devicectl list devices`, and cannot be renamed from inside the guest or from Finder, Xcode or `idevicename`: a rename there reports success and changes nothing. `vphone-vm` hands the name to the guest in NVRAM each time it starts, so `vm rename` applies from the next boot. The guest's own name stays in its preferences, untouched. A VM name of more than 255 UTF-8 bytes, or with a control character, is not used, and the guest shows its own name. See `Research/Guest/device_name_pinning.md`.+The guest shows the VM's name as its device name, in Xcode's device list and `xcrun devicectl list devices`, and cannot be renamed from inside the guest or from Finder, Xcode or `idevicename`: a rename there reports success and changes nothing. `vphone-vm` hands the name to the guest each time it connects to vphoned, a few seconds into every boot, and the guest keeps it for the next boot. After `vm rename`, Finder and `ideviceinfo` see the new name as soon as the machine is up; Xcode and `devicectl` read it when the device appears and may show the old name until the following boot. An existing machine moved to a bundle with this feature receives the guest library with its environment update and uses it from the boot after that. The guest's own name stays in its preferences, untouched. A VM name of more than 255 UTF-8 bytes, or with a control character, is not used, and the guest shows its own name. See `Research/Guest/device_name_pinning.md`.## Manual stagesdiff --git a/Research/0_binary_patch_comparison.md b/Research/0_binary_patch_comparison.mdindex e9dc8642..09e3e90d 100644--- a/Research/0_binary_patch_comparison.md+++ b/Research/0_binary_patch_comparison.md@@ -566,7 +566,8 @@ do NOT execute these).| 24 | No binary change: both spawn hooks insert `libbatteryhealthfix.dylib` into `Settings` (`/Applications/Preferences.app/Preferences`) beside SystemHook, where it interposes `IOPSCopyPowerSourcesInfo`, `IOPSCopyPowerSourcesByType`, `IOPSCopyPowerSourcesByTypePrecise`, `notify_register_check` / `notify_get_state` / `notify_cancel` and `MGGetBoolAnswer` — **all bases** | none (new guest dylib `VPhoneGuestComponents/BatteryHealthFix/libbatteryhealthfix.c`, installed at `/usr/lib/libbatteryhealthfix.dylib`) | **Stop Settings → Battery → Battery Health & Charging loading forever.** The VM's battery is Virtualization.framework's synthetic power source (charge and connectivity only), and the health half of a real battery's description comes from AppleSmartBattery, which no VM has. Measured on `iPhone17,3 27.0 (24A435)`: powerd's internal battery description has one `BatteryPacks` entry holding only `PackID`, `Cycle count` and `Transport Type`, no `Battery Service State`/`Flags` or `Maximum Capacity Percent` anywhere, and `com.apple.thermalmonitor.ageAwareMitigationState` stays 0. `-[BatteryHealthUIController specifiers]` asks `-[BatteryHealthUIInformation batteryDataUnavailable]`, which answers YES while `+getManagementState` is 0, while no pack parses (`-[BatteryHealthUIPackInformation initWithPowerSourceInformation:]` drops a pack without service flags and state), or while the overall genuine status is -1 — and it is -1 because `MGGetBoolAnswer("D6/BMDrlb8V3WSiqL8gL+w")` (HasBatteryModuleAuth, `+[PLGestaltUtilities hasBatteryModuleAuth]`) answers 1 on the guest, sending `+genuineBatteryStatusForPackIndex:` to an `AppleBatteryAuth`/`AppleAuthCPRelay` service that does not exist. The controller then shows its global spinner and re-asks on a timer. iPadOS 26.6.2 (23G90) has the same gate in `+[BatteryUIResourceClass batteryDataUnavailable]`, reading the flat keys of `IOPSCopyPowerSourcesByType`'s array, the same notify name and the same MobileGestalt key. The hook answers as a new battery without battery authentication: each internal-battery description is copied with `Battery Service State` 0, `Battery Service Flags` 0, `Maximum Capacity Percent` 100 and `Cycle count` 0 at the top level, and each of powerd's packs (or one new pack) completed with a `BatteryHealth` dictionary of the same three numbers plus `Date of manufacture`/`Date of first use` (the birth time of `/private/var/mobile`, i.e. the restore); keys already present are never replaced, and a description that already has them is passed through. A mitigation state of 0 on a token registered for the age-aware name reads as 2 ("supporting normal peak performance"). HasBatteryModuleAuth reads as no only while `IOServiceGetMatchingService("AppleBatteryAuth")` finds nothing. Interposing reaches the callers because `BatteryUsageUI.bundle` is a standalone Mach-O bound through dyld's interposing table (cache-to-cache calls are not; see `MISFix/MISFixSignature.c`), and inserting it — rather than SystemHook `dlopen`ing it like row 21 — is what puts the table in place before the bundle loads. `vpInsertedLibraryFor` in `Shared/InjectionEnvironment.h` picks it or libmisfix for a path; the two target sets do not overlap. Ships with `system-launchdaemons-boot-environment`; existing guests get it from the vphoned environment update on their next start with the new bundle (offline `cfw update-environment` only replaces libraries a VM already has). launchd starts Settings itself, so it is the launchd hook that inserts it: a guest updated only by that online sync needs one more reboot before launchd runs the new hook, which the update already reports as `reboot_required`; an offline environment update replaces the hook before boot. **Validated (2026-10-04, `bhtest-iphone`, `iPhone17,3 27.0 (24A435)` + cloudOS 26.4):** before, the page showed only the spinner and the two charging switches; after, Maximum Capacity 100%, Peak Performance Capability "Your battery is currently supporting normal peak performance", the two switches, no spinner; the hook's log shows all three answers taken once per process. Re-checked on the final bundle after a reboot of the same guest, with the launchd hook logging `inserted+batteryhealthfix` for each Settings launch. **iPad16,1 26.6.2 (23G90), `bhtest-ipad`, created with the new bundle:** the hook is inserted and stays inert, and Settings runs without a crash; that iPad has no Battery Health page at all, because `-[BatteryUIController setUpBatteryHealthGroup]` offers the row only on an iPhone or, through `+[PLBatteryUIBackendModel shouldShowModifiedHealthController]`, on an iPad that supports the fixed charge limit with the `PerfPowerServices/battery_health_details` feature on — the model decides, as on hardware. The 26.x gate inside the page is from static analysis; no 26.x iPhone image was at hand to run it. | Y | Y | Y || 25 | No binary change: `libvcamcaptured.dylib` stops every other thread in `cameracaptured` (`task_threads` + `thread_suspend`, self excluded, one patcher at a time) around each `vcc_patch_word` / `vcc_patch_two_nops` text rewrite — **all bases** | none (guest dylib `VPhoneGuestComponents/VCamCaptured/Image/VCamCodePatch.m`, installed at `/usr/lib/libvcamcaptured.dylib`) | **Stop the hook's own runtime patching from crashing `cameracaptured`, which froze the whole VM when the camera was opened.** The hook rewrites CMCapture shared-cache `__text` through `vm_protect(RW|COPY)` → write → `vm_protect(RX)`; for the whole flip the 16K page carries no execute permission, and the pages it touches (the `-12783` error-code sites, the master-clock gate, the prewarm call) are live XPC server code. Two crash reports caught a thread fetching an instruction in a page mid-flip while the patching thread was in `vcc_patch_word` on the same boot: `ipad-mini-01` `cameracaptured-2026-10-03-045638.ips` died in `__FigFlashlightGetClassID_block_invoke` on `com.apple.coremedia.flashlight(34)-messages`, and `ipad-pro-13` `cameracaptured-2026-10-04-225558.ips` died in `captureSourceServer_handleRegisterNotificationForProprietaryDefaultChangesMessage` on `com.apple.coremedia.capturesource(523)-messages` — the register-for-source-changes XPC that camera enumeration itself sends. Both are `EXC_BAD_ACCESS (SIGBUS)`, `KERN_PROTECTION_FAILURE` on an instruction fetch, in a region snapshotted `r-x/rwx`, `SM=COW` (the rwx max-protection is the flip's fingerprint). The card: with row 23 removing the boot crash, any later `cameracaptured` restart (jetsam, another crash) while a camera client reconnects sends its first XPCs straight into the +3 s reinstall window; one SIGBUS → launchd throttles → every AVCapture client, SpringBoard's main thread included, blocks forever in a synchronous XPC — the "VM 卡死" report of 2026-10-05. The stopped section is exactly two `vm_protect` calls, the word write and `sys_icache_invalidate`: no locks, no allocation, no logging, so a frozen thread holding any userspace lock cannot deadlock the patcher; every `vcc_log` moved after the resume, and a mutex serialises patchers (constructor prewarm patch vs the +3 s install block). All five runtime text-patching call sites (`vcc_scan_and_patch` ×2, the prewarm NOP, the session-hook pair, the source-installation NOPs) funnel through the two fixed functions. Validation: kill-and-relaunch stress with Camera.app auto-reconnecting (the same collision that produced both crashes) produces no new `cameracaptured` crash report, and the boot log's `patch_word OK` lines are unchanged. See `Research/Guest/virtual_camera_transport.md` ("The patch race that froze the whole VM"). | Y | Y | Y || 26 | No binary change: both spawn hooks insert `libdevicehubfix.dylib` into `cryptexd` and the DDI's `dtremotedisplayd` and `dtdeviceinfod`. In `cryptexd` it interposes `fcntl` and reports an `EPERM` from `F_SETPROTECTIONCLASS` as `ENOTSUP`; in `dtremotedisplayd` it interposes `MediaStreamSupportedFeatures.current` (answers `0x8c`) and `CurrentDevice.isCustomerRestricted` (answers false) from the DDI's `CoreDeviceUtilities`; in `dtdeviceinfod` it interposes `MGCopyAnswer` and fills a missing `FramebufferIdentifier` for `phone11` chrome — **all bases** | none (new guest dylib `VPhoneGuestComponents/DeviceHubFix/libdevicehubfix.c`, installed at `/usr/lib/libdevicehubfix.dylib`) | **Let Xcode 27's DeviceHub show the guest's screen.** On iOS 27 `cryptexd` stages each DDI asset with `open(O_RDWR)` + `fcntl(F_SETPROTECTIONCLASS, 4)` and accepts only `ENOTSUP` as a failure; a guest answers `EPERM` (`set protection class: [1: Operation not permitted]`, `staging failed`), so CoreDevice shows the device as "connected (no DDI)" for good. With the DDI mounted, DeviceHub asks `dtremotedisplayd` for its media stream features and gets 0 from CoreDeviceUtilities' policy: `isCustomerRestricted` (`isProductionFused && !hasInternalOSBuild && hasInternalDDI == false`) refuses every pre-27.0 device, and remote control is limited to iPhone, Apple Watch and Apple TV, which refuses every iPad. `0x8c` is what a Mac host reports for itself (mirrored primary display 0x4, system audio 0x8, display information 0x80). The 27.x iPhone guest reports `phone11` chrome with no `FramebufferIdentifier`, so DeviceHub drew the screen over the bezel corners; the hook answers only that missing key with Xcode's matching mask `4E5532ED-1470-47D1-BDF4-7AA90C26957A` from `/Library/Developer/DeviceKit/chrome_map.plist`. Interposing reaches all of them because `cryptexd`, `dtremotedisplayd`, `dtdeviceinfod` and `CoreDeviceUtilities` are standalone images; the two Swift symbols are weak flat-namespace imports, resolving to nothing outside `dtremotedisplayd`. On 27.x the view also needs row 11's conditional dispatch, or the capture display stays black. Ships with `system-launchdaemons-boot-environment`; an existing guest gets it from the environment update. Details: `Research/Guest/devicehub_screen_viewing.md`. **Validated (2026-10-06/07):** `iPad16,1 26.6.2 (23G90)`: DeviceHub receives `supportedFeatures: 140`, `MediaStreamStart` succeeds and the view shows the live home screen. `iPhone17,3 27.0.1 (24A446)`: the DDI mounts (`F_SETPROTECTIONCLASS EPERM, reported as ENOTSUP`), and with row 11's conditional dispatch DeviceHub shows the home screen and Settings live, clipped inside the chrome (`Found FramebufferMaskIdentifier from displayInfo`). Open: latency that grows over a long session and occasional stalls after a cold start, both upstream of the Mac receiver. | Y | Y | Y |-| 27 | No binary change: both spawn hooks insert `libdevicename.dylib` into `configd` and `lockdownd` (after `libmisfix.dylib`, the first process to take two inserted libraries). In `configd` it interposes `SCDynamicStoreSetMultiple` and `SCDynamicStoreSetValue` and pins `Setup:/System`'s `ComputerName`; in `lockdownd` it interposes `SCPreferencesSetComputerName`, `SCPreferencesSetHostName` and `SCPreferencesSetLocalHostName` and refuses renames with `kSCStatusAccessError`. Inert unless NVRAM `vphone-device-name` holds a valid name — **all bases** | none (new guest dylib `VPhoneGuestComponents/DeviceName/libdevicename.c`, installed at `/usr/lib/libdevicename.dylib`) | **Pin the guest's device name to the one the host chose.** The name is `System/System/ComputerName` in `preferences.plist`; configd's PreferencesMonitor (`updateConfiguration`, 24A435 `0x100062098`) flattens it into `Setup:/System` with one `SCDynamicStoreSetMultiple`, and every reader (`SCDynamicStoreCopyComputerName` in lockdownd's `copy_device_name`, MobileGestalt `UserAssignedDeviceName`, `UIDevice.name`) reads the store. The hook rewrites that publication, not the preferences read: the monitor's model-change path (`sub_10006155c`) writes the `kSCPrefSystem` value it reads back to disk, and the publication route leaves `preferences.plist` with the guest's own name, so turning the feature off restores it. A publication that leaves `Setup:/System` out as unchanged gets the store's value pinned; one that removes it gets the pinned name instead, so a guest with no name in its preferences gets one and lockdownd's startup naming does not run. lockdownd's `set_device_name` (`0x1000073b0`) is the only caller of the three setters; it logs their failure and still commits, and the `SetValue DeviceName` handler ignores the result, so a host rename reports success and the name stays. A rename to the pinned name passes through. The host writes the variable (UTF-8, no terminator) before each boot and removes it when the feature is off; 1–255 bytes of valid UTF-8 without control characters, otherwise off. Interposing works because both daemons are standalone images. Ships with `system-launchdaemons-boot-environment`; takes effect at the next boot. Details: `Research/Guest/device_name_pinning.md`. **Not yet run on a guest**: NVRAM readability from both daemons, and whether Settings renames through lockdownd, are open. | Y | Y | Y |+| 27 | No binary change: both spawn hooks insert `libdevicename.dylib` into `configd` and `lockdownd` (after `libmisfix.dylib`, the first process to take two inserted libraries). In `configd` it interposes `SCDynamicStoreSetMultiple` and `SCDynamicStoreSetValue` and pins `Setup:/System`'s `ComputerName`; in `lockdownd` it interposes `SCPreferencesSetComputerName`, `SCPreferencesSetHostName` and `SCPreferencesSetLocalHostName` and refuses every rename with `kSCStatusAccessError`. Inert unless `/var/db/vphone/devicename.plist` holds a valid `DeviceName` — **all bases** | none (new guest dylib `VPhoneGuestComponents/DeviceName/libdevicename.c`, installed at `/usr/lib/libdevicename.dylib`; vphoned `device.name.get`/`device.name.set`) | **Pin the guest's device name to the VM's name.** The name is `System/System/ComputerName` in `preferences.plist`; configd's PreferencesMonitor (`updateConfiguration`, 24A435 `0x100062098`) flattens it into `Setup:/System` with one `SCDynamicStoreSetMultiple`, and every reader (`SCDynamicStoreCopyComputerName` in lockdownd's `copy_device_name`, MobileGestalt `UserAssignedDeviceName`, `UIDevice.name`) reads the store. The hook rewrites that publication, not the preferences read: the monitor's model-change path (`sub_10006155c`) writes the `kSCPrefSystem` value it reads back to disk, and the publication route leaves `preferences.plist` with the guest's own name. A publication that leaves `Setup:/System` out as unchanged gets the store's value pinned; one that removes it gets the pinned name instead. `vphone-vm` sends the VM's name to vphoned's `device.name.set` after every connect; vphoned writes the file (one rename, 0644) and applies the preferences unchanged, so configd publishes again and the new pin, or the guest's own name when the file is removed, is live within a second. The file outlives a reboot, so configd's first publication at boot carries it. The library re-reads the file when its inode, size or mtime change. lockdownd's `set_device_name` (`0x1000073b0`) is the only caller of the three setters; it logs their failure and still commits, and the `SetValue DeviceName` handler ignores the result, so a host rename reports success and the name stays. The pinned name itself is refused too: lockdownd runs `set_device_name(copy_device_name())` whenever it starts, and a lockdownd restarted after configd published would otherwise write the pinned name and derived host names into `preferences.plist` (seen once). An NVRAM variable was the first channel and never reached the guest: iBoot keeps only the variables it knows (even `vphone-vm`'s `boot-args` write is replaced). Interposing works because both daemons are standalone images. Ships with `system-launchdaemons-boot-environment` and the environment update; takes effect at the next boot. Verified on iOS 27.0 (24A435) on 2026-10-07: pin at boot and live, host rename refused, `vm rename` followed, preferences untouched. CoreDevice (`devicectl`, DeviceHub) reads the name when the device appears and can lag one boot after a rename. Details: `Research/Guest/device_name_pinning.md`. | Y | Y | Y |+### Swift port status — the eight DSC patchers (2026-09-23)@@ -2792,4 +2793,4 @@ Two standard-blocked declarations hide Apple Account, Game Center, iCloud and Wa## Pinned guest device name (2026-10-07)-Row 27. `libdevicename.dylib` makes configd publish the name the host writes to NVRAM `vphone-device-name` as the device name, and makes lockdownd refuse renames to anything else; without the variable it passes everything through. It is the first library a process receives beside another: lockdownd already took `libmisfix.dylib`, so `vpInsertedLibrariesFor` in `Shared/InjectionEnvironment.h` now returns every installed library for a path and `vpInsertHookLibraries` adds each one an environment lacks. Single-library targets and their spawn log lines are unchanged. `preferences.plist` is never written: the pin is applied to configd's `SCDynamicStoreSetMultiple` publication, because the `SCPreferencesGetValue(kSCPrefSystem)` it flattens is also read and written back on configd's model-change path. Static analysis only so far; see `Research/Guest/device_name_pinning.md` for the flow, the assumptions still to confirm and the verification steps.+Row 27. `libdevicename.dylib` makes configd publish the VM's name, which `vphone-vm` hands to vphoned after every connect and vphoned keeps in `/var/db/vphone/devicename.plist`, as the device name, and makes lockdownd refuse every rename; without the file it passes everything through. NVRAM was tried first and does not reach the guest: iBoot drops variables it does not know. It is the first library a process receives beside another: lockdownd already took `libmisfix.dylib`, so `vpInsertedLibrariesFor` in `Shared/InjectionEnvironment.h` now returns every installed library for a path and `vpInsertHookLibraries` adds each one an environment lacks. Single-library targets and their spawn log lines are unchanged. `preferences.plist` is never written: the pin is applied to configd's `SCDynamicStoreSetMultiple` publication, because the `SCPreferencesGetValue(kSCPrefSystem)` it flattens is also read and written back on configd's model-change path. Verified on iOS 27.0 (24A435) on 2026-10-07; iOS 26.x not run yet. See `Research/Guest/device_name_pinning.md` for the flow, the measurements and the verification.diff --git a/Research/Guest/device_name_pinning.md b/Research/Guest/device_name_pinning.mdindex ff6aeae0..0e7d8ae4 100644--- a/Research/Guest/device_name_pinning.md+++ b/Research/Guest/device_name_pinning.md@@ -2,12 +2,13 @@The host can give a guest a fixed device name, the one Xcode's DeviceHub,`devicectl`, Finder and the guest's own Settings show, and keep it from being-renamed inside the guest. This note covers the guest half:-`libdevicename.dylib`. The host half writes the NVRAM variable it reads.+renamed inside the guest or from the host. The name is the VM's name:+`vphone-vm` hands it to vphoned after every connect, vphoned stores it in the+guest, and `libdevicename.dylib` in configd and lockdownd applies it.Static analysis of the iOS 27.0 (24A435) `configd` and `lockdownd` from an-`iPhone17,3` guest, 2026-10-07. Addresses are from those binaries. Status: not-yet run on a guest; see [Verification](#verification).+`iPhone17,3` guest, 2026-10-07. Addresses are from those binaries. Run on an+iOS 27.0 guest; see [Verification](#verification).## Where the name lives@@ -45,53 +46,97 @@ name, `SCPreferencesCommitChanges`, `SCPreferencesApplyChanges`. These arelockdownd's only callers of the three setters. A failing setter is onlylogged, and the function still commits. It has two callers:-- startup (`0x100011ec0`): when `copy_device_name` finds no name, lockdownd- names the device after `MarketingDeviceFamilyName`;+- startup (`0x100011e4c`…`0x100011ec0`): every time lockdownd starts it calls+ `set_device_name(copy_device_name())`, or with `MarketingDeviceFamilyName`+ when there is no name, and records the name in its data ark (`-DeviceName`);- the lockdown `SetValue DeviceName` handler (`0x10001ed7c`), which ignoresthe result. The host's rename (Finder, `idevicename`) arrives here.## The channel-Before every boot, `vphone-vm` writes the VM's name (the folder holding-`config.plist`) to NVRAM variable `vphone-device-name`: its UTF-8 bytes, no-terminator. There is no setting; the device name is the VM name, so `vm-rename` applies from the next boot. A VM name that cannot be a device name-(the rule below, `VPhoneGuestDeviceName` on the host) is not written, and-`vphone-vm` removes the variable instead. The guest reads it once per process as the-`IODeviceTree:/options` property of that name, then under Apple's NVRAM GUID-(`7C436110-…:vphone-device-name`) if the bare name is absent.--The value must be 1 to 255 bytes of valid UTF-8 with no control characters;-trailing NULs are dropped, and a CFString is accepted as well as CFData. Any-other value means the feature is off and the library passes every call-through.+The name is `DeviceName` in `/var/db/vphone/devicename.plist`, a binary+property list beside `misfix.plist`, mode 0644, owned by root. vphoned writes+it, replacing the file in one rename, and removes it:++- `device.name.set {name}` stores a name (not blank, at most 255 UTF-8 bytes,+ no control character: `VPhoneGuestDeviceName` on the host) and returns+ `{name, changed}`; `{name: null}` removes the file; `device.name.get` returns+ `{name}`. Capability `device_name`.+- After a change vphoned applies configd's preferences unchanged+ (`SCPreferencesApplyChanges`) so configd publishes again, and posts+ `com.apple.mobile.lockdown.device_name_changed`.+- `vphone-vm` calls `device.name.set` with the VM's name (the folder holding+ `config.plist`) on every connect, or with null for a VM name that breaks the+ rule. There is no setting.++The file survives a reboot, so from the second boot on configd's first+publication already carries the name, before lockdownd first asks for it. The+first boot after the feature arrives, and the first boot after `vm rename`,+start with the previous name (or none) and change when vphoned connects.++The library checks the file on each decision (`stat`; read again when inode,+size or modification time changed), not once per process. The value must be+1 to 255 bytes of valid UTF-8 with no control characters; a missing file, one+that does not parse, or any other value means nothing is pinned and every call+passes through.++### NVRAM does not reach the guest++The first channel was an NVRAM variable, `vphone-device-name`, written by+`vphone-vm` through `VZMacAuxiliaryStorage`'s private+`_setDataValue:forNVRAMVariableNamed:error:` before each boot. It never+arrived (2026-10-07, dhtest-iphone27):++- `IODeviceTree:/options` in the guest had 8 properties: `StartupMute`,+ `boot-breadcrumbs`, `fm-spstatus`, `user_language_enum`,+ `fm-activation-locked`, `boot-args`, `auto-boot`, `fm-locktype`. Neither the+ bare name nor the Apple-GUID form was there, read from lockdownd as root.+- `nvram.bin` keeps iBoot's two 512 KiB "common" banks at `0xa04000` and+ `0xa84000` (header `Z\x82\x02\x00 nvram`, adler32 of bank+0x14…+0x80000 at+ +0x10). A `vphone-device-name=…` entry added to the newest bank by hand, with+ the checksum fixed, was gone from both banks after one boot.+- `vphone-vm`'s own `boot-args` write (`serial=3 debug=0x104c04`) does not+ reach the guest either: the banks hold an empty `boot-args=`, and launchd+ logs `boot-args = serial=3 -v debug=0x2014e`, the string the iBoot patch+ supplies.++iBoot rewrites the store with the variables it knows (its list of names is in+`nvram.bin`) and drops the rest, so the host cannot hand the guest anything+through NVRAM. vphoned is the channel instead.## configd: publishing the pinned name`SCDynamicStoreSetMultiple` is interposed. For a call that sets or removesanything under `Setup:`, which in configd is the preferences monitor,`Setup:/System` is rewritten so its `ComputerName` is the pinned name and its-`ComputerNameEncoding` is UTF-8. Other entries stay.+`ComputerNameEncoding` is UTF-8. Other entries stay. Calls that publish only+`State:` keys, from configd's other plugins, never read the file.- The call sets `Setup:/System`: its value is pinned.- The call leaves it out because it did not change: the store's current value(`SCDynamicStoreCopyValue`) is pinned and added if it names anything else.- This covers a first boot whose preferences have no name: the store gets one- anyway, so lockdownd's startup naming finds a name and does not run.+ This covers a first boot whose preferences have no name.- The call removes it: the removal is dropped and a value holding the pinnedname is set instead.`SCDynamicStoreSetValue("Setup:/System", …)` is pinned the same way. No configdcaller is known to set that key directly.+A name set while the guest runs takes effect at once. vphoned's apply makes the+monitor publish even though the preferences did not change. Measured with a+tracing build (24A435): with the store holding the guest's own name, the call+sets one `Setup:` key and leaves `Setup:/System` out, and the store's value gets+the pin; with a pin in the store and none in the file any more, the call sets+`Setup:/System` to the preferences' value (the monitor compares with the store),+so the guest's own name returns without a reboot.+The pin is applied when configd publishes, not when it reads thepreferences. Replacing what `SCPreferencesGetValue(prefs, kSCPrefSystem)`returns would reach the same flattening, but the monitor's model-change path(`sub_10006155c`) reads that value and writes it back with`SCPreferencesSetValue` around `__SCNetworkConfigurationSaveModel`, whichwould commit the pinned name to disk. Applied at publication, it never-reaches `preferences.plist`: the file keeps the guest's own name, and a guest booted without the-variable shows that name again.+reaches `preferences.plist`.Not pinned: `LocalHostName` and the DNS host name, which are separate keysderived from the name when it is set; set-hostname's@@ -100,15 +145,25 @@ directly to decide a DNS host name after a reverse lookup.## lockdownd: refusing renames-While a name is pinned, `SCPreferencesSetComputerName` with any other name-returns false and sets `kSCStatusAccessError` (`_SCErrorSet`, exported by-SystemConfiguration). The host name and local host name setters that follow on+While a name is pinned, `SCPreferencesSetComputerName` returns false and sets+`kSCStatusAccessError` (`_SCErrorSet`, exported by SystemConfiguration),+whatever the name. The host name and local host name setters that follow onthe same preferences object are refused too, so the commit changes nothing.-A rename to the pinned name itself goes through.Because `set_device_name` and its `SetValue` handler ignore the failures, ahost that renames the guest is told it worked, and the name stays.-lockdownd logs `SCPreferencesSetComputerName failed (…): Permission denied`.++The pinned name itself is refused as well. lockdownd calls+`set_device_name(copy_device_name())` every time it starts. At boot that runs+before configd's first publication and asks for the name the preferences+already hold (seen as `refused SCPreferencesSetComputerName("probe-two")` while+the pin was `dhtest-iphone27`). A lockdownd started later, after a crash or+vphoned's `udid.set`/`udid.clear`, which stop it, reads the pinned name from the+store. A first version let a rename to the pinned name through, and one such+restart wrote `ComputerName "dhtest 27 测试"`, `HostName` and `LocalHostName`+`dhtest-27-ceshi` into `preferences.plist`. Refusing every rename while pinned+keeps the file as the guest left it; the refusal of the pinned name is logged+like any other.## Injection@@ -120,7 +175,10 @@ with`DYLD_INSERT_LIBRARIES=/usr/lib/SystemHook-vphone.dylib:/usr/lib/libmisfix.dylib:/usr/lib/libdevicename.dylib`.A job launchd spawns itself goes through the launchd hook; one started through`xpcproxy` goes through SystemHook. Either way it gets both libraries, and an-environment that already names some of them gains only the missing ones.+environment that already names some of them gains only the missing ones. On+24A435 both come through SystemHook: `vphone-systemhook-spawn.log` has+`configd decision=inserted+devicename` and `lockdownd+decision=inserted+misfix+devicename`.The interposes reach configd's and lockdownd's calls because both arestandalone images binding through their own imports. A call made inside the@@ -128,42 +186,61 @@ shared cache is not rebound (see "An interpose does not cross the sharedcache" in `0_binary_patch_comparison.md`). The library checks`getprogname()` and acts only in configd or lockdownd.-The library ships with `system-launchdaemons-boot-environment`. configd and-lockdownd pick it up when they next start, which in practice is the next boot.+The library ships with `system-launchdaemons-boot-environment` and with the+environment update. A guest that receives it from an online update starts+using it at its next boot, when configd and lockdownd are spawned again.++## What the host sees, and when++- lockdown readers (`ideviceinfo -k DeviceName`, Finder, `idevicename`) read+ the store on every request, so they follow a change at once.+- CoreDevice (`xcrun devicectl`, Xcode's device list, DeviceHub) reads the+ name when the device's remote service appears, near the time vphoned first+ answers, and keeps it. After `vm rename` the first boot is a race: one run+ showed the new name, another kept the old one until the next boot.+ Restarting the guest's remoted to force a new handshake is not an option:+ launchd only starts it again with a new NCM link, and after a USB+ re-enumeration (`udid.clear`) the host's remoted failed to connect+ (`connect(2) … Operation timed out`) and CoreDevice dropped the device until+ the guest rebooted.-## Assumptions to confirm+## Assumptions not yet checked-- Root processes can read `vphone-device-name` from `IODeviceTree:/options` as- the host writes it, bare or under the GUID.-- lockdownd can read it too. If it cannot, renames reach `preferences.plist`,- but configd still publishes the pinned name.- PreferencesMonitor is the only publisher of `Setup:/System`.-- Settings' General → About → Name goes through lockdownd. If Settings writes- the preferences itself, it is not refused, but configd still publishes the- pinned name.-- configd starts after `/private/var` is mounted, so its log lines are kept.- The pin does not depend on the log.+- Settings' General → About → Name goes through lockdownd (seen statically).+ If Settings writes the preferences itself, it is not refused, but configd+ still publishes the pinned name.+- iOS 26.x guests: not run yet.## Verification-On a test VM named, for example, `Lab Phone`:--1. `/var/mobile/Library/Caches/vphone-launchdhook-injection.log` or- `vphone-systemhook-spawn.log` shows `inserted+devicename` for configd and- `inserted+misfix+devicename` for lockdownd.-2. `/var/mobile/Library/Caches/vphone-devicename.log` has- `configd pinned name "Lab Phone"` and `published Setup:/System ComputerName- "Lab Phone"`.-3. `ideviceinfo -k DeviceName`, `xcrun devicectl list devices` and DeviceHub- show `Lab Phone`. So does Settings → General → About.-4. `idevicename Other` returns, and `ideviceinfo -k DeviceName` still says- `Lab Phone`. The log has `lockdownd refused- SCPreferencesSetComputerName("Other")`. `preferences.plist` keeps the name- it had before.-5. After `vm rename` to another name and a reboot, every view shows the new- name.+Run 2026-10-07 on dhtest-iphone27 (iPhone99,11, iOS 27.0 24A435), VM name+`dhtest-iphone27`, then renamed to `dhtest 27 测试`. Logs:+`/var/mobile/Library/Caches/vphone-devicename.log` in the guest, `[device]`+lines in the VM's console log on the host.++1. First boot without the file: `vm start --wait` returned 5 s after start,+ and the first `ideviceinfo -k DeviceName` answer a second later was already+ `dhtest-iphone27`; configd logged `pinned name "dhtest-iphone27"` and+ `published Setup:/System ComputerName "dhtest-iphone27"` after vphoned+ connected.+2. Reboot with the file: configd's first publication carries the pin, before+ lockdownd's start-up rename (refused), and the first lockdown answer and+ `devicectl` show `dhtest-iphone27`.+3. `idevicename "Renamed By Host"` prints success; `ideviceinfo` and+ `devicectl` keep `dhtest-iphone27`; `preferences.plist` keeps+ `ComputerName`/`HostName`/`LocalHostName` `probe-two`; the log has the three+ refusals.+4. `vm rename` to `dhtest 27 测试`, boot: the first lockdown answer (1 s after+ vphoned answered) was `dhtest 27 测试`; configd logged the old pin at boot,+ then the new one. `devicectl` showed the new name in this run.+5. `device.name.set null` while running: `ideviceinfo` showed the guest's own+ name 1 s later; setting the name again pinned it 1 s later. lockdownd+ killed while pinned came back, refused its start-up rename to the pinned+ name, and `preferences.plist` kept its name.Host-side checks need no guest: `make -C VPhoneGuestComponentstest-injection-environment test-devicename` covers target matching,-lockdownd's two libraries, the NVRAM value's decoding, the publication-rewrite and the rename decision.+lockdownd's two libraries, reading the file's contents, the publication+rewrite and the rename decision; `VPhoneCoreKitTests` covers the host's name+rule.