2011-07-25 09:45:25 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-07-25 09:45:25 +04:00
|
|
|
* Update Data PDUs
|
|
|
|
*
|
|
|
|
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
2016-04-05 18:07:45 +03:00
|
|
|
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
|
|
|
|
* Copyright 2016 Thincast Technologies GmbH
|
2011-07-25 09:45:25 +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>
|
2012-08-15 01:09:01 +04:00
|
|
|
|
2012-11-22 04:22:41 +04:00
|
|
|
#include <winpr/crt.h>
|
2013-05-07 06:27:19 +04:00
|
|
|
#include <winpr/print.h>
|
2013-07-29 04:21:43 +04:00
|
|
|
#include <winpr/synch.h>
|
2013-01-09 02:18:10 +04:00
|
|
|
#include <winpr/thread.h>
|
2013-01-25 04:08:30 +04:00
|
|
|
#include <winpr/collections.h>
|
2012-11-22 04:22:41 +04:00
|
|
|
|
2023-11-24 21:37:20 +03:00
|
|
|
#include "settings.h"
|
2011-07-25 09:45:25 +04:00
|
|
|
#include "update.h"
|
2011-08-24 19:31:58 +04:00
|
|
|
#include "surface.h"
|
2013-01-25 05:05:03 +04:00
|
|
|
#include "message.h"
|
2016-02-18 16:19:36 +03:00
|
|
|
#include "info.h"
|
2017-07-10 16:29:09 +03:00
|
|
|
#include "window.h"
|
2012-09-24 12:59:18 +04:00
|
|
|
|
2014-09-12 16:36:29 +04:00
|
|
|
#include <freerdp/log.h>
|
2012-10-08 09:32:41 +04:00
|
|
|
#include <freerdp/peer.h>
|
2011-10-03 04:28:20 +04:00
|
|
|
#include <freerdp/codec/bitmap.h>
|
2011-07-25 09:45:25 +04:00
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
#include "../cache/pointer.h"
|
|
|
|
#include "../cache/palette.h"
|
|
|
|
#include "../cache/bitmap.h"
|
2016-02-18 16:19:36 +03:00
|
|
|
|
2014-09-12 16:36:29 +04:00
|
|
|
#define TAG FREERDP_TAG("core.update")
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static const char* const UPDATE_TYPE_STRINGS[] = { "Orders", "Bitmap", "Palette", "Synchronize" };
|
2011-07-25 09:45:25 +04:00
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
static const char* update_type_to_string(UINT16 updateType)
|
|
|
|
{
|
|
|
|
if (updateType >= ARRAYSIZE(UPDATE_TYPE_STRINGS))
|
|
|
|
return "UNKNOWN";
|
|
|
|
|
|
|
|
return UPDATE_TYPE_STRINGS[updateType];
|
|
|
|
}
|
|
|
|
|
2017-07-31 13:16:47 +03:00
|
|
|
static BOOL update_recv_orders(rdpUpdate* update, wStream* s)
|
2011-07-25 09:45:25 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT16 numberOrders = 0;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(update);
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 6))
|
2013-01-12 03:46:04 +04:00
|
|
|
return FALSE;
|
2013-01-19 01:50:25 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Seek_UINT16(s); /* pad2OctetsA (2 bytes) */
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, numberOrders); /* numberOrders (2 bytes) */
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Seek_UINT16(s); /* pad2OctetsB (2 bytes) */
|
2011-07-25 22:50:26 +04:00
|
|
|
|
|
|
|
while (numberOrders > 0)
|
|
|
|
{
|
2012-02-11 17:30:09 +04:00
|
|
|
if (!update_recv_order(update, s))
|
2015-05-02 06:26:08 +03:00
|
|
|
{
|
2015-06-23 12:08:44 +03:00
|
|
|
WLog_ERR(TAG, "update_recv_order() failed");
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2015-03-19 02:41:29 +03:00
|
|
|
}
|
2013-05-07 06:27:19 +04:00
|
|
|
|
2011-07-25 22:50:26 +04:00
|
|
|
numberOrders--;
|
|
|
|
}
|
2012-02-11 17:30:09 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-07-25 09:45:25 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_read_bitmap_data(rdpUpdate* update, wStream* s, BITMAP_DATA* bitmapData)
|
2011-07-25 09:45:25 +04:00
|
|
|
{
|
2019-05-09 14:23:25 +03:00
|
|
|
WINPR_UNUSED(update);
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(bitmapData);
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 18))
|
2013-01-12 03:46:04 +04:00
|
|
|
return FALSE;
|
2013-01-19 01:50:25 +04:00
|
|
|
|
2013-08-08 05:47:03 +04:00
|
|
|
Stream_Read_UINT16(s, bitmapData->destLeft);
|
|
|
|
Stream_Read_UINT16(s, bitmapData->destTop);
|
|
|
|
Stream_Read_UINT16(s, bitmapData->destRight);
|
|
|
|
Stream_Read_UINT16(s, bitmapData->destBottom);
|
|
|
|
Stream_Read_UINT16(s, bitmapData->width);
|
|
|
|
Stream_Read_UINT16(s, bitmapData->height);
|
|
|
|
Stream_Read_UINT16(s, bitmapData->bitsPerPixel);
|
|
|
|
Stream_Read_UINT16(s, bitmapData->flags);
|
|
|
|
Stream_Read_UINT16(s, bitmapData->bitmapLength);
|
|
|
|
|
2021-10-12 13:26:22 +03:00
|
|
|
if ((bitmapData->width == 0) || (bitmapData->height == 0))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Invalid BITMAP_DATA: width=%" PRIu16 ", height=%" PRIu16, bitmapData->width,
|
|
|
|
bitmapData->height);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-08-08 05:47:03 +04:00
|
|
|
if (bitmapData->flags & BITMAP_COMPRESSION)
|
2011-07-25 22:50:26 +04:00
|
|
|
{
|
2013-08-08 05:47:03 +04:00
|
|
|
if (!(bitmapData->flags & NO_BITMAP_COMPRESSION_HDR))
|
2011-12-20 05:31:37 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
|
2020-03-31 10:23:42 +03:00
|
|
|
return FALSE;
|
|
|
|
|
2016-07-19 17:15:38 +03:00
|
|
|
Stream_Read_UINT16(s,
|
|
|
|
bitmapData->cbCompFirstRowSize); /* cbCompFirstRowSize (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s,
|
|
|
|
bitmapData->cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT16(s, bitmapData->cbScanWidth); /* cbScanWidth (2 bytes) */
|
2016-07-19 17:15:38 +03:00
|
|
|
Stream_Read_UINT16(s,
|
|
|
|
bitmapData->cbUncompressedSize); /* cbUncompressedSize (2 bytes) */
|
2013-08-08 05:47:03 +04:00
|
|
|
bitmapData->bitmapLength = bitmapData->cbCompMainBodySize;
|
2011-12-20 05:31:37 +04:00
|
|
|
}
|
2011-07-25 22:50:26 +04:00
|
|
|
|
2013-08-08 05:47:03 +04:00
|
|
|
bitmapData->compressed = TRUE;
|
2011-08-04 11:39:10 +04:00
|
|
|
}
|
|
|
|
else
|
2013-08-08 05:47:03 +04:00
|
|
|
bitmapData->compressed = FALSE;
|
2013-08-08 07:46:17 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, bitmapData->bitmapLength))
|
2016-07-19 17:15:38 +03:00
|
|
|
return FALSE;
|
|
|
|
|
2018-07-05 09:44:42 +03:00
|
|
|
if (bitmapData->bitmapLength > 0)
|
|
|
|
{
|
|
|
|
bitmapData->bitmapDataStream = malloc(bitmapData->bitmapLength);
|
2018-09-04 11:40:17 +03:00
|
|
|
|
2018-07-05 09:44:42 +03:00
|
|
|
if (!bitmapData->bitmapDataStream)
|
|
|
|
return FALSE;
|
2018-09-04 11:40:17 +03:00
|
|
|
|
2023-06-07 16:38:21 +03:00
|
|
|
memcpy(bitmapData->bitmapDataStream, Stream_ConstPointer(s), bitmapData->bitmapLength);
|
2018-07-05 09:44:42 +03:00
|
|
|
Stream_Seek(s, bitmapData->bitmapLength);
|
|
|
|
}
|
2018-09-04 11:40:17 +03:00
|
|
|
|
2013-01-12 03:46:04 +04:00
|
|
|
return TRUE;
|
2011-07-25 09:45:25 +04:00
|
|
|
}
|
|
|
|
|
2022-01-11 18:01:33 +03:00
|
|
|
static BOOL update_write_bitmap_data(rdpUpdate* update_pub, wStream* s, BITMAP_DATA* bitmapData)
|
2013-08-08 05:47:03 +04:00
|
|
|
{
|
2022-01-11 18:01:33 +03:00
|
|
|
rdp_update_internal* update = update_cast(update_pub);
|
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(bitmapData);
|
|
|
|
|
2015-03-30 18:15:45 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, 64 + bitmapData->bitmapLength))
|
2015-03-30 19:29:32 +03:00
|
|
|
return FALSE;
|
2013-08-08 05:47:03 +04:00
|
|
|
|
2022-01-11 19:00:26 +03:00
|
|
|
if (update->common.autoCalculateBitmapData)
|
2019-06-04 17:33:18 +03:00
|
|
|
{
|
|
|
|
bitmapData->flags = 0;
|
|
|
|
bitmapData->cbCompFirstRowSize = 0;
|
2013-08-08 07:46:17 +04:00
|
|
|
|
2019-06-04 17:33:18 +03:00
|
|
|
if (bitmapData->compressed)
|
|
|
|
bitmapData->flags |= BITMAP_COMPRESSION;
|
2013-08-08 07:46:17 +04:00
|
|
|
|
2022-01-11 18:01:33 +03:00
|
|
|
if (update->common.context->settings->NoBitmapCompressionHeader)
|
2019-06-04 17:33:18 +03:00
|
|
|
{
|
|
|
|
bitmapData->flags |= NO_BITMAP_COMPRESSION_HDR;
|
|
|
|
bitmapData->cbCompMainBodySize = bitmapData->bitmapLength;
|
|
|
|
}
|
2013-08-08 07:46:17 +04:00
|
|
|
}
|
|
|
|
|
2013-08-08 05:47:03 +04:00
|
|
|
Stream_Write_UINT16(s, bitmapData->destLeft);
|
|
|
|
Stream_Write_UINT16(s, bitmapData->destTop);
|
|
|
|
Stream_Write_UINT16(s, bitmapData->destRight);
|
|
|
|
Stream_Write_UINT16(s, bitmapData->destBottom);
|
|
|
|
Stream_Write_UINT16(s, bitmapData->width);
|
|
|
|
Stream_Write_UINT16(s, bitmapData->height);
|
|
|
|
Stream_Write_UINT16(s, bitmapData->bitsPerPixel);
|
|
|
|
Stream_Write_UINT16(s, bitmapData->flags);
|
|
|
|
Stream_Write_UINT16(s, bitmapData->bitmapLength);
|
|
|
|
|
|
|
|
if (bitmapData->flags & BITMAP_COMPRESSION)
|
|
|
|
{
|
|
|
|
if (!(bitmapData->flags & NO_BITMAP_COMPRESSION_HDR))
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT16(s,
|
|
|
|
bitmapData->cbCompFirstRowSize); /* cbCompFirstRowSize (2 bytes) */
|
|
|
|
Stream_Write_UINT16(s,
|
|
|
|
bitmapData->cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */
|
|
|
|
Stream_Write_UINT16(s, bitmapData->cbScanWidth); /* cbScanWidth (2 bytes) */
|
|
|
|
Stream_Write_UINT16(s,
|
|
|
|
bitmapData->cbUncompressedSize); /* cbUncompressedSize (2 bytes) */
|
2013-08-08 05:47:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
Stream_Write(s, bitmapData->bitmapDataStream, bitmapData->bitmapLength);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Stream_Write(s, bitmapData->bitmapDataStream, bitmapData->bitmapLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
BITMAP_UPDATE* update_read_bitmap_update(rdpUpdate* update, wStream* s)
|
2011-07-25 09:45:25 +04:00
|
|
|
{
|
2018-03-30 11:43:20 +03:00
|
|
|
BITMAP_UPDATE* bitmapUpdate = calloc(1, sizeof(BITMAP_UPDATE));
|
2022-01-11 18:01:33 +03:00
|
|
|
rdp_update_internal* up = update_cast(update);
|
2018-03-30 11:43:20 +03:00
|
|
|
|
|
|
|
if (!bitmapUpdate)
|
|
|
|
goto fail;
|
2013-01-19 01:50:25 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2013-01-19 01:50:25 +04:00
|
|
|
|
2013-08-08 05:47:03 +04:00
|
|
|
Stream_Read_UINT16(s, bitmapUpdate->number); /* numberRectangles (2 bytes) */
|
2022-01-11 18:01:33 +03:00
|
|
|
WLog_Print(up->log, WLOG_TRACE, "BitmapUpdate: %" PRIu32 "", bitmapUpdate->number);
|
2014-09-06 00:06:19 +04:00
|
|
|
|
2022-01-26 20:10:58 +03:00
|
|
|
bitmapUpdate->rectangles = (BITMAP_DATA*)calloc(bitmapUpdate->number, sizeof(BITMAP_DATA));
|
2015-03-11 08:40:20 +03:00
|
|
|
|
2022-01-26 20:10:58 +03:00
|
|
|
if (!bitmapUpdate->rectangles)
|
|
|
|
goto fail;
|
2013-08-08 05:47:03 +04:00
|
|
|
|
|
|
|
/* rectangles */
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 i = 0; i < bitmapUpdate->number; i++)
|
2013-08-08 05:47:03 +04:00
|
|
|
{
|
|
|
|
if (!update_read_bitmap_data(update, s, &bitmapUpdate->rectangles[i]))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2011-10-03 07:09:13 +04:00
|
|
|
}
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
return bitmapUpdate;
|
|
|
|
fail:
|
2024-02-04 13:11:29 +03:00
|
|
|
WINPR_PRAGMA_DIAG_PUSH
|
|
|
|
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
|
2018-03-30 11:43:20 +03:00
|
|
|
free_bitmap_update(update->context, bitmapUpdate);
|
2024-02-04 13:11:29 +03:00
|
|
|
WINPR_PRAGMA_DIAG_POP
|
2018-03-30 11:43:20 +03:00
|
|
|
return NULL;
|
2013-08-08 05:47:03 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL update_write_bitmap_update(rdpUpdate* update, wStream* s,
|
2016-07-19 17:15:38 +03:00
|
|
|
const BITMAP_UPDATE* bitmapUpdate)
|
2013-08-08 05:47:03 +04:00
|
|
|
{
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(update);
|
|
|
|
WINPR_ASSERT(bitmapUpdate);
|
2013-08-08 05:47:03 +04:00
|
|
|
|
2015-03-30 18:15:45 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, 32))
|
2015-03-30 19:29:32 +03:00
|
|
|
return FALSE;
|
2013-08-08 05:47:03 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT16(s, UPDATE_TYPE_BITMAP); /* updateType */
|
2013-08-08 05:47:03 +04:00
|
|
|
Stream_Write_UINT16(s, bitmapUpdate->number); /* numberRectangles (2 bytes) */
|
2011-07-25 09:45:25 +04:00
|
|
|
|
|
|
|
/* rectangles */
|
2022-09-30 12:00:53 +03:00
|
|
|
for (UINT32 i = 0; i < bitmapUpdate->number; i++)
|
2011-07-25 09:45:25 +04:00
|
|
|
{
|
2013-08-08 05:47:03 +04:00
|
|
|
if (!update_write_bitmap_data(update, s, &bitmapUpdate->rectangles[i]))
|
2013-01-12 03:46:04 +04:00
|
|
|
return FALSE;
|
2011-07-25 09:45:25 +04:00
|
|
|
}
|
2013-08-08 05:47:03 +04:00
|
|
|
|
2013-01-12 03:46:04 +04:00
|
|
|
return TRUE;
|
2011-07-25 09:45:25 +04:00
|
|
|
}
|
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
PALETTE_UPDATE* update_read_palette(rdpUpdate* update, wStream* s)
|
2011-07-25 09:45:25 +04:00
|
|
|
{
|
2018-03-30 11:43:20 +03:00
|
|
|
PALETTE_UPDATE* palette_update = calloc(1, sizeof(PALETTE_UPDATE));
|
|
|
|
|
|
|
|
if (!palette_update)
|
|
|
|
goto fail;
|
2011-07-27 02:32:14 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 6))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2013-01-19 01:50:25 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */
|
|
|
|
Stream_Read_UINT32(s, palette_update->number); /* numberColors (4 bytes), must be set to 256 */
|
2011-07-27 02:32:14 +04:00
|
|
|
|
|
|
|
if (palette_update->number > 256)
|
|
|
|
palette_update->number = 256;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
2023-01-24 16:53:36 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, palette_update->number, 3ull))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2013-01-12 03:46:04 +04:00
|
|
|
|
2011-07-25 09:45:25 +04:00
|
|
|
/* paletteEntries */
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 i = 0; i < palette_update->number; i++)
|
2011-07-27 02:32:14 +04:00
|
|
|
{
|
2024-01-30 12:25:38 +03:00
|
|
|
PALETTE_ENTRY* entry = &palette_update->entries[i];
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, entry->red);
|
2014-08-07 01:58:58 +04:00
|
|
|
Stream_Read_UINT8(s, entry->green);
|
|
|
|
Stream_Read_UINT8(s, entry->blue);
|
2011-07-27 02:32:14 +04:00
|
|
|
}
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
return palette_update;
|
|
|
|
fail:
|
2024-02-04 13:11:29 +03:00
|
|
|
WINPR_PRAGMA_DIAG_PUSH
|
|
|
|
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
|
2018-03-30 11:43:20 +03:00
|
|
|
free_palette_update(update->context, palette_update);
|
2024-02-04 13:11:29 +03:00
|
|
|
WINPR_PRAGMA_DIAG_POP
|
2018-03-30 11:43:20 +03:00
|
|
|
return NULL;
|
2011-07-25 09:45:25 +04:00
|
|
|
}
|
|
|
|
|
2020-03-31 10:21:43 +03:00
|
|
|
static BOOL update_read_synchronize(rdpUpdate* update, wStream* s)
|
2011-07-25 09:45:25 +04:00
|
|
|
{
|
2019-05-09 14:23:25 +03:00
|
|
|
WINPR_UNUSED(update);
|
2020-03-31 10:21:43 +03:00
|
|
|
return Stream_SafeSeek(s, 2); /* pad2Octets (2 bytes) */
|
|
|
|
/**
|
|
|
|
* The Synchronize Update is an artifact from the
|
|
|
|
* T.128 protocol and should be ignored.
|
|
|
|
*/
|
2011-07-25 09:45:25 +04:00
|
|
|
}
|
|
|
|
|
2017-07-31 13:16:47 +03:00
|
|
|
static BOOL update_read_play_sound(wStream* s, PLAY_SOUND_UPDATE* play_sound)
|
2011-08-24 10:54:46 +04:00
|
|
|
{
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(play_sound);
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
|
2013-01-12 03:46:04 +04:00
|
|
|
return FALSE;
|
2013-01-19 01:50:25 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT32(s, play_sound->duration); /* duration (4 bytes) */
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT32(s, play_sound->frequency); /* frequency (4 bytes) */
|
2013-01-12 03:46:04 +04:00
|
|
|
return TRUE;
|
2011-08-24 10:54:46 +04:00
|
|
|
}
|
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
BOOL update_recv_play_sound(rdpUpdate* update, wStream* s)
|
2011-08-24 10:54:46 +04:00
|
|
|
{
|
2022-09-30 12:00:53 +03:00
|
|
|
PLAY_SOUND_UPDATE play_sound = { 0 };
|
|
|
|
|
|
|
|
WINPR_ASSERT(update);
|
2018-05-04 13:03:26 +03:00
|
|
|
|
2018-04-03 18:17:45 +03:00
|
|
|
if (!update_read_play_sound(s, &play_sound))
|
2013-01-12 03:46:04 +04:00
|
|
|
return FALSE;
|
2013-01-19 01:50:25 +04:00
|
|
|
|
2018-04-03 18:17:45 +03:00
|
|
|
return IFCALLRESULT(FALSE, update->PlaySound, update->context, &play_sound);
|
2011-08-24 10:54:46 +04:00
|
|
|
}
|
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
POINTER_POSITION_UPDATE* update_read_pointer_position(rdpUpdate* update, wStream* s)
|
2011-08-24 10:38:39 +04:00
|
|
|
{
|
2018-03-30 11:43:20 +03:00
|
|
|
POINTER_POSITION_UPDATE* pointer_position = calloc(1, sizeof(POINTER_POSITION_UPDATE));
|
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(update);
|
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
if (!pointer_position)
|
|
|
|
goto fail;
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2013-01-19 01:50:25 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, pointer_position->xPos); /* xPos (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, pointer_position->yPos); /* yPos (2 bytes) */
|
2018-03-30 11:43:20 +03:00
|
|
|
return pointer_position;
|
|
|
|
fail:
|
2024-02-04 13:11:29 +03:00
|
|
|
WINPR_PRAGMA_DIAG_PUSH
|
|
|
|
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
|
2018-03-30 11:43:20 +03:00
|
|
|
free_pointer_position_update(update->context, pointer_position);
|
2024-02-04 13:11:29 +03:00
|
|
|
WINPR_PRAGMA_DIAG_POP
|
2018-03-30 11:43:20 +03:00
|
|
|
return NULL;
|
2011-08-24 10:38:39 +04:00
|
|
|
}
|
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
POINTER_SYSTEM_UPDATE* update_read_pointer_system(rdpUpdate* update, wStream* s)
|
2011-08-24 10:38:39 +04:00
|
|
|
{
|
2018-03-30 11:43:20 +03:00
|
|
|
POINTER_SYSTEM_UPDATE* pointer_system = calloc(1, sizeof(POINTER_SYSTEM_UPDATE));
|
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(update);
|
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
if (!pointer_system)
|
|
|
|
goto fail;
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2013-01-19 01:50:25 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT32(s, pointer_system->type); /* systemPointerType (4 bytes) */
|
2018-03-30 11:43:20 +03:00
|
|
|
return pointer_system;
|
|
|
|
fail:
|
2024-02-04 13:11:29 +03:00
|
|
|
WINPR_PRAGMA_DIAG_PUSH
|
|
|
|
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
|
2018-03-30 11:43:20 +03:00
|
|
|
free_pointer_system_update(update->context, pointer_system);
|
2024-02-04 13:11:29 +03:00
|
|
|
WINPR_PRAGMA_DIAG_POP
|
2018-03-30 11:43:20 +03:00
|
|
|
return NULL;
|
2011-08-24 10:38:39 +04:00
|
|
|
}
|
|
|
|
|
2020-04-22 11:54:05 +03:00
|
|
|
static BOOL _update_read_pointer_color(wStream* s, POINTER_COLOR_UPDATE* pointer_color, BYTE xorBpp,
|
|
|
|
UINT32 flags)
|
2011-08-24 10:38:39 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE* newMask = NULL;
|
|
|
|
UINT32 scanlineSize = 0;
|
2020-04-22 11:54:05 +03:00
|
|
|
UINT32 max = 32;
|
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(pointer_color);
|
|
|
|
|
2020-04-22 11:54:05 +03:00
|
|
|
if (flags & LARGE_POINTER_FLAG_96x96)
|
|
|
|
max = 96;
|
2014-05-29 01:07:00 +04:00
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
if (!pointer_color)
|
|
|
|
goto fail;
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 14))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2013-01-12 03:46:04 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, pointer_color->cacheIndex); /* cacheIndex (2 bytes) */
|
2023-04-14 08:35:21 +03:00
|
|
|
Stream_Read_UINT16(s, pointer_color->hotSpotX); /* hotSpot.xPos (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, pointer_color->hotSpotY); /* hotSpot.yPos (2 bytes) */
|
2014-05-29 01:07:00 +04:00
|
|
|
/**
|
|
|
|
* As stated in 2.2.9.1.1.4.4 Color Pointer Update:
|
|
|
|
* The maximum allowed pointer width/height is 96 pixels if the client indicated support
|
|
|
|
* for large pointers by setting the LARGE_POINTER_FLAG (0x00000001) in the Large
|
|
|
|
* Pointer Capability Set (section 2.2.7.2.7). If the LARGE_POINTER_FLAG was not
|
|
|
|
* set, the maximum allowed pointer width/height is 32 pixels.
|
|
|
|
*
|
2020-04-22 11:54:05 +03:00
|
|
|
* So we check for a maximum for CVE-2014-0250.
|
2014-05-29 01:07:00 +04:00
|
|
|
*/
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT16(s, pointer_color->width); /* width (2 bytes) */
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, pointer_color->height); /* height (2 bytes) */
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2020-04-22 11:54:05 +03:00
|
|
|
if ((pointer_color->width > max) || (pointer_color->height > max))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2014-05-29 01:07:00 +04:00
|
|
|
|
2019-05-23 13:15:26 +03:00
|
|
|
Stream_Read_UINT16(s, pointer_color->lengthAndMask); /* lengthAndMask (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, pointer_color->lengthXorMask); /* lengthXorMask (2 bytes) */
|
2011-08-24 10:38:39 +04:00
|
|
|
|
2012-03-18 23:34:08 +04:00
|
|
|
/**
|
|
|
|
* There does not seem to be any documentation on why
|
2023-04-14 08:35:21 +03:00
|
|
|
* hotSpot.xPos / hotSpot.yPos can be larger than width / height
|
2012-03-18 23:34:08 +04:00
|
|
|
* so it is missing in documentation or a bug in implementation
|
|
|
|
* 2.2.9.1.1.4.4 Color Pointer Update (TS_COLORPOINTERATTRIBUTE)
|
|
|
|
*/
|
2023-04-14 08:35:21 +03:00
|
|
|
if (pointer_color->hotSpotX >= pointer_color->width)
|
|
|
|
pointer_color->hotSpotX = 0;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2023-04-14 08:35:21 +03:00
|
|
|
if (pointer_color->hotSpotY >= pointer_color->height)
|
|
|
|
pointer_color->hotSpotY = 0;
|
2012-03-18 23:34:08 +04:00
|
|
|
|
2011-08-24 10:38:39 +04:00
|
|
|
if (pointer_color->lengthXorMask > 0)
|
|
|
|
{
|
2014-05-29 01:07:00 +04:00
|
|
|
/**
|
|
|
|
* Spec states that:
|
|
|
|
*
|
|
|
|
* xorMaskData (variable): A variable-length array of bytes. Contains the 24-bpp, bottom-up
|
|
|
|
* XOR mask scan-line data. The XOR mask is padded to a 2-byte boundary for each encoded
|
2019-11-06 17:24:51 +03:00
|
|
|
* scan-line. For example, if a 3x3 pixel cursor is being sent, then each scan-line will
|
|
|
|
* consume 10 bytes (3 pixels per scan-line multiplied by 3 bytes per pixel, rounded up to
|
|
|
|
* the next even number of bytes).
|
2014-05-29 01:07:00 +04:00
|
|
|
*
|
|
|
|
* In fact instead of 24-bpp, the bpp parameter is given by the containing packet.
|
|
|
|
*/
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, pointer_color->lengthXorMask))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2013-01-29 03:42:32 +04:00
|
|
|
|
2014-05-29 02:12:48 +04:00
|
|
|
scanlineSize = (7 + xorBpp * pointer_color->width) / 8;
|
2014-05-29 01:07:00 +04:00
|
|
|
scanlineSize = ((scanlineSize + 1) / 2) * 2;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2014-05-29 02:12:48 +04:00
|
|
|
if (scanlineSize * pointer_color->height != pointer_color->lengthXorMask)
|
2014-05-29 01:07:00 +04:00
|
|
|
{
|
2018-02-28 12:10:09 +03:00
|
|
|
WLog_ERR(TAG,
|
2019-11-06 17:24:51 +03:00
|
|
|
"invalid lengthXorMask: width=%" PRIu32 " height=%" PRIu32 ", %" PRIu32
|
|
|
|
" instead of %" PRIu32 "",
|
|
|
|
pointer_color->width, pointer_color->height, pointer_color->lengthXorMask,
|
|
|
|
scanlineSize * pointer_color->height);
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2014-05-29 01:07:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
newMask = realloc(pointer_color->xorMaskData, pointer_color->lengthXorMask);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2014-05-29 01:07:00 +04:00
|
|
|
if (!newMask)
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2014-05-29 01:07:00 +04:00
|
|
|
|
|
|
|
pointer_color->xorMaskData = newMask;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read(s, pointer_color->xorMaskData, pointer_color->lengthXorMask);
|
2011-08-24 10:38:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pointer_color->lengthAndMask > 0)
|
|
|
|
{
|
2014-05-29 01:07:00 +04:00
|
|
|
/**
|
|
|
|
* andMaskData (variable): A variable-length array of bytes. Contains the 1-bpp, bottom-up
|
|
|
|
* AND mask scan-line data. The AND mask is padded to a 2-byte boundary for each encoded
|
2019-11-06 17:24:51 +03:00
|
|
|
* scan-line. For example, if a 7x7 pixel cursor is being sent, then each scan-line will
|
|
|
|
* consume 2 bytes (7 pixels per scan-line multiplied by 1 bpp, rounded up to the next even
|
|
|
|
* number of bytes).
|
2014-05-29 01:07:00 +04:00
|
|
|
*/
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, pointer_color->lengthAndMask))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2013-01-29 03:42:32 +04:00
|
|
|
|
2014-05-29 01:07:00 +04:00
|
|
|
scanlineSize = ((7 + pointer_color->width) / 8);
|
|
|
|
scanlineSize = ((1 + scanlineSize) / 2) * 2;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2014-05-29 02:12:48 +04:00
|
|
|
if (scanlineSize * pointer_color->height != pointer_color->lengthAndMask)
|
2014-05-29 01:07:00 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG, "invalid lengthAndMask: %" PRIu32 " instead of %" PRIu32 "",
|
2016-07-19 17:15:38 +03:00
|
|
|
pointer_color->lengthAndMask, scanlineSize * pointer_color->height);
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2014-05-29 01:07:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
newMask = realloc(pointer_color->andMaskData, pointer_color->lengthAndMask);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2014-05-29 01:07:00 +04:00
|
|
|
if (!newMask)
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2014-05-29 01:07:00 +04:00
|
|
|
|
|
|
|
pointer_color->andMaskData = newMask;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read(s, pointer_color->andMaskData, pointer_color->lengthAndMask);
|
2011-08-24 10:38:39 +04:00
|
|
|
}
|
|
|
|
|
2013-04-30 06:35:15 +04:00
|
|
|
if (Stream_GetRemainingLength(s) > 0)
|
2013-05-09 00:27:21 +04:00
|
|
|
Stream_Seek_UINT8(s); /* pad (1 byte) */
|
2013-01-29 03:42:32 +04:00
|
|
|
|
2013-01-12 03:46:04 +04:00
|
|
|
return TRUE;
|
2018-03-30 11:43:20 +03:00
|
|
|
fail:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
POINTER_COLOR_UPDATE* update_read_pointer_color(rdpUpdate* update, wStream* s, BYTE xorBpp)
|
|
|
|
{
|
|
|
|
POINTER_COLOR_UPDATE* pointer_color = calloc(1, sizeof(POINTER_COLOR_UPDATE));
|
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(update);
|
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
if (!pointer_color)
|
|
|
|
goto fail;
|
|
|
|
|
2020-04-22 11:54:05 +03:00
|
|
|
if (!_update_read_pointer_color(s, pointer_color, xorBpp,
|
|
|
|
update->context->settings->LargePointerFlag))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
return pointer_color;
|
|
|
|
fail:
|
2024-02-04 13:11:29 +03:00
|
|
|
WINPR_PRAGMA_DIAG_PUSH
|
|
|
|
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
|
2018-03-30 11:43:20 +03:00
|
|
|
free_pointer_color_update(update->context, pointer_color);
|
2024-02-04 13:11:29 +03:00
|
|
|
WINPR_PRAGMA_DIAG_POP
|
2018-03-30 11:43:20 +03:00
|
|
|
return NULL;
|
2011-08-24 10:38:39 +04:00
|
|
|
}
|
|
|
|
|
2019-12-19 11:35:53 +03:00
|
|
|
static BOOL _update_read_pointer_large(wStream* s, POINTER_LARGE_UPDATE* pointer)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE* newMask = NULL;
|
|
|
|
UINT32 scanlineSize = 0;
|
2019-12-19 11:35:53 +03:00
|
|
|
|
|
|
|
if (!pointer)
|
|
|
|
goto fail;
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 20))
|
2019-12-19 11:35:53 +03:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
Stream_Read_UINT16(s, pointer->xorBpp);
|
|
|
|
Stream_Read_UINT16(s, pointer->cacheIndex); /* cacheIndex (2 bytes) */
|
2023-04-14 08:35:21 +03:00
|
|
|
Stream_Read_UINT16(s, pointer->hotSpotX); /* hotSpot.xPos (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, pointer->hotSpotY); /* hotSpot.yPos (2 bytes) */
|
2019-12-19 11:35:53 +03:00
|
|
|
|
|
|
|
Stream_Read_UINT16(s, pointer->width); /* width (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, pointer->height); /* height (2 bytes) */
|
|
|
|
|
|
|
|
if ((pointer->width > 384) || (pointer->height > 384))
|
|
|
|
goto fail;
|
|
|
|
|
2020-04-22 13:09:37 +03:00
|
|
|
Stream_Read_UINT32(s, pointer->lengthAndMask); /* lengthAndMask (4 bytes) */
|
|
|
|
Stream_Read_UINT32(s, pointer->lengthXorMask); /* lengthXorMask (4 bytes) */
|
2019-12-19 11:35:53 +03:00
|
|
|
|
|
|
|
if (pointer->hotSpotX >= pointer->width)
|
|
|
|
pointer->hotSpotX = 0;
|
|
|
|
|
|
|
|
if (pointer->hotSpotY >= pointer->height)
|
|
|
|
pointer->hotSpotY = 0;
|
|
|
|
|
|
|
|
if (pointer->lengthXorMask > 0)
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Spec states that:
|
|
|
|
*
|
|
|
|
* xorMaskData (variable): A variable-length array of bytes. Contains the 24-bpp, bottom-up
|
|
|
|
* XOR mask scan-line data. The XOR mask is padded to a 2-byte boundary for each encoded
|
|
|
|
* scan-line. For example, if a 3x3 pixel cursor is being sent, then each scan-line will
|
|
|
|
* consume 10 bytes (3 pixels per scan-line multiplied by 3 bytes per pixel, rounded up to
|
|
|
|
* the next even number of bytes).
|
|
|
|
*
|
|
|
|
* In fact instead of 24-bpp, the bpp parameter is given by the containing packet.
|
|
|
|
*/
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, pointer->lengthXorMask))
|
2019-12-19 11:35:53 +03:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
scanlineSize = (7 + pointer->xorBpp * pointer->width) / 8;
|
|
|
|
scanlineSize = ((scanlineSize + 1) / 2) * 2;
|
|
|
|
|
|
|
|
if (scanlineSize * pointer->height != pointer->lengthXorMask)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG,
|
|
|
|
"invalid lengthXorMask: width=%" PRIu32 " height=%" PRIu32 ", %" PRIu32
|
|
|
|
" instead of %" PRIu32 "",
|
|
|
|
pointer->width, pointer->height, pointer->lengthXorMask,
|
|
|
|
scanlineSize * pointer->height);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
newMask = realloc(pointer->xorMaskData, pointer->lengthXorMask);
|
|
|
|
|
|
|
|
if (!newMask)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
pointer->xorMaskData = newMask;
|
|
|
|
Stream_Read(s, pointer->xorMaskData, pointer->lengthXorMask);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pointer->lengthAndMask > 0)
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* andMaskData (variable): A variable-length array of bytes. Contains the 1-bpp, bottom-up
|
|
|
|
* AND mask scan-line data. The AND mask is padded to a 2-byte boundary for each encoded
|
|
|
|
* scan-line. For example, if a 7x7 pixel cursor is being sent, then each scan-line will
|
|
|
|
* consume 2 bytes (7 pixels per scan-line multiplied by 1 bpp, rounded up to the next even
|
|
|
|
* number of bytes).
|
|
|
|
*/
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, pointer->lengthAndMask))
|
2019-12-19 11:35:53 +03:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
scanlineSize = ((7 + pointer->width) / 8);
|
|
|
|
scanlineSize = ((1 + scanlineSize) / 2) * 2;
|
|
|
|
|
|
|
|
if (scanlineSize * pointer->height != pointer->lengthAndMask)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "invalid lengthAndMask: %" PRIu32 " instead of %" PRIu32 "",
|
|
|
|
pointer->lengthAndMask, scanlineSize * pointer->height);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
newMask = realloc(pointer->andMaskData, pointer->lengthAndMask);
|
|
|
|
|
|
|
|
if (!newMask)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
pointer->andMaskData = newMask;
|
|
|
|
Stream_Read(s, pointer->andMaskData, pointer->lengthAndMask);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Stream_GetRemainingLength(s) > 0)
|
|
|
|
Stream_Seek_UINT8(s); /* pad (1 byte) */
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
fail:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
POINTER_LARGE_UPDATE* update_read_pointer_large(rdpUpdate* update, wStream* s)
|
|
|
|
{
|
|
|
|
POINTER_LARGE_UPDATE* pointer = calloc(1, sizeof(POINTER_LARGE_UPDATE));
|
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(update);
|
|
|
|
|
2019-12-19 11:35:53 +03:00
|
|
|
if (!pointer)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
if (!_update_read_pointer_large(s, pointer))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
return pointer;
|
|
|
|
fail:
|
2024-02-04 13:11:29 +03:00
|
|
|
WINPR_PRAGMA_DIAG_PUSH
|
|
|
|
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
|
2019-12-19 11:35:53 +03:00
|
|
|
free_pointer_large_update(update->context, pointer);
|
2024-02-04 13:11:29 +03:00
|
|
|
WINPR_PRAGMA_DIAG_POP
|
2019-12-19 11:35:53 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
POINTER_NEW_UPDATE* update_read_pointer_new(rdpUpdate* update, wStream* s)
|
2011-08-24 10:38:39 +04:00
|
|
|
{
|
2018-03-30 11:43:20 +03:00
|
|
|
POINTER_NEW_UPDATE* pointer_new = calloc(1, sizeof(POINTER_NEW_UPDATE));
|
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(update);
|
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
if (!pointer_new)
|
|
|
|
goto fail;
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2013-01-19 01:50:25 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, pointer_new->xorBpp); /* xorBpp (2 bytes) */
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2014-05-29 11:24:59 +04:00
|
|
|
if ((pointer_new->xorBpp < 1) || (pointer_new->xorBpp > 32))
|
2014-05-29 02:12:48 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG, "invalid xorBpp %" PRIu32 "", pointer_new->xorBpp);
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2014-05-29 02:12:48 +04:00
|
|
|
}
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2020-04-22 11:54:05 +03:00
|
|
|
if (!_update_read_pointer_color(s, &pointer_new->colorPtrAttr, pointer_new->xorBpp,
|
|
|
|
update->context->settings->LargePointerFlag)) /* colorPtrAttr */
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
return pointer_new;
|
|
|
|
fail:
|
2024-02-04 13:11:29 +03:00
|
|
|
WINPR_PRAGMA_DIAG_PUSH
|
|
|
|
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
|
2018-03-30 11:43:20 +03:00
|
|
|
free_pointer_new_update(update->context, pointer_new);
|
2024-02-04 13:11:29 +03:00
|
|
|
WINPR_PRAGMA_DIAG_POP
|
2018-03-30 11:43:20 +03:00
|
|
|
return NULL;
|
2011-08-24 10:38:39 +04:00
|
|
|
}
|
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
POINTER_CACHED_UPDATE* update_read_pointer_cached(rdpUpdate* update, wStream* s)
|
2011-08-24 10:38:39 +04:00
|
|
|
{
|
2018-03-30 11:43:20 +03:00
|
|
|
POINTER_CACHED_UPDATE* pointer = calloc(1, sizeof(POINTER_CACHED_UPDATE));
|
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(update);
|
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
if (!pointer)
|
|
|
|
goto fail;
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
|
2018-05-04 12:46:46 +03:00
|
|
|
goto fail;
|
2013-01-19 01:50:25 +04:00
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
Stream_Read_UINT16(s, pointer->cacheIndex); /* cacheIndex (2 bytes) */
|
|
|
|
return pointer;
|
|
|
|
fail:
|
2024-02-04 13:11:29 +03:00
|
|
|
WINPR_PRAGMA_DIAG_PUSH
|
|
|
|
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
|
2018-03-30 11:43:20 +03:00
|
|
|
free_pointer_cached_update(update->context, pointer);
|
2024-02-04 13:11:29 +03:00
|
|
|
WINPR_PRAGMA_DIAG_POP
|
2018-03-30 11:43:20 +03:00
|
|
|
return NULL;
|
2011-08-24 10:38:39 +04:00
|
|
|
}
|
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
BOOL update_recv_pointer(rdpUpdate* update, wStream* s)
|
2011-08-24 10:38:39 +04:00
|
|
|
{
|
2018-03-30 11:43:20 +03:00
|
|
|
BOOL rc = FALSE;
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT16 messageType = 0;
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(update);
|
|
|
|
|
2011-11-22 02:48:03 +04:00
|
|
|
rdpContext* context = update->context;
|
|
|
|
rdpPointerUpdate* pointer = update->pointer;
|
2011-08-24 10:38:39 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 2 + 2))
|
2013-01-12 03:46:04 +04:00
|
|
|
return FALSE;
|
2013-01-19 01:50:25 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, messageType); /* messageType (2 bytes) */
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */
|
2011-08-24 10:38:39 +04:00
|
|
|
|
|
|
|
switch (messageType)
|
|
|
|
{
|
|
|
|
case PTR_MSG_TYPE_POSITION:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
|
|
|
POINTER_POSITION_UPDATE* pointer_position = update_read_pointer_position(update, s);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (pointer_position)
|
|
|
|
{
|
|
|
|
rc = IFCALLRESULT(FALSE, pointer->PointerPosition, context, pointer_position);
|
|
|
|
free_pointer_position_update(context, pointer_position);
|
2018-03-30 11:43:20 +03:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-08-24 10:38:39 +04:00
|
|
|
|
|
|
|
case PTR_MSG_TYPE_SYSTEM:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
|
|
|
POINTER_SYSTEM_UPDATE* pointer_system = update_read_pointer_system(update, s);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (pointer_system)
|
|
|
|
{
|
|
|
|
rc = IFCALLRESULT(FALSE, pointer->PointerSystem, context, pointer_system);
|
|
|
|
free_pointer_system_update(context, pointer_system);
|
2018-03-30 11:43:20 +03:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-08-24 10:38:39 +04:00
|
|
|
|
|
|
|
case PTR_MSG_TYPE_COLOR:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
|
|
|
POINTER_COLOR_UPDATE* pointer_color = update_read_pointer_color(update, s, 24);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (pointer_color)
|
|
|
|
{
|
|
|
|
rc = IFCALLRESULT(FALSE, pointer->PointerColor, context, pointer_color);
|
|
|
|
free_pointer_color_update(context, pointer_color);
|
2018-03-30 11:43:20 +03:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-08-24 10:38:39 +04:00
|
|
|
|
2019-12-19 11:35:53 +03:00
|
|
|
case PTR_MSG_TYPE_POINTER_LARGE:
|
|
|
|
{
|
|
|
|
POINTER_LARGE_UPDATE* pointer_large = update_read_pointer_large(update, s);
|
|
|
|
|
|
|
|
if (pointer_large)
|
|
|
|
{
|
|
|
|
rc = IFCALLRESULT(FALSE, pointer->PointerLarge, context, pointer_large);
|
|
|
|
free_pointer_large_update(context, pointer_large);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-08-24 10:38:39 +04:00
|
|
|
case PTR_MSG_TYPE_POINTER:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
|
|
|
POINTER_NEW_UPDATE* pointer_new = update_read_pointer_new(update, s);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (pointer_new)
|
|
|
|
{
|
|
|
|
rc = IFCALLRESULT(FALSE, pointer->PointerNew, context, pointer_new);
|
|
|
|
free_pointer_new_update(context, pointer_new);
|
2018-03-30 11:43:20 +03:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-08-24 10:38:39 +04:00
|
|
|
|
|
|
|
case PTR_MSG_TYPE_CACHED:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
|
|
|
POINTER_CACHED_UPDATE* pointer_cached = update_read_pointer_cached(update, s);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (pointer_cached)
|
|
|
|
{
|
|
|
|
rc = IFCALLRESULT(FALSE, pointer->PointerCached, context, pointer_cached);
|
|
|
|
free_pointer_cached_update(context, pointer_cached);
|
2018-03-30 11:43:20 +03:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-08-24 10:38:39 +04:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
return rc;
|
2011-08-24 10:38:39 +04:00
|
|
|
}
|
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
BOOL update_recv(rdpUpdate* update, wStream* s)
|
2011-07-25 09:45:25 +04:00
|
|
|
{
|
2018-03-30 11:43:20 +03:00
|
|
|
BOOL rc = FALSE;
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT16 updateType = 0;
|
2022-01-11 18:01:33 +03:00
|
|
|
rdp_update_internal* up = update_cast(update);
|
2011-11-22 04:41:49 +04:00
|
|
|
rdpContext* context = update->context;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(context);
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
|
2013-01-12 03:46:04 +04:00
|
|
|
return FALSE;
|
2013-01-19 01:50:25 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, updateType); /* updateType (2 bytes) */
|
2022-01-11 18:01:33 +03:00
|
|
|
WLog_Print(up->log, WLOG_TRACE, "%s Update Data PDU", update_type_to_string(updateType));
|
2018-03-30 11:43:20 +03:00
|
|
|
|
2019-04-11 16:30:05 +03:00
|
|
|
if (!update_begin_paint(update))
|
|
|
|
goto fail;
|
2011-07-28 21:46:36 +04:00
|
|
|
|
2011-07-25 09:45:25 +04:00
|
|
|
switch (updateType)
|
|
|
|
{
|
|
|
|
case UPDATE_TYPE_ORDERS:
|
2018-03-30 11:43:20 +03:00
|
|
|
rc = update_recv_orders(update, s);
|
2011-07-25 09:45:25 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case UPDATE_TYPE_BITMAP:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
|
|
|
BITMAP_UPDATE* bitmap_update = update_read_bitmap_update(update, s);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!bitmap_update)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "UPDATE_TYPE_BITMAP - update_read_bitmap_update() failed");
|
|
|
|
goto fail;
|
2018-03-30 11:43:20 +03:00
|
|
|
}
|
2011-07-25 09:45:25 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
rc = IFCALLRESULT(FALSE, update->BitmapUpdate, context, bitmap_update);
|
2022-09-30 12:00:53 +03:00
|
|
|
free_bitmap_update(context, bitmap_update);
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2018-03-30 11:43:20 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
case UPDATE_TYPE_PALETTE:
|
|
|
|
{
|
|
|
|
PALETTE_UPDATE* palette_update = update_read_palette(update, s);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!palette_update)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "UPDATE_TYPE_PALETTE - update_read_palette() failed");
|
|
|
|
goto fail;
|
2018-03-30 11:43:20 +03:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
|
|
|
|
rc = IFCALLRESULT(FALSE, update->Palette, context, palette_update);
|
|
|
|
free_palette_update(context, palette_update);
|
|
|
|
}
|
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
|
|
|
case UPDATE_TYPE_SYNCHRONIZE:
|
2020-03-31 10:21:43 +03:00
|
|
|
if (!update_read_synchronize(update, s))
|
|
|
|
goto fail;
|
2018-03-30 11:43:20 +03:00
|
|
|
rc = IFCALLRESULT(TRUE, update->Synchronize, context);
|
2011-07-25 09:45:25 +04:00
|
|
|
break;
|
2017-10-02 22:28:02 +03:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
}
|
2011-07-28 21:46:36 +04:00
|
|
|
|
2019-04-11 16:30:05 +03:00
|
|
|
fail:
|
|
|
|
|
|
|
|
if (!update_end_paint(update))
|
|
|
|
rc = FALSE;
|
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
if (!rc)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG, "UPDATE_TYPE %s [%" PRIu16 "] failed", update_type_to_string(updateType),
|
|
|
|
updateType);
|
2018-03-30 11:43:20 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-07-25 09:45:25 +04:00
|
|
|
}
|
|
|
|
|
2011-08-08 05:12:36 +04:00
|
|
|
void update_reset_state(rdpUpdate* update)
|
|
|
|
{
|
2022-01-11 18:01:33 +03:00
|
|
|
rdp_update_internal* up = update_cast(update);
|
2022-01-11 18:35:56 +03:00
|
|
|
rdp_primary_update_internal* primary = primary_update_cast(update->primary);
|
2011-11-22 03:11:43 +04:00
|
|
|
|
2022-01-11 18:01:33 +03:00
|
|
|
WINPR_ASSERT(primary);
|
|
|
|
|
2013-01-24 23:09:44 +04:00
|
|
|
ZeroMemory(&primary->order_info, sizeof(ORDER_INFO));
|
|
|
|
ZeroMemory(&primary->dstblt, sizeof(DSTBLT_ORDER));
|
|
|
|
ZeroMemory(&primary->patblt, sizeof(PATBLT_ORDER));
|
|
|
|
ZeroMemory(&primary->scrblt, sizeof(SCRBLT_ORDER));
|
|
|
|
ZeroMemory(&primary->opaque_rect, sizeof(OPAQUE_RECT_ORDER));
|
|
|
|
ZeroMemory(&primary->draw_nine_grid, sizeof(DRAW_NINE_GRID_ORDER));
|
|
|
|
ZeroMemory(&primary->multi_dstblt, sizeof(MULTI_DSTBLT_ORDER));
|
|
|
|
ZeroMemory(&primary->multi_patblt, sizeof(MULTI_PATBLT_ORDER));
|
|
|
|
ZeroMemory(&primary->multi_scrblt, sizeof(MULTI_SCRBLT_ORDER));
|
|
|
|
ZeroMemory(&primary->multi_opaque_rect, sizeof(MULTI_OPAQUE_RECT_ORDER));
|
|
|
|
ZeroMemory(&primary->multi_draw_nine_grid, sizeof(MULTI_DRAW_NINE_GRID_ORDER));
|
|
|
|
ZeroMemory(&primary->line_to, sizeof(LINE_TO_ORDER));
|
2023-09-19 11:51:23 +03:00
|
|
|
|
|
|
|
free(primary->polyline.points);
|
2013-01-24 23:09:44 +04:00
|
|
|
ZeroMemory(&primary->polyline, sizeof(POLYLINE_ORDER));
|
2023-09-19 11:51:23 +03:00
|
|
|
|
2013-01-24 23:09:44 +04:00
|
|
|
ZeroMemory(&primary->memblt, sizeof(MEMBLT_ORDER));
|
|
|
|
ZeroMemory(&primary->mem3blt, sizeof(MEM3BLT_ORDER));
|
|
|
|
ZeroMemory(&primary->save_bitmap, sizeof(SAVE_BITMAP_ORDER));
|
|
|
|
ZeroMemory(&primary->glyph_index, sizeof(GLYPH_INDEX_ORDER));
|
|
|
|
ZeroMemory(&primary->fast_index, sizeof(FAST_INDEX_ORDER));
|
2023-09-19 11:51:23 +03:00
|
|
|
|
|
|
|
free(primary->fast_glyph.glyphData.aj);
|
2013-01-24 23:09:44 +04:00
|
|
|
ZeroMemory(&primary->fast_glyph, sizeof(FAST_GLYPH_ORDER));
|
2023-09-19 11:51:23 +03:00
|
|
|
|
|
|
|
free(primary->polygon_sc.points);
|
2013-01-24 23:09:44 +04:00
|
|
|
ZeroMemory(&primary->polygon_sc, sizeof(POLYGON_SC_ORDER));
|
2023-09-19 11:51:23 +03:00
|
|
|
|
|
|
|
free(primary->polygon_cb.points);
|
2013-01-24 23:09:44 +04:00
|
|
|
ZeroMemory(&primary->polygon_cb, sizeof(POLYGON_CB_ORDER));
|
2023-09-19 11:51:23 +03:00
|
|
|
|
2013-01-24 23:09:44 +04:00
|
|
|
ZeroMemory(&primary->ellipse_sc, sizeof(ELLIPSE_SC_ORDER));
|
|
|
|
ZeroMemory(&primary->ellipse_cb, sizeof(ELLIPSE_CB_ORDER));
|
2011-11-22 03:11:43 +04:00
|
|
|
primary->order_info.orderType = ORDER_TYPE_PATBLT;
|
2013-01-25 07:38:13 +04:00
|
|
|
|
2022-01-11 18:01:33 +03:00
|
|
|
if (!up->initialState)
|
2013-01-25 07:38:13 +04:00
|
|
|
{
|
2022-09-30 12:00:53 +03:00
|
|
|
rdp_altsec_update_internal* altsec = altsec_update_cast(update->altsec);
|
|
|
|
WINPR_ASSERT(altsec);
|
|
|
|
|
2013-01-25 07:38:13 +04:00
|
|
|
altsec->switch_surface.bitmapId = SCREEN_BITMAP_SURFACE;
|
2022-01-11 18:29:40 +03:00
|
|
|
IFCALL(altsec->common.SwitchSurface, update->context, &(altsec->switch_surface));
|
2013-01-25 07:38:13 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-05 14:55:48 +03:00
|
|
|
BOOL update_post_connect(rdpUpdate* update)
|
2013-01-25 07:38:13 +04:00
|
|
|
{
|
2022-01-11 18:01:33 +03:00
|
|
|
rdp_update_internal* up = update_cast(update);
|
2022-01-11 18:29:40 +03:00
|
|
|
rdp_altsec_update_internal* altsec = altsec_update_cast(update->altsec);
|
2022-01-11 18:01:33 +03:00
|
|
|
|
2022-01-11 18:29:40 +03:00
|
|
|
WINPR_ASSERT(update->context);
|
|
|
|
WINPR_ASSERT(update->context->settings);
|
2022-01-11 18:01:33 +03:00
|
|
|
up->asynchronous = update->context->settings->AsyncUpdate;
|
2013-01-28 03:22:46 +04:00
|
|
|
|
2022-01-11 18:01:33 +03:00
|
|
|
if (up->asynchronous)
|
|
|
|
if (!(up->proxy = update_message_proxy_new(update)))
|
2015-05-05 14:55:48 +03:00
|
|
|
return FALSE;
|
2013-01-25 07:38:13 +04:00
|
|
|
|
2022-01-11 18:29:40 +03:00
|
|
|
altsec->switch_surface.bitmapId = SCREEN_BITMAP_SURFACE;
|
|
|
|
IFCALL(update->altsec->SwitchSurface, update->context, &(altsec->switch_surface));
|
2022-01-11 18:01:33 +03:00
|
|
|
up->initialState = FALSE;
|
2015-05-05 14:55:48 +03:00
|
|
|
return TRUE;
|
2011-08-08 05:12:36 +04:00
|
|
|
}
|
|
|
|
|
2014-07-14 21:27:50 +04:00
|
|
|
void update_post_disconnect(rdpUpdate* update)
|
|
|
|
{
|
2022-01-11 18:01:33 +03:00
|
|
|
rdp_update_internal* up = update_cast(update);
|
2014-07-14 21:27:50 +04:00
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(update->context);
|
|
|
|
WINPR_ASSERT(update->context->settings);
|
|
|
|
|
2022-01-11 18:01:33 +03:00
|
|
|
up->asynchronous = update->context->settings->AsyncUpdate;
|
2017-05-17 16:58:44 +03:00
|
|
|
|
2022-01-11 18:01:33 +03:00
|
|
|
if (up->asynchronous)
|
|
|
|
update_message_proxy_free(up->proxy);
|
|
|
|
|
|
|
|
up->initialState = TRUE;
|
2014-07-14 21:27:50 +04:00
|
|
|
}
|
|
|
|
|
2019-04-11 16:30:05 +03:00
|
|
|
static BOOL _update_begin_paint(rdpContext* context)
|
2011-08-23 16:37:08 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(context);
|
2022-01-11 18:01:33 +03:00
|
|
|
rdp_update_internal* update = update_cast(context->update);
|
2013-05-10 00:30:28 +04:00
|
|
|
|
|
|
|
if (update->us)
|
2019-04-11 16:30:05 +03:00
|
|
|
{
|
2022-01-11 18:01:33 +03:00
|
|
|
if (!update_end_paint(&update->common))
|
2019-04-11 16:30:05 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
2011-09-21 01:01:38 +04:00
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(context->rdp);
|
2013-05-10 00:30:28 +04:00
|
|
|
s = fastpath_update_pdu_init_new(context->rdp->fastpath);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2013-05-10 00:30:28 +04:00
|
|
|
Stream_SealLength(s);
|
2021-10-16 21:39:34 +03:00
|
|
|
Stream_GetLength(s, update->offsetOrders);
|
2013-05-10 00:30:28 +04:00
|
|
|
Stream_Seek(s, 2); /* numberOrders (2 bytes) */
|
|
|
|
update->combineUpdates = TRUE;
|
|
|
|
update->numberOrders = 0;
|
|
|
|
update->us = s;
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2011-08-23 16:37:08 +04:00
|
|
|
}
|
|
|
|
|
2019-04-11 16:30:05 +03:00
|
|
|
static BOOL _update_end_paint(rdpContext* context)
|
2011-08-23 16:37:08 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(context);
|
2022-01-11 18:01:33 +03:00
|
|
|
rdp_update_internal* update = update_cast(context->update);
|
2013-05-10 00:30:28 +04:00
|
|
|
|
|
|
|
if (!update->us)
|
2015-04-14 11:14:23 +03:00
|
|
|
return FALSE;
|
2013-05-10 00:30:28 +04:00
|
|
|
|
|
|
|
s = update->us;
|
|
|
|
Stream_SealLength(s);
|
2021-10-16 21:39:34 +03:00
|
|
|
Stream_SetPosition(s, update->offsetOrders);
|
2013-05-10 00:30:28 +04:00
|
|
|
Stream_Write_UINT16(s, update->numberOrders); /* numberOrders (2 bytes) */
|
|
|
|
Stream_SetPosition(s, Stream_Length(s));
|
|
|
|
|
|
|
|
if (update->numberOrders > 0)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_DBG(TAG, "sending %" PRIu16 " orders", update->numberOrders);
|
2019-05-23 13:15:26 +03:00
|
|
|
fastpath_send_update_pdu(context->rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s, FALSE);
|
2013-05-10 00:30:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
update->combineUpdates = FALSE;
|
|
|
|
update->numberOrders = 0;
|
2021-10-16 21:39:34 +03:00
|
|
|
update->offsetOrders = 0;
|
2013-05-10 00:30:28 +04:00
|
|
|
update->us = NULL;
|
|
|
|
Stream_Free(s, TRUE);
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2011-11-11 23:02:59 +04:00
|
|
|
}
|
|
|
|
|
2013-06-10 00:49:19 +04:00
|
|
|
static void update_flush(rdpContext* context)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
rdp_update_internal* update = NULL;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
update = update_cast(context->update);
|
2013-06-10 00:49:19 +04:00
|
|
|
|
|
|
|
if (update->numberOrders > 0)
|
|
|
|
{
|
2022-01-11 18:01:33 +03:00
|
|
|
update_end_paint(&update->common);
|
|
|
|
update_begin_paint(&update->common);
|
2013-06-10 00:49:19 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-10 04:37:58 +04:00
|
|
|
static void update_force_flush(rdpContext* context)
|
|
|
|
{
|
2019-04-11 16:30:05 +03:00
|
|
|
update_flush(context);
|
2013-06-10 04:37:58 +04:00
|
|
|
}
|
|
|
|
|
2022-01-11 18:01:33 +03:00
|
|
|
static BOOL update_check_flush(rdpContext* context, size_t size)
|
2013-06-10 03:47:59 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
|
|
|
rdp_update_internal* update = NULL;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
update = update_cast(context->update);
|
|
|
|
|
2013-06-10 03:47:59 +04:00
|
|
|
s = update->us;
|
|
|
|
|
2013-07-29 00:31:38 +04:00
|
|
|
if (!update->us)
|
|
|
|
{
|
2022-01-11 18:01:33 +03:00
|
|
|
update_begin_paint(&update->common);
|
2013-07-29 00:31:38 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-07-29 18:21:32 +04:00
|
|
|
if (Stream_GetPosition(s) + size + 64 >= 0x3FFF)
|
2013-06-10 03:47:59 +04:00
|
|
|
{
|
|
|
|
update_flush(context);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_set_bounds(rdpContext* context, const rdpBounds* bounds)
|
2013-05-10 03:41:32 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
rdp_update_internal* update = NULL;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
|
|
|
|
update = update_cast(context->update);
|
|
|
|
|
2013-05-10 03:41:32 +04:00
|
|
|
CopyMemory(&update->previousBounds, &update->currentBounds, sizeof(rdpBounds));
|
|
|
|
|
|
|
|
if (!bounds)
|
|
|
|
ZeroMemory(&update->currentBounds, sizeof(rdpBounds));
|
|
|
|
else
|
|
|
|
CopyMemory(&update->currentBounds, bounds, sizeof(rdpBounds));
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2013-05-10 03:41:32 +04:00
|
|
|
}
|
|
|
|
|
2019-11-20 13:30:14 +03:00
|
|
|
static BOOL update_bounds_is_null(rdpBounds* bounds)
|
2013-05-10 03:41:32 +04:00
|
|
|
{
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(bounds);
|
2019-11-06 17:24:51 +03:00
|
|
|
if ((bounds->left == 0) && (bounds->top == 0) && (bounds->right == 0) && (bounds->bottom == 0))
|
2013-05-10 03:41:32 +04:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-20 13:30:14 +03:00
|
|
|
static BOOL update_bounds_equals(rdpBounds* bounds1, rdpBounds* bounds2)
|
2013-05-10 03:41:32 +04:00
|
|
|
{
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(bounds1);
|
|
|
|
WINPR_ASSERT(bounds2);
|
|
|
|
|
2013-05-10 03:41:32 +04:00
|
|
|
if ((bounds1->left == bounds2->left) && (bounds1->top == bounds2->top) &&
|
2016-07-19 17:15:38 +03:00
|
|
|
(bounds1->right == bounds2->right) && (bounds1->bottom == bounds2->bottom))
|
2013-05-10 03:41:32 +04:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-20 13:30:14 +03:00
|
|
|
static int update_prepare_bounds(rdpContext* context, ORDER_INFO* orderInfo)
|
2013-05-10 03:41:32 +04:00
|
|
|
{
|
|
|
|
int length = 0;
|
2024-01-23 18:49:54 +03:00
|
|
|
rdp_update_internal* update = NULL;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(orderInfo);
|
|
|
|
|
|
|
|
update = update_cast(context->update);
|
|
|
|
|
2013-05-10 03:41:32 +04:00
|
|
|
orderInfo->boundsFlags = 0;
|
|
|
|
|
|
|
|
if (update_bounds_is_null(&update->currentBounds))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
orderInfo->controlFlags |= ORDER_BOUNDS;
|
|
|
|
|
|
|
|
if (update_bounds_equals(&update->previousBounds, &update->currentBounds))
|
|
|
|
{
|
|
|
|
orderInfo->controlFlags |= ORDER_ZERO_BOUNDS_DELTAS;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
length += 1;
|
|
|
|
|
|
|
|
if (update->previousBounds.left != update->currentBounds.left)
|
|
|
|
{
|
|
|
|
orderInfo->bounds.left = update->currentBounds.left;
|
|
|
|
orderInfo->boundsFlags |= BOUND_LEFT;
|
|
|
|
length += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (update->previousBounds.top != update->currentBounds.top)
|
|
|
|
{
|
|
|
|
orderInfo->bounds.top = update->currentBounds.top;
|
|
|
|
orderInfo->boundsFlags |= BOUND_TOP;
|
|
|
|
length += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (update->previousBounds.right != update->currentBounds.right)
|
|
|
|
{
|
|
|
|
orderInfo->bounds.right = update->currentBounds.right;
|
|
|
|
orderInfo->boundsFlags |= BOUND_RIGHT;
|
|
|
|
length += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (update->previousBounds.bottom != update->currentBounds.bottom)
|
|
|
|
{
|
|
|
|
orderInfo->bounds.bottom = update->currentBounds.bottom;
|
|
|
|
orderInfo->boundsFlags |= BOUND_BOTTOM;
|
|
|
|
length += 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static int update_prepare_order_info(rdpContext* context, ORDER_INFO* orderInfo, UINT32 orderType)
|
2013-05-10 03:41:32 +04:00
|
|
|
{
|
|
|
|
int length = 1;
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(orderInfo);
|
|
|
|
|
2013-05-10 03:41:32 +04:00
|
|
|
orderInfo->fieldFlags = 0;
|
|
|
|
orderInfo->orderType = orderType;
|
|
|
|
orderInfo->controlFlags = ORDER_STANDARD;
|
|
|
|
orderInfo->controlFlags |= ORDER_TYPE_CHANGE;
|
|
|
|
length += 1;
|
2020-05-26 08:28:33 +03:00
|
|
|
length += get_primary_drawing_order_field_bytes(orderInfo->orderType, NULL);
|
2013-05-10 03:41:32 +04:00
|
|
|
length += update_prepare_bounds(context, orderInfo);
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
2019-11-20 13:30:14 +03:00
|
|
|
static int update_write_order_info(rdpContext* context, wStream* s, ORDER_INFO* orderInfo,
|
|
|
|
size_t offset)
|
2013-05-10 03:41:32 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t position = 0;
|
2022-09-30 12:00:53 +03:00
|
|
|
|
2019-05-09 14:23:25 +03:00
|
|
|
WINPR_UNUSED(context);
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(orderInfo);
|
|
|
|
|
2013-05-10 03:41:32 +04:00
|
|
|
position = Stream_GetPosition(s);
|
|
|
|
Stream_SetPosition(s, offset);
|
|
|
|
Stream_Write_UINT8(s, orderInfo->controlFlags); /* controlFlags (1 byte) */
|
|
|
|
|
|
|
|
if (orderInfo->controlFlags & ORDER_TYPE_CHANGE)
|
|
|
|
Stream_Write_UINT8(s, orderInfo->orderType); /* orderType (1 byte) */
|
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
if (!update_write_field_flags(
|
|
|
|
s, orderInfo->fieldFlags, orderInfo->controlFlags,
|
|
|
|
get_primary_drawing_order_field_bytes(orderInfo->orderType, NULL)))
|
|
|
|
return -1;
|
|
|
|
if (!update_write_bounds(s, orderInfo))
|
|
|
|
return -1;
|
2013-05-10 03:41:32 +04:00
|
|
|
Stream_SetPosition(s, position);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static void update_write_refresh_rect(wStream* s, BYTE count, const RECTANGLE_16* areas)
|
2011-11-11 23:02:59 +04:00
|
|
|
{
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(s);
|
|
|
|
WINPR_ASSERT(areas || (count == 0));
|
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, count); /* numberOfAreas (1 byte) */
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Seek(s, 3); /* pad3Octets (3 bytes) */
|
2011-11-11 23:02:59 +04:00
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
for (BYTE i = 0; i < count; i++)
|
2012-09-24 12:59:18 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT16(s, areas[i].left); /* left (2 bytes) */
|
|
|
|
Stream_Write_UINT16(s, areas[i].top); /* top (2 bytes) */
|
|
|
|
Stream_Write_UINT16(s, areas[i].right); /* right (2 bytes) */
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, areas[i].bottom); /* bottom (2 bytes) */
|
2012-09-24 12:59:18 +04:00
|
|
|
}
|
2011-11-11 23:02:59 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_send_refresh_rect(rdpContext* context, BYTE count, const RECTANGLE_16* areas)
|
2011-11-11 23:02:59 +04:00
|
|
|
{
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(context);
|
2011-11-22 04:41:49 +04:00
|
|
|
rdpRdp* rdp = context->rdp;
|
2011-11-11 23:02:59 +04:00
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(rdp->settings);
|
2012-11-08 00:13:14 +04:00
|
|
|
if (rdp->settings->RefreshRect)
|
2012-05-28 16:20:42 +04:00
|
|
|
{
|
2018-10-02 14:18:13 +03:00
|
|
|
wStream* s = rdp_data_pdu_init(rdp);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
2011-11-11 23:02:59 +04:00
|
|
|
|
2016-07-19 17:15:38 +03:00
|
|
|
update_write_refresh_rect(s, count, areas);
|
2018-10-02 14:18:13 +03:00
|
|
|
return rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_REFRESH_RECT, rdp->mcs->userId);
|
2012-05-28 16:20:42 +04:00
|
|
|
}
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2011-11-11 23:02:59 +04:00
|
|
|
}
|
|
|
|
|
2019-05-23 13:15:26 +03:00
|
|
|
static void update_write_suppress_output(wStream* s, BYTE allow, const RECTANGLE_16* area)
|
2011-11-11 23:02:59 +04:00
|
|
|
{
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(s);
|
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, allow); /* allowDisplayUpdates (1 byte) */
|
2014-11-14 13:25:05 +03:00
|
|
|
/* Use zeros for padding (like mstsc) for compatibility with legacy servers */
|
|
|
|
Stream_Zero(s, 3); /* pad3Octets (3 bytes) */
|
2011-11-11 23:02:59 +04:00
|
|
|
|
|
|
|
if (allow > 0)
|
2012-09-24 12:59:18 +04:00
|
|
|
{
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(area);
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT16(s, area->left); /* left (2 bytes) */
|
|
|
|
Stream_Write_UINT16(s, area->top); /* top (2 bytes) */
|
|
|
|
Stream_Write_UINT16(s, area->right); /* right (2 bytes) */
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, area->bottom); /* bottom (2 bytes) */
|
2012-09-24 12:59:18 +04:00
|
|
|
}
|
2011-11-11 23:02:59 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_send_suppress_output(rdpContext* context, BYTE allow, const RECTANGLE_16* area)
|
2011-11-11 23:02:59 +04:00
|
|
|
{
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(context);
|
2011-11-22 04:41:49 +04:00
|
|
|
rdpRdp* rdp = context->rdp;
|
2011-11-11 23:02:59 +04:00
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(rdp);
|
|
|
|
WINPR_ASSERT(rdp->settings);
|
2012-11-08 00:13:14 +04:00
|
|
|
if (rdp->settings->SuppressOutput)
|
2012-05-28 16:20:42 +04:00
|
|
|
{
|
2018-10-02 14:18:13 +03:00
|
|
|
wStream* s = rdp_data_pdu_init(rdp);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
2011-11-11 23:02:59 +04:00
|
|
|
|
2016-07-19 17:15:38 +03:00
|
|
|
update_write_suppress_output(s, allow, area);
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(rdp->mcs);
|
2019-11-06 17:24:51 +03:00
|
|
|
return rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_SUPPRESS_OUTPUT, rdp->mcs->userId);
|
2012-05-28 16:20:42 +04:00
|
|
|
}
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2011-08-23 16:37:08 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
static BOOL update_send_surface_command(rdpContext* context, wStream* s)
|
2011-08-27 05:44:37 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* update = NULL;
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(context);
|
2011-11-22 04:41:49 +04:00
|
|
|
rdpRdp* rdp = context->rdp;
|
2024-01-23 18:49:54 +03:00
|
|
|
BOOL ret = 0;
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(rdp);
|
2011-12-03 10:42:13 +04:00
|
|
|
update = fastpath_update_pdu_init(rdp->fastpath);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!update)
|
|
|
|
return FALSE;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(update, Stream_GetPosition(s)))
|
|
|
|
{
|
|
|
|
ret = FALSE;
|
2015-04-22 11:23:25 +03:00
|
|
|
goto out;
|
2015-04-14 11:14:23 +03:00
|
|
|
}
|
|
|
|
|
2016-07-19 17:15:38 +03:00
|
|
|
Stream_Write(update, Stream_Buffer(s), Stream_GetPosition(s));
|
2019-11-06 17:24:51 +03:00
|
|
|
ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SURFCMDS, update, FALSE);
|
2015-04-22 11:23:25 +03:00
|
|
|
out:
|
2013-06-13 12:56:06 +04:00
|
|
|
Stream_Release(update);
|
2015-04-14 11:14:23 +03:00
|
|
|
return ret;
|
2011-08-27 05:44:37 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL update_send_surface_bits(rdpContext* context,
|
2016-07-19 17:15:38 +03:00
|
|
|
const SURFACE_BITS_COMMAND* surfaceBitsCommand)
|
2011-08-23 19:28:28 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(context);
|
2011-11-22 04:41:49 +04:00
|
|
|
rdpRdp* rdp = context->rdp;
|
2015-04-14 11:14:23 +03:00
|
|
|
BOOL ret = FALSE;
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(surfaceBitsCommand);
|
|
|
|
WINPR_ASSERT(rdp);
|
|
|
|
|
2013-06-22 03:20:20 +04:00
|
|
|
update_force_flush(context);
|
2011-12-03 10:42:13 +04:00
|
|
|
s = fastpath_update_pdu_init(rdp->fastpath);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
|
|
|
|
2018-02-28 12:10:09 +03:00
|
|
|
if (!update_write_surfcmd_surface_bits(s, surfaceBitsCommand))
|
2015-04-14 11:14:23 +03:00
|
|
|
goto out_fail;
|
|
|
|
|
2016-07-19 17:15:38 +03:00
|
|
|
if (!fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SURFCMDS, s,
|
|
|
|
surfaceBitsCommand->skipCompression))
|
2015-04-14 11:14:23 +03:00
|
|
|
goto out_fail;
|
2013-06-22 03:20:20 +04:00
|
|
|
|
|
|
|
update_force_flush(context);
|
2015-04-14 11:14:23 +03:00
|
|
|
ret = TRUE;
|
|
|
|
out_fail:
|
2013-06-13 12:56:06 +04:00
|
|
|
Stream_Release(s);
|
2015-04-14 11:14:23 +03:00
|
|
|
return ret;
|
2011-08-23 19:28:28 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL update_send_surface_frame_marker(rdpContext* context,
|
2019-11-06 17:24:51 +03:00
|
|
|
const SURFACE_FRAME_MARKER* surfaceFrameMarker)
|
2011-12-16 03:26:32 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(context);
|
2011-12-16 03:26:32 +04:00
|
|
|
rdpRdp* rdp = context->rdp;
|
2015-04-14 11:14:23 +03:00
|
|
|
BOOL ret = FALSE;
|
2013-06-22 03:20:20 +04:00
|
|
|
update_force_flush(context);
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(rdp);
|
2011-12-16 03:26:32 +04:00
|
|
|
s = fastpath_update_pdu_init(rdp->fastpath);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
|
|
|
|
2016-07-19 17:15:38 +03:00
|
|
|
if (!update_write_surfcmd_frame_marker(s, surfaceFrameMarker->frameAction,
|
|
|
|
surfaceFrameMarker->frameId) ||
|
2019-11-06 17:24:51 +03:00
|
|
|
!fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SURFCMDS, s, FALSE))
|
2015-04-14 11:14:23 +03:00
|
|
|
goto out_fail;
|
2014-09-19 22:23:17 +04:00
|
|
|
|
|
|
|
update_force_flush(context);
|
2015-04-14 11:14:23 +03:00
|
|
|
ret = TRUE;
|
|
|
|
out_fail:
|
2014-09-19 22:23:17 +04:00
|
|
|
Stream_Release(s);
|
2015-04-14 11:14:23 +03:00
|
|
|
return ret;
|
2014-09-19 22:23:17 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_send_surface_frame_bits(rdpContext* context, const SURFACE_BITS_COMMAND* cmd,
|
|
|
|
BOOL first, BOOL last, UINT32 frameId)
|
2014-09-19 22:23:17 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
2014-09-19 22:23:17 +04:00
|
|
|
rdpRdp* rdp = context->rdp;
|
2015-04-14 11:14:23 +03:00
|
|
|
BOOL ret = FALSE;
|
2022-09-30 12:00:53 +03:00
|
|
|
|
2014-09-19 22:23:17 +04:00
|
|
|
update_force_flush(context);
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(rdp);
|
2014-09-19 22:23:17 +04:00
|
|
|
s = fastpath_update_pdu_init(rdp->fastpath);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
2015-04-17 17:21:55 +03:00
|
|
|
|
2014-09-19 22:23:17 +04:00
|
|
|
if (first)
|
2015-04-14 11:14:23 +03:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!update_write_surfcmd_frame_marker(s, SURFACECMD_FRAMEACTION_BEGIN, frameId))
|
2015-04-14 11:14:23 +03:00
|
|
|
goto out_fail;
|
|
|
|
}
|
2014-09-19 22:23:17 +04:00
|
|
|
|
2018-02-28 12:10:09 +03:00
|
|
|
if (!update_write_surfcmd_surface_bits(s, cmd))
|
2015-04-14 11:14:23 +03:00
|
|
|
goto out_fail;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2014-09-19 22:23:17 +04:00
|
|
|
if (last)
|
2015-04-14 11:14:23 +03:00
|
|
|
{
|
|
|
|
if (!update_write_surfcmd_frame_marker(s, SURFACECMD_FRAMEACTION_END, frameId))
|
2015-04-17 17:21:55 +03:00
|
|
|
goto out_fail;
|
2015-04-14 11:14:23 +03:00
|
|
|
}
|
2014-09-19 22:23:17 +04:00
|
|
|
|
2016-07-19 17:15:38 +03:00
|
|
|
ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SURFCMDS, s,
|
|
|
|
cmd->skipCompression);
|
2013-06-22 03:20:20 +04:00
|
|
|
update_force_flush(context);
|
2015-04-14 11:14:23 +03:00
|
|
|
out_fail:
|
2013-06-13 12:56:06 +04:00
|
|
|
Stream_Release(s);
|
2015-04-14 11:14:23 +03:00
|
|
|
return ret;
|
2011-12-16 03:26:32 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
static BOOL update_send_frame_acknowledge(rdpContext* context, UINT32 frameId)
|
2013-01-17 08:58:01 +04:00
|
|
|
{
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(context);
|
2013-01-17 08:58:01 +04:00
|
|
|
rdpRdp* rdp = context->rdp;
|
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(rdp);
|
|
|
|
WINPR_ASSERT(rdp->settings);
|
2013-01-19 12:45:24 +04:00
|
|
|
if (rdp->settings->ReceivedCapabilities[CAPSET_TYPE_FRAME_ACKNOWLEDGE])
|
|
|
|
{
|
2018-10-02 14:18:13 +03:00
|
|
|
wStream* s = rdp_data_pdu_init(rdp);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT32(s, frameId);
|
2019-11-06 17:24:51 +03:00
|
|
|
return rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_FRAME_ACKNOWLEDGE, rdp->mcs->userId);
|
2013-01-19 12:45:24 +04:00
|
|
|
}
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2013-01-17 08:58:01 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
static BOOL update_send_synchronize(rdpContext* context)
|
2011-08-25 13:03:53 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(context);
|
2011-11-22 04:41:49 +04:00
|
|
|
rdpRdp* rdp = context->rdp;
|
2024-01-23 18:49:54 +03:00
|
|
|
BOOL ret = 0;
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(rdp);
|
2011-08-25 13:03:53 +04:00
|
|
|
s = fastpath_update_pdu_init(rdp->fastpath);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2013-05-09 00:27:21 +04:00
|
|
|
Stream_Zero(s, 2); /* pad2Octets (2 bytes) */
|
2019-11-06 17:24:51 +03:00
|
|
|
ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SYNCHRONIZE, s, FALSE);
|
2013-06-13 12:56:06 +04:00
|
|
|
Stream_Release(s);
|
2015-04-14 11:14:23 +03:00
|
|
|
return ret;
|
2011-08-25 13:03:53 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
static BOOL update_send_desktop_resize(rdpContext* context)
|
2011-09-06 13:19:16 +04:00
|
|
|
{
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(context);
|
2015-04-14 11:14:23 +03:00
|
|
|
return rdp_server_reactivate(context->rdp);
|
2011-09-06 13:19:16 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_send_bitmap_update(rdpContext* context, const BITMAP_UPDATE* bitmapUpdate)
|
2013-08-08 05:47:03 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(context);
|
2013-08-08 05:47:03 +04:00
|
|
|
rdpRdp* rdp = context->rdp;
|
|
|
|
rdpUpdate* update = context->update;
|
2015-04-14 11:14:23 +03:00
|
|
|
BOOL ret = TRUE;
|
2022-09-30 12:00:53 +03:00
|
|
|
|
2013-08-08 07:46:17 +04:00
|
|
|
update_force_flush(context);
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(rdp);
|
2013-08-08 07:46:17 +04:00
|
|
|
s = fastpath_update_pdu_init(rdp->fastpath);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!update_write_bitmap_update(update, s, bitmapUpdate) ||
|
2016-07-19 17:15:38 +03:00
|
|
|
!fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_BITMAP, s,
|
|
|
|
bitmapUpdate->skipCompression))
|
2015-04-14 11:14:23 +03:00
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
goto out_fail;
|
|
|
|
}
|
2013-08-08 07:46:17 +04:00
|
|
|
|
|
|
|
update_force_flush(context);
|
2015-04-14 11:14:23 +03:00
|
|
|
out_fail:
|
2013-08-08 05:47:03 +04:00
|
|
|
Stream_Release(s);
|
2015-04-14 11:14:23 +03:00
|
|
|
return ret;
|
2013-08-08 05:47:03 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_send_play_sound(rdpContext* context, const PLAY_SOUND_UPDATE* play_sound)
|
2014-07-16 17:38:10 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(context);
|
2014-07-16 17:38:10 +04:00
|
|
|
rdpRdp* rdp = context->rdp;
|
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(rdp);
|
|
|
|
WINPR_ASSERT(rdp->settings);
|
|
|
|
WINPR_ASSERT(play_sound);
|
2016-07-19 17:15:38 +03:00
|
|
|
if (!rdp->settings->ReceivedCapabilities[CAPSET_TYPE_SOUND])
|
|
|
|
{
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2014-07-16 17:38:10 +04:00
|
|
|
}
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2014-07-16 17:38:10 +04:00
|
|
|
s = rdp_data_pdu_init(rdp);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2014-07-16 17:38:10 +04:00
|
|
|
Stream_Write_UINT32(s, play_sound->duration);
|
|
|
|
Stream_Write_UINT32(s, play_sound->frequency);
|
2018-10-02 14:18:13 +03:00
|
|
|
return rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_PLAY_SOUND, rdp->mcs->userId);
|
2014-07-16 17:38:10 +04:00
|
|
|
}
|
2019-05-23 13:15:26 +03:00
|
|
|
|
2013-07-29 04:21:43 +04:00
|
|
|
/**
|
|
|
|
* Primary Drawing Orders
|
|
|
|
*/
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_send_dstblt(rdpContext* context, const DSTBLT_ORDER* dstblt)
|
2013-05-13 01:46:13 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
|
|
|
size_t offset = 0;
|
|
|
|
UINT32 headerLength = 0;
|
2013-05-13 01:46:13 +04:00
|
|
|
ORDER_INFO orderInfo;
|
2024-01-23 18:49:54 +03:00
|
|
|
int inf = 0;
|
|
|
|
rdp_update_internal* update = NULL;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(dstblt);
|
|
|
|
|
|
|
|
update = update_cast(context->update);
|
|
|
|
|
2019-05-23 13:15:26 +03:00
|
|
|
headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_DSTBLT);
|
2016-04-05 18:07:45 +03:00
|
|
|
inf = update_approximate_dstblt_order(&orderInfo, dstblt);
|
|
|
|
update_check_flush(context, headerLength + inf);
|
2013-05-13 01:46:13 +04:00
|
|
|
s = update->us;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2013-05-13 01:46:13 +04:00
|
|
|
offset = Stream_GetPosition(s);
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, headerLength))
|
|
|
|
return FALSE;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_Seek(s, headerLength);
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!update_write_dstblt_order(s, &orderInfo, dstblt))
|
|
|
|
return FALSE;
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2016-07-19 17:15:38 +03:00
|
|
|
update_write_order_info(context, s, &orderInfo, offset);
|
2013-05-13 01:46:13 +04:00
|
|
|
update->numberOrders++;
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2013-05-13 01:46:13 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
static BOOL update_send_patblt(rdpContext* context, PATBLT_ORDER* patblt)
|
2013-05-07 20:45:52 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
|
|
|
size_t offset = 0;
|
|
|
|
int headerLength = 0;
|
2013-05-07 20:45:52 +04:00
|
|
|
ORDER_INFO orderInfo;
|
2024-01-23 18:49:54 +03:00
|
|
|
rdp_update_internal* update = NULL;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(patblt);
|
|
|
|
update = update_cast(context->update);
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_PATBLT);
|
|
|
|
update_check_flush(context, headerLength + update_approximate_patblt_order(&orderInfo, patblt));
|
2013-05-10 00:30:28 +04:00
|
|
|
s = update->us;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2013-05-10 03:41:32 +04:00
|
|
|
offset = Stream_GetPosition(s);
|
2013-05-07 20:45:52 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, headerLength))
|
|
|
|
return FALSE;
|
2013-05-10 00:30:28 +04:00
|
|
|
|
2016-07-19 17:15:38 +03:00
|
|
|
Stream_Seek(s, headerLength);
|
2013-05-07 20:45:52 +04:00
|
|
|
update_write_patblt_order(s, &orderInfo, patblt);
|
2013-05-10 03:41:32 +04:00
|
|
|
update_write_order_info(context, s, &orderInfo, offset);
|
2013-05-10 00:30:28 +04:00
|
|
|
update->numberOrders++;
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2013-05-07 20:45:52 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL update_send_scrblt(rdpContext* context, const SCRBLT_ORDER* scrblt)
|
2011-11-24 20:47:40 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
|
|
|
UINT32 offset = 0;
|
|
|
|
UINT32 headerLength = 0;
|
2013-05-07 20:45:52 +04:00
|
|
|
ORDER_INFO orderInfo;
|
2024-01-23 18:49:54 +03:00
|
|
|
int inf = 0;
|
|
|
|
rdp_update_internal* update = NULL;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(scrblt);
|
|
|
|
update = update_cast(context->update);
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_SCRBLT);
|
2016-04-05 18:07:45 +03:00
|
|
|
inf = update_approximate_scrblt_order(&orderInfo, scrblt);
|
|
|
|
update_check_flush(context, headerLength + inf);
|
2013-05-10 00:30:28 +04:00
|
|
|
s = update->us;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return TRUE;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2013-05-10 03:41:32 +04:00
|
|
|
offset = Stream_GetPosition(s);
|
2011-11-24 20:47:40 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, headerLength))
|
|
|
|
return FALSE;
|
2013-05-10 00:30:28 +04:00
|
|
|
|
2016-07-19 17:15:38 +03:00
|
|
|
Stream_Seek(s, headerLength);
|
2013-05-07 20:45:52 +04:00
|
|
|
update_write_scrblt_order(s, &orderInfo, scrblt);
|
2013-05-10 03:41:32 +04:00
|
|
|
update_write_order_info(context, s, &orderInfo, offset);
|
2013-05-10 00:30:28 +04:00
|
|
|
update->numberOrders++;
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2011-11-24 20:47:40 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_send_opaque_rect(rdpContext* context, const OPAQUE_RECT_ORDER* opaque_rect)
|
2013-05-07 06:27:19 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
|
|
|
size_t offset = 0;
|
|
|
|
int headerLength = 0;
|
2013-05-07 06:27:19 +04:00
|
|
|
ORDER_INFO orderInfo;
|
2024-01-23 18:49:54 +03:00
|
|
|
rdp_update_internal* update = NULL;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(opaque_rect);
|
|
|
|
update = update_cast(context->update);
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_OPAQUE_RECT);
|
|
|
|
update_check_flush(context, headerLength +
|
|
|
|
update_approximate_opaque_rect_order(&orderInfo, opaque_rect));
|
2013-05-10 00:30:28 +04:00
|
|
|
s = update->us;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2013-05-10 03:41:32 +04:00
|
|
|
offset = Stream_GetPosition(s);
|
2013-05-07 06:27:19 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, headerLength))
|
|
|
|
return FALSE;
|
2013-05-10 00:30:28 +04:00
|
|
|
|
2016-07-19 17:15:38 +03:00
|
|
|
Stream_Seek(s, headerLength);
|
2013-05-07 06:27:19 +04:00
|
|
|
update_write_opaque_rect_order(s, &orderInfo, opaque_rect);
|
2013-05-10 03:41:32 +04:00
|
|
|
update_write_order_info(context, s, &orderInfo, offset);
|
2013-05-10 00:30:28 +04:00
|
|
|
update->numberOrders++;
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2013-05-07 06:27:19 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_send_line_to(rdpContext* context, const LINE_TO_ORDER* line_to)
|
2013-05-13 01:46:13 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
|
|
|
int offset = 0;
|
|
|
|
int headerLength = 0;
|
2013-05-13 01:46:13 +04:00
|
|
|
ORDER_INFO orderInfo;
|
2024-01-23 18:49:54 +03:00
|
|
|
int inf = 0;
|
|
|
|
rdp_update_internal* update = NULL;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(line_to);
|
|
|
|
update = update_cast(context->update);
|
2019-11-06 17:24:51 +03:00
|
|
|
headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_LINE_TO);
|
2016-04-05 18:07:45 +03:00
|
|
|
inf = update_approximate_line_to_order(&orderInfo, line_to);
|
|
|
|
update_check_flush(context, headerLength + inf);
|
2013-05-13 01:46:13 +04:00
|
|
|
s = update->us;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2013-05-13 01:46:13 +04:00
|
|
|
offset = Stream_GetPosition(s);
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, headerLength))
|
|
|
|
return FALSE;
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2016-07-19 17:15:38 +03:00
|
|
|
Stream_Seek(s, headerLength);
|
2013-05-13 01:46:13 +04:00
|
|
|
update_write_line_to_order(s, &orderInfo, line_to);
|
|
|
|
update_write_order_info(context, s, &orderInfo, offset);
|
|
|
|
update->numberOrders++;
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2013-05-13 01:46:13 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
static BOOL update_send_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
|
2013-05-07 19:41:32 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
|
|
|
size_t offset = 0;
|
|
|
|
int headerLength = 0;
|
2013-05-07 19:41:32 +04:00
|
|
|
ORDER_INFO orderInfo;
|
2024-01-23 18:49:54 +03:00
|
|
|
rdp_update_internal* update = NULL;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(memblt);
|
|
|
|
update = update_cast(context->update);
|
2019-11-06 17:24:51 +03:00
|
|
|
headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_MEMBLT);
|
|
|
|
update_check_flush(context, headerLength + update_approximate_memblt_order(&orderInfo, memblt));
|
2013-05-10 00:30:28 +04:00
|
|
|
s = update->us;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2013-05-10 03:41:32 +04:00
|
|
|
offset = Stream_GetPosition(s);
|
2013-05-07 19:41:32 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, headerLength))
|
|
|
|
return FALSE;
|
2013-05-10 00:30:28 +04:00
|
|
|
|
2016-07-19 17:15:38 +03:00
|
|
|
Stream_Seek(s, headerLength);
|
2013-05-07 19:41:32 +04:00
|
|
|
update_write_memblt_order(s, &orderInfo, memblt);
|
2013-05-10 03:41:32 +04:00
|
|
|
update_write_order_info(context, s, &orderInfo, offset);
|
2013-05-10 00:30:28 +04:00
|
|
|
update->numberOrders++;
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2013-05-07 19:41:32 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_send_glyph_index(rdpContext* context, GLYPH_INDEX_ORDER* glyph_index)
|
2013-05-07 20:45:52 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
|
|
|
size_t offset = 0;
|
|
|
|
int headerLength = 0;
|
|
|
|
int inf = 0;
|
2013-05-07 20:45:52 +04:00
|
|
|
ORDER_INFO orderInfo;
|
2024-01-23 18:49:54 +03:00
|
|
|
rdp_update_internal* update = NULL;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(glyph_index);
|
|
|
|
update = update_cast(context->update);
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_GLYPH_INDEX);
|
2016-04-05 18:07:45 +03:00
|
|
|
inf = update_approximate_glyph_index_order(&orderInfo, glyph_index);
|
|
|
|
update_check_flush(context, headerLength + inf);
|
2013-05-10 00:30:28 +04:00
|
|
|
s = update->us;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2013-05-10 03:41:32 +04:00
|
|
|
offset = Stream_GetPosition(s);
|
2013-05-07 20:45:52 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, headerLength))
|
|
|
|
return FALSE;
|
2013-05-10 00:30:28 +04:00
|
|
|
|
2016-07-19 17:15:38 +03:00
|
|
|
Stream_Seek(s, headerLength);
|
2013-05-07 20:45:52 +04:00
|
|
|
update_write_glyph_index_order(s, &orderInfo, glyph_index);
|
2013-05-10 03:41:32 +04:00
|
|
|
update_write_order_info(context, s, &orderInfo, offset);
|
2013-05-10 00:30:28 +04:00
|
|
|
update->numberOrders++;
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2013-05-07 20:45:52 +04:00
|
|
|
}
|
|
|
|
|
2013-07-29 04:21:43 +04:00
|
|
|
/*
|
|
|
|
* Secondary Drawing Orders
|
|
|
|
*/
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_send_cache_bitmap(rdpContext* context, const CACHE_BITMAP_ORDER* cache_bitmap)
|
2013-05-13 01:46:13 +04:00
|
|
|
{
|
2023-07-28 15:03:14 +03:00
|
|
|
const size_t headerLength = 6;
|
|
|
|
UINT16 extraFlags = 0;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(cache_bitmap);
|
2023-07-28 15:03:14 +03:00
|
|
|
rdp_update_internal* update = update_cast(context->update);
|
2022-01-11 18:01:33 +03:00
|
|
|
|
2023-07-28 15:03:14 +03:00
|
|
|
const BYTE orderType = cache_bitmap->compressed ? ORDER_TYPE_CACHE_BITMAP_COMPRESSED
|
|
|
|
: ORDER_TYPE_BITMAP_UNCOMPRESSED;
|
|
|
|
const size_t inf =
|
2019-11-06 17:24:51 +03:00
|
|
|
update_approximate_cache_bitmap_order(cache_bitmap, cache_bitmap->compressed, &extraFlags);
|
2016-04-05 18:07:45 +03:00
|
|
|
update_check_flush(context, headerLength + inf);
|
2023-07-28 15:03:14 +03:00
|
|
|
wStream* s = update->us;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
|
|
|
|
2023-07-28 15:03:14 +03:00
|
|
|
const size_t bm = Stream_GetPosition(s);
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, headerLength))
|
|
|
|
return FALSE;
|
|
|
|
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_Seek(s, headerLength);
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!update_write_cache_bitmap_order(s, cache_bitmap, cache_bitmap->compressed, &extraFlags))
|
2015-04-14 11:14:23 +03:00
|
|
|
return FALSE;
|
|
|
|
|
2023-07-28 15:03:14 +03:00
|
|
|
const size_t em = Stream_GetPosition(s);
|
|
|
|
WINPR_ASSERT(em >= bm + 13);
|
|
|
|
const size_t orderLength = (em - bm) - 13;
|
|
|
|
WINPR_ASSERT(orderLength <= UINT16_MAX);
|
|
|
|
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_SetPosition(s, bm);
|
2019-05-23 13:15:26 +03:00
|
|
|
Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY); /* controlFlags (1 byte) */
|
2023-07-28 15:03:14 +03:00
|
|
|
Stream_Write_UINT16(s, (UINT16)orderLength); /* orderLength (2 bytes) */
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT16(s, extraFlags); /* extraFlags (2 bytes) */
|
|
|
|
Stream_Write_UINT8(s, orderType); /* orderType (1 byte) */
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_SetPosition(s, em);
|
|
|
|
update->numberOrders++;
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2013-05-13 01:46:13 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_send_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2)
|
2013-05-07 07:21:12 +04:00
|
|
|
{
|
2023-07-28 15:03:14 +03:00
|
|
|
const size_t headerLength = 6;
|
|
|
|
UINT16 extraFlags = 0;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(cache_bitmap_v2);
|
2023-07-28 15:03:14 +03:00
|
|
|
rdp_update_internal* update = update_cast(context->update);
|
2022-01-11 18:01:33 +03:00
|
|
|
|
2023-07-28 15:03:14 +03:00
|
|
|
const BYTE orderType = cache_bitmap_v2->compressed ? ORDER_TYPE_BITMAP_COMPRESSED_V2
|
|
|
|
: ORDER_TYPE_BITMAP_UNCOMPRESSED_V2;
|
2013-05-10 05:04:41 +04:00
|
|
|
|
2013-07-29 04:21:43 +04:00
|
|
|
if (context->settings->NoBitmapCompressionHeader)
|
|
|
|
cache_bitmap_v2->flags |= CBR2_NO_BITMAP_COMPRESSION_HDR;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
update_check_flush(context, headerLength +
|
|
|
|
update_approximate_cache_bitmap_v2_order(
|
|
|
|
cache_bitmap_v2, cache_bitmap_v2->compressed, &extraFlags));
|
2023-07-28 15:03:14 +03:00
|
|
|
wStream* s = update->us;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
|
|
|
|
2023-07-28 15:03:14 +03:00
|
|
|
const size_t bm = Stream_GetPosition(s);
|
2013-05-10 00:30:28 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, headerLength))
|
|
|
|
return FALSE;
|
|
|
|
|
2013-05-10 00:30:28 +04:00
|
|
|
Stream_Seek(s, headerLength);
|
2013-05-07 07:21:12 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!update_write_cache_bitmap_v2_order(s, cache_bitmap_v2, cache_bitmap_v2->compressed,
|
|
|
|
&extraFlags))
|
2015-04-14 11:14:23 +03:00
|
|
|
return FALSE;
|
|
|
|
|
2023-07-28 15:03:14 +03:00
|
|
|
const size_t em = Stream_GetPosition(s);
|
|
|
|
WINPR_ASSERT(em >= bm + 13);
|
|
|
|
const size_t orderLength = (em - bm) - 13;
|
|
|
|
WINPR_ASSERT(orderLength <= UINT16_MAX);
|
|
|
|
|
2013-05-10 00:30:28 +04:00
|
|
|
Stream_SetPosition(s, bm);
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY); /* controlFlags (1 byte) */
|
2023-07-28 15:03:14 +03:00
|
|
|
Stream_Write_UINT16(s, (UINT16)orderLength); /* orderLength (2 bytes) */
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT16(s, extraFlags); /* extraFlags (2 bytes) */
|
|
|
|
Stream_Write_UINT8(s, orderType); /* orderType (1 byte) */
|
2013-05-10 00:30:28 +04:00
|
|
|
Stream_SetPosition(s, em);
|
|
|
|
update->numberOrders++;
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2013-05-07 07:21:12 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_send_cache_bitmap_v3(rdpContext* context, CACHE_BITMAP_V3_ORDER* cache_bitmap_v3)
|
2013-05-13 01:46:13 +04:00
|
|
|
{
|
2023-07-28 15:03:14 +03:00
|
|
|
const size_t headerLength = 6;
|
|
|
|
UINT16 extraFlags = 0;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(cache_bitmap_v3);
|
2023-07-28 15:03:14 +03:00
|
|
|
rdp_update_internal* update = update_cast(context->update);
|
2022-01-11 18:01:33 +03:00
|
|
|
|
2023-07-28 15:03:14 +03:00
|
|
|
const BYTE orderType = ORDER_TYPE_BITMAP_COMPRESSED_V3;
|
2019-11-06 17:24:51 +03:00
|
|
|
update_check_flush(context, headerLength + update_approximate_cache_bitmap_v3_order(
|
|
|
|
cache_bitmap_v3, &extraFlags));
|
2023-07-28 15:03:14 +03:00
|
|
|
wStream* s = update->us;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
|
|
|
|
2023-07-28 15:03:14 +03:00
|
|
|
const size_t bm = Stream_GetPosition(s);
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, headerLength))
|
|
|
|
return FALSE;
|
|
|
|
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_Seek(s, headerLength);
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!update_write_cache_bitmap_v3_order(s, cache_bitmap_v3, &extraFlags))
|
|
|
|
return FALSE;
|
|
|
|
|
2023-07-28 15:03:14 +03:00
|
|
|
const size_t em = Stream_GetPosition(s);
|
|
|
|
WINPR_ASSERT(em >= bm + 13);
|
|
|
|
const size_t orderLength = (em - bm) - 13;
|
|
|
|
WINPR_ASSERT(orderLength <= UINT16_MAX);
|
|
|
|
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_SetPosition(s, bm);
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY); /* controlFlags (1 byte) */
|
2023-07-28 15:03:14 +03:00
|
|
|
Stream_Write_UINT16(s, (UINT16)orderLength); /* orderLength (2 bytes) */
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT16(s, extraFlags); /* extraFlags (2 bytes) */
|
|
|
|
Stream_Write_UINT8(s, orderType); /* orderType (1 byte) */
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_SetPosition(s, em);
|
|
|
|
update->numberOrders++;
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2013-05-13 01:46:13 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL update_send_cache_color_table(rdpContext* context,
|
2019-11-06 17:24:51 +03:00
|
|
|
const CACHE_COLOR_TABLE_ORDER* cache_color_table)
|
2013-05-13 01:46:13 +04:00
|
|
|
{
|
2023-07-28 15:03:14 +03:00
|
|
|
UINT16 flags = 0;
|
|
|
|
size_t headerLength = 6;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(cache_color_table);
|
2023-07-28 15:03:14 +03:00
|
|
|
rdp_update_internal* update = update_cast(context->update);
|
2022-01-11 18:01:33 +03:00
|
|
|
|
2023-07-28 15:03:14 +03:00
|
|
|
const size_t inf = update_approximate_cache_color_table_order(cache_color_table, &flags);
|
2016-04-05 18:07:45 +03:00
|
|
|
update_check_flush(context, headerLength + inf);
|
2023-07-28 15:03:14 +03:00
|
|
|
wStream* s = update->us;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
|
|
|
|
2023-07-28 15:03:14 +03:00
|
|
|
const size_t bm = Stream_GetPosition(s);
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, headerLength))
|
|
|
|
return FALSE;
|
|
|
|
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_Seek(s, headerLength);
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!update_write_cache_color_table_order(s, cache_color_table, &flags))
|
|
|
|
return FALSE;
|
|
|
|
|
2023-07-28 15:03:14 +03:00
|
|
|
const size_t em = Stream_GetPosition(s);
|
|
|
|
WINPR_ASSERT(em >= bm + 13);
|
|
|
|
const size_t orderLength = (em - bm) - 13;
|
|
|
|
WINPR_ASSERT(orderLength <= UINT16_MAX);
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_SetPosition(s, bm);
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY); /* controlFlags (1 byte) */
|
2023-07-28 15:03:14 +03:00
|
|
|
Stream_Write_UINT16(s, (UINT16)orderLength); /* orderLength (2 bytes) */
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT16(s, flags); /* extraFlags (2 bytes) */
|
|
|
|
Stream_Write_UINT8(s, ORDER_TYPE_CACHE_COLOR_TABLE); /* orderType (1 byte) */
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_SetPosition(s, em);
|
|
|
|
update->numberOrders++;
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2013-05-13 01:46:13 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_send_cache_glyph(rdpContext* context, const CACHE_GLYPH_ORDER* cache_glyph)
|
2013-05-08 02:44:22 +04:00
|
|
|
{
|
2023-07-28 15:03:14 +03:00
|
|
|
UINT16 flags = 0;
|
|
|
|
const size_t headerLength = 6;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(cache_glyph);
|
2023-07-28 15:03:14 +03:00
|
|
|
rdp_update_internal* update = update_cast(context->update);
|
2022-01-11 18:01:33 +03:00
|
|
|
|
2023-07-28 15:03:14 +03:00
|
|
|
const size_t inf = update_approximate_cache_glyph_order(cache_glyph, &flags);
|
2016-04-05 18:07:45 +03:00
|
|
|
update_check_flush(context, headerLength + inf);
|
2023-07-28 15:03:14 +03:00
|
|
|
wStream* s = update->us;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
|
|
|
|
2023-07-28 15:03:14 +03:00
|
|
|
const size_t bm = Stream_GetPosition(s);
|
2013-05-10 00:30:28 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, headerLength))
|
|
|
|
return FALSE;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2013-05-10 00:30:28 +04:00
|
|
|
Stream_Seek(s, headerLength);
|
2013-05-08 02:44:22 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!update_write_cache_glyph_order(s, cache_glyph, &flags))
|
|
|
|
return FALSE;
|
|
|
|
|
2023-07-28 15:03:14 +03:00
|
|
|
const size_t em = Stream_GetPosition(s);
|
|
|
|
WINPR_ASSERT(em >= bm + 13);
|
|
|
|
const size_t orderLength = (em - bm) - 13;
|
|
|
|
WINPR_ASSERT(orderLength <= UINT16_MAX);
|
2013-05-10 00:30:28 +04:00
|
|
|
Stream_SetPosition(s, bm);
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY); /* controlFlags (1 byte) */
|
2023-07-28 15:03:14 +03:00
|
|
|
Stream_Write_UINT16(s, (UINT16)orderLength); /* orderLength (2 bytes) */
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT16(s, flags); /* extraFlags (2 bytes) */
|
|
|
|
Stream_Write_UINT8(s, ORDER_TYPE_CACHE_GLYPH); /* orderType (1 byte) */
|
2013-05-10 00:30:28 +04:00
|
|
|
Stream_SetPosition(s, em);
|
|
|
|
update->numberOrders++;
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2013-05-08 02:44:22 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL update_send_cache_glyph_v2(rdpContext* context,
|
2016-07-19 17:15:38 +03:00
|
|
|
const CACHE_GLYPH_V2_ORDER* cache_glyph_v2)
|
2013-05-07 19:41:32 +04:00
|
|
|
{
|
2023-07-28 15:03:14 +03:00
|
|
|
UINT16 flags = 0;
|
|
|
|
const size_t headerLength = 6;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(cache_glyph_v2);
|
2023-07-28 15:03:14 +03:00
|
|
|
rdp_update_internal* update = update_cast(context->update);
|
2022-01-11 18:01:33 +03:00
|
|
|
|
2023-07-28 15:03:14 +03:00
|
|
|
const size_t inf = update_approximate_cache_glyph_v2_order(cache_glyph_v2, &flags);
|
2016-04-05 18:07:45 +03:00
|
|
|
update_check_flush(context, headerLength + inf);
|
2023-07-28 15:03:14 +03:00
|
|
|
wStream* s = update->us;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
|
|
|
|
2023-07-28 15:03:14 +03:00
|
|
|
const size_t bm = Stream_GetPosition(s);
|
2013-05-10 00:30:28 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, headerLength))
|
|
|
|
return FALSE;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2013-05-10 00:30:28 +04:00
|
|
|
Stream_Seek(s, headerLength);
|
2013-05-07 19:41:32 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!update_write_cache_glyph_v2_order(s, cache_glyph_v2, &flags))
|
|
|
|
return FALSE;
|
|
|
|
|
2023-07-28 15:03:14 +03:00
|
|
|
const size_t em = Stream_GetPosition(s);
|
|
|
|
WINPR_ASSERT(em >= bm + 13);
|
|
|
|
const size_t orderLength = (em - bm) - 13;
|
|
|
|
WINPR_ASSERT(orderLength <= UINT16_MAX);
|
2013-05-10 00:30:28 +04:00
|
|
|
Stream_SetPosition(s, bm);
|
2017-12-11 12:25:21 +03:00
|
|
|
Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY); /* controlFlags (1 byte) */
|
2023-07-28 15:03:14 +03:00
|
|
|
Stream_Write_UINT16(s, (UINT16)orderLength); /* orderLength (2 bytes) */
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT16(s, flags); /* extraFlags (2 bytes) */
|
|
|
|
Stream_Write_UINT8(s, ORDER_TYPE_CACHE_GLYPH); /* orderType (1 byte) */
|
2013-05-10 00:30:28 +04:00
|
|
|
Stream_SetPosition(s, em);
|
|
|
|
update->numberOrders++;
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2013-05-07 19:41:32 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_send_cache_brush(rdpContext* context, const CACHE_BRUSH_ORDER* cache_brush)
|
2013-05-13 01:46:13 +04:00
|
|
|
{
|
2023-07-28 15:03:14 +03:00
|
|
|
UINT16 flags = 0;
|
|
|
|
const size_t headerLength = 6;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(cache_brush);
|
2023-07-28 15:03:14 +03:00
|
|
|
rdp_update_internal* update = update_cast(context->update);
|
2022-01-11 18:01:33 +03:00
|
|
|
|
2023-07-28 15:03:14 +03:00
|
|
|
const size_t inf = update_approximate_cache_brush_order(cache_brush, &flags);
|
2016-04-05 18:07:45 +03:00
|
|
|
update_check_flush(context, headerLength + inf);
|
2023-07-28 15:03:14 +03:00
|
|
|
wStream* s = update->us;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2023-07-28 15:03:14 +03:00
|
|
|
const size_t bm = Stream_GetPosition(s);
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, headerLength))
|
|
|
|
return FALSE;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_Seek(s, headerLength);
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!update_write_cache_brush_order(s, cache_brush, &flags))
|
|
|
|
return FALSE;
|
|
|
|
|
2023-07-28 15:03:14 +03:00
|
|
|
const size_t em = Stream_GetPosition(s);
|
|
|
|
WINPR_ASSERT(em > bm + 13);
|
|
|
|
const size_t orderLength = (em - bm) - 13;
|
|
|
|
WINPR_ASSERT(orderLength <= UINT16_MAX);
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_SetPosition(s, bm);
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY); /* controlFlags (1 byte) */
|
2023-07-28 15:03:14 +03:00
|
|
|
Stream_Write_UINT16(s, (UINT16)orderLength); /* orderLength (2 bytes) */
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT16(s, flags); /* extraFlags (2 bytes) */
|
|
|
|
Stream_Write_UINT8(s, ORDER_TYPE_CACHE_BRUSH); /* orderType (1 byte) */
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_SetPosition(s, em);
|
|
|
|
update->numberOrders++;
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2013-05-13 01:46:13 +04:00
|
|
|
}
|
|
|
|
|
2013-07-29 04:21:43 +04:00
|
|
|
/**
|
|
|
|
* Alternate Secondary Drawing Orders
|
|
|
|
*/
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL update_send_create_offscreen_bitmap_order(
|
2019-11-06 17:24:51 +03:00
|
|
|
rdpContext* context, const CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap)
|
2013-05-12 21:42:53 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
|
|
|
size_t bm = 0;
|
|
|
|
size_t em = 0;
|
|
|
|
size_t inf = 0;
|
|
|
|
BYTE orderType = 0;
|
|
|
|
BYTE controlFlags = 0;
|
|
|
|
size_t headerLength = 0;
|
|
|
|
rdp_update_internal* update = NULL;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(create_offscreen_bitmap);
|
|
|
|
update = update_cast(context->update);
|
|
|
|
|
2013-05-12 21:42:53 +04:00
|
|
|
headerLength = 1;
|
|
|
|
orderType = ORDER_TYPE_CREATE_OFFSCREEN_BITMAP;
|
|
|
|
controlFlags = ORDER_SECONDARY | (orderType << 2);
|
2019-11-06 17:24:51 +03:00
|
|
|
inf = update_approximate_create_offscreen_bitmap_order(create_offscreen_bitmap);
|
2016-04-05 18:07:45 +03:00
|
|
|
update_check_flush(context, headerLength + inf);
|
2022-09-30 12:00:53 +03:00
|
|
|
|
2013-05-12 21:42:53 +04:00
|
|
|
s = update->us;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2013-05-12 21:42:53 +04:00
|
|
|
bm = Stream_GetPosition(s);
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, headerLength))
|
|
|
|
return FALSE;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2013-05-12 21:42:53 +04:00
|
|
|
Stream_Seek(s, headerLength);
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!update_write_create_offscreen_bitmap_order(s, create_offscreen_bitmap))
|
|
|
|
return FALSE;
|
2013-05-12 21:42:53 +04:00
|
|
|
|
2016-07-19 17:15:38 +03:00
|
|
|
em = Stream_GetPosition(s);
|
2013-05-12 21:42:53 +04:00
|
|
|
Stream_SetPosition(s, bm);
|
|
|
|
Stream_Write_UINT8(s, controlFlags); /* controlFlags (1 byte) */
|
|
|
|
Stream_SetPosition(s, em);
|
|
|
|
update->numberOrders++;
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2013-05-12 21:42:53 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_send_switch_surface_order(rdpContext* context,
|
|
|
|
const SWITCH_SURFACE_ORDER* switch_surface)
|
2013-05-12 21:42:53 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
|
|
|
size_t bm = 0;
|
|
|
|
size_t em = 0;
|
|
|
|
size_t inf = 0;
|
|
|
|
BYTE orderType = 0;
|
|
|
|
BYTE controlFlags = 0;
|
|
|
|
size_t headerLength = 0;
|
|
|
|
rdp_update_internal* update = NULL;
|
2017-05-17 16:58:44 +03:00
|
|
|
|
2022-01-11 18:01:33 +03:00
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(switch_surface);
|
|
|
|
update = update_cast(context->update);
|
2017-05-17 16:58:44 +03:00
|
|
|
|
2013-05-12 21:42:53 +04:00
|
|
|
headerLength = 1;
|
|
|
|
orderType = ORDER_TYPE_SWITCH_SURFACE;
|
|
|
|
controlFlags = ORDER_SECONDARY | (orderType << 2);
|
2019-11-06 17:24:51 +03:00
|
|
|
inf = update_approximate_switch_surface_order(switch_surface);
|
2016-04-05 18:07:45 +03:00
|
|
|
update_check_flush(context, headerLength + inf);
|
2013-05-12 21:42:53 +04:00
|
|
|
s = update->us;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2013-05-12 21:42:53 +04:00
|
|
|
bm = Stream_GetPosition(s);
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, headerLength))
|
|
|
|
return FALSE;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2013-05-12 21:42:53 +04:00
|
|
|
Stream_Seek(s, headerLength);
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!update_write_switch_surface_order(s, switch_surface))
|
|
|
|
return FALSE;
|
2013-05-12 21:42:53 +04:00
|
|
|
|
2016-07-19 17:15:38 +03:00
|
|
|
em = Stream_GetPosition(s);
|
2013-05-12 21:42:53 +04:00
|
|
|
Stream_SetPosition(s, bm);
|
|
|
|
Stream_Write_UINT8(s, controlFlags); /* controlFlags (1 byte) */
|
|
|
|
Stream_SetPosition(s, em);
|
|
|
|
update->numberOrders++;
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2013-05-12 21:42:53 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL update_send_pointer_system(rdpContext* context,
|
2016-07-19 17:15:38 +03:00
|
|
|
const POINTER_SYSTEM_UPDATE* pointer_system)
|
2011-08-25 13:03:53 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
|
|
|
BYTE updateCode = 0;
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
2011-11-22 03:11:43 +04:00
|
|
|
rdpRdp* rdp = context->rdp;
|
2024-01-23 18:49:54 +03:00
|
|
|
BOOL ret = 0;
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(rdp);
|
2011-08-25 13:03:53 +04:00
|
|
|
s = fastpath_update_pdu_init(rdp->fastpath);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
2012-09-17 05:05:51 +04:00
|
|
|
|
2011-08-25 13:03:53 +04:00
|
|
|
if (pointer_system->type == SYSPTR_NULL)
|
2011-12-03 10:42:13 +04:00
|
|
|
updateCode = FASTPATH_UPDATETYPE_PTR_NULL;
|
2011-08-25 13:03:53 +04:00
|
|
|
else
|
2011-12-03 10:42:13 +04:00
|
|
|
updateCode = FASTPATH_UPDATETYPE_PTR_DEFAULT;
|
2014-07-16 17:38:10 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
ret = fastpath_send_update_pdu(rdp->fastpath, updateCode, s, FALSE);
|
2013-06-13 12:56:06 +04:00
|
|
|
Stream_Release(s);
|
2015-04-14 11:14:23 +03:00
|
|
|
return ret;
|
2011-08-25 13:03:53 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL update_send_pointer_position(rdpContext* context,
|
2019-11-06 17:24:51 +03:00
|
|
|
const POINTER_POSITION_UPDATE* pointerPosition)
|
2014-11-07 01:25:41 +03:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(context);
|
2014-11-07 01:25:41 +03:00
|
|
|
rdpRdp* rdp = context->rdp;
|
2015-04-14 11:14:23 +03:00
|
|
|
BOOL ret = FALSE;
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(rdp);
|
2014-11-07 01:25:41 +03:00
|
|
|
s = fastpath_update_pdu_init(rdp->fastpath);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
2014-11-07 01:25:41 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, 16))
|
|
|
|
goto out_fail;
|
2014-11-07 01:25:41 +03:00
|
|
|
|
|
|
|
Stream_Write_UINT16(s, pointerPosition->xPos); /* xPos (2 bytes) */
|
|
|
|
Stream_Write_UINT16(s, pointerPosition->yPos); /* yPos (2 bytes) */
|
2019-11-06 17:24:51 +03:00
|
|
|
ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_PTR_POSITION, s, FALSE);
|
2015-04-14 11:14:23 +03:00
|
|
|
out_fail:
|
2014-11-07 01:25:41 +03:00
|
|
|
Stream_Release(s);
|
2015-04-14 11:14:23 +03:00
|
|
|
return ret;
|
2014-11-07 01:25:41 +03:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_write_pointer_color(wStream* s, const POINTER_COLOR_UPDATE* pointer_color)
|
2011-12-03 04:54:02 +04:00
|
|
|
{
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(pointer_color);
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, 32 + pointer_color->lengthAndMask +
|
|
|
|
pointer_color->lengthXorMask))
|
2015-04-14 11:14:23 +03:00
|
|
|
return FALSE;
|
2012-09-17 05:05:51 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, pointer_color->cacheIndex);
|
2023-04-14 08:35:21 +03:00
|
|
|
Stream_Write_UINT16(s, pointer_color->hotSpotX);
|
|
|
|
Stream_Write_UINT16(s, pointer_color->hotSpotY);
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, pointer_color->width);
|
|
|
|
Stream_Write_UINT16(s, pointer_color->height);
|
|
|
|
Stream_Write_UINT16(s, pointer_color->lengthAndMask);
|
|
|
|
Stream_Write_UINT16(s, pointer_color->lengthXorMask);
|
2012-09-17 05:05:51 +04:00
|
|
|
|
2011-12-03 04:54:02 +04:00
|
|
|
if (pointer_color->lengthXorMask > 0)
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write(s, pointer_color->xorMaskData, pointer_color->lengthXorMask);
|
2014-07-16 17:38:10 +04:00
|
|
|
|
2011-12-03 04:54:02 +04:00
|
|
|
if (pointer_color->lengthAndMask > 0)
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write(s, pointer_color->andMaskData, pointer_color->lengthAndMask);
|
2014-07-16 17:38:10 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, 0); /* pad (1 byte) */
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2011-12-03 04:54:02 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL update_send_pointer_color(rdpContext* context,
|
2016-07-19 17:15:38 +03:00
|
|
|
const POINTER_COLOR_UPDATE* pointer_color)
|
2011-12-03 04:54:02 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
2011-12-03 04:54:02 +04:00
|
|
|
rdpRdp* rdp = context->rdp;
|
2015-04-14 11:14:23 +03:00
|
|
|
BOOL ret = FALSE;
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(rdp);
|
|
|
|
WINPR_ASSERT(pointer_color);
|
2011-12-03 04:54:02 +04:00
|
|
|
s = fastpath_update_pdu_init(rdp->fastpath);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
|
|
|
|
2015-04-17 17:21:55 +03:00
|
|
|
if (!update_write_pointer_color(s, pointer_color))
|
2015-04-14 11:14:23 +03:00
|
|
|
goto out_fail;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_COLOR, s, FALSE);
|
2015-04-14 11:14:23 +03:00
|
|
|
out_fail:
|
2013-06-13 12:56:06 +04:00
|
|
|
Stream_Release(s);
|
2015-04-14 11:14:23 +03:00
|
|
|
return ret;
|
2011-12-03 04:54:02 +04:00
|
|
|
}
|
|
|
|
|
2019-12-19 11:35:53 +03:00
|
|
|
static BOOL update_write_pointer_large(wStream* s, const POINTER_LARGE_UPDATE* pointer)
|
|
|
|
{
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(pointer);
|
|
|
|
|
2019-12-19 11:35:53 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, 32 + pointer->lengthAndMask + pointer->lengthXorMask))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Write_UINT16(s, pointer->xorBpp);
|
|
|
|
Stream_Write_UINT16(s, pointer->cacheIndex);
|
|
|
|
Stream_Write_UINT16(s, pointer->hotSpotX);
|
|
|
|
Stream_Write_UINT16(s, pointer->hotSpotY);
|
|
|
|
Stream_Write_UINT16(s, pointer->width);
|
|
|
|
Stream_Write_UINT16(s, pointer->height);
|
|
|
|
Stream_Write_UINT32(s, pointer->lengthAndMask);
|
|
|
|
Stream_Write_UINT32(s, pointer->lengthXorMask);
|
|
|
|
Stream_Write(s, pointer->xorMaskData, pointer->lengthXorMask);
|
|
|
|
Stream_Write(s, pointer->andMaskData, pointer->lengthAndMask);
|
|
|
|
Stream_Write_UINT8(s, 0); /* pad (1 byte) */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL update_send_pointer_large(rdpContext* context, const POINTER_LARGE_UPDATE* pointer)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(context);
|
2019-12-19 11:35:53 +03:00
|
|
|
rdpRdp* rdp = context->rdp;
|
|
|
|
BOOL ret = FALSE;
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(rdp);
|
|
|
|
WINPR_ASSERT(pointer);
|
2019-12-19 11:35:53 +03:00
|
|
|
s = fastpath_update_pdu_init(rdp->fastpath);
|
|
|
|
|
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!update_write_pointer_large(s, pointer))
|
|
|
|
goto out_fail;
|
|
|
|
|
|
|
|
ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_LARGE_POINTER, s, FALSE);
|
|
|
|
out_fail:
|
|
|
|
Stream_Release(s);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_send_pointer_new(rdpContext* context, const POINTER_NEW_UPDATE* pointer_new)
|
2011-12-03 04:54:02 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
2011-12-03 04:54:02 +04:00
|
|
|
rdpRdp* rdp = context->rdp;
|
2015-04-14 11:14:23 +03:00
|
|
|
BOOL ret = FALSE;
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(rdp);
|
|
|
|
WINPR_ASSERT(pointer_new);
|
2011-12-03 04:54:02 +04:00
|
|
|
s = fastpath_update_pdu_init(rdp->fastpath);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
2014-11-07 01:25:41 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, 16))
|
|
|
|
goto out_fail;
|
2014-11-07 01:25:41 +03:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, pointer_new->xorBpp); /* xorBpp (2 bytes) */
|
2016-04-05 18:07:45 +03:00
|
|
|
update_write_pointer_color(s, &pointer_new->colorPtrAttr);
|
2019-11-06 17:24:51 +03:00
|
|
|
ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_POINTER, s, FALSE);
|
2015-04-14 11:14:23 +03:00
|
|
|
out_fail:
|
2013-06-13 12:56:06 +04:00
|
|
|
Stream_Release(s);
|
2015-04-14 11:14:23 +03:00
|
|
|
return ret;
|
2011-12-03 04:54:02 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL update_send_pointer_cached(rdpContext* context,
|
2016-07-19 17:15:38 +03:00
|
|
|
const POINTER_CACHED_UPDATE* pointer_cached)
|
2011-12-03 04:54:02 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
2011-12-03 04:54:02 +04:00
|
|
|
rdpRdp* rdp = context->rdp;
|
2024-01-23 18:49:54 +03:00
|
|
|
BOOL ret = 0;
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(rdp);
|
|
|
|
WINPR_ASSERT(pointer_cached);
|
2011-12-03 04:54:02 +04:00
|
|
|
s = fastpath_update_pdu_init(rdp->fastpath);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, pointer_cached->cacheIndex); /* cacheIndex (2 bytes) */
|
2019-11-06 17:24:51 +03:00
|
|
|
ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_CACHED, s, FALSE);
|
2013-06-13 12:56:06 +04:00
|
|
|
Stream_Release(s);
|
2015-04-14 11:14:23 +03:00
|
|
|
return ret;
|
2011-12-03 04:54:02 +04:00
|
|
|
}
|
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
BOOL update_read_refresh_rect(rdpUpdate* update, wStream* s)
|
2012-05-26 17:34:09 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE numberOfAreas = 0;
|
2022-09-30 12:00:53 +03:00
|
|
|
RECTANGLE_16 areas[256] = { 0 };
|
2022-01-11 18:01:33 +03:00
|
|
|
rdp_update_internal* up = update_cast(update);
|
2012-05-26 17:34:09 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2012-05-26 17:34:09 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, numberOfAreas);
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, 3); /* pad3Octects */
|
2012-05-26 17:34:09 +04:00
|
|
|
|
2023-01-24 16:53:36 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, numberOfAreas, 8ull))
|
2013-01-14 02:37:50 +04:00
|
|
|
return FALSE;
|
2013-05-02 02:15:55 +04:00
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
for (BYTE index = 0; index < numberOfAreas; index++)
|
2022-04-19 15:29:17 +03:00
|
|
|
{
|
2022-09-30 12:00:53 +03:00
|
|
|
RECTANGLE_16* area = &areas[index];
|
2012-09-16 01:51:05 +04:00
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
Stream_Read_UINT16(s, area->left);
|
|
|
|
Stream_Read_UINT16(s, area->top);
|
|
|
|
Stream_Read_UINT16(s, area->right);
|
|
|
|
Stream_Read_UINT16(s, area->bottom);
|
2012-09-16 01:51:05 +04:00
|
|
|
}
|
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(update->context);
|
|
|
|
WINPR_ASSERT(update->context->settings);
|
2015-02-18 21:33:19 +03:00
|
|
|
if (update->context->settings->RefreshRect)
|
|
|
|
IFCALL(update->RefreshRect, update->context, numberOfAreas, areas);
|
|
|
|
else
|
2022-01-11 18:01:33 +03:00
|
|
|
WLog_Print(up->log, WLOG_WARN, "ignoring refresh rect request from client");
|
2012-09-16 01:51:05 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2012-05-26 17:34:09 +04:00
|
|
|
}
|
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
BOOL update_read_suppress_output(rdpUpdate* update, wStream* s)
|
2012-05-26 17:34:09 +04:00
|
|
|
{
|
2022-01-11 18:01:33 +03:00
|
|
|
rdp_update_internal* up = update_cast(update);
|
2020-03-03 15:10:24 +03:00
|
|
|
RECTANGLE_16* prect = NULL;
|
|
|
|
RECTANGLE_16 rect = { 0 };
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE allowDisplayUpdates = 0;
|
2012-05-26 17:34:09 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
WINPR_ASSERT(up);
|
|
|
|
WINPR_ASSERT(s);
|
|
|
|
|
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2012-05-26 17:34:09 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, allowDisplayUpdates);
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, 3); /* pad3Octects */
|
2012-09-17 05:05:51 +04:00
|
|
|
|
2020-03-03 15:10:24 +03:00
|
|
|
if (allowDisplayUpdates > 0)
|
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, sizeof(RECTANGLE_16)))
|
2020-03-03 15:10:24 +03:00
|
|
|
return FALSE;
|
2022-04-19 15:29:17 +03:00
|
|
|
|
2020-03-03 15:10:24 +03:00
|
|
|
Stream_Read_UINT16(s, rect.left);
|
|
|
|
Stream_Read_UINT16(s, rect.top);
|
|
|
|
Stream_Read_UINT16(s, rect.right);
|
|
|
|
Stream_Read_UINT16(s, rect.bottom);
|
|
|
|
|
|
|
|
prect = ▭
|
|
|
|
}
|
2012-05-26 17:34:09 +04:00
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(update->context);
|
|
|
|
WINPR_ASSERT(update->context->settings);
|
2015-02-18 21:33:19 +03:00
|
|
|
if (update->context->settings->SuppressOutput)
|
2020-03-03 15:10:24 +03:00
|
|
|
IFCALL(update->SuppressOutput, update->context, allowDisplayUpdates, prect);
|
2015-02-18 21:33:19 +03:00
|
|
|
else
|
2022-01-11 18:01:33 +03:00
|
|
|
WLog_Print(up->log, WLOG_WARN, "ignoring suppress output request from client");
|
2012-05-26 17:34:09 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2012-05-26 17:34:09 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_send_set_keyboard_indicators(rdpContext* context, UINT16 led_flags)
|
2014-09-30 20:18:29 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
2014-11-07 01:25:41 +03:00
|
|
|
rdpRdp* rdp = context->rdp;
|
|
|
|
s = rdp_data_pdu_init(rdp);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT16(s, 0); /* unitId should be 0 according to MS-RDPBCGR 2.2.8.2.1.1 */
|
2014-11-07 01:25:41 +03:00
|
|
|
Stream_Write_UINT16(s, led_flags); /* ledFlags (2 bytes) */
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(rdp->mcs);
|
2019-11-06 17:24:51 +03:00
|
|
|
return rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_SET_KEYBOARD_INDICATORS, rdp->mcs->userId);
|
2014-09-30 20:18:29 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_send_set_keyboard_ime_status(rdpContext* context, UINT16 imeId, UINT32 imeState,
|
|
|
|
UINT32 imeConvMode)
|
2017-05-12 10:43:58 +03:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
2017-05-12 10:43:58 +03:00
|
|
|
rdpRdp* rdp = context->rdp;
|
|
|
|
s = rdp_data_pdu_init(rdp);
|
|
|
|
|
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* unitId should be 0 according to MS-RDPBCGR 2.2.8.2.2.1 */
|
|
|
|
Stream_Write_UINT16(s, imeId);
|
|
|
|
Stream_Write_UINT32(s, imeState);
|
|
|
|
Stream_Write_UINT32(s, imeConvMode);
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(rdp->mcs);
|
2019-11-06 17:24:51 +03:00
|
|
|
return rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_SET_KEYBOARD_IME_STATUS, rdp->mcs->userId);
|
2017-05-12 10:43:58 +03:00
|
|
|
}
|
|
|
|
|
2019-12-17 12:16:54 +03:00
|
|
|
static UINT16 update_calculate_new_or_existing_window(const WINDOW_ORDER_INFO* orderInfo,
|
|
|
|
const WINDOW_STATE_ORDER* stateOrder)
|
|
|
|
{
|
|
|
|
UINT16 orderSize = 11;
|
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(orderInfo);
|
|
|
|
WINPR_ASSERT(stateOrder);
|
|
|
|
|
2019-12-17 12:16:54 +03:00
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_OWNER) != 0)
|
|
|
|
orderSize += 4;
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_STYLE) != 0)
|
|
|
|
orderSize += 8;
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_SHOW) != 0)
|
|
|
|
orderSize += 1;
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_TITLE) != 0)
|
|
|
|
orderSize += 2 + stateOrder->titleInfo.length;
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET) != 0)
|
|
|
|
orderSize += 8;
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE) != 0)
|
|
|
|
orderSize += 8;
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_RESIZE_MARGIN_X) != 0)
|
|
|
|
orderSize += 8;
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_RESIZE_MARGIN_Y) != 0)
|
|
|
|
orderSize += 8;
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_RP_CONTENT) != 0)
|
|
|
|
orderSize += 1;
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_ROOT_PARENT) != 0)
|
|
|
|
orderSize += 4;
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET) != 0)
|
|
|
|
orderSize += 8;
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA) != 0)
|
|
|
|
orderSize += 8;
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE) != 0)
|
|
|
|
orderSize += 8;
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS) != 0)
|
|
|
|
orderSize += 2 + stateOrder->numWindowRects * sizeof(RECTANGLE_16);
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VIS_OFFSET) != 0)
|
|
|
|
orderSize += 8;
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY) != 0)
|
|
|
|
orderSize += 2 + stateOrder->numVisibilityRects * sizeof(RECTANGLE_16);
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_OVERLAY_DESCRIPTION) != 0)
|
|
|
|
orderSize += 2 + stateOrder->OverlayDescription.length;
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_TASKBAR_BUTTON) != 0)
|
|
|
|
orderSize += 1;
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_ENFORCE_SERVER_ZORDER) != 0)
|
|
|
|
orderSize += 1;
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_APPBAR_STATE) != 0)
|
|
|
|
orderSize += 1;
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_APPBAR_EDGE) != 0)
|
|
|
|
orderSize += 1;
|
|
|
|
|
|
|
|
return orderSize;
|
|
|
|
}
|
|
|
|
|
2020-01-15 13:11:24 +03:00
|
|
|
static BOOL update_send_new_or_existing_window(rdpContext* context,
|
|
|
|
const WINDOW_ORDER_INFO* orderInfo,
|
|
|
|
const WINDOW_STATE_ORDER* stateOrder)
|
2019-07-08 11:42:51 +03:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2019-07-08 11:42:51 +03:00
|
|
|
BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2);
|
2020-01-15 12:18:45 +03:00
|
|
|
UINT16 orderSize = update_calculate_new_or_existing_window(orderInfo, stateOrder);
|
2024-01-23 18:49:54 +03:00
|
|
|
rdp_update_internal* update = NULL;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(orderInfo);
|
|
|
|
WINPR_ASSERT(stateOrder);
|
|
|
|
|
2022-01-11 18:01:33 +03:00
|
|
|
update = update_cast(context->update);
|
2020-01-15 12:18:45 +03:00
|
|
|
|
|
|
|
update_check_flush(context, orderSize);
|
|
|
|
|
2019-07-08 11:42:51 +03:00
|
|
|
s = update->us;
|
|
|
|
|
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
|
|
|
|
2019-12-17 12:16:54 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, orderSize))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Write_UINT8(s, controlFlags); /* Header (1 byte) */
|
|
|
|
Stream_Write_UINT16(s, orderSize); /* OrderSize (2 bytes) */
|
2019-07-08 11:42:51 +03:00
|
|
|
Stream_Write_UINT32(s, orderInfo->fieldFlags); /* FieldsPresentFlags (4 bytes) */
|
|
|
|
Stream_Write_UINT32(s, orderInfo->windowId); /* WindowID (4 bytes) */
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_OWNER) != 0)
|
|
|
|
Stream_Write_UINT32(s, stateOrder->ownerWindowId);
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_STYLE) != 0)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT32(s, stateOrder->style);
|
|
|
|
Stream_Write_UINT32(s, stateOrder->extendedStyle);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_SHOW) != 0)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT8(s, stateOrder->showState);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_TITLE) != 0)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT16(s, stateOrder->titleInfo.length);
|
|
|
|
Stream_Write(s, stateOrder->titleInfo.string, stateOrder->titleInfo.length);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET) != 0)
|
|
|
|
{
|
2020-01-15 12:20:54 +03:00
|
|
|
Stream_Write_INT32(s, stateOrder->clientOffsetX);
|
|
|
|
Stream_Write_INT32(s, stateOrder->clientOffsetY);
|
2019-07-08 11:42:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE) != 0)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT32(s, stateOrder->clientAreaWidth);
|
|
|
|
Stream_Write_UINT32(s, stateOrder->clientAreaHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_RESIZE_MARGIN_X) != 0)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT32(s, stateOrder->resizeMarginLeft);
|
|
|
|
Stream_Write_UINT32(s, stateOrder->resizeMarginRight);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_RESIZE_MARGIN_Y) != 0)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT32(s, stateOrder->resizeMarginTop);
|
|
|
|
Stream_Write_UINT32(s, stateOrder->resizeMarginBottom);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_RP_CONTENT) != 0)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT8(s, stateOrder->RPContent);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_ROOT_PARENT) != 0)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT32(s, stateOrder->rootParentHandle);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET) != 0)
|
|
|
|
{
|
2020-01-15 12:20:54 +03:00
|
|
|
Stream_Write_INT32(s, stateOrder->windowOffsetX);
|
|
|
|
Stream_Write_INT32(s, stateOrder->windowOffsetY);
|
2019-07-08 11:42:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA) != 0)
|
|
|
|
{
|
2020-01-15 12:20:54 +03:00
|
|
|
Stream_Write_INT32(s, stateOrder->windowClientDeltaX);
|
|
|
|
Stream_Write_INT32(s, stateOrder->windowClientDeltaY);
|
2019-07-08 11:42:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE) != 0)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT32(s, stateOrder->windowWidth);
|
|
|
|
Stream_Write_UINT32(s, stateOrder->windowHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS) != 0)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT16(s, stateOrder->numWindowRects);
|
|
|
|
Stream_Write(s, stateOrder->windowRects, stateOrder->numWindowRects * sizeof(RECTANGLE_16));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VIS_OFFSET) != 0)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT32(s, stateOrder->visibleOffsetX);
|
|
|
|
Stream_Write_UINT32(s, stateOrder->visibleOffsetY);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY) != 0)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT16(s, stateOrder->numVisibilityRects);
|
|
|
|
Stream_Write(s, stateOrder->visibilityRects,
|
|
|
|
stateOrder->numVisibilityRects * sizeof(RECTANGLE_16));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_OVERLAY_DESCRIPTION) != 0)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT16(s, stateOrder->OverlayDescription.length);
|
|
|
|
Stream_Write(s, stateOrder->OverlayDescription.string,
|
|
|
|
stateOrder->OverlayDescription.length);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_TASKBAR_BUTTON) != 0)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT8(s, stateOrder->TaskbarButton);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_ENFORCE_SERVER_ZORDER) != 0)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT8(s, stateOrder->EnforceServerZOrder);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_APPBAR_STATE) != 0)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT8(s, stateOrder->AppBarState);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_APPBAR_EDGE) != 0)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT8(s, stateOrder->AppBarEdge);
|
|
|
|
}
|
|
|
|
|
|
|
|
update->numberOrders++;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-01-15 13:11:24 +03:00
|
|
|
static BOOL update_send_window_create(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
|
|
|
|
const WINDOW_STATE_ORDER* stateOrder)
|
2019-07-08 11:42:51 +03:00
|
|
|
{
|
|
|
|
return update_send_new_or_existing_window(context, orderInfo, stateOrder);
|
|
|
|
}
|
|
|
|
|
2020-01-15 13:11:24 +03:00
|
|
|
static BOOL update_send_window_update(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
|
|
|
|
const WINDOW_STATE_ORDER* stateOrder)
|
2019-07-08 11:42:51 +03:00
|
|
|
{
|
|
|
|
return update_send_new_or_existing_window(context, orderInfo, stateOrder);
|
|
|
|
}
|
|
|
|
|
2019-12-17 12:16:54 +03:00
|
|
|
static UINT16 update_calculate_window_icon_order(const WINDOW_ORDER_INFO* orderInfo,
|
|
|
|
const WINDOW_ICON_ORDER* iconOrder)
|
|
|
|
{
|
|
|
|
UINT16 orderSize = 23;
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(iconOrder);
|
2019-12-17 12:16:54 +03:00
|
|
|
ICON_INFO* iconInfo = iconOrder->iconInfo;
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(iconInfo);
|
2019-12-17 12:16:54 +03:00
|
|
|
|
|
|
|
orderSize += iconInfo->cbBitsColor + iconInfo->cbBitsMask;
|
|
|
|
|
|
|
|
if (iconInfo->bpp <= 8)
|
|
|
|
orderSize += 2 + iconInfo->cbColorTable;
|
|
|
|
|
|
|
|
return orderSize;
|
|
|
|
}
|
|
|
|
|
2020-01-15 13:11:24 +03:00
|
|
|
static BOOL update_send_window_icon(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
|
|
|
|
const WINDOW_ICON_ORDER* iconOrder)
|
2019-07-08 11:42:51 +03:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2019-07-08 11:42:51 +03:00
|
|
|
BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2);
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(iconOrder);
|
2019-07-08 11:42:51 +03:00
|
|
|
ICON_INFO* iconInfo = iconOrder->iconInfo;
|
2020-01-15 12:18:45 +03:00
|
|
|
UINT16 orderSize = update_calculate_window_icon_order(orderInfo, iconOrder);
|
2024-01-23 18:49:54 +03:00
|
|
|
rdp_update_internal* update = NULL;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(orderInfo);
|
|
|
|
WINPR_ASSERT(iconInfo);
|
|
|
|
|
2022-01-11 18:01:33 +03:00
|
|
|
update = update_cast(context->update);
|
2020-01-15 12:18:45 +03:00
|
|
|
|
|
|
|
update_check_flush(context, orderSize);
|
|
|
|
|
2019-07-08 11:42:51 +03:00
|
|
|
s = update->us;
|
|
|
|
|
2019-12-17 12:16:54 +03:00
|
|
|
if (!s || !iconInfo)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!Stream_EnsureRemainingCapacity(s, orderSize))
|
2019-07-08 11:42:51 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* Write Hdr */
|
2019-12-17 12:16:54 +03:00
|
|
|
Stream_Write_UINT8(s, controlFlags); /* Header (1 byte) */
|
|
|
|
Stream_Write_UINT16(s, orderSize); /* OrderSize (2 bytes) */
|
2019-07-08 11:42:51 +03:00
|
|
|
Stream_Write_UINT32(s, orderInfo->fieldFlags); /* FieldsPresentFlags (4 bytes) */
|
|
|
|
Stream_Write_UINT32(s, orderInfo->windowId); /* WindowID (4 bytes) */
|
|
|
|
/* Write body */
|
|
|
|
Stream_Write_UINT16(s, iconInfo->cacheEntry); /* CacheEntry (2 bytes) */
|
|
|
|
Stream_Write_UINT8(s, iconInfo->cacheId); /* CacheId (1 byte) */
|
|
|
|
Stream_Write_UINT8(s, iconInfo->bpp); /* Bpp (1 byte) */
|
|
|
|
Stream_Write_UINT16(s, iconInfo->width); /* Width (2 bytes) */
|
|
|
|
Stream_Write_UINT16(s, iconInfo->height); /* Height (2 bytes) */
|
|
|
|
|
|
|
|
if (iconInfo->bpp <= 8)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT16(s, iconInfo->cbColorTable); /* CbColorTable (2 bytes) */
|
|
|
|
}
|
|
|
|
|
|
|
|
Stream_Write_UINT16(s, iconInfo->cbBitsMask); /* CbBitsMask (2 bytes) */
|
|
|
|
Stream_Write_UINT16(s, iconInfo->cbBitsColor); /* CbBitsColor (2 bytes) */
|
|
|
|
Stream_Write(s, iconInfo->bitsMask, iconInfo->cbBitsMask); /* BitsMask (variable) */
|
|
|
|
|
|
|
|
if (iconInfo->bpp <= 8)
|
|
|
|
{
|
|
|
|
Stream_Write(s, iconInfo->colorTable, iconInfo->cbColorTable); /* ColorTable (variable) */
|
|
|
|
}
|
|
|
|
|
|
|
|
Stream_Write(s, iconInfo->bitsColor, iconInfo->cbBitsColor); /* BitsColor (variable) */
|
2019-12-17 12:16:54 +03:00
|
|
|
|
2019-07-08 11:42:51 +03:00
|
|
|
update->numberOrders++;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-01-15 13:11:24 +03:00
|
|
|
static BOOL update_send_window_cached_icon(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
|
|
|
|
const WINDOW_CACHED_ICON_ORDER* cachedIconOrder)
|
2019-07-08 11:42:51 +03:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2019-07-08 11:42:51 +03:00
|
|
|
BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2);
|
|
|
|
UINT16 orderSize = 14;
|
2022-09-30 12:00:53 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(cachedIconOrder);
|
|
|
|
const CACHED_ICON_INFO* cachedIcon = &cachedIconOrder->cachedIcon;
|
2024-01-23 18:49:54 +03:00
|
|
|
rdp_update_internal* update = NULL;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(orderInfo);
|
|
|
|
WINPR_ASSERT(cachedIcon);
|
|
|
|
|
2022-01-11 18:01:33 +03:00
|
|
|
update = update_cast(context->update);
|
2019-07-08 11:42:51 +03:00
|
|
|
|
2020-01-15 12:18:45 +03:00
|
|
|
update_check_flush(context, orderSize);
|
|
|
|
|
|
|
|
s = update->us;
|
2019-07-08 11:42:51 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
|
|
|
|
2019-12-17 12:16:54 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, orderSize))
|
|
|
|
return FALSE;
|
|
|
|
|
2019-07-08 11:42:51 +03:00
|
|
|
/* Write Hdr */
|
|
|
|
Stream_Write_UINT8(s, controlFlags); /* Header (1 byte) */
|
|
|
|
Stream_Write_UINT16(s, orderSize); /* OrderSize (2 bytes) */
|
|
|
|
Stream_Write_UINT32(s, orderInfo->fieldFlags); /* FieldsPresentFlags (4 bytes) */
|
|
|
|
Stream_Write_UINT32(s, orderInfo->windowId); /* WindowID (4 bytes) */
|
|
|
|
/* Write body */
|
2022-09-30 12:00:53 +03:00
|
|
|
Stream_Write_UINT16(s, cachedIcon->cacheEntry); /* CacheEntry (2 bytes) */
|
|
|
|
Stream_Write_UINT8(s, cachedIcon->cacheId); /* CacheId (1 byte) */
|
2019-07-08 11:42:51 +03:00
|
|
|
update->numberOrders++;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-01-15 13:11:24 +03:00
|
|
|
static BOOL update_send_window_delete(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo)
|
2019-07-08 11:42:51 +03:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2019-07-08 11:42:51 +03:00
|
|
|
BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2);
|
|
|
|
UINT16 orderSize = 11;
|
2024-01-23 18:49:54 +03:00
|
|
|
rdp_update_internal* update = NULL;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(orderInfo);
|
2022-01-11 18:01:33 +03:00
|
|
|
update = update_cast(context->update);
|
|
|
|
|
2020-01-15 12:18:45 +03:00
|
|
|
update_check_flush(context, orderSize);
|
|
|
|
|
2019-07-08 11:42:51 +03:00
|
|
|
s = update->us;
|
|
|
|
|
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
|
|
|
|
2019-12-17 12:16:54 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, orderSize))
|
|
|
|
return FALSE;
|
|
|
|
|
2019-07-08 11:42:51 +03:00
|
|
|
/* Write Hdr */
|
|
|
|
Stream_Write_UINT8(s, controlFlags); /* Header (1 byte) */
|
|
|
|
Stream_Write_UINT16(s, orderSize); /* OrderSize (2 bytes) */
|
|
|
|
Stream_Write_UINT32(s, orderInfo->fieldFlags); /* FieldsPresentFlags (4 bytes) */
|
|
|
|
Stream_Write_UINT32(s, orderInfo->windowId); /* WindowID (4 bytes) */
|
|
|
|
update->numberOrders++;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-12-17 12:16:54 +03:00
|
|
|
static UINT16 update_calculate_new_or_existing_notification_icons_order(
|
|
|
|
const WINDOW_ORDER_INFO* orderInfo, const NOTIFY_ICON_STATE_ORDER* iconStateOrder)
|
|
|
|
{
|
|
|
|
UINT16 orderSize = 15;
|
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(orderInfo);
|
|
|
|
WINPR_ASSERT(iconStateOrder);
|
|
|
|
|
2019-12-17 12:16:54 +03:00
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_VERSION) != 0)
|
|
|
|
orderSize += 4;
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_TIP) != 0)
|
|
|
|
{
|
|
|
|
orderSize += 2 + iconStateOrder->toolTip.length;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_INFO_TIP) != 0)
|
|
|
|
{
|
|
|
|
NOTIFY_ICON_INFOTIP infoTip = iconStateOrder->infoTip;
|
|
|
|
orderSize += 12 + infoTip.text.length + infoTip.title.length;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_STATE) != 0)
|
|
|
|
{
|
|
|
|
orderSize += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_ICON) != 0)
|
|
|
|
{
|
|
|
|
ICON_INFO iconInfo = iconStateOrder->icon;
|
|
|
|
orderSize += 12;
|
|
|
|
|
|
|
|
if (iconInfo.bpp <= 8)
|
|
|
|
orderSize += 2 + iconInfo.cbColorTable;
|
|
|
|
|
|
|
|
orderSize += iconInfo.cbBitsMask + iconInfo.cbBitsColor;
|
|
|
|
}
|
|
|
|
else if ((orderInfo->fieldFlags & WINDOW_ORDER_CACHED_ICON) != 0)
|
|
|
|
{
|
|
|
|
orderSize += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
return orderSize;
|
|
|
|
}
|
|
|
|
|
2020-01-15 13:11:24 +03:00
|
|
|
static BOOL
|
|
|
|
update_send_new_or_existing_notification_icons(rdpContext* context,
|
|
|
|
const WINDOW_ORDER_INFO* orderInfo,
|
|
|
|
const NOTIFY_ICON_STATE_ORDER* iconStateOrder)
|
2019-07-08 11:42:51 +03:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2019-07-08 11:42:51 +03:00
|
|
|
BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2);
|
2019-12-11 16:08:10 +03:00
|
|
|
BOOL versionFieldPresent = FALSE;
|
2022-04-28 10:56:11 +03:00
|
|
|
const UINT16 orderSize =
|
2020-01-15 12:18:45 +03:00
|
|
|
update_calculate_new_or_existing_notification_icons_order(orderInfo, iconStateOrder);
|
2024-01-23 18:49:54 +03:00
|
|
|
rdp_update_internal* update = NULL;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(orderInfo);
|
|
|
|
WINPR_ASSERT(iconStateOrder);
|
2022-01-11 18:01:33 +03:00
|
|
|
update = update_cast(context->update);
|
2020-01-15 12:18:45 +03:00
|
|
|
|
|
|
|
update_check_flush(context, orderSize);
|
2019-07-08 11:42:51 +03:00
|
|
|
|
2019-12-11 16:08:10 +03:00
|
|
|
s = update->us;
|
2019-07-08 11:42:51 +03:00
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
|
|
|
|
2019-12-17 12:16:54 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, orderSize))
|
|
|
|
return FALSE;
|
|
|
|
|
2019-07-08 11:42:51 +03:00
|
|
|
/* Write Hdr */
|
2019-12-17 12:16:54 +03:00
|
|
|
Stream_Write_UINT8(s, controlFlags); /* Header (1 byte) */
|
|
|
|
Stream_Write_INT16(s, orderSize); /* OrderSize (2 bytes) */
|
2019-07-08 11:42:51 +03:00
|
|
|
Stream_Write_UINT32(s, orderInfo->fieldFlags); /* FieldsPresentFlags (4 bytes) */
|
|
|
|
Stream_Write_UINT32(s, orderInfo->windowId); /* WindowID (4 bytes) */
|
|
|
|
Stream_Write_UINT32(s, orderInfo->notifyIconId); /* NotifyIconId (4 bytes) */
|
|
|
|
|
|
|
|
/* Write body */
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_VERSION) != 0)
|
|
|
|
{
|
2019-12-11 16:08:10 +03:00
|
|
|
versionFieldPresent = TRUE;
|
2019-07-08 11:42:51 +03:00
|
|
|
Stream_Write_UINT32(s, iconStateOrder->version);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_TIP) != 0)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT16(s, iconStateOrder->toolTip.length);
|
|
|
|
Stream_Write(s, iconStateOrder->toolTip.string, iconStateOrder->toolTip.length);
|
|
|
|
}
|
|
|
|
|
2019-12-11 16:08:10 +03:00
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_INFO_TIP) != 0)
|
2019-07-08 11:42:51 +03:00
|
|
|
{
|
|
|
|
NOTIFY_ICON_INFOTIP infoTip = iconStateOrder->infoTip;
|
2019-12-11 16:08:10 +03:00
|
|
|
|
|
|
|
/* info tip should not be sent when version is 0 */
|
|
|
|
if (versionFieldPresent && iconStateOrder->version == 0)
|
|
|
|
return FALSE;
|
|
|
|
|
2019-07-08 11:42:51 +03:00
|
|
|
Stream_Write_UINT32(s, infoTip.timeout); /* Timeout (4 bytes) */
|
|
|
|
Stream_Write_UINT32(s, infoTip.flags); /* InfoFlags (4 bytes) */
|
|
|
|
Stream_Write_UINT16(s, infoTip.text.length); /* InfoTipText (variable) */
|
|
|
|
Stream_Write(s, infoTip.text.string, infoTip.text.length);
|
|
|
|
Stream_Write_UINT16(s, infoTip.title.length); /* Title (variable) */
|
|
|
|
Stream_Write(s, infoTip.title.string, infoTip.title.length);
|
|
|
|
}
|
|
|
|
|
2019-12-17 12:16:54 +03:00
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_STATE) != 0)
|
2019-07-08 11:42:51 +03:00
|
|
|
{
|
2019-12-17 12:16:54 +03:00
|
|
|
/* notify state should not be sent when version is 0 */
|
|
|
|
if (versionFieldPresent && iconStateOrder->version == 0)
|
|
|
|
return FALSE;
|
|
|
|
|
2019-07-08 11:42:51 +03:00
|
|
|
Stream_Write_UINT32(s, iconStateOrder->state);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & WINDOW_ORDER_ICON) != 0)
|
|
|
|
{
|
|
|
|
ICON_INFO iconInfo = iconStateOrder->icon;
|
|
|
|
Stream_Write_UINT16(s, iconInfo.cacheEntry); /* CacheEntry (2 bytes) */
|
|
|
|
Stream_Write_UINT8(s, iconInfo.cacheId); /* CacheId (1 byte) */
|
|
|
|
Stream_Write_UINT8(s, iconInfo.bpp); /* Bpp (1 byte) */
|
|
|
|
Stream_Write_UINT16(s, iconInfo.width); /* Width (2 bytes) */
|
|
|
|
Stream_Write_UINT16(s, iconInfo.height); /* Height (2 bytes) */
|
|
|
|
|
|
|
|
if (iconInfo.bpp <= 8)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT16(s, iconInfo.cbColorTable); /* CbColorTable (2 bytes) */
|
|
|
|
}
|
|
|
|
|
|
|
|
Stream_Write_UINT16(s, iconInfo.cbBitsMask); /* CbBitsMask (2 bytes) */
|
|
|
|
Stream_Write_UINT16(s, iconInfo.cbBitsColor); /* CbBitsColor (2 bytes) */
|
|
|
|
Stream_Write(s, iconInfo.bitsMask, iconInfo.cbBitsMask); /* BitsMask (variable) */
|
|
|
|
|
|
|
|
if (iconInfo.bpp <= 8)
|
|
|
|
{
|
|
|
|
Stream_Write(s, iconInfo.colorTable, iconInfo.cbColorTable); /* ColorTable (variable) */
|
|
|
|
}
|
|
|
|
|
|
|
|
Stream_Write(s, iconInfo.bitsColor, iconInfo.cbBitsColor); /* BitsColor (variable) */
|
|
|
|
}
|
|
|
|
else if ((orderInfo->fieldFlags & WINDOW_ORDER_CACHED_ICON) != 0)
|
|
|
|
{
|
|
|
|
CACHED_ICON_INFO cachedIcon = iconStateOrder->cachedIcon;
|
|
|
|
Stream_Write_UINT16(s, cachedIcon.cacheEntry); /* CacheEntry (2 bytes) */
|
|
|
|
Stream_Write_UINT8(s, cachedIcon.cacheId); /* CacheId (1 byte) */
|
|
|
|
}
|
|
|
|
|
|
|
|
update->numberOrders++;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-01-15 13:11:24 +03:00
|
|
|
static BOOL update_send_notify_icon_create(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
|
|
|
|
const NOTIFY_ICON_STATE_ORDER* iconStateOrder)
|
2019-07-08 11:42:51 +03:00
|
|
|
{
|
|
|
|
return update_send_new_or_existing_notification_icons(context, orderInfo, iconStateOrder);
|
|
|
|
}
|
|
|
|
|
2020-01-15 13:11:24 +03:00
|
|
|
static BOOL update_send_notify_icon_update(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
|
|
|
|
const NOTIFY_ICON_STATE_ORDER* iconStateOrder)
|
2019-07-08 11:42:51 +03:00
|
|
|
{
|
|
|
|
return update_send_new_or_existing_notification_icons(context, orderInfo, iconStateOrder);
|
|
|
|
}
|
|
|
|
|
2020-01-15 13:11:24 +03:00
|
|
|
static BOOL update_send_notify_icon_delete(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo)
|
2019-07-08 11:42:51 +03:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2019-07-08 11:42:51 +03:00
|
|
|
BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2);
|
|
|
|
UINT16 orderSize = 15;
|
2024-01-23 18:49:54 +03:00
|
|
|
rdp_update_internal* update = NULL;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(orderInfo);
|
2022-01-11 18:01:33 +03:00
|
|
|
update = update_cast(context->update);
|
|
|
|
|
2020-01-15 12:18:45 +03:00
|
|
|
update_check_flush(context, orderSize);
|
|
|
|
|
2019-07-08 11:42:51 +03:00
|
|
|
s = update->us;
|
|
|
|
|
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* Write Hdr */
|
|
|
|
Stream_Write_UINT8(s, controlFlags); /* Header (1 byte) */
|
|
|
|
Stream_Write_UINT16(s, orderSize); /* OrderSize (2 bytes) */
|
|
|
|
Stream_Write_UINT32(s, orderInfo->fieldFlags); /* FieldsPresentFlags (4 bytes) */
|
|
|
|
Stream_Write_UINT32(s, orderInfo->windowId); /* WindowID (4 bytes) */
|
|
|
|
Stream_Write_UINT32(s, orderInfo->notifyIconId); /* NotifyIconId (4 bytes) */
|
|
|
|
update->numberOrders++;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-01-15 12:18:45 +03:00
|
|
|
static UINT16 update_calculate_monitored_desktop(const WINDOW_ORDER_INFO* orderInfo,
|
|
|
|
const MONITORED_DESKTOP_ORDER* monitoredDesktop)
|
|
|
|
{
|
|
|
|
UINT16 orderSize = 7;
|
|
|
|
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(orderInfo);
|
|
|
|
WINPR_ASSERT(monitoredDesktop);
|
|
|
|
|
2020-01-15 12:18:45 +03:00
|
|
|
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_ACTIVE_WND)
|
|
|
|
{
|
|
|
|
orderSize += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_ZORDER)
|
|
|
|
{
|
|
|
|
orderSize += 1 + (4 * monitoredDesktop->numWindowIds);
|
|
|
|
}
|
|
|
|
|
|
|
|
return orderSize;
|
|
|
|
}
|
|
|
|
|
2020-01-15 13:11:24 +03:00
|
|
|
static BOOL update_send_monitored_desktop(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
|
|
|
|
const MONITORED_DESKTOP_ORDER* monitoredDesktop)
|
2019-07-08 11:42:51 +03:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2019-07-08 11:42:51 +03:00
|
|
|
BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2);
|
2020-01-15 12:18:45 +03:00
|
|
|
UINT16 orderSize = update_calculate_monitored_desktop(orderInfo, monitoredDesktop);
|
2024-01-23 18:49:54 +03:00
|
|
|
rdp_update_internal* update = NULL;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(orderInfo);
|
|
|
|
WINPR_ASSERT(monitoredDesktop);
|
|
|
|
|
2022-01-11 18:01:33 +03:00
|
|
|
update = update_cast(context->update);
|
|
|
|
|
2020-01-15 12:18:45 +03:00
|
|
|
update_check_flush(context, orderSize);
|
|
|
|
|
2019-07-08 11:42:51 +03:00
|
|
|
s = update->us;
|
|
|
|
|
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
|
|
|
|
2020-01-15 12:18:45 +03:00
|
|
|
Stream_Write_UINT8(s, controlFlags); /* Header (1 byte) */
|
|
|
|
Stream_Write_UINT16(s, orderSize); /* OrderSize (2 bytes) */
|
2019-07-08 11:42:51 +03:00
|
|
|
Stream_Write_UINT32(s, orderInfo->fieldFlags); /* FieldsPresentFlags (4 bytes) */
|
|
|
|
|
|
|
|
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_ACTIVE_WND)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT32(s, monitoredDesktop->activeWindowId); /* activeWindowId (4 bytes) */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_ZORDER)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT8(s, monitoredDesktop->numWindowIds); /* numWindowIds (1 byte) */
|
|
|
|
|
|
|
|
/* windowIds */
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 i = 0; i < monitoredDesktop->numWindowIds; i++)
|
2019-07-08 11:42:51 +03:00
|
|
|
{
|
|
|
|
Stream_Write_UINT32(s, monitoredDesktop->windowIds[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
update->numberOrders++;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-01-15 13:11:24 +03:00
|
|
|
static BOOL update_send_non_monitored_desktop(rdpContext* context,
|
|
|
|
const WINDOW_ORDER_INFO* orderInfo)
|
2019-07-08 11:42:51 +03:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2019-07-08 11:42:51 +03:00
|
|
|
BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2);
|
|
|
|
UINT16 orderSize = 7;
|
2024-01-23 18:49:54 +03:00
|
|
|
rdp_update_internal* update = NULL;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(context);
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(orderInfo);
|
2022-01-11 18:01:33 +03:00
|
|
|
update = update_cast(context->update);
|
|
|
|
|
2020-01-15 12:18:45 +03:00
|
|
|
update_check_flush(context, orderSize);
|
|
|
|
|
2019-07-08 11:42:51 +03:00
|
|
|
s = update->us;
|
|
|
|
|
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Write_UINT8(s, controlFlags); /* Header (1 byte) */
|
|
|
|
Stream_Write_UINT16(s, orderSize); /* OrderSize (2 bytes) */
|
|
|
|
Stream_Write_UINT32(s, orderInfo->fieldFlags); /* FieldsPresentFlags (4 bytes) */
|
|
|
|
update->numberOrders++;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-08-23 16:37:08 +04:00
|
|
|
void update_register_server_callbacks(rdpUpdate* update)
|
|
|
|
{
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(update);
|
|
|
|
|
2019-04-11 16:30:05 +03:00
|
|
|
update->BeginPaint = _update_begin_paint;
|
|
|
|
update->EndPaint = _update_end_paint;
|
2013-05-10 03:41:32 +04:00
|
|
|
update->SetBounds = update_set_bounds;
|
2011-08-25 13:03:53 +04:00
|
|
|
update->Synchronize = update_send_synchronize;
|
2011-09-06 13:19:16 +04:00
|
|
|
update->DesktopResize = update_send_desktop_resize;
|
2013-08-08 05:47:03 +04:00
|
|
|
update->BitmapUpdate = update_send_bitmap_update;
|
2011-08-23 19:28:28 +04:00
|
|
|
update->SurfaceBits = update_send_surface_bits;
|
2011-12-16 03:26:32 +04:00
|
|
|
update->SurfaceFrameMarker = update_send_surface_frame_marker;
|
2011-08-27 05:44:37 +04:00
|
|
|
update->SurfaceCommand = update_send_surface_command;
|
2014-09-19 22:23:17 +04:00
|
|
|
update->SurfaceFrameBits = update_send_surface_frame_bits;
|
2014-07-16 17:38:10 +04:00
|
|
|
update->PlaySound = update_send_play_sound;
|
2014-09-30 20:18:29 +04:00
|
|
|
update->SetKeyboardIndicators = update_send_set_keyboard_indicators;
|
2017-05-12 10:43:58 +03:00
|
|
|
update->SetKeyboardImeStatus = update_send_set_keyboard_ime_status;
|
2016-02-18 16:19:36 +03:00
|
|
|
update->SaveSessionInfo = rdp_send_save_session_info;
|
2019-01-29 12:33:06 +03:00
|
|
|
update->ServerStatusInfo = rdp_send_server_status_info;
|
2013-05-13 01:46:13 +04:00
|
|
|
update->primary->DstBlt = update_send_dstblt;
|
2013-05-07 20:45:52 +04:00
|
|
|
update->primary->PatBlt = update_send_patblt;
|
2011-11-24 20:47:40 +04:00
|
|
|
update->primary->ScrBlt = update_send_scrblt;
|
2013-05-07 06:27:19 +04:00
|
|
|
update->primary->OpaqueRect = update_send_opaque_rect;
|
2013-05-13 01:46:13 +04:00
|
|
|
update->primary->LineTo = update_send_line_to;
|
2013-05-07 19:41:32 +04:00
|
|
|
update->primary->MemBlt = update_send_memblt;
|
2013-05-07 20:45:52 +04:00
|
|
|
update->primary->GlyphIndex = update_send_glyph_index;
|
2013-05-13 01:46:13 +04:00
|
|
|
update->secondary->CacheBitmap = update_send_cache_bitmap;
|
2013-05-07 07:21:12 +04:00
|
|
|
update->secondary->CacheBitmapV2 = update_send_cache_bitmap_v2;
|
2013-05-13 01:46:13 +04:00
|
|
|
update->secondary->CacheBitmapV3 = update_send_cache_bitmap_v3;
|
|
|
|
update->secondary->CacheColorTable = update_send_cache_color_table;
|
2013-05-08 02:44:22 +04:00
|
|
|
update->secondary->CacheGlyph = update_send_cache_glyph;
|
2013-05-07 19:41:32 +04:00
|
|
|
update->secondary->CacheGlyphV2 = update_send_cache_glyph_v2;
|
2013-05-13 01:46:13 +04:00
|
|
|
update->secondary->CacheBrush = update_send_cache_brush;
|
2019-01-29 12:33:06 +03:00
|
|
|
update->altsec->CreateOffscreenBitmap = update_send_create_offscreen_bitmap_order;
|
2013-05-12 21:42:53 +04:00
|
|
|
update->altsec->SwitchSurface = update_send_switch_surface_order;
|
2011-11-22 02:48:03 +04:00
|
|
|
update->pointer->PointerSystem = update_send_pointer_system;
|
2014-11-07 01:25:41 +03:00
|
|
|
update->pointer->PointerPosition = update_send_pointer_position;
|
2011-12-03 04:54:02 +04:00
|
|
|
update->pointer->PointerColor = update_send_pointer_color;
|
2019-12-19 11:35:53 +03:00
|
|
|
update->pointer->PointerLarge = update_send_pointer_large;
|
2011-12-03 04:54:02 +04:00
|
|
|
update->pointer->PointerNew = update_send_pointer_new;
|
|
|
|
update->pointer->PointerCached = update_send_pointer_cached;
|
2019-07-08 11:42:51 +03:00
|
|
|
update->window->WindowCreate = update_send_window_create;
|
|
|
|
update->window->WindowUpdate = update_send_window_update;
|
|
|
|
update->window->WindowIcon = update_send_window_icon;
|
|
|
|
update->window->WindowCachedIcon = update_send_window_cached_icon;
|
|
|
|
update->window->WindowDelete = update_send_window_delete;
|
|
|
|
update->window->NotifyIconCreate = update_send_notify_icon_create;
|
|
|
|
update->window->NotifyIconUpdate = update_send_notify_icon_update;
|
|
|
|
update->window->NotifyIconDelete = update_send_notify_icon_delete;
|
|
|
|
update->window->MonitoredDesktop = update_send_monitored_desktop;
|
|
|
|
update->window->NonMonitoredDesktop = update_send_non_monitored_desktop;
|
2011-08-23 16:37:08 +04:00
|
|
|
}
|
|
|
|
|
2012-05-26 17:34:09 +04:00
|
|
|
void update_register_client_callbacks(rdpUpdate* update)
|
|
|
|
{
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(update);
|
|
|
|
|
2012-05-26 17:34:09 +04:00
|
|
|
update->RefreshRect = update_send_refresh_rect;
|
|
|
|
update->SuppressOutput = update_send_suppress_output;
|
2013-01-17 08:58:01 +04:00
|
|
|
update->SurfaceFrameAcknowledge = update_send_frame_acknowledge;
|
2012-05-26 17:34:09 +04:00
|
|
|
}
|
|
|
|
|
2013-01-25 21:08:00 +04:00
|
|
|
int update_process_messages(rdpUpdate* update)
|
|
|
|
{
|
2013-02-04 23:56:54 +04:00
|
|
|
return update_message_queue_process_pending_messages(update);
|
2013-01-25 21:08:00 +04:00
|
|
|
}
|
|
|
|
|
2016-07-19 17:15:38 +03:00
|
|
|
static void update_free_queued_message(void* obj)
|
2013-11-12 18:05:15 +04:00
|
|
|
{
|
2016-07-19 17:15:38 +03:00
|
|
|
wMessage* msg = (wMessage*)obj;
|
2013-11-12 18:05:15 +04:00
|
|
|
update_message_queue_free_message(msg);
|
|
|
|
}
|
|
|
|
|
2019-05-08 16:36:20 +03:00
|
|
|
void update_free_window_state(WINDOW_STATE_ORDER* window_state)
|
2017-06-21 17:07:07 +03:00
|
|
|
{
|
2018-02-28 12:10:09 +03:00
|
|
|
if (!window_state)
|
|
|
|
return;
|
2017-06-23 04:21:16 +03:00
|
|
|
|
2019-05-08 16:36:20 +03:00
|
|
|
free(window_state->OverlayDescription.string);
|
2018-02-28 12:10:09 +03:00
|
|
|
free(window_state->titleInfo.string);
|
|
|
|
free(window_state->windowRects);
|
|
|
|
free(window_state->visibilityRects);
|
2019-05-08 16:36:20 +03:00
|
|
|
memset(window_state, 0, sizeof(WINDOW_STATE_ORDER));
|
2017-06-21 17:07:07 +03:00
|
|
|
}
|
|
|
|
|
2011-07-28 08:38:25 +04:00
|
|
|
rdpUpdate* update_new(rdpRdp* rdp)
|
2011-07-27 02:32:14 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
const wObject cb = { NULL, NULL, NULL, update_free_queued_message, NULL };
|
2023-06-26 11:17:42 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(rdp);
|
|
|
|
WINPR_ASSERT(rdp->context);
|
|
|
|
|
|
|
|
rdp_update_internal* update = (rdp_update_internal*)calloc(1, sizeof(rdp_update_internal));
|
2011-07-27 02:32:14 +04:00
|
|
|
|
2015-05-18 12:28:00 +03:00
|
|
|
if (!update)
|
|
|
|
return NULL;
|
2012-01-01 00:36:04 +04:00
|
|
|
|
2022-03-23 15:18:35 +03:00
|
|
|
update->common.context = rdp->context;
|
2015-05-18 12:28:00 +03:00
|
|
|
update->log = WLog_Get("com.freerdp.core.update");
|
2019-04-11 16:30:05 +03:00
|
|
|
InitializeCriticalSection(&(update->mux));
|
2022-01-11 18:01:33 +03:00
|
|
|
update->common.pointer = (rdpPointerUpdate*)calloc(1, sizeof(rdpPointerUpdate));
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2022-01-11 18:01:33 +03:00
|
|
|
if (!update->common.pointer)
|
2018-04-03 18:17:45 +03:00
|
|
|
goto fail;
|
2012-11-22 04:22:41 +04:00
|
|
|
|
2023-06-26 11:17:42 +03:00
|
|
|
rdp_primary_update_internal* primary =
|
|
|
|
(rdp_primary_update_internal*)calloc(1, sizeof(rdp_primary_update_internal));
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2022-01-11 18:42:19 +03:00
|
|
|
if (!primary)
|
2018-04-03 18:17:45 +03:00
|
|
|
goto fail;
|
2022-01-11 18:42:19 +03:00
|
|
|
update->common.primary = &primary->common;
|
2011-11-22 02:48:03 +04:00
|
|
|
|
2023-06-26 11:17:42 +03:00
|
|
|
rdp_secondary_update_internal* secondary =
|
|
|
|
(rdp_secondary_update_internal*)calloc(1, sizeof(rdp_secondary_update_internal));
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2022-01-11 18:42:19 +03:00
|
|
|
if (!secondary)
|
2018-04-03 18:17:45 +03:00
|
|
|
goto fail;
|
2022-01-11 18:42:19 +03:00
|
|
|
update->common.secondary = &secondary->common;
|
2012-11-22 04:22:41 +04:00
|
|
|
|
2023-06-26 11:17:42 +03:00
|
|
|
rdp_altsec_update_internal* altsec =
|
|
|
|
(rdp_altsec_update_internal*)calloc(1, sizeof(rdp_altsec_update_internal));
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2022-01-11 18:29:40 +03:00
|
|
|
if (!altsec)
|
2018-04-03 18:17:45 +03:00
|
|
|
goto fail;
|
2012-11-22 04:22:41 +04:00
|
|
|
|
2022-01-11 18:29:40 +03:00
|
|
|
update->common.altsec = &altsec->common;
|
2022-01-11 18:01:33 +03:00
|
|
|
update->common.window = (rdpWindowUpdate*)calloc(1, sizeof(rdpWindowUpdate));
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2022-01-11 18:01:33 +03:00
|
|
|
if (!update->common.window)
|
2018-04-03 18:17:45 +03:00
|
|
|
goto fail;
|
2012-01-01 00:36:04 +04:00
|
|
|
|
2023-06-26 11:17:42 +03:00
|
|
|
OFFSCREEN_DELETE_LIST* deleteList = &(altsec->create_offscreen_bitmap.deleteList);
|
2015-05-18 12:28:00 +03:00
|
|
|
deleteList->sIndices = 64;
|
2017-05-30 11:46:43 +03:00
|
|
|
deleteList->indices = calloc(deleteList->sIndices, 2);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-05-18 12:28:00 +03:00
|
|
|
if (!deleteList->indices)
|
2018-04-03 18:17:45 +03:00
|
|
|
goto fail;
|
2012-01-31 20:11:22 +04:00
|
|
|
|
2016-07-19 17:15:38 +03:00
|
|
|
deleteList->cIndices = 0;
|
2022-01-11 18:01:33 +03:00
|
|
|
update->common.SuppressOutput = update_send_suppress_output;
|
2015-05-18 12:28:00 +03:00
|
|
|
update->initialState = TRUE;
|
2022-01-11 19:00:26 +03:00
|
|
|
update->common.autoCalculateBitmapData = TRUE;
|
2015-05-18 12:28:00 +03:00
|
|
|
update->queue = MessageQueue_New(&cb);
|
2016-07-19 17:15:38 +03:00
|
|
|
|
2015-05-18 12:28:00 +03:00
|
|
|
if (!update->queue)
|
2018-04-03 18:17:45 +03:00
|
|
|
goto fail;
|
2015-05-18 12:28:00 +03:00
|
|
|
|
2022-01-11 18:01:33 +03:00
|
|
|
return &update->common;
|
2018-04-03 18:17:45 +03:00
|
|
|
fail:
|
2024-02-04 13:11:29 +03:00
|
|
|
WINPR_PRAGMA_DIAG_PUSH
|
|
|
|
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
|
2022-01-11 18:01:33 +03:00
|
|
|
update_free(&update->common);
|
2024-02-04 13:11:29 +03:00
|
|
|
WINPR_PRAGMA_DIAG_POP
|
2015-05-18 12:28:00 +03:00
|
|
|
return NULL;
|
2011-07-27 02:32:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void update_free(rdpUpdate* update)
|
|
|
|
{
|
|
|
|
if (update != NULL)
|
|
|
|
{
|
2022-01-11 18:01:33 +03:00
|
|
|
rdp_update_internal* up = update_cast(update);
|
2022-01-11 18:29:40 +03:00
|
|
|
rdp_altsec_update_internal* altsec = altsec_update_cast(update->altsec);
|
|
|
|
OFFSCREEN_DELETE_LIST* deleteList = &(altsec->create_offscreen_bitmap.deleteList);
|
2018-05-04 13:03:26 +03:00
|
|
|
|
|
|
|
if (deleteList)
|
|
|
|
free(deleteList->indices);
|
|
|
|
|
2012-10-09 07:21:26 +04:00
|
|
|
free(update->pointer);
|
2018-05-04 13:03:26 +03:00
|
|
|
|
|
|
|
if (update->primary)
|
|
|
|
{
|
2022-01-11 18:35:56 +03:00
|
|
|
rdp_primary_update_internal* primary = primary_update_cast(update->primary);
|
2023-09-19 11:51:23 +03:00
|
|
|
|
|
|
|
free(primary->polygon_cb.points);
|
2022-01-11 18:35:56 +03:00
|
|
|
free(primary->polyline.points);
|
|
|
|
free(primary->polygon_sc.points);
|
|
|
|
free(primary->fast_glyph.glyphData.aj);
|
|
|
|
free(primary);
|
2018-05-04 13:03:26 +03:00
|
|
|
}
|
|
|
|
|
2012-10-09 07:21:26 +04:00
|
|
|
free(update->secondary);
|
2022-01-11 18:35:56 +03:00
|
|
|
free(altsec);
|
2018-05-04 13:03:26 +03:00
|
|
|
|
|
|
|
if (update->window)
|
|
|
|
{
|
|
|
|
free(update->window);
|
|
|
|
}
|
|
|
|
|
2022-01-11 18:01:33 +03:00
|
|
|
MessageQueue_Free(up->queue);
|
|
|
|
DeleteCriticalSection(&up->mux);
|
2012-10-09 07:21:26 +04:00
|
|
|
free(update);
|
2011-07-27 02:32:14 +04:00
|
|
|
}
|
|
|
|
}
|
2019-04-11 16:30:05 +03:00
|
|
|
|
2022-01-11 19:00:26 +03:00
|
|
|
void rdp_update_lock(rdpUpdate* update)
|
2019-04-11 16:30:05 +03:00
|
|
|
{
|
2022-01-11 18:01:33 +03:00
|
|
|
rdp_update_internal* up = update_cast(update);
|
|
|
|
EnterCriticalSection(&up->mux);
|
2021-10-07 11:25:09 +03:00
|
|
|
}
|
|
|
|
|
2022-01-11 19:00:26 +03:00
|
|
|
void rdp_update_unlock(rdpUpdate* update)
|
2021-10-07 11:25:09 +03:00
|
|
|
{
|
2022-01-11 18:01:33 +03:00
|
|
|
rdp_update_internal* up = update_cast(update);
|
|
|
|
LeaveCriticalSection(&up->mux);
|
2021-10-07 11:25:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL update_begin_paint(rdpUpdate* update)
|
|
|
|
{
|
2022-09-30 12:00:53 +03:00
|
|
|
WINPR_ASSERT(update);
|
2022-01-11 19:00:26 +03:00
|
|
|
rdp_update_lock(update);
|
2019-04-11 16:30:05 +03:00
|
|
|
|
2023-12-19 17:29:27 +03:00
|
|
|
WINPR_ASSERT(update->context);
|
|
|
|
|
2024-03-08 21:56:14 +03:00
|
|
|
BOOL rc = IFCALLRESULT(TRUE, update->BeginPaint, update->context);
|
|
|
|
if (!rc)
|
|
|
|
WLog_WARN(TAG, "BeginPaint call failed");
|
|
|
|
|
2023-12-19 17:29:27 +03:00
|
|
|
/* Reset the invalid regions, we start a new frame here. */
|
|
|
|
rdpGdi* gdi = update->context->gdi;
|
|
|
|
WINPR_ASSERT(gdi);
|
|
|
|
if (gdi->hdc && gdi->primary && gdi->primary->hdc)
|
|
|
|
{
|
|
|
|
HGDI_WND hwnd = gdi->primary->hdc->hwnd;
|
|
|
|
WINPR_ASSERT(hwnd);
|
|
|
|
WINPR_ASSERT(hwnd->invalid);
|
|
|
|
|
|
|
|
hwnd->invalid->null = TRUE;
|
|
|
|
hwnd->ninvalid = 0;
|
|
|
|
}
|
|
|
|
|
2023-08-23 14:03:00 +03:00
|
|
|
return rc;
|
2019-04-11 16:30:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL update_end_paint(rdpUpdate* update)
|
|
|
|
{
|
2022-11-30 10:37:59 +03:00
|
|
|
BOOL rc = TRUE;
|
2019-04-11 16:30:05 +03:00
|
|
|
|
2023-08-23 11:42:46 +03:00
|
|
|
WINPR_ASSERT(update);
|
2023-08-04 11:14:42 +03:00
|
|
|
IFCALLRET(update->EndPaint, rc, update->context);
|
2023-08-23 14:03:00 +03:00
|
|
|
if (!rc)
|
|
|
|
WLog_WARN(TAG, "EndPaint call failed");
|
2022-01-11 19:00:26 +03:00
|
|
|
rdp_update_unlock(update);
|
2019-04-11 16:30:05 +03:00
|
|
|
return rc;
|
|
|
|
}
|