2013-05-09 07:18:42 +04:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
|
|
* Input Virtual Channel Extension
|
|
|
|
*
|
|
|
|
* Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
2014-11-21 00:19:29 +03:00
|
|
|
* Copyright 2014 David Fort <contact@hardening-consulting.com>
|
2013-05-09 07:18:42 +04:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2022-02-16 13:20:38 +03:00
|
|
|
#include <freerdp/config.h>
|
2013-05-09 07:18:42 +04:00
|
|
|
|
|
|
|
#include <winpr/crt.h>
|
|
|
|
#include <winpr/stream.h>
|
|
|
|
|
|
|
|
#include "rdpei_common.h"
|
|
|
|
|
2020-11-11 10:54:46 +03:00
|
|
|
BOOL rdpei_read_2byte_unsigned(wStream* s, UINT16* value)
|
2013-05-09 07:18:42 +04:00
|
|
|
{
|
|
|
|
BYTE byte;
|
|
|
|
|
|
|
|
if (Stream_GetRemainingLength(s) < 1)
|
|
|
|
return FALSE;
|
2013-05-09 08:21:33 +04:00
|
|
|
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
|
|
|
|
if (byte & 0x80)
|
|
|
|
{
|
|
|
|
if (Stream_GetRemainingLength(s) < 1)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*value = (byte & 0x7F) << 8;
|
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
*value |= byte;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*value = (byte & 0x7F);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-11-11 10:54:46 +03:00
|
|
|
BOOL rdpei_write_2byte_unsigned(wStream* s, UINT16 value)
|
2013-05-09 07:18:42 +04:00
|
|
|
{
|
|
|
|
BYTE byte;
|
|
|
|
|
2020-11-11 10:54:46 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, 2))
|
|
|
|
return FALSE;
|
|
|
|
|
2013-05-09 07:18:42 +04:00
|
|
|
if (value > 0x7FFF)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (value >= 0x7F)
|
|
|
|
{
|
|
|
|
byte = ((value & 0x7F00) >> 8);
|
|
|
|
Stream_Write_UINT8(s, byte | 0x80);
|
|
|
|
byte = (value & 0xFF);
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
byte = (value & 0x7F);
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-11-11 10:54:46 +03:00
|
|
|
BOOL rdpei_read_2byte_signed(wStream* s, INT16* value)
|
2013-05-09 07:18:42 +04:00
|
|
|
{
|
|
|
|
BYTE byte;
|
|
|
|
BOOL negative;
|
|
|
|
|
|
|
|
if (Stream_GetRemainingLength(s) < 1)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
|
|
|
|
negative = (byte & 0x40) ? TRUE : FALSE;
|
|
|
|
|
|
|
|
*value = (byte & 0x3F);
|
|
|
|
|
|
|
|
if (byte & 0x80)
|
|
|
|
{
|
|
|
|
if (Stream_GetRemainingLength(s) < 1)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
*value = (*value << 8) | byte;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (negative)
|
|
|
|
*value *= -1;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-11-11 10:54:46 +03:00
|
|
|
BOOL rdpei_write_2byte_signed(wStream* s, INT16 value)
|
2013-05-09 07:18:42 +04:00
|
|
|
{
|
|
|
|
BYTE byte;
|
|
|
|
BOOL negative = FALSE;
|
|
|
|
|
2020-11-11 10:54:46 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, 2))
|
|
|
|
return FALSE;
|
|
|
|
|
2013-05-09 07:18:42 +04:00
|
|
|
if (value < 0)
|
|
|
|
{
|
|
|
|
negative = TRUE;
|
|
|
|
value *= -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value > 0x3FFF)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (value >= 0x3F)
|
|
|
|
{
|
|
|
|
byte = ((value & 0x3F00) >> 8);
|
|
|
|
|
|
|
|
if (negative)
|
|
|
|
byte |= 0x40;
|
|
|
|
|
|
|
|
Stream_Write_UINT8(s, byte | 0x80);
|
|
|
|
byte = (value & 0xFF);
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
byte = (value & 0x3F);
|
|
|
|
|
|
|
|
if (negative)
|
|
|
|
byte |= 0x40;
|
|
|
|
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL rdpei_read_4byte_unsigned(wStream* s, UINT32* value)
|
|
|
|
{
|
|
|
|
BYTE byte;
|
|
|
|
BYTE count;
|
|
|
|
|
|
|
|
if (Stream_GetRemainingLength(s) < 1)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
|
|
|
|
count = (byte & 0xC0) >> 6;
|
|
|
|
|
|
|
|
if (Stream_GetRemainingLength(s) < count)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
switch (count)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
*value = (byte & 0x3F);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
*value = (byte & 0x3F) << 8;
|
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
*value |= byte;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
*value = (byte & 0x3F) << 16;
|
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
*value |= (byte << 8);
|
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
*value |= byte;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
*value = (byte & 0x3F) << 24;
|
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
*value |= (byte << 16);
|
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
*value |= (byte << 8);
|
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
*value |= byte;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL rdpei_write_4byte_unsigned(wStream* s, UINT32 value)
|
|
|
|
{
|
|
|
|
BYTE byte;
|
|
|
|
|
2020-11-11 10:54:46 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, 4))
|
|
|
|
return FALSE;
|
|
|
|
|
2020-05-19 20:46:01 +03:00
|
|
|
if (value <= 0x3FUL)
|
2013-05-09 07:18:42 +04:00
|
|
|
{
|
|
|
|
Stream_Write_UINT8(s, value);
|
|
|
|
}
|
2020-05-19 20:46:01 +03:00
|
|
|
else if (value <= 0x3FFFUL)
|
2013-05-09 07:18:42 +04:00
|
|
|
{
|
|
|
|
byte = (value >> 8) & 0x3F;
|
|
|
|
Stream_Write_UINT8(s, byte | 0x40);
|
|
|
|
byte = (value & 0xFF);
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
}
|
2020-05-19 20:46:01 +03:00
|
|
|
else if (value <= 0x3FFFFFUL)
|
2013-05-09 07:18:42 +04:00
|
|
|
{
|
|
|
|
byte = (value >> 16) & 0x3F;
|
|
|
|
Stream_Write_UINT8(s, byte | 0x80);
|
|
|
|
byte = (value >> 8) & 0xFF;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value & 0xFF);
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
}
|
2020-05-19 20:46:01 +03:00
|
|
|
else if (value <= 0x3FFFFFFFUL)
|
2013-05-09 07:18:42 +04:00
|
|
|
{
|
|
|
|
byte = (value >> 24) & 0x3F;
|
|
|
|
Stream_Write_UINT8(s, byte | 0xC0);
|
|
|
|
byte = (value >> 16) & 0xFF;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value >> 8) & 0xFF;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value & 0xFF);
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL rdpei_read_4byte_signed(wStream* s, INT32* value)
|
|
|
|
{
|
|
|
|
BYTE byte;
|
|
|
|
BYTE count;
|
|
|
|
BOOL negative;
|
|
|
|
|
|
|
|
if (Stream_GetRemainingLength(s) < 1)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
|
|
|
|
count = (byte & 0xC0) >> 6;
|
|
|
|
negative = (byte & 0x20);
|
|
|
|
|
|
|
|
if (Stream_GetRemainingLength(s) < count)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
switch (count)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
*value = (byte & 0x1F);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
*value = (byte & 0x1F) << 8;
|
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
*value |= byte;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
*value = (byte & 0x1F) << 16;
|
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
*value |= (byte << 8);
|
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
*value |= byte;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
*value = (byte & 0x1F) << 24;
|
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
*value |= (byte << 16);
|
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
*value |= (byte << 8);
|
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
*value |= byte;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (negative)
|
|
|
|
*value *= -1;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL rdpei_write_4byte_signed(wStream* s, INT32 value)
|
|
|
|
{
|
|
|
|
BYTE byte;
|
|
|
|
BOOL negative = FALSE;
|
|
|
|
|
2020-11-11 10:54:46 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, 4))
|
|
|
|
return FALSE;
|
|
|
|
|
2013-05-09 07:18:42 +04:00
|
|
|
if (value < 0)
|
|
|
|
{
|
|
|
|
negative = TRUE;
|
|
|
|
value *= -1;
|
|
|
|
}
|
|
|
|
|
2020-06-03 10:53:18 +03:00
|
|
|
if (value <= 0x1FL)
|
2013-05-09 07:18:42 +04:00
|
|
|
{
|
|
|
|
byte = value & 0x1F;
|
|
|
|
|
|
|
|
if (negative)
|
|
|
|
byte |= 0x20;
|
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-09 07:18:42 +04:00
|
|
|
}
|
2020-06-03 10:53:18 +03:00
|
|
|
else if (value <= 0x1FFFL)
|
2013-05-09 07:18:42 +04:00
|
|
|
{
|
|
|
|
byte = (value >> 8) & 0x1F;
|
|
|
|
|
|
|
|
if (negative)
|
|
|
|
byte |= 0x20;
|
|
|
|
|
|
|
|
Stream_Write_UINT8(s, byte | 0x40);
|
|
|
|
byte = (value & 0xFF);
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
}
|
2020-06-03 10:53:18 +03:00
|
|
|
else if (value <= 0x1FFFFFL)
|
2013-05-09 07:18:42 +04:00
|
|
|
{
|
|
|
|
byte = (value >> 16) & 0x1F;
|
|
|
|
|
|
|
|
if (negative)
|
|
|
|
byte |= 0x20;
|
|
|
|
|
|
|
|
Stream_Write_UINT8(s, byte | 0x80);
|
|
|
|
byte = (value >> 8) & 0xFF;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value & 0xFF);
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
}
|
2020-06-03 10:53:18 +03:00
|
|
|
else if (value <= 0x1FFFFFFFL)
|
2013-05-09 07:18:42 +04:00
|
|
|
{
|
|
|
|
byte = (value >> 24) & 0x1F;
|
|
|
|
|
|
|
|
if (negative)
|
|
|
|
byte |= 0x20;
|
|
|
|
|
|
|
|
Stream_Write_UINT8(s, byte | 0xC0);
|
|
|
|
byte = (value >> 16) & 0xFF;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value >> 8) & 0xFF;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value & 0xFF);
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL rdpei_read_8byte_unsigned(wStream* s, UINT64* value)
|
|
|
|
{
|
2021-07-28 16:18:03 +03:00
|
|
|
UINT64 byte;
|
2013-05-09 07:18:42 +04:00
|
|
|
BYTE count;
|
|
|
|
|
|
|
|
if (Stream_GetRemainingLength(s) < 1)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
|
|
|
|
count = (byte & 0xE0) >> 5;
|
|
|
|
|
|
|
|
if (Stream_GetRemainingLength(s) < count)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
switch (count)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
*value = (byte & 0x1F);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2021-07-28 16:18:03 +03:00
|
|
|
*value = (byte & 0x1FU) << 8U;
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
*value |= byte;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2021-07-28 16:18:03 +03:00
|
|
|
*value = (byte & 0x1FU) << 16U;
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2021-07-28 16:18:03 +03:00
|
|
|
*value |= (byte << 8U);
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
*value |= byte;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
2021-07-28 16:18:03 +03:00
|
|
|
*value = (byte & 0x1FU) << 24U;
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2021-07-28 16:18:03 +03:00
|
|
|
*value |= (byte << 16U);
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2021-07-28 16:18:03 +03:00
|
|
|
*value |= (byte << 8U);
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
*value |= byte;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
2021-07-28 16:18:03 +03:00
|
|
|
*value = ((byte & 0x1FU)) << 32U;
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2021-07-28 16:18:03 +03:00
|
|
|
*value |= (byte << 24U);
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2021-07-28 16:18:03 +03:00
|
|
|
*value |= (byte << 16U);
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2021-07-28 16:18:03 +03:00
|
|
|
*value |= (byte << 8U);
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
*value |= byte;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
2021-07-28 16:18:03 +03:00
|
|
|
*value = ((byte & 0x1FU)) << 40U;
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2021-07-28 16:18:03 +03:00
|
|
|
*value |= ((byte) << 32U);
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2021-07-28 16:18:03 +03:00
|
|
|
*value |= (byte << 24U);
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2021-07-28 16:18:03 +03:00
|
|
|
*value |= (byte << 16U);
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2021-07-28 16:18:03 +03:00
|
|
|
*value |= (byte << 8U);
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
*value |= byte;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 6:
|
2021-07-28 16:18:03 +03:00
|
|
|
*value = ((byte & 0x1FU)) << 48U;
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2021-07-28 16:18:03 +03:00
|
|
|
*value |= ((byte) << 40U);
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2021-07-28 16:18:03 +03:00
|
|
|
*value |= ((byte) << 32U);
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2021-07-28 16:18:03 +03:00
|
|
|
*value |= (byte << 24U);
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2021-07-28 16:18:03 +03:00
|
|
|
*value |= (byte << 16U);
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2021-07-28 16:18:03 +03:00
|
|
|
*value |= (byte << 8U);
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
*value |= byte;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 7:
|
2021-07-28 16:18:03 +03:00
|
|
|
*value = ((byte & 0x1FU)) << 56U;
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2021-07-28 16:18:03 +03:00
|
|
|
*value |= ((byte) << 48U);
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2021-07-28 16:18:03 +03:00
|
|
|
*value |= ((byte) << 40U);
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2021-07-28 16:18:03 +03:00
|
|
|
*value |= ((byte) << 32U);
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2021-07-28 16:18:03 +03:00
|
|
|
*value |= (byte << 24U);
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2021-07-28 16:18:03 +03:00
|
|
|
*value |= (byte << 16U);
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2021-07-28 16:18:03 +03:00
|
|
|
*value |= (byte << 8U);
|
2013-05-09 07:18:42 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
|
|
|
*value |= byte;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL rdpei_write_8byte_unsigned(wStream* s, UINT64 value)
|
|
|
|
{
|
|
|
|
BYTE byte;
|
|
|
|
|
2020-11-11 10:54:46 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, 8))
|
|
|
|
return FALSE;
|
|
|
|
|
2020-05-19 20:46:01 +03:00
|
|
|
if (value <= 0x1FULL)
|
2013-05-09 07:18:42 +04:00
|
|
|
{
|
|
|
|
byte = value & 0x1F;
|
2013-05-14 09:06:25 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-09 07:18:42 +04:00
|
|
|
}
|
2020-05-19 20:46:01 +03:00
|
|
|
else if (value <= 0x1FFFULL)
|
2013-05-09 07:18:42 +04:00
|
|
|
{
|
|
|
|
byte = (value >> 8) & 0x1F;
|
2013-05-14 09:06:25 +04:00
|
|
|
byte |= (1 << 5);
|
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-09 07:18:42 +04:00
|
|
|
byte = (value & 0xFF);
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
}
|
2020-05-19 20:46:01 +03:00
|
|
|
else if (value <= 0x1FFFFFULL)
|
2013-05-09 07:18:42 +04:00
|
|
|
{
|
|
|
|
byte = (value >> 16) & 0x1F;
|
2013-05-14 09:06:25 +04:00
|
|
|
byte |= (2 << 5);
|
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-09 07:18:42 +04:00
|
|
|
byte = (value >> 8) & 0xFF;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value & 0xFF);
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
}
|
2020-10-20 18:07:58 +03:00
|
|
|
else if (value <= 0x1FFFFFFFULL)
|
2013-05-09 07:18:42 +04:00
|
|
|
{
|
|
|
|
byte = (value >> 24) & 0x1F;
|
2013-05-14 09:06:25 +04:00
|
|
|
byte |= (3 << 5);
|
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-09 07:18:42 +04:00
|
|
|
byte = (value >> 16) & 0xFF;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value >> 8) & 0xFF;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value & 0xFF);
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
}
|
2020-10-20 18:07:58 +03:00
|
|
|
else if (value <= 0x1FFFFFFFFFULL)
|
2013-05-09 07:18:42 +04:00
|
|
|
{
|
|
|
|
byte = (value >> 32) & 0x1F;
|
2013-05-14 09:06:25 +04:00
|
|
|
byte |= (4 << 5);
|
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-09 07:18:42 +04:00
|
|
|
byte = (value >> 24) & 0x1F;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value >> 16) & 0xFF;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value >> 8) & 0xFF;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value & 0xFF);
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
}
|
2020-10-20 18:07:58 +03:00
|
|
|
else if (value <= 0x1FFFFFFFFFFFULL)
|
2013-05-09 07:18:42 +04:00
|
|
|
{
|
|
|
|
byte = (value >> 40) & 0x1F;
|
2013-05-14 09:06:25 +04:00
|
|
|
byte |= (5 << 5);
|
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-09 07:18:42 +04:00
|
|
|
byte = (value >> 32) & 0x1F;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value >> 24) & 0x1F;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value >> 16) & 0xFF;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value >> 8) & 0xFF;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value & 0xFF);
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
}
|
2020-10-20 18:07:58 +03:00
|
|
|
else if (value <= 0x1FFFFFFFFFFFFFULL)
|
2013-05-09 07:18:42 +04:00
|
|
|
{
|
|
|
|
byte = (value >> 48) & 0x1F;
|
2013-05-14 09:06:25 +04:00
|
|
|
byte |= (6 << 5);
|
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-09 07:18:42 +04:00
|
|
|
byte = (value >> 40) & 0x1F;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value >> 32) & 0x1F;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value >> 24) & 0x1F;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value >> 16) & 0xFF;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value >> 8) & 0xFF;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value & 0xFF);
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
}
|
2020-05-19 20:46:01 +03:00
|
|
|
else if (value <= 0x1FFFFFFFFFFFFFFFULL)
|
2013-05-09 07:18:42 +04:00
|
|
|
{
|
|
|
|
byte = (value >> 56) & 0x1F;
|
2013-05-14 09:06:25 +04:00
|
|
|
byte |= (7 << 5);
|
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-09 07:18:42 +04:00
|
|
|
byte = (value >> 48) & 0x1F;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value >> 40) & 0x1F;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value >> 32) & 0x1F;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value >> 24) & 0x1F;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value >> 16) & 0xFF;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value >> 8) & 0xFF;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = (value & 0xFF);
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2014-11-21 00:19:29 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
void touch_event_reset(RDPINPUT_TOUCH_EVENT* event)
|
2014-11-21 00:19:29 +03:00
|
|
|
{
|
2020-11-11 10:54:46 +03:00
|
|
|
UINT16 i;
|
2014-11-21 00:19:29 +03:00
|
|
|
|
|
|
|
for (i = 0; i < event->frameCount; i++)
|
|
|
|
touch_frame_reset(&event->frames[i]);
|
|
|
|
|
|
|
|
free(event->frames);
|
|
|
|
event->frames = NULL;
|
|
|
|
event->frameCount = 0;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
void touch_frame_reset(RDPINPUT_TOUCH_FRAME* frame)
|
2014-11-21 00:19:29 +03:00
|
|
|
{
|
|
|
|
free(frame->contacts);
|
|
|
|
frame->contacts = NULL;
|
|
|
|
frame->contactCount = 0;
|
|
|
|
}
|
2020-11-11 10:54:46 +03:00
|
|
|
|
|
|
|
void pen_event_reset(RDPINPUT_PEN_EVENT* event)
|
|
|
|
{
|
|
|
|
UINT16 i;
|
|
|
|
|
|
|
|
for (i = 0; i < event->frameCount; i++)
|
|
|
|
pen_frame_reset(&event->frames[i]);
|
|
|
|
|
|
|
|
free(event->frames);
|
|
|
|
event->frames = NULL;
|
|
|
|
event->frameCount = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void pen_frame_reset(RDPINPUT_PEN_FRAME* frame)
|
|
|
|
{
|
|
|
|
free(frame->contacts);
|
|
|
|
frame->contacts = NULL;
|
|
|
|
frame->contactCount = 0;
|
|
|
|
}
|