ironrdp-cliprdr crate implements the CLIPRDR static virtual channel for clipboard redirection as specified in MS-RDPECLIP. This channel enables copy/paste functionality between the local machine and the remote desktop session.
Overview
The clipboard redirection channel operates through a state machine that coordinates clipboard operations between client and server. It supports both simple text/image clipboard transfers and complex file transfers with delay rendering.Core Types
Cliprdr
The main processor for the CLIPRDR channel, generic over aRole type parameter.
new(backend: Box<dyn CliprdrBackend>) -> Self- Creates a new CLIPRDR processor with the given backendinitiate_copy(available_formats: &[ClipboardFormat]) -> PduResult<CliprdrSvcMessages<R>>- Initiates a copy operationinitiate_paste(requested_format: ClipboardFormatId) -> PduResult<CliprdrSvcMessages<R>>- Initiates a paste operationsubmit_format_data(response: OwnedFormatDataResponse) -> PduResult<CliprdrSvcMessages<R>>- Submits format data responselock_clipboard(clip_data_id: u32)- Locks clipboard data before file transferunlock_clipboard(clip_data_id: u32)- Unlocks clipboard data after transferrequest_file_contents(request: FileContentsRequest)- Requests file contents from remotesubmit_file_contents(response: FileContentsResponse)- Submits file contents response
ironrdp-cliprdr/src/lib.rs:54
CliprdrBackend
OS-specific clipboard backend interface that handles platform-specific clipboard operations.ironrdp-cliprdr/src/backend.rs:69
Protocol Flow
Initialization
- Server sends
CapabilitiesandMonitorReadyPDUs - Client responds with its
Capabilities,TemporaryDirectory, and initialFormatList - Server acknowledges with
FormatListResponse - Channel transitions to
Readystate
Copy Operation (Local to Remote)
- User initiates copy on client side
- Client calls
initiate_copy()with available formats - Client sends
FormatListPDU to server - Server responds with
FormatListResponse - When user pastes on server, server sends
FormatDataRequest - Client backend receives request via
on_format_data_request() - Client sends format data via
submit_format_data()
Paste Operation (Remote to Local)
- User initiates copy on server side
- Server sends
FormatListwith available formats - Client receives formats via
on_remote_copy() - When user pastes on client, client calls
initiate_paste() - Client sends
FormatDataRequestto server - Server responds with
FormatDataResponse - Client receives data via
on_format_data_response()
File Transfer Operations
For file transfers, the channel supports:- Lock/Unlock: Ensures data stability during multi-part file transfers
- File Contents Requests: Retrieves specific byte ranges from files
- Delay Rendering: Files are only transferred when actually pasted
PDU Types
Thepdu module defines all clipboard protocol data units:
ClipboardPdu- Top-level PDU enum containing all message typesCapabilities- Clipboard capabilities negotiationFormatList- List of available clipboard formatsFormatDataRequest/FormatDataResponse- Request/response for clipboard dataFileContentsRequest/FileContentsResponse- Request/response for file contentsLockDataId/UnlockDataId- Lock/unlock clipboard data during file transfersClientTemporaryDirectory- Client’s temporary directory path
Clipboard Formats
Implementation Notes
The CLIPRDR channel requires
CHANNEL_FLAG_SHOW_PROTOCOL flag for all messages as they contain chunked data per MS-RDPBCGR specification.Related Crates
- ironrdp-cliprdr-native: Platform-specific clipboard backend implementations for Windows, macOS, and Linux
- ironrdp-cliprdr-format: Clipboard format definitions and conversions
- ironrdp-svc: Static virtual channel traits and infrastructure

