# attach/windows/ — Windows USB attach for the virtual Kinect v1 (todo 12) Presents the OS-agnostic `core/protocol` emitter (`nui::protocol::KinectV1Device`) to Windows via the **usbip-win VHCI client**, so the real Microsoft Kinect driver (`kinect*.inf`) binds to it and the real `Kinect10.dll` NUI runtime enumerates it as a physical Kinect. It reuses the `attach/linux` USB/IP **server** unchanged — that server is OS-agnostic (USB/IP protocol v1.1.1); only the client (the Windows VHCI driver) and the MS driver binding differ per OS. The architecture, the decision to reuse USB/IP instead of writing a bespoke bus driver, the exact device topology, and the one real risk (isochronous framing) are in [`docs/approach.md`](docs/approach.md). Read it before running anything here. ## Status in THIS environment: **`[~]` BLOCKED (no Windows, no WDK)** This directory was authored on a Linux/WSL2 host with **no Windows and no Windows Driver Kit**. A Windows virtual USB bus driver (KMDF/UMDF) and the `usbip-win` VHCI driver both need the WDK + MSVC and can only be built on Windows; mingw cannot build Windows kernel-mode drivers. **Nothing in this directory was built or run.** No binding, no enumeration, and no DEA playability was observed. Every build/attach/verify step below is for the **user's Windows box**. The reusable server half is complete and socket-verified in `attach/linux/`. What is delivered and ready to use on Windows: | Deliverable | Path | What it does | | --- | --- | --- | | Approach + architecture + decision record | `docs/approach.md` | why USB/IP, topology, ISO risk, fallbacks | | Attach map / device identities | `config/kinect-usbip.json` | server host:port + the three busids/VID:PIDs | | Install a VHCI client | `scripts/Install-UsbIpWin.ps1` | installs usbip-win2 (signed) or usbip-win (test-signed) | | Test-signing + cert (legacy client) | `scripts/Enable-TestSigning.ps1`, `scripts/Disable-TestSigning.ps1` | `bcdedit`, Secure-Boot check, PFX import | | Attach / detach the sensor | `scripts/Attach-Kinect.ps1`, `scripts/Detach-Kinect.ps1` | three `usbip attach`, graceful detach | | Verify binding | `scripts/Verify-KinectDevice.ps1` | PnP check that the MS Kinect driver bound, no yellow-bang | ## Prerequisites On the **host** running the device emitter (any Linux box, a Linux VM, or WSL2 with a usable networking stack — the same binary serves both OSes): ```sh cmake -S attach/linux -B attach/linux/build cmake --build attach/linux/build ./attach/linux/build/kinect_attach serve --port 3240 # exports busids 1-1 camera, 1-2 audio, 1-3 motor ``` (For a real session the emitter is fed by the tracker/synth pipeline, plan todos 5/7/10; the standalone `serve` uses a placeholder frame source and is enough to prove enumeration/binding.) On the **Windows box**: - Windows 10 x64 1903 (build 18362) or later (usbip-win2 requirement), or Windows 11. - The **Kinect for Windows Runtime + SDK v1.8** installed — this provides the real Kinect USB driver (`kinect*.inf`) and `Kinect10.dll`, which are what must bind to and enumerate the virtual device. Without them there is nothing on the Windows side to recognize the sensor. - The **Kinect for Windows Developer Toolkit v1.8** for the `KinectExplorer-D2D` / `SkeletonBasics-D2D` samples used to confirm NUI enumeration. - A USB/IP VHCI client (installed below). - An elevated PowerShell for every script here. ## Pick a client Two prebuilt USB/IP VHCI clients work; this directory supports both. - **usbip-win2 (vadimgrn) — RECOMMENDED.** UDE driver, **attestation/WHLK-signed**, ships an MSI. Because it is properly signed it typically needs **no** test-signing and **no** Secure-Boot change. Download the MSI from . Requires Windows 10 1903+. - **usbip-win (cezanne) — legacy fallback.** Test-signed VHCI driver (`vhci(ude)` or `vhci(wdm)`). Requires **test-signing ON**, **Secure Boot OFF**, and its bundled `usbip_test.pfx` imported. Download/extract a release zip from (e.g. `usbip-win-0.3.5` or `0.3.6-dev`). Use this only if usbip-win2 does not work on the target OS. ## Runbook ### A. If using usbip-win2 (signed — the simple path) ```powershell # Elevated PowerShell on the Windows box. Create a System Restore Point first (USB hubs restart). cd attach\windows\scripts .\Install-UsbIpWin.ps1 -Client usbip-win2 -InstallerPath C:\path\to\USBip-.x64.msi # (reboot only if Windows prompts; the signed UDE driver usually loads without test-signing) # With the attach/linux server running on the host (edit config\kinect-usbip.json 'host' if remote): .\Attach-Kinect.ps1 # attaches busids 1-1, 1-2, 1-3 .\Verify-KinectDevice.ps1 # confirms the three PIDs bound to the MS Kinect driver ``` If the signed driver still refuses to load (`usbip.exe` reports the driver blocked), fall through to the test-signing steps in section B — they apply to any unsigned/test-signed driver. ### B. If using usbip-win (legacy — test-signing required) Test-signing is the Windows posture that lets a driver **not** signed by a Microsoft-trusted CA load. Windows x64 enforces driver signing; a self-built/test-signed VHCI driver is signed by a test certificate, so the box must be in test-signing mode **and** trust that certificate, and **Secure Boot must be off** (firmware enforces the same signing policy). This is a **personal-use development posture, not production** — a test-signed driver is untrusted for signing purposes. ```powershell # Elevated PowerShell on the Windows box. cd attach\windows\scripts # 1. Secure Boot OFF (in UEFI firmware), then enable test-signing + import the test cert. .\Enable-TestSigning.ps1 -PfxPath C:\path\to\usbip-win-\usbip_test.pfx # -> warns if Secure Boot is still ON; runs 'bcdedit /set testsigning on'; # imports usbip_test.pfx (password: usbip) into LocalMachine Root AND TrustedPublisher. # REBOOT. A "Test Mode" desktop watermark appears afterward — that is expected and harmless. # 2. Install the test-signed VHCI driver. .\Install-UsbIpWin.ps1 -Client usbip-win -PackageDir C:\path\to\usbip-win- # 3. Attach + verify (server running on the host). .\Attach-Kinect.ps1 .\Verify-KinectDevice.ps1 ``` **Watermark:** with test-signing on you will see `Test Mode Windows ` in the lower-right of the desktop. It is the expected signal that signature enforcement is relaxed; it does not affect gameplay. ### C. Verify (both paths) `Verify-KinectDevice.ps1` checks, via PnP, that `VID_045E&PID_02AE` (camera), `PID_02AD` (audio) and `PID_02B0` (motor) are **present**, **bound with no Problem code**, and reports the binding INF/service. The pass criteria for plan todo 12: 1. **Device Manager** shows the Kinect devices bound to the **Microsoft Kinect driver** (`kinect*.inf`), no yellow-bang. If `Verify-KinectDevice.ps1` reports the service/INF as `usbip*`, the VHCI stub attached the device but the MS Kinect driver did not match its descriptors — check that the real Kinect 1.8 runtime+driver are installed and that the descriptors match (todo 13 / spike-windows.md Step 4 captures any delta the MS driver demands). 2. **The NUI runtime enumerates it:** launch `KinectExplorer-D2D` (it should list the sensor) or run `SkeletonBasics-D2D` (it should open the sensor). Equivalently `NuiGetSensorCount() >= 1` and `NuiCreateSensorByIndex(0, ...)` succeed. Streams may be empty until todo 13 serves depth — that is expected at the binding stage. Capture a Device Manager screenshot and the KinectExplorer window to `.omo/evidence/task-12-webcam-kinect-emulator.*`. ### D. Detach / teardown ```powershell .\Detach-Kinect.ps1 -All # graceful device removal of all attached ports # legacy client only, when fully done with the virtual Kinect: # usbip.exe uninstall # remove the VHCI driver FIRST .\Disable-TestSigning.ps1 # then turn test-signing back off; reboot; re-enable Secure Boot ``` Detaching while DEA or a Kinect SDK sample holds the sensor must surface a clean **device-removed / sensor-unplugged** to the app (no BSOD) — that is todo 12's documented failure scenario to confirm on Windows. ## When to drop to the NUI-shim fallback (todo 14) If the device-level path cannot be made to work on the target Windows box — the MS Kinect driver will not bind to the virtual descriptors, or the USB/IP ISO framing is rejected and extending the shared server's ISO handling (see `docs/approach.md` §5) does not resolve it — switch to the clean-room `Kinect10.dll` NUI shim in `fallback/windows-nui/` (plan todo 14). That shim injects skeleton/depth directly and proves **playability** (IS-3/IS-4) but, per the plan, does **NOT** satisfy IS-1 (OS enumerates the sensor) or IS-2 (the real MS NUI runtime skeletonizes synthetic depth). Do not report IS-1/IS-2 as proven from the shim path; if the device path cannot be achieved, the plan says to HALT and re-plan rather than accept shim gameplay as that proof. ## Known constraints (documented, not hidden) - **Bitness.** spike-windows.md Step 2 settles whether DEA / `gamekdm.dll` is x86 or x64 and therefore which arch the shipping Windows chain targets. The USB/IP attach here is arch-agnostic at the wire level (it is a TCP client + a generic VHCI driver), so the same scripts serve either bitness; the bitness constraint bites the NUI-shim (todo 14) and any in-process code, not this attach path. usbip-win2 ships x64/ARM64; the legacy client ships x86/x64. - **Isochronous framing.** The shared server models the camera's ISO IN endpoints as single packets without the USB/IP `iso_packet_descriptor` array (a documented simplification validated against the Linux `vhci-hcd` client). Whether the Windows VHCI + MS Kinect driver accept that is the open question todo 13 resolves; the fix, if needed, is in the shared `core/`+`attach/linux` ISO path and is reused by Windows, not a Windows-only change (`docs/approach.md` §5). - **No driver is built here.** These are install/attach/verify helpers that drive prebuilt usbip-win releases and the MS Kinect driver. Building `usbip-win`/`usbip-win2` from source, or a bespoke KMDF/UMDF bus driver, needs the WDK + MSVC on Windows and is out of this environment's reach.