int length;
int position;
+ printf("%s\n", __FUNCTION__);
+
position = Stream_GetPosition(s);
Stream_SetPosition(s, Stream_Length(s));
end = (WCHAR*) Stream_Pointer(s);
{
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);
+
+ 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, (context->priv->ClientFormatNames[i].length + 1) * 2);
+ 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;
* 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),
while (1)
{
+ BytesReturned = 0;
+
status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE);
if (WaitForSingleObject(context->priv->StopEvent, 0) == WAIT_OBJECT_0)
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);