2011-08-10 01:42:10 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-08-10 01:42:10 +04:00
|
|
|
* RAIL Virtual Channel Plugin
|
|
|
|
*
|
|
|
|
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
|
|
|
* Copyright 2011 Roman Barabanov <romanbarabanov@gmail.com>
|
|
|
|
* Copyright 2011 Vic Lee
|
2015-06-08 19:04:05 +03:00
|
|
|
* Copyright 2015 Thincast Technologies GmbH
|
|
|
|
* Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
|
2011-08-10 01:42:10 +04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2012-08-15 01:09:01 +04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2012-10-09 04:26:11 +04:00
|
|
|
#include <winpr/crt.h>
|
|
|
|
|
2011-08-10 01:42:10 +04:00
|
|
|
#include <freerdp/types.h>
|
2012-10-09 04:26:11 +04:00
|
|
|
#include <freerdp/constants.h>
|
2011-08-10 01:42:10 +04:00
|
|
|
|
2011-08-12 00:27:16 +04:00
|
|
|
#include "rail_orders.h"
|
2011-08-10 01:42:10 +04:00
|
|
|
#include "rail_main.h"
|
|
|
|
|
2016-11-14 23:23:05 +03:00
|
|
|
static rdpChannelHandles g_ChannelHandles = { NULL, NULL };
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2014-11-12 18:43:02 +03:00
|
|
|
RailClientContext* rail_get_client_interface(railPlugin* rail)
|
2013-10-15 07:16:40 +04:00
|
|
|
{
|
|
|
|
RailClientContext* pInterface;
|
2014-11-12 18:43:02 +03:00
|
|
|
pInterface = (RailClientContext*) rail->channelEntryPoints.pInterface;
|
2013-10-15 07:16:40 +04:00
|
|
|
return pInterface;
|
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rail_send(railPlugin* rail, wStream* s)
|
2011-08-10 01:42:10 +04:00
|
|
|
{
|
2015-08-27 15:25:09 +03:00
|
|
|
UINT status;
|
2011-08-10 01:42:10 +04:00
|
|
|
|
2014-11-12 18:43:02 +03:00
|
|
|
if (!rail)
|
|
|
|
{
|
|
|
|
status = CHANNEL_RC_BAD_INIT_HANDLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
status = rail->channelEntryPoints.pVirtualChannelWrite(rail->OpenHandle,
|
2016-09-26 13:12:37 +03:00
|
|
|
Stream_Buffer(s), (UINT32) Stream_GetPosition(s), s);
|
2014-11-12 18:43:02 +03:00
|
|
|
}
|
2011-08-10 01:42:10 +04:00
|
|
|
|
2014-11-12 18:43:02 +03:00
|
|
|
if (status != CHANNEL_RC_OK)
|
|
|
|
{
|
|
|
|
Stream_Free(s, TRUE);
|
2015-01-20 13:55:50 +03:00
|
|
|
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
2016-09-26 13:12:37 +03:00
|
|
|
WTSErrorToString(status), status);
|
2014-11-12 18:43:02 +03:00
|
|
|
}
|
2011-08-10 01:42:10 +04:00
|
|
|
|
2014-11-12 18:43:02 +03:00
|
|
|
return status;
|
2011-08-10 01:42:10 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
|
|
|
UINT rail_send_channel_data(railPlugin* rail, void* data, size_t length)
|
2011-08-10 01:42:10 +04:00
|
|
|
{
|
2014-11-12 18:43:02 +03:00
|
|
|
wStream* s = NULL;
|
|
|
|
s = Stream_New(NULL, length);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-06-08 19:04:05 +03:00
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Stream_New failed!");
|
|
|
|
return CHANNEL_RC_NO_MEMORY;
|
|
|
|
}
|
2011-08-10 01:42:10 +04:00
|
|
|
|
2016-08-09 13:04:06 +03:00
|
|
|
Stream_Write(s, data, length);
|
2015-06-08 19:04:05 +03:00
|
|
|
return rail_send(rail, s);
|
2011-08-12 12:26:57 +04:00
|
|
|
}
|
2011-08-10 01:42:10 +04:00
|
|
|
|
2013-10-12 01:09:36 +04:00
|
|
|
/**
|
|
|
|
* Callback Interface
|
|
|
|
*/
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rail_client_execute(RailClientContext* context,
|
2016-09-26 13:12:37 +03:00
|
|
|
RAIL_EXEC_ORDER* exec)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2013-10-15 07:16:40 +04:00
|
|
|
char* exeOrFile;
|
2014-11-12 17:46:04 +03:00
|
|
|
railPlugin* rail = (railPlugin*) context->handle;
|
2013-10-15 07:16:40 +04:00
|
|
|
exeOrFile = exec->RemoteApplicationProgram;
|
|
|
|
|
2013-10-23 00:28:23 +04:00
|
|
|
if (!exeOrFile)
|
2015-06-08 19:04:05 +03:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
2013-10-23 00:28:23 +04:00
|
|
|
|
2013-10-15 07:16:40 +04:00
|
|
|
if (strlen(exeOrFile) >= 2)
|
|
|
|
{
|
|
|
|
if (strncmp(exeOrFile, "||", 2) != 0)
|
|
|
|
exec->flags |= RAIL_EXEC_FLAG_FILE;
|
|
|
|
}
|
|
|
|
|
2016-08-09 13:04:06 +03:00
|
|
|
rail_string_to_unicode_string(exec->RemoteApplicationProgram,
|
2016-09-26 13:12:37 +03:00
|
|
|
&exec->exeOrFile); /* RemoteApplicationProgram */
|
2016-08-09 13:04:06 +03:00
|
|
|
rail_string_to_unicode_string(exec->RemoteApplicationWorkingDir,
|
2016-09-26 13:12:37 +03:00
|
|
|
&exec->workingDir); /* ShellWorkingDirectory */
|
2016-08-09 13:04:06 +03:00
|
|
|
rail_string_to_unicode_string(exec->RemoteApplicationArguments,
|
2016-09-26 13:12:37 +03:00
|
|
|
&exec->arguments); /* RemoteApplicationCmdLine */
|
2015-06-08 19:04:05 +03:00
|
|
|
return rail_send_client_exec_order(rail, exec);
|
2013-10-12 01:09:36 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rail_client_activate(RailClientContext* context,
|
2016-09-26 13:12:37 +03:00
|
|
|
RAIL_ACTIVATE_ORDER* activate)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2013-10-21 05:59:03 +04:00
|
|
|
railPlugin* rail = (railPlugin*) context->handle;
|
2015-06-08 19:04:05 +03:00
|
|
|
return rail_send_client_activate_order(rail, activate);
|
2013-10-12 01:09:36 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rail_send_client_sysparam(RailClientContext* context,
|
2016-09-26 13:12:37 +03:00
|
|
|
RAIL_SYSPARAM_ORDER* sysparam)
|
2013-10-15 07:16:40 +04:00
|
|
|
{
|
|
|
|
wStream* s;
|
|
|
|
int length;
|
|
|
|
railPlugin* rail = (railPlugin*) context->handle;
|
2015-08-27 15:25:09 +03:00
|
|
|
UINT error;
|
2013-10-15 07:16:40 +04:00
|
|
|
length = RAIL_SYSPARAM_ORDER_LENGTH;
|
|
|
|
|
|
|
|
switch (sysparam->param)
|
|
|
|
{
|
|
|
|
case SPI_SET_DRAG_FULL_WINDOWS:
|
|
|
|
case SPI_SET_KEYBOARD_CUES:
|
|
|
|
case SPI_SET_KEYBOARD_PREF:
|
|
|
|
case SPI_SET_MOUSE_BUTTON_SWAP:
|
|
|
|
length += 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SPI_SET_WORK_AREA:
|
|
|
|
case SPI_DISPLAY_CHANGE:
|
|
|
|
case SPI_TASKBAR_POS:
|
|
|
|
length += 8;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SPI_SET_HIGH_CONTRAST:
|
|
|
|
length += sysparam->highContrast.colorSchemeLength + 10;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
s = rail_pdu_init(RAIL_SYSPARAM_ORDER_LENGTH + 8);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-05-18 12:28:00 +03:00
|
|
|
if (!s)
|
2015-06-08 19:04:05 +03:00
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "rail_pdu_init failed!");
|
|
|
|
return CHANNEL_RC_NO_MEMORY;
|
|
|
|
}
|
2015-05-18 12:28:00 +03:00
|
|
|
|
2015-06-08 19:04:05 +03:00
|
|
|
if ((error = rail_write_client_sysparam_order(s, sysparam)))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "rail_write_client_sysparam_order failed with error %lu!", error);
|
|
|
|
Stream_Free(s, TRUE);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((error = rail_send_pdu(rail, s, RDP_RAIL_ORDER_SYSPARAM)))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "rail_send_pdu failed with error %lu!", error);
|
|
|
|
}
|
2015-05-18 12:28:00 +03:00
|
|
|
|
2013-10-15 07:16:40 +04:00
|
|
|
Stream_Free(s, TRUE);
|
2015-06-08 19:04:05 +03:00
|
|
|
return error;
|
2013-10-15 07:16:40 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rail_client_system_param(RailClientContext* context,
|
2016-09-26 13:12:37 +03:00
|
|
|
RAIL_SYSPARAM_ORDER* sysparam)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2015-08-27 15:25:09 +03:00
|
|
|
UINT error = CHANNEL_RC_OK;
|
2015-05-18 12:28:00 +03:00
|
|
|
|
2013-10-15 07:16:40 +04:00
|
|
|
if (sysparam->params & SPI_MASK_SET_HIGH_CONTRAST)
|
|
|
|
{
|
|
|
|
sysparam->param = SPI_SET_HIGH_CONTRAST;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-06-08 19:04:05 +03:00
|
|
|
if ((error = rail_send_client_sysparam(context, sysparam)))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "rail_send_client_sysparam failed with error %lu!", error);
|
|
|
|
return error;
|
|
|
|
}
|
2013-10-15 07:16:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sysparam->params & SPI_MASK_TASKBAR_POS)
|
|
|
|
{
|
|
|
|
sysparam->param = SPI_TASKBAR_POS;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-06-08 19:04:05 +03:00
|
|
|
if ((error = rail_send_client_sysparam(context, sysparam)))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "rail_send_client_sysparam failed with error %lu!", error);
|
|
|
|
return error;
|
|
|
|
}
|
2013-10-15 07:16:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sysparam->params & SPI_MASK_SET_MOUSE_BUTTON_SWAP)
|
|
|
|
{
|
|
|
|
sysparam->param = SPI_SET_MOUSE_BUTTON_SWAP;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-06-08 19:04:05 +03:00
|
|
|
if ((error = rail_send_client_sysparam(context, sysparam)))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "rail_send_client_sysparam failed with error %lu!", error);
|
|
|
|
return error;
|
|
|
|
}
|
2013-10-15 07:16:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sysparam->params & SPI_MASK_SET_KEYBOARD_PREF)
|
|
|
|
{
|
|
|
|
sysparam->param = SPI_SET_KEYBOARD_PREF;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-06-08 19:04:05 +03:00
|
|
|
if ((error = rail_send_client_sysparam(context, sysparam)))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "rail_send_client_sysparam failed with error %lu!", error);
|
|
|
|
return error;
|
|
|
|
}
|
2013-10-15 07:16:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sysparam->params & SPI_MASK_SET_DRAG_FULL_WINDOWS)
|
|
|
|
{
|
|
|
|
sysparam->param = SPI_SET_DRAG_FULL_WINDOWS;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-06-08 19:04:05 +03:00
|
|
|
if ((error = rail_send_client_sysparam(context, sysparam)))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "rail_send_client_sysparam failed with error %lu!", error);
|
|
|
|
return error;
|
|
|
|
}
|
2013-10-15 07:16:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sysparam->params & SPI_MASK_SET_KEYBOARD_CUES)
|
|
|
|
{
|
|
|
|
sysparam->param = SPI_SET_KEYBOARD_CUES;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-06-08 19:04:05 +03:00
|
|
|
if ((error = rail_send_client_sysparam(context, sysparam)))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "rail_send_client_sysparam failed with error %lu!", error);
|
|
|
|
return error;
|
|
|
|
}
|
2013-10-15 07:16:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sysparam->params & SPI_MASK_SET_WORK_AREA)
|
|
|
|
{
|
|
|
|
sysparam->param = SPI_SET_WORK_AREA;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-06-08 19:04:05 +03:00
|
|
|
if ((error = rail_send_client_sysparam(context, sysparam)))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "rail_send_client_sysparam failed with error %lu!", error);
|
|
|
|
return error;
|
|
|
|
}
|
2013-10-15 07:16:40 +04:00
|
|
|
}
|
|
|
|
|
2015-06-08 19:04:05 +03:00
|
|
|
return error;
|
2013-10-12 01:09:36 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rail_server_system_param(RailClientContext* context,
|
2016-09-26 13:12:37 +03:00
|
|
|
RAIL_SYSPARAM_ORDER* sysparam)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2015-06-08 19:04:05 +03:00
|
|
|
return CHANNEL_RC_OK; /* stub - should be registered by client */
|
2013-10-12 01:09:36 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rail_client_system_command(RailClientContext* context,
|
2016-09-26 13:12:37 +03:00
|
|
|
RAIL_SYSCOMMAND_ORDER* syscommand)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2013-10-21 05:59:03 +04:00
|
|
|
railPlugin* rail = (railPlugin*) context->handle;
|
2015-06-08 19:04:05 +03:00
|
|
|
return rail_send_client_syscommand_order(rail, syscommand);
|
2013-10-12 01:09:36 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rail_client_handshake(RailClientContext* context,
|
2016-09-26 13:12:37 +03:00
|
|
|
RAIL_HANDSHAKE_ORDER* handshake)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2013-10-21 05:59:03 +04:00
|
|
|
railPlugin* rail = (railPlugin*) context->handle;
|
2015-06-08 19:04:05 +03:00
|
|
|
return rail_send_handshake_order(rail, handshake);
|
2013-10-12 01:09:36 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rail_server_handshake(RailClientContext* context,
|
2016-09-26 13:12:37 +03:00
|
|
|
RAIL_HANDSHAKE_ORDER* handshake)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2015-06-08 19:04:05 +03:00
|
|
|
return CHANNEL_RC_OK; /* stub - should be registered by client */
|
2013-10-12 01:09:36 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rail_client_handshake_ex(RailClientContext* context,
|
2016-09-26 13:12:37 +03:00
|
|
|
RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2013-10-21 05:59:03 +04:00
|
|
|
railPlugin* rail = (railPlugin*) context->handle;
|
2015-06-08 19:04:05 +03:00
|
|
|
return rail_send_handshake_ex_order(rail, handshakeEx);
|
2013-10-12 01:09:36 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rail_server_handshake_ex(RailClientContext* context,
|
2016-09-26 13:12:37 +03:00
|
|
|
RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2015-06-08 19:04:05 +03:00
|
|
|
return CHANNEL_RC_OK; /* stub - should be registered by client */
|
2013-10-12 01:09:36 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rail_client_notify_event(RailClientContext* context,
|
2016-09-26 13:12:37 +03:00
|
|
|
RAIL_NOTIFY_EVENT_ORDER* notifyEvent)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2013-10-21 05:59:03 +04:00
|
|
|
railPlugin* rail = (railPlugin*) context->handle;
|
2015-06-08 19:04:05 +03:00
|
|
|
return rail_send_client_notify_event_order(rail, notifyEvent);
|
2013-10-12 01:09:36 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rail_client_window_move(RailClientContext* context,
|
2016-09-26 13:12:37 +03:00
|
|
|
RAIL_WINDOW_MOVE_ORDER* windowMove)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2013-10-21 05:59:03 +04:00
|
|
|
railPlugin* rail = (railPlugin*) context->handle;
|
2015-06-08 19:04:05 +03:00
|
|
|
return rail_send_client_window_move_order(rail, windowMove);
|
2013-10-12 01:09:36 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rail_server_local_move_size(RailClientContext* context,
|
2016-09-26 13:12:37 +03:00
|
|
|
RAIL_LOCALMOVESIZE_ORDER* localMoveSize)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2015-06-08 19:04:05 +03:00
|
|
|
return CHANNEL_RC_OK; /* stub - should be registered by client */
|
2013-10-12 01:09:36 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rail_server_min_max_info(RailClientContext* context,
|
2016-09-26 13:12:37 +03:00
|
|
|
RAIL_MINMAXINFO_ORDER* minMaxInfo)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2015-06-08 19:04:05 +03:00
|
|
|
return CHANNEL_RC_OK; /* stub - should be registered by client */
|
2013-10-12 01:09:36 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rail_client_information(RailClientContext* context,
|
2016-09-26 13:12:37 +03:00
|
|
|
RAIL_CLIENT_STATUS_ORDER* clientStatus)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2013-10-21 05:59:03 +04:00
|
|
|
railPlugin* rail = (railPlugin*) context->handle;
|
2015-06-08 19:04:05 +03:00
|
|
|
return rail_send_client_status_order(rail, clientStatus);
|
2013-10-12 01:09:36 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rail_client_system_menu(RailClientContext* context,
|
2016-09-26 13:12:37 +03:00
|
|
|
RAIL_SYSMENU_ORDER* sysmenu)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2013-10-21 05:59:03 +04:00
|
|
|
railPlugin* rail = (railPlugin*) context->handle;
|
2015-06-08 19:04:05 +03:00
|
|
|
return rail_send_client_sysmenu_order(rail, sysmenu);
|
2013-10-12 01:09:36 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rail_client_language_bar_info(RailClientContext* context,
|
2016-09-26 13:12:37 +03:00
|
|
|
RAIL_LANGBAR_INFO_ORDER* langBarInfo)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2013-10-21 05:59:03 +04:00
|
|
|
railPlugin* rail = (railPlugin*) context->handle;
|
2015-06-08 19:04:05 +03:00
|
|
|
return rail_send_client_langbar_info_order(rail, langBarInfo);
|
2013-10-12 01:09:36 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rail_server_language_bar_info(RailClientContext* context,
|
2016-09-26 13:12:37 +03:00
|
|
|
RAIL_LANGBAR_INFO_ORDER* langBarInfo)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2015-06-08 19:04:05 +03:00
|
|
|
return CHANNEL_RC_OK; /* stub - should be registered by client */
|
2013-10-12 01:09:36 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rail_server_execute_result(RailClientContext* context,
|
2016-09-26 13:12:37 +03:00
|
|
|
RAIL_EXEC_RESULT_ORDER* execResult)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2015-06-08 19:04:05 +03:00
|
|
|
return CHANNEL_RC_OK; /* stub - should be registered by client */
|
2013-10-12 01:09:36 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rail_client_get_appid_request(RailClientContext* context,
|
2016-09-26 13:12:37 +03:00
|
|
|
RAIL_GET_APPID_REQ_ORDER* getAppIdReq)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2013-10-21 05:59:03 +04:00
|
|
|
railPlugin* rail = (railPlugin*) context->handle;
|
2015-06-08 19:04:05 +03:00
|
|
|
return rail_send_client_get_appid_req_order(rail, getAppIdReq);
|
2013-10-12 01:09:36 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rail_server_get_appid_response(RailClientContext* context,
|
2016-09-26 13:12:37 +03:00
|
|
|
RAIL_GET_APPID_RESP_ORDER* getAppIdResp)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2015-06-08 19:04:05 +03:00
|
|
|
return CHANNEL_RC_OK; /* stub - should be registered by client */
|
2013-10-12 01:09:36 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
|
|
|
static UINT rail_virtual_channel_event_data_received(railPlugin* rail,
|
2016-09-26 13:12:37 +03:00
|
|
|
void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
2014-11-12 18:43:02 +03:00
|
|
|
{
|
|
|
|
wStream* data_in;
|
|
|
|
|
|
|
|
if ((dataFlags & CHANNEL_FLAG_SUSPEND) || (dataFlags & CHANNEL_FLAG_RESUME))
|
|
|
|
{
|
2015-06-08 19:04:05 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2014-11-12 18:43:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (dataFlags & CHANNEL_FLAG_FIRST)
|
|
|
|
{
|
|
|
|
if (rail->data_in)
|
|
|
|
Stream_Free(rail->data_in, TRUE);
|
|
|
|
|
|
|
|
rail->data_in = Stream_New(NULL, totalLength);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-05-18 12:28:00 +03:00
|
|
|
if (!rail->data_in)
|
|
|
|
{
|
2015-06-08 19:04:05 +03:00
|
|
|
WLog_ERR(TAG, "Stream_New failed!");
|
|
|
|
return CHANNEL_RC_NO_MEMORY;
|
2015-05-18 12:28:00 +03:00
|
|
|
}
|
2014-11-12 18:43:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
data_in = rail->data_in;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-05-18 12:28:00 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(data_in, (int) dataLength))
|
|
|
|
{
|
2015-06-08 19:04:05 +03:00
|
|
|
WLog_ERR(TAG, "Stream_EnsureRemainingCapacity failed!");
|
|
|
|
return CHANNEL_RC_NO_MEMORY;
|
2015-05-18 12:28:00 +03:00
|
|
|
}
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2014-11-12 18:43:02 +03:00
|
|
|
Stream_Write(data_in, pData, dataLength);
|
|
|
|
|
|
|
|
if (dataFlags & CHANNEL_FLAG_LAST)
|
|
|
|
{
|
|
|
|
if (Stream_Capacity(data_in) != Stream_GetPosition(data_in))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "rail_plugin_process_received: read error");
|
2015-06-08 19:04:05 +03:00
|
|
|
return ERROR_INTERNAL_ERROR;
|
2014-11-12 18:43:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
rail->data_in = NULL;
|
|
|
|
Stream_SealLength(data_in);
|
|
|
|
Stream_SetPosition(data_in, 0);
|
|
|
|
|
2015-07-15 10:50:35 +03:00
|
|
|
if (!MessageQueue_Post(rail->queue, NULL, 0, (void*) data_in, NULL))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "MessageQueue_Post failed!");
|
|
|
|
return ERROR_INTERNAL_ERROR;
|
|
|
|
}
|
2014-11-12 18:43:02 +03:00
|
|
|
}
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-06-08 19:04:05 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2014-11-12 18:43:02 +03:00
|
|
|
}
|
|
|
|
|
2016-08-09 13:04:06 +03:00
|
|
|
static VOID VCAPITYPE rail_virtual_channel_open_event(DWORD openHandle,
|
2016-09-26 13:12:37 +03:00
|
|
|
UINT event,
|
|
|
|
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
2014-11-12 18:43:02 +03:00
|
|
|
{
|
2015-08-27 15:25:09 +03:00
|
|
|
UINT error = CHANNEL_RC_OK;
|
2016-11-14 23:23:05 +03:00
|
|
|
railPlugin* rail = (railPlugin*) freerdp_channel_get_open_handle_data(&g_ChannelHandles, openHandle);
|
2014-11-12 18:43:02 +03:00
|
|
|
|
2016-08-09 13:04:06 +03:00
|
|
|
if (!rail || (rail->OpenHandle != openHandle))
|
2014-11-12 18:43:02 +03:00
|
|
|
{
|
2015-06-08 19:04:05 +03:00
|
|
|
WLog_ERR(TAG, "rail_virtual_channel_open_event: error no match");
|
2014-11-12 18:43:02 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (event)
|
|
|
|
{
|
|
|
|
case CHANNEL_EVENT_DATA_RECEIVED:
|
2016-08-09 13:04:06 +03:00
|
|
|
if ((error = rail_virtual_channel_event_data_received(rail, pData, dataLength,
|
2016-09-26 13:12:37 +03:00
|
|
|
totalLength, dataFlags)))
|
2016-08-09 13:04:06 +03:00
|
|
|
WLog_ERR(TAG, "rail_virtual_channel_event_data_received failed with error %lu!",
|
2016-09-26 13:12:37 +03:00
|
|
|
error);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2014-11-12 18:43:02 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CHANNEL_EVENT_WRITE_COMPLETE:
|
|
|
|
Stream_Free((wStream*) pData, TRUE);
|
|
|
|
break;
|
2015-01-20 13:55:50 +03:00
|
|
|
|
|
|
|
case CHANNEL_EVENT_USER:
|
|
|
|
break;
|
2014-11-12 18:43:02 +03:00
|
|
|
}
|
2015-07-15 10:50:35 +03:00
|
|
|
|
|
|
|
if (error && rail->rdpcontext)
|
2016-08-09 13:04:06 +03:00
|
|
|
setChannelError(rail->rdpcontext, error,
|
2016-09-26 13:12:37 +03:00
|
|
|
"rail_virtual_channel_open_event reported an error");
|
2015-07-15 10:50:35 +03:00
|
|
|
|
2015-06-08 19:04:05 +03:00
|
|
|
return;
|
2014-11-12 18:43:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void* rail_virtual_channel_client_thread(void* arg)
|
|
|
|
{
|
|
|
|
wStream* data;
|
|
|
|
wMessage message;
|
|
|
|
railPlugin* rail = (railPlugin*) arg;
|
2015-08-27 15:25:09 +03:00
|
|
|
UINT error = CHANNEL_RC_OK;
|
2016-09-26 13:12:37 +03:00
|
|
|
|
2014-11-12 18:43:02 +03:00
|
|
|
while (1)
|
|
|
|
{
|
2014-12-27 23:20:29 +03:00
|
|
|
if (!MessageQueue_Wait(rail->queue))
|
2015-07-15 10:50:35 +03:00
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "MessageQueue_Wait failed!");
|
|
|
|
error = ERROR_INTERNAL_ERROR;
|
2014-11-12 18:43:02 +03:00
|
|
|
break;
|
2015-07-15 10:50:35 +03:00
|
|
|
}
|
2014-11-12 18:43:02 +03:00
|
|
|
|
2015-07-15 10:50:35 +03:00
|
|
|
if (!MessageQueue_Peek(rail->queue, &message, TRUE))
|
2014-11-12 18:43:02 +03:00
|
|
|
{
|
2015-07-15 10:50:35 +03:00
|
|
|
WLog_ERR(TAG, "MessageQueue_Peek failed!");
|
|
|
|
error = ERROR_INTERNAL_ERROR;
|
|
|
|
break;
|
|
|
|
}
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-07-15 10:50:35 +03:00
|
|
|
if (message.id == WMQ_QUIT)
|
|
|
|
break;
|
2014-11-12 18:43:02 +03:00
|
|
|
|
2015-07-15 10:50:35 +03:00
|
|
|
if (message.id == 0)
|
|
|
|
{
|
|
|
|
data = (wStream*) message.wParam;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-07-15 10:50:35 +03:00
|
|
|
if ((error = rail_order_recv(rail, data)))
|
2014-11-12 18:43:02 +03:00
|
|
|
{
|
2015-07-15 10:50:35 +03:00
|
|
|
WLog_ERR(TAG, "rail_order_recv failed with error %d!", error);
|
|
|
|
break;
|
2014-11-12 18:43:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-15 10:50:35 +03:00
|
|
|
if (error && rail->rdpcontext)
|
2016-08-09 13:04:06 +03:00
|
|
|
setChannelError(rail->rdpcontext, error,
|
2016-09-26 13:12:37 +03:00
|
|
|
"rail_virtual_channel_client_thread reported an error");
|
2015-07-15 10:50:35 +03:00
|
|
|
|
2015-06-08 19:04:05 +03:00
|
|
|
ExitThread((DWORD)error);
|
2014-11-12 18:43:02 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rail_virtual_channel_event_connected(railPlugin* rail, LPVOID pData,
|
2016-09-26 13:12:37 +03:00
|
|
|
UINT32 dataLength)
|
2014-11-12 18:43:02 +03:00
|
|
|
{
|
2015-08-27 15:25:09 +03:00
|
|
|
UINT status;
|
2014-11-12 18:43:02 +03:00
|
|
|
status = rail->channelEntryPoints.pVirtualChannelOpen(rail->InitHandle,
|
2016-09-26 13:12:37 +03:00
|
|
|
&rail->OpenHandle, rail->channelDef.name, rail_virtual_channel_open_event);
|
2014-11-12 18:43:02 +03:00
|
|
|
|
2015-06-08 19:04:05 +03:00
|
|
|
if (status != CHANNEL_RC_OK)
|
2015-05-18 12:28:00 +03:00
|
|
|
{
|
2015-06-08 19:04:05 +03:00
|
|
|
WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08X]",
|
2016-09-26 13:12:37 +03:00
|
|
|
WTSErrorToString(status), status);
|
2015-06-08 19:04:05 +03:00
|
|
|
return status;
|
2014-11-12 18:43:02 +03:00
|
|
|
}
|
|
|
|
|
2016-11-14 23:23:05 +03:00
|
|
|
freerdp_channel_add_open_handle_data(&g_ChannelHandles, rail->OpenHandle, (void*) rail);
|
|
|
|
|
2014-12-27 23:20:29 +03:00
|
|
|
rail->queue = MessageQueue_New(NULL);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-05-18 12:28:00 +03:00
|
|
|
if (!rail->queue)
|
|
|
|
{
|
2015-06-08 19:04:05 +03:00
|
|
|
WLog_ERR(TAG, "MessageQueue_New failed!");
|
|
|
|
return CHANNEL_RC_NO_MEMORY;
|
2015-05-18 12:28:00 +03:00
|
|
|
}
|
2014-11-12 18:43:02 +03:00
|
|
|
|
2015-06-08 19:04:05 +03:00
|
|
|
if (!(rail->thread = CreateThread(NULL, 0,
|
2016-09-26 13:12:37 +03:00
|
|
|
(LPTHREAD_START_ROUTINE) rail_virtual_channel_client_thread, (void*) rail, 0,
|
|
|
|
NULL)))
|
2015-06-08 19:04:05 +03:00
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "CreateThread failed!");
|
|
|
|
MessageQueue_Free(rail->queue);
|
|
|
|
rail->queue = NULL;
|
|
|
|
return ERROR_INTERNAL_ERROR;
|
|
|
|
}
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-06-08 19:04:05 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2014-11-12 18:43:02 +03:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
|
|
|
static UINT rail_virtual_channel_event_disconnected(railPlugin* rail)
|
2014-11-12 18:43:02 +03:00
|
|
|
{
|
2015-01-20 13:55:50 +03:00
|
|
|
UINT rc;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
|
|
|
if (MessageQueue_PostQuit(rail->queue, 0)
|
|
|
|
&& (WaitForSingleObject(rail->thread, INFINITE) == WAIT_FAILED))
|
|
|
|
{
|
|
|
|
rc = GetLastError();
|
|
|
|
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", rc);
|
|
|
|
return rc;
|
|
|
|
}
|
2014-11-12 18:43:02 +03:00
|
|
|
|
2015-01-20 13:55:50 +03:00
|
|
|
MessageQueue_Free(rail->queue);
|
|
|
|
CloseHandle(rail->thread);
|
|
|
|
rail->queue = NULL;
|
|
|
|
rail->thread = NULL;
|
|
|
|
rc = rail->channelEntryPoints.pVirtualChannelClose(rail->OpenHandle);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-01-20 13:55:50 +03:00
|
|
|
if (CHANNEL_RC_OK != rc)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "pVirtualChannelClose failed with %s [%08X]",
|
2016-09-26 13:12:37 +03:00
|
|
|
WTSErrorToString(rc), rc);
|
2016-08-09 13:04:06 +03:00
|
|
|
return rc;
|
2015-01-20 13:55:50 +03:00
|
|
|
}
|
2014-11-12 18:43:02 +03:00
|
|
|
|
2016-08-09 13:04:06 +03:00
|
|
|
rail->OpenHandle = 0;
|
|
|
|
|
2014-11-12 18:43:02 +03:00
|
|
|
if (rail->data_in)
|
|
|
|
{
|
|
|
|
Stream_Free(rail->data_in, TRUE);
|
|
|
|
rail->data_in = NULL;
|
|
|
|
}
|
|
|
|
|
2016-11-14 23:23:05 +03:00
|
|
|
freerdp_channel_remove_open_handle_data(&g_ChannelHandles, rail->OpenHandle);
|
|
|
|
|
2016-08-09 13:04:06 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2015-01-20 13:55:50 +03:00
|
|
|
}
|
2014-12-27 23:20:29 +03:00
|
|
|
|
2015-01-20 13:55:50 +03:00
|
|
|
static void rail_virtual_channel_event_terminated(railPlugin* rail)
|
|
|
|
{
|
2016-11-14 23:23:05 +03:00
|
|
|
freerdp_channel_remove_init_handle_data(&g_ChannelHandles, (void*) rail);
|
2016-08-09 13:04:06 +03:00
|
|
|
rail->InitHandle = 0;
|
2014-12-27 23:20:29 +03:00
|
|
|
free(rail);
|
2014-11-12 18:43:02 +03:00
|
|
|
}
|
|
|
|
|
2016-08-09 13:04:06 +03:00
|
|
|
static VOID VCAPITYPE rail_virtual_channel_init_event(LPVOID pInitHandle,
|
2016-09-26 13:12:37 +03:00
|
|
|
UINT event, LPVOID pData, UINT dataLength)
|
2014-11-12 18:43:02 +03:00
|
|
|
{
|
2015-08-27 15:25:09 +03:00
|
|
|
UINT error = CHANNEL_RC_OK;
|
2016-11-14 23:23:05 +03:00
|
|
|
railPlugin* rail = (railPlugin*) freerdp_channel_get_init_handle_data(&g_ChannelHandles, pInitHandle);
|
2014-11-12 18:43:02 +03:00
|
|
|
|
2016-08-09 13:04:06 +03:00
|
|
|
if (!rail || (rail->InitHandle != pInitHandle))
|
2014-11-12 18:43:02 +03:00
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "rail_virtual_channel_init_event: error no match");
|
2016-03-14 15:19:08 +03:00
|
|
|
return;
|
2014-11-12 18:43:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (event)
|
|
|
|
{
|
|
|
|
case CHANNEL_EVENT_CONNECTED:
|
2015-07-15 10:50:35 +03:00
|
|
|
if ((error = rail_virtual_channel_event_connected(rail, pData, dataLength)))
|
2016-08-09 13:04:06 +03:00
|
|
|
WLog_ERR(TAG, "rail_virtual_channel_event_connected failed with error %lu!",
|
2016-09-26 13:12:37 +03:00
|
|
|
error);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2014-11-12 18:43:02 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CHANNEL_EVENT_DISCONNECTED:
|
2015-07-30 16:49:21 +03:00
|
|
|
if ((error = rail_virtual_channel_event_disconnected(rail)))
|
2016-08-09 13:04:06 +03:00
|
|
|
WLog_ERR(TAG, "rail_virtual_channel_event_disconnected failed with error %lu!",
|
2016-09-26 13:12:37 +03:00
|
|
|
error);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2014-11-12 18:43:02 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CHANNEL_EVENT_TERMINATED:
|
|
|
|
rail_virtual_channel_event_terminated(rail);
|
|
|
|
break;
|
|
|
|
}
|
2015-07-15 10:50:35 +03:00
|
|
|
|
2016-08-09 13:04:06 +03:00
|
|
|
if (error && rail->rdpcontext)
|
|
|
|
setChannelError(rail->rdpcontext, error,
|
2016-09-26 13:12:37 +03:00
|
|
|
"rail_virtual_channel_init_event reported an error");
|
2014-11-12 18:43:02 +03:00
|
|
|
}
|
|
|
|
|
2012-10-09 06:48:17 +04:00
|
|
|
/* rail is always built-in */
|
2012-10-09 04:26:11 +04:00
|
|
|
#define VirtualChannelEntry rail_VirtualChannelEntry
|
|
|
|
|
2014-03-04 03:28:31 +04:00
|
|
|
BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
2012-10-09 04:26:11 +04:00
|
|
|
{
|
2015-01-20 13:55:50 +03:00
|
|
|
UINT rc;
|
2013-12-06 01:55:28 +04:00
|
|
|
railPlugin* rail;
|
2016-09-26 13:12:14 +03:00
|
|
|
RailClientContext* context = NULL;
|
2014-02-17 02:38:59 +04:00
|
|
|
CHANNEL_ENTRY_POINTS_FREERDP* pEntryPointsEx;
|
2015-06-08 19:04:05 +03:00
|
|
|
BOOL isFreerdp = FALSE;
|
2014-06-11 16:42:32 +04:00
|
|
|
rail = (railPlugin*) calloc(1, sizeof(railPlugin));
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-06-08 19:04:05 +03:00
|
|
|
if (!rail)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "calloc failed!");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2012-10-09 04:26:11 +04:00
|
|
|
|
2014-11-12 18:43:02 +03:00
|
|
|
rail->channelDef.options =
|
2016-08-09 13:04:06 +03:00
|
|
|
CHANNEL_OPTION_INITIALIZED |
|
|
|
|
CHANNEL_OPTION_ENCRYPT_RDP |
|
|
|
|
CHANNEL_OPTION_COMPRESS_RDP |
|
|
|
|
CHANNEL_OPTION_SHOW_PROTOCOL;
|
2014-11-12 18:43:02 +03:00
|
|
|
strcpy(rail->channelDef.name, "rail");
|
2014-02-17 02:38:59 +04:00
|
|
|
pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP*) pEntryPoints;
|
2013-10-12 01:09:36 +04:00
|
|
|
|
2014-02-17 02:38:59 +04:00
|
|
|
if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_FREERDP)) &&
|
2016-08-09 13:04:06 +03:00
|
|
|
(pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER))
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2014-11-12 00:35:30 +03:00
|
|
|
context = (RailClientContext*) calloc(1, sizeof(RailClientContext));
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-05-18 12:28:00 +03:00
|
|
|
if (!context)
|
2015-06-08 19:04:05 +03:00
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "calloc failed!");
|
|
|
|
free(rail);
|
2015-05-18 12:28:00 +03:00
|
|
|
return FALSE;
|
2015-06-08 19:04:05 +03:00
|
|
|
}
|
2013-10-12 01:09:36 +04:00
|
|
|
|
2013-12-06 01:55:28 +04:00
|
|
|
context->handle = (void*) rail;
|
2014-11-12 00:35:30 +03:00
|
|
|
context->custom = NULL;
|
2013-10-12 01:09:36 +04:00
|
|
|
context->ClientExecute = rail_client_execute;
|
|
|
|
context->ClientActivate = rail_client_activate;
|
2013-10-15 07:16:40 +04:00
|
|
|
context->ClientSystemParam = rail_client_system_param;
|
2013-10-12 01:09:36 +04:00
|
|
|
context->ServerSystemParam = rail_server_system_param;
|
|
|
|
context->ClientSystemCommand = rail_client_system_command;
|
|
|
|
context->ClientHandshake = rail_client_handshake;
|
|
|
|
context->ServerHandshake = rail_server_handshake;
|
2013-10-21 05:59:03 +04:00
|
|
|
context->ClientHandshakeEx = rail_client_handshake_ex;
|
|
|
|
context->ServerHandshakeEx = rail_server_handshake_ex;
|
2013-10-12 01:09:36 +04:00
|
|
|
context->ClientNotifyEvent = rail_client_notify_event;
|
|
|
|
context->ClientWindowMove = rail_client_window_move;
|
|
|
|
context->ServerLocalMoveSize = rail_server_local_move_size;
|
|
|
|
context->ServerMinMaxInfo = rail_server_min_max_info;
|
|
|
|
context->ClientInformation = rail_client_information;
|
|
|
|
context->ClientSystemMenu = rail_client_system_menu;
|
|
|
|
context->ClientLanguageBarInfo = rail_client_language_bar_info;
|
|
|
|
context->ServerLanguageBarInfo = rail_server_language_bar_info;
|
|
|
|
context->ServerExecuteResult = rail_server_execute_result;
|
|
|
|
context->ClientGetAppIdRequest = rail_client_get_appid_request;
|
|
|
|
context->ServerGetAppIdResponse = rail_server_get_appid_response;
|
2015-07-15 10:50:35 +03:00
|
|
|
rail->rdpcontext = pEntryPointsEx->context;
|
2013-10-12 01:09:36 +04:00
|
|
|
*(pEntryPointsEx->ppInterface) = (void*) context;
|
2014-12-27 23:20:29 +03:00
|
|
|
rail->context = context;
|
2015-06-08 19:04:05 +03:00
|
|
|
isFreerdp = TRUE;
|
2013-10-12 01:09:36 +04:00
|
|
|
}
|
|
|
|
|
2013-10-12 01:36:34 +04:00
|
|
|
WLog_Init();
|
2013-12-06 01:55:28 +04:00
|
|
|
rail->log = WLog_Get("com.freerdp.channels.rail.client");
|
|
|
|
WLog_Print(rail->log, WLOG_DEBUG, "VirtualChannelEntry");
|
2016-08-09 13:04:06 +03:00
|
|
|
CopyMemory(&(rail->channelEntryPoints), pEntryPoints,
|
2016-09-26 13:12:37 +03:00
|
|
|
sizeof(CHANNEL_ENTRY_POINTS_FREERDP));
|
2015-01-20 13:55:50 +03:00
|
|
|
rc = rail->channelEntryPoints.pVirtualChannelInit(&rail->InitHandle,
|
2016-09-26 13:12:37 +03:00
|
|
|
&rail->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
|
|
|
|
rail_virtual_channel_init_event);
|
2015-06-08 19:04:05 +03:00
|
|
|
|
2015-01-20 13:55:50 +03:00
|
|
|
if (CHANNEL_RC_OK != rc)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]",
|
2016-09-26 13:12:37 +03:00
|
|
|
WTSErrorToString(rc), rc);
|
2015-06-08 19:04:05 +03:00
|
|
|
goto error_out;
|
2015-01-20 13:55:50 +03:00
|
|
|
}
|
2014-11-12 18:43:02 +03:00
|
|
|
|
|
|
|
rail->channelEntryPoints.pInterface = *(rail->channelEntryPoints.ppInterface);
|
|
|
|
rail->channelEntryPoints.ppInterface = &(rail->channelEntryPoints.pInterface);
|
2016-11-14 23:23:05 +03:00
|
|
|
|
|
|
|
freerdp_channel_add_init_handle_data(&g_ChannelHandles, rail->InitHandle, (void*) rail);
|
|
|
|
|
2015-06-08 19:04:05 +03:00
|
|
|
return TRUE;
|
|
|
|
error_out:
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2016-09-26 13:12:14 +03:00
|
|
|
if (context)
|
|
|
|
*(pEntryPointsEx->ppInterface) = NULL;
|
|
|
|
|
2015-06-08 19:04:05 +03:00
|
|
|
if (isFreerdp)
|
|
|
|
free(rail->context);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-06-08 19:04:05 +03:00
|
|
|
free(rail);
|
|
|
|
return FALSE;
|
2012-10-09 04:26:11 +04:00
|
|
|
}
|