Create ms-rdpeclip.h and update ms-rdpbcgr.h

This commit is contained in:
matt335672 2021-05-27 15:34:13 +01:00
parent 85b101dfb2
commit 3ea19ef0cd
7 changed files with 112 additions and 65 deletions

View File

@ -10,6 +10,7 @@ include_HEADERS = \
ms-erref.h \
ms-fscc.h \
ms-rdpbcgr.h \
ms-rdpeclip.h \
ms-rdpefs.h \
ms-rdpegdi.h \
ms-rdpele.h \

View File

@ -236,6 +236,15 @@
#define exDiscReasonLicenseCantUpgradeLicense 0x0109
#define exDiscReasonLicenseNoRemoteConnections 0x010a
/* Virtual channel PDU (2.2.6.1) */
#define CHANNEL_CHUNK_LENGTH 1600
/* Channel PDU Header flags (2.2.6.1.1) */
/* NOTE: XR_ prefixed to avoid conflict with FreeRDP */
#define XR_CHANNEL_FLAG_FIRST 0x00000001
#define XR_CHANNEL_FLAG_LAST 0x00000002
#define XR_CHANNEL_FLAG_SHOW_PROTOCOL 0x00000010
/* General Capability Set: osMajorType (2.2.7.1.1) */
#define OSMAJORTYPE_UNSPECIFIED 0x0000
#define OSMAJORTYPE_WINDOWS 0x0001

90
common/ms-rdpeclip.h Normal file
View File

@ -0,0 +1,90 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
* MS-RDPECLIP : Definitions from [MS-RDPECLIP]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* References to MS-RDPECLIP are currently correct for v220210407 of that
* document
*/
#if !defined(MS_RDPECLIP_H)
#define MS_RDPECLIP_H
/* Clipboard PDU header message codes 2.2.1 */
#define CB_MONITOR_READY 1
#define CB_FORMAT_LIST 2
#define CB_FORMAT_LIST_RESPONSE 3
#define CB_FORMAT_DATA_REQUEST 4
#define CB_FORMAT_DATA_RESPONSE 5
#define CB_TEMP_DIRECTORY 6
#define CB_CLIP_CAPS 7
#define CB_FILECONTENTS_REQUEST 8
#define CB_FILECONTENTS_RESPONSE 9
#define CB_LOCK_CLIPDATA 10
#define CB_UNLOCK_CLIPDATA 11
#define CB_PDUTYPE_TO_STR(pdu_type) \
((pdu_type) == CB_MONITOR_READY ? "CB_MONITOR_READY" : \
(pdu_type) == CB_FORMAT_LIST ? "CB_FORMAT_LIST" : \
(pdu_type) == CB_FORMAT_LIST_RESPONSE ? "CB_FORMAT_LIST_RESPONSE" : \
(pdu_type) == CB_FORMAT_DATA_REQUEST ? "CB_FORMAT_DATA_REQUEST" : \
(pdu_type) == CB_FORMAT_DATA_RESPONSE ? "CB_FORMAT_DATA_RESPONSE" : \
(pdu_type) == CB_TEMP_DIRECTORY ? "CB_TEMP_DIRECTORY" : \
(pdu_type) == CB_CLIP_CAPS ? "CB_CLIP_CAPS" : \
(pdu_type) == CB_FILECONTENTS_REQUEST ? "CB_FILECONTENTS_REQUEST" : \
(pdu_type) == CB_FILECONTENTS_RESPONSE ? "CB_FILECONTENTS_RESPONSE" : \
(pdu_type) == CB_LOCK_CLIPDATA ? "CB_LOCK_CLIPDATA" : \
(pdu_type) == CB_UNLOCK_CLIPDATA ? "CB_UNLOCK_CLIPDATA" : \
"unknown" \
)
/* Clipboard PDU header message flags 2.2.1 */
#define CB_RESPONSE_OK 0x0001
#define CB_RESPONSE_FAIL 0x0002
#define CB_ASCII_NAMES 0x0004
/* Capability set codes 2.2.2.1.1 */
#define CB_CAPSTYPE_GENERAL 1
#define CB_CAPS_VERSION_1 1
#define CB_CAPS_VERSION_2 2
/* General capability set general flags 2.2.2.1.1.1 */
#define CB_USE_LONG_FORMAT_NAMES 0x00000002
#define CB_STREAM_FILECLIP_ENABLED 0x00000004
#define CB_FILECLIP_NO_FILE_PATHS 0x00000008
#define CB_CAN_LOCK_CLIPDATA 0x00000010
/* File contents request PDU 2.2.5.3 */
/* Note that in the document these do not have a CB_ prefix */
#define CB_FILECONTENTS_SIZE 0x00000001
#define CB_FILECONTENTS_RANGE 0x00000002
/* File descriptor structure flags 2.2.5.2.3.1 */
/* Note that in the document these do not have a CB_ prefix */
#define CB_FD_ATTRIBUTES 0x00000004
#define CB_FD_FILESIZE 0x00000040
#define CB_FD_WRITESTIME 0x00000020
#define CB_FD_PROGRESSUI 0x00004000
/* File descriptor structure file attributes 2.2.5.2.3.1 */
/* Note that in the document these do not have a CB_ prefix */
#define CB_FILE_ATTRIBUTE_READONLY 0x00000001
#define CB_FILE_ATTRIBUTE_HIDDEN 0x00000002
#define CB_FILE_ATTRIBUTE_SYSTEM 0x00000004
#define CB_FILE_ATTRIBUTE_DIRECTORY 0x00000010
#define CB_FILE_ATTRIBUTE_ARCHIVE 0x00000020
#define CB_FILE_ATTRIBUTE_NORMAL 0x00000080
#endif /* MS_RDPECLIP_H */

View File

@ -25,13 +25,6 @@
#include "libxrdp.h"
#include "string_calls.h"
/* todo, move these to constants.h */
//#define CHANNEL_CHUNK_LENGTH 1600 /* todo, why is this so small? */
#define CHANNEL_CHUNK_LENGTH 8192
#define CHANNEL_FLAG_FIRST 0x01
#define CHANNEL_FLAG_LAST 0x02
#define CHANNEL_FLAG_SHOW_PROTOCOL 0x10
#define CMD_DVC_OPEN_CHANNEL 0x10
#define CMD_DVC_DATA_FIRST 0x20
#define CMD_DVC_DATA 0x30
@ -751,7 +744,7 @@ xrdp_channel_drdynvc_send_capability_request(struct xrdp_channel *self)
s_mark_end(s);
/* send command to client */
total_data_len = (int) (s->end - phold);
flags = CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST;
flags = XR_CHANNEL_FLAG_FIRST | XR_CHANNEL_FLAG_LAST;
channel_id = self->drdynvc_channel_id;
LOG_DEVEL(LOG_LEVEL_TRACE, "Sending [MS-RDPEDYC] DYNVC_CAPS_VERSION2 "
"cbId 0, Sp 0, Cmd 0x05, Version 2, PriorityCharge0 0, "
@ -864,7 +857,7 @@ xrdp_channel_drdynvc_open(struct xrdp_channel *self, const char *name,
/* cbId (low 2 bits), Pri (2 bits), Cmd (hi 4 bits) */
cmd_ptr[0] = CMD_DVC_OPEN_CHANNEL | ((chan_pri << 2) & 0x0c) | cbChId;
static_channel_id = self->drdynvc_channel_id;
static_flags = CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST;
static_flags = XR_CHANNEL_FLAG_FIRST | XR_CHANNEL_FLAG_LAST;
s_mark_end(s);
total_data_len = (int) (s->end - cmd_ptr);
@ -936,7 +929,7 @@ xrdp_channel_drdynvc_close(struct xrdp_channel *self, int chan_id)
/* cbId (low 2 bits), Sp (2 bits), Cmd (hi 4 bits) */
cmd_ptr[0] = CMD_DVC_CLOSE_CHANNEL | cbChId;
static_channel_id = self->drdynvc_channel_id;
static_flags = CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST;
static_flags = XR_CHANNEL_FLAG_FIRST | XR_CHANNEL_FLAG_LAST;
s_mark_end(s);
total_data_len = (int) (s->end - cmd_ptr);
@ -1012,7 +1005,7 @@ xrdp_channel_drdynvc_data_first(struct xrdp_channel *self, int chan_id,
/* cbId (low 2 bits), Len (2 bits), Cmd (hi 4 bits) */
cmd_ptr[0] = CMD_DVC_DATA_FIRST | (cbTotalDataSize << 2) | cbChId;
static_channel_id = self->drdynvc_channel_id;
static_flags = CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST;
static_flags = XR_CHANNEL_FLAG_FIRST | XR_CHANNEL_FLAG_LAST;
s_mark_end(s);
LOG_DEVEL(LOG_LEVEL_TRACE, "Sending [MS-RDPEDYC] DYNVC_DATA_FIRST "
"cbId %d, Len %d, Cmd 0x%2.2x, ChannelId %d, Length %d",
@ -1083,7 +1076,7 @@ xrdp_channel_drdynvc_data(struct xrdp_channel *self, int chan_id,
/* cbId (low 2 bits), Sp (2 bits), Cmd (hi 4 bits) */
cmd_ptr[0] = CMD_DVC_DATA | cbChId;
static_channel_id = self->drdynvc_channel_id;
static_flags = CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST;
static_flags = XR_CHANNEL_FLAG_FIRST | XR_CHANNEL_FLAG_LAST;
s_mark_end(s);
total_data_len = (int) (s->end - cmd_ptr);
LOG_DEVEL(LOG_LEVEL_TRACE, "Sending [MS-RDPEDYC] DYNVC_DATA "

View File

@ -177,7 +177,7 @@ x-special/gnome-copied-files
#include "clipboard_common.h"
#include "xcommon.h"
#include "chansrv_fuse.h"
#include "ms-rdpeclip.h"
static char g_bmp_image_header[] =
{
@ -234,7 +234,7 @@ struct clip_s2c g_clip_s2c;
struct clip_c2s g_clip_c2s;
/* default version and flags */
static int g_cliprdr_version = 2;
static int g_cliprdr_version = CB_CAPS_VERSION_2;
static int g_cliprdr_flags = CB_USE_LONG_FORMAT_NAMES |
CB_STREAM_FILECLIP_ENABLED |
CB_FILECLIP_NO_FILE_PATHS;
@ -418,7 +418,7 @@ clipboard_init(void)
out_uint16_le(s, 1); /* cCapabilitiesSets */
out_uint16_le(s, 0); /* pad1 */
/* CLIPRDR_GENERAL_CAPABILITY */
out_uint16_le(s, 1); /* capabilitySetType */
out_uint16_le(s, CB_CAPSTYPE_GENERAL); /* capabilitySetType */
out_uint16_le(s, 12); /* lengthCapability */
out_uint32_le(s, g_cliprdr_version); /* version */
out_uint32_le(s, g_cliprdr_flags); /* generalFlags */

View File

@ -22,28 +22,9 @@
#include "arch.h"
#include "parse.h"
#define CB_CAPSTYPE_GENERAL 1
#define CB_MONITOR_READY 1
#define CB_FORMAT_LIST 2
#define CB_FORMAT_LIST_RESPONSE 3
#define CB_FORMAT_DATA_REQUEST 4
#define CB_FORMAT_DATA_RESPONSE 5
#define CB_TEMP_DIRECTORY 6
#define CB_CLIP_CAPS 7
#define CB_FILECONTENTS_REQUEST 8
#define CB_FILECONTENTS_RESPONSE 9
#define CB_LOCK_CLIPDATA 10
#define CB_UNLOCK_CLIPDATA 11
#define CB_USE_LONG_FORMAT_NAMES 0x00000002
#define CB_STREAM_FILECLIP_ENABLED 0x00000004
#define CB_FILECLIP_NO_FILE_PATHS 0x00000008
#define CB_CAN_LOCK_CLIPDATA 0x00000010
#define CB_FILECONTENTS_SIZE 0x00000001
#define CB_FILECONTENTS_RANGE 0x00000002
/*
* TODO : Replace these with the definitions in xrdp_constants.h
* where possible */
#define CB_FORMAT_RAW 0x0000
#define CB_FORMAT_TEXT 0x0001
#define CB_FORMAT_DIB 0x0008
@ -54,39 +35,11 @@
#define CB_FORMAT_GIF 0xD013
#define CB_FORMAT_FILE 0xC0BC
/* Used by the Format List Response PDU, Format Data Response PDU, and File
Contents Response PDU to indicate that the associated request Format List
PDU, Format Data Request PDU, and File Contents Request PDU were processed
successfully. */
#define CB_RESPONSE_OK 0x0001
/* Used by the Format List Response PDU, Format Data Response PDU, and File
Contents Response PDU to indicate that the associated Format List PDU,
Format Data Request PDU, and File Contents Request PDU were not processed
successfully. */
#define CB_RESPONSE_FAIL 0x0002
/* Used by the Short Format Name variant of the Format List Response PDU to
indicate the format names are in ASCII 8. */
#define CB_ASCII_NAMES 0x0004
/* these are the supported general types */
#define XRDP_CB_TEXT 1
#define XRDP_CB_BITMAP 2
#define XRDP_CB_FILE 3
#define CB_FD_ATTRIBUTES 0x00000004
#define CB_FD_FILESIZE 0x00000040
#define CB_FD_WRITESTIME 0x00000020
#define CB_FD_PROGRESSUI 0x00004000
#define CB_FILE_ATTRIBUTE_READONLY 0x00000001
#define CB_FILE_ATTRIBUTE_HIDDEN 0x00000002
#define CB_FILE_ATTRIBUTE_SYSTEM 0x00000004
#define CB_FILE_ATTRIBUTE_DIRECTORY 0x00000010
#define CB_FILE_ATTRIBUTE_ARCHIVE 0x00000020
#define CB_FILE_ATTRIBUTE_NORMAL 0x00000080
struct clip_s2c /* server to client, pasting from linux app to mstsc */
{
int incr_in_progress;

View File

@ -41,6 +41,7 @@
#include "clipboard_common.h"
#include "xcommon.h"
#include "chansrv_fuse.h"
#include "ms-rdpeclip.h"
extern int g_cliprdr_chan_id; /* in chansrv.c */