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 position;
printf("%s\n", __FUNCTION__);
position = Stream_GetPosition(s);
Stream_SetPosition(s, Stream_Length(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) */
context->priv->ClientFormatNames[i].length = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s),
-1, &context->priv->ClientFormatNames[i].name, 0, NULL, NULL);
length = cliprdr_wcslen((WCHAR*) Stream_Pointer(s), end);
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++)
{
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].name);
context->priv->ClientFormatNames[i].name,
context->priv->ClientFormatNames[i].length);
}
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!
*/
if (context->priv->ClientComputerName)
{
free(context->priv->ClientComputerName);
context->priv->ClientComputerName = NULL;
}
if (UnicodeFlag)
{
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s),
@ -579,6 +585,8 @@ static void* rdpdr_server_thread(void* arg)
while (1)
{
BytesReturned = 0;
status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE);
if (WaitForSingleObject(context->priv->StopEvent, 0) == WAIT_OBJECT_0)
@ -586,8 +594,8 @@ static void* rdpdr_server_thread(void* arg)
break;
}
if (WTSVirtualChannelRead(context->priv->ChannelHandle, 0,
Stream_Buffer(s), Stream_Capacity(s), &BytesReturned))
if (WTSVirtualChannelRead(context->priv->ChannelHandle, 0, Stream_Pointer(s),
Stream_Capacity(s) - Stream_GetPosition(s), &BytesReturned))
{
if (BytesReturned)
Stream_Seek(s, BytesReturned);