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>
|
2017-02-20 20:31:58 +03:00
|
|
|
* Copyright 2017 Armin Novak <armin.novak@thincast.com>
|
|
|
|
* Copyright 2017 Thincast Technologies GmbH
|
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.
|
|
|
|
*/
|
|
|
|
|
2022-02-16 13:20:38 +03:00
|
|
|
#include <freerdp/config.h>
|
2012-08-15 01:09:01 +04:00
|
|
|
|
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>
|
2023-03-14 12:39:18 +03:00
|
|
|
#include <freerdp/freerdp.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"
|
|
|
|
|
2021-05-29 00:27:17 +03:00
|
|
|
#include "../../../channels/client/addin.h"
|
2021-03-12 18:54:45 +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
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
RailClientContext* pInterface = NULL;
|
2017-12-20 17:00:21 +03:00
|
|
|
|
|
|
|
if (!rail)
|
|
|
|
return NULL;
|
|
|
|
|
2019-11-06 17:24:51 +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
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT status = 0;
|
2011-08-10 01:42:10 +04:00
|
|
|
|
2014-11-12 18:43:02 +03:00
|
|
|
if (!rail)
|
2019-10-28 16:28:11 +03:00
|
|
|
{
|
|
|
|
Stream_Free(s, TRUE);
|
2017-12-20 17:00:21 +03:00
|
|
|
return CHANNEL_RC_BAD_INIT_HANDLE;
|
2019-10-28 16:28:11 +03:00
|
|
|
}
|
2017-12-20 17:00:21 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
status = rail->channelEntryPoints.pVirtualChannelWriteEx(
|
|
|
|
rail->InitHandle, rail->OpenHandle, Stream_Buffer(s), (UINT32)Stream_GetPosition(s), s);
|
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);
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG, "pVirtualChannelWriteEx failed with %s [%08" PRIX32 "]",
|
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
|
|
|
|
*/
|
2019-02-19 16:13:34 +03:00
|
|
|
UINT rail_send_channel_data(railPlugin* rail, wStream* src)
|
2011-08-10 01:42:10 +04:00
|
|
|
{
|
2019-02-19 16:13:34 +03:00
|
|
|
if (!rail || !src)
|
2015-06-08 19:04:05 +03:00
|
|
|
{
|
2024-08-26 15:09:25 +03:00
|
|
|
Stream_Free(src, TRUE);
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
2015-06-08 19:04:05 +03:00
|
|
|
}
|
2011-08-10 01:42:10 +04:00
|
|
|
|
2024-08-26 15:09:25 +03:00
|
|
|
return rail_send(rail, src);
|
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
|
|
|
|
*/
|
2019-11-06 17:24:51 +03:00
|
|
|
static UINT rail_client_execute(RailClientContext* context, const RAIL_EXEC_ORDER* exec)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2024-04-17 22:56:37 +03:00
|
|
|
const char* exeOrFile = NULL;
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT error = 0;
|
|
|
|
railPlugin* rail = NULL;
|
|
|
|
UINT16 flags = 0;
|
2018-09-14 11:04:16 +03:00
|
|
|
RAIL_UNICODE_STRING ruExeOrFile = { 0 };
|
|
|
|
RAIL_UNICODE_STRING ruWorkingDir = { 0 };
|
|
|
|
RAIL_UNICODE_STRING ruArguments = { 0 };
|
2017-12-20 17:00:21 +03:00
|
|
|
|
|
|
|
if (!context || !exec)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
rail = (railPlugin*)context->handle;
|
2013-10-15 07:16:40 +04:00
|
|
|
exeOrFile = exec->RemoteApplicationProgram;
|
2018-09-14 11:04:16 +03:00
|
|
|
flags = exec->flags;
|
2013-10-15 07:16:40 +04:00
|
|
|
|
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
|
|
|
|
2019-07-04 10:58:08 +03:00
|
|
|
if (!utf8_string_to_rail_string(exec->RemoteApplicationProgram,
|
|
|
|
&ruExeOrFile) || /* RemoteApplicationProgram */
|
|
|
|
!utf8_string_to_rail_string(exec->RemoteApplicationWorkingDir,
|
|
|
|
&ruWorkingDir) || /* ShellWorkingDirectory */
|
|
|
|
!utf8_string_to_rail_string(exec->RemoteApplicationArguments,
|
|
|
|
&ruArguments)) /* RemoteApplicationCmdLine */
|
2018-09-14 11:04:16 +03:00
|
|
|
error = ERROR_INTERNAL_ERROR;
|
|
|
|
else
|
|
|
|
error = rail_send_client_exec_order(rail, flags, &ruExeOrFile, &ruWorkingDir, &ruArguments);
|
|
|
|
|
|
|
|
free(ruExeOrFile.string);
|
|
|
|
free(ruWorkingDir.string);
|
|
|
|
free(ruArguments.string);
|
2017-06-21 10:43:41 +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
|
|
|
|
*/
|
2019-11-06 17:24:51 +03:00
|
|
|
static UINT rail_client_activate(RailClientContext* context, const RAIL_ACTIVATE_ORDER* activate)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
railPlugin* rail = NULL;
|
2017-12-20 17:00:21 +03:00
|
|
|
|
|
|
|
if (!context || !activate)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
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
|
|
|
|
*/
|
2019-11-06 17:24:51 +03:00
|
|
|
static UINT rail_send_client_sysparam(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam)
|
2013-10-15 07:16:40 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2017-12-20 17:00:21 +03:00
|
|
|
size_t length = RAIL_SYSPARAM_ORDER_LENGTH;
|
2024-01-23 18:49:54 +03:00
|
|
|
railPlugin* rail = NULL;
|
|
|
|
UINT error = 0;
|
|
|
|
BOOL extendedSpiSupported = 0;
|
2017-12-20 17:00:21 +03:00
|
|
|
|
|
|
|
if (!context || !sysparam)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
rail = (railPlugin*)context->handle;
|
2013-10-15 07:16:40 +04:00
|
|
|
|
|
|
|
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;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2019-05-15 16:25:04 +03:00
|
|
|
case SPI_SETFILTERKEYS:
|
|
|
|
length += 20;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SPI_SETSTICKYKEYS:
|
|
|
|
case SPI_SETCARETWIDTH:
|
|
|
|
case SPI_SETTOGGLEKEYS:
|
|
|
|
length += 4;
|
2017-02-20 20:31:58 +03:00
|
|
|
break;
|
2019-05-15 16:25:04 +03:00
|
|
|
|
|
|
|
default:
|
|
|
|
return ERROR_BAD_ARGUMENTS;
|
2013-10-15 07:16:40 +04:00
|
|
|
}
|
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
s = rail_pdu_init(length);
|
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
|
|
|
|
2019-12-10 13:03:30 +03:00
|
|
|
extendedSpiSupported = rail_is_extended_spi_supported(rail->channelFlags);
|
|
|
|
if ((error = rail_write_sysparam_order(s, sysparam, extendedSpiSupported)))
|
2015-06-08 19:04:05 +03:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG, "rail_write_client_sysparam_order failed with error %" PRIu32 "!", error);
|
2015-06-08 19:04:05 +03:00
|
|
|
Stream_Free(s, TRUE);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2024-08-27 10:08:04 +03:00
|
|
|
return rail_send_pdu(rail, s, TS_RAIL_ORDER_SYSPARAM);
|
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,
|
2018-09-14 11:04:16 +03:00
|
|
|
const RAIL_SYSPARAM_ORDER* sysInParam)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2015-08-27 15:25:09 +03:00
|
|
|
UINT error = CHANNEL_RC_OK;
|
2018-09-14 11:04:16 +03:00
|
|
|
RAIL_SYSPARAM_ORDER sysparam;
|
2015-05-18 12:28:00 +03:00
|
|
|
|
2018-09-14 11:04:16 +03:00
|
|
|
if (!context || !sysInParam)
|
2017-12-20 17:00:21 +03:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2018-09-14 11:04:16 +03:00
|
|
|
sysparam = *sysInParam;
|
|
|
|
|
|
|
|
if (sysparam.params & SPI_MASK_SET_HIGH_CONTRAST)
|
2013-10-15 07:16:40 +04:00
|
|
|
{
|
2018-09-14 11:04:16 +03:00
|
|
|
sysparam.param = SPI_SET_HIGH_CONTRAST;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2018-09-14 11:04:16 +03:00
|
|
|
if ((error = rail_send_client_sysparam(context, &sysparam)))
|
2015-06-08 19:04:05 +03:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG, "rail_send_client_sysparam failed with error %" PRIu32 "!", error);
|
2015-06-08 19:04:05 +03:00
|
|
|
return error;
|
|
|
|
}
|
2013-10-15 07:16:40 +04:00
|
|
|
}
|
|
|
|
|
2018-09-14 11:04:16 +03:00
|
|
|
if (sysparam.params & SPI_MASK_TASKBAR_POS)
|
2013-10-15 07:16:40 +04:00
|
|
|
{
|
2018-09-14 11:04:16 +03:00
|
|
|
sysparam.param = SPI_TASKBAR_POS;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2018-09-14 11:04:16 +03:00
|
|
|
if ((error = rail_send_client_sysparam(context, &sysparam)))
|
2015-06-08 19:04:05 +03:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG, "rail_send_client_sysparam failed with error %" PRIu32 "!", error);
|
2015-06-08 19:04:05 +03:00
|
|
|
return error;
|
|
|
|
}
|
2013-10-15 07:16:40 +04:00
|
|
|
}
|
|
|
|
|
2018-09-14 11:04:16 +03:00
|
|
|
if (sysparam.params & SPI_MASK_SET_MOUSE_BUTTON_SWAP)
|
2013-10-15 07:16:40 +04:00
|
|
|
{
|
2018-09-14 11:04:16 +03:00
|
|
|
sysparam.param = SPI_SET_MOUSE_BUTTON_SWAP;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2018-09-14 11:04:16 +03:00
|
|
|
if ((error = rail_send_client_sysparam(context, &sysparam)))
|
2015-06-08 19:04:05 +03:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG, "rail_send_client_sysparam failed with error %" PRIu32 "!", error);
|
2015-06-08 19:04:05 +03:00
|
|
|
return error;
|
|
|
|
}
|
2013-10-15 07:16:40 +04:00
|
|
|
}
|
|
|
|
|
2018-09-14 11:04:16 +03:00
|
|
|
if (sysparam.params & SPI_MASK_SET_KEYBOARD_PREF)
|
2013-10-15 07:16:40 +04:00
|
|
|
{
|
2018-09-14 11:04:16 +03:00
|
|
|
sysparam.param = SPI_SET_KEYBOARD_PREF;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2018-09-14 11:04:16 +03:00
|
|
|
if ((error = rail_send_client_sysparam(context, &sysparam)))
|
2015-06-08 19:04:05 +03:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG, "rail_send_client_sysparam failed with error %" PRIu32 "!", error);
|
2015-06-08 19:04:05 +03:00
|
|
|
return error;
|
|
|
|
}
|
2013-10-15 07:16:40 +04:00
|
|
|
}
|
|
|
|
|
2018-09-14 11:04:16 +03:00
|
|
|
if (sysparam.params & SPI_MASK_SET_DRAG_FULL_WINDOWS)
|
2013-10-15 07:16:40 +04:00
|
|
|
{
|
2018-09-14 11:04:16 +03:00
|
|
|
sysparam.param = SPI_SET_DRAG_FULL_WINDOWS;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2018-09-14 11:04:16 +03:00
|
|
|
if ((error = rail_send_client_sysparam(context, &sysparam)))
|
2015-06-08 19:04:05 +03:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG, "rail_send_client_sysparam failed with error %" PRIu32 "!", error);
|
2015-06-08 19:04:05 +03:00
|
|
|
return error;
|
|
|
|
}
|
2013-10-15 07:16:40 +04:00
|
|
|
}
|
|
|
|
|
2018-09-14 11:04:16 +03:00
|
|
|
if (sysparam.params & SPI_MASK_SET_KEYBOARD_CUES)
|
2013-10-15 07:16:40 +04:00
|
|
|
{
|
2018-09-14 11:04:16 +03:00
|
|
|
sysparam.param = SPI_SET_KEYBOARD_CUES;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2018-09-14 11:04:16 +03:00
|
|
|
if ((error = rail_send_client_sysparam(context, &sysparam)))
|
2015-06-08 19:04:05 +03:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG, "rail_send_client_sysparam failed with error %" PRIu32 "!", error);
|
2015-06-08 19:04:05 +03:00
|
|
|
return error;
|
|
|
|
}
|
2013-10-15 07:16:40 +04:00
|
|
|
}
|
|
|
|
|
2018-09-14 11:04:16 +03:00
|
|
|
if (sysparam.params & SPI_MASK_SET_WORK_AREA)
|
2013-10-15 07:16:40 +04:00
|
|
|
{
|
2018-09-14 11:04:16 +03:00
|
|
|
sysparam.param = SPI_SET_WORK_AREA;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2018-09-14 11:04:16 +03:00
|
|
|
if ((error = rail_send_client_sysparam(context, &sysparam)))
|
2015-06-08 19:04:05 +03:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG, "rail_send_client_sysparam failed with error %" PRIu32 "!", error);
|
2015-06-08 19:04:05 +03:00
|
|
|
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_client_system_command(RailClientContext* context,
|
2018-09-14 11:04:16 +03:00
|
|
|
const RAIL_SYSCOMMAND_ORDER* syscommand)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
railPlugin* rail = NULL;
|
2017-12-20 17:00:21 +03:00
|
|
|
|
|
|
|
if (!context || !syscommand)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
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
|
|
|
|
*/
|
2019-11-06 17:24:51 +03:00
|
|
|
static UINT rail_client_handshake(RailClientContext* context, const RAIL_HANDSHAKE_ORDER* handshake)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
railPlugin* rail = NULL;
|
2017-12-20 17:00:21 +03:00
|
|
|
|
|
|
|
if (!context || !handshake)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
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_client_notify_event(RailClientContext* context,
|
2018-09-14 11:04:16 +03:00
|
|
|
const RAIL_NOTIFY_EVENT_ORDER* notifyEvent)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
railPlugin* rail = NULL;
|
2017-12-20 17:00:21 +03:00
|
|
|
|
|
|
|
if (!context || !notifyEvent)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
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,
|
2018-09-14 11:04:16 +03:00
|
|
|
const RAIL_WINDOW_MOVE_ORDER* windowMove)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
railPlugin* rail = NULL;
|
2017-12-20 17:00:21 +03:00
|
|
|
|
|
|
|
if (!context || !windowMove)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
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_client_information(RailClientContext* context,
|
2018-09-14 11:04:16 +03:00
|
|
|
const RAIL_CLIENT_STATUS_ORDER* clientStatus)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
railPlugin* rail = NULL;
|
2017-12-20 17:00:21 +03:00
|
|
|
|
|
|
|
if (!context || !clientStatus)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
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
|
|
|
|
*/
|
2019-11-06 17:24:51 +03:00
|
|
|
static UINT rail_client_system_menu(RailClientContext* context, const RAIL_SYSMENU_ORDER* sysmenu)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
railPlugin* rail = NULL;
|
2017-12-20 17:00:21 +03:00
|
|
|
|
|
|
|
if (!context || !sysmenu)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
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,
|
2019-11-06 17:24:51 +03:00
|
|
|
const RAIL_LANGBAR_INFO_ORDER* langBarInfo)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
railPlugin* rail = NULL;
|
2017-12-20 17:00:21 +03:00
|
|
|
|
|
|
|
if (!context || !langBarInfo)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-05-08 16:36:20 +03:00
|
|
|
static UINT rail_client_language_ime_info(RailClientContext* context,
|
2019-11-06 17:24:51 +03:00
|
|
|
const RAIL_LANGUAGEIME_INFO_ORDER* langImeInfo)
|
2019-05-08 16:36:20 +03:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
railPlugin* rail = NULL;
|
2019-05-08 16:36:20 +03:00
|
|
|
|
|
|
|
if (!context || !langImeInfo)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
rail = (railPlugin*)context->handle;
|
2019-05-08 16:36:20 +03:00
|
|
|
return rail_send_client_languageime_info_order(rail, langImeInfo);
|
|
|
|
}
|
|
|
|
|
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,
|
2019-11-06 17:24:51 +03:00
|
|
|
const RAIL_GET_APPID_REQ_ORDER* getAppIdReq)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
railPlugin* rail = NULL;
|
2017-12-20 17:00:21 +03:00
|
|
|
|
|
|
|
if (!context || !getAppIdReq || !context->handle)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-07-04 10:58:08 +03:00
|
|
|
static UINT rail_client_compartment_info(RailClientContext* context,
|
|
|
|
const RAIL_COMPARTMENT_INFO_ORDER* compartmentInfo)
|
2019-02-19 16:13:34 +03:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
railPlugin* rail = NULL;
|
2019-02-19 16:13:34 +03:00
|
|
|
|
2019-07-04 10:58:08 +03:00
|
|
|
if (!context || !compartmentInfo || !context->handle)
|
2019-02-19 16:13:34 +03:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
rail = (railPlugin*)context->handle;
|
2019-07-04 10:58:08 +03:00
|
|
|
return rail_send_client_compartment_info_order(rail, compartmentInfo);
|
2019-02-19 16:13:34 +03:00
|
|
|
}
|
|
|
|
|
2019-07-04 10:58:08 +03:00
|
|
|
static UINT rail_client_cloak(RailClientContext* context, const RAIL_CLOAK* cloak)
|
2019-02-19 16:13:34 +03:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
railPlugin* rail = NULL;
|
2019-02-19 16:13:34 +03:00
|
|
|
|
2019-07-04 10:58:08 +03:00
|
|
|
if (!context || !cloak || !context->handle)
|
2019-02-19 16:13:34 +03:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
rail = (railPlugin*)context->handle;
|
2019-07-04 10:58:08 +03:00
|
|
|
return rail_send_client_cloak_order(rail, cloak);
|
2019-02-19 16:13:34 +03:00
|
|
|
}
|
|
|
|
|
2019-07-04 10:58:08 +03:00
|
|
|
static UINT rail_client_snap_arrange(RailClientContext* context, const RAIL_SNAP_ARRANGE* snap)
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
railPlugin* rail = NULL;
|
2019-07-04 10:58:08 +03:00
|
|
|
|
|
|
|
if (!context || !snap || !context->handle)
|
2017-12-20 17:00:21 +03:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2019-07-04 10:58:08 +03:00
|
|
|
rail = (railPlugin*)context->handle;
|
|
|
|
return rail_send_client_snap_arrange_order(rail, snap);
|
2013-10-12 01:09:36 +04:00
|
|
|
}
|
|
|
|
|
2016-11-22 14:18:38 +03:00
|
|
|
static VOID VCAPITYPE rail_virtual_channel_open_event_ex(LPVOID lpUserParam, DWORD openHandle,
|
2019-11-06 17:24:51 +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;
|
2019-11-06 17:24:51 +03:00
|
|
|
railPlugin* rail = (railPlugin*)lpUserParam;
|
2014-11-12 18:43:02 +03:00
|
|
|
|
|
|
|
switch (event)
|
|
|
|
{
|
|
|
|
case CHANNEL_EVENT_DATA_RECEIVED:
|
2020-01-29 10:52:25 +03:00
|
|
|
if (!rail || (rail->OpenHandle != openHandle))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "error no match");
|
|
|
|
return;
|
|
|
|
}
|
2021-03-12 18:54:45 +03:00
|
|
|
|
|
|
|
if ((error = channel_client_post_message(rail->MsgsHandle, pData, dataLength,
|
|
|
|
totalLength, dataFlags)))
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG,
|
2021-03-12 18:54:45 +03:00
|
|
|
"rail_virtual_channel_event_data_received"
|
|
|
|
" failed with error %" PRIu32 "!",
|
2016-09-26 13:12:37 +03:00
|
|
|
error);
|
2021-03-12 18:54:45 +03:00
|
|
|
}
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2014-11-12 18:43:02 +03:00
|
|
|
break;
|
|
|
|
|
2019-10-28 17:13:42 +03:00
|
|
|
case CHANNEL_EVENT_WRITE_CANCELLED:
|
2014-11-12 18:43:02 +03:00
|
|
|
case CHANNEL_EVENT_WRITE_COMPLETE:
|
2019-10-28 16:57:39 +03:00
|
|
|
{
|
2019-10-28 18:43:47 +03:00
|
|
|
wStream* s = (wStream*)pData;
|
2019-10-28 16:57:39 +03:00
|
|
|
Stream_Free(s, TRUE);
|
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
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
|
|
|
|
2020-01-29 10:52:25 +03:00
|
|
|
if (error && rail && 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");
|
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
|
|
|
|
*/
|
2019-11-06 17:24:51 +03:00
|
|
|
static UINT rail_virtual_channel_event_connected(railPlugin* rail, LPVOID pData, UINT32 dataLength)
|
2014-11-12 18:43:02 +03:00
|
|
|
{
|
2019-07-04 10:58:08 +03:00
|
|
|
RailClientContext* context = rail_get_client_interface(rail);
|
2021-09-06 16:50:50 +03:00
|
|
|
UINT status = CHANNEL_RC_OK;
|
2014-11-12 18:43:02 +03:00
|
|
|
|
2021-09-06 16:50:50 +03:00
|
|
|
WINPR_ASSERT(rail);
|
2014-11-12 18:43:02 +03:00
|
|
|
|
2019-07-04 10:58:08 +03:00
|
|
|
if (context)
|
|
|
|
{
|
|
|
|
IFCALLRET(context->OnOpen, status, context, &rail->sendHandshake);
|
|
|
|
|
|
|
|
if (status != CHANNEL_RC_OK)
|
|
|
|
WLog_ERR(TAG, "context->OnOpen failed with %s [%08" PRIX32 "]",
|
|
|
|
WTSErrorToString(status), status);
|
|
|
|
}
|
2021-08-25 11:02:46 +03:00
|
|
|
rail->MsgsHandle = channel_client_create_handler(rail->rdpcontext, rail, rail_order_recv,
|
|
|
|
RAIL_SVC_CHANNEL_NAME);
|
2021-09-06 16:50:50 +03:00
|
|
|
if (!rail->MsgsHandle)
|
|
|
|
return ERROR_INTERNAL_ERROR;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2021-09-06 16:50:50 +03:00
|
|
|
return rail->channelEntryPoints.pVirtualChannelOpenEx(rail->InitHandle, &rail->OpenHandle,
|
|
|
|
rail->channelDef.name,
|
|
|
|
rail_virtual_channel_open_event_ex);
|
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
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT rc = 0;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2021-09-06 17:46:01 +03:00
|
|
|
channel_client_quit_handler(rail->MsgsHandle);
|
2018-04-09 12:10:03 +03:00
|
|
|
if (rail->OpenHandle == 0)
|
|
|
|
return CHANNEL_RC_OK;
|
|
|
|
|
2021-09-06 17:46:01 +03:00
|
|
|
WINPR_ASSERT(rail->channelEntryPoints.pVirtualChannelCloseEx);
|
2016-11-22 14:18:38 +03:00
|
|
|
rc = rail->channelEntryPoints.pVirtualChannelCloseEx(rail->InitHandle, rail->OpenHandle);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-01-20 13:55:50 +03:00
|
|
|
if (CHANNEL_RC_OK != rc)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG, "pVirtualChannelCloseEx failed with %s [%08" PRIX32 "]", 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;
|
|
|
|
|
|
|
|
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-08-09 13:04:06 +03:00
|
|
|
rail->InitHandle = 0;
|
2017-07-18 15:37:46 +03:00
|
|
|
free(rail->context);
|
2014-12-27 23:20:29 +03:00
|
|
|
free(rail);
|
2014-11-12 18:43:02 +03:00
|
|
|
}
|
|
|
|
|
2016-11-22 14:18:38 +03:00
|
|
|
static VOID VCAPITYPE rail_virtual_channel_init_event_ex(LPVOID lpUserParam, LPVOID pInitHandle,
|
2019-11-06 17:24:51 +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;
|
2019-11-06 17:24:51 +03:00
|
|
|
railPlugin* rail = (railPlugin*)lpUserParam;
|
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
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG, "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)))
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG, "rail_virtual_channel_event_connected failed with error %" PRIu32 "!",
|
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)))
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG,
|
|
|
|
"rail_virtual_channel_event_disconnected failed with error %" PRIu32 "!",
|
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;
|
2016-12-19 19:07:01 +03:00
|
|
|
|
|
|
|
case CHANNEL_EVENT_ATTACHED:
|
|
|
|
case CHANNEL_EVENT_DETACHED:
|
|
|
|
default:
|
|
|
|
break;
|
2014-11-12 18:43:02 +03:00
|
|
|
}
|
2015-07-15 10:50:35 +03:00
|
|
|
|
2016-08-09 13:04:06 +03:00
|
|
|
if (error && rail->rdpcontext)
|
2019-11-06 17:24:51 +03:00
|
|
|
setChannelError(rail->rdpcontext, error,
|
|
|
|
"rail_virtual_channel_init_event_ex reported an error");
|
2014-11-12 18:43:02 +03:00
|
|
|
}
|
|
|
|
|
2012-10-09 06:48:17 +04:00
|
|
|
/* rail is always built-in */
|
2019-11-06 17:24:51 +03:00
|
|
|
#define VirtualChannelEntryEx rail_VirtualChannelEntryEx
|
2012-10-09 04:26:11 +04:00
|
|
|
|
2023-08-25 14:41:09 +03:00
|
|
|
FREERDP_ENTRY_POINT(BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints,
|
|
|
|
PVOID pInitHandle))
|
2012-10-09 04:26:11 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT rc = 0;
|
|
|
|
railPlugin* rail = NULL;
|
2016-09-26 13:12:14 +03:00
|
|
|
RailClientContext* context = NULL;
|
2024-01-23 18:49:54 +03:00
|
|
|
CHANNEL_ENTRY_POINTS_FREERDP_EX* pEntryPointsEx = NULL;
|
2015-06-08 19:04:05 +03:00
|
|
|
BOOL isFreerdp = FALSE;
|
2019-11-06 17:24:51 +03: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
|
|
|
|
2019-07-04 10:58:08 +03:00
|
|
|
/* Default to automatically replying to server handshakes */
|
|
|
|
rail->sendHandshake = TRUE;
|
2019-11-06 17:24:51 +03:00
|
|
|
rail->channelDef.options = CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP |
|
|
|
|
CHANNEL_OPTION_COMPRESS_RDP | CHANNEL_OPTION_SHOW_PROTOCOL;
|
2024-08-26 16:39:33 +03:00
|
|
|
(void)sprintf_s(rail->channelDef.name, ARRAYSIZE(rail->channelDef.name), RAIL_SVC_CHANNEL_NAME);
|
2019-11-06 17:24:51 +03:00
|
|
|
pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*)pEntryPoints;
|
2013-10-12 01:09:36 +04:00
|
|
|
|
2016-11-22 14:18:38 +03:00
|
|
|
if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX)) &&
|
2016-08-09 13:04:06 +03:00
|
|
|
(pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER))
|
2013-10-12 01:09:36 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +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
|
|
|
|
2019-11-06 17:24:51 +03: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->ClientSystemCommand = rail_client_system_command;
|
|
|
|
context->ClientHandshake = rail_client_handshake;
|
|
|
|
context->ClientNotifyEvent = rail_client_notify_event;
|
|
|
|
context->ClientWindowMove = rail_client_window_move;
|
|
|
|
context->ClientInformation = rail_client_information;
|
|
|
|
context->ClientSystemMenu = rail_client_system_menu;
|
|
|
|
context->ClientLanguageBarInfo = rail_client_language_bar_info;
|
2019-05-08 16:36:20 +03:00
|
|
|
context->ClientLanguageIMEInfo = rail_client_language_ime_info;
|
2013-10-12 01:09:36 +04:00
|
|
|
context->ClientGetAppIdRequest = rail_client_get_appid_request;
|
2019-02-19 16:13:34 +03:00
|
|
|
context->ClientSnapArrange = rail_client_snap_arrange;
|
|
|
|
context->ClientCloak = rail_client_cloak;
|
2019-07-04 10:58:08 +03:00
|
|
|
context->ClientCompartmentInfo = rail_client_compartment_info;
|
2015-07-15 10:50:35 +03:00
|
|
|
rail->rdpcontext = pEntryPointsEx->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-12-06 01:55:28 +04:00
|
|
|
rail->log = WLog_Get("com.freerdp.channels.rail.client");
|
2016-11-22 14:18:38 +03:00
|
|
|
WLog_Print(rail->log, WLOG_DEBUG, "VirtualChannelEntryEx");
|
2019-11-06 17:24:51 +03:00
|
|
|
CopyMemory(&(rail->channelEntryPoints), pEntryPoints, sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX));
|
2016-11-22 14:18:38 +03:00
|
|
|
rail->InitHandle = pInitHandle;
|
2019-11-06 17:24:51 +03:00
|
|
|
rc = rail->channelEntryPoints.pVirtualChannelInitEx(
|
|
|
|
rail, context, pInitHandle, &rail->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
|
|
|
|
rail_virtual_channel_init_event_ex);
|
2015-06-08 19:04:05 +03:00
|
|
|
|
2015-01-20 13:55:50 +03:00
|
|
|
if (CHANNEL_RC_OK != rc)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG, "failed with %s [%08" PRIX32 "]", 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
|
|
|
|
2016-11-23 15:17:56 +03:00
|
|
|
rail->channelEntryPoints.pInterface = context;
|
2015-06-08 19:04:05 +03:00
|
|
|
return TRUE;
|
|
|
|
error_out:
|
2016-08-09 13:04:06 +03:00
|
|
|
|
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
|
|
|
}
|