rail: fix bugs uncovered by increased warning level

This commit is contained in:
Marc-André Moreau 2011-08-11 14:06:19 -04:00
parent 1af258018d
commit 53981e9dba
4 changed files with 81 additions and 37 deletions

View File

@ -552,6 +552,8 @@ static void rail_vchannel_process_server_get_appid_resp_order(RAIL_SESSION* sess
rail_unicode_string_free(&app_id);
}
extern uint8 RAIL_ORDER_TYPE_STRINGS[][32];
void rail_vchannel_process_received_vchannel_data(RAIL_SESSION * session, STREAM* s)
{
size_t length = 0;
@ -566,6 +568,9 @@ void rail_vchannel_process_received_vchannel_data(RAIL_SESSION * session, STREAM
DEBUG_RAIL("rail_on_channel_data_received: session=0x%p data_size=%d "
"orderType=0x%X orderLength=%d", session, (int) length, order_type, order_length);
printf("Received %s PDU, length:%d\n",
RAIL_ORDER_TYPE_STRINGS[((order_type & 0xF0) >> 3) + (order_type & 0x0F)], order_length);
switch (order_type)
{
case RDP_RAIL_ORDER_HANDSHAKE:

View File

@ -87,6 +87,9 @@ void rail_string_to_unicode_string(rdpRail* rail, char* string, UNICODE_STRING*
unicode_string->string = NULL;
unicode_string->length = 0;
if (strlen(string) < 1)
return;
buffer = freerdp_uniconv_out(rail->uniconv, string, &length);
unicode_string->string = (uint8*) buffer;
@ -166,18 +169,55 @@ void rail_core_on_channel_terminated(RAIL_SESSION* session)
void rail_core_handle_server_handshake(RAIL_SESSION* session, uint32 build_number)
{
uint32 client_build_number = 0x00001db0;
RAIL_VCHANNEL_EVENT event = {0};
DEBUG_RAIL("rail_core_handle_server_handshake: session=0x%p buildNumber=0x%X.", session, build_number);
#if 1
session->rail->handshake.buildNumber = 0x00001DB0;
DEBUG_RAIL("Server Handshake");
session->rail->handshake.buildNumber = 0x00001DB1;
rail_send_handshake_order(session->rail);
session->rail->client_status.flags = RAIL_CLIENTSTATUS_ALLOWLOCALMOVESIZE;
rail_send_client_status_order(session->rail);
/* sysparam update */
session->rail->sysparam.systemParam = SPI_SET_HIGH_CONTRAST;
session->rail->sysparam.highContrast.colorScheme.string = NULL;
session->rail->sysparam.highContrast.colorScheme.length = 0;
session->rail->sysparam.highContrast.flags = 0x7E;
rail_send_client_sysparam_order(session->rail);
session->rail->sysparam.systemParam = SPI_TASKBAR_POS;
session->rail->sysparam.rectangle.left = 0;
session->rail->sysparam.rectangle.top = 0;
session->rail->sysparam.rectangle.right = 1024;
session->rail->sysparam.rectangle.bottom = 29;
rail_send_client_sysparam_order(session->rail);
session->rail->sysparam.systemParam = SPI_SET_MOUSE_BUTTON_SWAP;
session->rail->sysparam.value = False;
rail_send_client_sysparam_order(session->rail);
session->rail->sysparam.systemParam = SPI_SET_KEYBOARD_PREF;
session->rail->sysparam.value = False;
rail_send_client_sysparam_order(session->rail);
session->rail->sysparam.systemParam = SPI_SET_DRAG_FULL_WINDOWS;
session->rail->sysparam.value = True;
rail_send_client_sysparam_order(session->rail);
session->rail->sysparam.systemParam = SPI_SET_KEYBOARD_CUES;
session->rail->sysparam.value = False;
rail_send_client_sysparam_order(session->rail);
session->rail->sysparam.systemParam = SPI_SET_WORK_AREA;
session->rail->sysparam.rectangle.left = 0;
session->rail->sysparam.rectangle.top = 0;
session->rail->sysparam.rectangle.right = 1024;
session->rail->sysparam.rectangle.bottom = 768;
rail_send_client_sysparam_order(session->rail);
/* execute */
session->rail->exec.flags =
RAIL_EXEC_FLAG_EXPAND_WORKINGDIRECTORY |
RAIL_EXEC_FLAG_EXPAND_ARGUMENTS;
@ -191,6 +231,11 @@ void rail_core_handle_server_handshake(RAIL_SESSION* session, uint32 build_numbe
rail_core_send_client_execute(session, False, "||firefox", "", "");
#else
uint32 client_build_number = 0x00001db0;
RAIL_VCHANNEL_EVENT event = {0};
DEBUG_RAIL("rail_core_handle_server_handshake: session=0x%p buildNumber=0x%X.", session, build_number);
// Step 1. Send Handshake PDU (2.2.2.2.1)
// Fixed: MS-RDPERP 1.3.2.1 is not correct!
rail_vchannel_send_handshake_order(session, client_build_number);
@ -214,6 +259,8 @@ void rail_core_handle_server_handshake(RAIL_SESSION* session, uint32 build_numbe
void rail_core_handle_exec_result(RAIL_SESSION* session, uint16 flags, uint16 exec_result, uint32 raw_result, UNICODE_STRING* exe_or_file)
{
DEBUG_RAIL("EXEC_RESULT");
#if 0
RAIL_VCHANNEL_EVENT event = {0};
RAIL_STRING exe_or_file_;
@ -234,10 +281,12 @@ void rail_core_handle_exec_result(RAIL_SESSION* session, uint16 flags, uint16 ex
event.param.exec_result_info.exe_or_file = exe_or_file_.buffer;
session->event_sender->send_rail_vchannel_event(session->event_sender->event_sender_object, &event);
#endif
}
void rail_core_handle_server_sysparam(RAIL_SESSION* session, RAIL_SERVER_SYSPARAM* sysparam)
{
#if 0
RAIL_VCHANNEL_EVENT event = {0};
DEBUG_RAIL("rail_core_handle_server_sysparam: session=0x%p "
@ -245,20 +294,6 @@ void rail_core_handle_server_sysparam(RAIL_SESSION* session, RAIL_SERVER_SYSPARA
session, sysparam->type, sysparam->value.screen_saver_enabled,
sysparam->value.screen_saver_lock_enabled);
#if 1
session->rail->sysparam.systemParam = SPI_SET_DRAG_FULL_WINDOWS;
session->rail->sysparam.value = True;
session->rail->sysparam.systemParam = SPI_SET_KEYBOARD_CUES;
session->rail->sysparam.value = False;
session->rail->sysparam.systemParam = SPI_SET_KEYBOARD_PREF;
session->rail->sysparam.value = False;
session->rail->sysparam.systemParam = SPI_SET_MOUSE_BUTTON_SWAP;
session->rail->sysparam.value = False;
#else
init_vchannel_event(&event, RAIL_VCHANNEL_EVENT_SERVER_SYSPARAM_RECEIVED);
event.param.server_param_info.param_type = sysparam->type;
event.param.server_param_info.screen_saver_enabled =
@ -502,6 +537,7 @@ static void rail_core_handle_ui_get_app_id(RAIL_SESSION* session, RAIL_UI_EVENT*
void rail_core_handle_ui_event(RAIL_SESSION* session, RAIL_UI_EVENT* event)
{
return;
struct
{

View File

@ -18,6 +18,7 @@
limitations under the License.
*/
#include <freerdp/utils/rail.h>
#include <freerdp/utils/memory.h>
#include "rail_orders.h"
@ -91,16 +92,17 @@ void rail_send_pdu(rdpRail* rail, STREAM* s, uint16 orderType)
/* send */
printf("Sending %s PDU, length:%d\n",
RAIL_ORDER_TYPE_STRINGS[((orderType & 0xF0) >> 3) + orderType], orderLength);
RAIL_ORDER_TYPE_STRINGS[((orderType & 0xF0) >> 3) + (orderType & 0x0F)], orderLength);
rail->data_sender->send_rail_vchannel_data(rail->data_sender->data_sender_object, s->data, orderLength);
}
void rail_write_high_contrast(STREAM* s, HIGH_CONTRAST* high_contrast)
{
high_contrast->colorSchemeLength = high_contrast->colorScheme.length + 2;
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 */
rail_write_unicode_string(s, &high_contrast->colorScheme); /* colorScheme */
}
void rail_read_handshake_order(STREAM* s, RAIL_HANDSHAKE_ORDER* handshake)
@ -113,7 +115,7 @@ void rail_read_server_exec_result_order(STREAM* s, RAIL_EXEC_RESULT_ORDER* exec_
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) */
stream_seek_uint16(s); /* padding (2 bytes) */
rail_read_unicode_string(s, &exec_result->exeOrFile); /* exeOrFile */
}
@ -203,11 +205,11 @@ void rail_write_client_sysparam_order(STREAM* s, RAIL_SYSPARAM_ORDER* sysparam)
case SPI_SET_WORK_AREA:
case SPI_DISPLAY_CHANGE:
case SPI_TASKBAR_POS:
stream_write(s, sysparam->body, 8);
rail_write_rectangle_16(s, &sysparam->rectangle);
break;
case SPI_SET_HIGH_CONTRAST:
rail_write_high_contrast(s, (HIGH_CONTRAST*) sysparam->body);
rail_write_high_contrast(s, &sysparam->highContrast);
break;
}
}
@ -269,7 +271,7 @@ void rail_order_recv(rdpRail* rail, STREAM* s)
rail_read_pdu_header(s, &orderType, &orderLength);
printf("Received %s PDU, length:%d\n",
RAIL_ORDER_TYPE_STRINGS[((orderType & 0xF0) >> 3) + orderType], orderLength);
RAIL_ORDER_TYPE_STRINGS[((orderType & 0xF0) >> 3) + (orderType & 0x0F)], orderLength);
switch (orderType)
{
@ -360,12 +362,12 @@ void rail_send_client_sysparam_order(rdpRail* rail)
break;
case SPI_SET_HIGH_CONTRAST:
length += ((HIGH_CONTRAST*)(rail->sysparam.body))->colorSchemeLength + 8;
length += rail->sysparam.highContrast.colorSchemeLength + 10;
break;
}
s = rail_pdu_init(RAIL_SYSPARAM_ORDER_LENGTH);
rail_write_sysparam_order(s, &rail->sysparam);
rail_write_client_sysparam_order(s, &rail->sysparam);
rail_send_pdu(rail, s, RAIL_ORDER_TYPE_SYSPARAM);
}
@ -373,7 +375,7 @@ 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_write_client_activate_order(s, &rail->activate);
rail_send_pdu(rail, s, RAIL_ORDER_TYPE_ACTIVATE);
}
@ -381,7 +383,7 @@ 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_write_client_sysmenu_order(s, &rail->sysmenu);
rail_send_pdu(rail, s, RAIL_ORDER_TYPE_SYSMENU);
}
@ -389,7 +391,7 @@ 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_write_client_syscommand_order(s, &rail->syscommand);
rail_send_pdu(rail, s, RAIL_ORDER_TYPE_SYSCOMMAND);
}
@ -397,7 +399,7 @@ 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_write_client_notify_event_order(s, &rail->notify_event);
rail_send_pdu(rail, s, RAIL_ORDER_TYPE_NOTIFY_EVENT);
}
@ -405,7 +407,7 @@ 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_write_client_window_move_order(s, &rail->window_move);
rail_send_pdu(rail, s, RAIL_ORDER_TYPE_WINDOW_MOVE);
}
@ -413,7 +415,7 @@ 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_write_client_get_appid_req_order(s, &rail->get_appid_req);
rail_send_pdu(rail, s, RAIL_ORDER_TYPE_GET_APPID_REQ);
}
@ -421,7 +423,7 @@ 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_write_langbar_info_order(s, &rail->langbar_info);
rail_send_pdu(rail, s, RAIL_ORDER_TYPE_LANGBAR_INFO);
}

View File

@ -152,7 +152,7 @@ struct _HIGH_CONTRAST
{
uint32 flags;
uint32 colorSchemeLength;
uint8* colorScheme;
UNICODE_STRING colorScheme;
};
typedef struct _HIGH_CONTRAST HIGH_CONTRAST;
@ -192,7 +192,8 @@ struct _RAIL_SYSPARAM_ORDER
{
uint32 systemParam;
boolean value;
uint8* body;
RECTANGLE_16 rectangle;
HIGH_CONTRAST highContrast;
};
typedef struct _RAIL_SYSPARAM_ORDER RAIL_SYSPARAM_ORDER;