Windows service mode: full elevated routing for standard users

Author: mgthCreated Jul 21, 2026Updated Jul 30, 2026
Labelsenhancement

Follow-up to #400 and #512.

The next release makes LBM start for standard users (asInvoker manifest + opportunistic elevation for split-token admins). One gap remains for non-admin accounts: UIPI blocks input injection while an elevated window has focus, so routing pauses during that focus. Closing that gap needs the daemon to run at System integrity inside the user's session — a service-based mode.

Why the earlier attempt failed: a Windows service lives in session 0 (isolation since Vista) — from there the interactive desktop is unreachable by design: no low-level hooks, no input injection. Nothing was wrong with the capture code itself.

The viable design (what commercial input remappers do):

  1. An installer-registered service (LocalSystem) never captures anything itself.
  2. It watches sessions (WTSGetActiveConsoleSessionId, logon/unlock/switch notifications via SERVICE_CONTROL_SESSIONCHANGE).
  3. For the active interactive session it launches the hook daemon inside that session: duplicate its own SYSTEM token, SetTokenInformation(TokenSessionId, <session>), then CreateProcessAsUser targeting WinSta0\Default.
  4. The daemon then runs at System IL in the user's session: WH_MOUSE_LL + SendInput work, and UIPI is satisfied even over elevated windows — full routing for standard users, and no UAC anywhere.
  5. UI ↔ daemon keeps the existing local TCP protocol; the service only manages the daemon lifecycle (start per session, kill on logoff, restart on crash).

Scope to figure out: installer service registration, per-session config resolution (the daemon must read the session user's layout, not SYSTEM's), and making this an opt-in install mode so the current task-scheduler path remains the default.