22#include <freerdp/config.h>
24#include <winpr/assert.h>
30#include <freerdp/log.h>
31#include <freerdp/freerdp.h>
34#include <winpr/stream.h>
35#include <winpr/collections.h>
37#include "../cache/pointer.h"
38#include "../cache/bitmap.h"
39#include "../cache/palette.h"
40#include "../cache/glyph.h"
41#include "../cache/brush.h"
42#include "../cache/cache.h"
44#define TAG FREERDP_TAG("core.message")
48static BOOL update_message_BeginPaint(rdpContext* context)
52 if (!context || !context->update)
55 up = update_cast(context->update);
56 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, BeginPaint),
nullptr,
60static BOOL update_message_EndPaint(rdpContext* context)
64 if (!context || !context->update)
67 up = update_cast(context->update);
68 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, EndPaint),
nullptr,
72static BOOL update_message_SetBounds(rdpContext* context,
const rdpBounds* bounds)
74 rdpBounds* wParam =
nullptr;
77 if (!context || !context->update)
82 wParam = (rdpBounds*)malloc(
sizeof(rdpBounds));
87 CopyMemory(wParam, bounds,
sizeof(rdpBounds));
90 up = update_cast(context->update);
91 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, SetBounds),
92 (
void*)wParam,
nullptr);
95static BOOL update_message_Synchronize(rdpContext* context)
99 if (!context || !context->update)
102 up = update_cast(context->update);
103 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, Synchronize),
nullptr,
107static BOOL update_message_DesktopResize(rdpContext* context)
111 if (!context || !context->update)
114 up = update_cast(context->update);
115 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, DesktopResize),
119static BOOL update_message_BitmapUpdate(rdpContext* context,
const BITMAP_UPDATE* bitmap)
124 if (!context || !context->update || !bitmap)
127 wParam = copy_bitmap_update(context, bitmap);
132 up = update_cast(context->update);
133 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, BitmapUpdate),
134 (
void*)wParam,
nullptr);
137static BOOL update_message_Palette(rdpContext* context,
const PALETTE_UPDATE* palette)
142 if (!context || !context->update || !palette)
145 wParam = copy_palette_update(context, palette);
150 up = update_cast(context->update);
151 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, Palette),
152 (
void*)wParam,
nullptr);
155static BOOL update_message_PlaySound(rdpContext* context,
const PLAY_SOUND_UPDATE* playSound)
160 if (!context || !context->update || !playSound)
170 up = update_cast(context->update);
171 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, PlaySound),
172 (
void*)wParam,
nullptr);
175static BOOL update_message_SetKeyboardIndicators(rdpContext* context, UINT16 led_flags)
179 if (!context || !context->update)
182 up = update_cast(context->update);
183 return MessageQueue_Post(up->queue, (
void*)context,
184 MakeMessageId(Update, SetKeyboardIndicators), (
void*)(
size_t)led_flags,
188static BOOL update_message_SetKeyboardImeStatus(rdpContext* context, UINT16 imeId, UINT32 imeState,
193 if (!context || !context->update)
196 up = update_cast(context->update);
197 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, SetKeyboardImeStatus),
198 (
void*)(
size_t)((((UINT32)imeId << 16UL) & 0xFFFF0000) | imeState),
199 (
void*)(
size_t)imeConvMode);
202static BOOL update_message_RefreshRect(rdpContext* context, BYTE count,
const RECTANGLE_16* areas)
207 if (!context || !context->update || !areas)
215 CopyMemory(lParam, areas,
sizeof(
RECTANGLE_16) * count);
217 up = update_cast(context->update);
218 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, RefreshRect),
219 (
void*)(
size_t)count, (
void*)lParam);
222static BOOL update_message_SuppressOutput(rdpContext* context, BYTE allow,
const RECTANGLE_16* area)
227 if (!context || !context->update)
240 up = update_cast(context->update);
241 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, SuppressOutput),
242 (
void*)(
size_t)allow, (
void*)lParam);
245static BOOL update_message_SurfaceCommand(rdpContext* context,
wStream* s)
250 if (!context || !context->update || !s)
253 wParam = Stream_New(
nullptr, Stream_GetRemainingLength(s));
258 Stream_Copy(s, wParam, Stream_GetRemainingLength(s));
259 Stream_ResetPosition(wParam);
261 up = update_cast(context->update);
262 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, SurfaceCommand),
263 (
void*)wParam,
nullptr);
266static BOOL update_message_SurfaceBits(rdpContext* context,
272 if (!context || !context->update || !surfaceBitsCommand)
275 wParam = copy_surface_bits_command(context, surfaceBitsCommand);
280 up = update_cast(context->update);
281 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, SurfaceBits),
282 (
void*)wParam,
nullptr);
285static BOOL update_message_SurfaceFrameMarker(rdpContext* context,
291 if (!context || !context->update || !surfaceFrameMarker)
301 up = update_cast(context->update);
302 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, SurfaceFrameMarker),
303 (
void*)wParam,
nullptr);
306static BOOL update_message_SurfaceFrameAcknowledge(rdpContext* context, UINT32 frameId)
310 if (!context || !context->update)
313 up = update_cast(context->update);
314 return MessageQueue_Post(up->queue, (
void*)context,
315 MakeMessageId(Update, SurfaceFrameAcknowledge), (
void*)(
size_t)frameId,
321static BOOL update_message_DstBlt(rdpContext* context,
const DSTBLT_ORDER* dstBlt)
326 if (!context || !context->update || !dstBlt)
336 up = update_cast(context->update);
337 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, DstBlt),
338 (
void*)wParam,
nullptr);
341static BOOL update_message_PatBlt(rdpContext* context,
PATBLT_ORDER* patBlt)
346 if (!context || !context->update || !patBlt)
355 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
357 up = update_cast(context->update);
358 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, PatBlt),
359 (
void*)wParam,
nullptr);
362static BOOL update_message_ScrBlt(rdpContext* context,
const SCRBLT_ORDER* scrBlt)
367 if (!context || !context->update || !scrBlt)
377 up = update_cast(context->update);
378 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, ScrBlt),
379 (
void*)wParam,
nullptr);
382static BOOL update_message_OpaqueRect(rdpContext* context,
const OPAQUE_RECT_ORDER* opaqueRect)
387 if (!context || !context->update || !opaqueRect)
397 up = update_cast(context->update);
398 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, OpaqueRect),
399 (
void*)wParam,
nullptr);
402static BOOL update_message_DrawNineGrid(rdpContext* context,
408 if (!context || !context->update || !drawNineGrid)
418 up = update_cast(context->update);
419 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, DrawNineGrid),
420 (
void*)wParam,
nullptr);
423static BOOL update_message_MultiDstBlt(rdpContext* context,
const MULTI_DSTBLT_ORDER* multiDstBlt)
428 if (!context || !context->update || !multiDstBlt)
438 up = update_cast(context->update);
439 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, MultiDstBlt),
440 (
void*)wParam,
nullptr);
443static BOOL update_message_MultiPatBlt(rdpContext* context,
const MULTI_PATBLT_ORDER* multiPatBlt)
448 if (!context || !context->update || !multiPatBlt)
457 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
459 up = update_cast(context->update);
460 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, MultiPatBlt),
461 (
void*)wParam,
nullptr);
464static BOOL update_message_MultiScrBlt(rdpContext* context,
const MULTI_SCRBLT_ORDER* multiScrBlt)
469 if (!context || !context->update || !multiScrBlt)
479 up = update_cast(context->update);
480 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, MultiScrBlt),
481 (
void*)wParam,
nullptr);
484static BOOL update_message_MultiOpaqueRect(rdpContext* context,
490 if (!context || !context->update || !multiOpaqueRect)
500 up = update_cast(context->update);
501 return MessageQueue_Post(up->queue, (
void*)context,
502 MakeMessageId(PrimaryUpdate, MultiOpaqueRect), (
void*)wParam,
nullptr);
505static BOOL update_message_MultiDrawNineGrid(rdpContext* context,
511 if (!context || !context->update || !multiDrawNineGrid)
522 up = update_cast(context->update);
523 return MessageQueue_Post(up->queue, (
void*)context,
524 MakeMessageId(PrimaryUpdate, MultiDrawNineGrid), (
void*)wParam,
528static BOOL update_message_LineTo(rdpContext* context,
const LINE_TO_ORDER* lineTo)
533 if (!context || !context->update || !lineTo)
543 up = update_cast(context->update);
544 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, LineTo),
545 (
void*)wParam,
nullptr);
548static BOOL update_message_Polyline(rdpContext* context,
const POLYLINE_ORDER* polyline)
553 if (!context || !context->update || !polyline)
570 CopyMemory(wParam->points, polyline->points,
sizeof(
DELTA_POINT) * wParam->numDeltaEntries);
572 up = update_cast(context->update);
573 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, Polyline),
574 (
void*)wParam,
nullptr);
577static BOOL update_message_MemBlt(rdpContext* context,
MEMBLT_ORDER* memBlt)
582 if (!context || !context->update || !memBlt)
592 up = update_cast(context->update);
593 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, MemBlt),
594 (
void*)wParam,
nullptr);
597static BOOL update_message_Mem3Blt(rdpContext* context,
MEM3BLT_ORDER* mem3Blt)
602 if (!context || !context->update || !mem3Blt)
611 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
613 up = update_cast(context->update);
614 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, Mem3Blt),
615 (
void*)wParam,
nullptr);
618static BOOL update_message_SaveBitmap(rdpContext* context,
const SAVE_BITMAP_ORDER* saveBitmap)
623 if (!context || !context->update || !saveBitmap)
633 up = update_cast(context->update);
634 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, SaveBitmap),
635 (
void*)wParam,
nullptr);
638static BOOL update_message_GlyphIndex(rdpContext* context,
GLYPH_INDEX_ORDER* glyphIndex)
643 if (!context || !context->update || !glyphIndex)
652 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
654 up = update_cast(context->update);
655 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, GlyphIndex),
656 (
void*)wParam,
nullptr);
659static BOOL update_message_FastIndex(rdpContext* context,
const FAST_INDEX_ORDER* fastIndex)
664 if (!context || !context->update || !fastIndex)
674 up = update_cast(context->update);
675 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, FastIndex),
676 (
void*)wParam,
nullptr);
679static BOOL update_message_FastGlyph(rdpContext* context,
const FAST_GLYPH_ORDER* fastGlyph)
684 if (!context || !context->update || !fastGlyph)
694 if (wParam->cbData > 1)
696 wParam->glyphData.aj = (BYTE*)malloc(fastGlyph->glyphData.cb);
698 if (!wParam->glyphData.aj)
704 CopyMemory(wParam->glyphData.aj, fastGlyph->glyphData.aj, fastGlyph->glyphData.cb);
708 wParam->glyphData.aj =
nullptr;
711 up = update_cast(context->update);
712 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, FastGlyph),
713 (
void*)wParam,
nullptr);
716static BOOL update_message_PolygonSC(rdpContext* context,
const POLYGON_SC_ORDER* polygonSC)
718 if (!context || !context->update || !polygonSC)
726 *wParam = *polygonSC;
727 if (polygonSC->numPoints > 0)
737 CopyMemory(wParam->points, polygonSC->points,
sizeof(
DELTA_POINT) * wParam->numPoints);
741 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, PolygonSC),
742 (
void*)wParam,
nullptr);
745static BOOL update_message_PolygonCB(rdpContext* context,
POLYGON_CB_ORDER* polygonCB)
747 if (!context || !context->update || !polygonCB)
755 *wParam = *polygonCB;
756 if (polygonCB->numPoints > 0)
766 CopyMemory(wParam->points, polygonCB->points,
sizeof(
DELTA_POINT) * wParam->numPoints);
769 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
772 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, PolygonCB),
773 (
void*)wParam,
nullptr);
776static BOOL update_message_EllipseSC(rdpContext* context,
const ELLIPSE_SC_ORDER* ellipseSC)
778 if (!context || !context->update || !ellipseSC)
789 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, EllipseSC),
790 (
void*)wParam,
nullptr);
793static BOOL update_message_EllipseCB(rdpContext* context,
const ELLIPSE_CB_ORDER* ellipseCB)
798 if (!context || !context->update || !ellipseCB)
807 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
809 up = update_cast(context->update);
810 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, EllipseCB),
811 (
void*)wParam,
nullptr);
816static BOOL update_message_CacheBitmap(rdpContext* context,
822 if (!context || !context->update || !cacheBitmapOrder)
825 wParam = copy_cache_bitmap_order(context, cacheBitmapOrder);
830 up = update_cast(context->update);
831 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(SecondaryUpdate, CacheBitmap),
832 (
void*)wParam,
nullptr);
835static BOOL update_message_CacheBitmapV2(rdpContext* context,
841 if (!context || !context->update || !cacheBitmapV2Order)
844 wParam = copy_cache_bitmap_v2_order(context, cacheBitmapV2Order);
849 up = update_cast(context->update);
850 return MessageQueue_Post(up->queue, (
void*)context,
851 MakeMessageId(SecondaryUpdate, CacheBitmapV2), (
void*)wParam,
nullptr);
854static BOOL update_message_CacheBitmapV3(rdpContext* context,
860 if (!context || !context->update || !cacheBitmapV3Order)
863 wParam = copy_cache_bitmap_v3_order(context, cacheBitmapV3Order);
868 up = update_cast(context->update);
869 return MessageQueue_Post(up->queue, (
void*)context,
870 MakeMessageId(SecondaryUpdate, CacheBitmapV3), (
void*)wParam,
nullptr);
873static BOOL update_message_CacheColorTable(rdpContext* context,
879 if (!context || !context->update || !cacheColorTableOrder)
882 wParam = copy_cache_color_table_order(context, cacheColorTableOrder);
887 up = update_cast(context->update);
888 return MessageQueue_Post(up->queue, (
void*)context,
889 MakeMessageId(SecondaryUpdate, CacheColorTable), (
void*)wParam,
893static BOOL update_message_CacheGlyph(rdpContext* context,
const CACHE_GLYPH_ORDER* cacheGlyphOrder)
898 if (!context || !context->update || !cacheGlyphOrder)
901 wParam = copy_cache_glyph_order(context, cacheGlyphOrder);
906 up = update_cast(context->update);
907 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(SecondaryUpdate, CacheGlyph),
908 (
void*)wParam,
nullptr);
911static BOOL update_message_CacheGlyphV2(rdpContext* context,
917 if (!context || !context->update || !cacheGlyphV2Order)
920 wParam = copy_cache_glyph_v2_order(context, cacheGlyphV2Order);
925 up = update_cast(context->update);
926 return MessageQueue_Post(up->queue, (
void*)context,
927 MakeMessageId(SecondaryUpdate, CacheGlyphV2), (
void*)wParam,
nullptr);
930static BOOL update_message_CacheBrush(rdpContext* context,
const CACHE_BRUSH_ORDER* cacheBrushOrder)
935 if (!context || !context->update || !cacheBrushOrder)
938 wParam = copy_cache_brush_order(context, cacheBrushOrder);
943 up = update_cast(context->update);
944 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(SecondaryUpdate, CacheBrush),
945 (
void*)wParam,
nullptr);
951update_message_CreateOffscreenBitmap(rdpContext* context,
957 if (!context || !context->update || !createOffscreenBitmap)
966 wParam->deleteList.cIndices = createOffscreenBitmap->deleteList.cIndices;
967 wParam->deleteList.sIndices = wParam->deleteList.cIndices;
968 wParam->deleteList.indices = (UINT16*)calloc(wParam->deleteList.cIndices,
sizeof(UINT16));
970 if (!wParam->deleteList.indices)
976 CopyMemory(wParam->deleteList.indices, createOffscreenBitmap->deleteList.indices,
977 wParam->deleteList.cIndices);
979 up = update_cast(context->update);
980 return MessageQueue_Post(up->queue, (
void*)context,
981 MakeMessageId(AltSecUpdate, CreateOffscreenBitmap), (
void*)wParam,
985static BOOL update_message_SwitchSurface(rdpContext* context,
991 if (!context || !context->update || !switchSurface)
1001 up = update_cast(context->update);
1002 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(AltSecUpdate, SwitchSurface),
1003 (
void*)wParam,
nullptr);
1007update_message_CreateNineGridBitmap(rdpContext* context,
1013 if (!context || !context->update || !createNineGridBitmap)
1023 up = update_cast(context->update);
1024 return MessageQueue_Post(up->queue, (
void*)context,
1025 MakeMessageId(AltSecUpdate, CreateNineGridBitmap), (
void*)wParam,
1029static BOOL update_message_FrameMarker(rdpContext* context,
const FRAME_MARKER_ORDER* frameMarker)
1034 if (!context || !context->update || !frameMarker)
1044 up = update_cast(context->update);
1045 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(AltSecUpdate, FrameMarker),
1046 (
void*)wParam,
nullptr);
1049static BOOL update_message_StreamBitmapFirst(rdpContext* context,
1055 if (!context || !context->update || !streamBitmapFirst)
1066 up = update_cast(context->update);
1067 return MessageQueue_Post(up->queue, (
void*)context,
1068 MakeMessageId(AltSecUpdate, StreamBitmapFirst), (
void*)wParam,
1072static BOOL update_message_StreamBitmapNext(rdpContext* context,
1078 if (!context || !context->update || !streamBitmapNext)
1089 up = update_cast(context->update);
1090 return MessageQueue_Post(up->queue, (
void*)context,
1091 MakeMessageId(AltSecUpdate, StreamBitmapNext), (
void*)wParam,
nullptr);
1094static BOOL update_message_DrawGdiPlusFirst(rdpContext* context,
1100 if (!context || !context->update || !drawGdiPlusFirst)
1110 up = update_cast(context->update);
1111 return MessageQueue_Post(up->queue, (
void*)context,
1112 MakeMessageId(AltSecUpdate, DrawGdiPlusFirst), (
void*)wParam,
nullptr);
1115static BOOL update_message_DrawGdiPlusNext(rdpContext* context,
1121 if (!context || !context->update || !drawGdiPlusNext)
1132 up = update_cast(context->update);
1133 return MessageQueue_Post(up->queue, (
void*)context,
1134 MakeMessageId(AltSecUpdate, DrawGdiPlusNext), (
void*)wParam,
nullptr);
1137static BOOL update_message_DrawGdiPlusEnd(rdpContext* context,
1143 if (!context || !context->update || !drawGdiPlusEnd)
1154 up = update_cast(context->update);
1155 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(AltSecUpdate, DrawGdiPlusEnd),
1156 (
void*)wParam,
nullptr);
1160update_message_DrawGdiPlusCacheFirst(rdpContext* context,
1166 if (!context || !context->update || !drawGdiPlusCacheFirst)
1177 up = update_cast(context->update);
1178 return MessageQueue_Post(up->queue, (
void*)context,
1179 MakeMessageId(AltSecUpdate, DrawGdiPlusCacheFirst), (
void*)wParam,
1184update_message_DrawGdiPlusCacheNext(rdpContext* context,
1190 if (!context || !context->update || !drawGdiPlusCacheNext)
1201 up = update_cast(context->update);
1202 return MessageQueue_Post(up->queue, (
void*)context,
1203 MakeMessageId(AltSecUpdate, DrawGdiPlusCacheNext), (
void*)wParam,
1208update_message_DrawGdiPlusCacheEnd(rdpContext* context,
1214 if (!context || !context->update || !drawGdiPlusCacheEnd)
1225 up = update_cast(context->update);
1226 return MessageQueue_Post(up->queue, (
void*)context,
1227 MakeMessageId(AltSecUpdate, DrawGdiPlusCacheEnd), (
void*)wParam,
1235 WINPR_ASSERT(((str->length == 0) && (str->string ==
nullptr)) ||
1236 (str->length == _wcsnlen(str->string, str->length)));
1238 .length = str->length };
1246 free(order->windowRects);
1247 free(order->visibilityRects);
1248 rail_unicode_string_free(&order->titleInfo);
1249 rail_unicode_string_free(&order->OverlayDescription);
1261 clone->titleInfo = rail_unicode_string_clone(&order->titleInfo);
1262 clone->OverlayDescription = rail_unicode_string_clone(&order->OverlayDescription);
1263 clone->windowRects = rectangles_clone(order->windowRects, order->numWindowRects);
1264 clone->visibilityRects = rectangles_clone(order->visibilityRects, order->numVisibilityRects);
1265 if (!clone->windowRects || !clone->visibilityRects ||
1266 (!clone->titleInfo.string && (clone->titleInfo.length > 0)) ||
1267 (!clone->OverlayDescription.string && (clone->OverlayDescription.length > 0)))
1269 window_state_order_free(clone);
1275static BOOL update_message_WindowCreate(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1278 if (!context || !context->update || !orderInfo || !windowState)
1286 *wParam = *orderInfo;
1297 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(WindowUpdate, WindowCreate),
1298 (
void*)wParam, (
void*)lParam);
1301static BOOL update_message_WindowUpdate(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1304 if (!context || !context->update || !orderInfo || !windowState)
1312 *wParam = *orderInfo;
1323 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(WindowUpdate, WindowUpdate),
1324 (
void*)wParam, (
void*)lParam);
1327static BOOL update_message_WindowIcon(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1330 if (!context || !context->update || !orderInfo || !windowIcon)
1338 *wParam = *orderInfo;
1345 *lParam = *windowIcon;
1346 lParam->iconInfo = calloc(1,
sizeof(
ICON_INFO));
1348 if (!lParam->iconInfo)
1351 *lParam->iconInfo = *windowIcon->iconInfo;
1353 WLog_VRB(TAG,
"update_message_WindowIcon");
1355 if (windowIcon->iconInfo->cbBitsColor > 0)
1357 lParam->iconInfo->bitsColor = (BYTE*)malloc(windowIcon->iconInfo->cbBitsColor);
1359 if (!lParam->iconInfo->bitsColor)
1362 CopyMemory(lParam->iconInfo->bitsColor, windowIcon->iconInfo->bitsColor,
1363 windowIcon->iconInfo->cbBitsColor);
1366 if (windowIcon->iconInfo->cbBitsMask > 0)
1368 lParam->iconInfo->bitsMask = (BYTE*)malloc(windowIcon->iconInfo->cbBitsMask);
1370 if (!lParam->iconInfo->bitsMask)
1373 CopyMemory(lParam->iconInfo->bitsMask, windowIcon->iconInfo->bitsMask,
1374 windowIcon->iconInfo->cbBitsMask);
1377 if (windowIcon->iconInfo->cbColorTable > 0)
1379 lParam->iconInfo->colorTable = (BYTE*)malloc(windowIcon->iconInfo->cbColorTable);
1381 if (!lParam->iconInfo->colorTable)
1384 CopyMemory(lParam->iconInfo->colorTable, windowIcon->iconInfo->colorTable,
1385 windowIcon->iconInfo->cbColorTable);
1389 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(WindowUpdate, WindowIcon),
1390 (
void*)wParam, (
void*)lParam);
1393 if (lParam && lParam->iconInfo)
1395 free(lParam->iconInfo->bitsColor);
1396 free(lParam->iconInfo->bitsMask);
1397 free(lParam->iconInfo->colorTable);
1398 free(lParam->iconInfo);
1406static BOOL update_message_WindowCachedIcon(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1413 if (!context || !context->update || !orderInfo || !windowCachedIcon)
1432 up = update_cast(context->update);
1433 return MessageQueue_Post(up->queue, (
void*)context,
1434 MakeMessageId(WindowUpdate, WindowCachedIcon), (
void*)wParam,
1438static BOOL update_message_WindowDelete(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo)
1443 if (!context || !context->update || !orderInfo)
1453 up = update_cast(context->update);
1454 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(WindowUpdate, WindowDelete),
1455 (
void*)wParam,
nullptr);
1463 rail_unicode_string_free(¬ify->toolTip);
1464 rail_unicode_string_free(¬ify->infoTip.text);
1465 rail_unicode_string_free(¬ify->infoTip.title);
1466 free(notify->icon.bitsColor);
1467 free(notify->icon.bitsMask);
1468 free(notify->icon.colorTable);
1474 dst->bitsColor =
nullptr;
1475 dst->bitsMask =
nullptr;
1476 dst->colorTable =
nullptr;
1478 if (src->cbBitsColor > 0)
1480 dst->bitsColor = (BYTE*)malloc(src->cbBitsColor);
1481 if (!dst->bitsColor)
1483 CopyMemory(dst->bitsColor, src->bitsColor, src->cbBitsColor);
1486 if (src->cbBitsMask > 0)
1488 dst->bitsMask = (BYTE*)malloc(src->cbBitsMask);
1491 CopyMemory(dst->bitsMask, src->bitsMask, src->cbBitsMask);
1494 if (src->cbColorTable > 0)
1496 dst->colorTable = (BYTE*)malloc(src->cbColorTable);
1497 if (!dst->colorTable)
1499 CopyMemory(dst->colorTable, src->colorTable, src->cbColorTable);
1512 clone->toolTip = rail_unicode_string_clone(&order->toolTip);
1513 clone->infoTip.text = rail_unicode_string_clone(&order->infoTip.text);
1514 clone->infoTip.title = rail_unicode_string_clone(&order->infoTip.title);
1516 if (!icon_info_clone(&clone->icon, &order->icon) ||
1517 (!clone->toolTip.string && (order->toolTip.length > 0)) ||
1518 (!clone->infoTip.text.string && (order->infoTip.text.length > 0)) ||
1519 (!clone->infoTip.title.string && (order->infoTip.title.length > 0)))
1521 notify_icon_state_order_free(clone);
1528static BOOL update_message_NotifyIconCreate(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1535 if (!context || !context->update || !orderInfo || !notifyIconState)
1544 lParam = notify_icon_state_order_clone(notifyIconState);
1552 up = update_cast(context->update);
1553 return MessageQueue_Post(up->queue, (
void*)context,
1554 MakeMessageId(WindowUpdate, NotifyIconCreate), (
void*)wParam,
1558static BOOL update_message_NotifyIconUpdate(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1565 if (!context || !context->update || !orderInfo || !notifyIconState)
1574 lParam = notify_icon_state_order_clone(notifyIconState);
1582 up = update_cast(context->update);
1583 return MessageQueue_Post(up->queue, (
void*)context,
1584 MakeMessageId(WindowUpdate, NotifyIconUpdate), (
void*)wParam,
1588static BOOL update_message_NotifyIconDelete(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo)
1593 if (!context || !context->update || !orderInfo)
1603 up = update_cast(context->update);
1604 return MessageQueue_Post(up->queue, (
void*)context,
1605 MakeMessageId(WindowUpdate, NotifyIconDelete), (
void*)wParam,
nullptr);
1608static BOOL update_message_MonitoredDesktop(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1615 if (!context || !context->update || !orderInfo || !monitoredDesktop)
1633 lParam->windowIds =
nullptr;
1635 if (lParam->numWindowIds)
1637 lParam->windowIds = (UINT32*)calloc(lParam->numWindowIds,
sizeof(UINT32));
1638 CopyMemory(lParam->windowIds, monitoredDesktop->windowIds, lParam->numWindowIds);
1641 up = update_cast(context->update);
1642 return MessageQueue_Post(up->queue, (
void*)context,
1643 MakeMessageId(WindowUpdate, MonitoredDesktop), (
void*)wParam,
1647static BOOL update_message_NonMonitoredDesktop(rdpContext* context,
1653 if (!context || !context->update || !orderInfo)
1663 up = update_cast(context->update);
1664 return MessageQueue_Post(up->queue, (
void*)context,
1665 MakeMessageId(WindowUpdate, NonMonitoredDesktop), (
void*)wParam,
1671static BOOL update_message_PointerPosition(rdpContext* context,
1677 if (!context || !context->update || !pointerPosition)
1680 wParam = copy_pointer_position_update(context, pointerPosition);
1685 up = update_cast(context->update);
1686 return MessageQueue_Post(up->queue, (
void*)context,
1687 MakeMessageId(PointerUpdate, PointerPosition), (
void*)wParam,
nullptr);
1690static BOOL update_message_PointerSystem(rdpContext* context,
1696 if (!context || !context->update || !pointerSystem)
1699 wParam = copy_pointer_system_update(context, pointerSystem);
1704 up = update_cast(context->update);
1705 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerSystem),
1706 (
void*)wParam,
nullptr);
1709static BOOL update_message_PointerColor(rdpContext* context,
1715 if (!context || !context->update || !pointerColor)
1718 wParam = copy_pointer_color_update(context, pointerColor);
1723 up = update_cast(context->update);
1724 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerColor),
1725 (
void*)wParam,
nullptr);
1728static BOOL update_message_PointerLarge(rdpContext* context,
const POINTER_LARGE_UPDATE* pointer)
1733 if (!context || !context->update || !pointer)
1736 wParam = copy_pointer_large_update(context, pointer);
1741 up = update_cast(context->update);
1742 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerLarge),
1743 (
void*)wParam,
nullptr);
1746static BOOL update_message_PointerNew(rdpContext* context,
const POINTER_NEW_UPDATE* pointerNew)
1751 if (!context || !context->update || !pointerNew)
1754 wParam = copy_pointer_new_update(context, pointerNew);
1759 up = update_cast(context->update);
1760 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerNew),
1761 (
void*)wParam,
nullptr);
1764static BOOL update_message_PointerCached(rdpContext* context,
1770 if (!context || !context->update || !pointerCached)
1773 wParam = copy_pointer_cached_update(context, pointerCached);
1778 up = update_cast(context->update);
1779 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerCached),
1780 (
void*)wParam,
nullptr);
1784static BOOL update_message_free_update_class(wMessage* msg,
int type)
1786 rdpContext* context =
nullptr;
1791 context = (rdpContext*)msg->context;
1795 case Update_BeginPaint:
1798 case Update_EndPaint:
1801 case Update_SetBounds:
1805 case Update_Synchronize:
1808 case Update_DesktopResize:
1811 case Update_BitmapUpdate:
1814 free_bitmap_update(context, wParam);
1818 case Update_Palette:
1821 free_palette_update(context, palette);
1825 case Update_PlaySound:
1829 case Update_RefreshRect:
1833 case Update_SuppressOutput:
1837 case Update_SurfaceCommand:
1840 Stream_Free(s, TRUE);
1844 case Update_SurfaceBits:
1847 free_surface_bits_command(context, wParam);
1851 case Update_SurfaceFrameMarker:
1855 case Update_SurfaceFrameAcknowledge:
1856 case Update_SetKeyboardIndicators:
1857 case Update_SetKeyboardImeStatus:
1867static BOOL update_message_process_update_class(rdpUpdateProxy* proxy, wMessage* msg,
int type)
1876 case Update_BeginPaint:
1877 rc = IFCALLRESULT(TRUE, proxy->BeginPaint, msg->context);
1880 case Update_EndPaint:
1881 rc = IFCALLRESULT(TRUE, proxy->EndPaint, msg->context);
1884 case Update_SetBounds:
1885 rc = IFCALLRESULT(TRUE, proxy->SetBounds, msg->context, (rdpBounds*)msg->wParam);
1888 case Update_Synchronize:
1889 rc = IFCALLRESULT(TRUE, proxy->Synchronize, msg->context);
1892 case Update_DesktopResize:
1893 rc = IFCALLRESULT(TRUE, proxy->DesktopResize, msg->context);
1896 case Update_BitmapUpdate:
1897 rc = IFCALLRESULT(TRUE, proxy->BitmapUpdate, msg->context, (
BITMAP_UPDATE*)msg->wParam);
1900 case Update_Palette:
1901 rc = IFCALLRESULT(TRUE, proxy->Palette, msg->context, (
PALETTE_UPDATE*)msg->wParam);
1904 case Update_PlaySound:
1906 IFCALLRESULT(TRUE, proxy->PlaySound, msg->context, (
PLAY_SOUND_UPDATE*)msg->wParam);
1909 case Update_RefreshRect:
1910 rc = IFCALLRESULT(TRUE, proxy->RefreshRect, msg->context, (BYTE)(
size_t)msg->wParam,
1914 case Update_SuppressOutput:
1915 rc = IFCALLRESULT(TRUE, proxy->SuppressOutput, msg->context, (BYTE)(
size_t)msg->wParam,
1919 case Update_SurfaceCommand:
1920 rc = IFCALLRESULT(TRUE, proxy->SurfaceCommand, msg->context, (
wStream*)msg->wParam);
1923 case Update_SurfaceBits:
1924 rc = IFCALLRESULT(TRUE, proxy->SurfaceBits, msg->context,
1928 case Update_SurfaceFrameMarker:
1929 rc = IFCALLRESULT(TRUE, proxy->SurfaceFrameMarker, msg->context,
1933 case Update_SurfaceFrameAcknowledge:
1934 rc = IFCALLRESULT(TRUE, proxy->SurfaceFrameAcknowledge, msg->context,
1935 (UINT32)(
size_t)msg->wParam);
1938 case Update_SetKeyboardIndicators:
1939 rc = IFCALLRESULT(TRUE, proxy->SetKeyboardIndicators, msg->context,
1940 (UINT16)(
size_t)msg->wParam);
1943 case Update_SetKeyboardImeStatus:
1945 const UINT16 imeId = ((size_t)msg->wParam) >> 16 & 0xFFFF;
1946 const UINT32 imeState = ((size_t)msg->wParam) & 0xFFFF;
1947 const UINT32 imeConvMode = ((size_t)msg->lParam) & 0xFFFFFFFFUL;
1948 rc = IFCALLRESULT(TRUE, proxy->SetKeyboardImeStatus, msg->context, imeId, imeState,
1960static BOOL update_message_free_primary_update_class(wMessage* msg,
int type)
1967 case PrimaryUpdate_DstBlt:
1971 case PrimaryUpdate_PatBlt:
1975 case PrimaryUpdate_ScrBlt:
1979 case PrimaryUpdate_OpaqueRect:
1983 case PrimaryUpdate_DrawNineGrid:
1987 case PrimaryUpdate_MultiDstBlt:
1991 case PrimaryUpdate_MultiPatBlt:
1995 case PrimaryUpdate_MultiScrBlt:
1999 case PrimaryUpdate_MultiOpaqueRect:
2003 case PrimaryUpdate_MultiDrawNineGrid:
2007 case PrimaryUpdate_LineTo:
2011 case PrimaryUpdate_Polyline:
2014 free(wParam->points);
2019 case PrimaryUpdate_MemBlt:
2023 case PrimaryUpdate_Mem3Blt:
2027 case PrimaryUpdate_SaveBitmap:
2031 case PrimaryUpdate_GlyphIndex:
2035 case PrimaryUpdate_FastIndex:
2039 case PrimaryUpdate_FastGlyph:
2042 free(wParam->glyphData.aj);
2047 case PrimaryUpdate_PolygonSC:
2050 free(wParam->points);
2055 case PrimaryUpdate_PolygonCB:
2058 free(wParam->points);
2063 case PrimaryUpdate_EllipseSC:
2067 case PrimaryUpdate_EllipseCB:
2078static BOOL update_message_process_primary_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2086 case PrimaryUpdate_DstBlt:
2087 return IFCALLRESULT(TRUE, proxy->DstBlt, msg->context, (
DSTBLT_ORDER*)msg->wParam);
2089 case PrimaryUpdate_PatBlt:
2090 return IFCALLRESULT(TRUE, proxy->PatBlt, msg->context, (
PATBLT_ORDER*)msg->wParam);
2092 case PrimaryUpdate_ScrBlt:
2093 return IFCALLRESULT(TRUE, proxy->ScrBlt, msg->context, (
SCRBLT_ORDER*)msg->wParam);
2095 case PrimaryUpdate_OpaqueRect:
2096 return IFCALLRESULT(TRUE, proxy->OpaqueRect, msg->context,
2099 case PrimaryUpdate_DrawNineGrid:
2100 return IFCALLRESULT(TRUE, proxy->DrawNineGrid, msg->context,
2103 case PrimaryUpdate_MultiDstBlt:
2104 return IFCALLRESULT(TRUE, proxy->MultiDstBlt, msg->context,
2107 case PrimaryUpdate_MultiPatBlt:
2108 return IFCALLRESULT(TRUE, proxy->MultiPatBlt, msg->context,
2111 case PrimaryUpdate_MultiScrBlt:
2112 return IFCALLRESULT(TRUE, proxy->MultiScrBlt, msg->context,
2115 case PrimaryUpdate_MultiOpaqueRect:
2116 return IFCALLRESULT(TRUE, proxy->MultiOpaqueRect, msg->context,
2119 case PrimaryUpdate_MultiDrawNineGrid:
2120 return IFCALLRESULT(TRUE, proxy->MultiDrawNineGrid, msg->context,
2123 case PrimaryUpdate_LineTo:
2124 return IFCALLRESULT(TRUE, proxy->LineTo, msg->context, (
LINE_TO_ORDER*)msg->wParam);
2126 case PrimaryUpdate_Polyline:
2127 return IFCALLRESULT(TRUE, proxy->Polyline, msg->context, (
POLYLINE_ORDER*)msg->wParam);
2129 case PrimaryUpdate_MemBlt:
2130 return IFCALLRESULT(TRUE, proxy->MemBlt, msg->context, (
MEMBLT_ORDER*)msg->wParam);
2132 case PrimaryUpdate_Mem3Blt:
2133 return IFCALLRESULT(TRUE, proxy->Mem3Blt, msg->context, (
MEM3BLT_ORDER*)msg->wParam);
2135 case PrimaryUpdate_SaveBitmap:
2136 return IFCALLRESULT(TRUE, proxy->SaveBitmap, msg->context,
2139 case PrimaryUpdate_GlyphIndex:
2140 return IFCALLRESULT(TRUE, proxy->GlyphIndex, msg->context,
2143 case PrimaryUpdate_FastIndex:
2144 return IFCALLRESULT(TRUE, proxy->FastIndex, msg->context,
2147 case PrimaryUpdate_FastGlyph:
2148 return IFCALLRESULT(TRUE, proxy->FastGlyph, msg->context,
2151 case PrimaryUpdate_PolygonSC:
2152 return IFCALLRESULT(TRUE, proxy->PolygonSC, msg->context,
2155 case PrimaryUpdate_PolygonCB:
2156 return IFCALLRESULT(TRUE, proxy->PolygonCB, msg->context,
2159 case PrimaryUpdate_EllipseSC:
2160 return IFCALLRESULT(TRUE, proxy->EllipseSC, msg->context,
2163 case PrimaryUpdate_EllipseCB:
2164 return IFCALLRESULT(TRUE, proxy->EllipseCB, msg->context,
2172static BOOL update_message_free_secondary_update_class(wMessage* msg,
int type)
2174 rdpContext* context =
nullptr;
2179 context = msg->context;
2183 case SecondaryUpdate_CacheBitmap:
2186 free_cache_bitmap_order(context, wParam);
2190 case SecondaryUpdate_CacheBitmapV2:
2193 free_cache_bitmap_v2_order(context, wParam);
2197 case SecondaryUpdate_CacheBitmapV3:
2200 free_cache_bitmap_v3_order(context, wParam);
2204 case SecondaryUpdate_CacheColorTable:
2207 free_cache_color_table_order(context, wParam);
2211 case SecondaryUpdate_CacheGlyph:
2214 free_cache_glyph_order(context, wParam);
2218 case SecondaryUpdate_CacheGlyphV2:
2221 free_cache_glyph_v2_order(context, wParam);
2225 case SecondaryUpdate_CacheBrush:
2228 free_cache_brush_order(context, wParam);
2239static BOOL update_message_process_secondary_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2247 case SecondaryUpdate_CacheBitmap:
2248 return IFCALLRESULT(TRUE, proxy->CacheBitmap, msg->context,
2251 case SecondaryUpdate_CacheBitmapV2:
2252 return IFCALLRESULT(TRUE, proxy->CacheBitmapV2, msg->context,
2255 case SecondaryUpdate_CacheBitmapV3:
2256 return IFCALLRESULT(TRUE, proxy->CacheBitmapV3, msg->context,
2259 case SecondaryUpdate_CacheColorTable:
2260 return IFCALLRESULT(TRUE, proxy->CacheColorTable, msg->context,
2263 case SecondaryUpdate_CacheGlyph:
2264 return IFCALLRESULT(TRUE, proxy->CacheGlyph, msg->context,
2267 case SecondaryUpdate_CacheGlyphV2:
2268 return IFCALLRESULT(TRUE, proxy->CacheGlyphV2, msg->context,
2271 case SecondaryUpdate_CacheBrush:
2272 return IFCALLRESULT(TRUE, proxy->CacheBrush, msg->context,
2280static BOOL update_message_free_altsec_update_class(wMessage* msg,
int type)
2287 case AltSecUpdate_CreateOffscreenBitmap:
2290 free(wParam->deleteList.indices);
2295 case AltSecUpdate_SwitchSurface:
2299 case AltSecUpdate_CreateNineGridBitmap:
2303 case AltSecUpdate_FrameMarker:
2307 case AltSecUpdate_StreamBitmapFirst:
2311 case AltSecUpdate_StreamBitmapNext:
2315 case AltSecUpdate_DrawGdiPlusFirst:
2319 case AltSecUpdate_DrawGdiPlusNext:
2323 case AltSecUpdate_DrawGdiPlusEnd:
2327 case AltSecUpdate_DrawGdiPlusCacheFirst:
2331 case AltSecUpdate_DrawGdiPlusCacheNext:
2335 case AltSecUpdate_DrawGdiPlusCacheEnd:
2346static BOOL update_message_process_altsec_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2354 case AltSecUpdate_CreateOffscreenBitmap:
2355 return IFCALLRESULT(TRUE, proxy->CreateOffscreenBitmap, msg->context,
2358 case AltSecUpdate_SwitchSurface:
2359 return IFCALLRESULT(TRUE, proxy->SwitchSurface, msg->context,
2362 case AltSecUpdate_CreateNineGridBitmap:
2363 return IFCALLRESULT(TRUE, proxy->CreateNineGridBitmap, msg->context,
2366 case AltSecUpdate_FrameMarker:
2367 return IFCALLRESULT(TRUE, proxy->FrameMarker, msg->context,
2370 case AltSecUpdate_StreamBitmapFirst:
2371 return IFCALLRESULT(TRUE, proxy->StreamBitmapFirst, msg->context,
2374 case AltSecUpdate_StreamBitmapNext:
2375 return IFCALLRESULT(TRUE, proxy->StreamBitmapNext, msg->context,
2378 case AltSecUpdate_DrawGdiPlusFirst:
2379 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusFirst, msg->context,
2382 case AltSecUpdate_DrawGdiPlusNext:
2383 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusNext, msg->context,
2386 case AltSecUpdate_DrawGdiPlusEnd:
2387 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusEnd, msg->context,
2390 case AltSecUpdate_DrawGdiPlusCacheFirst:
2391 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusCacheFirst, msg->context,
2394 case AltSecUpdate_DrawGdiPlusCacheNext:
2395 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusCacheNext, msg->context,
2398 case AltSecUpdate_DrawGdiPlusCacheEnd:
2399 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusCacheEnd, msg->context,
2407static BOOL update_message_free_window_update_class(wMessage* msg,
int type)
2414 case WindowUpdate_WindowCreate:
2416 window_state_order_free(msg->lParam);
2419 case WindowUpdate_WindowUpdate:
2421 window_state_order_free(msg->lParam);
2424 case WindowUpdate_WindowIcon:
2429 if (windowIcon->iconInfo->cbBitsColor > 0)
2431 free(windowIcon->iconInfo->bitsColor);
2434 if (windowIcon->iconInfo->cbBitsMask > 0)
2436 free(windowIcon->iconInfo->bitsMask);
2439 if (windowIcon->iconInfo->cbColorTable > 0)
2441 free(windowIcon->iconInfo->colorTable);
2445 free(windowIcon->iconInfo);
2450 case WindowUpdate_WindowCachedIcon:
2455 case WindowUpdate_WindowDelete:
2459 case WindowUpdate_NotifyIconCreate:
2461 notify_icon_state_order_free(msg->lParam);
2464 case WindowUpdate_NotifyIconUpdate:
2466 notify_icon_state_order_free(msg->lParam);
2469 case WindowUpdate_NotifyIconDelete:
2473 case WindowUpdate_MonitoredDesktop:
2477 free(lParam->windowIds);
2482 case WindowUpdate_NonMonitoredDesktop:
2493static BOOL update_message_process_window_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2501 case WindowUpdate_WindowCreate:
2502 return IFCALLRESULT(TRUE, proxy->WindowCreate, msg->context,
2505 case WindowUpdate_WindowUpdate:
2506 return IFCALLRESULT(TRUE, proxy->WindowCreate, msg->context,
2509 case WindowUpdate_WindowIcon:
2513 return IFCALLRESULT(TRUE, proxy->WindowIcon, msg->context, orderInfo, windowIcon);
2516 case WindowUpdate_WindowCachedIcon:
2517 return IFCALLRESULT(TRUE, proxy->WindowCachedIcon, msg->context,
2521 case WindowUpdate_WindowDelete:
2522 return IFCALLRESULT(TRUE, proxy->WindowDelete, msg->context,
2525 case WindowUpdate_NotifyIconCreate:
2526 return IFCALLRESULT(TRUE, proxy->NotifyIconCreate, msg->context,
2530 case WindowUpdate_NotifyIconUpdate:
2531 return IFCALLRESULT(TRUE, proxy->NotifyIconUpdate, msg->context,
2535 case WindowUpdate_NotifyIconDelete:
2536 return IFCALLRESULT(TRUE, proxy->NotifyIconDelete, msg->context,
2539 case WindowUpdate_MonitoredDesktop:
2540 return IFCALLRESULT(TRUE, proxy->MonitoredDesktop, msg->context,
2544 case WindowUpdate_NonMonitoredDesktop:
2545 return IFCALLRESULT(TRUE, proxy->NonMonitoredDesktop, msg->context,
2553static BOOL update_message_free_pointer_update_class(wMessage* msg,
int type)
2555 rdpContext* context =
nullptr;
2560 context = msg->context;
2564 case PointerUpdate_PointerPosition:
2567 free_pointer_position_update(context, wParam);
2571 case PointerUpdate_PointerSystem:
2574 free_pointer_system_update(context, wParam);
2578 case PointerUpdate_PointerCached:
2581 free_pointer_cached_update(context, wParam);
2585 case PointerUpdate_PointerColor:
2588 free_pointer_color_update(context, wParam);
2592 case PointerUpdate_PointerNew:
2595 free_pointer_new_update(context, wParam);
2606static BOOL update_message_process_pointer_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2614 case PointerUpdate_PointerPosition:
2615 return IFCALLRESULT(TRUE, proxy->PointerPosition, msg->context,
2618 case PointerUpdate_PointerSystem:
2619 return IFCALLRESULT(TRUE, proxy->PointerSystem, msg->context,
2622 case PointerUpdate_PointerColor:
2623 return IFCALLRESULT(TRUE, proxy->PointerColor, msg->context,
2626 case PointerUpdate_PointerNew:
2627 return IFCALLRESULT(TRUE, proxy->PointerNew, msg->context,
2630 case PointerUpdate_PointerCached:
2631 return IFCALLRESULT(TRUE, proxy->PointerCached, msg->context,
2639static BOOL update_message_free_class(wMessage* msg,
int msgClass,
int msgType)
2641 BOOL status = FALSE;
2646 status = update_message_free_update_class(msg, msgType);
2649 case PrimaryUpdate_Class:
2650 status = update_message_free_primary_update_class(msg, msgType);
2653 case SecondaryUpdate_Class:
2654 status = update_message_free_secondary_update_class(msg, msgType);
2657 case AltSecUpdate_Class:
2658 status = update_message_free_altsec_update_class(msg, msgType);
2661 case WindowUpdate_Class:
2662 status = update_message_free_window_update_class(msg, msgType);
2665 case PointerUpdate_Class:
2666 status = update_message_free_pointer_update_class(msg, msgType);
2674 WLog_ERR(TAG,
"Unknown message: class: %d type: %d", msgClass, msgType);
2679static int update_message_process_class(rdpUpdateProxy* proxy, wMessage* msg,
int msgClass,
2682 BOOL status = FALSE;
2687 status = update_message_process_update_class(proxy, msg, msgType);
2690 case PrimaryUpdate_Class:
2691 status = update_message_process_primary_update_class(proxy, msg, msgType);
2694 case SecondaryUpdate_Class:
2695 status = update_message_process_secondary_update_class(proxy, msg, msgType);
2698 case AltSecUpdate_Class:
2699 status = update_message_process_altsec_update_class(proxy, msg, msgType);
2702 case WindowUpdate_Class:
2703 status = update_message_process_window_update_class(proxy, msg, msgType);
2706 case PointerUpdate_Class:
2707 status = update_message_process_pointer_update_class(proxy, msg, msgType);
2717 WLog_ERR(TAG,
"message: class: %d type: %d failed", msgClass, msgType);
2724int update_message_queue_process_message(rdpUpdate* update, wMessage* message)
2731 if (!update || !message)
2734 if (message->id == WMQ_QUIT)
2737 msgClass = GetMessageClass(message->id);
2738 msgType = GetMessageType(message->id);
2739 status = update_message_process_class(up->proxy, message, msgClass, msgType);
2740 update_message_free_class(message, msgClass, msgType);
2748int update_message_queue_free_message(wMessage* message)
2756 if (message->id == WMQ_QUIT)
2759 msgClass = GetMessageClass(message->id);
2760 msgType = GetMessageType(message->id);
2761 return update_message_free_class(message, msgClass, msgType);
2764int update_message_queue_process_pending_messages(rdpUpdate* update)
2767 wMessage message = WINPR_C_ARRAY_INIT;
2770 wMessageQueue* queue = up->queue;
2772 while (MessageQueue_Peek(queue, &message, TRUE))
2774 status = update_message_queue_process_message(update, &message);
2783static BOOL update_message_register_interface(rdpUpdateProxy* message, rdpUpdate* update)
2785 rdpPrimaryUpdate* primary =
nullptr;
2786 rdpSecondaryUpdate* secondary =
nullptr;
2787 rdpAltSecUpdate* altsec =
nullptr;
2788 rdpWindowUpdate* window =
nullptr;
2789 rdpPointerUpdate* pointer =
nullptr;
2791 if (!message || !update)
2794 primary = update->primary;
2795 secondary = update->secondary;
2796 altsec = update->altsec;
2797 window = update->window;
2798 pointer = update->pointer;
2800 if (!primary || !secondary || !altsec || !window || !pointer)
2804 message->BeginPaint = update->BeginPaint;
2805 message->EndPaint = update->EndPaint;
2806 message->SetBounds = update->SetBounds;
2807 message->Synchronize = update->Synchronize;
2808 message->DesktopResize = update->DesktopResize;
2809 message->BitmapUpdate = update->BitmapUpdate;
2810 message->Palette = update->Palette;
2811 message->PlaySound = update->PlaySound;
2812 message->SetKeyboardIndicators = update->SetKeyboardIndicators;
2813 message->SetKeyboardImeStatus = update->SetKeyboardImeStatus;
2814 message->RefreshRect = update->RefreshRect;
2815 message->SuppressOutput = update->SuppressOutput;
2816 message->SurfaceCommand = update->SurfaceCommand;
2817 message->SurfaceBits = update->SurfaceBits;
2818 message->SurfaceFrameMarker = update->SurfaceFrameMarker;
2819 message->SurfaceFrameAcknowledge = update->SurfaceFrameAcknowledge;
2820 update->BeginPaint = update_message_BeginPaint;
2821 update->EndPaint = update_message_EndPaint;
2822 update->SetBounds = update_message_SetBounds;
2823 update->Synchronize = update_message_Synchronize;
2824 update->DesktopResize = update_message_DesktopResize;
2825 update->BitmapUpdate = update_message_BitmapUpdate;
2826 update->Palette = update_message_Palette;
2827 update->PlaySound = update_message_PlaySound;
2828 update->SetKeyboardIndicators = update_message_SetKeyboardIndicators;
2829 update->SetKeyboardImeStatus = update_message_SetKeyboardImeStatus;
2830 update->RefreshRect = update_message_RefreshRect;
2831 update->SuppressOutput = update_message_SuppressOutput;
2832 update->SurfaceCommand = update_message_SurfaceCommand;
2833 update->SurfaceBits = update_message_SurfaceBits;
2834 update->SurfaceFrameMarker = update_message_SurfaceFrameMarker;
2835 update->SurfaceFrameAcknowledge = update_message_SurfaceFrameAcknowledge;
2837 message->DstBlt = primary->DstBlt;
2838 message->PatBlt = primary->PatBlt;
2839 message->ScrBlt = primary->ScrBlt;
2840 message->OpaqueRect = primary->OpaqueRect;
2841 message->DrawNineGrid = primary->DrawNineGrid;
2842 message->MultiDstBlt = primary->MultiDstBlt;
2843 message->MultiPatBlt = primary->MultiPatBlt;
2844 message->MultiScrBlt = primary->MultiScrBlt;
2845 message->MultiOpaqueRect = primary->MultiOpaqueRect;
2846 message->MultiDrawNineGrid = primary->MultiDrawNineGrid;
2847 message->LineTo = primary->LineTo;
2848 message->Polyline = primary->Polyline;
2849 message->MemBlt = primary->MemBlt;
2850 message->Mem3Blt = primary->Mem3Blt;
2851 message->SaveBitmap = primary->SaveBitmap;
2852 message->GlyphIndex = primary->GlyphIndex;
2853 message->FastIndex = primary->FastIndex;
2854 message->FastGlyph = primary->FastGlyph;
2855 message->PolygonSC = primary->PolygonSC;
2856 message->PolygonCB = primary->PolygonCB;
2857 message->EllipseSC = primary->EllipseSC;
2858 message->EllipseCB = primary->EllipseCB;
2859 primary->DstBlt = update_message_DstBlt;
2860 primary->PatBlt = update_message_PatBlt;
2861 primary->ScrBlt = update_message_ScrBlt;
2862 primary->OpaqueRect = update_message_OpaqueRect;
2863 primary->DrawNineGrid = update_message_DrawNineGrid;
2864 primary->MultiDstBlt = update_message_MultiDstBlt;
2865 primary->MultiPatBlt = update_message_MultiPatBlt;
2866 primary->MultiScrBlt = update_message_MultiScrBlt;
2867 primary->MultiOpaqueRect = update_message_MultiOpaqueRect;
2868 primary->MultiDrawNineGrid = update_message_MultiDrawNineGrid;
2869 primary->LineTo = update_message_LineTo;
2870 primary->Polyline = update_message_Polyline;
2871 primary->MemBlt = update_message_MemBlt;
2872 primary->Mem3Blt = update_message_Mem3Blt;
2873 primary->SaveBitmap = update_message_SaveBitmap;
2874 primary->GlyphIndex = update_message_GlyphIndex;
2875 primary->FastIndex = update_message_FastIndex;
2876 primary->FastGlyph = update_message_FastGlyph;
2877 primary->PolygonSC = update_message_PolygonSC;
2878 primary->PolygonCB = update_message_PolygonCB;
2879 primary->EllipseSC = update_message_EllipseSC;
2880 primary->EllipseCB = update_message_EllipseCB;
2882 message->CacheBitmap = secondary->CacheBitmap;
2883 message->CacheBitmapV2 = secondary->CacheBitmapV2;
2884 message->CacheBitmapV3 = secondary->CacheBitmapV3;
2885 message->CacheColorTable = secondary->CacheColorTable;
2886 message->CacheGlyph = secondary->CacheGlyph;
2887 message->CacheGlyphV2 = secondary->CacheGlyphV2;
2888 message->CacheBrush = secondary->CacheBrush;
2889 secondary->CacheBitmap = update_message_CacheBitmap;
2890 secondary->CacheBitmapV2 = update_message_CacheBitmapV2;
2891 secondary->CacheBitmapV3 = update_message_CacheBitmapV3;
2892 secondary->CacheColorTable = update_message_CacheColorTable;
2893 secondary->CacheGlyph = update_message_CacheGlyph;
2894 secondary->CacheGlyphV2 = update_message_CacheGlyphV2;
2895 secondary->CacheBrush = update_message_CacheBrush;
2897 message->CreateOffscreenBitmap = altsec->CreateOffscreenBitmap;
2898 message->SwitchSurface = altsec->SwitchSurface;
2899 message->CreateNineGridBitmap = altsec->CreateNineGridBitmap;
2900 message->FrameMarker = altsec->FrameMarker;
2901 message->StreamBitmapFirst = altsec->StreamBitmapFirst;
2902 message->StreamBitmapNext = altsec->StreamBitmapNext;
2903 message->DrawGdiPlusFirst = altsec->DrawGdiPlusFirst;
2904 message->DrawGdiPlusNext = altsec->DrawGdiPlusNext;
2905 message->DrawGdiPlusEnd = altsec->DrawGdiPlusEnd;
2906 message->DrawGdiPlusCacheFirst = altsec->DrawGdiPlusCacheFirst;
2907 message->DrawGdiPlusCacheNext = altsec->DrawGdiPlusCacheNext;
2908 message->DrawGdiPlusCacheEnd = altsec->DrawGdiPlusCacheEnd;
2909 altsec->CreateOffscreenBitmap = update_message_CreateOffscreenBitmap;
2910 altsec->SwitchSurface = update_message_SwitchSurface;
2911 altsec->CreateNineGridBitmap = update_message_CreateNineGridBitmap;
2912 altsec->FrameMarker = update_message_FrameMarker;
2913 altsec->StreamBitmapFirst = update_message_StreamBitmapFirst;
2914 altsec->StreamBitmapNext = update_message_StreamBitmapNext;
2915 altsec->DrawGdiPlusFirst = update_message_DrawGdiPlusFirst;
2916 altsec->DrawGdiPlusNext = update_message_DrawGdiPlusNext;
2917 altsec->DrawGdiPlusEnd = update_message_DrawGdiPlusEnd;
2918 altsec->DrawGdiPlusCacheFirst = update_message_DrawGdiPlusCacheFirst;
2919 altsec->DrawGdiPlusCacheNext = update_message_DrawGdiPlusCacheNext;
2920 altsec->DrawGdiPlusCacheEnd = update_message_DrawGdiPlusCacheEnd;
2922 message->WindowCreate = window->WindowCreate;
2923 message->WindowUpdate = window->WindowUpdate;
2924 message->WindowIcon = window->WindowIcon;
2925 message->WindowCachedIcon = window->WindowCachedIcon;
2926 message->WindowDelete = window->WindowDelete;
2927 message->NotifyIconCreate = window->NotifyIconCreate;
2928 message->NotifyIconUpdate = window->NotifyIconUpdate;
2929 message->NotifyIconDelete = window->NotifyIconDelete;
2930 message->MonitoredDesktop = window->MonitoredDesktop;
2931 message->NonMonitoredDesktop = window->NonMonitoredDesktop;
2932 window->WindowCreate = update_message_WindowCreate;
2933 window->WindowUpdate = update_message_WindowUpdate;
2934 window->WindowIcon = update_message_WindowIcon;
2935 window->WindowCachedIcon = update_message_WindowCachedIcon;
2936 window->WindowDelete = update_message_WindowDelete;
2937 window->NotifyIconCreate = update_message_NotifyIconCreate;
2938 window->NotifyIconUpdate = update_message_NotifyIconUpdate;
2939 window->NotifyIconDelete = update_message_NotifyIconDelete;
2940 window->MonitoredDesktop = update_message_MonitoredDesktop;
2941 window->NonMonitoredDesktop = update_message_NonMonitoredDesktop;
2943 message->PointerPosition = pointer->PointerPosition;
2944 message->PointerSystem = pointer->PointerSystem;
2945 message->PointerColor = pointer->PointerColor;
2946 message->PointerLarge = pointer->PointerLarge;
2947 message->PointerNew = pointer->PointerNew;
2948 message->PointerCached = pointer->PointerCached;
2949 pointer->PointerPosition = update_message_PointerPosition;
2950 pointer->PointerSystem = update_message_PointerSystem;
2951 pointer->PointerColor = update_message_PointerColor;
2952 pointer->PointerLarge = update_message_PointerLarge;
2953 pointer->PointerNew = update_message_PointerNew;
2954 pointer->PointerCached = update_message_PointerCached;
2958static DWORD WINAPI update_message_proxy_thread(LPVOID arg)
2960 rdpUpdate* update = (rdpUpdate*)arg;
2961 wMessage message = WINPR_C_ARRAY_INIT;
2964 while (MessageQueue_Wait(up->queue))
2968 if (MessageQueue_Peek(up->queue, &message, TRUE))
2969 status = update_message_queue_process_message(update, &message);
2979rdpUpdateProxy* update_message_proxy_new(rdpUpdate* update)
2981 rdpUpdateProxy* message =
nullptr;
2986 if (!(message = (rdpUpdateProxy*)calloc(1,
sizeof(rdpUpdateProxy))))
2989 message->update = update;
2990 update_message_register_interface(message, update);
2992 if (!(message->thread =
2993 CreateThread(
nullptr, 0, update_message_proxy_thread, update, 0,
nullptr)))
2995 WLog_ERR(TAG,
"Failed to create proxy thread");
3003void update_message_proxy_free(rdpUpdateProxy* message)
3008 if (MessageQueue_PostQuit(up->queue, 0))
3009 (void)WaitForSingleObject(message->thread, INFINITE);
3011 (void)CloseHandle(message->thread);
3017static int input_message_free_input_class(wMessage* msg,
int type)
3025 case Input_SynchronizeEvent:
3028 case Input_KeyboardEvent:
3031 case Input_UnicodeKeyboardEvent:
3034 case Input_MouseEvent:
3037 case Input_ExtendedMouseEvent:
3040 case Input_FocusInEvent:
3043 case Input_KeyboardPauseEvent:
3054static int input_message_process_input_class(rdpInputProxy* proxy, wMessage* msg,
int type)
3063 case Input_SynchronizeEvent:
3064 IFCALL(proxy->SynchronizeEvent, msg->context, (UINT32)(
size_t)msg->wParam);
3067 case Input_KeyboardEvent:
3068 IFCALL(proxy->KeyboardEvent, msg->context, (UINT16)(
size_t)msg->wParam,
3069 (UINT8)(
size_t)msg->lParam);
3072 case Input_UnicodeKeyboardEvent:
3073 IFCALL(proxy->UnicodeKeyboardEvent, msg->context, (UINT16)(
size_t)msg->wParam,
3074 (UINT16)(
size_t)msg->lParam);
3077 case Input_MouseEvent:
3082 pos = (UINT32)(
size_t)msg->lParam;
3083 x = ((pos & 0xFFFF0000) >> 16);
3084 y = (pos & 0x0000FFFF);
3085 IFCALL(proxy->MouseEvent, msg->context, (UINT16)(
size_t)msg->wParam, x, y);
3089 case Input_ExtendedMouseEvent:
3094 pos = (UINT32)(
size_t)msg->lParam;
3095 x = ((pos & 0xFFFF0000) >> 16);
3096 y = (pos & 0x0000FFFF);
3097 IFCALL(proxy->ExtendedMouseEvent, msg->context, (UINT16)(
size_t)msg->wParam, x, y);
3101 case Input_FocusInEvent:
3102 IFCALL(proxy->FocusInEvent, msg->context, (UINT16)(
size_t)msg->wParam);
3105 case Input_KeyboardPauseEvent:
3106 IFCALL(proxy->KeyboardPauseEvent, msg->context);
3117static int input_message_free_class(wMessage* msg,
int msgClass,
int msgType)
3124 status = input_message_free_input_class(msg, msgType);
3133 WLog_ERR(TAG,
"Unknown event: class: %d type: %d", msgClass, msgType);
3138static int input_message_process_class(rdpInputProxy* proxy, wMessage* msg,
int msgClass,
3146 status = input_message_process_input_class(proxy, msg, msgType);
3155 WLog_ERR(TAG,
"Unknown event: class: %d type: %d", msgClass, msgType);
3160int input_message_queue_free_message(wMessage* message)
3169 if (message->id == WMQ_QUIT)
3172 msgClass = GetMessageClass(message->id);
3173 msgType = GetMessageType(message->id);
3174 status = input_message_free_class(message, msgClass, msgType);
3182int input_message_queue_process_message(rdpInput* input, wMessage* message)
3192 if (message->id == WMQ_QUIT)
3195 msgClass = GetMessageClass(message->id);
3196 msgType = GetMessageType(message->id);
3197 status = input_message_process_class(in->proxy, message, msgClass, msgType);
3198 input_message_free_class(message, msgClass, msgType);
3206int input_message_queue_process_pending_messages(rdpInput* input)
3209 wMessage message = WINPR_C_ARRAY_INIT;
3215 wMessageQueue* queue = in->queue;
3217 while (MessageQueue_Peek(queue, &message, TRUE))
3219 status = input_message_queue_process_message(input, &message);