Commit Graph
96 Commits
Author SHA1 Message Date
James Stringer 9ccaa5d629 Implement Windows guest accessibility collector in C
Replace the C++ collector with a C17 implementation using the existing
accessibility protocol and VM viewer bridge. Separate UI Automation
capture/actions, event handling, and Windows JSON serialization.

Translate native control patterns and text/table relationships generically,
preserve element identity across snapshots, and align request deadlines
and refresh scheduling with the macOS collector.
2026-09-22 18:29:51 -04:00
James Stringer b10c3de086 Add guest accessibility support to macOS VM viewers
Expose guest accessibility trees through a host AppKit helper and forward attributes, actions, text operations, and input through shared transport.

Package macOS and Windows guest collectors and integrate viewer lifecycle, refresh scheduling, and geometry handling.
2026-09-16 18:13:23 -04:00
James Stringer af241cdaf3 Bump version to 0.1.8
App Sandbox 0.1.8

### Added

- Choose a specific GPU when creating or editing a VM on Windows, with automatic fallback if that GPU becomes unavailable.
  Thanks to @TejasPersonal, @Mungr3ss and @JasonSTX for requesting this ([#109](https://github.com/jamesstringer90/appsandbox/issues/109)), and @trevmlt for documenting the multi-GPU problem and a workaround ([#110](https://github.com/jamesstringer90/appsandbox/issues/110)).

### Fixed

- Preserve VM MAC addresses across restarts on Windows and macOS, allowing router address reservations to keep working.
  Thanks to @kurokawaikki for identifying the changing MAC addresses ([#92](https://github.com/jamesstringer90/appsandbox/issues/92)).
- Keep automatic login enabled and prevent password expiry for newly created Windows VMs on Windows and macOS hosts.
  Thanks to @macg4dave for reporting unexpected login prompts ([#133](https://github.com/jamesstringer90/appsandbox/issues/133)).
- Fix network setup failures when starting multiple VMs at the same time on Windows.
- Reduce unexpected SSH port changes on Windows by retrying the saved port, with clearer failure messages.
- Fix missing network drivers in newly created Windows VMs on macOS.
  Thanks to @YiwenLu-yiwen for reporting the failed download and confirming the workaround ([#107](https://github.com/jamesstringer90/appsandbox/issues/107#issuecomment-5689676123)).
2026-09-15 21:55:30 -04:00
James Stringer 0ad1739c7e Keep Windows VM automatic login and passwords from expiring
Apply persistent automatic login and non-expiring passwords across Windows VM setup paths.
2026-09-15 20:17:41 -04:00
James Stringer 042559092b Preserve VM MAC addresses across restarts
Save and reuse each VM's MAC address on Windows and macOS hosts, including existing VMs that do not yet have one.
2026-09-15 20:17:41 -04:00
James Stringer c654b940d0 Bump version to 0.1.7
App Sandbox 0.1.7

### Added

- NVIDIA DLSS support in compatible Vulkan games running in Windows VMs on x64 Windows hosts.
  Thanks to @darkjezza for reporting this ([#139](https://github.com/jamesstringer90/appsandbox/issues/139)).
- A dedicated VM settings dialog on Windows and macOS, and a clearer snapshot and branch manager on Windows.

### Fixed

- Corrected GPU and network information on macOS and removed unsupported network options.
2026-09-14 22:49:27 -04:00
James Stringer cc446a73f2 Fix Vulkan DLSS GPU identity matching 2026-09-14 19:21:42 -04:00
James Stringer 3480763be3 Bump version to 0.1.6
App Sandbox 0.1.6

### Added

- Native NVIDIA OpenGL and Vulkan support in Windows VMs on x64 Windows hosts, including 32-bit games and applications.
  **Special thanks to @Poldino95 for figuring out why NVIDIA's native graphics drivers weren't working inside VMs and demonstrating working solutions. Their detailed research provided the foundation for these improvements.** ([#130](https://github.com/jamesstringer90/appsandbox/pull/130), [#131](https://github.com/jamesstringer90/appsandbox/pull/131))
  Thanks also to @N1qro for reporting Vulkan game launch failures ([#73](https://github.com/jamesstringer90/appsandbox/issues/73)).

- NVIDIA DLSS support in compatible 64-bit games running in Windows VMs on x64 Windows hosts.
  Thanks again to @Poldino95 for identifying what prevented DLSS from working and demonstrating the solution ([#129](https://github.com/jamesstringer90/appsandbox/pull/129)), and @Giraffe886 for raising this ([#98](https://github.com/jamesstringer90/appsandbox/issues/98)).

### Fixed

- Improved OpenGL and Vulkan support for Intel and AMD GPUs in Windows VMs by using their native graphics drivers, including supplying missing AMD driver files.
- Fixed Ubuntu 26.04.1 VMs getting stuck during installation.
  Thanks to @EzYDark for diagnosing the package compatibility problem and proposing a fix ([#120](https://github.com/jamesstringer90/appsandbox/pull/120)).
- Fixed Firefox failing to launch in newly created Ubuntu VMs.
  Thanks to @EzYDark for identifying the cause and proposing a fix ([#120](https://github.com/jamesstringer90/appsandbox/pull/120)).
- Fixed package update errors in newly created Ubuntu VMs caused by leftover installation-disc sources.
2026-09-13 20:28:37 -04:00
James Stringer 0d9069dd98 Use lowercase NVIDIA shim filenames 2026-09-13 19:37:21 -04:00
James Stringer 66095f03e7 Enable NVIDIA DLSS in Windows GPU VMs 2026-09-13 19:29:20 -04:00
James Stringer 62d7a0a002 Enable native OpenGL and Vulkan in Windows GPU VMs
Improves OpenGL and Vulkan support for Windows VMs on x64 Windows hosts.

NVIDIA GPUs now support native OpenGL and Vulkan, including 32-bit applications.

Fixed missing AMD OpenGL and Vulkan driver files in Windows VMs.

Intel and AMD VMs now use their native graphics runtimes by default instead of Mesa.

The NVIDIA components build, sign, and bundle through the existing release process and install through the existing guest-agent file transfer. Native runtime setup requires the updated guest agent; older agents retain their existing graphics setup.
2026-09-13 16:23:11 -04:00
James Stringer 16f8a72cc0 Fix Ubuntu Firefox permissions and APT sources 2026-09-13 14:33:53 -04:00
James Stringer 6d2e10fd0b Fix Ubuntu ISO build dependency version selection 2026-09-13 13:14:44 -04:00
James Stringer 4b43155f47 Clarify native GPU shim and provisioning names 2026-09-12 20:39:40 -04:00
James Stringer 17f7ba07e9 Enable native OpenGL and Vulkan for Windows GPU VMs
Build and stage x64 and x86 NVIDIA shims through the existing solution and deploy them through P9 and the guest agent. Include active AMD runtime packages and prefer native OpenGL and Vulkan on NVIDIA, AMD, and Intel guests.
2026-09-12 19:26:06 -04:00
James Stringer 9d6342f977 Fix viewer mouse capture and keyboard handling 2026-09-08 22:49:37 -04:00
James Stringer 92c7a350f9 Remove redundant source comments 2026-09-07 20:58:47 -04:00
James Stringer a68665db2d Restore static NAT networking and preserve saved VM IPs 2026-09-07 20:20:41 -04:00
James Stringer fcdef6223c Configure NAT DHCP subnets and remove Windows agent IP setup 2026-09-07 17:44:17 -04:00
James Stringer c737c292cf Use DHCP for Windows-host NAT networking 2026-09-07 15:44:22 -04:00
James Stringer 4e2493dfbe Fix international keyboard input and Linux clipboard copying 2026-09-07 14:27:27 -04:00
James Stringer 978f52b8f5 Fix VM setup, storage, snapshots, and viewer behavior 2026-09-07 13:02:28 -04:00
James Stringer 2d9eae869a Bump version to 0.1.4
App Sandbox 0.1.4

- **Windows 11 (ARM64) VMs on macOS.** On an Apple Silicon Mac, App Sandbox can
  now create and run Windows 11 ARM guests -- previously a macOS host could only
  run macOS guests. The Windows guest gets its own display window, keyboard and
  mouse, sound, clipboard (including copying files to and from your Mac),
  one-click SSH, and networking, and is built from a Windows 11 ARM64 ISO you
  provide. It runs on a self-contained virtual-machine engine bundled with the
  app, and the guest agent and drivers are downloaded (code-signed) when you
  create the VM, so no test-signed components ship inside App Sandbox.

- **Non-ASCII usernames and passwords now work when creating a VM through the
  scriptable API.** Characters outside plain ASCII (for example Chinese) arrive
  from the API JSON-escaped; App Sandbox stored the escape sequences literally
  instead of decoding them, so a VM created via the API with such a credential
  would reject the login. They are now decoded correctly. (The desktop app was
  unaffected.)
- **The virtual display now recovers if it gets disabled in the guest.** The
  guest agent kept trying to restart the App Sandbox display driver -- which
  can't re-enable a disabled device -- so the picture never came back; it is now
  re-enabled and recovers.
- Various stability and bug fixes across the Windows and macOS components.

- **Windows VMs on macOS are not GPU-accelerated.**
- **x64 (emulated) apps in ARM Windows VMs don't get the OpenGL fix** -- the Mesa
  driver shipped on ARM is ARM64-only; native ARM64 apps get full GPU OpenGL.
  (carried over from 0.1.2)
- **ARM Linux (Ubuntu 26.04 LTS) guests do not work -- on ARM, Windows is the
  only working guest** (Ubuntu 26.04's arm64 kernel churns BPF JIT memory and
  never reaches the desktop). (carried over from 0.1.2)
2026-06-30 20:57:07 -04:00
James Stringer e931f24bf7 Remove superseded dev prototypes from the engine and ivshmem tools
win2ntfs.c was the standalone harness that validated the WIM->NTFS apply;
that logic now lives (with real per-file SIDs) in win_disk.c. AppSandboxSHM_producer.c
was the ivshmem bring-up bandwidth POC whose host-side reader (shm-test) is gone;
the production data path is asb_transport over the AppSandboxSHM driver. Neither
file was compiled by any target or included anywhere.
2026-06-30 19:30:52 -04:00
James Stringer 095a4f9ed4 Remove dev-only agent build/deploy scripts added in this branch
build-arm64.cmd and deploy-arm64.cmd were manual dev-VM helpers (cl build
of the guest binaries + hand-copy to C:\Windows\AppSandbox); the production
pipeline builds via msbuild on AppSandbox.sln and never referenced them.
2026-06-30 18:57:27 -04:00
James Stringer 4898c4692f Remove TODO planning docs; complete THIRD-PARTY-NOTICES for the bundled deps
- Delete the TODO/ planning + runbook docs, and fix the four code/README comments
  that pointed at them (asb_transport.c/.h; the tools/ivshmem and vendor/qemu-ivshmem
  READMEs now point at the vendored QEMU directly).
- THIRD-PARTY-NOTICES.md: add the bundled QEMU stack (QEMU GPL-2.0; GLib +
  gettext/libintl LGPL-2.1; PCRE2 BSD; EDK2/TianoCore BSD-2-Clause-Patent) and
  NetKVM (BSD-3) -- shipped/staged by the app but previously absent from the
  top-level notices. The QEMU entry cross-references the bundled
  vendor/qemu-ivshmem/LICENSES/NOTICE.md + WRITTEN_OFFER.txt. A usage audit
  confirmed every listed dependency is still in use, so nothing was removed.
2026-06-30 18:42:49 -04:00
James Stringer dfd6fe475f Win-on-Mac: fix ivshmem AGENT/SSH region overlap and display readiness
Post-review fixes and release prep for the win-on-mac feature.

* asb_shm_layout.h: fix a region-sizing bug -- the AGENT (ch1) slot stride
  (0x20070) exceeded ASB_AGENT_REGION_SIZE (0x20000) by 112 bytes, so the agent
  host->guest ring overran into the adjacent SSH (ch7) region and corrupted its
  slot state under sustained traffic. Enlarge the AGENT region to 0x21000
  (downstream offsets cascade) and add per-region compile-time guards
  (n_slots*stride <= region_size) so this class of overlap fails the build.
  Host/publisher-side only -- the guest reads geometry from the published directory.

* headless.m: GET /display readiness now includes idd_ready for a Windows guest,
  matching the open precondition (asb_core_mac.m) and the Windows host
  (asb_vm_idd_ready). Before, the Mac readiness was running && agent_online only,
  so it could report ready before the VDD was up and a poll-then-open would
  spuriously 409 display_not_ready. macOS guests are unchanged.

* iso-patch-mac.m (stage): wipe the plaintext password buffer on the
  --shadowhash-file read-failure path, matching the sibling --kcpassword-file path.

* iso_patch_mac.m: point the signed Windows guest payload at the v0.1.4 release.

* vm_lifecycle.py: raise the Windows build-stall budget to 3600 s for the
  signal-less first-boot window under concurrent multi-VM load.

* tools/headless-api/README.md: document Windows guests on macOS hosts (platform
  matrix, host-fixed line, requirements heading, osType field).
2026-06-30 18:12:32 -04:00
James Stringer c042b92a21 Agent: enable (not just restart) a disabled VDD to recover it
ensure_vdd_running() detected a disabled AppSandboxVDD and ran `devcon restart`,
which reports success but cannot clear CONFIGFLAG_DISABLED on a device in
CM_PROB_DISABLED -- so the device snapped straight back to disabled and the agent
looped forever (detect disabled -> restart -> still disabled, every 20s). Only
`devcon enable` (DICS_ENABLE) clears the explicit-disable bit.

Now: ENABLE a disabled device; keep RESTART for a stuck-but-enabled ("problem") one.
2026-06-29 21:31:59 -04:00
James Stringer 303b34dab8 Win-on-Mac: encode the guest password in the daemon for all three configs
All three guest configs now obfuscate/hash the account credential in the daemon
and hand the disk-applier child only the non-plaintext result -- the plaintext
never crosses the process boundary, mirroring the Windows-on-Windows model.

  * Win-on-Mac: the daemon generates unattend.xml / setup.cmd / SetupComplete.cmd
    in-process via the shared asb_provision_* (base64 of UTF-16LE(pass+"Password"),
    the same encoder the Windows backend uses) and passes build-windows only
    --prov-dir; the plaintext --pass argv is gone. The child still detects the
    install.wim language and reports LANG:, and the daemon re-generates unattend.xml
    in-process with the detected tag -- the exact mirror of vhdx_create_thread.
  * Mac-on-Mac: the salted PBKDF2-SHA512 ShadowHash + kcpassword are computed in
    the daemon via the new shared tools/provision/mac_account_hash.{h,m}; the stage
    child takes --shadowhash-file / --kcpassword-file. --user-password-file remains
    a direct-CLI fallback.
  * Verified end-to-end on live Windows + macOS guests with a 12-character mixed
    Chinese/English password (ValidateCredentials / dscl -authonly), exercising the
    UTF-16 surrogate path.

Also in this checkpoint of accumulated win-on-mac work:

  * agent: report_idd_status re-runs on the device-check loop (force-on-connect +
    on-change) so display readiness tracks the live, self-healed VDD state instead
    of a single one-shot sample.
  * disk builder (tools/iso-patch-mac/engine): WIM reader gains the install-image
    default-language reader behind the language auto-detect; win_disk locale/apply
    refinements.
  * display + transport: idd_display Metal render + clipboard-reader paths;
    asb_ivshmem_transport slot-reclaim hardening.
  * housekeeping: remove the dev-only transport test harness (tools/transport/test/*);
    update headless-api test scripts; drop changelog-style comments.
2026-06-29 20:50:32 -04:00
James Stringer 4b28e7138d Windows-on-Mac: JIT-only guest payload; remove the bundled test-signed fallback
The Mac host now sources the entire Windows guest payload via JIT download + cache --
no bundled/embedded fallback, so zero test-signed binaries ship in the app.

- iso-patch-mac.m (build-windows): --signed-payload-zip is now required (its extraction
  failing is a hard error, not a fallback); new --netkvm-zip. Extract the signed zip in
  full -- the Windows-built zip uses backslash separators that forward-slash unzip
  include-patterns never match (unzip exits 11 and stages nothing); a full extract makes
  Info-ZIP rewrite them into real resources/ + drivers/. Stage our VDD/VAD/SHM from the
  signed payload and NetKVM from its own zip (best-effort). Drop --payload/--devcon.
- iso_patch_mac.{h,m}: buildWindowsDiskWithISO drops payloadDir/devconExe, takes a
  required signedPayloadZip + optional netkvmZip. Add ensureNetkvmZipCached (pulls the
  vendored netkvm-arm64.zip from the public repo, cached like the IPSW).
- asb_core_mac.m: remove windows_payload_directory()/devcon_exe_path(); the create flow
  fails if the signed payload download fails (JIT-only). NetKVM + OpenSSH best-effort.
- Remove the "Embed agent_win" Xcode phase and git rm tools/agent_win (the test-signed
  EXEs + drivers). The app bundle embeds zero Windows test-signed binaries.

Fixes the staging bug where the backslash zip silently fell back to the bundled
WDKTestCert drivers, which failed DriverStore import (0xE0000243), so the agent never
came online.
2026-06-28 23:09:39 -04:00
James Stringer 3cddb072e7 Windows-on-Mac: JIT-download the signed guest payload instead of bundling it
The macOS host now pulls the signed Windows release zip (EV-signed agent EXEs +
MS-attestation-signed drivers, incl. the ivshmem AppSandboxSHM) and stages those
into the guest, instead of the bundled test-signed tools/agent_win payload.

- iso_patch_mac.m: ensureSignedWinPayloadZipCached mirrors ensureOpenSSHMsiCached
  -- a single atomic writeToFile of the release zip to a version-named file under
  the support dir (sibling of VMs/), race-safe by the same single atomic write.
  Returns the cached zip path; the build extracts it.
- iso-patch-mac.m (build-windows): new --signed-payload-zip. When given, the CLI
  selectively unzips resources/appsandbox-*.exe + drivers/* into its own per-build
  temp and prefers them over --payload (so concurrent creates never collide);
  derives binDir/drvDir/devconPath from it. Falls back to --payload on any problem.
  The signed drivers carry no .cer, so SetupComplete's `if exist` certutil steps
  no-op; devcon comes from the zip's drivers/.
- iso_patch_mac.{h,m}: buildWindowsDiskWithISO threads signedPayloadZip and makes
  --payload conditional (a nil bundle can't crash the args array).
- asb_core_mac.m: start_windows_build_flow caches the zip off-main and passes it;
  bundled payload remains the fallback. NetKVM is still not downloaded.

The bundled test-signed payload stays embedded as a fallback for now; dropping the
Xcode "Embed agent_win" phase (to fully remove test-signed binaries from the app)
is a follow-up once the download URL is durable. Mac target not compiled here.
2026-06-28 21:16:30 -04:00
James Stringer 584f0b7cc5 Windows: unify provisioning (R5) + fix UTF-8 username/password handling
Provisioning unification (R5):
- disk_util.c delegates generate_unattend_vhdx / generate_vhdx_setup_cmd /
  generate_vhdx_setupcomplete to the shared tools/provision/win_provision.c, and
  stages AppSandboxSHM + NetKVM (existence-gated) in generate_vhdx_manifest.
- Compile win_provision.c into AppSandboxCore.vcxproj. Win->Win output is
  equivalent (the SHM/NetKVM install steps are if-exist no-ops on a PC host).

UTF-8 / non-ASCII credentials:
- win_provision.c: encode the unattend <Password> as true UTF-16LE (was a UTF-8
  byte zero-extend that corrupted non-ASCII/CJK passwords); ASCII unchanged. Plus
  case-insensitive locale-tag lookup and ComputerName truncation by UTF-8 code
  points (never splitting a multibyte char).
- webview2_bridge.c json_get_string: decode JSON escapes (\uXXXX, \" \ ...) so
  non-ASCII values from the headless SDK (json.dumps/ensure_ascii) are no longer
  stored as literal \uXXXX text. Validated end-to-end: a CJK password now sets
  correctly and Windows authenticates against it.
- disk_util.c wrapper: check the WideCharToMultiByte conversions.

Also included in the working tree:
- Reconcile user-mode .vcxproj platform toolset v145 -> v143 (VS2022).
- WINDOWS_AGENT_BRIEF.md: correct stale driver-name/symbol/devcon references.
2026-06-28 21:16:30 -04:00
James Stringer 842c194e2c Windows-on-Mac: build-integrate the SHM driver, fix provisioning, harden transport/display
- Rename the ivshmem guest driver asb_ivshmem -> AppSandboxSHM everywhere (files, INF
  service/binary/catalog + display strings, device-interface GUID symbol with the GUID
  value preserved, driver source, transport, provisioning, payload, iso-patch stage list).
  QEMU's ivshmem device id and the Mac host transport (asb_ivshmem_transport.*) keep names.
- Build the driver through the VS pipeline like VDD/VAD: AppSandboxSHM.vcxproj (KMDF) +
  Package/AppSandboxSHMPackage.vcxproj (Inf2Cat + TestSign + post-build copy into
  bin\Release[-ARM64]\drivers), registered in AppSandbox.sln; add to submission-config.json
  + make-release.ps1 for MS attestation. INF gets a .10.0...22000 (Win11) TargetOSVersion
  decoration (required by DIRID 13 / PnpLockdown).
- Install the SHM PCI driver with devcon update (not devcon install, which fabricates a
  phantom ROOT devnode on a real PnP hwid) -- same pattern as NetKVM.
- Fix SetupComplete.cmd: a literal (...) in an echo inside a cmd ( ) block desynced cmd's
  paren matcher and silently skipped every driver install; removed it.
- iso-patch: per-build -shadow ISO attach so concurrent VM builds get independent devices.
- Reconcile all user-mode .vcxproj to the v145 (VS 2026) toolset.
- Transport/display: guest liveness beacon + h2g-stall reclaim, zero-copy Metal render of
  the IDD display, clipboard-file paste chown for the root daemon.
- Refresh the committed tools/agent_win payload; update the windows-on-mac integration plan.
2026-06-22 22:38:34 -04:00
James Stringer 0d4897dd6b Windows guest on Mac host via QEMU+HVF + ivshmem transport
Run Windows 11 ARM64 guests on macOS over QEMU+HVF, with an ivshmem
shared-memory transport carrying every guest channel (agent control,
display/VDD, input, audio, clipboard, SSH, 9P) - no guest networking
required.

- tools/transport: one guest transport API, two backends (PC AF_HYPERV,
  Mac ivshmem); SPSC ring with an acquire-barrier fix for SSH integrity
- tools/ivshmem: our own KMDF ivshmem BAR-mapping driver (no third party)
- src/backend_mac: Mac-host ivshmem transport, QEMU VM lifecycle, IDD
  display consumer, agent/SSH proxies, ISO->disk patcher, Windows create
- tools/agent + channel EXEs + tools/vdd: wired to asb_transport
- tools/agent_win: staged guest payload (interim, pending JIT pull)
- vendor/qemu-ivshmem: vendored QEMU 11.0.1 fork (ivshmem-plain) + LGPL
  source mirror for the self-contained app bundle
- tools/sign/make-release.ps1: use the host-native ARM64 MSBuild so the
  WDK driver ApiValidator runs (the x86 validator fails on ARM64)
2026-06-21 18:30:59 -04:00
James Stringer df0e2532e0 Bump version to 0.1.3
### Added
- **Headless mode with a scriptable HTTP/JSON API (Windows + macOS).** Launch
  App Sandbox with `--headless` to run a single-owner background daemon exposing
  a loopback HTTP/JSON API that mirrors the GUI: create, start, shut down, edit,
  and delete VMs; manage snapshots, branches, and templates (Windows); read SSH
  connection info; subscribe to a live event stream; and open or close a VM's
  display window -- all from a script. Ships a dependency-free Python SDK,
  runnable examples, and a cross-platform test suite (bundled in the release
  package under headless-api/, alongside the app). Launching normally (no
  `--headless`) is unchanged.
- **One-click SSH key login.** With the SSH server enabled, the new "Deploy SSH
  key" option installs an App Sandbox key into the guest (Windows, Linux, and
  macOS) so the GUI's SSH button and the SDK connect without a password.

### Fixed
- **Excessive GPU usage while viewing a Windows VM.** The display window was
  redrawing as fast as it could -- presenting ~2,100 frames a second and holding
  the host GPU near 90% even on a static screen. It now redraws only when the
  picture changes (plus a small safety refresh), dropping to the real frame rate
  (~30-60 fps) with no added latency.
- **A graceful shutdown could report a false error.** On a busy guest, a
  shutdown that actually succeeded could surface as a failure; shutdown and
  restart now report success once the request is delivered and confirm it by the
  guest exiting.
- **The headless daemon now cleans up its VMs when it exits**, instead of
  leaving them running with no owner.
- **macOS: text fields no longer autocorrect or autocapitalize** VM names,
  usernames, paths, and snapshot names as you type.
- Various stability and bug fixes across the Windows, macOS, and Linux
  components.

### Known issues
- **Create VMs one at a time.** Creating several at once can race on the
  disk-image build/staging step, causing a build to fail and the VM to be
  removed; create them sequentially.
- **x64 (emulated) apps in ARM Windows VMs don't get the OpenGL fix** -- the
  Mesa driver shipped on ARM is ARM64-only; native ARM64 apps get full GPU
  OpenGL. (carried over from 0.1.2)
- **ARM Linux (Ubuntu 26.04 LTS) guests do not work -- on ARM, Windows is the
  only working guest** (Ubuntu 26.04's arm64 kernel churns BPF JIT memory and
  never reaches the desktop). (carried over from 0.1.2)
2026-06-11 22:03:47 -04:00
James Stringer a800e5d3fa Ship the headless-api SDK alongside the app in release packages
Both release packagers now place a headless-api/ folder next to the app at the
zip root (AppSandbox.exe / AppSandbox.app + headless-api/), so a user who
installs from a release gets the Python SDK, examples, and tests without cloning
the repo. The folder holds asb.py, README.md, examples/ and tests/ -- no tools/
parent, and __pycache__/*.pyc are excluded.

Windows (make-release.ps1): stage the folder into the explicit allowlist just
before zipping, and add it to the required-artifacts tripwire.

macOS (make-release-mac.sh): publish_package stages the already-stapled .app
plus the SDK and archives the staging dir contents (ditto -c -k without
--keepParent) so both land at the zip root; ditto copies the bundle verbatim,
preserving its signature and notarization staple.

The SDK is added only at the final packaging step, after the binaries and
drivers are signed and (macOS) the app is notarized and stapled.
2026-06-11 21:52:14 -04:00
James Stringer 9b9b92f053 Add the display window to the macOS headless daemon; retire the plan docs
Bring macOS to parity with the Windows display feature: open/close/poll the VM's
display window over the API (POST/DELETE/GET /v1/vms/{name}/display, plus
displayOpen on every status object), so a script can show the same view the GUI's
Connect button does. Validated live on Apple silicon.

The GUI already creates the per-VM VZVirtualMachineView window on the Running
transition (gated off under --headless); the daemon now opens it on an explicit
request after two gates:
  - A-gate: asb_mac_have_gui_session() (CGSessionCopyCurrentDictionary /
    kCGSessionOnConsoleKey) -- a daemon with no console Aqua session (launchd /
    SSH) refuses with 409 no_display instead of spawning an invisible window;
  - readiness: running && agent_online. macOS has no frame channel or display
    driver (the view binds the in-process VM framebuffer directly), so there is
    nothing to probe -- unlike the Windows/Linux idd_status latch.
New core API asb_mac_open_display / asb_mac_close_display (asb_core_mac.m); new
codes BACKEND_ERR_NO_DISPLAY / BACKEND_ERR_NOT_READY (asb_types.h).

run_headless swaps the bare CFRunLoopRun() for [NSApp run] (Accessory policy)
ONLY in a console GUI session -- the window needs the window server; otherwise it
keeps the bare CFRunLoop so the daemon still runs headless over SSH/launchd. Both
loops drain the main dispatch queue, so every VZ op and the SIGINT/SIGTERM sources
are unaffected; cleanup_and_exit exit()s directly, so no quit-path change. The
spike the design flagged as unverifiable without a Mac was confirmed here: VZ
main-queue dispatches still fire under [NSApp run], and windows open, take focus,
and deliver windowWillClose:.

Close tracking avoids a mid-close use-after-free: VzDisplayWindow gains a
userClosed flag set in windowWillClose:; displayOpen reads display && !userClosed,
and open_display reaps a self-(X)-closed window on the next request (off the WM
close stack), mirroring the Windows reap. showDisplay also calls
activateIgnoringOtherApps: so the Accessory daemon's window comes to the front.

tests: vm_lifecycle.py now runs the display open/close check on macOS too (it
self-skips on 409 no_display or a Linux guest whose agent predates idd_status).
README documents the macOS display support (matrix row, the console-session
A-gate, and the running && agentOnline readiness).

Remove tools/headless-api/PLAN.md and display-plan.md: these were the design /
decision logs for the headless port and the display feature, both now shipped and
validated. Their dangling references in README.md and headless.m comments are
cleaned up in the same change.
2026-06-11 20:27:52 -04:00
James Stringer 7ed54b1fc4 Document edit() and snap_take() stopped-only preconditions in the SDK
edit() honors ramMb/cpuCores/gpuMode/networkMode on a stopped VM (name is fixed at create, other keys ignored; 409 if running); snap_take() requires the VM stopped (409 vm_running).
2026-06-11 20:08:47 -04:00
James Stringer 82c5bd7507 Mark Linux display validated in the plan; advise sequential VM creates
display-plan.md: the Linux display half is now implemented and validated (confirmed on fresh Linux VMs built from the pushed branch, where the agent's idd_status latches readiness and the display opens).

README.md: note that VMs should be created sequentially -- concurrent creates can race on the VHDX-build prefetch/staging and a build may fail (iso-patch.exe exit 1) and be removed.
2026-06-11 18:59:16 -04:00
James Stringer 889ccbc3a1 Implement headless display open/close with agent-reported readiness
Add POST/DELETE/GET /vms/{name}/display plus the open_display/close_display/display_status/display_ready SDK methods, so a script can open and close a VM's display window like the GUI's Connect button.

Readiness is a latched flag, not a frame-channel probe: connecting to the guest frame service is itself becoming the display's single consumer, so polling it would steal the slot and blank the display. The guest agent reports the display driver state over the agent channel (idd_status) and the host latches it as idd_ready; asb_vm_idd_ready = running && agent_online && idd_ready. The Linux agent reports idd_status:ok once the user session is up (Mutter compositing).

The display window is daemon-owned (per-VM table keyed by unique_id), gated on a visible window station, and self-tears-down on the X button; displayOpen is read from the live window state, so it is honest however the window closed.
2026-06-11 18:14:13 -04:00
James Stringer b95913dc1c Add headless display-open design plan
tools/headless-api/display-plan.md: design for opening/closing a VM display window
through the headless API (POST/DELETE /v1/vms/{name}/display). Windows is implementable
(vm_display_idd_create is self-contained); macOS is design-only and unvalidated (it
swaps the daemon run loop to AppKit and needs a Mac to verify). Access model: bearer
token for auth + a runtime "can this session render a window" gate; no loopback/peer
detection.
2026-06-10 22:30:34 -04:00
James Stringer 929ad69f89 Make the headless SDK and test suite cross-platform; update docs
asb.py: resolve the support directory, daemon launch hint, and SSH key path per
platform (%ProgramData%\AppSandbox on Windows, ~/Library/Application Support/
AppSandbox on macOS) so the same SDK drives either daemon from its host.json.

tests: the suite is now capability-gated and runs on either host. helpers.py
adds IS_MAC, the per-platform VM/disk paths, the macOS IPSW location, a key-auth
login helper (chmod on mac), and wait_progress -- a stall-based wait that watches
the VM's reported progress/status instead of a fixed deadline, so a slow install
or IPSW download doesn't false-fail. run_all.py launches the macOS suite as two
concurrent VMs (one downloading a fresh IPSW, one from cache) sized 4096 MB / 2
cores / 64 GB, with a leftover sweep and IPSW housekeeping. The lifecycle and
host/validation tests assert 501 for snapshots/templates on macOS and run the
Windows-only template build only where supported.

docs: README gains a platform-support matrix (which guest OSes and host features
each platform supports) and the macOS sudo/SUDO_USER launch model alongside the
Windows instructions. PLAN.md records the macOS port, the Windows
cleanup-on-exit fix, the guest-agent threading fix, and the startup fail-fast /
GUI polish.
2026-06-10 19:00:04 -04:00
James Stringer 73e8a253ed Deploy the SSH key off the accept loop in the macOS guest agent
The macOS guest agent ran ssh_deploy_key inline on its single command socket.
On a cold first boot the find_primary_user lookup (getpwent/OpenDirectory) can
take several seconds, during which the agent could not service heartbeats or
replies and the host would tear the connection down -- the key deploy reported
as failed even though it eventually succeeded.

Run the deploy on a detached worker thread (spawn_deploy_key) so the accept loop
keeps responding. send_line takes a mutex so a worker's reply can't interleave
its bytes with the loop's writes on the shared socket, and a connection
generation counter (g_conn_gen, bumped on every connection start/end) lets a
worker tell its connection is gone -- and the fd possibly reused by a new client
-- and suppress a stale write via send_line_gen. deploy_ssh_key now returns
failure (reports ssh_key_failed) when the chown of authorized_keys fails instead
of falsely reporting success.
2026-06-10 18:34:41 -04:00
James Stringer 4087baa4bf Add headless --headless daemon, HTTP/JSON API + Python SDK, and SSH key deploy
Headless mode: `appsandbox.exe --headless` runs a single-owner daemon that hosts
the core over a loopback HTTP/JSON API (http.sys) with a host.json discovery
file. A dependency-free Python SDK, examples, and a self-contained regression
suite live under tools/headless-api/ (PLAN.md = design rationale).

The API mirrors the GUI: create/start/shutdown/stop/delete/edit, snapshots and
branches (incl. base branches via the new asb_snap_base_branch_count), templates,
sshInfo, an SSE /v1/events stream, GUI-mirrored input validation, a startup
fail-fast (admin / Win11 build / VirtualMachinePlatform), and a single-instance
mutex shared with the GUI so only one of GUI/headless runs at a time.

SSH key deploy: sshDeployKey (requires sshEnabled) has the core generate an
AppSandbox ed25519 keypair once and the guest agent write the public key into
authorized_keys -- Windows administrators_authorized_keys (+ ACL), Linux/macOS
~/.ssh -- reporting a new ssh_key_deployed status (sshState 4). The GUI SSH
button and the SDK use the key for password-less login. Verified end-to-end on
Windows.

The Linux guest builds its agent/driver source from this branch's GitHub repo;
asb_core.c points the prefetch at "headless-api" (revert to "main" before merge,
see PLAN.md).
2026-06-09 20:12:18 -04:00
James Stringer 1060c2ac5b Add Mesa standalone opengl32 for Windows guest OpenGL
Deploy Mesa's standalone opengl32 trio (opengl32.dll + gallium_wgl.dll + z-1.dll,
the gallium d3d12 driver + WGL frontend) system-wide into Windows GPU-PV guests,
so apps get hardware OpenGL 4.6 via D3D12 (WARP software 4.6 when there is no GPU).
OpenCL (OpenCLOn12), Vulkan (Dozen) and dxil.dll are unchanged.

- tools/win-mesa-gl: vendored prebuilt trio for x64 + arm64 (Mesa 26.1.2,
  EV-signed) plus build-mesa.cmd, aarch64-cross.txt, sign-mesa.ps1, and README.
- AppSandbox.vcxproj: stage the build's-arch trio into resources\win-mesa-gl
  per-config, alongside the WebView2Loader copy.
- asb_core.c: prepare_gl_layers_share stages the trio into the AppSandbox.GlLayers
  Plan 9 share.
- agent.c: gl_provision deploys the trio into the guest's System32 (take ownership,
  rename the in-use opengl32 aside, copy in; re-applied every boot to self-heal),
  and keeps the dxil.dll staging + Khronos OpenCL/Vulkan ICD registrations.
- Remove the appsandbox_gl_shim project (AppSandbox.sln, tools/gl-shim).
- .gitignore: un-ignore the vendored prebuilt Mesa binaries.
- SIGNING.md: drop the shim; the Mesa trio is pre-signed via sign-mesa.ps1.
2026-06-06 22:06:33 -04:00
James Stringer e5acdaaf8b Add ARM64 support for the Linux guest (iso-patch)
iso-patch builds an arm64 Ubuntu VHDX: the grub/shim/EFI, apt, dxcore and
mesa paths are selected from the build arch at compile time via the new
target_arch.h, and the arm64 serial console is ttyAMA0 (PL011) not ttyS0.
x64 behavior is unchanged. (Windows-on-ARM support landed in the previous
commit.)

Known issue: an arm64 Ubuntu 26.04 LTS guest boots very slowly on this
platform and is not usable in practice yet — Windows is the supported
arm64 guest for now. The 26.04 generic kernel is built
CONFIG_BPF_JIT_ALWAYS_ON (+RODATA_FULL), so systemd's constant BPF churn
JIT-allocs and frees executable memory, and each free issues a broadcast
cross-CPU TLB/cache-maintenance op (TLBI ..IS). arm64 has no Hyper-V
paravirt TLB flush, so the hypervisor traps every one and the cost scales
with vCPU count; the host's experimental Insider Hyper-V services them
slowly. Fewer vCPUs or a stable Hyper-V build mitigate it.

Also trim the previous commit's ARM code comments down to the essential
architectural differences.
2026-06-05 18:42:50 -04:00
James Stringer 717c5b5148 Add ARM64 (Windows on ARM) support
Build, EV-sign, Microsoft attestation-sign, and package AppSandbox for
Windows on ARM with feature parity to x64 except the vTPM and guest-state
isolation (neither is supported by ARM Windows HCS). Target architecture is
resolved at compile time (ASB_IS_ARM64 in disk_util.h); the supported pairing
is x64 build/host/guest and ARM64 build/host/guest, so one flag drives every
architecture decision. x64 behavior is unchanged throughout.

Runtime:
- hcs_vm.c: omit SecuritySettings (vTPM + GuestStateOnly isolation) on ARM;
  Secure Boot is retained.
- disk_util.c: emit the arch token in every autounattend/unattend
  processorArchitecture attribute; on ARM, bypass the Win11 Setup hardware
  checks via the HKLM\SYSTEM\Setup\LabConfig keys across all VM-creation
  paths; select the arch-correct OpenSSH Server MSI.
- d3dlayers.c / agent.c: resolve, download, and stage the arm64 D3D mapping
  layers for GPU-PV; stage the Vulkan ICD manifest under the arch-neutral
  name dzn_icd.json.

Build and release pipeline:
- AppSandbox.sln: add the missing AppSandboxPackage Release|ARM64 Build.0 so
  the VS GUI actually runs sign+package for the ARM64 config.
- AppSandboxPackage.vcxproj: run make-release.ps1 for Release on x64 or ARM64,
  passing -Platform $(Platform).
- make-release.ps1 / sign-drivers.ps1: -Platform ARM64 selects bin\Release-ARM64,
  the ARM64 attestation profile, and the AppSandbox-<ver>-win-arm64.zip name.
  Sanitize LIB before Add-Type so the .NET Framework C# compiler does not fail
  (CS1668) on the non-existent atlmfc\lib\ARM64 path the VS ARM64 build adds to
  LIB.
- Directory.Build.props: disable ApiValidator only when cross-building ARM64 on
  a non-ARM64 host (the x86 ApiExtractor cannot read ARM64 PEs); Microsoft
  re-runs full API validation on every attestation submission.
- Package.vcxproj: stage the vendored ARM64 devcon.exe into the ARM64 drivers
  output, mirroring the x64 devcon copy.
- vendor/devcon/arm64/devcon.exe: add the vendored ARM64 devcon.exe, un-ignored
  in .gitignore mirroring the existing vendor/webview2/arm64 precedent.
2026-06-04 19:00:27 -04:00
James Stringer 9f1772ce60 Add MIT LICENSE and third-party license notices
- LICENSE: MIT, Copyright (c) 2026 James Stringer.
- THIRD-PARTY-NOTICES.md: scopes the MIT grant around bundled third-party
  components, documenting each one's license/copyright:
    dxgkrnl (Microsoft WSL2 GPU driver) GPL-2.0; iso-patch/engine/xz 0BSD;
    wsl-mesa prebuilt (Mesa 25.3.6) MIT; WDF SDK, WebView2 SDK, DevCon (Microsoft).
- tools/linux/dxgkrnl/COPYING: verbatim GPL-2.0 text shipped with the GPL'd
  driver source.
- tools/linux/wsl-mesa/prebuilt/MESA-LICENSE.txt: Mesa's headline MIT license,
  shipped next to the prebuilt binary.
- README: license section points to LICENSE + THIRD-PARTY-NOTICES.
- Info.plist: copyright string now names the holder and notes MIT.

The asb_drm Linux kernel module keeps its existing dual (GPL-2.0 OR MIT)
licensing; vendored sources keep their own SPDX headers.
2026-06-03 21:47:02 -04:00
James Stringer 503db33307 Harden iso-patch-mac (ARC over-release, resume-sidecar overflow)
- C8  StageEntry stored ARC __strong NSString members in an NSValue (raw byte
      copy, no retain), so ARC over-released them each loop iteration ->
      double-free/UAF in the privileged stage path; mark __unsafe_unretained
      (the source strings outlive the command via the outer autorelease pool).
- L10 resumeDataFromSidecarAt: `raw.length < 8 + n` overflowed for n near
      UINT64_MAX, bypassing the guard and throwing NSRangeException; compare
      with subtraction (`n > raw.length - 8`).
2026-06-03 20:58:30 -04:00
James Stringer c617d0f374 Fix macOS guest agent bugs (clipboard parsing, symlink paste, child reaping)
- C3  appsandbox-clipboard.m: inbound `format_len` was unbounded, so a
      32-bit `format_len + 1` could wrap to malloc(0) then read/write ~4GB;
      bound it against CLIP_MAX_PAYLOAD and allocate in size_t. Both sites.
- M13 appsandbox-agent.m: mute/unmute (and shutdown) fork+exec children were
      never reaped, accumulating zombies; ignore SIGCHLD so Darwin auto-reaps.
- M19 appsandbox-clipboard.m (guest half): handle the new symlink entry type
      -- recreate links with symlink() instead of treating them as dirs.
2026-06-03 20:58:30 -04:00