channels/cliprdr: fix unicode conversion

This commit is contained in:
Marc-André Moreau 2013-08-19 12:21:40 -04:00
parent 23a8354656
commit 73c02a7637
2 changed files with 29 additions and 7 deletions

View File

@ -249,6 +249,8 @@ static int cliprdr_server_receive_long_format_list(CliprdrServerContext* context
int length; int length;
int position; int position;
printf("%s\n", __FUNCTION__);
position = Stream_GetPosition(s); position = Stream_GetPosition(s);
Stream_SetPosition(s, Stream_Length(s)); Stream_SetPosition(s, Stream_Length(s));
end = (WCHAR*) Stream_Pointer(s); end = (WCHAR*) Stream_Pointer(s);
@ -281,17 +283,29 @@ static int cliprdr_server_receive_long_format_list(CliprdrServerContext* context
{ {
Stream_Read_UINT32(s, context->priv->ClientFormatNames[i].id); /* formatId (4 bytes) */ Stream_Read_UINT32(s, context->priv->ClientFormatNames[i].id); /* formatId (4 bytes) */
context->priv->ClientFormatNames[i].length = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), length = cliprdr_wcslen((WCHAR*) Stream_Pointer(s), end);
-1, &context->priv->ClientFormatNames[i].name, 0, NULL, NULL);
Stream_Seek(s, (context->priv->ClientFormatNames[i].length + 1) * 2); context->priv->ClientFormatNames[i].name = NULL;
if (length)
{
context->priv->ClientFormatNames[i].length = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s),
-1, &(context->priv->ClientFormatNames[i].name), 0, NULL, NULL) - 1;
}
else
{
context->priv->ClientFormatNames[i].length = 0;
}
Stream_Seek(s, (length + 1) * 2); /* wszFormatName */
} }
for (i = 0; i < context->priv->ClientFormatNameCount; i++) for (i = 0; i < context->priv->ClientFormatNameCount; i++)
{ {
printf("Format %d: Id: 0x%04X Name: %s\n", i, printf("Format %d: Id: 0x%04X Name: %s Length: %d\n", i,
context->priv->ClientFormatNames[i].id, context->priv->ClientFormatNames[i].id,
context->priv->ClientFormatNames[i].name); context->priv->ClientFormatNames[i].name,
context->priv->ClientFormatNames[i].length);
} }
return 0; return 0;

View File

@ -90,6 +90,12 @@ static int rdpdr_server_receive_client_name_request(RdpdrServerContext* context,
* not in characters, including the NULL terminator! * not in characters, including the NULL terminator!
*/ */
if (context->priv->ClientComputerName)
{
free(context->priv->ClientComputerName);
context->priv->ClientComputerName = NULL;
}
if (UnicodeFlag) if (UnicodeFlag)
{ {
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s),
@ -579,6 +585,8 @@ static void* rdpdr_server_thread(void* arg)
while (1) while (1)
{ {
BytesReturned = 0;
status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE); status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE);
if (WaitForSingleObject(context->priv->StopEvent, 0) == WAIT_OBJECT_0) if (WaitForSingleObject(context->priv->StopEvent, 0) == WAIT_OBJECT_0)
@ -586,8 +594,8 @@ static void* rdpdr_server_thread(void* arg)
break; break;
} }
if (WTSVirtualChannelRead(context->priv->ChannelHandle, 0, if (WTSVirtualChannelRead(context->priv->ChannelHandle, 0, Stream_Pointer(s),
Stream_Buffer(s), Stream_Capacity(s), &BytesReturned)) Stream_Capacity(s) - Stream_GetPosition(s), &BytesReturned))
{ {
if (BytesReturned) if (BytesReturned)
Stream_Seek(s, BytesReturned); Stream_Seek(s, BytesReturned);