2011-08-10 01:42:10 +04:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Client
|
|
|
|
* RAIL Virtual Channel Plugin
|
|
|
|
*
|
|
|
|
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
|
|
|
* Copyright 2011 Roman Barabanov <romanbarabanov@gmail.com>
|
|
|
|
* Copyright 2011 Vic Lee
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <freerdp/constants.h>
|
|
|
|
#include <freerdp/types.h>
|
|
|
|
#include <freerdp/utils/memory.h>
|
|
|
|
#include <freerdp/utils/svc_plugin.h>
|
|
|
|
#include <freerdp/rail.h>
|
|
|
|
|
2011-08-12 00:27:16 +04:00
|
|
|
#include "rail_orders.h"
|
2011-08-10 01:42:10 +04:00
|
|
|
#include "rail_main.h"
|
|
|
|
|
2011-08-19 16:42:14 +04:00
|
|
|
void rail_send_channel_data(void* rail_object, void* data, size_t length)
|
2011-08-10 01:42:10 +04:00
|
|
|
{
|
|
|
|
STREAM* s = NULL;
|
2011-08-12 12:26:57 +04:00
|
|
|
railPlugin* plugin = (railPlugin*) rail_object;
|
2011-08-10 01:42:10 +04:00
|
|
|
|
|
|
|
s = stream_new(length);
|
|
|
|
stream_write(s, data, length);
|
|
|
|
|
|
|
|
svc_plugin_send((rdpSvcPlugin*) plugin, s);
|
|
|
|
}
|
|
|
|
|
2011-08-18 01:28:26 +04:00
|
|
|
static void on_free_rail_channel_event(RDP_EVENT* event)
|
2011-08-10 01:42:10 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-08-18 05:33:22 +04:00
|
|
|
void rail_send_channel_event(void* rail_object, uint16 event_type, void* param)
|
2011-08-10 01:42:10 +04:00
|
|
|
{
|
2011-08-18 01:28:26 +04:00
|
|
|
RDP_EVENT* out_event = NULL;
|
2011-08-18 05:33:22 +04:00
|
|
|
railPlugin* plugin = (railPlugin*) rail_object;
|
|
|
|
out_event = freerdp_event_new(RDP_EVENT_CLASS_RAIL, event_type, on_free_rail_channel_event, param);
|
2011-08-10 01:42:10 +04:00
|
|
|
svc_plugin_send_event((rdpSvcPlugin*) plugin, out_event);
|
|
|
|
}
|
|
|
|
|
2011-08-12 12:26:57 +04:00
|
|
|
static void rail_process_connect(rdpSvcPlugin* plugin)
|
2011-08-10 01:42:10 +04:00
|
|
|
{
|
2011-08-12 12:26:57 +04:00
|
|
|
railPlugin* rail = (railPlugin*) plugin;
|
2011-08-10 01:42:10 +04:00
|
|
|
|
2011-08-12 12:26:57 +04:00
|
|
|
rail->rail_order = rail_order_new();
|
2011-08-18 01:28:26 +04:00
|
|
|
rail->rail_order->plugin_data = (RDP_PLUGIN_DATA*)plugin->channel_entry_points.pExtendedData;
|
2011-08-19 16:42:14 +04:00
|
|
|
rail->rail_order->plugin = rail;
|
2011-08-10 01:42:10 +04:00
|
|
|
}
|
|
|
|
|
2011-08-12 12:26:57 +04:00
|
|
|
static void rail_process_terminate(rdpSvcPlugin* plugin)
|
2011-08-10 01:42:10 +04:00
|
|
|
{
|
2011-08-15 01:05:34 +04:00
|
|
|
|
2011-08-12 12:26:57 +04:00
|
|
|
}
|
2011-08-10 01:42:10 +04:00
|
|
|
|
2011-08-12 12:26:57 +04:00
|
|
|
static void rail_process_receive(rdpSvcPlugin* plugin, STREAM* s)
|
|
|
|
{
|
|
|
|
railPlugin* rail = (railPlugin*) plugin;
|
|
|
|
rail_order_recv(rail->rail_order, s);
|
|
|
|
stream_free(s);
|
|
|
|
}
|
2011-08-10 01:42:10 +04:00
|
|
|
|
2011-08-18 05:33:22 +04:00
|
|
|
void rail_recv_set_sysparams_event(rdpRailOrder* rail_order, RDP_EVENT* event)
|
|
|
|
{
|
|
|
|
RDP_PLUGIN_DATA* data;
|
|
|
|
|
|
|
|
/* Send System Parameters */
|
|
|
|
|
|
|
|
rail_send_client_sysparams_order(rail_order);
|
|
|
|
|
|
|
|
/* execute */
|
|
|
|
|
|
|
|
rail_order->exec.flags =
|
|
|
|
RAIL_EXEC_FLAG_EXPAND_WORKINGDIRECTORY |
|
|
|
|
RAIL_EXEC_FLAG_EXPAND_ARGUMENTS;
|
|
|
|
|
|
|
|
data = rail_order->plugin_data;
|
|
|
|
while (data && data->size > 0)
|
|
|
|
{
|
|
|
|
rail_string_to_unicode_string(rail_order, (char*)data->data[0], &rail_order->exec.exeOrFile);
|
|
|
|
rail_string_to_unicode_string(rail_order, (char*)data->data[1], &rail_order->exec.workingDir);
|
|
|
|
rail_string_to_unicode_string(rail_order, (char*)data->data[2], &rail_order->exec.arguments);
|
|
|
|
|
|
|
|
rail_send_client_exec_order(rail_order);
|
|
|
|
|
|
|
|
data = (RDP_PLUGIN_DATA*)(((void*)data) + data->size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-18 01:28:26 +04:00
|
|
|
static void rail_process_event(rdpSvcPlugin* plugin, RDP_EVENT* event)
|
2011-08-12 12:26:57 +04:00
|
|
|
{
|
|
|
|
railPlugin* rail = NULL;
|
2011-08-18 05:33:22 +04:00
|
|
|
rail = (railPlugin*) plugin;
|
|
|
|
|
|
|
|
switch (event->event_type)
|
|
|
|
{
|
|
|
|
case RDP_EVENT_TYPE_RAIL_CLIENT_SET_SYSPARAMS:
|
|
|
|
rail_recv_set_sysparams_event(rail->rail_order, event);
|
|
|
|
break;
|
2011-08-10 01:42:10 +04:00
|
|
|
|
2011-08-18 05:33:22 +04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2011-08-10 01:42:10 +04:00
|
|
|
|
2011-08-12 12:26:57 +04:00
|
|
|
freerdp_event_free(event);
|
2011-08-10 01:42:10 +04:00
|
|
|
}
|
|
|
|
|
2011-08-12 12:26:57 +04:00
|
|
|
DEFINE_SVC_PLUGIN(rail, "rail",
|
|
|
|
CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP |
|
|
|
|
CHANNEL_OPTION_COMPRESS_RDP | CHANNEL_OPTION_SHOW_PROTOCOL)
|
|
|
|
|