rail: started new cleaner RAIL orders parsing/encoding code
This commit is contained in:
parent
21aa8ad9a8
commit
b680ac1ecc
@ -22,6 +22,8 @@ set(RAIL_SRCS
|
||||
rail_main.h
|
||||
rail_core.c
|
||||
rail_core.h
|
||||
rail_orders.c
|
||||
rail_orders.h
|
||||
rail_channel_orders.c
|
||||
rail_channel_orders.h
|
||||
)
|
||||
|
@ -128,9 +128,9 @@ void rail_vchannel_send_exec_order(RAIL_SESSION* session, uint16 flags,
|
||||
STREAM st_stream = {0};
|
||||
STREAM* s = &st_stream;
|
||||
|
||||
uint16 exe_or_file_length = exe_or_file->cbString;
|
||||
uint16 working_directory_length = working_directory->cbString;
|
||||
uint16 arguments_length = arguments->cbString;
|
||||
uint16 exe_or_file_length = exe_or_file->length;
|
||||
uint16 working_directory_length = working_directory->length;
|
||||
uint16 arguments_length = arguments->length;
|
||||
|
||||
size_t data_length =
|
||||
2 + /*Flags (2 bytes)*/
|
||||
@ -166,14 +166,14 @@ size_t get_sysparam_size_in_rdp_stream(RAIL_CLIENT_SYSPARAM * sysparam)
|
||||
case SPI_SET_KEYBOARD_PREF: {return 1;}
|
||||
case SPI_SET_MOUSE_BUTTON_SWAP: {return 1;}
|
||||
case SPI_SET_WORK_AREA: {return 8;}
|
||||
case RAIL_SPI_DISPLAY_CHANGE: {return 8;}
|
||||
case RAIL_SPI_TASKBAR_POS: {return 8;}
|
||||
case SPI_DISPLAY_CHANGE: {return 8;}
|
||||
case SPI_TASKBAR_POS: {return 8;}
|
||||
case SPI_SET_HIGH_CONTRAST:
|
||||
{
|
||||
return (4 + /*Flags (4 bytes)*/
|
||||
4 + /*ColorSchemeLength (4 bytes)*/
|
||||
2 + /*UNICODE_STRING.cbString (2 bytes)*/
|
||||
sysparam->value.high_contrast_system_info.color_scheme.cbString);
|
||||
sysparam->value.high_contrast_system_info.color_scheme.length);
|
||||
}
|
||||
};
|
||||
|
||||
@ -221,18 +221,18 @@ void rail_vchannel_send_client_sysparam_update_order(RAIL_SESSION* session, RAIL
|
||||
rail_write_rectangle_16(s, &sysparam->value.work_area);
|
||||
break;
|
||||
|
||||
case RAIL_SPI_DISPLAY_CHANGE:
|
||||
case SPI_DISPLAY_CHANGE:
|
||||
rail_write_rectangle_16(s, &sysparam->value.display_resolution);
|
||||
break;
|
||||
|
||||
case RAIL_SPI_TASKBAR_POS:
|
||||
case SPI_TASKBAR_POS:
|
||||
rail_write_rectangle_16(s, &sysparam->value.taskbar_size);
|
||||
break;
|
||||
|
||||
case SPI_SET_HIGH_CONTRAST:
|
||||
{
|
||||
uint32 color_scheme_length = 2 +
|
||||
sysparam->value.high_contrast_system_info.color_scheme.cbString;
|
||||
sysparam->value.high_contrast_system_info.color_scheme.length;
|
||||
|
||||
stream_write_uint32(s, sysparam->value.high_contrast_system_info.flags);
|
||||
stream_write_uint32(s, color_scheme_length);
|
||||
@ -352,8 +352,7 @@ void rail_vchannel_send_client_system_menu_order(RAIL_SESSION* session, uint32 w
|
||||
stream_write_uint16(s, left);
|
||||
stream_write_uint16(s, top);
|
||||
|
||||
rail_vchannel_send_order_data(session, RDP_RAIL_ORDER_SYSMENU, data,
|
||||
data_length);
|
||||
rail_vchannel_send_order_data(session, RDP_RAIL_ORDER_SYSMENU, data, data_length);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -542,11 +541,11 @@ static void rail_vchannel_process_server_get_appid_resp_order(RAIL_SESSION* sess
|
||||
uint32 window_id = 0;
|
||||
UNICODE_STRING app_id = {0};
|
||||
|
||||
app_id.cbString = 256;
|
||||
app_id.string = xmalloc(app_id.cbString);
|
||||
app_id.length = 256;
|
||||
app_id.string = xmalloc(app_id.length);
|
||||
|
||||
stream_read_uint32(s, window_id);
|
||||
stream_read(s, app_id.string, app_id.cbString);
|
||||
stream_read(s, app_id.string, app_id.length);
|
||||
|
||||
rail_core_handle_server_get_app_resp(session, window_id, &app_id);
|
||||
rail_unicode_string_free(&app_id);
|
||||
|
@ -41,8 +41,6 @@
|
||||
//
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Flow of init stage over channel;
|
||||
|
||||
@ -84,14 +82,14 @@ void rail_string2unicode_string(RAIL_SESSION* session, RAIL_STRING* string, UNIC
|
||||
char* result_buffer = NULL;
|
||||
|
||||
unicode_string->string = NULL;
|
||||
unicode_string->cbString = 0;
|
||||
unicode_string->length = 0;
|
||||
|
||||
if (string->length == 0) return;
|
||||
|
||||
result_buffer = freerdp_uniconv_out(session->uniconv, (char*) string->buffer, &result_length);
|
||||
|
||||
unicode_string->string = (uint8*) result_buffer;
|
||||
unicode_string->cbString = (uint16) result_length;
|
||||
unicode_string->length = (uint16) result_length;
|
||||
}
|
||||
|
||||
void rail_unicode_string2string(RAIL_SESSION* session, UNICODE_STRING* unicode_string, RAIL_STRING* string)
|
||||
@ -101,10 +99,10 @@ void rail_unicode_string2string(RAIL_SESSION* session, UNICODE_STRING* unicode_s
|
||||
string->buffer = NULL;
|
||||
string->length = 0;
|
||||
|
||||
if (unicode_string->cbString == 0)
|
||||
if (unicode_string->length == 0)
|
||||
return;
|
||||
|
||||
result_buffer = freerdp_uniconv_in(session->uniconv, unicode_string->string, unicode_string->cbString);
|
||||
result_buffer = freerdp_uniconv_in(session->uniconv, unicode_string->string, unicode_string->length);
|
||||
|
||||
string->buffer = (uint8*)result_buffer;
|
||||
string->length = strlen(result_buffer) + 1;
|
||||
@ -179,10 +177,10 @@ void rail_core_handle_exec_result(RAIL_SESSION* session, uint16 flags, uint16 ex
|
||||
|
||||
DEBUG_RAIL("rail_core_handle_exec_result: session=0x%p flags=0x%X "
|
||||
"exec_result=0x%X raw_result=0x%X exe_or_file=(length=%d dump>)",
|
||||
session, flags, exec_result, raw_result, exe_or_file->cbString);
|
||||
session, flags, exec_result, raw_result, exe_or_file->length);
|
||||
|
||||
#ifdef WITH_DEBUG_RAIL
|
||||
freerdp_hexdump(exe_or_file->string, exe_or_file->cbString);
|
||||
freerdp_hexdump(exe_or_file->string, exe_or_file->length);
|
||||
#endif
|
||||
|
||||
rail_unicode_string2string(session, exe_or_file, &exe_or_file_);
|
||||
@ -285,10 +283,10 @@ void rail_core_handle_server_get_app_resp(RAIL_SESSION* session, uint32 window_i
|
||||
RAIL_STRING app_id_;
|
||||
|
||||
DEBUG_RAIL("rail_core_handle_server_get_app_resp: session=0x%p "
|
||||
"window_id=0x%X app_id=(length=%d dump>)", session, window_id, app_id->cbString);
|
||||
"window_id=0x%X app_id=(length=%d dump>)", session, window_id, app_id->length);
|
||||
|
||||
#ifdef WITH_DEBUG_RAIL
|
||||
freerdp_hexdump(app_id->string, app_id->cbString);
|
||||
freerdp_hexdump(app_id->string, app_id->length);
|
||||
#endif
|
||||
|
||||
rail_unicode_string2string(session, app_id, &app_id_);
|
||||
|
@ -97,7 +97,7 @@ typedef struct _RAIL_VCHANNEL_EVENT_SENDER RAIL_VCHANNEL_EVENT_SENDER;
|
||||
|
||||
struct _RAIL_SESSION
|
||||
{
|
||||
UNICONV * uniconv;
|
||||
UNICONV* uniconv;
|
||||
RAIL_VCHANNEL_DATA_SENDER* data_sender;
|
||||
RAIL_VCHANNEL_EVENT_SENDER* event_sender;
|
||||
};
|
||||
|
406
channels/rail/rail_orders.c
Normal file
406
channels/rail/rail_orders.c
Normal file
@ -0,0 +1,406 @@
|
||||
/*
|
||||
FreeRDP: A Remote Desktop Protocol client.
|
||||
Remote Applications Integrated Locally (RAIL) Orders
|
||||
|
||||
Copyright 2009 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
Copyright 2011 Roman Barabanov <romanbarabanov@gmail.com>
|
||||
|
||||
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 <freerdp/utils/memory.h>
|
||||
|
||||
#include "rail_orders.h"
|
||||
|
||||
void rail_read_pdu_header(STREAM* s, uint16* orderType, uint16* orderLength)
|
||||
{
|
||||
stream_read_uint16(s, *orderType); /* orderType (2 bytes) */
|
||||
stream_read_uint16(s, *orderLength); /* orderLength (2 bytes) */
|
||||
}
|
||||
|
||||
void rail_write_pdu_header(STREAM* s, uint16 orderType, uint16 orderLength)
|
||||
{
|
||||
stream_write_uint16(s, orderType); /* orderType (2 bytes) */
|
||||
stream_write_uint16(s, orderLength); /* orderLength (2 bytes) */
|
||||
}
|
||||
|
||||
STREAM* rail_pdu_init(int length)
|
||||
{
|
||||
STREAM* s;
|
||||
s = stream_new(length + RAIL_PDU_HEADER_LENGTH);
|
||||
stream_seek(s, RAIL_PDU_HEADER_LENGTH);
|
||||
return s;
|
||||
}
|
||||
|
||||
void rail_send_pdu(STREAM* s, uint16 orderType)
|
||||
{
|
||||
uint16 orderLength;
|
||||
|
||||
orderLength = stream_get_length(s);
|
||||
stream_set_pos(s, 0);
|
||||
|
||||
rail_write_pdu_header(s, orderType, orderLength);
|
||||
stream_set_pos(s, orderLength);
|
||||
|
||||
/* send */
|
||||
}
|
||||
|
||||
void rail_write_high_contrast(STREAM* s, HIGH_CONTRAST* high_contrast)
|
||||
{
|
||||
stream_write_uint32(s, high_contrast->flags); /* flags (4 bytes) */
|
||||
stream_write_uint32(s, high_contrast->colorSchemeLength); /* colorSchemeLength (4 bytes) */
|
||||
stream_write(s, high_contrast->colorScheme, high_contrast->colorSchemeLength); /* colorScheme */
|
||||
}
|
||||
|
||||
void rail_read_handshake_order(STREAM* s, RAIL_HANDSHAKE_ORDER* handshake)
|
||||
{
|
||||
stream_read_uint32(s, handshake->buildNumber); /* buildNumber (4 bytes) */
|
||||
}
|
||||
|
||||
void rail_read_server_exec_result_order(STREAM* s, RAIL_EXEC_RESULT_ORDER* exec_result)
|
||||
{
|
||||
stream_read_uint16(s, exec_result->flags); /* flags (2 bytes) */
|
||||
stream_read_uint16(s, exec_result->execResult); /* execResult (2 bytes) */
|
||||
stream_read_uint32(s, exec_result->rawResult); /* rawResult (4 bytes) */
|
||||
stream_skip_uint16(s); /* padding (2 bytes) */
|
||||
rail_read_unicode_string(s, &exec_result->exeOrFile); /* exeOrFile */
|
||||
}
|
||||
|
||||
void rail_read_server_sysparam_order(STREAM* s, RAIL_SYSPARAM_ORDER* sysparam)
|
||||
{
|
||||
uint8 body;
|
||||
stream_read_uint32(s, sysparam->systemParam); /* systemParam (4 bytes) */
|
||||
stream_read_uint8(s, body); /* body (1 byte) */
|
||||
sysparam->value = (body != 0) ? True : False;
|
||||
}
|
||||
|
||||
void rail_read_server_minmaxinfo_order(STREAM* s, RAIL_MINMAXINFO_ORDER* minmaxinfo)
|
||||
{
|
||||
stream_read_uint32(s, minmaxinfo->windowId); /* windowId (4 bytes) */
|
||||
stream_read_uint16(s, minmaxinfo->maxWidth); /* maxWidth (2 bytes) */
|
||||
stream_read_uint16(s, minmaxinfo->maxHeight); /* maxHeight (2 bytes) */
|
||||
stream_read_uint16(s, minmaxinfo->maxPosX); /* maxPosX (2 bytes) */
|
||||
stream_read_uint16(s, minmaxinfo->maxPosY); /* maxPosY (2 bytes) */
|
||||
stream_read_uint16(s, minmaxinfo->minTrackWidth); /* minTrackWidth (2 bytes) */
|
||||
stream_read_uint16(s, minmaxinfo->minTrackHeight); /* minTrackHeight (2 bytes) */
|
||||
stream_read_uint16(s, minmaxinfo->maxTrackWidth); /* maxTrackWidth (2 bytes) */
|
||||
stream_read_uint16(s, minmaxinfo->maxTrackHeight); /* maxTrackHeight (2 bytes) */
|
||||
}
|
||||
|
||||
void rail_read_server_localmovesize_order(STREAM* s, RAIL_LOCALMOVESIZE_ORDER* localmovesize)
|
||||
{
|
||||
uint16 isMoveSizeStart;
|
||||
stream_read_uint32(s, localmovesize->windowId); /* windowId (4 bytes) */
|
||||
|
||||
stream_read_uint16(s, isMoveSizeStart); /* isMoveSizeStart (2 bytes) */
|
||||
localmovesize->isMoveSizeStart = (isMoveSizeStart != 0) ? True : False;
|
||||
|
||||
stream_read_uint16(s, localmovesize->moveSizeType); /* moveSizeType (2 bytes) */
|
||||
stream_read_uint16(s, localmovesize->posX); /* posX (2 bytes) */
|
||||
stream_read_uint16(s, localmovesize->posY); /* posY (2 bytes) */
|
||||
}
|
||||
|
||||
void rail_read_server_get_appid_resp_order(STREAM* s, RAIL_GET_APPID_RESP_ORDER* get_appid_resp)
|
||||
{
|
||||
stream_read_uint32(s, get_appid_resp->windowId); /* windowId (4 bytes) */
|
||||
|
||||
get_appid_resp->applicationId.length = 256;
|
||||
stream_read(s, get_appid_resp->applicationId.string, 256); /* applicationId (256 bytes) */
|
||||
}
|
||||
|
||||
void rail_read_langbar_info_order(STREAM* s, RAIL_LANGBAR_INFO_ORDER* langbar_info)
|
||||
{
|
||||
stream_read_uint32(s, langbar_info->languageBarStatus); /* languageBarStatus (4 bytes) */
|
||||
}
|
||||
|
||||
void rail_write_handshake_order(STREAM* s, RAIL_HANDSHAKE_ORDER* handshake)
|
||||
{
|
||||
stream_write_uint32(s, handshake->buildNumber); /* buildNumber (4 bytes) */
|
||||
}
|
||||
|
||||
void rail_write_client_status_order(STREAM* s, RAIL_CLIENT_STATUS_ORDER* client_status)
|
||||
{
|
||||
stream_write_uint32(s, client_status->flags); /* flags (4 bytes) */
|
||||
}
|
||||
|
||||
void rail_write_client_exec_order(STREAM* s, RAIL_EXEC_ORDER* exec)
|
||||
{
|
||||
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) */
|
||||
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 */
|
||||
}
|
||||
|
||||
void rail_write_client_sysparam_order(STREAM* s, RAIL_SYSPARAM_ORDER* sysparam)
|
||||
{
|
||||
uint8 body;
|
||||
stream_write_uint32(s, sysparam->systemParam); /* systemParam (4 bytes) */
|
||||
|
||||
switch (sysparam->systemParam)
|
||||
{
|
||||
case SPI_SET_DRAG_FULL_WINDOWS:
|
||||
case SPI_SET_KEYBOARD_CUES:
|
||||
case SPI_SET_KEYBOARD_PREF:
|
||||
case SPI_SET_MOUSE_BUTTON_SWAP:
|
||||
body = sysparam->value;
|
||||
stream_write_uint8(s, body);
|
||||
break;
|
||||
|
||||
case SPI_SET_WORK_AREA:
|
||||
case SPI_DISPLAY_CHANGE:
|
||||
case SPI_TASKBAR_POS:
|
||||
stream_write(s, sysparam->body, 8);
|
||||
break;
|
||||
|
||||
case SPI_SET_HIGH_CONTRAST:
|
||||
rail_write_high_contrast(s, (HIGH_CONTRAST*) sysparam->body);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void rail_write_client_activate_order(STREAM* s, RAIL_ACTIVATE_ORDER* activate)
|
||||
{
|
||||
uint8 enabled;
|
||||
|
||||
stream_write_uint32(s, activate->windowId); /* windowId (4 bytes) */
|
||||
|
||||
enabled = activate->enabled;
|
||||
stream_write_uint8(s, enabled); /* enabled (1 byte) */
|
||||
}
|
||||
|
||||
void rail_write_client_sysmenu_order(STREAM* s, RAIL_SYSMENU_ORDER* sysmenu)
|
||||
{
|
||||
stream_write_uint32(s, sysmenu->windowId); /* windowId (4 bytes) */
|
||||
stream_write_uint16(s, sysmenu->left); /* left (2 bytes) */
|
||||
stream_write_uint16(s, sysmenu->top); /* top (2 bytes) */
|
||||
}
|
||||
|
||||
void rail_write_client_syscommand_order(STREAM* s, RAIL_SYSCOMMAND_ORDER* syscommand)
|
||||
{
|
||||
stream_write_uint32(s, syscommand->windowId); /* windowId (4 bytes) */
|
||||
stream_write_uint16(s, syscommand->command); /* command (2 bytes) */
|
||||
}
|
||||
|
||||
void rail_write_client_notify_event_order(STREAM* s, RAIL_NOTIFY_EVENT_ORDER* notify_event)
|
||||
{
|
||||
stream_write_uint32(s, notify_event->windowId); /* windowId (4 bytes) */
|
||||
stream_write_uint32(s, notify_event->notifyIconId); /* notifyIconId (4 bytes) */
|
||||
stream_write_uint32(s, notify_event->message); /* notifyIconId (4 bytes) */
|
||||
}
|
||||
|
||||
void rail_write_client_window_move_order(STREAM* s, RAIL_WINDOW_MOVE_ORDER* window_move)
|
||||
{
|
||||
stream_write_uint32(s, window_move->windowId); /* windowId (4 bytes) */
|
||||
stream_write_uint16(s, window_move->left); /* left (2 bytes) */
|
||||
stream_write_uint16(s, window_move->top); /* top (2 bytes) */
|
||||
stream_write_uint16(s, window_move->right); /* right (2 bytes) */
|
||||
stream_write_uint16(s, window_move->bottom); /* bottom (2 bytes) */
|
||||
}
|
||||
|
||||
void rail_write_client_get_appid_req_order(STREAM* s, RAIL_GET_APPID_REQ_ORDER* get_appid_req)
|
||||
{
|
||||
stream_write_uint32(s, get_appid_req->windowId); /* windowId (4 bytes) */
|
||||
}
|
||||
|
||||
void rail_write_langbar_info_order(STREAM* s, RAIL_LANGBAR_INFO_ORDER* langbar_info)
|
||||
{
|
||||
stream_write_uint32(s, langbar_info->languageBarStatus); /* languageBarStatus (4 bytes) */
|
||||
}
|
||||
|
||||
void rail_order_recv(rdpRail* rail, STREAM* s)
|
||||
{
|
||||
uint16 orderType;
|
||||
uint16 orderLength;
|
||||
|
||||
rail_read_pdu_header(s, &orderType, &orderLength);
|
||||
|
||||
switch (orderType)
|
||||
{
|
||||
case RDP_RAIL_ORDER_HANDSHAKE:
|
||||
rail_read_handshake_order(s, &rail->handshake);
|
||||
break;
|
||||
|
||||
case RDP_RAIL_ORDER_EXEC_RESULT:
|
||||
rail_read_server_exec_result_order(s, &rail->exec_result);
|
||||
break;
|
||||
|
||||
case RDP_RAIL_ORDER_SYSPARAM:
|
||||
rail_read_server_sysparam_order(s, &rail->sysparam);
|
||||
break;
|
||||
|
||||
case RDP_RAIL_ORDER_MINMAXINFO:
|
||||
rail_read_server_minmaxinfo_order(s, &rail->minmaxinfo);
|
||||
break;
|
||||
|
||||
case RDP_RAIL_ORDER_LOCALMOVESIZE:
|
||||
rail_read_server_localmovesize_order(s, &rail->localmovesize);
|
||||
break;
|
||||
|
||||
case RDP_RAIL_ORDER_GET_APPID_RESP:
|
||||
rail_read_server_get_appid_resp_order(s, &rail->get_appid_resp);
|
||||
break;
|
||||
|
||||
case RDP_RAIL_ORDER_LANGBARINFO:
|
||||
rail_read_langbar_info_order(s, &rail->langbar_info);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void rail_send_handshake_order(rdpRail* rail)
|
||||
{
|
||||
STREAM* s;
|
||||
s = rail_pdu_init(RAIL_HANDSHAKE_ORDER_LENGTH);
|
||||
rail_write_handshake_order(s, &rail->handshake);
|
||||
rail_send_pdu(s, RAIL_ORDER_TYPE_HANDSHAKE);
|
||||
}
|
||||
|
||||
void rail_send_client_status_order(rdpRail* rail)
|
||||
{
|
||||
STREAM* s;
|
||||
s = rail_pdu_init(RAIL_CLIENT_STATUS_ORDER_LENGTH);
|
||||
rail_write_client_status_order(s, &rail->client_status);
|
||||
rail_send_pdu(s, RAIL_ORDER_TYPE_CLIENT_STATUS);
|
||||
}
|
||||
|
||||
void rail_send_client_exec_order(rdpRail* rail)
|
||||
{
|
||||
STREAM* s;
|
||||
int length;
|
||||
|
||||
length = RAIL_EXEC_ORDER_LENGTH +
|
||||
rail->exec.exeOrFile.length +
|
||||
rail->exec.workingDir.length;
|
||||
rail->exec.arguments.length;
|
||||
|
||||
s = rail_pdu_init(RAIL_EXEC_ORDER_LENGTH);
|
||||
rail_write_exec_order(s, &rail->exec);
|
||||
rail_send_pdu(s, RAIL_ORDER_TYPE_EXEC);
|
||||
}
|
||||
|
||||
void rail_send_client_sysparam_order(rdpRail* rail)
|
||||
{
|
||||
STREAM* s;
|
||||
int length;
|
||||
|
||||
length = RAIL_SYSPARAM_ORDER_LENGTH;
|
||||
|
||||
switch (rail->sysparam.systemParam)
|
||||
{
|
||||
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 += ((HIGH_CONTRAST*)(rail->sysparam.body))->colorSchemeLength + 8;
|
||||
break;
|
||||
}
|
||||
|
||||
s = rail_pdu_init(RAIL_SYSPARAM_ORDER_LENGTH);
|
||||
rail_write_sysparam_order(s, &rail->sysparam);
|
||||
rail_send_pdu(s, RAIL_ORDER_TYPE_SYSPARAM);
|
||||
}
|
||||
|
||||
void rail_send_client_activate_order(rdpRail* rail)
|
||||
{
|
||||
STREAM* s;
|
||||
s = rail_pdu_init(RAIL_ACTIVATE_ORDER_LENGTH);
|
||||
rail_write_activate_order(s, &rail->activate);
|
||||
rail_send_pdu(s, RAIL_ORDER_TYPE_ACTIVATE);
|
||||
}
|
||||
|
||||
void rail_send_client_sysmenu_order(rdpRail* rail)
|
||||
{
|
||||
STREAM* s;
|
||||
s = rail_pdu_init(RAIL_SYSMENU_ORDER_LENGTH);
|
||||
rail_write_sysmenu_order(s, &rail->sysmenu);
|
||||
rail_send_pdu(s, RAIL_ORDER_TYPE_SYSMENU);
|
||||
}
|
||||
|
||||
void rail_send_client_syscommand_order(rdpRail* rail)
|
||||
{
|
||||
STREAM* s;
|
||||
s = rail_pdu_init(RAIL_SYSCOMMAND_ORDER_LENGTH);
|
||||
rail_write_syscommand_order(s, &rail->syscommand);
|
||||
rail_send_pdu(s, RAIL_ORDER_TYPE_SYSCOMMAND);
|
||||
}
|
||||
|
||||
void rail_send_client_notify_event_order(rdpRail* rail)
|
||||
{
|
||||
STREAM* s;
|
||||
s = rail_pdu_init(RAIL_NOTIFY_EVENT_ORDER_LENGTH);
|
||||
rail_write_notify_event_order(s, &rail->notify_event);
|
||||
rail_send_pdu(s, RAIL_ORDER_TYPE_NOTIFY_EVENT);
|
||||
}
|
||||
|
||||
void rail_send_client_window_move_order(rdpRail* rail)
|
||||
{
|
||||
STREAM* s;
|
||||
s = rail_pdu_init(RAIL_WINDOW_MOVE_ORDER_LENGTH);
|
||||
rail_write_window_move_order(s, &rail->window_move);
|
||||
rail_send_pdu(s, RAIL_ORDER_TYPE_WINDOW_MOVE);
|
||||
}
|
||||
|
||||
void rail_send_client_get_appid_req_order(rdpRail* rail)
|
||||
{
|
||||
STREAM* s;
|
||||
s = rail_pdu_init(RAIL_GET_APPID_REQ_ORDER_LENGTH);
|
||||
rail_write_window_move_order(s, &rail->get_appid_req);
|
||||
rail_send_pdu(s, RAIL_ORDER_TYPE_GET_APPID_REQ);
|
||||
}
|
||||
|
||||
void rail_send_client_langbar_info_order(rdpRail* rail)
|
||||
{
|
||||
STREAM* s;
|
||||
s = rail_pdu_init(RAIL_LANGBAR_INFO_ORDER_LENGTH);
|
||||
rail_write_window_move_order(s, &rail->langbar_info);
|
||||
rail_send_pdu(s, RAIL_ORDER_TYPE_LANGBAR_INFO);
|
||||
}
|
||||
|
||||
rdpRail* rail_new()
|
||||
{
|
||||
rdpRail* rail;
|
||||
|
||||
rail = (rdpRail*) xzalloc(sizeof(rdpRail));
|
||||
|
||||
if (rail != NULL)
|
||||
{
|
||||
rail->uniconv = freerdp_uniconv_new();
|
||||
}
|
||||
|
||||
return rail;
|
||||
}
|
||||
|
||||
void rail_free(rdpRail* rail)
|
||||
{
|
||||
if (rail != NULL)
|
||||
{
|
||||
freerdp_uniconv_free(rail->uniconv);
|
||||
xfree(rail);
|
||||
}
|
||||
}
|
||||
|
116
channels/rail/rail_orders.h
Normal file
116
channels/rail/rail_orders.h
Normal file
@ -0,0 +1,116 @@
|
||||
/*
|
||||
FreeRDP: A Remote Desktop Protocol client.
|
||||
Remote Applications Integrated Locally (RAIL)
|
||||
|
||||
Copyright 2009 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
Copyright 2011 Roman Barabanov <romanbarabanov@gmail.com>
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef __RAIL_ORDERS_H
|
||||
#define __RAIL_ORDERS_H
|
||||
|
||||
#include <freerdp/rail.h>
|
||||
#include <freerdp/utils/stream.h>
|
||||
|
||||
struct rdp_rail
|
||||
{
|
||||
UNICONV* uniconv;
|
||||
RAIL_HANDSHAKE_ORDER handshake;
|
||||
RAIL_CLIENT_STATUS_ORDER client_status;
|
||||
RAIL_EXEC_ORDER exec;
|
||||
RAIL_EXEC_RESULT_ORDER exec_result;
|
||||
RAIL_SYSPARAM_ORDER sysparam;
|
||||
RAIL_ACTIVATE_ORDER activate;
|
||||
RAIL_SYSMENU_ORDER sysmenu;
|
||||
RAIL_SYSCOMMAND_ORDER syscommand;
|
||||
RAIL_NOTIFY_EVENT_ORDER notify_event;
|
||||
RAIL_MINMAXINFO_ORDER minmaxinfo;
|
||||
RAIL_LOCALMOVESIZE_ORDER localmovesize;
|
||||
RAIL_WINDOW_MOVE_ORDER window_move;
|
||||
RAIL_LANGBAR_INFO_ORDER langbar_info;
|
||||
RAIL_GET_APPID_REQ_ORDER get_appid_req;
|
||||
RAIL_GET_APPID_RESP_ORDER get_appid_resp;
|
||||
};
|
||||
typedef struct rdp_rail rdpRail;
|
||||
|
||||
#define RAIL_ORDER_TYPE_EXEC 0x0001
|
||||
#define RAIL_ORDER_TYPE_ACTIVATE 0x0002
|
||||
#define RAIL_ORDER_TYPE_SYSPARAM 0x0003
|
||||
#define RAIL_ORDER_TYPE_SYSCOMMAND 0x0004
|
||||
#define RAIL_ORDER_TYPE_HANDSHAKE 0x0005
|
||||
#define RAIL_ORDER_TYPE_NOTIFY_EVENT 0x0006
|
||||
#define RAIL_ORDER_TYPE_WINDOW_MOVE 0x0008
|
||||
#define RAIL_ORDER_TYPE_LOCALMOVESIZE 0x0009
|
||||
#define RAIL_ORDER_TYPE_MINMAXINFO 0x000A
|
||||
#define RAIL_ORDER_TYPE_CLIENT_STATUS 0x000B
|
||||
#define RAIL_ORDER_TYPE_SYSMENU 0x000C
|
||||
#define RAIL_ORDER_TYPE_LANGBAR_INFO 0x000D
|
||||
#define RAIL_ORDER_TYPE_EXEC_RESULT 0x0080
|
||||
#define RAIL_ORDER_TYPE_GET_APPID_REQ 0x000E
|
||||
#define RAIL_ORDER_TYPE_GET_APPID_RESP 0x000F
|
||||
|
||||
#define RAIL_PDU_HEADER_LENGTH 4
|
||||
|
||||
/* Fixed length of PDUs, excluding variable lengths */
|
||||
#define RAIL_HANDSHAKE_ORDER_LENGTH 4 /* fixed */
|
||||
#define RAIL_CLIENT_STATUS_ORDER_LENGTH 4 /* fixed */
|
||||
#define RAIL_EXEC_ORDER_LENGTH 8 /* variable */
|
||||
#define RAIL_SYSPARAM_ORDER_LENGTH 4 /* variable */
|
||||
#define RAIL_ACTIVATE_ORDER_LENGTH 5 /* fixed */
|
||||
#define RAIL_SYSMENU_ORDER_LENGTH 8 /* fixed */
|
||||
#define RAIL_SYSCOMMAND_ORDER_LENGTH 6 /* fixed */
|
||||
#define RAIL_NOTIFY_EVENT_ORDER_LENGTH 12 /* fixed */
|
||||
#define RAIL_WINDOW_MOVE_ORDER_LENGTH 12 /* fixed */
|
||||
#define RAIL_GET_APPID_REQ_ORDER_LENGTH 4 /* fixed */
|
||||
#define RAIL_LANGBAR_INFO_ORDER_LENGTH 4 /* fixed */
|
||||
|
||||
void rail_read_handshake_order(STREAM* s, RAIL_HANDSHAKE_ORDER* handshake);
|
||||
void rail_read_server_exec_result_order(STREAM* s, RAIL_EXEC_RESULT_ORDER* exec_result);
|
||||
void rail_read_server_sysparam_order(STREAM* s, RAIL_SYSPARAM_ORDER* sysparam);
|
||||
void rail_read_server_minmaxinfo_order(STREAM* s, RAIL_MINMAXINFO_ORDER* minmaxinfo);
|
||||
void rail_read_server_localmovesize_order(STREAM* s, RAIL_LOCALMOVESIZE_ORDER* localmovesize);
|
||||
void rail_read_server_get_appid_resp_order(STREAM* s, RAIL_GET_APPID_RESP_ORDER* get_appid_resp);
|
||||
void rail_read_langbar_info_order(STREAM* s, RAIL_LANGBAR_INFO_ORDER* langbar_info);
|
||||
|
||||
void rail_write_handshake_order(STREAM* s, RAIL_HANDSHAKE_ORDER* handshake);
|
||||
void rail_write_client_status_order(STREAM* s, RAIL_CLIENT_STATUS_ORDER* client_status);
|
||||
void rail_write_client_exec_order(STREAM* s, RAIL_EXEC_ORDER* exec);
|
||||
void rail_write_client_sysparam_order(STREAM* s, RAIL_SYSPARAM_ORDER* sysparam);
|
||||
void rail_write_client_activate_order(STREAM* s, RAIL_ACTIVATE_ORDER* activate);
|
||||
void rail_write_client_sysmenu_order(STREAM* s, RAIL_SYSMENU_ORDER* sysmenu);
|
||||
void rail_write_client_syscommand_order(STREAM* s, RAIL_SYSCOMMAND_ORDER* syscommand);
|
||||
void rail_write_client_notify_event_order(STREAM* s, RAIL_NOTIFY_EVENT_ORDER* notify_event);
|
||||
void rail_write_client_window_move_order(STREAM* s, RAIL_WINDOW_MOVE_ORDER* window_move);
|
||||
void rail_write_client_get_appid_req_order(STREAM* s, RAIL_GET_APPID_REQ_ORDER* get_appid_req);
|
||||
void rail_write_langbar_info_order(STREAM* s, RAIL_LANGBAR_INFO_ORDER* langbar_info);
|
||||
|
||||
void rail_order_recv(rdpRail* rail, STREAM* s);
|
||||
|
||||
void rail_send_handshake_order(rdpRail* rail);
|
||||
void rail_send_client_status_order(rdpRail* rail);
|
||||
void rail_send_client_exec_order(rdpRail* rail);
|
||||
void rail_send_client_sysparam_order(rdpRail* rail);
|
||||
void rail_send_client_activate_order(rdpRail* rail);
|
||||
void rail_send_client_sysmenu_order(rdpRail* rail);
|
||||
void rail_send_client_syscommand_order(rdpRail* rail);
|
||||
void rail_send_client_notify_event_order(rdpRail* rail);
|
||||
void rail_send_client_window_move_order(rdpRail* rail);
|
||||
void rail_send_client_get_appid_req_order(rdpRail* rail);
|
||||
void rail_send_client_langbar_info_order(rdpRail* rail);
|
||||
|
||||
rdpRail* rail_new();
|
||||
void rail_free(rdpRail* rail);
|
||||
|
||||
#endif /* __RAIL_ORDERS_H */
|
@ -56,11 +56,11 @@
|
||||
#define SPI_SET_DRAG_FULL_WINDOWS 0x00000025
|
||||
#define SPI_SET_KEYBOARD_CUES 0x0000100B
|
||||
#define SPI_SET_KEYBOARD_PREF 0x00000045
|
||||
#define SPI_SET_WORK_AREA 0x0000002F
|
||||
#define SPI_SET_MOUSE_BUTTON_SWAP 0x00000021
|
||||
#define SPI_SET_WORK_AREA 0x0000002F
|
||||
#define SPI_DISPLAY_CHANGE 0x0000F001
|
||||
#define SPI_TASKBAR_POS 0x0000F000
|
||||
#define SPI_SET_HIGH_CONTRAST 0x00000043
|
||||
#define RAIL_SPI_DISPLAY_CHANGE 0x0000F001
|
||||
#define RAIL_SPI_TASKBAR_POS 0x0000F000
|
||||
|
||||
/* Server System Parameters Update PDU */
|
||||
#define SPI_SET_SCREEN_SAVE_ACTIVE 0x00000011
|
||||
@ -134,7 +134,7 @@
|
||||
|
||||
struct _UNICODE_STRING
|
||||
{
|
||||
uint16 cbString;
|
||||
uint16 length;
|
||||
uint8* string;
|
||||
};
|
||||
typedef struct _UNICODE_STRING UNICODE_STRING;
|
||||
@ -148,6 +148,14 @@ struct _RECTANGLE_16
|
||||
};
|
||||
typedef struct _RECTANGLE_16 RECTANGLE_16;
|
||||
|
||||
struct _HIGH_CONTRAST
|
||||
{
|
||||
uint32 flags;
|
||||
uint32 colorSchemeLength;
|
||||
uint8* colorScheme;
|
||||
};
|
||||
typedef struct _HIGH_CONTRAST HIGH_CONTRAST;
|
||||
|
||||
/* RAIL Orders */
|
||||
|
||||
struct _RAIL_HANDSHAKE_ORDER
|
||||
@ -183,6 +191,7 @@ typedef struct _RAIL_EXEC_RESULT_ORDER RAIL_EXEC_RESULT_ORDER;
|
||||
struct _RAIL_SYSPARAM_ORDER
|
||||
{
|
||||
uint32 systemParam;
|
||||
boolean value;
|
||||
uint8* body;
|
||||
};
|
||||
typedef struct _RAIL_SYSPARAM_ORDER RAIL_SYSPARAM_ORDER;
|
||||
@ -234,7 +243,7 @@ typedef struct _RAIL_MINMAXINFO_ORDER RAIL_MINMAXINFO_ORDER;
|
||||
struct _RAIL_LOCALMOVESIZE_ORDER
|
||||
{
|
||||
uint32 windowId;
|
||||
uint16 isMoveSizeStart;
|
||||
boolean isMoveSizeStart;
|
||||
uint16 moveSizeType;
|
||||
uint16 posX;
|
||||
uint16 posY;
|
||||
@ -249,7 +258,7 @@ struct _RAIL_WINDOWMOVE_ORDER
|
||||
uint16 right;
|
||||
uint16 bottom;
|
||||
};
|
||||
typedef struct _RAIL_WINDOWMOVE_ORDER RAIL_WINDOWMOVE_ORDER;
|
||||
typedef struct _RAIL_WINDOWMOVE_ORDER RAIL_WINDOW_MOVE_ORDER;
|
||||
|
||||
struct _RAIL_GET_APPID_REQ_ORDER
|
||||
{
|
||||
@ -268,7 +277,7 @@ struct _RAIL_LANGBARINFO_ORDER
|
||||
{
|
||||
uint32 languageBarStatus;
|
||||
};
|
||||
typedef struct _RAIL_LANGBARINFO_ORDER RAIL_LANGBARINFO_ORDER;
|
||||
typedef struct _RAIL_LANGBARINFO_ORDER RAIL_LANGBAR_INFO_ORDER;
|
||||
|
||||
/* RAIL Constants */
|
||||
|
||||
|
@ -23,13 +23,13 @@
|
||||
|
||||
void rail_unicode_string_alloc(UNICODE_STRING* unicode_string, uint16 cbString)
|
||||
{
|
||||
unicode_string->cbString = cbString;
|
||||
unicode_string->length = cbString;
|
||||
unicode_string->string = xzalloc(cbString);
|
||||
}
|
||||
|
||||
void rail_unicode_string_free(UNICODE_STRING* unicode_string)
|
||||
{
|
||||
unicode_string->cbString = 0;
|
||||
unicode_string->length = 0;
|
||||
|
||||
if (unicode_string->string != NULL)
|
||||
xfree(unicode_string->string);
|
||||
@ -37,25 +37,25 @@ void rail_unicode_string_free(UNICODE_STRING* unicode_string)
|
||||
|
||||
void rail_read_unicode_string(STREAM* s, UNICODE_STRING* unicode_string)
|
||||
{
|
||||
stream_read_uint16(s, unicode_string->cbString); /* cbString (2 bytes) */
|
||||
stream_read_uint16(s, unicode_string->length); /* cbString (2 bytes) */
|
||||
|
||||
if (unicode_string->string == NULL)
|
||||
unicode_string->string = (uint8*) xmalloc(unicode_string->cbString);
|
||||
unicode_string->string = (uint8*) xmalloc(unicode_string->length);
|
||||
else
|
||||
unicode_string->string = (uint8*) xrealloc(unicode_string->string, unicode_string->cbString);
|
||||
unicode_string->string = (uint8*) xrealloc(unicode_string->string, unicode_string->length);
|
||||
|
||||
stream_read(s, unicode_string->string, unicode_string->cbString);
|
||||
stream_read(s, unicode_string->string, unicode_string->length);
|
||||
}
|
||||
|
||||
void rail_write_unicode_string(STREAM* s, UNICODE_STRING* unicode_string)
|
||||
{
|
||||
stream_write_uint16(s, unicode_string->cbString); /* cbString (2 bytes) */
|
||||
stream_write(s, unicode_string->string, unicode_string->cbString); /* string */
|
||||
stream_write_uint16(s, unicode_string->length); /* cbString (2 bytes) */
|
||||
stream_write(s, unicode_string->string, unicode_string->length); /* string */
|
||||
}
|
||||
|
||||
void rail_write_unicode_string_value(STREAM* s, UNICODE_STRING* unicode_string)
|
||||
{
|
||||
stream_write(s, unicode_string->string, unicode_string->cbString); /* string */
|
||||
stream_write(s, unicode_string->string, unicode_string->length); /* string */
|
||||
}
|
||||
|
||||
void rail_read_rectangle_16(STREAM* s, RECTANGLE_16* rectangle_16)
|
||||
|
Loading…
Reference in New Issue
Block a user