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
|
|
|
* Drawing Orders
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
2023-10-16 13:59:19 +03:00
|
|
|
#include "settings.h"
|
|
|
|
|
2018-10-15 11:34:47 +03:00
|
|
|
#include <winpr/wtypes.h>
|
2012-11-22 06:22:06 +04:00
|
|
|
#include <winpr/crt.h>
|
2023-08-05 12:31:08 +03:00
|
|
|
#include <winpr/assert.h>
|
2012-11-22 06:22:06 +04:00
|
|
|
|
2011-09-05 00:49:22 +04:00
|
|
|
#include <freerdp/api.h>
|
2014-09-12 16:36:29 +04:00
|
|
|
#include <freerdp/log.h>
|
2011-10-21 01:28:59 +04:00
|
|
|
#include <freerdp/graphics.h>
|
2011-10-03 04:28:20 +04:00
|
|
|
#include <freerdp/codec/bitmap.h>
|
2017-12-22 12:37:04 +03:00
|
|
|
#include <freerdp/gdi/gdi.h>
|
2011-08-09 10:32:50 +04:00
|
|
|
|
2011-07-25 09:45:25 +04:00
|
|
|
#include "orders.h"
|
2023-10-13 10:20:16 +03:00
|
|
|
#include "window.h"
|
2011-07-25 09:45:25 +04:00
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
#include "../cache/glyph.h"
|
|
|
|
#include "../cache/bitmap.h"
|
|
|
|
#include "../cache/brush.h"
|
|
|
|
#include "../cache/cache.h"
|
|
|
|
|
2014-09-12 16:36:29 +04:00
|
|
|
#define TAG FREERDP_TAG("core.orders")
|
|
|
|
|
2023-08-03 13:02:11 +03:00
|
|
|
static const char primary_order_str[] = "Primary Drawing Order";
|
|
|
|
static const char secondary_order_str[] = "Secondary Drawing Order";
|
|
|
|
static const char alt_sec_order_str[] = "Alternate Secondary Drawing Order";
|
|
|
|
|
2020-05-26 08:28:33 +03:00
|
|
|
BYTE get_primary_drawing_order_field_bytes(UINT32 orderType, BOOL* pValid)
|
|
|
|
{
|
|
|
|
if (pValid)
|
|
|
|
*pValid = TRUE;
|
|
|
|
switch (orderType)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return DSTBLT_ORDER_FIELD_BYTES;
|
|
|
|
case 1:
|
|
|
|
return PATBLT_ORDER_FIELD_BYTES;
|
|
|
|
case 2:
|
|
|
|
return SCRBLT_ORDER_FIELD_BYTES;
|
|
|
|
case 3:
|
|
|
|
return 0;
|
|
|
|
case 4:
|
|
|
|
return 0;
|
|
|
|
case 5:
|
|
|
|
return 0;
|
|
|
|
case 6:
|
|
|
|
return 0;
|
|
|
|
case 7:
|
|
|
|
return DRAW_NINE_GRID_ORDER_FIELD_BYTES;
|
|
|
|
case 8:
|
|
|
|
return MULTI_DRAW_NINE_GRID_ORDER_FIELD_BYTES;
|
|
|
|
case 9:
|
|
|
|
return LINE_TO_ORDER_FIELD_BYTES;
|
|
|
|
case 10:
|
|
|
|
return OPAQUE_RECT_ORDER_FIELD_BYTES;
|
|
|
|
case 11:
|
|
|
|
return SAVE_BITMAP_ORDER_FIELD_BYTES;
|
|
|
|
case 12:
|
|
|
|
return 0;
|
|
|
|
case 13:
|
|
|
|
return MEMBLT_ORDER_FIELD_BYTES;
|
|
|
|
case 14:
|
|
|
|
return MEM3BLT_ORDER_FIELD_BYTES;
|
|
|
|
case 15:
|
|
|
|
return MULTI_DSTBLT_ORDER_FIELD_BYTES;
|
|
|
|
case 16:
|
|
|
|
return MULTI_PATBLT_ORDER_FIELD_BYTES;
|
|
|
|
case 17:
|
|
|
|
return MULTI_SCRBLT_ORDER_FIELD_BYTES;
|
|
|
|
case 18:
|
|
|
|
return MULTI_OPAQUE_RECT_ORDER_FIELD_BYTES;
|
|
|
|
case 19:
|
|
|
|
return FAST_INDEX_ORDER_FIELD_BYTES;
|
|
|
|
case 20:
|
|
|
|
return POLYGON_SC_ORDER_FIELD_BYTES;
|
|
|
|
case 21:
|
|
|
|
return POLYGON_CB_ORDER_FIELD_BYTES;
|
|
|
|
case 22:
|
|
|
|
return POLYLINE_ORDER_FIELD_BYTES;
|
|
|
|
case 23:
|
|
|
|
return 0;
|
|
|
|
case 24:
|
|
|
|
return FAST_GLYPH_ORDER_FIELD_BYTES;
|
|
|
|
case 25:
|
|
|
|
return ELLIPSE_SC_ORDER_FIELD_BYTES;
|
|
|
|
case 26:
|
|
|
|
return ELLIPSE_CB_ORDER_FIELD_BYTES;
|
|
|
|
case 27:
|
|
|
|
return GLYPH_INDEX_ORDER_FIELD_BYTES;
|
|
|
|
default:
|
|
|
|
if (pValid)
|
|
|
|
*pValid = FALSE;
|
|
|
|
WLog_WARN(TAG, "Invalid orderType 0x%08X received", orderType);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
|
2020-05-26 08:50:55 +03:00
|
|
|
static BYTE get_cbr2_bpp(UINT32 bpp, BOOL* pValid)
|
|
|
|
{
|
|
|
|
if (pValid)
|
|
|
|
*pValid = TRUE;
|
|
|
|
switch (bpp)
|
|
|
|
{
|
|
|
|
case 3:
|
|
|
|
return 8;
|
|
|
|
case 4:
|
|
|
|
return 16;
|
|
|
|
case 5:
|
|
|
|
return 24;
|
|
|
|
case 6:
|
|
|
|
return 32;
|
|
|
|
default:
|
|
|
|
WLog_WARN(TAG, "Invalid bpp %" PRIu32, bpp);
|
|
|
|
if (pValid)
|
|
|
|
*pValid = FALSE;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
|
2020-05-26 08:50:55 +03:00
|
|
|
static BYTE get_bmf_bpp(UINT32 bmf, BOOL* pValid)
|
|
|
|
{
|
|
|
|
if (pValid)
|
|
|
|
*pValid = TRUE;
|
2020-06-23 10:24:35 +03:00
|
|
|
/* Mask out highest bit */
|
|
|
|
switch (bmf & (~CACHED_BRUSH))
|
2020-05-26 08:50:55 +03:00
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
return 1;
|
|
|
|
case 3:
|
|
|
|
return 8;
|
|
|
|
case 4:
|
|
|
|
return 16;
|
|
|
|
case 5:
|
|
|
|
return 24;
|
|
|
|
case 6:
|
|
|
|
return 32;
|
|
|
|
default:
|
|
|
|
WLog_WARN(TAG, "Invalid bmf %" PRIu32, bmf);
|
|
|
|
if (pValid)
|
|
|
|
*pValid = FALSE;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static BYTE get_bpp_bmf(UINT32 bpp, BOOL* pValid)
|
|
|
|
{
|
|
|
|
if (pValid)
|
|
|
|
*pValid = TRUE;
|
|
|
|
switch (bpp)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
return 1;
|
|
|
|
case 8:
|
|
|
|
return 3;
|
|
|
|
case 16:
|
|
|
|
return 4;
|
|
|
|
case 24:
|
|
|
|
return 5;
|
|
|
|
case 32:
|
|
|
|
return 6;
|
|
|
|
default:
|
|
|
|
WLog_WARN(TAG, "Invalid color depth %" PRIu32, bpp);
|
|
|
|
if (pValid)
|
|
|
|
*pValid = FALSE;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2018-10-17 15:16:16 +03:00
|
|
|
static BOOL check_order_activated(wLog* log, rdpSettings* settings, const char* orderName,
|
2020-06-29 09:04:15 +03:00
|
|
|
BOOL condition, const char* extendedMessage)
|
2018-10-16 16:56:17 +03:00
|
|
|
{
|
|
|
|
if (!condition)
|
|
|
|
{
|
2018-10-17 13:15:57 +03:00
|
|
|
if (settings->AllowUnanouncedOrdersFromServer)
|
|
|
|
{
|
|
|
|
WLog_Print(log, WLOG_WARN,
|
2019-11-06 17:24:51 +03:00
|
|
|
"%s - SERVER BUG: The support for this feature was not announced!",
|
|
|
|
orderName);
|
2020-06-29 09:04:15 +03:00
|
|
|
if (extendedMessage)
|
|
|
|
WLog_Print(log, WLOG_WARN, "%s", extendedMessage);
|
2018-10-17 15:16:16 +03:00
|
|
|
return TRUE;
|
2018-10-17 13:15:57 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WLog_Print(log, WLOG_ERROR,
|
2019-11-06 17:24:51 +03:00
|
|
|
"%s - SERVER BUG: The support for this feature was not announced! Use "
|
|
|
|
"/relax-order-checks to ignore",
|
2018-10-17 13:15:57 +03:00
|
|
|
orderName);
|
2020-06-29 09:04:15 +03:00
|
|
|
if (extendedMessage)
|
|
|
|
WLog_Print(log, WLOG_WARN, "%s", extendedMessage);
|
2018-10-17 15:16:16 +03:00
|
|
|
return FALSE;
|
2018-10-17 13:15:57 +03:00
|
|
|
}
|
2018-10-16 16:56:17 +03:00
|
|
|
}
|
|
|
|
|
2018-10-17 15:16:16 +03:00
|
|
|
return TRUE;
|
2018-10-16 16:56:17 +03:00
|
|
|
}
|
|
|
|
|
2018-10-17 15:16:16 +03:00
|
|
|
static BOOL check_alt_order_supported(wLog* log, rdpSettings* settings, BYTE orderType,
|
|
|
|
const char* orderName)
|
2018-10-16 16:56:17 +03:00
|
|
|
{
|
2020-06-29 09:04:15 +03:00
|
|
|
const char* extendedMessage = NULL;
|
2018-10-16 16:56:17 +03:00
|
|
|
BOOL condition = FALSE;
|
|
|
|
|
|
|
|
switch (orderType)
|
|
|
|
{
|
|
|
|
case ORDER_TYPE_CREATE_OFFSCREEN_BITMAP:
|
|
|
|
case ORDER_TYPE_SWITCH_SURFACE:
|
|
|
|
condition = settings->OffscreenSupportLevel != 0;
|
2023-09-04 11:13:08 +03:00
|
|
|
extendedMessage = "Adding /cache:offscreen might mitigate";
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_CREATE_NINE_GRID_BITMAP:
|
|
|
|
condition = settings->DrawNineGridEnabled;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_FRAME_MARKER:
|
2019-11-06 17:24:51 +03:00
|
|
|
condition = settings->FrameMarkerCommandEnabled;
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_GDIPLUS_FIRST:
|
|
|
|
case ORDER_TYPE_GDIPLUS_NEXT:
|
|
|
|
case ORDER_TYPE_GDIPLUS_END:
|
|
|
|
case ORDER_TYPE_GDIPLUS_CACHE_FIRST:
|
|
|
|
case ORDER_TYPE_GDIPLUS_CACHE_NEXT:
|
|
|
|
case ORDER_TYPE_GDIPLUS_CACHE_END:
|
2019-11-06 17:24:51 +03:00
|
|
|
condition = settings->DrawGdiPlusCacheEnabled;
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
2018-10-18 11:55:48 +03:00
|
|
|
case ORDER_TYPE_WINDOW:
|
|
|
|
condition = settings->RemoteWndSupportLevel != WINDOW_LEVEL_NOT_SUPPORTED;
|
|
|
|
break;
|
|
|
|
|
2018-10-16 16:56:17 +03:00
|
|
|
case ORDER_TYPE_STREAM_BITMAP_FIRST:
|
|
|
|
case ORDER_TYPE_STREAM_BITMAP_NEXT:
|
|
|
|
case ORDER_TYPE_COMPDESK_FIRST:
|
|
|
|
condition = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(log, WLOG_WARN, "%s - %s UNKNOWN", orderName, alt_sec_order_str);
|
2018-10-16 16:56:17 +03:00
|
|
|
condition = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-06-29 09:04:15 +03:00
|
|
|
return check_order_activated(log, settings, orderName, condition, extendedMessage);
|
2018-10-16 16:56:17 +03:00
|
|
|
}
|
|
|
|
|
2018-10-17 15:16:16 +03:00
|
|
|
static BOOL check_secondary_order_supported(wLog* log, rdpSettings* settings, BYTE orderType,
|
2019-11-06 17:24:51 +03:00
|
|
|
const char* orderName)
|
2018-10-16 16:56:17 +03:00
|
|
|
{
|
2020-06-29 09:04:15 +03:00
|
|
|
const char* extendedMessage = NULL;
|
2018-10-16 16:56:17 +03:00
|
|
|
BOOL condition = FALSE;
|
|
|
|
|
|
|
|
switch (orderType)
|
|
|
|
{
|
|
|
|
case ORDER_TYPE_BITMAP_UNCOMPRESSED:
|
|
|
|
case ORDER_TYPE_CACHE_BITMAP_COMPRESSED:
|
|
|
|
condition = settings->BitmapCacheEnabled;
|
2023-09-04 11:13:08 +03:00
|
|
|
extendedMessage = "Adding /cache:bitmap might mitigate";
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_BITMAP_UNCOMPRESSED_V2:
|
|
|
|
case ORDER_TYPE_BITMAP_COMPRESSED_V2:
|
|
|
|
condition = settings->BitmapCacheEnabled;
|
2023-09-04 11:13:08 +03:00
|
|
|
extendedMessage = "Adding /cache:bitmap might mitigate";
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_BITMAP_COMPRESSED_V3:
|
|
|
|
condition = settings->BitmapCacheV3Enabled;
|
2023-09-04 11:13:08 +03:00
|
|
|
extendedMessage = "Adding /cache:bitmap might mitigate";
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_CACHE_COLOR_TABLE:
|
2019-11-06 17:24:51 +03:00
|
|
|
condition = (settings->OrderSupport[NEG_MEMBLT_INDEX] ||
|
|
|
|
settings->OrderSupport[NEG_MEM3BLT_INDEX]);
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_CACHE_GLYPH:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
|
|
|
switch (settings->GlyphSupportLevel)
|
2018-10-16 16:56:17 +03:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
case GLYPH_SUPPORT_PARTIAL:
|
|
|
|
case GLYPH_SUPPORT_FULL:
|
|
|
|
case GLYPH_SUPPORT_ENCODE:
|
|
|
|
condition = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GLYPH_SUPPORT_NONE:
|
|
|
|
default:
|
|
|
|
condition = FALSE;
|
|
|
|
break;
|
2018-10-16 16:56:17 +03:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2018-10-16 16:56:17 +03:00
|
|
|
|
|
|
|
case ORDER_TYPE_CACHE_BRUSH:
|
|
|
|
condition = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
WLog_Print(log, WLOG_WARN, "SECONDARY ORDER %s not supported", orderName);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-06-29 09:04:15 +03:00
|
|
|
return check_order_activated(log, settings, orderName, condition, extendedMessage);
|
2018-10-16 16:56:17 +03:00
|
|
|
}
|
|
|
|
|
2018-10-17 15:16:16 +03:00
|
|
|
static BOOL check_primary_order_supported(wLog* log, rdpSettings* settings, UINT32 orderType,
|
2019-11-06 17:24:51 +03:00
|
|
|
const char* orderName)
|
2018-10-16 16:56:17 +03:00
|
|
|
{
|
2020-06-29 09:04:15 +03:00
|
|
|
const char* extendedMessage = NULL;
|
2018-10-16 16:56:17 +03:00
|
|
|
BOOL condition = FALSE;
|
|
|
|
|
|
|
|
switch (orderType)
|
|
|
|
{
|
|
|
|
case ORDER_TYPE_DSTBLT:
|
|
|
|
condition = settings->OrderSupport[NEG_DSTBLT_INDEX];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_SCRBLT:
|
|
|
|
condition = settings->OrderSupport[NEG_SCRBLT_INDEX];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_DRAW_NINE_GRID:
|
|
|
|
condition = settings->OrderSupport[NEG_DRAWNINEGRID_INDEX];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_MULTI_DRAW_NINE_GRID:
|
|
|
|
condition = settings->OrderSupport[NEG_MULTI_DRAWNINEGRID_INDEX];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_LINE_TO:
|
|
|
|
condition = settings->OrderSupport[NEG_LINETO_INDEX];
|
|
|
|
break;
|
|
|
|
|
2018-10-17 11:09:27 +03:00
|
|
|
/* [MS-RDPEGDI] 2.2.2.2.1.1.2.5 OpaqueRect (OPAQUERECT_ORDER)
|
|
|
|
* suggests that PatBlt and OpaqueRect imply each other. */
|
|
|
|
case ORDER_TYPE_PATBLT:
|
2018-10-16 16:56:17 +03:00
|
|
|
case ORDER_TYPE_OPAQUE_RECT:
|
2018-10-17 11:09:27 +03:00
|
|
|
condition = settings->OrderSupport[NEG_OPAQUE_RECT_INDEX] ||
|
|
|
|
settings->OrderSupport[NEG_PATBLT_INDEX];
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_SAVE_BITMAP:
|
|
|
|
condition = settings->OrderSupport[NEG_SAVEBITMAP_INDEX];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_MEMBLT:
|
|
|
|
condition = settings->OrderSupport[NEG_MEMBLT_INDEX];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_MEM3BLT:
|
|
|
|
condition = settings->OrderSupport[NEG_MEM3BLT_INDEX];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_MULTI_DSTBLT:
|
|
|
|
condition = settings->OrderSupport[NEG_MULTIDSTBLT_INDEX];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_MULTI_PATBLT:
|
|
|
|
condition = settings->OrderSupport[NEG_MULTIPATBLT_INDEX];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_MULTI_SCRBLT:
|
|
|
|
condition = settings->OrderSupport[NEG_MULTIDSTBLT_INDEX];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_MULTI_OPAQUE_RECT:
|
|
|
|
condition = settings->OrderSupport[NEG_MULTIOPAQUERECT_INDEX];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_FAST_INDEX:
|
|
|
|
condition = settings->OrderSupport[NEG_FAST_INDEX_INDEX];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_POLYGON_SC:
|
|
|
|
condition = settings->OrderSupport[NEG_POLYGON_SC_INDEX];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_POLYGON_CB:
|
|
|
|
condition = settings->OrderSupport[NEG_POLYGON_CB_INDEX];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_POLYLINE:
|
|
|
|
condition = settings->OrderSupport[NEG_POLYLINE_INDEX];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_FAST_GLYPH:
|
|
|
|
condition = settings->OrderSupport[NEG_FAST_GLYPH_INDEX];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_ELLIPSE_SC:
|
|
|
|
condition = settings->OrderSupport[NEG_ELLIPSE_SC_INDEX];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_ELLIPSE_CB:
|
|
|
|
condition = settings->OrderSupport[NEG_ELLIPSE_CB_INDEX];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_GLYPH_INDEX:
|
|
|
|
condition = settings->OrderSupport[NEG_GLYPH_INDEX_INDEX];
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(log, WLOG_ERROR, "%s %s not supported", orderName, primary_order_str);
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-06-29 09:04:15 +03:00
|
|
|
return check_order_activated(log, settings, orderName, condition, extendedMessage);
|
2018-10-16 16:56:17 +03:00
|
|
|
}
|
|
|
|
|
2024-09-12 01:21:27 +03:00
|
|
|
WINPR_PRAGMA_DIAG_PUSH
|
|
|
|
WINPR_PRAGMA_DIAG_IGNORED_FORMAT_NONLITERAL
|
2018-10-15 14:10:48 +03:00
|
|
|
static const char* primary_order_string(UINT32 orderType)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
const char* orders[] = { "[0x%02" PRIx8 "] DstBlt",
|
|
|
|
"[0x%02" PRIx8 "] PatBlt",
|
|
|
|
"[0x%02" PRIx8 "] ScrBlt",
|
|
|
|
"[0x%02" PRIx8 "] UNUSED",
|
|
|
|
"[0x%02" PRIx8 "] UNUSED",
|
|
|
|
"[0x%02" PRIx8 "] UNUSED",
|
|
|
|
"[0x%02" PRIx8 "] UNUSED",
|
|
|
|
"[0x%02" PRIx8 "] DrawNineGrid",
|
|
|
|
"[0x%02" PRIx8 "] MultiDrawNineGrid",
|
|
|
|
"[0x%02" PRIx8 "] LineTo",
|
|
|
|
"[0x%02" PRIx8 "] OpaqueRect",
|
|
|
|
"[0x%02" PRIx8 "] SaveBitmap",
|
|
|
|
"[0x%02" PRIx8 "] UNUSED",
|
|
|
|
"[0x%02" PRIx8 "] MemBlt",
|
|
|
|
"[0x%02" PRIx8 "] Mem3Blt",
|
|
|
|
"[0x%02" PRIx8 "] MultiDstBlt",
|
|
|
|
"[0x%02" PRIx8 "] MultiPatBlt",
|
|
|
|
"[0x%02" PRIx8 "] MultiScrBlt",
|
|
|
|
"[0x%02" PRIx8 "] MultiOpaqueRect",
|
|
|
|
"[0x%02" PRIx8 "] FastIndex",
|
|
|
|
"[0x%02" PRIx8 "] PolygonSC",
|
|
|
|
"[0x%02" PRIx8 "] PolygonCB",
|
|
|
|
"[0x%02" PRIx8 "] Polyline",
|
|
|
|
"[0x%02" PRIx8 "] UNUSED",
|
|
|
|
"[0x%02" PRIx8 "] FastGlyph",
|
|
|
|
"[0x%02" PRIx8 "] EllipseSC",
|
|
|
|
"[0x%02" PRIx8 "] EllipseCB",
|
|
|
|
"[0x%02" PRIx8 "] GlyphIndex" };
|
|
|
|
const char* fmt = "[0x%02" PRIx8 "] UNKNOWN";
|
|
|
|
static char buffer[64] = { 0 };
|
2018-10-15 14:10:48 +03:00
|
|
|
|
|
|
|
if (orderType < ARRAYSIZE(orders))
|
|
|
|
fmt = orders[orderType];
|
|
|
|
|
2024-08-26 16:39:33 +03:00
|
|
|
(void)sprintf_s(buffer, ARRAYSIZE(buffer), fmt, orderType);
|
2018-10-15 14:10:48 +03:00
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
static const char* secondary_order_string(UINT32 orderType)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
const char* orders[] = { "[0x%02" PRIx8 "] Cache Bitmap",
|
|
|
|
"[0x%02" PRIx8 "] Cache Color Table",
|
|
|
|
"[0x%02" PRIx8 "] Cache Bitmap (Compressed)",
|
|
|
|
"[0x%02" PRIx8 "] Cache Glyph",
|
|
|
|
"[0x%02" PRIx8 "] Cache Bitmap V2",
|
|
|
|
"[0x%02" PRIx8 "] Cache Bitmap V2 (Compressed)",
|
|
|
|
"[0x%02" PRIx8 "] UNUSED",
|
|
|
|
"[0x%02" PRIx8 "] Cache Brush",
|
|
|
|
"[0x%02" PRIx8 "] Cache Bitmap V3" };
|
|
|
|
const char* fmt = "[0x%02" PRIx8 "] UNKNOWN";
|
|
|
|
static char buffer[64] = { 0 };
|
2018-10-15 14:10:48 +03:00
|
|
|
|
|
|
|
if (orderType < ARRAYSIZE(orders))
|
|
|
|
fmt = orders[orderType];
|
|
|
|
|
2024-08-26 16:39:33 +03:00
|
|
|
(void)sprintf_s(buffer, ARRAYSIZE(buffer), fmt, orderType);
|
2018-10-15 14:10:48 +03:00
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
static const char* altsec_order_string(BYTE orderType)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
const char* orders[] = {
|
|
|
|
"[0x%02" PRIx8 "] Switch Surface", "[0x%02" PRIx8 "] Create Offscreen Bitmap",
|
|
|
|
"[0x%02" PRIx8 "] Stream Bitmap First", "[0x%02" PRIx8 "] Stream Bitmap Next",
|
|
|
|
"[0x%02" PRIx8 "] Create NineGrid Bitmap", "[0x%02" PRIx8 "] Draw GDI+ First",
|
|
|
|
"[0x%02" PRIx8 "] Draw GDI+ Next", "[0x%02" PRIx8 "] Draw GDI+ End",
|
|
|
|
"[0x%02" PRIx8 "] Draw GDI+ Cache First", "[0x%02" PRIx8 "] Draw GDI+ Cache Next",
|
|
|
|
"[0x%02" PRIx8 "] Draw GDI+ Cache End", "[0x%02" PRIx8 "] Windowing",
|
|
|
|
"[0x%02" PRIx8 "] Desktop Composition", "[0x%02" PRIx8 "] Frame Marker"
|
2018-10-15 14:10:48 +03:00
|
|
|
};
|
2019-11-06 17:24:51 +03:00
|
|
|
const char* fmt = "[0x%02" PRIx8 "] UNKNOWN";
|
|
|
|
static char buffer[64] = { 0 };
|
2018-10-15 14:10:48 +03:00
|
|
|
|
|
|
|
if (orderType < ARRAYSIZE(orders))
|
|
|
|
fmt = orders[orderType];
|
|
|
|
|
2024-08-26 16:39:33 +03:00
|
|
|
(void)sprintf_s(buffer, ARRAYSIZE(buffer), fmt, orderType);
|
2018-10-15 14:10:48 +03:00
|
|
|
return buffer;
|
|
|
|
}
|
2024-09-12 01:21:27 +03:00
|
|
|
WINPR_PRAGMA_DIAG_POP
|
2018-10-15 14:56:19 +03:00
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
static INLINE BOOL update_read_coord(wStream* s, INT32* coord, BOOL delta)
|
2011-07-27 00:58:10 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
INT8 lsi8 = 0;
|
|
|
|
INT16 lsi16 = 0;
|
2011-07-27 00:58:10 +04:00
|
|
|
|
|
|
|
if (delta)
|
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-07 06:27:19 +04:00
|
|
|
|
2016-07-18 18:45:30 +03:00
|
|
|
Stream_Read_INT8(s, lsi8);
|
2011-11-24 00:48:49 +04:00
|
|
|
*coord += lsi8;
|
2011-07-27 00:58:10 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-07 06:27:19 +04:00
|
|
|
|
2016-07-18 18:45:30 +03:00
|
|
|
Stream_Read_INT16(s, lsi16);
|
2011-11-24 00:48:49 +04:00
|
|
|
*coord = lsi16;
|
2011-07-27 00:58:10 +04:00
|
|
|
}
|
2013-05-07 06:27:19 +04:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
static INLINE BOOL update_write_coord(wStream* s, INT32 coord)
|
|
|
|
{
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, coord);
|
2013-05-07 06:27:19 +04:00
|
|
|
return TRUE;
|
|
|
|
}
|
2013-03-21 23:19:33 +04:00
|
|
|
static INLINE BOOL update_read_color(wStream* s, UINT32* color)
|
2011-07-27 00:58:10 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE byte = 0;
|
2011-07-27 00:58:10 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 3))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-07 20:45:52 +04:00
|
|
|
|
2016-07-18 12:16:36 +03:00
|
|
|
*color = 0;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2019-11-06 17:24:51 +03:00
|
|
|
*color = (UINT32)byte;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2019-11-06 17:24:51 +03:00
|
|
|
*color |= ((UINT32)byte << 8) & 0xFF00;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2019-11-06 17:24:51 +03:00
|
|
|
*color |= ((UINT32)byte << 16) & 0xFF0000;
|
2013-05-07 20:45:52 +04:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
static INLINE BOOL update_write_color(wStream* s, UINT32 color)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE byte = 0;
|
2013-05-07 20:45:52 +04:00
|
|
|
byte = (color & 0xFF);
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-07 20:45:52 +04:00
|
|
|
byte = ((color >> 8) & 0xFF);
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-07 20:45:52 +04:00
|
|
|
byte = ((color >> 16) & 0xFF);
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-07-27 00:58:10 +04:00
|
|
|
}
|
2016-07-18 12:16:36 +03:00
|
|
|
static INLINE BOOL update_read_colorref(wStream* s, UINT32* color)
|
2011-08-03 00:58:42 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE byte = 0;
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
|
2016-07-18 12:16:36 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*color = 0;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2011-08-03 00:58:42 +04:00
|
|
|
*color = byte;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2016-07-18 12:16:36 +03:00
|
|
|
*color |= ((UINT32)byte << 8);
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2016-07-18 12:16:36 +03:00
|
|
|
*color |= ((UINT32)byte << 16);
|
2013-05-09 00:27:21 +04:00
|
|
|
Stream_Seek_UINT8(s);
|
2016-07-18 12:16:36 +03:00
|
|
|
return TRUE;
|
2011-08-03 00:58:42 +04:00
|
|
|
}
|
2016-07-18 12:16:36 +03:00
|
|
|
static INLINE BOOL update_read_color_quad(wStream* s, UINT32* color)
|
2011-08-03 11:29:56 +04:00
|
|
|
{
|
2016-07-18 12:16:36 +03:00
|
|
|
return update_read_colorref(s, color);
|
2011-08-03 11:29:56 +04:00
|
|
|
}
|
2013-05-13 01:46:13 +04:00
|
|
|
static INLINE void update_write_color_quad(wStream* s, UINT32 color)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE byte = 0;
|
2016-07-18 12:16:36 +03:00
|
|
|
byte = (color >> 16) & 0xFF;
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2016-07-18 12:16:36 +03:00
|
|
|
byte = (color >> 8) & 0xFF;
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
byte = color & 0xFF;
|
|
|
|
Stream_Write_UINT8(s, byte);
|
|
|
|
}
|
2013-03-21 23:19:33 +04:00
|
|
|
static INLINE BOOL update_read_2byte_unsigned(wStream* s, UINT32* value)
|
2011-08-03 00:58:42 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE byte = 0;
|
2011-08-03 00:58:42 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2011-08-03 00:58:42 +04:00
|
|
|
|
2011-08-04 01:09:12 +04:00
|
|
|
if (byte & 0x80)
|
2011-08-03 00:58:42 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
|
|
|
|
2011-08-04 01:09:12 +04:00
|
|
|
*value = (byte & 0x7F) << 8;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2011-08-03 00:58:42 +04:00
|
|
|
*value |= byte;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-08-04 01:09:12 +04:00
|
|
|
*value = (byte & 0x7F);
|
2011-08-03 00:58:42 +04:00
|
|
|
}
|
2013-05-07 07:21:12 +04:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
static INLINE BOOL update_write_2byte_unsigned(wStream* s, UINT32 value)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE byte = 0;
|
2013-05-07 07:21:12 +04:00
|
|
|
|
|
|
|
if (value > 0x7FFF)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (value >= 0x7F)
|
|
|
|
{
|
|
|
|
byte = ((value & 0x7F00) >> 8);
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte | 0x80);
|
2013-05-07 07:21:12 +04:00
|
|
|
byte = (value & 0xFF);
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-07 07:21:12 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-07 19:41:32 +04:00
|
|
|
byte = (value & 0x7F);
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-07 07:21:12 +04:00
|
|
|
}
|
|
|
|
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-08-03 00:58:42 +04:00
|
|
|
}
|
2013-03-21 23:19:33 +04:00
|
|
|
static INLINE BOOL update_read_2byte_signed(wStream* s, INT32* value)
|
2011-08-03 11:29:56 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE byte = 0;
|
|
|
|
BOOL negative = 0;
|
2011-08-03 11:29:56 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2012-10-09 10:31:28 +04:00
|
|
|
negative = (byte & 0x40) ? TRUE : FALSE;
|
2011-08-04 11:23:53 +04:00
|
|
|
*value = (byte & 0x3F);
|
|
|
|
|
2011-08-04 01:09:12 +04:00
|
|
|
if (byte & 0x80)
|
2011-08-03 11:29:56 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-07 19:41:32 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2011-08-04 11:23:53 +04:00
|
|
|
*value = (*value << 8) | byte;
|
2011-08-03 11:29:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (negative)
|
|
|
|
*value *= -1;
|
2013-05-07 19:41:32 +04:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
static INLINE BOOL update_write_2byte_signed(wStream* s, INT32 value)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE byte = 0;
|
2013-05-07 19:41:32 +04:00
|
|
|
BOOL negative = FALSE;
|
|
|
|
|
|
|
|
if (value < 0)
|
|
|
|
{
|
|
|
|
negative = TRUE;
|
|
|
|
value *= -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value > 0x3FFF)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (value >= 0x3F)
|
|
|
|
{
|
|
|
|
byte = ((value & 0x3F00) >> 8);
|
|
|
|
|
|
|
|
if (negative)
|
|
|
|
byte |= 0x40;
|
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte | 0x80);
|
2013-05-07 19:41:32 +04:00
|
|
|
byte = (value & 0xFF);
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-07 19:41:32 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
byte = (value & 0x3F);
|
|
|
|
|
|
|
|
if (negative)
|
|
|
|
byte |= 0x40;
|
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-07 19:41:32 +04:00
|
|
|
}
|
|
|
|
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-08-03 11:29:56 +04:00
|
|
|
}
|
2013-03-21 23:19:33 +04:00
|
|
|
static INLINE BOOL update_read_4byte_unsigned(wStream* s, UINT32* value)
|
2011-08-04 07:33:44 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE byte = 0;
|
|
|
|
BYTE count = 0;
|
2011-08-04 07:33:44 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-08 07:41:39 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2011-08-04 07:33:44 +04:00
|
|
|
count = (byte & 0xC0) >> 6;
|
2013-05-08 07:41:39 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, count))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2011-08-04 07:33:44 +04:00
|
|
|
|
|
|
|
switch (count)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
*value = (byte & 0x3F);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
*value = (byte & 0x3F) << 8;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2011-08-04 07:33:44 +04:00
|
|
|
*value |= byte;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
*value = (byte & 0x3F) << 16;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2011-08-04 07:33:44 +04:00
|
|
|
*value |= (byte << 8);
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2011-08-04 07:33:44 +04:00
|
|
|
*value |= byte;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
*value = (byte & 0x3F) << 24;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2011-08-04 07:33:44 +04:00
|
|
|
*value |= (byte << 16);
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2011-08-04 07:33:44 +04:00
|
|
|
*value |= (byte << 8);
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2011-08-04 07:33:44 +04:00
|
|
|
*value |= byte;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2013-05-07 07:21:12 +04:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
static INLINE BOOL update_write_4byte_unsigned(wStream* s, UINT32 value)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE byte = 0;
|
2013-05-07 07:21:12 +04:00
|
|
|
|
|
|
|
if (value <= 0x3F)
|
|
|
|
{
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, value);
|
2013-05-07 07:21:12 +04:00
|
|
|
}
|
|
|
|
else if (value <= 0x3FFF)
|
|
|
|
{
|
|
|
|
byte = (value >> 8) & 0x3F;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte | 0x40);
|
2013-05-07 07:21:12 +04:00
|
|
|
byte = (value & 0xFF);
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-07 07:21:12 +04:00
|
|
|
}
|
|
|
|
else if (value <= 0x3FFFFF)
|
|
|
|
{
|
|
|
|
byte = (value >> 16) & 0x3F;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte | 0x80);
|
2013-05-07 07:21:12 +04:00
|
|
|
byte = (value >> 8) & 0xFF;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-07 07:21:12 +04:00
|
|
|
byte = (value & 0xFF);
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-07 07:21:12 +04:00
|
|
|
}
|
2014-04-28 01:21:30 +04:00
|
|
|
else if (value <= 0x3FFFFFFF)
|
2013-05-07 07:21:12 +04:00
|
|
|
{
|
|
|
|
byte = (value >> 24) & 0x3F;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte | 0xC0);
|
2013-05-07 07:21:12 +04:00
|
|
|
byte = (value >> 16) & 0xFF;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-07 07:21:12 +04:00
|
|
|
byte = (value >> 8) & 0xFF;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-07 07:21:12 +04:00
|
|
|
byte = (value & 0xFF);
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-07 07:21:12 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-08-04 07:33:44 +04:00
|
|
|
}
|
2024-04-22 10:57:37 +03:00
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
static INLINE BOOL update_read_delta(wStream* s, INT32* value)
|
2011-08-04 11:23:53 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE byte = 0;
|
2024-04-22 10:57:37 +03:00
|
|
|
UINT32 uvalue = 0;
|
2011-08-04 11:23:53 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2011-08-04 11:23:53 +04:00
|
|
|
|
|
|
|
if (byte & 0x40)
|
2024-04-22 10:57:37 +03:00
|
|
|
uvalue = (byte | ~0x3F);
|
2011-08-04 11:23:53 +04:00
|
|
|
else
|
2024-04-22 10:57:37 +03:00
|
|
|
uvalue = (byte & 0x3F);
|
2011-08-04 11:23:53 +04:00
|
|
|
|
|
|
|
if (byte & 0x80)
|
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2024-04-22 10:57:37 +03:00
|
|
|
uvalue = (uvalue << 8) | byte;
|
2011-08-04 11:23:53 +04:00
|
|
|
}
|
2024-04-22 10:57:37 +03:00
|
|
|
*value = (INT32)uvalue;
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-08-04 11:23:53 +04:00
|
|
|
}
|
2014-04-29 18:02:31 +04:00
|
|
|
#if 0
|
2013-03-21 23:19:33 +04:00
|
|
|
static INLINE void update_read_glyph_delta(wStream* s, UINT16* value)
|
2011-09-05 00:49:22 +04:00
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE byte;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2011-09-05 00:49:22 +04:00
|
|
|
|
|
|
|
if (byte == 0x80)
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, *value);
|
2011-09-05 00:49:22 +04:00
|
|
|
else
|
|
|
|
*value = (byte & 0x3F);
|
|
|
|
}
|
2013-03-21 23:19:33 +04:00
|
|
|
static INLINE void update_seek_glyph_delta(wStream* s)
|
2011-09-05 00:49:22 +04:00
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE byte;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2011-09-05 00:49:22 +04:00
|
|
|
|
|
|
|
if (byte & 0x80)
|
2013-05-09 00:27:21 +04:00
|
|
|
Stream_Seek_UINT8(s);
|
2011-09-05 00:49:22 +04:00
|
|
|
}
|
2014-04-29 18:02:31 +04:00
|
|
|
#endif
|
2019-11-06 17:24:51 +03:00
|
|
|
static INLINE BOOL update_read_brush(wStream* s, rdpBrush* brush, BYTE fieldFlags)
|
2011-08-08 05:12:36 +04:00
|
|
|
{
|
|
|
|
if (fieldFlags & ORDER_FIELD_01)
|
2013-01-12 03:17:45 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-07 20:45:52 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, brush->x);
|
2013-01-12 03:17:45 +04:00
|
|
|
}
|
2011-08-08 05:12:36 +04:00
|
|
|
|
|
|
|
if (fieldFlags & ORDER_FIELD_02)
|
2013-01-12 03:17:45 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-07 20:45:52 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, brush->y);
|
2013-01-12 03:17:45 +04:00
|
|
|
}
|
2011-08-08 05:12:36 +04:00
|
|
|
|
|
|
|
if (fieldFlags & ORDER_FIELD_03)
|
2013-01-12 03:17:45 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-07 20:45:52 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, brush->style);
|
2013-01-12 03:17:45 +04:00
|
|
|
}
|
2011-08-08 05:12:36 +04:00
|
|
|
|
|
|
|
if (fieldFlags & ORDER_FIELD_04)
|
2013-01-12 03:17:45 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-07 20:45:52 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, brush->hatch);
|
2013-01-12 03:17:45 +04:00
|
|
|
}
|
2011-08-08 05:12:36 +04:00
|
|
|
|
|
|
|
if (brush->style & CACHED_BRUSH)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BOOL rc = 0;
|
2011-08-08 05:12:36 +04:00
|
|
|
brush->index = brush->hatch;
|
2020-05-26 08:50:55 +03:00
|
|
|
brush->bpp = get_bmf_bpp(brush->style, &rc);
|
|
|
|
if (!rc)
|
|
|
|
return FALSE;
|
2011-08-08 05:12:36 +04:00
|
|
|
if (brush->bpp == 0)
|
|
|
|
brush->bpp = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fieldFlags & ORDER_FIELD_05)
|
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 7))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-07 20:45:52 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
brush->data = (BYTE*)brush->p8x8;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, brush->data[7]);
|
|
|
|
Stream_Read_UINT8(s, brush->data[6]);
|
|
|
|
Stream_Read_UINT8(s, brush->data[5]);
|
|
|
|
Stream_Read_UINT8(s, brush->data[4]);
|
|
|
|
Stream_Read_UINT8(s, brush->data[3]);
|
|
|
|
Stream_Read_UINT8(s, brush->data[2]);
|
|
|
|
Stream_Read_UINT8(s, brush->data[1]);
|
2011-08-08 05:12:36 +04:00
|
|
|
brush->data[0] = brush->hatch;
|
|
|
|
}
|
2013-05-07 20:45:52 +04:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
static INLINE BOOL update_write_brush(wStream* s, rdpBrush* brush, BYTE fieldFlags)
|
2013-05-07 20:45:52 +04:00
|
|
|
{
|
|
|
|
if (fieldFlags & ORDER_FIELD_01)
|
|
|
|
{
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, brush->x);
|
2013-05-07 20:45:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fieldFlags & ORDER_FIELD_02)
|
|
|
|
{
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, brush->y);
|
2013-05-07 20:45:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fieldFlags & ORDER_FIELD_03)
|
|
|
|
{
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, brush->style);
|
2013-05-07 20:45:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (brush->style & CACHED_BRUSH)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BOOL rc = 0;
|
2013-05-08 02:44:22 +04:00
|
|
|
brush->hatch = brush->index;
|
2020-05-26 08:50:55 +03:00
|
|
|
brush->bpp = get_bmf_bpp(brush->style, &rc);
|
|
|
|
if (!rc)
|
|
|
|
return FALSE;
|
2013-05-07 20:45:52 +04:00
|
|
|
if (brush->bpp == 0)
|
|
|
|
brush->bpp = 1;
|
|
|
|
}
|
|
|
|
|
2013-05-08 02:44:22 +04:00
|
|
|
if (fieldFlags & ORDER_FIELD_04)
|
|
|
|
{
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, brush->hatch);
|
2013-05-08 02:44:22 +04:00
|
|
|
}
|
|
|
|
|
2013-05-07 20:45:52 +04:00
|
|
|
if (fieldFlags & ORDER_FIELD_05)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
brush->data = (BYTE*)brush->p8x8;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, brush->data[7]);
|
|
|
|
Stream_Write_UINT8(s, brush->data[6]);
|
|
|
|
Stream_Write_UINT8(s, brush->data[5]);
|
|
|
|
Stream_Write_UINT8(s, brush->data[4]);
|
|
|
|
Stream_Write_UINT8(s, brush->data[3]);
|
|
|
|
Stream_Write_UINT8(s, brush->data[2]);
|
|
|
|
Stream_Write_UINT8(s, brush->data[1]);
|
2013-05-07 20:45:52 +04:00
|
|
|
brush->data[0] = brush->hatch;
|
|
|
|
}
|
|
|
|
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-08-08 05:12:36 +04:00
|
|
|
}
|
2024-08-29 16:10:21 +03:00
|
|
|
static INLINE BOOL update_read_delta_rects(wStream* s, DELTA_RECT* rectangles, const UINT32* nr)
|
2011-08-04 11:23:53 +04:00
|
|
|
{
|
2020-03-30 19:14:18 +03:00
|
|
|
UINT32 number = *nr;
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE flags = 0;
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE* zeroBits = NULL;
|
|
|
|
UINT32 zeroBitsSize = 0;
|
2011-08-04 11:23:53 +04:00
|
|
|
|
|
|
|
if (number > 45)
|
2020-03-30 19:14:18 +03:00
|
|
|
{
|
|
|
|
WLog_WARN(TAG, "Invalid number of delta rectangles %" PRIu32, number);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-08-04 11:23:53 +04:00
|
|
|
|
|
|
|
zeroBitsSize = ((number + 1) / 2);
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, zeroBitsSize))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-15 22:42:37 +04:00
|
|
|
|
2013-05-09 00:27:21 +04:00
|
|
|
Stream_GetPointer(s, zeroBits);
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, zeroBitsSize);
|
2016-07-19 14:02:08 +03:00
|
|
|
ZeroMemory(rectangles, sizeof(DELTA_RECT) * number);
|
2011-08-04 11:23:53 +04:00
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 i = 0; i < number; i++)
|
2011-08-04 11:23:53 +04:00
|
|
|
{
|
2016-07-19 14:02:08 +03:00
|
|
|
if (i % 2 == 0)
|
|
|
|
flags = zeroBits[i / 2];
|
2011-08-04 11:23:53 +04:00
|
|
|
|
2013-01-12 03:17:45 +04:00
|
|
|
if ((~flags & 0x80) && !update_read_delta(s, &rectangles[i].left))
|
|
|
|
return FALSE;
|
2011-08-04 11:23:53 +04:00
|
|
|
|
2013-01-12 03:17:45 +04:00
|
|
|
if ((~flags & 0x40) && !update_read_delta(s, &rectangles[i].top))
|
|
|
|
return FALSE;
|
2011-08-04 11:23:53 +04:00
|
|
|
|
|
|
|
if (~flags & 0x20)
|
2013-01-12 03:17:45 +04:00
|
|
|
{
|
2013-01-19 01:50:25 +04:00
|
|
|
if (!update_read_delta(s, &rectangles[i].width))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
2016-07-19 14:02:08 +03:00
|
|
|
else if (i > 0)
|
2011-08-04 11:23:53 +04:00
|
|
|
rectangles[i].width = rectangles[i - 1].width;
|
2016-07-19 14:02:08 +03:00
|
|
|
else
|
|
|
|
rectangles[i].width = 0;
|
2011-08-04 11:23:53 +04:00
|
|
|
|
|
|
|
if (~flags & 0x10)
|
2013-01-12 03:17:45 +04:00
|
|
|
{
|
2013-01-19 01:50:25 +04:00
|
|
|
if (!update_read_delta(s, &rectangles[i].height))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
2016-07-19 14:02:08 +03:00
|
|
|
else if (i > 0)
|
|
|
|
rectangles[i].height = rectangles[i - 1].height;
|
2011-08-04 11:23:53 +04:00
|
|
|
else
|
2016-07-19 14:02:08 +03:00
|
|
|
rectangles[i].height = 0;
|
|
|
|
|
|
|
|
if (i > 0)
|
2013-05-15 22:42:37 +04:00
|
|
|
{
|
2016-07-19 14:02:08 +03:00
|
|
|
rectangles[i].left += rectangles[i - 1].left;
|
|
|
|
rectangles[i].top += rectangles[i - 1].top;
|
2013-05-15 22:42:37 +04:00
|
|
|
}
|
2011-08-04 11:23:53 +04:00
|
|
|
|
|
|
|
flags <<= 4;
|
|
|
|
}
|
2013-05-15 22:42:37 +04:00
|
|
|
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-08-04 11:23:53 +04:00
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2023-09-04 12:02:01 +03:00
|
|
|
static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT** points, UINT32 number,
|
|
|
|
INT16 x, INT16 y)
|
2011-08-04 11:23:53 +04:00
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE flags = 0;
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE* zeroBits = NULL;
|
2022-01-11 18:29:40 +03:00
|
|
|
UINT32 zeroBitsSize = ((number + 3) / 4);
|
2011-08-04 11:23:53 +04:00
|
|
|
|
2023-09-04 12:02:01 +03:00
|
|
|
WINPR_ASSERT(points);
|
|
|
|
DELTA_POINT* newpoints = (DELTA_POINT*)realloc(*points, sizeof(DELTA_POINT) * number);
|
|
|
|
|
|
|
|
if (!newpoints)
|
|
|
|
return FALSE;
|
|
|
|
*points = newpoints;
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, zeroBitsSize))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-15 22:42:37 +04:00
|
|
|
|
2013-05-09 00:27:21 +04:00
|
|
|
Stream_GetPointer(s, zeroBits);
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, zeroBitsSize);
|
2023-09-21 10:25:15 +03:00
|
|
|
ZeroMemory(*points, sizeof(DELTA_POINT) * number);
|
2011-08-04 11:23:53 +04:00
|
|
|
|
2023-09-04 12:02:01 +03:00
|
|
|
for (UINT32 i = 0; i < number; i++)
|
2011-08-04 11:23:53 +04:00
|
|
|
{
|
2011-09-10 15:32:09 +04:00
|
|
|
if (i % 4 == 0)
|
|
|
|
flags = zeroBits[i / 4];
|
2011-08-04 11:23:53 +04:00
|
|
|
|
2023-09-04 12:02:01 +03:00
|
|
|
if ((~flags & 0x80) && !update_read_delta(s, &newpoints[i].x))
|
2015-05-02 06:26:08 +03:00
|
|
|
{
|
2015-06-23 12:08:44 +03:00
|
|
|
WLog_ERR(TAG, "update_read_delta(x) failed");
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2015-03-19 02:41:29 +03:00
|
|
|
}
|
2011-08-04 11:23:53 +04:00
|
|
|
|
2023-09-04 12:02:01 +03:00
|
|
|
if ((~flags & 0x40) && !update_read_delta(s, &newpoints[i].y))
|
2015-05-02 06:26:08 +03:00
|
|
|
{
|
2015-06-23 12:08:44 +03:00
|
|
|
WLog_ERR(TAG, "update_read_delta(y) failed");
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2015-03-19 02:41:29 +03:00
|
|
|
}
|
2011-08-04 11:23:53 +04:00
|
|
|
|
|
|
|
flags <<= 2;
|
|
|
|
}
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-08-04 11:23:53 +04:00
|
|
|
}
|
2020-10-12 12:09:10 +03:00
|
|
|
|
2021-01-13 13:52:24 +03:00
|
|
|
static BOOL order_field_flag_is_set(const ORDER_INFO* orderInfo, BYTE number)
|
|
|
|
{
|
|
|
|
const UINT32 mask = (1UL << ((UINT32)number - 1UL));
|
|
|
|
const BOOL set = (orderInfo->fieldFlags & mask) != 0;
|
|
|
|
return set;
|
|
|
|
}
|
|
|
|
|
2023-09-04 10:26:06 +03:00
|
|
|
static INLINE BOOL read_order_field_byte(const char* orderName, const ORDER_INFO* orderInfo,
|
|
|
|
wStream* s, BYTE number, UINT32* target, BOOL optional)
|
2020-10-12 12:09:10 +03:00
|
|
|
{
|
2023-09-04 10:26:06 +03:00
|
|
|
WINPR_ASSERT(orderName);
|
|
|
|
WINPR_ASSERT(orderInfo);
|
|
|
|
WINPR_ASSERT(target);
|
|
|
|
|
2021-01-13 13:52:24 +03:00
|
|
|
if (!order_field_flag_is_set(orderInfo, number))
|
2023-09-04 11:57:38 +03:00
|
|
|
{
|
|
|
|
WLog_DBG(TAG, "order %s field %" PRIu8 " not found [optional:%d]", orderName, number,
|
|
|
|
optional);
|
2020-10-12 12:09:10 +03:00
|
|
|
return TRUE;
|
2023-09-04 11:57:38 +03:00
|
|
|
}
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2020-10-12 12:09:10 +03:00
|
|
|
return FALSE;
|
|
|
|
Stream_Read_UINT8(s, *target);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2023-09-04 10:26:06 +03:00
|
|
|
static INLINE BOOL read_order_field_2bytes(const char* orderName, const ORDER_INFO* orderInfo,
|
|
|
|
wStream* s, BYTE number, UINT32* target1,
|
|
|
|
UINT32* target2, BOOL optional)
|
2020-10-12 12:09:10 +03:00
|
|
|
{
|
2023-09-04 10:26:06 +03:00
|
|
|
WINPR_ASSERT(orderName);
|
|
|
|
WINPR_ASSERT(orderInfo);
|
|
|
|
WINPR_ASSERT(target1);
|
|
|
|
WINPR_ASSERT(target2);
|
|
|
|
|
2021-01-13 13:52:24 +03:00
|
|
|
if (!order_field_flag_is_set(orderInfo, number))
|
2023-09-04 11:57:38 +03:00
|
|
|
{
|
|
|
|
WLog_DBG(TAG, "order %s field %" PRIu8 " not found [optional:%d]", orderName, number,
|
|
|
|
optional);
|
2020-10-12 12:09:10 +03:00
|
|
|
return TRUE;
|
2023-09-04 11:57:38 +03:00
|
|
|
}
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
|
2020-10-12 12:09:10 +03:00
|
|
|
return FALSE;
|
|
|
|
Stream_Read_UINT8(s, *target1);
|
|
|
|
Stream_Read_UINT8(s, *target2);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2023-09-04 10:26:06 +03:00
|
|
|
static INLINE BOOL read_order_field_uint16(const char* orderName, const ORDER_INFO* orderInfo,
|
|
|
|
wStream* s, BYTE number, UINT32* target, BOOL optional)
|
2020-10-12 12:09:10 +03:00
|
|
|
{
|
2023-09-04 10:26:06 +03:00
|
|
|
WINPR_ASSERT(orderName);
|
|
|
|
WINPR_ASSERT(orderInfo);
|
|
|
|
WINPR_ASSERT(target);
|
|
|
|
|
2021-01-13 13:52:24 +03:00
|
|
|
if (!order_field_flag_is_set(orderInfo, number))
|
2023-09-04 11:57:38 +03:00
|
|
|
{
|
|
|
|
WLog_DBG(TAG, "order %s field %" PRIu8 " not found [optional:%d]", orderName, number,
|
|
|
|
optional);
|
2020-10-12 12:09:10 +03:00
|
|
|
return TRUE;
|
2023-09-04 11:57:38 +03:00
|
|
|
}
|
2020-10-12 12:09:10 +03:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
|
2020-10-12 12:09:10 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Read_UINT16(s, *target);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2023-09-04 10:26:06 +03:00
|
|
|
static INLINE BOOL read_order_field_int16(const char* orderName, const ORDER_INFO* orderInfo,
|
|
|
|
wStream* s, BYTE number, INT32* target, BOOL optional)
|
2020-10-12 12:09:10 +03:00
|
|
|
{
|
2023-09-04 10:26:06 +03:00
|
|
|
WINPR_ASSERT(orderName);
|
|
|
|
WINPR_ASSERT(orderInfo);
|
|
|
|
WINPR_ASSERT(target);
|
|
|
|
|
2021-01-13 13:52:24 +03:00
|
|
|
if (!order_field_flag_is_set(orderInfo, number))
|
2023-09-04 11:57:38 +03:00
|
|
|
{
|
|
|
|
WLog_DBG(TAG, "order %s field %" PRIu8 " not found [optional:%d]", orderName, number,
|
|
|
|
optional);
|
2020-10-12 12:09:10 +03:00
|
|
|
return TRUE;
|
2023-09-04 11:57:38 +03:00
|
|
|
}
|
2020-10-12 12:09:10 +03:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
|
2020-10-12 12:09:10 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Read_INT16(s, *target);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2023-09-04 10:26:06 +03:00
|
|
|
static INLINE BOOL read_order_field_uint32(const char* orderName, const ORDER_INFO* orderInfo,
|
|
|
|
wStream* s, BYTE number, UINT32* target, BOOL optional)
|
2020-10-12 12:09:10 +03:00
|
|
|
{
|
2023-09-04 10:26:06 +03:00
|
|
|
WINPR_ASSERT(orderName);
|
|
|
|
WINPR_ASSERT(orderInfo);
|
|
|
|
WINPR_ASSERT(target);
|
|
|
|
|
2021-01-13 13:52:24 +03:00
|
|
|
if (!order_field_flag_is_set(orderInfo, number))
|
2023-09-04 11:57:38 +03:00
|
|
|
{
|
|
|
|
WLog_DBG(TAG, "order %s field %" PRIu8 " not found [optional:%d]", orderName, number,
|
|
|
|
optional);
|
2020-10-12 12:09:10 +03:00
|
|
|
return TRUE;
|
2023-09-04 11:57:38 +03:00
|
|
|
}
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
|
2020-10-12 12:09:10 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Read_UINT32(s, *target);
|
2020-10-16 09:14:13 +03:00
|
|
|
return TRUE;
|
2020-10-12 12:09:10 +03:00
|
|
|
}
|
|
|
|
|
2023-09-04 10:26:06 +03:00
|
|
|
static INLINE BOOL read_order_field_coord(const char* orderName, const ORDER_INFO* orderInfo,
|
|
|
|
wStream* s, UINT32 NO, INT32* TARGET, BOOL optional)
|
2020-10-12 12:09:10 +03:00
|
|
|
{
|
2023-09-04 10:26:06 +03:00
|
|
|
WINPR_ASSERT(orderName);
|
|
|
|
WINPR_ASSERT(orderInfo);
|
|
|
|
WINPR_ASSERT(TARGET);
|
|
|
|
|
2021-01-13 13:52:24 +03:00
|
|
|
if (!order_field_flag_is_set(orderInfo, NO))
|
2023-09-04 11:57:38 +03:00
|
|
|
{
|
|
|
|
WLog_DBG(TAG, "order %s field %" PRIu8 " not found [optional:%d]", orderName, NO, optional);
|
2020-10-12 12:09:10 +03:00
|
|
|
return TRUE;
|
2023-09-04 11:57:38 +03:00
|
|
|
}
|
2020-10-12 12:09:10 +03:00
|
|
|
|
|
|
|
return update_read_coord(s, TARGET, orderInfo->deltaCoordinates);
|
|
|
|
}
|
|
|
|
|
2023-09-04 10:26:06 +03:00
|
|
|
static INLINE BOOL read_order_field_color(const char* orderName, const ORDER_INFO* orderInfo,
|
|
|
|
wStream* s, UINT32 NO, UINT32* TARGET, BOOL optional)
|
2016-07-18 12:16:36 +03:00
|
|
|
{
|
2023-09-04 10:26:06 +03:00
|
|
|
WINPR_ASSERT(orderName);
|
|
|
|
WINPR_ASSERT(orderInfo);
|
|
|
|
WINPR_ASSERT(TARGET);
|
|
|
|
|
2021-01-13 13:52:24 +03:00
|
|
|
if (!order_field_flag_is_set(orderInfo, NO))
|
2023-09-04 11:57:38 +03:00
|
|
|
{
|
|
|
|
WLog_DBG(TAG, "order %s field %" PRIu8 " not found [optional:%d]", orderName, NO, optional);
|
2020-10-12 12:09:10 +03:00
|
|
|
return TRUE;
|
2023-09-04 11:57:38 +03:00
|
|
|
}
|
2016-07-18 12:16:36 +03:00
|
|
|
|
2020-10-12 12:09:10 +03:00
|
|
|
if (!update_read_color(s, TARGET))
|
2016-07-18 12:16:36 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
static INLINE BOOL FIELD_SKIP_BUFFER16(wStream* s, UINT32 TARGET_LEN)
|
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
|
2016-07-18 12:16:36 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Read_UINT16(s, TARGET_LEN);
|
|
|
|
|
|
|
|
if (!Stream_SafeSeek(s, TARGET_LEN))
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG, "error skipping %" PRIu32 " bytes", TARGET_LEN);
|
2016-07-18 12:16:36 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2013-01-12 03:17:45 +04:00
|
|
|
/* Primary Drawing Orders */
|
2023-09-04 10:26:06 +03:00
|
|
|
static BOOL update_read_dstblt_order(const char* orderName, wStream* s, const ORDER_INFO* orderInfo,
|
|
|
|
DSTBLT_ORDER* dstblt)
|
|
|
|
{
|
|
|
|
if (read_order_field_coord(orderName, orderInfo, s, 1, &dstblt->nLeftRect, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 2, &dstblt->nTopRect, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 3, &dstblt->nWidth, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 4, &dstblt->nHeight, FALSE) &&
|
|
|
|
read_order_field_byte(orderName, orderInfo, s, 5, &dstblt->bRop, TRUE))
|
2020-10-15 12:03:29 +03:00
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
|
|
|
size_t update_approximate_dstblt_order(ORDER_INFO* orderInfo, const DSTBLT_ORDER* dstblt)
|
2013-06-10 01:56:57 +04:00
|
|
|
{
|
2022-01-11 18:29:40 +03:00
|
|
|
WINPR_UNUSED(orderInfo);
|
|
|
|
WINPR_UNUSED(dstblt);
|
2013-06-10 01:56:57 +04:00
|
|
|
return 32;
|
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL update_write_dstblt_order(wStream* s, ORDER_INFO* orderInfo, const DSTBLT_ORDER* dstblt)
|
2013-05-13 01:46:13 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, update_approximate_dstblt_order(orderInfo, dstblt)))
|
2015-03-26 19:09:47 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
orderInfo->fieldFlags = 0;
|
2013-05-13 01:46:13 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_01;
|
|
|
|
update_write_coord(s, dstblt->nLeftRect);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_02;
|
|
|
|
update_write_coord(s, dstblt->nTopRect);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_03;
|
|
|
|
update_write_coord(s, dstblt->nWidth);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_04;
|
|
|
|
update_write_coord(s, dstblt->nHeight);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_05;
|
|
|
|
Stream_Write_UINT8(s, dstblt->bRop);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2023-09-04 10:26:06 +03:00
|
|
|
static BOOL update_read_patblt_order(const char* orderName, wStream* s, const ORDER_INFO* orderInfo,
|
|
|
|
PATBLT_ORDER* patblt)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2023-09-04 10:26:06 +03:00
|
|
|
if (read_order_field_coord(orderName, orderInfo, s, 1, &patblt->nLeftRect, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 2, &patblt->nTopRect, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 3, &patblt->nWidth, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 4, &patblt->nHeight, FALSE) &&
|
|
|
|
read_order_field_byte(orderName, orderInfo, s, 5, &patblt->bRop, TRUE) &&
|
|
|
|
read_order_field_color(orderName, orderInfo, s, 6, &patblt->backColor, TRUE) &&
|
|
|
|
read_order_field_color(orderName, orderInfo, s, 7, &patblt->foreColor, TRUE) &&
|
2020-10-15 12:03:29 +03:00
|
|
|
update_read_brush(s, &patblt->brush, orderInfo->fieldFlags >> 7))
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
|
|
|
size_t update_approximate_patblt_order(ORDER_INFO* orderInfo, PATBLT_ORDER* patblt)
|
2013-06-10 01:56:57 +04:00
|
|
|
{
|
2022-01-11 18:29:40 +03:00
|
|
|
WINPR_UNUSED(orderInfo);
|
|
|
|
WINPR_UNUSED(patblt);
|
2013-06-10 01:56:57 +04:00
|
|
|
return 32;
|
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL update_write_patblt_order(wStream* s, ORDER_INFO* orderInfo, PATBLT_ORDER* patblt)
|
2013-05-07 20:45:52 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, update_approximate_patblt_order(orderInfo, patblt)))
|
2015-03-26 19:09:47 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
orderInfo->fieldFlags = 0;
|
2013-05-07 20:45:52 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_01;
|
|
|
|
update_write_coord(s, patblt->nLeftRect);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_02;
|
|
|
|
update_write_coord(s, patblt->nTopRect);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_03;
|
|
|
|
update_write_coord(s, patblt->nWidth);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_04;
|
|
|
|
update_write_coord(s, patblt->nHeight);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_05;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, patblt->bRop);
|
2013-05-07 20:45:52 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_06;
|
2013-05-09 22:33:39 +04:00
|
|
|
update_write_color(s, patblt->backColor);
|
2013-05-07 20:45:52 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_07;
|
2013-05-09 22:33:39 +04:00
|
|
|
update_write_color(s, patblt->foreColor);
|
2013-05-07 20:45:52 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_08;
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_09;
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_10;
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_11;
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_12;
|
|
|
|
update_write_brush(s, &patblt->brush, orderInfo->fieldFlags >> 7);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2023-09-04 10:26:06 +03:00
|
|
|
static BOOL update_read_scrblt_order(const char* orderName, wStream* s, const ORDER_INFO* orderInfo,
|
|
|
|
SCRBLT_ORDER* scrblt)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2023-09-04 10:26:06 +03:00
|
|
|
if (read_order_field_coord(orderName, orderInfo, s, 1, &scrblt->nLeftRect, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 2, &scrblt->nTopRect, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 3, &scrblt->nWidth, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 4, &scrblt->nHeight, FALSE) &&
|
|
|
|
read_order_field_byte(orderName, orderInfo, s, 5, &scrblt->bRop, TRUE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 6, &scrblt->nXSrc, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 7, &scrblt->nYSrc, FALSE))
|
2020-10-15 12:03:29 +03:00
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
2013-05-07 20:45:52 +04:00
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
|
|
|
size_t update_approximate_scrblt_order(ORDER_INFO* orderInfo, const SCRBLT_ORDER* scrblt)
|
2013-06-10 01:56:57 +04:00
|
|
|
{
|
2022-01-11 18:29:40 +03:00
|
|
|
WINPR_UNUSED(orderInfo);
|
|
|
|
WINPR_UNUSED(scrblt);
|
2013-06-10 01:56:57 +04:00
|
|
|
return 32;
|
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL update_write_scrblt_order(wStream* s, ORDER_INFO* orderInfo, const SCRBLT_ORDER* scrblt)
|
2013-05-07 20:45:52 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, update_approximate_scrblt_order(orderInfo, scrblt)))
|
2015-03-26 19:09:47 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
orderInfo->fieldFlags = 0;
|
2013-05-07 20:45:52 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_01;
|
|
|
|
update_write_coord(s, scrblt->nLeftRect);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_02;
|
|
|
|
update_write_coord(s, scrblt->nTopRect);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_03;
|
|
|
|
update_write_coord(s, scrblt->nWidth);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_04;
|
|
|
|
update_write_coord(s, scrblt->nHeight);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_05;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, scrblt->bRop);
|
2013-05-07 20:45:52 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_06;
|
|
|
|
update_write_coord(s, scrblt->nXSrc);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_07;
|
|
|
|
update_write_coord(s, scrblt->nYSrc);
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2023-09-04 10:26:06 +03:00
|
|
|
static BOOL update_read_opaque_rect_order(const char* orderName, wStream* s,
|
|
|
|
const ORDER_INFO* orderInfo,
|
2019-11-06 17:24:51 +03:00
|
|
|
OPAQUE_RECT_ORDER* opaque_rect)
|
2011-08-02 20:59:45 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE byte = 0;
|
2023-09-04 10:26:06 +03:00
|
|
|
if (!read_order_field_coord(orderName, orderInfo, s, 1, &opaque_rect->nLeftRect, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 2, &opaque_rect->nTopRect, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 3, &opaque_rect->nWidth, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 4, &opaque_rect->nHeight, FALSE))
|
2020-10-12 12:09:10 +03:00
|
|
|
return FALSE;
|
2011-08-02 20:59:45 +04:00
|
|
|
|
2020-10-12 12:09:10 +03:00
|
|
|
if ((orderInfo->fieldFlags & ORDER_FIELD_05) != 0)
|
2011-08-02 20:59:45 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-07 06:27:19 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2019-11-06 17:24:51 +03:00
|
|
|
opaque_rect->color = (opaque_rect->color & 0x00FFFF00) | ((UINT32)byte);
|
2011-08-02 20:59:45 +04:00
|
|
|
}
|
|
|
|
|
2020-10-12 12:09:10 +03:00
|
|
|
if ((orderInfo->fieldFlags & ORDER_FIELD_06) != 0)
|
2013-05-07 06:27:19 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-07 06:27:19 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2019-11-06 17:24:51 +03:00
|
|
|
opaque_rect->color = (opaque_rect->color & 0x00FF00FF) | ((UINT32)byte << 8);
|
2011-08-02 20:59:45 +04:00
|
|
|
}
|
|
|
|
|
2020-10-12 12:09:10 +03:00
|
|
|
if ((orderInfo->fieldFlags & ORDER_FIELD_07) != 0)
|
2013-05-07 06:27:19 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-07 06:27:19 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2019-11-06 17:24:51 +03:00
|
|
|
opaque_rect->color = (opaque_rect->color & 0x0000FFFF) | ((UINT32)byte << 16);
|
2011-08-02 20:59:45 +04:00
|
|
|
}
|
2013-05-07 06:27:19 +04:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
|
|
|
size_t update_approximate_opaque_rect_order(ORDER_INFO* orderInfo,
|
|
|
|
const OPAQUE_RECT_ORDER* opaque_rect)
|
2013-06-10 01:56:57 +04:00
|
|
|
{
|
2022-01-11 18:29:40 +03:00
|
|
|
WINPR_UNUSED(orderInfo);
|
|
|
|
WINPR_UNUSED(opaque_rect);
|
2013-06-10 01:56:57 +04:00
|
|
|
return 32;
|
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
BOOL update_write_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo,
|
2016-07-21 13:53:44 +03:00
|
|
|
const OPAQUE_RECT_ORDER* opaque_rect)
|
2013-05-07 06:27:19 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE byte = 0;
|
2022-01-11 18:29:40 +03:00
|
|
|
size_t inf = update_approximate_opaque_rect_order(orderInfo, opaque_rect);
|
2013-05-07 06:27:19 +04:00
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, inf))
|
2015-03-26 19:09:47 +03:00
|
|
|
return FALSE;
|
2013-05-10 00:30:28 +04:00
|
|
|
|
2016-07-18 12:16:36 +03:00
|
|
|
// TODO: Color format conversion
|
2013-05-07 06:27:19 +04:00
|
|
|
orderInfo->fieldFlags = 0;
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_01;
|
|
|
|
update_write_coord(s, opaque_rect->nLeftRect);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_02;
|
|
|
|
update_write_coord(s, opaque_rect->nTopRect);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_03;
|
|
|
|
update_write_coord(s, opaque_rect->nWidth);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_04;
|
|
|
|
update_write_coord(s, opaque_rect->nHeight);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_05;
|
|
|
|
byte = opaque_rect->color & 0x000000FF;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-07 06:27:19 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_06;
|
|
|
|
byte = (opaque_rect->color & 0x0000FF00) >> 8;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-07 06:27:19 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_07;
|
|
|
|
byte = (opaque_rect->color & 0x00FF0000) >> 16;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-08-02 20:59:45 +04:00
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2023-09-04 10:26:06 +03:00
|
|
|
static BOOL update_read_draw_nine_grid_order(const char* orderName, wStream* s,
|
|
|
|
const ORDER_INFO* orderInfo,
|
2019-11-06 17:24:51 +03:00
|
|
|
DRAW_NINE_GRID_ORDER* draw_nine_grid)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2023-09-04 10:26:06 +03:00
|
|
|
if (read_order_field_coord(orderName, orderInfo, s, 1, &draw_nine_grid->srcLeft, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 2, &draw_nine_grid->srcTop, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 3, &draw_nine_grid->srcRight, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 4, &draw_nine_grid->srcBottom, FALSE) &&
|
|
|
|
read_order_field_uint16(orderName, orderInfo, s, 5, &draw_nine_grid->bitmapId, FALSE))
|
2020-10-15 12:03:29 +03:00
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2023-09-04 10:26:06 +03:00
|
|
|
static BOOL update_read_multi_dstblt_order(const char* orderName, wStream* s,
|
|
|
|
const ORDER_INFO* orderInfo,
|
2019-11-06 17:24:51 +03:00
|
|
|
MULTI_DSTBLT_ORDER* multi_dstblt)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2023-09-04 10:43:32 +03:00
|
|
|
UINT32 numRectangles = multi_dstblt->numRectangles;
|
2023-09-04 10:26:06 +03:00
|
|
|
if (!read_order_field_coord(orderName, orderInfo, s, 1, &multi_dstblt->nLeftRect, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 2, &multi_dstblt->nTopRect, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 3, &multi_dstblt->nWidth, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 4, &multi_dstblt->nHeight, FALSE) ||
|
|
|
|
!read_order_field_byte(orderName, orderInfo, s, 5, &multi_dstblt->bRop, TRUE) ||
|
2023-09-04 10:43:32 +03:00
|
|
|
!read_order_field_byte(orderName, orderInfo, s, 6, &numRectangles, TRUE))
|
2020-10-12 12:09:10 +03:00
|
|
|
return FALSE;
|
2011-08-02 20:59:45 +04:00
|
|
|
|
2020-10-12 12:09:10 +03:00
|
|
|
if ((orderInfo->fieldFlags & ORDER_FIELD_07) != 0)
|
2011-08-03 11:29:56 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-06-10 01:56:57 +04:00
|
|
|
|
2023-09-04 10:43:32 +03:00
|
|
|
multi_dstblt->numRectangles = numRectangles;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, multi_dstblt->cbData);
|
2020-03-30 19:14:18 +03:00
|
|
|
return update_read_delta_rects(s, multi_dstblt->rectangles, &multi_dstblt->numRectangles);
|
2011-08-03 11:29:56 +04:00
|
|
|
}
|
2023-09-04 10:43:32 +03:00
|
|
|
if (numRectangles > multi_dstblt->numRectangles)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "%s numRectangles %" PRIu32 " > %" PRIu32, orderName, numRectangles,
|
|
|
|
multi_dstblt->numRectangles);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
multi_dstblt->numRectangles = numRectangles;
|
|
|
|
return TRUE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2023-09-04 10:26:06 +03:00
|
|
|
static BOOL update_read_multi_patblt_order(const char* orderName, wStream* s,
|
|
|
|
const ORDER_INFO* orderInfo,
|
2019-11-06 17:24:51 +03:00
|
|
|
MULTI_PATBLT_ORDER* multi_patblt)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2023-09-04 10:26:06 +03:00
|
|
|
if (!read_order_field_coord(orderName, orderInfo, s, 1, &multi_patblt->nLeftRect, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 2, &multi_patblt->nTopRect, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 3, &multi_patblt->nWidth, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 4, &multi_patblt->nHeight, FALSE) ||
|
|
|
|
!read_order_field_byte(orderName, orderInfo, s, 5, &multi_patblt->bRop, TRUE) ||
|
|
|
|
!read_order_field_color(orderName, orderInfo, s, 6, &multi_patblt->backColor, TRUE) ||
|
|
|
|
!read_order_field_color(orderName, orderInfo, s, 7, &multi_patblt->foreColor, TRUE))
|
2020-10-12 12:09:10 +03:00
|
|
|
return FALSE;
|
2011-07-26 00:54:15 +04:00
|
|
|
|
2013-01-19 01:50:25 +04:00
|
|
|
if (!update_read_brush(s, &multi_patblt->brush, orderInfo->fieldFlags >> 7))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2011-08-02 20:59:45 +04:00
|
|
|
|
2023-09-04 10:43:32 +03:00
|
|
|
UINT32 numRectangles = multi_patblt->numRectangles;
|
|
|
|
if (!read_order_field_byte(orderName, orderInfo, s, 13, &numRectangles, TRUE))
|
2020-10-12 12:09:10 +03:00
|
|
|
return FALSE;
|
2011-08-02 20:59:45 +04:00
|
|
|
|
2020-10-12 12:09:10 +03:00
|
|
|
if ((orderInfo->fieldFlags & ORDER_FIELD_14) != 0)
|
2011-08-03 11:29:56 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-06-10 01:56:57 +04:00
|
|
|
|
2023-09-04 10:43:32 +03:00
|
|
|
multi_patblt->numRectangles = numRectangles;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, multi_patblt->cbData);
|
2013-06-10 01:56:57 +04:00
|
|
|
|
2020-03-30 19:14:18 +03:00
|
|
|
if (!update_read_delta_rects(s, multi_patblt->rectangles, &multi_patblt->numRectangles))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2011-08-03 11:29:56 +04:00
|
|
|
}
|
2023-09-04 10:43:32 +03:00
|
|
|
|
|
|
|
if (numRectangles > multi_patblt->numRectangles)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "%s numRectangles %" PRIu32 " > %" PRIu32, orderName, numRectangles,
|
|
|
|
multi_patblt->numRectangles);
|
2023-08-05 12:31:08 +03:00
|
|
|
return FALSE;
|
2023-09-04 10:43:32 +03:00
|
|
|
}
|
|
|
|
multi_patblt->numRectangles = numRectangles;
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2023-09-04 10:26:06 +03:00
|
|
|
static BOOL update_read_multi_scrblt_order(const char* orderName, wStream* s,
|
|
|
|
const ORDER_INFO* orderInfo,
|
2019-11-06 17:24:51 +03:00
|
|
|
MULTI_SCRBLT_ORDER* multi_scrblt)
|
2011-08-02 20:59:45 +04:00
|
|
|
{
|
2023-08-05 12:31:08 +03:00
|
|
|
WINPR_ASSERT(orderInfo);
|
|
|
|
WINPR_ASSERT(multi_scrblt);
|
|
|
|
|
2023-09-04 10:43:32 +03:00
|
|
|
UINT32 numRectangles = multi_scrblt->numRectangles;
|
2023-09-04 10:26:06 +03:00
|
|
|
if (!read_order_field_coord(orderName, orderInfo, s, 1, &multi_scrblt->nLeftRect, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 2, &multi_scrblt->nTopRect, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 3, &multi_scrblt->nWidth, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 4, &multi_scrblt->nHeight, FALSE) ||
|
|
|
|
!read_order_field_byte(orderName, orderInfo, s, 5, &multi_scrblt->bRop, TRUE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 6, &multi_scrblt->nXSrc, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 7, &multi_scrblt->nYSrc, FALSE) ||
|
2023-09-04 10:43:32 +03:00
|
|
|
!read_order_field_byte(orderName, orderInfo, s, 8, &numRectangles, TRUE))
|
2020-10-12 12:09:10 +03:00
|
|
|
return FALSE;
|
2011-08-02 20:59:45 +04:00
|
|
|
|
2020-10-12 12:09:10 +03:00
|
|
|
if ((orderInfo->fieldFlags & ORDER_FIELD_09) != 0)
|
2011-08-03 11:29:56 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-06-10 01:56:57 +04:00
|
|
|
|
2023-09-04 10:43:32 +03:00
|
|
|
multi_scrblt->numRectangles = numRectangles;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, multi_scrblt->cbData);
|
2020-03-30 19:14:18 +03:00
|
|
|
return update_read_delta_rects(s, multi_scrblt->rectangles, &multi_scrblt->numRectangles);
|
2011-08-03 11:29:56 +04:00
|
|
|
}
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2023-09-04 10:43:32 +03:00
|
|
|
if (numRectangles > multi_scrblt->numRectangles)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "%s numRectangles %" PRIu32 " > %" PRIu32, orderName, numRectangles,
|
|
|
|
multi_scrblt->numRectangles);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
multi_scrblt->numRectangles = numRectangles;
|
|
|
|
|
|
|
|
return TRUE;
|
2011-08-02 20:59:45 +04:00
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2023-09-04 10:26:06 +03:00
|
|
|
static BOOL update_read_multi_opaque_rect_order(const char* orderName, wStream* s,
|
|
|
|
const ORDER_INFO* orderInfo,
|
2019-11-06 17:24:51 +03:00
|
|
|
MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE byte = 0;
|
2023-09-04 10:26:06 +03:00
|
|
|
if (!read_order_field_coord(orderName, orderInfo, s, 1, &multi_opaque_rect->nLeftRect, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 2, &multi_opaque_rect->nTopRect, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 3, &multi_opaque_rect->nWidth, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 4, &multi_opaque_rect->nHeight, FALSE))
|
2020-10-12 12:09:10 +03:00
|
|
|
return FALSE;
|
2011-07-27 00:58:10 +04:00
|
|
|
|
2020-10-12 12:09:10 +03:00
|
|
|
if ((orderInfo->fieldFlags & ORDER_FIELD_05) != 0)
|
2011-07-27 00:58:10 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-06-10 01:56:57 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2019-11-06 17:24:51 +03:00
|
|
|
multi_opaque_rect->color = (multi_opaque_rect->color & 0x00FFFF00) | ((UINT32)byte);
|
2011-07-27 00:58:10 +04:00
|
|
|
}
|
|
|
|
|
2020-10-12 12:09:10 +03:00
|
|
|
if ((orderInfo->fieldFlags & ORDER_FIELD_06) != 0)
|
2011-07-27 00:58:10 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-06-10 01:56:57 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2019-11-06 17:24:51 +03:00
|
|
|
multi_opaque_rect->color = (multi_opaque_rect->color & 0x00FF00FF) | ((UINT32)byte << 8);
|
2011-07-27 00:58:10 +04:00
|
|
|
}
|
|
|
|
|
2020-10-12 12:09:10 +03:00
|
|
|
if ((orderInfo->fieldFlags & ORDER_FIELD_07) != 0)
|
2011-07-27 00:58:10 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-06-10 01:56:57 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2019-11-06 17:24:51 +03:00
|
|
|
multi_opaque_rect->color = (multi_opaque_rect->color & 0x0000FFFF) | ((UINT32)byte << 16);
|
2011-07-27 00:58:10 +04:00
|
|
|
}
|
2011-08-02 20:59:45 +04:00
|
|
|
|
2023-09-04 10:43:32 +03:00
|
|
|
UINT32 numRectangles = multi_opaque_rect->numRectangles;
|
|
|
|
if (!read_order_field_byte(orderName, orderInfo, s, 8, &numRectangles, TRUE))
|
2020-10-12 12:09:10 +03:00
|
|
|
return FALSE;
|
2011-08-02 20:59:45 +04:00
|
|
|
|
2020-10-12 12:09:10 +03:00
|
|
|
if ((orderInfo->fieldFlags & ORDER_FIELD_09) != 0)
|
2011-08-03 11:29:56 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2023-09-04 10:43:32 +03:00
|
|
|
multi_opaque_rect->numRectangles = numRectangles;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, multi_opaque_rect->cbData);
|
2016-07-15 17:23:00 +03:00
|
|
|
return update_read_delta_rects(s, multi_opaque_rect->rectangles,
|
2020-03-30 19:14:18 +03:00
|
|
|
&multi_opaque_rect->numRectangles);
|
2011-08-03 11:29:56 +04:00
|
|
|
}
|
2023-09-04 10:43:32 +03:00
|
|
|
if (numRectangles > multi_opaque_rect->numRectangles)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "%s numRectangles %" PRIu32 " > %" PRIu32, orderName, numRectangles,
|
|
|
|
multi_opaque_rect->numRectangles);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
multi_opaque_rect->numRectangles = numRectangles;
|
2013-06-10 01:56:57 +04:00
|
|
|
|
2023-09-04 10:43:32 +03:00
|
|
|
return TRUE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2023-09-04 10:26:06 +03:00
|
|
|
static BOOL update_read_multi_draw_nine_grid_order(const char* orderName, wStream* s,
|
|
|
|
const ORDER_INFO* orderInfo,
|
2019-11-06 17:24:51 +03:00
|
|
|
MULTI_DRAW_NINE_GRID_ORDER* multi_draw_nine_grid)
|
2013-01-12 03:17:45 +04:00
|
|
|
{
|
2023-09-04 10:43:32 +03:00
|
|
|
UINT32 nDeltaEntries = multi_draw_nine_grid->nDeltaEntries;
|
2023-09-04 10:26:06 +03:00
|
|
|
if (!read_order_field_coord(orderName, orderInfo, s, 1, &multi_draw_nine_grid->srcLeft,
|
|
|
|
FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 2, &multi_draw_nine_grid->srcTop, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 3, &multi_draw_nine_grid->srcRight,
|
|
|
|
FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 4, &multi_draw_nine_grid->srcBottom,
|
|
|
|
FALSE) ||
|
|
|
|
!read_order_field_uint16(orderName, orderInfo, s, 5, &multi_draw_nine_grid->bitmapId,
|
|
|
|
TRUE) ||
|
2023-09-04 10:43:32 +03:00
|
|
|
!read_order_field_byte(orderName, orderInfo, s, 6, &nDeltaEntries, TRUE))
|
2020-10-12 12:09:10 +03:00
|
|
|
return FALSE;
|
2011-08-02 20:59:45 +04:00
|
|
|
|
2020-10-12 12:09:10 +03:00
|
|
|
if ((orderInfo->fieldFlags & ORDER_FIELD_07) != 0)
|
2011-08-03 11:29:56 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
|
2018-10-15 15:30:38 +03:00
|
|
|
return FALSE;
|
|
|
|
|
2023-09-04 10:43:32 +03:00
|
|
|
multi_draw_nine_grid->nDeltaEntries = nDeltaEntries;
|
2018-10-15 15:30:38 +03:00
|
|
|
Stream_Read_UINT16(s, multi_draw_nine_grid->cbData);
|
|
|
|
return update_read_delta_rects(s, multi_draw_nine_grid->rectangles,
|
2020-03-30 19:14:18 +03:00
|
|
|
&multi_draw_nine_grid->nDeltaEntries);
|
2011-08-03 11:29:56 +04:00
|
|
|
}
|
2013-06-10 01:56:57 +04:00
|
|
|
|
2023-09-04 10:43:32 +03:00
|
|
|
if (nDeltaEntries > multi_draw_nine_grid->nDeltaEntries)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "%s nDeltaEntries %" PRIu32 " > %" PRIu32, orderName, nDeltaEntries,
|
|
|
|
multi_draw_nine_grid->nDeltaEntries);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
multi_draw_nine_grid->nDeltaEntries = nDeltaEntries;
|
|
|
|
|
|
|
|
return TRUE;
|
2011-08-02 20:59:45 +04:00
|
|
|
}
|
2023-09-04 10:26:06 +03:00
|
|
|
static BOOL update_read_line_to_order(const char* orderName, wStream* s,
|
|
|
|
const ORDER_INFO* orderInfo, LINE_TO_ORDER* line_to)
|
|
|
|
{
|
|
|
|
if (read_order_field_uint16(orderName, orderInfo, s, 1, &line_to->backMode, TRUE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 2, &line_to->nXStart, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 3, &line_to->nYStart, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 4, &line_to->nXEnd, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 5, &line_to->nYEnd, FALSE) &&
|
|
|
|
read_order_field_color(orderName, orderInfo, s, 6, &line_to->backColor, TRUE) &&
|
|
|
|
read_order_field_byte(orderName, orderInfo, s, 7, &line_to->bRop2, TRUE) &&
|
|
|
|
read_order_field_byte(orderName, orderInfo, s, 8, &line_to->penStyle, TRUE) &&
|
|
|
|
read_order_field_byte(orderName, orderInfo, s, 9, &line_to->penWidth, TRUE) &&
|
|
|
|
read_order_field_color(orderName, orderInfo, s, 10, &line_to->penColor, TRUE))
|
2020-10-15 12:03:29 +03:00
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
2011-08-02 20:59:45 +04:00
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
|
|
|
size_t update_approximate_line_to_order(ORDER_INFO* orderInfo, const LINE_TO_ORDER* line_to)
|
2013-06-10 01:56:57 +04:00
|
|
|
{
|
2022-01-11 18:29:40 +03:00
|
|
|
WINPR_UNUSED(orderInfo);
|
|
|
|
WINPR_UNUSED(line_to);
|
2013-06-10 01:56:57 +04:00
|
|
|
return 32;
|
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL update_write_line_to_order(wStream* s, ORDER_INFO* orderInfo, const LINE_TO_ORDER* line_to)
|
2013-05-13 01:46:13 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, update_approximate_line_to_order(orderInfo, line_to)))
|
2015-03-26 19:09:47 +03:00
|
|
|
return FALSE;
|
2013-05-13 01:46:13 +04:00
|
|
|
|
|
|
|
orderInfo->fieldFlags = 0;
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_01;
|
|
|
|
Stream_Write_UINT16(s, line_to->backMode);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_02;
|
|
|
|
update_write_coord(s, line_to->nXStart);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_03;
|
|
|
|
update_write_coord(s, line_to->nYStart);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_04;
|
|
|
|
update_write_coord(s, line_to->nXEnd);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_05;
|
|
|
|
update_write_coord(s, line_to->nYEnd);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_06;
|
|
|
|
update_write_color(s, line_to->backColor);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_07;
|
|
|
|
Stream_Write_UINT8(s, line_to->bRop2);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_08;
|
|
|
|
Stream_Write_UINT8(s, line_to->penStyle);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_09;
|
|
|
|
Stream_Write_UINT8(s, line_to->penWidth);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_10;
|
|
|
|
update_write_color(s, line_to->penColor);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2023-09-04 10:26:06 +03:00
|
|
|
static BOOL update_read_polyline_order(const char* orderName, wStream* s,
|
|
|
|
const ORDER_INFO* orderInfo, POLYLINE_ORDER* polyline)
|
2011-08-02 20:59:45 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT32 word = 0;
|
2015-03-15 16:09:16 +03:00
|
|
|
UINT32 new_num = polyline->numDeltaEntries;
|
2023-09-04 10:26:06 +03:00
|
|
|
if (!read_order_field_coord(orderName, orderInfo, s, 1, &polyline->xStart, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 2, &polyline->yStart, FALSE) ||
|
|
|
|
!read_order_field_byte(orderName, orderInfo, s, 3, &polyline->bRop2, TRUE) ||
|
|
|
|
!read_order_field_uint16(orderName, orderInfo, s, 4, &word, TRUE) ||
|
|
|
|
!read_order_field_color(orderName, orderInfo, s, 5, &polyline->penColor, TRUE) ||
|
|
|
|
!read_order_field_byte(orderName, orderInfo, s, 6, &new_num, TRUE))
|
2020-10-12 12:09:10 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & ORDER_FIELD_07) != 0)
|
2011-08-03 11:29:56 +04:00
|
|
|
{
|
2020-04-06 16:08:25 +03:00
|
|
|
if (new_num == 0)
|
|
|
|
return FALSE;
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, polyline->cbData);
|
2011-09-02 19:08:50 +04:00
|
|
|
|
2015-03-11 08:40:20 +03:00
|
|
|
polyline->numDeltaEntries = new_num;
|
2023-09-04 12:02:01 +03:00
|
|
|
return update_read_delta_points(s, &polyline->points, polyline->numDeltaEntries,
|
2016-07-21 13:53:44 +03:00
|
|
|
polyline->xStart, polyline->yStart);
|
2011-08-03 11:29:56 +04:00
|
|
|
}
|
2023-09-04 10:43:32 +03:00
|
|
|
if (new_num > polyline->numDeltaEntries)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "%s numDeltaEntries %" PRIu32 " > %" PRIu32, orderName, new_num,
|
|
|
|
polyline->numDeltaEntries);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
polyline->numDeltaEntries = new_num;
|
2013-05-07 23:33:52 +04:00
|
|
|
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2023-09-04 10:26:06 +03:00
|
|
|
static BOOL update_read_memblt_order(const char* orderName, wStream* s, const ORDER_INFO* orderInfo,
|
|
|
|
MEMBLT_ORDER* memblt)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2016-07-18 18:45:30 +03:00
|
|
|
if (!s || !orderInfo || !memblt)
|
|
|
|
return FALSE;
|
|
|
|
|
2023-09-04 10:26:06 +03:00
|
|
|
if (!read_order_field_uint16(orderName, orderInfo, s, 1, &memblt->cacheId, TRUE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 2, &memblt->nLeftRect, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 3, &memblt->nTopRect, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 4, &memblt->nWidth, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 5, &memblt->nHeight, FALSE) ||
|
|
|
|
!read_order_field_byte(orderName, orderInfo, s, 6, &memblt->bRop, TRUE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 7, &memblt->nXSrc, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 8, &memblt->nYSrc, FALSE) ||
|
|
|
|
!read_order_field_uint16(orderName, orderInfo, s, 9, &memblt->cacheIndex, TRUE))
|
2020-10-12 12:09:10 +03:00
|
|
|
return FALSE;
|
2011-10-21 20:17:04 +04:00
|
|
|
memblt->colorIndex = (memblt->cacheId >> 8);
|
|
|
|
memblt->cacheId = (memblt->cacheId & 0xFF);
|
2013-11-03 22:29:48 +04:00
|
|
|
memblt->bitmap = NULL;
|
2013-05-07 19:41:32 +04:00
|
|
|
return TRUE;
|
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
|
|
|
size_t update_approximate_memblt_order(ORDER_INFO* orderInfo, const MEMBLT_ORDER* memblt)
|
2013-06-10 01:56:57 +04:00
|
|
|
{
|
2022-01-11 18:29:40 +03:00
|
|
|
WINPR_UNUSED(orderInfo);
|
|
|
|
WINPR_UNUSED(memblt);
|
2013-07-29 18:21:32 +04:00
|
|
|
return 64;
|
2013-06-10 01:56:57 +04:00
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL update_write_memblt_order(wStream* s, ORDER_INFO* orderInfo, const MEMBLT_ORDER* memblt)
|
2013-05-07 19:41:32 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT16 cacheId = 0;
|
2013-05-07 19:41:32 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, update_approximate_memblt_order(orderInfo, memblt)))
|
2015-03-26 19:09:47 +03:00
|
|
|
return FALSE;
|
2013-05-10 00:30:28 +04:00
|
|
|
|
2013-05-07 19:41:32 +04:00
|
|
|
cacheId = (memblt->cacheId & 0xFF) | ((memblt->colorIndex & 0xFF) << 8);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_01;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, cacheId);
|
2013-05-07 19:41:32 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_02;
|
|
|
|
update_write_coord(s, memblt->nLeftRect);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_03;
|
|
|
|
update_write_coord(s, memblt->nTopRect);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_04;
|
|
|
|
update_write_coord(s, memblt->nWidth);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_05;
|
|
|
|
update_write_coord(s, memblt->nHeight);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_06;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, memblt->bRop);
|
2013-05-07 19:41:32 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_07;
|
|
|
|
update_write_coord(s, memblt->nXSrc);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_08;
|
|
|
|
update_write_coord(s, memblt->nYSrc);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_09;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, memblt->cacheIndex);
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2023-09-04 10:26:06 +03:00
|
|
|
static BOOL update_read_mem3blt_order(const char* orderName, wStream* s,
|
|
|
|
const ORDER_INFO* orderInfo, MEM3BLT_ORDER* mem3blt)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2023-09-04 10:26:06 +03:00
|
|
|
if (!read_order_field_uint16(orderName, orderInfo, s, 1, &mem3blt->cacheId, TRUE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 2, &mem3blt->nLeftRect, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 3, &mem3blt->nTopRect, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 4, &mem3blt->nWidth, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 5, &mem3blt->nHeight, FALSE) ||
|
|
|
|
!read_order_field_byte(orderName, orderInfo, s, 6, &mem3blt->bRop, TRUE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 7, &mem3blt->nXSrc, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 8, &mem3blt->nYSrc, FALSE) ||
|
|
|
|
!read_order_field_color(orderName, orderInfo, s, 9, &mem3blt->backColor, TRUE) ||
|
|
|
|
!read_order_field_color(orderName, orderInfo, s, 10, &mem3blt->foreColor, TRUE))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2011-10-21 20:17:04 +04:00
|
|
|
|
2020-10-12 12:09:10 +03:00
|
|
|
if (!update_read_brush(s, &mem3blt->brush, orderInfo->fieldFlags >> 10) ||
|
2023-09-04 10:26:06 +03:00
|
|
|
!read_order_field_uint16(orderName, orderInfo, s, 16, &mem3blt->cacheIndex, TRUE))
|
2020-10-12 12:09:10 +03:00
|
|
|
return FALSE;
|
2011-10-21 20:17:04 +04:00
|
|
|
mem3blt->colorIndex = (mem3blt->cacheId >> 8);
|
|
|
|
mem3blt->cacheId = (mem3blt->cacheId & 0xFF);
|
2013-11-03 22:29:48 +04:00
|
|
|
mem3blt->bitmap = NULL;
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2023-09-04 10:26:06 +03:00
|
|
|
static BOOL update_read_save_bitmap_order(const char* orderName, wStream* s,
|
|
|
|
const ORDER_INFO* orderInfo,
|
2019-11-06 17:24:51 +03:00
|
|
|
SAVE_BITMAP_ORDER* save_bitmap)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2023-09-04 10:26:06 +03:00
|
|
|
if (read_order_field_uint32(orderName, orderInfo, s, 1, &save_bitmap->savedBitmapPosition,
|
|
|
|
TRUE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 2, &save_bitmap->nLeftRect, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 3, &save_bitmap->nTopRect, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 4, &save_bitmap->nRightRect, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 5, &save_bitmap->nBottomRect, FALSE) &&
|
|
|
|
read_order_field_byte(orderName, orderInfo, s, 6, &save_bitmap->operation, TRUE))
|
2020-10-15 12:03:29 +03:00
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2023-09-04 10:26:06 +03:00
|
|
|
static BOOL update_read_glyph_index_order(const char* orderName, wStream* s,
|
|
|
|
const ORDER_INFO* orderInfo,
|
2019-11-06 17:24:51 +03:00
|
|
|
GLYPH_INDEX_ORDER* glyph_index)
|
2013-01-12 03:17:45 +04:00
|
|
|
{
|
2023-09-04 10:26:06 +03:00
|
|
|
if (!read_order_field_byte(orderName, orderInfo, s, 1, &glyph_index->cacheId, TRUE) ||
|
|
|
|
!read_order_field_byte(orderName, orderInfo, s, 2, &glyph_index->flAccel, TRUE) ||
|
|
|
|
!read_order_field_byte(orderName, orderInfo, s, 3, &glyph_index->ulCharInc, TRUE) ||
|
|
|
|
!read_order_field_byte(orderName, orderInfo, s, 4, &glyph_index->fOpRedundant, TRUE) ||
|
|
|
|
!read_order_field_color(orderName, orderInfo, s, 5, &glyph_index->backColor, TRUE) ||
|
|
|
|
!read_order_field_color(orderName, orderInfo, s, 6, &glyph_index->foreColor, TRUE) ||
|
|
|
|
!read_order_field_int16(orderName, orderInfo, s, 7, &glyph_index->bkLeft, TRUE) ||
|
|
|
|
!read_order_field_int16(orderName, orderInfo, s, 8, &glyph_index->bkTop, TRUE) ||
|
|
|
|
!read_order_field_int16(orderName, orderInfo, s, 9, &glyph_index->bkRight, TRUE) ||
|
|
|
|
!read_order_field_int16(orderName, orderInfo, s, 10, &glyph_index->bkBottom, TRUE) ||
|
|
|
|
!read_order_field_int16(orderName, orderInfo, s, 11, &glyph_index->opLeft, TRUE) ||
|
|
|
|
!read_order_field_int16(orderName, orderInfo, s, 12, &glyph_index->opTop, TRUE) ||
|
|
|
|
!read_order_field_int16(orderName, orderInfo, s, 13, &glyph_index->opRight, TRUE) ||
|
|
|
|
!read_order_field_int16(orderName, orderInfo, s, 14, &glyph_index->opBottom, TRUE) ||
|
2020-10-12 12:09:10 +03:00
|
|
|
!update_read_brush(s, &glyph_index->brush, orderInfo->fieldFlags >> 14) ||
|
2023-09-04 10:26:06 +03:00
|
|
|
!read_order_field_int16(orderName, orderInfo, s, 20, &glyph_index->x, TRUE) ||
|
|
|
|
!read_order_field_int16(orderName, orderInfo, s, 21, &glyph_index->y, TRUE))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2011-08-03 11:29:56 +04:00
|
|
|
|
2020-10-12 12:09:10 +03:00
|
|
|
if ((orderInfo->fieldFlags & ORDER_FIELD_22) != 0)
|
2011-08-03 11:29:56 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-07 20:45:52 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, glyph_index->cbData);
|
2013-01-12 03:17:45 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, glyph_index->cbData))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-07 20:45:52 +04:00
|
|
|
|
2023-06-07 16:38:21 +03:00
|
|
|
CopyMemory(glyph_index->data, Stream_ConstPointer(s), glyph_index->cbData);
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, glyph_index->cbData);
|
2011-08-03 11:29:56 +04:00
|
|
|
}
|
2013-05-07 20:45:52 +04:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
|
|
|
size_t update_approximate_glyph_index_order(ORDER_INFO* orderInfo,
|
|
|
|
const GLYPH_INDEX_ORDER* glyph_index)
|
2013-06-10 01:56:57 +04:00
|
|
|
{
|
2022-01-11 18:29:40 +03:00
|
|
|
WINPR_UNUSED(orderInfo);
|
|
|
|
WINPR_UNUSED(glyph_index);
|
2013-06-10 01:56:57 +04:00
|
|
|
return 64;
|
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
BOOL update_write_glyph_index_order(wStream* s, ORDER_INFO* orderInfo,
|
2016-07-21 13:53:44 +03:00
|
|
|
GLYPH_INDEX_ORDER* glyph_index)
|
2013-05-07 20:45:52 +04:00
|
|
|
{
|
2022-01-11 18:29:40 +03:00
|
|
|
size_t inf = update_approximate_glyph_index_order(orderInfo, glyph_index);
|
2013-05-07 20:45:52 +04:00
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, inf))
|
2015-03-26 19:09:47 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
orderInfo->fieldFlags = 0;
|
2013-05-07 20:45:52 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_01;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, glyph_index->cacheId);
|
2013-05-07 20:45:52 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_02;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, glyph_index->flAccel);
|
2013-05-07 20:45:52 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_03;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, glyph_index->ulCharInc);
|
2013-05-07 20:45:52 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_04;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, glyph_index->fOpRedundant);
|
2013-05-07 20:45:52 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_05;
|
|
|
|
update_write_color(s, glyph_index->backColor);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_06;
|
|
|
|
update_write_color(s, glyph_index->foreColor);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_07;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, glyph_index->bkLeft);
|
2013-05-07 20:45:52 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_08;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, glyph_index->bkTop);
|
2013-05-07 20:45:52 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_09;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, glyph_index->bkRight);
|
2013-05-07 20:45:52 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_10;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, glyph_index->bkBottom);
|
2013-05-07 20:45:52 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_11;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, glyph_index->opLeft);
|
2013-05-07 20:45:52 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_12;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, glyph_index->opTop);
|
2013-05-07 20:45:52 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_13;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, glyph_index->opRight);
|
2013-05-07 20:45:52 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_14;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, glyph_index->opBottom);
|
2013-05-07 20:45:52 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_15;
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_16;
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_17;
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_18;
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_19;
|
|
|
|
update_write_brush(s, &glyph_index->brush, orderInfo->fieldFlags >> 14);
|
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_20;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, glyph_index->x);
|
2013-05-07 20:45:52 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_21;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, glyph_index->y);
|
2013-05-07 20:45:52 +04:00
|
|
|
orderInfo->fieldFlags |= ORDER_FIELD_22;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, glyph_index->cbData);
|
2013-05-07 20:45:52 +04:00
|
|
|
Stream_Write(s, glyph_index->data, glyph_index->cbData);
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2023-09-04 10:26:06 +03:00
|
|
|
static BOOL update_read_fast_index_order(const char* orderName, wStream* s,
|
|
|
|
const ORDER_INFO* orderInfo, FAST_INDEX_ORDER* fast_index)
|
|
|
|
{
|
|
|
|
if (!read_order_field_byte(orderName, orderInfo, s, 1, &fast_index->cacheId, TRUE) ||
|
|
|
|
!read_order_field_2bytes(orderName, orderInfo, s, 2, &fast_index->ulCharInc,
|
|
|
|
&fast_index->flAccel, TRUE) ||
|
|
|
|
!read_order_field_color(orderName, orderInfo, s, 3, &fast_index->backColor, TRUE) ||
|
|
|
|
!read_order_field_color(orderName, orderInfo, s, 4, &fast_index->foreColor, TRUE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 5, &fast_index->bkLeft, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 6, &fast_index->bkTop, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 7, &fast_index->bkRight, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 8, &fast_index->bkBottom, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 9, &fast_index->opLeft, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 10, &fast_index->opTop, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 11, &fast_index->opRight, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 12, &fast_index->opBottom, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 13, &fast_index->x, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 14, &fast_index->y, FALSE))
|
2020-10-12 12:09:10 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & ORDER_FIELD_15) != 0)
|
2011-08-03 11:29:56 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-06-10 01:56:57 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, fast_index->cbData);
|
2013-01-12 03:17:45 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, fast_index->cbData))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-06-10 01:56:57 +04:00
|
|
|
|
2023-06-07 16:38:21 +03:00
|
|
|
CopyMemory(fast_index->data, Stream_ConstPointer(s), fast_index->cbData);
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, fast_index->cbData);
|
2011-08-03 11:29:56 +04:00
|
|
|
}
|
2013-06-10 01:56:57 +04:00
|
|
|
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2023-09-04 10:26:06 +03:00
|
|
|
static BOOL update_read_fast_glyph_order(const char* orderName, wStream* s,
|
|
|
|
const ORDER_INFO* orderInfo, FAST_GLYPH_ORDER* fastGlyph)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2014-12-03 22:17:27 +03:00
|
|
|
GLYPH_DATA_V2* glyph = &fastGlyph->glyphData;
|
2023-09-04 10:26:06 +03:00
|
|
|
if (!read_order_field_byte(orderName, orderInfo, s, 1, &fastGlyph->cacheId, TRUE))
|
2020-10-12 12:09:10 +03:00
|
|
|
return FALSE;
|
|
|
|
if (fastGlyph->cacheId > 9)
|
|
|
|
return FALSE;
|
2023-09-04 10:26:06 +03:00
|
|
|
if (!read_order_field_2bytes(orderName, orderInfo, s, 2, &fastGlyph->ulCharInc,
|
|
|
|
&fastGlyph->flAccel, TRUE) ||
|
|
|
|
!read_order_field_color(orderName, orderInfo, s, 3, &fastGlyph->backColor, TRUE) ||
|
|
|
|
!read_order_field_color(orderName, orderInfo, s, 4, &fastGlyph->foreColor, TRUE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 5, &fastGlyph->bkLeft, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 6, &fastGlyph->bkTop, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 7, &fastGlyph->bkRight, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 8, &fastGlyph->bkBottom, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 9, &fastGlyph->opLeft, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 10, &fastGlyph->opTop, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 11, &fastGlyph->opRight, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 12, &fastGlyph->opBottom, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 13, &fastGlyph->x, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 14, &fastGlyph->y, FALSE))
|
2020-10-12 12:09:10 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & ORDER_FIELD_15) != 0)
|
2011-08-03 11:29:56 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
const BYTE* src = NULL;
|
2021-10-14 09:42:49 +03:00
|
|
|
wStream subbuffer;
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* sub = NULL;
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-02-03 21:41:59 +04:00
|
|
|
|
2014-12-03 22:17:27 +03:00
|
|
|
Stream_Read_UINT8(s, fastGlyph->cbData);
|
2013-02-03 21:41:59 +04:00
|
|
|
|
2023-06-07 16:38:21 +03:00
|
|
|
src = Stream_ConstPointer(s);
|
2020-10-12 11:29:30 +03:00
|
|
|
if (!Stream_SafeSeek(s, fastGlyph->cbData) || (fastGlyph->cbData == 0))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-02-03 21:41:59 +04:00
|
|
|
|
2020-10-12 11:29:30 +03:00
|
|
|
CopyMemory(fastGlyph->data, src, fastGlyph->cbData);
|
2021-10-14 09:42:49 +03:00
|
|
|
sub = Stream_StaticInit(&subbuffer, fastGlyph->data, fastGlyph->cbData);
|
2013-01-12 03:17:45 +04:00
|
|
|
|
2021-10-14 09:42:49 +03:00
|
|
|
Stream_Read_UINT8(sub, glyph->cacheIndex);
|
2013-02-03 21:41:59 +04:00
|
|
|
|
2014-12-03 22:17:27 +03:00
|
|
|
if (fastGlyph->cbData > 1)
|
2011-11-25 03:32:49 +04:00
|
|
|
{
|
2021-10-14 09:42:49 +03:00
|
|
|
if (!update_read_2byte_signed(sub, &glyph->x) ||
|
|
|
|
!update_read_2byte_signed(sub, &glyph->y) ||
|
|
|
|
!update_read_2byte_unsigned(sub, &glyph->cx) ||
|
|
|
|
!update_read_2byte_unsigned(sub, &glyph->cy))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-02-03 21:41:59 +04:00
|
|
|
|
2021-10-12 13:26:22 +03:00
|
|
|
if ((glyph->cx == 0) || (glyph->cy == 0))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "GLYPH_DATA_V2::cx=%" PRIu32 ", GLYPH_DATA_V2::cy=%" PRIu32,
|
|
|
|
glyph->cx, glyph->cy);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-10-14 09:42:49 +03:00
|
|
|
glyph->cb = Stream_GetRemainingLength(sub);
|
2020-10-12 11:29:30 +03:00
|
|
|
if (glyph->cb > 0)
|
2013-11-01 07:35:24 +04:00
|
|
|
{
|
2020-10-12 11:29:30 +03:00
|
|
|
BYTE* new_aj = (BYTE*)realloc(glyph->aj, glyph->cb);
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2015-03-11 08:40:20 +03:00
|
|
|
if (!new_aj)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
glyph->aj = new_aj;
|
2021-10-14 09:42:49 +03:00
|
|
|
Stream_Read(sub, glyph->aj, glyph->cb);
|
2020-10-12 11:29:30 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
free(glyph->aj);
|
|
|
|
glyph->aj = NULL;
|
2013-11-01 07:35:24 +04:00
|
|
|
}
|
2011-11-25 03:32:49 +04:00
|
|
|
}
|
2011-08-03 11:29:56 +04:00
|
|
|
}
|
2013-06-10 01:56:57 +04:00
|
|
|
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2023-09-04 10:26:06 +03:00
|
|
|
static BOOL update_read_polygon_sc_order(const char* orderName, wStream* s,
|
|
|
|
const ORDER_INFO* orderInfo, POLYGON_SC_ORDER* polygon_sc)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2015-03-15 16:09:16 +03:00
|
|
|
UINT32 num = polygon_sc->numPoints;
|
2023-09-04 10:26:06 +03:00
|
|
|
if (!read_order_field_coord(orderName, orderInfo, s, 1, &polygon_sc->xStart, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 2, &polygon_sc->yStart, FALSE) ||
|
|
|
|
!read_order_field_byte(orderName, orderInfo, s, 3, &polygon_sc->bRop2, TRUE) ||
|
|
|
|
!read_order_field_byte(orderName, orderInfo, s, 4, &polygon_sc->fillMode, TRUE) ||
|
|
|
|
!read_order_field_color(orderName, orderInfo, s, 5, &polygon_sc->brushColor, TRUE) ||
|
|
|
|
!read_order_field_byte(orderName, orderInfo, s, 6, &num, TRUE))
|
2020-10-12 12:09:10 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if ((orderInfo->fieldFlags & ORDER_FIELD_07) != 0)
|
2011-08-03 11:29:56 +04:00
|
|
|
{
|
2020-04-06 16:08:25 +03:00
|
|
|
if (num == 0)
|
|
|
|
return FALSE;
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-06-10 01:56:57 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, polygon_sc->cbData);
|
2015-03-11 08:40:20 +03:00
|
|
|
|
|
|
|
polygon_sc->numPoints = num;
|
2023-09-04 12:02:01 +03:00
|
|
|
return update_read_delta_points(s, &polygon_sc->points, polygon_sc->numPoints,
|
2016-07-21 13:53:44 +03:00
|
|
|
polygon_sc->xStart, polygon_sc->yStart);
|
2011-08-03 11:29:56 +04:00
|
|
|
}
|
2023-09-04 10:43:32 +03:00
|
|
|
if (num > polygon_sc->numPoints)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "%s numPoints %" PRIu32 " > %" PRIu32, orderName, num, polygon_sc->numPoints);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
polygon_sc->numPoints = num;
|
2013-06-10 01:56:57 +04:00
|
|
|
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2023-09-04 10:26:06 +03:00
|
|
|
static BOOL update_read_polygon_cb_order(const char* orderName, wStream* s,
|
|
|
|
const ORDER_INFO* orderInfo, POLYGON_CB_ORDER* polygon_cb)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2015-03-15 16:09:16 +03:00
|
|
|
UINT32 num = polygon_cb->numPoints;
|
2023-09-04 10:26:06 +03:00
|
|
|
if (!read_order_field_coord(orderName, orderInfo, s, 1, &polygon_cb->xStart, FALSE) ||
|
|
|
|
!read_order_field_coord(orderName, orderInfo, s, 2, &polygon_cb->yStart, FALSE) ||
|
|
|
|
!read_order_field_byte(orderName, orderInfo, s, 3, &polygon_cb->bRop2, TRUE) ||
|
|
|
|
!read_order_field_byte(orderName, orderInfo, s, 4, &polygon_cb->fillMode, TRUE) ||
|
|
|
|
!read_order_field_color(orderName, orderInfo, s, 5, &polygon_cb->backColor, TRUE) ||
|
|
|
|
!read_order_field_color(orderName, orderInfo, s, 6, &polygon_cb->foreColor, TRUE))
|
2020-10-12 12:09:10 +03:00
|
|
|
return FALSE;
|
2011-07-27 00:58:10 +04:00
|
|
|
|
2013-01-19 01:50:25 +04:00
|
|
|
if (!update_read_brush(s, &polygon_cb->brush, orderInfo->fieldFlags >> 6))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2011-07-27 00:58:10 +04:00
|
|
|
|
2023-09-04 10:26:06 +03:00
|
|
|
if (!read_order_field_byte(orderName, orderInfo, s, 12, &num, TRUE))
|
2020-10-12 12:09:10 +03:00
|
|
|
return FALSE;
|
2011-07-26 00:54:15 +04:00
|
|
|
|
2020-10-12 12:09:10 +03:00
|
|
|
if ((orderInfo->fieldFlags & ORDER_FIELD_13) != 0)
|
2011-08-03 11:29:56 +04:00
|
|
|
{
|
2020-04-06 16:08:25 +03:00
|
|
|
if (num == 0)
|
|
|
|
return FALSE;
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-06-10 01:56:57 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, polygon_cb->cbData);
|
2015-03-11 08:40:20 +03:00
|
|
|
polygon_cb->numPoints = num;
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2023-09-04 12:02:01 +03:00
|
|
|
if (!update_read_delta_points(s, &polygon_cb->points, polygon_cb->numPoints,
|
2016-07-21 13:53:44 +03:00
|
|
|
polygon_cb->xStart, polygon_cb->yStart))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2011-08-03 11:29:56 +04:00
|
|
|
}
|
2012-02-13 02:14:59 +04:00
|
|
|
|
2023-09-04 10:43:32 +03:00
|
|
|
if (num > polygon_cb->numPoints)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "%s numPoints %" PRIu32 " > %" PRIu32, orderName, num, polygon_cb->numPoints);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
polygon_cb->numPoints = num;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
polygon_cb->backMode = (polygon_cb->bRop2 & 0x80) ? BACKMODE_TRANSPARENT : BACKMODE_OPAQUE;
|
2012-02-13 02:14:59 +04:00
|
|
|
polygon_cb->bRop2 = (polygon_cb->bRop2 & 0x1F);
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2023-09-04 10:26:06 +03:00
|
|
|
static BOOL update_read_ellipse_sc_order(const char* orderName, wStream* s,
|
|
|
|
const ORDER_INFO* orderInfo, ELLIPSE_SC_ORDER* ellipse_sc)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2023-09-04 10:26:06 +03:00
|
|
|
if (read_order_field_coord(orderName, orderInfo, s, 1, &ellipse_sc->leftRect, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 2, &ellipse_sc->topRect, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 3, &ellipse_sc->rightRect, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 4, &ellipse_sc->bottomRect, FALSE) &&
|
|
|
|
read_order_field_byte(orderName, orderInfo, s, 5, &ellipse_sc->bRop2, TRUE) &&
|
|
|
|
read_order_field_byte(orderName, orderInfo, s, 6, &ellipse_sc->fillMode, TRUE) &&
|
|
|
|
read_order_field_color(orderName, orderInfo, s, 7, &ellipse_sc->color, TRUE))
|
2020-10-15 12:03:29 +03:00
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2023-09-04 10:26:06 +03:00
|
|
|
static BOOL update_read_ellipse_cb_order(const char* orderName, wStream* s,
|
|
|
|
const ORDER_INFO* orderInfo, ELLIPSE_CB_ORDER* ellipse_cb)
|
|
|
|
{
|
|
|
|
if (read_order_field_coord(orderName, orderInfo, s, 1, &ellipse_cb->leftRect, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 2, &ellipse_cb->topRect, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 3, &ellipse_cb->rightRect, FALSE) &&
|
|
|
|
read_order_field_coord(orderName, orderInfo, s, 4, &ellipse_cb->bottomRect, FALSE) &&
|
|
|
|
read_order_field_byte(orderName, orderInfo, s, 5, &ellipse_cb->bRop2, TRUE) &&
|
|
|
|
read_order_field_byte(orderName, orderInfo, s, 6, &ellipse_cb->fillMode, TRUE) &&
|
|
|
|
read_order_field_color(orderName, orderInfo, s, 7, &ellipse_cb->backColor, TRUE) &&
|
|
|
|
read_order_field_color(orderName, orderInfo, s, 8, &ellipse_cb->foreColor, TRUE) &&
|
2020-10-15 12:03:29 +03:00
|
|
|
update_read_brush(s, &ellipse_cb->brush, orderInfo->fieldFlags >> 8))
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2024-04-17 10:20:29 +03:00
|
|
|
|
2011-07-26 00:54:15 +04:00
|
|
|
/* Secondary Drawing Orders */
|
2024-04-17 10:20:29 +03:00
|
|
|
WINPR_ATTR_MALLOC(free_cache_bitmap_order, 2)
|
2018-03-30 11:43:20 +03:00
|
|
|
static CACHE_BITMAP_ORDER* update_read_cache_bitmap_order(rdpUpdate* update, wStream* s,
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL compressed, UINT16 flags)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
CACHE_BITMAP_ORDER* cache_bitmap = NULL;
|
2022-01-11 18:01:33 +03:00
|
|
|
rdp_update_internal* up = update_cast(update);
|
2018-03-30 11:43:20 +03:00
|
|
|
|
2018-05-04 13:03:26 +03:00
|
|
|
if (!update || !s)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
cache_bitmap = calloc(1, sizeof(CACHE_BITMAP_ORDER));
|
|
|
|
|
|
|
|
if (!cache_bitmap)
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 9))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2013-05-08 01:40:54 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT8(s, cache_bitmap->cacheId); /* cacheId (1 byte) */
|
|
|
|
Stream_Seek_UINT8(s); /* pad1Octet (1 byte) */
|
|
|
|
Stream_Read_UINT8(s, cache_bitmap->bitmapWidth); /* bitmapWidth (1 byte) */
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_Read_UINT8(s, cache_bitmap->bitmapHeight); /* bitmapHeight (1 byte) */
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT8(s, cache_bitmap->bitmapBpp); /* bitmapBpp (1 byte) */
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2014-05-29 12:12:02 +04:00
|
|
|
if ((cache_bitmap->bitmapBpp < 1) || (cache_bitmap->bitmapBpp > 32))
|
|
|
|
{
|
2022-01-11 18:01:33 +03:00
|
|
|
WLog_Print(up->log, WLOG_ERROR, "invalid bitmap bpp %" PRIu32 "", cache_bitmap->bitmapBpp);
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2014-05-29 12:12:02 +04:00
|
|
|
}
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_Read_UINT16(s, cache_bitmap->bitmapLength); /* bitmapLength (2 bytes) */
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT16(s, cache_bitmap->cacheIndex); /* cacheIndex (2 bytes) */
|
2011-08-03 00:58:42 +04:00
|
|
|
|
|
|
|
if (compressed)
|
|
|
|
{
|
2012-01-05 05:17:11 +04:00
|
|
|
if ((flags & NO_BITMAP_COMPRESSION_HDR) == 0)
|
2011-08-03 00:58:42 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
BYTE* bitmapComprHdr = (BYTE*)&(cache_bitmap->bitmapComprHdr);
|
2013-05-08 01:40:54 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2013-05-08 01:40:54 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read(s, bitmapComprHdr, 8); /* bitmapComprHdr (8 bytes) */
|
2013-05-13 01:46:13 +04:00
|
|
|
cache_bitmap->bitmapLength -= 8;
|
2011-08-03 00:58:42 +04:00
|
|
|
}
|
2018-03-30 11:43:20 +03:00
|
|
|
}
|
2013-01-12 03:17:45 +04:00
|
|
|
|
2020-03-30 19:18:12 +03:00
|
|
|
if (cache_bitmap->bitmapLength == 0)
|
|
|
|
goto fail;
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, cache_bitmap->bitmapLength))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2013-01-12 03:17:45 +04:00
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
cache_bitmap->bitmapDataStream = malloc(cache_bitmap->bitmapLength);
|
2013-01-12 03:17:45 +04:00
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
if (!cache_bitmap->bitmapDataStream)
|
|
|
|
goto fail;
|
2013-05-08 01:40:54 +04:00
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
Stream_Read(s, cache_bitmap->bitmapDataStream, cache_bitmap->bitmapLength);
|
2013-05-13 01:46:13 +04:00
|
|
|
cache_bitmap->compressed = compressed;
|
2018-03-30 11:43:20 +03:00
|
|
|
return cache_bitmap;
|
|
|
|
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_cache_bitmap_order(update->context, cache_bitmap);
|
2024-02-04 13:11:29 +03:00
|
|
|
WINPR_PRAGMA_DIAG_POP
|
2018-03-30 11:43:20 +03:00
|
|
|
return NULL;
|
2013-05-13 01:46:13 +04:00
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
|
|
|
size_t update_approximate_cache_bitmap_order(const CACHE_BITMAP_ORDER* cache_bitmap,
|
2024-08-29 16:10:21 +03:00
|
|
|
BOOL compressed, const UINT16* flags)
|
2013-06-10 01:56:57 +04:00
|
|
|
{
|
2022-01-11 18:29:40 +03:00
|
|
|
WINPR_ASSERT(cache_bitmap);
|
|
|
|
WINPR_UNUSED(compressed);
|
|
|
|
WINPR_UNUSED(flags);
|
2013-06-10 01:56:57 +04:00
|
|
|
return 64 + cache_bitmap->bitmapLength;
|
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL update_write_cache_bitmap_order(wStream* s, const CACHE_BITMAP_ORDER* cache_bitmap,
|
2016-07-21 13:53:44 +03:00
|
|
|
BOOL compressed, UINT16* flags)
|
2013-05-13 01:46:13 +04:00
|
|
|
{
|
2016-04-05 18:07:45 +03:00
|
|
|
UINT32 bitmapLength = cache_bitmap->bitmapLength;
|
2022-01-11 18:29:40 +03:00
|
|
|
size_t inf = update_approximate_cache_bitmap_order(cache_bitmap, compressed, flags);
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, inf))
|
2015-03-26 19:09:47 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*flags = NO_BITMAP_COMPRESSION_HDR;
|
2013-05-13 01:46:13 +04:00
|
|
|
|
|
|
|
if ((*flags & NO_BITMAP_COMPRESSION_HDR) == 0)
|
2016-04-05 18:07:45 +03:00
|
|
|
bitmapLength += 8;
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT8(s, cache_bitmap->cacheId); /* cacheId (1 byte) */
|
|
|
|
Stream_Write_UINT8(s, 0); /* pad1Octet (1 byte) */
|
|
|
|
Stream_Write_UINT8(s, cache_bitmap->bitmapWidth); /* bitmapWidth (1 byte) */
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_Write_UINT8(s, cache_bitmap->bitmapHeight); /* bitmapHeight (1 byte) */
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT8(s, cache_bitmap->bitmapBpp); /* bitmapBpp (1 byte) */
|
|
|
|
Stream_Write_UINT16(s, bitmapLength); /* bitmapLength (2 bytes) */
|
|
|
|
Stream_Write_UINT16(s, cache_bitmap->cacheIndex); /* cacheIndex (2 bytes) */
|
2013-05-13 01:46:13 +04:00
|
|
|
|
|
|
|
if (compressed)
|
|
|
|
{
|
|
|
|
if ((*flags & NO_BITMAP_COMPRESSION_HDR) == 0)
|
|
|
|
{
|
2021-08-02 13:13:34 +03:00
|
|
|
const BYTE* bitmapComprHdr = (const BYTE*)&(cache_bitmap->bitmapComprHdr);
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_Write(s, bitmapComprHdr, 8); /* bitmapComprHdr (8 bytes) */
|
2016-04-05 18:07:45 +03:00
|
|
|
bitmapLength -= 8;
|
2013-05-13 01:46:13 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
Stream_Write(s, cache_bitmap->bitmapDataStream, bitmapLength);
|
2013-05-13 01:46:13 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-05 18:07:45 +03:00
|
|
|
Stream_Write(s, cache_bitmap->bitmapDataStream, bitmapLength);
|
2013-05-13 01:46:13 +04:00
|
|
|
}
|
2013-05-08 01:40:54 +04:00
|
|
|
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2024-04-17 10:20:29 +03:00
|
|
|
WINPR_ATTR_MALLOC(free_cache_bitmap_v2_order, 2)
|
2018-03-30 11:43:20 +03:00
|
|
|
static CACHE_BITMAP_V2_ORDER* update_read_cache_bitmap_v2_order(rdpUpdate* update, wStream* s,
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL compressed, UINT16 flags)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BOOL rc = 0;
|
|
|
|
BYTE bitsPerPixelId = 0;
|
|
|
|
CACHE_BITMAP_V2_ORDER* cache_bitmap_v2 = NULL;
|
2018-05-04 13:03:26 +03:00
|
|
|
|
|
|
|
if (!update || !s)
|
|
|
|
return NULL;
|
2018-03-30 11:43:20 +03:00
|
|
|
|
2018-05-04 13:03:26 +03:00
|
|
|
cache_bitmap_v2 = calloc(1, sizeof(CACHE_BITMAP_V2_ORDER));
|
|
|
|
|
|
|
|
if (!cache_bitmap_v2)
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
|
|
|
|
2013-05-08 01:40:54 +04:00
|
|
|
cache_bitmap_v2->cacheId = flags & 0x0003;
|
|
|
|
cache_bitmap_v2->flags = (flags & 0xFF80) >> 7;
|
2011-08-04 07:33:44 +04:00
|
|
|
bitsPerPixelId = (flags & 0x0078) >> 3;
|
2020-05-26 08:50:55 +03:00
|
|
|
cache_bitmap_v2->bitmapBpp = get_cbr2_bpp(bitsPerPixelId, &rc);
|
|
|
|
if (!rc)
|
|
|
|
goto fail;
|
2011-08-03 00:58:42 +04:00
|
|
|
|
2013-05-08 01:40:54 +04:00
|
|
|
if (cache_bitmap_v2->flags & CBR2_PERSISTENT_KEY_PRESENT)
|
2011-08-04 07:33:44 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2013-05-07 07:21:12 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT32(s, cache_bitmap_v2->key1); /* key1 (4 bytes) */
|
|
|
|
Stream_Read_UINT32(s, cache_bitmap_v2->key2); /* key2 (4 bytes) */
|
2011-08-04 07:33:44 +04:00
|
|
|
}
|
|
|
|
|
2013-05-08 01:40:54 +04:00
|
|
|
if (cache_bitmap_v2->flags & CBR2_HEIGHT_SAME_AS_WIDTH)
|
2011-08-04 07:33:44 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!update_read_2byte_unsigned(s, &cache_bitmap_v2->bitmapWidth)) /* bitmapWidth */
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2013-05-07 07:21:12 +04:00
|
|
|
|
2013-05-08 01:40:54 +04:00
|
|
|
cache_bitmap_v2->bitmapHeight = cache_bitmap_v2->bitmapWidth;
|
2011-08-04 07:33:44 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!update_read_2byte_unsigned(s, &cache_bitmap_v2->bitmapWidth) || /* bitmapWidth */
|
|
|
|
!update_read_2byte_unsigned(s, &cache_bitmap_v2->bitmapHeight)) /* bitmapHeight */
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2011-08-04 07:33:44 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!update_read_4byte_unsigned(s, &cache_bitmap_v2->bitmapLength) || /* bitmapLength */
|
|
|
|
!update_read_2byte_unsigned(s, &cache_bitmap_v2->cacheIndex)) /* cacheIndex */
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2011-08-03 00:58:42 +04:00
|
|
|
|
2013-05-08 01:40:54 +04:00
|
|
|
if (cache_bitmap_v2->flags & CBR2_DO_NOT_CACHE)
|
|
|
|
cache_bitmap_v2->cacheIndex = BITMAP_CACHE_WAITING_LIST_INDEX;
|
2012-01-04 03:22:42 +04:00
|
|
|
|
2011-08-03 00:58:42 +04:00
|
|
|
if (compressed)
|
|
|
|
{
|
2013-05-08 01:40:54 +04:00
|
|
|
if (!(cache_bitmap_v2->flags & CBR2_NO_BITMAP_COMPRESSION_HDR))
|
2011-08-03 00:58:42 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2013-01-12 03:17:45 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT16(
|
|
|
|
s, cache_bitmap_v2->cbCompFirstRowSize); /* cbCompFirstRowSize (2 bytes) */
|
|
|
|
Stream_Read_UINT16(
|
|
|
|
s, cache_bitmap_v2->cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, cache_bitmap_v2->cbScanWidth); /* cbScanWidth (2 bytes) */
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT16(
|
|
|
|
s, cache_bitmap_v2->cbUncompressedSize); /* cbUncompressedSize (2 bytes) */
|
2013-05-08 01:40:54 +04:00
|
|
|
cache_bitmap_v2->bitmapLength = cache_bitmap_v2->cbCompMainBodySize;
|
2011-08-03 00:58:42 +04:00
|
|
|
}
|
2018-03-30 11:43:20 +03:00
|
|
|
}
|
2011-09-12 07:35:33 +04:00
|
|
|
|
2020-03-30 19:18:12 +03:00
|
|
|
if (cache_bitmap_v2->bitmapLength == 0)
|
|
|
|
goto fail;
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, cache_bitmap_v2->bitmapLength))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2013-05-07 07:21:12 +04:00
|
|
|
|
2018-11-29 13:05:13 +03:00
|
|
|
if (cache_bitmap_v2->bitmapLength == 0)
|
|
|
|
goto fail;
|
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
cache_bitmap_v2->bitmapDataStream = malloc(cache_bitmap_v2->bitmapLength);
|
2013-05-07 07:21:12 +04:00
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
if (!cache_bitmap_v2->bitmapDataStream)
|
|
|
|
goto fail;
|
2013-05-07 07:21:12 +04:00
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
Stream_Read(s, cache_bitmap_v2->bitmapDataStream, cache_bitmap_v2->bitmapLength);
|
2013-05-08 01:40:54 +04:00
|
|
|
cache_bitmap_v2->compressed = compressed;
|
2018-03-30 11:43:20 +03:00
|
|
|
return cache_bitmap_v2;
|
|
|
|
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_cache_bitmap_v2_order(update->context, cache_bitmap_v2);
|
2024-02-04 13:11:29 +03:00
|
|
|
WINPR_PRAGMA_DIAG_POP
|
2018-03-30 11:43:20 +03:00
|
|
|
return NULL;
|
2013-05-07 07:21:12 +04:00
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
|
|
|
size_t update_approximate_cache_bitmap_v2_order(CACHE_BITMAP_V2_ORDER* cache_bitmap_v2,
|
2024-08-29 16:10:21 +03:00
|
|
|
BOOL compressed, const UINT16* flags)
|
2013-06-10 01:56:57 +04:00
|
|
|
{
|
2022-01-11 18:29:40 +03:00
|
|
|
WINPR_ASSERT(cache_bitmap_v2);
|
|
|
|
WINPR_UNUSED(flags);
|
|
|
|
WINPR_UNUSED(compressed);
|
|
|
|
|
2013-06-10 01:56:57 +04:00
|
|
|
return 64 + cache_bitmap_v2->bitmapLength;
|
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL update_write_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2,
|
|
|
|
BOOL compressed, UINT16* flags)
|
2013-05-07 07:21:12 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BOOL rc = 0;
|
|
|
|
BYTE bitsPerPixelId = 0;
|
2013-05-07 07:21:12 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(
|
|
|
|
s, update_approximate_cache_bitmap_v2_order(cache_bitmap_v2, compressed, flags)))
|
2015-03-26 19:09:47 +03:00
|
|
|
return FALSE;
|
2013-05-10 00:30:28 +04:00
|
|
|
|
2020-05-26 08:50:55 +03:00
|
|
|
bitsPerPixelId = get_bpp_bmf(cache_bitmap_v2->bitmapBpp, &rc);
|
|
|
|
if (!rc)
|
|
|
|
return FALSE;
|
2019-11-06 17:24:51 +03:00
|
|
|
*flags = (cache_bitmap_v2->cacheId & 0x0003) | (bitsPerPixelId << 3) |
|
|
|
|
((cache_bitmap_v2->flags << 7) & 0xFF80);
|
2013-05-07 07:21:12 +04:00
|
|
|
|
|
|
|
if (cache_bitmap_v2->flags & CBR2_PERSISTENT_KEY_PRESENT)
|
|
|
|
{
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT32(s, cache_bitmap_v2->key1); /* key1 (4 bytes) */
|
|
|
|
Stream_Write_UINT32(s, cache_bitmap_v2->key2); /* key2 (4 bytes) */
|
2013-05-07 07:21:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cache_bitmap_v2->flags & CBR2_HEIGHT_SAME_AS_WIDTH)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!update_write_2byte_unsigned(s, cache_bitmap_v2->bitmapWidth)) /* bitmapWidth */
|
2013-05-07 07:21:12 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!update_write_2byte_unsigned(s, cache_bitmap_v2->bitmapWidth) || /* bitmapWidth */
|
|
|
|
!update_write_2byte_unsigned(s, cache_bitmap_v2->bitmapHeight)) /* bitmapHeight */
|
2013-05-07 07:21:12 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-05-08 07:41:39 +04:00
|
|
|
if (cache_bitmap_v2->flags & CBR2_DO_NOT_CACHE)
|
|
|
|
cache_bitmap_v2->cacheIndex = BITMAP_CACHE_WAITING_LIST_INDEX;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!update_write_4byte_unsigned(s, cache_bitmap_v2->bitmapLength) || /* bitmapLength */
|
|
|
|
!update_write_2byte_unsigned(s, cache_bitmap_v2->cacheIndex)) /* cacheIndex */
|
2013-05-07 07:21:12 +04:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (compressed)
|
|
|
|
{
|
|
|
|
if (!(cache_bitmap_v2->flags & CBR2_NO_BITMAP_COMPRESSION_HDR))
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT16(
|
|
|
|
s, cache_bitmap_v2->cbCompFirstRowSize); /* cbCompFirstRowSize (2 bytes) */
|
|
|
|
Stream_Write_UINT16(
|
|
|
|
s, cache_bitmap_v2->cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */
|
|
|
|
Stream_Write_UINT16(s, cache_bitmap_v2->cbScanWidth); /* cbScanWidth (2 bytes) */
|
|
|
|
Stream_Write_UINT16(
|
|
|
|
s, cache_bitmap_v2->cbUncompressedSize); /* cbUncompressedSize (2 bytes) */
|
2013-05-07 07:21:12 +04:00
|
|
|
cache_bitmap_v2->bitmapLength = cache_bitmap_v2->cbCompMainBodySize;
|
|
|
|
}
|
|
|
|
|
2015-03-30 18:15:45 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, cache_bitmap_v2->bitmapLength))
|
2015-03-26 19:09:47 +03:00
|
|
|
return FALSE;
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write(s, cache_bitmap_v2->bitmapDataStream, cache_bitmap_v2->bitmapLength);
|
2013-05-07 07:21:12 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-03-30 18:15:45 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, cache_bitmap_v2->bitmapLength))
|
2015-03-26 19:09:47 +03:00
|
|
|
return FALSE;
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write(s, cache_bitmap_v2->bitmapDataStream, cache_bitmap_v2->bitmapLength);
|
2013-05-07 07:21:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
cache_bitmap_v2->compressed = compressed;
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2024-04-17 10:20:29 +03:00
|
|
|
|
|
|
|
WINPR_ATTR_MALLOC(free_cache_bitmap_v3_order, 2)
|
2018-03-30 11:43:20 +03:00
|
|
|
static CACHE_BITMAP_V3_ORDER* update_read_cache_bitmap_v3_order(rdpUpdate* update, wStream* s,
|
2019-11-06 17:24:51 +03:00
|
|
|
UINT16 flags)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BOOL rc = 0;
|
|
|
|
BYTE bitsPerPixelId = 0;
|
|
|
|
BITMAP_DATA_EX* bitmapData = NULL;
|
|
|
|
UINT32 new_len = 0;
|
|
|
|
BYTE* new_data = NULL;
|
|
|
|
CACHE_BITMAP_V3_ORDER* cache_bitmap_v3 = NULL;
|
2022-01-11 18:01:33 +03:00
|
|
|
rdp_update_internal* up = update_cast(update);
|
2018-05-04 13:03:26 +03:00
|
|
|
|
|
|
|
if (!update || !s)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
cache_bitmap_v3 = calloc(1, sizeof(CACHE_BITMAP_V3_ORDER));
|
2018-03-30 11:43:20 +03:00
|
|
|
|
2018-05-04 13:03:26 +03:00
|
|
|
if (!cache_bitmap_v3)
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
|
|
|
|
2013-05-13 01:46:13 +04:00
|
|
|
cache_bitmap_v3->cacheId = flags & 0x00000003;
|
|
|
|
cache_bitmap_v3->flags = (flags & 0x0000FF80) >> 7;
|
2011-08-03 00:58:42 +04:00
|
|
|
bitsPerPixelId = (flags & 0x00000078) >> 3;
|
2020-05-26 08:50:55 +03:00
|
|
|
cache_bitmap_v3->bpp = get_cbr2_bpp(bitsPerPixelId, &rc);
|
|
|
|
if (!rc)
|
|
|
|
goto fail;
|
2011-07-26 00:54:15 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 21))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2011-08-04 07:33:44 +04:00
|
|
|
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_Read_UINT16(s, cache_bitmap_v3->cacheIndex); /* cacheIndex (2 bytes) */
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT32(s, cache_bitmap_v3->key1); /* key1 (4 bytes) */
|
|
|
|
Stream_Read_UINT32(s, cache_bitmap_v3->key2); /* key2 (4 bytes) */
|
2013-05-13 01:46:13 +04:00
|
|
|
bitmapData = &cache_bitmap_v3->bitmapData;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, bitmapData->bpp);
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2014-05-29 12:12:02 +04:00
|
|
|
if ((bitmapData->bpp < 1) || (bitmapData->bpp > 32))
|
|
|
|
{
|
2022-01-11 18:01:33 +03:00
|
|
|
WLog_Print(up->log, WLOG_ERROR, "invalid bpp value %" PRIu32 "", bitmapData->bpp);
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2014-05-29 12:12:02 +04:00
|
|
|
}
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Seek_UINT8(s); /* reserved1 (1 byte) */
|
|
|
|
Stream_Seek_UINT8(s); /* reserved2 (1 byte) */
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, bitmapData->codecID); /* codecID (1 byte) */
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT16(s, bitmapData->width); /* width (2 bytes) */
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, bitmapData->height); /* height (2 bytes) */
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT32(s, new_len); /* length (4 bytes) */
|
2011-08-04 07:33:44 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if ((new_len == 0) || (!Stream_CheckAndLogRequiredLength(TAG, s, new_len)))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
new_data = (BYTE*)realloc(bitmapData->data, new_len);
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2015-03-11 08:40:20 +03:00
|
|
|
if (!new_data)
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2015-03-11 08:40:20 +03:00
|
|
|
bitmapData->data = new_data;
|
|
|
|
bitmapData->length = new_len;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read(s, bitmapData->data, bitmapData->length);
|
2018-03-30 11:43:20 +03:00
|
|
|
return cache_bitmap_v3;
|
|
|
|
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_cache_bitmap_v3_order(update->context, cache_bitmap_v3);
|
2024-02-04 13:11:29 +03:00
|
|
|
WINPR_PRAGMA_DIAG_POP
|
2018-03-30 11:43:20 +03:00
|
|
|
return NULL;
|
2013-05-13 01:46:13 +04:00
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
|
|
|
size_t update_approximate_cache_bitmap_v3_order(CACHE_BITMAP_V3_ORDER* cache_bitmap_v3,
|
|
|
|
UINT16* flags)
|
2013-06-10 01:56:57 +04:00
|
|
|
{
|
|
|
|
BITMAP_DATA_EX* bitmapData = &cache_bitmap_v3->bitmapData;
|
|
|
|
return 64 + bitmapData->length;
|
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL update_write_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_bitmap_v3,
|
|
|
|
UINT16* flags)
|
2013-05-13 01:46:13 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BOOL rc = 0;
|
|
|
|
BYTE bitsPerPixelId = 0;
|
|
|
|
BITMAP_DATA_EX* bitmapData = NULL;
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(
|
|
|
|
s, update_approximate_cache_bitmap_v3_order(cache_bitmap_v3, flags)))
|
2015-03-26 19:09:47 +03:00
|
|
|
return FALSE;
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2015-03-26 19:09:47 +03:00
|
|
|
bitmapData = &cache_bitmap_v3->bitmapData;
|
2020-05-26 08:50:55 +03:00
|
|
|
bitsPerPixelId = get_bpp_bmf(cache_bitmap_v3->bpp, &rc);
|
|
|
|
if (!rc)
|
|
|
|
return FALSE;
|
2013-05-13 01:46:13 +04:00
|
|
|
*flags = (cache_bitmap_v3->cacheId & 0x00000003) |
|
2019-11-06 17:24:51 +03:00
|
|
|
((cache_bitmap_v3->flags << 7) & 0x0000FF80) | ((bitsPerPixelId << 3) & 0x00000078);
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_Write_UINT16(s, cache_bitmap_v3->cacheIndex); /* cacheIndex (2 bytes) */
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT32(s, cache_bitmap_v3->key1); /* key1 (4 bytes) */
|
|
|
|
Stream_Write_UINT32(s, cache_bitmap_v3->key2); /* key2 (4 bytes) */
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_Write_UINT8(s, bitmapData->bpp);
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT8(s, 0); /* reserved1 (1 byte) */
|
|
|
|
Stream_Write_UINT8(s, 0); /* reserved2 (1 byte) */
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_Write_UINT8(s, bitmapData->codecID); /* codecID (1 byte) */
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT16(s, bitmapData->width); /* width (2 bytes) */
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_Write_UINT16(s, bitmapData->height); /* height (2 bytes) */
|
|
|
|
Stream_Write_UINT32(s, bitmapData->length); /* length (4 bytes) */
|
|
|
|
Stream_Write(s, bitmapData->data, bitmapData->length);
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2024-04-17 10:20:29 +03:00
|
|
|
|
|
|
|
WINPR_ATTR_MALLOC(free_cache_color_table_order, 2)
|
2018-03-30 11:43:20 +03:00
|
|
|
static CACHE_COLOR_TABLE_ORDER* update_read_cache_color_table_order(rdpUpdate* update, wStream* s,
|
2019-11-06 17:24:51 +03:00
|
|
|
UINT16 flags)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT32* colorTable = NULL;
|
2018-03-30 11:43:20 +03:00
|
|
|
CACHE_COLOR_TABLE_ORDER* cache_color_table = calloc(1, sizeof(CACHE_COLOR_TABLE_ORDER));
|
|
|
|
|
|
|
|
if (!cache_color_table)
|
|
|
|
goto fail;
|
2011-08-03 11:29:56 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 3))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2013-02-04 01:19:25 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT8(s, cache_color_table->cacheIndex); /* cacheIndex (1 byte) */
|
|
|
|
Stream_Read_UINT16(s, cache_color_table->numberColors); /* numberColors (2 bytes) */
|
2011-07-26 00:54:15 +04:00
|
|
|
|
2013-05-13 01:46:13 +04:00
|
|
|
if (cache_color_table->numberColors != 256)
|
2013-02-04 01:19:25 +04:00
|
|
|
{
|
|
|
|
/* This field MUST be set to 256 */
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2013-02-04 01:19:25 +04:00
|
|
|
}
|
2013-01-12 03:17:45 +04:00
|
|
|
|
2023-01-24 16:53:36 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, cache_color_table->numberColors, 4ull))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2011-08-03 11:29:56 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
colorTable = (UINT32*)&cache_color_table->colorTable;
|
2011-08-03 11:29:56 +04:00
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 i = 0; i < cache_color_table->numberColors; i++)
|
2011-08-03 11:29:56 +04:00
|
|
|
update_read_color_quad(s, &colorTable[i]);
|
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
return cache_color_table;
|
|
|
|
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_cache_color_table_order(update->context, cache_color_table);
|
2024-02-04 13:11:29 +03:00
|
|
|
WINPR_PRAGMA_DIAG_POP
|
2018-03-30 11:43:20 +03:00
|
|
|
return NULL;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
|
|
|
size_t update_approximate_cache_color_table_order(const CACHE_COLOR_TABLE_ORDER* cache_color_table,
|
2024-08-29 16:10:21 +03:00
|
|
|
const UINT16* flags)
|
2013-06-10 01:56:57 +04:00
|
|
|
{
|
2022-01-11 18:29:40 +03:00
|
|
|
WINPR_UNUSED(cache_color_table);
|
|
|
|
WINPR_UNUSED(flags);
|
|
|
|
|
2013-06-10 01:56:57 +04:00
|
|
|
return 16 + (256 * 4);
|
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
BOOL update_write_cache_color_table_order(wStream* s,
|
2019-11-06 17:24:51 +03:00
|
|
|
const CACHE_COLOR_TABLE_ORDER* cache_color_table,
|
|
|
|
UINT16* flags)
|
2013-05-13 01:46:13 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t inf = 0;
|
|
|
|
const UINT32* colorTable = NULL;
|
2013-05-13 01:46:13 +04:00
|
|
|
|
|
|
|
if (cache_color_table->numberColors != 256)
|
|
|
|
return FALSE;
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
inf = update_approximate_cache_color_table_order(cache_color_table, flags);
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, inf))
|
2015-03-26 19:09:47 +03:00
|
|
|
return FALSE;
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT8(s, cache_color_table->cacheIndex); /* cacheIndex (1 byte) */
|
|
|
|
Stream_Write_UINT16(s, cache_color_table->numberColors); /* numberColors (2 bytes) */
|
2021-08-02 13:13:34 +03:00
|
|
|
colorTable = (const UINT32*)&cache_color_table->colorTable;
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (size_t i = 0; i < cache_color_table->numberColors; i++)
|
2013-05-13 01:46:13 +04:00
|
|
|
{
|
|
|
|
update_write_color_quad(s, colorTable[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
static CACHE_GLYPH_ORDER* update_read_cache_glyph_order(rdpUpdate* update, wStream* s, UINT16 flags)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2018-03-30 11:43:20 +03:00
|
|
|
CACHE_GLYPH_ORDER* cache_glyph_order = calloc(1, sizeof(CACHE_GLYPH_ORDER));
|
|
|
|
|
2022-04-28 09:00:39 +03:00
|
|
|
WINPR_ASSERT(update);
|
|
|
|
WINPR_ASSERT(s);
|
|
|
|
|
|
|
|
if (!cache_glyph_order)
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2011-08-03 11:29:56 +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-29 03:42:32 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, cache_glyph_order->cacheId); /* cacheId (1 byte) */
|
|
|
|
Stream_Read_UINT8(s, cache_glyph_order->cGlyphs); /* cGlyphs (1 byte) */
|
2011-08-03 11:29:56 +04:00
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 i = 0; i < cache_glyph_order->cGlyphs; i++)
|
2011-08-03 11:29:56 +04:00
|
|
|
{
|
2016-07-19 14:02:08 +03:00
|
|
|
GLYPH_DATA* glyph = &cache_glyph_order->glyphData[i];
|
2011-08-03 11:29:56 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 10))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2013-01-29 03:42:32 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, glyph->cacheIndex);
|
2016-07-19 14:02:08 +03:00
|
|
|
Stream_Read_INT16(s, glyph->x);
|
|
|
|
Stream_Read_INT16(s, glyph->y);
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, glyph->cx);
|
|
|
|
Stream_Read_UINT16(s, glyph->cy);
|
2011-08-03 11:29:56 +04:00
|
|
|
glyph->cb = ((glyph->cx + 7) / 8) * glyph->cy;
|
2011-09-07 21:45:25 +04:00
|
|
|
glyph->cb += ((glyph->cb % 4) > 0) ? 4 - (glyph->cb % 4) : 0;
|
2011-07-26 00:54:15 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, glyph->cb))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2013-01-29 03:42:32 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
glyph->aj = (BYTE*)malloc(glyph->cb);
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
if (!glyph->aj)
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read(s, glyph->aj, glyph->cb);
|
2011-08-03 11:29:56 +04:00
|
|
|
}
|
2011-09-07 21:45:25 +04:00
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
if ((flags & CG_GLYPH_UNICODE_PRESENT) && (cache_glyph_order->cGlyphs > 0))
|
2013-01-29 03:42:32 +04:00
|
|
|
{
|
2018-03-30 11:43:20 +03:00
|
|
|
cache_glyph_order->unicodeCharacters = calloc(cache_glyph_order->cGlyphs, sizeof(WCHAR));
|
|
|
|
|
|
|
|
if (!cache_glyph_order->unicodeCharacters)
|
|
|
|
goto fail;
|
|
|
|
|
2023-01-24 16:53:36 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, cache_glyph_order->cGlyphs,
|
|
|
|
sizeof(WCHAR)))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UTF16_String(s, cache_glyph_order->unicodeCharacters,
|
|
|
|
cache_glyph_order->cGlyphs);
|
2013-01-12 03:17:45 +04:00
|
|
|
}
|
2013-01-29 03:42:32 +04:00
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
return cache_glyph_order;
|
|
|
|
fail:
|
|
|
|
free_cache_glyph_order(update->context, cache_glyph_order);
|
|
|
|
return NULL;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2024-08-29 16:10:21 +03:00
|
|
|
size_t update_approximate_cache_glyph_order(const CACHE_GLYPH_ORDER* cache_glyph,
|
|
|
|
const UINT16* flags)
|
2013-06-10 01:56:57 +04:00
|
|
|
{
|
2022-01-11 18:29:40 +03:00
|
|
|
WINPR_ASSERT(cache_glyph);
|
|
|
|
WINPR_UNUSED(flags);
|
2013-06-10 01:56:57 +04:00
|
|
|
return 2 + cache_glyph->cGlyphs * 32;
|
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL update_write_cache_glyph_order(wStream* s, const CACHE_GLYPH_ORDER* cache_glyph, UINT16* flags)
|
2013-05-08 02:44:22 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
INT16 lsi16 = 0;
|
|
|
|
const GLYPH_DATA* glyph = NULL;
|
2022-01-11 18:29:40 +03:00
|
|
|
size_t inf = update_approximate_cache_glyph_order(cache_glyph, flags);
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, inf))
|
2015-03-26 19:09:47 +03:00
|
|
|
return FALSE;
|
2013-05-10 00:30:28 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, cache_glyph->cacheId); /* cacheId (1 byte) */
|
|
|
|
Stream_Write_UINT8(s, cache_glyph->cGlyphs); /* cGlyphs (1 byte) */
|
2013-05-08 02:44:22 +04:00
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 i = 0; i < cache_glyph->cGlyphs; i++)
|
2013-05-08 02:44:22 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT32 cb = 0;
|
2013-05-08 02:44:22 +04:00
|
|
|
glyph = &cache_glyph->glyphData[i];
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, glyph->cacheIndex); /* cacheIndex (2 bytes) */
|
2013-05-08 02:44:22 +04:00
|
|
|
lsi16 = glyph->x;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, lsi16); /* x (2 bytes) */
|
2013-05-08 02:44:22 +04:00
|
|
|
lsi16 = glyph->y;
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT16(s, lsi16); /* y (2 bytes) */
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, glyph->cx); /* cx (2 bytes) */
|
|
|
|
Stream_Write_UINT16(s, glyph->cy); /* cy (2 bytes) */
|
2016-04-05 18:07:45 +03:00
|
|
|
cb = ((glyph->cx + 7) / 8) * glyph->cy;
|
|
|
|
cb += ((cb % 4) > 0) ? 4 - (cb % 4) : 0;
|
|
|
|
Stream_Write(s, glyph->aj, cb);
|
2013-05-08 02:44:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (*flags & CG_GLYPH_UNICODE_PRESENT)
|
|
|
|
{
|
2024-08-26 17:33:59 +03:00
|
|
|
Stream_Zero(s, 2ULL * cache_glyph->cGlyphs);
|
2013-05-08 02:44:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
static CACHE_GLYPH_V2_ORDER* update_read_cache_glyph_v2_order(rdpUpdate* update, wStream* s,
|
2019-11-06 17:24:51 +03:00
|
|
|
UINT16 flags)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2018-03-30 11:43:20 +03:00
|
|
|
CACHE_GLYPH_V2_ORDER* cache_glyph_v2 = calloc(1, sizeof(CACHE_GLYPH_V2_ORDER));
|
|
|
|
|
|
|
|
if (!cache_glyph_v2)
|
|
|
|
goto fail;
|
|
|
|
|
2013-05-07 19:41:32 +04:00
|
|
|
cache_glyph_v2->cacheId = (flags & 0x000F);
|
|
|
|
cache_glyph_v2->flags = (flags & 0x00F0) >> 4;
|
|
|
|
cache_glyph_v2->cGlyphs = (flags & 0xFF00) >> 8;
|
2011-08-03 11:29:56 +04:00
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 i = 0; i < cache_glyph_v2->cGlyphs; i++)
|
2011-08-03 11:29:56 +04:00
|
|
|
{
|
2016-07-19 14:02:08 +03:00
|
|
|
GLYPH_DATA_V2* glyph = &cache_glyph_v2->glyphData[i];
|
2011-08-03 11:29:56 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2013-01-29 03:42:32 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, glyph->cacheIndex);
|
2013-01-12 03:17:45 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!update_read_2byte_signed(s, &glyph->x) || !update_read_2byte_signed(s, &glyph->y) ||
|
2016-07-15 17:23:00 +03:00
|
|
|
!update_read_2byte_unsigned(s, &glyph->cx) ||
|
|
|
|
!update_read_2byte_unsigned(s, &glyph->cy))
|
2013-01-12 03:17:45 +04:00
|
|
|
{
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2013-01-12 03:17:45 +04:00
|
|
|
}
|
2011-08-03 11:29:56 +04:00
|
|
|
|
|
|
|
glyph->cb = ((glyph->cx + 7) / 8) * glyph->cy;
|
2012-01-05 05:20:58 +04:00
|
|
|
glyph->cb += ((glyph->cb % 4) > 0) ? 4 - (glyph->cb % 4) : 0;
|
2011-08-03 11:29:56 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, glyph->cb))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2013-01-29 03:42:32 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
glyph->aj = (BYTE*)malloc(glyph->cb);
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
if (!glyph->aj)
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read(s, glyph->aj, glyph->cb);
|
2011-08-03 11:29:56 +04:00
|
|
|
}
|
2012-01-05 05:20:58 +04:00
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
if ((flags & CG_GLYPH_UNICODE_PRESENT) && (cache_glyph_v2->cGlyphs > 0))
|
|
|
|
{
|
|
|
|
cache_glyph_v2->unicodeCharacters = calloc(cache_glyph_v2->cGlyphs, sizeof(WCHAR));
|
2013-05-07 19:41:32 +04:00
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
if (!cache_glyph_v2->unicodeCharacters)
|
|
|
|
goto fail;
|
|
|
|
|
2023-01-24 16:53:36 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, cache_glyph_v2->cGlyphs, sizeof(WCHAR)))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
Stream_Read_UTF16_String(s, cache_glyph_v2->unicodeCharacters, cache_glyph_v2->cGlyphs);
|
|
|
|
}
|
|
|
|
|
|
|
|
return cache_glyph_v2;
|
|
|
|
fail:
|
|
|
|
free_cache_glyph_v2_order(update->context, cache_glyph_v2);
|
|
|
|
return NULL;
|
2013-05-07 19:41:32 +04:00
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
|
|
|
size_t update_approximate_cache_glyph_v2_order(const CACHE_GLYPH_V2_ORDER* cache_glyph_v2,
|
2024-08-29 16:10:21 +03:00
|
|
|
const UINT16* flags)
|
2013-06-10 01:56:57 +04:00
|
|
|
{
|
2022-01-11 18:29:40 +03:00
|
|
|
WINPR_ASSERT(cache_glyph_v2);
|
|
|
|
WINPR_UNUSED(flags);
|
2013-06-10 01:56:57 +04:00
|
|
|
return 8 + cache_glyph_v2->cGlyphs * 32;
|
|
|
|
}
|
2022-01-11 18:29:40 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL update_write_cache_glyph_v2_order(wStream* s, const CACHE_GLYPH_V2_ORDER* cache_glyph_v2,
|
2016-07-21 13:53:44 +03:00
|
|
|
UINT16* flags)
|
2013-05-07 19:41:32 +04:00
|
|
|
{
|
2022-01-11 18:29:40 +03:00
|
|
|
size_t inf = update_approximate_cache_glyph_v2_order(cache_glyph_v2, flags);
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, inf))
|
2015-03-26 19:09:47 +03:00
|
|
|
return FALSE;
|
2013-05-10 00:30:28 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
*flags = (cache_glyph_v2->cacheId & 0x000F) | ((cache_glyph_v2->flags & 0x000F) << 4) |
|
2016-07-21 13:53:44 +03:00
|
|
|
((cache_glyph_v2->cGlyphs & 0x00FF) << 8);
|
2013-05-07 19:41:32 +04:00
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 i = 0; i < cache_glyph_v2->cGlyphs; i++)
|
2013-05-07 19:41:32 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT32 cb = 0;
|
2016-04-05 18:07:45 +03:00
|
|
|
const GLYPH_DATA_V2* glyph = &cache_glyph_v2->glyphData[i];
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, glyph->cacheIndex);
|
2013-05-07 19:41:32 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!update_write_2byte_signed(s, glyph->x) || !update_write_2byte_signed(s, glyph->y) ||
|
2016-07-15 17:23:00 +03:00
|
|
|
!update_write_2byte_unsigned(s, glyph->cx) ||
|
|
|
|
!update_write_2byte_unsigned(s, glyph->cy))
|
2013-05-07 19:41:32 +04:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
cb = ((glyph->cx + 7) / 8) * glyph->cy;
|
|
|
|
cb += ((cb % 4) > 0) ? 4 - (cb % 4) : 0;
|
|
|
|
Stream_Write(s, glyph->aj, cb);
|
2013-05-07 19:41:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (*flags & CG_GLYPH_UNICODE_PRESENT)
|
|
|
|
{
|
2024-08-26 17:33:59 +03:00
|
|
|
Stream_Zero(s, 2ULL * cache_glyph_v2->cGlyphs);
|
2013-01-12 03:17:45 +04:00
|
|
|
}
|
2013-01-29 03:42:32 +04:00
|
|
|
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2020-04-21 11:18:22 +03:00
|
|
|
static BOOL update_decompress_brush(wStream* s, BYTE* output, size_t outSize, BYTE bpp)
|
2011-08-05 21:58:46 +04:00
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE byte = 0;
|
2023-06-07 16:38:21 +03:00
|
|
|
const BYTE* palette = Stream_PointerAs(s, const BYTE) + 16;
|
2020-08-10 13:04:02 +03:00
|
|
|
const size_t bytesPerPixel = ((bpp + 1) / 8);
|
2011-08-05 21:58:46 +04:00
|
|
|
|
2023-01-24 16:53:36 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, 4ULL + bytesPerPixel, 4ULL))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (INT8 y = 7; y >= 0; y--)
|
2011-08-05 21:58:46 +04:00
|
|
|
{
|
2024-01-30 12:25:38 +03:00
|
|
|
for (size_t x = 0; x < 8; x++)
|
2011-08-05 21:58:46 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT32 index = 0;
|
2011-12-30 23:23:47 +04:00
|
|
|
if ((x % 4) == 0)
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2011-08-05 21:58:46 +04:00
|
|
|
|
2011-12-30 23:23:47 +04:00
|
|
|
index = ((byte >> ((3 - (x % 4)) * 2)) & 0x03);
|
2011-08-05 21:58:46 +04:00
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (size_t k = 0; k < bytesPerPixel; k++)
|
2011-08-05 21:58:46 +04:00
|
|
|
{
|
2024-08-26 17:33:59 +03:00
|
|
|
const size_t dstIndex = ((8ULL * y + x) * bytesPerPixel) + k;
|
2020-04-21 11:18:22 +03:00
|
|
|
const size_t srcIndex = (index * bytesPerPixel) + k;
|
|
|
|
if (dstIndex >= outSize)
|
|
|
|
return FALSE;
|
|
|
|
output[dstIndex] = palette[srcIndex];
|
2011-08-05 21:58:46 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-08-05 21:58:46 +04:00
|
|
|
}
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL update_compress_brush(wStream* s, const BYTE* input, BYTE bpp)
|
2013-05-13 01:46:13 +04:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
static CACHE_BRUSH_ORDER* update_read_cache_brush_order(rdpUpdate* update, wStream* s, UINT16 flags)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BOOL rc = 0;
|
|
|
|
BYTE iBitmapFormat = 0;
|
2012-10-09 10:38:39 +04:00
|
|
|
BOOL compressed = FALSE;
|
2022-01-11 18:01:33 +03:00
|
|
|
rdp_update_internal* up = update_cast(update);
|
2018-03-30 11:43:20 +03:00
|
|
|
CACHE_BRUSH_ORDER* cache_brush = calloc(1, sizeof(CACHE_BRUSH_ORDER));
|
|
|
|
|
|
|
|
if (!cache_brush)
|
|
|
|
goto fail;
|
2011-07-26 00:54:15 +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-29 03:42:32 +04:00
|
|
|
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_Read_UINT8(s, cache_brush->index); /* cacheEntry (1 byte) */
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT8(s, iBitmapFormat); /* iBitmapFormat (1 byte) */
|
2018-10-16 18:09:29 +03:00
|
|
|
|
2020-05-26 08:50:55 +03:00
|
|
|
cache_brush->bpp = get_bmf_bpp(iBitmapFormat, &rc);
|
|
|
|
if (!rc)
|
2018-10-16 18:09:29 +03:00
|
|
|
goto fail;
|
|
|
|
|
2020-07-20 16:29:44 +03:00
|
|
|
Stream_Read_UINT8(s, cache_brush->cx); /* cx (1 byte) */
|
|
|
|
Stream_Read_UINT8(s, cache_brush->cy); /* cy (1 byte) */
|
|
|
|
/* according to Section 2.2.2.2.1.2.7 errata the windows implementation sets this filed is set
|
|
|
|
* to 0x00 */
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT8(s, cache_brush->style); /* style (1 byte) */
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_Read_UINT8(s, cache_brush->length); /* iBytes (1 byte) */
|
2011-08-03 11:29:56 +04:00
|
|
|
|
2013-05-13 01:46:13 +04:00
|
|
|
if ((cache_brush->cx == 8) && (cache_brush->cy == 8))
|
2011-08-05 21:58:46 +04:00
|
|
|
{
|
2013-05-13 01:46:13 +04:00
|
|
|
if (cache_brush->bpp == 1)
|
2011-08-05 21:58:46 +04:00
|
|
|
{
|
2013-05-13 01:46:13 +04:00
|
|
|
if (cache_brush->length != 8)
|
2011-08-05 21:58:46 +04:00
|
|
|
{
|
2022-01-11 18:01:33 +03:00
|
|
|
WLog_Print(up->log, WLOG_ERROR, "incompatible 1bpp brush of length:%" PRIu32 "",
|
2018-10-15 14:20:47 +03:00
|
|
|
cache_brush->length);
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2011-08-05 21:58:46 +04:00
|
|
|
}
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2011-08-03 11:29:56 +04:00
|
|
|
|
2020-07-15 19:04:02 +03:00
|
|
|
/* rows are encoded in reverse order */
|
2024-01-30 12:25:38 +03:00
|
|
|
for (int i = 7; i >= 0; i--)
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_Read_UINT8(s, cache_brush->data[i]);
|
2011-08-05 21:58:46 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-13 01:46:13 +04:00
|
|
|
if ((iBitmapFormat == BMF_8BPP) && (cache_brush->length == 20))
|
2012-10-09 10:31:28 +04:00
|
|
|
compressed = TRUE;
|
2013-05-13 01:46:13 +04:00
|
|
|
else if ((iBitmapFormat == BMF_16BPP) && (cache_brush->length == 24))
|
2012-10-09 10:31:28 +04:00
|
|
|
compressed = TRUE;
|
2020-07-15 19:04:02 +03:00
|
|
|
else if ((iBitmapFormat == BMF_24BPP) && (cache_brush->length == 28))
|
|
|
|
compressed = TRUE;
|
2013-05-13 01:46:13 +04:00
|
|
|
else if ((iBitmapFormat == BMF_32BPP) && (cache_brush->length == 32))
|
2012-10-09 10:31:28 +04:00
|
|
|
compressed = TRUE;
|
2011-12-30 23:23:47 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
if (compressed != FALSE)
|
2011-08-05 21:58:46 +04:00
|
|
|
{
|
|
|
|
/* compressed brush */
|
2020-04-21 11:18:22 +03:00
|
|
|
if (!update_decompress_brush(s, cache_brush->data, sizeof(cache_brush->data),
|
|
|
|
cache_brush->bpp))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2011-08-05 21:58:46 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* uncompressed brush */
|
2014-02-11 07:12:13 +04:00
|
|
|
UINT32 scanline = (cache_brush->bpp / 8) * 8;
|
2013-01-29 03:42:32 +04:00
|
|
|
|
2023-01-24 16:53:36 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, scanline, 8ull))
|
2018-03-30 11:43:20 +03:00
|
|
|
goto fail;
|
2011-08-08 05:12:36 +04:00
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (int i = 7; i >= 0; i--)
|
2011-08-08 05:12:36 +04:00
|
|
|
{
|
2024-08-26 17:33:59 +03:00
|
|
|
Stream_Read(s, &cache_brush->data[1LL * i * scanline], scanline);
|
2013-05-13 01:46:13 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
return cache_brush;
|
|
|
|
fail:
|
|
|
|
free_cache_brush_order(update->context, cache_brush);
|
|
|
|
return NULL;
|
2013-05-13 01:46:13 +04:00
|
|
|
}
|
2022-01-11 18:01:33 +03:00
|
|
|
|
2024-08-29 16:10:21 +03:00
|
|
|
size_t update_approximate_cache_brush_order(const CACHE_BRUSH_ORDER* cache_brush,
|
|
|
|
const UINT16* flags)
|
2013-06-10 01:56:57 +04:00
|
|
|
{
|
2022-01-11 18:01:33 +03:00
|
|
|
WINPR_UNUSED(cache_brush);
|
|
|
|
WINPR_UNUSED(flags);
|
|
|
|
|
2013-06-10 01:56:57 +04:00
|
|
|
return 64;
|
|
|
|
}
|
2022-01-11 18:01:33 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL update_write_cache_brush_order(wStream* s, const CACHE_BRUSH_ORDER* cache_brush, UINT16* flags)
|
2013-05-13 01:46:13 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE iBitmapFormat = 0;
|
|
|
|
BOOL rc = 0;
|
2013-05-13 01:46:13 +04:00
|
|
|
BOOL compressed = FALSE;
|
|
|
|
|
2016-07-15 17:23:00 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s,
|
2016-07-21 13:53:44 +03:00
|
|
|
update_approximate_cache_brush_order(cache_brush, flags)))
|
2015-03-26 19:09:47 +03:00
|
|
|
return FALSE;
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2020-05-26 08:50:55 +03:00
|
|
|
iBitmapFormat = get_bpp_bmf(cache_brush->bpp, &rc);
|
|
|
|
if (!rc)
|
|
|
|
return FALSE;
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT8(s, cache_brush->index); /* cacheEntry (1 byte) */
|
|
|
|
Stream_Write_UINT8(s, iBitmapFormat); /* iBitmapFormat (1 byte) */
|
|
|
|
Stream_Write_UINT8(s, cache_brush->cx); /* cx (1 byte) */
|
|
|
|
Stream_Write_UINT8(s, cache_brush->cy); /* cy (1 byte) */
|
|
|
|
Stream_Write_UINT8(s, cache_brush->style); /* style (1 byte) */
|
2013-05-13 01:46:13 +04:00
|
|
|
Stream_Write_UINT8(s, cache_brush->length); /* iBytes (1 byte) */
|
|
|
|
|
|
|
|
if ((cache_brush->cx == 8) && (cache_brush->cy == 8))
|
|
|
|
{
|
|
|
|
if (cache_brush->bpp == 1)
|
|
|
|
{
|
|
|
|
if (cache_brush->length != 8)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG, "incompatible 1bpp brush of length:%" PRIu32 "", cache_brush->length);
|
2013-05-13 01:46:13 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (int i = 7; i >= 0; i--)
|
2013-05-13 01:46:13 +04:00
|
|
|
{
|
|
|
|
Stream_Write_UINT8(s, cache_brush->data[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((iBitmapFormat == BMF_8BPP) && (cache_brush->length == 20))
|
|
|
|
compressed = TRUE;
|
|
|
|
else if ((iBitmapFormat == BMF_16BPP) && (cache_brush->length == 24))
|
|
|
|
compressed = TRUE;
|
|
|
|
else if ((iBitmapFormat == BMF_32BPP) && (cache_brush->length == 32))
|
|
|
|
compressed = TRUE;
|
|
|
|
|
|
|
|
if (compressed != FALSE)
|
|
|
|
{
|
|
|
|
/* compressed brush */
|
|
|
|
if (!update_compress_brush(s, cache_brush->data, cache_brush->bpp))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* uncompressed brush */
|
|
|
|
int scanline = (cache_brush->bpp / 8) * 8;
|
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (int i = 7; i >= 0; i--)
|
2013-05-13 01:46:13 +04:00
|
|
|
{
|
2024-08-26 17:33:59 +03:00
|
|
|
Stream_Write(s, &cache_brush->data[1LL * i * scanline], scanline);
|
2011-08-08 05:12:36 +04:00
|
|
|
}
|
2011-08-05 21:58:46 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-01-29 03:42:32 +04:00
|
|
|
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
|
|
|
/* Alternate Secondary Drawing Orders */
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL
|
|
|
|
update_read_create_offscreen_bitmap_order(wStream* s,
|
|
|
|
CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT16 flags = 0;
|
|
|
|
BOOL deleteListPresent = 0;
|
|
|
|
OFFSCREEN_DELETE_LIST* deleteList = NULL;
|
2011-08-03 00:58:42 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 6))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-12 21:42:53 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, flags); /* flags (2 bytes) */
|
2011-08-04 11:23:53 +04:00
|
|
|
create_offscreen_bitmap->id = flags & 0x7FFF;
|
2012-10-09 10:31:28 +04:00
|
|
|
deleteListPresent = (flags & 0x8000) ? TRUE : FALSE;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, create_offscreen_bitmap->cx); /* cx (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, create_offscreen_bitmap->cy); /* cy (2 bytes) */
|
2012-01-11 22:24:01 +04:00
|
|
|
deleteList = &(create_offscreen_bitmap->deleteList);
|
2013-05-12 21:42:53 +04:00
|
|
|
|
2021-10-12 13:26:22 +03:00
|
|
|
if ((create_offscreen_bitmap->cx == 0) || (create_offscreen_bitmap->cy == 0))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Invalid OFFSCREEN_DELETE_LIST: cx=%" PRIu16 ", cy=%" PRIu16,
|
|
|
|
create_offscreen_bitmap->cx, create_offscreen_bitmap->cy);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-08-03 00:58:42 +04:00
|
|
|
if (deleteListPresent)
|
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-12 21:42:53 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, deleteList->cIndices);
|
2011-08-03 00:58:42 +04:00
|
|
|
|
2012-01-01 00:36:04 +04:00
|
|
|
if (deleteList->cIndices > deleteList->sIndices)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT16* new_indices = NULL;
|
2024-08-26 17:33:59 +03:00
|
|
|
new_indices = (UINT16*)realloc(deleteList->indices, 2ULL * deleteList->cIndices);
|
2015-03-11 08:40:20 +03:00
|
|
|
|
|
|
|
if (!new_indices)
|
|
|
|
return FALSE;
|
|
|
|
|
2012-01-01 00:36:04 +04:00
|
|
|
deleteList->sIndices = deleteList->cIndices;
|
2015-03-11 08:40:20 +03:00
|
|
|
deleteList->indices = new_indices;
|
2012-01-01 00:36:04 +04:00
|
|
|
}
|
2011-08-03 00:58:42 +04:00
|
|
|
|
2023-01-24 16:53:36 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, deleteList->cIndices, 2ull))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 i = 0; i < deleteList->cIndices; i++)
|
2011-08-03 00:58:42 +04:00
|
|
|
{
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, deleteList->indices[i]);
|
2011-08-03 00:58:42 +04:00
|
|
|
}
|
|
|
|
}
|
2012-01-11 22:24:01 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
deleteList->cIndices = 0;
|
|
|
|
}
|
2013-05-12 21:42:53 +04:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
size_t update_approximate_create_offscreen_bitmap_order(
|
2016-07-15 17:23:00 +03:00
|
|
|
const CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap)
|
2013-06-10 01:56:57 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
const OFFSCREEN_DELETE_LIST* deleteList = NULL;
|
2022-01-11 18:01:33 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(create_offscreen_bitmap);
|
|
|
|
|
|
|
|
deleteList = &(create_offscreen_bitmap->deleteList);
|
|
|
|
WINPR_ASSERT(deleteList);
|
|
|
|
|
2013-07-29 18:21:32 +04:00
|
|
|
return 32 + deleteList->cIndices * 2;
|
2013-06-10 01:56:57 +04:00
|
|
|
}
|
2022-01-11 18:01:33 +03:00
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
BOOL update_write_create_offscreen_bitmap_order(
|
2019-11-06 17:24:51 +03:00
|
|
|
wStream* s, const CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap)
|
2013-05-12 21:42:53 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT16 flags = 0;
|
|
|
|
BOOL deleteListPresent = 0;
|
|
|
|
const OFFSCREEN_DELETE_LIST* deleteList = NULL;
|
2013-05-12 21:42:53 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(
|
|
|
|
s, update_approximate_create_offscreen_bitmap_order(create_offscreen_bitmap)))
|
2015-03-26 19:09:47 +03:00
|
|
|
return FALSE;
|
2013-05-12 21:42:53 +04:00
|
|
|
|
2015-03-26 19:09:47 +03:00
|
|
|
deleteList = &(create_offscreen_bitmap->deleteList);
|
2013-05-12 21:42:53 +04:00
|
|
|
flags = create_offscreen_bitmap->id & 0x7FFF;
|
|
|
|
deleteListPresent = (deleteList->cIndices > 0) ? TRUE : FALSE;
|
|
|
|
|
|
|
|
if (deleteListPresent)
|
|
|
|
flags |= 0x8000;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Write_UINT16(s, flags); /* flags (2 bytes) */
|
2013-05-12 21:42:53 +04:00
|
|
|
Stream_Write_UINT16(s, create_offscreen_bitmap->cx); /* cx (2 bytes) */
|
|
|
|
Stream_Write_UINT16(s, create_offscreen_bitmap->cy); /* cy (2 bytes) */
|
|
|
|
|
|
|
|
if (deleteListPresent)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT16(s, deleteList->cIndices);
|
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (size_t i = 0; i < deleteList->cIndices; i++)
|
2013-05-12 21:42:53 +04:00
|
|
|
{
|
|
|
|
Stream_Write_UINT16(s, deleteList->indices[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_read_switch_surface_order(wStream* s, SWITCH_SURFACE_ORDER* switch_surface)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-12 21:42:53 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, switch_surface->bitmapId); /* bitmapId (2 bytes) */
|
2013-05-12 21:42:53 +04:00
|
|
|
return TRUE;
|
|
|
|
}
|
2022-01-11 18:01:33 +03:00
|
|
|
size_t update_approximate_switch_surface_order(const SWITCH_SURFACE_ORDER* switch_surface)
|
2013-06-10 01:56:57 +04:00
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL update_write_switch_surface_order(wStream* s, const SWITCH_SURFACE_ORDER* switch_surface)
|
2013-05-12 21:42:53 +04:00
|
|
|
{
|
2022-01-11 18:01:33 +03:00
|
|
|
size_t inf = update_approximate_switch_surface_order(switch_surface);
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, inf))
|
2015-03-26 19:09:47 +03:00
|
|
|
return FALSE;
|
2013-05-12 21:42:53 +04:00
|
|
|
|
2013-06-10 04:37:58 +04:00
|
|
|
Stream_Write_UINT16(s, switch_surface->bitmapId); /* bitmapId (2 bytes) */
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL
|
|
|
|
update_read_create_nine_grid_bitmap_order(wStream* s,
|
|
|
|
CREATE_NINE_GRID_BITMAP_ORDER* create_nine_grid_bitmap)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
NINE_GRID_BITMAP_INFO* nineGridInfo = NULL;
|
2011-08-03 00:58:42 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 19))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-12 21:42:53 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT8(s, create_nine_grid_bitmap->bitmapBpp); /* bitmapBpp (1 byte) */
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if ((create_nine_grid_bitmap->bitmapBpp < 1) || (create_nine_grid_bitmap->bitmapBpp > 32))
|
2014-05-29 12:12:02 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG, "invalid bpp value %" PRIu32 "", create_nine_grid_bitmap->bitmapBpp);
|
2014-05-29 12:12:02 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
2011-08-03 00:58:42 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT16(s, create_nine_grid_bitmap->bitmapId); /* bitmapId (2 bytes) */
|
2011-08-03 00:58:42 +04:00
|
|
|
nineGridInfo = &(create_nine_grid_bitmap->nineGridInfo);
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT32(s, nineGridInfo->flFlags); /* flFlags (4 bytes) */
|
|
|
|
Stream_Read_UINT16(s, nineGridInfo->ulLeftWidth); /* ulLeftWidth (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, nineGridInfo->ulRightWidth); /* ulRightWidth (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, nineGridInfo->ulTopHeight); /* ulTopHeight (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, nineGridInfo->ulBottomHeight); /* ulBottomHeight (2 bytes) */
|
|
|
|
update_read_colorref(s, &nineGridInfo->crTransparent); /* crTransparent (4 bytes) */
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_read_frame_marker_order(wStream* s, FRAME_MARKER_ORDER* frame_marker)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-06-10 01:56:57 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT32(s, frame_marker->action); /* action (4 bytes) */
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_read_stream_bitmap_first_order(wStream* s,
|
|
|
|
STREAM_BITMAP_FIRST_ORDER* stream_bitmap_first)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 10)) // 8 + 2 at least
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT8(s, stream_bitmap_first->bitmapFlags); /* bitmapFlags (1 byte) */
|
|
|
|
Stream_Read_UINT8(s, stream_bitmap_first->bitmapBpp); /* bitmapBpp (1 byte) */
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if ((stream_bitmap_first->bitmapBpp < 1) || (stream_bitmap_first->bitmapBpp > 32))
|
2014-05-29 12:12:02 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG, "invalid bpp value %" PRIu32 "", stream_bitmap_first->bitmapBpp);
|
2014-05-29 12:12:02 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT16(s, stream_bitmap_first->bitmapType); /* bitmapType (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, stream_bitmap_first->bitmapWidth); /* bitmapWidth (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, stream_bitmap_first->bitmapHeight); /* bitmapHeigth (2 bytes) */
|
2011-08-03 00:58:42 +04:00
|
|
|
|
2013-05-13 01:46:13 +04:00
|
|
|
if (stream_bitmap_first->bitmapFlags & STREAM_BITMAP_V2)
|
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT32(s, stream_bitmap_first->bitmapSize); /* bitmapSize (4 bytes) */
|
2013-05-13 01:46:13 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT16(s, stream_bitmap_first->bitmapSize); /* bitmapSize (2 bytes) */
|
2013-01-12 03:17:45 +04:00
|
|
|
}
|
2011-07-26 00:54:15 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
FIELD_SKIP_BUFFER16(
|
|
|
|
s, stream_bitmap_first->bitmapBlockSize); /* bitmapBlockSize(2 bytes) + bitmapBlock */
|
2013-05-13 01:46:13 +04:00
|
|
|
return TRUE;
|
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_read_stream_bitmap_next_order(wStream* s,
|
|
|
|
STREAM_BITMAP_NEXT_ORDER* stream_bitmap_next)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 5))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT8(s, stream_bitmap_next->bitmapFlags); /* bitmapFlags (1 byte) */
|
|
|
|
Stream_Read_UINT16(s, stream_bitmap_next->bitmapType); /* bitmapType (2 bytes) */
|
|
|
|
FIELD_SKIP_BUFFER16(
|
|
|
|
s, stream_bitmap_next->bitmapBlockSize); /* bitmapBlockSize(2 bytes) + bitmapBlock */
|
2013-05-13 01:46:13 +04:00
|
|
|
return TRUE;
|
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_read_draw_gdiplus_first_order(wStream* s,
|
|
|
|
DRAW_GDIPLUS_FIRST_ORDER* draw_gdiplus_first)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 11))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Seek_UINT8(s); /* pad1Octet (1 byte) */
|
|
|
|
Stream_Read_UINT16(s, draw_gdiplus_first->cbSize); /* cbSize (2 bytes) */
|
|
|
|
Stream_Read_UINT32(s, draw_gdiplus_first->cbTotalSize); /* cbTotalSize (4 bytes) */
|
|
|
|
Stream_Read_UINT32(s, draw_gdiplus_first->cbTotalEmfSize); /* cbTotalEmfSize (4 bytes) */
|
|
|
|
return Stream_SafeSeek(s, draw_gdiplus_first->cbSize); /* emfRecords */
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_read_draw_gdiplus_next_order(wStream* s,
|
|
|
|
DRAW_GDIPLUS_NEXT_ORDER* draw_gdiplus_next)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 3))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Seek_UINT8(s); /* pad1Octet (1 byte) */
|
|
|
|
FIELD_SKIP_BUFFER16(s, draw_gdiplus_next->cbSize); /* cbSize(2 bytes) + emfRecords */
|
2013-05-13 01:46:13 +04:00
|
|
|
return TRUE;
|
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_read_draw_gdiplus_end_order(wStream* s, DRAW_GDIPLUS_END_ORDER* draw_gdiplus_end)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 11))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Seek_UINT8(s); /* pad1Octet (1 byte) */
|
|
|
|
Stream_Read_UINT16(s, draw_gdiplus_end->cbSize); /* cbSize (2 bytes) */
|
|
|
|
Stream_Read_UINT32(s, draw_gdiplus_end->cbTotalSize); /* cbTotalSize (4 bytes) */
|
|
|
|
Stream_Read_UINT32(s, draw_gdiplus_end->cbTotalEmfSize); /* cbTotalEmfSize (4 bytes) */
|
|
|
|
return Stream_SafeSeek(s, draw_gdiplus_end->cbSize); /* emfRecords */
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL
|
|
|
|
update_read_draw_gdiplus_cache_first_order(wStream* s,
|
|
|
|
DRAW_GDIPLUS_CACHE_FIRST_ORDER* draw_gdiplus_cache_first)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 11))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT8(s, draw_gdiplus_cache_first->flags); /* flags (1 byte) */
|
|
|
|
Stream_Read_UINT16(s, draw_gdiplus_cache_first->cacheType); /* cacheType (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, draw_gdiplus_cache_first->cacheIndex); /* cacheIndex (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, draw_gdiplus_cache_first->cbSize); /* cbSize (2 bytes) */
|
|
|
|
Stream_Read_UINT32(s, draw_gdiplus_cache_first->cbTotalSize); /* cbTotalSize (4 bytes) */
|
|
|
|
return Stream_SafeSeek(s, draw_gdiplus_cache_first->cbSize); /* emfRecords */
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL
|
|
|
|
update_read_draw_gdiplus_cache_next_order(wStream* s,
|
|
|
|
DRAW_GDIPLUS_CACHE_NEXT_ORDER* draw_gdiplus_cache_next)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 7))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT8(s, draw_gdiplus_cache_next->flags); /* flags (1 byte) */
|
|
|
|
Stream_Read_UINT16(s, draw_gdiplus_cache_next->cacheType); /* cacheType (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, draw_gdiplus_cache_next->cacheIndex); /* cacheIndex (2 bytes) */
|
|
|
|
FIELD_SKIP_BUFFER16(s, draw_gdiplus_cache_next->cbSize); /* cbSize(2 bytes) + emfRecords */
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2013-05-13 01:46:13 +04:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL
|
|
|
|
update_read_draw_gdiplus_cache_end_order(wStream* s,
|
|
|
|
DRAW_GDIPLUS_CACHE_END_ORDER* draw_gdiplus_cache_end)
|
2011-07-26 00:54:15 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 11))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-13 01:46:13 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
Stream_Read_UINT8(s, draw_gdiplus_cache_end->flags); /* flags (1 byte) */
|
|
|
|
Stream_Read_UINT16(s, draw_gdiplus_cache_end->cacheType); /* cacheType (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, draw_gdiplus_cache_end->cacheIndex); /* cacheIndex (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, draw_gdiplus_cache_end->cbSize); /* cbSize (2 bytes) */
|
|
|
|
Stream_Read_UINT32(s, draw_gdiplus_cache_end->cbTotalSize); /* cbTotalSize (4 bytes) */
|
|
|
|
return Stream_SafeSeek(s, draw_gdiplus_cache_end->cbSize); /* emfRecords */
|
2011-07-26 00:54:15 +04:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_read_field_flags(wStream* s, UINT32* fieldFlags, BYTE flags, BYTE fieldBytes)
|
2011-07-26 07:51:13 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE byte = 0;
|
2011-07-26 07:51:13 +04:00
|
|
|
|
|
|
|
if (flags & ORDER_ZERO_FIELD_BYTE_BIT0)
|
|
|
|
fieldBytes--;
|
|
|
|
|
|
|
|
if (flags & ORDER_ZERO_FIELD_BYTE_BIT1)
|
|
|
|
{
|
2011-08-08 05:12:36 +04:00
|
|
|
if (fieldBytes > 1)
|
2011-07-26 07:51:13 +04:00
|
|
|
fieldBytes -= 2;
|
2011-08-08 05:12:36 +04:00
|
|
|
else
|
|
|
|
fieldBytes = 0;
|
2011-07-26 07:51:13 +04:00
|
|
|
}
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, fieldBytes))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
|
|
|
|
2011-07-26 07:51:13 +04:00
|
|
|
*fieldFlags = 0;
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (int i = 0; i < fieldBytes; i++)
|
2011-07-26 07:51:13 +04:00
|
|
|
{
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, byte);
|
2011-07-26 07:51:13 +04:00
|
|
|
*fieldFlags |= byte << (i * 8);
|
|
|
|
}
|
2013-05-08 01:40:54 +04:00
|
|
|
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-07-26 07:51:13 +04:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL update_write_field_flags(wStream* s, UINT32 fieldFlags, BYTE flags, BYTE fieldBytes)
|
2013-05-07 23:33:52 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE byte = 0;
|
2013-05-07 23:33:52 +04:00
|
|
|
|
2013-05-08 01:40:54 +04:00
|
|
|
if (fieldBytes == 1)
|
2013-05-07 23:33:52 +04:00
|
|
|
{
|
2013-05-08 01:40:54 +04:00
|
|
|
byte = fieldFlags & 0xFF;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-07 23:33:52 +04:00
|
|
|
}
|
2013-05-08 01:40:54 +04:00
|
|
|
else if (fieldBytes == 2)
|
|
|
|
{
|
|
|
|
byte = fieldFlags & 0xFF;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-08 01:40:54 +04:00
|
|
|
byte = (fieldFlags >> 8) & 0xFF;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-08 01:40:54 +04:00
|
|
|
}
|
|
|
|
else if (fieldBytes == 3)
|
|
|
|
{
|
|
|
|
byte = fieldFlags & 0xFF;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-08 01:40:54 +04:00
|
|
|
byte = (fieldFlags >> 8) & 0xFF;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-08 01:40:54 +04:00
|
|
|
byte = (fieldFlags >> 16) & 0xFF;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(s, byte);
|
2013-05-08 01:40:54 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2013-05-07 23:33:52 +04:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2016-04-05 18:07:45 +03:00
|
|
|
static BOOL update_read_bounds(wStream* s, rdpBounds* bounds)
|
2011-07-26 07:51:13 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE flags = 0;
|
2011-07-26 07:51:13 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-10 03:41:32 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, flags); /* field flags */
|
2011-07-26 07:51:13 +04:00
|
|
|
|
2011-08-05 10:19:17 +04:00
|
|
|
if (flags & BOUND_LEFT)
|
2013-01-12 03:17:45 +04:00
|
|
|
{
|
|
|
|
if (!update_read_coord(s, &bounds->left, FALSE))
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-08-05 10:19:17 +04:00
|
|
|
else if (flags & BOUND_DELTA_LEFT)
|
2013-01-12 03:17:45 +04:00
|
|
|
{
|
|
|
|
if (!update_read_coord(s, &bounds->left, TRUE))
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-08-05 10:19:17 +04:00
|
|
|
|
|
|
|
if (flags & BOUND_TOP)
|
2013-01-12 03:17:45 +04:00
|
|
|
{
|
|
|
|
if (!update_read_coord(s, &bounds->top, FALSE))
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-08-05 10:19:17 +04:00
|
|
|
else if (flags & BOUND_DELTA_TOP)
|
2013-01-12 03:17:45 +04:00
|
|
|
{
|
2013-01-19 01:50:25 +04:00
|
|
|
if (!update_read_coord(s, &bounds->top, TRUE))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
2011-08-05 10:19:17 +04:00
|
|
|
|
|
|
|
if (flags & BOUND_RIGHT)
|
2013-01-12 03:17:45 +04:00
|
|
|
{
|
2013-01-19 01:50:25 +04:00
|
|
|
if (!update_read_coord(s, &bounds->right, FALSE))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
2011-08-05 10:19:17 +04:00
|
|
|
else if (flags & BOUND_DELTA_RIGHT)
|
2013-01-12 03:17:45 +04:00
|
|
|
{
|
2013-01-19 01:50:25 +04:00
|
|
|
if (!update_read_coord(s, &bounds->right, TRUE))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
2011-08-05 10:19:17 +04:00
|
|
|
|
|
|
|
if (flags & BOUND_BOTTOM)
|
2013-01-12 03:17:45 +04:00
|
|
|
{
|
2013-01-19 01:50:25 +04:00
|
|
|
if (!update_read_coord(s, &bounds->bottom, FALSE))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
2011-08-05 10:19:17 +04:00
|
|
|
else if (flags & BOUND_DELTA_BOTTOM)
|
2013-01-12 03:17:45 +04:00
|
|
|
{
|
2013-01-19 01:50:25 +04:00
|
|
|
if (!update_read_coord(s, &bounds->bottom, TRUE))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
2013-05-10 03:41:32 +04:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
BOOL update_write_bounds(wStream* s, ORDER_INFO* orderInfo)
|
|
|
|
{
|
|
|
|
if (!(orderInfo->controlFlags & ORDER_BOUNDS))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (orderInfo->controlFlags & ORDER_ZERO_BOUNDS_DELTAS)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
Stream_Write_UINT8(s, orderInfo->boundsFlags); /* field flags */
|
|
|
|
|
|
|
|
if (orderInfo->boundsFlags & BOUND_LEFT)
|
|
|
|
{
|
|
|
|
if (!update_write_coord(s, orderInfo->bounds.left))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else if (orderInfo->boundsFlags & BOUND_DELTA_LEFT)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
if (orderInfo->boundsFlags & BOUND_TOP)
|
|
|
|
{
|
|
|
|
if (!update_write_coord(s, orderInfo->bounds.top))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else if (orderInfo->boundsFlags & BOUND_DELTA_TOP)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
if (orderInfo->boundsFlags & BOUND_RIGHT)
|
|
|
|
{
|
|
|
|
if (!update_write_coord(s, orderInfo->bounds.right))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else if (orderInfo->boundsFlags & BOUND_DELTA_RIGHT)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
if (orderInfo->boundsFlags & BOUND_BOTTOM)
|
|
|
|
{
|
|
|
|
if (!update_write_coord(s, orderInfo->bounds.bottom))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else if (orderInfo->boundsFlags & BOUND_DELTA_BOTTOM)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-01-12 03:17:45 +04:00
|
|
|
return TRUE;
|
2011-07-26 07:51:13 +04:00
|
|
|
}
|
2018-10-16 16:56:17 +03:00
|
|
|
|
|
|
|
static BOOL read_primary_order(wLog* log, const char* orderName, wStream* s,
|
2022-01-11 18:35:56 +03:00
|
|
|
const ORDER_INFO* orderInfo, rdpPrimaryUpdate* primary_pub)
|
2011-07-25 09:45:25 +04:00
|
|
|
{
|
2018-10-15 11:34:47 +03:00
|
|
|
BOOL rc = FALSE;
|
2022-01-11 18:35:56 +03:00
|
|
|
rdp_primary_update_internal* primary = primary_update_cast(primary_pub);
|
2018-10-15 14:10:48 +03:00
|
|
|
|
2022-01-11 18:35:56 +03:00
|
|
|
if (!s || !orderInfo || !orderName)
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2012-02-11 17:30:09 +04:00
|
|
|
|
2018-10-16 16:56:17 +03:00
|
|
|
switch (orderInfo->orderType)
|
2015-05-02 06:26:08 +03:00
|
|
|
{
|
2018-10-16 16:56:17 +03:00
|
|
|
case ORDER_TYPE_DSTBLT:
|
2023-09-04 10:26:06 +03:00
|
|
|
rc = update_read_dstblt_order(orderName, s, orderInfo, &(primary->dstblt));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
2018-10-16 16:56:17 +03:00
|
|
|
case ORDER_TYPE_PATBLT:
|
2023-09-04 10:26:06 +03:00
|
|
|
rc = update_read_patblt_order(orderName, s, orderInfo, &(primary->patblt));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
2011-07-28 22:32:16 +04:00
|
|
|
|
2018-10-16 16:56:17 +03:00
|
|
|
case ORDER_TYPE_SCRBLT:
|
2023-09-04 10:26:06 +03:00
|
|
|
rc = update_read_scrblt_order(orderName, s, orderInfo, &(primary->scrblt));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
2018-10-15 11:34:47 +03:00
|
|
|
|
2018-10-16 16:56:17 +03:00
|
|
|
case ORDER_TYPE_OPAQUE_RECT:
|
2023-09-04 10:26:06 +03:00
|
|
|
rc = update_read_opaque_rect_order(orderName, s, orderInfo, &(primary->opaque_rect));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
2018-10-15 11:34:47 +03:00
|
|
|
|
2018-10-16 16:56:17 +03:00
|
|
|
case ORDER_TYPE_DRAW_NINE_GRID:
|
2023-09-04 10:26:06 +03:00
|
|
|
rc = update_read_draw_nine_grid_order(orderName, s, orderInfo,
|
|
|
|
&(primary->draw_nine_grid));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
2011-07-26 07:51:13 +04:00
|
|
|
|
2018-10-16 16:56:17 +03:00
|
|
|
case ORDER_TYPE_MULTI_DSTBLT:
|
2023-09-04 10:26:06 +03:00
|
|
|
rc = update_read_multi_dstblt_order(orderName, s, orderInfo, &(primary->multi_dstblt));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
2011-07-26 07:51:13 +04:00
|
|
|
|
2018-10-16 16:56:17 +03:00
|
|
|
case ORDER_TYPE_MULTI_PATBLT:
|
2023-09-04 10:26:06 +03:00
|
|
|
rc = update_read_multi_patblt_order(orderName, s, orderInfo, &(primary->multi_patblt));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_MULTI_SCRBLT:
|
2023-09-04 10:26:06 +03:00
|
|
|
rc = update_read_multi_scrblt_order(orderName, s, orderInfo, &(primary->multi_scrblt));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_MULTI_OPAQUE_RECT:
|
2023-09-04 10:26:06 +03:00
|
|
|
rc = update_read_multi_opaque_rect_order(orderName, s, orderInfo,
|
|
|
|
&(primary->multi_opaque_rect));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_MULTI_DRAW_NINE_GRID:
|
2023-09-04 10:26:06 +03:00
|
|
|
rc = update_read_multi_draw_nine_grid_order(orderName, s, orderInfo,
|
2019-11-06 17:24:51 +03:00
|
|
|
&(primary->multi_draw_nine_grid));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_LINE_TO:
|
2023-09-04 10:26:06 +03:00
|
|
|
rc = update_read_line_to_order(orderName, s, orderInfo, &(primary->line_to));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_POLYLINE:
|
2023-09-04 10:26:06 +03:00
|
|
|
rc = update_read_polyline_order(orderName, s, orderInfo, &(primary->polyline));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_MEMBLT:
|
2023-09-04 10:26:06 +03:00
|
|
|
rc = update_read_memblt_order(orderName, s, orderInfo, &(primary->memblt));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_MEM3BLT:
|
2023-09-04 10:26:06 +03:00
|
|
|
rc = update_read_mem3blt_order(orderName, s, orderInfo, &(primary->mem3blt));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_SAVE_BITMAP:
|
2023-09-04 10:26:06 +03:00
|
|
|
rc = update_read_save_bitmap_order(orderName, s, orderInfo, &(primary->save_bitmap));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_GLYPH_INDEX:
|
2023-09-04 10:26:06 +03:00
|
|
|
rc = update_read_glyph_index_order(orderName, s, orderInfo, &(primary->glyph_index));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_FAST_INDEX:
|
2023-09-04 10:26:06 +03:00
|
|
|
rc = update_read_fast_index_order(orderName, s, orderInfo, &(primary->fast_index));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_FAST_GLYPH:
|
2023-09-04 10:26:06 +03:00
|
|
|
rc = update_read_fast_glyph_order(orderName, s, orderInfo, &(primary->fast_glyph));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_POLYGON_SC:
|
2023-09-04 10:26:06 +03:00
|
|
|
rc = update_read_polygon_sc_order(orderName, s, orderInfo, &(primary->polygon_sc));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_POLYGON_CB:
|
2023-09-04 10:26:06 +03:00
|
|
|
rc = update_read_polygon_cb_order(orderName, s, orderInfo, &(primary->polygon_cb));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_ELLIPSE_SC:
|
2023-09-04 10:26:06 +03:00
|
|
|
rc = update_read_ellipse_sc_order(orderName, s, orderInfo, &(primary->ellipse_sc));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_ELLIPSE_CB:
|
2023-09-04 10:26:06 +03:00
|
|
|
rc = update_read_ellipse_cb_order(orderName, s, orderInfo, &(primary->ellipse_cb));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(log, WLOG_WARN, "%s %s not supported, ignoring", primary_order_str,
|
2019-11-06 17:24:51 +03:00
|
|
|
orderName);
|
2018-10-16 16:56:17 +03:00
|
|
|
rc = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!rc)
|
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(log, WLOG_ERROR, "%s %s failed", primary_order_str, orderName);
|
2018-10-16 16:56:17 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE field = 0;
|
2018-10-16 16:56:17 +03:00
|
|
|
BOOL rc = FALSE;
|
2022-01-11 18:01:33 +03:00
|
|
|
rdp_update_internal* up = update_cast(update);
|
2018-10-16 16:56:17 +03:00
|
|
|
rdpContext* context = update->context;
|
2022-01-11 18:35:56 +03:00
|
|
|
rdp_primary_update_internal* primary = primary_update_cast(update->primary);
|
2024-01-23 18:49:54 +03:00
|
|
|
ORDER_INFO* orderInfo = NULL;
|
|
|
|
rdpSettings* settings = NULL;
|
|
|
|
const char* orderName = NULL;
|
|
|
|
BOOL defaultReturn = 0;
|
2021-09-17 09:59:10 +03:00
|
|
|
|
2022-01-11 18:01:33 +03:00
|
|
|
WINPR_ASSERT(s);
|
|
|
|
|
|
|
|
orderInfo = &(primary->order_info);
|
|
|
|
WINPR_ASSERT(orderInfo);
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
|
|
|
|
settings = context->settings;
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
|
2021-09-17 09:59:10 +03:00
|
|
|
defaultReturn = freerdp_settings_get_bool(settings, FreeRDP_DeactivateClientDecoding);
|
2018-10-16 16:56:17 +03:00
|
|
|
|
|
|
|
if (flags & ORDER_TYPE_CHANGE)
|
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2018-10-16 16:56:17 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Read_UINT8(s, orderInfo->orderType); /* orderType (1 byte) */
|
|
|
|
}
|
|
|
|
|
|
|
|
orderName = primary_order_string(orderInfo->orderType);
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s", primary_order_str, orderName);
|
2018-10-16 16:56:17 +03:00
|
|
|
|
2022-01-11 18:01:33 +03:00
|
|
|
if (!check_primary_order_supported(up->log, settings, orderInfo->orderType, orderName))
|
2018-10-17 15:16:16 +03:00
|
|
|
return FALSE;
|
2018-10-16 16:56:17 +03:00
|
|
|
|
2020-05-26 08:28:33 +03:00
|
|
|
field = get_primary_drawing_order_field_bytes(orderInfo->orderType, &rc);
|
|
|
|
if (!rc)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!update_read_field_flags(s, &(orderInfo->fieldFlags), flags, field))
|
2018-10-16 16:56:17 +03:00
|
|
|
{
|
2022-01-11 18:01:33 +03:00
|
|
|
WLog_Print(up->log, WLOG_ERROR, "update_read_field_flags() failed");
|
2018-10-16 16:56:17 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & ORDER_BOUNDS)
|
|
|
|
{
|
|
|
|
if (!(flags & ORDER_ZERO_BOUNDS_DELTAS))
|
|
|
|
{
|
|
|
|
if (!update_read_bounds(s, &orderInfo->bounds))
|
2015-05-02 06:26:08 +03:00
|
|
|
{
|
2022-01-11 18:01:33 +03:00
|
|
|
WLog_Print(up->log, WLOG_ERROR, "update_read_bounds() failed");
|
2018-10-16 16:56:17 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-17 09:59:10 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, update->SetBounds, context, &orderInfo->bounds);
|
2018-10-16 16:56:17 +03:00
|
|
|
|
|
|
|
if (!rc)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
orderInfo->deltaCoordinates = (flags & ORDER_DELTA_COORDINATES) ? TRUE : FALSE;
|
|
|
|
|
2022-01-11 18:35:56 +03:00
|
|
|
if (!read_primary_order(up->log, orderName, s, orderInfo, &primary->common))
|
2018-10-16 16:56:17 +03:00
|
|
|
return FALSE;
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2022-01-11 18:35:56 +03:00
|
|
|
rc = IFCALLRESULT(TRUE, primary->common.OrderInfo, context, orderInfo, orderName);
|
2021-01-26 17:25:06 +03:00
|
|
|
if (!rc)
|
|
|
|
return FALSE;
|
|
|
|
|
2018-10-16 16:56:17 +03:00
|
|
|
switch (orderInfo->orderType)
|
|
|
|
{
|
|
|
|
case ORDER_TYPE_DSTBLT:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s rop=%s [0x%08" PRIx32 "]", primary_order_str,
|
2019-11-06 17:24:51 +03:00
|
|
|
orderName, gdi_rop3_code_string(primary->dstblt.bRop),
|
|
|
|
gdi_rop3_code(primary->dstblt.bRop));
|
2022-01-11 18:35:56 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, primary->common.DstBlt, context, &primary->dstblt);
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
|
|
|
case ORDER_TYPE_PATBLT:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s rop=%s [0x%08" PRIx32 "]", primary_order_str,
|
2019-11-06 17:24:51 +03:00
|
|
|
orderName, gdi_rop3_code_string(primary->patblt.bRop),
|
|
|
|
gdi_rop3_code(primary->patblt.bRop));
|
2022-01-11 18:35:56 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, primary->common.PatBlt, context, &primary->patblt);
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
|
|
|
case ORDER_TYPE_SCRBLT:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s rop=%s [0x%08" PRIx32 "]", primary_order_str,
|
2019-11-06 17:24:51 +03:00
|
|
|
orderName, gdi_rop3_code_string(primary->scrblt.bRop),
|
|
|
|
gdi_rop3_code(primary->scrblt.bRop));
|
2022-01-11 18:35:56 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, primary->common.ScrBlt, context, &primary->scrblt);
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
2011-08-02 20:59:45 +04:00
|
|
|
case ORDER_TYPE_OPAQUE_RECT:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s", primary_order_str, orderName);
|
2022-01-11 18:35:56 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, primary->common.OpaqueRect, context,
|
|
|
|
&primary->opaque_rect);
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-08-02 20:59:45 +04:00
|
|
|
|
2011-07-26 00:54:15 +04:00
|
|
|
case ORDER_TYPE_DRAW_NINE_GRID:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s", primary_order_str, orderName);
|
2022-01-11 18:35:56 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, primary->common.DrawNineGrid, context,
|
2021-09-17 09:59:10 +03:00
|
|
|
&primary->draw_nine_grid);
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
2011-08-02 20:59:45 +04:00
|
|
|
case ORDER_TYPE_MULTI_DSTBLT:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s rop=%s [0x%08" PRIx32 "]", primary_order_str,
|
2019-11-06 17:24:51 +03:00
|
|
|
orderName, gdi_rop3_code_string(primary->multi_dstblt.bRop),
|
|
|
|
gdi_rop3_code(primary->multi_dstblt.bRop));
|
2022-01-11 18:35:56 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, primary->common.MultiDstBlt, context,
|
|
|
|
&primary->multi_dstblt);
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-08-02 20:59:45 +04:00
|
|
|
|
|
|
|
case ORDER_TYPE_MULTI_PATBLT:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s rop=%s [0x%08" PRIx32 "]", primary_order_str,
|
2019-11-06 17:24:51 +03:00
|
|
|
orderName, gdi_rop3_code_string(primary->multi_patblt.bRop),
|
|
|
|
gdi_rop3_code(primary->multi_patblt.bRop));
|
2022-01-11 18:35:56 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, primary->common.MultiPatBlt, context,
|
|
|
|
&primary->multi_patblt);
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-08-02 20:59:45 +04:00
|
|
|
|
|
|
|
case ORDER_TYPE_MULTI_SCRBLT:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s rop=%s [0x%08" PRIx32 "]", primary_order_str,
|
2019-11-06 17:24:51 +03:00
|
|
|
orderName, gdi_rop3_code_string(primary->multi_scrblt.bRop),
|
|
|
|
gdi_rop3_code(primary->multi_scrblt.bRop));
|
2022-01-11 18:35:56 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, primary->common.MultiScrBlt, context,
|
|
|
|
&primary->multi_scrblt);
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-08-02 20:59:45 +04:00
|
|
|
|
|
|
|
case ORDER_TYPE_MULTI_OPAQUE_RECT:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s", primary_order_str, orderName);
|
2022-01-11 18:35:56 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, primary->common.MultiOpaqueRect, context,
|
2021-09-17 09:59:10 +03:00
|
|
|
&primary->multi_opaque_rect);
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-08-02 20:59:45 +04:00
|
|
|
|
2011-07-26 00:54:15 +04:00
|
|
|
case ORDER_TYPE_MULTI_DRAW_NINE_GRID:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s", primary_order_str, orderName);
|
2022-01-11 18:35:56 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, primary->common.MultiDrawNineGrid, context,
|
2019-11-06 17:24:51 +03:00
|
|
|
&primary->multi_draw_nine_grid);
|
|
|
|
}
|
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
2011-07-26 00:54:15 +04:00
|
|
|
case ORDER_TYPE_LINE_TO:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s", primary_order_str, orderName);
|
2022-01-11 18:35:56 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, primary->common.LineTo, context, &primary->line_to);
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
2011-08-02 20:59:45 +04:00
|
|
|
case ORDER_TYPE_POLYLINE:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s", primary_order_str, orderName);
|
2022-01-11 18:35:56 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, primary->common.Polyline, context, &primary->polyline);
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
|
|
|
case ORDER_TYPE_MEMBLT:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s rop=%s [0x%08" PRIx32 "]", primary_order_str,
|
2019-11-06 17:24:51 +03:00
|
|
|
orderName, gdi_rop3_code_string(primary->memblt.bRop),
|
|
|
|
gdi_rop3_code(primary->memblt.bRop));
|
2022-01-11 18:35:56 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, primary->common.MemBlt, context, &primary->memblt);
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
|
|
|
case ORDER_TYPE_MEM3BLT:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s rop=%s [0x%08" PRIx32 "]", primary_order_str,
|
2019-11-06 17:24:51 +03:00
|
|
|
orderName, gdi_rop3_code_string(primary->mem3blt.bRop),
|
|
|
|
gdi_rop3_code(primary->mem3blt.bRop));
|
2022-01-11 18:35:56 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, primary->common.Mem3Blt, context, &primary->mem3blt);
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
2011-08-02 20:59:45 +04:00
|
|
|
case ORDER_TYPE_SAVE_BITMAP:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s", primary_order_str, orderName);
|
2022-01-11 18:35:56 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, primary->common.SaveBitmap, context,
|
|
|
|
&primary->save_bitmap);
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
2011-08-03 11:29:56 +04:00
|
|
|
case ORDER_TYPE_GLYPH_INDEX:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s", primary_order_str, orderName);
|
2022-01-11 18:35:56 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, primary->common.GlyphIndex, context,
|
|
|
|
&primary->glyph_index);
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-08-03 11:29:56 +04:00
|
|
|
|
2011-08-02 20:59:45 +04:00
|
|
|
case ORDER_TYPE_FAST_INDEX:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s", primary_order_str, orderName);
|
2022-01-11 18:35:56 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, primary->common.FastIndex, context,
|
|
|
|
&primary->fast_index);
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
2011-08-02 20:59:45 +04:00
|
|
|
case ORDER_TYPE_FAST_GLYPH:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s", primary_order_str, orderName);
|
2022-01-11 18:35:56 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, primary->common.FastGlyph, context,
|
|
|
|
&primary->fast_glyph);
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
|
|
|
case ORDER_TYPE_POLYGON_SC:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s", primary_order_str, orderName);
|
2022-01-11 18:35:56 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, primary->common.PolygonSC, context,
|
|
|
|
&primary->polygon_sc);
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
|
|
|
case ORDER_TYPE_POLYGON_CB:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s", primary_order_str, orderName);
|
2022-01-11 18:35:56 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, primary->common.PolygonCB, context,
|
|
|
|
&primary->polygon_cb);
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
|
|
|
case ORDER_TYPE_ELLIPSE_SC:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s", primary_order_str, orderName);
|
2022-01-11 18:35:56 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, primary->common.EllipseSC, context,
|
|
|
|
&primary->ellipse_sc);
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
|
|
|
case ORDER_TYPE_ELLIPSE_CB:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s", primary_order_str, orderName);
|
2022-01-11 18:35:56 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, primary->common.EllipseCB, context,
|
|
|
|
&primary->ellipse_cb);
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
|
|
|
default:
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_WARN, "%s %s not supported", primary_order_str, orderName);
|
2011-07-25 09:45:25 +04:00
|
|
|
break;
|
|
|
|
}
|
2011-07-28 22:32:16 +04:00
|
|
|
|
2018-10-15 11:34:47 +03:00
|
|
|
if (!rc)
|
2018-10-15 14:56:19 +03:00
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_ERROR, "%s %s failed", primary_order_str, orderName);
|
2018-10-15 11:34:47 +03:00
|
|
|
return FALSE;
|
2018-10-15 14:56:19 +03:00
|
|
|
}
|
2018-10-15 11:34:47 +03:00
|
|
|
|
2011-07-28 22:32:16 +04:00
|
|
|
if (flags & ORDER_BOUNDS)
|
2011-08-05 10:19:17 +04:00
|
|
|
{
|
2021-09-17 09:59:10 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, update->SetBounds, context, NULL);
|
2011-08-05 10:19:17 +04:00
|
|
|
}
|
2012-02-11 17:30:09 +04:00
|
|
|
|
2018-10-15 11:34:47 +03:00
|
|
|
return rc;
|
2011-07-25 09:45:25 +04:00
|
|
|
}
|
2018-10-16 16:56:17 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_recv_secondary_order(rdpUpdate* update, wStream* s, BYTE flags)
|
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
|
|
|
size_t start = 0;
|
|
|
|
size_t end = 0;
|
|
|
|
size_t pos = 0;
|
|
|
|
size_t diff = 0;
|
|
|
|
BYTE orderType = 0;
|
|
|
|
UINT16 extraFlags = 0;
|
|
|
|
INT16 orderLength = 0;
|
|
|
|
INT32 orderLengthFull = 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;
|
2018-10-16 14:48:43 +03:00
|
|
|
rdpSettings* settings = context->settings;
|
2011-11-22 04:41:49 +04:00
|
|
|
rdpSecondaryUpdate* secondary = update->secondary;
|
2024-01-23 18:49:54 +03:00
|
|
|
const char* name = NULL;
|
|
|
|
BOOL defaultReturn = 0;
|
2021-09-17 09:59:10 +03:00
|
|
|
|
|
|
|
defaultReturn = freerdp_settings_get_bool(settings, FreeRDP_DeactivateClientDecoding);
|
2011-07-25 09:45:25 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 5))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-05-08 01:40:54 +04:00
|
|
|
|
2022-06-23 08:57:38 +03:00
|
|
|
Stream_Read_INT16(s, orderLength); /* orderLength (2 bytes signed) */
|
|
|
|
Stream_Read_UINT16(s, extraFlags); /* extraFlags (2 bytes) */
|
|
|
|
Stream_Read_UINT8(s, orderType); /* orderType (1 byte) */
|
2021-01-13 13:52:24 +03:00
|
|
|
|
|
|
|
start = Stream_GetPosition(s);
|
|
|
|
name = secondary_order_string(orderType);
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s", secondary_order_str, name);
|
2021-01-28 16:08:35 +03:00
|
|
|
rc = IFCALLRESULT(TRUE, secondary->CacheOrderInfo, context, orderLength, extraFlags, orderType,
|
2021-01-26 17:25:06 +03:00
|
|
|
name);
|
|
|
|
if (!rc)
|
|
|
|
return FALSE;
|
|
|
|
|
2020-07-15 19:04:02 +03:00
|
|
|
/*
|
|
|
|
* According to [MS-RDPEGDI] 2.2.2.2.1.2.1.1 the order length must be increased by 13 bytes
|
|
|
|
* including the header. As we already read the header 7 left
|
|
|
|
*/
|
2021-08-23 13:08:35 +03:00
|
|
|
|
|
|
|
/* orderLength might be negative without the adjusted header data.
|
|
|
|
* Account for that here so all further checks operate on the correct value.
|
|
|
|
*/
|
|
|
|
orderLengthFull = orderLength + 7;
|
2022-04-19 15:29:17 +03:00
|
|
|
if (orderLengthFull < 0)
|
2020-03-30 18:22:34 +03:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
WLog_Print(up->log, WLOG_ERROR, "orderLength %" PRIu16 " must be >= 7", orderLength);
|
2020-03-30 18:22:34 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, (size_t)orderLengthFull))
|
|
|
|
return FALSE;
|
|
|
|
|
2022-01-11 18:01:33 +03:00
|
|
|
if (!check_secondary_order_supported(up->log, settings, orderType, name))
|
2018-10-17 15:16:16 +03:00
|
|
|
return FALSE;
|
2018-10-16 16:56:17 +03:00
|
|
|
|
2011-07-25 09:45:25 +04:00
|
|
|
switch (orderType)
|
|
|
|
{
|
|
|
|
case ORDER_TYPE_BITMAP_UNCOMPRESSED:
|
2011-08-02 20:59:45 +04:00
|
|
|
case ORDER_TYPE_CACHE_BITMAP_COMPRESSED:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
|
|
|
const BOOL compressed = (orderType == ORDER_TYPE_CACHE_BITMAP_COMPRESSED);
|
|
|
|
CACHE_BITMAP_ORDER* order =
|
|
|
|
update_read_cache_bitmap_order(update, s, compressed, extraFlags);
|
2011-07-25 09:45:25 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (order)
|
|
|
|
{
|
2021-09-17 09:59:10 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, secondary->CacheBitmap, context, order);
|
2019-11-06 17:24:51 +03:00
|
|
|
free_cache_bitmap_order(context, order);
|
2015-03-19 02:41:29 +03:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
case ORDER_TYPE_BITMAP_UNCOMPRESSED_V2:
|
2011-08-02 20:59:45 +04:00
|
|
|
case ORDER_TYPE_BITMAP_COMPRESSED_V2:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
|
|
|
const BOOL compressed = (orderType == ORDER_TYPE_BITMAP_COMPRESSED_V2);
|
|
|
|
CACHE_BITMAP_V2_ORDER* order =
|
|
|
|
update_read_cache_bitmap_v2_order(update, s, compressed, extraFlags);
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (order)
|
|
|
|
{
|
2021-09-17 09:59:10 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, secondary->CacheBitmapV2, context, order);
|
2019-11-06 17:24:51 +03:00
|
|
|
free_cache_bitmap_v2_order(context, order);
|
2018-03-30 11:43:20 +03:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
2011-08-02 20:59:45 +04:00
|
|
|
case ORDER_TYPE_BITMAP_COMPRESSED_V3:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
|
|
|
CACHE_BITMAP_V3_ORDER* order = update_read_cache_bitmap_v3_order(update, s, extraFlags);
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (order)
|
|
|
|
{
|
2021-09-17 09:59:10 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, secondary->CacheBitmapV3, context, order);
|
2019-11-06 17:24:51 +03:00
|
|
|
free_cache_bitmap_v3_order(context, order);
|
2018-03-30 11:43:20 +03:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
2011-08-02 20:59:45 +04:00
|
|
|
case ORDER_TYPE_CACHE_COLOR_TABLE:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
|
|
|
CACHE_COLOR_TABLE_ORDER* order =
|
|
|
|
update_read_cache_color_table_order(update, s, extraFlags);
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (order)
|
|
|
|
{
|
2021-09-17 09:59:10 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, secondary->CacheColorTable, context, order);
|
2019-11-06 17:24:51 +03:00
|
|
|
free_cache_color_table_order(context, order);
|
2018-03-30 11:43:20 +03:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
2011-08-02 20:59:45 +04:00
|
|
|
case ORDER_TYPE_CACHE_GLYPH:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
|
|
|
switch (settings->GlyphSupportLevel)
|
2011-08-02 20:59:45 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
case GLYPH_SUPPORT_PARTIAL:
|
|
|
|
case GLYPH_SUPPORT_FULL:
|
|
|
|
{
|
|
|
|
CACHE_GLYPH_ORDER* order = update_read_cache_glyph_order(update, s, extraFlags);
|
|
|
|
|
|
|
|
if (order)
|
|
|
|
{
|
2021-09-17 09:59:10 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, secondary->CacheGlyph, context, order);
|
2019-11-06 17:24:51 +03:00
|
|
|
free_cache_glyph_order(context, order);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GLYPH_SUPPORT_ENCODE:
|
2015-05-02 06:26:08 +03:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
CACHE_GLYPH_V2_ORDER* order =
|
|
|
|
update_read_cache_glyph_v2_order(update, s, extraFlags);
|
|
|
|
|
|
|
|
if (order)
|
|
|
|
{
|
2021-09-17 09:59:10 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, secondary->CacheGlyphV2, context, order);
|
2019-11-06 17:24:51 +03:00
|
|
|
free_cache_glyph_v2_order(context, order);
|
|
|
|
}
|
2015-03-19 02:41:29 +03:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GLYPH_SUPPORT_NONE:
|
|
|
|
default:
|
|
|
|
break;
|
2011-08-02 20:59:45 +04:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
2011-08-02 20:59:45 +04:00
|
|
|
case ORDER_TYPE_CACHE_BRUSH:
|
2018-10-16 14:48:43 +03:00
|
|
|
/* [MS-RDPEGDI] 2.2.2.2.1.2.7 Cache Brush (CACHE_BRUSH_ORDER) */
|
2015-05-02 06:26:08 +03:00
|
|
|
{
|
2018-03-30 11:43:20 +03:00
|
|
|
CACHE_BRUSH_ORDER* order = update_read_cache_brush_order(update, s, extraFlags);
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
if (order)
|
|
|
|
{
|
2021-09-17 09:59:10 +03:00
|
|
|
rc = IFCALLRESULT(defaultReturn, secondary->CacheBrush, context, order);
|
2018-03-30 11:43:20 +03:00
|
|
|
free_cache_brush_order(context, order);
|
|
|
|
}
|
|
|
|
}
|
2011-07-25 09:45:25 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_WARN, "%s %s not supported", secondary_order_str, name);
|
2011-07-25 09:45:25 +04:00
|
|
|
break;
|
|
|
|
}
|
2011-07-26 07:51:13 +04:00
|
|
|
|
2018-03-30 11:43:20 +03:00
|
|
|
if (!rc)
|
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_ERROR, "%s %s failed", secondary_order_str, name);
|
2018-03-30 11:43:20 +03:00
|
|
|
}
|
|
|
|
|
2021-08-23 13:08:35 +03:00
|
|
|
end = start + orderLengthFull;
|
2020-07-15 01:08:15 +03:00
|
|
|
pos = Stream_GetPosition(s);
|
|
|
|
if (pos > end)
|
2020-03-31 09:31:24 +03:00
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_WARN, "%s %s: read %" PRIuz "bytes too much", secondary_order_str,
|
2023-08-03 09:17:59 +03:00
|
|
|
name, pos - end);
|
2020-03-31 09:31:24 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
2020-07-15 01:08:15 +03:00
|
|
|
diff = end - pos;
|
2020-03-31 09:31:24 +03:00
|
|
|
if (diff > 0)
|
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s: read %" PRIuz "bytes short, skipping",
|
|
|
|
secondary_order_str, name, diff);
|
2020-05-27 09:10:11 +03:00
|
|
|
if (!Stream_SafeSeek(s, diff))
|
|
|
|
return FALSE;
|
2020-03-31 09:31:24 +03:00
|
|
|
}
|
2018-03-30 11:43:20 +03:00
|
|
|
return rc;
|
2011-07-25 09:45:25 +04:00
|
|
|
}
|
2018-10-16 16:56:17 +03:00
|
|
|
|
2023-08-03 13:02:11 +03:00
|
|
|
static BOOL read_altsec_order(wLog* log, wStream* s, BYTE orderType, rdpAltSecUpdate* altsec_pub)
|
2018-10-16 16:56:17 +03:00
|
|
|
{
|
|
|
|
BOOL rc = FALSE;
|
2022-01-11 18:29:40 +03:00
|
|
|
rdp_altsec_update_internal* altsec = altsec_update_cast(altsec_pub);
|
|
|
|
|
|
|
|
WINPR_ASSERT(s);
|
2018-10-16 16:56:17 +03:00
|
|
|
|
|
|
|
switch (orderType)
|
|
|
|
{
|
|
|
|
case ORDER_TYPE_CREATE_OFFSCREEN_BITMAP:
|
2019-11-06 17:24:51 +03:00
|
|
|
rc = update_read_create_offscreen_bitmap_order(s, &(altsec->create_offscreen_bitmap));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_SWITCH_SURFACE:
|
|
|
|
rc = update_read_switch_surface_order(s, &(altsec->switch_surface));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_CREATE_NINE_GRID_BITMAP:
|
2019-11-06 17:24:51 +03:00
|
|
|
rc = update_read_create_nine_grid_bitmap_order(s, &(altsec->create_nine_grid_bitmap));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_FRAME_MARKER:
|
|
|
|
rc = update_read_frame_marker_order(s, &(altsec->frame_marker));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_STREAM_BITMAP_FIRST:
|
|
|
|
rc = update_read_stream_bitmap_first_order(s, &(altsec->stream_bitmap_first));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_STREAM_BITMAP_NEXT:
|
|
|
|
rc = update_read_stream_bitmap_next_order(s, &(altsec->stream_bitmap_next));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_GDIPLUS_FIRST:
|
|
|
|
rc = update_read_draw_gdiplus_first_order(s, &(altsec->draw_gdiplus_first));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_GDIPLUS_NEXT:
|
|
|
|
rc = update_read_draw_gdiplus_next_order(s, &(altsec->draw_gdiplus_next));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_GDIPLUS_END:
|
|
|
|
rc = update_read_draw_gdiplus_end_order(s, &(altsec->draw_gdiplus_end));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_GDIPLUS_CACHE_FIRST:
|
2019-11-06 17:24:51 +03:00
|
|
|
rc = update_read_draw_gdiplus_cache_first_order(s, &(altsec->draw_gdiplus_cache_first));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_GDIPLUS_CACHE_NEXT:
|
2019-11-06 17:24:51 +03:00
|
|
|
rc = update_read_draw_gdiplus_cache_next_order(s, &(altsec->draw_gdiplus_cache_next));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_GDIPLUS_CACHE_END:
|
2019-11-06 17:24:51 +03:00
|
|
|
rc = update_read_draw_gdiplus_cache_end_order(s, &(altsec->draw_gdiplus_cache_end));
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_WINDOW:
|
|
|
|
/* This order is handled elsewhere. */
|
2018-10-18 13:34:10 +03:00
|
|
|
rc = TRUE;
|
2018-10-16 16:56:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_COMPDESK_FIRST:
|
|
|
|
rc = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-08-03 09:17:59 +03:00
|
|
|
if (!rc)
|
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(log, WLOG_ERROR, "Read %s %s failed", alt_sec_order_str,
|
2023-08-03 09:17:59 +03:00
|
|
|
altsec_order_string(orderType));
|
|
|
|
}
|
|
|
|
|
2018-10-16 16:56:17 +03:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL update_recv_altsec_order(rdpUpdate* update, wStream* s, BYTE flags)
|
2011-07-25 09:45:25 +04:00
|
|
|
{
|
2022-04-28 10:56:11 +03:00
|
|
|
BYTE orderType = flags >> 2; /* orderType is in higher 6 bits of flags field */
|
2018-10-15 14:15:57 +03:00
|
|
|
BOOL rc = FALSE;
|
2022-01-11 18:01:33 +03:00
|
|
|
rdp_update_internal* up = update_cast(update);
|
2011-11-22 04:53:38 +04:00
|
|
|
rdpContext* context = update->context;
|
2018-10-16 14:59:37 +03:00
|
|
|
rdpSettings* settings = context->settings;
|
2022-01-11 18:29:40 +03:00
|
|
|
rdp_altsec_update_internal* altsec = altsec_update_cast(update->altsec);
|
2018-10-15 14:10:48 +03:00
|
|
|
const char* orderName = altsec_order_string(orderType);
|
2022-01-11 18:29:40 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(s);
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_DEBUG, "%s %s", alt_sec_order_str, orderName);
|
2018-10-16 16:56:17 +03:00
|
|
|
|
2022-01-11 18:29:40 +03:00
|
|
|
rc = IFCALLRESULT(TRUE, altsec->common.DrawOrderInfo, context, orderType, orderName);
|
2021-01-26 17:25:06 +03:00
|
|
|
if (!rc)
|
|
|
|
return FALSE;
|
|
|
|
|
2022-01-11 18:01:33 +03:00
|
|
|
if (!check_alt_order_supported(up->log, settings, orderType, orderName))
|
2018-10-17 15:16:16 +03:00
|
|
|
return FALSE;
|
2018-10-16 16:56:17 +03:00
|
|
|
|
2023-08-03 13:02:11 +03:00
|
|
|
if (!read_altsec_order(up->log, s, orderType, &altsec->common))
|
2018-10-16 16:56:17 +03:00
|
|
|
return FALSE;
|
|
|
|
|
2011-07-25 09:45:25 +04:00
|
|
|
switch (orderType)
|
|
|
|
{
|
2011-08-02 20:59:45 +04:00
|
|
|
case ORDER_TYPE_CREATE_OFFSCREEN_BITMAP:
|
2022-01-11 18:29:40 +03:00
|
|
|
IFCALLRET(altsec->common.CreateOffscreenBitmap, rc, context,
|
2018-10-16 16:56:17 +03:00
|
|
|
&(altsec->create_offscreen_bitmap));
|
2011-08-02 20:59:45 +04:00
|
|
|
break;
|
|
|
|
|
2011-07-25 09:45:25 +04:00
|
|
|
case ORDER_TYPE_SWITCH_SURFACE:
|
2022-01-11 18:29:40 +03:00
|
|
|
IFCALLRET(altsec->common.SwitchSurface, rc, context, &(altsec->switch_surface));
|
2011-07-25 09:45:25 +04:00
|
|
|
break;
|
|
|
|
|
2011-08-02 20:59:45 +04:00
|
|
|
case ORDER_TYPE_CREATE_NINE_GRID_BITMAP:
|
2022-01-11 18:29:40 +03:00
|
|
|
IFCALLRET(altsec->common.CreateNineGridBitmap, rc, context,
|
2018-10-16 16:56:17 +03:00
|
|
|
&(altsec->create_nine_grid_bitmap));
|
2011-07-25 09:45:25 +04:00
|
|
|
break;
|
|
|
|
|
2011-08-02 20:59:45 +04:00
|
|
|
case ORDER_TYPE_FRAME_MARKER:
|
2022-01-11 18:29:40 +03:00
|
|
|
IFCALLRET(altsec->common.FrameMarker, rc, context, &(altsec->frame_marker));
|
2011-07-25 09:45:25 +04:00
|
|
|
break;
|
|
|
|
|
2011-08-02 20:59:45 +04:00
|
|
|
case ORDER_TYPE_STREAM_BITMAP_FIRST:
|
2022-01-11 18:29:40 +03:00
|
|
|
IFCALLRET(altsec->common.StreamBitmapFirst, rc, context,
|
|
|
|
&(altsec->stream_bitmap_first));
|
2011-07-25 09:45:25 +04:00
|
|
|
break;
|
|
|
|
|
2011-08-02 20:59:45 +04:00
|
|
|
case ORDER_TYPE_STREAM_BITMAP_NEXT:
|
2022-01-11 18:29:40 +03:00
|
|
|
IFCALLRET(altsec->common.StreamBitmapNext, rc, context, &(altsec->stream_bitmap_next));
|
2011-07-25 09:45:25 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_GDIPLUS_FIRST:
|
2022-01-11 18:29:40 +03:00
|
|
|
IFCALLRET(altsec->common.DrawGdiPlusFirst, rc, context, &(altsec->draw_gdiplus_first));
|
2011-07-25 09:45:25 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_GDIPLUS_NEXT:
|
2022-01-11 18:29:40 +03:00
|
|
|
IFCALLRET(altsec->common.DrawGdiPlusNext, rc, context, &(altsec->draw_gdiplus_next));
|
2011-07-25 09:45:25 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_GDIPLUS_END:
|
2022-01-11 18:29:40 +03:00
|
|
|
IFCALLRET(altsec->common.DrawGdiPlusEnd, rc, context, &(altsec->draw_gdiplus_end));
|
2011-07-25 09:45:25 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_GDIPLUS_CACHE_FIRST:
|
2022-01-11 18:29:40 +03:00
|
|
|
IFCALLRET(altsec->common.DrawGdiPlusCacheFirst, rc, context,
|
2018-10-16 16:56:17 +03:00
|
|
|
&(altsec->draw_gdiplus_cache_first));
|
2011-07-25 09:45:25 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_GDIPLUS_CACHE_NEXT:
|
2022-01-11 18:29:40 +03:00
|
|
|
IFCALLRET(altsec->common.DrawGdiPlusCacheNext, rc, context,
|
2018-10-16 16:56:17 +03:00
|
|
|
&(altsec->draw_gdiplus_cache_next));
|
2011-07-25 09:45:25 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_GDIPLUS_CACHE_END:
|
2022-01-11 18:29:40 +03:00
|
|
|
IFCALLRET(altsec->common.DrawGdiPlusCacheEnd, rc, context,
|
|
|
|
&(altsec->draw_gdiplus_cache_end));
|
2011-07-25 09:45:25 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_TYPE_WINDOW:
|
2018-10-15 14:56:19 +03:00
|
|
|
rc = update_recv_altsec_window_order(update, s);
|
|
|
|
break;
|
2011-07-25 09:45:25 +04:00
|
|
|
|
|
|
|
case ORDER_TYPE_COMPDESK_FIRST:
|
2018-10-15 14:15:57 +03:00
|
|
|
rc = TRUE;
|
2011-07-25 09:45:25 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2016-07-15 17:23:00 +03:00
|
|
|
|
2018-10-15 14:56:19 +03:00
|
|
|
if (!rc)
|
|
|
|
{
|
2023-08-03 13:02:11 +03:00
|
|
|
WLog_Print(up->log, WLOG_ERROR, "%s %s failed", alt_sec_order_str, orderName);
|
2018-10-15 14:56:19 +03:00
|
|
|
}
|
|
|
|
|
2018-10-15 14:15:57 +03:00
|
|
|
return rc;
|
2011-07-25 09:45:25 +04:00
|
|
|
}
|
2013-03-21 23:19:33 +04:00
|
|
|
BOOL update_recv_order(rdpUpdate* update, wStream* s)
|
2011-07-25 09:45:25 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BOOL rc = 0;
|
|
|
|
BYTE controlFlags = 0;
|
2022-01-11 18:01:33 +03:00
|
|
|
rdp_update_internal* up = update_cast(update);
|
2011-07-25 09:45:25 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-01-12 03:17:45 +04:00
|
|
|
return FALSE;
|
2013-01-19 01:50:25 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, controlFlags); /* controlFlags (1 byte) */
|
2011-07-25 09:45:25 +04:00
|
|
|
|
2011-08-05 00:22:15 +04:00
|
|
|
if (!(controlFlags & ORDER_STANDARD))
|
2018-10-15 14:56:19 +03:00
|
|
|
rc = update_recv_altsec_order(update, s, controlFlags);
|
2011-08-05 00:22:15 +04:00
|
|
|
else if (controlFlags & ORDER_SECONDARY)
|
2018-10-15 14:56:19 +03:00
|
|
|
rc = update_recv_secondary_order(update, s, controlFlags);
|
2011-08-05 00:22:15 +04:00
|
|
|
else
|
2018-10-15 14:56:19 +03:00
|
|
|
rc = update_recv_primary_order(update, s, controlFlags);
|
2011-07-27 00:58:10 +04:00
|
|
|
|
2018-10-15 14:56:19 +03:00
|
|
|
if (!rc)
|
2022-01-11 18:01:33 +03:00
|
|
|
WLog_Print(up->log, WLOG_ERROR, "order flags %02" PRIx8 " failed", controlFlags);
|
2018-10-15 14:56:19 +03:00
|
|
|
|
|
|
|
return rc;
|
2023-08-03 13:02:11 +03:00
|
|
|
}
|