Commit Graph

2132 Commits

Author SHA1 Message Date
Benoît CORTIER e8e1311fac ci: add CodSpeed benchmark reporting
Report the codec and corpus Criterion benchmarks through CodSpeed simulation, and time each hash-free replay capture as a separate manual wall-time command. The connector remains Criterion-only because preparation dominates its process time.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-23 01:52:46 +09:00
Benoît CORTIER a58dfe90b8 docs(connector): document connector benchmark policy
Record what the connector benchmark relies on but the tree does not show: manifest tables come from corpus-check, the fingerprint sorts Channel Join Requests, the timed drive stays production-only, and the workload depends on capture decoding alone.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-23 01:49:37 +09:00
Benoît CORTIER e18bfe504a refactor(connector): reuse connector verification in corpus check
Call ConnectorReplay::verify from corpus-check instead of repeating its comparison, so both paths share one contract and observe and mismatch stay private.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-23 01:49:37 +09:00
Benoît CORTIER 1edf666151 docs(connector): describe the timed connector span
The timed run constructs the connector and steps it to Connected, so describe it that way instead of starting at the captured Connection Confirm.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-23 01:49:37 +09:00
Benoît CORTIER 0f8535ac8d perf(connector): time connection establishment from captures
Add a connector benchmark that drives the production ClientConnector from a captured X.224 Connection Confirm to Connected, with a client configuration derived from the captured client frames. Captures opt in by listing \connector\ and recording a [capture.connector] expectation; corpus-check verifies it, corpus-bench and xtask expose it, and the timed run only steps the connector.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-23 01:49:37 +09:00
Benoît CORTIER b9b49a4de0 docs(bench): document benchmark extension policy
Add a nested AGENTS.md covering benchmark eligibility, extension points, timed-path rules, expectation drift, and fixture pitfalls that the source tree does not make obvious.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-23 01:44:34 +09:00
Benoît CORTIER a54260afe2 build(bench): gate perfenc dependencies
Make the server encoder, Tokio, and tracing dependencies optional behind a perfenc feature enabled by default, and build the corpus tooling with --no-default-features so corpus checks and capture replay skip them.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-23 01:44:34 +09:00
Benoît CORTIER 00f270aacb refactor(bench): drop redundant benchmark checks
Share the color conversion call between its preflight and timed loop, and drop a perfenc check implied by the encoded byte count.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-23 01:44:34 +09:00
Benoît CORTIER 691414d96b perf(bench): time capture replay
Captures list benchmark kinds in the corpus manifest. The corpus check rejects a capture listing replay unless its expectation renders an active or terminated session, so a capture whose replay becomes complete keeps its benchmark.

The corpus Criterion target registers replay/<id> for each listed capture, verifies the full output once inside the selected benchmark, and then times replays that skip hashing the output. corpus-bench replay runs one replay for whole-process timing, and cargo xtask bench replay refuses an unlisted capture before Criterion can silently match nothing.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-23 01:44:34 +09:00
Benoît CORTIER 1f1aa0e06b perf: consolidate benchmark entry points
Move perfenc into ironrdp-bench and remove the root benches package. perfenc now stops cleanly at end of input, rejects a truncated final frame, prints one summary line, and fails when the encoder produces no output.

Graphics benchmarks use deterministic nonzero fixtures, the full-image RemoteFX stride matches its width, and encoder output is observable. Bulk benchmarks keep codec teardown outside timing and assert that every registered input compresses and round-trips; inputs at the passthrough threshold are no longer silently skipped.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-23 01:44:34 +09:00
Benoît CORTIER 063965bc9a refactor(bench): keep replay summary conversion private
Expectation::from_summary is only used by the corpus checker, so it no
longer exposes ironrdp-capture-replay types through the public API.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-23 01:42:10 +09:00
Benoît CORTIER 0a7b7984d7 fix(bench): requalify captures after SRL decoding fix
#2134 decodes Windows SRL streams without their trailing zeros, which
removes the static-channel gaps from both rendered captures.
no-nla-accepted and no-nla-smartcard now replay as complete with 86 and
87 graphics updates.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-23 01:42:10 +09:00
Benoît CORTIER 0d9f408e12 fix: validate CredSSP replay limitation
Require a DER TSRequest header at the start of both decrypted streams
before reporting a credssp-prefix limitation.

Key the CI corpus cache on fetch inputs only, copy replay summaries
into expectations exhaustively, and tally outcomes with named counters.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-23 01:42:10 +09:00
Benoît CORTIER 5a98c525cf feat: add capture corpus replay checks
Replay pinned captures in process through a typed ironrdp-bench
manifest and compare every result with its recorded expectation.

Capture replay now stops at session termination, classifies NLA
captures whose decrypted stream begins with CredSSP as unsupported,
and exposes prepared replay, lifecycle, outcome, and summary
primitives without full-frame copies.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-23 01:42:10 +09:00
Benoît CORTIER 5e9662009e test(capture): share synthetic capture builders
Reuse the capture module's packet and TLS builders in key-log tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-23 01:35:37 +09:00
Benoît CORTIER 7743855841 refactor: make capture replay library-only
Make ironrdp-capture-replay a library-only crate so consumers no longer link the PNG export tool. Move the tool to the binary-only ironrdp-capture-export package without changing export behavior.

Issue: #1955

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-23 01:31:25 +09:00
Benoît CORTIER 1b6811133e refactor(capture): tidy extraction
Avoid cloning decrypted primary streams and clarify the extracted capture diagnostics and test oracles.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-23 01:28:01 +09:00
Benoît CORTIER 7e0b506697 refactor(capture): move tests to extra testsuite
Move capture decoding tests into the extra integration testsuite while retaining the disabled library test harness.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-23 00:19:20 +09:00
Benoît CORTIER 928274e3fe fix: distinguish empty gateway tunnels
Report decoded gateway tunnels with no RDP stream separately from malformed tunnel framing.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-23 00:19:19 +09:00
Benoît CORTIER 18fa8e2a5c refactor: centralize capture decryption
Keep gateway tunnel unwrapping and RDP TLS decryption in the capture crate so replay only recovers state and routes plaintext.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-23 00:19:19 +09:00
Benoît CORTIER 05c08b712d refactor: extract capture decoding
Move pcapng decoding, TCP reassembly, TLS decryption, and RD Gateway
unwrapping into ironrdp-capture so connector workloads can avoid replay
routing and export dependencies.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-23 00:17:30 +09:00
Marc-André Moreau b9d1400033 feat(cliprdr): transfer files through the Windows clipboard (#2179)
Adds clipboard file transfer, in both directions, to the Windows
clipboard backend (`WinClipboard`), and stops it advertising formats it
can't deliver. ActiveX and `ironrdp-client` get the feature as is; the
.NET FFI gets it through new bindings, opt-in.

## Backend (`feat(cliprdr)`)

**Remote to local.** When the remote format list has
`FileGroupDescriptorW`, an OLE data object goes on the clipboard
(`OleSetClipboard`). It offers `FileGroupDescriptorW` and one
`FileContents` `IStream` per file (`lindex`), plus the other remote
formats.
- Streams read through `FileContents` RANGE requests carrying the
`clipDataId` of the lock `Cliprdr` took for that list, so a paste keeps
working after the remote clipboard changes, until the lock is released.
Files over 4 GiB work.
- OLE needs an STA: this is only enabled when `WinClipboard` is created
on one. COM is never initialized on a thread that has none.
- The objects are not agile and run on the clipboard thread. A stream
read blocks it like `WM_RENDERFORMAT` handling already does (30 s
timeout, chunks up to 1 MiB with read-ahead). Backend events arriving
during a wait are now queued instead of dropped.

**Local to remote.** `CF_HDROP` paths (directories walked into relative
paths), or another application's virtual files (`FileGroupDescriptorW` +
`FileContents`), are offered with `SendInitiateFileCopy` once the
channel is ready. The remote's SIZE/RANGE requests are served, from the
lock snapshot when a `clipDataId` is given.

**Capabilities.** The backend now negotiates `STREAM_FILECLIP_ENABLED`,
`FILECLIP_NO_FILE_PATHS`, `CAN_LOCK_CLIPDATA` and
`HUGE_FILE_SUPPORT_ENABLED`.

**Format filtering.** Handle-based formats (`CF_BITMAP`,
`CF_ENHMETAFILE`, `CF_METAFILEPICT`, `CF_PALETTE`), private ranges,
local paths and shell items (`CF_HDROP`, `FileNameW`, `Shell IDList
Array`) and OLE storage formats are no longer advertised in either
direction. Images still go through as `CF_DIB`, which Windows
synthesizes.

**Request validation.** `ironrdp-client` treats a rejected clipboard
request as session-fatal, so the backend checks what it sends against
the rules `Cliprdr` enforces: file list indexes, range bounds, huge-file
positions, and released locks.

**Also fixed.** The window subclass state leaked on drop, and
`WM_DESTROY` freed it while `WM_NCDESTROY` could still use it.

## Viewer (`fix(viewer)`)

Without a backend factory, `ironrdp-client` created `WinClipboard` on
the RDP thread, which runs a tokio runtime and no Windows message loop,
so clipboard redirection never worked in the viewer (no clipboard
events, no backend wake-ups, no STA for OLE). The viewer now initializes
OLE and creates the clipboard, with file transfer, on its winit thread
and hands the factory to `RdpClient`.

## .NET FFI (`feat(ffi)`)

- `ActiveStage.SubmitClipboardMessage` hands any backend message to the
clipboard channel, file transfer included, and returns the frame to
send.
- `ActiveStage.DriveClipboardTimeouts` expires clipboard locks and file
transfers.
- `WinCliprdr.NewWithFileTransfer(bool)` opts in. `WinCliprdr.New()`
keeps file transfer off, so existing consumers that only route the three
original message types don't receive new ones.
- `WinCliprdr.NextClipboardMessageTimeout(ms)` lets a loop wake up to
drive the timeouts.
- The Avalonia example opts in, submits every message through
`SubmitClipboardMessage`, drives the timeouts, and logs a failed
clipboard operation instead of stopping clipboard handling.

Only the four affected generated files are included.

## Testing

- `cargo xtask check fmt`, `check lints` and `check locks` pass.
- 12 unit tests in `cliprdr_native::windows`: format filtering, file
list building, file contents serving, range sizing, descriptor
round-trips.
- 6 tests in `cliprdr_native::windows_live` run a `CliprdrClient` over
`WinClipboard` against an in-memory `CliprdrServer` on the real Windows
clipboard. They are opt-in with `IRONRDP_WIN_CLIPBOARD_LIVE=1`, because
they replace the clipboard and briefly open an Explorer window. All pass
locally:
- Explorer pastes remote folders and files, contents checked byte for
byte.
  - A 5 GiB remote file is read through OLE past 4 GiB.
  - Remote handle and path formats are not offered locally.
- Local folders reach the remote, both at connect time and when copied
mid-session.
  - Local image formats are filtered.
  - Virtual files from another session reach the remote.
- .NET: the solution builds and the smoke tests pass (9/9, one new).

- End to end with `ironrdp-viewer` against a Windows 11 server
(rdpclip): capabilities negotiated as `STREAM_FILECLIP_ENABLED |
FILECLIP_NO_FILE_PATHS | CAN_LOCK_CLIPDATA | HUGE_FILE_SUPPORT_ENABLED`.
A local folder (nested directories, an empty directory, an empty file, a
5 MiB random file) copied in Explorer was pasted into Explorer in the
session, served under rdpclip's lock. Copying it back in the session and
pasting it into a local Explorer window gave byte-identical files
(SHA-256).

Not verified by hand: ActiveX and the Avalonia example against a real
server.

## Notes for review

- This conflicts with #2175 in `MainWindow.axaml.cs` and the generated
`ActiveStage` files. The clipboard loop body here is a single
`SubmitClipboardMessage` call, so the merge only needs #2175's
`WithActiveStage(...)` wrapper around it; the generated files can be
regenerated.
- Running the extra test suite locally may need `CMAKE` pointed at
Visual Studio 2026's bundled CMake: `libopus_sys` fails with older CMake
versions that lack the "Visual Studio 18 2026" generator.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 08:47:03 -04:00
Marc-André Moreau c3dd17e607 fix(dvc): decompress the compressed data PDUs of DRDYNVC version 3 (#2173)
## Problem

`DrdynvcClient` echoes the server's capabilities version. When a server
offers version 3, the client therefore claims support for
DYNVC_DATA_FIRST_COMPRESSED (0x06) and DYNVC_DATA_COMPRESSED (0x07),
MS-RDPEDYC 2.2.3.3 and 2.2.3.4. It could not decode either:
`DrdynvcServerPdu::decode` had no arm for them. A server that used them
would break the DRDYNVC channel.

## Fix

This PR implements version 3 rather than answering with version 2. The
first commit downgraded the answer; the second replaces the downgrade
with real support.

- **`ironrdp-bulk`: new `rdp8` module.** An RDP 8.0 bulk decompressor
(MS-RDPEGFX 3.1.9.1) that is `no_std` (alloc only) and has no
dependencies. It accepts `PACKET_COMPR_TYPE_RDP8` (0x04) and
`PACKET_COMPR_TYPE_RDP8_LITE` (0x06), the type DVC segments carry. It
has two profiles. `Rdp8Decompressor::new()` is the graphics profile: a
2.5 MB history, 64 MiB per segment and 256 MiB per multipart message,
matching the existing decoder. `Rdp8Decompressor::new_lite()` is the RDP
8.0 Lite profile defined in MS-RDPEDYC 2.2.3.3: an 8,192-byte history
and maximum match distance, at most 8,192 uncompressed bytes per
segment, and a single segment per message. The existing ZGFX decoder in
`ironrdp-graphics` couldn't be reused: it needs `std` and `num-derive`
(a proc-macro), which core-tier `ironrdp-dvc` cannot depend on, and it
rejects 0x06.
- **`ironrdp-dvc`: decode and reassemble.** New `DataFirstCompressedPdu`
and `DataCompressedPdu` types, added to the `#[non_exhaustive]`
`DrdynvcDataPdu`, decode on both the client and server side.
`CompleteData` decompresses each block before reassembly, so one message
can mix compressed and uncompressed blocks (MS-RDPEDYC 2.2.3). Each
channel gets its own RDP 8.0 Lite decompression context (MS-RDPEDYC
3.1.5.2.5), created on the channel's first compressed block. A block
that makes a message longer than its declared `Length` is now an error
for both compressed and uncompressed data; before, the uncompressed path
logged it and dropped the message. The `DataFirstCompressedPdu` and
`DataCompressedPdu` constructors document the Lite payload format, so
the graphics pipeline's RDP 8.0 output is not mistaken for a valid
payload.
- **Client capabilities.** A version 3 offer is answered with version 3
again. `DrdynvcServer` still offers version 2 and now tolerates
compressed data from clients.

## Tests

- **Spec samples:** the MS-RDPEDYC 4.3.3 and 4.3.4 sample PDUs decode
and encode byte for byte (`dvc::data_compressed`). The client
reassembles them into one message (`dvc::client`). The spec's samples
decompress to 3,192 bytes while declaring 3,195, so the test supplies
the last 3 bytes in an uncompressed DYNVC_DATA block.
- **Per-channel history:** a test checks that one channel's compressed
data cannot refer back to another channel's history.
- **Length overruns:** tests check that a compressed first block, or a
later uncompressed block, that runs past the declared `Length` is an
error.
- **Lite limits:** `ironrdp-bulk` unit tests check that the Lite profile
rejects a match distance of 8,193 (accepted by RDP 8.0), keeps exactly
the last 8,192 bytes of history, caps segments at 8,192 bytes, and
rejects multipart messages.
- **Against the EGFX decoder:**
`bulk::rdp8_decodes_windows_egfx_captures` decodes the Windows ZGFX
captures already in `ironrdp-graphics` and gets identical output.
`bulk::rdp8_decodes_ironrdp_compressor_output` round-trips IronRDP's
ZGFX compressor output, including multipart messages.
- **Fuzzing:** a new `bulk_rdp8` fuzz target and `bulk_decompress_rdp8`
oracle require that any input the graphics decoder accepts decodes
identically with the new decompressor's RDP 8.0 profile. The same input
also runs through the Lite profile. Regression seeds are under
`test_data/fuzz_regression/bulk_decompress_rdp8`. A local run of 300,000
mutated captures and spec samples found no disagreement.
- **Unit tests:** `ironrdp-bulk` unit tests cover literals, matches, raw
byte runs, RDP 8.0 Lite, multipart messages, history carried across
messages, and malformed input.

## Checks

- **Tests:** `cargo test -p ironrdp-testsuite-core -p ironrdp-bulk`
passes: 1897 and 154 tests.
- **Format:** `cargo xtask check fmt -v` passes.
- **Lints:** `cargo clippy -D warnings` is clean on `ironrdp-bulk`,
`ironrdp-dvc`, `ironrdp-testsuite-core` and `ironrdp-fuzzing` (all
targets), and on the `no_std` builds of `ironrdp-bulk` and
`ironrdp-dvc`. `fuzz/` builds with the new target. The workspace-wide
`cargo xtask check lints` could not finish locally because the
`libopus_sys` build script fails on this machine.

## Not verified / follow-up

- **Live server:** not tested against a live Windows server sending
compressed DVC data.
- **Duplicate decoder:** EGFX still uses its own decoder in
`ironrdp-graphics`. Moving it onto `ironrdp_bulk::rdp8` would remove the
duplication, but it is a performance-sensitive path and should come with
benchmarks in a separate change.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 22:54:58 -04:00
Marc-André Moreau b735d190dd feat(ffi): redirect smartcards through WinSCard on Windows (#2175)
## Problem

`ClientConnector.WithStaticChannelRdpdr` in the .NET FFI announces a
smartcard device backed by `NoopRdpdrBackend`. That backend's
`handle_scard_call` returned no messages, so the client never completed
any MS-RDPESC IOCTL the server sent (EstablishContext, ListReaders,
GetStatusChange, ...). Server-side WinSCard calls in the session hung,
which can stall logon and UAC prompts that check for readers.
`ironrdp-client` attaches the same backend when RDPDR is enabled with no
native backend.

## Fix

**The noop backend answers every smartcard call.** It replies with the
return structure the server expects for that IOCTL, with `ReturnCode =
SCARD_E_NO_SERVICE` and `IoStatus = STATUS_SUCCESS`, as MS-RDPESC 3.1.4
requires for smart card errors. Shared helpers in `ironrdp-rdpdr` build
these replies, and the Windows backend now uses them too:

- `ScardCall::error_response` builds the completion for a failed call.
An IOCTL with no known return structure gets `STATUS_UNSUCCESSFUL` and
no output, as in FreeRDP; this path is unreachable today.
- `esc::complete_call` replies `STATUS_BUFFER_TOO_SMALL` when the
structure does not fit the server's output buffer, so the server retries
with a larger one (3.2.5.2).
- Error returns zero every field besides `ReturnCode` (2.2.3): empty
context and handle (`ScardContext::empty`, `ScardHandle::empty`), NULL
buffers, and no reader states (kept on `SCARD_E_TIMEOUT`, as FreeRDP
does). This also fixes failure replies in the Windows backend (Connect,
Transmit, Reconnect, GetTransmitCount, GetDeviceTypeId).

**Real WinSCard redirection in the FFI on Windows.**
`WithStaticChannelRdpdr` now backs the smartcard with the WinSCard
passthrough from `ironrdp-rdpdr-native`, the same backend the viewer and
ActiveX use. Other platforms keep the noop backend.

The native backend runs blocking calls (GetStatusChange, Connect,
Transmit, ...) on worker threads, and their completions only reach the
server through `Rdpdr::poll_deferred_messages`. So:

- `ActiveStage.Process` sends deferred RDPDR completions after each
frame, as `ironrdp-client` does, except after `DeactivateAll` or
`Terminate`.
- New `ActiveStage.PollRdpdrDeferred()` returns them while the server is
idle. Hosts should call it about every 50 ms, serialized with their
other `ActiveStage` calls.
- The Avalonia example polls every 50 ms from its read loop, and starts
the next read only after the current frame's outputs are handled, so
reactivation reads are not raced.

The existing .NET API is unchanged; `PollRdpdrDeferred` is an addition.
The regenerated bindings only add the new method and doc comments.

## Related PRs

This PR builds on #2161 and #2162, both now merged into master:

- #2161 makes `Framed.Write` safe for concurrent writers, which the
example's 50 ms poll relies on.
- #2162 locks every `ActiveStage` call in the Avalonia example. This PR
only adds the RDPDR poll, the read-ordering fix and a null guard in
`SendFastpath` on top of it.

## Testing

- Testsuite tests send an EstablishContext IOCTL through `Rdpdr` with
the noop backend, cover the `STATUS_BUFFER_TOO_SMALL` and no-structure
paths, and check that error replies for eight call types are all zero
after `ReturnCode`.
- `cargo test` passes for `ironrdp-rdpdr`, `ironrdp-rdpdr-native` and
the testsuite's rdpdr tests.
- `cargo xtask check fmt`, `cargo xtask check locks`, `cargo xtask ffi
build` and `cargo xtask ffi bindings` (which builds the .NET library)
pass, and the Avalonia example builds.
- Clippy with `-D warnings` is clean on `ironrdp-rdpdr`,
`ironrdp-rdpdr-native`, `ironrdp-testsuite-core` and `ffi`. The full
`cargo xtask check lints` could not run locally because the
`libopus_sys` CMake build fails on that machine.

Not tested: a live session with a reader and card, and building the FFI
for non-Windows targets (left to CI).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 22:49:12 -04:00
Benoît Cortier baa9a65d6c ci(pr-automation): add conditional specialist reviewers (#2188)
Add five optional specialists to the review pipeline, one per newly
adopted review skill, triggered as the `code-review` skill prescribes:

- `intent-drift` (`intent-drift-audit` and `intent-files`): runs when a
changed path is governed by an intent file on `master` or added by the
PR, following the `intent-files` placement rule.
- `intent-review` (`intent-review`, `intent-files`, and its pitfalls
reference): runs when an `INTENT*.md` or `*.intent*.md` is added or
modified.
- `test` (`test-reviewer`, `test-writer` with its references, and
`test-oracle-reviewer`): runs when a changed, non-removed Rust or C#
file is on a test path, or when its content at the PR's merge base or
head contains a test marker. A marker in the added lines decides without
reading either revision. Markers are matched over the whole text, so
multiline attributes work, and include `#[cfg(...)]` predicates naming
`test` other than as `not(test)`. A predicate scan stops at 4 KiB, and
an unclosed one counts as a marker. A production-only edit in a file
that also holds tests selects `test`; that is the accepted cost of not
locating edits inside tests. An unresolvable merge base, an unfetchable
head, or an unreadable file also selects `test`.
- `dependency` (`dependency-reviewer`, `dependency-pruner`, and the
repo-local `public-dependency`): runs when `Cargo.toml`, `Cargo.lock`,
`package.json`, `package-lock.json`, or a `.csproj` gains lines.
- `rust-style` (`rust-style-reviewer`, `rust-style`, and the trusted
`STYLE.md`): runs when a `.rs` file gains lines.

Deterministic analysis derives these at classification time from the PR
file list and patches, plus `git ls-files` on the trusted `master`
checkout to find intent files. Renamed files match path rules under both
their old and new names. The result is persisted in the existing `AI
classification` check state. The classifier schema and the check-state
version are unchanged, so earlier three-reviewer checks stay valid.
`protocol` and `skeptical` remain the only required reviewers; a failed
optional specialist is disclosed as reduced coverage.

The new canonical order is `protocol`, `skeptical`, `intent-drift`,
`intent-review`, `test`, `dependency`, `code-compressor`, `rust-style`.
Required and correctness reviewers start first when more than three are
selected.

Not added: `contract-review`, because the repository has no
`CONTRACT*.md` yet. It joins with the first contract (one agent JSON,
one prompt, one path rule). `test-oracle-reviewer` is not a separate
specialist because `test` runs it.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-21 22:22:24 -04:00
Marc-André Moreau 1de38a2ee5 feat: drive redirection for the viewer, .rdp files and Windows hotplug (#2178)
Drive redirection used to be reachable only through ActiveX and the
daemon's fixed volume list. This makes it usable from the viewer and
from standard `.rdp` files, and adds automatic drive hotplug on Windows.

## Changes

- **`ironrdp-cfg`**: `DriveRedirection` parses `drivestoredirect` with
mstsc semantics (`*` = every drive including later ones,
`DynamicDrives`, `C:\;E:\`). A nonempty `drivestoredirect` wins;
otherwise `redirectdrives:i:1` selects every drive, as in FreeRDP. New
`PropertySetExt` accessors for both keys plus `drive_redirection()`.
- **`ironrdp-client`**: `RdpdrConfig::drives` and
`ConfigBuilder::with_drive_redirection`, filled from the property set.
The client only carries the selection; frontends build the native
factory.
- **`ironrdp-rdpdr-native`** (Windows):
- A redirected root may now be a directory on a volume
(`C:\Users\name`), not only `C:\`. Paths with `..`, `\?\`/device/UNC
prefixes, `:` or NUL are rejected, and the root is still opened with
`OBJ_DONT_REPARSE`.
- `WindowsRdpdrBackendFactory::with_logical_drives` registers drive
letters as device IDs 1–26 and announces the selected letters present
when each connection (including reconnects) starts.
- `LogicalDriveWatcher` watches `WM_DEVICECHANGE` on a hidden top-level
window, plus a 2 s `GetLogicalDrives` poll for network drives, which are
not broadcast. It reports arrivals and removals; arrivals are added to
the shared selection.
- **`ironrdp-viewer`**: `--drive NAME,PATH`, `--drives`, `--home-drive`,
`--dynamic-drives`; honors the `.rdp` keys; attaches the RDPDR backend
whenever any drive, smartcard or printer redirection is requested;
forwards watcher changes as `AddRdpdrDrive` / `RemoveRdpdrDrive`.
- **`ironrdp-daemon`**: honors `drivestoredirect` / `redirectdrives` on
connect (an explicit `ironrdp_rdpdr:i:0` disables them) and keeps a
watcher for the session's lifetime. Configured daemon volumes now use
device IDs from 27, so they cannot collide with drive letters.

## Testing

- `cargo xtask check fmt -v` and `cargo xtask check lints -v` pass.
- New tests: `.rdp` parsing and precedence
(`testsuite-core/tests/cfg.rs`), viewer CLI and `.rdp` mapping
(`testsuite-extra/tests/client/config.rs`), root path validation,
logical-drive factory, daemon factory.
- Opt-in `watcher_reports_subst_drive_arrival_and_removal` (`--ignored`)
maps a free letter with `subst` and passes locally: arrival and removal
are both reported.
- Not done: a live session against a server, and a physical USB stick.
- `e2e::egfx_moves_onto_the_udp_tunnel_with_soft_sync` timed out once
under a parallel run and passed 3/3 alone; it is unrelated to this
change.

## Merge note

This overlaps the printer redirection PR #2177 in `ironrdp-rdpdr-native`
(`factory.rs`, exports, README), `ironrdp-client` config, and the
viewer's `cli.rs` / `main.rs`. Whichever lands second needs a rebase.
The device ID layout is: 0 smartcard, 1–26 drive letters, 27+ named
drives, printers from `u32::MAX - 1` down.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 21:33:06 -04:00
Marc-André Moreau 75ee516f34 ci(agent): make the agentic RDP scenario prove what it rendered (#2189)
## Summary

The manually dispatched **Agentic RDP** workflow passed, but its
screenshot showed Edge's first-run welcome dialog instead of the
requested page. The scenario also hid two weaknesses:

- **Daemon readiness probe never waited.** A failing native command does
not throw in PowerShell, so the `try/catch` loop in
`Start-AgentDaemon.ps1` returned on its first attempt and logged a
`connect to daemon ... os error 2` backtrace. It now checks
`$LASTEXITCODE`, discards the expected stderr, and fails fast if the
daemon process exits.
- **Agent input failures were ignored.** `Invoke-Agent` in the desktop
scenario now throws on a non-zero exit code, matching
`Invoke-AgentRdpdrRegression.ps1`.

The desktop scenario now proves what it rendered:

- Sets the Edge `HideFirstRunExperience` policy for the scenario and
restores the previous value afterwards.
- Opens a solid-color `data:` marker page in a maximized Edge window.
- Polls screenshots for up to 45 s and fails unless the center pixel
matches the marker color.

The PR also bumps `Swatinem/rust-cache` from v2.7.3 to v2.9.1 to match
the other workflows, which removes the Node 20 deprecation warning.

## Verification

- [Run
39642171433](https://github.com/Devolutions/IronRDP/actions/runs/39642171433)
and [run
39647100713](https://github.com/Devolutions/IronRDP/actions/runs/39647100713)
on this branch both passed.
- In both runs, the screenshot shows the blue "IronRDP agentic RDP"
marker page, and the typed command is visible in the address bar.
- The log no longer contains the daemon probe error or the cache
warnings.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 21:26:39 -04:00
Marc-André Moreau 850839f475 feat(rdpdr)!: redirect serial and parallel ports (MS-RDPESP) (#2187)
Adds serial (COM) and parallel (LPT) port redirection ([MS-RDPESP]) over
RDPDR, with a Windows backend, and wires it into the viewer, `.rdp`
files, the agent daemon and ActiveX. The behavior follows mstsc
(mstscax.dll 10.0.26100.9444) except where noted below.

## Protocol (`ironrdp-rdpdr`, core tier, no I/O)
- `PORT_CAPS_SET` (`CapabilityMessage::new_port`,
`Capabilities::add_port`, `CoreCapability::supports_port`).
- Serial/parallel device announces (`Devices::add_port`): the DOS name
goes in `PreferredDosName`, and there is no device data. They match the
MS-RDPESP 4.1 annotations byte for byte.
- `Rdpdr::with_port(RdpdrPort)`. Ports are only announced when the
server advertises the port capability, at the same points as mstsc:
- Serial ports are announced at Client ID Confirm, after the smart
cards, in a Device List Announce of their own.
  - Parallel ports go in the post-logon batch with drives and printers.
- When Windows sends Client ID Confirm before its capability request (it
does this when it re-announces the channel for an existing session),
serial ports are announced at User Logged On instead.
- New `pdu::esp` module:
- `PortIoCtlCode` with the MS-RDPESP IOCTL table, and `check_buffers`,
which applies the same buffer checks mstsc makes before touching the
device.
- `PortIoRequest` for create, close, read, write, flush and device
control.
- Only the `ntddser.h` buffers those checks need (`SerialTimeouts`,
`SerialQueueSize`, `SerialStatus`). IOCTL buffers are otherwise opaque,
because the Windows backend forwards them unchanged; typed buffers can
be added with the first client that interprets them.
- Port IRPs go to the new `RdpdrBackend::handle_port_io_request`, which
completes them with `STATUS_NOT_SUPPORTED` by default. The processor
completes, rather than ignoring, major functions that MS-RDPESP does not
describe (`STATUS_NOT_SUPPORTED`) and device controls whose
InputBufferLength is longer than the PDU (`STATUS_INVALID_PARAMETER`).
mstsc sends no completion at all in that second case.
- `DeviceControlResponse::with_raw_output` carries output produced by a
driver.
- **Early IRPs:** port IRPs use #2191's `device_is_announced`, so a
Create or DeviceControl that Windows sends before the announcement
response is served instead of dropped.
`handle_server_device_announce_response` is where a backend learns of a
rejection, and the Windows backend releases the files and pending
requests the server opened before rejecting the port, because the
processor ignores the rejected port's closes.

## Windows backend (`ironrdp-rdpdr-native`)
- **Selection:**
`WindowsRdpdrBackendFactory::with_port_redirection(WindowsPortRedirection)`
selects all, named or no ports of each kind. Ports are enumerated when
each product is built. Like mstsc, only `COM<n>` serial and `LPT<n>`
parallel ports can be named, so a name cannot hand another kind of
device to the server.
- **Opening:**
- Every server create opens its own local handle (`NtCreateFile`,
asynchronous) with the server's DesiredAccess, its ShareAccess without
`FILE_SHARE_DELETE`, and its disposition. `FILE_SUPERSEDE` and
`FILE_OVERWRITE` are rejected with `STATUS_INVALID_PARAMETER`.
- A second open of an exclusive port therefore fails as it would
locally.
- A newly opened serial port gets its default configuration
(`GetDefaultCommConfigW`) and mstsc's timeouts: ReadIntervalTimeout 200
ms, ReadTotalTimeoutConstant 5 s, WriteTotalTimeoutConstant 60 s,
multipliers unchanged. This is skipped when the default configuration
cannot be read. Parallel ports are opened as-is.
- **I/O:**
- Reads, writes and IOCTLs are sent to the driver unchanged
(`NtReadFile` / `NtWriteFile` / `NtDeviceIoControlFile`), after the
`check_buffers` checks.
- The driver's NTSTATUS and `Information` are returned as-is, as
MS-RDPESP Appendix A describes. Errors carry no data; warnings such as
`STATUS_BUFFER_OVERFLOW` keep partial output.
- A `WAIT_ON_MASK` completion always carries its 4-byte mask, as in
mstsc.
- Reads and IOCTL output buffers are capped at 64 KiB, which partial
reads allow.
- **Pending requests:**
- Requests the driver pends (reads, `IOCTL_SERIAL_WAIT_ON_MASK`)
complete through `poll_deferred_messages`.
- Each pending request has a worker thread with a 64 KiB stack that
waits on the request's event. Workers acquire the host's
`RdpdrWorkerThreadHooks` (ActiveX module lifetime). They hand the
finished request back to the session, which keeps the request allocated
until it retires the pending entry.
- `IRP_MJ_CLOSE` cancels the file's pending requests
(`NtCancelIoFileEx`) without blocking the channel thread. Their real
completions, then the close completion, follow through
`poll_deferred_messages`.
- A request the driver hasn't completed 2 s after cancellation is
reported as cancelled and left to its worker. A new initialization
sequence abandons pending requests without waiting.
- A flush completes once the file's earlier writes have finished.
Deferred flushes count toward the pending-request limit.

## Wiring
- `.rdp`: `redirectcomports` (`ironrdp-cfg` accessors) maps to the new
`RdpdrConfig::ports` / `ConfigBuilder::with_ports`.
- Client: `build_rdpdr_channel` announces the product's ports, honours
the RD Gateway `HTTP_TUNNEL_REDIR_DISABLE_PORT` policy, and rejects
device ID collisions.
- Viewer: `--serial PORT` / `--parallel PORT` (repeatable, or `all`),
like FreeRDP's `/serial:COM1` and `/parallel:LPT1`. Without them,
`redirectcomports:i:1` redirects every port unless `ironrdp_rdpdr:i:0`.
- Daemon/agent: a connect-time `redirectcomports:i:1` redirects every
port.
- ActiveX: `RedirectPorts` is implemented instead of returning
`E_NOTIMPL`. It is persisted as `redirectcomports`, which is also
accepted by `ApplySettings` / `SetRdpProperty`.

**Breaking:** `RdpdrConfig` gains a public `ports` field, so code that
builds it with a struct literal has to set it.

## mstscax comparison
A sibling session decompiled mstscax.dll 10.0.26100.9444 with public
symbols (classes `W32DrCOM`, `W32DrLPT`, `W32DrPRT`). The notes are
behavioral only; no code or structure was copied.

**Confirmed and matched:**
- Announce: DOS name as PreferredDosName, DeviceDataLength 0.
- COM ports announced at Client ID Confirm in their own PDU; LPT ports
after logon. COM ports that missed that point are announced at User
Logged On.
- One local handle per server create, with the server's access, its
share mode without `FILE_SHARE_DELETE`, and its disposition.
`FILE_SUPERSEDE` / `FILE_OVERWRITE` are rejected.
- COM only: default comm configuration plus 200 ms / 5 s / 60 s timeouts
on open.
- Close answers with `STATUS_SUCCESS`; an unknown FileId fails.
- IOCTL pre-checks:
- `STATUS_BUFFER_TOO_SMALL` for short `SET_BAUD_RATE`, `SET_QUEUE_SIZE`,
`SET_TIMEOUTS` or `PURGE` input, and for short `WAIT_ON_MASK` or
`GET_COMMSTATUS` output.
  - `STATUS_INVALID_PARAMETER` for all-`MAXULONG` read timeouts.
  - A `WAIT_ON_MASK` completion always reports 4 output bytes.
- Ports that are themselves redirected (DOS target containing `RdpDr`,
as in a nested session) are skipped. Busy ports are still announced.
- Only `COM<n>` and `LPT<n>` names are redirected.
- `SpecialTypeDeviceCap`: mstsc sends the value from its static
capability template, 0, and does not count serial ports. It uses the
server's value only to cap the special-class devices it announces before
logon, and COM ports are not in that batch. This client likewise does
not count serial ports.

**Deliberate differences:**
- **Enumeration.** mstsc opens `COM1`..`COM32` and `LPT0`..`LPT9` to
test which exist (the limits come from `COMPortMax` / `LPTPortMax`).
This reads the DOS device list instead, so ports are not opened just to
enumerate them and there is no upper port number.
- **IOCTL forwarding.** mstsc translates most serial IOCTLs into Win32
comm calls (`SetCommState`, `WaitCommEvent`, ...). This forwards every
IOCTL to the driver, which is what those calls do underneath. MS-RDPESP
Appendix A allows both.
- **Status codes.** mstsc maps Win32 errors back to NTSTATUS with a
small table, and anything else, including `ERROR_OPERATION_ABORTED`,
becomes `STATUS_UNSUCCESSFUL`. Using the NT APIs returns the driver's
exact NTSTATUS instead.
- **`SpecialTypeDeviceCap`.** MS-RDPEFS 2.2.2.7.1 names serial ports as
special devices, but like mstsc this client does not count them,
although they are announced before logon. Windows Server 2025 accepts
that.
- **Close.** mstsc answers close at once and lets aborted I/O complete
afterwards with an error. This sends the cancelled requests'
completions, normally `STATUS_CANCELLED`, before the close completion,
as MS-RDPEFS 3.1.5.1 requires.

## Testing
- `cargo xtask check fmt`, `lints`, `tests` and `locks` pass.
- `ironrdp-testsuite-core`:
  - capability layout;
  - COM2/LPT1 announces against MS-RDPESP 4.1;
  - the MS-RDPESP 4.4 device-control and close exchanges, byte for byte;
  - announce timing, including Client ID Confirm before capabilities;
- IRP routing, including IRPs before the announcement response (served)
and after a rejection (ignored);
  - unsupported, malformed and oversized-input IRPs;
  - `check_buffers`;
  - round trips of the remaining serial buffers at driver sizes.
- `ironrdp-rdpdr-native`, with named pipes standing in for ports:
  - a pending read completed through `poll`, and a forwarded write;
  - a failed IOCTL with no output, and the 4-byte `WAIT_ON_MASK` output;
  - a request rejected by `check_buffers`;
- a pending read cancelled on close, with the close completing through
`poll`, and a completed but unpolled request keeping its real result on
close;
- reset abandoning pending requests without waiting, and a rejected
port's files and pending requests being released;
  - a second create on an exclusive device failing;
  - supersede/overwrite rejection;
  - the deferred-flush limit.
- Client, viewer, daemon and ActiveX tests for the configuration paths.
- **Live, against Windows Server 2025, via `ironrdp-agent`:** there is
no serial hardware or com0com on this machine, so a temporary per-logon
DOS link (`COM9` / `LPT3` pointing at a local named pipe) stood in for
the port.
- The server accepted the pre-logon `COM9` announce and the post-logon
`LPT3` announce. On the re-announced sequence, `COM9` was announced at
User Logged On.
- `echo ...>COM9` and `echo ...>LPT3` in `cmd` on the server arrived
locally byte for byte.
- A PowerShell `FileStream` on `//./COM9` read data sent by the client.
- After the local port disappeared, the server's next open failed with
the driver's `STATUS_OBJECT_NAME_NOT_FOUND`.
- **Not tested:** the serial-settings IOCTLs and the comm defaults
against a real serial driver, because `GetDefaultCommConfigW` fails for
a pipe.

[MS-RDPESP]:
https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpesp/

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 21:00:37 -04:00
Marc-André Moreau ed65759d4a feat(client): play video optimized remoting with geometry tracking (#2185)
## Summary

Adds MS-RDPEVOR video optimized remoting with MS-RDPEGT geometry
tracking to the client.

> Stacked on the camera redirection PR (it reuses
`DrdynvcClient::with_dynamic_channel_factory` and touches the same
client wiring). Merge that one first; this PR then retargets to
`master`.

- **`ironrdp-rdpegt`** (new, `no_std`): `MAPPED_GEOMETRY_PACKET` codec
with RGNDATA regions, and `GeometryClient`, which tracks the mappings
and notifies an observer.
- **`ironrdp-rdpevor`** (new): TSMM PDU codecs, `VideoControlClient` /
`VideoDataClient`, and a sans-I/O `VideoPresenter` that:
  - answers Start Presentation only once it has a decoder;
- reassembles fragmented samples and decodes them through the existing
`ironrdp_egfx::decode::H264Decoder` trait;
  - schedules pictures from their timestamps against an injected clock;
  - scales and clips them to the mapped geometry;
  - asks for a key frame after loss or a decode failure.
- **`ironrdp-egfx-native`** (new): `MediaFoundationH264Decoder`, an
`H264Decoder` backed by the H.264 decoder MFT shipped with Windows. It
runs in low-latency mode, follows format changes, and converts NV12 with
BT.601 limited or BT.709 full range.
- **`ironrdp-session`**: `ActiveStage::composite_rgba32`, which
composites externally rendered pixels and records their damage.
- **`ironrdp-client`**
  - `video` feature (in `all`) and an `openh264` feature.
- The default decoder is Media Foundation on Windows, or OpenH264 with
`openh264`. With no decoder the channels are still declined.
  - A presentation timer and a compositing step in the session loop.
- A new `ironrdp_egfx:i:<0|1>` property. Windows closes the video
channels unless the graphics pipeline is on.
- **`ironrdp-viewer`** / **`ironrdp`**: `openh264`, `client-video`,
`client-openh264` features.
- **`ironrdp-daemon`**: built with `video`, so `ironrdp-agent` can play
RDPEVOR video.

## Verification

- **Live, Windows Server 2025 through `ironrdp-agent`** (`--prop
ironrdp_egfx:i:1`):
  - YouTube in Edge streamed as a 672x448 RDPEVOR presentation.
- 3,035 pictures were presented (86 dropped catching up), placed at the
RDPEGT mapping; the session screenshot shows the video in place.
- Without the graphics pipeline the server closes the video channels.
Geometry and video channels are reopened during the session, which the
factory registration handles.
- **Tests**: `ironrdp-testsuite-core` covers the MS-RDPEVOR and
MS-RDPEGT specification examples, malformed input, reassembly, timing,
loss and key-frame requests, and scaling and clipping.
- The real H.264 sample from MS-RDPEVOR 4.3 decodes through OpenH264
(`openh264-bundled`) and through Media Foundation (Windows), and lands
at the MS-RDPEGT 4.1 rectangle.
  - The two decoders agree within a mean channel difference of 2.
- **Checks**: `cargo xtask check fmt -v`, `cargo xtask check lints -v`
and `cargo xtask check locks -v` pass.
- **Known**: `e2e::egfx_moves_onto_the_udp_tunnel_with_soft_sync` fails
locally on `master` as well; it is unrelated to this change.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 20:27:44 -04:00
Marc-André Moreau 0f735b174a feat(client): redirect Windows cameras with Media Foundation (#2184)
## Summary

Closes the camera redirection gap with FreeRDP: local cameras can now be
redirected to Windows sessions over MS-RDPECAM.

- **`ironrdp-rdpecam`**
- Protocol version 2: property list, property value and set property
value, plus the version 2 error codes. Version 1 still works; device
messages carry the negotiated version through `DeviceMessage`.
- Sample Requests are answered asynchronously. The backend gets a
`SampleSink` and sends one response per request from its capture thread.
  - H.264 and MJPEG samples are accepted, with picture-start checks.
- All the channels Windows opens for one device share one backend and
one device state. Windows opens up to four `RDCamera_Device_N` channels
at once and spreads its requests across them. The lock is `spin`
(already in the dependency graph), so the crate stays `no_std`.
- **`ironrdp-rdpecam-native`** (new): Windows Media Foundation capture
backend.
  - Device enumeration with stable ids (symbolic links).
  - Native media types mapped to the RDPECAM formats.
- Compressed formats passed through. Raw-only cameras are encoded to
H.264 with the software encoder MFT.
  - Camera properties through `IAMCameraControl` / `IAMVideoProcAmp`.
- Camera arrival and removal through configuration manager
notifications.
- **`ironrdp-dvc`**: `DrdynvcClient::with_dynamic_channel_factory`, for
channels the server closes and reopens (the camera enumerator is
reopened after logon).
- **`ironrdp-client`**: `camera` feature, `CameraConfig` and the
`camerastoredirect` `.rdp` property (`*`, symbolic links or friendly
names, `-` to exclude), and camera hotplug in the session loop.
- **`ironrdp-viewer`**: `--camera` (repeatable) and `--camera-raw`.
- **`ironrdp-activex`**: the existing camera collection now drives
redirection. `Redirected`, `AddConfig`, `RedirectByDefault`,
`EncodeVideo` and `EncodingQuality` work instead of returning
`E_NOTIMPL`.
- **`ironrdp-daemon`**: built with `camera` on Windows, so
`ironrdp-agent` can redirect cameras.

Video optimized remoting is in a stacked follow-up PR.

## Verification

- **Live, Windows 11 Enterprise 26H2 (Hyper-V VM) through
`ironrdp-agent`**
  - The local webcam shows in the Camera app.
- The server negotiated version 2, read the camera properties, and
started a 1080p30 H.264 stream encoded by the Media Foundation encoder
MFT.
  - Closing the app deactivated the device and released the webcam.
- **Windows Server 2025**: the server never opens
`RDCamera_Device_Enumerator`, even with Server-Media-Foundation
installed, so it is not a usable test host.
- **Local, against the real webcam without a server**: enumeration,
media types, raw NV12 capture and H.264 encoding (SPS/PPS/IDR in the
first sample).
- **Tests**: `ironrdp-testsuite-core` has RDPECAM v1 and v2 wire
fixtures, async sample delivery, properties, compressed formats, and the
shared device across channels. `ironrdp-testsuite-extra` covers
`camerastoredirect` parsing; the ActiveX camera collection tests are
updated.
- **Checks**: `cargo xtask check fmt -v`, `cargo xtask check lints -v`
and `cargo xtask check locks -v` pass.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 18:32:47 -04:00
Benoît Cortier 00f9704cf8 ci(pr-automation): retry provider error events in streams (#2192)
Specialist reviews kept ending as "provider request failed", leaving
pull requests labeled automation-failed. The provider occasionally
reports a failure as an error event inside an HTTP 200 stream. The
OpenAI SDK raises that as an APIError without a status, which fell
through to the non-retryable default classification, so one transient
provider hiccup discarded the whole reviewer stage.

A status-less APIError is now a transient provider-response failure
retried within the existing request-retry budget, like a malformed
stream. An error event carrying a known quota code stays permanent.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 16:09:04 -04:00
Benoît Cortier f24ba3e3cd docs(agents): protect generated changelogs (#1746)
Restrict crate changelog updates to release-plz release PRs, where
release preparation can refine generated entries.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-21 16:06:58 -04:00
Marc-André Moreau 29fc63dae4 fix(rdpdr): serve IRPs for devices awaiting announcement response (#2191)
Windows can send the first IRP for a redirected device just before the
`ServerDeviceAnnounceResponse` that accepts it. `ironrdp-rdpdr` ignored
such IRPs without completing them, so the server waited about 30 seconds
and then retried.

This showed up in a live test of drive redirection (#2178) against a
Windows Server session, after a reconnect. The log shows the order:

```
DeviceIoRequest { device_id: 3, major_function: Create }
WARN Ignoring filesystem IRP before device announcement confirmation device_id=3
ServerDeviceAnnounceResponse { device_id: 3, result_code: STATUS_SUCCESS }   (same millisecond)
... 30 s later ...
DeviceIoRequest { device_id: 3, major_function: Create }
```

## Change

A device awaiting its announcement response now counts as announced, for
both filesystem and printer IRPs (`Rdpdr::device_is_announced`). FreeRDP
behaves the same way: it serves every registered device and only
unregisters one when the server rejects it.

- If the server later rejects the device, the existing rejection path
still removes the drive from the backend, which cancels its pending
IRPs.
- A printer `Create` before acceptance is completed with
`STATUS_UNSUCCESSFUL` in the channel and does not reach the backend. It
would start a native print job that a rejection could leave allocated,
because IRPs for rejected devices, including the close, are ignored.
Other early printer IRPs complete without allocating.
- IRPs for devices that were never announced, or were rejected, are
still ignored, as MS-RDPEFS recommends.

## Testing

- New `ironrdp-rdpdr` tests: a drive IRP before the response reaches the
backend; an early IRP followed by a rejection removes the drive. New
core testsuite tests: a printer IRP before the response is completed, an
early printer `Create` fails without reaching the backend, and a
`Create` after acceptance reaches it. All three fail without the fix.
- `cargo xtask check fmt -v` and `cargo xtask check lints -v` pass, as
do the tests in `ironrdp-rdpdr`, `ironrdp-rdpdr-native`,
`ironrdp-testsuite-core` and `ironrdp-testsuite-extra`.
- The live reconnect has not been rerun with this fix.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 15:39:24 -04:00
devolutionsbot e5c9eb21b5 chore(agents): sync shared skills (#2190)
Synchronizes configured shared skills from their upstream repositories.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-10-21 15:17:54 -04:00
Benoît Cortier d1d8e4fd13 chore(agents): adopt shared Rust style and test skills (#2131)
AGENTS.md now holds only policy that no tool enforces and that an agent
would not find on its own path. The first pass dropped content
discoverable from the tree or covered by a skill or `STYLE.md`: the role
preamble, the generic workflow, file and directory listings, xtask
command lists, the copy of the style rules, and a stale list of crates
missing from `ARCHITECTURE.md`. A review pass then moved rules to where
they trigger. Comment wrapping and test-module placement went to
`rust-style`. The dependency policies went to `public-dependency`. The
`iron-remote-desktop` base-API rule went to nested `AGENTS.md` files
next to its TypeScript and Rust definitions. It dropped rules already
stated by `ARCHITECTURE.md`, `protocol-reviewer`, or root `Cargo.toml`
comments. It also added a pointer to the testsuite crates and a warning
that synced skills are overwritten from Devolutions Gateway. The file
goes from 155 to 35 lines.

`STYLE.md` now extends the sentence-per-line rule to code comments and
doc comments. Devolutions Gateway and picky-rs vendor this file and will
re-sync it.

New skills, mirrored from Devolutions Gateway and added to the weekly
sync list:

- `rust-style`: everyday Rust rules from `STYLE.md`.
- `rust-style-reviewer`: fresh-context style review of changed Rust
lines, now run by `code-review`.
- `test-oracle-reviewer`: checks that a test's expected value is
independent of the code under test.
- `test-pruner`: prunes and strengthens tests with oracle classification
and cargo-mutants evidence.

The sync list also gains the remaining generic Devolutions Gateway
skills. `tdd` and its closure (`grill-intent`, `intent-files`,
`variants`) are dependencies of the synced `test-writer`,
`test-reviewer`, and `test-pruner`. The `contribute` flow brings `lead`,
`orchestrate-effort`, `review-feedback-loop`, `blind-testsuite`,
`contract-review`, `dependency-pruner`, `dependency-reviewer`,
`intent-drift-audit`, and `intent-review`. Intent and skill authoring
brings `agents-md`, `agents-md-review`, `contract-authoring`, and
`skill-discipline`. `code-review` now runs `intent-drift-audit`,
`intent-review`, `contract-review`, `test-reviewer`, and
`dependency-reviewer` when their conditions apply.

Claude Code discovers project skills only under `.claude/skills` and
reads only `CLAUDE.md`, so `.claude/skills` links to `.agents/skills`
and `CLAUDE.md` links sit beside both nested `AGENTS.md` files, as the
root one already does.

`AGENTS.md` now tells agents to start a work session with `/contribute`,
which picks the delivery flow by scale and the skills each step needs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-21 14:47:46 -04:00
Marc-André Moreau bf5d4a47a3 build(release): make all new crates publishable (#2180)
Several crates added since the last release were marked `publish =
false` or lack release metadata, so `cargo publish` cannot release them
or the crates that depend on them, including `ironrdp-agent`,
`ironrdp-viewer`, `ironrdp-client`, and `ironrdp-server`.

This makes all new crates publishable, except internal tooling and
`ironrdp-activex`, `ironrdp-rdpecam`, and `ironrdp-capture-replay`,
which stay internal:

- Drop `publish = false` from `ironrdp-daemon`, `ironrdp-rpc`,
`ironrdp-rdpeai`, and `ironrdp-rdpeusb`. `ironrdp-client`,
`ironrdp-server`, and `ironrdp-rdpsnd-native` depend on
`ironrdp-rdpeai`, and `ironrdp-server` depends on `ironrdp-rdpeusb`;
Cargo rejects these even as optional dependencies.
- Set `rust-version = "1.94"` on the newly published crates that lacked
it.
- Give every not-yet-published crate a `CHANGELOG.md` that release-plz
can extend: the git-cliff header followed by an empty `## [Unreleased]`
section. release-plz keeps the header through that line and inserts the
generated release below it. Replace the placeholder `## [0.1.0] -
YYYY-MM-DD` heading in `ironrdp-rdpei`, which release-plz would
otherwise duplicate.
- Make READMEs suitable for crates.io by linking sibling crates through
docs.rs and no longer describing `ironrdp-rpc` as internal.
- Render the README as crate docs for `ironrdp-rpc`, `ironrdp-daemon`,
and `ironrdp-rdpeusb` without repeating its first sentence.
- Update `ARCHITECTURE.md`: drop the "not published" note on
`ironrdp-daemon` and add an `ironrdp-rpc` entry.

Crates.io Trusted Publishing cannot create new crates, which is why the
`Release crates` workflow currently fails on `ironrdp-rail`. A crates.io
owner must publish these manually once, in dependency order, after the
bumped versions of their already-published dependencies: `ironrdp-rail`,
`ironrdp-rdpei`, `ironrdp-rpc`, `ironrdp-rdpeai`, `ironrdp-rdpel`,
`ironrdp-rdpemt`, `ironrdp-rdpeudp`, `ironrdp-rdpeudp-tokio`,
`ironrdp-usb`, `ironrdp-rdpeusb`, `ironrdp-rdpewa`,
`ironrdp-rdpewa-native`, `ironrdp-vmconnect`, and `ironrdp-daemon`
(which needs the new `ironrdp-client` release first).

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Benoît CORTIER <git.divisible626@passmail.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-22 02:22:27 +09:00
Ki Hyun Park a8b4aaa814 fix(graphics): check Planar sizes before allocating (#2176)
The RDP6 bitmap stream (Planar) decoder grew its output buffer and, for
RLE streams, its reusable plane buffer to the caller's width × height
before reading the compressed body. A 3-byte body declared as 4096×4096
made it allocate 50,331,648 bytes for each buffer before failing.

The decoder now checks the body before growing either buffer. Encoding
ensures at least one segment per scan line and a segment decodes to at
most 47 values (MS-RDPEGDI 3.1.9.2.3, 2.2.2.5.1.2), so an RLE body
shorter than that minimum is rejected. The minimum is exact, so no valid
stream is refused. The output buffer is reserved only once the planes
have decoded.

The plane size is computed with checked multiplication and bounded so
that four planes fit in `usize`, which keeps every later size
computation from overflowing, on wasm32 included. These failures reuse
`BitmapDecodeError::InvalidUncompressedDataSize`, so the public error
type is unchanged.

Allocation now grows with the body: the plane buffer is at most 47 times
its length. The plane buffer is still kept for reuse across bitmaps, and
a valid bitmap of the same length leaves the same size behind.

Fixes #2093
2026-10-21 17:14:00 +00:00
Marcus Perryman 579979ead4 Improve Windows Arm release-binaries times by 10% (#2186)
## Summary

Github standard Arm runners have an unconfigured NVMe drive. To improve
build efficiency by 10% this change configures the drive on every run
with an ReFS partition and moves the build to that drive. The intended
benefit is moving build-tree and Cargo-cache I/O from the system volume
to unused local NVMe.

The change only impacts runs that use **`windows-11-arm` job**. 

**On `windows-11-arm`, the measured IronRDP job time (median) improved
by 50s (10.4%) from 481 to 431, including provisioning and cache
overhead.** The compilation time fell from 343 to 326 seconds.

This is a minimal change that touches just the one YML file. An
additional saving is possible by removing NASM install for this runner
as it is not used. I'll prep a separate PR for that.

## Scope and safety

To keep this behaviour durable even if the underlying VM image changes:
- Gate on `runner.os == 'Windows'`, `runner.arch == 'ARM64'`, and
`runner.environment == 'github-hosted'`, to allow the same improvement
if the runner label changes. Also blocks out custom Arm runners to avoid
damaging a custom setup. The step is skipped entirely on Windows x64,
Linux, macOS, and self-hosted runners.
- No-op if `D:` is already assigned. To null the impact if the base VM
image configuration takes this change.
- Initialize only eligible NVMe disk: RAW, zero partitions, online,
writable, non-boot/non-system, at least 50 GiB, and absent from the
partition inventory. Missing or ambiguous storage is a logged no-op.
- Require an ordinary workspace (not a link) and an ordinary Cargo home,
if it exists. Populated workspaces are supported: existing files are
copied before replacing the workspace path with a junction. Never clear
disks, resize partitions, or reformat existing volumes. Operational
errors fail visibly rather than silently continuing after partial
provisioning.
- Use `Format-Volume -DevDrive -FileSystem ReFS` with Windows defaults.
No antivirus exclusions, protection disabling, or filter/trust
overrides.

The workspace and Cargo home move behind junctions to `D:\workspace` and
`D:\cargo-home`; `TEMP`/`TMP` use `D:\build-temp`. `CARGO_HOME`
explicitly names its physical D: path so GNU tar can save and restore
the Rust cache correctly across the workspace junction. The running
Actions agent, `GITHUB_WORKSPACE`, `RUNNER_TEMP`, Rust toolchain, and
hosted tool cache are not reconfigured.

Move any files that might be populated in the workspace by a pre-job.
After copying succeeds the original directory is renamed as a backup and
the original path replaced by the junction.

## Measured wall-clock impact

The comparison below uses the **six `windows-11-arm` cold-cache agent
jobs**
(https://github.com/marcpems/IronRDP-ci-benchmark/actions/runs/39574497666/attempts/1),
with **three fresh jobs per storage variant**, measuring the
empty-workspace path before the populated-workspace extension:

| Runner label | Default median job | ReFS median job | Observed
reduction | Default / ReFS median compile |
|---|---:|---:|---:|---:|
| `windows-11-arm` | 481 s | 431 s | 50 s / 10.4% | 343 s / 326 s |

Job time is `completed_at - started_at`: it includes provisioning,
checkout, dependency installation, caching, compilation, packaging,
artifact upload, benchmark validation, and post-job cleanup. It excludes
queueing.

No timing tests have been done for a populated workspace.

## Verification

- All `windows-11-arm` cold verification jobs passed; all 400 MB Rust
caches were independently verified through GitHub's cache API.
- [Published-release compatibility
run](https://github.com/marcpems/IronRDP-ci-benchmark/actions/runs/39574562225):
both Windows x64 binaries passed with the new step skipped. The Arm
agent passed on both storage variants.
- Revalidated this PR's actual workflow with 22 non-destructive
storage-guard cases, PowerShell parsing, actionlint, and all 12
OS/architecture/hosting combinations.
- Structural YAML comparison: removing the added step reproduces current
upstream's workflow exactly. Empty-workspace relocation retains the
measured fast path; No benchmark tooling or test harness is added to
upstream.
- [Populated-workspace
validation](https://github.com/marcpems/IronRDP-ci-benchmark/actions/runs/39606041636):
both empty and populated workspaces passed on real ReFS volumes using
`windows-11-arm`, including hidden/system and read-only attributes,
nested and empty directories, file symlinks, directory junctions, backup
preservation, and subsequent checkout. Five local cases additionally
covered hidden-only contents, partial-copy failure, and
junction-creation failure; the original data remained available on
failures.

## Evidence and reuse

- [Detailed methodology, caveats, per-job results, cache inventory, and
guard
tests](https://github.com/marcpems/IronRDP-ci-benchmark/tree/baec7cf0a4798d45f35b552290905636c77b6979/benchmarks/refs-storage)
- [Reproducible fork-only benchmark
workflow](https://github.com/marcpems/IronRDP-ci-benchmark/blob/perf/windows-arm-refs-benchmark/.github/workflows/refs-benchmark.yml)

Co-authored-by: marcpems <20582938+marcpems@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-21 11:42:50 -04:00
irvingouj@Devolutions 5a088293c9 refactor(ffi): annotate Diplomat accessors (#2163)
The Diplomat version we are moving to no longer turns `get_*`/`set_*`
methods into C# properties from a config prefix. Each accessor needs its
own attribute, or the property silently disappears from the bindings.

Annotate every accessor that the current bindings expose as a property:
86 getters and 19 setters. The nine `&mut self` getters are left as
methods, because the new generator refuses getters that take `&mut
self`.

The pinned 0.7 macro strips `#[diplomat::attr]`, so this changes no
generated code.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 15:37:54 +00:00
irvingouj@Devolutions db0a45a03c fix(ffi): lock ActiveStage in the Avalonia example (#2162)
The example calls into `ActiveStage` and `DecodedImage` from the PDU
loop, the clipboard loop and the UI thread without any lock, so two
`&mut` borrows of the same native object can be live at once. The next
Diplomat runtime turns this into an "Another borrow is already active"
exception, which would end the session loop.

Take one lock around each native call on the stage or the image, through
a `WithStageLock` helper, and route the five input handlers through one
`SendFastpath` helper. The lock is never held across an `await` or a
dispatcher call, so it cannot deadlock with the UI thread.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 15:37:53 +00:00
irvingouj@Devolutions 549fc050dc fix(ffi): use an async lock for Framed writes (#2161)
`Framed.Write` held a `Mutex` across `await _stream.WriteAsync(...)`.
That broke in three ways:
- A `Mutex` must be released by the thread that took it. Without a
synchronization context, the code after the `await` can run on another
thread, so `ReleaseMutex` threw `ApplicationException`.
- A `Mutex` lets its owning thread enter again, so two writes started
from one thread were not serialized at all.
- `WaitOne` blocked the calling thread, such as the Avalonia UI thread,
while another thread held the lock.

Use a `SemaphoreSlim` with `WaitAsync`, which has no thread affinity, is
not re-entrant, and does not block a thread while it waits.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:05:12 -04:00
Marc-André Moreau 0784fceca8 feat(displaycontrol)!: multi-monitor layouts with orientation and DPI (#2182)
Display Control (MS-RDPEDISP) was only usable for a single primary
monitor at 100% device scale. This lets clients send complete monitor
layouts during the session, with real orientation and DPI, and wires it
into the viewer and the ActiveX control.

## Changes

**`ironrdp-displaycontrol`** (breaking)
- `DisplayControlMonitorLayout::new` now rejects overlapping monitors
and, for multi-monitor layouts, monitors not adjacent to another one
(MS-RDPEDISP 3.1.5.2). Layouts it previously accepted can now fail.
- `fit_to_capabilities` enforces the server's `MaxNumMonitors` and
maximum monitor area (MS-RDPEDISP 3.2.5.2): extra monitors are dropped
(the primary is kept), a single oversized monitor is scaled down keeping
its aspect ratio, and an oversized multi-monitor layout is rejected
rather than shrunk (which would move monitors relative to each other).
- `DisplayControlClient` stores the server capabilities and gains
`encode_monitor_layout`; `encode_single_primary_monitor` fits to the
capabilities too.
- `new_single_primary_monitor` clamps the desktop scale to 100..=500 and
derives the device scale (100/140/180) from it instead of hard-coding
100%; a square monitor is landscape.
- Helpers: capability getters, `area`, `desktop_size`,
`MonitorLayoutEntry::adjust_desktop_scale_factor`,
`DeviceScaleFactor::from_value` / `from_desktop_scale_factor`.

**`ironrdp-session`**: `ActiveStage::prepare_monitor_layout`,
`encode_monitor_layout`, `display_control_capabilities`.

**`ironrdp-client`** (breaking, new enum variant):
`RdpInputEvent::MonitorLayout` shares the resize queue. Without Display
Control it reconnects advertising the requested monitors in the GCC
Client Monitor Data block. A layout the server capabilities cannot
accept is logged and dropped instead of ending the session.

**Viewer**: handles `WindowEvent::ScaleFactorChanged` through the
debounced resize path, so the session follows the window DPI. The viewer
is a single window, so it still sends one primary monitor. The
RPC-backed path passes the window scale too (`Daemon::try_resize` takes
a scale; the daemon crate is unpublished).

**ActiveX**
- Multimonitor sessions no longer reject dynamic updates. Like mstsc,
they mirror the local monitors: `UpdateSessionDisplaySettings`,
`WM_DISPLAYCHANGE` and `WM_DPICHANGED` (debounced) send the full local
topology with each monitor's position, rotation and effective DPI.
Explicit scale arguments override every monitor;
width/height/orientation/physical size describe a single monitor and are
ignored in multimon.
- The sent topology becomes the configured one, keeping it consistent
with the GCC monitors advertised at connect time and confirmed by the
server's monitor layout.
- Single-monitor updates now accept rotation and 140%/180% device scale
(explicit layout). Values MS-RDPEDISP does not define return
`E_INVALIDARG` (was `E_NOTIMPL`).
- `active_multimon_layout_rejects_dynamic_display_updates` is replaced
by `active_multimon_layout_sends_full_display_control_layouts`.

## Testing
- New `ironrdp-testsuite-core` tests for overlap/adjacency validation,
capability fitting, scale clamping and client encoding; unit tests in
session, client and ActiveX.
- `cargo xtask check fmt -v` and `cargo xtask check lints -v` pass;
tests pass for every touched crate.
- Not tested against a live Windows server.

## Known limitations
- `WM_DISPLAYCHANGE` is only broadcast to top-level windows, so the
ActiveX control sees it only when its window is top-level.
- An odd local monitor width is rounded down, which can leave a 1-pixel
gap that fails the adjacency check; the update is then logged and
skipped.
- The `.rdp` keys `use multimon`, `selectedmonitors` and `dynamic
resolution` are not handled yet.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 07:05:34 -04:00
MuNeNiCK 860cf6ccb1 feat(web): support WebSocket subprotocols (#1970) 2026-10-21 07:36:37 +00:00
Marc-André Moreau 0f9154d212 fix(rdpdr): complete unsupported drive IRPs instead of failing (#2174)
## Problem

A well-formed drive I/O request that IronRDP does not implement was a
decode error in the RDPDR processor. That error goes through
`svc.process(...).map_err(SessionError::pdu)?` in `ironrdp-session`, so
the whole RDP session ended. The requests affected were:

- `IRP_MJ_SET_VOLUME_INFORMATION`: `ServerDriveIoRequest::decode`
returns `unsupported_value_err!`.
- Set information, query volume information and query directory requests
whose information class is not one of the classes the decoders accept.
- `IRP_MJ_DIRECTORY_CONTROL` with a minor function other than
QUERY_DIRECTORY or NOTIFY_CHANGE_DIRECTORY.

FreeRDP's drive channel completes these requests with an error status,
and the session continues.

## Fix

`Rdpdr` now checks filesystem IRPs before decoding them. When a request
is one of the unsupported kinds above, the processor completes it itself
with the request's DeviceId and CompletionId, and the backend never sees
it. Each reply has the layout the server expects for that request type:

| Request | IoStatus | Reply body |
| --- | --- | --- |
| Set volume information | `STATUS_NOT_SUPPORTED` | Length echoed back
(MS-RDPEFS 2.2.3.4.7 says it MUST match the request) |
| Set information, unsupported class | `STATUS_NOT_SUPPORTED` | Length
echoed back |
| Query volume information, unsupported class | `STATUS_NOT_SUPPORTED` |
Empty buffer |
| Query directory, unsupported class | `STATUS_NOT_SUPPORTED` | Empty
buffer and the 1-byte padding |
| Directory control, undescribed minor function | `STATUS_UNSUCCESSFUL`
| None |

The directory-control case follows MS-RDPEFS 3.1.5.2: a MajorFunction or
MinorFunction the protocol does not describe "SHOULD be completed" with
`STATUS_UNSUCCESSFUL`. FreeRDP uses `STATUS_NOT_SUPPORTED` there.

Truncated requests are still decode errors.

The lists of accepted information classes now live in crate-private
`is_valid_class` helpers, which the decoders and the new check share. No
public API changes.

Query information requests already accepted any class and passed it to
the backend, which answers with a status. The native backends already
reply `STATUS_NOT_SUPPORTED` for operations they do not implement.

## Tests

`ironrdp-testsuite-core` has six new tests in `tests/rdpdr/mod.rs`. Five
check the status, device and completion IDs, and reply layout for each
case in the table. The sixth checks that truncated requests still fail.

Ran `cargo xtask check fmt -v`, `cargo xtask check lints -v`, the
`ironrdp-rdpdr` and `ironrdp-rdpdr-native` tests, and the rdpdr tests in
`ironrdp-testsuite-core`. All pass.

## Not covered

Two more requests can still end the session the same way. They are left
for separate changes:

- A MajorFunction value the protocol does not define fails in
`DeviceIoRequest::decode`, before dispatch. MS-RDPEFS 3.1.5.2 asks for a
`STATUS_UNSUCCESSFUL` completion.
- Smartcard IRPs: a request that is not a device control is decoded as
one anyway, and an unknown smartcard IOCTL code is a decode error.
FreeRDP answers both with `STATUS_NOT_SUPPORTED`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 19:13:03 -04:00
irvingouj@Devolutions 3a3c27d3a8 fix(ffi): dispose CredSSP generator before reuse (#2160)
`ProcessTsRequest` returns a generator that holds an exclusive borrow of
the CredSSP sequence. The CredSSP loop left it alive and then called
`HandleProcessResult` on the same sequence, so two `&mut` borrows of it
were live at once.

Dispose the generator as soon as it has produced the client state.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-20 17:34:52 -04:00
irvingouj@Devolutions a1d824f0ea fix(ffi): stop panicking on larger output buffers (#2159)
`VecU8`, `BytesSlice` and `U32Slice` checked that the output buffer was
not too small, then called `copy_from_slice` on the whole buffer. Any
buffer larger than the data passed the check and panicked, which aborts
the host process across the FFI boundary. `WriteBuf.ReadIntoBuf` had no
check at all: a larger buffer panicked the same way, and a shorter one
silently got only the start of the data.

Copy into the front of the buffer, leave the rest untouched, and fail
when the buffer is too small. The four methods now share one
`fill_prefix` helper.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-20 17:34:51 -04:00
irvingouj@Devolutions 8aa19d03ef test: add .NET smoke tests for the FFI bindings (#2158)
The .NET bindings had no runtime test, only a compile check. Upcoming
Diplomat work changes how the generated wrappers hold native handles, so
a regression would only show up in a consumer app.

Add a small console test runner, in the same style as IronVNC's, that
exercises the bindings without a network: image data, byte buffers,
error mapping, PDU sizing, config validation, and the first X.224
exchange of the connector. Run it in the FFI CI job.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-20 17:34:51 -04:00
irvingouj@Devolutions aa237eb6a0 docs(ffi): define .NET binding intent (#2157)
The Diplomat version we are moving to makes `IDisposable` opt-in per
opaque type and rejects overlapping calls that mutate an object, so the
bindings need rules for disposal and concurrency.

Adopt the disposal rule IronVNC already follows: a type is `IDisposable`
only when it owns a large allocation the garbage collector cannot see, a
scarce or externally observable resource, or a borrowing view of a
disposable type. Also record that no opaque type with a lifetime touches
borrowed data when dropped, since .NET finalizers run in no
deterministic order. These two sections are a verbatim copy of IronVNC
`ffi/src/INTENT.md` at 5c3ea3d5.

Add a concurrency section: the generated code rejects only overlapping
calls that mutate an object, the hand-written layer locks fragile places
such as `Framed`, and otherwise a consumer makes one call at a time on
each native object.

The file sits in `ffi/` so it covers both the Rust bridge and the C#
layer under `ffi/dotnet/`. It states where the bindings are going, not
where they are: some of today's code does not follow it yet, and
follow-up changes bring that code in line.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-20 16:48:16 -04:00
Marc-André Moreau df977e1206 fix(ffi): invert no_audio_playback mapping in connector config (#2172)
`ConfigBuilder::build` in the FFI copied `no_audio_playback` straight
into `enable_audio_playback`, so setting "no audio playback" to true
enabled playback and false disabled it.

The mapping is now inverted (`!no_audio_playback.unwrap_or(false)`).
When the flag is set, `INFO_NOAUDIOPLAYBACK` is sent in the Client Info
PDU, asking the server not to play audio on the client. The default
(field unset) is unchanged: playback enabled.

The FFI currently exposes no setter for this field, so the bug was
latent; this fixes the mapping ahead of any setter being added. No unit
test: the `ffi` crate has no config-building test pattern.

Checks: `cargo xtask check fmt` and `cargo clippy -p ffi --all-targets
-- -D warnings` pass.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-20 16:24:15 -04:00
Marc-André Moreau 408b86ea91 feat(viewer): redirect the default Windows printer (#2156)
Windows default-printer redirection (#1876) was only reachable through
the ActiveX control's `RedirectPrinters` setting. This exposes it in
`ironrdp-viewer` and `ironrdp-daemon`.

## Changes

- **`ironrdp-cfg`:** add `redirect_printers` / `set_redirect_printers` /
`clear_redirect_printers` for the standard `redirectprinters` `.rdp`
property.
- **`ironrdp-viewer`:** add `--printer`. The Windows backend factory now
asks for the default printer (`with_default_printer`). A `.rdp` file's
`redirectprinters` property does not enable it, because mstsc writes
`redirectprinters:i:1` by default and would otherwise announce the local
printer for any stock file. The README documents the flag and the
matching-driver requirement.
- **`ironrdp-daemon`:** read `redirectprinters` on each connect and
build a printer-only factory on demand. An explicit `ironrdp_rdpdr:i:0`
overrides it. Non-Windows hosts log a warning and ignore the property.
- **`ironrdp-agent`:** add `redirectprinters` to the property help
table.
- **`ironrdp-client` (gateway fix):** honor
`HTTP_TUNNEL_REDIR_DISABLE_PRINTER` (MS-TSGU 2.2.5.3.7). The client
checked only the drive and clipboard flags, so a printer was announced
even when the RD Gateway disabled printer redirection.
`build_rdpdr_channel` now takes an `RdpdrDevicePolicy` for drives and
printers instead of a single drive bool. This also covers the existing
ActiveX path.

It uses the existing backend unchanged: the current default queue only,
RAW jobs, and the remote host needs a printer driver with the same name
as the local queue's driver. Multiple printers and Easy Print/XPS are
not part of this PR.

## Testing

- `cargo test -p ironrdp-client --lib`: new tests cover a printer-only
product under printer-restricted policy and the `disables_printer`
gateway flag.
- `cargo test -p ironrdp-daemon rdpdr`: new test for the printer-only
factory.
- `cargo test -p ironrdp-testsuite-extra --test integration_tests_extra
client::config`: new test that the viewer redirects only with
`--printer`, including when a stock file sets `redirectprinters:i:1`.
- `cargo xtask check fmt` and `cargo xtask check lints` pass locally on
Windows. `check typos` was not run locally.
- Not tested end to end against a server with a matching driver.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 15:30:08 -04:00