Blame channels/cliprdr/client/cliprdr_main.c

Packit 1fb8d4
/**
Packit 1fb8d4
 * FreeRDP: A Remote Desktop Protocol Implementation
Packit 1fb8d4
 * Clipboard Virtual Channel
Packit 1fb8d4
 *
Packit 1fb8d4
 * Copyright 2009-2011 Jay Sorg
Packit 1fb8d4
 * Copyright 2010-2011 Vic Lee
Packit 1fb8d4
 * Copyright 2015 Thincast Technologies GmbH
Packit 1fb8d4
 * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
Packit 1fb8d4
 *
Packit 1fb8d4
 * Licensed under the Apache License, Version 2.0 (the "License");
Packit 1fb8d4
 * you may not use this file except in compliance with the License.
Packit 1fb8d4
 * You may obtain a copy of the License at
Packit 1fb8d4
 *
Packit 1fb8d4
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit 1fb8d4
 *
Packit 1fb8d4
 * Unless required by applicable law or agreed to in writing, software
Packit 1fb8d4
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 1fb8d4
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 1fb8d4
 * See the License for the specific language governing permissions and
Packit 1fb8d4
 * limitations under the License.
Packit 1fb8d4
 */
Packit 1fb8d4
Packit 1fb8d4
#ifdef HAVE_CONFIG_H
Packit 1fb8d4
#include "config.h"
Packit 1fb8d4
#endif
Packit 1fb8d4
Packit 1fb8d4
#include <winpr/crt.h>
Packit 1fb8d4
#include <winpr/print.h>
Packit 1fb8d4
Packit 1fb8d4
#include <freerdp/types.h>
Packit 1fb8d4
#include <freerdp/constants.h>
Packit 1fb8d4
#include <freerdp/client/cliprdr.h>
Packit 1fb8d4
Packit 1fb8d4
#include "cliprdr_main.h"
Packit 1fb8d4
#include "cliprdr_format.h"
Packit Service 5a9772
#include "../cliprdr_common.h"
Packit 1fb8d4
Packit 1fb8d4
#ifdef WITH_DEBUG_CLIPRDR
Packit Service 5a9772
static const char* const CB_MSG_TYPE_STRINGS[] = { "",
Packit Service 5a9772
	                                               "CB_MONITOR_READY",
Packit Service 5a9772
	                                               "CB_FORMAT_LIST",
Packit Service 5a9772
	                                               "CB_FORMAT_LIST_RESPONSE",
Packit Service 5a9772
	                                               "CB_FORMAT_DATA_REQUEST",
Packit Service 5a9772
	                                               "CB_FORMAT_DATA_RESPONSE",
Packit Service 5a9772
	                                               "CB_TEMP_DIRECTORY",
Packit Service 5a9772
	                                               "CB_CLIP_CAPS",
Packit Service 5a9772
	                                               "CB_FILECONTENTS_REQUEST",
Packit Service 5a9772
	                                               "CB_FILECONTENTS_RESPONSE",
Packit Service 5a9772
	                                               "CB_LOCK_CLIPDATA",
Packit Service 5a9772
	                                               "CB_UNLOCK_CLIPDATA" };
Packit 1fb8d4
#endif
Packit 1fb8d4
Packit 1fb8d4
CliprdrClientContext* cliprdr_get_client_interface(cliprdrPlugin* cliprdr)
Packit 1fb8d4
{
Packit 1fb8d4
	CliprdrClientContext* pInterface;
Packit 1fb8d4
Packit 1fb8d4
	if (!cliprdr)
Packit 1fb8d4
		return NULL;
Packit 1fb8d4
Packit Service 5a9772
	pInterface = (CliprdrClientContext*)cliprdr->channelEntryPoints.pInterface;
Packit 1fb8d4
	return pInterface;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
/**
Packit 1fb8d4
 * Function description
Packit 1fb8d4
 *
Packit 1fb8d4
 * @return 0 on success, otherwise a Win32 error code
Packit 1fb8d4
 */
Packit 1fb8d4
static UINT cliprdr_packet_send(cliprdrPlugin* cliprdr, wStream* s)
Packit 1fb8d4
{
Packit 1fb8d4
	size_t pos;
Packit 1fb8d4
	UINT32 dataLen;
Packit 1fb8d4
	UINT status = CHANNEL_RC_OK;
Packit 1fb8d4
	pos = Stream_GetPosition(s);
Packit 1fb8d4
	dataLen = pos - 8;
Packit 1fb8d4
	Stream_SetPosition(s, 4);
Packit 1fb8d4
	Stream_Write_UINT32(s, dataLen);
Packit 1fb8d4
	Stream_SetPosition(s, pos);
Packit 1fb8d4
#ifdef WITH_DEBUG_CLIPRDR
Packit Service 5a9772
	WLog_DBG(TAG, "Cliprdr Sending (%" PRIu32 " bytes)", dataLen + 8);
Packit 1fb8d4
	winpr_HexDump(TAG, WLOG_DEBUG, Stream_Buffer(s), dataLen + 8);
Packit 1fb8d4
#endif
Packit 1fb8d4
Packit 1fb8d4
	if (!cliprdr)
Packit 1fb8d4
	{
Packit 1fb8d4
		status = CHANNEL_RC_BAD_INIT_HANDLE;
Packit 1fb8d4
	}
Packit 1fb8d4
	else
Packit 1fb8d4
	{
Packit Service 5a9772
		status = cliprdr->channelEntryPoints.pVirtualChannelWriteEx(
Packit Service 5a9772
		    cliprdr->InitHandle, cliprdr->OpenHandle, Stream_Buffer(s),
Packit Service 5a9772
		    (UINT32)Stream_GetPosition(s), s);
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	if (status != CHANNEL_RC_OK)
Packit Service 5a9772
	{
Packit Service 5a9772
		Stream_Free(s, TRUE);
Packit Service 5a9772
		WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08" PRIX32 "]",
Packit 1fb8d4
		         WTSErrorToString(status), status);
Packit Service 5a9772
	}
Packit 1fb8d4
Packit 1fb8d4
	return status;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
#ifdef WITH_DEBUG_CLIPRDR
Packit 1fb8d4
static void cliprdr_print_general_capability_flags(UINT32 flags)
Packit 1fb8d4
{
Packit Service 5a9772
	WLog_INFO(TAG, "generalFlags (0x%08" PRIX32 ") {", flags);
Packit 1fb8d4
Packit 1fb8d4
	if (flags & CB_USE_LONG_FORMAT_NAMES)
Packit Service 5a9772
		WLog_INFO(TAG, "\tCB_USE_LONG_FORMAT_NAMES");
Packit 1fb8d4
Packit 1fb8d4
	if (flags & CB_STREAM_FILECLIP_ENABLED)
Packit Service 5a9772
		WLog_INFO(TAG, "\tCB_STREAM_FILECLIP_ENABLED");
Packit 1fb8d4
Packit 1fb8d4
	if (flags & CB_FILECLIP_NO_FILE_PATHS)
Packit Service 5a9772
		WLog_INFO(TAG, "\tCB_FILECLIP_NO_FILE_PATHS");
Packit 1fb8d4
Packit 1fb8d4
	if (flags & CB_CAN_LOCK_CLIPDATA)
Packit Service 5a9772
		WLog_INFO(TAG, "\tCB_CAN_LOCK_CLIPDATA");
Packit 1fb8d4
Packit Service 5a9772
	WLog_INFO(TAG, "}");
Packit 1fb8d4
}
Packit 1fb8d4
#endif
Packit 1fb8d4
Packit 1fb8d4
/**
Packit 1fb8d4
 * Function description
Packit 1fb8d4
 *
Packit 1fb8d4
 * @return 0 on success, otherwise a Win32 error code
Packit 1fb8d4
 */
Packit Service 5a9772
static UINT cliprdr_process_general_capability(cliprdrPlugin* cliprdr, wStream* s)
Packit 1fb8d4
{
Packit 1fb8d4
	UINT32 version;
Packit 1fb8d4
	UINT32 generalFlags;
Packit 1fb8d4
	CLIPRDR_CAPABILITIES capabilities;
Packit 1fb8d4
	CLIPRDR_GENERAL_CAPABILITY_SET generalCapabilitySet;
Packit 1fb8d4
	CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
Packit 1fb8d4
	UINT error = CHANNEL_RC_OK;
Packit 1fb8d4
Packit 1fb8d4
	if (!context)
Packit 1fb8d4
	{
Packit 1fb8d4
		WLog_ERR(TAG, "cliprdr_get_client_interface failed!");
Packit 1fb8d4
		return ERROR_INTERNAL_ERROR;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	if (Stream_GetRemainingLength(s) < 8)
Packit 1fb8d4
		return ERROR_INVALID_DATA;
Packit 1fb8d4
Packit Service 5a9772
	Stream_Read_UINT32(s, version);      /* version (4 bytes) */
Packit 1fb8d4
	Stream_Read_UINT32(s, generalFlags); /* generalFlags (4 bytes) */
Packit Service 5a9772
	DEBUG_CLIPRDR("Version: %" PRIu32 "", version);
Packit 1fb8d4
#ifdef WITH_DEBUG_CLIPRDR
Packit 1fb8d4
	cliprdr_print_general_capability_flags(generalFlags);
Packit 1fb8d4
#endif
Packit 1fb8d4
Packit Service 5a9772
	cliprdr->useLongFormatNames = (generalFlags & CB_USE_LONG_FORMAT_NAMES);
Packit Service 5a9772
	cliprdr->streamFileClipEnabled = (generalFlags & CB_STREAM_FILECLIP_ENABLED);
Packit Service 5a9772
	cliprdr->fileClipNoFilePaths = (generalFlags & CB_FILECLIP_NO_FILE_PATHS);
Packit Service 5a9772
	cliprdr->canLockClipData = (generalFlags & CB_CAN_LOCK_CLIPDATA);
Packit 1fb8d4
	cliprdr->capabilitiesReceived = TRUE;
Packit 1fb8d4
Packit 1fb8d4
	if (!context->custom)
Packit 1fb8d4
	{
Packit 1fb8d4
		WLog_ERR(TAG, "context->custom not set!");
Packit 1fb8d4
		return ERROR_INTERNAL_ERROR;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit Service 5a9772
	capabilities.msgType = CB_CLIP_CAPS;
Packit 1fb8d4
	capabilities.cCapabilitiesSets = 1;
Packit Service 5a9772
	capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET*)&(generalCapabilitySet);
Packit 1fb8d4
	generalCapabilitySet.capabilitySetType = CB_CAPSTYPE_GENERAL;
Packit 1fb8d4
	generalCapabilitySet.capabilitySetLength = 12;
Packit 1fb8d4
	generalCapabilitySet.version = version;
Packit 1fb8d4
	generalCapabilitySet.generalFlags = generalFlags;
Packit 1fb8d4
	IFCALLRET(context->ServerCapabilities, error, context, &capabilities);
Packit 1fb8d4
Packit 1fb8d4
	if (error)
Packit Service 5a9772
		WLog_ERR(TAG, "ServerCapabilities failed with error %" PRIu32 "!", error);
Packit 1fb8d4
Packit 1fb8d4
	return error;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
/**
Packit 1fb8d4
 * Function description
Packit 1fb8d4
 *
Packit 1fb8d4
 * @return 0 on success, otherwise a Win32 error code
Packit 1fb8d4
 */
Packit Service 5a9772
static UINT cliprdr_process_clip_caps(cliprdrPlugin* cliprdr, wStream* s, UINT32 length,
Packit Service 5a9772
                                      UINT16 flags)
Packit 1fb8d4
{
Packit 1fb8d4
	UINT16 index;
Packit 1fb8d4
	UINT16 lengthCapability;
Packit 1fb8d4
	UINT16 cCapabilitiesSets;
Packit 1fb8d4
	UINT16 capabilitySetType;
Packit 1fb8d4
	UINT error = CHANNEL_RC_OK;
Packit 1fb8d4
Packit 1fb8d4
	if (Stream_GetRemainingLength(s) < 4)
Packit 1fb8d4
		return ERROR_INVALID_DATA;
Packit 1fb8d4
Packit 1fb8d4
	Stream_Read_UINT16(s, cCapabilitiesSets); /* cCapabilitiesSets (2 bytes) */
Packit Service 5a9772
	Stream_Seek_UINT16(s);                    /* pad1 (2 bytes) */
Packit 1fb8d4
	WLog_Print(cliprdr->log, WLOG_DEBUG, "ServerCapabilities");
Packit 1fb8d4
Packit 1fb8d4
	for (index = 0; index < cCapabilitiesSets; index++)
Packit 1fb8d4
	{
Packit 1fb8d4
		if (Stream_GetRemainingLength(s) < 4)
Packit 1fb8d4
			return ERROR_INVALID_DATA;
Packit 1fb8d4
Packit 1fb8d4
		Stream_Read_UINT16(s, capabilitySetType); /* capabilitySetType (2 bytes) */
Packit Service 5a9772
		Stream_Read_UINT16(s, lengthCapability);  /* lengthCapability (2 bytes) */
Packit 1fb8d4
Packit Service 5a9772
		if ((lengthCapability < 4) || (Stream_GetRemainingLength(s) < (lengthCapability - 4U)))
Packit 1fb8d4
			return ERROR_INVALID_DATA;
Packit 1fb8d4
Packit 1fb8d4
		switch (capabilitySetType)
Packit 1fb8d4
		{
Packit 1fb8d4
			case CB_CAPSTYPE_GENERAL:
Packit 1fb8d4
				if ((error = cliprdr_process_general_capability(cliprdr, s)))
Packit 1fb8d4
				{
Packit Service 5a9772
					WLog_ERR(TAG,
Packit Service 5a9772
					         "cliprdr_process_general_capability failed with error %" PRIu32 "!",
Packit 1fb8d4
					         error);
Packit 1fb8d4
					return error;
Packit 1fb8d4
				}
Packit 1fb8d4
Packit 1fb8d4
				break;
Packit 1fb8d4
Packit 1fb8d4
			default:
Packit Service 5a9772
				WLog_ERR(TAG, "unknown cliprdr capability set: %" PRIu16 "", capabilitySetType);
Packit 1fb8d4
				return CHANNEL_RC_BAD_PROC;
Packit 1fb8d4
		}
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	return error;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
/**
Packit 1fb8d4
 * Function description
Packit 1fb8d4
 *
Packit 1fb8d4
 * @return 0 on success, otherwise a Win32 error code
Packit 1fb8d4
 */
Packit Service 5a9772
static UINT cliprdr_process_monitor_ready(cliprdrPlugin* cliprdr, wStream* s, UINT32 length,
Packit Service 5a9772
                                          UINT16 flags)
Packit 1fb8d4
{
Packit 1fb8d4
	CLIPRDR_MONITOR_READY monitorReady;
Packit 1fb8d4
	CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
Packit 1fb8d4
	UINT error = CHANNEL_RC_OK;
Packit 1fb8d4
	WLog_Print(cliprdr->log, WLOG_DEBUG, "MonitorReady");
Packit 1fb8d4
Packit 1fb8d4
	if (!context->custom)
Packit 1fb8d4
	{
Packit 1fb8d4
		WLog_ERR(TAG, "context->custom not set!");
Packit 1fb8d4
		return ERROR_INTERNAL_ERROR;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	if (!cliprdr->capabilitiesReceived)
Packit 1fb8d4
	{
Packit 1fb8d4
		/**
Packit Service 5a9772
		 * The clipboard capabilities pdu from server to client is optional,
Packit Service 5a9772
		 * but a server using it must send it before sending the monitor ready pdu.
Packit Service 5a9772
		 * When the server capabilities pdu is not used, default capabilities
Packit Service 5a9772
		 * corresponding to a generalFlags field set to zero are assumed.
Packit Service 5a9772
		 */
Packit 1fb8d4
		cliprdr->useLongFormatNames = FALSE;
Packit 1fb8d4
		cliprdr->streamFileClipEnabled = FALSE;
Packit 1fb8d4
		cliprdr->fileClipNoFilePaths = TRUE;
Packit 1fb8d4
		cliprdr->canLockClipData = FALSE;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	monitorReady.msgType = CB_MONITOR_READY;
Packit 1fb8d4
	monitorReady.msgFlags = flags;
Packit 1fb8d4
	monitorReady.dataLen = length;
Packit 1fb8d4
	IFCALLRET(context->MonitorReady, error, context, &monitorReady);
Packit 1fb8d4
Packit 1fb8d4
	if (error)
Packit Service 5a9772
		WLog_ERR(TAG, "MonitorReady failed with error %" PRIu32 "!", error);
Packit 1fb8d4
Packit 1fb8d4
	return error;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
/**
Packit 1fb8d4
 * Function description
Packit 1fb8d4
 *
Packit 1fb8d4
 * @return 0 on success, otherwise a Win32 error code
Packit 1fb8d4
 */
Packit Service 5a9772
static UINT cliprdr_process_filecontents_request(cliprdrPlugin* cliprdr, wStream* s, UINT32 length,
Packit Service 5a9772
                                                 UINT16 flags)
Packit 1fb8d4
{
Packit 1fb8d4
	CLIPRDR_FILE_CONTENTS_REQUEST request;
Packit 1fb8d4
	CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
Packit 1fb8d4
	UINT error = CHANNEL_RC_OK;
Packit 1fb8d4
	WLog_Print(cliprdr->log, WLOG_DEBUG, "FileContentsRequest");
Packit 1fb8d4
Packit 1fb8d4
	if (!context->custom)
Packit 1fb8d4
	{
Packit 1fb8d4
		WLog_ERR(TAG, "context->custom not set!");
Packit 1fb8d4
		return ERROR_INTERNAL_ERROR;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	request.msgType = CB_FILECONTENTS_REQUEST;
Packit 1fb8d4
	request.msgFlags = flags;
Packit 1fb8d4
	request.dataLen = length;
Packit Service 5a9772
Packit Service 5a9772
	if ((error = cliprdr_read_file_contents_request(s, &request)))
Packit Service 5a9772
		return error;
Packit 1fb8d4
Packit 1fb8d4
	IFCALLRET(context->ServerFileContentsRequest, error, context, &request);
Packit 1fb8d4
Packit 1fb8d4
	if (error)
Packit Service 5a9772
		WLog_ERR(TAG, "ServerFileContentsRequest failed with error %" PRIu32 "!", error);
Packit 1fb8d4
Packit 1fb8d4
	return error;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
/**
Packit 1fb8d4
 * Function description
Packit 1fb8d4
 *
Packit 1fb8d4
 * @return 0 on success, otherwise a Win32 error code
Packit 1fb8d4
 */
Packit Service 5a9772
static UINT cliprdr_process_filecontents_response(cliprdrPlugin* cliprdr, wStream* s, UINT32 length,
Packit Service 5a9772
                                                  UINT16 flags)
Packit 1fb8d4
{
Packit 1fb8d4
	CLIPRDR_FILE_CONTENTS_RESPONSE response;
Packit 1fb8d4
	CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
Packit 1fb8d4
	UINT error = CHANNEL_RC_OK;
Packit 1fb8d4
	WLog_Print(cliprdr->log, WLOG_DEBUG, "FileContentsResponse");
Packit 1fb8d4
Packit 1fb8d4
	if (!context->custom)
Packit 1fb8d4
	{
Packit 1fb8d4
		WLog_ERR(TAG, "context->custom not set!");
Packit 1fb8d4
		return ERROR_INTERNAL_ERROR;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	response.msgType = CB_FILECONTENTS_RESPONSE;
Packit 1fb8d4
	response.msgFlags = flags;
Packit 1fb8d4
	response.dataLen = length;
Packit Service 5a9772
Packit Service 5a9772
	if ((error = cliprdr_read_file_contents_response(s, &response)))
Packit Service 5a9772
		return error;
Packit Service 5a9772
Packit 1fb8d4
	IFCALLRET(context->ServerFileContentsResponse, error, context, &response);
Packit 1fb8d4
Packit 1fb8d4
	if (error)
Packit Service 5a9772
		WLog_ERR(TAG, "ServerFileContentsResponse failed with error %" PRIu32 "!", error);
Packit 1fb8d4
Packit 1fb8d4
	return error;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
/**
Packit 1fb8d4
 * Function description
Packit 1fb8d4
 *
Packit 1fb8d4
 * @return 0 on success, otherwise a Win32 error code
Packit 1fb8d4
 */
Packit Service 5a9772
static UINT cliprdr_process_lock_clipdata(cliprdrPlugin* cliprdr, wStream* s, UINT32 length,
Packit Service 5a9772
                                          UINT16 flags)
Packit 1fb8d4
{
Packit 1fb8d4
	CLIPRDR_LOCK_CLIPBOARD_DATA lockClipboardData;
Packit 1fb8d4
	CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
Packit 1fb8d4
	UINT error = CHANNEL_RC_OK;
Packit 1fb8d4
	WLog_Print(cliprdr->log, WLOG_DEBUG, "LockClipData");
Packit 1fb8d4
Packit 1fb8d4
	if (!context->custom)
Packit 1fb8d4
	{
Packit 1fb8d4
		WLog_ERR(TAG, "context->custom not set!");
Packit 1fb8d4
		return ERROR_INTERNAL_ERROR;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	if (Stream_GetRemainingLength(s) < 4)
Packit 1fb8d4
	{
Packit 1fb8d4
		WLog_ERR(TAG, "not enough remaining data");
Packit 1fb8d4
		return ERROR_INVALID_DATA;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	lockClipboardData.msgType = CB_LOCK_CLIPDATA;
Packit 1fb8d4
	lockClipboardData.msgFlags = flags;
Packit 1fb8d4
	lockClipboardData.dataLen = length;
Packit 1fb8d4
	Stream_Read_UINT32(s, lockClipboardData.clipDataId); /* clipDataId (4 bytes) */
Packit 1fb8d4
	IFCALLRET(context->ServerLockClipboardData, error, context, &lockClipboardData);
Packit 1fb8d4
Packit 1fb8d4
	if (error)
Packit Service 5a9772
		WLog_ERR(TAG, "ServerLockClipboardData failed with error %" PRIu32 "!", error);
Packit 1fb8d4
Packit 1fb8d4
	return error;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
/**
Packit 1fb8d4
 * Function description
Packit 1fb8d4
 *
Packit 1fb8d4
 * @return 0 on success, otherwise a Win32 error code
Packit 1fb8d4
 */
Packit Service 5a9772
static UINT cliprdr_process_unlock_clipdata(cliprdrPlugin* cliprdr, wStream* s, UINT32 length,
Packit Service 5a9772
                                            UINT16 flags)
Packit 1fb8d4
{
Packit 1fb8d4
	CLIPRDR_UNLOCK_CLIPBOARD_DATA unlockClipboardData;
Packit 1fb8d4
	CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
Packit 1fb8d4
	UINT error = CHANNEL_RC_OK;
Packit 1fb8d4
	WLog_Print(cliprdr->log, WLOG_DEBUG, "UnlockClipData");
Packit 1fb8d4
Packit 1fb8d4
	if (!context->custom)
Packit 1fb8d4
	{
Packit 1fb8d4
		WLog_ERR(TAG, "context->custom not set!");
Packit 1fb8d4
		return ERROR_INTERNAL_ERROR;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit Service 5a9772
	if ((error = cliprdr_read_unlock_clipdata(s, &unlockClipboardData)))
Packit Service 5a9772
		return error;
Packit 1fb8d4
Packit 1fb8d4
	unlockClipboardData.msgType = CB_UNLOCK_CLIPDATA;
Packit 1fb8d4
	unlockClipboardData.msgFlags = flags;
Packit 1fb8d4
	unlockClipboardData.dataLen = length;
Packit Service 5a9772
Packit Service 5a9772
	IFCALLRET(context->ServerUnlockClipboardData, error, context, &unlockClipboardData);
Packit 1fb8d4
Packit 1fb8d4
	if (error)
Packit Service 5a9772
		WLog_ERR(TAG, "ServerUnlockClipboardData failed with error %" PRIu32 "!", error);
Packit 1fb8d4
Packit 1fb8d4
	return error;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
/**
Packit 1fb8d4
 * Function description
Packit 1fb8d4
 *
Packit 1fb8d4
 * @return 0 on success, otherwise a Win32 error code
Packit 1fb8d4
 */
Packit 1fb8d4
static UINT cliprdr_order_recv(cliprdrPlugin* cliprdr, wStream* s)
Packit 1fb8d4
{
Packit 1fb8d4
	UINT16 msgType;
Packit 1fb8d4
	UINT16 msgFlags;
Packit 1fb8d4
	UINT32 dataLen;
Packit 1fb8d4
	UINT error;
Packit 1fb8d4
Packit 1fb8d4
	if (Stream_GetRemainingLength(s) < 8)
Packit 1fb8d4
		return ERROR_INVALID_DATA;
Packit 1fb8d4
Packit Service 5a9772
	Stream_Read_UINT16(s, msgType);  /* msgType (2 bytes) */
Packit 1fb8d4
	Stream_Read_UINT16(s, msgFlags); /* msgFlags (2 bytes) */
Packit Service 5a9772
	Stream_Read_UINT32(s, dataLen);  /* dataLen (4 bytes) */
Packit 1fb8d4
Packit 1fb8d4
	if (Stream_GetRemainingLength(s) < dataLen)
Packit 1fb8d4
		return ERROR_INVALID_DATA;
Packit 1fb8d4
Packit 1fb8d4
#ifdef WITH_DEBUG_CLIPRDR
Packit Service 5a9772
	WLog_DBG(TAG, "msgType: %s (%" PRIu16 "), msgFlags: %" PRIu16 " dataLen: %" PRIu32 "",
Packit 1fb8d4
	         CB_MSG_TYPE_STRINGS[msgType], msgType, msgFlags, dataLen);
Packit 1fb8d4
	winpr_HexDump(TAG, WLOG_DEBUG, Stream_Buffer(s), dataLen + 8);
Packit 1fb8d4
#endif
Packit 1fb8d4
Packit 1fb8d4
	switch (msgType)
Packit 1fb8d4
	{
Packit 1fb8d4
		case CB_CLIP_CAPS:
Packit 1fb8d4
			if ((error = cliprdr_process_clip_caps(cliprdr, s, dataLen, msgFlags)))
Packit Service 5a9772
				WLog_ERR(TAG, "cliprdr_process_clip_caps failed with error %" PRIu32 "!", error);
Packit 1fb8d4
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		case CB_MONITOR_READY:
Packit 1fb8d4
			if ((error = cliprdr_process_monitor_ready(cliprdr, s, dataLen, msgFlags)))
Packit Service 5a9772
				WLog_ERR(TAG, "cliprdr_process_monitor_ready failed with error %" PRIu32 "!",
Packit Service 5a9772
				         error);
Packit 1fb8d4
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		case CB_FORMAT_LIST:
Packit 1fb8d4
			if ((error = cliprdr_process_format_list(cliprdr, s, dataLen, msgFlags)))
Packit Service 5a9772
				WLog_ERR(TAG, "cliprdr_process_format_list failed with error %" PRIu32 "!", error);
Packit 1fb8d4
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		case CB_FORMAT_LIST_RESPONSE:
Packit 1fb8d4
			if ((error = cliprdr_process_format_list_response(cliprdr, s, dataLen, msgFlags)))
Packit Service 5a9772
				WLog_ERR(TAG, "cliprdr_process_format_list_response failed with error %" PRIu32 "!",
Packit 1fb8d4
				         error);
Packit 1fb8d4
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		case CB_FORMAT_DATA_REQUEST:
Packit 1fb8d4
			if ((error = cliprdr_process_format_data_request(cliprdr, s, dataLen, msgFlags)))
Packit Service 5a9772
				WLog_ERR(TAG, "cliprdr_process_format_data_request failed with error %" PRIu32 "!",
Packit 1fb8d4
				         error);
Packit 1fb8d4
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		case CB_FORMAT_DATA_RESPONSE:
Packit 1fb8d4
			if ((error = cliprdr_process_format_data_response(cliprdr, s, dataLen, msgFlags)))
Packit Service 5a9772
				WLog_ERR(TAG, "cliprdr_process_format_data_response failed with error %" PRIu32 "!",
Packit 1fb8d4
				         error);
Packit 1fb8d4
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		case CB_FILECONTENTS_REQUEST:
Packit 1fb8d4
			if ((error = cliprdr_process_filecontents_request(cliprdr, s, dataLen, msgFlags)))
Packit Service 5a9772
				WLog_ERR(TAG, "cliprdr_process_filecontents_request failed with error %" PRIu32 "!",
Packit 1fb8d4
				         error);
Packit 1fb8d4
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		case CB_FILECONTENTS_RESPONSE:
Packit 1fb8d4
			if ((error = cliprdr_process_filecontents_response(cliprdr, s, dataLen, msgFlags)))
Packit Service 5a9772
				WLog_ERR(TAG,
Packit Service 5a9772
				         "cliprdr_process_filecontents_response failed with error %" PRIu32 "!",
Packit 1fb8d4
				         error);
Packit 1fb8d4
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		case CB_LOCK_CLIPDATA:
Packit 1fb8d4
			if ((error = cliprdr_process_lock_clipdata(cliprdr, s, dataLen, msgFlags)))
Packit Service 5a9772
				WLog_ERR(TAG, "cliprdr_process_lock_clipdata failed with error %" PRIu32 "!",
Packit Service 5a9772
				         error);
Packit 1fb8d4
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		case CB_UNLOCK_CLIPDATA:
Packit 1fb8d4
			if ((error = cliprdr_process_unlock_clipdata(cliprdr, s, dataLen, msgFlags)))
Packit Service 5a9772
				WLog_ERR(TAG, "cliprdr_process_lock_clipdata failed with error %" PRIu32 "!",
Packit Service 5a9772
				         error);
Packit 1fb8d4
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		default:
Packit 1fb8d4
			error = CHANNEL_RC_BAD_PROC;
Packit Service 5a9772
			WLog_ERR(TAG, "unknown msgType %" PRIu16 "", msgType);
Packit 1fb8d4
			break;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	Stream_Free(s, TRUE);
Packit 1fb8d4
	return error;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
/**
Packit 1fb8d4
 * Callback Interface
Packit 1fb8d4
 */
Packit 1fb8d4
Packit 1fb8d4
/**
Packit 1fb8d4
 * Function description
Packit 1fb8d4
 *
Packit 1fb8d4
 * @return 0 on success, otherwise a Win32 error code
Packit 1fb8d4
 */
Packit 1fb8d4
static UINT cliprdr_client_capabilities(CliprdrClientContext* context,
Packit Service 5a9772
                                        const CLIPRDR_CAPABILITIES* capabilities)
Packit 1fb8d4
{
Packit 1fb8d4
	wStream* s;
Packit Service 5a9772
	UINT32 flags;
Packit Service 5a9772
	const CLIPRDR_GENERAL_CAPABILITY_SET* generalCapabilitySet;
Packit Service 5a9772
	cliprdrPlugin* cliprdr = (cliprdrPlugin*)context->handle;
Packit Service 5a9772
Packit 1fb8d4
	s = cliprdr_packet_new(CB_CLIP_CAPS, 0, 4 + CB_CAPSTYPE_GENERAL_LEN);
Packit 1fb8d4
Packit 1fb8d4
	if (!s)
Packit 1fb8d4
	{
Packit 1fb8d4
		WLog_ERR(TAG, "cliprdr_packet_new failed!");
Packit 1fb8d4
		return ERROR_INTERNAL_ERROR;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	Stream_Write_UINT16(s, 1); /* cCapabilitiesSets */
Packit 1fb8d4
	Stream_Write_UINT16(s, 0); /* pad1 */
Packit Service 5a9772
	generalCapabilitySet = (const CLIPRDR_GENERAL_CAPABILITY_SET*)capabilities->capabilitySets;
Packit Service 5a9772
	Stream_Write_UINT16(s, generalCapabilitySet->capabilitySetType);   /* capabilitySetType */
Packit 1fb8d4
	Stream_Write_UINT16(s, generalCapabilitySet->capabilitySetLength); /* lengthCapability */
Packit Service 5a9772
	Stream_Write_UINT32(s, generalCapabilitySet->version);             /* version */
Packit Service 5a9772
	flags = generalCapabilitySet->generalFlags;
Packit Service 5a9772
Packit Service 5a9772
	/* Client capabilities are sent in response to server capabilities.
Packit Service 5a9772
	 * -> Do not request features the server does not support.
Packit Service 5a9772
	 * -> Update clipboard context feature state to what was agreed upon.
Packit Service 5a9772
	 */
Packit Service 5a9772
	if (!cliprdr->useLongFormatNames)
Packit Service 5a9772
		flags &= ~CB_USE_LONG_FORMAT_NAMES;
Packit Service 5a9772
	if (!cliprdr->streamFileClipEnabled)
Packit Service 5a9772
		flags &= ~CB_STREAM_FILECLIP_ENABLED;
Packit Service 5a9772
	if (!cliprdr->fileClipNoFilePaths)
Packit Service 5a9772
		flags &= ~CB_FILECLIP_NO_FILE_PATHS;
Packit Service 5a9772
	if (!cliprdr->canLockClipData)
Packit Service 5a9772
		flags &= CB_CAN_LOCK_CLIPDATA;
Packit Service 5a9772
Packit Service 5a9772
	cliprdr->useLongFormatNames = flags & CB_USE_LONG_FORMAT_NAMES;
Packit Service 5a9772
	cliprdr->streamFileClipEnabled = flags & CB_STREAM_FILECLIP_ENABLED;
Packit Service 5a9772
	cliprdr->fileClipNoFilePaths = flags & CB_FILECLIP_NO_FILE_PATHS;
Packit Service 5a9772
	cliprdr->canLockClipData = flags & CB_CAN_LOCK_CLIPDATA;
Packit Service 5a9772
Packit Service 5a9772
	Stream_Write_UINT32(s, flags); /* generalFlags */
Packit 1fb8d4
	WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientCapabilities");
Packit 1fb8d4
	return cliprdr_packet_send(cliprdr, s);
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
/**
Packit 1fb8d4
 * Function description
Packit 1fb8d4
 *
Packit 1fb8d4
 * @return 0 on success, otherwise a Win32 error code
Packit 1fb8d4
 */
Packit 1fb8d4
static UINT cliprdr_temp_directory(CliprdrClientContext* context,
Packit Service 5a9772
                                   const CLIPRDR_TEMP_DIRECTORY* tempDirectory)
Packit 1fb8d4
{
Packit 1fb8d4
	int length;
Packit 1fb8d4
	wStream* s;
Packit 1fb8d4
	WCHAR* wszTempDir = NULL;
Packit Service 5a9772
	cliprdrPlugin* cliprdr = (cliprdrPlugin*)context->handle;
Packit Service 5a9772
	s = cliprdr_packet_new(CB_TEMP_DIRECTORY, 0, 260 * sizeof(WCHAR));
Packit 1fb8d4
Packit 1fb8d4
	if (!s)
Packit 1fb8d4
	{
Packit 1fb8d4
		WLog_ERR(TAG, "cliprdr_packet_new failed!");
Packit 1fb8d4
		return ERROR_INTERNAL_ERROR;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	length = ConvertToUnicode(CP_UTF8, 0, tempDirectory->szTempDir, -1, &wszTempDir, 0);
Packit 1fb8d4
Packit 1fb8d4
	if (length < 0)
Packit 1fb8d4
		return ERROR_INTERNAL_ERROR;
Packit 1fb8d4
Packit Service 5a9772
	/* Path must be 260 UTF16 characters with '\0' termination.
Packit Service 5a9772
	 * ensure this here */
Packit Service 5a9772
	if (length >= 260)
Packit Service 5a9772
		length = 259;
Packit 1fb8d4
Packit Service 5a9772
	Stream_Write_UTF16_String(s, wszTempDir, length);
Packit Service 5a9772
	Stream_Zero(s, 520 - (length * sizeof(WCHAR)));
Packit 1fb8d4
	free(wszTempDir);
Packit Service 5a9772
	WLog_Print(cliprdr->log, WLOG_DEBUG, "TempDirectory: %s", tempDirectory->szTempDir);
Packit 1fb8d4
	return cliprdr_packet_send(cliprdr, s);
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
/**
Packit 1fb8d4
 * Function description
Packit 1fb8d4
 *
Packit 1fb8d4
 * @return 0 on success, otherwise a Win32 error code
Packit 1fb8d4
 */
Packit 1fb8d4
static UINT cliprdr_client_format_list(CliprdrClientContext* context,
Packit Service 5a9772
                                       const CLIPRDR_FORMAT_LIST* formatList)
Packit 1fb8d4
{
Packit 1fb8d4
	wStream* s;
Packit Service 5a9772
	cliprdrPlugin* cliprdr = (cliprdrPlugin*)context->handle;
Packit 1fb8d4
Packit Service 5a9772
	s = cliprdr_packet_format_list_new(formatList, cliprdr->useLongFormatNames);
Packit Service 5a9772
	if (!s)
Packit 1fb8d4
	{
Packit Service 5a9772
		WLog_ERR(TAG, "cliprdr_packet_format_list_new failed!");
Packit Service 5a9772
		return ERROR_INTERNAL_ERROR;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit Service 5a9772
	WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientFormatList: numFormats: %" PRIu32 "",
Packit 1fb8d4
	           formatList->numFormats);
Packit 1fb8d4
	return cliprdr_packet_send(cliprdr, s);
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
/**
Packit 1fb8d4
 * Function description
Packit 1fb8d4
 *
Packit 1fb8d4
 * @return 0 on success, otherwise a Win32 error code
Packit 1fb8d4
 */
Packit Service 5a9772
static UINT
Packit Service 5a9772
cliprdr_client_format_list_response(CliprdrClientContext* context,
Packit Service 5a9772
                                    const CLIPRDR_FORMAT_LIST_RESPONSE* formatListResponse)
Packit 1fb8d4
{
Packit 1fb8d4
	wStream* s;
Packit Service 5a9772
	cliprdrPlugin* cliprdr = (cliprdrPlugin*)context->handle;
Packit Service 5a9772
	s = cliprdr_packet_new(CB_FORMAT_LIST_RESPONSE, formatListResponse->msgFlags, 0);
Packit 1fb8d4
Packit 1fb8d4
	if (!s)
Packit 1fb8d4
	{
Packit 1fb8d4
		WLog_ERR(TAG, "cliprdr_packet_new failed!");
Packit 1fb8d4
		return ERROR_INTERNAL_ERROR;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientFormatListResponse");
Packit 1fb8d4
	return cliprdr_packet_send(cliprdr, s);
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
/**
Packit 1fb8d4
 * Function description
Packit 1fb8d4
 *
Packit 1fb8d4
 * @return 0 on success, otherwise a Win32 error code
Packit 1fb8d4
 */
Packit 1fb8d4
static UINT cliprdr_client_lock_clipboard_data(CliprdrClientContext* context,
Packit Service 5a9772
                                               const CLIPRDR_LOCK_CLIPBOARD_DATA* lockClipboardData)
Packit 1fb8d4
{
Packit 1fb8d4
	wStream* s;
Packit Service 5a9772
	cliprdrPlugin* cliprdr = (cliprdrPlugin*)context->handle;
Packit Service 5a9772
	s = cliprdr_packet_lock_clipdata_new(lockClipboardData);
Packit 1fb8d4
Packit 1fb8d4
	if (!s)
Packit 1fb8d4
	{
Packit 1fb8d4
		WLog_ERR(TAG, "cliprdr_packet_new failed!");
Packit 1fb8d4
		return ERROR_INTERNAL_ERROR;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit Service 5a9772
	WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientLockClipboardData: clipDataId: 0x%08" PRIX32 "",
Packit 1fb8d4
	           lockClipboardData->clipDataId);
Packit 1fb8d4
	return cliprdr_packet_send(cliprdr, s);
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
/**
Packit 1fb8d4
 * Function description
Packit 1fb8d4
 *
Packit 1fb8d4
 * @return 0 on success, otherwise a Win32 error code
Packit 1fb8d4
 */
Packit Service 5a9772
static UINT
Packit Service 5a9772
cliprdr_client_unlock_clipboard_data(CliprdrClientContext* context,
Packit Service 5a9772
                                     const CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData)
Packit 1fb8d4
{
Packit 1fb8d4
	wStream* s;
Packit Service 5a9772
	cliprdrPlugin* cliprdr = (cliprdrPlugin*)context->handle;
Packit Service 5a9772
	s = cliprdr_packet_unlock_clipdata_new(unlockClipboardData);
Packit 1fb8d4
Packit 1fb8d4
	if (!s)
Packit 1fb8d4
	{
Packit 1fb8d4
		WLog_ERR(TAG, "cliprdr_packet_new failed!");
Packit 1fb8d4
		return ERROR_INTERNAL_ERROR;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit Service 5a9772
	WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientUnlockClipboardData: clipDataId: 0x%08" PRIX32 "",
Packit 1fb8d4
	           unlockClipboardData->clipDataId);
Packit 1fb8d4
	return cliprdr_packet_send(cliprdr, s);
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
/**
Packit 1fb8d4
 * Function description
Packit 1fb8d4
 *
Packit 1fb8d4
 * @return 0 on success, otherwise a Win32 error code
Packit 1fb8d4
 */
Packit 1fb8d4
static UINT cliprdr_client_format_data_request(CliprdrClientContext* context,
Packit Service 5a9772
                                               const CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest)
Packit 1fb8d4
{
Packit 1fb8d4
	wStream* s;
Packit Service 5a9772
	cliprdrPlugin* cliprdr = (cliprdrPlugin*)context->handle;
Packit Service 5a9772
Packit Service 5a9772
	s = cliprdr_packet_new(CB_FORMAT_DATA_REQUEST, 0, 4);
Packit 1fb8d4
Packit 1fb8d4
	if (!s)
Packit 1fb8d4
	{
Packit 1fb8d4
		WLog_ERR(TAG, "cliprdr_packet_new failed!");
Packit 1fb8d4
		return ERROR_INTERNAL_ERROR;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	Stream_Write_UINT32(s, formatDataRequest->requestedFormatId); /* requestedFormatId (4 bytes) */
Packit 1fb8d4
	WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientFormatDataRequest");
Packit 1fb8d4
	return cliprdr_packet_send(cliprdr, s);
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
/**
Packit 1fb8d4
 * Function description
Packit 1fb8d4
 *
Packit 1fb8d4
 * @return 0 on success, otherwise a Win32 error code
Packit 1fb8d4
 */
Packit Service 5a9772
static UINT
Packit Service 5a9772
cliprdr_client_format_data_response(CliprdrClientContext* context,
Packit Service 5a9772
                                    const CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse)
Packit 1fb8d4
{
Packit 1fb8d4
	wStream* s;
Packit Service 5a9772
	cliprdrPlugin* cliprdr = (cliprdrPlugin*)context->handle;
Packit Service 5a9772
Packit Service 5a9772
	s = cliprdr_packet_new(CB_FORMAT_DATA_RESPONSE, formatDataResponse->msgFlags,
Packit Service 5a9772
	                       formatDataResponse->dataLen);
Packit 1fb8d4
Packit 1fb8d4
	if (!s)
Packit 1fb8d4
	{
Packit 1fb8d4
		WLog_ERR(TAG, "cliprdr_packet_new failed!");
Packit 1fb8d4
		return ERROR_INTERNAL_ERROR;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit Service 5a9772
	Stream_Write(s, formatDataResponse->requestedFormatData, formatDataResponse->dataLen);
Packit 1fb8d4
	WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientFormatDataResponse");
Packit 1fb8d4
	return cliprdr_packet_send(cliprdr, s);
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
/**
Packit 1fb8d4
 * Function description
Packit 1fb8d4
 *
Packit 1fb8d4
 * @return 0 on success, otherwise a Win32 error code
Packit 1fb8d4
 */
Packit Service 5a9772
static UINT
Packit Service 5a9772
cliprdr_client_file_contents_request(CliprdrClientContext* context,
Packit Service 5a9772
                                     const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
Packit 1fb8d4
{
Packit 1fb8d4
	wStream* s;
Packit Service 5a9772
	cliprdrPlugin* cliprdr = (cliprdrPlugin*)context->handle;
Packit Service 5a9772
Packit Service 5a9772
	s = cliprdr_packet_file_contents_request_new(fileContentsRequest);
Packit 1fb8d4
Packit 1fb8d4
	if (!s)
Packit 1fb8d4
	{
Packit Service 5a9772
		WLog_ERR(TAG, "cliprdr_packet_file_contents_request_new failed!");
Packit 1fb8d4
		return ERROR_INTERNAL_ERROR;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit Service 5a9772
	WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientFileContentsRequest: streamId: 0x%08" PRIX32 "",
Packit 1fb8d4
	           fileContentsRequest->streamId);
Packit 1fb8d4
	return cliprdr_packet_send(cliprdr, s);
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
/**
Packit 1fb8d4
 * Function description
Packit 1fb8d4
 *
Packit 1fb8d4
 * @return 0 on success, otherwise a Win32 error code
Packit 1fb8d4
 */
Packit Service 5a9772
static UINT
Packit Service 5a9772
cliprdr_client_file_contents_response(CliprdrClientContext* context,
Packit Service 5a9772
                                      const CLIPRDR_FILE_CONTENTS_RESPONSE* fileContentsResponse)
Packit 1fb8d4
{
Packit 1fb8d4
	wStream* s;
Packit Service 5a9772
	cliprdrPlugin* cliprdr = (cliprdrPlugin*)context->handle;
Packit Service 5a9772
	s = cliprdr_packet_file_contents_response_new(fileContentsResponse);
Packit 1fb8d4
Packit 1fb8d4
	if (!s)
Packit 1fb8d4
	{
Packit 1fb8d4
		WLog_ERR(TAG, "cliprdr_packet_new failed!");
Packit 1fb8d4
		return ERROR_INTERNAL_ERROR;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit Service 5a9772
	WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientFileContentsResponse: streamId: 0x%08" PRIX32 "",
Packit 1fb8d4
	           fileContentsResponse->streamId);
Packit 1fb8d4
	return cliprdr_packet_send(cliprdr, s);
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
/**
Packit 1fb8d4
 * Function description
Packit 1fb8d4
 *
Packit 1fb8d4
 * @return 0 on success, otherwise a Win32 error code
Packit 1fb8d4
 */
Packit Service 5a9772
static UINT cliprdr_virtual_channel_event_data_received(cliprdrPlugin* cliprdr, void* pData,
Packit Service 5a9772
                                                        UINT32 dataLength, UINT32 totalLength,
Packit Service 5a9772
                                                        UINT32 dataFlags)
Packit 1fb8d4
{
Packit 1fb8d4
	wStream* data_in;
Packit 1fb8d4
Packit 1fb8d4
	if ((dataFlags & CHANNEL_FLAG_SUSPEND) || (dataFlags & CHANNEL_FLAG_RESUME))
Packit 1fb8d4
	{
Packit 1fb8d4
		return CHANNEL_RC_OK;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	if (dataFlags & CHANNEL_FLAG_FIRST)
Packit 1fb8d4
	{
Packit 1fb8d4
		if (cliprdr->data_in)
Packit 1fb8d4
			Stream_Free(cliprdr->data_in, TRUE);
Packit 1fb8d4
Packit 1fb8d4
		cliprdr->data_in = Stream_New(NULL, totalLength);
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	if (!(data_in = cliprdr->data_in))
Packit 1fb8d4
	{
Packit 1fb8d4
		WLog_ERR(TAG, "Stream_New failed!");
Packit 1fb8d4
		return CHANNEL_RC_NO_MEMORY;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit Service 5a9772
	if (!Stream_EnsureRemainingCapacity(data_in, dataLength))
Packit 1fb8d4
	{
Packit 1fb8d4
		Stream_Free(cliprdr->data_in, TRUE);
Packit 1fb8d4
		cliprdr->data_in = NULL;
Packit 1fb8d4
		return CHANNEL_RC_NO_MEMORY;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	Stream_Write(data_in, pData, dataLength);
Packit 1fb8d4
Packit 1fb8d4
	if (dataFlags & CHANNEL_FLAG_LAST)
Packit 1fb8d4
	{
Packit 1fb8d4
		if (Stream_Capacity(data_in) != Stream_GetPosition(data_in))
Packit 1fb8d4
		{
Packit 1fb8d4
			WLog_ERR(TAG, "cliprdr_plugin_process_received: read error");
Packit 1fb8d4
			return ERROR_INTERNAL_ERROR;
Packit 1fb8d4
		}
Packit 1fb8d4
Packit 1fb8d4
		cliprdr->data_in = NULL;
Packit 1fb8d4
		Stream_SealLength(data_in);
Packit 1fb8d4
		Stream_SetPosition(data_in, 0);
Packit 1fb8d4
Packit Service 5a9772
		if (!MessageQueue_Post(cliprdr->queue, NULL, 0, (void*)data_in, NULL))
Packit 1fb8d4
		{
Packit 1fb8d4
			WLog_ERR(TAG, "MessageQueue_Post failed!");
Packit 1fb8d4
			return ERROR_INTERNAL_ERROR;
Packit 1fb8d4
		}
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	return CHANNEL_RC_OK;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
static VOID VCAPITYPE cliprdr_virtual_channel_open_event_ex(LPVOID lpUserParam, DWORD openHandle,
Packit Service 5a9772
                                                            UINT event, LPVOID pData,
Packit Service 5a9772
                                                            UINT32 dataLength, UINT32 totalLength,
Packit Service 5a9772
                                                            UINT32 dataFlags)
Packit 1fb8d4
{
Packit 1fb8d4
	UINT error = CHANNEL_RC_OK;
Packit Service 5a9772
	cliprdrPlugin* cliprdr = (cliprdrPlugin*)lpUserParam;
Packit 1fb8d4
Packit 1fb8d4
	switch (event)
Packit 1fb8d4
	{
Packit 1fb8d4
		case CHANNEL_EVENT_DATA_RECEIVED:
Packit Service 5a9772
			if (!cliprdr || (cliprdr->OpenHandle != openHandle))
Packit Service 5a9772
			{
Packit Service 5a9772
				WLog_ERR(TAG, "error no match");
Packit Service 5a9772
				return;
Packit Service 5a9772
			}
Packit 1fb8d4
			if ((error = cliprdr_virtual_channel_event_data_received(cliprdr, pData, dataLength,
Packit Service 5a9772
			                                                         totalLength, dataFlags)))
Packit Service 5a9772
				WLog_ERR(TAG, "failed with error %" PRIu32 "", error);
Packit 1fb8d4
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit Service 5a9772
		case CHANNEL_EVENT_WRITE_CANCELLED:
Packit 1fb8d4
		case CHANNEL_EVENT_WRITE_COMPLETE:
Packit Service 5a9772
		{
Packit Service 5a9772
			wStream* s = (wStream*)pData;
Packit Service 5a9772
			Stream_Free(s, TRUE);
Packit Service 5a9772
		}
Packit Service 5a9772
		break;
Packit 1fb8d4
Packit 1fb8d4
		case CHANNEL_EVENT_USER:
Packit 1fb8d4
			break;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit Service 5a9772
	if (error && cliprdr && cliprdr->context->rdpcontext)
Packit 1fb8d4
		setChannelError(cliprdr->context->rdpcontext, error,
Packit 1fb8d4
		                "cliprdr_virtual_channel_open_event_ex reported an error");
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
static DWORD WINAPI cliprdr_virtual_channel_client_thread(LPVOID arg)
Packit 1fb8d4
{
Packit 1fb8d4
	wStream* data;
Packit 1fb8d4
	wMessage message;
Packit Service 5a9772
	cliprdrPlugin* cliprdr = (cliprdrPlugin*)arg;
Packit 1fb8d4
	UINT error = CHANNEL_RC_OK;
Packit 1fb8d4
Packit 1fb8d4
	while (1)
Packit 1fb8d4
	{
Packit 1fb8d4
		if (!MessageQueue_Wait(cliprdr->queue))
Packit 1fb8d4
		{
Packit 1fb8d4
			WLog_ERR(TAG, "MessageQueue_Wait failed!");
Packit 1fb8d4
			error = ERROR_INTERNAL_ERROR;
Packit 1fb8d4
			break;
Packit 1fb8d4
		}
Packit 1fb8d4
Packit 1fb8d4
		if (!MessageQueue_Peek(cliprdr->queue, &message, TRUE))
Packit 1fb8d4
		{
Packit 1fb8d4
			WLog_ERR(TAG, "MessageQueue_Peek failed!");
Packit 1fb8d4
			error = ERROR_INTERNAL_ERROR;
Packit 1fb8d4
			break;
Packit 1fb8d4
		}
Packit 1fb8d4
Packit 1fb8d4
		if (message.id == WMQ_QUIT)
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		if (message.id == 0)
Packit 1fb8d4
		{
Packit Service 5a9772
			data = (wStream*)message.wParam;
Packit 1fb8d4
Packit 1fb8d4
			if ((error = cliprdr_order_recv(cliprdr, data)))
Packit 1fb8d4
			{
Packit Service 5a9772
				WLog_ERR(TAG, "cliprdr_order_recv failed with error %" PRIu32 "!", error);
Packit 1fb8d4
				break;
Packit 1fb8d4
			}
Packit 1fb8d4
		}
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	if (error && cliprdr->context->rdpcontext)
Packit 1fb8d4
		setChannelError(cliprdr->context->rdpcontext, error,
Packit 1fb8d4
		                "cliprdr_virtual_channel_client_thread reported an error");
Packit 1fb8d4
Packit 1fb8d4
	ExitThread(error);
Packit 1fb8d4
	return error;
Packit 1fb8d4
}
Packit 1fb8d4
Packit Service 5a9772
static void cliprdr_free_msg(void* obj)
Packit Service 5a9772
{
Packit Service 5a9772
	wMessage* msg = (wMessage*)obj;
Packit Service 5a9772
Packit Service 5a9772
	if (msg)
Packit Service 5a9772
	{
Packit Service 5a9772
		wStream* s = (wStream*)msg->wParam;
Packit Service 5a9772
		Stream_Free(s, TRUE);
Packit Service 5a9772
	}
Packit Service 5a9772
}
Packit Service 5a9772
Packit 1fb8d4
/**
Packit 1fb8d4
 * Function description
Packit 1fb8d4
 *
Packit 1fb8d4
 * @return 0 on success, otherwise a Win32 error code
Packit 1fb8d4
 */
Packit Service 5a9772
static UINT cliprdr_virtual_channel_event_connected(cliprdrPlugin* cliprdr, LPVOID pData,
Packit Service 5a9772
                                                    UINT32 dataLength)
Packit 1fb8d4
{
Packit 1fb8d4
	UINT32 status;
Packit Service 5a9772
	wObject obj = { 0 };
Packit Service 5a9772
	status = cliprdr->channelEntryPoints.pVirtualChannelOpenEx(
Packit Service 5a9772
	    cliprdr->InitHandle, &cliprdr->OpenHandle, cliprdr->channelDef.name,
Packit Service 5a9772
	    cliprdr_virtual_channel_open_event_ex);
Packit 1fb8d4
Packit 1fb8d4
	if (status != CHANNEL_RC_OK)
Packit 1fb8d4
	{
Packit Service 5a9772
		WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08" PRIX32 "]",
Packit 1fb8d4
		         WTSErrorToString(status), status);
Packit 1fb8d4
		return status;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit Service 5a9772
	obj.fnObjectFree = cliprdr_free_msg;
Packit Service 5a9772
	cliprdr->queue = MessageQueue_New(&obj);
Packit 1fb8d4
Packit 1fb8d4
	if (!cliprdr->queue)
Packit 1fb8d4
	{
Packit 1fb8d4
		WLog_ERR(TAG, "MessageQueue_New failed!");
Packit 1fb8d4
		return ERROR_NOT_ENOUGH_MEMORY;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	if (!(cliprdr->thread = CreateThread(NULL, 0, cliprdr_virtual_channel_client_thread,
Packit Service 5a9772
	                                     (void*)cliprdr, 0, NULL)))
Packit 1fb8d4
	{
Packit 1fb8d4
		WLog_ERR(TAG, "CreateThread failed!");
Packit 1fb8d4
		MessageQueue_Free(cliprdr->queue);
Packit 1fb8d4
		cliprdr->queue = NULL;
Packit 1fb8d4
		return ERROR_INTERNAL_ERROR;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	return CHANNEL_RC_OK;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
/**
Packit 1fb8d4
 * Function description
Packit 1fb8d4
 *
Packit 1fb8d4
 * @return 0 on success, otherwise a Win32 error code
Packit 1fb8d4
 */
Packit 1fb8d4
static UINT cliprdr_virtual_channel_event_disconnected(cliprdrPlugin* cliprdr)
Packit 1fb8d4
{
Packit 1fb8d4
	UINT rc;
Packit 1fb8d4
Packit 1fb8d4
	if (cliprdr->OpenHandle == 0)
Packit 1fb8d4
		return CHANNEL_RC_OK;
Packit 1fb8d4
Packit Service 5a9772
	if (MessageQueue_PostQuit(cliprdr->queue, 0) &&
Packit Service 5a9772
	    (WaitForSingleObject(cliprdr->thread, INFINITE) == WAIT_FAILED))
Packit 1fb8d4
	{
Packit 1fb8d4
		rc = GetLastError();
Packit Service 5a9772
		WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "", rc);
Packit 1fb8d4
		return rc;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	MessageQueue_Free(cliprdr->queue);
Packit 1fb8d4
	CloseHandle(cliprdr->thread);
Packit Service 5a9772
	rc = cliprdr->channelEntryPoints.pVirtualChannelCloseEx(cliprdr->InitHandle,
Packit Service 5a9772
	                                                        cliprdr->OpenHandle);
Packit 1fb8d4
Packit 1fb8d4
	if (CHANNEL_RC_OK != rc)
Packit 1fb8d4
	{
Packit Service 5a9772
		WLog_ERR(TAG, "pVirtualChannelClose failed with %s [%08" PRIX32 "]", WTSErrorToString(rc),
Packit Service 5a9772
		         rc);
Packit 1fb8d4
		return rc;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	cliprdr->OpenHandle = 0;
Packit 1fb8d4
Packit 1fb8d4
	if (cliprdr->data_in)
Packit 1fb8d4
	{
Packit 1fb8d4
		Stream_Free(cliprdr->data_in, TRUE);
Packit 1fb8d4
		cliprdr->data_in = NULL;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	return CHANNEL_RC_OK;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
/**
Packit 1fb8d4
 * Function description
Packit 1fb8d4
 *
Packit 1fb8d4
 * @return 0 on success, otherwise a Win32 error code
Packit 1fb8d4
 */
Packit 1fb8d4
static UINT cliprdr_virtual_channel_event_terminated(cliprdrPlugin* cliprdr)
Packit 1fb8d4
{
Packit 1fb8d4
	cliprdr->InitHandle = 0;
Packit 1fb8d4
	free(cliprdr->context);
Packit 1fb8d4
	free(cliprdr);
Packit 1fb8d4
	return CHANNEL_RC_OK;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
static VOID VCAPITYPE cliprdr_virtual_channel_init_event_ex(LPVOID lpUserParam, LPVOID pInitHandle,
Packit Service 5a9772
                                                            UINT event, LPVOID pData,
Packit Service 5a9772
                                                            UINT dataLength)
Packit 1fb8d4
{
Packit 1fb8d4
	UINT error = CHANNEL_RC_OK;
Packit Service 5a9772
	cliprdrPlugin* cliprdr = (cliprdrPlugin*)lpUserParam;
Packit 1fb8d4
Packit 1fb8d4
	if (!cliprdr || (cliprdr->InitHandle != pInitHandle))
Packit 1fb8d4
	{
Packit 1fb8d4
		WLog_ERR(TAG, "error no match");
Packit 1fb8d4
		return;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	switch (event)
Packit 1fb8d4
	{
Packit 1fb8d4
		case CHANNEL_EVENT_CONNECTED:
Packit 1fb8d4
			if ((error = cliprdr_virtual_channel_event_connected(cliprdr, pData, dataLength)))
Packit Service 5a9772
				WLog_ERR(TAG,
Packit Service 5a9772
				         "cliprdr_virtual_channel_event_connected failed with error %" PRIu32 "!",
Packit 1fb8d4
				         error);
Packit 1fb8d4
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		case CHANNEL_EVENT_DISCONNECTED:
Packit 1fb8d4
			if ((error = cliprdr_virtual_channel_event_disconnected(cliprdr)))
Packit 1fb8d4
				WLog_ERR(TAG,
Packit Service 5a9772
				         "cliprdr_virtual_channel_event_disconnected failed with error %" PRIu32
Packit Service 5a9772
				         "!",
Packit Service 5a9772
				         error);
Packit 1fb8d4
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		case CHANNEL_EVENT_TERMINATED:
Packit 1fb8d4
			if ((error = cliprdr_virtual_channel_event_terminated(cliprdr)))
Packit Service 5a9772
				WLog_ERR(TAG,
Packit Service 5a9772
				         "cliprdr_virtual_channel_event_terminated failed with error %" PRIu32 "!",
Packit 1fb8d4
				         error);
Packit 1fb8d4
Packit 1fb8d4
			break;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	if (error && cliprdr->context->rdpcontext)
Packit 1fb8d4
		setChannelError(cliprdr->context->rdpcontext, error,
Packit 1fb8d4
		                "cliprdr_virtual_channel_init_event reported an error");
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
/* cliprdr is always built-in */
Packit Service 5a9772
#define VirtualChannelEntryEx cliprdr_VirtualChannelEntryEx
Packit 1fb8d4
Packit 1fb8d4
BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID pInitHandle)
Packit 1fb8d4
{
Packit 1fb8d4
	UINT rc;
Packit 1fb8d4
	cliprdrPlugin* cliprdr;
Packit 1fb8d4
	CliprdrClientContext* context = NULL;
Packit 1fb8d4
	CHANNEL_ENTRY_POINTS_FREERDP_EX* pEntryPointsEx;
Packit Service 5a9772
	cliprdr = (cliprdrPlugin*)calloc(1, sizeof(cliprdrPlugin));
Packit 1fb8d4
Packit 1fb8d4
	if (!cliprdr)
Packit 1fb8d4
	{
Packit 1fb8d4
		WLog_ERR(TAG, "calloc failed!");
Packit 1fb8d4
		return FALSE;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit Service 5a9772
	cliprdr->channelDef.options = CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP |
Packit Service 5a9772
	                              CHANNEL_OPTION_COMPRESS_RDP | CHANNEL_OPTION_SHOW_PROTOCOL;
Packit 1fb8d4
	sprintf_s(cliprdr->channelDef.name, ARRAYSIZE(cliprdr->channelDef.name), "cliprdr");
Packit Service 5a9772
	pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*)pEntryPoints;
Packit 1fb8d4
Packit 1fb8d4
	if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX)) &&
Packit 1fb8d4
	    (pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER))
Packit 1fb8d4
	{
Packit Service 5a9772
		context = (CliprdrClientContext*)calloc(1, sizeof(CliprdrClientContext));
Packit 1fb8d4
Packit 1fb8d4
		if (!context)
Packit 1fb8d4
		{
Packit 1fb8d4
			free(cliprdr);
Packit 1fb8d4
			WLog_ERR(TAG, "calloc failed!");
Packit 1fb8d4
			return FALSE;
Packit 1fb8d4
		}
Packit 1fb8d4
Packit Service 5a9772
		context->handle = (void*)cliprdr;
Packit 1fb8d4
		context->custom = NULL;
Packit 1fb8d4
		context->ClientCapabilities = cliprdr_client_capabilities;
Packit 1fb8d4
		context->TempDirectory = cliprdr_temp_directory;
Packit 1fb8d4
		context->ClientFormatList = cliprdr_client_format_list;
Packit 1fb8d4
		context->ClientFormatListResponse = cliprdr_client_format_list_response;
Packit 1fb8d4
		context->ClientLockClipboardData = cliprdr_client_lock_clipboard_data;
Packit 1fb8d4
		context->ClientUnlockClipboardData = cliprdr_client_unlock_clipboard_data;
Packit 1fb8d4
		context->ClientFormatDataRequest = cliprdr_client_format_data_request;
Packit 1fb8d4
		context->ClientFormatDataResponse = cliprdr_client_format_data_response;
Packit 1fb8d4
		context->ClientFileContentsRequest = cliprdr_client_file_contents_request;
Packit 1fb8d4
		context->ClientFileContentsResponse = cliprdr_client_file_contents_response;
Packit 1fb8d4
		cliprdr->context = context;
Packit 1fb8d4
		context->rdpcontext = pEntryPointsEx->context;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	cliprdr->log = WLog_Get("com.freerdp.channels.cliprdr.client");
Packit 1fb8d4
	WLog_Print(cliprdr->log, WLOG_DEBUG, "VirtualChannelEntryEx");
Packit 1fb8d4
	CopyMemory(&(cliprdr->channelEntryPoints), pEntryPoints,
Packit 1fb8d4
	           sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX));
Packit 1fb8d4
	cliprdr->InitHandle = pInitHandle;
Packit Service 5a9772
	rc = cliprdr->channelEntryPoints.pVirtualChannelInitEx(
Packit Service 5a9772
	    cliprdr, context, pInitHandle, &cliprdr->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
Packit Service 5a9772
	    cliprdr_virtual_channel_init_event_ex);
Packit 1fb8d4
Packit 1fb8d4
	if (CHANNEL_RC_OK != rc)
Packit 1fb8d4
	{
Packit Service 5a9772
		WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08" PRIX32 "]", WTSErrorToString(rc),
Packit Service 5a9772
		         rc);
Packit 1fb8d4
		free(cliprdr->context);
Packit 1fb8d4
		free(cliprdr);
Packit 1fb8d4
		return FALSE;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	cliprdr->channelEntryPoints.pInterface = context;
Packit 1fb8d4
	return TRUE;
Packit 1fb8d4
}