* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2011 Roman Barabanov <romanbarabanov@gmail.com>
* Copyright 2011 Vic Lee
+ * Copyright 2015 Thincast Technologies GmbH
+ * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
return pInterface;
}
-int rail_send(railPlugin* rail, wStream* s)
+WIN32ERROR rail_send(railPlugin* rail, wStream* s)
{
- UINT32 status = 0;
+ WIN32ERROR status;
if (!rail)
{
return status;
}
-BOOL rail_send_channel_data(railPlugin* rail, void* data, size_t length)
+WIN32ERROR rail_send_channel_data(railPlugin* rail, void* data, size_t length)
{
wStream* s = NULL;
s = Stream_New(NULL, length);
+ if (!s)
+ {
+ WLog_ERR(TAG, "Stream_New failed!");
+ return CHANNEL_RC_NO_MEMORY;
+ }
Stream_Write(s, data, length);
- return rail_send(rail, s) == CHANNEL_RC_OK;
+ return rail_send(rail, s);
}
/**
* Callback Interface
*/
-int rail_client_execute(RailClientContext* context, RAIL_EXEC_ORDER* exec)
+WIN32ERROR rail_client_execute(RailClientContext* context, RAIL_EXEC_ORDER* exec)
{
char* exeOrFile;
railPlugin* rail = (railPlugin*) context->handle;
exeOrFile = exec->RemoteApplicationProgram;
if (!exeOrFile)
- return -1;
+ return ERROR_INVALID_PARAMETER;
if (strlen(exeOrFile) >= 2)
{
rail_string_to_unicode_string(exec->RemoteApplicationWorkingDir, &exec->workingDir); /* ShellWorkingDirectory */
rail_string_to_unicode_string(exec->RemoteApplicationArguments, &exec->arguments); /* RemoteApplicationCmdLine */
- return rail_send_client_exec_order(rail, exec) ? 0 : -1;
+ return rail_send_client_exec_order(rail, exec);
}
-int rail_client_activate(RailClientContext* context, RAIL_ACTIVATE_ORDER* activate)
+WIN32ERROR rail_client_activate(RailClientContext* context, RAIL_ACTIVATE_ORDER* activate)
{
railPlugin* rail = (railPlugin*) context->handle;
- return rail_send_client_activate_order(rail, activate) ? 0 : -1;
+ return rail_send_client_activate_order(rail, activate);
}
-BOOL rail_send_client_sysparam(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam)
+WIN32ERROR rail_send_client_sysparam(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam)
{
wStream* s;
int length;
- BOOL ret;
railPlugin* rail = (railPlugin*) context->handle;
+ WIN32ERROR error;
length = RAIL_SYSPARAM_ORDER_LENGTH;
s = rail_pdu_init(RAIL_SYSPARAM_ORDER_LENGTH + 8);
if (!s)
- return FALSE;
+ {
+ WLog_ERR(TAG, "rail_pdu_init failed!");
+ return CHANNEL_RC_NO_MEMORY;
+ }
- ret = rail_write_client_sysparam_order(s, sysparam) &&
- rail_send_pdu(rail, s, RDP_RAIL_ORDER_SYSPARAM);
+ 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);
+ }
Stream_Free(s, TRUE);
- return ret;
+ return error;
}
-int rail_client_system_param(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam)
+WIN32ERROR rail_client_system_param(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam)
{
- BOOL ok = TRUE;
+ WIN32ERROR error = CHANNEL_RC_OK;
if (sysparam->params & SPI_MASK_SET_HIGH_CONTRAST)
{
sysparam->param = SPI_SET_HIGH_CONTRAST;
- ok &= rail_send_client_sysparam(context, sysparam);
+ if ((error = rail_send_client_sysparam(context, sysparam)))
+ {
+ WLog_ERR(TAG, "rail_send_client_sysparam failed with error %lu!", error);
+ return error;
+ }
}
if (sysparam->params & SPI_MASK_TASKBAR_POS)
{
sysparam->param = SPI_TASKBAR_POS;
- ok &= rail_send_client_sysparam(context, sysparam);
+ if ((error = rail_send_client_sysparam(context, sysparam)))
+ {
+ WLog_ERR(TAG, "rail_send_client_sysparam failed with error %lu!", error);
+ return error;
+ }
}
if (sysparam->params & SPI_MASK_SET_MOUSE_BUTTON_SWAP)
{
sysparam->param = SPI_SET_MOUSE_BUTTON_SWAP;
- ok &= rail_send_client_sysparam(context, sysparam);
+ if ((error = rail_send_client_sysparam(context, sysparam)))
+ {
+ WLog_ERR(TAG, "rail_send_client_sysparam failed with error %lu!", error);
+ return error;
+ }
}
if (sysparam->params & SPI_MASK_SET_KEYBOARD_PREF)
{
sysparam->param = SPI_SET_KEYBOARD_PREF;
- ok &= rail_send_client_sysparam(context, sysparam);
+ if ((error = rail_send_client_sysparam(context, sysparam)))
+ {
+ WLog_ERR(TAG, "rail_send_client_sysparam failed with error %lu!", error);
+ return error;
+ }
}
if (sysparam->params & SPI_MASK_SET_DRAG_FULL_WINDOWS)
{
sysparam->param = SPI_SET_DRAG_FULL_WINDOWS;
- ok &= rail_send_client_sysparam(context, sysparam);
+ if ((error = rail_send_client_sysparam(context, sysparam)))
+ {
+ WLog_ERR(TAG, "rail_send_client_sysparam failed with error %lu!", error);
+ return error;
+ }
}
if (sysparam->params & SPI_MASK_SET_KEYBOARD_CUES)
{
sysparam->param = SPI_SET_KEYBOARD_CUES;
- ok &= rail_send_client_sysparam(context, sysparam);
+ if ((error = rail_send_client_sysparam(context, sysparam)))
+ {
+ WLog_ERR(TAG, "rail_send_client_sysparam failed with error %lu!", error);
+ return error;
+ }
}
if (sysparam->params & SPI_MASK_SET_WORK_AREA)
{
sysparam->param = SPI_SET_WORK_AREA;
- ok &= rail_send_client_sysparam(context, sysparam);
+ if ((error = rail_send_client_sysparam(context, sysparam)))
+ {
+ WLog_ERR(TAG, "rail_send_client_sysparam failed with error %lu!", error);
+ return error;
+ }
}
- return ok ? 0 : -1;
+ return error;
}
-int rail_server_system_param(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam)
+WIN32ERROR rail_server_system_param(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam)
{
- return 0; /* stub - should be registered by client */
+ return CHANNEL_RC_OK; /* stub - should be registered by client */
}
-int rail_client_system_command(RailClientContext* context, RAIL_SYSCOMMAND_ORDER* syscommand)
+WIN32ERROR rail_client_system_command(RailClientContext* context, RAIL_SYSCOMMAND_ORDER* syscommand)
{
railPlugin* rail = (railPlugin*) context->handle;
- return rail_send_client_syscommand_order(rail, syscommand) ? 0 : -1;
+ return rail_send_client_syscommand_order(rail, syscommand);
}
-int rail_client_handshake(RailClientContext* context, RAIL_HANDSHAKE_ORDER* handshake)
+WIN32ERROR rail_client_handshake(RailClientContext* context, RAIL_HANDSHAKE_ORDER* handshake)
{
railPlugin* rail = (railPlugin*) context->handle;
- return rail_send_handshake_order(rail, handshake) ? 0 : -1;
+ return rail_send_handshake_order(rail, handshake);
}
-int rail_server_handshake(RailClientContext* context, RAIL_HANDSHAKE_ORDER* handshake)
+WIN32ERROR rail_server_handshake(RailClientContext* context, RAIL_HANDSHAKE_ORDER* handshake)
{
- return 0; /* stub - should be registered by client */
+ return CHANNEL_RC_OK; /* stub - should be registered by client */
}
-int rail_client_handshake_ex(RailClientContext* context, RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
+WIN32ERROR rail_client_handshake_ex(RailClientContext* context, RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
{
railPlugin* rail = (railPlugin*) context->handle;
- return rail_send_handshake_ex_order(rail, handshakeEx) ? 0 : -1;
+ return rail_send_handshake_ex_order(rail, handshakeEx);
}
-int rail_server_handshake_ex(RailClientContext* context, RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
+WIN32ERROR rail_server_handshake_ex(RailClientContext* context, RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
{
- return 0; /* stub - should be registered by client */
+ return CHANNEL_RC_OK; /* stub - should be registered by client */
}
-int rail_client_notify_event(RailClientContext* context, RAIL_NOTIFY_EVENT_ORDER* notifyEvent)
+WIN32ERROR rail_client_notify_event(RailClientContext* context, RAIL_NOTIFY_EVENT_ORDER* notifyEvent)
{
railPlugin* rail = (railPlugin*) context->handle;
- return rail_send_client_notify_event_order(rail, notifyEvent) ? 0 : -1;
+ return rail_send_client_notify_event_order(rail, notifyEvent);
}
-int rail_client_window_move(RailClientContext* context, RAIL_WINDOW_MOVE_ORDER* windowMove)
+WIN32ERROR rail_client_window_move(RailClientContext* context, RAIL_WINDOW_MOVE_ORDER* windowMove)
{
railPlugin* rail = (railPlugin*) context->handle;
- return rail_send_client_window_move_order(rail, windowMove) ? 0 : -1;
+ return rail_send_client_window_move_order(rail, windowMove);
}
-int rail_server_local_move_size(RailClientContext* context, RAIL_LOCALMOVESIZE_ORDER* localMoveSize)
+WIN32ERROR rail_server_local_move_size(RailClientContext* context, RAIL_LOCALMOVESIZE_ORDER* localMoveSize)
{
- return 0; /* stub - should be registered by client */
+ return CHANNEL_RC_OK; /* stub - should be registered by client */
}
-int rail_server_min_max_info(RailClientContext* context, RAIL_MINMAXINFO_ORDER* minMaxInfo)
+WIN32ERROR rail_server_min_max_info(RailClientContext* context, RAIL_MINMAXINFO_ORDER* minMaxInfo)
{
- return 0; /* stub - should be registered by client */
+ return CHANNEL_RC_OK; /* stub - should be registered by client */
}
-int rail_client_information(RailClientContext* context, RAIL_CLIENT_STATUS_ORDER* clientStatus)
+WIN32ERROR rail_client_information(RailClientContext* context, RAIL_CLIENT_STATUS_ORDER* clientStatus)
{
railPlugin* rail = (railPlugin*) context->handle;
- return rail_send_client_status_order(rail, clientStatus) ? 0 : -1;
+ return rail_send_client_status_order(rail, clientStatus);
}
-int rail_client_system_menu(RailClientContext* context, RAIL_SYSMENU_ORDER* sysmenu)
+WIN32ERROR rail_client_system_menu(RailClientContext* context, RAIL_SYSMENU_ORDER* sysmenu)
{
railPlugin* rail = (railPlugin*) context->handle;
- return rail_send_client_sysmenu_order(rail, sysmenu) ? 0 : -1;
+ return rail_send_client_sysmenu_order(rail, sysmenu);
}
-int rail_client_language_bar_info(RailClientContext* context, RAIL_LANGBAR_INFO_ORDER* langBarInfo)
+WIN32ERROR rail_client_language_bar_info(RailClientContext* context, RAIL_LANGBAR_INFO_ORDER* langBarInfo)
{
railPlugin* rail = (railPlugin*) context->handle;
- return rail_send_client_langbar_info_order(rail, langBarInfo) ? 0 : -1;
+ return rail_send_client_langbar_info_order(rail, langBarInfo);
}
-int rail_server_language_bar_info(RailClientContext* context, RAIL_LANGBAR_INFO_ORDER* langBarInfo)
+WIN32ERROR rail_server_language_bar_info(RailClientContext* context, RAIL_LANGBAR_INFO_ORDER* langBarInfo)
{
- return 0; /* stub - should be registered by client */
+ return CHANNEL_RC_OK; /* stub - should be registered by client */
}
-int rail_server_execute_result(RailClientContext* context, RAIL_EXEC_RESULT_ORDER* execResult)
+WIN32ERROR rail_server_execute_result(RailClientContext* context, RAIL_EXEC_RESULT_ORDER* execResult)
{
- return 0; /* stub - should be registered by client */
+ return CHANNEL_RC_OK; /* stub - should be registered by client */
}
-int rail_client_get_appid_request(RailClientContext* context, RAIL_GET_APPID_REQ_ORDER* getAppIdReq)
+WIN32ERROR rail_client_get_appid_request(RailClientContext* context, RAIL_GET_APPID_REQ_ORDER* getAppIdReq)
{
railPlugin* rail = (railPlugin*) context->handle;
- return rail_send_client_get_appid_req_order(rail, getAppIdReq) ? 0 : -1;
+ return rail_send_client_get_appid_req_order(rail, getAppIdReq);
}
-int rail_server_get_appid_response(RailClientContext* context, RAIL_GET_APPID_RESP_ORDER* getAppIdResp)
+WIN32ERROR rail_server_get_appid_response(RailClientContext* context, RAIL_GET_APPID_RESP_ORDER* getAppIdResp)
{
- return 0; /* stub - should be registered by client */
+ return CHANNEL_RC_OK; /* stub - should be registered by client */
}
/****************************************************************************************/
static wListDictionary* g_InitHandles = NULL;
static wListDictionary* g_OpenHandles = NULL;
-BOOL rail_add_init_handle_data(void* pInitHandle, void* pUserData)
+WIN32ERROR rail_add_init_handle_data(void* pInitHandle, void* pUserData)
{
if (!g_InitHandles)
{
g_InitHandles = ListDictionary_New(TRUE);
- if (!g_InitHandles)
- return FALSE;
+ }
+ if (!g_InitHandles)
+ {
+ WLog_ERR(TAG, "ListDictionary_New failed!");
+ return CHANNEL_RC_NO_MEMORY;
}
- return ListDictionary_Add(g_InitHandles, pInitHandle, pUserData);
+ if (!ListDictionary_Add(g_InitHandles, pInitHandle, pUserData))
+ {
+ WLog_ERR(TAG, "ListDictionary_Add failed!");
+ return ERROR_INTERNAL_ERROR;
+ }
+ return CHANNEL_RC_OK;
}
void* rail_get_init_handle_data(void* pInitHandle)
}
}
-BOOL rail_add_open_handle_data(DWORD openHandle, void* pUserData)
+WIN32ERROR rail_add_open_handle_data(DWORD openHandle, void* pUserData)
{
void* pOpenHandle = (void*) (size_t) openHandle;
if (!g_OpenHandles)
{
g_OpenHandles = ListDictionary_New(TRUE);
- if (!g_OpenHandles)
- return FALSE;
+ }
+ if (!g_OpenHandles)
+ {
+ WLog_ERR(TAG, "ListDictionary_New failed!");
+ return CHANNEL_RC_NO_MEMORY;
}
- return ListDictionary_Add(g_OpenHandles, pOpenHandle, pUserData);
+ ListDictionary_Add(g_OpenHandles, pOpenHandle, pUserData);
+ {
+ WLog_ERR(TAG, "ListDictionary_Add failed!");
+ return ERROR_INTERNAL_ERROR;
+ }
+ return CHANNEL_RC_OK;
}
void* rail_get_open_handle_data(DWORD openHandle)
}
}
-static void rail_virtual_channel_event_data_received(railPlugin* rail,
+static WIN32ERROR rail_virtual_channel_event_data_received(railPlugin* rail,
void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
{
wStream* data_in;
if ((dataFlags & CHANNEL_FLAG_SUSPEND) || (dataFlags & CHANNEL_FLAG_RESUME))
{
- return;
+ return CHANNEL_RC_OK;
}
if (dataFlags & CHANNEL_FLAG_FIRST)
rail->data_in = Stream_New(NULL, totalLength);
if (!rail->data_in)
{
- WLog_ERR(TAG, "%s: unable to allocate data_in", __FUNCTION__);
- return;
+ WLog_ERR(TAG, "Stream_New failed!");
+ return CHANNEL_RC_NO_MEMORY;
}
}
data_in = rail->data_in;
if (!Stream_EnsureRemainingCapacity(data_in, (int) dataLength))
{
- WLog_ERR(TAG, "%s: unable to grow data_in to %d", __FUNCTION__, dataLength);
- return;
+ WLog_ERR(TAG, "Stream_EnsureRemainingCapacity failed!");
+ return CHANNEL_RC_NO_MEMORY;
}
Stream_Write(data_in, pData, dataLength);
if (Stream_Capacity(data_in) != Stream_GetPosition(data_in))
{
WLog_ERR(TAG, "rail_plugin_process_received: read error");
+ return ERROR_INTERNAL_ERROR;
}
rail->data_in = NULL;
MessageQueue_Post(rail->queue, NULL, 0, (void*) data_in, NULL);
}
+ return CHANNEL_RC_OK;
}
static VOID VCAPITYPE rail_virtual_channel_open_event(DWORD openHandle, UINT event,
if (!rail)
{
- WLog_ERR(TAG, "rail_virtual_channel_open_event: error no match");
+ WLog_ERR(TAG, "rail_virtual_channel_open_event: error no match");
+ rail->error = CHANNEL_RC_BAD_CHANNEL;
return;
}
+ rail->error = CHANNEL_RC_OK;
switch (event)
{
case CHANNEL_EVENT_DATA_RECEIVED:
- rail_virtual_channel_event_data_received(rail, pData, dataLength, totalLength, dataFlags);
+ if ((rail->error = rail_virtual_channel_event_data_received(rail, pData, dataLength, totalLength, dataFlags)))
+ {
+ WLog_ERR(TAG, "rail_virtual_channel_event_data_received failed with error %lu!", rail->error);
+ return;
+ }
break;
case CHANNEL_EVENT_WRITE_COMPLETE:
case CHANNEL_EVENT_USER:
break;
}
+ return;
+ //TODO report error
}
static void* rail_virtual_channel_client_thread(void* arg)
wStream* data;
wMessage message;
railPlugin* rail = (railPlugin*) arg;
+ WIN32ERROR error = CHANNEL_RC_OK;
while (1)
{
if (message.id == 0)
{
data = (wStream*) message.wParam;
- if (!rail_order_recv(rail, data))
+ if ((error = rail_order_recv(rail, data)))
{
- WLog_ERR(TAG, "%s: invalid message, exiting", __FUNCTION__);
+ WLog_ERR(TAG, "rail_order_recv failed with error %d!", error);
break;
}
}
}
}
- ExitThread(0);
+ ExitThread((DWORD)error);
return NULL;
}
-static void rail_virtual_channel_event_connected(railPlugin* rail, LPVOID pData, UINT32 dataLength)
+static WIN32ERROR rail_virtual_channel_event_connected(railPlugin* rail, LPVOID pData, UINT32 dataLength)
{
- UINT32 status;
+ WIN32ERROR status;
status = rail->channelEntryPoints.pVirtualChannelOpen(rail->InitHandle,
&rail->OpenHandle, rail->channelDef.name, rail_virtual_channel_open_event);
- if (!rail_add_open_handle_data(rail->OpenHandle, rail))
+ if (status != CHANNEL_RC_OK)
{
- WLog_ERR(TAG, "%s: unable to register open handle", __FUNCTION__);
- return;
+ WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08X]",
+ WTSErrorToString(status), status);
+ return status;
}
- if (status != CHANNEL_RC_OK)
+ if ((status = rail_add_open_handle_data(rail->OpenHandle, rail)))
{
- WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08X]",
- WTSErrorToString(status), status);
- return;
+ WLog_ERR(TAG, "rail_add_open_handle_data failed with error %lu!", status);
+ return status;
}
rail->queue = MessageQueue_New(NULL);
if (!rail->queue)
{
- WLog_ERR(TAG, "%s: unable to create a message queue", __FUNCTION__);
- return;
+ WLog_ERR(TAG, "MessageQueue_New failed!");
+ return CHANNEL_RC_NO_MEMORY;
}
- rail->thread = CreateThread(NULL, 0,
- (LPTHREAD_START_ROUTINE) rail_virtual_channel_client_thread, (void*) rail, 0, NULL);
+ if (!(rail->thread = CreateThread(NULL, 0,
+ (LPTHREAD_START_ROUTINE) rail_virtual_channel_client_thread, (void*) rail, 0, NULL)))
+ {
+ WLog_ERR(TAG, "CreateThread failed!");
+ MessageQueue_Free(rail->queue);
+ rail->queue = NULL;
+ return ERROR_INTERNAL_ERROR;
+ }
+ return CHANNEL_RC_OK;
}
static void rail_virtual_channel_event_disconnected(railPlugin* rail)
if (!rail)
{
WLog_ERR(TAG, "rail_virtual_channel_init_event: error no match");
+ rail->error = CHANNEL_RC_BAD_CHANNEL;
return;
}
+ rail->error = CHANNEL_RC_OK;
+
switch (event)
{
case CHANNEL_EVENT_CONNECTED:
- rail_virtual_channel_event_connected(rail, pData, dataLength);
+ if ((rail->error = rail_virtual_channel_event_connected(rail, pData, dataLength)))
+ {
+ WLog_ERR(TAG, "rail_virtual_channel_event_connected failed with error %lu!", rail->error);
+ return;
+ }
break;
case CHANNEL_EVENT_DISCONNECTED:
rail_virtual_channel_event_terminated(rail);
break;
}
+ return;
+ //TODO report error
}
/* rail is always built-in */
railPlugin* rail;
RailClientContext* context;
CHANNEL_ENTRY_POINTS_FREERDP* pEntryPointsEx;
+ BOOL isFreerdp = FALSE;
+ WIN32ERROR error;
rail = (railPlugin*) calloc(1, sizeof(railPlugin));
+ if (!rail)
+ {
+ WLog_ERR(TAG, "calloc failed!");
+ return FALSE;
+ }
rail->channelDef.options =
CHANNEL_OPTION_INITIALIZED |
{
context = (RailClientContext*) calloc(1, sizeof(RailClientContext));
if (!context)
+ {
+ WLog_ERR(TAG, "calloc failed!");
+ free(rail);
return FALSE;
+ }
context->handle = (void*) rail;
context->custom = NULL;
*(pEntryPointsEx->ppInterface) = (void*) context;
rail->context = context;
+ isFreerdp = TRUE;
}
WLog_Init();
rc = rail->channelEntryPoints.pVirtualChannelInit(&rail->InitHandle,
&rail->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000, rail_virtual_channel_init_event);
+
if (CHANNEL_RC_OK != rc)
{
WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]",
WTSErrorToString(rc), rc);
- free(rail);
- return -1;
+ goto error_out;
}
rail->channelEntryPoints.pInterface = *(rail->channelEntryPoints.ppInterface);
rail->channelEntryPoints.ppInterface = &(rail->channelEntryPoints.pInterface);
- return rail_add_init_handle_data(rail->InitHandle, (void*) rail);
+ if ((error = rail_add_init_handle_data(rail->InitHandle, (void*) rail)))
+ {
+ WLog_ERR(TAG, "rail_add_init_handle_data failed with error %lu!", error);
+ goto error_out;
+ }
+
+ return TRUE;
+error_out:
+ if (isFreerdp)
+ free(rail->context);
+ free(rail);
+ return FALSE;
}
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2011 Roman Barabanov <romanbarabanov@gmail.com>
* Copyright 2011 Vic Lee
+ * Copyright 2015 Thincast Technologies GmbH
+ * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
void* InitHandle;
DWORD OpenHandle;
wMessageQueue* queue;
+ WIN32ERROR error;
};
typedef struct rail_plugin railPlugin;
RailClientContext* rail_get_client_interface(railPlugin* rail);
-BOOL rail_send_channel_data(railPlugin* rail, void* data, size_t length);
+WIN32ERROR rail_send_channel_data(railPlugin* rail, void* data, size_t length);
#endif /* FREERDP_CHANNEL_CLIENT_RAIL_MAIN_H */
*
* Copyright 2009 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2011 Roman Barabanov <romanbarabanov@gmail.com>
+ * Copyright 2015 Thincast Technologies GmbH
+ * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "rail_orders.h"
-static BOOL rail_write_unicode_string(wStream* s, RAIL_UNICODE_STRING* unicode_string)
+static WIN32ERROR rail_write_unicode_string(wStream* s, RAIL_UNICODE_STRING* unicode_string)
{
if (!Stream_EnsureRemainingCapacity(s, 2 + unicode_string->length))
- return FALSE;
+ {
+ WLog_ERR(TAG, "Stream_EnsureRemainingCapacity failed!");
+ return CHANNEL_RC_NO_MEMORY;
+ }
Stream_Write_UINT16(s, unicode_string->length); /* cbString (2 bytes) */
Stream_Write(s, unicode_string->string, unicode_string->length); /* string */
- return TRUE;
+ return CHANNEL_RC_OK;
}
-static BOOL rail_write_unicode_string_value(wStream* s, RAIL_UNICODE_STRING* unicode_string)
+static WIN32ERROR rail_write_unicode_string_value(wStream* s, RAIL_UNICODE_STRING* unicode_string)
{
if (unicode_string->length > 0)
{
if (!Stream_EnsureRemainingCapacity(s, unicode_string->length))
- return FALSE;
+ {
+ WLog_ERR(TAG, "Stream_EnsureRemainingCapacity failed!");
+ return CHANNEL_RC_NO_MEMORY;
+ }
Stream_Write(s, unicode_string->string, unicode_string->length); /* string */
}
- return TRUE;
+ return CHANNEL_RC_OK;
}
-BOOL rail_send_pdu(railPlugin* rail, wStream* s, UINT16 orderType)
+WIN32ERROR rail_send_pdu(railPlugin* rail, wStream* s, UINT16 orderType)
{
UINT16 orderLength;
return rail_send_channel_data(rail, Stream_Buffer(s), orderLength);
}
-BOOL rail_write_high_contrast(wStream* s, RAIL_HIGH_CONTRAST* highContrast)
+WIN32ERROR rail_write_high_contrast(wStream* s, RAIL_HIGH_CONTRAST* highContrast)
{
highContrast->colorSchemeLength = highContrast->colorScheme.length + 2;
Stream_Write_UINT32(s, highContrast->flags); /* flags (4 bytes) */
return rail_write_unicode_string(s, &highContrast->colorScheme); /* colorScheme */
}
-BOOL rail_read_server_exec_result_order(wStream* s, RAIL_EXEC_RESULT_ORDER* execResult)
+WIN32ERROR rail_read_server_exec_result_order(wStream* s, RAIL_EXEC_RESULT_ORDER* execResult)
{
if (Stream_GetRemainingLength(s) < 8)
- return FALSE;
+ {
+ WLog_ERR(TAG, "Stream_GetRemainingLength failed!");
+ return ERROR_INVALID_DATA;
+ }
Stream_Read_UINT16(s, execResult->flags); /* flags (2 bytes) */
Stream_Read_UINT16(s, execResult->execResult); /* execResult (2 bytes) */
Stream_Read_UINT32(s, execResult->rawResult); /* rawResult (4 bytes) */
Stream_Seek_UINT16(s); /* padding (2 bytes) */
- return rail_read_unicode_string(s, &execResult->exeOrFile); /* exeOrFile */
+ return rail_read_unicode_string(s, &execResult->exeOrFile) ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR; /* exeOrFile */
}
-BOOL rail_read_server_sysparam_order(wStream* s, RAIL_SYSPARAM_ORDER* sysparam)
+WIN32ERROR rail_read_server_sysparam_order(wStream* s, RAIL_SYSPARAM_ORDER* sysparam)
{
BYTE body;
if (Stream_GetRemainingLength(s) < 5)
- return FALSE;
+ {
+ WLog_ERR(TAG, "Stream_GetRemainingLength failed!");
+ return ERROR_INVALID_DATA;
+ }
Stream_Read_UINT32(s, sysparam->param); /* systemParam (4 bytes) */
Stream_Read_UINT8(s, body); /* body (1 byte) */
break;
}
- return TRUE;
+ return CHANNEL_RC_OK;
}
-BOOL rail_read_server_minmaxinfo_order(wStream* s, RAIL_MINMAXINFO_ORDER* minmaxinfo)
+WIN32ERROR rail_read_server_minmaxinfo_order(wStream* s, RAIL_MINMAXINFO_ORDER* minmaxinfo)
{
if (Stream_GetRemainingLength(s) < 20)
- return FALSE;
+ {
+ WLog_ERR(TAG, "Stream_GetRemainingLength failed!");
+ return ERROR_INVALID_DATA;
+ }
Stream_Read_UINT32(s, minmaxinfo->windowId); /* windowId (4 bytes) */
Stream_Read_UINT16(s, minmaxinfo->maxWidth); /* maxWidth (2 bytes) */
Stream_Read_UINT16(s, minmaxinfo->maxTrackWidth); /* maxTrackWidth (2 bytes) */
Stream_Read_UINT16(s, minmaxinfo->maxTrackHeight); /* maxTrackHeight (2 bytes) */
- return TRUE;
+ return CHANNEL_RC_OK;
}
-BOOL rail_read_server_localmovesize_order(wStream* s, RAIL_LOCALMOVESIZE_ORDER* localMoveSize)
+WIN32ERROR rail_read_server_localmovesize_order(wStream* s, RAIL_LOCALMOVESIZE_ORDER* localMoveSize)
{
UINT16 isMoveSizeStart;
if (Stream_GetRemainingLength(s) < 12)
- return FALSE;
+ {
+ WLog_ERR(TAG, "Stream_GetRemainingLength failed!");
+ return ERROR_INVALID_DATA;
+ }
Stream_Read_UINT32(s, localMoveSize->windowId); /* windowId (4 bytes) */
Stream_Read_UINT16(s, localMoveSize->posX); /* posX (2 bytes) */
Stream_Read_UINT16(s, localMoveSize->posY); /* posY (2 bytes) */
- return TRUE;
+ return CHANNEL_RC_OK;
}
-BOOL rail_read_server_get_appid_resp_order(wStream* s, RAIL_GET_APPID_RESP_ORDER* getAppidResp)
+WIN32ERROR rail_read_server_get_appid_resp_order(wStream* s, RAIL_GET_APPID_RESP_ORDER* getAppidResp)
{
if (Stream_GetRemainingLength(s) < 516)
- return FALSE;
+ {
+ WLog_ERR(TAG, "Stream_GetRemainingLength failed!");
+ return ERROR_INVALID_DATA;
+ }
Stream_Read_UINT32(s, getAppidResp->windowId); /* windowId (4 bytes) */
Stream_Read(s, (BYTE*) &(getAppidResp->applicationId), 512); /* applicationId (256 UNICODE chars) */
- return TRUE;
+ return CHANNEL_RC_OK;
}
-BOOL rail_read_langbar_info_order(wStream* s, RAIL_LANGBAR_INFO_ORDER* langbarInfo)
+WIN32ERROR rail_read_langbar_info_order(wStream* s, RAIL_LANGBAR_INFO_ORDER* langbarInfo)
{
if (Stream_GetRemainingLength(s) < 4)
- return FALSE;
+ {
+ WLog_ERR(TAG, "Stream_GetRemainingLength failed!");
+ return ERROR_INVALID_DATA;
+ }
Stream_Read_UINT32(s, langbarInfo->languageBarStatus); /* languageBarStatus (4 bytes) */
- return TRUE;
+ return CHANNEL_RC_OK;
}
void rail_write_client_status_order(wStream* s, RAIL_CLIENT_STATUS_ORDER* clientStatus)
Stream_Write_UINT32(s, clientStatus->flags); /* flags (4 bytes) */
}
-BOOL rail_write_client_exec_order(wStream* s, RAIL_EXEC_ORDER* exec)
+WIN32ERROR rail_write_client_exec_order(wStream* s, RAIL_EXEC_ORDER* exec)
{
+ WIN32ERROR error;
Stream_Write_UINT16(s, exec->flags); /* flags (2 bytes) */
Stream_Write_UINT16(s, exec->exeOrFile.length); /* exeOrFileLength (2 bytes) */
Stream_Write_UINT16(s, exec->workingDir.length); /* workingDirLength (2 bytes) */
Stream_Write_UINT16(s, exec->arguments.length); /* argumentsLength (2 bytes) */
-
- return rail_write_unicode_string_value(s, &exec->exeOrFile) && /* exeOrFile */
- rail_write_unicode_string_value(s, &exec->workingDir) && /* workingDir */
- rail_write_unicode_string_value(s, &exec->arguments); /* arguments */
+ if ((error = rail_write_unicode_string_value(s, &exec->exeOrFile)))
+ {
+ return error;
+ }
+ if ((error = rail_write_unicode_string_value(s, &exec->workingDir)))
+ {
+ return error;
+ }
+ if ((error = rail_write_unicode_string_value(s, &exec->arguments)))
+ {
+ return error;
+ }
+ return error;
}
-BOOL rail_write_client_sysparam_order(wStream* s, RAIL_SYSPARAM_ORDER* sysparam)
+WIN32ERROR rail_write_client_sysparam_order(wStream* s, RAIL_SYSPARAM_ORDER* sysparam)
{
BYTE body;
- BOOL ret = TRUE;
+ WIN32ERROR error = CHANNEL_RC_OK;
Stream_Write_UINT32(s, sysparam->param); /* systemParam (4 bytes) */
break;
case SPI_SET_HIGH_CONTRAST:
- ret = rail_write_high_contrast(s, &sysparam->highContrast);
+ error = rail_write_high_contrast(s, &sysparam->highContrast);
break;
}
- return ret;
+ return error;
}
void rail_write_client_activate_order(wStream* s, RAIL_ACTIVATE_ORDER* activate)
Stream_Write_UINT32(s, langbarInfo->languageBarStatus); /* languageBarStatus (4 bytes) */
}
-BOOL rail_recv_handshake_order(railPlugin* rail, RAIL_HANDSHAKE_ORDER* handshake, wStream* s)
+WIN32ERROR rail_recv_handshake_order(railPlugin* rail, RAIL_HANDSHAKE_ORDER* handshake, wStream* s)
{
RailClientContext* context = rail_get_client_interface(rail);
+ WIN32ERROR error;
- if (!rail_read_handshake_order(s, handshake))
- return FALSE;
+ if ((error = rail_read_handshake_order(s, handshake)))
+ {
+ WLog_ERR(TAG, "rail_read_handshake_order failed with error %lu!", error);
+ return error;
+ }
if (context->custom)
{
- IFCALL(context->ServerHandshake, context, handshake);
- return TRUE;
+ IFCALLRET(context->ServerHandshake, error, context, handshake);
}
- return TRUE;
+ return error;
}
-BOOL rail_recv_handshake_ex_order(railPlugin* rail, RAIL_HANDSHAKE_EX_ORDER* handshakeEx, wStream* s)
+WIN32ERROR rail_recv_handshake_ex_order(railPlugin* rail, RAIL_HANDSHAKE_EX_ORDER* handshakeEx, wStream* s)
{
RailClientContext* context = rail_get_client_interface(rail);
+ WIN32ERROR error;
- if (!rail_read_handshake_ex_order(s, handshakeEx))
- return FALSE;
+ if ((error = rail_read_handshake_ex_order(s, handshakeEx)))
+ {
+ WLog_ERR(TAG, "rail_read_handshake_ex_order failed with error %lu!", error);
+ return error;
+ }
if (context->custom)
{
- IFCALL(context->ClientHandshakeEx, context, handshakeEx);
+ IFCALLRET(context->ClientHandshakeEx, error, context, handshakeEx);
}
- return TRUE;
+ return error;
}
-BOOL rail_recv_exec_result_order(railPlugin* rail, RAIL_EXEC_RESULT_ORDER* execResult, wStream* s)
+WIN32ERROR rail_recv_exec_result_order(railPlugin* rail, RAIL_EXEC_RESULT_ORDER* execResult, wStream* s)
{
RailClientContext* context = rail_get_client_interface(rail);
+ WIN32ERROR error;
ZeroMemory(execResult, sizeof(RAIL_EXEC_RESULT_ORDER));
- if (!rail_read_server_exec_result_order(s, execResult))
- return FALSE;
+ if ((error = rail_read_server_exec_result_order(s, execResult)))
+ {
+ WLog_ERR(TAG, "rail_read_server_exec_result_order failed with error %lu!", error);
+ return error;
+ }
if (context->custom)
{
- IFCALL(context->ServerExecuteResult, context, execResult);
+ IFCALLRET(context->ServerExecuteResult, error, context, execResult);
}
- return TRUE;
+ return error;
}
-BOOL rail_recv_server_sysparam_order(railPlugin* rail, RAIL_SYSPARAM_ORDER* sysparam, wStream* s)
+WIN32ERROR rail_recv_server_sysparam_order(railPlugin* rail, RAIL_SYSPARAM_ORDER* sysparam, wStream* s)
{
RailClientContext* context = rail_get_client_interface(rail);
+ WIN32ERROR error;
- if (!rail_read_server_sysparam_order(s, sysparam))
- return FALSE;
+ if ((error = rail_read_server_sysparam_order(s, sysparam)))
+ {
+ WLog_ERR(TAG, "rail_read_server_sysparam_order failed with error %lu!", error);
+ return error;
+ }
if (context->custom)
{
- IFCALL(context->ServerSystemParam, context, sysparam);
+ IFCALLRET(context->ServerSystemParam, error, context, sysparam);
}
- return TRUE;
+ return error;
}
-BOOL rail_recv_server_minmaxinfo_order(railPlugin* rail, RAIL_MINMAXINFO_ORDER* minMaxInfo, wStream* s)
+WIN32ERROR rail_recv_server_minmaxinfo_order(railPlugin* rail, RAIL_MINMAXINFO_ORDER* minMaxInfo, wStream* s)
{
RailClientContext* context = rail_get_client_interface(rail);
+ WIN32ERROR error;
- if (!rail_read_server_minmaxinfo_order(s, minMaxInfo))
- return FALSE;
+ if ((error = rail_read_server_minmaxinfo_order(s, minMaxInfo)))
+ {
+ WLog_ERR(TAG, "rail_read_server_minmaxinfo_order failed with error %lu!", error);
+ return error;
+ }
if (context->custom)
{
- IFCALL(context->ServerMinMaxInfo, context, minMaxInfo);
+ IFCALLRET(context->ServerMinMaxInfo, error, context, minMaxInfo);
}
- return TRUE;
+ return error;
}
-BOOL rail_recv_server_localmovesize_order(railPlugin* rail, RAIL_LOCALMOVESIZE_ORDER* localMoveSize, wStream* s)
+WIN32ERROR rail_recv_server_localmovesize_order(railPlugin* rail, RAIL_LOCALMOVESIZE_ORDER* localMoveSize, wStream* s)
{
RailClientContext* context = rail_get_client_interface(rail);
+ WIN32ERROR error;
- if (!rail_read_server_localmovesize_order(s, localMoveSize))
- return FALSE;
+ if ((error = rail_read_server_localmovesize_order(s, localMoveSize)))
+ {
+ WLog_ERR(TAG, "rail_read_server_localmovesize_order failed with error %lu!", error);
+ return error;
+ }
if (context->custom)
{
- IFCALL(context->ServerLocalMoveSize, context, localMoveSize);
+ IFCALLRET(context->ServerLocalMoveSize, error, context, localMoveSize);
}
- return TRUE;
+ return error;
}
-BOOL rail_recv_server_get_appid_resp_order(railPlugin* rail, RAIL_GET_APPID_RESP_ORDER* getAppIdResp, wStream* s)
+WIN32ERROR rail_recv_server_get_appid_resp_order(railPlugin* rail, RAIL_GET_APPID_RESP_ORDER* getAppIdResp, wStream* s)
{
RailClientContext* context = rail_get_client_interface(rail);
+ WIN32ERROR error;
- if (!rail_read_server_get_appid_resp_order(s, getAppIdResp))
- return FALSE;
+ if ((error = rail_read_server_get_appid_resp_order(s, getAppIdResp)))
+ {
+ WLog_ERR(TAG, "rail_read_server_get_appid_resp_order failed with error %lu!", error);
+ return error;
+ }
if (context->custom)
{
- IFCALL(context->ServerGetAppIdResponse, context, getAppIdResp);
+ IFCALLRET(context->ServerGetAppIdResponse, error, context, getAppIdResp);
}
- return TRUE;
+ return error;
}
-BOOL rail_recv_langbar_info_order(railPlugin* rail, RAIL_LANGBAR_INFO_ORDER* langBarInfo, wStream* s)
+WIN32ERROR rail_recv_langbar_info_order(railPlugin* rail, RAIL_LANGBAR_INFO_ORDER* langBarInfo, wStream* s)
{
RailClientContext* context = rail_get_client_interface(rail);
+ WIN32ERROR error;
- if (!rail_read_langbar_info_order(s, langBarInfo))
- return FALSE;
+ if ((error = rail_read_langbar_info_order(s, langBarInfo)))
+ {
+ WLog_ERR(TAG, "rail_read_langbar_info_order failed with error %lu!", error);
+ return error;
+ }
if (context->custom)
{
- IFCALL(context->ServerLanguageBarInfo, context, langBarInfo);
+ IFCALLRET(context->ServerLanguageBarInfo, error, context, langBarInfo);
}
- return TRUE;
+ return error;
}
-BOOL rail_order_recv(railPlugin* rail, wStream* s)
+WIN32ERROR rail_order_recv(railPlugin* rail, wStream* s)
{
UINT16 orderType;
UINT16 orderLength;
+ WIN32ERROR error;
- if (!rail_read_pdu_header(s, &orderType, &orderLength))
- return FALSE;
+ if ((error = rail_read_pdu_header(s, &orderType, &orderLength)))
+ {
+ WLog_ERR(TAG, "rail_read_pdu_header failed with error %lu!", error);
+ return error;
+ }
- WLog_Print(rail->log, WLOG_DEBUG, "Received %s PDU, length: %d",
+ WLog_Print(rail->log, WLOG_DEBUG, "Received %s PDU, length:%lu",
RAIL_ORDER_TYPE_STRINGS[((orderType & 0xF0) >> 3) + (orderType & 0x0F)], orderLength);
switch (orderType)
default:
WLog_ERR(TAG, "Unknown RAIL PDU order reveived.");
+ return ERROR_INVALID_DATA;
break;
}
- return TRUE;
+ return CHANNEL_RC_OK;
}
-BOOL rail_send_handshake_order(railPlugin* rail, RAIL_HANDSHAKE_ORDER* handshake)
+WIN32ERROR rail_send_handshake_order(railPlugin* rail, RAIL_HANDSHAKE_ORDER* handshake)
{
wStream* s;
- BOOL ret;
+ WIN32ERROR error;
s = rail_pdu_init(RAIL_HANDSHAKE_ORDER_LENGTH);
if (!s)
- return FALSE;
+ {
+ WLog_ERR(TAG, "rail_pdu_init failed!");
+ return CHANNEL_RC_NO_MEMORY;
+ }
rail_write_handshake_order(s, handshake);
- ret = rail_send_pdu(rail, s, RDP_RAIL_ORDER_HANDSHAKE);
+ error = rail_send_pdu(rail, s, RDP_RAIL_ORDER_HANDSHAKE);
Stream_Free(s, TRUE);
- return ret;
+ return error;
}
-BOOL rail_send_handshake_ex_order(railPlugin* rail, RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
+WIN32ERROR rail_send_handshake_ex_order(railPlugin* rail, RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
{
wStream* s;
- BOOL ret;
+ WIN32ERROR error;
s = rail_pdu_init(RAIL_HANDSHAKE_EX_ORDER_LENGTH);
if (!s)
- return FALSE;
+ {
+ WLog_ERR(TAG, "rail_pdu_init failed!");
+ return CHANNEL_RC_NO_MEMORY;
+ }
rail_write_handshake_ex_order(s, handshakeEx);
- ret = rail_send_pdu(rail, s, RDP_RAIL_ORDER_HANDSHAKE_EX);
+ error = rail_send_pdu(rail, s, RDP_RAIL_ORDER_HANDSHAKE_EX);
Stream_Free(s, TRUE);
- return ret;
+ return error;
}
-BOOL rail_send_client_status_order(railPlugin* rail, RAIL_CLIENT_STATUS_ORDER* clientStatus)
+WIN32ERROR rail_send_client_status_order(railPlugin* rail, RAIL_CLIENT_STATUS_ORDER* clientStatus)
{
wStream* s;
- BOOL ret;
+ WIN32ERROR error;
s = rail_pdu_init(RAIL_CLIENT_STATUS_ORDER_LENGTH);
if (!s)
- return FALSE;
+ {
+ WLog_ERR(TAG, "rail_pdu_init failed!");
+ return CHANNEL_RC_NO_MEMORY;
+ }
rail_write_client_status_order(s, clientStatus);
- ret = rail_send_pdu(rail, s, RDP_RAIL_ORDER_CLIENTSTATUS);
+ error = rail_send_pdu(rail, s, RDP_RAIL_ORDER_CLIENTSTATUS);
Stream_Free(s, TRUE);
- return ret;
+ return error;
}
-BOOL rail_send_client_exec_order(railPlugin* rail, RAIL_EXEC_ORDER* exec)
+WIN32ERROR rail_send_client_exec_order(railPlugin* rail, RAIL_EXEC_ORDER* exec)
{
wStream* s;
- BOOL ret;
- int length;
+ WIN32ERROR error;
+ size_t length;
length = RAIL_EXEC_ORDER_LENGTH +
exec->exeOrFile.length +
s = rail_pdu_init(length);
if (!s)
- return FALSE;
+ {
+ WLog_ERR(TAG, "rail_pdu_init failed!");
+ return CHANNEL_RC_NO_MEMORY;
+ }
- ret = rail_write_client_exec_order(s, exec) &&
- rail_send_pdu(rail, s, RDP_RAIL_ORDER_EXEC);
+ if ((error = rail_write_client_exec_order(s, exec)))
+ {
+ WLog_ERR(TAG, "rail_write_client_exec_order failed with error %lu!", error);
+ return error;
+ }
+ if ((error = rail_send_pdu(rail, s, RDP_RAIL_ORDER_EXEC)))
+ {
+ WLog_ERR(TAG, "rail_send_pdu failed with error %lu!", error);
+ return error;
+ }
Stream_Free(s, TRUE);
- return ret;
+ return error;
}
-BOOL rail_send_client_sysparam_order(railPlugin* rail, RAIL_SYSPARAM_ORDER* sysparam)
+WIN32ERROR rail_send_client_sysparam_order(railPlugin* rail, RAIL_SYSPARAM_ORDER* sysparam)
{
wStream* s;
int length;
- BOOL ret = FALSE;
+ WIN32ERROR error;
length = RAIL_SYSPARAM_ORDER_LENGTH;
s = rail_pdu_init(RAIL_SYSPARAM_ORDER_LENGTH + 8);
if (!s)
- return FALSE;
+ {
+ WLog_ERR(TAG, "rail_pdu_init failed!");
+ return CHANNEL_RC_NO_MEMORY;
+ }
- ret = rail_write_client_sysparam_order(s, sysparam) &&
- rail_send_pdu(rail, s, RDP_RAIL_ORDER_SYSPARAM);
+ if ((error = rail_write_client_sysparam_order(s, sysparam)))
+ {
+ WLog_ERR(TAG, "rail_write_client_sysparam_order failed with error %lu!", error);
+ return error;
+ }
+
+ if ((error = rail_send_pdu(rail, s, RDP_RAIL_ORDER_SYSPARAM)))
+ {
+ WLog_ERR(TAG, "rail_send_pdu failed with error %lu!", error);
+ return error;
+ }
Stream_Free(s, TRUE);
- return ret;
+ return error;
}
-BOOL rail_send_client_sysparams_order(railPlugin* rail, RAIL_SYSPARAM_ORDER* sysparam)
+WIN32ERROR rail_send_client_sysparams_order(railPlugin* rail, RAIL_SYSPARAM_ORDER* sysparam)
{
- BOOL ret = TRUE;
+ WIN32ERROR error = CHANNEL_RC_OK;
if (sysparam->params & SPI_MASK_SET_HIGH_CONTRAST)
{
sysparam->param = SPI_SET_HIGH_CONTRAST;
- ret &= rail_send_client_sysparam_order(rail, sysparam);
+ if ((error = rail_send_client_sysparam_order(rail, sysparam)))
+ {
+ WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %lu!", error);
+ return error;
+ }
}
if (sysparam->params & SPI_MASK_TASKBAR_POS)
{
sysparam->param = SPI_TASKBAR_POS;
- ret &= rail_send_client_sysparam_order(rail, sysparam);
+ if ((error = rail_send_client_sysparam_order(rail, sysparam)))
+ {
+ WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %lu!", error);
+ return error;
+ }
}
if (sysparam->params & SPI_MASK_SET_MOUSE_BUTTON_SWAP)
{
sysparam->param = SPI_SET_MOUSE_BUTTON_SWAP;
- ret &= rail_send_client_sysparam_order(rail, sysparam);
+ if ((error = rail_send_client_sysparam_order(rail, sysparam)))
+ {
+ WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %lu!", error);
+ return error;
+ }
}
if (sysparam->params & SPI_MASK_SET_KEYBOARD_PREF)
{
sysparam->param = SPI_SET_KEYBOARD_PREF;
- ret &= rail_send_client_sysparam_order(rail, sysparam);
+ if ((error = rail_send_client_sysparam_order(rail, sysparam)))
+ {
+ WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %lu!", error);
+ return error;
+ }
}
if (sysparam->params & SPI_MASK_SET_DRAG_FULL_WINDOWS)
{
sysparam->param = SPI_SET_DRAG_FULL_WINDOWS;
- ret &= rail_send_client_sysparam_order(rail, sysparam);
+ if ((error = rail_send_client_sysparam_order(rail, sysparam)))
+ {
+ WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %lu!", error);
+ return error;
+ }
}
if (sysparam->params & SPI_MASK_SET_KEYBOARD_CUES)
{
sysparam->param = SPI_SET_KEYBOARD_CUES;
- ret &= rail_send_client_sysparam_order(rail, sysparam);
+ if ((error = rail_send_client_sysparam_order(rail, sysparam)))
+ {
+ WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %lu!", error);
+ return error;
+ }
}
if (sysparam->params & SPI_MASK_SET_WORK_AREA)
{
sysparam->param = SPI_SET_WORK_AREA;
- ret &= rail_send_client_sysparam_order(rail, sysparam);
+ if ((error = rail_send_client_sysparam_order(rail, sysparam)))
+ {
+ WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %lu!", error);
+ return error;
+ }
}
- return ret;
+ return error;
}
-BOOL rail_send_client_activate_order(railPlugin* rail, RAIL_ACTIVATE_ORDER* activate)
+WIN32ERROR rail_send_client_activate_order(railPlugin* rail, RAIL_ACTIVATE_ORDER* activate)
{
wStream* s;
- BOOL ret;
+ WIN32ERROR error;
s = rail_pdu_init(RAIL_ACTIVATE_ORDER_LENGTH);
if (!s)
- return FALSE;
+ {
+ WLog_ERR(TAG, "rail_pdu_init failed!");
+ return CHANNEL_RC_NO_MEMORY;
+ }
rail_write_client_activate_order(s, activate);
- ret = rail_send_pdu(rail, s, RDP_RAIL_ORDER_ACTIVATE);
+ error = rail_send_pdu(rail, s, RDP_RAIL_ORDER_ACTIVATE);
Stream_Free(s, TRUE);
- return ret;
+ return error;
}
-BOOL rail_send_client_sysmenu_order(railPlugin* rail, RAIL_SYSMENU_ORDER* sysmenu)
+WIN32ERROR rail_send_client_sysmenu_order(railPlugin* rail, RAIL_SYSMENU_ORDER* sysmenu)
{
wStream* s;
- BOOL ret;
+ WIN32ERROR error;
s = rail_pdu_init(RAIL_SYSMENU_ORDER_LENGTH);
if (!s)
- return FALSE;
+ {
+ WLog_ERR(TAG, "rail_pdu_init failed!");
+ return CHANNEL_RC_NO_MEMORY;
+ }
rail_write_client_sysmenu_order(s, sysmenu);
- ret = rail_send_pdu(rail, s, RDP_RAIL_ORDER_SYSMENU);
+ error = rail_send_pdu(rail, s, RDP_RAIL_ORDER_SYSMENU);
Stream_Free(s, TRUE);
- return ret;
+ return error;
}
-BOOL rail_send_client_syscommand_order(railPlugin* rail, RAIL_SYSCOMMAND_ORDER* syscommand)
+WIN32ERROR rail_send_client_syscommand_order(railPlugin* rail, RAIL_SYSCOMMAND_ORDER* syscommand)
{
wStream* s;
- BOOL ret;
+ WIN32ERROR error;
s = rail_pdu_init(RAIL_SYSCOMMAND_ORDER_LENGTH);
if (!s)
- return FALSE;
+ {
+ WLog_ERR(TAG, "rail_pdu_init failed!");
+ return CHANNEL_RC_NO_MEMORY;
+ }
rail_write_client_syscommand_order(s, syscommand);
- ret = rail_send_pdu(rail, s, RDP_RAIL_ORDER_SYSCOMMAND);
+ error = rail_send_pdu(rail, s, RDP_RAIL_ORDER_SYSCOMMAND);
Stream_Free(s, TRUE);
- return ret;
+ return error;
}
-BOOL rail_send_client_notify_event_order(railPlugin* rail, RAIL_NOTIFY_EVENT_ORDER* notifyEvent)
+WIN32ERROR rail_send_client_notify_event_order(railPlugin* rail, RAIL_NOTIFY_EVENT_ORDER* notifyEvent)
{
wStream* s;
- BOOL ret;
+ WIN32ERROR error;
s = rail_pdu_init(RAIL_NOTIFY_EVENT_ORDER_LENGTH);
if (!s)
- return FALSE;
+ {
+ WLog_ERR(TAG, "rail_pdu_init failed!");
+ return CHANNEL_RC_NO_MEMORY;
+ }
rail_write_client_notify_event_order(s, notifyEvent);
- ret = rail_send_pdu(rail, s, RDP_RAIL_ORDER_NOTIFY_EVENT);
+ error = rail_send_pdu(rail, s, RDP_RAIL_ORDER_NOTIFY_EVENT);
Stream_Free(s, TRUE);
- return ret;
+ return error;
}
-BOOL rail_send_client_window_move_order(railPlugin* rail, RAIL_WINDOW_MOVE_ORDER* windowMove)
+WIN32ERROR rail_send_client_window_move_order(railPlugin* rail, RAIL_WINDOW_MOVE_ORDER* windowMove)
{
wStream* s;
- BOOL ret;
+ WIN32ERROR error;
s = rail_pdu_init(RAIL_WINDOW_MOVE_ORDER_LENGTH);
if (!s)
- return FALSE;
+ {
+ WLog_ERR(TAG, "rail_pdu_init failed!");
+ return CHANNEL_RC_NO_MEMORY;
+ }
rail_write_client_window_move_order(s, windowMove);
- ret = rail_send_pdu(rail, s, RDP_RAIL_ORDER_WINDOWMOVE);
+ error = rail_send_pdu(rail, s, RDP_RAIL_ORDER_WINDOWMOVE);
Stream_Free(s, TRUE);
- return ret;
+ return error;
}
-BOOL rail_send_client_get_appid_req_order(railPlugin* rail, RAIL_GET_APPID_REQ_ORDER* getAppIdReq)
+WIN32ERROR rail_send_client_get_appid_req_order(railPlugin* rail, RAIL_GET_APPID_REQ_ORDER* getAppIdReq)
{
wStream* s;
- BOOL ret;
+ WIN32ERROR error;
s = rail_pdu_init(RAIL_GET_APPID_REQ_ORDER_LENGTH);
if (!s)
- return FALSE;
+ {
+ WLog_ERR(TAG, "rail_pdu_init failed!");
+ return CHANNEL_RC_NO_MEMORY;
+ }
rail_write_client_get_appid_req_order(s, getAppIdReq);
- ret = rail_send_pdu(rail, s, RDP_RAIL_ORDER_GET_APPID_REQ);
+ error = rail_send_pdu(rail, s, RDP_RAIL_ORDER_GET_APPID_REQ);
Stream_Free(s, TRUE);
- return ret;
+ return error;
}
-BOOL rail_send_client_langbar_info_order(railPlugin* rail, RAIL_LANGBAR_INFO_ORDER* langBarInfo)
+WIN32ERROR rail_send_client_langbar_info_order(railPlugin* rail, RAIL_LANGBAR_INFO_ORDER* langBarInfo)
{
wStream* s;
- BOOL ret;
+ WIN32ERROR error;
s = rail_pdu_init(RAIL_LANGBAR_INFO_ORDER_LENGTH);
if (!s)
- return FALSE;
+ {
+ WLog_ERR(TAG, "rail_pdu_init failed!");
+ return CHANNEL_RC_NO_MEMORY;
+ }
rail_write_langbar_info_order(s, langBarInfo);
- ret = rail_send_pdu(rail, s, RDP_RAIL_ORDER_LANGBARINFO);
+ error = rail_send_pdu(rail, s, RDP_RAIL_ORDER_LANGBARINFO);
Stream_Free(s, TRUE);
- return ret;
+ return error;
}
*
* Copyright 2009 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2011 Roman Barabanov <romanbarabanov@gmail.com>
+ * Copyright 2015 Thincast Technologies GmbH
+ * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#define TAG CHANNELS_TAG("rail.client")
-BOOL rail_read_server_exec_result_order(wStream* s, RAIL_EXEC_RESULT_ORDER* exec_result);
-BOOL rail_read_server_sysparam_order(wStream* s, RAIL_SYSPARAM_ORDER* sysparam);
-BOOL rail_read_server_minmaxinfo_order(wStream* s, RAIL_MINMAXINFO_ORDER* minmaxinfo);
-BOOL rail_read_server_localmovesize_order(wStream* s, RAIL_LOCALMOVESIZE_ORDER* localmovesize);
-BOOL rail_read_server_get_appid_resp_order(wStream* s, RAIL_GET_APPID_RESP_ORDER* get_appid_resp);
-BOOL rail_read_langbar_info_order(wStream* s, RAIL_LANGBAR_INFO_ORDER* langbar_info);
+WIN32ERROR rail_read_server_exec_result_order(wStream* s, RAIL_EXEC_RESULT_ORDER* exec_result);
+WIN32ERROR rail_read_server_sysparam_order(wStream* s, RAIL_SYSPARAM_ORDER* sysparam);
+WIN32ERROR rail_read_server_minmaxinfo_order(wStream* s, RAIL_MINMAXINFO_ORDER* minmaxinfo);
+WIN32ERROR rail_read_server_localmovesize_order(wStream* s, RAIL_LOCALMOVESIZE_ORDER* localmovesize);
+WIN32ERROR rail_read_server_get_appid_resp_order(wStream* s, RAIL_GET_APPID_RESP_ORDER* get_appid_resp);
+WIN32ERROR rail_read_langbar_info_order(wStream* s, RAIL_LANGBAR_INFO_ORDER* langbar_info);
void rail_write_client_status_order(wStream* s, RAIL_CLIENT_STATUS_ORDER* client_status);
-BOOL rail_write_client_exec_order(wStream* s, RAIL_EXEC_ORDER* exec);
-BOOL rail_write_client_sysparam_order(wStream* s, RAIL_SYSPARAM_ORDER* sysparam);
+WIN32ERROR rail_write_client_exec_order(wStream* s, RAIL_EXEC_ORDER* exec);
+WIN32ERROR rail_write_client_sysparam_order(wStream* s, RAIL_SYSPARAM_ORDER* sysparam);
void rail_write_client_activate_order(wStream* s, RAIL_ACTIVATE_ORDER* activate);
void rail_write_client_sysmenu_order(wStream* s, RAIL_SYSMENU_ORDER* sysmenu);
void rail_write_client_syscommand_order(wStream* s, RAIL_SYSCOMMAND_ORDER* syscommand);
void rail_write_client_get_appid_req_order(wStream* s, RAIL_GET_APPID_REQ_ORDER* get_appid_req);
void rail_write_langbar_info_order(wStream* s, RAIL_LANGBAR_INFO_ORDER* langbar_info);
-BOOL rail_order_recv(railPlugin* rail, wStream* s);
-BOOL rail_send_pdu(railPlugin* rail, wStream* s, UINT16 orderType);
+WIN32ERROR rail_order_recv(railPlugin* rail, wStream* s);
+WIN32ERROR rail_send_pdu(railPlugin* rail, wStream* s, UINT16 orderType);
-BOOL rail_send_handshake_order(railPlugin* rail, RAIL_HANDSHAKE_ORDER* handshake);
-BOOL rail_send_handshake_ex_order(railPlugin* rail, RAIL_HANDSHAKE_EX_ORDER* handshakeEx);
-BOOL rail_send_client_status_order(railPlugin* rail, RAIL_CLIENT_STATUS_ORDER* clientStatus);
-BOOL rail_send_client_exec_order(railPlugin* rail, RAIL_EXEC_ORDER* exec);
-BOOL rail_send_client_sysparam_order(railPlugin* rail, RAIL_SYSPARAM_ORDER* sysparam);
-BOOL rail_send_client_sysparams_order(railPlugin* rail, RAIL_SYSPARAM_ORDER* sysparam);
-BOOL rail_send_client_activate_order(railPlugin* rail, RAIL_ACTIVATE_ORDER* activate);
-BOOL rail_send_client_sysmenu_order(railPlugin* rail, RAIL_SYSMENU_ORDER* sysmenu);
-BOOL rail_send_client_syscommand_order(railPlugin* rail, RAIL_SYSCOMMAND_ORDER* syscommand);
-BOOL rail_send_client_notify_event_order(railPlugin* rail, RAIL_NOTIFY_EVENT_ORDER* notifyEvent);
-BOOL rail_send_client_window_move_order(railPlugin* rail, RAIL_WINDOW_MOVE_ORDER* windowMove);
-BOOL rail_send_client_get_appid_req_order(railPlugin* rail, RAIL_GET_APPID_REQ_ORDER* getAppIdReq);
-BOOL rail_send_client_langbar_info_order(railPlugin* rail, RAIL_LANGBAR_INFO_ORDER* langBarInfo);
+WIN32ERROR rail_send_handshake_order(railPlugin* rail, RAIL_HANDSHAKE_ORDER* handshake);
+WIN32ERROR rail_send_handshake_ex_order(railPlugin* rail, RAIL_HANDSHAKE_EX_ORDER* handshakeEx);
+WIN32ERROR rail_send_client_status_order(railPlugin* rail, RAIL_CLIENT_STATUS_ORDER* clientStatus);
+WIN32ERROR rail_send_client_exec_order(railPlugin* rail, RAIL_EXEC_ORDER* exec);
+WIN32ERROR rail_send_client_sysparam_order(railPlugin* rail, RAIL_SYSPARAM_ORDER* sysparam);
+WIN32ERROR rail_send_client_sysparams_order(railPlugin* rail, RAIL_SYSPARAM_ORDER* sysparam);
+WIN32ERROR rail_send_client_activate_order(railPlugin* rail, RAIL_ACTIVATE_ORDER* activate);
+WIN32ERROR rail_send_client_sysmenu_order(railPlugin* rail, RAIL_SYSMENU_ORDER* sysmenu);
+WIN32ERROR rail_send_client_syscommand_order(railPlugin* rail, RAIL_SYSCOMMAND_ORDER* syscommand);
+WIN32ERROR rail_send_client_notify_event_order(railPlugin* rail, RAIL_NOTIFY_EVENT_ORDER* notifyEvent);
+WIN32ERROR rail_send_client_window_move_order(railPlugin* rail, RAIL_WINDOW_MOVE_ORDER* windowMove);
+WIN32ERROR rail_send_client_get_appid_req_order(railPlugin* rail, RAIL_GET_APPID_REQ_ORDER* getAppIdReq);
+WIN32ERROR rail_send_client_langbar_info_order(railPlugin* rail, RAIL_LANGBAR_INFO_ORDER* langBarInfo);
#endif /* __RAIL_ORDERS_H */
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2011 Roman Barabanov <romanbarabanov@gmail.com>
* Copyright 2011 Vic Lee
+ * Copyright 2015 Thincast Technologies GmbH
+ * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
unicode_string->length = (UINT16) length;
}
-BOOL rail_read_pdu_header(wStream* s, UINT16* orderType, UINT16* orderLength)
+WIN32ERROR rail_read_pdu_header(wStream* s, UINT16* orderType, UINT16* orderLength)
{
if (Stream_GetRemainingLength(s) < 4)
- return FALSE;
+ return ERROR_INVALID_DATA;
Stream_Read_UINT16(s, *orderType); /* orderType (2 bytes) */
Stream_Read_UINT16(s, *orderLength); /* orderLength (2 bytes) */
- return TRUE;
+ return CHANNEL_RC_OK;
}
void rail_write_pdu_header(wStream* s, UINT16 orderType, UINT16 orderLength)
Stream_Write_UINT16(s, orderLength); /* orderLength (2 bytes) */
}
-wStream* rail_pdu_init(int length)
+wStream* rail_pdu_init(size_t length)
{
wStream* s;
s = Stream_New(NULL, length + RAIL_PDU_HEADER_LENGTH);
return s;
}
-BOOL rail_read_handshake_order(wStream* s, RAIL_HANDSHAKE_ORDER* handshake)
+WIN32ERROR rail_read_handshake_order(wStream* s, RAIL_HANDSHAKE_ORDER* handshake)
{
if (Stream_GetRemainingLength(s) < 4)
- return FALSE;
+ return ERROR_INVALID_DATA;
Stream_Read_UINT32(s, handshake->buildNumber); /* buildNumber (4 bytes) */
- return TRUE;
+ return CHANNEL_RC_OK;
}
void rail_write_handshake_order(wStream* s, RAIL_HANDSHAKE_ORDER* handshake)
Stream_Write_UINT32(s, handshake->buildNumber); /* buildNumber (4 bytes) */
}
-BOOL rail_read_handshake_ex_order(wStream* s, RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
+WIN32ERROR rail_read_handshake_ex_order(wStream* s, RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
{
if (Stream_GetRemainingLength(s) < 8)
- return FALSE;
+ return ERROR_INVALID_DATA;
Stream_Read_UINT32(s, handshakeEx->buildNumber); /* buildNumber (4 bytes) */
Stream_Read_UINT32(s, handshakeEx->railHandshakeFlags); /* railHandshakeFlags (4 bytes) */
- return TRUE;
+ return CHANNEL_RC_OK;
}
void rail_write_handshake_ex_order(wStream* s, RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2011 Roman Barabanov <romanbarabanov@gmail.com>
* Copyright 2011 Vic Lee
+ * Copyright 2015 Thincast Technologies GmbH
+ * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#define FREERDP_CHANNEL_RAIL_COMMON_H
#include <freerdp/rail.h>
+#include <winpr/win32error.h>
extern const char* const RAIL_ORDER_TYPE_STRINGS[];
#define RAIL_LANGBAR_INFO_ORDER_LENGTH 4 /* fixed */
void rail_string_to_unicode_string(char* string, RAIL_UNICODE_STRING* unicode_string);
-BOOL rail_read_handshake_order(wStream* s, RAIL_HANDSHAKE_ORDER* handshake);
+WIN32ERROR rail_read_handshake_order(wStream* s, RAIL_HANDSHAKE_ORDER* handshake);
void rail_write_handshake_order(wStream* s, RAIL_HANDSHAKE_ORDER* handshake);
-BOOL rail_read_handshake_ex_order(wStream* s, RAIL_HANDSHAKE_EX_ORDER* handshakeEx);
+WIN32ERROR rail_read_handshake_ex_order(wStream* s, RAIL_HANDSHAKE_EX_ORDER* handshakeEx);
void rail_write_handshake_ex_order(wStream* s, RAIL_HANDSHAKE_EX_ORDER* handshakeEx);
-wStream* rail_pdu_init(int length);
-BOOL rail_read_pdu_header(wStream* s, UINT16* orderType, UINT16* orderLength);
+wStream* rail_pdu_init(size_t length);
+WIN32ERROR rail_read_pdu_header(wStream* s, UINT16* orderType, UINT16* orderLength);
void rail_write_pdu_header(wStream* s, UINT16 orderType, UINT16 orderLength);
#endif /* FREERDP_CHANNEL_RAIL_COMMON_H */
/* RemoteApp Virtual Channel Extension */
-static int wf_rail_server_execute_result(RailClientContext* context, RAIL_EXEC_RESULT_ORDER* execResult)
+static WIN32ERROR wf_rail_server_execute_result(RailClientContext* context, RAIL_EXEC_RESULT_ORDER* execResult)
{
WLog_DBG(TAG, "RailServerExecuteResult: 0x%04X", execResult->rawResult);
- return 1;
+ return CHANNEL_RC_OK;
}
-static int wf_rail_server_system_param(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam)
+static WIN32ERROR wf_rail_server_system_param(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam)
{
- return 1;
+ return CHANNEL_RC_OK;
}
-static int wf_rail_server_handshake(RailClientContext* context, RAIL_HANDSHAKE_ORDER* handshake)
+static WIN32ERROR wf_rail_server_handshake(RailClientContext* context, RAIL_HANDSHAKE_ORDER* handshake)
{
RAIL_EXEC_ORDER exec;
RAIL_SYSPARAM_ORDER sysparam;
context->ClientExecute(context, &exec);
- return 1;
+ return CHANNEL_RC_OK;
}
-static int wf_rail_server_handshake_ex(RailClientContext* context, RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
+static WIN32ERROR wf_rail_server_handshake_ex(RailClientContext* context, RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
{
- return 1;
+ return CHANNEL_RC_OK;
}
-static int wf_rail_server_local_move_size(RailClientContext* context, RAIL_LOCALMOVESIZE_ORDER* localMoveSize)
+static WIN32ERROR wf_rail_server_local_move_size(RailClientContext* context, RAIL_LOCALMOVESIZE_ORDER* localMoveSize)
{
- return 1;
+ return CHANNEL_RC_OK;
}
-static int wf_rail_server_min_max_info(RailClientContext* context, RAIL_MINMAXINFO_ORDER* minMaxInfo)
+static WIN32ERROR wf_rail_server_min_max_info(RailClientContext* context, RAIL_MINMAXINFO_ORDER* minMaxInfo)
{
- return 1;
+ return CHANNEL_RC_OK;
}
-static int wf_rail_server_language_bar_info(RailClientContext* context, RAIL_LANGBAR_INFO_ORDER* langBarInfo)
+static WIN32ERROR wf_rail_server_language_bar_info(RailClientContext* context, RAIL_LANGBAR_INFO_ORDER* langBarInfo)
{
- return 1;
+ return CHANNEL_RC_OK;
}
-static int wf_rail_server_get_appid_response(RailClientContext* context, RAIL_GET_APPID_RESP_ORDER* getAppIdResp)
+static WIN32ERROR wf_rail_server_get_appid_response(RailClientContext* context, RAIL_GET_APPID_RESP_ORDER* getAppIdResp)
{
- return 1;
+ return CHANNEL_RC_OK;
}
void wf_rail_invalidate_region(wfContext* wfc, REGION16* invalidRegion)
/* RemoteApp Virtual Channel Extension */
-static int xf_rail_server_execute_result(RailClientContext* context, RAIL_EXEC_RESULT_ORDER* execResult)
+static WIN32ERROR xf_rail_server_execute_result(RailClientContext* context, RAIL_EXEC_RESULT_ORDER* execResult)
{
xfContext* xfc = (xfContext*) context->custom;
xf_rail_enable_remoteapp_mode(xfc);
}
- return 1;
+ return CHANNEL_RC_OK;
}
-static int xf_rail_server_system_param(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam)
+static WIN32ERROR xf_rail_server_system_param(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam)
{
- return 1;
+ return CHANNEL_RC_OK;
}
-static int xf_rail_server_handshake(RailClientContext* context, RAIL_HANDSHAKE_ORDER* handshake)
+static WIN32ERROR xf_rail_server_handshake(RailClientContext* context, RAIL_HANDSHAKE_ORDER* handshake)
{
RAIL_EXEC_ORDER exec;
RAIL_SYSPARAM_ORDER sysparam;
context->ClientExecute(context, &exec);
- return 1;
+ return CHANNEL_RC_OK;
}
-static int xf_rail_server_handshake_ex(RailClientContext* context, RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
+static WIN32ERROR xf_rail_server_handshake_ex(RailClientContext* context, RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
{
- return 1;
+ return CHANNEL_RC_OK;
}
-static int xf_rail_server_local_move_size(RailClientContext* context, RAIL_LOCALMOVESIZE_ORDER* localMoveSize)
+static WIN32ERROR xf_rail_server_local_move_size(RailClientContext* context, RAIL_LOCALMOVESIZE_ORDER* localMoveSize)
{
int x = 0, y = 0;
int direction = 0;
(void*) (UINT_PTR) localMoveSize->windowId);
if (!appWindow)
- return -1;
+ return ERROR_INTERNAL_ERROR;
switch (localMoveSize->moveSizeType)
{
x = localMoveSize->posX;
y = localMoveSize->posY;
/* FIXME: local keyboard moves not working */
- return 1;
+ return CHANNEL_RC_OK;
break;
case RAIL_WMSZ_KEYSIZE:
x = localMoveSize->posX;
y = localMoveSize->posY;
/* FIXME: local keyboard moves not working */
- return 1;
+ return CHANNEL_RC_OK;
break;
}
xf_EndLocalMoveSize(xfc, appWindow);
}
- return 1;
+ return CHANNEL_RC_OK;
}
-static int xf_rail_server_min_max_info(RailClientContext* context, RAIL_MINMAXINFO_ORDER* minMaxInfo)
+static WIN32ERROR xf_rail_server_min_max_info(RailClientContext* context, RAIL_MINMAXINFO_ORDER* minMaxInfo)
{
xfAppWindow* appWindow = NULL;
xfContext* xfc = (xfContext*) context->custom;
(void*) (UINT_PTR) minMaxInfo->windowId);
if (!appWindow)
- return -1;
+ return ERROR_INTERNAL_ERROR;
xf_SetWindowMinMaxInfo(xfc, appWindow,
minMaxInfo->maxWidth, minMaxInfo->maxHeight,
minMaxInfo->minTrackWidth, minMaxInfo->minTrackHeight,
minMaxInfo->maxTrackWidth, minMaxInfo->maxTrackHeight);
- return 1;
+ return CHANNEL_RC_OK;
}
-static int xf_rail_server_language_bar_info(RailClientContext* context, RAIL_LANGBAR_INFO_ORDER* langBarInfo)
+static WIN32ERROR xf_rail_server_language_bar_info(RailClientContext* context, RAIL_LANGBAR_INFO_ORDER* langBarInfo)
{
- return 1;
+ return CHANNEL_RC_OK;
}
-static int xf_rail_server_get_appid_response(RailClientContext* context, RAIL_GET_APPID_RESP_ORDER* getAppIdResp)
+static WIN32ERROR xf_rail_server_get_appid_response(RailClientContext* context, RAIL_GET_APPID_RESP_ORDER* getAppIdResp)
{
- return 1;
+ return CHANNEL_RC_OK;
}
int xf_rail_init(xfContext* xfc, RailClientContext* rail)
#include <freerdp/rail.h>
#include <freerdp/message.h>
#include <freerdp/channels/rail.h>
+#include <winpr/win32error.h>
/**
* Client Interface
typedef struct _rail_client_context RailClientContext;
-typedef int (*pcRailClientExecute)(RailClientContext* context, RAIL_EXEC_ORDER* exec);
-typedef int (*pcRailClientActivate)(RailClientContext* context, RAIL_ACTIVATE_ORDER* activate);
-typedef int (*pcRailClientSystemParam)(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam);
-typedef int (*pcRailServerSystemParam)(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam);
-typedef int (*pcRailClientSystemCommand)(RailClientContext* context, RAIL_SYSCOMMAND_ORDER* syscommand);
-typedef int (*pcRailClientHandshake)(RailClientContext* context, RAIL_HANDSHAKE_ORDER* handshake);
-typedef int (*pcRailServerHandshake)(RailClientContext* context, RAIL_HANDSHAKE_ORDER* handshake);
-typedef int (*pcRailClientHandshakeEx)(RailClientContext* context, RAIL_HANDSHAKE_EX_ORDER* handshakeEx);
-typedef int (*pcRailServerHandshakeEx)(RailClientContext* context, RAIL_HANDSHAKE_EX_ORDER* handshakeEx);
-typedef int (*pcRailClientNotifyEvent)(RailClientContext* context, RAIL_NOTIFY_EVENT_ORDER* notifyEvent);
-typedef int (*pcRailClientWindowMove)(RailClientContext* context, RAIL_WINDOW_MOVE_ORDER* windowMove);
-typedef int (*pcRailServerLocalMoveSize)(RailClientContext* context, RAIL_LOCALMOVESIZE_ORDER* localMoveSize);
-typedef int (*pcRailServerMinMaxInfo)(RailClientContext* context, RAIL_MINMAXINFO_ORDER* minMaxInfo);
-typedef int (*pcRailClientInformation)(RailClientContext* context, RAIL_CLIENT_STATUS_ORDER* clientStatus);
-typedef int (*pcRailClientSystemMenu)(RailClientContext* context, RAIL_SYSMENU_ORDER* sysmenu);
-typedef int (*pcRailClientLanguageBarInfo)(RailClientContext* context, RAIL_LANGBAR_INFO_ORDER* langBarInfo);
-typedef int (*pcRailServerLanguageBarInfo)(RailClientContext* context, RAIL_LANGBAR_INFO_ORDER* langBarInfo);
-typedef int (*pcRailServerExecuteResult)(RailClientContext* context, RAIL_EXEC_RESULT_ORDER* execResult);
-typedef int (*pcRailClientGetAppIdRequest)(RailClientContext* context, RAIL_GET_APPID_REQ_ORDER* getAppIdReq);
-typedef int (*pcRailServerGetAppIdResponse)(RailClientContext* context, RAIL_GET_APPID_RESP_ORDER* getAppIdResp);
+typedef WIN32ERROR (*pcRailClientExecute)(RailClientContext* context, RAIL_EXEC_ORDER* exec);
+typedef WIN32ERROR (*pcRailClientActivate)(RailClientContext* context, RAIL_ACTIVATE_ORDER* activate);
+typedef WIN32ERROR (*pcRailClientSystemParam)(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam);
+typedef WIN32ERROR (*pcRailServerSystemParam)(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam);
+typedef WIN32ERROR (*pcRailClientSystemCommand)(RailClientContext* context, RAIL_SYSCOMMAND_ORDER* syscommand);
+typedef WIN32ERROR (*pcRailClientHandshake)(RailClientContext* context, RAIL_HANDSHAKE_ORDER* handshake);
+typedef WIN32ERROR (*pcRailServerHandshake)(RailClientContext* context, RAIL_HANDSHAKE_ORDER* handshake);
+typedef WIN32ERROR (*pcRailClientHandshakeEx)(RailClientContext* context, RAIL_HANDSHAKE_EX_ORDER* handshakeEx);
+typedef WIN32ERROR (*pcRailServerHandshakeEx)(RailClientContext* context, RAIL_HANDSHAKE_EX_ORDER* handshakeEx);
+typedef WIN32ERROR (*pcRailClientNotifyEvent)(RailClientContext* context, RAIL_NOTIFY_EVENT_ORDER* notifyEvent);
+typedef WIN32ERROR (*pcRailClientWindowMove)(RailClientContext* context, RAIL_WINDOW_MOVE_ORDER* windowMove);
+typedef WIN32ERROR (*pcRailServerLocalMoveSize)(RailClientContext* context, RAIL_LOCALMOVESIZE_ORDER* localMoveSize);
+typedef WIN32ERROR (*pcRailServerMinMaxInfo)(RailClientContext* context, RAIL_MINMAXINFO_ORDER* minMaxInfo);
+typedef WIN32ERROR (*pcRailClientInformation)(RailClientContext* context, RAIL_CLIENT_STATUS_ORDER* clientStatus);
+typedef WIN32ERROR (*pcRailClientSystemMenu)(RailClientContext* context, RAIL_SYSMENU_ORDER* sysmenu);
+typedef WIN32ERROR (*pcRailClientLanguageBarInfo)(RailClientContext* context, RAIL_LANGBAR_INFO_ORDER* langBarInfo);
+typedef WIN32ERROR (*pcRailServerLanguageBarInfo)(RailClientContext* context, RAIL_LANGBAR_INFO_ORDER* langBarInfo);
+typedef WIN32ERROR (*pcRailServerExecuteResult)(RailClientContext* context, RAIL_EXEC_RESULT_ORDER* execResult);
+typedef WIN32ERROR (*pcRailClientGetAppIdRequest)(RailClientContext* context, RAIL_GET_APPID_REQ_ORDER* getAppIdReq);
+typedef WIN32ERROR (*pcRailServerGetAppIdResponse)(RailClientContext* context, RAIL_GET_APPID_RESP_ORDER* getAppIdResp);
struct _rail_client_context
{