windows-development-sandbox 1.7.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config.example.json +10 -0
- package/dist/app/context.d.ts +8 -0
- package/dist/app/context.js +12 -0
- package/dist/app/features/defs.d.ts +322 -0
- package/dist/app/features/defs.js +28 -0
- package/dist/app/features/sandbox/index.d.ts +2 -0
- package/dist/app/features/sandbox/index.js +3 -0
- package/dist/app/features/sandbox/sandbox.def.d.ts +193 -0
- package/dist/app/features/sandbox/sandbox.def.js +245 -0
- package/dist/app/features/sandbox/sandbox.run.d.ts +72 -0
- package/dist/app/features/sandbox/sandbox.run.js +98 -0
- package/dist/app/features/sessions/index.d.ts +2 -0
- package/dist/app/features/sessions/index.js +3 -0
- package/dist/app/features/sessions/sessions.def.d.ts +141 -0
- package/dist/app/features/sessions/sessions.def.js +176 -0
- package/dist/app/features/sessions/sessions.run.d.ts +39 -0
- package/dist/app/features/sessions/sessions.run.js +58 -0
- package/dist/{cli/menu/settings/categories.d.ts → app/features/settings/categories.def.d.ts} +2 -0
- package/dist/{cli/menu/settings/categories.js → app/features/settings/categories.def.js} +24 -5
- package/dist/app/features/settings/index.d.ts +5 -0
- package/dist/app/features/settings/index.js +6 -0
- package/dist/{cli/menu/settings/config-file.d.ts → app/features/settings/settings-file.d.ts} +1 -1
- package/dist/{cli/menu/settings/config-file.js → app/features/settings/settings-file.js} +1 -1
- package/dist/app/features/settings/settings-rows.d.ts +35 -0
- package/dist/app/features/settings/settings-rows.js +94 -0
- package/dist/app/features/settings/settings.def.d.ts +157 -0
- package/dist/app/features/settings/settings.def.js +179 -0
- package/dist/app/features/settings/settings.run.d.ts +67 -0
- package/dist/app/features/settings/settings.run.js +84 -0
- package/dist/app/kernel/define.d.ts +143 -0
- package/dist/app/kernel/define.js +42 -0
- package/dist/app/kernel/errors.d.ts +34 -0
- package/dist/app/kernel/errors.js +45 -0
- package/dist/app/kernel/fields.d.ts +70 -0
- package/dist/app/kernel/fields.js +243 -0
- package/dist/app/kernel/index.d.ts +8 -0
- package/dist/app/kernel/index.js +10 -0
- package/dist/app/kernel/io.d.ts +193 -0
- package/dist/app/kernel/io.js +126 -0
- package/dist/app/kernel/rpc.d.ts +156 -0
- package/dist/app/kernel/rpc.js +47 -0
- package/dist/app/kernel/text.d.ts +6 -0
- package/dist/app/kernel/text.js +57 -0
- package/dist/app/kernel/view.d.ts +146 -0
- package/dist/app/kernel/view.js +28 -0
- package/dist/app/registry.d.ts +10 -0
- package/dist/app/registry.js +50 -0
- package/dist/cli/args.d.ts +5 -0
- package/dist/cli/args.js +6 -0
- package/dist/cli/commands/engine.d.ts +2 -0
- package/dist/cli/commands/engine.js +60 -0
- package/dist/cli/commands/index.d.ts +1 -1
- package/dist/cli/commands/index.js +1 -1
- package/dist/cli/commands/launch/launch.js +47 -7
- package/dist/cli/commands/launch/prepare.js +3 -3
- package/dist/cli/commands/launch/running.js +2 -1
- package/dist/cli/commands/launch/summary.d.ts +2 -0
- package/dist/cli/commands/maintenance/config-share.d.ts +12 -0
- package/dist/cli/commands/maintenance/config-share.js +80 -0
- package/dist/cli/commands/maintenance/config.js +8 -82
- package/dist/cli/commands/maintenance/logs.js +14 -0
- package/dist/cli/commands/registry.js +3 -7
- package/dist/cli/commands/repair/checks/contained.d.ts +2 -0
- package/dist/cli/commands/repair/checks/contained.js +139 -0
- package/dist/cli/commands/repair/checks/hcs.d.ts +7 -0
- package/dist/cli/commands/repair/checks/hcs.js +28 -0
- package/dist/cli/commands/repair/checks/index.js +4 -0
- package/dist/cli/commands/repair/checks/pc.js +32 -1
- package/dist/cli/commands/repair/checks/sandbox.js +16 -1
- package/dist/cli/commands/repair/checks/vpn.js +34 -9
- package/dist/cli/commands/repair/env.js +2 -1
- package/dist/cli/commands/sessions/index.d.ts +0 -4
- package/dist/cli/commands/sessions/index.js +3 -7
- package/dist/cli/commands/shared-use.d.ts +5 -2
- package/dist/cli/commands/shared-use.js +11 -8
- package/dist/cli/commands/storage/contained.d.ts +3 -0
- package/dist/cli/commands/storage/contained.js +179 -0
- package/dist/cli/commands/storage/offer.js +7 -1
- package/dist/cli/commands/storage/storage.js +10 -2
- package/dist/cli/commands/user-config.js +1 -1
- package/dist/cli/commands/vpn.js +19 -3
- package/dist/cli/commands/web.js +2 -0
- package/dist/cli/index.js +2 -1
- package/dist/cli/manifest.d.ts +72 -104
- package/dist/cli/manifest.js +64 -39
- package/dist/cli/menu/add-agent.d.ts +1 -1
- package/dist/cli/menu/add-agent.js +1 -1
- package/dist/cli/menu/apps.d.ts +7 -1
- package/dist/cli/menu/apps.js +36 -0
- package/dist/cli/menu/command-fields.d.ts +1 -1
- package/dist/cli/menu/command-form.js +2 -2
- package/dist/cli/menu/io-menu.d.ts +29 -0
- package/dist/cli/menu/io-menu.js +126 -0
- package/dist/cli/menu/live.d.ts +27 -0
- package/dist/cli/menu/live.js +69 -0
- package/dist/cli/menu/memory.d.ts +19 -0
- package/dist/cli/menu/memory.js +53 -0
- package/dist/cli/menu/menu.d.ts +10 -1
- package/dist/cli/menu/menu.js +27 -9
- package/dist/cli/menu/pages/agents-page.d.ts +3 -1
- package/dist/cli/menu/pages/agents-page.js +12 -5
- package/dist/cli/menu/pages/apps-page.d.ts +3 -1
- package/dist/cli/menu/pages/apps-page.js +19 -2
- package/dist/cli/menu/pages/list-page.d.ts +27 -0
- package/dist/cli/menu/pages/list-page.js +109 -7
- package/dist/cli/menu/pages/maintenance-page.d.ts +0 -5
- package/dist/cli/menu/pages/maintenance-page.js +17 -19
- package/dist/cli/menu/pages/sandbox-page.d.ts +4 -6
- package/dist/cli/menu/pages/sandbox-page.js +26 -118
- package/dist/cli/menu/pages/scopes.d.ts +1 -1
- package/dist/cli/menu/pages/sessions-page.d.ts +5 -11
- package/dist/cli/menu/pages/sessions-page.js +19 -88
- package/dist/cli/menu/pages/settings-page.d.ts +2 -10
- package/dist/cli/menu/pages/settings-page.js +64 -94
- package/dist/cli/menu/render-view.d.ts +28 -0
- package/dist/cli/menu/render-view.js +112 -0
- package/dist/cli/menu/settings/{path-kind.d.ts → ask-path.d.ts} +1 -7
- package/dist/cli/menu/settings/ask-path.js +14 -0
- package/dist/cli/menu/settings/collections/collection-editor.d.ts +1 -1
- package/dist/cli/menu/settings/collections/string-list-editor.d.ts +1 -2
- package/dist/cli/menu/settings/collections/string-list-editor.js +1 -1
- package/dist/cli/menu/settings/draft.d.ts +1 -1
- package/dist/cli/menu/settings/format.d.ts +1 -3
- package/dist/cli/menu/settings/format.js +6 -36
- package/dist/cli/menu/settings/index.d.ts +1 -3
- package/dist/cli/menu/settings/index.js +3 -3
- package/dist/cli/menu/settings/object-editor.d.ts +1 -1
- package/dist/cli/menu/settings/share.d.ts +36 -0
- package/dist/cli/menu/settings/share.js +131 -0
- package/dist/cli/menu/settings/value-editor.d.ts +5 -1
- package/dist/cli/menu/settings/value-editor.js +57 -54
- package/dist/cli/menu/several.js +1 -1
- package/dist/cli/menu/share-settings.d.ts +21 -0
- package/dist/cli/menu/share-settings.js +112 -0
- package/dist/cli/menu/shell.d.ts +21 -5
- package/dist/cli/menu/shell.js +31 -6
- package/dist/cli/menu/views.d.ts +7 -0
- package/dist/cli/menu/views.js +11 -0
- package/dist/cli/menu/vpn-login.js +8 -0
- package/dist/cli/operations/handler.d.ts +6 -0
- package/dist/cli/operations/handler.js +61 -0
- package/dist/cli/operations/index.d.ts +4 -0
- package/dist/cli/operations/index.js +5 -0
- package/dist/cli/operations/input.d.ts +6 -0
- package/dist/cli/operations/input.js +37 -0
- package/dist/cli/operations/io-cli.d.ts +7 -0
- package/dist/cli/operations/io-cli.js +62 -0
- package/dist/cli/operations/spec.d.ts +18 -0
- package/dist/cli/operations/spec.js +108 -0
- package/dist/cli/output/colors.d.ts +2 -2
- package/dist/cli/output/colors.js +2 -11
- package/dist/cli/output/index.d.ts +1 -0
- package/dist/cli/output/index.js +1 -0
- package/dist/cli/output/print.d.ts +3 -1
- package/dist/cli/output/print.js +7 -3
- package/dist/cli/output/progress.d.ts +15 -0
- package/dist/cli/output/progress.js +44 -0
- package/dist/cli/output/render-view.d.ts +4 -0
- package/dist/cli/output/render-view.js +63 -0
- package/dist/cli/services/agent-commands-service.d.ts +2 -0
- package/dist/cli/services/agent-commands-service.js +11 -2
- package/dist/cli/services/logs-service.js +4 -3
- package/dist/cli/tui/app.d.ts +6 -1
- package/dist/cli/tui/app.js +26 -4
- package/dist/cli/tui/list/list-screen.d.ts +14 -0
- package/dist/cli/tui/list/list-screen.js +64 -36
- package/dist/cli/tui/list/list-types.d.ts +2 -0
- package/dist/cli/tui/terminal.d.ts +7 -0
- package/dist/cli/tui/terminal.js +30 -10
- package/dist/core/config/defaults.js +8 -0
- package/dist/core/schema/config.d.ts +13 -0
- package/dist/core/schema/config.js +16 -1
- package/dist/core/schema/harness.d.ts +1 -0
- package/dist/core/schema/harness.js +5 -0
- package/dist/core/schema/sandbox.d.ts +6 -0
- package/dist/core/schema/sandbox.js +20 -3
- package/dist/core/schema/vpn.d.ts +2 -1
- package/dist/core/schema/vpn.js +3 -3
- package/dist/core/types.d.ts +23 -5
- package/dist/core/util/fs.d.ts +2 -0
- package/dist/core/util/fs.js +9 -0
- package/dist/core/util/index.d.ts +1 -1
- package/dist/core/util/index.js +1 -1
- package/dist/guest/agents/agent-files.d.ts +5 -0
- package/dist/guest/agents/agent-files.js +4 -0
- package/dist/guest/agents/local-state.d.ts +2 -0
- package/dist/guest/agents/local-state.js +21 -1
- package/dist/guest/boot/boot.js +2 -1
- package/dist/guest/daemon/daemon.js +4 -0
- package/dist/guest/daemon/sessions.d.ts +5 -0
- package/dist/guest/daemon/sessions.js +17 -3
- package/dist/guest/entries/daemon.js +3 -0
- package/dist/guest/governor/decide.d.ts +61 -0
- package/dist/guest/governor/decide.js +182 -0
- package/dist/guest/governor/governor.d.ts +42 -0
- package/dist/guest/governor/governor.js +214 -0
- package/dist/guest/governor/index.d.ts +2 -0
- package/dist/guest/governor/index.js +2 -0
- package/dist/guest/runtime/csc.d.ts +1 -0
- package/dist/guest/runtime/csc.js +1 -0
- package/dist/guest/sessions/viewer.js +3 -1
- package/dist/guest/toolchains/native/rust-extras.js +4 -2
- package/dist/guest/vpn/vpn.js +69 -21
- package/dist/guest/vpn/wireguard.d.ts +32 -0
- package/dist/guest/vpn/wireguard.js +132 -0
- package/dist/host/agent-commands/commands.d.ts +4 -0
- package/dist/host/agent-commands/commands.js +31 -7
- package/dist/host/audit/log.d.ts +1 -1
- package/dist/host/channel/attach.d.ts +3 -1
- package/dist/host/channel/attach.js +5 -2
- package/dist/host/channel/channel.d.ts +2 -0
- package/dist/host/channel/channel.js +4 -0
- package/dist/host/engines/engine.d.ts +12 -0
- package/dist/host/engines/engine.js +1 -0
- package/dist/host/engines/hcs/check.d.ts +25 -0
- package/dist/host/engines/hcs/check.js +95 -0
- package/dist/host/engines/hcs/documents.d.ts +44 -0
- package/dist/host/engines/hcs/documents.js +155 -0
- package/dist/host/engines/hcs/engine.d.ts +39 -0
- package/dist/host/engines/hcs/engine.js +171 -0
- package/dist/host/engines/hcs/helper.d.ts +43 -0
- package/dist/host/engines/hcs/helper.js +173 -0
- package/dist/host/engines/hcs/images.d.ts +37 -0
- package/dist/host/engines/hcs/images.js +152 -0
- package/dist/host/engines/index.d.ts +7 -0
- package/dist/host/engines/index.js +5 -0
- package/dist/host/engines/registry.d.ts +16 -0
- package/dist/host/engines/registry.js +30 -0
- package/dist/host/engines/types.d.ts +58 -0
- package/dist/host/engines/types.js +1 -0
- package/dist/host/engines/windows-sandbox/engine.d.ts +16 -0
- package/dist/host/engines/windows-sandbox/engine.js +63 -0
- package/dist/host/engines/windows-sandbox/wsb-text.d.ts +2 -0
- package/dist/host/engines/windows-sandbox/wsb-text.js +29 -0
- package/dist/host/launch/generate.d.ts +5 -1
- package/dist/host/launch/generate.js +50 -8
- package/dist/host/launch/index.d.ts +3 -1
- package/dist/host/launch/index.js +3 -1
- package/dist/host/launch/launch-plan.d.ts +13 -0
- package/dist/host/launch/launch-plan.js +26 -0
- package/dist/host/launch/mappings.js +2 -1
- package/dist/host/launch/risk-notes.d.ts +10 -0
- package/dist/host/launch/risk-notes.js +18 -0
- package/dist/host/launch/session-file.d.ts +2 -0
- package/dist/host/launch/session-file.js +7 -1
- package/dist/host/launch/wsb-file.d.ts +28 -4
- package/dist/host/launch/wsb-file.js +61 -42
- package/dist/host/life/crash-report.d.ts +27 -1
- package/dist/host/life/crash-report.js +173 -7
- package/dist/host/life/host-memory.d.ts +40 -0
- package/dist/host/life/host-memory.js +137 -0
- package/dist/host/life/index.d.ts +2 -0
- package/dist/host/life/index.js +2 -0
- package/dist/host/life/stop-events.d.ts +2 -0
- package/dist/host/life/stop-events.js +20 -3
- package/dist/host/life/stop-warning.js +1 -1
- package/dist/host/life/watchdog.d.ts +54 -0
- package/dist/host/life/watchdog.js +108 -0
- package/dist/host/native.d.ts +3 -2
- package/dist/host/native.js +22 -3
- package/dist/host/profile/claude-login.js +3 -2
- package/dist/host/sandbox/contained-deps.d.ts +2 -0
- package/dist/host/sandbox/contained-deps.js +17 -0
- package/dist/host/sandbox/index.d.ts +2 -0
- package/dist/host/sandbox/index.js +2 -0
- package/dist/host/sandbox/platform.d.ts +2 -0
- package/dist/host/sandbox/platform.js +7 -7
- package/dist/host/sandbox/tasklist.d.ts +13 -0
- package/dist/host/sandbox/tasklist.js +47 -0
- package/dist/host/secrets/launch-secrets.js +2 -1
- package/dist/host/sharing/current.js +2 -6
- package/dist/host/storage/contained/check.d.ts +9 -0
- package/dist/host/storage/contained/check.js +37 -0
- package/dist/host/storage/contained/contained-storage.d.ts +66 -0
- package/dist/host/storage/contained/contained-storage.js +168 -0
- package/dist/host/storage/contained/disk-port.d.ts +43 -0
- package/dist/host/storage/contained/disk-port.js +122 -0
- package/dist/host/storage/contained/index.d.ts +9 -0
- package/dist/host/storage/contained/index.js +8 -0
- package/dist/host/storage/contained/layout.d.ts +28 -0
- package/dist/host/storage/contained/layout.js +45 -0
- package/dist/host/storage/contained/resolve.d.ts +4 -0
- package/dist/host/storage/contained/resolve.js +30 -0
- package/dist/host/storage/contained/setting.d.ts +1 -0
- package/dist/host/storage/contained/setting.js +5 -0
- package/dist/host/storage/contained/state.d.ts +89 -0
- package/dist/host/storage/contained/state.js +166 -0
- package/dist/host/storage/contained/transfer.d.ts +24 -0
- package/dist/host/storage/contained/transfer.js +121 -0
- package/dist/host/storage/index.d.ts +2 -0
- package/dist/host/storage/index.js +2 -0
- package/dist/host/storage/providers/contained.d.ts +15 -0
- package/dist/host/storage/providers/contained.js +39 -0
- package/dist/host/storage/providers/folder.d.ts +12 -0
- package/dist/host/storage/providers/folder.js +20 -0
- package/dist/host/storage/providers/index.d.ts +4 -0
- package/dist/host/storage/providers/index.js +3 -0
- package/dist/host/storage/providers/registry.d.ts +9 -0
- package/dist/host/storage/providers/registry.js +14 -0
- package/dist/host/storage/providers/types.d.ts +33 -0
- package/dist/host/storage/providers/types.js +1 -0
- package/dist/host/tools/conpty.js +3 -2
- package/dist/host/tools/windows-terminal.js +8 -7
- package/dist/host/vpn/index.d.ts +1 -1
- package/dist/host/vpn/index.js +1 -1
- package/dist/host/vpn/prepare.d.ts +2 -0
- package/dist/host/vpn/prepare.js +63 -2
- package/dist/host/web/browser.d.ts +2 -0
- package/dist/host/web/browser.js +14 -1
- package/dist/host/web/index.d.ts +3 -2
- package/dist/host/web/index.js +3 -2
- package/dist/host/web/rpc.d.ts +24 -0
- package/dist/host/web/rpc.js +149 -0
- package/dist/host/web/runner.d.ts +2 -0
- package/dist/host/web/runner.js +1 -2
- package/dist/host/web/server.d.ts +7 -0
- package/dist/host/web/server.js +23 -3
- package/dist/runtime/agent.js +69 -8
- package/dist/runtime/daemon.js +1058 -624
- package/dist/runtime/db.js +69 -8
- package/dist/runtime/main.js +624 -182
- package/dist/runtime/netproxy.js +69 -8
- package/dist/runtime/view.js +87 -13
- package/dist/selftest/agent-paths.test.js +11 -1
- package/dist/selftest/app.test.d.ts +2 -0
- package/dist/selftest/app.test.js +324 -0
- package/dist/selftest/channel.test.js +13 -0
- package/dist/selftest/cli.test.js +2 -1
- package/dist/selftest/config.test.js +59 -0
- package/dist/selftest/contained.test.d.ts +2 -0
- package/dist/selftest/contained.test.js +544 -0
- package/dist/selftest/credentials.test.js +1 -1
- package/dist/selftest/engine.test.d.ts +2 -0
- package/dist/selftest/engine.test.js +127 -0
- package/dist/selftest/hcs.test.d.ts +2 -0
- package/dist/selftest/hcs.test.js +482 -0
- package/dist/selftest/heavy-load.test.d.ts +2 -0
- package/dist/selftest/heavy-load.test.js +329 -0
- package/dist/selftest/index.js +12 -0
- package/dist/selftest/layout.test.js +12 -0
- package/dist/selftest/menu-perf.test.d.ts +2 -0
- package/dist/selftest/menu-perf.test.js +248 -0
- package/dist/selftest/menu-screens.js +4 -2
- package/dist/selftest/menu.test.js +36 -8
- package/dist/selftest/support/engine-cases.d.ts +8 -0
- package/dist/selftest/support/engine-cases.js +65 -0
- package/dist/selftest/support/engine-golden.d.ts +3 -0
- package/dist/selftest/support/engine-golden.js +66 -0
- package/dist/selftest/support/fixtures.d.ts +7 -1
- package/dist/selftest/support/hcs-probes.d.ts +17 -0
- package/dist/selftest/support/hcs-probes.js +41 -0
- package/dist/selftest/vpn.test.js +136 -3
- package/dist/selftest/web.test.js +101 -3
- package/dist/shared/channel/run-dir.d.ts +4 -1
- package/dist/shared/channel/run-dir.js +7 -1
- package/dist/shared/channel/schema.d.ts +35 -1
- package/dist/shared/channel/schema.js +27 -0
- package/dist/shared/channel/secrets.d.ts +1 -0
- package/dist/shared/channel/secrets.js +6 -0
- package/dist/shared/memory/index.d.ts +1 -0
- package/dist/shared/memory/index.js +1 -0
- package/dist/shared/memory/policy.d.ts +33 -0
- package/dist/shared/memory/policy.js +55 -0
- package/dist/shared/pty/output-filter.d.ts +14 -1
- package/dist/shared/pty/output-filter.js +22 -4
- package/dist/shared/pty/terminal.d.ts +4 -1
- package/dist/shared/pty/terminal.js +4 -2
- package/dist/shared/system.d.ts +1 -0
- package/dist/shared/system.js +1 -0
- package/dist/shared/vpn/download.d.ts +16 -0
- package/dist/shared/vpn/download.js +16 -0
- package/dist/shared/vpn/wireguard.d.ts +51 -0
- package/dist/shared/vpn/wireguard.js +227 -0
- package/dist/sync/sync-cycle.js +5 -5
- package/dist/sync/watcher.d.ts +13 -0
- package/dist/sync/watcher.js +92 -3
- package/dist/web/index.html +4 -3
- package/dist/web/main-NRRS5O6Z.js +157 -0
- package/dist/web/main-T5DMCHYV.css +1 -0
- package/native/csharp/HcsHost/AssemblyInfo.cs +14 -0
- package/native/csharp/HcsHost/Guard.cs +100 -0
- package/native/csharp/HcsHost/Hcs.cs +256 -0
- package/native/csharp/HcsHost/Json.cs +78 -0
- package/native/csharp/HcsHost/Program.cs +185 -0
- package/native/csharp/HcsHost/VirtualDisk.cs +95 -0
- package/native/csharp/HostTools/AssemblyInfo.cs +14 -0
- package/native/csharp/HostTools/MemoryStatus.cs +107 -0
- package/native/csharp/HostTools/Program.cs +58 -17
- package/native/scripts/check-contained.ps1 +28 -0
- package/native/scripts/contained-common.ps1 +241 -0
- package/native/scripts/dismount-contained.ps1 +66 -0
- package/native/scripts/memory-status.ps1 +34 -0
- package/native/scripts/mount-contained.ps1 +139 -0
- package/native/scripts/run-elevated.ps1 +17 -4
- package/native/scripts/stop-events.ps1 +23 -8
- package/package.json +9 -2
- package/sandbox/csharp/MemGov.cs +398 -0
- package/sandbox/csharp/PtyHost.cs +111 -5
- package/schemas/config.schema.json +60 -6
- package/schemas/sandbox-config.schema.json +3 -3
- package/dist/cli/commands/sessions/control.d.ts +0 -4
- package/dist/cli/commands/sessions/control.js +0 -66
- package/dist/cli/commands/sessions/list.d.ts +0 -2
- package/dist/cli/commands/sessions/list.js +0 -48
- package/dist/cli/commands/sessions/status.d.ts +0 -4
- package/dist/cli/commands/sessions/status.js +0 -114
- package/dist/cli/commands/sessions/window.d.ts +0 -3
- package/dist/cli/commands/sessions/window.js +0 -18
- package/dist/cli/menu/settings/path-kind.js +0 -44
- package/dist/web/main-CXESL347.js +0 -45
- package/dist/web/main-VLR7DVQ4.css +0 -1
- /package/dist/{cli/menu/settings → app/kernel}/schema-node.d.ts +0 -0
- /package/dist/{cli/menu/settings → app/kernel}/schema-node.js +0 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
// Calls into computecore.dll (Host Compute Service) and computestorage.dll (HcsGrantVmAccess). Signatures are from
|
|
2
|
+
// the Microsoft HCS API reference (learn.microsoft.com/virtualization/api/hcs/reference/*), checked there for the
|
|
3
|
+
// operation and compute-system functions; HcsGrantVmAccess is from the computestorage.h header (not re-checked).
|
|
4
|
+
// Nothing here has run against a real HCS: the PC this was written on had no Hyper-V.
|
|
5
|
+
using System;
|
|
6
|
+
using System.ComponentModel;
|
|
7
|
+
using System.Runtime.InteropServices;
|
|
8
|
+
|
|
9
|
+
namespace AgentSandbox.HcsHost
|
|
10
|
+
{
|
|
11
|
+
/// <summary>What an HCS call answered: the HRESULT and the JSON document (result or error) that came with it.</summary>
|
|
12
|
+
public sealed class HcsReply
|
|
13
|
+
{
|
|
14
|
+
public int HResult;
|
|
15
|
+
public string Json = "";
|
|
16
|
+
|
|
17
|
+
public bool Ok
|
|
18
|
+
{
|
|
19
|
+
get { return HResult == 0; }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public string Message()
|
|
23
|
+
{
|
|
24
|
+
if (HResult == 0)
|
|
25
|
+
{
|
|
26
|
+
return "ok";
|
|
27
|
+
}
|
|
28
|
+
string known = HcsErrorText((uint)HResult);
|
|
29
|
+
if (known != null)
|
|
30
|
+
{
|
|
31
|
+
return known;
|
|
32
|
+
}
|
|
33
|
+
Exception ex = Marshal.GetExceptionForHR(HResult);
|
|
34
|
+
return ex != null ? ex.Message : "error 0x" + HResult.ToString("X8");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/// <summary>The HCS-specific codes (learn.microsoft.com/virtualization/api/hcs/reference/hcshresult), or null.</summary>
|
|
38
|
+
private static string HcsErrorText(uint hr)
|
|
39
|
+
{
|
|
40
|
+
switch (hr)
|
|
41
|
+
{
|
|
42
|
+
case 0x80370102u:
|
|
43
|
+
return "a required Windows feature is not installed (HCS_E_HYPERV_NOT_INSTALLED)";
|
|
44
|
+
case 0x8037010Du:
|
|
45
|
+
return "the compute system document is invalid (HCS_E_INVALID_JSON)";
|
|
46
|
+
case 0x8037010Eu:
|
|
47
|
+
return "no compute system has that id (HCS_E_SYSTEM_NOT_FOUND)";
|
|
48
|
+
case 0x8037010Fu:
|
|
49
|
+
return "a compute system with that id already exists (HCS_E_SYSTEM_ALREADY_EXISTS)";
|
|
50
|
+
case 0x80370110u:
|
|
51
|
+
return "the compute system is not running (HCS_E_SYSTEM_ALREADY_STOPPED)";
|
|
52
|
+
case 0x80370114u:
|
|
53
|
+
return "a required Windows feature is not installed (HCS_E_SERVICE_NOT_AVAILABLE)";
|
|
54
|
+
case 0x80370118u:
|
|
55
|
+
return "the operation did not complete in time (HCS_E_OPERATION_TIMEOUT)";
|
|
56
|
+
case 0x8037011Bu:
|
|
57
|
+
return "only Administrators or Hyper-V Administrators may do this (HCS_E_ACCESS_DENIED, see https://aka.ms/hcsadmin)";
|
|
58
|
+
default:
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public static class Hcs
|
|
65
|
+
{
|
|
66
|
+
private const uint GenericAll = 0x10000000;
|
|
67
|
+
private const uint QueryMs = 15000;
|
|
68
|
+
private const uint ChangeMs = 180000;
|
|
69
|
+
|
|
70
|
+
private delegate int Begin(IntPtr operation);
|
|
71
|
+
|
|
72
|
+
private delegate int BeginOn(IntPtr system, IntPtr operation);
|
|
73
|
+
|
|
74
|
+
private static class NativeMethods
|
|
75
|
+
{
|
|
76
|
+
[DllImport("computecore.dll", ExactSpelling = true, SetLastError = true)]
|
|
77
|
+
public static extern IntPtr HcsCreateOperation(IntPtr context, IntPtr callback);
|
|
78
|
+
|
|
79
|
+
[DllImport("computecore.dll", ExactSpelling = true)]
|
|
80
|
+
public static extern void HcsCloseOperation(IntPtr operation);
|
|
81
|
+
|
|
82
|
+
[DllImport("computecore.dll", ExactSpelling = true)]
|
|
83
|
+
public static extern int HcsWaitForOperationResult(IntPtr operation, uint timeoutMs, out IntPtr resultDocument);
|
|
84
|
+
|
|
85
|
+
[DllImport("computecore.dll", ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
86
|
+
public static extern int HcsEnumerateComputeSystems(string query, IntPtr operation);
|
|
87
|
+
|
|
88
|
+
[DllImport("computecore.dll", ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
89
|
+
public static extern int HcsCreateComputeSystem(string id, string configuration, IntPtr operation, IntPtr securityDescriptor, out IntPtr computeSystem);
|
|
90
|
+
|
|
91
|
+
[DllImport("computecore.dll", ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
92
|
+
public static extern int HcsOpenComputeSystem(string id, uint requestedAccess, out IntPtr computeSystem);
|
|
93
|
+
|
|
94
|
+
[DllImport("computecore.dll", ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
95
|
+
public static extern int HcsStartComputeSystem(IntPtr computeSystem, IntPtr operation, string options);
|
|
96
|
+
|
|
97
|
+
[DllImport("computecore.dll", ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
98
|
+
public static extern int HcsTerminateComputeSystem(IntPtr computeSystem, IntPtr operation, string options);
|
|
99
|
+
|
|
100
|
+
[DllImport("computecore.dll", ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
101
|
+
public static extern int HcsGetComputeSystemProperties(IntPtr computeSystem, IntPtr operation, string propertyQuery);
|
|
102
|
+
|
|
103
|
+
[DllImport("computecore.dll", ExactSpelling = true)]
|
|
104
|
+
public static extern void HcsCloseComputeSystem(IntPtr computeSystem);
|
|
105
|
+
|
|
106
|
+
[DllImport("computecore.dll", ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
107
|
+
public static extern int HcsGetServiceProperties(string propertyQuery, out IntPtr result);
|
|
108
|
+
|
|
109
|
+
[DllImport("computestorage.dll", ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
110
|
+
public static extern int HcsGrantVmAccess(string vmId, string filePath);
|
|
111
|
+
|
|
112
|
+
[DllImport("kernel32.dll", SetLastError = true)]
|
|
113
|
+
public static extern IntPtr LocalFree(IntPtr mem);
|
|
114
|
+
|
|
115
|
+
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
|
116
|
+
public static extern IntPtr LoadLibrary(string fileName);
|
|
117
|
+
|
|
118
|
+
[DllImport("kernel32.dll", SetLastError = true)]
|
|
119
|
+
public static extern bool FreeLibrary(IntPtr module);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/// <summary>A LocalFree-able wide string from HCS, as text (empty when null).</summary>
|
|
123
|
+
private static string TakeString(IntPtr p)
|
|
124
|
+
{
|
|
125
|
+
if (p == IntPtr.Zero)
|
|
126
|
+
{
|
|
127
|
+
return "";
|
|
128
|
+
}
|
|
129
|
+
try
|
|
130
|
+
{
|
|
131
|
+
return Marshal.PtrToStringUni(p);
|
|
132
|
+
}
|
|
133
|
+
finally
|
|
134
|
+
{
|
|
135
|
+
NativeMethods.LocalFree(p);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/// <summary>Whether a DLL (computecore.dll) can be loaded at all on this PC.</summary>
|
|
140
|
+
public static bool CanLoad(string dll)
|
|
141
|
+
{
|
|
142
|
+
IntPtr module = NativeMethods.LoadLibrary(dll);
|
|
143
|
+
if (module == IntPtr.Zero)
|
|
144
|
+
{
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
NativeMethods.FreeLibrary(module);
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
public static HcsReply ServiceProperties(string queryJson)
|
|
152
|
+
{
|
|
153
|
+
HcsReply reply = new HcsReply();
|
|
154
|
+
IntPtr result = IntPtr.Zero;
|
|
155
|
+
reply.HResult = NativeMethods.HcsGetServiceProperties(queryJson, out result);
|
|
156
|
+
reply.Json = TakeString(result);
|
|
157
|
+
return reply;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/// <summary>Starts an operation with `begin`, waits for it and returns its result document.</summary>
|
|
161
|
+
private static HcsReply Run(Begin begin, uint waitMs)
|
|
162
|
+
{
|
|
163
|
+
HcsReply reply = new HcsReply();
|
|
164
|
+
IntPtr operation = NativeMethods.HcsCreateOperation(IntPtr.Zero, IntPtr.Zero);
|
|
165
|
+
if (operation == IntPtr.Zero)
|
|
166
|
+
{
|
|
167
|
+
reply.HResult = Marshal.GetHRForLastWin32Error();
|
|
168
|
+
return reply;
|
|
169
|
+
}
|
|
170
|
+
try
|
|
171
|
+
{
|
|
172
|
+
int hr = begin(operation);
|
|
173
|
+
if (hr != 0)
|
|
174
|
+
{
|
|
175
|
+
reply.HResult = hr;
|
|
176
|
+
return reply;
|
|
177
|
+
}
|
|
178
|
+
IntPtr doc = IntPtr.Zero;
|
|
179
|
+
reply.HResult = NativeMethods.HcsWaitForOperationResult(operation, waitMs, out doc);
|
|
180
|
+
reply.Json = TakeString(doc);
|
|
181
|
+
return reply;
|
|
182
|
+
}
|
|
183
|
+
finally
|
|
184
|
+
{
|
|
185
|
+
NativeMethods.HcsCloseOperation(operation);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
public static HcsReply Enumerate(string queryJson)
|
|
190
|
+
{
|
|
191
|
+
return Run(delegate(IntPtr op) { return NativeMethods.HcsEnumerateComputeSystems(queryJson, op); }, QueryMs);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/// <summary>Creates a compute system from a document. The handle is closed again: the system stays.</summary>
|
|
195
|
+
public static HcsReply Create(string id, string document)
|
|
196
|
+
{
|
|
197
|
+
IntPtr system = IntPtr.Zero;
|
|
198
|
+
try
|
|
199
|
+
{
|
|
200
|
+
return Run(
|
|
201
|
+
delegate(IntPtr op) { return NativeMethods.HcsCreateComputeSystem(id, document, op, IntPtr.Zero, out system); },
|
|
202
|
+
ChangeMs);
|
|
203
|
+
}
|
|
204
|
+
finally
|
|
205
|
+
{
|
|
206
|
+
if (system != IntPtr.Zero)
|
|
207
|
+
{
|
|
208
|
+
NativeMethods.HcsCloseComputeSystem(system);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
private static HcsReply WithSystem(string id, uint waitMs, BeginOn call)
|
|
214
|
+
{
|
|
215
|
+
IntPtr system = IntPtr.Zero;
|
|
216
|
+
int hr = NativeMethods.HcsOpenComputeSystem(id, GenericAll, out system);
|
|
217
|
+
if (hr != 0)
|
|
218
|
+
{
|
|
219
|
+
HcsReply failed = new HcsReply();
|
|
220
|
+
failed.HResult = hr;
|
|
221
|
+
return failed;
|
|
222
|
+
}
|
|
223
|
+
try
|
|
224
|
+
{
|
|
225
|
+
return Run(delegate(IntPtr op) { return call(system, op); }, waitMs);
|
|
226
|
+
}
|
|
227
|
+
finally
|
|
228
|
+
{
|
|
229
|
+
NativeMethods.HcsCloseComputeSystem(system);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
public static HcsReply Start(string id)
|
|
234
|
+
{
|
|
235
|
+
return WithSystem(id, ChangeMs, delegate(IntPtr system, IntPtr op) { return NativeMethods.HcsStartComputeSystem(system, op, null); });
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
public static HcsReply Terminate(string id)
|
|
239
|
+
{
|
|
240
|
+
return WithSystem(id, ChangeMs, delegate(IntPtr system, IntPtr op) { return NativeMethods.HcsTerminateComputeSystem(system, op, null); });
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
public static HcsReply Properties(string id, string queryJson)
|
|
244
|
+
{
|
|
245
|
+
return WithSystem(id, QueryMs, delegate(IntPtr system, IntPtr op) { return NativeMethods.HcsGetComputeSystemProperties(system, op, queryJson); });
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/// <summary>Lets the virtual machine `vmId` open the file (its disk). The file must exist.</summary>
|
|
249
|
+
public static HcsReply GrantVmAccess(string vmId, string filePath)
|
|
250
|
+
{
|
|
251
|
+
HcsReply reply = new HcsReply();
|
|
252
|
+
reply.HResult = NativeMethods.HcsGrantVmAccess(vmId, filePath);
|
|
253
|
+
return reply;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Minimal JSON output for HcsHost's response file: one flat object of strings and a boolean. Requests are read with
|
|
2
|
+
// JavaScriptSerializer (System.Web.Extensions, part of .NET 4.x).
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using System.Text;
|
|
5
|
+
|
|
6
|
+
namespace AgentSandbox.HcsHost
|
|
7
|
+
{
|
|
8
|
+
public static class Json
|
|
9
|
+
{
|
|
10
|
+
public static string Quote(string text)
|
|
11
|
+
{
|
|
12
|
+
StringBuilder sb = new StringBuilder();
|
|
13
|
+
sb.Append('"');
|
|
14
|
+
if (text != null)
|
|
15
|
+
{
|
|
16
|
+
foreach (char ch in text)
|
|
17
|
+
{
|
|
18
|
+
if (ch == '"')
|
|
19
|
+
{
|
|
20
|
+
sb.Append("\\\"");
|
|
21
|
+
}
|
|
22
|
+
else if (ch == '\\')
|
|
23
|
+
{
|
|
24
|
+
sb.Append("\\\\");
|
|
25
|
+
}
|
|
26
|
+
else if (ch == '\n')
|
|
27
|
+
{
|
|
28
|
+
sb.Append("\\n");
|
|
29
|
+
}
|
|
30
|
+
else if (ch == '\r')
|
|
31
|
+
{
|
|
32
|
+
sb.Append("\\r");
|
|
33
|
+
}
|
|
34
|
+
else if (ch == '\t')
|
|
35
|
+
{
|
|
36
|
+
sb.Append("\\t");
|
|
37
|
+
}
|
|
38
|
+
else if (ch < ' ')
|
|
39
|
+
{
|
|
40
|
+
sb.Append("\\u").Append(((int)ch).ToString("x4"));
|
|
41
|
+
}
|
|
42
|
+
else
|
|
43
|
+
{
|
|
44
|
+
sb.Append(ch);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
sb.Append('"');
|
|
49
|
+
return sb.ToString();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/// <summary>{"ok":..,"hresult":"0x..","message":"..","json":"..","values":{..}}</summary>
|
|
53
|
+
public static string Response(bool ok, int hresult, string message, string json, IDictionary<string, string> values)
|
|
54
|
+
{
|
|
55
|
+
StringBuilder sb = new StringBuilder();
|
|
56
|
+
sb.Append("{\"ok\":").Append(ok ? "true" : "false");
|
|
57
|
+
sb.Append(",\"hresult\":").Append(Quote("0x" + hresult.ToString("X8")));
|
|
58
|
+
sb.Append(",\"message\":").Append(Quote(message));
|
|
59
|
+
sb.Append(",\"json\":").Append(Quote(json));
|
|
60
|
+
sb.Append(",\"values\":{");
|
|
61
|
+
bool first = true;
|
|
62
|
+
if (values != null)
|
|
63
|
+
{
|
|
64
|
+
foreach (KeyValuePair<string, string> pair in values)
|
|
65
|
+
{
|
|
66
|
+
if (!first)
|
|
67
|
+
{
|
|
68
|
+
sb.Append(',');
|
|
69
|
+
}
|
|
70
|
+
first = false;
|
|
71
|
+
sb.Append(Quote(pair.Key)).Append(':').Append(Quote(pair.Value));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
sb.Append("}}");
|
|
75
|
+
return sb.ToString();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// HcsHost.exe <verb> [arguments] --out <response.json>
|
|
2
|
+
// Verbs: check, enumerate, properties <id>, create <request.json>, start <id>, terminate <id>,
|
|
3
|
+
// grant-vm-access <vmId> <file>, create-vhdx <path> <maxGb>.
|
|
4
|
+
// The answer is one JSON file (see Json.Response); exit code 0 = ok, 1 = failed, 2 = wrong use. A create request is
|
|
5
|
+
// {"id": "...", "document": "<the HCS document as a JSON string>"}. Never attaches a disk to this PC.
|
|
6
|
+
using System;
|
|
7
|
+
using System.Collections.Generic;
|
|
8
|
+
using System.IO;
|
|
9
|
+
using System.Security.Principal;
|
|
10
|
+
using System.Text;
|
|
11
|
+
using System.Web.Script.Serialization;
|
|
12
|
+
|
|
13
|
+
namespace AgentSandbox.HcsHost
|
|
14
|
+
{
|
|
15
|
+
public static class Program
|
|
16
|
+
{
|
|
17
|
+
private const long MaxRequestBytes = 1024 * 1024;
|
|
18
|
+
private const int ExitOk = 0;
|
|
19
|
+
private const int ExitFailed = 1;
|
|
20
|
+
private const int ExitUsage = 2;
|
|
21
|
+
private static readonly SecurityIdentifier HyperVAdministrators = new SecurityIdentifier("S-1-5-32-578");
|
|
22
|
+
|
|
23
|
+
public static int Main(string[] args)
|
|
24
|
+
{
|
|
25
|
+
string outFile = null;
|
|
26
|
+
List<string> rest = new List<string>();
|
|
27
|
+
for (int i = 0; i < args.Length; i++)
|
|
28
|
+
{
|
|
29
|
+
if (args[i] == "--out" && i + 1 < args.Length)
|
|
30
|
+
{
|
|
31
|
+
outFile = args[i + 1];
|
|
32
|
+
i++;
|
|
33
|
+
}
|
|
34
|
+
else
|
|
35
|
+
{
|
|
36
|
+
rest.Add(args[i]);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
string response;
|
|
40
|
+
int code;
|
|
41
|
+
try
|
|
42
|
+
{
|
|
43
|
+
code = Dispatch(rest, out response);
|
|
44
|
+
}
|
|
45
|
+
catch (Exception ex)
|
|
46
|
+
{
|
|
47
|
+
response = Json.Response(false, ex.HResult, ex.Message, "", null);
|
|
48
|
+
code = ExitFailed;
|
|
49
|
+
}
|
|
50
|
+
Write(outFile, response);
|
|
51
|
+
return code;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private static void Write(string outFile, string text)
|
|
55
|
+
{
|
|
56
|
+
if (outFile == null)
|
|
57
|
+
{
|
|
58
|
+
Console.Out.WriteLine(text);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
File.WriteAllText(outFile, text, new UTF8Encoding(false));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private static int Usage(out string response, string what)
|
|
65
|
+
{
|
|
66
|
+
response = Json.Response(false, 0, "Usage: " + what, "", null);
|
|
67
|
+
return ExitUsage;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private static int FromReply(HcsReply reply, IDictionary<string, string> values, out string response)
|
|
71
|
+
{
|
|
72
|
+
response = Json.Response(reply.Ok, reply.HResult, reply.Message(), reply.Json, values);
|
|
73
|
+
return reply.Ok ? ExitOk : ExitFailed;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private static int Dispatch(List<string> args, out string response)
|
|
77
|
+
{
|
|
78
|
+
if (args.Count == 0)
|
|
79
|
+
{
|
|
80
|
+
return Usage(out response, "HcsHost <check|enumerate|properties|create|start|terminate|grant-vm-access|create-vhdx> ... --out file");
|
|
81
|
+
}
|
|
82
|
+
string verb = args[0];
|
|
83
|
+
if (verb == "check")
|
|
84
|
+
{
|
|
85
|
+
return Check(out response);
|
|
86
|
+
}
|
|
87
|
+
if (verb == "enumerate")
|
|
88
|
+
{
|
|
89
|
+
return FromReply(Hcs.Enumerate(null), null, out response);
|
|
90
|
+
}
|
|
91
|
+
if (verb == "properties" && args.Count == 2)
|
|
92
|
+
{
|
|
93
|
+
if (Refused(Guard.IdProblem(args[1]), out response))
|
|
94
|
+
{
|
|
95
|
+
return ExitUsage;
|
|
96
|
+
}
|
|
97
|
+
return FromReply(Hcs.Properties(args[1], "{\"PropertyTypes\":[]}"), null, out response);
|
|
98
|
+
}
|
|
99
|
+
if (verb == "create" && args.Count == 2)
|
|
100
|
+
{
|
|
101
|
+
return Create(args[1], out response);
|
|
102
|
+
}
|
|
103
|
+
if ((verb == "start" || verb == "terminate") && args.Count == 2)
|
|
104
|
+
{
|
|
105
|
+
// Twice guarded: the id must look like ours, and HCS itself must say the system is ours.
|
|
106
|
+
if (Refused(Guard.IdProblem(args[1]), out response) || Refused(Guard.OwnerProblem(args[1]), out response))
|
|
107
|
+
{
|
|
108
|
+
return ExitUsage;
|
|
109
|
+
}
|
|
110
|
+
return FromReply(verb == "start" ? Hcs.Start(args[1]) : Hcs.Terminate(args[1]), null, out response);
|
|
111
|
+
}
|
|
112
|
+
if (verb == "grant-vm-access" && args.Count == 3)
|
|
113
|
+
{
|
|
114
|
+
if (Refused(Guard.IdProblem(args[1]), out response) || Refused(Guard.DiskProblem(args[2]), out response))
|
|
115
|
+
{
|
|
116
|
+
return ExitUsage;
|
|
117
|
+
}
|
|
118
|
+
return FromReply(Hcs.GrantVmAccess(args[1], args[2]), null, out response);
|
|
119
|
+
}
|
|
120
|
+
if (verb == "create-vhdx" && args.Count == 3)
|
|
121
|
+
{
|
|
122
|
+
long maxGb;
|
|
123
|
+
if (!long.TryParse(args[2], out maxGb))
|
|
124
|
+
{
|
|
125
|
+
return Usage(out response, "create-vhdx <path> <maxGb>");
|
|
126
|
+
}
|
|
127
|
+
VirtualDisk.Create(args[1], maxGb);
|
|
128
|
+
response = Json.Response(true, 0, "ok", "", null);
|
|
129
|
+
return ExitOk;
|
|
130
|
+
}
|
|
131
|
+
return Usage(out response, "unknown verb or wrong number of arguments: " + verb);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/// <summary>Read-only facts: can computecore load, who am I, what does the service say.</summary>
|
|
135
|
+
private static int Check(out string response)
|
|
136
|
+
{
|
|
137
|
+
Dictionary<string, string> values = new Dictionary<string, string>();
|
|
138
|
+
values["computecore"] = Hcs.CanLoad("computecore.dll") ? "yes" : "no";
|
|
139
|
+
WindowsPrincipal principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
|
|
140
|
+
values["administrator"] = principal.IsInRole(WindowsBuiltInRole.Administrator) ? "yes" : "no";
|
|
141
|
+
values["hyperVAdministrators"] = principal.IsInRole(HyperVAdministrators) ? "yes" : "no";
|
|
142
|
+
if (values["computecore"] != "yes")
|
|
143
|
+
{
|
|
144
|
+
response = Json.Response(false, 0, "computecore.dll is not on this PC", "", values);
|
|
145
|
+
return ExitFailed;
|
|
146
|
+
}
|
|
147
|
+
HcsReply reply = Hcs.ServiceProperties(null);
|
|
148
|
+
return FromReply(reply, values, out response);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
private static int Create(string requestFile, out string response)
|
|
152
|
+
{
|
|
153
|
+
FileInfo info = new FileInfo(requestFile);
|
|
154
|
+
if (!info.Exists || info.Length > MaxRequestBytes)
|
|
155
|
+
{
|
|
156
|
+
return Usage(out response, "create <request.json> (a file of at most 1 MB)");
|
|
157
|
+
}
|
|
158
|
+
JavaScriptSerializer serializer = new JavaScriptSerializer();
|
|
159
|
+
Dictionary<string, object> request = serializer.Deserialize<Dictionary<string, object>>(File.ReadAllText(requestFile, Encoding.UTF8));
|
|
160
|
+
object id;
|
|
161
|
+
object document;
|
|
162
|
+
if (!request.TryGetValue("id", out id) || !request.TryGetValue("document", out document) || !(id is string) || !(document is string))
|
|
163
|
+
{
|
|
164
|
+
return Usage(out response, "the request needs a text id and a text document");
|
|
165
|
+
}
|
|
166
|
+
if (Refused(Guard.IdProblem((string)id), out response) || Refused(Guard.DocumentProblem((string)document), out response))
|
|
167
|
+
{
|
|
168
|
+
return ExitUsage;
|
|
169
|
+
}
|
|
170
|
+
return FromReply(Hcs.Create((string)id, (string)document), null, out response);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/// <summary>True (with the refusal as the response) when `problem` says why the request is not allowed.</summary>
|
|
174
|
+
private static bool Refused(string problem, out string response)
|
|
175
|
+
{
|
|
176
|
+
if (problem == null)
|
|
177
|
+
{
|
|
178
|
+
response = null;
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
response = Json.Response(false, 0, "Refused: " + problem, "", null);
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Creates a blank dynamic VHDX with CreateVirtualDisk (virtdisk.dll). The disk is never attached to this PC: no
|
|
2
|
+
// AttachVirtualDisk, no mount, no drive letter. Signatures from the Microsoft virtdisk.h reference (not re-checked).
|
|
3
|
+
using System;
|
|
4
|
+
using System.ComponentModel;
|
|
5
|
+
using System.IO;
|
|
6
|
+
using System.Runtime.InteropServices;
|
|
7
|
+
|
|
8
|
+
namespace AgentSandbox.HcsHost
|
|
9
|
+
{
|
|
10
|
+
public static class VirtualDisk
|
|
11
|
+
{
|
|
12
|
+
private const uint VirtualStorageTypeDeviceVhdx = 3;
|
|
13
|
+
private static readonly Guid VendorMicrosoft = new Guid("EC984AEC-A0F9-47e9-901F-71415A66345B");
|
|
14
|
+
private const uint CreateVirtualDiskVersion1 = 1;
|
|
15
|
+
private const uint AccessNone = 0;
|
|
16
|
+
private const uint FlagNone = 0;
|
|
17
|
+
|
|
18
|
+
[StructLayout(LayoutKind.Sequential)]
|
|
19
|
+
private struct VirtualStorageType
|
|
20
|
+
{
|
|
21
|
+
public uint DeviceId;
|
|
22
|
+
public Guid VendorId;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
[StructLayout(LayoutKind.Sequential)]
|
|
26
|
+
private struct CreateVirtualDiskParametersV1
|
|
27
|
+
{
|
|
28
|
+
public uint Version;
|
|
29
|
+
public Guid UniqueId;
|
|
30
|
+
public ulong MaximumSize;
|
|
31
|
+
public uint BlockSizeInBytes;
|
|
32
|
+
public uint SectorSizeInBytes;
|
|
33
|
+
public IntPtr ParentPath;
|
|
34
|
+
public IntPtr SourcePath;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private static class NativeMethods
|
|
38
|
+
{
|
|
39
|
+
[DllImport("virtdisk.dll", CharSet = CharSet.Unicode)]
|
|
40
|
+
public static extern int CreateVirtualDisk(
|
|
41
|
+
ref VirtualStorageType storageType,
|
|
42
|
+
string path,
|
|
43
|
+
uint accessMask,
|
|
44
|
+
IntPtr securityDescriptor,
|
|
45
|
+
uint flags,
|
|
46
|
+
uint providerSpecificFlags,
|
|
47
|
+
ref CreateVirtualDiskParametersV1 parameters,
|
|
48
|
+
IntPtr overlapped,
|
|
49
|
+
out IntPtr handle);
|
|
50
|
+
|
|
51
|
+
[DllImport("kernel32.dll", SetLastError = true)]
|
|
52
|
+
public static extern bool CloseHandle(IntPtr handle);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/// <summary>A new sparse VHDX of at most maxGb GB. An existing file is never touched.</summary>
|
|
56
|
+
public static void Create(string path, long maxGb)
|
|
57
|
+
{
|
|
58
|
+
if (!path.EndsWith(".vhdx", StringComparison.OrdinalIgnoreCase))
|
|
59
|
+
{
|
|
60
|
+
throw new ArgumentException("The disk file must end in .vhdx");
|
|
61
|
+
}
|
|
62
|
+
if (maxGb < 1 || maxGb > 4096)
|
|
63
|
+
{
|
|
64
|
+
throw new ArgumentException("The size must be 1 to 4096 GB");
|
|
65
|
+
}
|
|
66
|
+
if (File.Exists(path))
|
|
67
|
+
{
|
|
68
|
+
throw new IOException("The disk file already exists: " + path);
|
|
69
|
+
}
|
|
70
|
+
VirtualStorageType type = new VirtualStorageType();
|
|
71
|
+
type.DeviceId = VirtualStorageTypeDeviceVhdx;
|
|
72
|
+
type.VendorId = VendorMicrosoft;
|
|
73
|
+
CreateVirtualDiskParametersV1 parameters = new CreateVirtualDiskParametersV1();
|
|
74
|
+
parameters.Version = CreateVirtualDiskVersion1;
|
|
75
|
+
parameters.MaximumSize = (ulong)maxGb * 1024UL * 1024UL * 1024UL;
|
|
76
|
+
IntPtr handle = IntPtr.Zero;
|
|
77
|
+
try
|
|
78
|
+
{
|
|
79
|
+
// CreateVirtualDisk returns the error code itself (not through GetLastError).
|
|
80
|
+
int error = NativeMethods.CreateVirtualDisk(ref type, path, AccessNone, IntPtr.Zero, FlagNone, 0, ref parameters, IntPtr.Zero, out handle);
|
|
81
|
+
if (error != 0)
|
|
82
|
+
{
|
|
83
|
+
throw new Win32Exception(error);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
finally
|
|
87
|
+
{
|
|
88
|
+
if (handle != IntPtr.Zero && handle != new IntPtr(-1))
|
|
89
|
+
{
|
|
90
|
+
NativeMethods.CloseHandle(handle);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// What HostTools.exe says about itself in its file properties (publisher, product, description, version), so Windows,
|
|
2
|
+
// antivirus software and you can tell what it is. It is built on this PC from the sources next to this file.
|
|
3
|
+
using System.Reflection;
|
|
4
|
+
using System.Runtime.InteropServices;
|
|
5
|
+
|
|
6
|
+
[assembly: AssemblyTitle("Windows Development Sandbox host helper")]
|
|
7
|
+
[assembly: AssemblyDescription("Helper of windows-development-sandbox (open source, MIT): keeps this PC awake while a sandbox runs, shows and hides the Windows Sandbox window, reads the Windows events that end a sandbox and adds its folder to your PATH. Source: https://github.com/JoshDiDuca/windows-development-sandbox")]
|
|
8
|
+
[assembly: AssemblyCompany("windows-development-sandbox (open source)")]
|
|
9
|
+
[assembly: AssemblyProduct("Windows Development Sandbox")]
|
|
10
|
+
[assembly: AssemblyCopyright("MIT License, windows-development-sandbox contributors")]
|
|
11
|
+
[assembly: AssemblyVersion("1.9.0.0")]
|
|
12
|
+
[assembly: AssemblyFileVersion("1.9.0.0")]
|
|
13
|
+
[assembly: AssemblyInformationalVersion("1.9.0")]
|
|
14
|
+
[assembly: ComVisible(false)]
|