22 #include <freerdp/config.h>
26 #include <winpr/wtypes.h>
27 #include <winpr/crt.h>
28 #include <winpr/assert.h>
29 #include <winpr/cast.h>
31 #include <freerdp/api.h>
32 #include <freerdp/log.h>
33 #include <freerdp/graphics.h>
34 #include <freerdp/codec/bitmap.h>
35 #include <freerdp/gdi/gdi.h>
40 #include "../cache/glyph.h"
41 #include "../cache/bitmap.h"
42 #include "../cache/brush.h"
43 #include "../cache/cache.h"
45 #define TAG FREERDP_TAG("core.orders")
49 #define get_checked_uint16(value) get_checked_uint16_int((value), __FILE__, __func__, __LINE__)
50 static inline UINT16 get_checked_uint16_int(UINT32 value,
const char* file,
const char* fkt,
53 WINPR_ASSERT_AT(value <= UINT16_MAX, file, fkt, line);
57 #define get_checked_uint8(value) get_checked_uint8_int((value), __FILE__, __func__, __LINE__)
58 static inline UINT8 get_checked_uint8_int(UINT32 value,
const char* file,
const char* fkt,
61 WINPR_ASSERT_AT(value <= UINT8_MAX, file, fkt, line);
65 #define get_checked_int16(value) get_checked_int16_int((value), __FILE__, __func__, __LINE__)
66 static inline INT16 get_checked_int16_int(INT32 value,
const char* file,
const char* fkt,
69 WINPR_ASSERT_AT(value <= INT16_MAX, file, fkt, line);
70 WINPR_ASSERT_AT(value >= INT16_MIN, file, fkt, line);
74 #define gdi_rob3_code_string_checked(value) \
75 gdi_rob3_code_string_checked_int((value), __FILE__, __func__, __LINE__)
76 static inline const char* gdi_rob3_code_string_checked_int(UINT32 rob,
const char* file,
77 const char* fkt,
size_t line)
79 WINPR_ASSERT_AT((rob) <= UINT8_MAX, file, fkt, line);
80 return gdi_rop3_code_string((BYTE)rob);
83 #define gdi_rop3_code_checked(value) \
84 gdi_rop3_code_checked_int((value), __FILE__, __func__, __LINE__)
85 static inline DWORD gdi_rop3_code_checked_int(UINT32 code,
const char* file,
const char* fkt,
88 WINPR_ASSERT_AT(code <= UINT8_MAX, file, fkt, line);
89 return gdi_rop3_code((UINT8)code);
92 static const char primary_order_str[] =
"Primary Drawing Order";
93 static const char secondary_order_str[] =
"Secondary Drawing Order";
94 static const char alt_sec_order_str[] =
"Alternate Secondary Drawing Order";
96 BYTE get_primary_drawing_order_field_bytes(UINT32 orderType, BOOL* pValid)
103 return DSTBLT_ORDER_FIELD_BYTES;
105 return PATBLT_ORDER_FIELD_BYTES;
107 return SCRBLT_ORDER_FIELD_BYTES;
117 return DRAW_NINE_GRID_ORDER_FIELD_BYTES;
119 return MULTI_DRAW_NINE_GRID_ORDER_FIELD_BYTES;
121 return LINE_TO_ORDER_FIELD_BYTES;
123 return OPAQUE_RECT_ORDER_FIELD_BYTES;
125 return SAVE_BITMAP_ORDER_FIELD_BYTES;
129 return MEMBLT_ORDER_FIELD_BYTES;
131 return MEM3BLT_ORDER_FIELD_BYTES;
133 return MULTI_DSTBLT_ORDER_FIELD_BYTES;
135 return MULTI_PATBLT_ORDER_FIELD_BYTES;
137 return MULTI_SCRBLT_ORDER_FIELD_BYTES;
139 return MULTI_OPAQUE_RECT_ORDER_FIELD_BYTES;
141 return FAST_INDEX_ORDER_FIELD_BYTES;
143 return POLYGON_SC_ORDER_FIELD_BYTES;
145 return POLYGON_CB_ORDER_FIELD_BYTES;
147 return POLYLINE_ORDER_FIELD_BYTES;
151 return FAST_GLYPH_ORDER_FIELD_BYTES;
153 return ELLIPSE_SC_ORDER_FIELD_BYTES;
155 return ELLIPSE_CB_ORDER_FIELD_BYTES;
157 return GLYPH_INDEX_ORDER_FIELD_BYTES;
161 WLog_WARN(TAG,
"Invalid orderType 0x%08X received", orderType);
166 static BYTE get_cbr2_bpp(UINT32 bpp, BOOL* pValid)
181 WLog_WARN(TAG,
"Invalid bpp %" PRIu32, bpp);
188 static BYTE get_bmf_bpp(UINT32 bmf, BOOL* pValid)
193 switch (bmf & (uint32_t)(~CACHED_BRUSH))
206 WLog_WARN(TAG,
"Invalid bmf %" PRIu32, bmf);
212 static BYTE get_bpp_bmf(UINT32 bpp, BOOL* pValid)
229 WLog_WARN(TAG,
"Invalid color depth %" PRIu32, bpp);
236 static BOOL check_order_activated(wLog* log, rdpSettings* settings,
const char* orderName,
237 BOOL condition,
const char* extendedMessage)
241 if (settings->AllowUnanouncedOrdersFromServer)
243 WLog_Print(log, WLOG_WARN,
244 "%s - SERVER BUG: The support for this feature was not announced!",
247 WLog_Print(log, WLOG_WARN,
"%s", extendedMessage);
252 WLog_Print(log, WLOG_ERROR,
253 "%s - SERVER BUG: The support for this feature was not announced! Use "
254 "/relax-order-checks to ignore",
257 WLog_Print(log, WLOG_WARN,
"%s", extendedMessage);
265 static BOOL check_alt_order_supported(wLog* log, rdpSettings* settings, BYTE orderType,
266 const char* orderName)
268 const char* extendedMessage = NULL;
269 BOOL condition = FALSE;
273 case ORDER_TYPE_CREATE_OFFSCREEN_BITMAP:
274 case ORDER_TYPE_SWITCH_SURFACE:
275 condition = settings->OffscreenSupportLevel != 0;
276 extendedMessage =
"Adding /cache:offscreen might mitigate";
279 case ORDER_TYPE_CREATE_NINE_GRID_BITMAP:
280 condition = settings->DrawNineGridEnabled;
283 case ORDER_TYPE_FRAME_MARKER:
284 condition = settings->FrameMarkerCommandEnabled;
287 case ORDER_TYPE_GDIPLUS_FIRST:
288 case ORDER_TYPE_GDIPLUS_NEXT:
289 case ORDER_TYPE_GDIPLUS_END:
290 case ORDER_TYPE_GDIPLUS_CACHE_FIRST:
291 case ORDER_TYPE_GDIPLUS_CACHE_NEXT:
292 case ORDER_TYPE_GDIPLUS_CACHE_END:
293 condition = settings->DrawGdiPlusCacheEnabled;
296 case ORDER_TYPE_WINDOW:
297 condition = settings->RemoteWndSupportLevel != WINDOW_LEVEL_NOT_SUPPORTED;
300 case ORDER_TYPE_STREAM_BITMAP_FIRST:
301 case ORDER_TYPE_STREAM_BITMAP_NEXT:
302 case ORDER_TYPE_COMPDESK_FIRST:
307 WLog_Print(log, WLOG_WARN,
"%s - %s UNKNOWN", orderName, alt_sec_order_str);
312 return check_order_activated(log, settings, orderName, condition, extendedMessage);
315 static BOOL check_secondary_order_supported(wLog* log, rdpSettings* settings, BYTE orderType,
316 const char* orderName)
318 const char* extendedMessage = NULL;
319 BOOL condition = FALSE;
323 case ORDER_TYPE_BITMAP_UNCOMPRESSED:
324 case ORDER_TYPE_CACHE_BITMAP_COMPRESSED:
325 condition = settings->BitmapCacheEnabled;
326 extendedMessage =
"Adding /cache:bitmap might mitigate";
329 case ORDER_TYPE_BITMAP_UNCOMPRESSED_V2:
330 case ORDER_TYPE_BITMAP_COMPRESSED_V2:
331 condition = settings->BitmapCacheEnabled;
332 extendedMessage =
"Adding /cache:bitmap might mitigate";
335 case ORDER_TYPE_BITMAP_COMPRESSED_V3:
336 condition = settings->BitmapCacheV3Enabled;
337 extendedMessage =
"Adding /cache:bitmap might mitigate";
340 case ORDER_TYPE_CACHE_COLOR_TABLE:
341 condition = (settings->OrderSupport[NEG_MEMBLT_INDEX] ||
342 settings->OrderSupport[NEG_MEM3BLT_INDEX]);
345 case ORDER_TYPE_CACHE_GLYPH:
347 switch (settings->GlyphSupportLevel)
349 case GLYPH_SUPPORT_PARTIAL:
350 case GLYPH_SUPPORT_FULL:
351 case GLYPH_SUPPORT_ENCODE:
355 case GLYPH_SUPPORT_NONE:
363 case ORDER_TYPE_CACHE_BRUSH:
368 WLog_Print(log, WLOG_WARN,
"SECONDARY ORDER %s not supported", orderName);
372 return check_order_activated(log, settings, orderName, condition, extendedMessage);
375 static BOOL check_primary_order_supported(wLog* log, rdpSettings* settings, UINT32 orderType,
376 const char* orderName)
378 const char* extendedMessage = NULL;
379 BOOL condition = FALSE;
383 case ORDER_TYPE_DSTBLT:
384 condition = settings->OrderSupport[NEG_DSTBLT_INDEX];
387 case ORDER_TYPE_SCRBLT:
388 condition = settings->OrderSupport[NEG_SCRBLT_INDEX];
391 case ORDER_TYPE_DRAW_NINE_GRID:
392 condition = settings->OrderSupport[NEG_DRAWNINEGRID_INDEX];
395 case ORDER_TYPE_MULTI_DRAW_NINE_GRID:
396 condition = settings->OrderSupport[NEG_MULTI_DRAWNINEGRID_INDEX];
399 case ORDER_TYPE_LINE_TO:
400 condition = settings->OrderSupport[NEG_LINETO_INDEX];
405 case ORDER_TYPE_PATBLT:
406 case ORDER_TYPE_OPAQUE_RECT:
407 condition = settings->OrderSupport[NEG_OPAQUE_RECT_INDEX] ||
408 settings->OrderSupport[NEG_PATBLT_INDEX];
411 case ORDER_TYPE_SAVE_BITMAP:
412 condition = settings->OrderSupport[NEG_SAVEBITMAP_INDEX];
415 case ORDER_TYPE_MEMBLT:
416 condition = settings->OrderSupport[NEG_MEMBLT_INDEX];
419 case ORDER_TYPE_MEM3BLT:
420 condition = settings->OrderSupport[NEG_MEM3BLT_INDEX];
423 case ORDER_TYPE_MULTI_DSTBLT:
424 condition = settings->OrderSupport[NEG_MULTIDSTBLT_INDEX];
427 case ORDER_TYPE_MULTI_PATBLT:
428 condition = settings->OrderSupport[NEG_MULTIPATBLT_INDEX];
431 case ORDER_TYPE_MULTI_SCRBLT:
432 condition = settings->OrderSupport[NEG_MULTIDSTBLT_INDEX];
435 case ORDER_TYPE_MULTI_OPAQUE_RECT:
436 condition = settings->OrderSupport[NEG_MULTIOPAQUERECT_INDEX];
439 case ORDER_TYPE_FAST_INDEX:
440 condition = settings->OrderSupport[NEG_FAST_INDEX_INDEX];
443 case ORDER_TYPE_POLYGON_SC:
444 condition = settings->OrderSupport[NEG_POLYGON_SC_INDEX];
447 case ORDER_TYPE_POLYGON_CB:
448 condition = settings->OrderSupport[NEG_POLYGON_CB_INDEX];
451 case ORDER_TYPE_POLYLINE:
452 condition = settings->OrderSupport[NEG_POLYLINE_INDEX];
455 case ORDER_TYPE_FAST_GLYPH:
456 condition = settings->OrderSupport[NEG_FAST_GLYPH_INDEX];
459 case ORDER_TYPE_ELLIPSE_SC:
460 condition = settings->OrderSupport[NEG_ELLIPSE_SC_INDEX];
463 case ORDER_TYPE_ELLIPSE_CB:
464 condition = settings->OrderSupport[NEG_ELLIPSE_CB_INDEX];
467 case ORDER_TYPE_GLYPH_INDEX:
468 condition = settings->OrderSupport[NEG_GLYPH_INDEX_INDEX];
472 WLog_Print(log, WLOG_ERROR,
"%s %s not supported", orderName, primary_order_str);
476 return check_order_activated(log, settings, orderName, condition, extendedMessage);
479 WINPR_PRAGMA_DIAG_PUSH
480 WINPR_PRAGMA_DIAG_IGNORED_FORMAT_NONLITERAL
481 static const char* primary_order_string(UINT32 orderType)
483 const char* orders[] = {
"[0x%02" PRIx8
"] DstBlt",
484 "[0x%02" PRIx8
"] PatBlt",
485 "[0x%02" PRIx8
"] ScrBlt",
486 "[0x%02" PRIx8
"] UNUSED",
487 "[0x%02" PRIx8
"] UNUSED",
488 "[0x%02" PRIx8
"] UNUSED",
489 "[0x%02" PRIx8
"] UNUSED",
490 "[0x%02" PRIx8
"] DrawNineGrid",
491 "[0x%02" PRIx8
"] MultiDrawNineGrid",
492 "[0x%02" PRIx8
"] LineTo",
493 "[0x%02" PRIx8
"] OpaqueRect",
494 "[0x%02" PRIx8
"] SaveBitmap",
495 "[0x%02" PRIx8
"] UNUSED",
496 "[0x%02" PRIx8
"] MemBlt",
497 "[0x%02" PRIx8
"] Mem3Blt",
498 "[0x%02" PRIx8
"] MultiDstBlt",
499 "[0x%02" PRIx8
"] MultiPatBlt",
500 "[0x%02" PRIx8
"] MultiScrBlt",
501 "[0x%02" PRIx8
"] MultiOpaqueRect",
502 "[0x%02" PRIx8
"] FastIndex",
503 "[0x%02" PRIx8
"] PolygonSC",
504 "[0x%02" PRIx8
"] PolygonCB",
505 "[0x%02" PRIx8
"] Polyline",
506 "[0x%02" PRIx8
"] UNUSED",
507 "[0x%02" PRIx8
"] FastGlyph",
508 "[0x%02" PRIx8
"] EllipseSC",
509 "[0x%02" PRIx8
"] EllipseCB",
510 "[0x%02" PRIx8
"] GlyphIndex" };
511 const char* fmt =
"[0x%02" PRIx8
"] UNKNOWN";
512 static char buffer[64] = { 0 };
514 if (orderType < ARRAYSIZE(orders))
515 fmt = orders[orderType];
517 (void)sprintf_s(buffer, ARRAYSIZE(buffer), fmt, orderType);
520 static const char* secondary_order_string(UINT32 orderType)
522 const char* orders[] = {
"[0x%02" PRIx8
"] Cache Bitmap",
523 "[0x%02" PRIx8
"] Cache Color Table",
524 "[0x%02" PRIx8
"] Cache Bitmap (Compressed)",
525 "[0x%02" PRIx8
"] Cache Glyph",
526 "[0x%02" PRIx8
"] Cache Bitmap V2",
527 "[0x%02" PRIx8
"] Cache Bitmap V2 (Compressed)",
528 "[0x%02" PRIx8
"] UNUSED",
529 "[0x%02" PRIx8
"] Cache Brush",
530 "[0x%02" PRIx8
"] Cache Bitmap V3" };
531 const char* fmt =
"[0x%02" PRIx8
"] UNKNOWN";
532 static char buffer[64] = { 0 };
534 if (orderType < ARRAYSIZE(orders))
535 fmt = orders[orderType];
537 (void)sprintf_s(buffer, ARRAYSIZE(buffer), fmt, orderType);
540 static const char* altsec_order_string(BYTE orderType)
542 const char* orders[] = {
543 "[0x%02" PRIx8
"] Switch Surface",
"[0x%02" PRIx8
"] Create Offscreen Bitmap",
544 "[0x%02" PRIx8
"] Stream Bitmap First",
"[0x%02" PRIx8
"] Stream Bitmap Next",
545 "[0x%02" PRIx8
"] Create NineGrid Bitmap",
"[0x%02" PRIx8
"] Draw GDI+ First",
546 "[0x%02" PRIx8
"] Draw GDI+ Next",
"[0x%02" PRIx8
"] Draw GDI+ End",
547 "[0x%02" PRIx8
"] Draw GDI+ Cache First",
"[0x%02" PRIx8
"] Draw GDI+ Cache Next",
548 "[0x%02" PRIx8
"] Draw GDI+ Cache End",
"[0x%02" PRIx8
"] Windowing",
549 "[0x%02" PRIx8
"] Desktop Composition",
"[0x%02" PRIx8
"] Frame Marker"
551 const char* fmt =
"[0x%02" PRIx8
"] UNKNOWN";
552 static char buffer[64] = { 0 };
554 if (orderType < ARRAYSIZE(orders))
555 fmt = orders[orderType];
557 (void)sprintf_s(buffer, ARRAYSIZE(buffer), fmt, orderType);
560 WINPR_PRAGMA_DIAG_POP
562 static INLINE BOOL update_read_coord(
wStream* s, INT32* coord, BOOL delta)
569 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
572 Stream_Read_INT8(s, lsi8);
577 if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
580 Stream_Read_INT16(s, lsi16);
587 #define update_write_coord(s, coord) \
588 update_write_coord_int((s), (coord), #coord, __FILE__, __func__, __LINE__)
590 static INLINE BOOL update_write_coord_int(
wStream* s, INT32 coord,
const char* name,
591 const char* file,
const char* fkt,
size_t line)
593 if ((coord < 0) || (coord > UINT16_MAX))
595 const DWORD level = WLOG_WARN;
596 wLog* log = WLog_Get(TAG);
597 if (WLog_IsLevelActive(log, level))
599 WLog_PrintMessage(log, WLOG_MESSAGE_TEXT, level, line, file, fkt,
600 "[%s] 0 <= %" PRId32
" <= %" PRIu16, name, coord, UINT16_MAX);
605 Stream_Write_UINT16(s, (UINT16)coord);
608 static INLINE BOOL update_read_color(
wStream* s, UINT32* color)
612 if (!Stream_CheckAndLogRequiredLength(TAG, s, 3))
616 Stream_Read_UINT8(s,
byte);
617 *color = (UINT32)
byte;
618 Stream_Read_UINT8(s,
byte);
619 *color |= ((UINT32)
byte << 8) & 0xFF00;
620 Stream_Read_UINT8(s,
byte);
621 *color |= ((UINT32)
byte << 16) & 0xFF0000;
624 static INLINE BOOL update_write_color(
wStream* s, UINT32 color)
627 byte = (color & 0xFF);
628 Stream_Write_UINT8(s,
byte);
629 byte = ((color >> 8) & 0xFF);
630 Stream_Write_UINT8(s,
byte);
631 byte = ((color >> 16) & 0xFF);
632 Stream_Write_UINT8(s,
byte);
635 static INLINE BOOL update_read_colorref(
wStream* s, UINT32* color)
639 if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
643 Stream_Read_UINT8(s,
byte);
645 Stream_Read_UINT8(s,
byte);
646 *color |= ((UINT32)
byte << 8);
647 Stream_Read_UINT8(s,
byte);
648 *color |= ((UINT32)
byte << 16);
649 Stream_Seek_UINT8(s);
652 static INLINE BOOL update_read_color_quad(
wStream* s, UINT32* color)
654 return update_read_colorref(s, color);
656 static INLINE
void update_write_color_quad(
wStream* s, UINT32 color)
659 byte = (color >> 16) & 0xFF;
660 Stream_Write_UINT8(s,
byte);
661 byte = (color >> 8) & 0xFF;
662 Stream_Write_UINT8(s,
byte);
664 Stream_Write_UINT8(s,
byte);
666 static INLINE BOOL update_read_2byte_unsigned(
wStream* s, UINT32* value)
670 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
673 Stream_Read_UINT8(s,
byte);
677 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
680 *value = ((
byte & 0x7F) << 8) & 0xFFFF;
681 Stream_Read_UINT8(s,
byte);
686 *value = (
byte & 0x7F);
691 static INLINE BOOL update_write_2byte_unsigned(
wStream* s, UINT32 value)
700 byte = ((value & 0x7F00) >> 8);
701 Stream_Write_UINT8(s,
byte | 0x80);
702 byte = (value & 0xFF);
703 Stream_Write_UINT8(s,
byte);
707 byte = (value & 0x7F);
708 Stream_Write_UINT8(s,
byte);
713 static INLINE BOOL update_read_2byte_signed(
wStream* s, INT32* value)
718 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
721 Stream_Read_UINT8(s,
byte);
722 negative = (
byte & 0x40) ? TRUE : FALSE;
723 *value = (
byte & 0x3F);
727 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
730 Stream_Read_UINT8(s,
byte);
731 *value = (*value << 8) |
byte;
739 static INLINE BOOL update_write_2byte_signed(
wStream* s, INT32 value)
742 BOOL negative = FALSE;
755 byte = ((value & 0x3F00) >> 8);
760 Stream_Write_UINT8(s,
byte | 0x80);
761 byte = (value & 0xFF);
762 Stream_Write_UINT8(s,
byte);
766 byte = (value & 0x3F);
771 Stream_Write_UINT8(s,
byte);
776 static INLINE BOOL update_read_4byte_unsigned(
wStream* s, UINT32* value)
778 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
781 const UINT32
byte = Stream_Get_UINT8(s);
782 const BYTE count = WINPR_ASSERTING_INT_CAST(uint8_t, (
byte & 0xC0) >> 6);
784 if (!Stream_CheckAndLogRequiredLength(TAG, s, count))
790 *value = (
byte & 0x3F);
794 *value = ((
byte & 0x3F) << 8) & 0xFFFF;
795 *value |= Stream_Get_UINT8(s);
799 *value = ((
byte & 0x3F) << 16) & 0xFFFFFF;
800 *value |= ((Stream_Get_UINT8(s) << 8)) & 0xFFFF;
801 *value |= Stream_Get_UINT8(s);
805 *value = ((
byte & 0x3F) << 24) & 0xFF000000;
806 *value |= ((Stream_Get_UINT8(s) << 16)) & 0xFF0000;
807 *value |= ((Stream_Get_UINT8(s) << 8)) & 0xFF00;
808 *value |= Stream_Get_UINT8(s);
817 static INLINE BOOL update_write_4byte_unsigned(
wStream* s, UINT32 value)
823 Stream_Write_UINT8(s, (UINT8)value);
825 else if (value <= 0x3FFF)
827 byte = (value >> 8) & 0x3F;
828 Stream_Write_UINT8(s,
byte | 0x40);
829 byte = (value & 0xFF);
830 Stream_Write_UINT8(s,
byte);
832 else if (value <= 0x3FFFFF)
834 byte = (value >> 16) & 0x3F;
835 Stream_Write_UINT8(s,
byte | 0x80);
836 byte = (value >> 8) & 0xFF;
837 Stream_Write_UINT8(s,
byte);
838 byte = (value & 0xFF);
839 Stream_Write_UINT8(s,
byte);
841 else if (value <= 0x3FFFFFFF)
843 byte = (value >> 24) & 0x3F;
844 Stream_Write_UINT8(s,
byte | 0xC0);
845 byte = (value >> 16) & 0xFF;
846 Stream_Write_UINT8(s,
byte);
847 byte = (value >> 8) & 0xFF;
848 Stream_Write_UINT8(s,
byte);
849 byte = (value & 0xFF);
850 Stream_Write_UINT8(s,
byte);
858 static INLINE BOOL update_read_delta(
wStream* s, INT32* value)
863 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
866 Stream_Read_UINT8(s,
byte);
869 uvalue = (
byte | ((~0x3F) & 0xFF));
871 uvalue = (
byte & 0x3F);
875 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
878 Stream_Read_UINT8(s,
byte);
879 uvalue = (uvalue << 8) |
byte;
881 *value = (INT32)uvalue;
886 static INLINE
void update_read_glyph_delta(
wStream* s, UINT16* value)
889 Stream_Read_UINT8(s,
byte);
892 Stream_Read_UINT16(s, *value);
894 *value = (
byte & 0x3F);
896 static INLINE
void update_seek_glyph_delta(
wStream* s)
899 Stream_Read_UINT8(s,
byte);
902 Stream_Seek_UINT8(s);
905 static INLINE BOOL update_read_brush(
wStream* s, rdpBrush* brush, BYTE fieldFlags)
907 if (fieldFlags & ORDER_FIELD_01)
909 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
912 Stream_Read_UINT8(s, brush->x);
915 if (fieldFlags & ORDER_FIELD_02)
917 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
920 Stream_Read_UINT8(s, brush->y);
923 if (fieldFlags & ORDER_FIELD_03)
925 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
928 Stream_Read_UINT8(s, brush->style);
931 if (fieldFlags & ORDER_FIELD_04)
933 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
936 Stream_Read_UINT8(s, brush->hatch);
939 if (brush->style & CACHED_BRUSH)
942 brush->index = brush->hatch;
943 brush->bpp = get_bmf_bpp(brush->style, &rc);
950 if (fieldFlags & ORDER_FIELD_05)
952 if (!Stream_CheckAndLogRequiredLength(TAG, s, 7))
955 brush->data = (BYTE*)brush->p8x8;
956 Stream_Read_UINT8(s, brush->data[7]);
957 Stream_Read_UINT8(s, brush->data[6]);
958 Stream_Read_UINT8(s, brush->data[5]);
959 Stream_Read_UINT8(s, brush->data[4]);
960 Stream_Read_UINT8(s, brush->data[3]);
961 Stream_Read_UINT8(s, brush->data[2]);
962 Stream_Read_UINT8(s, brush->data[1]);
963 brush->data[0] = get_checked_uint8(brush->hatch);
968 static INLINE BOOL update_write_brush(
wStream* s, rdpBrush* brush, BYTE fieldFlags)
970 if (fieldFlags & ORDER_FIELD_01)
972 if (!Stream_EnsureRemainingCapacity(s, 1))
974 Stream_Write_UINT8(s, get_checked_uint8(brush->x));
977 if (fieldFlags & ORDER_FIELD_02)
979 if (!Stream_EnsureRemainingCapacity(s, 1))
981 Stream_Write_UINT8(s, get_checked_uint8(brush->y));
984 if (fieldFlags & ORDER_FIELD_03)
986 if (!Stream_EnsureRemainingCapacity(s, 1))
988 Stream_Write_UINT8(s, get_checked_uint8(brush->style));
991 if (brush->style & CACHED_BRUSH)
994 brush->hatch = brush->index;
995 brush->bpp = get_bmf_bpp(brush->style, &rc);
1002 if (fieldFlags & ORDER_FIELD_04)
1004 if (!Stream_EnsureRemainingCapacity(s, 1))
1006 Stream_Write_UINT8(s, get_checked_uint8(brush->hatch));
1009 if (fieldFlags & ORDER_FIELD_05)
1011 brush->data = (BYTE*)brush->p8x8;
1012 if (!Stream_EnsureRemainingCapacity(s, 7))
1014 Stream_Write_UINT8(s, brush->data[7]);
1015 Stream_Write_UINT8(s, brush->data[6]);
1016 Stream_Write_UINT8(s, brush->data[5]);
1017 Stream_Write_UINT8(s, brush->data[4]);
1018 Stream_Write_UINT8(s, brush->data[3]);
1019 Stream_Write_UINT8(s, brush->data[2]);
1020 Stream_Write_UINT8(s, brush->data[1]);
1021 brush->data[0] = get_checked_uint8(brush->hatch);
1026 static INLINE BOOL update_read_delta_rects(
wStream* s,
DELTA_RECT* rectangles,
const UINT32* nr)
1028 UINT32 number = *nr;
1030 BYTE* zeroBits = NULL;
1031 UINT32 zeroBitsSize = 0;
1035 WLog_WARN(TAG,
"Invalid number of delta rectangles %" PRIu32, number);
1039 zeroBitsSize = ((number + 1) / 2);
1041 if (!Stream_CheckAndLogRequiredLength(TAG, s, zeroBitsSize))
1044 Stream_GetPointer(s, zeroBits);
1045 Stream_Seek(s, zeroBitsSize);
1046 ZeroMemory(rectangles,
sizeof(
DELTA_RECT) * number);
1048 for (UINT32 i = 0; i < number; i++)
1051 flags = zeroBits[i / 2];
1053 if ((~flags & 0x80) && !update_read_delta(s, &rectangles[i].left))
1056 if ((~flags & 0x40) && !update_read_delta(s, &rectangles[i].top))
1061 if (!update_read_delta(s, &rectangles[i].width))
1065 rectangles[i].width = rectangles[i - 1].width;
1067 rectangles[i].width = 0;
1071 if (!update_read_delta(s, &rectangles[i].height))
1075 rectangles[i].height = rectangles[i - 1].height;
1077 rectangles[i].height = 0;
1081 rectangles[i].left += rectangles[i - 1].left;
1082 rectangles[i].top += rectangles[i - 1].top;
1091 static INLINE BOOL update_read_delta_points(
wStream* s,
DELTA_POINT** points, UINT32 number,
1095 BYTE* zeroBits = NULL;
1096 UINT32 zeroBitsSize = ((number + 3) / 4);
1098 WINPR_ASSERT(points);
1103 *points = newpoints;
1105 if (!Stream_CheckAndLogRequiredLength(TAG, s, zeroBitsSize))
1108 Stream_GetPointer(s, zeroBits);
1109 Stream_Seek(s, zeroBitsSize);
1110 ZeroMemory(*points,
sizeof(
DELTA_POINT) * number);
1112 for (UINT32 i = 0; i < number; i++)
1115 flags = zeroBits[i / 4];
1117 if ((~flags & 0x80) && !update_read_delta(s, &newpoints[i].x))
1119 WLog_ERR(TAG,
"update_read_delta(x) failed");
1123 if ((~flags & 0x40) && !update_read_delta(s, &newpoints[i].y))
1125 WLog_ERR(TAG,
"update_read_delta(y) failed");
1135 static BOOL order_field_flag_is_set(
const ORDER_INFO* orderInfo, BYTE number)
1137 const UINT32 mask = (UINT32)(1UL << ((UINT32)number - 1UL));
1138 const BOOL set = (orderInfo->fieldFlags & mask) != 0;
1142 static INLINE BOOL read_order_field_byte(
const char* orderName,
const ORDER_INFO* orderInfo,
1143 wStream* s, BYTE number, UINT32* target, BOOL optional)
1145 WINPR_ASSERT(orderName);
1146 WINPR_ASSERT(orderInfo);
1147 WINPR_ASSERT(target);
1149 if (!order_field_flag_is_set(orderInfo, number))
1151 WLog_DBG(TAG,
"order %s field %" PRIu8
" not found [optional:%d]", orderName, number,
1155 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
1157 Stream_Read_UINT8(s, *target);
1161 static INLINE BOOL read_order_field_2bytes(
const char* orderName,
const ORDER_INFO* orderInfo,
1162 wStream* s, BYTE number, UINT32* target1,
1163 UINT32* target2, BOOL optional)
1165 WINPR_ASSERT(orderName);
1166 WINPR_ASSERT(orderInfo);
1167 WINPR_ASSERT(target1);
1168 WINPR_ASSERT(target2);
1170 if (!order_field_flag_is_set(orderInfo, number))
1172 WLog_DBG(TAG,
"order %s field %" PRIu8
" not found [optional:%d]", orderName, number,
1176 if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
1178 Stream_Read_UINT8(s, *target1);
1179 Stream_Read_UINT8(s, *target2);
1183 static INLINE BOOL read_order_field_uint16(
const char* orderName,
const ORDER_INFO* orderInfo,
1184 wStream* s, BYTE number, UINT32* target, BOOL optional)
1186 WINPR_ASSERT(orderName);
1187 WINPR_ASSERT(orderInfo);
1188 WINPR_ASSERT(target);
1190 if (!order_field_flag_is_set(orderInfo, number))
1192 WLog_DBG(TAG,
"order %s field %" PRIu8
" not found [optional:%d]", orderName, number,
1197 if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
1200 Stream_Read_UINT16(s, *target);
1204 static INLINE BOOL read_order_field_int16(
const char* orderName,
const ORDER_INFO* orderInfo,
1205 wStream* s, BYTE number, INT32* target, BOOL optional)
1207 WINPR_ASSERT(orderName);
1208 WINPR_ASSERT(orderInfo);
1209 WINPR_ASSERT(target);
1211 if (!order_field_flag_is_set(orderInfo, number))
1213 WLog_DBG(TAG,
"order %s field %" PRIu8
" not found [optional:%d]", orderName, number,
1218 if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
1221 Stream_Read_INT16(s, *target);
1225 static INLINE BOOL read_order_field_uint32(
const char* orderName,
const ORDER_INFO* orderInfo,
1226 wStream* s, BYTE number, UINT32* target, BOOL optional)
1228 WINPR_ASSERT(orderName);
1229 WINPR_ASSERT(orderInfo);
1230 WINPR_ASSERT(target);
1232 if (!order_field_flag_is_set(orderInfo, number))
1234 WLog_DBG(TAG,
"order %s field %" PRIu8
" not found [optional:%d]", orderName, number,
1239 if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
1242 Stream_Read_UINT32(s, *target);
1246 static INLINE BOOL read_order_field_coord(
const char* orderName,
const ORDER_INFO* orderInfo,
1247 wStream* s, UINT32 NO, INT32* TARGET, BOOL optional)
1249 WINPR_ASSERT(orderName);
1250 WINPR_ASSERT(orderInfo);
1251 WINPR_ASSERT(TARGET);
1253 if (!order_field_flag_is_set(orderInfo, get_checked_uint8(NO)))
1255 WLog_DBG(TAG,
"order %s field %" PRIu8
" not found [optional:%d]", orderName,
1256 get_checked_uint8(NO), optional);
1260 return update_read_coord(s, TARGET, orderInfo->deltaCoordinates);
1263 static INLINE BOOL read_order_field_color(
const char* orderName,
const ORDER_INFO* orderInfo,
1264 wStream* s, UINT32 NO, UINT32* TARGET, BOOL optional)
1266 WINPR_ASSERT(orderName);
1267 WINPR_ASSERT(orderInfo);
1268 WINPR_ASSERT(TARGET);
1270 if (!order_field_flag_is_set(orderInfo, get_checked_uint8(NO)))
1272 WLog_DBG(TAG,
"order %s field %" PRIu8
" not found [optional:%d]", orderName,
1273 get_checked_uint8(NO), optional);
1277 if (!update_read_color(s, TARGET))
1282 static INLINE BOOL FIELD_SKIP_BUFFER16(
wStream* s, UINT32 TARGET_LEN)
1284 if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
1287 Stream_Read_UINT16(s, TARGET_LEN);
1289 if (!Stream_SafeSeek(s, TARGET_LEN))
1291 WLog_ERR(TAG,
"error skipping %" PRIu32
" bytes", TARGET_LEN);
1298 static BOOL update_read_dstblt_order(
const char* orderName,
wStream* s,
const ORDER_INFO* orderInfo,
1301 if (read_order_field_coord(orderName, orderInfo, s, 1, &dstblt->nLeftRect, FALSE) &&
1302 read_order_field_coord(orderName, orderInfo, s, 2, &dstblt->nTopRect, FALSE) &&
1303 read_order_field_coord(orderName, orderInfo, s, 3, &dstblt->nWidth, FALSE) &&
1304 read_order_field_coord(orderName, orderInfo, s, 4, &dstblt->nHeight, FALSE) &&
1305 read_order_field_byte(orderName, orderInfo, s, 5, &dstblt->bRop, TRUE))
1312 WINPR_UNUSED(orderInfo);
1313 WINPR_UNUSED(dstblt);
1319 if (!Stream_EnsureRemainingCapacity(s, update_approximate_dstblt_order(orderInfo, dstblt)))
1322 orderInfo->fieldFlags = 0;
1323 orderInfo->fieldFlags |= ORDER_FIELD_01;
1324 if (!update_write_coord(s, dstblt->nLeftRect))
1326 orderInfo->fieldFlags |= ORDER_FIELD_02;
1327 if (!update_write_coord(s, dstblt->nTopRect))
1329 orderInfo->fieldFlags |= ORDER_FIELD_03;
1330 if (!update_write_coord(s, dstblt->nWidth))
1332 orderInfo->fieldFlags |= ORDER_FIELD_04;
1333 if (!update_write_coord(s, dstblt->nHeight))
1335 orderInfo->fieldFlags |= ORDER_FIELD_05;
1336 Stream_Write_UINT8(s, get_checked_uint8(dstblt->bRop));
1340 static BOOL update_read_patblt_order(
const char* orderName,
wStream* s,
const ORDER_INFO* orderInfo,
1343 if (read_order_field_coord(orderName, orderInfo, s, 1, &patblt->nLeftRect, FALSE) &&
1344 read_order_field_coord(orderName, orderInfo, s, 2, &patblt->nTopRect, FALSE) &&
1345 read_order_field_coord(orderName, orderInfo, s, 3, &patblt->nWidth, FALSE) &&
1346 read_order_field_coord(orderName, orderInfo, s, 4, &patblt->nHeight, FALSE) &&
1347 read_order_field_byte(orderName, orderInfo, s, 5, &patblt->bRop, TRUE) &&
1348 read_order_field_color(orderName, orderInfo, s, 6, &patblt->backColor, TRUE) &&
1349 read_order_field_color(orderName, orderInfo, s, 7, &patblt->foreColor, TRUE) &&
1350 update_read_brush(s, &patblt->brush,
1351 get_checked_uint8((orderInfo->fieldFlags >> 7) & 0x1F)))
1358 WINPR_UNUSED(orderInfo);
1359 WINPR_UNUSED(patblt);
1365 if (!Stream_EnsureRemainingCapacity(s, update_approximate_patblt_order(orderInfo, patblt)))
1368 orderInfo->fieldFlags = 0;
1369 orderInfo->fieldFlags |= ORDER_FIELD_01;
1370 if (!update_write_coord(s, patblt->nLeftRect))
1372 orderInfo->fieldFlags |= ORDER_FIELD_02;
1373 if (!update_write_coord(s, patblt->nTopRect))
1375 orderInfo->fieldFlags |= ORDER_FIELD_03;
1376 if (!update_write_coord(s, patblt->nWidth))
1378 orderInfo->fieldFlags |= ORDER_FIELD_04;
1379 if (!update_write_coord(s, patblt->nHeight))
1381 orderInfo->fieldFlags |= ORDER_FIELD_05;
1382 Stream_Write_UINT8(s, get_checked_uint8(patblt->bRop));
1383 orderInfo->fieldFlags |= ORDER_FIELD_06;
1384 update_write_color(s, patblt->backColor);
1385 orderInfo->fieldFlags |= ORDER_FIELD_07;
1386 update_write_color(s, patblt->foreColor);
1387 orderInfo->fieldFlags |= ORDER_FIELD_08;
1388 orderInfo->fieldFlags |= ORDER_FIELD_09;
1389 orderInfo->fieldFlags |= ORDER_FIELD_10;
1390 orderInfo->fieldFlags |= ORDER_FIELD_11;
1391 orderInfo->fieldFlags |= ORDER_FIELD_12;
1392 update_write_brush(s, &patblt->brush, get_checked_uint8((orderInfo->fieldFlags >> 7) & 0x1F));
1396 static BOOL update_read_scrblt_order(
const char* orderName,
wStream* s,
const ORDER_INFO* orderInfo,
1399 WINPR_ASSERT(orderInfo);
1400 WINPR_ASSERT(scrblt);
1401 if (read_order_field_coord(orderName, orderInfo, s, 1, &scrblt->nLeftRect, FALSE) &&
1402 read_order_field_coord(orderName, orderInfo, s, 2, &scrblt->nTopRect, FALSE) &&
1403 read_order_field_coord(orderName, orderInfo, s, 3, &scrblt->nWidth, FALSE) &&
1404 read_order_field_coord(orderName, orderInfo, s, 4, &scrblt->nHeight, FALSE) &&
1405 read_order_field_byte(orderName, orderInfo, s, 5, &scrblt->bRop, TRUE) &&
1406 read_order_field_coord(orderName, orderInfo, s, 6, &scrblt->nXSrc, FALSE) &&
1407 read_order_field_coord(orderName, orderInfo, s, 7, &scrblt->nYSrc, FALSE))
1414 WINPR_ASSERT(orderInfo);
1415 WINPR_ASSERT(scrblt);
1416 WINPR_UNUSED(orderInfo);
1417 WINPR_UNUSED(scrblt);
1423 WINPR_ASSERT(orderInfo);
1424 WINPR_ASSERT(scrblt);
1425 if (!Stream_EnsureRemainingCapacity(s, update_approximate_scrblt_order(orderInfo, scrblt)))
1428 orderInfo->fieldFlags = 0;
1429 orderInfo->fieldFlags |= ORDER_FIELD_01;
1430 if (!update_write_coord(s, scrblt->nLeftRect))
1432 orderInfo->fieldFlags |= ORDER_FIELD_02;
1433 if (!update_write_coord(s, scrblt->nTopRect))
1435 orderInfo->fieldFlags |= ORDER_FIELD_03;
1436 if (!update_write_coord(s, scrblt->nWidth))
1438 orderInfo->fieldFlags |= ORDER_FIELD_04;
1439 if (!update_write_coord(s, scrblt->nHeight))
1441 orderInfo->fieldFlags |= ORDER_FIELD_05;
1442 WINPR_ASSERT(scrblt->bRop <= UINT8_MAX);
1443 Stream_Write_UINT8(s, (UINT8)scrblt->bRop);
1444 orderInfo->fieldFlags |= ORDER_FIELD_06;
1445 if (!update_write_coord(s, scrblt->nXSrc))
1447 orderInfo->fieldFlags |= ORDER_FIELD_07;
1448 if (!update_write_coord(s, scrblt->nYSrc))
1452 static BOOL update_read_opaque_rect_order(
const char* orderName,
wStream* s,
1457 if (!read_order_field_coord(orderName, orderInfo, s, 1, &opaque_rect->nLeftRect, FALSE) ||
1458 !read_order_field_coord(orderName, orderInfo, s, 2, &opaque_rect->nTopRect, FALSE) ||
1459 !read_order_field_coord(orderName, orderInfo, s, 3, &opaque_rect->nWidth, FALSE) ||
1460 !read_order_field_coord(orderName, orderInfo, s, 4, &opaque_rect->nHeight, FALSE))
1463 if ((orderInfo->fieldFlags & ORDER_FIELD_05) != 0)
1465 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
1468 Stream_Read_UINT8(s,
byte);
1469 opaque_rect->color = (opaque_rect->color & 0x00FFFF00) | ((UINT32)byte);
1472 if ((orderInfo->fieldFlags & ORDER_FIELD_06) != 0)
1474 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
1477 Stream_Read_UINT8(s,
byte);
1478 opaque_rect->color = (opaque_rect->color & 0x00FF00FF) | ((UINT32)
byte << 8);
1481 if ((orderInfo->fieldFlags & ORDER_FIELD_07) != 0)
1483 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
1486 Stream_Read_UINT8(s,
byte);
1487 opaque_rect->color = (opaque_rect->color & 0x0000FFFF) | ((UINT32)
byte << 16);
1493 size_t update_approximate_opaque_rect_order(
ORDER_INFO* orderInfo,
1496 WINPR_UNUSED(orderInfo);
1497 WINPR_UNUSED(opaque_rect);
1505 size_t inf = update_approximate_opaque_rect_order(orderInfo, opaque_rect);
1507 if (!Stream_EnsureRemainingCapacity(s, inf))
1511 orderInfo->fieldFlags = 0;
1512 orderInfo->fieldFlags |= ORDER_FIELD_01;
1513 if (!update_write_coord(s, opaque_rect->nLeftRect))
1515 orderInfo->fieldFlags |= ORDER_FIELD_02;
1516 if (!update_write_coord(s, opaque_rect->nTopRect))
1518 orderInfo->fieldFlags |= ORDER_FIELD_03;
1519 if (!update_write_coord(s, opaque_rect->nWidth))
1521 orderInfo->fieldFlags |= ORDER_FIELD_04;
1522 if (!update_write_coord(s, opaque_rect->nHeight))
1524 orderInfo->fieldFlags |= ORDER_FIELD_05;
1525 byte = opaque_rect->color & 0x000000FF;
1526 Stream_Write_UINT8(s,
byte);
1527 orderInfo->fieldFlags |= ORDER_FIELD_06;
1528 byte = (opaque_rect->color & 0x0000FF00) >> 8;
1529 Stream_Write_UINT8(s,
byte);
1530 orderInfo->fieldFlags |= ORDER_FIELD_07;
1531 byte = (opaque_rect->color & 0x00FF0000) >> 16;
1532 Stream_Write_UINT8(s,
byte);
1536 static BOOL update_read_draw_nine_grid_order(
const char* orderName,
wStream* s,
1540 if (read_order_field_coord(orderName, orderInfo, s, 1, &draw_nine_grid->srcLeft, FALSE) &&
1541 read_order_field_coord(orderName, orderInfo, s, 2, &draw_nine_grid->srcTop, FALSE) &&
1542 read_order_field_coord(orderName, orderInfo, s, 3, &draw_nine_grid->srcRight, FALSE) &&
1543 read_order_field_coord(orderName, orderInfo, s, 4, &draw_nine_grid->srcBottom, FALSE) &&
1544 read_order_field_uint16(orderName, orderInfo, s, 5, &draw_nine_grid->bitmapId, FALSE))
1549 static BOOL update_read_multi_dstblt_order(
const char* orderName,
wStream* s,
1553 UINT32 numRectangles = multi_dstblt->numRectangles;
1554 if (!read_order_field_coord(orderName, orderInfo, s, 1, &multi_dstblt->nLeftRect, FALSE) ||
1555 !read_order_field_coord(orderName, orderInfo, s, 2, &multi_dstblt->nTopRect, FALSE) ||
1556 !read_order_field_coord(orderName, orderInfo, s, 3, &multi_dstblt->nWidth, FALSE) ||
1557 !read_order_field_coord(orderName, orderInfo, s, 4, &multi_dstblt->nHeight, FALSE) ||
1558 !read_order_field_byte(orderName, orderInfo, s, 5, &multi_dstblt->bRop, TRUE) ||
1559 !read_order_field_byte(orderName, orderInfo, s, 6, &numRectangles, TRUE))
1562 if ((orderInfo->fieldFlags & ORDER_FIELD_07) != 0)
1564 if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
1567 multi_dstblt->numRectangles = numRectangles;
1568 Stream_Read_UINT16(s, multi_dstblt->cbData);
1569 return update_read_delta_rects(s, multi_dstblt->rectangles, &multi_dstblt->numRectangles);
1571 if (numRectangles > multi_dstblt->numRectangles)
1573 WLog_ERR(TAG,
"%s numRectangles %" PRIu32
" > %" PRIu32, orderName, numRectangles,
1574 multi_dstblt->numRectangles);
1577 multi_dstblt->numRectangles = numRectangles;
1581 static BOOL update_read_multi_patblt_order(
const char* orderName,
wStream* s,
1585 if (!read_order_field_coord(orderName, orderInfo, s, 1, &multi_patblt->nLeftRect, FALSE) ||
1586 !read_order_field_coord(orderName, orderInfo, s, 2, &multi_patblt->nTopRect, FALSE) ||
1587 !read_order_field_coord(orderName, orderInfo, s, 3, &multi_patblt->nWidth, FALSE) ||
1588 !read_order_field_coord(orderName, orderInfo, s, 4, &multi_patblt->nHeight, FALSE) ||
1589 !read_order_field_byte(orderName, orderInfo, s, 5, &multi_patblt->bRop, TRUE) ||
1590 !read_order_field_color(orderName, orderInfo, s, 6, &multi_patblt->backColor, TRUE) ||
1591 !read_order_field_color(orderName, orderInfo, s, 7, &multi_patblt->foreColor, TRUE))
1594 if (!update_read_brush(s, &multi_patblt->brush,
1595 get_checked_uint8((orderInfo->fieldFlags >> 7) & 0x1F)))
1598 UINT32 numRectangles = multi_patblt->numRectangles;
1599 if (!read_order_field_byte(orderName, orderInfo, s, 13, &numRectangles, TRUE))
1602 if ((orderInfo->fieldFlags & ORDER_FIELD_14) != 0)
1604 if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
1607 multi_patblt->numRectangles = numRectangles;
1608 Stream_Read_UINT16(s, multi_patblt->cbData);
1610 if (!update_read_delta_rects(s, multi_patblt->rectangles, &multi_patblt->numRectangles))
1614 if (numRectangles > multi_patblt->numRectangles)
1616 WLog_ERR(TAG,
"%s numRectangles %" PRIu32
" > %" PRIu32, orderName, numRectangles,
1617 multi_patblt->numRectangles);
1620 multi_patblt->numRectangles = numRectangles;
1625 static BOOL update_read_multi_scrblt_order(
const char* orderName,
wStream* s,
1629 WINPR_ASSERT(orderInfo);
1630 WINPR_ASSERT(multi_scrblt);
1632 UINT32 numRectangles = multi_scrblt->numRectangles;
1633 if (!read_order_field_coord(orderName, orderInfo, s, 1, &multi_scrblt->nLeftRect, FALSE) ||
1634 !read_order_field_coord(orderName, orderInfo, s, 2, &multi_scrblt->nTopRect, FALSE) ||
1635 !read_order_field_coord(orderName, orderInfo, s, 3, &multi_scrblt->nWidth, FALSE) ||
1636 !read_order_field_coord(orderName, orderInfo, s, 4, &multi_scrblt->nHeight, FALSE) ||
1637 !read_order_field_byte(orderName, orderInfo, s, 5, &multi_scrblt->bRop, TRUE) ||
1638 !read_order_field_coord(orderName, orderInfo, s, 6, &multi_scrblt->nXSrc, FALSE) ||
1639 !read_order_field_coord(orderName, orderInfo, s, 7, &multi_scrblt->nYSrc, FALSE) ||
1640 !read_order_field_byte(orderName, orderInfo, s, 8, &numRectangles, TRUE))
1643 if ((orderInfo->fieldFlags & ORDER_FIELD_09) != 0)
1645 if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
1648 multi_scrblt->numRectangles = numRectangles;
1649 Stream_Read_UINT16(s, multi_scrblt->cbData);
1650 return update_read_delta_rects(s, multi_scrblt->rectangles, &multi_scrblt->numRectangles);
1653 if (numRectangles > multi_scrblt->numRectangles)
1655 WLog_ERR(TAG,
"%s numRectangles %" PRIu32
" > %" PRIu32, orderName, numRectangles,
1656 multi_scrblt->numRectangles);
1659 multi_scrblt->numRectangles = numRectangles;
1664 static BOOL update_read_multi_opaque_rect_order(
const char* orderName,
wStream* s,
1669 if (!read_order_field_coord(orderName, orderInfo, s, 1, &multi_opaque_rect->nLeftRect, FALSE) ||
1670 !read_order_field_coord(orderName, orderInfo, s, 2, &multi_opaque_rect->nTopRect, FALSE) ||
1671 !read_order_field_coord(orderName, orderInfo, s, 3, &multi_opaque_rect->nWidth, FALSE) ||
1672 !read_order_field_coord(orderName, orderInfo, s, 4, &multi_opaque_rect->nHeight, FALSE))
1675 if ((orderInfo->fieldFlags & ORDER_FIELD_05) != 0)
1677 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
1680 Stream_Read_UINT8(s,
byte);
1681 multi_opaque_rect->color = (multi_opaque_rect->color & 0x00FFFF00) | ((UINT32)byte);
1684 if ((orderInfo->fieldFlags & ORDER_FIELD_06) != 0)
1686 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
1689 Stream_Read_UINT8(s,
byte);
1690 multi_opaque_rect->color = (multi_opaque_rect->color & 0x00FF00FF) | ((UINT32)
byte << 8);
1693 if ((orderInfo->fieldFlags & ORDER_FIELD_07) != 0)
1695 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
1698 Stream_Read_UINT8(s,
byte);
1699 multi_opaque_rect->color = (multi_opaque_rect->color & 0x0000FFFF) | ((UINT32)
byte << 16);
1702 UINT32 numRectangles = multi_opaque_rect->numRectangles;
1703 if (!read_order_field_byte(orderName, orderInfo, s, 8, &numRectangles, TRUE))
1706 if ((orderInfo->fieldFlags & ORDER_FIELD_09) != 0)
1708 if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
1711 multi_opaque_rect->numRectangles = numRectangles;
1712 Stream_Read_UINT16(s, multi_opaque_rect->cbData);
1713 return update_read_delta_rects(s, multi_opaque_rect->rectangles,
1714 &multi_opaque_rect->numRectangles);
1716 if (numRectangles > multi_opaque_rect->numRectangles)
1718 WLog_ERR(TAG,
"%s numRectangles %" PRIu32
" > %" PRIu32, orderName, numRectangles,
1719 multi_opaque_rect->numRectangles);
1722 multi_opaque_rect->numRectangles = numRectangles;
1727 static BOOL update_read_multi_draw_nine_grid_order(
const char* orderName,
wStream* s,
1731 UINT32 nDeltaEntries = multi_draw_nine_grid->nDeltaEntries;
1732 if (!read_order_field_coord(orderName, orderInfo, s, 1, &multi_draw_nine_grid->srcLeft,
1734 !read_order_field_coord(orderName, orderInfo, s, 2, &multi_draw_nine_grid->srcTop, FALSE) ||
1735 !read_order_field_coord(orderName, orderInfo, s, 3, &multi_draw_nine_grid->srcRight,
1737 !read_order_field_coord(orderName, orderInfo, s, 4, &multi_draw_nine_grid->srcBottom,
1739 !read_order_field_uint16(orderName, orderInfo, s, 5, &multi_draw_nine_grid->bitmapId,
1741 !read_order_field_byte(orderName, orderInfo, s, 6, &nDeltaEntries, TRUE))
1744 if ((orderInfo->fieldFlags & ORDER_FIELD_07) != 0)
1746 if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
1749 multi_draw_nine_grid->nDeltaEntries = nDeltaEntries;
1750 Stream_Read_UINT16(s, multi_draw_nine_grid->cbData);
1751 return update_read_delta_rects(s, multi_draw_nine_grid->rectangles,
1752 &multi_draw_nine_grid->nDeltaEntries);
1755 if (nDeltaEntries > multi_draw_nine_grid->nDeltaEntries)
1757 WLog_ERR(TAG,
"%s nDeltaEntries %" PRIu32
" > %" PRIu32, orderName, nDeltaEntries,
1758 multi_draw_nine_grid->nDeltaEntries);
1761 multi_draw_nine_grid->nDeltaEntries = nDeltaEntries;
1765 static BOOL update_read_line_to_order(
const char* orderName,
wStream* s,
1768 if (read_order_field_uint16(orderName, orderInfo, s, 1, &line_to->backMode, TRUE) &&
1769 read_order_field_coord(orderName, orderInfo, s, 2, &line_to->nXStart, FALSE) &&
1770 read_order_field_coord(orderName, orderInfo, s, 3, &line_to->nYStart, FALSE) &&
1771 read_order_field_coord(orderName, orderInfo, s, 4, &line_to->nXEnd, FALSE) &&
1772 read_order_field_coord(orderName, orderInfo, s, 5, &line_to->nYEnd, FALSE) &&
1773 read_order_field_color(orderName, orderInfo, s, 6, &line_to->backColor, TRUE) &&
1774 read_order_field_byte(orderName, orderInfo, s, 7, &line_to->bRop2, TRUE) &&
1775 read_order_field_byte(orderName, orderInfo, s, 8, &line_to->penStyle, TRUE) &&
1776 read_order_field_byte(orderName, orderInfo, s, 9, &line_to->penWidth, TRUE) &&
1777 read_order_field_color(orderName, orderInfo, s, 10, &line_to->penColor, TRUE))
1784 WINPR_UNUSED(orderInfo);
1785 WINPR_UNUSED(line_to);
1791 if (!Stream_EnsureRemainingCapacity(s, update_approximate_line_to_order(orderInfo, line_to)))
1794 orderInfo->fieldFlags = 0;
1795 orderInfo->fieldFlags |= ORDER_FIELD_01;
1796 Stream_Write_UINT16(s, get_checked_uint16(line_to->backMode));
1797 orderInfo->fieldFlags |= ORDER_FIELD_02;
1798 if (!update_write_coord(s, line_to->nXStart))
1800 orderInfo->fieldFlags |= ORDER_FIELD_03;
1801 if (!update_write_coord(s, line_to->nYStart))
1803 orderInfo->fieldFlags |= ORDER_FIELD_04;
1804 if (!update_write_coord(s, line_to->nXEnd))
1806 orderInfo->fieldFlags |= ORDER_FIELD_05;
1807 if (!update_write_coord(s, line_to->nYEnd))
1809 orderInfo->fieldFlags |= ORDER_FIELD_06;
1810 update_write_color(s, line_to->backColor);
1811 orderInfo->fieldFlags |= ORDER_FIELD_07;
1812 Stream_Write_UINT8(s, get_checked_uint8(line_to->bRop2));
1813 orderInfo->fieldFlags |= ORDER_FIELD_08;
1814 Stream_Write_UINT8(s, get_checked_uint8(line_to->penStyle));
1815 orderInfo->fieldFlags |= ORDER_FIELD_09;
1816 Stream_Write_UINT8(s, get_checked_uint8(line_to->penWidth));
1817 orderInfo->fieldFlags |= ORDER_FIELD_10;
1818 update_write_color(s, line_to->penColor);
1822 static BOOL update_read_polyline_order(
const char* orderName,
wStream* s,
1826 UINT32 new_num = polyline->numDeltaEntries;
1827 if (!read_order_field_coord(orderName, orderInfo, s, 1, &polyline->xStart, FALSE) ||
1828 !read_order_field_coord(orderName, orderInfo, s, 2, &polyline->yStart, FALSE) ||
1829 !read_order_field_byte(orderName, orderInfo, s, 3, &polyline->bRop2, TRUE) ||
1830 !read_order_field_uint16(orderName, orderInfo, s, 4, &word, TRUE) ||
1831 !read_order_field_color(orderName, orderInfo, s, 5, &polyline->penColor, TRUE) ||
1832 !read_order_field_byte(orderName, orderInfo, s, 6, &new_num, TRUE))
1835 if ((orderInfo->fieldFlags & ORDER_FIELD_07) != 0)
1840 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
1843 Stream_Read_UINT8(s, polyline->cbData);
1845 polyline->numDeltaEntries = new_num;
1846 return update_read_delta_points(s, &polyline->points, polyline->numDeltaEntries,
1847 get_checked_int16(polyline->xStart),
1848 get_checked_int16(polyline->yStart));
1850 if (new_num > polyline->numDeltaEntries)
1852 WLog_ERR(TAG,
"%s numDeltaEntries %" PRIu32
" > %" PRIu32, orderName, new_num,
1853 polyline->numDeltaEntries);
1856 polyline->numDeltaEntries = new_num;
1861 static BOOL update_read_memblt_order(
const char* orderName,
wStream* s,
const ORDER_INFO* orderInfo,
1864 if (!s || !orderInfo || !memblt)
1867 if (!read_order_field_uint16(orderName, orderInfo, s, 1, &memblt->cacheId, TRUE) ||
1868 !read_order_field_coord(orderName, orderInfo, s, 2, &memblt->nLeftRect, FALSE) ||
1869 !read_order_field_coord(orderName, orderInfo, s, 3, &memblt->nTopRect, FALSE) ||
1870 !read_order_field_coord(orderName, orderInfo, s, 4, &memblt->nWidth, FALSE) ||
1871 !read_order_field_coord(orderName, orderInfo, s, 5, &memblt->nHeight, FALSE) ||
1872 !read_order_field_byte(orderName, orderInfo, s, 6, &memblt->bRop, TRUE) ||
1873 !read_order_field_coord(orderName, orderInfo, s, 7, &memblt->nXSrc, FALSE) ||
1874 !read_order_field_coord(orderName, orderInfo, s, 8, &memblt->nYSrc, FALSE) ||
1875 !read_order_field_uint16(orderName, orderInfo, s, 9, &memblt->cacheIndex, TRUE))
1877 memblt->colorIndex = (memblt->cacheId >> 8);
1878 memblt->cacheId = (memblt->cacheId & 0xFF);
1879 memblt->bitmap = NULL;
1885 WINPR_UNUSED(orderInfo);
1886 WINPR_UNUSED(memblt);
1892 if (!Stream_EnsureRemainingCapacity(s, update_approximate_memblt_order(orderInfo, memblt)))
1895 const UINT16 cacheId = (UINT16)((memblt->cacheId & 0xFF) | ((memblt->colorIndex & 0xFF) << 8));
1896 orderInfo->fieldFlags |= ORDER_FIELD_01;
1897 Stream_Write_UINT16(s, cacheId);
1898 orderInfo->fieldFlags |= ORDER_FIELD_02;
1899 if (!update_write_coord(s, memblt->nLeftRect))
1901 orderInfo->fieldFlags |= ORDER_FIELD_03;
1902 if (!update_write_coord(s, memblt->nTopRect))
1904 orderInfo->fieldFlags |= ORDER_FIELD_04;
1905 if (!update_write_coord(s, memblt->nWidth))
1907 orderInfo->fieldFlags |= ORDER_FIELD_05;
1908 if (!update_write_coord(s, memblt->nHeight))
1910 orderInfo->fieldFlags |= ORDER_FIELD_06;
1911 Stream_Write_UINT8(s, get_checked_uint8(memblt->bRop));
1912 orderInfo->fieldFlags |= ORDER_FIELD_07;
1913 if (!update_write_coord(s, memblt->nXSrc))
1915 orderInfo->fieldFlags |= ORDER_FIELD_08;
1916 if (!update_write_coord(s, memblt->nYSrc))
1918 orderInfo->fieldFlags |= ORDER_FIELD_09;
1919 Stream_Write_UINT16(s, get_checked_uint16(memblt->cacheIndex));
1922 static BOOL update_read_mem3blt_order(
const char* orderName,
wStream* s,
1925 if (!read_order_field_uint16(orderName, orderInfo, s, 1, &mem3blt->cacheId, TRUE) ||
1926 !read_order_field_coord(orderName, orderInfo, s, 2, &mem3blt->nLeftRect, FALSE) ||
1927 !read_order_field_coord(orderName, orderInfo, s, 3, &mem3blt->nTopRect, FALSE) ||
1928 !read_order_field_coord(orderName, orderInfo, s, 4, &mem3blt->nWidth, FALSE) ||
1929 !read_order_field_coord(orderName, orderInfo, s, 5, &mem3blt->nHeight, FALSE) ||
1930 !read_order_field_byte(orderName, orderInfo, s, 6, &mem3blt->bRop, TRUE) ||
1931 !read_order_field_coord(orderName, orderInfo, s, 7, &mem3blt->nXSrc, FALSE) ||
1932 !read_order_field_coord(orderName, orderInfo, s, 8, &mem3blt->nYSrc, FALSE) ||
1933 !read_order_field_color(orderName, orderInfo, s, 9, &mem3blt->backColor, TRUE) ||
1934 !read_order_field_color(orderName, orderInfo, s, 10, &mem3blt->foreColor, TRUE))
1937 if (!update_read_brush(s, &mem3blt->brush,
1938 get_checked_uint8((orderInfo->fieldFlags >> 10) & 0x1F)) ||
1939 !read_order_field_uint16(orderName, orderInfo, s, 16, &mem3blt->cacheIndex, TRUE))
1941 mem3blt->colorIndex = (mem3blt->cacheId >> 8);
1942 mem3blt->cacheId = (mem3blt->cacheId & 0xFF);
1943 mem3blt->bitmap = NULL;
1946 static BOOL update_read_save_bitmap_order(
const char* orderName,
wStream* s,
1950 if (read_order_field_uint32(orderName, orderInfo, s, 1, &save_bitmap->savedBitmapPosition,
1952 read_order_field_coord(orderName, orderInfo, s, 2, &save_bitmap->nLeftRect, FALSE) &&
1953 read_order_field_coord(orderName, orderInfo, s, 3, &save_bitmap->nTopRect, FALSE) &&
1954 read_order_field_coord(orderName, orderInfo, s, 4, &save_bitmap->nRightRect, FALSE) &&
1955 read_order_field_coord(orderName, orderInfo, s, 5, &save_bitmap->nBottomRect, FALSE) &&
1956 read_order_field_byte(orderName, orderInfo, s, 6, &save_bitmap->operation, TRUE))
1960 static BOOL update_read_glyph_index_order(
const char* orderName,
wStream* s,
1964 if (!read_order_field_byte(orderName, orderInfo, s, 1, &glyph_index->cacheId, TRUE) ||
1965 !read_order_field_byte(orderName, orderInfo, s, 2, &glyph_index->flAccel, TRUE) ||
1966 !read_order_field_byte(orderName, orderInfo, s, 3, &glyph_index->ulCharInc, TRUE) ||
1967 !read_order_field_byte(orderName, orderInfo, s, 4, &glyph_index->fOpRedundant, TRUE) ||
1968 !read_order_field_color(orderName, orderInfo, s, 5, &glyph_index->backColor, TRUE) ||
1969 !read_order_field_color(orderName, orderInfo, s, 6, &glyph_index->foreColor, TRUE) ||
1970 !read_order_field_int16(orderName, orderInfo, s, 7, &glyph_index->bkLeft, TRUE) ||
1971 !read_order_field_int16(orderName, orderInfo, s, 8, &glyph_index->bkTop, TRUE) ||
1972 !read_order_field_int16(orderName, orderInfo, s, 9, &glyph_index->bkRight, TRUE) ||
1973 !read_order_field_int16(orderName, orderInfo, s, 10, &glyph_index->bkBottom, TRUE) ||
1974 !read_order_field_int16(orderName, orderInfo, s, 11, &glyph_index->opLeft, TRUE) ||
1975 !read_order_field_int16(orderName, orderInfo, s, 12, &glyph_index->opTop, TRUE) ||
1976 !read_order_field_int16(orderName, orderInfo, s, 13, &glyph_index->opRight, TRUE) ||
1977 !read_order_field_int16(orderName, orderInfo, s, 14, &glyph_index->opBottom, TRUE) ||
1978 !update_read_brush(s, &glyph_index->brush,
1979 get_checked_uint8((orderInfo->fieldFlags >> 14) & 0x1F)) ||
1980 !read_order_field_int16(orderName, orderInfo, s, 20, &glyph_index->x, TRUE) ||
1981 !read_order_field_int16(orderName, orderInfo, s, 21, &glyph_index->y, TRUE))
1984 if ((orderInfo->fieldFlags & ORDER_FIELD_22) != 0)
1986 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
1989 Stream_Read_UINT8(s, glyph_index->cbData);
1991 if (!Stream_CheckAndLogRequiredLength(TAG, s, glyph_index->cbData))
1994 CopyMemory(glyph_index->data, Stream_ConstPointer(s), glyph_index->cbData);
1995 Stream_Seek(s, glyph_index->cbData);
2001 size_t update_approximate_glyph_index_order(
ORDER_INFO* orderInfo,
2004 WINPR_UNUSED(orderInfo);
2005 WINPR_UNUSED(glyph_index);
2012 size_t inf = update_approximate_glyph_index_order(orderInfo, glyph_index);
2014 if (!Stream_EnsureRemainingCapacity(s, inf))
2017 if (!Stream_EnsureRemainingCapacity(s, 4))
2019 orderInfo->fieldFlags = 0;
2020 orderInfo->fieldFlags |= ORDER_FIELD_01;
2021 Stream_Write_UINT8(s, get_checked_uint8(glyph_index->cacheId));
2022 orderInfo->fieldFlags |= ORDER_FIELD_02;
2023 Stream_Write_UINT8(s, get_checked_uint8(glyph_index->flAccel));
2024 orderInfo->fieldFlags |= ORDER_FIELD_03;
2025 Stream_Write_UINT8(s, get_checked_uint8(glyph_index->ulCharInc));
2026 orderInfo->fieldFlags |= ORDER_FIELD_04;
2027 Stream_Write_UINT8(s, get_checked_uint8(glyph_index->fOpRedundant));
2028 orderInfo->fieldFlags |= ORDER_FIELD_05;
2029 if (!update_write_color(s, get_checked_uint8(glyph_index->backColor)))
2031 orderInfo->fieldFlags |= ORDER_FIELD_06;
2032 if (!update_write_color(s, glyph_index->foreColor))
2035 if (!Stream_EnsureRemainingCapacity(s, 14))
2037 orderInfo->fieldFlags |= ORDER_FIELD_07;
2038 Stream_Write_INT16(s, get_checked_int16(glyph_index->bkLeft));
2039 orderInfo->fieldFlags |= ORDER_FIELD_08;
2040 Stream_Write_INT16(s, get_checked_int16(glyph_index->bkTop));
2041 orderInfo->fieldFlags |= ORDER_FIELD_09;
2042 Stream_Write_INT16(s, get_checked_int16(glyph_index->bkRight));
2043 orderInfo->fieldFlags |= ORDER_FIELD_10;
2044 Stream_Write_INT16(s, get_checked_int16(glyph_index->bkBottom));
2045 orderInfo->fieldFlags |= ORDER_FIELD_11;
2046 Stream_Write_INT16(s, get_checked_int16(glyph_index->opLeft));
2047 orderInfo->fieldFlags |= ORDER_FIELD_12;
2048 Stream_Write_INT16(s, get_checked_int16(glyph_index->opTop));
2049 orderInfo->fieldFlags |= ORDER_FIELD_13;
2050 Stream_Write_INT16(s, get_checked_int16(glyph_index->opRight));
2051 orderInfo->fieldFlags |= ORDER_FIELD_14;
2052 Stream_Write_INT16(s, get_checked_int16(glyph_index->opBottom));
2053 orderInfo->fieldFlags |= ORDER_FIELD_15;
2054 orderInfo->fieldFlags |= ORDER_FIELD_16;
2055 orderInfo->fieldFlags |= ORDER_FIELD_17;
2056 orderInfo->fieldFlags |= ORDER_FIELD_18;
2057 orderInfo->fieldFlags |= ORDER_FIELD_19;
2058 if (!update_write_brush(s, &glyph_index->brush,
2059 get_checked_uint8((orderInfo->fieldFlags >> 14) & 0x1F)))
2062 if (!Stream_EnsureRemainingCapacity(s, 5ULL + glyph_index->cbData))
2064 orderInfo->fieldFlags |= ORDER_FIELD_20;
2065 Stream_Write_INT16(s, get_checked_int16(glyph_index->x));
2066 orderInfo->fieldFlags |= ORDER_FIELD_21;
2067 Stream_Write_INT16(s, get_checked_int16(glyph_index->y));
2068 orderInfo->fieldFlags |= ORDER_FIELD_22;
2069 Stream_Write_UINT8(s, get_checked_uint8(glyph_index->cbData));
2070 Stream_Write(s, glyph_index->data, glyph_index->cbData);
2073 static BOOL update_read_fast_index_order(
const char* orderName,
wStream* s,
2076 if (!read_order_field_byte(orderName, orderInfo, s, 1, &fast_index->cacheId, TRUE) ||
2077 !read_order_field_2bytes(orderName, orderInfo, s, 2, &fast_index->ulCharInc,
2078 &fast_index->flAccel, TRUE) ||
2079 !read_order_field_color(orderName, orderInfo, s, 3, &fast_index->backColor, TRUE) ||
2080 !read_order_field_color(orderName, orderInfo, s, 4, &fast_index->foreColor, TRUE) ||
2081 !read_order_field_coord(orderName, orderInfo, s, 5, &fast_index->bkLeft, FALSE) ||
2082 !read_order_field_coord(orderName, orderInfo, s, 6, &fast_index->bkTop, FALSE) ||
2083 !read_order_field_coord(orderName, orderInfo, s, 7, &fast_index->bkRight, FALSE) ||
2084 !read_order_field_coord(orderName, orderInfo, s, 8, &fast_index->bkBottom, FALSE) ||
2085 !read_order_field_coord(orderName, orderInfo, s, 9, &fast_index->opLeft, FALSE) ||
2086 !read_order_field_coord(orderName, orderInfo, s, 10, &fast_index->opTop, FALSE) ||
2087 !read_order_field_coord(orderName, orderInfo, s, 11, &fast_index->opRight, FALSE) ||
2088 !read_order_field_coord(orderName, orderInfo, s, 12, &fast_index->opBottom, FALSE) ||
2089 !read_order_field_coord(orderName, orderInfo, s, 13, &fast_index->x, FALSE) ||
2090 !read_order_field_coord(orderName, orderInfo, s, 14, &fast_index->y, FALSE))
2093 if ((orderInfo->fieldFlags & ORDER_FIELD_15) != 0)
2095 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
2098 Stream_Read_UINT8(s, fast_index->cbData);
2100 if (!Stream_CheckAndLogRequiredLength(TAG, s, fast_index->cbData))
2103 CopyMemory(fast_index->data, Stream_ConstPointer(s), fast_index->cbData);
2104 Stream_Seek(s, fast_index->cbData);
2109 static BOOL update_read_fast_glyph_order(
const char* orderName,
wStream* s,
2113 if (!read_order_field_byte(orderName, orderInfo, s, 1, &fastGlyph->cacheId, TRUE))
2115 if (fastGlyph->cacheId > 9)
2117 if (!read_order_field_2bytes(orderName, orderInfo, s, 2, &fastGlyph->ulCharInc,
2118 &fastGlyph->flAccel, TRUE) ||
2119 !read_order_field_color(orderName, orderInfo, s, 3, &fastGlyph->backColor, TRUE) ||
2120 !read_order_field_color(orderName, orderInfo, s, 4, &fastGlyph->foreColor, TRUE) ||
2121 !read_order_field_coord(orderName, orderInfo, s, 5, &fastGlyph->bkLeft, FALSE) ||
2122 !read_order_field_coord(orderName, orderInfo, s, 6, &fastGlyph->bkTop, FALSE) ||
2123 !read_order_field_coord(orderName, orderInfo, s, 7, &fastGlyph->bkRight, FALSE) ||
2124 !read_order_field_coord(orderName, orderInfo, s, 8, &fastGlyph->bkBottom, FALSE) ||
2125 !read_order_field_coord(orderName, orderInfo, s, 9, &fastGlyph->opLeft, FALSE) ||
2126 !read_order_field_coord(orderName, orderInfo, s, 10, &fastGlyph->opTop, FALSE) ||
2127 !read_order_field_coord(orderName, orderInfo, s, 11, &fastGlyph->opRight, FALSE) ||
2128 !read_order_field_coord(orderName, orderInfo, s, 12, &fastGlyph->opBottom, FALSE) ||
2129 !read_order_field_coord(orderName, orderInfo, s, 13, &fastGlyph->x, FALSE) ||
2130 !read_order_field_coord(orderName, orderInfo, s, 14, &fastGlyph->y, FALSE))
2133 if ((orderInfo->fieldFlags & ORDER_FIELD_15) != 0)
2135 const BYTE* src = NULL;
2138 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
2141 Stream_Read_UINT8(s, fastGlyph->cbData);
2143 src = Stream_ConstPointer(s);
2144 if (!Stream_SafeSeek(s, fastGlyph->cbData) || (fastGlyph->cbData == 0))
2147 CopyMemory(fastGlyph->data, src, fastGlyph->cbData);
2148 sub = Stream_StaticInit(&subbuffer, fastGlyph->data, fastGlyph->cbData);
2150 Stream_Read_UINT8(sub, glyph->cacheIndex);
2152 if (fastGlyph->cbData > 1)
2154 if (!update_read_2byte_signed(sub, &glyph->x) ||
2155 !update_read_2byte_signed(sub, &glyph->y) ||
2156 !update_read_2byte_unsigned(sub, &glyph->cx) ||
2157 !update_read_2byte_unsigned(sub, &glyph->cy))
2160 if ((glyph->cx == 0) || (glyph->cy == 0))
2162 WLog_ERR(TAG,
"GLYPH_DATA_V2::cx=%" PRIu32
", GLYPH_DATA_V2::cy=%" PRIu32,
2163 glyph->cx, glyph->cy);
2167 const size_t slen = Stream_GetRemainingLength(sub);
2168 if (slen > UINT32_MAX)
2170 glyph->cb = (UINT32)slen;
2173 BYTE* new_aj = (BYTE*)realloc(glyph->aj, glyph->cb);
2179 Stream_Read(sub, glyph->aj, glyph->cb);
2191 static BOOL update_read_polygon_sc_order(
const char* orderName,
wStream* s,
2194 UINT32 num = polygon_sc->numPoints;
2195 if (!read_order_field_coord(orderName, orderInfo, s, 1, &polygon_sc->xStart, FALSE) ||
2196 !read_order_field_coord(orderName, orderInfo, s, 2, &polygon_sc->yStart, FALSE) ||
2197 !read_order_field_byte(orderName, orderInfo, s, 3, &polygon_sc->bRop2, TRUE) ||
2198 !read_order_field_byte(orderName, orderInfo, s, 4, &polygon_sc->fillMode, TRUE) ||
2199 !read_order_field_color(orderName, orderInfo, s, 5, &polygon_sc->brushColor, TRUE) ||
2200 !read_order_field_byte(orderName, orderInfo, s, 6, &num, TRUE))
2203 if ((orderInfo->fieldFlags & ORDER_FIELD_07) != 0)
2208 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
2211 Stream_Read_UINT8(s, polygon_sc->cbData);
2213 polygon_sc->numPoints = num;
2214 return update_read_delta_points(s, &polygon_sc->points, polygon_sc->numPoints,
2215 get_checked_int16(polygon_sc->xStart),
2216 get_checked_int16(polygon_sc->yStart));
2218 if (num > polygon_sc->numPoints)
2220 WLog_ERR(TAG,
"%s numPoints %" PRIu32
" > %" PRIu32, orderName, num, polygon_sc->numPoints);
2223 polygon_sc->numPoints = num;
2227 static BOOL update_read_polygon_cb_order(
const char* orderName,
wStream* s,
2230 UINT32 num = polygon_cb->numPoints;
2231 if (!read_order_field_coord(orderName, orderInfo, s, 1, &polygon_cb->xStart, FALSE) ||
2232 !read_order_field_coord(orderName, orderInfo, s, 2, &polygon_cb->yStart, FALSE) ||
2233 !read_order_field_byte(orderName, orderInfo, s, 3, &polygon_cb->bRop2, TRUE) ||
2234 !read_order_field_byte(orderName, orderInfo, s, 4, &polygon_cb->fillMode, TRUE) ||
2235 !read_order_field_color(orderName, orderInfo, s, 5, &polygon_cb->backColor, TRUE) ||
2236 !read_order_field_color(orderName, orderInfo, s, 6, &polygon_cb->foreColor, TRUE))
2239 if (!update_read_brush(s, &polygon_cb->brush,
2240 get_checked_uint8((orderInfo->fieldFlags >> 6) & 0x1F)))
2243 if (!read_order_field_byte(orderName, orderInfo, s, 12, &num, TRUE))
2246 if ((orderInfo->fieldFlags & ORDER_FIELD_13) != 0)
2251 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
2254 Stream_Read_UINT8(s, polygon_cb->cbData);
2255 polygon_cb->numPoints = num;
2257 if (!update_read_delta_points(s, &polygon_cb->points, polygon_cb->numPoints,
2258 get_checked_int16(polygon_cb->xStart),
2259 get_checked_int16(polygon_cb->yStart)))
2263 if (num > polygon_cb->numPoints)
2265 WLog_ERR(TAG,
"%s numPoints %" PRIu32
" > %" PRIu32, orderName, num, polygon_cb->numPoints);
2268 polygon_cb->numPoints = num;
2270 polygon_cb->backMode = (polygon_cb->bRop2 & 0x80) ? BACKMODE_TRANSPARENT : BACKMODE_OPAQUE;
2271 polygon_cb->bRop2 = (polygon_cb->bRop2 & 0x1F);
2274 static BOOL update_read_ellipse_sc_order(
const char* orderName,
wStream* s,
2277 if (read_order_field_coord(orderName, orderInfo, s, 1, &ellipse_sc->leftRect, FALSE) &&
2278 read_order_field_coord(orderName, orderInfo, s, 2, &ellipse_sc->topRect, FALSE) &&
2279 read_order_field_coord(orderName, orderInfo, s, 3, &ellipse_sc->rightRect, FALSE) &&
2280 read_order_field_coord(orderName, orderInfo, s, 4, &ellipse_sc->bottomRect, FALSE) &&
2281 read_order_field_byte(orderName, orderInfo, s, 5, &ellipse_sc->bRop2, TRUE) &&
2282 read_order_field_byte(orderName, orderInfo, s, 6, &ellipse_sc->fillMode, TRUE) &&
2283 read_order_field_color(orderName, orderInfo, s, 7, &ellipse_sc->color, TRUE))
2287 static BOOL update_read_ellipse_cb_order(
const char* orderName,
wStream* s,
2290 if (read_order_field_coord(orderName, orderInfo, s, 1, &ellipse_cb->leftRect, FALSE) &&
2291 read_order_field_coord(orderName, orderInfo, s, 2, &ellipse_cb->topRect, FALSE) &&
2292 read_order_field_coord(orderName, orderInfo, s, 3, &ellipse_cb->rightRect, FALSE) &&
2293 read_order_field_coord(orderName, orderInfo, s, 4, &ellipse_cb->bottomRect, FALSE) &&
2294 read_order_field_byte(orderName, orderInfo, s, 5, &ellipse_cb->bRop2, TRUE) &&
2295 read_order_field_byte(orderName, orderInfo, s, 6, &ellipse_cb->fillMode, TRUE) &&
2296 read_order_field_color(orderName, orderInfo, s, 7, &ellipse_cb->backColor, TRUE) &&
2297 read_order_field_color(orderName, orderInfo, s, 8, &ellipse_cb->foreColor, TRUE) &&
2298 update_read_brush(s, &ellipse_cb->brush,
2299 get_checked_uint8((orderInfo->fieldFlags >> 8) & 0x1F)))
2305 WINPR_ATTR_MALLOC(free_cache_bitmap_order, 2)
2307 BOOL compressed, UINT16 flags)
2320 if (!Stream_CheckAndLogRequiredLength(TAG, s, 9))
2323 Stream_Read_UINT8(s, cache_bitmap->cacheId);
2324 Stream_Seek_UINT8(s);
2325 Stream_Read_UINT8(s, cache_bitmap->bitmapWidth);
2326 Stream_Read_UINT8(s, cache_bitmap->bitmapHeight);
2327 Stream_Read_UINT8(s, cache_bitmap->bitmapBpp);
2329 if ((cache_bitmap->bitmapBpp < 1) || (cache_bitmap->bitmapBpp > 32))
2331 WLog_Print(up->log, WLOG_ERROR,
"invalid bitmap bpp %" PRIu32
"", cache_bitmap->bitmapBpp);
2335 Stream_Read_UINT16(s, cache_bitmap->bitmapLength);
2336 Stream_Read_UINT16(s, cache_bitmap->cacheIndex);
2340 if ((flags & NO_BITMAP_COMPRESSION_HDR) == 0)
2342 BYTE* bitmapComprHdr = (BYTE*)&(cache_bitmap->bitmapComprHdr);
2344 if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
2347 Stream_Read(s, bitmapComprHdr, 8);
2348 cache_bitmap->bitmapLength -= 8;
2352 if (cache_bitmap->bitmapLength == 0)
2355 if (!Stream_CheckAndLogRequiredLength(TAG, s, cache_bitmap->bitmapLength))
2358 cache_bitmap->bitmapDataStream = malloc(cache_bitmap->bitmapLength);
2360 if (!cache_bitmap->bitmapDataStream)
2363 Stream_Read(s, cache_bitmap->bitmapDataStream, cache_bitmap->bitmapLength);
2364 cache_bitmap->compressed = compressed;
2365 return cache_bitmap;
2367 WINPR_PRAGMA_DIAG_PUSH
2368 WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
2369 free_cache_bitmap_order(update->context, cache_bitmap);
2370 WINPR_PRAGMA_DIAG_POP
2375 BOOL compressed,
const UINT16* flags)
2377 WINPR_ASSERT(cache_bitmap);
2378 WINPR_UNUSED(compressed);
2379 WINPR_UNUSED(flags);
2380 return 64 + cache_bitmap->bitmapLength;
2384 BOOL compressed, UINT16* flags)
2386 UINT32 bitmapLength = cache_bitmap->bitmapLength;
2387 size_t inf = update_approximate_cache_bitmap_order(cache_bitmap, compressed, flags);
2389 if (!Stream_EnsureRemainingCapacity(s, inf))
2392 *flags = NO_BITMAP_COMPRESSION_HDR;
2394 if ((*flags & NO_BITMAP_COMPRESSION_HDR) == 0)
2397 Stream_Write_UINT8(s, get_checked_uint8(cache_bitmap->cacheId));
2398 Stream_Write_UINT8(s, 0);
2399 Stream_Write_UINT8(s, get_checked_uint8(cache_bitmap->bitmapWidth));
2400 Stream_Write_UINT8(s,
2401 get_checked_uint8(cache_bitmap->bitmapHeight));
2402 Stream_Write_UINT8(s, get_checked_uint8(cache_bitmap->bitmapBpp));
2403 Stream_Write_UINT16(s, get_checked_uint16(bitmapLength));
2404 Stream_Write_UINT16(s, get_checked_uint16(cache_bitmap->cacheIndex));
2408 if ((*flags & NO_BITMAP_COMPRESSION_HDR) == 0)
2410 const BYTE* bitmapComprHdr = (
const BYTE*)&(cache_bitmap->bitmapComprHdr);
2411 Stream_Write(s, bitmapComprHdr, 8);
2415 Stream_Write(s, cache_bitmap->bitmapDataStream, bitmapLength);
2419 Stream_Write(s, cache_bitmap->bitmapDataStream, bitmapLength);
2425 WINPR_ATTR_MALLOC(free_cache_bitmap_v2_order, 2)
2427 BOOL compressed, UINT16 flags)
2430 BYTE bitsPerPixelId = 0;
2438 if (!cache_bitmap_v2)
2441 cache_bitmap_v2->cacheId = flags & 0x0003;
2442 cache_bitmap_v2->flags = (flags & 0xFF80) >> 7;
2443 bitsPerPixelId = (flags & 0x0078) >> 3;
2444 cache_bitmap_v2->bitmapBpp = get_cbr2_bpp(bitsPerPixelId, &rc);
2448 if (cache_bitmap_v2->flags & CBR2_PERSISTENT_KEY_PRESENT)
2450 if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
2453 Stream_Read_UINT32(s, cache_bitmap_v2->key1);
2454 Stream_Read_UINT32(s, cache_bitmap_v2->key2);
2457 if (cache_bitmap_v2->flags & CBR2_HEIGHT_SAME_AS_WIDTH)
2459 if (!update_read_2byte_unsigned(s, &cache_bitmap_v2->bitmapWidth))
2462 cache_bitmap_v2->bitmapHeight = cache_bitmap_v2->bitmapWidth;
2466 if (!update_read_2byte_unsigned(s, &cache_bitmap_v2->bitmapWidth) ||
2467 !update_read_2byte_unsigned(s, &cache_bitmap_v2->bitmapHeight))
2471 if (!update_read_4byte_unsigned(s, &cache_bitmap_v2->bitmapLength) ||
2472 !update_read_2byte_unsigned(s, &cache_bitmap_v2->cacheIndex))
2475 if (cache_bitmap_v2->flags & CBR2_DO_NOT_CACHE)
2476 cache_bitmap_v2->cacheIndex = BITMAP_CACHE_WAITING_LIST_INDEX;
2480 if (!(cache_bitmap_v2->flags & CBR2_NO_BITMAP_COMPRESSION_HDR))
2482 if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
2486 s, cache_bitmap_v2->cbCompFirstRowSize);
2488 s, cache_bitmap_v2->cbCompMainBodySize);
2489 Stream_Read_UINT16(s, cache_bitmap_v2->cbScanWidth);
2491 s, cache_bitmap_v2->cbUncompressedSize);
2492 cache_bitmap_v2->bitmapLength = cache_bitmap_v2->cbCompMainBodySize;
2496 if (cache_bitmap_v2->bitmapLength == 0)
2499 if (!Stream_CheckAndLogRequiredLength(TAG, s, cache_bitmap_v2->bitmapLength))
2502 if (cache_bitmap_v2->bitmapLength == 0)
2505 cache_bitmap_v2->bitmapDataStream = malloc(cache_bitmap_v2->bitmapLength);
2507 if (!cache_bitmap_v2->bitmapDataStream)
2510 Stream_Read(s, cache_bitmap_v2->bitmapDataStream, cache_bitmap_v2->bitmapLength);
2511 cache_bitmap_v2->compressed = compressed;
2512 return cache_bitmap_v2;
2514 WINPR_PRAGMA_DIAG_PUSH
2515 WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
2516 free_cache_bitmap_v2_order(update->context, cache_bitmap_v2);
2517 WINPR_PRAGMA_DIAG_POP
2522 BOOL compressed,
const UINT16* flags)
2524 WINPR_ASSERT(cache_bitmap_v2);
2525 WINPR_UNUSED(flags);
2526 WINPR_UNUSED(compressed);
2528 return 64 + cache_bitmap_v2->bitmapLength;
2532 BOOL compressed, UINT16* flags)
2535 BYTE bitsPerPixelId = 0;
2537 if (!Stream_EnsureRemainingCapacity(
2538 s, update_approximate_cache_bitmap_v2_order(cache_bitmap_v2, compressed, flags)))
2541 bitsPerPixelId = get_bpp_bmf(cache_bitmap_v2->bitmapBpp, &rc);
2544 WINPR_ASSERT(cache_bitmap_v2->cacheId <= 3);
2545 WINPR_ASSERT(bitsPerPixelId <= 0x0f);
2546 WINPR_ASSERT(cache_bitmap_v2->flags <= 0x1FF);
2547 *flags = (UINT16)((cache_bitmap_v2->cacheId & 0x0003) | ((bitsPerPixelId << 3) & 0xFFFF) |
2548 ((cache_bitmap_v2->flags << 7) & 0xFF80));
2550 if (cache_bitmap_v2->flags & CBR2_PERSISTENT_KEY_PRESENT)
2552 Stream_Write_UINT32(s, cache_bitmap_v2->key1);
2553 Stream_Write_UINT32(s, cache_bitmap_v2->key2);
2556 if (cache_bitmap_v2->flags & CBR2_HEIGHT_SAME_AS_WIDTH)
2558 if (!update_write_2byte_unsigned(s, cache_bitmap_v2->bitmapWidth))
2563 if (!update_write_2byte_unsigned(s, cache_bitmap_v2->bitmapWidth) ||
2564 !update_write_2byte_unsigned(s, cache_bitmap_v2->bitmapHeight))
2568 if (cache_bitmap_v2->flags & CBR2_DO_NOT_CACHE)
2569 cache_bitmap_v2->cacheIndex = BITMAP_CACHE_WAITING_LIST_INDEX;
2571 if (!update_write_4byte_unsigned(s, cache_bitmap_v2->bitmapLength) ||
2572 !update_write_2byte_unsigned(s, cache_bitmap_v2->cacheIndex))
2577 if (!(cache_bitmap_v2->flags & CBR2_NO_BITMAP_COMPRESSION_HDR))
2579 Stream_Write_UINT16(
2580 s, get_checked_uint16(
2581 cache_bitmap_v2->cbCompFirstRowSize));
2582 Stream_Write_UINT16(
2583 s, get_checked_uint16(
2584 cache_bitmap_v2->cbCompMainBodySize));
2585 Stream_Write_UINT16(
2586 s, get_checked_uint16(cache_bitmap_v2->cbScanWidth));
2587 Stream_Write_UINT16(
2588 s, get_checked_uint16(
2589 cache_bitmap_v2->cbUncompressedSize));
2590 cache_bitmap_v2->bitmapLength = cache_bitmap_v2->cbCompMainBodySize;
2593 if (!Stream_EnsureRemainingCapacity(s, cache_bitmap_v2->bitmapLength))
2596 Stream_Write(s, cache_bitmap_v2->bitmapDataStream, cache_bitmap_v2->bitmapLength);
2600 if (!Stream_EnsureRemainingCapacity(s, cache_bitmap_v2->bitmapLength))
2603 Stream_Write(s, cache_bitmap_v2->bitmapDataStream, cache_bitmap_v2->bitmapLength);
2606 cache_bitmap_v2->compressed = compressed;
2610 WINPR_ATTR_MALLOC(free_cache_bitmap_v3_order, 2)
2615 BYTE bitsPerPixelId = 0;
2618 BYTE* new_data = NULL;
2627 if (!cache_bitmap_v3)
2630 cache_bitmap_v3->cacheId = flags & 0x00000003;
2631 cache_bitmap_v3->flags = (flags & 0x0000FF80) >> 7;
2632 bitsPerPixelId = (flags & 0x00000078) >> 3;
2633 cache_bitmap_v3->bpp = get_cbr2_bpp(bitsPerPixelId, &rc);
2637 if (!Stream_CheckAndLogRequiredLength(TAG, s, 21))
2640 Stream_Read_UINT16(s, cache_bitmap_v3->cacheIndex);
2641 Stream_Read_UINT32(s, cache_bitmap_v3->key1);
2642 Stream_Read_UINT32(s, cache_bitmap_v3->key2);
2643 bitmapData = &cache_bitmap_v3->bitmapData;
2644 Stream_Read_UINT8(s, bitmapData->bpp);
2646 if ((bitmapData->bpp < 1) || (bitmapData->bpp > 32))
2648 WLog_Print(up->log, WLOG_ERROR,
"invalid bpp value %" PRIu32
"", bitmapData->bpp);
2652 Stream_Seek_UINT8(s);
2653 Stream_Seek_UINT8(s);
2654 Stream_Read_UINT8(s, bitmapData->codecID);
2655 Stream_Read_UINT16(s, bitmapData->width);
2656 Stream_Read_UINT16(s, bitmapData->height);
2657 Stream_Read_UINT32(s, new_len);
2659 if ((new_len == 0) || (!Stream_CheckAndLogRequiredLength(TAG, s, new_len)))
2662 new_data = (BYTE*)realloc(bitmapData->data, new_len);
2667 bitmapData->data = new_data;
2668 bitmapData->length = new_len;
2669 Stream_Read(s, bitmapData->data, bitmapData->length);
2670 return cache_bitmap_v3;
2672 WINPR_PRAGMA_DIAG_PUSH
2673 WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
2674 free_cache_bitmap_v3_order(update->context, cache_bitmap_v3);
2675 WINPR_PRAGMA_DIAG_POP
2683 return 64 + bitmapData->length;
2690 BYTE bitsPerPixelId = 0;
2693 if (!Stream_EnsureRemainingCapacity(
2694 s, update_approximate_cache_bitmap_v3_order(cache_bitmap_v3, flags)))
2697 bitmapData = &cache_bitmap_v3->bitmapData;
2698 bitsPerPixelId = get_bpp_bmf(cache_bitmap_v3->bpp, &rc);
2701 *flags = (cache_bitmap_v3->cacheId & 0x00000003) |
2702 ((cache_bitmap_v3->flags << 7) & 0x0000FF80) | ((bitsPerPixelId << 3) & 0x00000078);
2703 Stream_Write_UINT16(s,
2704 get_checked_uint16(cache_bitmap_v3->cacheIndex));
2705 Stream_Write_UINT32(s, cache_bitmap_v3->key1);
2706 Stream_Write_UINT32(s, cache_bitmap_v3->key2);
2707 Stream_Write_UINT8(s, get_checked_uint8(bitmapData->bpp));
2708 Stream_Write_UINT8(s, 0);
2709 Stream_Write_UINT8(s, 0);
2710 Stream_Write_UINT8(s, get_checked_uint8(bitmapData->codecID));
2711 Stream_Write_UINT16(s, get_checked_uint16(bitmapData->width));
2712 Stream_Write_UINT16(s, get_checked_uint16(bitmapData->height));
2713 Stream_Write_UINT32(s, bitmapData->length);
2714 Stream_Write(s, bitmapData->data, bitmapData->length);
2718 WINPR_ATTR_MALLOC(free_cache_color_table_order, 2)
2722 UINT32* colorTable = NULL;
2725 if (!cache_color_table)
2728 if (!Stream_CheckAndLogRequiredLength(TAG, s, 3))
2731 Stream_Read_UINT8(s, cache_color_table->cacheIndex);
2732 Stream_Read_UINT16(s, cache_color_table->numberColors);
2734 if (cache_color_table->numberColors != 256)
2740 if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, cache_color_table->numberColors, 4ull))
2743 colorTable = (UINT32*)&cache_color_table->colorTable;
2745 for (UINT32 i = 0; i < cache_color_table->numberColors; i++)
2746 update_read_color_quad(s, &colorTable[i]);
2748 return cache_color_table;
2750 WINPR_PRAGMA_DIAG_PUSH
2751 WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
2752 free_cache_color_table_order(update->context, cache_color_table);
2753 WINPR_PRAGMA_DIAG_POP
2758 const UINT16* flags)
2760 WINPR_UNUSED(cache_color_table);
2761 WINPR_UNUSED(flags);
2763 return 16 + (256 * 4);
2766 BOOL update_write_cache_color_table_order(
wStream* s,
2771 const UINT32* colorTable = NULL;
2773 if (cache_color_table->numberColors != 256)
2776 inf = update_approximate_cache_color_table_order(cache_color_table, flags);
2778 if (!Stream_EnsureRemainingCapacity(s, inf))
2781 Stream_Write_UINT8(s,
2782 get_checked_uint8(cache_color_table->cacheIndex));
2783 Stream_Write_UINT16(
2784 s, get_checked_uint16(cache_color_table->numberColors));
2785 colorTable = (
const UINT32*)&cache_color_table->colorTable;
2787 for (
size_t i = 0; i < cache_color_table->numberColors; i++)
2789 update_write_color_quad(s, colorTable[i]);
2798 WINPR_ASSERT(update);
2801 if (!cache_glyph_order)
2804 if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
2807 Stream_Read_UINT8(s, cache_glyph_order->cacheId);
2808 Stream_Read_UINT8(s, cache_glyph_order->cGlyphs);
2810 for (UINT32 i = 0; i < cache_glyph_order->cGlyphs; i++)
2812 GLYPH_DATA* glyph = &cache_glyph_order->glyphData[i];
2814 if (!Stream_CheckAndLogRequiredLength(TAG, s, 10))
2817 Stream_Read_UINT16(s, glyph->cacheIndex);
2818 Stream_Read_INT16(s, glyph->x);
2819 Stream_Read_INT16(s, glyph->y);
2820 Stream_Read_UINT16(s, glyph->cx);
2821 Stream_Read_UINT16(s, glyph->cy);
2822 glyph->cb = ((glyph->cx + 7) / 8) * glyph->cy;
2823 glyph->cb += ((glyph->cb % 4) > 0) ? 4 - (glyph->cb % 4) : 0;
2825 if (!Stream_CheckAndLogRequiredLength(TAG, s, glyph->cb))
2828 glyph->aj = (BYTE*)malloc(glyph->cb);
2833 Stream_Read(s, glyph->aj, glyph->cb);
2836 if ((flags & CG_GLYPH_UNICODE_PRESENT) && (cache_glyph_order->cGlyphs > 0))
2838 cache_glyph_order->unicodeCharacters = calloc(cache_glyph_order->cGlyphs,
sizeof(WCHAR));
2840 if (!cache_glyph_order->unicodeCharacters)
2843 if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, cache_glyph_order->cGlyphs,
2847 Stream_Read_UTF16_String(s, cache_glyph_order->unicodeCharacters,
2848 cache_glyph_order->cGlyphs);
2851 return cache_glyph_order;
2853 free_cache_glyph_order(update->context, cache_glyph_order);
2857 size_t update_approximate_cache_glyph_order(
const CACHE_GLYPH_ORDER* cache_glyph,
2858 const UINT16* flags)
2860 WINPR_ASSERT(cache_glyph);
2861 WINPR_UNUSED(flags);
2862 return 2 + cache_glyph->cGlyphs * 32;
2868 size_t inf = update_approximate_cache_glyph_order(cache_glyph, flags);
2870 if (!Stream_EnsureRemainingCapacity(s, inf))
2873 Stream_Write_UINT8(s, get_checked_uint8(cache_glyph->cacheId));
2874 Stream_Write_UINT8(s, get_checked_uint8(cache_glyph->cGlyphs));
2876 for (UINT32 i = 0; i < cache_glyph->cGlyphs; i++)
2879 glyph = &cache_glyph->glyphData[i];
2880 Stream_Write_UINT16(s, get_checked_uint16(glyph->cacheIndex));
2881 Stream_Write_INT16(s, glyph->x);
2882 Stream_Write_INT16(s, glyph->y);
2883 Stream_Write_UINT16(s, get_checked_uint16(glyph->cx));
2884 Stream_Write_UINT16(s, get_checked_uint16(glyph->cy));
2885 cb = ((glyph->cx + 7) / 8) * glyph->cy;
2886 cb += ((cb % 4) > 0) ? 4 - (cb % 4) : 0;
2887 Stream_Write(s, glyph->aj, cb);
2890 if (*flags & CG_GLYPH_UNICODE_PRESENT)
2892 Stream_Zero(s, 2ULL * cache_glyph->cGlyphs);
2903 if (!cache_glyph_v2)
2906 cache_glyph_v2->cacheId = (flags & 0x000F);
2907 cache_glyph_v2->flags = (flags & 0x00F0) >> 4;
2908 cache_glyph_v2->cGlyphs = (flags & 0xFF00) >> 8;
2910 for (UINT32 i = 0; i < cache_glyph_v2->cGlyphs; i++)
2914 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
2917 Stream_Read_UINT8(s, glyph->cacheIndex);
2919 if (!update_read_2byte_signed(s, &glyph->x) || !update_read_2byte_signed(s, &glyph->y) ||
2920 !update_read_2byte_unsigned(s, &glyph->cx) ||
2921 !update_read_2byte_unsigned(s, &glyph->cy))
2926 glyph->cb = ((glyph->cx + 7) / 8) * glyph->cy;
2927 glyph->cb += ((glyph->cb % 4) > 0) ? 4 - (glyph->cb % 4) : 0;
2929 if (!Stream_CheckAndLogRequiredLength(TAG, s, glyph->cb))
2932 glyph->aj = (BYTE*)malloc(glyph->cb);
2937 Stream_Read(s, glyph->aj, glyph->cb);
2940 if ((flags & CG_GLYPH_UNICODE_PRESENT) && (cache_glyph_v2->cGlyphs > 0))
2942 cache_glyph_v2->unicodeCharacters = calloc(cache_glyph_v2->cGlyphs,
sizeof(WCHAR));
2944 if (!cache_glyph_v2->unicodeCharacters)
2947 if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, cache_glyph_v2->cGlyphs,
sizeof(WCHAR)))
2950 Stream_Read_UTF16_String(s, cache_glyph_v2->unicodeCharacters, cache_glyph_v2->cGlyphs);
2953 return cache_glyph_v2;
2955 free_cache_glyph_v2_order(update->context, cache_glyph_v2);
2960 const UINT16* flags)
2962 WINPR_ASSERT(cache_glyph_v2);
2963 WINPR_UNUSED(flags);
2964 return 8 + cache_glyph_v2->cGlyphs * 32;
2970 size_t inf = update_approximate_cache_glyph_v2_order(cache_glyph_v2, flags);
2972 if (!Stream_EnsureRemainingCapacity(s, inf))
2975 WINPR_ASSERT(cache_glyph_v2->cacheId <= 0x0F);
2976 WINPR_ASSERT(cache_glyph_v2->flags <= 0x0F);
2977 WINPR_ASSERT(cache_glyph_v2->cGlyphs <= 0xFF);
2978 *flags = (UINT16)((cache_glyph_v2->cacheId & 0x000F) | ((cache_glyph_v2->flags & 0x000F) << 4) |
2979 ((cache_glyph_v2->cGlyphs & 0x00FF) << 8));
2981 for (UINT32 i = 0; i < cache_glyph_v2->cGlyphs; i++)
2985 Stream_Write_UINT8(s, get_checked_uint8(glyph->cacheIndex));
2987 if (!update_write_2byte_signed(s, glyph->x) || !update_write_2byte_signed(s, glyph->y) ||
2988 !update_write_2byte_unsigned(s, glyph->cx) ||
2989 !update_write_2byte_unsigned(s, glyph->cy))
2994 cb = ((glyph->cx + 7) / 8) * glyph->cy;
2995 cb += ((cb % 4) > 0) ? 4 - (cb % 4) : 0;
2996 Stream_Write(s, glyph->aj, cb);
2999 if (*flags & CG_GLYPH_UNICODE_PRESENT)
3001 Stream_Zero(s, 2ULL * cache_glyph_v2->cGlyphs);
3006 static BOOL update_decompress_brush(
wStream* s, BYTE* output,
size_t outSize, BYTE bpp)
3009 const BYTE* palette = Stream_PointerAs(s,
const BYTE) + 16;
3010 const size_t bytesPerPixel = ((bpp + 1) / 8);
3012 if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, 4ULL + bytesPerPixel, 4ULL))
3015 for (
size_t y = 0; y < 7; y++)
3017 for (
size_t x = 0; x < 8; x++)
3020 Stream_Read_UINT8(s,
byte);
3022 const uint32_t index = ((
byte >> ((3 - (x % 4)) * 2)) & 0x03);
3024 for (
size_t k = 0; k < bytesPerPixel; k++)
3026 const size_t dstIndex = ((8ULL * (7ULL - y) + x) * bytesPerPixel) + k;
3027 const size_t srcIndex = (index * bytesPerPixel) + k;
3028 if (dstIndex >= outSize)
3030 output[dstIndex] = palette[srcIndex];
3037 static BOOL update_compress_brush(
wStream* s,
const BYTE* input, BYTE bpp)
3044 BYTE iBitmapFormat = 0;
3045 BOOL compressed = FALSE;
3052 if (!Stream_CheckAndLogRequiredLength(TAG, s, 6))
3055 Stream_Read_UINT8(s, cache_brush->index);
3056 Stream_Read_UINT8(s, iBitmapFormat);
3058 cache_brush->bpp = get_bmf_bpp(iBitmapFormat, &rc);
3062 Stream_Read_UINT8(s, cache_brush->cx);
3063 Stream_Read_UINT8(s, cache_brush->cy);
3066 Stream_Read_UINT8(s, cache_brush->style);
3067 Stream_Read_UINT8(s, cache_brush->length);
3069 if ((cache_brush->cx == 8) && (cache_brush->cy == 8))
3071 if (cache_brush->bpp == 1)
3073 if (cache_brush->length != 8)
3075 WLog_Print(up->log, WLOG_ERROR,
"incompatible 1bpp brush of length:%" PRIu32
"",
3076 cache_brush->length);
3080 if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
3084 for (
int i = 7; i >= 0; i--)
3085 Stream_Read_UINT8(s, cache_brush->data[i]);
3089 if ((iBitmapFormat == BMF_8BPP) && (cache_brush->length == 20))
3091 else if ((iBitmapFormat == BMF_16BPP) && (cache_brush->length == 24))
3093 else if ((iBitmapFormat == BMF_24BPP) && (cache_brush->length == 28))
3095 else if ((iBitmapFormat == BMF_32BPP) && (cache_brush->length == 32))
3098 if (compressed != FALSE)
3101 if (!update_decompress_brush(s, cache_brush->data,
sizeof(cache_brush->data),
3102 get_checked_uint8(cache_brush->bpp)))
3108 UINT32 scanline = (cache_brush->bpp / 8) * 8;
3110 if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, scanline, 8ull))
3113 for (
int i = 7; i >= 0; i--)
3115 Stream_Read(s, &cache_brush->data[1LL * i * scanline], scanline);
3123 free_cache_brush_order(update->context, cache_brush);
3127 size_t update_approximate_cache_brush_order(
const CACHE_BRUSH_ORDER* cache_brush,
3128 const UINT16* flags)
3130 WINPR_UNUSED(cache_brush);
3131 WINPR_UNUSED(flags);
3138 BYTE iBitmapFormat = 0;
3140 BOOL compressed = FALSE;
3142 if (!Stream_EnsureRemainingCapacity(s,
3143 update_approximate_cache_brush_order(cache_brush, flags)))
3146 iBitmapFormat = get_bpp_bmf(cache_brush->bpp, &rc);
3149 Stream_Write_UINT8(s, get_checked_uint8(cache_brush->index));
3150 Stream_Write_UINT8(s, iBitmapFormat);
3151 Stream_Write_UINT8(s, get_checked_uint8(cache_brush->cx));
3152 Stream_Write_UINT8(s, get_checked_uint8(cache_brush->cy));
3153 Stream_Write_UINT8(s, get_checked_uint8(cache_brush->style));
3154 Stream_Write_UINT8(s, get_checked_uint8(cache_brush->length));
3156 if ((cache_brush->cx == 8) && (cache_brush->cy == 8))
3158 if (cache_brush->bpp == 1)
3160 if (cache_brush->length != 8)
3162 WLog_ERR(TAG,
"incompatible 1bpp brush of length:%" PRIu32
"", cache_brush->length);
3166 for (
int i = 7; i >= 0; i--)
3168 Stream_Write_UINT8(s, cache_brush->data[i]);
3173 if ((iBitmapFormat == BMF_8BPP) && (cache_brush->length == 20))
3175 else if ((iBitmapFormat == BMF_16BPP) && (cache_brush->length == 24))
3177 else if ((iBitmapFormat == BMF_32BPP) && (cache_brush->length == 32))
3180 if (compressed != FALSE)
3183 if (!update_compress_brush(s, cache_brush->data,
3184 get_checked_uint8(cache_brush->bpp)))
3190 const size_t scanline = 8ULL * (cache_brush->bpp / 8);
3192 for (
size_t i = 0; i <= 7; i++)
3194 Stream_Write(s, &cache_brush->data[1LL * (7 - i) * scanline], scanline);
3204 update_read_create_offscreen_bitmap_order(
wStream* s,
3208 BOOL deleteListPresent = 0;
3211 if (!Stream_CheckAndLogRequiredLength(TAG, s, 6))
3214 Stream_Read_UINT16(s, flags);
3215 create_offscreen_bitmap->id = flags & 0x7FFF;
3216 deleteListPresent = (flags & 0x8000) ? TRUE : FALSE;
3217 Stream_Read_UINT16(s, create_offscreen_bitmap->cx);
3218 Stream_Read_UINT16(s, create_offscreen_bitmap->cy);
3219 deleteList = &(create_offscreen_bitmap->deleteList);
3221 if ((create_offscreen_bitmap->cx == 0) || (create_offscreen_bitmap->cy == 0))
3223 WLog_ERR(TAG,
"Invalid OFFSCREEN_DELETE_LIST: cx=%" PRIu16
", cy=%" PRIu16,
3224 create_offscreen_bitmap->cx, create_offscreen_bitmap->cy);
3228 if (deleteListPresent)
3230 if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
3233 Stream_Read_UINT16(s, deleteList->cIndices);
3235 if (deleteList->cIndices > deleteList->sIndices)
3237 UINT16* new_indices = NULL;
3238 new_indices = (UINT16*)realloc(deleteList->indices, 2ULL * deleteList->cIndices);
3243 deleteList->sIndices = deleteList->cIndices;
3244 deleteList->indices = new_indices;
3247 if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, deleteList->cIndices, 2ull))
3250 for (UINT32 i = 0; i < deleteList->cIndices; i++)
3252 Stream_Read_UINT16(s, deleteList->indices[i]);
3257 deleteList->cIndices = 0;
3263 size_t update_approximate_create_offscreen_bitmap_order(
3268 WINPR_ASSERT(create_offscreen_bitmap);
3270 deleteList = &(create_offscreen_bitmap->deleteList);
3271 WINPR_ASSERT(deleteList);
3273 return 32 + deleteList->cIndices * 2;
3276 BOOL update_write_create_offscreen_bitmap_order(
3280 BOOL deleteListPresent = 0;
3283 if (!Stream_EnsureRemainingCapacity(
3284 s, update_approximate_create_offscreen_bitmap_order(create_offscreen_bitmap)))
3287 deleteList = &(create_offscreen_bitmap->deleteList);
3288 flags = create_offscreen_bitmap->id & 0x7FFF;
3289 deleteListPresent = (deleteList->cIndices > 0) ? TRUE : FALSE;
3291 if (deleteListPresent)
3294 Stream_Write_UINT16(s, flags);
3295 Stream_Write_UINT16(s, get_checked_uint16(create_offscreen_bitmap->cx));
3296 Stream_Write_UINT16(s, get_checked_uint16(create_offscreen_bitmap->cy));
3298 if (deleteListPresent)
3300 Stream_Write_UINT16(s, get_checked_uint16(deleteList->cIndices));
3302 for (
size_t i = 0; i < deleteList->cIndices; i++)
3304 Stream_Write_UINT16(s, deleteList->indices[i]);
3312 if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
3315 Stream_Read_UINT16(s, switch_surface->bitmapId);
3324 size_t inf = update_approximate_switch_surface_order(switch_surface);
3326 if (!Stream_EnsureRemainingCapacity(s, inf))
3329 WINPR_ASSERT(switch_surface->bitmapId <= UINT16_MAX);
3330 Stream_Write_UINT16(s, (UINT16)switch_surface->bitmapId);
3334 update_read_create_nine_grid_bitmap_order(
wStream* s,
3339 if (!Stream_CheckAndLogRequiredLength(TAG, s, 19))
3342 Stream_Read_UINT8(s, create_nine_grid_bitmap->bitmapBpp);
3344 if ((create_nine_grid_bitmap->bitmapBpp < 1) || (create_nine_grid_bitmap->bitmapBpp > 32))
3346 WLog_ERR(TAG,
"invalid bpp value %" PRIu32
"", create_nine_grid_bitmap->bitmapBpp);
3350 Stream_Read_UINT16(s, create_nine_grid_bitmap->bitmapId);
3351 nineGridInfo = &(create_nine_grid_bitmap->nineGridInfo);
3352 Stream_Read_UINT32(s, nineGridInfo->flFlags);
3353 Stream_Read_UINT16(s, nineGridInfo->ulLeftWidth);
3354 Stream_Read_UINT16(s, nineGridInfo->ulRightWidth);
3355 Stream_Read_UINT16(s, nineGridInfo->ulTopHeight);
3356 Stream_Read_UINT16(s, nineGridInfo->ulBottomHeight);
3357 update_read_colorref(s, &nineGridInfo->crTransparent);
3362 if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
3365 Stream_Read_UINT32(s, frame_marker->action);
3368 static BOOL update_read_stream_bitmap_first_order(
wStream* s,
3371 if (!Stream_CheckAndLogRequiredLength(TAG, s, 10))
3374 Stream_Read_UINT8(s, stream_bitmap_first->bitmapFlags);
3375 Stream_Read_UINT8(s, stream_bitmap_first->bitmapBpp);
3377 if ((stream_bitmap_first->bitmapBpp < 1) || (stream_bitmap_first->bitmapBpp > 32))
3379 WLog_ERR(TAG,
"invalid bpp value %" PRIu32
"", stream_bitmap_first->bitmapBpp);
3383 Stream_Read_UINT16(s, stream_bitmap_first->bitmapType);
3384 Stream_Read_UINT16(s, stream_bitmap_first->bitmapWidth);
3385 Stream_Read_UINT16(s, stream_bitmap_first->bitmapHeight);
3387 if (stream_bitmap_first->bitmapFlags & STREAM_BITMAP_V2)
3389 if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
3392 Stream_Read_UINT32(s, stream_bitmap_first->bitmapSize);
3396 if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
3399 Stream_Read_UINT16(s, stream_bitmap_first->bitmapSize);
3402 FIELD_SKIP_BUFFER16(
3403 s, stream_bitmap_first->bitmapBlockSize);
3406 static BOOL update_read_stream_bitmap_next_order(
wStream* s,
3409 if (!Stream_CheckAndLogRequiredLength(TAG, s, 5))
3412 Stream_Read_UINT8(s, stream_bitmap_next->bitmapFlags);
3413 Stream_Read_UINT16(s, stream_bitmap_next->bitmapType);
3414 FIELD_SKIP_BUFFER16(
3415 s, stream_bitmap_next->bitmapBlockSize);
3418 static BOOL update_read_draw_gdiplus_first_order(
wStream* s,
3421 if (!Stream_CheckAndLogRequiredLength(TAG, s, 11))
3424 Stream_Seek_UINT8(s);
3425 Stream_Read_UINT16(s, draw_gdiplus_first->cbSize);
3426 Stream_Read_UINT32(s, draw_gdiplus_first->cbTotalSize);
3427 Stream_Read_UINT32(s, draw_gdiplus_first->cbTotalEmfSize);
3428 return Stream_SafeSeek(s, draw_gdiplus_first->cbSize);
3430 static BOOL update_read_draw_gdiplus_next_order(
wStream* s,
3433 if (!Stream_CheckAndLogRequiredLength(TAG, s, 3))
3436 Stream_Seek_UINT8(s);
3437 FIELD_SKIP_BUFFER16(s, draw_gdiplus_next->cbSize);
3442 if (!Stream_CheckAndLogRequiredLength(TAG, s, 11))
3445 Stream_Seek_UINT8(s);
3446 Stream_Read_UINT16(s, draw_gdiplus_end->cbSize);
3447 Stream_Read_UINT32(s, draw_gdiplus_end->cbTotalSize);
3448 Stream_Read_UINT32(s, draw_gdiplus_end->cbTotalEmfSize);
3449 return Stream_SafeSeek(s, draw_gdiplus_end->cbSize);
3452 update_read_draw_gdiplus_cache_first_order(
wStream* s,
3455 if (!Stream_CheckAndLogRequiredLength(TAG, s, 11))
3458 Stream_Read_UINT8(s, draw_gdiplus_cache_first->flags);
3459 Stream_Read_UINT16(s, draw_gdiplus_cache_first->cacheType);
3460 Stream_Read_UINT16(s, draw_gdiplus_cache_first->cacheIndex);
3461 Stream_Read_UINT16(s, draw_gdiplus_cache_first->cbSize);
3462 Stream_Read_UINT32(s, draw_gdiplus_cache_first->cbTotalSize);
3463 return Stream_SafeSeek(s, draw_gdiplus_cache_first->cbSize);
3466 update_read_draw_gdiplus_cache_next_order(
wStream* s,
3469 if (!Stream_CheckAndLogRequiredLength(TAG, s, 7))
3472 Stream_Read_UINT8(s, draw_gdiplus_cache_next->flags);
3473 Stream_Read_UINT16(s, draw_gdiplus_cache_next->cacheType);
3474 Stream_Read_UINT16(s, draw_gdiplus_cache_next->cacheIndex);
3475 FIELD_SKIP_BUFFER16(s, draw_gdiplus_cache_next->cbSize);
3479 update_read_draw_gdiplus_cache_end_order(
wStream* s,
3482 if (!Stream_CheckAndLogRequiredLength(TAG, s, 11))
3485 Stream_Read_UINT8(s, draw_gdiplus_cache_end->flags);
3486 Stream_Read_UINT16(s, draw_gdiplus_cache_end->cacheType);
3487 Stream_Read_UINT16(s, draw_gdiplus_cache_end->cacheIndex);
3488 Stream_Read_UINT16(s, draw_gdiplus_cache_end->cbSize);
3489 Stream_Read_UINT32(s, draw_gdiplus_cache_end->cbTotalSize);
3490 return Stream_SafeSeek(s, draw_gdiplus_cache_end->cbSize);
3492 static BOOL update_read_field_flags(
wStream* s, UINT32* fieldFlags, BYTE flags, BYTE fieldBytes)
3494 if (flags & ORDER_ZERO_FIELD_BYTE_BIT0)
3497 if (flags & ORDER_ZERO_FIELD_BYTE_BIT1)
3505 if (!Stream_CheckAndLogRequiredLength(TAG, s, fieldBytes))
3510 for (
size_t i = 0; i < fieldBytes; i++)
3512 const UINT32
byte = Stream_Get_UINT8(s);
3513 *fieldFlags |= (
byte << (i * 8ULL)) & 0xFFFFFFFF;
3518 BOOL update_write_field_flags(
wStream* s, UINT32 fieldFlags, BYTE flags, BYTE fieldBytes)
3522 if (fieldBytes == 1)
3524 byte = fieldFlags & 0xFF;
3525 Stream_Write_UINT8(s,
byte);
3527 else if (fieldBytes == 2)
3529 byte = fieldFlags & 0xFF;
3530 Stream_Write_UINT8(s,
byte);
3531 byte = (fieldFlags >> 8) & 0xFF;
3532 Stream_Write_UINT8(s,
byte);
3534 else if (fieldBytes == 3)
3536 byte = fieldFlags & 0xFF;
3537 Stream_Write_UINT8(s,
byte);
3538 byte = (fieldFlags >> 8) & 0xFF;
3539 Stream_Write_UINT8(s,
byte);
3540 byte = (fieldFlags >> 16) & 0xFF;
3541 Stream_Write_UINT8(s,
byte);
3550 static BOOL update_read_bounds(
wStream* s, rdpBounds* bounds)
3554 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
3557 Stream_Read_UINT8(s, flags);
3559 if (flags & BOUND_LEFT)
3561 if (!update_read_coord(s, &bounds->left, FALSE))
3564 else if (flags & BOUND_DELTA_LEFT)
3566 if (!update_read_coord(s, &bounds->left, TRUE))
3570 if (flags & BOUND_TOP)
3572 if (!update_read_coord(s, &bounds->top, FALSE))
3575 else if (flags & BOUND_DELTA_TOP)
3577 if (!update_read_coord(s, &bounds->top, TRUE))
3581 if (flags & BOUND_RIGHT)
3583 if (!update_read_coord(s, &bounds->right, FALSE))
3586 else if (flags & BOUND_DELTA_RIGHT)
3588 if (!update_read_coord(s, &bounds->right, TRUE))
3592 if (flags & BOUND_BOTTOM)
3594 if (!update_read_coord(s, &bounds->bottom, FALSE))
3597 else if (flags & BOUND_DELTA_BOTTOM)
3599 if (!update_read_coord(s, &bounds->bottom, TRUE))
3607 WINPR_ASSERT(orderInfo);
3609 if (!(orderInfo->controlFlags & ORDER_BOUNDS))
3612 if (orderInfo->controlFlags & ORDER_ZERO_BOUNDS_DELTAS)
3615 Stream_Write_UINT8(s, get_checked_uint8(orderInfo->boundsFlags));
3617 if (orderInfo->boundsFlags & BOUND_LEFT)
3619 if (!update_write_coord(s, orderInfo->bounds.left))
3622 else if (orderInfo->boundsFlags & BOUND_DELTA_LEFT)
3626 if (orderInfo->boundsFlags & BOUND_TOP)
3628 if (!update_write_coord(s, orderInfo->bounds.top))
3631 else if (orderInfo->boundsFlags & BOUND_DELTA_TOP)
3635 if (orderInfo->boundsFlags & BOUND_RIGHT)
3637 if (!update_write_coord(s, orderInfo->bounds.right))
3640 else if (orderInfo->boundsFlags & BOUND_DELTA_RIGHT)
3644 if (orderInfo->boundsFlags & BOUND_BOTTOM)
3646 if (!update_write_coord(s, orderInfo->bounds.bottom))
3649 else if (orderInfo->boundsFlags & BOUND_DELTA_BOTTOM)
3656 static BOOL read_primary_order(wLog* log,
const char* orderName,
wStream* s,
3657 const ORDER_INFO* orderInfo, rdpPrimaryUpdate* primary_pub)
3662 if (!s || !orderInfo || !orderName)
3665 switch (orderInfo->orderType)
3667 case ORDER_TYPE_DSTBLT:
3668 rc = update_read_dstblt_order(orderName, s, orderInfo, &(primary->dstblt));
3671 case ORDER_TYPE_PATBLT:
3672 rc = update_read_patblt_order(orderName, s, orderInfo, &(primary->patblt));
3675 case ORDER_TYPE_SCRBLT:
3676 rc = update_read_scrblt_order(orderName, s, orderInfo, &(primary->scrblt));
3679 case ORDER_TYPE_OPAQUE_RECT:
3680 rc = update_read_opaque_rect_order(orderName, s, orderInfo, &(primary->opaque_rect));
3683 case ORDER_TYPE_DRAW_NINE_GRID:
3684 rc = update_read_draw_nine_grid_order(orderName, s, orderInfo,
3685 &(primary->draw_nine_grid));
3688 case ORDER_TYPE_MULTI_DSTBLT:
3689 rc = update_read_multi_dstblt_order(orderName, s, orderInfo, &(primary->multi_dstblt));
3692 case ORDER_TYPE_MULTI_PATBLT:
3693 rc = update_read_multi_patblt_order(orderName, s, orderInfo, &(primary->multi_patblt));
3696 case ORDER_TYPE_MULTI_SCRBLT:
3697 rc = update_read_multi_scrblt_order(orderName, s, orderInfo, &(primary->multi_scrblt));
3700 case ORDER_TYPE_MULTI_OPAQUE_RECT:
3701 rc = update_read_multi_opaque_rect_order(orderName, s, orderInfo,
3702 &(primary->multi_opaque_rect));
3705 case ORDER_TYPE_MULTI_DRAW_NINE_GRID:
3706 rc = update_read_multi_draw_nine_grid_order(orderName, s, orderInfo,
3707 &(primary->multi_draw_nine_grid));
3710 case ORDER_TYPE_LINE_TO:
3711 rc = update_read_line_to_order(orderName, s, orderInfo, &(primary->line_to));
3714 case ORDER_TYPE_POLYLINE:
3715 rc = update_read_polyline_order(orderName, s, orderInfo, &(primary->polyline));
3718 case ORDER_TYPE_MEMBLT:
3719 rc = update_read_memblt_order(orderName, s, orderInfo, &(primary->memblt));
3722 case ORDER_TYPE_MEM3BLT:
3723 rc = update_read_mem3blt_order(orderName, s, orderInfo, &(primary->mem3blt));
3726 case ORDER_TYPE_SAVE_BITMAP:
3727 rc = update_read_save_bitmap_order(orderName, s, orderInfo, &(primary->save_bitmap));
3730 case ORDER_TYPE_GLYPH_INDEX:
3731 rc = update_read_glyph_index_order(orderName, s, orderInfo, &(primary->glyph_index));
3734 case ORDER_TYPE_FAST_INDEX:
3735 rc = update_read_fast_index_order(orderName, s, orderInfo, &(primary->fast_index));
3738 case ORDER_TYPE_FAST_GLYPH:
3739 rc = update_read_fast_glyph_order(orderName, s, orderInfo, &(primary->fast_glyph));
3742 case ORDER_TYPE_POLYGON_SC:
3743 rc = update_read_polygon_sc_order(orderName, s, orderInfo, &(primary->polygon_sc));
3746 case ORDER_TYPE_POLYGON_CB:
3747 rc = update_read_polygon_cb_order(orderName, s, orderInfo, &(primary->polygon_cb));
3750 case ORDER_TYPE_ELLIPSE_SC:
3751 rc = update_read_ellipse_sc_order(orderName, s, orderInfo, &(primary->ellipse_sc));
3754 case ORDER_TYPE_ELLIPSE_CB:
3755 rc = update_read_ellipse_cb_order(orderName, s, orderInfo, &(primary->ellipse_cb));
3759 WLog_Print(log, WLOG_WARN,
"%s %s not supported, ignoring", primary_order_str,
3767 WLog_Print(log, WLOG_ERROR,
"%s %s failed", primary_order_str, orderName);
3774 static BOOL update_recv_primary_order(rdpUpdate* update,
wStream* s, BYTE flags)
3779 rdpContext* context = update->context;
3782 rdpSettings* settings = NULL;
3783 const char* orderName = NULL;
3784 BOOL defaultReturn = 0;
3788 orderInfo = &(primary->order_info);
3789 WINPR_ASSERT(orderInfo);
3790 WINPR_ASSERT(context);
3792 settings = context->settings;
3793 WINPR_ASSERT(settings);
3797 if (flags & ORDER_TYPE_CHANGE)
3799 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
3802 Stream_Read_UINT8(s, orderInfo->orderType);
3805 orderName = primary_order_string(orderInfo->orderType);
3806 WLog_Print(up->log, WLOG_DEBUG,
"%s %s", primary_order_str, orderName);
3808 if (!check_primary_order_supported(up->log, settings, orderInfo->orderType, orderName))
3811 field = get_primary_drawing_order_field_bytes(orderInfo->orderType, &rc);
3815 if (!update_read_field_flags(s, &(orderInfo->fieldFlags), flags, field))
3817 WLog_Print(up->log, WLOG_ERROR,
"update_read_field_flags() failed");
3821 if (flags & ORDER_BOUNDS)
3823 if (!(flags & ORDER_ZERO_BOUNDS_DELTAS))
3825 if (!update_read_bounds(s, &orderInfo->bounds))
3827 WLog_Print(up->log, WLOG_ERROR,
"update_read_bounds() failed");
3832 rc = IFCALLRESULT(defaultReturn, update->SetBounds, context, &orderInfo->bounds);
3838 orderInfo->deltaCoordinates = (flags & ORDER_DELTA_COORDINATES) ? TRUE : FALSE;
3840 if (!read_primary_order(up->log, orderName, s, orderInfo, &primary->common))
3843 rc = IFCALLRESULT(TRUE, primary->common.OrderInfo, context, orderInfo, orderName);
3847 switch (orderInfo->orderType)
3849 case ORDER_TYPE_DSTBLT:
3851 WLog_Print(up->log, WLOG_DEBUG,
"%s %s rop=%s [0x%08" PRIx32
"]", primary_order_str,
3852 orderName, gdi_rob3_code_string_checked(primary->dstblt.bRop),
3853 gdi_rop3_code_checked(primary->dstblt.bRop));
3854 rc = IFCALLRESULT(defaultReturn, primary->common.DstBlt, context, &primary->dstblt);
3858 case ORDER_TYPE_PATBLT:
3860 WINPR_ASSERT(primary->patblt.bRop <= UINT8_MAX);
3861 WLog_Print(up->log, WLOG_DEBUG,
"%s %s rop=%s [0x%08" PRIx32
"]", primary_order_str,
3862 orderName, gdi_rob3_code_string_checked(primary->patblt.bRop),
3863 gdi_rop3_code_checked(primary->patblt.bRop));
3864 rc = IFCALLRESULT(defaultReturn, primary->common.PatBlt, context, &primary->patblt);
3868 case ORDER_TYPE_SCRBLT:
3870 WINPR_ASSERT(primary->scrblt.bRop <= UINT8_MAX);
3871 WLog_Print(up->log, WLOG_DEBUG,
"%s %s rop=%s [0x%08" PRIx32
"]", primary_order_str,
3872 orderName, gdi_rob3_code_string_checked((UINT8)primary->scrblt.bRop),
3873 gdi_rop3_code_checked(primary->scrblt.bRop));
3874 rc = IFCALLRESULT(defaultReturn, primary->common.ScrBlt, context, &primary->scrblt);
3878 case ORDER_TYPE_OPAQUE_RECT:
3880 WLog_Print(up->log, WLOG_DEBUG,
"%s %s", primary_order_str, orderName);
3881 rc = IFCALLRESULT(defaultReturn, primary->common.OpaqueRect, context,
3882 &primary->opaque_rect);
3886 case ORDER_TYPE_DRAW_NINE_GRID:
3888 WLog_Print(up->log, WLOG_DEBUG,
"%s %s", primary_order_str, orderName);
3889 rc = IFCALLRESULT(defaultReturn, primary->common.DrawNineGrid, context,
3890 &primary->draw_nine_grid);
3894 case ORDER_TYPE_MULTI_DSTBLT:
3896 WLog_Print(up->log, WLOG_DEBUG,
"%s %s rop=%s [0x%08" PRIx32
"]", primary_order_str,
3897 orderName, gdi_rob3_code_string_checked(primary->multi_dstblt.bRop),
3898 gdi_rop3_code_checked(primary->multi_dstblt.bRop));
3899 rc = IFCALLRESULT(defaultReturn, primary->common.MultiDstBlt, context,
3900 &primary->multi_dstblt);
3904 case ORDER_TYPE_MULTI_PATBLT:
3906 WLog_Print(up->log, WLOG_DEBUG,
"%s %s rop=%s [0x%08" PRIx32
"]", primary_order_str,
3907 orderName, gdi_rob3_code_string_checked(primary->multi_patblt.bRop),
3908 gdi_rop3_code_checked(primary->multi_patblt.bRop));
3909 rc = IFCALLRESULT(defaultReturn, primary->common.MultiPatBlt, context,
3910 &primary->multi_patblt);
3914 case ORDER_TYPE_MULTI_SCRBLT:
3916 WLog_Print(up->log, WLOG_DEBUG,
"%s %s rop=%s [0x%08" PRIx32
"]", primary_order_str,
3917 orderName, gdi_rob3_code_string_checked(primary->multi_scrblt.bRop),
3918 gdi_rop3_code_checked(primary->multi_scrblt.bRop));
3919 rc = IFCALLRESULT(defaultReturn, primary->common.MultiScrBlt, context,
3920 &primary->multi_scrblt);
3924 case ORDER_TYPE_MULTI_OPAQUE_RECT:
3926 WLog_Print(up->log, WLOG_DEBUG,
"%s %s", primary_order_str, orderName);
3927 rc = IFCALLRESULT(defaultReturn, primary->common.MultiOpaqueRect, context,
3928 &primary->multi_opaque_rect);
3932 case ORDER_TYPE_MULTI_DRAW_NINE_GRID:
3934 WLog_Print(up->log, WLOG_DEBUG,
"%s %s", primary_order_str, orderName);
3935 rc = IFCALLRESULT(defaultReturn, primary->common.MultiDrawNineGrid, context,
3936 &primary->multi_draw_nine_grid);
3940 case ORDER_TYPE_LINE_TO:
3942 WLog_Print(up->log, WLOG_DEBUG,
"%s %s", primary_order_str, orderName);
3943 rc = IFCALLRESULT(defaultReturn, primary->common.LineTo, context, &primary->line_to);
3947 case ORDER_TYPE_POLYLINE:
3949 WLog_Print(up->log, WLOG_DEBUG,
"%s %s", primary_order_str, orderName);
3950 rc = IFCALLRESULT(defaultReturn, primary->common.Polyline, context, &primary->polyline);
3954 case ORDER_TYPE_MEMBLT:
3956 WINPR_ASSERT(primary->memblt.bRop <= UINT8_MAX);
3957 WLog_Print(up->log, WLOG_DEBUG,
"%s %s rop=%s [0x%08" PRIx32
"]", primary_order_str,
3958 orderName, gdi_rob3_code_string_checked(primary->memblt.bRop),
3959 gdi_rop3_code_checked(primary->memblt.bRop));
3960 rc = IFCALLRESULT(defaultReturn, primary->common.MemBlt, context, &primary->memblt);
3964 case ORDER_TYPE_MEM3BLT:
3966 WINPR_ASSERT(primary->mem3blt.bRop <= UINT8_MAX);
3967 WLog_Print(up->log, WLOG_DEBUG,
"%s %s rop=%s [0x%08" PRIx32
"]", primary_order_str,
3968 orderName, gdi_rob3_code_string_checked(primary->mem3blt.bRop),
3969 gdi_rop3_code_checked(primary->mem3blt.bRop));
3970 rc = IFCALLRESULT(defaultReturn, primary->common.Mem3Blt, context, &primary->mem3blt);
3974 case ORDER_TYPE_SAVE_BITMAP:
3976 WLog_Print(up->log, WLOG_DEBUG,
"%s %s", primary_order_str, orderName);
3977 rc = IFCALLRESULT(defaultReturn, primary->common.SaveBitmap, context,
3978 &primary->save_bitmap);
3982 case ORDER_TYPE_GLYPH_INDEX:
3984 WLog_Print(up->log, WLOG_DEBUG,
"%s %s", primary_order_str, orderName);
3985 rc = IFCALLRESULT(defaultReturn, primary->common.GlyphIndex, context,
3986 &primary->glyph_index);
3990 case ORDER_TYPE_FAST_INDEX:
3992 WLog_Print(up->log, WLOG_DEBUG,
"%s %s", primary_order_str, orderName);
3993 rc = IFCALLRESULT(defaultReturn, primary->common.FastIndex, context,
3994 &primary->fast_index);
3998 case ORDER_TYPE_FAST_GLYPH:
4000 WLog_Print(up->log, WLOG_DEBUG,
"%s %s", primary_order_str, orderName);
4001 rc = IFCALLRESULT(defaultReturn, primary->common.FastGlyph, context,
4002 &primary->fast_glyph);
4006 case ORDER_TYPE_POLYGON_SC:
4008 WLog_Print(up->log, WLOG_DEBUG,
"%s %s", primary_order_str, orderName);
4009 rc = IFCALLRESULT(defaultReturn, primary->common.PolygonSC, context,
4010 &primary->polygon_sc);
4014 case ORDER_TYPE_POLYGON_CB:
4016 WLog_Print(up->log, WLOG_DEBUG,
"%s %s", primary_order_str, orderName);
4017 rc = IFCALLRESULT(defaultReturn, primary->common.PolygonCB, context,
4018 &primary->polygon_cb);
4022 case ORDER_TYPE_ELLIPSE_SC:
4024 WLog_Print(up->log, WLOG_DEBUG,
"%s %s", primary_order_str, orderName);
4025 rc = IFCALLRESULT(defaultReturn, primary->common.EllipseSC, context,
4026 &primary->ellipse_sc);
4030 case ORDER_TYPE_ELLIPSE_CB:
4032 WLog_Print(up->log, WLOG_DEBUG,
"%s %s", primary_order_str, orderName);
4033 rc = IFCALLRESULT(defaultReturn, primary->common.EllipseCB, context,
4034 &primary->ellipse_cb);
4039 WLog_Print(up->log, WLOG_WARN,
"%s %s not supported", primary_order_str, orderName);
4045 WLog_Print(up->log, WLOG_ERROR,
"%s %s failed", primary_order_str, orderName);
4049 if (flags & ORDER_BOUNDS)
4051 rc = IFCALLRESULT(defaultReturn, update->SetBounds, context, NULL);
4057 static BOOL update_recv_secondary_order(rdpUpdate* update,
wStream* s, BYTE flags)
4065 UINT16 extraFlags = 0;
4066 INT16 orderLength = 0;
4068 rdpContext* context = update->context;
4069 rdpSettings* settings = context->settings;
4070 rdpSecondaryUpdate* secondary = update->secondary;
4071 const char* name = NULL;
4072 BOOL defaultReturn = 0;
4076 if (!Stream_CheckAndLogRequiredLength(TAG, s, 5))
4079 Stream_Read_INT16(s, orderLength);
4080 Stream_Read_UINT16(s, extraFlags);
4081 Stream_Read_UINT8(s, orderType);
4083 start = Stream_GetPosition(s);
4084 name = secondary_order_string(orderType);
4085 WLog_Print(up->log, WLOG_DEBUG,
"%s %s", secondary_order_str, name);
4086 rc = IFCALLRESULT(TRUE, secondary->CacheOrderInfo, context, orderLength, extraFlags, orderType,
4099 if (orderLength < 0)
4101 WLog_Print(up->log, WLOG_ERROR,
"orderLength %" PRIu16
" must be >= 7", orderLength);
4105 const size_t orderLengthFull = WINPR_ASSERTING_INT_CAST(
size_t, orderLength) + 7ULL;
4106 if (!Stream_CheckAndLogRequiredLength(TAG, s, orderLengthFull))
4109 if (!check_secondary_order_supported(up->log, settings, orderType, name))
4114 case ORDER_TYPE_BITMAP_UNCOMPRESSED:
4115 case ORDER_TYPE_CACHE_BITMAP_COMPRESSED:
4117 const BOOL compressed = (orderType == ORDER_TYPE_CACHE_BITMAP_COMPRESSED);
4119 update_read_cache_bitmap_order(update, s, compressed, extraFlags);
4123 rc = IFCALLRESULT(defaultReturn, secondary->CacheBitmap, context, order);
4124 free_cache_bitmap_order(context, order);
4129 case ORDER_TYPE_BITMAP_UNCOMPRESSED_V2:
4130 case ORDER_TYPE_BITMAP_COMPRESSED_V2:
4132 const BOOL compressed = (orderType == ORDER_TYPE_BITMAP_COMPRESSED_V2);
4134 update_read_cache_bitmap_v2_order(update, s, compressed, extraFlags);
4138 rc = IFCALLRESULT(defaultReturn, secondary->CacheBitmapV2, context, order);
4139 free_cache_bitmap_v2_order(context, order);
4144 case ORDER_TYPE_BITMAP_COMPRESSED_V3:
4150 rc = IFCALLRESULT(defaultReturn, secondary->CacheBitmapV3, context, order);
4151 free_cache_bitmap_v3_order(context, order);
4156 case ORDER_TYPE_CACHE_COLOR_TABLE:
4159 update_read_cache_color_table_order(update, s, extraFlags);
4163 rc = IFCALLRESULT(defaultReturn, secondary->CacheColorTable, context, order);
4164 free_cache_color_table_order(context, order);
4169 case ORDER_TYPE_CACHE_GLYPH:
4171 switch (settings->GlyphSupportLevel)
4173 case GLYPH_SUPPORT_PARTIAL:
4174 case GLYPH_SUPPORT_FULL:
4176 CACHE_GLYPH_ORDER* order = update_read_cache_glyph_order(update, s, extraFlags);
4180 rc = IFCALLRESULT(defaultReturn, secondary->CacheGlyph, context, order);
4181 free_cache_glyph_order(context, order);
4186 case GLYPH_SUPPORT_ENCODE:
4189 update_read_cache_glyph_v2_order(update, s, extraFlags);
4193 rc = IFCALLRESULT(defaultReturn, secondary->CacheGlyphV2, context, order);
4194 free_cache_glyph_v2_order(context, order);
4199 case GLYPH_SUPPORT_NONE:
4206 case ORDER_TYPE_CACHE_BRUSH:
4209 CACHE_BRUSH_ORDER* order = update_read_cache_brush_order(update, s, extraFlags);
4213 rc = IFCALLRESULT(defaultReturn, secondary->CacheBrush, context, order);
4214 free_cache_brush_order(context, order);
4220 WLog_Print(up->log, WLOG_WARN,
"%s %s not supported", secondary_order_str, name);
4226 WLog_Print(up->log, WLOG_ERROR,
"%s %s failed", secondary_order_str, name);
4229 end = start + WINPR_ASSERTING_INT_CAST(
size_t, orderLengthFull);
4230 pos = Stream_GetPosition(s);
4233 WLog_Print(up->log, WLOG_WARN,
"%s %s: read %" PRIuz
"bytes too much", secondary_order_str,
4240 WLog_Print(up->log, WLOG_DEBUG,
"%s %s: read %" PRIuz
"bytes short, skipping",
4241 secondary_order_str, name, diff);
4242 if (!Stream_SafeSeek(s, diff))
4248 static BOOL read_altsec_order(wLog* log,
wStream* s, BYTE orderType, rdpAltSecUpdate* altsec_pub)
4257 case ORDER_TYPE_CREATE_OFFSCREEN_BITMAP:
4258 rc = update_read_create_offscreen_bitmap_order(s, &(altsec->create_offscreen_bitmap));
4261 case ORDER_TYPE_SWITCH_SURFACE:
4262 rc = update_read_switch_surface_order(s, &(altsec->switch_surface));
4265 case ORDER_TYPE_CREATE_NINE_GRID_BITMAP:
4266 rc = update_read_create_nine_grid_bitmap_order(s, &(altsec->create_nine_grid_bitmap));
4269 case ORDER_TYPE_FRAME_MARKER:
4270 rc = update_read_frame_marker_order(s, &(altsec->frame_marker));
4273 case ORDER_TYPE_STREAM_BITMAP_FIRST:
4274 rc = update_read_stream_bitmap_first_order(s, &(altsec->stream_bitmap_first));
4277 case ORDER_TYPE_STREAM_BITMAP_NEXT:
4278 rc = update_read_stream_bitmap_next_order(s, &(altsec->stream_bitmap_next));
4281 case ORDER_TYPE_GDIPLUS_FIRST:
4282 rc = update_read_draw_gdiplus_first_order(s, &(altsec->draw_gdiplus_first));
4285 case ORDER_TYPE_GDIPLUS_NEXT:
4286 rc = update_read_draw_gdiplus_next_order(s, &(altsec->draw_gdiplus_next));
4289 case ORDER_TYPE_GDIPLUS_END:
4290 rc = update_read_draw_gdiplus_end_order(s, &(altsec->draw_gdiplus_end));
4293 case ORDER_TYPE_GDIPLUS_CACHE_FIRST:
4294 rc = update_read_draw_gdiplus_cache_first_order(s, &(altsec->draw_gdiplus_cache_first));
4297 case ORDER_TYPE_GDIPLUS_CACHE_NEXT:
4298 rc = update_read_draw_gdiplus_cache_next_order(s, &(altsec->draw_gdiplus_cache_next));
4301 case ORDER_TYPE_GDIPLUS_CACHE_END:
4302 rc = update_read_draw_gdiplus_cache_end_order(s, &(altsec->draw_gdiplus_cache_end));
4305 case ORDER_TYPE_WINDOW:
4310 case ORDER_TYPE_COMPDESK_FIRST:
4320 WLog_Print(log, WLOG_ERROR,
"Read %s %s failed", alt_sec_order_str,
4321 altsec_order_string(orderType));
4327 static BOOL update_recv_altsec_order(rdpUpdate* update,
wStream* s, BYTE flags)
4329 BYTE orderType = flags >> 2;
4332 rdpContext* context = update->context;
4333 rdpSettings* settings = context->settings;
4335 const char* orderName = altsec_order_string(orderType);
4338 WINPR_ASSERT(context);
4339 WINPR_ASSERT(settings);
4341 WLog_Print(up->log, WLOG_DEBUG,
"%s %s", alt_sec_order_str, orderName);
4343 rc = IFCALLRESULT(TRUE, altsec->common.DrawOrderInfo, context, orderType, orderName);
4347 if (!check_alt_order_supported(up->log, settings, orderType, orderName))
4350 if (!read_altsec_order(up->log, s, orderType, &altsec->common))
4355 case ORDER_TYPE_CREATE_OFFSCREEN_BITMAP:
4356 IFCALLRET(altsec->common.CreateOffscreenBitmap, rc, context,
4357 &(altsec->create_offscreen_bitmap));
4360 case ORDER_TYPE_SWITCH_SURFACE:
4361 IFCALLRET(altsec->common.SwitchSurface, rc, context, &(altsec->switch_surface));
4364 case ORDER_TYPE_CREATE_NINE_GRID_BITMAP:
4365 IFCALLRET(altsec->common.CreateNineGridBitmap, rc, context,
4366 &(altsec->create_nine_grid_bitmap));
4369 case ORDER_TYPE_FRAME_MARKER:
4370 IFCALLRET(altsec->common.FrameMarker, rc, context, &(altsec->frame_marker));
4373 case ORDER_TYPE_STREAM_BITMAP_FIRST:
4374 IFCALLRET(altsec->common.StreamBitmapFirst, rc, context,
4375 &(altsec->stream_bitmap_first));
4378 case ORDER_TYPE_STREAM_BITMAP_NEXT:
4379 IFCALLRET(altsec->common.StreamBitmapNext, rc, context, &(altsec->stream_bitmap_next));
4382 case ORDER_TYPE_GDIPLUS_FIRST:
4383 IFCALLRET(altsec->common.DrawGdiPlusFirst, rc, context, &(altsec->draw_gdiplus_first));
4386 case ORDER_TYPE_GDIPLUS_NEXT:
4387 IFCALLRET(altsec->common.DrawGdiPlusNext, rc, context, &(altsec->draw_gdiplus_next));
4390 case ORDER_TYPE_GDIPLUS_END:
4391 IFCALLRET(altsec->common.DrawGdiPlusEnd, rc, context, &(altsec->draw_gdiplus_end));
4394 case ORDER_TYPE_GDIPLUS_CACHE_FIRST:
4395 IFCALLRET(altsec->common.DrawGdiPlusCacheFirst, rc, context,
4396 &(altsec->draw_gdiplus_cache_first));
4399 case ORDER_TYPE_GDIPLUS_CACHE_NEXT:
4400 IFCALLRET(altsec->common.DrawGdiPlusCacheNext, rc, context,
4401 &(altsec->draw_gdiplus_cache_next));
4404 case ORDER_TYPE_GDIPLUS_CACHE_END:
4405 IFCALLRET(altsec->common.DrawGdiPlusCacheEnd, rc, context,
4406 &(altsec->draw_gdiplus_cache_end));
4409 case ORDER_TYPE_WINDOW:
4410 rc = update_recv_altsec_window_order(update, s);
4413 case ORDER_TYPE_COMPDESK_FIRST:
4423 WLog_Print(up->log, WLOG_ERROR,
"%s %s failed", alt_sec_order_str, orderName);
4428 BOOL update_recv_order(rdpUpdate* update,
wStream* s)
4431 BYTE controlFlags = 0;
4434 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
4437 Stream_Read_UINT8(s, controlFlags);
4439 if (!(controlFlags & ORDER_STANDARD))
4440 rc = update_recv_altsec_order(update, s, controlFlags);
4441 else if (controlFlags & ORDER_SECONDARY)
4442 rc = update_recv_secondary_order(update, s, controlFlags);
4444 rc = update_recv_primary_order(update, s, controlFlags);
4447 WLog_Print(up->log, WLOG_ERROR,
"order flags %02" PRIx8
" failed", controlFlags);
FREERDP_API BOOL freerdp_settings_get_bool(const rdpSettings *settings, FreeRDP_Settings_Keys_Bool id)
Returns a boolean settings value.