Skip to content

feat(multi-pc): a Windows remote says when UIPI drops what it injects - #818

Merged
mgth merged 7 commits into
v6from
feat/mpc-uipi-blocked
Nov 24, 2026
Merged

mgth merged 7 commits into
v6from
feat/mpc-uipi-blocked

Conversation

@mgth

@mgth mgth commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Problème

Cas réel du 2026-11-24 (maître Linux, esclave Windows 11 vm124, agent esclave non élevé) : le clavier visuel (osk.exe, processus UIAccess de niveau High) prend le focus après un clic sur son icône dans la barre des tâches. UIPI jette alors tout ce que le hook esclave injecte, mouvement compris : le pointeur reste figé sur l'esclave, celui du maître revient à l'aveugle, et rien ne dit pourquoi.

Ce que fait la PR

  • Détection, hook esclave Windows (lbm-hook/src/remote/blocking.rs, remote/windows/foreground.rs) : SendInput ne signale pas un blocage UIPI (la doc le dit, il compte comme envoyé ce qu'il jette). Le hook compare donc le niveau d'intégrité du processus de la fenêtre au premier plan avec le sien, et son propre UIAccess. Le premier plan est suivi par EVENT_SYSTEM_FOREGROUND sur un fil dédié, seulement entre le début d'une session pilotée et son rangement ; aucune scrutation. Un SendInput incomplet (bureau sécurisé) compte aussi comme blocage. Nouvel événement hook InjectionBlocked { Block }.
  • Remontée : l'agent esclave relaie au maître par Control::InjectionBlocked, seulement vers un maître qui annonce la capacité InjectionBlocked dans son Hello (les deux rôles l'annoncent). Les envois sont chaînés pour qu'un blocage et sa fin arrivent dans l'ordre.
  • Affichage côté maître : PeerEntry::InjectionBlocked dans l'état Peers, Snapshot::InjectionBlocked pour le tray. Page Machines et tray : « Windows blocks the mouse and keyboard on : an elevated window has the focus… Turn on "Start with elevated privileges" ».
  • Option 3, retour du pointeur : un blocage annoncé pendant que le pointeur est chez l'esclave termine le saut comme InputReset (hook.restart()) : le pointeur revient chez le maître au lieu de rester figé là-bas. Une session qui recommence bloquée le redit, donc chaque nouvelle traversée revient aussi.
  • examples/peer_drive annonce la capacité, affiche les blocages et ramène le pointeur comme le ferait le maître.

Tests

  • remote::blocking : intégrités simulées (osk High+UIAccess vs hook Medium, hook élevé, hook UIAccess, jeton illisible, pas de premier plan) et règles de report (changement, début de session bloquée, envoi incomplet).
  • tests/peers.rs : capacité absente → rien n'est envoyé ; capacité présente → blocage puis fin, dans l'ordre ; côté maître, blocage pendant la traversée → connexion au hook fermée, Leave envoyé, état et blocked_remotes renseignés, effacés à la fin du lien.
  • Format du Control sur le fil ; lecture de l'état dans lbm-app (le blocage ne reconstruit pas la carte) ; texte du tray et de la page.
  • cargo clippy --workspace --all-targets propre sous Linux et --target x86_64-pc-windows-gnu. En local, seul supervise::an_absent_hook_is_launched_detached_and_outlives_the_agent échoue (cas connu : un vrai hook tourne sur la machine).

Essai réel (vm124, 2026-11-24)

Hook de cette branche lancé à côté de l'installation du mainteneur (LBM_HOOK_ENDPOINT, aucun binaire remplacé), piloté par un client local qui joue le rôle de l'agent relais :

Cas Résultat
Hook non élevé, mmc.exe élevé (console du mainteneur) au premier plan InjectionBlocked blocked by mmc.exe dès l'Enter, redit à la traversée suivante ; curseur figé
Hook non élevé, survol puis clic de l'icône du clavier visuel (osk.exe High + UIAccess) osk.exe prend le focus ~300 ms après le survol ; blocage signalé à cet instant (5 fois sur 6 par l'événement, la 6e seulement à la traversée suivante → filet ajouté : chaque lot compare le premier plan, c4bd07c), curseur figé
Hook élevé (tâche « Highest »), mmc.exe puis osk.exe au premier plan Rien de signalé, le curseur suit, les clics passent
SendInput avec une fenêtre élevée au premier plan Renvoie 1/1, GetLastError = 0 : confirme qu'il ne signale pas UIPI

Pas essayé en réel : la chaîne agent esclave → réseau → maître (le mutex « un agent par session » empêche un second agent à côté de celui du mainteneur, qu'il ne fallait pas arrêter) ; elle est couverte par tests/peers.rs sur boucle locale. Le retour du pointeur chez le maître n'a donc été vu qu'en test.

🤖 Generated with Claude Code

mgth and others added 5 commits November 24, 2026 16:00
A remote whose agent is not elevated injects nothing while a window of a
higher integrity level has the focus (osk.exe, Task Manager, an elevated
program): the pointer froze there and the master's came back blind, with
nothing said. SendInput does not report a UIPI block, so the hook compares
the foreground's integrity level (and its own UIAccess) with its own.

- lbm-hook: remote::blocking decides and reports (pure, tested);
  remote/windows/foreground follows EVENT_SYSTEM_FOREGROUND on a thread of
  its own, only between a session's begin and its park. A short SendInput
  (secure desktop) counts as a block too. Event::InjectionBlocked.
- lbm-net: Control::InjectionBlocked, remote -> master, sent only to a
  master that announced the InjectionBlocked capability; both roles
  announce it. Sends are chained so a block and its end keep their order.
- Master: PeerEntry::injection_blocked while linked; Snapshot lists the
  blocked remotes. A block said while the pointer is over there ends the
  hop, as InputReset does: the pointer comes home instead of staying frozen.
- lbm-app/lbm-ui (Machines page) and the tray say: "Windows blocks the
  mouse and keyboard on <name>: an elevated window has the focus" and how
  to get out of it ("Start with elevated privileges").

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e as a master does

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the vm124 trial

On the vm124 the foreground event once missed osk.exe taking the focus
(the hook's own focus hook missed it as well), and the block was said only
at the next crossing. Each batch now compares the foreground window with
the one last judged: one GetForegroundWindow per batch, judged again only
when it changed; no timer, nothing between sessions.

docs/multi-pc-etat.md: the trial (osk.exe and an elevated mmc.exe, hook
not elevated then elevated) and the limits that remain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@mgth mgth left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Les deux tests d’intégration sur la remontée du blocage passent sur boucle locale. Deux points restent à corriger dans le diagnostic. Je les ai vérifiés par lecture du chemin Windows, sans essai sur une session Windows.

@mgth mgth left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La branche est toujours sur 46be2412. Les deux remarques sur le changement de focus et le diagnostic d’envoi incomplet restent ouvertes. La fusion avec v6 (6e3b50d6) présente désormais deux conflits, vérifiés avec git merge-tree, dans rust/crates/lbm-agent/src/api.rs et rust/crates/lbm-agent/src/tray/mod.rs. Lors de la résolution, conserver à la fois le diagnostic de blocage Windows et l’affichage des autres outils de partage ajouté par #814.

mgth added a commit that referenced this pull request Nov 24, 2026
Review of #819: #816, #817 and #818 are still open, so "none" was wrong.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mgth and others added 2 commits November 24, 2026 16:55
# Conflicts:
#	docs/multi-pc-etat.md
#	rust/crates/lbm-agent/src/api.rs
#	rust/crates/lbm-agent/src/peers/actor.rs
#	rust/crates/lbm-agent/src/runtime.rs
#	rust/crates/lbm-agent/src/tray/mod.rs
#	rust/crates/lbm-ui/src/machines.rs
#	rust/crates/lbm-ui/tests/machines.rs
…e as such

Review of #818:
- A WinEvent is queued: judging the window it names could say a block for
  an elevated window already gone, after a batch saw an ordinary one back,
  and the master would end a crossing that works. The event now only says
  "look again": every observation (session start, event, batch) reads the
  foreground, judges it and says it under one lock (blocking::Watch), so
  nothing is said out of the order it was read.
- A short SendInput with no integrity difference seen (a secure desktop)
  is no longer shown as an elevated window: InjectionBlock carries a cause
  (Integrity, the default when absent, or Unknown, also what an unknown
  cause reads as). Only Integrity advises "Start with elevated
  privileges", on the Machines page and in the tray; the pointer still
  comes home either way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mgth
mgth merged commit fc4f521 into v6 Nov 24, 2026
3 checks passed
@mgth
mgth deleted the feat/mpc-uipi-blocked branch November 24, 2026 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant