Commit Graph

2118 Commits

Author SHA1 Message Date
irvingouj@Devolutions 18ec4a045e refactor(ffi): mark the IDisposable bridge types (#2164)
The Diplomat version we are moving to makes `IDisposable` opt-in.
Without the attribute, a generated wrapper only has a finalizer.

Mark the types that `ffi/INTENT.md` says are disposable:
- operating-system resources: `ActiveStage`, whose DVC pipe proxies own
named-pipe worker threads, and `WinCliprdr`, which owns the clipboard
window
- large buffers the garbage collector cannot see:
`ActiveStageOutputIterator`, `VecU8`, `WriteBuf`, and the clipboard
payloads `ClipboardMessage`, `ClipboardSvcMessage`, `FormatDataResponse`
and `FfiFileContentsResponse`

`DvcPipeProxyMessage` stays unmarked: sending one moves its payload out,
so nothing large is left behind.

Also mark `CredsspProcessGenerator`. None of the three conditions names
it, but it holds `&mut` of its `CredsspSequence`, and the sequence
rejects every other call until the generator is released. Releasing it
costs nothing.

`DecodedImage`, `DecodedPointer` and `ActiveStageOutput` also qualify,
but they hand out borrows that outlive the call, which the new generator
refuses for disposable types; a later change returns owned data so they
can be marked too.

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-22 21:51:20 -04:00
AKT99! 8b4146a34c docs: add ClawTank to Who uses IronRDP (#2205)
ClawTank is an open-source (Apache-2.0) RDP server for macOS built on
ironrdp-server. It streams H.264 over EGFX (AVC420) from VideoToolbox
and creates virtual displays that follow the client's Display Control
resizes. It also uses RDPSND, CLIPRDR (including file contents), and NLA
via CredSSP.

Co-authored-by: Arun Kumar Thiagarajan <222980227+HMAKT99@users.noreply.github.com>
2026-10-23 01:23:24 +00:00
truebest e4a0d17b8e feat(egfx): support client-initiated protocol reset (#2207)
Expose `GraphicsPipelineClient::request_protocol_reset()` to rebuild
graphics state without reconnecting RDP or interrupting other virtual
channels.
For negotiated V10.3–V10.7, it re-advertises the confirmed capability
version and flags, clears surfaces and codec state, and ignores
in-flight graphics until the server confirms that version again.
Changed flags are accepted; a processing error while awaiting reset
confirmation closes the client and subsequent input is rejected until
the channel is recreated with a new processor.
The alternate `V10_6Err` value is echoed only if previously confirmed.

The ACK count restarts because Windows resets its sent-frame count and
rejects cumulative post-reset ACKs.
ZGFX history and the last output extent remain intact, while pending
pixels and bitmap caches are discarded.
The caller must send the returned PDU before processing more input and
recreate the channel if sending or reset confirmation fails.
Unsupported versions and an already pending reset return `None`.

This implements the client-side reset described in [MS-RDPEGFX section
3.3.5.19](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpegfx/a720af02-0a47-44e2-a934-dc8534062b44)
and complements the server support in #1833.

---------

Co-authored-by: truebest <truebest@users.noreply.github.com>
2026-10-23 00:54:40 +00:00
Marc-André Moreau 45b67591e9 feat!: compressed audio over AUDIO_PLAYBACK_DVC (#2203)
Windows 8 and later servers stream audio over the AUDIO_PLAYBACK_DVC and
AUDIO_PLAYBACK_LOSSY_DVC dynamic channels, preferring AAC or ADPCM on
constrained links, but IronRDP declined those channels and could only
play PCM and Opus. Wave Confirm PDUs echoed the server timestamp,
playback dropped audio when its fixed 500 ms ring filled, and devices
could not be chosen.

- `ironrdp-rdpsnd` gains a pure `codec` module (PCM, G.711 A-law and
µ-law, IMA and Microsoft ADPCM decoders and encoders, bit-exact with the
Windows ACM codecs), an `RdpsndDvc` processor whose `RdpsndDvcState`
lets both dynamic channels share one negotiation (Windows negotiates on
the reliable channel and sends AAC on the lossy one), the UDP Wave
datagrams, and a `playout` jitter-buffer policy. Wave Confirm PDUs
report the hold time plus the handler's playback latency, and handlers
pick the formats to advertise from the server's list.
- The CPAL backend decodes every offered format it can, including AAC
through Media Foundation on Windows, plays through the jitter buffer
with a configurable latency target, reports buffered plus device
latency, follows the default device or a selected one, and maps the
server volume to the Windows audio session. Microphone capture encodes
to PCM, G.711 or ADPCM and selects its device.
- `ironrdp-client` registers the dynamic channels next to the static one
on a shared backend and adds `AudioConfig` (`ironrdp_audiooutputdevice`,
`ironrdp_audioinputdevice`, `ironrdp_audiolatency`); the viewer adds
`--audio-output-device`, `--audio-input-device`, `--audio-latency` and
`--list-audio-devices`.

Breaking: `ironrdp_rdpsnd_native::cpal` no longer exposes
`DecodeStream`, `PcmProducer` and `apply_volume`; use `RdpsndBackend`
and `apply_gain`.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 20:47:45 -04:00
Marc-André Moreau 8575afc308 feat(rdpdr)!: redirect several printers with cached settings (#2177)
Printer redirection could announce only the Windows default queue. Every
printer reused the `PRN1` port name and the default flag,
`PAKID_PRN_CACHE_DATA` was dropped so server-side printing preferences
were lost on reconnect, and the viewer ignored the `.rdp`
`redirectprinters` property that the daemon honored.

- **`ironrdp-rdpdr`:** `Rdpdr::with_redirected_printer` announces an
`RdpdrPrinter` with its own `PRN<n>` port name, flags, and cached
configuration. Only the first default printer keeps the default flag
(MS-RDPEPC 2.2.2.1). `RdpdrBackendProduct` holds a list of printers and
an optional `RdpdrPrinterCacheStore`. Cache-data PDUs are decoded in the
new `pdu::epc` module, saved through the embedder's store, and replayed
as `CachedPrinterConfigData` on the next announcement. A driver from an
add event replaces the announced driver unless the user chose it.
Entries are keyed by the local queue name and record the name the server
gave the printer (a rename event, or a queue a user installed on the
redirected port), which the next announcement uses (MS-RDPEPC 3.2.5.1.3,
3.2.5.1.6); the local Windows queue is never renamed by the server. The
channel does no I/O. Malformed cache and `PAKID_PRN_USING_XPS` PDUs fail
the channel like other malformed RDPDR packets (MS-RDPEFS 3.1.5.2); a
valid `PAKID_PRN_USING_XPS` is ignored because XPSFORMAT is never
announced.
- **`ironrdp-rdpdr-native`:** `WindowsPrinterRedirection` selects the
default queue, every local queue and printer connection (`EnumPrintersW`
with `PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS`, like FreeRDP), or
named queues, with per-queue driver overrides. One worker serves all
printers and binds each job to its device. Jobs keep the `RAW` datatype
because the server sends device-ready PRN data (MS-RDPEPC 3.2.5.1.2); a
queue default such as `NT EMF 1.008` or `XPS_PASS` would make the print
processor reinterpret it. `FileRdpdrPrinterCacheStore` persists cache
entries; it reads each entry once and writes on a background thread, so
cache events do not block the RDPDR channel on disk I/O. The README
records what Easy Print would need.
- **`ironrdp-svc` / `ironrdp-session`:** chunked static-channel PDUs no
longer always carry `CHANNEL_FLAG_SHOW_PROTOCOL`. The flag now comes
only from the message or from a channel defined with
`CHANNEL_OPTION_SHOW_PROTOCOL`, as in FreeRDP. A live Windows 11 host
silently dropped every RDPDR device announcement larger than one
1600-byte chunk, so printers announced with cached settings were never
redirected. This departs from the MS-RDPBCGR 3.1.5.2.1 wording in favor
of observed Windows and FreeRDP behavior.
- **`ironrdp-client`:** `RdpdrConfig::printers` mirrors
`redirectprinters` and can drop a product's printers; it defaults to
true. The channel announces every printer and marks a lone printer as
the default.
- **`ironrdp-daemon`:** printer settings persist per server under
`%APPDATA%\ironrdp-agent\printer-cache` (or
`IRONRDP_AGENT_PRINTER_CACHE`).
- **`ironrdp-viewer`:** adds `--printer-all`, `--printer-queue
<queue>[,<driver>]`, and `--printer-default`. `redirectprinters:i:1` now
redirects the default printer unless `ironrdp_rdpdr:i:0` is set, as in
the daemon. mstsc writes that property by default, so stock `.rdp` files
now redirect the default printer and save its server-side settings in
the per-server cache folder; this is intended and should be called out
in the release notes.

There is no fallback driver: a Windows 11 host that lacks the announced
driver still accepts the announcement and creates no queue, so the
client cannot detect it. `--printer-queue <queue>,<driver>` picks a
driver the host has.

Easy Print (XPSFORMAT) is not implemented: it needs the MS-RDPEXPS
`TSVCTKT` and `XPSRD` channels, PrintTicket conversion on the client,
XPS mode, and local XPS printing.

The public API changes incompatibly: `RdpdrPrinter::new` no longer marks
the printer as the default, `RdpdrBackendProduct::with_printer` appends
instead of replacing, `Devices::add_printer*` return whether a `PRN<n>`
port name was left, and `RdpdrConfig` has a new public `printers` field.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 18:14:55 -04:00
Marcus Perryman da4d45a18b Skip unnecessary NASM installation for Windows Arm releases - unused for Arm targets (#2204)
## Summary

Skip the unnecessary NASM installation for native Windows Arm release
builds as its unused and saves around **40.25 seconds / 8.6% on mean job
time** .

Minimum change, two lines (including comment) to gate install only when
on Windows Arm targeting Windows Arm. NASM is an x86/x64 assembler.

## Measured impact 

[24-job
comparison](https://github.com/marcpems/IronRDP-ci-benchmark/actions/runs/39747378333),
using only `windows-11-arm`, pinned upstream `bf5d4a47` (including
#2186), cold isolated caches, and eight observations per variant:

| Variant | Successful agent builds | Mean complete job |
|---|---:|---:|
| With NASM | 8/8 | 469.0 s |
| Without NASM | 8/8 | 428.8 s |
| Without NASM, with a 30-second delay | 8/8 | 452.1 s |

The average reduction was **36 s / 7.8%** with no compilation or
cache-initialization penalty (verified).

[Full methodology, raw measurements, reproducible analysis, and
limitations](https://github.com/marcpems/IronRDP-ci-benchmark/blob/e959d48649bc36c9adb23d92f4b517d6b917135b/benchmarks/nasm-refs-replication/README.md).

## Verification by LLM 

- Run 24 jobs. All 24 caches were independently confirmed through
GitHub's API.
- Omission jobs asserted NASM absence. Every build compiled the same 427
Cargo units/features and used the same native `aws-lc-sys`
aarch64/`clang-cl` configuration.
- Actionlint and 24 OS/architecture/target condition cases passed.
Removing the new condition leaves the workflow semantically identical to
today's upstream workflow; the shared action and its other callers are
untouched.
- The repeated campaign tested the agent. Earlier viewer comparisons
reached identical existing `libopus_sys` linker errors (`__imp_floor`,
`__imp_lrintf`) with and without NASM; this is not a viewer-failure fix.

---------

Co-authored-by: marcpems <20582938+marcpems@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Marc-André Moreau <mamoreau@devolutions.net>
2026-10-22 11:34:51 -04:00
Marc-André Moreau 637f838ea0 feat!: remote touch and pen through RDPEI (#2198)
ActiveX now remotes pen input. PT_PEN WM_POINTER messages become RDPEI
pen frames with pressure, rotation, tilt, barrel, eraser and inverted
flags, hover and contact state. Coalesced samples from
GetPointerPenInfoHistory become one frame each, timed by the digitizer.
Pens get their own device IDs when the server supports multipen
injection, otherwise only device 0 is used.

The viewer handles WindowEvent::Touch. It groups the per-contact winit
events into frames that restate unchanged contacts and maps positions
through the same scaling as the mouse. Windows mouse messages promoted
from touch or pen are dropped, so input is not sent twice. winit 0.30
reports pens as touch points with pressure only, so the viewer sends
them as touch contacts.

Both front-ends fall back to mouse emulation while the server does not
accept touch or pen, for example before logon. ironrdp-client reports
this through the new RdpOutputEvent::RdpeiInputState variant, which is a
breaking change for exhaustive matches. The client now advertises RDPEI
V300 with multipen injection, and RdpeiClient never advertises a version
above the server's. A closed channel resets the negotiation.

The contact lifetime state machine and the touch frame builder live in
ironrdp_rdpei::contact so front-ends share them.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 09:37:20 -04: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
Benoît Cortier 66bfd60ed3 ci(pr-automation): retry state writes and allow reruns (#2144)
A transient GitHub 500 while adding labels failed the final writer after
a successful classification, losing the whole run. The writer now
installs an Octokit request hook that retries 5xx responses up to three
times with 1, 2, and 4 second delays, but only for requests whose
repetition cannot duplicate state: reads, updates by identity,
deletions, and label additions. Creating comments, reviews, check runs,
and dispatches is never retried, so the review-once and canonical-check
guarantees hold. The github-script `retries` input was not used because
it retries every POST.

Re-running the failed writer job then published nothing and reported
success, leaving the canonical check in progress, because lease
ownership required the exact run attempt that claimed it. The lease
owner is now the workflow run: a later attempt of the same run continues
its lease, and admission in a later attempt may reclaim its own earlier
attempt's lease. GitHub runs attempts of one run sequentially, so other
runs remain excluded while any attempt is active, and a completed run
still releases the lease.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-20 14:28:32 +09:00
Benoît Cortier 1a1f8e6e6f ci(pr-automation): trust review-ready by completed_at (#2152)
GitHub check-run objects have no created_at field, so trustedReady
rejected every AI review-ready check. Reconciliation never selected
needs-review from a review-ready receipt, and repeated commands could
not update the existing check.

Validate the server-assigned completed_at timestamp instead, which every
completed check run carries, and align the test fixtures with the real
API shape.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-20 14:26:20 +09:00
AKolenda 9be90a7674 feat(session)!: answer bandwidth measurements during the session (#2012)
The session answered RTT requests on the message channel but ignored
continuous Bandwidth Measure Start and Stop. A shared
`AutoDetectResponder` now answers them.

- A continuous reliable Start opens or resets a window. Received TCP
frames contribute their complete length when no RDP Security Header is
present, including fast-path and TPKT/X224/MCS framing. Where a Security
Header is present, only bytes following it count.
- Results use the measured elapsed time with a 1 ms floor and saturating
counters. A missing or untimed window returns 1 ms and zero bytes.
- Connect-time requests belong to the connection sequence handled by
`ironrdp-connector` and are ignored here. Lossy-tunnel requests are not
answered on the main connection.

BREAKING CHANGE: `ActiveStage::process` and `x224::Processor::process`
take a `received_at: Option<MonotonicInstant>` argument, matching
`ironrdp_connector::Sequence::step`. Pass the time the transport read
the frame, such as `Framed::last_read_at()`; with `None`, bandwidth
results report 0 kbps. The native client, web client, FFI and examples
pass their arrival time.

Co-authored-by: AKolenda <testedemail2222@gmail.com>
Co-authored-by: Benoît CORTIER <git.divisible626@passmail.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-20 14:24:07 +09:00
Benoît Cortier fa9665501e feat(xtask): add pinned benchmark corpus (#1942)
Pin public Wireshark RDP captures for repeatable benchmark inputs.

Fetch only immutable raw URLs with curl, verify SHA-256 digests, and
atomically replace corrupt cache entries. CI rejects tracked packet
captures.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-20 13:43:12 +09:00
Willie Abrams 1f69e124e6 fix(graphics): decode Windows SRL streams without their trailing zeros (#2134)
Windows 11 sessions end on the first Progressive upgrade with
`SrlError::MissingTerminator`. Windows ends many SRL streams at their
last code word, with no trailing zero byte or zero bits.

The decoder now reads bits past the end as zeros and emits each `0`
bit's run of 2^K zeros as it reads it, as FreeRDP's
`progressive_rfx_srl_read` does. The raw stream already reads past its
end as zeros.

Checked against Windows 11 (the session renders), and against the old
decoder on the 125k random streams it accepted (identical output).
`MissingTerminator` and `Truncated` are no longer returned.

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

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 16:14:59 -04:00
Rophy Tsai 41b28b4676 fix(graphics): keep ZGFX segments within 65535 bytes of uncompressed data (#2136)
`compress_and_wrap_egfx` sent a whole PDU as one compressed segment
whenever the *compressed* size fit in 65,535 bytes, without checking the
*uncompressed* size. MS-RDPEGFX 3.1.9.1.2 allows at most 65,535
uncompressed bytes per segment, and FreeRDP fails with `zgfx_decompress
failure` on larger ones.

## Fix

Input larger than 65,535 bytes is now compressed in 65,535-byte chunks
and sent as a multipart message. The chunks share one `Compressor`, so
the history stays in step with the client. This is the same approach as
FreeRDP's `zgfx_compress_to_stream`. In `Auto` mode, a chunk that does
not get smaller is sent raw. In `Always` mode, a chunk that grows by
more than 1,000 bytes is sent raw (MS-RDPEGFX 3.1.9.1.2, RDP 8.0
compressor limits: "Maximum expansion of a segment ... 1,000 bytes").

One rule (`is_usable`) now decides compressed or raw for single segments
and for multipart chunks. So input that fits in one segment now also
follows the 1,000-byte expansion limit in `Always` mode; before, it was
sent compressed whatever the growth.

## Tests

New unit tests in `zgfx/api.rs`:

- `large_input_is_split_into_segments_within_limit`: no segment
decompresses to more than 65,535 bytes
- `large_incompressible_input_round_trips`
- `compressed_chunk_may_reference_raw_chunk`
- `always_mode_sends_badly_expanding_chunk_raw`
- `always_mode_sends_badly_expanding_single_segment_raw`

```
cargo test -p ironrdp-graphics -p ironrdp-egfx
  ironrdp-graphics: 251 passed, 0 failed
  ironrdp-egfx:      62 passed, 0 failed
cargo xtask check fmt -v      OK
cargo xtask check lints -v    OK
cargo xtask check tests -v    OK
cargo xtask check typos       OK
```

End to end: FreeRDP 3.30 `/gfx:AVC444` at 1280x720 with
`CompressionMode::Auto`: before the fix 2/2 sessions failed with
`zgfx_decompress failure`; after it 3/3 passed.

Not run: the WASM check of `cargo xtask ci` (the
`wasm32-unknown-unknown` target is not installed on my machine) and
FFI/.NET.

Fixes #2135
2026-10-19 16:14:18 -04:00
Richard Markiewicz d4c2fec346 chore(release): prepare for Devolutions.IronRdp v2026.10.19.0 (#2146)
Bumps the NuGet package version to **2026.10.19.0** (package
`2026.10.19`), as in #1048.

First package since 2025.12.4 to ship:
- the `ios-arm64` + `iossimulator-arm64` framework slices with
single-slice selection (9d206a3d) — 2025.12.4's fat `runtimes/ios`
binary had no arm64-simulator slice;
- the run-time iOS framework resolver (#2145).

After merge, publish with the **Build and publish** workflow
(`workflow_dispatch`, dry-run = false).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-19 19:21:04 +00:00
uchouT 9e85975616 fix(server)!: pass a DisplayContext to RdpServerDisplay::updates (#2073)
`RdpServerDisplay::updates()` now takes a `DisplayContext` with the
connection's `display_suppressed` flag and auto-detect handles. Each
connection creates its own, replacing the manual resets at connection
start. After a Deactivation-Reactivation Sequence, `updates()` is called
again with the same handles.

Signed-off-by: uchouT <i@uchout.moe>
2026-10-20 04:10:54 +09:00
Richard Markiewicz b81c7e3bbb fix(ffi): resolve the iOS framework at run time (#2145)
## Problem

The generated raw layer declares a bare
`[DllImport("DevolutionsIronRdp")]`. iOS is the only target that ships
the native code inside a framework bundle rather than a loose dylib, and
no default probing permutation resolves a path inside one, so P/Invoke
binding fails with a `DllNotFoundException` whose entire message is
`DevolutionsIronRdp`.

This is invisible under full AOT, which emits direct native calls and
never probes. It fails wherever binding happens at run time: the
simulator's JIT and any consumer running with `UseInterpreter=true`.

## Change

- **`NativeLibraryResolver.cs`** (new, hand-written outside
`Generated/`, which `cargo xtask ffi` wipes) - registers a
`DllImportResolver` for this assembly via `[ModuleInitializer]`, so
consumers need no setup. Gated to iOS; tries the framework's `@rpath`
install name, then the absolute path under the app bundle's
`Frameworks/`, then falls back to `GetMainProgramHandle()` for the
statically-linked / already-loaded case. That fallback probes a known
export first, so a genuinely missing library is still reported as a
`DllNotFoundException` naming it rather than as a per-symbol
`EntryPointNotFoundException` from an unrelated call later.
- `CA2255` (module initializers in libraries) is suppressed with
justification: the DllImports are spread across the generated `Raw*`
types with no shared static-constructor chokepoint, and requiring
consumers to call an initializer is the coupling this removes.

No packaging/CI change: master already ships `ios-arm64` +
`iossimulator-arm64` as separate frameworks with single-slice selection
(#9d206a3d) — that just hasn't been released since 2025.12.4, whose
`runtimes/ios` fat binary is arm64-device + x86_64-simulator only and
cannot load on an Apple-silicon simulator.

## Verification

Built both slices locally (`aarch64-apple-ios`, `aarch64-apple-ios-sim`
with the simulator `SDKROOT`, `production-ffi` profile), bundled them as
frameworks exactly as the workflow does, packed `Devolutions.IronRdp`
from this branch, and referenced it from an Avalonia iOS app
(`net10.0-ios`, `iossimulator-arm64`, `UseInterpreter=true`) on an
iPhone 16 Pro simulator:

```
[ironrdp-probe] bare-name TryLoad (expected False): False
[ironrdp-probe] FFI call succeeded: IronRDP native library loaded via Devolutions.IronRdp resolver
```

(`ConfigBuilder.New()` → `Build()` executes Rust code, including its
config validation.) No device available here; the device slice is the
same code path under AOT, which never probes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-19 14:21:46 -04:00
Rophy Tsai cddbe5f730 fix(server): report a failed NLA logon as STATUS_LOGON_FAILURE (#2138)
When CredSSP fails, the acceptor sends sspi's `TsRequest` with its
`errorCode` unchanged. sspi builds that code from the SSPI error, so a
wrong password or an unknown user (`LogonDenied`) is sent as
`0xC007030C`. That is not an NTSTATUS code (MS-ERREF 2.3.1). mstsc then
shows "This computer can't connect to the remote computer" (disconnect
reason 0x904) and does not ask for the password again.

MS-CSSP 2.2.1 says the server SHOULD send the NTSTATUS failure code in
`errorCode`, so the client can show a descriptive error.

## Fix

In `CredsspSequence::handle_process_result`, when the error is
`LogonDenied`, set `errorCode` to `STATUS_LOGON_FAILURE` (`0xC000006D`),
as Windows does. Other errors keep the code from sspi.

With sspi 0.23, a wrong password gives `LogonDenied` ("no candidate
credential matched"), not `MessageAltered`. `MessageAltered` now comes
only from integrity failures (for example, a `pubKeyAuth` mismatch).
Reporting those as wrong credentials would be misleading, so they are
not mapped.

## Tests

New test in `ironrdp-testsuite-core/tests/server/acceptor.rs`,
`credssp_failed_logon_is_reported_as_logon_failure`. It drives a CredSSP
exchange through `accept_credssp_with` with the existing
`HandshakeStream` harness: wrong password and unknown user, each with
`HYBRID` and `HYBRID_EX`. It decodes the last `TsRequest` that the
server writes and checks `error_code ==
Some(NStatusCode::LOGON_FAILURE)`. The harness now does not pass a
`TsRequest` with an error code back to the client.

```
cargo test -p ironrdp-testsuite-core --test integration_tests_core -- credssp_
  without the fix: 4 failed (left: Some(NStatusCode(0xc007030c)), right: Some(NStatusCode(0xc000006d)))
  with the fix:    22 passed, 0 failed
cargo xtask check fmt -v      OK
cargo xtask check lints -v    OK
cargo xtask check tests -v    OK (3507 passed, 0 failed)
typos (workspace, target/ excluded) OK
```

End to end: mstsc (Windows 10 22H2) with a wrong password to an
`ironrdp-server`-based server with NLA. With the fix, mstsc shows "Your
credentials did not work" with "The logon attempt failed" and asks for
the password again. A correct password still logs in.

Not run: the WASM check of `cargo xtask ci` (the
`wasm32-unknown-unknown` target is not installed on my machine), `cargo
xtask check locks`, and FFI/.NET.

Fixes #2137
2026-10-19 13:44:35 -04:00
Benoît Cortier 5b0291ff24 ci(pr-automation): retry malformed provider streams (#2143)
Helmcode's glm5.3 endpoint intermittently appends a post-finish delta
that carries a content key, which failed whole classifier and reviewer
stages as non-retryable and caused most recent automation-failed labels.

Every structurally malformed stream, including unparsable
server-sent-event data and rejected post-finish tails, is now a
transient provider failure retried within the existing per-call
request-retry budget, backoff, and stage deadline. Retries resend the
unchanged history and discard the failed attempt, so no tool from a
malformed batch executes. Such tails are still never accepted, and JSON,
schema, and semantic rejections remain output repairs.

Post-finish shapes now distinguish empty or null text keys
(delta-content-empty, delta-reasoning-empty) from carried text. Each
provider attempt records its own structural violation, the completion
log reports the request-retry count and any recovered violation, and
terminal failure logs report only the violation that caused the failure.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-20 02:07:21 +09:00
AKolenda aed5ce8ba2 feat(cliprdr): add a Linux clipboard backend (#2016)
Adds native Linux clipboard redirection for Unicode text and images,
built on the `data_control` Wayland client from #2055 (now on master)
with an X11/XFixes fallback.

Remote format lists are advertised immediately; contents are requested
only when a local application pastes. Local selection changes are
event-driven, and local content is read only when the RDP peer requests
it. The backend uses the existing clipboard loop detector and the
bounded bitmap converters in `ironrdp-cliprdr-format`.

CLIPRDR responses have no request identifier. Only one Format Data
Request is outstanding at a time: a timed-out OS paste is released,
while the wire request remains reserved until its late response is
drained. Selection generations reject obsolete data. If the peer never
answers, remote pastes fail until channel reinitialization instead of
applying stale content to a later copy.

The X11 side bounds pending transfers, supports INCR for large content
and isolates reads with separate requestor windows. Ownership
acknowledgments and current-owner checks prevent queued events from
replacing a newer remote selection.

The only change to the `data_control` module is a crate-internal
`synchronize()` (a `wl_display.sync` round trip). The backend calls it
after `set_selection` so that `owns_selection()` reflects whether the
selection was actually taken before the remote formats are treated as
mirrored. If it was not, the backend announces the local formats again.

File transfer and HTML are not implemented. Desktops without
data-control use X11/XWayland when available, otherwise the existing
stub backend.

Co-authored-by: AKolenda <testedemail2222@gmail.com>
2026-10-20 00:14:15 +09:00
truebest 3f977f89f8 fix(egfx): drop undecodable surface updates instead of the session (#1789)
Codec decode errors currently propagate through EGFX and terminate the
RDP session. Drop rejected AVC420, ClearCodec, Planar and Progressive
updates, retain protocol-persistent decoder contexts and caches, and
throttle diagnostics. Logs identify the actual codec and retain AVC420
frame/destination dimensions.

Only bitmap decoder failures become nonfatal. Unknown surfaces and
invalid rectangle ordering retain upstream validation behavior; recovery
from malformed headers or surface lifecycle errors needs a separate
policy. A client without an H.264 decoder retains the existing
capability-skip behavior. The cumulative `dropped_updates` accessor
counts updates rejected after attempted codec decoding, and capture
replay uses it alongside the unsupported-codec flag to report gaps
without terminating playback.

Regression tests cover Progressive upgrades on two surfaces after 64
failures, a cached ClearCodec glyph across failures and `ResetGraphics`,
actual CONTEXT-less Progressive rendering after `ResetGraphics`, replay
gaps for malformed supported codecs and unsupported AVC420, and retained
AVC420 dimension diagnostics. The context/cache regressions fail with
the old failure-streak reset heuristic.

Default EGFX/graphics/capture-replay tests (390), EGFX all-feature tests
(63), targeted Clippy and formatting pass. All-feature Clippy reproduces
existing `encode.rs` lint failures on unmodified `master`. A final local
Codex review found no remaining actionable findings.

Co-authored-by: truebest <truebest@users.noreply.github.com>
2026-10-20 00:11:36 +09:00
AKolenda b60ffdffa2 fix(egfx): keep the bitmap cache across ResetGraphics (#2011)
The compositor emptied the bitmap cache on every ResetGraphics. Windows
reuses cached toolbars, icons and text after a resize, so subsequent
CacheToSurface commands could leave those regions black until a fresh
upload.

`Compositor::reset` now drops surfaces and pending output while
retaining the bitmap cache and its allocation charge. MS-RDPEGFX
3.3.5.14 resets the graphics output; the bitmap-cache state is described
separately in 3.3.1.4. To preserve space for replacement surfaces in the
256 MiB budget, a cache exceeding the protocol's 100 MiB maximum is
discarded during reset.

The regression tests verify that cached content remains renderable after
reset, surface allocation charges are released, retained cache charges
remain accounted for, and an oversized cache is discarded.

Co-authored-by: AKolenda <testedemail2222@gmail.com>
2026-10-20 00:07:03 +09:00