Skip to main content
The CLIPRDR channel implements the [MS-RDPECLIP] clipboard redirection protocol. It synchronises clipboard content (text, images, file lists) between the RDP client and server. Channel name: cliprdr (CLIPRDR_CHANNEL_NAME) Client header: <freerdp/client/cliprdr.h>
Server header: <freerdp/server/cliprdr.h>
Protocol types: <freerdp/channels/cliprdr.h>

Client Context

CliprdrClientContext

typedef struct s_cliprdr_client_context CliprdrClientContext The client-side clipboard context. Obtain it via the dynamic virtual channel manager after the CLIPRDR channel is loaded. Function-pointer fields are split into:
  • Server → Client callbacks (prefixed Server*): set by the channel implementation; called when the server sends a message.
  • Client → Server calls (prefixed Client*): set by the channel implementation; called by your application to send a message to the server.

Key fields

void*
Application-defined context pointer. Store your private state here.
rdpContext*
The owning RDP context.
UINT32
Format ID from the most recent FormatDataRequest. Useful in ServerFormatDataRequest to know what to provide.

Inbound callbacks (server → client)

pcCliprdrServerCapabilities
Called when the server sends its clipboard capability set. Inspect generalFlags (e.g. CB_USE_LONG_FORMAT_NAMES, CB_STREAM_FILECLIP_ENABLED) to determine feature support.
pcCliprdrMonitorReady
Signals that the server clipboard channel is ready. Respond by calling ClientCapabilities then ClientFormatList.
pcCliprdrServerFormatList
Called when the server announces its available clipboard formats. Iterate formatList->formats[i] (each has formatId and optional formatName) to decide which formats you can handle.
pcCliprdrServerFormatDataRequest
Called when the server requests clipboard data in a specific format. Respond by calling ClientFormatDataResponse with the data.
pcCliprdrServerFormatDataResponse
Delivers the clipboard data the client previously requested via ClientFormatDataRequest.

Outbound calls (client → server)

pcCliprdrClientCapabilities
Send the client’s clipboard capabilities to the server. Call in response to MonitorReady.
pcCliprdrClientFormatList
Announce which clipboard formats are currently available on the client. Call whenever the local clipboard changes.
pcCliprdrClientFormatDataRequest
Request clipboard data from the server in the specified format. The response arrives via ServerFormatDataResponse.
pcCliprdrClientFormatDataResponse
Send clipboard data to the server in reply to ServerFormatDataRequest.

Server Context

CliprdrServerContext

typedef struct s_cliprdr_server_context CliprdrServerContext The server-side context. Created with cliprdr_server_context_new() and destroyed with cliprdr_server_context_free().
vcm is the virtual channel manager handle from the WTS API (e.g. WTSVirtualChannelManagerNew).

Server capability flags

BOOL
Set to TRUE to negotiate long format names (CB_USE_LONG_FORMAT_NAMES).
BOOL
Enable file clipboard streaming (CB_STREAM_FILECLIP_ENABLED).
BOOL
Advertise support for clipboard data locking (CB_CAN_LOCK_CLIPDATA).
BOOL
When TRUE, the implementation automatically sends ServerCapabilities and MonitorReady on channel open.

Channel control

psCliprdrOpen
Opens the SVC. Must be called before Start.
psCliprdrStart
Starts the server clipboard worker thread.
psCliprdrStop
Stops the worker thread.
psCliprdrGetEventHandle
Returns a waitable event handle for the server clipboard channel.
psCliprdrCheckEventHandle
Processes pending clipboard PDUs — call when the event handle is signalled.

Protocol Data Types


Clipboard Capability Flags


Typical Client-Side Flow

1

Channel activation

The CLIPRDR channel is loaded via freerdp_channels_load_plugin(). The framework invokes MonitorReady when the server is ready.
2

Send capabilities

In your MonitorReady handler, build a CLIPRDR_CAPABILITIES with a CLIPRDR_GENERAL_CAPABILITY_SET and call context->ClientCapabilities(context, &caps).
3

Announce formats

Call context->ClientFormatList(context, &list) with the formats currently on the local clipboard.
4

Respond to data requests

When ServerFormatDataRequest fires, serialize the clipboard content for requestedFormatId and call context->ClientFormatDataResponse(context, &response).
5

Request remote data

To paste from the remote side, call context->ClientFormatDataRequest(context, &request) after receiving ServerFormatList. Handle the data in ServerFormatDataResponse.
Build with -DCHANNEL_CLIPRDR=ON (the default) to include the CLIPRDR channel. The channel is enabled at runtime with the /clipboard command-line option.