Fixed winpr_HexDump calls.

This commit is contained in:
Armin Novak 2014-08-19 18:26:39 +02:00
parent d122200fe4
commit 6762d73ae1
13 changed files with 623 additions and 1051 deletions

View File

@ -30,12 +30,15 @@
#include <winpr/print.h>
#include <freerdp/types.h>
#include <freerdp/channels/log.h>
#include <freerdp/constants.h>
#include <freerdp/client/cliprdr.h>
#include "cliprdr_main.h"
#include "cliprdr_format.h"
#define TAG CHANNELS_TAG("cliprdr.client")
#ifdef WITH_DEBUG_CLIPRDR
static const char* const CB_MSG_TYPE_STRINGS[] =
{
@ -65,13 +68,11 @@ CliprdrClientContext* cliprdr_get_client_interface(cliprdrPlugin* cliprdr)
wStream* cliprdr_packet_new(UINT16 msgType, UINT16 msgFlags, UINT32 dataLen)
{
wStream* s;
s = Stream_New(NULL, dataLen + 8);
Stream_Write_UINT16(s, msgType);
Stream_Write_UINT16(s, msgFlags);
/* Write actual length after the entire packet has been constructed. */
Stream_Seek(s, 4);
return s;
}
@ -79,18 +80,15 @@ void cliprdr_packet_send(cliprdrPlugin* cliprdr, wStream* s)
{
int pos;
UINT32 dataLen;
pos = Stream_GetPosition(s);
dataLen = pos - 8;
Stream_SetPosition(s, 4);
Stream_Write_UINT32(s, dataLen);
Stream_SetPosition(s, pos);
#ifdef WITH_DEBUG_CLIPRDR
CLOG_DBG("Cliprdr Sending (%d bytes)\n", dataLen + 8);
winpr_HexDump(Stream_Buffer(s), dataLen + 8);
winpr_HexDump(TAG, WLOG_DEBUG, Stream_Buffer(s), dataLen + 8);
#endif
svc_plugin_send((rdpSvcPlugin*) cliprdr, s);
}
@ -101,18 +99,21 @@ static void cliprdr_process_connect(rdpSvcPlugin* plugin)
void cliprdr_print_general_capability_flags(UINT32 flags)
{
CLOG_ERR( "generalFlags (0x%08X) {\n", flags);
CLOG_ERR("generalFlags (0x%08X) {\n", flags);
if (flags & CB_USE_LONG_FORMAT_NAMES)
CLOG_ERR( "\tCB_USE_LONG_FORMAT_NAMES\n");
if (flags & CB_STREAM_FILECLIP_ENABLED)
CLOG_ERR( "\tCB_STREAM_FILECLIP_ENABLED\n");
if (flags & CB_FILECLIP_NO_FILE_PATHS)
CLOG_ERR( "\tCB_FILECLIP_NO_FILE_PATHS\n");
if (flags & CB_CAN_LOCK_CLIPDATA)
CLOG_ERR( "\tCB_CAN_LOCK_CLIPDATA\n");
CLOG_ERR("\tCB_USE_LONG_FORMAT_NAMES\n");
CLOG_ERR( "}\n");
if (flags & CB_STREAM_FILECLIP_ENABLED)
CLOG_ERR("\tCB_STREAM_FILECLIP_ENABLED\n");
if (flags & CB_FILECLIP_NO_FILE_PATHS)
CLOG_ERR("\tCB_FILECLIP_NO_FILE_PATHS\n");
if (flags & CB_CAN_LOCK_CLIPDATA)
CLOG_ERR("\tCB_CAN_LOCK_CLIPDATA\n");
CLOG_ERR("}\n");
}
static void cliprdr_process_general_capability(cliprdrPlugin* cliprdr, wStream* s)
@ -120,14 +121,10 @@ static void cliprdr_process_general_capability(cliprdrPlugin* cliprdr, wStream*
UINT32 version;
UINT32 generalFlags;
CliprdrClientContext* context;
context = cliprdr_get_client_interface(cliprdr);
Stream_Read_UINT32(s, version); /* version (4 bytes) */
Stream_Read_UINT32(s, generalFlags); /* generalFlags (4 bytes) */
DEBUG_CLIPRDR("Version: %d", version);
#ifdef WITH_DEBUG_CLIPRDR
cliprdr_print_general_capability_flags(generalFlags);
#endif
@ -150,13 +147,10 @@ static void cliprdr_process_general_capability(cliprdrPlugin* cliprdr, wStream*
{
CLIPRDR_CAPABILITIES capabilities;
CLIPRDR_GENERAL_CAPABILITY_SET generalCapabilitySet;
capabilities.cCapabilitiesSets = 1;
capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET*) &(generalCapabilitySet);
generalCapabilitySet.capabilitySetType = CB_CAPSTYPE_GENERAL;
generalCapabilitySet.capabilitySetLength = 12;
generalCapabilitySet.version = version;
generalCapabilitySet.generalFlags = generalFlags;
@ -166,10 +160,8 @@ static void cliprdr_process_general_capability(cliprdrPlugin* cliprdr, wStream*
else
{
RDP_CB_CLIP_CAPS* caps_event;
caps_event = (RDP_CB_CLIP_CAPS*) freerdp_event_new(CliprdrChannel_Class, CliprdrChannel_ClipCaps, NULL, NULL);
caps_event->capabilities = generalFlags;
svc_plugin_send_event((rdpSvcPlugin*) cliprdr, (wMessage*) caps_event);
}
}
@ -180,10 +172,8 @@ static void cliprdr_process_clip_caps(cliprdrPlugin* cliprdr, wStream* s, UINT16
UINT16 lengthCapability;
UINT16 cCapabilitiesSets;
UINT16 capabilitySetType;
Stream_Read_UINT16(s, cCapabilitiesSets); /* cCapabilitiesSets (2 bytes) */
Stream_Seek_UINT16(s); /* pad1 (2 bytes) */
DEBUG_CLIPRDR("cCapabilitiesSets %d", cCapabilitiesSets);
for (i = 0; i < cCapabilitiesSets; i++)
@ -196,7 +186,6 @@ static void cliprdr_process_clip_caps(cliprdrPlugin* cliprdr, wStream* s, UINT16
case CB_CAPSTYPE_GENERAL:
cliprdr_process_general_capability(cliprdr, s);
break;
default:
CLOG_ERR("unknown cliprdr capability set: %d", capabilitySetType);
break;
@ -208,25 +197,20 @@ static void cliprdr_send_clip_caps(cliprdrPlugin* cliprdr)
{
wStream* s;
UINT32 flags;
s = cliprdr_packet_new(CB_CLIP_CAPS, 0, 4 + CB_CAPSTYPE_GENERAL_LEN);
DEBUG_CLIPRDR("Sending Capabilities");
flags = CB_USE_LONG_FORMAT_NAMES
#ifdef _WIN32
| CB_STREAM_FILECLIP_ENABLED
| CB_FILECLIP_NO_FILE_PATHS
#endif
;
;
Stream_Write_UINT16(s, 1); /* cCapabilitiesSets */
Stream_Write_UINT16(s, 0); /* pad1 */
Stream_Write_UINT16(s, CB_CAPSTYPE_GENERAL); /* capabilitySetType */
Stream_Write_UINT16(s, CB_CAPSTYPE_GENERAL_LEN); /* lengthCapability */
Stream_Write_UINT32(s, CB_CAPS_VERSION_2); /* version */
Stream_Write_UINT32(s, flags); /* generalFlags */
cliprdr_packet_send(cliprdr, s);
}
@ -237,7 +221,6 @@ static void cliprdr_process_monitor_ready(cliprdrPlugin* cliprdr, wStream* s, UI
if (context->custom)
{
CLIPRDR_MONITOR_READY monitorReady;
monitorReady.msgType = CB_MONITOR_READY;
monitorReady.msgFlags = flags;
monitorReady.dataLen = length;
@ -253,7 +236,6 @@ static void cliprdr_process_monitor_ready(cliprdrPlugin* cliprdr, wStream* s, UI
cliprdr_send_clip_caps(cliprdr);
event = (RDP_CB_MONITOR_READY_EVENT*) freerdp_event_new(CliprdrChannel_Class, CliprdrChannel_MonitorReady, NULL, NULL);
svc_plugin_send_event((rdpSvcPlugin*) cliprdr, (wMessage*) event);
}
}
@ -261,10 +243,8 @@ static void cliprdr_process_monitor_ready(cliprdrPlugin* cliprdr, wStream* s, UI
static void cliprdr_process_filecontents_request(cliprdrPlugin* cliprdr, wStream* s, UINT32 length, UINT16 flags)
{
RDP_CB_FILECONTENTS_REQUEST_EVENT* cb_event;
cb_event = (RDP_CB_FILECONTENTS_REQUEST_EVENT*) freerdp_event_new(CliprdrChannel_Class,
CliprdrChannel_FilecontentsRequest, NULL, NULL);
CliprdrChannel_FilecontentsRequest, NULL, NULL);
Stream_Read_UINT32(s, cb_event->streamId);
Stream_Read_UINT32(s, cb_event->lindex);
Stream_Read_UINT32(s, cb_event->dwFlags);
@ -272,17 +252,14 @@ static void cliprdr_process_filecontents_request(cliprdrPlugin* cliprdr, wStream
Stream_Read_UINT32(s, cb_event->nPositionHigh);
Stream_Read_UINT32(s, cb_event->cbRequested);
//Stream_Read_UINT32(s, cb_event->clipDataId);
svc_plugin_send_event((rdpSvcPlugin*) cliprdr, (wMessage*) cb_event);
}
static void cliprdr_process_filecontents_response(cliprdrPlugin* cliprdr, wStream* s, UINT32 length, UINT16 flags)
{
RDP_CB_FILECONTENTS_RESPONSE_EVENT* cb_event;
cb_event = (RDP_CB_FILECONTENTS_RESPONSE_EVENT*) freerdp_event_new(CliprdrChannel_Class,
CliprdrChannel_FilecontentsResponse, NULL, NULL);
CliprdrChannel_FilecontentsResponse, NULL, NULL);
Stream_Read_UINT32(s, cb_event->streamId);
if (length > 0)
@ -298,24 +275,18 @@ static void cliprdr_process_filecontents_response(cliprdrPlugin* cliprdr, wStrea
static void cliprdr_process_lock_clipdata(cliprdrPlugin* cliprdr, wStream* s, UINT32 length, UINT16 flags)
{
RDP_CB_LOCK_CLIPDATA_EVENT* cb_event;
cb_event = (RDP_CB_LOCK_CLIPDATA_EVENT*) freerdp_event_new(CliprdrChannel_Class,
CliprdrChannel_LockClipdata, NULL, NULL);
CliprdrChannel_LockClipdata, NULL, NULL);
Stream_Read_UINT32(s, cb_event->clipDataId);
svc_plugin_send_event((rdpSvcPlugin*) cliprdr, (wMessage*) cb_event);
}
static void cliprdr_process_unlock_clipdata(cliprdrPlugin* cliprdr, wStream* s, UINT32 length, UINT16 flags)
{
RDP_CB_UNLOCK_CLIPDATA_EVENT* cb_event;
cb_event = (RDP_CB_UNLOCK_CLIPDATA_EVENT*) freerdp_event_new(CliprdrChannel_Class,
CliprdrChannel_UnLockClipdata, NULL, NULL);
CliprdrChannel_UnLockClipdata, NULL, NULL);
Stream_Read_UINT32(s, cb_event->clipDataId);
svc_plugin_send_event((rdpSvcPlugin*) cliprdr, (wMessage*) cb_event);
}
@ -325,16 +296,13 @@ static void cliprdr_process_receive(rdpSvcPlugin* plugin, wStream* s)
UINT16 msgFlags;
UINT32 dataLen;
cliprdrPlugin* cliprdr = (cliprdrPlugin*) plugin;
Stream_Read_UINT16(s, msgType);
Stream_Read_UINT16(s, msgFlags);
Stream_Read_UINT32(s, dataLen);
DEBUG_CLIPRDR("msgType: %s (%d), msgFlags: %d dataLen: %d",
CB_MSG_TYPE_STRINGS[msgType], msgType, msgFlags, dataLen);
CB_MSG_TYPE_STRINGS[msgType], msgType, msgFlags, dataLen);
#ifdef WITH_DEBUG_CLIPRDR
winpr_HexDump(Stream_Buffer(s), dataLen + 8);
winpr_HexDump(TAG, WLOG_DEBUG, Stream_Buffer(s), dataLen + 8);
#endif
switch (msgType)
@ -342,56 +310,44 @@ static void cliprdr_process_receive(rdpSvcPlugin* plugin, wStream* s)
case CB_CLIP_CAPS:
cliprdr_process_clip_caps(cliprdr, s, dataLen, msgFlags);
break;
case CB_MONITOR_READY:
cliprdr_process_monitor_ready(cliprdr, s, dataLen, msgFlags);
break;
case CB_FORMAT_LIST:
cliprdr_process_format_list(cliprdr, s, dataLen, msgFlags);
break;
case CB_FORMAT_LIST_RESPONSE:
cliprdr_process_format_list_response(cliprdr, s, dataLen, msgFlags);
break;
case CB_FORMAT_DATA_REQUEST:
cliprdr_process_format_data_request(cliprdr, s, dataLen, msgFlags);
break;
case CB_FORMAT_DATA_RESPONSE:
cliprdr_process_format_data_response(cliprdr, s, dataLen, msgFlags);
break;
case CB_FILECONTENTS_REQUEST:
cliprdr_process_filecontents_request(cliprdr, s, dataLen, msgFlags);
break;
case CB_FILECONTENTS_RESPONSE:
cliprdr_process_filecontents_response(cliprdr, s, dataLen, msgFlags);
break;
case CB_LOCK_CLIPDATA:
cliprdr_process_lock_clipdata(cliprdr, s, dataLen, msgFlags);
break;
case CB_UNLOCK_CLIPDATA:
cliprdr_process_unlock_clipdata(cliprdr, s, dataLen, msgFlags);
break;
default:
CLOG_ERR("unknown msgType %d", msgType);
break;
}
}
static void cliprdr_process_filecontents_request_event(cliprdrPlugin* plugin, RDP_CB_FILECONTENTS_REQUEST_EVENT * event)
static void cliprdr_process_filecontents_request_event(cliprdrPlugin* plugin, RDP_CB_FILECONTENTS_REQUEST_EVENT* event)
{
wStream *s;
wStream* s;
DEBUG_CLIPRDR("Sending File Contents Request.");
s = cliprdr_packet_new(CB_FILECONTENTS_REQUEST, 0, 24);
Stream_Write_UINT32(s, event->streamId);
Stream_Write_UINT32(s, event->lindex);
Stream_Write_UINT32(s, event->dwFlags);
@ -399,14 +355,12 @@ static void cliprdr_process_filecontents_request_event(cliprdrPlugin* plugin, RD
Stream_Write_UINT32(s, event->nPositionHigh);
Stream_Write_UINT32(s, event->cbRequested);
//Stream_Write_UINT32(s, event->clipDataId);
cliprdr_packet_send(plugin, s);
}
static void cliprdr_process_filecontents_response_event(cliprdrPlugin* plugin, RDP_CB_FILECONTENTS_RESPONSE_EVENT * event)
static void cliprdr_process_filecontents_response_event(cliprdrPlugin* plugin, RDP_CB_FILECONTENTS_RESPONSE_EVENT* event)
{
wStream* s;
DEBUG_CLIPRDR("Sending file contents response with size = %d", event->size);
if (event->size > 0)
@ -423,39 +377,30 @@ static void cliprdr_process_filecontents_response_event(cliprdrPlugin* plugin, R
cliprdr_packet_send(plugin, s);
}
static void cliprdr_process_lock_clipdata_event(cliprdrPlugin* plugin, RDP_CB_LOCK_CLIPDATA_EVENT * event)
static void cliprdr_process_lock_clipdata_event(cliprdrPlugin* plugin, RDP_CB_LOCK_CLIPDATA_EVENT* event)
{
wStream* s;
DEBUG_CLIPRDR("Sending Lock Request");
s = cliprdr_packet_new(CB_LOCK_CLIPDATA, 0, 4);
Stream_Write_UINT32(s, event->clipDataId);
cliprdr_packet_send(plugin, s);
}
static void cliprdr_process_unlock_clipdata_event(cliprdrPlugin* plugin, RDP_CB_UNLOCK_CLIPDATA_EVENT * event)
static void cliprdr_process_unlock_clipdata_event(cliprdrPlugin* plugin, RDP_CB_UNLOCK_CLIPDATA_EVENT* event)
{
wStream* s;
DEBUG_CLIPRDR("Sending UnLock Request");
s = cliprdr_packet_new(CB_UNLOCK_CLIPDATA, 0, 4);
Stream_Write_UINT32(s, event->clipDataId);
cliprdr_packet_send(plugin, s);
}
static void cliprdr_process_tempdir_event(cliprdrPlugin* plugin, RDP_CB_TEMPDIR_EVENT * event)
static void cliprdr_process_tempdir_event(cliprdrPlugin* plugin, RDP_CB_TEMPDIR_EVENT* event)
{
wStream* s;
DEBUG_CLIPRDR("Sending Temporary Directory.");
s = cliprdr_packet_new(CB_TEMP_DIRECTORY, 0, 520);
Stream_Write(s, event->dirname, 520);
cliprdr_packet_send(plugin, s);
}
@ -466,35 +411,27 @@ static void cliprdr_process_event(rdpSvcPlugin* plugin, wMessage* event)
case CliprdrChannel_FormatList:
cliprdr_process_format_list_event((cliprdrPlugin*) plugin, (RDP_CB_FORMAT_LIST_EVENT*) event);
break;
case CliprdrChannel_DataRequest:
cliprdr_process_format_data_request_event((cliprdrPlugin*) plugin, (RDP_CB_DATA_REQUEST_EVENT*) event);
break;
case CliprdrChannel_DataResponse:
cliprdr_process_format_data_response_event((cliprdrPlugin*) plugin, (RDP_CB_DATA_RESPONSE_EVENT*) event);
break;
case CliprdrChannel_FilecontentsRequest:
cliprdr_process_filecontents_request_event((cliprdrPlugin*) plugin, (RDP_CB_FILECONTENTS_REQUEST_EVENT *) event);
cliprdr_process_filecontents_request_event((cliprdrPlugin*) plugin, (RDP_CB_FILECONTENTS_REQUEST_EVENT*) event);
break;
case CliprdrChannel_FilecontentsResponse:
cliprdr_process_filecontents_response_event((cliprdrPlugin*) plugin, (RDP_CB_FILECONTENTS_RESPONSE_EVENT *) event);
cliprdr_process_filecontents_response_event((cliprdrPlugin*) plugin, (RDP_CB_FILECONTENTS_RESPONSE_EVENT*) event);
break;
case CliprdrChannel_LockClipdata:
cliprdr_process_lock_clipdata_event((cliprdrPlugin*) plugin, (RDP_CB_LOCK_CLIPDATA_EVENT *) event);
cliprdr_process_lock_clipdata_event((cliprdrPlugin*) plugin, (RDP_CB_LOCK_CLIPDATA_EVENT*) event);
break;
case CliprdrChannel_UnLockClipdata:
cliprdr_process_unlock_clipdata_event((cliprdrPlugin*) plugin, (RDP_CB_UNLOCK_CLIPDATA_EVENT *) event);
cliprdr_process_unlock_clipdata_event((cliprdrPlugin*) plugin, (RDP_CB_UNLOCK_CLIPDATA_EVENT*) event);
break;
case CliprdrChannel_TemporaryDirectory:
cliprdr_process_tempdir_event((cliprdrPlugin*) plugin, (RDP_CB_TEMPDIR_EVENT *) event);
cliprdr_process_tempdir_event((cliprdrPlugin*) plugin, (RDP_CB_TEMPDIR_EVENT*) event);
break;
default:
CLOG_ERR("unknown event type %d", GetMessageType(event->id));
break;
@ -518,21 +455,15 @@ int cliprdr_client_capabilities(CliprdrClientContext* context, CLIPRDR_CAPABILIT
wStream* s;
CLIPRDR_GENERAL_CAPABILITY_SET* generalCapabilitySet;
cliprdrPlugin* cliprdr = (cliprdrPlugin*) context->handle;
s = cliprdr_packet_new(CB_CLIP_CAPS, 0, 4 + CB_CAPSTYPE_GENERAL_LEN);
Stream_Write_UINT16(s, 1); /* cCapabilitiesSets */
Stream_Write_UINT16(s, 0); /* pad1 */
generalCapabilitySet = (CLIPRDR_GENERAL_CAPABILITY_SET*) capabilities->capabilitySets;
Stream_Write_UINT16(s, generalCapabilitySet->capabilitySetType); /* capabilitySetType */
Stream_Write_UINT16(s, generalCapabilitySet->capabilitySetLength); /* lengthCapability */
Stream_Write_UINT32(s, generalCapabilitySet->version); /* version */
Stream_Write_UINT32(s, generalCapabilitySet->generalFlags); /* generalFlags */
cliprdr_packet_send(cliprdr, s);
return 0;
}
@ -548,9 +479,7 @@ int cliprdr_client_format_list(CliprdrClientContext* context, CLIPRDR_FORMAT_LIS
for (index = 0; index < formatList->cFormats; index++)
{
format = (CLIPRDR_FORMAT*) &(formatList->formats[index]);
length += 4;
formatNameSize = 2;
if (format->formatName)
@ -564,20 +493,16 @@ int cliprdr_client_format_list(CliprdrClientContext* context, CLIPRDR_FORMAT_LIS
for (index = 0; index < formatList->cFormats; index++)
{
format = (CLIPRDR_FORMAT*) &(formatList->formats[index]);
Stream_Write_UINT32(s, format->formatId); /* formatId (4 bytes) */
if (format->formatName)
{
int cchWideChar;
LPWSTR lpWideCharStr;
lpWideCharStr = (LPWSTR) Stream_Pointer(s);
cchWideChar = (Stream_Capacity(s) - Stream_GetPosition(s)) / 2;
formatNameSize = MultiByteToWideChar(CP_UTF8, 0,
format->formatName, -1, lpWideCharStr, cchWideChar) * 2;
format->formatName, -1, lpWideCharStr, cchWideChar) * 2;
Stream_Seek(s, formatNameSize);
}
else
@ -587,7 +512,6 @@ int cliprdr_client_format_list(CliprdrClientContext* context, CLIPRDR_FORMAT_LIS
}
cliprdr_packet_send(cliprdr, s);
return 0;
}
@ -595,13 +519,10 @@ int cliprdr_client_format_list_response(CliprdrClientContext* context, CLIPRDR_F
{
wStream* s;
cliprdrPlugin* cliprdr = (cliprdrPlugin*) context->handle;
formatListResponse->msgType = CB_FORMAT_LIST_RESPONSE;
formatListResponse->dataLen = 0;
s = cliprdr_packet_new(formatListResponse->msgType, formatListResponse->msgFlags, formatListResponse->dataLen);
cliprdr_packet_send(cliprdr, s);
return 0;
}
@ -609,16 +530,12 @@ int cliprdr_client_format_data_request(CliprdrClientContext* context, CLIPRDR_FO
{
wStream* s;
cliprdrPlugin* cliprdr = (cliprdrPlugin*) context->handle;
formatDataRequest->msgType = CB_FORMAT_DATA_REQUEST;
formatDataRequest->msgFlags = 0;
formatDataRequest->dataLen = 4;
s = cliprdr_packet_new(formatDataRequest->msgType, formatDataRequest->msgFlags, formatDataRequest->dataLen);
Stream_Write_UINT32(s, formatDataRequest->requestedFormatId); /* requestedFormatId (4 bytes) */
cliprdr_packet_send(cliprdr, s);
return 0;
}
@ -626,14 +543,10 @@ int cliprdr_client_format_data_response(CliprdrClientContext* context, CLIPRDR_F
{
wStream* s;
cliprdrPlugin* cliprdr = (cliprdrPlugin*) context->handle;
formatDataResponse->msgType = CB_FORMAT_DATA_RESPONSE;
s = cliprdr_packet_new(formatDataResponse->msgType, formatDataResponse->msgFlags, formatDataResponse->dataLen);
Stream_Write(s, formatDataResponse->requestedFormatData, formatDataResponse->dataLen);
cliprdr_packet_send(cliprdr, s);
return 0;
}
@ -645,41 +558,32 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
cliprdrPlugin* cliprdr;
CliprdrClientContext* context;
CHANNEL_ENTRY_POINTS_FREERDP* pEntryPointsEx;
cliprdr = (cliprdrPlugin*) calloc(1, sizeof(cliprdrPlugin));
cliprdr->plugin.channel_def.options =
CHANNEL_OPTION_INITIALIZED |
CHANNEL_OPTION_ENCRYPT_RDP |
CHANNEL_OPTION_COMPRESS_RDP |
CHANNEL_OPTION_SHOW_PROTOCOL;
CHANNEL_OPTION_INITIALIZED |
CHANNEL_OPTION_ENCRYPT_RDP |
CHANNEL_OPTION_COMPRESS_RDP |
CHANNEL_OPTION_SHOW_PROTOCOL;
strcpy(cliprdr->plugin.channel_def.name, "cliprdr");
cliprdr->plugin.connect_callback = cliprdr_process_connect;
cliprdr->plugin.receive_callback = cliprdr_process_receive;
cliprdr->plugin.event_callback = cliprdr_process_event;
cliprdr->plugin.terminate_callback = cliprdr_process_terminate;
pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP*) pEntryPoints;
if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_FREERDP)) &&
(pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER))
{
context = (CliprdrClientContext*) calloc(1, sizeof(CliprdrClientContext));
context->handle = (void*) cliprdr;
context->ClientCapabilities = cliprdr_client_capabilities;
context->ClientFormatList = cliprdr_client_format_list;
context->ClientFormatListResponse = cliprdr_client_format_list_response;
context->ClientFormatDataRequest = cliprdr_client_format_data_request;
context->ClientFormatDataResponse = cliprdr_client_format_data_response;
*(pEntryPointsEx->ppInterface) = (void*) context;
}
svc_plugin_init((rdpSvcPlugin*) cliprdr, pEntryPoints);
return 1;
}

View File

@ -34,10 +34,14 @@
#include "tsmf_codec.h"
#include <freerdp/log.h>
#define TAG CHANNELS_TAG("tsmf.client")
typedef struct _TSMFMediaTypeMap
{
BYTE guid[16];
const char *name;
const char* name;
int type;
} TSMFMediaTypeMap;
@ -259,31 +263,40 @@ static const TSMFMediaTypeMap tsmf_format_type_map[] =
}
};
static void tsmf_print_guid(const BYTE *guid)
static void tsmf_print_guid(const BYTE* guid)
{
#ifdef WITH_DEBUG_TSMF
int i;
for(i = 3; i >= 0; i--)
CLOG_ERR( "%02X", guid[i]);
CLOG_ERR( "-");
for(i = 5; i >= 4; i--)
CLOG_ERR( "%02X", guid[i]);
CLOG_ERR( "-");
for(i = 7; i >= 6; i--)
CLOG_ERR( "%02X", guid[i]);
CLOG_ERR( "-");
for(i = 8; i < 16; i++)
for (i = 3; i >= 0; i--)
CLOG_ERR("%02X", guid[i]);
CLOG_ERR("-");
for (i = 5; i >= 4; i--)
CLOG_ERR("%02X", guid[i]);
CLOG_ERR("-");
for (i = 7; i >= 6; i--)
CLOG_ERR("%02X", guid[i]);
CLOG_ERR("-");
for (i = 8; i < 16; i++)
{
CLOG_ERR( "%02X", guid[i]);
if(i == 9)
CLOG_ERR( "-");
CLOG_ERR("%02X", guid[i]);
if (i == 9)
CLOG_ERR("-");
}
CLOG_ERR( "\n");
CLOG_ERR("\n");
#endif
}
/* http://msdn.microsoft.com/en-us/library/dd318229.aspx */
static UINT32 tsmf_codec_parse_BITMAPINFOHEADER(TS_AM_MEDIA_TYPE *mediatype, wStream *s, BOOL bypass)
static UINT32 tsmf_codec_parse_BITMAPINFOHEADER(TS_AM_MEDIA_TYPE* mediatype, wStream* s, BOOL bypass)
{
UINT32 biSize;
UINT32 biWidth;
@ -292,18 +305,22 @@ static UINT32 tsmf_codec_parse_BITMAPINFOHEADER(TS_AM_MEDIA_TYPE *mediatype, wSt
Stream_Read_UINT32(s, biWidth);
Stream_Read_UINT32(s, biHeight);
Stream_Seek(s, 28);
if(mediatype->Width == 0)
if (mediatype->Width == 0)
mediatype->Width = biWidth;
if(mediatype->Height == 0)
if (mediatype->Height == 0)
mediatype->Height = biHeight;
/* Assume there will be no color table for video? */
if(bypass && biSize > 40)
if (bypass && biSize > 40)
Stream_Seek(s, biSize - 40);
return (bypass ? biSize : 40);
}
/* http://msdn.microsoft.com/en-us/library/dd407326.aspx */
static UINT32 tsmf_codec_parse_VIDEOINFOHEADER2(TS_AM_MEDIA_TYPE *mediatype, wStream *s)
static UINT32 tsmf_codec_parse_VIDEOINFOHEADER2(TS_AM_MEDIA_TYPE* mediatype, wStream* s)
{
UINT64 AvgTimePerFrame;
/* VIDEOINFOHEADER2.rcSource, RECT(LONG left, LONG top, LONG right, LONG bottom) */
@ -327,7 +344,7 @@ static UINT32 tsmf_codec_parse_VIDEOINFOHEADER2(TS_AM_MEDIA_TYPE *mediatype, wSt
}
/* http://msdn.microsoft.com/en-us/library/dd390700.aspx */
static UINT32 tsmf_codec_parse_VIDEOINFOHEADER(TS_AM_MEDIA_TYPE *mediatype, wStream *s)
static UINT32 tsmf_codec_parse_VIDEOINFOHEADER(TS_AM_MEDIA_TYPE* mediatype, wStream* s)
{
/*
typedef struct tagVIDEOINFOHEADER {
@ -358,7 +375,7 @@ static UINT32 tsmf_codec_parse_VIDEOINFOHEADER(TS_AM_MEDIA_TYPE *mediatype, wStr
return 48;
}
BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE *mediatype, wStream *s)
BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s)
{
int i;
UINT32 cbFormat;
@ -367,27 +384,35 @@ BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE *mediatype, wStream *s)
/* MajorType */
DEBUG_TSMF("MajorType:");
tsmf_print_guid(Stream_Pointer(s));
for(i = 0; tsmf_major_type_map[i].type != TSMF_MAJOR_TYPE_UNKNOWN; i++)
for (i = 0; tsmf_major_type_map[i].type != TSMF_MAJOR_TYPE_UNKNOWN; i++)
{
if(memcmp(tsmf_major_type_map[i].guid, Stream_Pointer(s), 16) == 0)
if (memcmp(tsmf_major_type_map[i].guid, Stream_Pointer(s), 16) == 0)
break;
}
mediatype->MajorType = tsmf_major_type_map[i].type;
if(mediatype->MajorType == TSMF_MAJOR_TYPE_UNKNOWN)
if (mediatype->MajorType == TSMF_MAJOR_TYPE_UNKNOWN)
ret = FALSE;
DEBUG_TSMF("MajorType %s", tsmf_major_type_map[i].name);
Stream_Seek(s, 16);
/* SubType */
DEBUG_TSMF("SubType:");
tsmf_print_guid(Stream_Pointer(s));
for(i = 0; tsmf_sub_type_map[i].type != TSMF_SUB_TYPE_UNKNOWN; i++)
for (i = 0; tsmf_sub_type_map[i].type != TSMF_SUB_TYPE_UNKNOWN; i++)
{
if(memcmp(tsmf_sub_type_map[i].guid, Stream_Pointer(s), 16) == 0)
if (memcmp(tsmf_sub_type_map[i].guid, Stream_Pointer(s), 16) == 0)
break;
}
mediatype->SubType = tsmf_sub_type_map[i].type;
if(mediatype->SubType == TSMF_SUB_TYPE_UNKNOWN)
if (mediatype->SubType == TSMF_SUB_TYPE_UNKNOWN)
ret = FALSE;
DEBUG_TSMF("SubType %s", tsmf_sub_type_map[i].name);
Stream_Seek(s, 16);
/* bFixedSizeSamples, bTemporalCompression, SampleSize */
@ -395,23 +420,28 @@ BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE *mediatype, wStream *s)
/* FormatType */
DEBUG_TSMF("FormatType:");
tsmf_print_guid(Stream_Pointer(s));
for(i = 0; tsmf_format_type_map[i].type != TSMF_FORMAT_TYPE_UNKNOWN; i++)
for (i = 0; tsmf_format_type_map[i].type != TSMF_FORMAT_TYPE_UNKNOWN; i++)
{
if(memcmp(tsmf_format_type_map[i].guid, Stream_Pointer(s), 16) == 0)
if (memcmp(tsmf_format_type_map[i].guid, Stream_Pointer(s), 16) == 0)
break;
}
mediatype->FormatType = tsmf_format_type_map[i].type;
if(mediatype->FormatType == TSMF_FORMAT_TYPE_UNKNOWN)
if (mediatype->FormatType == TSMF_FORMAT_TYPE_UNKNOWN)
ret = FALSE;
DEBUG_TSMF("FormatType %s", tsmf_format_type_map[i].name);
Stream_Seek(s, 16);
/* cbFormat */
Stream_Read_UINT32(s, cbFormat);
DEBUG_TSMF("cbFormat %d", cbFormat);
#ifdef WITH_DEBUG_TSMF
winpr_HexDump(Stream_Pointer(s), cbFormat);
winpr_HexDump(TAG, WLOG_DEBUG, Stream_Pointer(s), cbFormat);
#endif
switch(mediatype->FormatType)
switch (mediatype->FormatType)
{
case TSMF_FORMAT_TYPE_MFVIDEOFORMAT:
/* http://msdn.microsoft.com/en-us/library/aa473808.aspx */
@ -425,11 +455,13 @@ BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE *mediatype, wStream *s)
Stream_Seek(s, 80);
Stream_Read_UINT32(s, mediatype->BitRate); /* compressedInfo.AvgBitrate */
Stream_Seek(s, 36);
if(cbFormat > 176)
if (cbFormat > 176)
{
mediatype->ExtraDataSize = cbFormat - 176;
mediatype->ExtraData = Stream_Pointer(s);
}
break;
case TSMF_FORMAT_TYPE_WAVEFORMATEX:
/* http://msdn.microsoft.com/en-us/library/dd757720.aspx */
@ -442,51 +474,62 @@ BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE *mediatype, wStream *s)
Stream_Read_UINT16(s, mediatype->BlockAlign);
Stream_Read_UINT16(s, mediatype->BitsPerSample);
Stream_Read_UINT16(s, mediatype->ExtraDataSize);
if(mediatype->ExtraDataSize > 0)
if (mediatype->ExtraDataSize > 0)
mediatype->ExtraData = Stream_Pointer(s);
break;
case TSMF_FORMAT_TYPE_MPEG1VIDEOINFO:
/* http://msdn.microsoft.com/en-us/library/dd390700.aspx */
i = tsmf_codec_parse_VIDEOINFOHEADER(mediatype, s);
i += tsmf_codec_parse_BITMAPINFOHEADER(mediatype, s, TRUE);
if(cbFormat > i)
if (cbFormat > i)
{
mediatype->ExtraDataSize = cbFormat - i;
mediatype->ExtraData = Stream_Pointer(s);
}
break;
case TSMF_FORMAT_TYPE_MPEG2VIDEOINFO:
/* http://msdn.microsoft.com/en-us/library/dd390707.aspx */
i = tsmf_codec_parse_VIDEOINFOHEADER2(mediatype, s);
i += tsmf_codec_parse_BITMAPINFOHEADER(mediatype, s, TRUE);
if(cbFormat > i)
if (cbFormat > i)
{
mediatype->ExtraDataSize = cbFormat - i;
mediatype->ExtraData = Stream_Pointer(s);
}
break;
case TSMF_FORMAT_TYPE_VIDEOINFO2:
i = tsmf_codec_parse_VIDEOINFOHEADER2(mediatype, s);
i += tsmf_codec_parse_BITMAPINFOHEADER(mediatype, s, FALSE);
if(cbFormat > i)
if (cbFormat > i)
{
mediatype->ExtraDataSize = cbFormat - i;
mediatype->ExtraData = Stream_Pointer(s);
}
break;
default:
break;
}
if(mediatype->SamplesPerSecond.Numerator == 0)
if (mediatype->SamplesPerSecond.Numerator == 0)
mediatype->SamplesPerSecond.Numerator = 1;
if(mediatype->SamplesPerSecond.Denominator == 0)
if (mediatype->SamplesPerSecond.Denominator == 0)
mediatype->SamplesPerSecond.Denominator = 1;
return ret;
}
BOOL tsmf_codec_check_media_type(wStream *s)
BOOL tsmf_codec_check_media_type(wStream* s)
{
BYTE *m;
BYTE* m;
BOOL ret;
TS_AM_MEDIA_TYPE mediatype;
Stream_GetPointer(s, m);

View File

@ -4,6 +4,7 @@
#include <freerdp/freerdp.h>
#include <freerdp/codec/mppc.h>
#include <freerdp/log.h>
static BYTE TEST_RDP5_COMPRESSED_DATA[] =
{
@ -747,18 +748,13 @@ int test_MppcCompressBellsRdp5()
MPPC_CONTEXT* mppc;
UINT32 expectedSize;
BYTE OutputBuffer[65536];
mppc = mppc_context_new(1, TRUE);
SrcSize = sizeof(TEST_MPPC_BELLS) - 1;
pSrcData = (BYTE*) TEST_MPPC_BELLS;
expectedSize = sizeof(TEST_MPPC_BELLS_RDP5) - 1;
DstSize = sizeof(OutputBuffer);
pDstData = OutputBuffer;
status = mppc_compress(mppc, pSrcData, SrcSize, &pDstData, &DstSize, &Flags);
printf("Flags: 0x%04X DstSize: %d\n", Flags, DstSize);
if (DstSize != expectedSize)
@ -770,18 +766,14 @@ int test_MppcCompressBellsRdp5()
if (memcmp(pDstData, TEST_MPPC_BELLS_RDP5, DstSize) != 0)
{
printf("MppcCompressBellsRdp5: output mismatch\n");
printf("Actual\n");
BitDump(pDstData, DstSize * 8, 0);
BitDump(__FUNCTION__, WLOG_INFO, pDstData, DstSize * 8, 0);
printf("Expected\n");
BitDump(TEST_MPPC_BELLS_RDP5, DstSize * 8, 0);
BitDump(__FUNCTION__, WLOG_INFO, TEST_MPPC_BELLS_RDP5, DstSize * 8, 0);
return -1;
}
mppc_context_free(mppc);
return 0;
}
@ -796,18 +788,13 @@ int test_MppcCompressBellsRdp4()
MPPC_CONTEXT* mppc;
UINT32 expectedSize;
BYTE OutputBuffer[65536];
mppc = mppc_context_new(0, TRUE);
SrcSize = sizeof(TEST_MPPC_BELLS) - 1;
pSrcData = (BYTE*) TEST_MPPC_BELLS;
expectedSize = sizeof(TEST_MPPC_BELLS_RDP4) - 1;
DstSize = sizeof(OutputBuffer);
pDstData = OutputBuffer;
status = mppc_compress(mppc, pSrcData, SrcSize, &pDstData, &DstSize, &Flags);
printf("flags: 0x%04X size: %d\n", Flags, DstSize);
if (DstSize != expectedSize)
@ -819,18 +806,14 @@ int test_MppcCompressBellsRdp4()
if (memcmp(pDstData, TEST_MPPC_BELLS_RDP4, DstSize) != 0)
{
printf("MppcCompressBellsRdp4: output mismatch\n");
printf("Actual\n");
BitDump(pDstData, DstSize * 8, 0);
BitDump(__FUNCTION__, WLOG_INFO, pDstData, DstSize * 8, 0);
printf("Expected\n");
BitDump(TEST_MPPC_BELLS_RDP4, DstSize * 8, 0);
BitDump(__FUNCTION__, WLOG_INFO, TEST_MPPC_BELLS_RDP4, DstSize * 8, 0);
return -1;
}
mppc_context_free(mppc);
return 0;
}
@ -844,14 +827,11 @@ int test_MppcDecompressBellsRdp5()
MPPC_CONTEXT* mppc;
UINT32 expectedSize;
BYTE* pDstData = NULL;
mppc = mppc_context_new(1, FALSE);
SrcSize = sizeof(TEST_MPPC_BELLS_RDP5) - 1;
pSrcData = (BYTE*) TEST_MPPC_BELLS_RDP5;
Flags = PACKET_AT_FRONT | PACKET_COMPRESSED | 1;
expectedSize = sizeof(TEST_MPPC_BELLS) - 1;
status = mppc_decompress(mppc, pSrcData, SrcSize, &pDstData, &DstSize, Flags);
printf("flags: 0x%04X size: %d\n", Flags, DstSize);
@ -868,7 +848,6 @@ int test_MppcDecompressBellsRdp5()
}
mppc_context_free(mppc);
return 0;
}
@ -882,14 +861,11 @@ int test_MppcDecompressBellsRdp4()
MPPC_CONTEXT* mppc;
UINT32 expectedSize;
BYTE* pDstData = NULL;
mppc = mppc_context_new(0, FALSE);
SrcSize = sizeof(TEST_MPPC_BELLS_RDP4) - 1;
pSrcData = (BYTE*) TEST_MPPC_BELLS_RDP4;
Flags = PACKET_AT_FRONT | PACKET_COMPRESSED | 0;
expectedSize = sizeof(TEST_MPPC_BELLS) - 1;
status = mppc_decompress(mppc, pSrcData, SrcSize, &pDstData, &DstSize, Flags);
printf("flags: 0x%04X size: %d\n", Flags, DstSize);
@ -906,7 +882,6 @@ int test_MppcDecompressBellsRdp4()
}
mppc_context_free(mppc);
return 0;
}
@ -921,18 +896,13 @@ int test_MppcCompressIslandRdp5()
MPPC_CONTEXT* mppc;
UINT32 expectedSize;
BYTE OutputBuffer[65536];
mppc = mppc_context_new(1, TRUE);
SrcSize = sizeof(TEST_ISLAND_DATA) - 1;
pSrcData = (BYTE*) TEST_ISLAND_DATA;
expectedSize = sizeof(TEST_ISLAND_DATA_RDP5) - 1;
DstSize = sizeof(OutputBuffer);
pDstData = OutputBuffer;
status = mppc_compress(mppc, pSrcData, SrcSize, &pDstData, &DstSize, &Flags);
printf("Flags: 0x%04X DstSize: %d\n", Flags, DstSize);
if (DstSize != expectedSize)
@ -944,18 +914,14 @@ int test_MppcCompressIslandRdp5()
if (memcmp(pDstData, TEST_ISLAND_DATA_RDP5, DstSize) != 0)
{
printf("MppcCompressIslandRdp5: output mismatch\n");
printf("Actual\n");
BitDump(pDstData, DstSize * 8, 0);
BitDump(__FUNCTION__, WLOG_INFO, pDstData, DstSize * 8, 0);
printf("Expected\n");
BitDump(TEST_ISLAND_DATA_RDP5, DstSize * 8, 0);
BitDump(__FUNCTION__, WLOG_INFO, TEST_ISLAND_DATA_RDP5, DstSize * 8, 0);
return -1;
}
mppc_context_free(mppc);
return 0;
}
@ -970,18 +936,13 @@ int test_MppcCompressBufferRdp5()
MPPC_CONTEXT* mppc;
UINT32 expectedSize;
BYTE OutputBuffer[65536];
mppc = mppc_context_new(1, TRUE);
SrcSize = sizeof(TEST_RDP5_UNCOMPRESSED_DATA);
pSrcData = (BYTE*) TEST_RDP5_UNCOMPRESSED_DATA;
expectedSize = sizeof(TEST_RDP5_COMPRESSED_DATA);
DstSize = sizeof(OutputBuffer);
pDstData = OutputBuffer;
status = mppc_compress(mppc, pSrcData, SrcSize, &pDstData, &DstSize, &Flags);
printf("flags: 0x%04X size: %d\n", Flags, DstSize);
if (DstSize != expectedSize)
@ -997,7 +958,6 @@ int test_MppcCompressBufferRdp5()
}
mppc_context_free(mppc);
return 0;
}
@ -1011,14 +971,11 @@ int test_MppcDecompressBufferRdp5()
MPPC_CONTEXT* mppc;
UINT32 expectedSize;
BYTE* pDstData = NULL;
mppc = mppc_context_new(1, FALSE);
SrcSize = sizeof(TEST_RDP5_COMPRESSED_DATA);
pSrcData = (BYTE*) TEST_RDP5_COMPRESSED_DATA;
Flags = PACKET_AT_FRONT | PACKET_COMPRESSED | 1;
expectedSize = sizeof(TEST_RDP5_UNCOMPRESSED_DATA);
status = mppc_decompress(mppc, pSrcData, SrcSize, &pDstData, &DstSize, Flags);
printf("flags: 0x%04X size: %d\n", Flags, DstSize);
@ -1035,7 +992,6 @@ int test_MppcDecompressBufferRdp5()
}
mppc_context_free(mppc);
return 0;
}

View File

@ -21,49 +21,37 @@ int test_NCrushCompressBells()
UINT32 expectedSize;
BYTE OutputBuffer[65536];
NCRUSH_CONTEXT* ncrush;
ncrush = ncrush_context_new(TRUE);
SrcSize = sizeof(TEST_BELLS_DATA) - 1;
pSrcData = (BYTE*) TEST_BELLS_DATA;
expectedSize = sizeof(TEST_BELLS_NCRUSH) - 1;
pDstData = OutputBuffer;
DstSize = sizeof(OutputBuffer);
ZeroMemory(OutputBuffer, sizeof(OutputBuffer));
status = ncrush_compress(ncrush, pSrcData, SrcSize, &pDstData, &DstSize, &Flags);
printf("status: %d Flags: 0x%04X DstSize: %d\n", status, Flags, DstSize);
if (DstSize != expectedSize)
{
printf("NCrushCompressBells: output size mismatch: Actual: %d, Expected: %d\n", DstSize, expectedSize);
printf("Actual\n");
BitDump(pDstData, DstSize * 8, 0);
BitDump(__FUNCTION__, WLOG_INFO, pDstData, DstSize * 8, 0);
printf("Expected\n");
BitDump(TEST_BELLS_NCRUSH, expectedSize * 8, 0);
BitDump(__FUNCTION__, WLOG_INFO, TEST_BELLS_NCRUSH, expectedSize * 8, 0);
return -1;
}
if (memcmp(pDstData, TEST_BELLS_NCRUSH, DstSize) != 0)
{
printf("NCrushCompressBells: output mismatch\n");
printf("Actual\n");
BitDump(pDstData, DstSize * 8, 0);
BitDump(__FUNCTION__, WLOG_INFO, pDstData, DstSize * 8, 0);
printf("Expected\n");
BitDump(TEST_BELLS_NCRUSH, expectedSize * 8, 0);
BitDump(__FUNCTION__, WLOG_INFO, TEST_BELLS_NCRUSH, expectedSize * 8, 0);
return -1;
}
ncrush_context_free(ncrush);
return 1;
}
@ -77,14 +65,11 @@ int test_NCrushDecompressBells()
UINT32 expectedSize;
BYTE* pDstData = NULL;
NCRUSH_CONTEXT* ncrush;
ncrush = ncrush_context_new(FALSE);
SrcSize = sizeof(TEST_BELLS_NCRUSH) - 1;
pSrcData = (BYTE*) TEST_BELLS_NCRUSH;
Flags = PACKET_COMPRESSED | 2;
expectedSize = sizeof(TEST_BELLS_DATA) - 1;
status = ncrush_decompress(ncrush, pSrcData, SrcSize, &pDstData, &DstSize, Flags);
printf("Flags: 0x%04X DstSize: %d\n", Flags, DstSize);
@ -101,7 +86,6 @@ int test_NCrushDecompressBells()
}
ncrush_context_free(ncrush);
return 1;
}

View File

@ -54,49 +54,37 @@ int test_XCrushCompressBells()
UINT32 expectedSize;
BYTE OutputBuffer[65536];
XCRUSH_CONTEXT* xcrush;
xcrush = xcrush_context_new(TRUE);
SrcSize = sizeof(TEST_BELLS_DATA) - 1;
pSrcData = (BYTE*) TEST_BELLS_DATA;
expectedSize = sizeof(TEST_BELLS_DATA_XCRUSH) - 1;
pDstData = OutputBuffer;
DstSize = sizeof(OutputBuffer);
ZeroMemory(OutputBuffer, sizeof(OutputBuffer));
status = xcrush_compress(xcrush, pSrcData, SrcSize, &pDstData, &DstSize, &Flags);
printf("status: %d Flags: 0x%04X DstSize: %d\n", status, Flags, DstSize);
if (DstSize != expectedSize)
{
printf("XCrushCompressBells: output size mismatch: Actual: %d, Expected: %d\n", DstSize, expectedSize);
printf("Actual\n");
BitDump(pDstData, DstSize * 8, 0);
BitDump(__FUNCTION__, WLOG_INFO, pDstData, DstSize * 8, 0);
printf("Expected\n");
BitDump(TEST_BELLS_DATA_XCRUSH, expectedSize * 8, 0);
BitDump(__FUNCTION__, WLOG_INFO, TEST_BELLS_DATA_XCRUSH, expectedSize * 8, 0);
return -1;
}
if (memcmp(pDstData, TEST_BELLS_DATA_XCRUSH, DstSize) != 0)
{
printf("XCrushCompressBells: output mismatch\n");
printf("Actual\n");
BitDump(pDstData, DstSize * 8, 0);
BitDump(__FUNCTION__, WLOG_INFO, pDstData, DstSize * 8, 0);
printf("Expected\n");
BitDump(TEST_BELLS_DATA_XCRUSH, expectedSize * 8, 0);
BitDump(__FUNCTION__, WLOG_INFO, TEST_BELLS_DATA_XCRUSH, expectedSize * 8, 0);
return -1;
}
xcrush_context_free(xcrush);
return 1;
}
@ -111,49 +99,37 @@ int test_XCrushCompressIsland()
UINT32 expectedSize;
BYTE OutputBuffer[65536];
XCRUSH_CONTEXT* xcrush;
xcrush = xcrush_context_new(TRUE);
SrcSize = sizeof(TEST_ISLAND_DATA) - 1;
pSrcData = (BYTE*) TEST_ISLAND_DATA;
expectedSize = sizeof(TEST_ISLAND_DATA_XCRUSH) - 1;
pDstData = OutputBuffer;
DstSize = sizeof(OutputBuffer);
ZeroMemory(OutputBuffer, sizeof(OutputBuffer));
status = xcrush_compress(xcrush, pSrcData, SrcSize, &pDstData, &DstSize, &Flags);
printf("status: %d Flags: 0x%04X DstSize: %d\n", status, Flags, DstSize);
if (DstSize != expectedSize)
{
printf("XCrushCompressIsland: output size mismatch: Actual: %d, Expected: %d\n", DstSize, expectedSize);
printf("Actual\n");
BitDump(pDstData, DstSize * 8, 0);
BitDump(__FUNCTION__, WLOG_INFO, pDstData, DstSize * 8, 0);
printf("Expected\n");
BitDump(TEST_ISLAND_DATA_XCRUSH, expectedSize * 8, 0);
BitDump(__FUNCTION__, WLOG_INFO, TEST_ISLAND_DATA_XCRUSH, expectedSize * 8, 0);
return -1;
}
if (memcmp(pDstData, TEST_ISLAND_DATA_XCRUSH, DstSize) != 0)
{
printf("XCrushCompressIsland: output mismatch\n");
printf("Actual\n");
BitDump(pDstData, DstSize * 8, 0);
BitDump(__FUNCTION__, WLOG_INFO, pDstData, DstSize * 8, 0);
printf("Expected\n");
BitDump(TEST_ISLAND_DATA_XCRUSH, expectedSize * 8, 0);
BitDump(__FUNCTION__, WLOG_INFO, TEST_ISLAND_DATA_XCRUSH, expectedSize * 8, 0);
return -1;
}
xcrush_context_free(xcrush);
return 1;
}
@ -161,7 +137,6 @@ int TestFreeRDPCodecXCrush(int argc, char* argv[])
{
//if (test_XCrushCompressBells() < 0)
// return -1;
if (test_XCrushCompressIsland() < 0)
return -1;

View File

@ -31,6 +31,7 @@
#include <winpr/tchar.h>
#include <winpr/synch.h>
#include <winpr/dsparse.h>
#include <freerdp/log.h>
#include <openssl/rand.h>
#include <openssl/bio.h>
@ -48,10 +49,11 @@
#include "rpc.h"
#define TAG FREERDP_TAG("core.gateway")
/* Security Verification Trailer Signature */
rpc_sec_verification_trailer RPC_SEC_VERIFICATION_TRAILER =
{ { 0x8a, 0xe3, 0x13, 0x71, 0x02, 0xf4, 0x36, 0x71 } };
{ { 0x8a, 0xe3, 0x13, 0x71, 0x02, 0xf4, 0x36, 0x71 } };
static char* PTYPE_STRINGS[] =
{
@ -92,45 +94,51 @@ const RPC_SECURITY_PROVIDER_INFO RPC_SECURITY_PROVIDER_INFO_TABLE[] =
void rpc_pdu_header_print(rpcconn_hdr_t* header)
{
DEBUG_WARN( "rpc_vers: %d\n", header->common.rpc_vers);
DEBUG_WARN( "rpc_vers_minor: %d\n", header->common.rpc_vers_minor);
DEBUG_WARN("rpc_vers: %d\n", header->common.rpc_vers);
DEBUG_WARN("rpc_vers_minor: %d\n", header->common.rpc_vers_minor);
if (header->common.ptype > PTYPE_RTS)
DEBUG_WARN( "ptype: %s (%d)\n", "PTYPE_UNKNOWN", header->common.ptype);
DEBUG_WARN("ptype: %s (%d)\n", "PTYPE_UNKNOWN", header->common.ptype);
else
DEBUG_WARN( "ptype: %s (%d)\n", PTYPE_STRINGS[header->common.ptype], header->common.ptype);
DEBUG_WARN("ptype: %s (%d)\n", PTYPE_STRINGS[header->common.ptype], header->common.ptype);
DEBUG_WARN("pfc_flags (0x%02X) = {", header->common.pfc_flags);
DEBUG_WARN( "pfc_flags (0x%02X) = {", header->common.pfc_flags);
if (header->common.pfc_flags & PFC_FIRST_FRAG)
DEBUG_WARN( " PFC_FIRST_FRAG");
DEBUG_WARN(" PFC_FIRST_FRAG");
if (header->common.pfc_flags & PFC_LAST_FRAG)
DEBUG_WARN( " PFC_LAST_FRAG");
DEBUG_WARN(" PFC_LAST_FRAG");
if (header->common.pfc_flags & PFC_PENDING_CANCEL)
DEBUG_WARN( " PFC_PENDING_CANCEL");
DEBUG_WARN(" PFC_PENDING_CANCEL");
if (header->common.pfc_flags & PFC_RESERVED_1)
DEBUG_WARN( " PFC_RESERVED_1");
DEBUG_WARN(" PFC_RESERVED_1");
if (header->common.pfc_flags & PFC_CONC_MPX)
DEBUG_WARN( " PFC_CONC_MPX");
DEBUG_WARN(" PFC_CONC_MPX");
if (header->common.pfc_flags & PFC_DID_NOT_EXECUTE)
DEBUG_WARN( " PFC_DID_NOT_EXECUTE");
DEBUG_WARN(" PFC_DID_NOT_EXECUTE");
if (header->common.pfc_flags & PFC_OBJECT_UUID)
DEBUG_WARN( " PFC_OBJECT_UUID");
DEBUG_WARN( " }\n");
DEBUG_WARN(" PFC_OBJECT_UUID");
DEBUG_WARN( "packed_drep[4]: %02X %02X %02X %02X\n",
header->common.packed_drep[0], header->common.packed_drep[1],
header->common.packed_drep[2], header->common.packed_drep[3]);
DEBUG_WARN( "frag_length: %d\n", header->common.frag_length);
DEBUG_WARN( "auth_length: %d\n", header->common.auth_length);
DEBUG_WARN( "call_id: %d\n", header->common.call_id);
DEBUG_WARN(" }\n");
DEBUG_WARN("packed_drep[4]: %02X %02X %02X %02X\n",
header->common.packed_drep[0], header->common.packed_drep[1],
header->common.packed_drep[2], header->common.packed_drep[3]);
DEBUG_WARN("frag_length: %d\n", header->common.frag_length);
DEBUG_WARN("auth_length: %d\n", header->common.auth_length);
DEBUG_WARN("call_id: %d\n", header->common.call_id);
if (header->common.ptype == PTYPE_RESPONSE)
{
DEBUG_WARN( "alloc_hint: %d\n", header->response.alloc_hint);
DEBUG_WARN( "p_cont_id: %d\n", header->response.p_cont_id);
DEBUG_WARN( "cancel_count: %d\n", header->response.cancel_count);
DEBUG_WARN( "reserved: %d\n", header->response.reserved);
DEBUG_WARN("alloc_hint: %d\n", header->response.alloc_hint);
DEBUG_WARN("p_cont_id: %d\n", header->response.p_cont_id);
DEBUG_WARN("cancel_count: %d\n", header->response.cancel_count);
DEBUG_WARN("reserved: %d\n", header->response.reserved);
}
}
@ -147,11 +155,9 @@ void rpc_pdu_header_init(rdpRpc* rpc, rpcconn_hdr_t* header)
UINT32 rpc_offset_align(UINT32* offset, UINT32 alignment)
{
UINT32 pad;
pad = *offset;
*offset = (*offset + alignment - 1) & ~(alignment - 1);
pad = *offset - pad;
return pad;
}
@ -245,7 +251,6 @@ BOOL rpc_get_stub_data_info(rdpRpc* rpc, BYTE* buffer, UINT32* offset, UINT32* l
UINT32 auth_pad_length;
UINT32 sec_trailer_offset;
rpc_sec_trailer* sec_trailer;
*offset = RPC_COMMON_FIELDS_LENGTH;
header = ((rpcconn_hdr_t*) buffer);
@ -265,7 +270,7 @@ BOOL rpc_get_stub_data_info(rdpRpc* rpc, BYTE* buffer, UINT32* offset, UINT32* l
*offset += 4;
break;
default:
DEBUG_WARN( "%s: unknown ptype=0x%x\n", __FUNCTION__, header->common.ptype);
DEBUG_WARN("%s: unknown ptype=0x%x\n", __FUNCTION__, header->common.ptype);
return FALSE;
}
@ -275,27 +280,23 @@ BOOL rpc_get_stub_data_info(rdpRpc* rpc, BYTE* buffer, UINT32* offset, UINT32* l
if (header->common.ptype == PTYPE_REQUEST)
{
UINT32 sec_trailer_offset;
sec_trailer_offset = header->common.frag_length - header->common.auth_length - 8;
*length = sec_trailer_offset - *offset;
return TRUE;
}
frag_length = header->common.frag_length;
auth_length = header->common.auth_length;
sec_trailer_offset = frag_length - auth_length - 8;
sec_trailer = (rpc_sec_trailer*) &buffer[sec_trailer_offset];
auth_pad_length = sec_trailer->auth_pad_length;
#if 0
DEBUG_WARN( "sec_trailer: type: %d level: %d pad_length: %d reserved: %d context_id: %d\n",
sec_trailer->auth_type,
sec_trailer->auth_level,
sec_trailer->auth_pad_length,
sec_trailer->auth_reserved,
sec_trailer->auth_context_id);
DEBUG_WARN("sec_trailer: type: %d level: %d pad_length: %d reserved: %d context_id: %d\n",
sec_trailer->auth_type,
sec_trailer->auth_level,
sec_trailer->auth_pad_length,
sec_trailer->auth_reserved,
sec_trailer->auth_context_id);
#endif
/**
@ -306,8 +307,8 @@ BOOL rpc_get_stub_data_info(rdpRpc* rpc, BYTE* buffer, UINT32* offset, UINT32* l
if ((frag_length - (sec_trailer_offset + 8)) != auth_length)
{
DEBUG_WARN( "invalid auth_length: actual: %d, expected: %d\n", auth_length,
(frag_length - (sec_trailer_offset + 8)));
DEBUG_WARN("invalid auth_length: actual: %d, expected: %d\n", auth_length,
(frag_length - (sec_trailer_offset + 8)));
}
*length = frag_length - auth_length - 24 - 8 - auth_pad_length;
@ -317,10 +318,10 @@ BOOL rpc_get_stub_data_info(rdpRpc* rpc, BYTE* buffer, UINT32* offset, UINT32* l
int rpc_out_read(rdpRpc* rpc, BYTE* data, int length)
{
int status;
status = BIO_read(rpc->TlsOut->bio, data, length);
if (status > 0) {
if (status > 0)
{
#ifdef HAVE_VALGRIND_MEMCHECK_H
VALGRIND_MAKE_MEM_DEFINED(data, status);
#endif
@ -336,25 +337,20 @@ int rpc_out_read(rdpRpc* rpc, BYTE* data, int length)
int rpc_out_write(rdpRpc* rpc, const BYTE* data, int length)
{
int status;
status = tls_write_all(rpc->TlsOut, data, length);
return status;
}
int rpc_in_write(rdpRpc* rpc, const BYTE* data, int length)
{
int status;
#ifdef WITH_DEBUG_TSG
DEBUG_WARN( "Sending PDU (length: %d)\n", length);
DEBUG_WARN("Sending PDU (length: %d)\n", length);
rpc_pdu_header_print((rpcconn_hdr_t*) data);
winpr_HexDump(data, length);
DEBUG_WARN( "\n");
winpr_HexDump(TAG, WLOG_DEBUG, data, length);
DEBUG_WARN("\n");
#endif
status = tls_write_all(rpc->TlsIn, data, length);
return status;
}
@ -369,27 +365,26 @@ int rpc_write(rdpRpc* rpc, BYTE* data, int length, UINT16 opnum)
RpcClientCall* clientCall;
SECURITY_STATUS encrypt_status;
rpcconn_request_hdr_t* request_pdu;
ntlm = rpc->ntlm;
if (!ntlm || !ntlm->table)
{
DEBUG_WARN( "%s: invalid ntlm context\n", __FUNCTION__);
DEBUG_WARN("%s: invalid ntlm context\n", __FUNCTION__);
return -1;
}
if (ntlm->table->QueryContextAttributes(&ntlm->context, SECPKG_ATTR_SIZES, &ntlm->ContextSizes) != SEC_E_OK)
{
DEBUG_WARN( "%s: QueryContextAttributes SECPKG_ATTR_SIZES failure\n", __FUNCTION__);
DEBUG_WARN("%s: QueryContextAttributes SECPKG_ATTR_SIZES failure\n", __FUNCTION__);
return -1;
}
request_pdu = (rpcconn_request_hdr_t*) calloc(1, sizeof(rpcconn_request_hdr_t));
if (!request_pdu)
return -1;
rpc_pdu_header_init(rpc, (rpcconn_hdr_t*) request_pdu);
request_pdu->ptype = PTYPE_REQUEST;
request_pdu->pfc_flags = PFC_FIRST_FRAG | PFC_LAST_FRAG;
request_pdu->auth_length = (UINT16) ntlm->ContextSizes.cbMaxSignature;
@ -397,8 +392,8 @@ int rpc_write(rdpRpc* rpc, BYTE* data, int length, UINT16 opnum)
request_pdu->alloc_hint = length;
request_pdu->p_cont_id = 0x0000;
request_pdu->opnum = opnum;
clientCall = rpc_client_call_new(request_pdu->call_id, request_pdu->opnum);
if (!clientCall)
goto out_free_pdu;
@ -409,11 +404,9 @@ int rpc_write(rdpRpc* rpc, BYTE* data, int length, UINT16 opnum)
rpc->PipeCallId = request_pdu->call_id;
request_pdu->stub_data = data;
offset = 24;
stub_data_pad = 0;
stub_data_pad = rpc_offset_align(&offset, 8);
offset += length;
request_pdu->auth_verifier.auth_pad_length = rpc_offset_align(&offset, 4);
request_pdu->auth_verifier.auth_type = RPC_C_AUTHN_WINNT;
@ -421,42 +414,38 @@ int rpc_write(rdpRpc* rpc, BYTE* data, int length, UINT16 opnum)
request_pdu->auth_verifier.auth_reserved = 0x00;
request_pdu->auth_verifier.auth_context_id = 0x00000000;
offset += (8 + request_pdu->auth_length);
request_pdu->frag_length = offset;
buffer = (BYTE*) calloc(1, request_pdu->frag_length);
if (!buffer)
goto out_free_pdu;
CopyMemory(buffer, request_pdu, 24);
CopyMemory(buffer, request_pdu, 24);
offset = 24;
rpc_offset_pad(&offset, stub_data_pad);
CopyMemory(&buffer[offset], request_pdu->stub_data, length);
offset += length;
rpc_offset_pad(&offset, request_pdu->auth_verifier.auth_pad_length);
CopyMemory(&buffer[offset], &request_pdu->auth_verifier.auth_type, 8);
offset += 8;
Buffers[0].BufferType = SECBUFFER_DATA; /* auth_data */
Buffers[1].BufferType = SECBUFFER_TOKEN; /* signature */
Buffers[0].pvBuffer = buffer;
Buffers[0].cbBuffer = offset;
Buffers[1].cbBuffer = ntlm->ContextSizes.cbMaxSignature;
Buffers[1].pvBuffer = calloc(1, Buffers[1].cbBuffer);
if (!Buffers[1].pvBuffer)
return -1;
Message.cBuffers = 2;
Message.ulVersion = SECBUFFER_VERSION;
Message.pBuffers = (PSecBuffer) &Buffers;
encrypt_status = ntlm->table->EncryptMessage(&ntlm->context, 0, &Message, rpc->SendSeqNum++);
if (encrypt_status != SEC_E_OK)
{
DEBUG_WARN( "EncryptMessage status: 0x%08X\n", encrypt_status);
DEBUG_WARN("EncryptMessage status: 0x%08X\n", encrypt_status);
free(request_pdu);
return -1;
}
@ -469,9 +458,7 @@ int rpc_write(rdpRpc* rpc, BYTE* data, int length, UINT16 opnum)
length = -1;
free(request_pdu);
return length;
out_free_clientCall:
rpc_client_call_free(clientCall);
out_free_pdu:
@ -486,7 +473,7 @@ BOOL rpc_connect(rdpRpc* rpc)
if (!rts_connect(rpc))
{
DEBUG_WARN( "rts_connect error!\n");
DEBUG_WARN("rts_connect error!\n");
return FALSE;
}
@ -494,7 +481,7 @@ BOOL rpc_connect(rdpRpc* rpc)
if (rpc_secure_bind(rpc) != 0)
{
DEBUG_WARN( "rpc_secure_bind error!\n");
DEBUG_WARN("rpc_secure_bind error!\n");
return FALSE;
}
@ -509,7 +496,6 @@ void rpc_client_virtual_connection_init(rdpRpc* rpc, RpcVirtualConnection* conne
connection->DefaultInChannel->PingOriginator.ConnectionTimeout = 30;
connection->DefaultInChannel->PingOriginator.KeepAliveInterval = 0;
connection->DefaultInChannel->Mutex = CreateMutex(NULL, FALSE, NULL);
connection->DefaultOutChannel->State = CLIENT_OUT_CHANNEL_STATE_INITIAL;
connection->DefaultOutChannel->BytesReceived = 0;
connection->DefaultOutChannel->ReceiverAvailableWindow = rpc->ReceiveWindow;
@ -527,16 +513,18 @@ RpcVirtualConnection* rpc_client_virtual_connection_new(rdpRpc* rpc)
return NULL;
connection->State = VIRTUAL_CONNECTION_STATE_INITIAL;
connection->DefaultInChannel = (RpcInChannel *)calloc(1, sizeof(RpcInChannel));
connection->DefaultInChannel = (RpcInChannel*)calloc(1, sizeof(RpcInChannel));
if (!connection->DefaultInChannel)
goto out_free;
connection->DefaultOutChannel = (RpcOutChannel*)calloc(1, sizeof(RpcOutChannel));
if (!connection->DefaultOutChannel)
goto out_default_in;
rpc_client_virtual_connection_init(rpc, connection);
return connection;
out_default_in:
free(connection->DefaultInChannel);
out_free:
@ -557,60 +545,56 @@ void rpc_client_virtual_connection_free(RpcVirtualConnection* virtual_connection
rdpRpc* rpc_new(rdpTransport* transport)
{
rdpRpc* rpc = (rdpRpc*) calloc(1, sizeof(rdpRpc));
if (!rpc)
return NULL;
rpc->State = RPC_CLIENT_STATE_INITIAL;
rpc->transport = transport;
rpc->settings = transport->settings;
rpc->SendSeqNum = 0;
rpc->ntlm = ntlm_new();
if (!rpc->ntlm)
goto out_free;
rpc->NtlmHttpIn = ntlm_http_new();
if (!rpc->NtlmHttpIn)
goto out_free_ntlm;
rpc->NtlmHttpOut = ntlm_http_new();
if (!rpc->NtlmHttpOut)
goto out_free_ntlm_http_in;
rpc_ntlm_http_init_channel(rpc, rpc->NtlmHttpIn, TSG_CHANNEL_IN);
rpc_ntlm_http_init_channel(rpc, rpc->NtlmHttpOut, TSG_CHANNEL_OUT);
rpc->PipeCallId = 0;
rpc->StubCallId = 0;
rpc->StubFragCount = 0;
rpc->rpc_vers = 5;
rpc->rpc_vers_minor = 0;
/* little-endian data representation */
rpc->packed_drep[0] = 0x10;
rpc->packed_drep[1] = 0x00;
rpc->packed_drep[2] = 0x00;
rpc->packed_drep[3] = 0x00;
rpc->max_xmit_frag = 0x0FF8;
rpc->max_recv_frag = 0x0FF8;
rpc->ReceiveWindow = 0x00010000;
rpc->ChannelLifetime = 0x40000000;
rpc->ChannelLifetimeSet = 0;
rpc->KeepAliveInterval = 300000;
rpc->CurrentKeepAliveInterval = rpc->KeepAliveInterval;
rpc->CurrentKeepAliveTime = 0;
rpc->VirtualConnection = rpc_client_virtual_connection_new(rpc);
if (!rpc->VirtualConnection)
goto out_free_ntlm_http_out;
rpc->VirtualConnectionCookieTable = ArrayList_New(TRUE);
if (!rpc->VirtualConnectionCookieTable)
goto out_free_virtual_connection;
@ -621,9 +605,7 @@ rdpRpc* rpc_new(rdpTransport* transport)
rpc->client->SynchronousSend = TRUE;
rpc->client->SynchronousReceive = TRUE;
return rpc;
out_free_virtualConnectionCookieTable:
rpc_client_free(rpc);
ArrayList_Free(rpc->VirtualConnectionCookieTable);
@ -653,10 +635,8 @@ void rpc_free(rdpRpc* rpc)
}
rpc_client_virtual_connection_free(rpc->VirtualConnection);
ArrayList_Clear(rpc->VirtualConnectionCookieTable);
ArrayList_Free(rpc->VirtualConnectionCookieTable);
free(rpc);
}
}

View File

@ -128,6 +128,7 @@ int rpc_client_on_fragment_received_event(rdpRpc* rpc)
switch (header->common.ptype)
{
case PTYPE_RTS:
if (rpc->VirtualConnection->State < VIRTUAL_CONNECTION_STATE_OPENED)
{
DEBUG_WARN("%s: warning: unhandled RTS PDU\n", __FUNCTION__);
@ -138,15 +139,12 @@ int rpc_client_on_fragment_received_event(rdpRpc* rpc)
rts_recv_out_of_sequence_pdu(rpc, buffer, header->common.frag_length);
rpc_client_fragment_pool_return(rpc, fragment);
return 0;
case PTYPE_FAULT:
rpc_recv_fault_pdu(header);
Queue_Enqueue(rpc->client->ReceiveQueue, NULL);
return -1;
case PTYPE_RESPONSE:
break;
default:
DEBUG_WARN("%s: unexpected RPC PDU type %d\n", __FUNCTION__, header->common.ptype);
Queue_Enqueue(rpc->client->ReceiveQueue, NULL);
@ -456,7 +454,7 @@ RPC_PDU* rpc_recv_dequeue_pdu(rdpRpc* rpc)
if (pdu)
{
DEBUG_WARN("Receiving PDU (length: %d, CallId: %d)\n", pdu->s->length, pdu->CallId);
winpr_HexDump(Stream_Buffer(pdu->s), Stream_Length(pdu->s));
winpr_HexDump(TAG, WLOG_DEBUG, Stream_Buffer(pdu->s), Stream_Length(pdu->s));
DEBUG_WARN("\n");
}
else

File diff suppressed because it is too large Load Diff

View File

@ -23,12 +23,14 @@
#endif
#include <winpr/crt.h>
#include <freerdp/log.h>
#include "redirection.h"
#include "certificate.h"
#include "license.h"
#define TAG FREERDP_TAG("core")
/* #define LICENSE_NULL_CLIENT_RANDOM 1 */
/* #define LICENSE_NULL_PREMASTER_SECRET 1 */
@ -36,20 +38,20 @@
static const char* const LICENSE_MESSAGE_STRINGS[] =
{
"",
"License Request",
"Platform Challenge",
"New License",
"Upgrade License",
"", "", "", "", "", "",
"", "", "", "", "", "",
"",
"License Info",
"New License Request",
"",
"Platform Challenge Response",
"", "", "", "", "", "", "", "", "",
"Error Alert"
"",
"License Request",
"Platform Challenge",
"New License",
"Upgrade License",
"", "", "", "", "", "",
"", "", "", "", "", "",
"",
"License Info",
"New License Request",
"",
"Platform Challenge Response",
"", "", "", "", "", "", "", "", "",
"Error Alert"
};
static const char* const error_codes[] =
@ -82,18 +84,14 @@ void license_print_product_info(LICENSE_PRODUCT_INFO* productInfo)
{
char* CompanyName = NULL;
char* ProductId = NULL;
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) productInfo->pbCompanyName,
productInfo->cbCompanyName / 2, &CompanyName, 0, NULL, NULL);
productInfo->cbCompanyName / 2, &CompanyName, 0, NULL, NULL);
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) productInfo->pbProductId,
productInfo->cbProductId / 2, &ProductId, 0, NULL, NULL);
DEBUG_WARN( "ProductInfo:\n");
DEBUG_WARN( "\tdwVersion: 0x%08X\n", productInfo->dwVersion);
DEBUG_WARN( "\tCompanyName: %s\n", CompanyName);
DEBUG_WARN( "\tProductId: %s\n", ProductId);
productInfo->cbProductId / 2, &ProductId, 0, NULL, NULL);
DEBUG_WARN("ProductInfo:\n");
DEBUG_WARN("\tdwVersion: 0x%08X\n", productInfo->dwVersion);
DEBUG_WARN("\tCompanyName: %s\n", CompanyName);
DEBUG_WARN("\tProductId: %s\n", ProductId);
free(CompanyName);
free(ProductId);
}
@ -102,13 +100,12 @@ void license_print_scope_list(SCOPE_LIST* scopeList)
{
int index;
LICENSE_BLOB* scope;
DEBUG_WARN( "ScopeList (%d):\n", scopeList->count);
DEBUG_WARN("ScopeList (%d):\n", scopeList->count);
for (index = 0; index < scopeList->count; index++)
{
scope = &scopeList->array[index];
DEBUG_WARN( "\t%s\n", (char*) scope->data);
DEBUG_WARN("\t%s\n", (char*) scope->data);
}
}
@ -133,7 +130,6 @@ BOOL license_read_preamble(wStream* s, BYTE* bMsgType, BYTE* flags, UINT16* wMsg
Stream_Read_UINT8(s, *bMsgType); /* bMsgType (1 byte) */
Stream_Read_UINT8(s, *flags); /* flags (1 byte) */
Stream_Read_UINT16(s, *wMsgSize); /* wMsgSize (2 bytes) */
return TRUE;
}
@ -163,17 +159,15 @@ void license_write_preamble(wStream* s, BYTE bMsgType, BYTE flags, UINT16 wMsgSi
wStream* license_send_stream_init(rdpLicense* license)
{
wStream* s;
license->rdp->sec_flags = SEC_LICENSE_PKT;
if (license->rdp->do_crypt)
license->rdp->sec_flags |= SEC_LICENSE_ENCRYPT_CS;
license->rdp->sec_flags |= SEC_LICENSE_ENCRYPT_CS;
s = transport_send_stream_init(license->rdp->transport, 4096);
rdp_init_stream(license->rdp, s);
license->PacketHeaderLength = Stream_GetPosition(s);
Stream_Seek(s, LICENSE_PREAMBLE_LENGTH);
return s;
}
@ -190,13 +184,10 @@ BOOL license_send(rdpLicense* license, wStream* s, BYTE type)
BYTE flags;
UINT16 wMsgSize;
rdpRdp* rdp = license->rdp;
DEBUG_LICENSE("Sending %s Packet", LICENSE_MESSAGE_STRINGS[type & 0x1F]);
length = Stream_GetPosition(s);
wMsgSize = length - license->PacketHeaderLength;
Stream_SetPosition(s, license->PacketHeaderLength);
flags = PREAMBLE_VERSION_3_0;
/**
@ -208,17 +199,13 @@ BOOL license_send(rdpLicense* license, wStream* s, BYTE type)
flags |= EXTENDED_ERROR_MSG_SUPPORTED;
license_write_preamble(s, type, flags, wMsgSize);
#ifdef WITH_DEBUG_LICENSE
DEBUG_WARN( "Sending %s Packet, length %d\n", LICENSE_MESSAGE_STRINGS[type & 0x1F], wMsgSize);
winpr_HexDump(Stream_Pointer(s) - LICENSE_PREAMBLE_LENGTH, wMsgSize);
DEBUG_WARN("Sending %s Packet, length %d\n", LICENSE_MESSAGE_STRINGS[type & 0x1F], wMsgSize);
winpr_HexDump(TAG, WLOG_DEBUG, Stream_Pointer(s) - LICENSE_PREAMBLE_LENGTH, wMsgSize);
#endif
Stream_SetPosition(s, length);
rdp_send(rdp, s, MCS_GLOBAL_CHANNEL_ID);
rdp->sec_flags = 0;
return TRUE;
}
@ -241,7 +228,7 @@ int license_recv(rdpLicense* license, wStream* s)
if (!rdp_read_header(license->rdp, s, &length, &channelId))
{
DEBUG_WARN( "%s: Incorrect RDP header.\n", __FUNCTION__);
DEBUG_WARN("%s: Incorrect RDP header.\n", __FUNCTION__);
return -1;
}
@ -252,7 +239,7 @@ int license_recv(rdpLicense* license, wStream* s)
{
if (!rdp_decrypt(license->rdp, s, length - 4, securityFlags))
{
DEBUG_WARN( "%s: rdp_decrypt failed\n", __FUNCTION__);
DEBUG_WARN("%s: rdp_decrypt failed\n", __FUNCTION__);
return -1;
}
}
@ -268,7 +255,7 @@ int license_recv(rdpLicense* license, wStream* s)
if (status < 0)
{
DEBUG_WARN( "%s: unexpected license packet.\n", __FUNCTION__);
DEBUG_WARN("%s: unexpected license packet.\n", __FUNCTION__);
return status;
}
@ -283,32 +270,33 @@ int license_recv(rdpLicense* license, wStream* s)
switch (bMsgType)
{
case LICENSE_REQUEST:
if (!license_read_license_request_packet(license, s))
return -1;
license_send_new_license_request_packet(license);
break;
case PLATFORM_CHALLENGE:
if (!license_read_platform_challenge_packet(license, s))
return -1;
license_send_platform_challenge_response_packet(license);
break;
case NEW_LICENSE:
license_read_new_license_packet(license, s);
break;
case UPGRADE_LICENSE:
license_read_upgrade_license_packet(license, s);
break;
case ERROR_ALERT:
if (!license_read_error_alert_packet(license, s))
return -1;
break;
break;
default:
DEBUG_WARN( "%s: invalid bMsgType:%d\n", __FUNCTION__, bMsgType);
DEBUG_WARN("%s: invalid bMsgType:%d\n", __FUNCTION__, bMsgType);
return FALSE;
}
@ -319,11 +307,9 @@ void license_generate_randoms(rdpLicense* license)
{
ZeroMemory(license->ClientRandom, CLIENT_RANDOM_LENGTH); /* ClientRandom */
ZeroMemory(license->PremasterSecret, PREMASTER_SECRET_LENGTH); /* PremasterSecret */
#ifndef LICENSE_NULL_CLIENT_RANDOM
crypto_nonce(license->ClientRandom, CLIENT_RANDOM_LENGTH); /* ClientRandom */
#endif
#ifndef LICENSE_NULL_PREMASTER_SECRET
crypto_nonce(license->PremasterSecret, PREMASTER_SECRET_LENGTH); /* PremasterSecret */
#endif
@ -337,45 +323,35 @@ void license_generate_randoms(rdpLicense* license)
void license_generate_keys(rdpLicense* license)
{
security_master_secret(license->PremasterSecret, license->ClientRandom,
license->ServerRandom, license->MasterSecret); /* MasterSecret */
license->ServerRandom, license->MasterSecret); /* MasterSecret */
security_session_key_blob(license->MasterSecret, license->ClientRandom,
license->ServerRandom, license->SessionKeyBlob); /* SessionKeyBlob */
license->ServerRandom, license->SessionKeyBlob); /* SessionKeyBlob */
security_mac_salt_key(license->SessionKeyBlob, license->ClientRandom,
license->ServerRandom, license->MacSaltKey); /* MacSaltKey */
license->ServerRandom, license->MacSaltKey); /* MacSaltKey */
security_licensing_encryption_key(license->SessionKeyBlob, license->ClientRandom,
license->ServerRandom, license->LicensingEncryptionKey); /* LicensingEncryptionKey */
license->ServerRandom, license->LicensingEncryptionKey); /* LicensingEncryptionKey */
#ifdef WITH_DEBUG_LICENSE
DEBUG_WARN( "ClientRandom:\n");
winpr_HexDump(license->ClientRandom, CLIENT_RANDOM_LENGTH);
DEBUG_WARN( "\n");
DEBUG_WARN( "ServerRandom:\n");
winpr_HexDump(license->ServerRandom, SERVER_RANDOM_LENGTH);
DEBUG_WARN( "\n");
DEBUG_WARN( "PremasterSecret:\n");
winpr_HexDump(license->PremasterSecret, PREMASTER_SECRET_LENGTH);
DEBUG_WARN( "\n");
DEBUG_WARN( "MasterSecret:\n");
winpr_HexDump(license->MasterSecret, MASTER_SECRET_LENGTH);
DEBUG_WARN( "\n");
DEBUG_WARN( "SessionKeyBlob:\n");
winpr_HexDump(license->SessionKeyBlob, SESSION_KEY_BLOB_LENGTH);
DEBUG_WARN( "\n");
DEBUG_WARN( "MacSaltKey:\n");
winpr_HexDump(license->MacSaltKey, MAC_SALT_KEY_LENGTH);
DEBUG_WARN( "\n");
DEBUG_WARN( "LicensingEncryptionKey:\n");
winpr_HexDump(license->LicensingEncryptionKey, LICENSING_ENCRYPTION_KEY_LENGTH);
DEBUG_WARN( "\n");
DEBUG_WARN("ClientRandom:\n");
winpr_HexDump(TAG, WLOG_DEBUG, license->ClientRandom, CLIENT_RANDOM_LENGTH);
DEBUG_WARN("\n");
DEBUG_WARN("ServerRandom:\n");
winpr_HexDump(TAG, WLOG_DEBUG, license->ServerRandom, SERVER_RANDOM_LENGTH);
DEBUG_WARN("\n");
DEBUG_WARN("PremasterSecret:\n");
winpr_HexDump(TAG, WLOG_DEBUG, license->PremasterSecret, PREMASTER_SECRET_LENGTH);
DEBUG_WARN("\n");
DEBUG_WARN("MasterSecret:\n");
winpr_HexDump(TAG, WLOG_DEBUG, license->MasterSecret, MASTER_SECRET_LENGTH);
DEBUG_WARN("\n");
DEBUG_WARN("SessionKeyBlob:\n");
winpr_HexDump(TAG, WLOG_DEBUG, license->SessionKeyBlob, SESSION_KEY_BLOB_LENGTH);
DEBUG_WARN("\n");
DEBUG_WARN("MacSaltKey:\n");
winpr_HexDump(TAG, WLOG_DEBUG, license->MacSaltKey, MAC_SALT_KEY_LENGTH);
DEBUG_WARN("\n");
DEBUG_WARN("LicensingEncryptionKey:\n");
winpr_HexDump(TAG, WLOG_DEBUG, license->LicensingEncryptionKey, LICENSING_ENCRYPTION_KEY_LENGTH);
DEBUG_WARN("\n");
#endif
}
@ -388,14 +364,13 @@ void license_generate_hwid(rdpLicense* license)
{
CryptoMd5 md5;
BYTE* mac_address;
ZeroMemory(license->HardwareId, HWID_LENGTH);
mac_address = license->rdp->transport->TcpIn->mac_address;
md5 = crypto_md5_init();
if (!md5)
{
DEBUG_WARN( "%s: unable to allocate a md5\n", __FUNCTION__);
DEBUG_WARN("%s: unable to allocate a md5\n", __FUNCTION__);
return;
}
@ -412,16 +387,14 @@ void license_get_server_rsa_public_key(rdpLicense* license)
if (license->ServerCertificate->length < 1)
{
certificate_read_server_certificate(license->certificate,
license->rdp->settings->ServerCertificate,
license->rdp->settings->ServerCertificateLength);
license->rdp->settings->ServerCertificate,
license->rdp->settings->ServerCertificateLength);
}
Exponent = license->certificate->cert_info.exponent;
Modulus = license->certificate->cert_info.Modulus;
ModulusLength = license->certificate->cert_info.ModulusLength;
CopyMemory(license->Exponent, Exponent, 4);
license->ModulusLength = ModulusLength;
license->Modulus = (BYTE*) malloc(ModulusLength);
memcpy(license->Modulus, Modulus, ModulusLength);
@ -430,51 +403,43 @@ void license_get_server_rsa_public_key(rdpLicense* license)
void license_encrypt_premaster_secret(rdpLicense* license)
{
BYTE* EncryptedPremasterSecret;
license_get_server_rsa_public_key(license);
#ifdef WITH_DEBUG_LICENSE
DEBUG_WARN( "Modulus (%d bits):\n", license->ModulusLength * 8);
winpr_HexDump(license->Modulus, license->ModulusLength);
DEBUG_WARN( "\n");
DEBUG_WARN( "Exponent:\n");
winpr_HexDump(license->Exponent, 4);
DEBUG_WARN( "\n");
DEBUG_WARN("Modulus (%d bits):\n", license->ModulusLength * 8);
winpr_HexDump(TAG, WLOG_DEBUG, license->Modulus, license->ModulusLength);
DEBUG_WARN("\n");
DEBUG_WARN("Exponent:\n");
winpr_HexDump(TAG, WLOG_DEBUG, license->Exponent, 4);
DEBUG_WARN("\n");
#endif
EncryptedPremasterSecret = (BYTE*) malloc(license->ModulusLength);
ZeroMemory(EncryptedPremasterSecret, license->ModulusLength);
license->EncryptedPremasterSecret->type = BB_RANDOM_BLOB;
license->EncryptedPremasterSecret->length = PREMASTER_SECRET_LENGTH;
#ifndef LICENSE_NULL_PREMASTER_SECRET
license->EncryptedPremasterSecret->length =
crypto_rsa_public_encrypt(license->PremasterSecret, PREMASTER_SECRET_LENGTH,
license->ModulusLength, license->Modulus, license->Exponent, EncryptedPremasterSecret);
license->ModulusLength, license->Modulus, license->Exponent, EncryptedPremasterSecret);
#endif
license->EncryptedPremasterSecret->data = EncryptedPremasterSecret;
}
void license_decrypt_platform_challenge(rdpLicense* license)
{
CryptoRc4 rc4;
license->PlatformChallenge->data = (BYTE*) malloc(license->EncryptedPlatformChallenge->length);
license->PlatformChallenge->length = license->EncryptedPlatformChallenge->length;
rc4 = crypto_rc4_init(license->LicensingEncryptionKey, LICENSING_ENCRYPTION_KEY_LENGTH);
if (!rc4)
{
DEBUG_WARN( "%s: unable to allocate a rc4\n", __FUNCTION__);
DEBUG_WARN("%s: unable to allocate a rc4\n", __FUNCTION__);
return;
}
crypto_rc4(rc4, license->EncryptedPlatformChallenge->length,
license->EncryptedPlatformChallenge->data,
license->PlatformChallenge->data);
license->EncryptedPlatformChallenge->data,
license->PlatformChallenge->data);
crypto_rc4_free(rc4);
}
@ -491,7 +456,6 @@ BOOL license_read_product_info(wStream* s, LICENSE_PRODUCT_INFO* productInfo)
return FALSE;
Stream_Read_UINT32(s, productInfo->dwVersion); /* dwVersion (4 bytes) */
Stream_Read_UINT32(s, productInfo->cbCompanyName); /* cbCompanyName (4 bytes) */
if (Stream_GetRemainingLength(s) < productInfo->cbCompanyName + 4)
@ -499,7 +463,6 @@ BOOL license_read_product_info(wStream* s, LICENSE_PRODUCT_INFO* productInfo)
productInfo->pbCompanyName = (BYTE*) malloc(productInfo->cbCompanyName);
Stream_Read(s, productInfo->pbCompanyName, productInfo->cbCompanyName);
Stream_Read_UINT32(s, productInfo->cbProductId); /* cbProductId (4 bytes) */
if (Stream_GetRemainingLength(s) < productInfo->cbProductId)
@ -511,7 +474,6 @@ BOOL license_read_product_info(wStream* s, LICENSE_PRODUCT_INFO* productInfo)
productInfo->pbProductId = (BYTE*) malloc(productInfo->cbProductId);
Stream_Read(s, productInfo->pbProductId, productInfo->cbProductId);
return TRUE;
}
@ -524,15 +486,12 @@ BOOL license_read_product_info(wStream* s, LICENSE_PRODUCT_INFO* productInfo)
LICENSE_PRODUCT_INFO* license_new_product_info()
{
LICENSE_PRODUCT_INFO* productInfo;
productInfo = (LICENSE_PRODUCT_INFO*) malloc(sizeof(LICENSE_PRODUCT_INFO));
productInfo->dwVersion = 0;
productInfo->cbCompanyName = 0;
productInfo->pbCompanyName = NULL;
productInfo->cbProductId = 0;
productInfo->pbProductId = NULL;
return productInfo;
}
@ -574,20 +533,19 @@ BOOL license_read_binary_blob(wStream* s, LICENSE_BLOB* blob)
return FALSE;
/*
* Server can choose to not send data by setting length to 0.
* If so, it may not bother to set the type, so shortcut the warning
*/
* Server can choose to not send data by setting length to 0.
* If so, it may not bother to set the type, so shortcut the warning
*/
if ((blob->type != BB_ANY_BLOB) && (blob->length == 0))
return TRUE;
if ((blob->type != wBlobType) && (blob->type != BB_ANY_BLOB))
{
DEBUG_WARN( "license binary blob type (%x) does not match expected type (%x).\n", wBlobType, blob->type);
DEBUG_WARN("license binary blob type (%x) does not match expected type (%x).\n", wBlobType, blob->type);
}
blob->type = wBlobType;
blob->data = (BYTE*) malloc(blob->length);
Stream_Read(s, blob->data, blob->length); /* blobData */
return TRUE;
}
@ -602,7 +560,6 @@ BOOL license_read_binary_blob(wStream* s, LICENSE_BLOB* blob)
void license_write_binary_blob(wStream* s, LICENSE_BLOB* blob)
{
Stream_EnsureRemainingCapacity(s, blob->length + 4);
Stream_Write_UINT16(s, blob->type); /* wBlobType (2 bytes) */
Stream_Write_UINT16(s, blob->length); /* wBlobLen (2 bytes) */
@ -613,17 +570,15 @@ void license_write_binary_blob(wStream* s, LICENSE_BLOB* blob)
void license_write_encrypted_premaster_secret_blob(wStream* s, LICENSE_BLOB* blob, UINT32 ModulusLength)
{
UINT32 length;
length = ModulusLength + 8;
if (blob->length > ModulusLength)
{
DEBUG_WARN( "license_write_encrypted_premaster_secret_blob: invalid blob\n");
DEBUG_WARN("license_write_encrypted_premaster_secret_blob: invalid blob\n");
return;
}
Stream_EnsureRemainingCapacity(s, length + 4);
Stream_Write_UINT16(s, blob->type); /* wBlobType (2 bytes) */
Stream_Write_UINT16(s, length); /* wBlobLen (2 bytes) */
@ -642,12 +597,10 @@ void license_write_encrypted_premaster_secret_blob(wStream* s, LICENSE_BLOB* blo
LICENSE_BLOB* license_new_binary_blob(UINT16 type)
{
LICENSE_BLOB* blob;
blob = (LICENSE_BLOB*) malloc(sizeof(LICENSE_BLOB));
blob->type = type;
blob->length = 0;
blob->data = NULL;
return blob;
}
@ -681,6 +634,7 @@ BOOL license_read_scope_list(wStream* s, SCOPE_LIST* scopeList)
return FALSE;
Stream_Read_UINT32(s, scopeCount); /* ScopeCount (4 bytes) */
if (scopeCount > Stream_GetRemainingLength(s) / 4) /* every blob is at least 4 bytes */
return FALSE;
@ -708,11 +662,9 @@ BOOL license_read_scope_list(wStream* s, SCOPE_LIST* scopeList)
SCOPE_LIST* license_new_scope_list()
{
SCOPE_LIST* scopeList;
scopeList = (SCOPE_LIST*) malloc(sizeof(SCOPE_LIST));
scopeList->count = 0;
scopeList->array = NULL;
return scopeList;
}
@ -781,19 +733,15 @@ BOOL license_read_license_request_packet(rdpLicense* license, wStream* s)
license_generate_keys(license);
license_generate_hwid(license);
license_encrypt_premaster_secret(license);
#ifdef WITH_DEBUG_LICENSE
DEBUG_WARN( "ServerRandom:\n");
winpr_HexDump(license->ServerRandom, 32);
DEBUG_WARN( "\n");
DEBUG_WARN("ServerRandom:\n");
winpr_HexDump(TAG, WLOG_DEBUG, license->ServerRandom, 32);
DEBUG_WARN("\n");
license_print_product_info(license->ProductInfo);
DEBUG_WARN( "\n");
DEBUG_WARN("\n");
license_print_scope_list(license->ScopeList);
DEBUG_WARN( "\n");
DEBUG_WARN("\n");
#endif
return TRUE;
}
@ -808,14 +756,12 @@ BOOL license_read_platform_challenge_packet(rdpLicense* license, wStream* s)
{
BYTE MacData[16];
UINT32 ConnectFlags = 0;
DEBUG_LICENSE("Receiving Platform Challenge Packet");
if (Stream_GetRemainingLength(s) < 4)
return FALSE;
Stream_Read_UINT32(s, ConnectFlags); /* ConnectFlags, Reserved (4 bytes) */
/* EncryptedPlatformChallenge */
license->EncryptedPlatformChallenge->type = BB_ANY_BLOB;
license_read_binary_blob(s, license->EncryptedPlatformChallenge);
@ -825,26 +771,20 @@ BOOL license_read_platform_challenge_packet(rdpLicense* license, wStream* s)
return FALSE;
Stream_Read(s, MacData, 16); /* MACData (16 bytes) */
license_decrypt_platform_challenge(license);
#ifdef WITH_DEBUG_LICENSE
DEBUG_WARN( "ConnectFlags: 0x%08X\n", ConnectFlags);
DEBUG_WARN( "\n");
DEBUG_WARN( "EncryptedPlatformChallenge:\n");
winpr_HexDump(license->EncryptedPlatformChallenge->data, license->EncryptedPlatformChallenge->length);
DEBUG_WARN( "\n");
DEBUG_WARN( "PlatformChallenge:\n");
winpr_HexDump(license->PlatformChallenge->data, license->PlatformChallenge->length);
DEBUG_WARN( "\n");
DEBUG_WARN( "MacData:\n");
winpr_HexDump(MacData, 16);
DEBUG_WARN( "\n");
DEBUG_WARN("ConnectFlags: 0x%08X\n", ConnectFlags);
DEBUG_WARN("\n");
DEBUG_WARN("EncryptedPlatformChallenge:\n");
winpr_HexDump(TAG, WLOG_DEBUG, license->EncryptedPlatformChallenge->data, license->EncryptedPlatformChallenge->length);
DEBUG_WARN("\n");
DEBUG_WARN("PlatformChallenge:\n");
winpr_HexDump(TAG, WLOG_DEBUG, license->PlatformChallenge->data, license->PlatformChallenge->length);
DEBUG_WARN("\n");
DEBUG_WARN("MacData:\n");
winpr_HexDump(TAG, WLOG_DEBUG, MacData, 16);
DEBUG_WARN("\n");
#endif
return TRUE;
}
@ -896,8 +836,8 @@ BOOL license_read_error_alert_packet(rdpLicense* license, wStream* s)
return FALSE;
#ifdef WITH_DEBUG_LICENSE
DEBUG_WARN( "dwErrorCode: %s, dwStateTransition: %s\n",
error_codes[dwErrorCode], state_transitions[dwStateTransition]);
DEBUG_WARN("dwErrorCode: %s, dwStateTransition: %s\n",
error_codes[dwErrorCode], state_transitions[dwStateTransition]);
#endif
if (dwErrorCode == STATUS_VALID_CLIENT)
@ -911,18 +851,14 @@ BOOL license_read_error_alert_packet(rdpLicense* license, wStream* s)
case ST_TOTAL_ABORT:
license->state = LICENSE_STATE_ABORTED;
break;
case ST_NO_TRANSITION:
license->state = LICENSE_STATE_COMPLETED;
break;
case ST_RESET_PHASE_TO_START:
license->state = LICENSE_STATE_AWAIT;
break;
case ST_RESEND_LAST_MESSAGE:
break;
default:
break;
}
@ -941,33 +877,26 @@ void license_write_new_license_request_packet(rdpLicense* license, wStream* s)
{
UINT32 PlatformId;
UINT32 PreferredKeyExchangeAlg = KEY_EXCHANGE_ALG_RSA;
PlatformId = CLIENT_OS_ID_WINNT_POST_52 | CLIENT_IMAGE_ID_MICROSOFT;
Stream_Write_UINT32(s, PreferredKeyExchangeAlg); /* PreferredKeyExchangeAlg (4 bytes) */
Stream_Write_UINT32(s, PlatformId); /* PlatformId (4 bytes) */
Stream_Write(s, license->ClientRandom, 32); /* ClientRandom (32 bytes) */
license_write_encrypted_premaster_secret_blob(s, license->EncryptedPremasterSecret, license->ModulusLength); /* EncryptedPremasterSecret */
license_write_binary_blob(s, license->ClientUserName); /* ClientUserName */
license_write_binary_blob(s, license->ClientMachineName); /* ClientMachineName */
#ifdef WITH_DEBUG_LICENSE
DEBUG_WARN( "PreferredKeyExchangeAlg: 0x%08X\n", PreferredKeyExchangeAlg);
DEBUG_WARN( "\n");
DEBUG_WARN( "ClientRandom:\n");
winpr_HexDump(license->ClientRandom, 32);
DEBUG_WARN( "\n");
DEBUG_WARN( "EncryptedPremasterSecret\n");
winpr_HexDump(license->EncryptedPremasterSecret->data, license->EncryptedPremasterSecret->length);
DEBUG_WARN( "\n");
DEBUG_WARN( "ClientUserName (%d): %s\n", license->ClientUserName->length, (char*) license->ClientUserName->data);
DEBUG_WARN( "\n");
DEBUG_WARN( "ClientMachineName (%d): %s\n", license->ClientMachineName->length, (char*) license->ClientMachineName->data);
DEBUG_WARN( "\n");
DEBUG_WARN("PreferredKeyExchangeAlg: 0x%08X\n", PreferredKeyExchangeAlg);
DEBUG_WARN("\n");
DEBUG_WARN("ClientRandom:\n");
winpr_HexDump(TAG, WLOG_DEBUG, license->ClientRandom, 32);
DEBUG_WARN("\n");
DEBUG_WARN("EncryptedPremasterSecret\n");
winpr_HexDump(TAG, WLOG_DEBUG, license->EncryptedPremasterSecret->data, license->EncryptedPremasterSecret->length);
DEBUG_WARN("\n");
DEBUG_WARN("ClientUserName (%d): %s\n", license->ClientUserName->length, (char*) license->ClientUserName->data);
DEBUG_WARN("\n");
DEBUG_WARN("ClientMachineName (%d): %s\n", license->ClientMachineName->length, (char*) license->ClientMachineName->data);
DEBUG_WARN("\n");
#endif
}
@ -981,9 +910,7 @@ void license_send_new_license_request_packet(rdpLicense* license)
{
wStream* s;
char* username;
DEBUG_LICENSE("Sending New License Packet");
s = license_send_stream_init(license);
if (license->rdp->settings->Username != NULL)
@ -993,17 +920,12 @@ void license_send_new_license_request_packet(rdpLicense* license)
license->ClientUserName->data = (BYTE*) username;
license->ClientUserName->length = strlen(username) + 1;
license->ClientMachineName->data = (BYTE*) license->rdp->settings->ClientHostname;
license->ClientMachineName->length = strlen(license->rdp->settings->ClientHostname) + 1;
license_write_new_license_request_packet(license, s);
license_send(license, s, NEW_LICENSE_REQUEST);
license->ClientUserName->data = NULL;
license->ClientUserName->length = 0;
license->ClientMachineName->data = NULL;
license->ClientMachineName->length = 0;
}
@ -1020,7 +942,6 @@ void license_write_platform_challenge_response_packet(rdpLicense* license, wStre
{
license_write_binary_blob(s, license->EncryptedPlatformChallenge); /* EncryptedPlatformChallengeResponse */
license_write_binary_blob(s, license->EncryptedHardwareId); /* EncryptedHWID */
Stream_EnsureRemainingCapacity(s, 16);
Stream_Write(s, macData, 16); /* MACData */
}
@ -1038,51 +959,42 @@ void license_send_platform_challenge_response_packet(rdpLicense* license)
BYTE* buffer;
CryptoRc4 rc4;
BYTE mac_data[16];
DEBUG_LICENSE("Sending Platform Challenge Response Packet");
s = license_send_stream_init(license);
license->EncryptedPlatformChallenge->type = BB_DATA_BLOB;
length = license->PlatformChallenge->length + HWID_LENGTH;
buffer = (BYTE*) malloc(length);
CopyMemory(buffer, license->PlatformChallenge->data, license->PlatformChallenge->length);
CopyMemory(&buffer[license->PlatformChallenge->length], license->HardwareId, HWID_LENGTH);
security_mac_data(license->MacSaltKey, buffer, length, mac_data);
free(buffer);
buffer = (BYTE*) malloc(HWID_LENGTH);
rc4 = crypto_rc4_init(license->LicensingEncryptionKey, LICENSING_ENCRYPTION_KEY_LENGTH);
if (!rc4)
{
DEBUG_WARN( "%s: unable to allocate a rc4\n", __FUNCTION__);
DEBUG_WARN("%s: unable to allocate a rc4\n", __FUNCTION__);
free(buffer);
return;
}
crypto_rc4(rc4, HWID_LENGTH, license->HardwareId, buffer);
crypto_rc4_free(rc4);
license->EncryptedHardwareId->type = BB_DATA_BLOB;
license->EncryptedHardwareId->data = buffer;
license->EncryptedHardwareId->length = HWID_LENGTH;
#ifdef WITH_DEBUG_LICENSE
DEBUG_WARN( "LicensingEncryptionKey:\n");
winpr_HexDump(license->LicensingEncryptionKey, 16);
DEBUG_WARN( "\n");
DEBUG_WARN( "HardwareId:\n");
winpr_HexDump(license->HardwareId, HWID_LENGTH);
DEBUG_WARN( "\n");
DEBUG_WARN( "EncryptedHardwareId:\n");
winpr_HexDump(license->EncryptedHardwareId->data, HWID_LENGTH);
DEBUG_WARN( "\n");
DEBUG_WARN("LicensingEncryptionKey:\n");
winpr_HexDump(TAG, WLOG_DEBUG, license->LicensingEncryptionKey, 16);
DEBUG_WARN("\n");
DEBUG_WARN("HardwareId:\n");
winpr_HexDump(TAG, WLOG_DEBUG, license->HardwareId, HWID_LENGTH);
DEBUG_WARN("\n");
DEBUG_WARN("EncryptedHardwareId:\n");
winpr_HexDump(TAG, WLOG_DEBUG, license->EncryptedHardwareId->data, HWID_LENGTH);
DEBUG_WARN("\n");
#endif
license_write_platform_challenge_response_packet(license, s, mac_data);
license_send(license, s, PLATFORM_CHALLENGE_RESPONSE);
}
@ -1095,16 +1007,11 @@ void license_send_platform_challenge_response_packet(rdpLicense* license)
BOOL license_send_valid_client_error_packet(rdpLicense* license)
{
wStream* s;
s = license_send_stream_init(license);
DEBUG_LICENSE("Sending Error Alert Packet");
Stream_Write_UINT32(s, STATUS_VALID_CLIENT); /* dwErrorCode */
Stream_Write_UINT32(s, ST_NO_TRANSITION); /* dwStateTransition */
license_write_binary_blob(s, license->ErrorInfo);
return license_send(license, s, ERROR_ALERT);
}
@ -1117,13 +1024,11 @@ BOOL license_send_valid_client_error_packet(rdpLicense* license)
rdpLicense* license_new(rdpRdp* rdp)
{
rdpLicense* license;
license = (rdpLicense*) malloc(sizeof(rdpLicense));
if (license != NULL)
{
ZeroMemory(license, sizeof(rdpLicense));
license->rdp = rdp;
license->state = LICENSE_STATE_AWAIT;
license->certificate = certificate_new();

View File

@ -27,6 +27,7 @@
#include <unistd.h>
#endif
#include <freerdp/log.h>
#include <freerdp/crypto/tls.h>
#include <winpr/crt.h>
@ -39,7 +40,8 @@
#include "nla.h"
#define TAG "com.freerdp.core"
#define TAG FREERDP_TAG("core")
/**
* TSRequest ::= SEQUENCE {
* version [0] INTEGER,
@ -340,7 +342,7 @@ int credssp_client_authenticate(rdpCredssp* credssp)
credssp->negoToken.cbBuffer = output_buffer.cbBuffer;
#ifdef WITH_DEBUG_CREDSSP
DEBUG_WARN("Sending Authentication Token\n");
winpr_HexDump(credssp->negoToken.pvBuffer, credssp->negoToken.cbBuffer);
winpr_HexDump(TAG, WLOG_DEBUG, credssp->negoToken.pvBuffer, credssp->negoToken.cbBuffer);
#endif
credssp_send(credssp);
credssp_buffer_free(credssp);
@ -360,7 +362,7 @@ int credssp_client_authenticate(rdpCredssp* credssp)
#ifdef WITH_DEBUG_CREDSSP
DEBUG_WARN("Receiving Authentication Token (%d)\n", (int) credssp->negoToken.cbBuffer);
winpr_HexDump(credssp->negoToken.pvBuffer, credssp->negoToken.cbBuffer);
winpr_HexDump(TAG, WLOG_DEBUG, credssp->negoToken.pvBuffer, credssp->negoToken.cbBuffer);
#endif
input_buffer.pvBuffer = credssp->negoToken.pvBuffer;
input_buffer.cbBuffer = credssp->negoToken.cbBuffer;

View File

@ -22,43 +22,57 @@
#endif
#include <winpr/crt.h>
#include <freerdp/log.h>
#include "connection.h"
#include "redirection.h"
#define TAG FREERDP_TAG("core")
void rdp_print_redirection_flags(UINT32 flags)
{
DEBUG_WARN( "redirectionFlags = {\n");
DEBUG_WARN("redirectionFlags = {\n");
if (flags & LB_TARGET_NET_ADDRESS)
DEBUG_WARN( "\tLB_TARGET_NET_ADDRESS\n");
if (flags & LB_LOAD_BALANCE_INFO)
DEBUG_WARN( "\tLB_LOAD_BALANCE_INFO\n");
if (flags & LB_USERNAME)
DEBUG_WARN( "\tLB_USERNAME\n");
if (flags & LB_DOMAIN)
DEBUG_WARN( "\tLB_DOMAIN\n");
if (flags & LB_PASSWORD)
DEBUG_WARN( "\tLB_PASSWORD\n");
if (flags & LB_DONTSTOREUSERNAME)
DEBUG_WARN( "\tLB_DONTSTOREUSERNAME\n");
if (flags & LB_SMARTCARD_LOGON)
DEBUG_WARN( "\tLB_SMARTCARD_LOGON\n");
if (flags & LB_NOREDIRECT)
DEBUG_WARN( "\tLB_NOREDIRECT\n");
if (flags & LB_TARGET_FQDN)
DEBUG_WARN( "\tLB_TARGET_FQDN\n");
if (flags & LB_TARGET_NETBIOS_NAME)
DEBUG_WARN( "\tLB_TARGET_NETBIOS_NAME\n");
if (flags & LB_TARGET_NET_ADDRESSES)
DEBUG_WARN( "\tLB_TARGET_NET_ADDRESSES\n");
if (flags & LB_CLIENT_TSV_URL)
DEBUG_WARN( "\tLB_CLIENT_TSV_URL\n");
if (flags & LB_SERVER_TSV_CAPABLE)
DEBUG_WARN( "\tLB_SERVER_TSV_CAPABLE\n");
DEBUG_WARN("\tLB_TARGET_NET_ADDRESS\n");
DEBUG_WARN( "}\n");
if (flags & LB_LOAD_BALANCE_INFO)
DEBUG_WARN("\tLB_LOAD_BALANCE_INFO\n");
if (flags & LB_USERNAME)
DEBUG_WARN("\tLB_USERNAME\n");
if (flags & LB_DOMAIN)
DEBUG_WARN("\tLB_DOMAIN\n");
if (flags & LB_PASSWORD)
DEBUG_WARN("\tLB_PASSWORD\n");
if (flags & LB_DONTSTOREUSERNAME)
DEBUG_WARN("\tLB_DONTSTOREUSERNAME\n");
if (flags & LB_SMARTCARD_LOGON)
DEBUG_WARN("\tLB_SMARTCARD_LOGON\n");
if (flags & LB_NOREDIRECT)
DEBUG_WARN("\tLB_NOREDIRECT\n");
if (flags & LB_TARGET_FQDN)
DEBUG_WARN("\tLB_TARGET_FQDN\n");
if (flags & LB_TARGET_NETBIOS_NAME)
DEBUG_WARN("\tLB_TARGET_NETBIOS_NAME\n");
if (flags & LB_TARGET_NET_ADDRESSES)
DEBUG_WARN("\tLB_TARGET_NET_ADDRESSES\n");
if (flags & LB_CLIENT_TSV_URL)
DEBUG_WARN("\tLB_CLIENT_TSV_URL\n");
if (flags & LB_SERVER_TSV_CAPABLE)
DEBUG_WARN("\tLB_SERVER_TSV_CAPABLE\n");
DEBUG_WARN("}\n");
}
BOOL rdp_redirection_read_string(wStream* s, char** str)
@ -67,7 +81,7 @@ BOOL rdp_redirection_read_string(wStream* s, char** str)
if (Stream_GetRemainingLength(s) < 4)
{
DEBUG_WARN( "rdp_redirection_read_string failure: cannot read length\n");
DEBUG_WARN("rdp_redirection_read_string failure: cannot read length\n");
return FALSE;
}
@ -75,13 +89,12 @@ BOOL rdp_redirection_read_string(wStream* s, char** str)
if (Stream_GetRemainingLength(s) < length)
{
DEBUG_WARN( "rdp_redirection_read_string failure: incorrect length %d\n", length);
DEBUG_WARN("rdp_redirection_read_string failure: incorrect length %d\n", length);
return FALSE;
}
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), length / 2, str, 0, NULL, NULL);
Stream_Seek(s, length);
return TRUE;
}
@ -89,7 +102,6 @@ int rdp_redirection_apply_settings(rdpRdp* rdp)
{
rdpSettings* settings = rdp->settings;
rdpRedirection* redirection = rdp->redirection;
settings->RedirectionFlags = redirection->flags;
settings->RedirectedSessionId = redirection->sessionID;
@ -107,7 +119,6 @@ int rdp_redirection_apply_settings(rdpRdp* rdp)
* Free previous LoadBalanceInfo, if any, otherwise it may end up
* being reused for the redirected session, which is not what we want.
*/
free(settings->LoadBalanceInfo);
settings->LoadBalanceInfo = NULL;
settings->LoadBalanceInfoLength = 0;
@ -162,9 +173,7 @@ int rdp_redirection_apply_settings(rdpRdp* rdp)
if (settings->RedirectionFlags & LB_TARGET_NET_ADDRESSES)
{
UINT32 i;
freerdp_target_net_addresses_free(settings);
settings->TargetNetAddressCount = redirection->TargetNetAddressesCount;
settings->TargetNetAddresses = (char**) malloc(sizeof(char*) * settings->TargetNetAddressCount);
@ -190,10 +199,8 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s)
Stream_Read_UINT16(s, length); /* length (2 bytes) */
Stream_Read_UINT32(s, redirection->sessionID); /* sessionID (4 bytes) */
Stream_Read_UINT32(s, redirection->flags); /* redirFlags (4 bytes) */
WLog_Print(redirection->log, WLOG_DEBUG, "flags: 0x%04X, redirFlags: 0x%04X length: %d, sessionID: 0x%08X",
flags, redirection->flags, length, redirection->sessionID);
flags, redirection->flags, length, redirection->sessionID);
#ifdef WITH_DEBUG_REDIR
rdp_print_redirection_flags(redirection->flags);
#endif
@ -218,7 +225,7 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s)
Stream_Read(s, redirection->LoadBalanceInfo, redirection->LoadBalanceInfoLength);
#ifdef WITH_DEBUG_REDIR
DEBUG_REDIR("loadBalanceInfo:");
winpr_HexDump(redirection->LoadBalanceInfo, redirection->LoadBalanceInfoLength);
winpr_HexDump(TAG, WLOG_DEBUG, redirection->LoadBalanceInfo, redirection->LoadBalanceInfoLength);
#endif
}
@ -247,10 +254,9 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s)
Stream_Read_UINT32(s, redirection->PasswordLength);
redirection->Password = (BYTE*) malloc(redirection->PasswordLength);
Stream_Read(s, redirection->Password, redirection->PasswordLength);
#ifdef WITH_DEBUG_REDIR
DEBUG_REDIR("PasswordCookie:");
winpr_HexDump(redirection->Password, redirection->PasswordLength);
winpr_HexDump(TAG, WLOG_DEBUG, redirection->Password, redirection->PasswordLength);
#endif
}
@ -282,10 +288,9 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s)
redirection->TsvUrl = (BYTE*) malloc(redirection->TsvUrlLength);
Stream_Read(s, redirection->TsvUrl, redirection->TsvUrlLength);
#ifdef WITH_DEBUG_REDIR
DEBUG_REDIR("TsvUrl:");
winpr_HexDump(redirection->TsvUrl, redirection->TsvUrlLength);
winpr_HexDump(TAG, WLOG_DEBUG, redirection->TsvUrl, redirection->TsvUrlLength);
#endif
}
@ -299,13 +304,10 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s)
return -1;
Stream_Read_UINT32(s, targetNetAddressesLength);
Stream_Read_UINT32(s, redirection->TargetNetAddressesCount);
count = redirection->TargetNetAddressesCount;
redirection->TargetNetAddresses = (char**) malloc(count * sizeof(char*));
ZeroMemory(redirection->TargetNetAddresses, count * sizeof(char*));
WLog_Print(redirection->log, WLOG_DEBUG, "TargetNetAddressesCount: %d", redirection->TargetNetAddressesCount);
for (i = 0; i < (int) count; i++)
@ -354,14 +356,12 @@ int rdp_recv_enhanced_security_redirection_packet(rdpRdp* rdp, wStream* s)
rdpRedirection* redirection_new()
{
rdpRedirection* redirection;
redirection = (rdpRedirection*) calloc(1, sizeof(rdpRedirection));
if (redirection)
{
WLog_Init();
redirection->log = WLog_Get("com.freerdp.core.redirection");
#ifdef WITH_DEBUG_REDIR
WLog_SetLogLevel(redirection->log, WLOG_TRACE);
#endif

View File

@ -31,6 +31,7 @@
#include <winpr/print.h>
#include <winpr/stream.h>
#include <freerdp/log.h>
#include <freerdp/error.h>
#include <freerdp/utils/tcp.h>
#include <freerdp/utils/ringbuffer.h>
@ -54,6 +55,7 @@
#include "transport.h"
#include "rdp.h"
#define TAG FREERDP_TAG("core")
#define BUFFER_SIZE 16384
@ -62,12 +64,9 @@ static void* transport_client_thread(void* arg);
wStream* transport_send_stream_init(rdpTransport* transport, int size)
{
wStream* s;
s = StreamPool_Take(transport->ReceivePool, size);
Stream_EnsureCapacity(s, size);
Stream_SetPosition(s, 0);
return s;
}
@ -87,10 +86,8 @@ void transport_stop(rdpTransport* transport)
{
SetEvent(transport->stopEvent);
WaitForSingleObject(transport->thread, INFINITE);
CloseHandle(transport->thread);
CloseHandle(transport->stopEvent);
transport->thread = NULL;
transport->stopEvent = NULL;
}
@ -105,9 +102,7 @@ BOOL transport_disconnect(rdpTransport* transport)
return FALSE;
transport_stop(transport);
BIO_free_all(transport->frontBio);
transport->frontBio = 0;
return status;
}
@ -115,7 +110,6 @@ BOOL transport_disconnect(rdpTransport* transport)
BOOL transport_connect_rdp(rdpTransport* transport)
{
/* RDP encryption */
return TRUE;
}
@ -128,11 +122,8 @@ static int transport_bio_tsg_write(BIO* bio, const char* buf, int num)
{
int status;
rdpTsg* tsg;
tsg = (rdpTsg*) bio->ptr;
BIO_clear_flags(bio, BIO_FLAGS_WRITE);
status = tsg_write(tsg, (BYTE*) buf, num);
if (status < 0)
@ -151,11 +142,8 @@ static int transport_bio_tsg_read(BIO* bio, char* buf, int size)
{
int status;
rdpTsg* tsg;
tsg = (rdpTsg*) bio->ptr;
BIO_clear_flags(bio, BIO_FLAGS_READ);
status = tsg_read(bio->ptr, (BYTE*) buf, size);
if (status < 0)
@ -227,13 +215,12 @@ BIO_METHOD* BIO_s_tsg(void)
BOOL transport_connect_tls(rdpTransport* transport)
{
rdpSettings *settings = transport->settings;
rdpTls *targetTls;
BIO *targetBio;
rdpSettings* settings = transport->settings;
rdpTls* targetTls;
BIO* targetBio;
int tls_status;
freerdp* instance;
rdpContext* context;
instance = (freerdp*) transport->settings->instance;
context = instance->context;
@ -241,7 +228,6 @@ BOOL transport_connect_tls(rdpTransport* transport)
{
transport->TsgTls = tls_new(transport->settings);
transport->layer = TRANSPORT_LAYER_TSG_TLS;
targetTls = transport->TsgTls;
targetBio = transport->frontBio;
}
@ -255,11 +241,9 @@ BOOL transport_connect_tls(rdpTransport* transport)
targetTls = transport->TlsIn;
targetBio = transport->TcpIn->bufferedBio;
transport->layer = TRANSPORT_LAYER_TLS;
}
targetTls->hostname = settings->ServerHostname;
targetTls->port = settings->ServerPort;
@ -267,7 +251,6 @@ BOOL transport_connect_tls(rdpTransport* transport)
targetTls->port = 3389;
targetTls->isGatewayTransport = FALSE;
tls_status = tls_connect(targetTls, targetBio);
if (tls_status < 1)
@ -290,9 +273,10 @@ BOOL transport_connect_tls(rdpTransport* transport)
}
transport->frontBio = targetTls->bio;
if (!transport->frontBio)
{
DEBUG_WARN( "%s: unable to prepend a filtering TLS bio", __FUNCTION__);
DEBUG_WARN("%s: unable to prepend a filtering TLS bio", __FUNCTION__);
return FALSE;
}
@ -303,8 +287,7 @@ BOOL transport_connect_nla(rdpTransport* transport)
{
freerdp* instance;
rdpSettings* settings;
rdpCredssp *credSsp;
rdpCredssp* credSsp;
settings = transport->settings;
instance = (freerdp*) settings->instance;
@ -319,6 +302,7 @@ BOOL transport_connect_nla(rdpTransport* transport)
if (!transport->credssp)
{
transport->credssp = credssp_new(instance, transport, settings);
if (!transport->credssp)
return FALSE;
@ -328,12 +312,14 @@ BOOL transport_connect_nla(rdpTransport* transport)
{
transport->credssp->ServicePrincipalName =
credssp_make_spn(settings->AuthenticationServiceClass, settings->ServerHostname);
if (!transport->credssp->ServicePrincipalName)
return FALSE;
}
}
credSsp = transport->credssp;
if (credssp_authenticate(credSsp) < 0)
{
if (!connectErrorCode)
@ -344,20 +330,17 @@ BOOL transport_connect_nla(rdpTransport* transport)
freerdp_set_last_error(instance->context, FREERDP_ERROR_AUTHENTICATION_FAILED);
}
DEBUG_WARN( "Authentication failure, check credentials.\n"
"If credentials are valid, the NTLMSSP implementation may be to blame.\n");
DEBUG_WARN("Authentication failure, check credentials.\n"
"If credentials are valid, the NTLMSSP implementation may be to blame.\n");
transport_set_nla_mode(transport, FALSE);
credssp_free(credSsp);
transport->credssp = NULL;
return FALSE;
}
transport_set_nla_mode(transport, FALSE);
credssp_free(credSsp);
transport->credssp = NULL;
return TRUE;
}
@ -367,11 +350,9 @@ BOOL transport_tsg_connect(rdpTransport* transport, const char* hostname, UINT16
int tls_status;
freerdp* instance;
rdpContext* context;
rdpSettings *settings = transport->settings;
rdpSettings* settings = transport->settings;
instance = (freerdp*) transport->settings->instance;
context = instance->context;
tsg = tsg_new(transport);
if (!tsg)
@ -403,9 +384,7 @@ BOOL transport_tsg_connect(rdpTransport* transport, const char* hostname, UINT16
transport->TlsIn->hostname = transport->TlsOut->hostname = settings->GatewayHostname;
transport->TlsIn->port = transport->TlsOut->port = settings->GatewayPort;
transport->TlsIn->isGatewayTransport = TRUE;
tls_status = tls_connect(transport->TlsIn, transport->TcpIn->bufferedBio);
if (tls_status < 1)
@ -425,7 +404,6 @@ BOOL transport_tsg_connect(rdpTransport* transport, const char* hostname, UINT16
}
transport->TlsOut->isGatewayTransport = TRUE;
tls_status = tls_connect(transport->TlsOut, transport->TcpOut->bufferedBio);
if (tls_status < 1)
@ -449,7 +427,6 @@ BOOL transport_tsg_connect(rdpTransport* transport, const char* hostname, UINT16
transport->frontBio = BIO_new(BIO_s_tsg());
transport->frontBio->ptr = tsg;
return TRUE;
}
@ -457,7 +434,6 @@ BOOL transport_connect(rdpTransport* transport, const char* hostname, UINT16 por
{
BOOL status = FALSE;
rdpSettings* settings = transport->settings;
transport->async = settings->AsyncTransport;
if (transport->GatewayEnabled)
@ -482,7 +458,6 @@ BOOL transport_connect(rdpTransport* transport, const char* hostname, UINT16 por
else
{
status = tcp_connect(transport->TcpIn, hostname, port, timeout);
transport->SplitInputOutput = FALSE;
transport->TcpOut = transport->TcpIn;
transport->frontBio = transport->TcpIn->bufferedBio;
@ -493,9 +468,8 @@ BOOL transport_connect(rdpTransport* transport, const char* hostname, UINT16 por
if (transport->async)
{
transport->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
transport->thread = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE) transport_client_thread, transport, 0, NULL);
(LPTHREAD_START_ROUTINE) transport_client_thread, transport, 0, NULL);
}
}
@ -505,7 +479,6 @@ BOOL transport_connect(rdpTransport* transport, const char* hostname, UINT16 por
BOOL transport_accept_rdp(rdpTransport* transport)
{
/* RDP encryption */
return TRUE;
}
@ -530,7 +503,6 @@ BOOL transport_accept_nla(rdpTransport* transport)
{
freerdp* instance;
rdpSettings* settings;
settings = transport->settings;
instance = (freerdp*) settings->instance;
@ -544,6 +516,7 @@ BOOL transport_accept_nla(rdpTransport* transport)
if (!tls_accept(transport->TlsIn, transport->TcpIn->bufferedBio, settings->CertificateFile, settings->PrivateKeyFile))
return FALSE;
transport->frontBio = transport->TlsIn->bio;
/* Network Level Authentication */
@ -559,26 +532,22 @@ BOOL transport_accept_nla(rdpTransport* transport)
if (credssp_authenticate(transport->credssp) < 0)
{
DEBUG_WARN( "client authentication failure\n");
DEBUG_WARN("client authentication failure\n");
transport_set_nla_mode(transport, FALSE);
credssp_free(transport->credssp);
transport->credssp = NULL;
tls_set_alert_code(transport->TlsIn, TLS_ALERT_LEVEL_FATAL, TLS_ALERT_DESCRIPTION_ACCESS_DENIED);
return FALSE;
}
/* don't free credssp module yet, we need to copy the credentials from it first */
transport_set_nla_mode(transport, FALSE);
return TRUE;
}
static int transport_wait_for_read(rdpTransport* transport)
{
rdpTcp *tcpIn = transport->TcpIn;
rdpTcp* tcpIn = transport->TcpIn;
if (tcpIn->readBlocked)
{
@ -595,9 +564,9 @@ static int transport_wait_for_read(rdpTransport* transport)
static int transport_wait_for_write(rdpTransport* transport)
{
rdpTcp *tcpOut;
rdpTcp* tcpOut;
tcpOut = transport->SplitInputOutput ? transport->TcpOut : transport->TcpIn;
if (tcpOut->writeBlocked)
{
return tcp_wait_write(tcpOut, 10);
@ -643,16 +612,16 @@ int transport_read_layer(rdpTransport* transport, BYTE* data, int bytes)
* requested bytes */
if (transport_wait_for_read(transport) < 0)
{
DEBUG_WARN( "%s: error when selecting for read\n", __FUNCTION__);
DEBUG_WARN("%s: error when selecting for read\n", __FUNCTION__);
return -1;
}
continue;
}
#ifdef HAVE_VALGRIND_MEMCHECK_H
VALGRIND_MAKE_MEM_DEFINED(data + read, bytes - read);
#endif
read += status;
}
@ -678,6 +647,7 @@ static int transport_read_layer_bytes(rdpTransport* transport, wStream* s, unsig
{
int status;
status = transport_read_layer(transport, Stream_Pointer(s), toRead);
if (status <= 0)
return status;
@ -702,8 +672,7 @@ int transport_read_pdu(rdpTransport* transport, wStream* s)
int status;
int position;
int pduLength;
BYTE *header;
BYTE* header;
position = 0;
pduLength = 0;
@ -714,7 +683,6 @@ int transport_read_pdu(rdpTransport* transport, wStream* s)
return -1;
position = Stream_GetPosition(s);
/* Make sure there is enough space for the longest header within the stream */
Stream_EnsureCapacity(s, 4);
@ -744,6 +712,7 @@ int transport_read_pdu(rdpTransport* transport, wStream* s)
{
if ((status = transport_read_layer_bytes(transport, s, 1)) != 1)
return status;
pduLength = header[2];
pduLength += 3;
}
@ -751,12 +720,13 @@ int transport_read_pdu(rdpTransport* transport, wStream* s)
{
if ((status = transport_read_layer_bytes(transport, s, 2)) != 1)
return status;
pduLength = (header[2] << 8) | header[3];
pduLength += 4;
}
else
{
DEBUG_WARN( "Error reading TSRequest!\n");
DEBUG_WARN("Error reading TSRequest!\n");
return -1;
}
}
@ -780,7 +750,7 @@ int transport_read_pdu(rdpTransport* transport, wStream* s)
/* min and max values according to ITU-T Rec. T.123 (01/2007) section 8 */
if (pduLength < 7 || pduLength > 0xFFFF)
{
DEBUG_WARN( "%s: tpkt - invalid pduLength: %d\n", __FUNCTION__, pduLength);
DEBUG_WARN("%s: tpkt - invalid pduLength: %d\n", __FUNCTION__, pduLength);
return -1;
}
}
@ -791,6 +761,7 @@ int transport_read_pdu(rdpTransport* transport, wStream* s)
{
if ((status = transport_read_layer_bytes(transport, s, 1)) != 1)
return status;
pduLength = ((header[1] & 0x7F) << 8) | header[2];
}
else
@ -803,27 +774,27 @@ int transport_read_pdu(rdpTransport* transport, wStream* s)
*/
if (pduLength < 3 || pduLength > 0x8000)
{
DEBUG_WARN( "%s: fast path - invalid pduLength: %d\n", __FUNCTION__, pduLength);
DEBUG_WARN("%s: fast path - invalid pduLength: %d\n", __FUNCTION__, pduLength);
return -1;
}
}
}
Stream_EnsureCapacity(s, Stream_GetPosition(s) + pduLength);
status = transport_read_layer_bytes(transport, s, pduLength - Stream_GetPosition(s));
if (status != 1)
return status;
#ifdef WITH_DEBUG_TRANSPORT
/* dump when whole PDU is read */
if (Stream_GetPosition(s) >= pduLength)
{
DEBUG_WARN( "Local < Remote\n");
winpr_HexDump(Stream_Buffer(s), pduLength);
DEBUG_WARN("Local < Remote\n");
winpr_HexDump(TAG, WLOG_DEBUG, Stream_Buffer(s), pduLength);
}
#endif
if (Stream_GetPosition(s) >= pduLength)
@ -834,24 +805,23 @@ int transport_read_pdu(rdpTransport* transport, wStream* s)
return Stream_Length(s);
}
BOOL transport_bio_buffered_drain(BIO *bio);
BOOL transport_bio_buffered_drain(BIO* bio);
int transport_write(rdpTransport* transport, wStream* s)
{
int length;
int status = -1;
EnterCriticalSection(&(transport->WriteLock));
length = Stream_GetPosition(s);
Stream_SetPosition(s, 0);
#ifdef WITH_DEBUG_TRANSPORT
if (length > 0)
{
DEBUG_WARN( "Local > Remote\n");
winpr_HexDump(Stream_Buffer(s), length);
DEBUG_WARN("Local > Remote\n");
winpr_HexDump(TAG, WLOG_DEBUG, Stream_Buffer(s), length);
}
#endif
if (length > 0)
@ -878,28 +848,29 @@ int transport_write(rdpTransport* transport, wStream* s)
if (transport_wait_for_write(transport) < 0)
{
DEBUG_WARN( "%s: error when selecting for write\n", __FUNCTION__);
DEBUG_WARN("%s: error when selecting for write\n", __FUNCTION__);
return -1;
}
continue;
}
if (transport->blocking || transport->settings->WaitForOutputBufferFlush)
{
/* blocking transport, we must ensure the write buffer is really empty */
rdpTcp *out = transport->TcpOut;
rdpTcp* out = transport->TcpOut;
while (out->writeBlocked)
{
if (transport_wait_for_write(transport) < 0)
{
DEBUG_WARN( "%s: error when selecting for write\n", __FUNCTION__);
DEBUG_WARN("%s: error when selecting for write\n", __FUNCTION__);
return -1;
}
if (!transport_bio_buffered_drain(out->bufferedBio))
{
DEBUG_WARN( "%s: error when draining outputBuffer\n", __FUNCTION__);
DEBUG_WARN("%s: error when draining outputBuffer\n", __FUNCTION__);
return -1;
}
}
@ -919,14 +890,12 @@ int transport_write(rdpTransport* transport, wStream* s)
Stream_Release(s);
LeaveCriticalSection(&(transport->WriteLock));
return status;
}
void transport_get_fds(rdpTransport* transport, void** rfds, int* rcount)
{
void* pfd;
#ifdef _WIN32
rfds[*rcount] = transport->TcpIn->event;
(*rcount)++;
@ -936,6 +905,7 @@ void transport_get_fds(rdpTransport* transport, void** rfds, int* rcount)
rfds[*rcount] = transport->TcpOut->event;
(*rcount)++;
}
#else
rfds[*rcount] = (void*)(long)(transport->TcpIn->sockfd);
(*rcount)++;
@ -945,8 +915,8 @@ void transport_get_fds(rdpTransport* transport, void** rfds, int* rcount)
rfds[*rcount] = (void*)(long)(transport->TcpOut->sockfd);
(*rcount)++;
}
#endif
#endif
pfd = GetEventWaitObject(transport->ReceiveEvent);
if (pfd)
@ -997,8 +967,8 @@ BOOL tranport_is_write_blocked(rdpTransport* transport)
return TRUE;
return transport->SplitInputOutput &&
transport->TcpOut &&
transport->TcpOut->writeBlocked;
transport->TcpOut &&
transport->TcpOut->writeBlocked;
}
int tranport_drain_output_buffer(rdpTransport* transport)
@ -1010,6 +980,7 @@ int tranport_drain_output_buffer(rdpTransport* transport)
{
if (!transport_bio_buffered_drain(transport->TcpIn->bufferedBio))
return -1;
ret |= transport->TcpIn->writeBlocked;
}
@ -1017,6 +988,7 @@ int tranport_drain_output_buffer(rdpTransport* transport)
{
if (!transport_bio_buffered_drain(transport->TcpOut->bufferedBio))
return -1;
ret |= transport->TcpOut->writeBlocked;
}
@ -1055,7 +1027,6 @@ int transport_check_fds(rdpTransport* transport)
* Note that transport->ReceiveBuffer is replaced after each iteration
* of this loop with a fresh stream instance from a pool.
*/
if ((status = transport_read_pdu(transport, transport->ReceiveBuffer)) <= 0)
{
return status;
@ -1069,13 +1040,13 @@ int transport_check_fds(rdpTransport* transport)
* 0: success
* 1: redirection
*/
recv_status = transport->ReceiveCallback(transport, received, transport->ReceiveExtra);
if (recv_status == 1)
{
return 1; /* session redirection */
}
Stream_Release(received);
if (recv_status < 0)
@ -1088,7 +1059,6 @@ int transport_check_fds(rdpTransport* transport)
BOOL transport_set_blocking_mode(rdpTransport* transport, BOOL blocking)
{
BOOL status;
status = TRUE;
transport->blocking = blocking;
@ -1128,25 +1098,19 @@ static void* transport_client_thread(void* arg)
freerdp* instance;
rdpContext* context;
rdpTransport* transport;
transport = (rdpTransport*) arg;
assert(NULL != transport);
assert(NULL != transport->settings);
instance = (freerdp*) transport->settings->instance;
assert(NULL != instance);
context = instance->context;
assert(NULL != instance->context);
WLog_Print(transport->log, WLOG_DEBUG, "Starting transport thread");
nCount = 0;
handles[nCount++] = transport->stopEvent;
handles[nCount++] = transport->connectedEvent;
status = WaitForMultipleObjects(nCount, handles, FALSE, INFINITE);
if (WaitForSingleObject(transport->stopEvent, 0) == WAIT_OBJECT_0)
{
WLog_Print(transport->log, WLOG_DEBUG, "Terminating transport thread");
@ -1160,9 +1124,7 @@ static void* transport_client_thread(void* arg)
{
nCount = 0;
handles[nCount++] = transport->stopEvent;
transport_get_read_handles(transport, (HANDLE*) &handles, &nCount);
status = WaitForMultipleObjects(nCount, handles, FALSE, INFINITE);
if (transport->layer == TRANSPORT_LAYER_CLOSED)
@ -1178,13 +1140,11 @@ static void* transport_client_thread(void* arg)
if (!freerdp_check_fds(instance))
{
}
}
}
WLog_Print(transport->log, WLOG_DEBUG, "Terminating transport thread");
ExitThread(0);
return NULL;
}
@ -1192,39 +1152,43 @@ static void* transport_client_thread(void* arg)
rdpTransport* transport_new(rdpSettings* settings)
{
rdpTransport* transport;
transport = (rdpTransport*)calloc(1, sizeof(rdpTransport));
transport = (rdpTransport *)calloc(1, sizeof(rdpTransport));
if (!transport)
return NULL;
WLog_Init();
transport->log = WLog_Get("com.freerdp.core.transport");
if (!transport->log)
goto out_free;
transport->TcpIn = tcp_new(settings);
if (!transport->TcpIn)
goto out_free;
transport->settings = settings;
/* a small 0.1ms delay when transport is blocking. */
transport->SleepInterval = 100;
transport->ReceivePool = StreamPool_New(TRUE, BUFFER_SIZE);
if (!transport->ReceivePool)
goto out_free_tcpin;
/* receive buffer for non-blocking read. */
transport->ReceiveBuffer = StreamPool_Take(transport->ReceivePool, 0);
if (!transport->ReceiveBuffer)
goto out_free_receivepool;
transport->ReceiveEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (!transport->ReceiveEvent || transport->ReceiveEvent == INVALID_HANDLE_VALUE)
goto out_free_receivebuffer;
transport->connectedEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (!transport->connectedEvent || transport->connectedEvent == INVALID_HANDLE_VALUE)
goto out_free_receiveEvent;
@ -1234,11 +1198,11 @@ rdpTransport* transport_new(rdpSettings* settings)
if (!InitializeCriticalSectionAndSpinCount(&(transport->ReadLock), 4000))
goto out_free_connectedEvent;
if (!InitializeCriticalSectionAndSpinCount(&(transport->WriteLock), 4000))
goto out_free_readlock;
return transport;
out_free_readlock:
DeleteCriticalSection(&(transport->ReadLock));
out_free_connectedEvent:
@ -1267,7 +1231,6 @@ void transport_free(rdpTransport* transport)
Stream_Release(transport->ReceiveBuffer);
StreamPool_Free(transport->ReceivePool);
CloseHandle(transport->ReceiveEvent);
CloseHandle(transport->connectedEvent);
@ -1288,12 +1251,9 @@ void transport_free(rdpTransport* transport)
transport->TcpIn = NULL;
transport->TcpOut = NULL;
tsg_free(transport->tsg);
transport->tsg = NULL;
DeleteCriticalSection(&(transport->ReadLock));
DeleteCriticalSection(&(transport->WriteLock));
free(transport);
}

View File

@ -29,8 +29,11 @@
#include "librail.h"
#include <freerdp/log.h>
#include <freerdp/rail/window.h>
#define TAG FREERDP_TAG("rail")
struct _WINDOW_STYLE
{
UINT32 style;
@ -99,8 +102,8 @@ static const WINDOW_STYLE EXTENDED_WINDOW_STYLES[] =
void print_window_styles(UINT32 style)
{
int i;
DEBUG_WARN("Window Styles:\n{\n");
DEBUG_WARN( "Window Styles:\n{\n");
for (i = 0; i < ARRAYSIZE(WINDOW_STYLES); i++)
{
if (style & WINDOW_STYLES[i].style)
@ -108,20 +111,21 @@ void print_window_styles(UINT32 style)
if (WINDOW_STYLES[i].multi)
{
if ((style & WINDOW_STYLES[i].style) != WINDOW_STYLES[i].style)
continue;
continue;
}
DEBUG_WARN( "\t%s\n", WINDOW_STYLES[i].name);
DEBUG_WARN("\t%s\n", WINDOW_STYLES[i].name);
}
}
DEBUG_WARN( "}\n");
DEBUG_WARN("}\n");
}
void print_extended_window_styles(UINT32 style)
{
int i;
DEBUG_WARN("Extended Window Styles:\n{\n");
DEBUG_WARN( "Extended Window Styles:\n{\n");
for (i = 0; i < ARRAYSIZE(EXTENDED_WINDOW_STYLES); i++)
{
if (style & EXTENDED_WINDOW_STYLES[i].style)
@ -129,13 +133,14 @@ void print_extended_window_styles(UINT32 style)
if (EXTENDED_WINDOW_STYLES[i].multi)
{
if ((style & EXTENDED_WINDOW_STYLES[i].style) != EXTENDED_WINDOW_STYLES[i].style)
continue;
continue;
}
DEBUG_WARN( "\t%s\n", EXTENDED_WINDOW_STYLES[i].name);
DEBUG_WARN("\t%s\n", EXTENDED_WINDOW_STYLES[i].name);
}
}
DEBUG_WARN( "}\n");
DEBUG_WARN("}\n");
}
void window_state_update(rdpWindow* window, WINDOW_ORDER_INFO* orderInfo, WINDOW_STATE_ORDER* window_state)
@ -149,13 +154,12 @@ void window_state_update(rdpWindow* window, WINDOW_ORDER_INFO* orderInfo, WINDOW
}
DEBUG_RAIL("windowId=0x%X ownerWindowId=0x%X",
window->windowId, window->ownerWindowId);
window->windowId, window->ownerWindowId);
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_STYLE)
{
window->style = window_state->style;
window->extendedStyle = window_state->extendedStyle;
#ifdef WITH_DEBUG_RAIL
print_window_styles(window->style);
print_extended_window_styles(window->extendedStyle);
@ -173,9 +177,8 @@ void window_state_update(rdpWindow* window, WINDOW_ORDER_INFO* orderInfo, WINDOW
window->titleInfo.length = window_state->titleInfo.length;
window->titleInfo.string = malloc(window_state->titleInfo.length);
memcpy(window->titleInfo.string, window_state->titleInfo.string, window->titleInfo.length);
#ifdef WITH_DEBUG_RAIL
winpr_HexDump(window->titleInfo.string, window->titleInfo.length);
winpr_HexDump(TAG, WLOG_DEBUG, window->titleInfo.string, window->titleInfo.length);
#endif
}
@ -183,18 +186,16 @@ void window_state_update(rdpWindow* window, WINDOW_ORDER_INFO* orderInfo, WINDOW
{
window->clientOffsetX = window_state->clientOffsetX;
window->clientOffsetY = window_state->clientOffsetY;
DEBUG_RAIL("Client Area Offset: (%d, %d)",
window->clientOffsetX, window->clientOffsetY);
window->clientOffsetX, window->clientOffsetY);
}
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE)
{
window->clientAreaWidth = window_state->clientAreaWidth;
window->clientAreaHeight = window_state->clientAreaHeight;
DEBUG_RAIL("Client Area Size: (%d, %d)",
window->clientAreaWidth, window->clientAreaHeight);
window->clientAreaWidth, window->clientAreaHeight);
}
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_RP_CONTENT)
@ -211,27 +212,24 @@ void window_state_update(rdpWindow* window, WINDOW_ORDER_INFO* orderInfo, WINDOW
{
window->windowOffsetX = window_state->windowOffsetX;
window->windowOffsetY = window_state->windowOffsetY;
DEBUG_RAIL("Window Offset: (%d, %d)",
window->windowOffsetX, window->windowOffsetY);
window->windowOffsetX, window->windowOffsetY);
}
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA)
{
window->windowClientDeltaX = window_state->windowClientDeltaX;
window->windowClientDeltaY = window_state->windowClientDeltaY;
DEBUG_RAIL("Window Client Delta: (%d, %d)",
window->windowClientDeltaX, window->windowClientDeltaY);
window->windowClientDeltaX, window->windowClientDeltaY);
}
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE)
{
window->windowWidth = window_state->windowWidth;
window->windowHeight = window_state->windowHeight;
DEBUG_RAIL("Window Size: (%d, %d)",
window->windowWidth, window->windowHeight);
window->windowWidth, window->windowHeight);
}
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS)
@ -247,8 +245,8 @@ void window_state_update(rdpWindow* window, WINDOW_ORDER_INFO* orderInfo, WINDOW
for (i = 0; i < (int) window_state->numWindowRects; i++)
{
DEBUG_RAIL("Window Rect #%d: left:%d top:%d right:%d bottom:%d", i,
window_state->windowRects[i].left, window_state->windowRects[i].top,
window_state->windowRects[i].right, window_state->windowRects[i].bottom);
window_state->windowRects[i].left, window_state->windowRects[i].top,
window_state->windowRects[i].right, window_state->windowRects[i].bottom);
}
}
@ -256,9 +254,8 @@ void window_state_update(rdpWindow* window, WINDOW_ORDER_INFO* orderInfo, WINDOW
{
window->visibleOffsetX = window_state->visibleOffsetX;
window->visibleOffsetY = window_state->visibleOffsetY;
DEBUG_RAIL("Window Visible Offset: (%d, %d)",
window->visibleOffsetX, window->visibleOffsetY);
window->visibleOffsetX, window->visibleOffsetY);
}
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY)
@ -274,8 +271,8 @@ void window_state_update(rdpWindow* window, WINDOW_ORDER_INFO* orderInfo, WINDOW
for (i = 0; i < (int) window_state->numVisibilityRects; i++)
{
DEBUG_RAIL("Visibility Rect #%d: left:%d top:%d right:%d bottom:%d", i,
window_state->visibilityRects[i].left, window_state->visibilityRects[i].top,
window_state->visibilityRects[i].right, window_state->visibilityRects[i].bottom);
window_state->visibilityRects[i].left, window_state->visibilityRects[i].top,
window_state->visibilityRects[i].right, window_state->visibilityRects[i].bottom);
}
}
}
@ -285,7 +282,7 @@ void rail_CreateWindow(rdpRail* rail, rdpWindow* window)
if (window->titleInfo.length > 0)
{
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) window->titleInfo.string, window->titleInfo.length / 2,
&window->title, 0, NULL, NULL);
&window->title, 0, NULL, NULL);
}
else
{
@ -299,6 +296,7 @@ void rail_CreateWindow(rdpRail* rail, rdpWindow* window)
{
IFCALL(rail->rail_SetWindowRects, rail, window);
}
if (window->fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY)
{
IFCALL(rail->rail_SetWindowVisibilityRects, rail, window);
@ -309,12 +307,10 @@ void rail_UpdateWindow(rdpRail* rail, rdpWindow* window)
{
if (window->fieldFlags & WINDOW_ORDER_FIELD_OWNER)
{
}
if (window->fieldFlags & WINDOW_ORDER_FIELD_STYLE)
{
}
if (window->fieldFlags & WINDOW_ORDER_FIELD_SHOW)
@ -331,29 +327,24 @@ void rail_UpdateWindow(rdpRail* rail, rdpWindow* window)
}
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) window->titleInfo.string, window->titleInfo.length / 2,
&window->title, 0, NULL, NULL);
&window->title, 0, NULL, NULL);
IFCALL(rail->rail_SetWindowText, rail, window);
}
if (window->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET)
{
}
if (window->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE)
{
}
if (window->fieldFlags & WINDOW_ORDER_FIELD_RP_CONTENT)
{
}
if (window->fieldFlags & WINDOW_ORDER_FIELD_ROOT_PARENT)
{
}
if ((window->fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET) ||
@ -364,7 +355,6 @@ void rail_UpdateWindow(rdpRail* rail, rdpWindow* window)
if (window->fieldFlags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA)
{
}
if (window->fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS)
@ -374,7 +364,6 @@ void rail_UpdateWindow(rdpRail* rail, rdpWindow* window)
if (window->fieldFlags & WINDOW_ORDER_FIELD_VIS_OFFSET)
{
}
if (window->fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY)