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->numWindowRects > 0)) ||
1266 (!clone->visibilityRects && (clone->numVisibilityRects > 0)) ||
1267 (!clone->titleInfo.string && (clone->titleInfo.length > 0)) ||
1268 (!clone->OverlayDescription.string && (clone->OverlayDescription.length > 0)))
1270 window_state_order_free(clone);
1276static BOOL update_message_WindowCreate(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1279 if (!context || !context->update || !orderInfo || !windowState)
1287 *wParam = *orderInfo;
1298 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(WindowUpdate, WindowCreate),
1299 (
void*)wParam, (
void*)lParam);
1302static BOOL update_message_WindowUpdate(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1305 if (!context || !context->update || !orderInfo || !windowState)
1313 *wParam = *orderInfo;
1324 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(WindowUpdate, WindowUpdate),
1325 (
void*)wParam, (
void*)lParam);
1328static BOOL update_message_WindowIcon(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1331 if (!context || !context->update || !orderInfo || !windowIcon)
1339 *wParam = *orderInfo;
1346 *lParam = *windowIcon;
1347 lParam->iconInfo = calloc(1,
sizeof(
ICON_INFO));
1349 if (!lParam->iconInfo)
1352 *lParam->iconInfo = *windowIcon->iconInfo;
1354 WLog_VRB(TAG,
"update_message_WindowIcon");
1356 if (windowIcon->iconInfo->cbBitsColor > 0)
1358 lParam->iconInfo->bitsColor = (BYTE*)malloc(windowIcon->iconInfo->cbBitsColor);
1360 if (!lParam->iconInfo->bitsColor)
1363 CopyMemory(lParam->iconInfo->bitsColor, windowIcon->iconInfo->bitsColor,
1364 windowIcon->iconInfo->cbBitsColor);
1367 if (windowIcon->iconInfo->cbBitsMask > 0)
1369 lParam->iconInfo->bitsMask = (BYTE*)malloc(windowIcon->iconInfo->cbBitsMask);
1371 if (!lParam->iconInfo->bitsMask)
1374 CopyMemory(lParam->iconInfo->bitsMask, windowIcon->iconInfo->bitsMask,
1375 windowIcon->iconInfo->cbBitsMask);
1378 if (windowIcon->iconInfo->cbColorTable > 0)
1380 lParam->iconInfo->colorTable = (BYTE*)malloc(windowIcon->iconInfo->cbColorTable);
1382 if (!lParam->iconInfo->colorTable)
1385 CopyMemory(lParam->iconInfo->colorTable, windowIcon->iconInfo->colorTable,
1386 windowIcon->iconInfo->cbColorTable);
1390 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(WindowUpdate, WindowIcon),
1391 (
void*)wParam, (
void*)lParam);
1394 if (lParam && lParam->iconInfo)
1396 free(lParam->iconInfo->bitsColor);
1397 free(lParam->iconInfo->bitsMask);
1398 free(lParam->iconInfo->colorTable);
1399 free(lParam->iconInfo);
1407static BOOL update_message_WindowCachedIcon(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1414 if (!context || !context->update || !orderInfo || !windowCachedIcon)
1433 up = update_cast(context->update);
1434 return MessageQueue_Post(up->queue, (
void*)context,
1435 MakeMessageId(WindowUpdate, WindowCachedIcon), (
void*)wParam,
1439static BOOL update_message_WindowDelete(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo)
1444 if (!context || !context->update || !orderInfo)
1454 up = update_cast(context->update);
1455 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(WindowUpdate, WindowDelete),
1456 (
void*)wParam,
nullptr);
1464 rail_unicode_string_free(¬ify->toolTip);
1465 rail_unicode_string_free(¬ify->infoTip.text);
1466 rail_unicode_string_free(¬ify->infoTip.title);
1467 free(notify->icon.bitsColor);
1468 free(notify->icon.bitsMask);
1469 free(notify->icon.colorTable);
1475 dst->bitsColor =
nullptr;
1476 dst->bitsMask =
nullptr;
1477 dst->colorTable =
nullptr;
1479 if (src->cbBitsColor > 0)
1481 dst->bitsColor = (BYTE*)malloc(src->cbBitsColor);
1482 if (!dst->bitsColor)
1484 CopyMemory(dst->bitsColor, src->bitsColor, src->cbBitsColor);
1487 if (src->cbBitsMask > 0)
1489 dst->bitsMask = (BYTE*)malloc(src->cbBitsMask);
1492 CopyMemory(dst->bitsMask, src->bitsMask, src->cbBitsMask);
1495 if (src->cbColorTable > 0)
1497 dst->colorTable = (BYTE*)malloc(src->cbColorTable);
1498 if (!dst->colorTable)
1500 CopyMemory(dst->colorTable, src->colorTable, src->cbColorTable);
1513 clone->toolTip = rail_unicode_string_clone(&order->toolTip);
1514 clone->infoTip.text = rail_unicode_string_clone(&order->infoTip.text);
1515 clone->infoTip.title = rail_unicode_string_clone(&order->infoTip.title);
1517 if (!icon_info_clone(&clone->icon, &order->icon) ||
1518 (!clone->toolTip.string && (order->toolTip.length > 0)) ||
1519 (!clone->infoTip.text.string && (order->infoTip.text.length > 0)) ||
1520 (!clone->infoTip.title.string && (order->infoTip.title.length > 0)))
1522 notify_icon_state_order_free(clone);
1529static BOOL update_message_NotifyIconCreate(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1536 if (!context || !context->update || !orderInfo || !notifyIconState)
1545 lParam = notify_icon_state_order_clone(notifyIconState);
1553 up = update_cast(context->update);
1554 return MessageQueue_Post(up->queue, (
void*)context,
1555 MakeMessageId(WindowUpdate, NotifyIconCreate), (
void*)wParam,
1559static BOOL update_message_NotifyIconUpdate(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1566 if (!context || !context->update || !orderInfo || !notifyIconState)
1575 lParam = notify_icon_state_order_clone(notifyIconState);
1583 up = update_cast(context->update);
1584 return MessageQueue_Post(up->queue, (
void*)context,
1585 MakeMessageId(WindowUpdate, NotifyIconUpdate), (
void*)wParam,
1589static BOOL update_message_NotifyIconDelete(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo)
1594 if (!context || !context->update || !orderInfo)
1604 up = update_cast(context->update);
1605 return MessageQueue_Post(up->queue, (
void*)context,
1606 MakeMessageId(WindowUpdate, NotifyIconDelete), (
void*)wParam,
nullptr);
1609static BOOL update_message_MonitoredDesktop(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1616 if (!context || !context->update || !orderInfo || !monitoredDesktop)
1634 lParam->windowIds =
nullptr;
1636 if (lParam->numWindowIds)
1638 lParam->windowIds = (UINT32*)calloc(lParam->numWindowIds,
sizeof(UINT32));
1639 CopyMemory(lParam->windowIds, monitoredDesktop->windowIds, lParam->numWindowIds);
1642 up = update_cast(context->update);
1643 return MessageQueue_Post(up->queue, (
void*)context,
1644 MakeMessageId(WindowUpdate, MonitoredDesktop), (
void*)wParam,
1648static BOOL update_message_NonMonitoredDesktop(rdpContext* context,
1654 if (!context || !context->update || !orderInfo)
1664 up = update_cast(context->update);
1665 return MessageQueue_Post(up->queue, (
void*)context,
1666 MakeMessageId(WindowUpdate, NonMonitoredDesktop), (
void*)wParam,
1672static BOOL update_message_PointerPosition(rdpContext* context,
1678 if (!context || !context->update || !pointerPosition)
1681 wParam = copy_pointer_position_update(context, pointerPosition);
1686 up = update_cast(context->update);
1687 return MessageQueue_Post(up->queue, (
void*)context,
1688 MakeMessageId(PointerUpdate, PointerPosition), (
void*)wParam,
nullptr);
1691static BOOL update_message_PointerSystem(rdpContext* context,
1697 if (!context || !context->update || !pointerSystem)
1700 wParam = copy_pointer_system_update(context, pointerSystem);
1705 up = update_cast(context->update);
1706 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerSystem),
1707 (
void*)wParam,
nullptr);
1710static BOOL update_message_PointerColor(rdpContext* context,
1716 if (!context || !context->update || !pointerColor)
1719 wParam = copy_pointer_color_update(context, pointerColor);
1724 up = update_cast(context->update);
1725 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerColor),
1726 (
void*)wParam,
nullptr);
1729static BOOL update_message_PointerLarge(rdpContext* context,
const POINTER_LARGE_UPDATE* pointer)
1734 if (!context || !context->update || !pointer)
1737 wParam = copy_pointer_large_update(context, pointer);
1742 up = update_cast(context->update);
1743 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerLarge),
1744 (
void*)wParam,
nullptr);
1747static BOOL update_message_PointerNew(rdpContext* context,
const POINTER_NEW_UPDATE* pointerNew)
1752 if (!context || !context->update || !pointerNew)
1755 wParam = copy_pointer_new_update(context, pointerNew);
1760 up = update_cast(context->update);
1761 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerNew),
1762 (
void*)wParam,
nullptr);
1765static BOOL update_message_PointerCached(rdpContext* context,
1771 if (!context || !context->update || !pointerCached)
1774 wParam = copy_pointer_cached_update(context, pointerCached);
1779 up = update_cast(context->update);
1780 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerCached),
1781 (
void*)wParam,
nullptr);
1785static BOOL update_message_free_update_class(wMessage* msg,
int type)
1787 rdpContext* context =
nullptr;
1792 context = (rdpContext*)msg->context;
1796 case Update_BeginPaint:
1799 case Update_EndPaint:
1802 case Update_SetBounds:
1806 case Update_Synchronize:
1809 case Update_DesktopResize:
1812 case Update_BitmapUpdate:
1815 free_bitmap_update(context, wParam);
1819 case Update_Palette:
1822 free_palette_update(context, palette);
1826 case Update_PlaySound:
1830 case Update_RefreshRect:
1834 case Update_SuppressOutput:
1838 case Update_SurfaceCommand:
1841 Stream_Free(s, TRUE);
1845 case Update_SurfaceBits:
1848 free_surface_bits_command(context, wParam);
1852 case Update_SurfaceFrameMarker:
1856 case Update_SurfaceFrameAcknowledge:
1857 case Update_SetKeyboardIndicators:
1858 case Update_SetKeyboardImeStatus:
1868static BOOL update_message_process_update_class(rdpUpdateProxy* proxy, wMessage* msg,
int type)
1877 case Update_BeginPaint:
1878 rc = IFCALLRESULT(TRUE, proxy->BeginPaint, msg->context);
1881 case Update_EndPaint:
1882 rc = IFCALLRESULT(TRUE, proxy->EndPaint, msg->context);
1885 case Update_SetBounds:
1886 rc = IFCALLRESULT(TRUE, proxy->SetBounds, msg->context, (rdpBounds*)msg->wParam);
1889 case Update_Synchronize:
1890 rc = IFCALLRESULT(TRUE, proxy->Synchronize, msg->context);
1893 case Update_DesktopResize:
1894 rc = IFCALLRESULT(TRUE, proxy->DesktopResize, msg->context);
1897 case Update_BitmapUpdate:
1898 rc = IFCALLRESULT(TRUE, proxy->BitmapUpdate, msg->context, (
BITMAP_UPDATE*)msg->wParam);
1901 case Update_Palette:
1902 rc = IFCALLRESULT(TRUE, proxy->Palette, msg->context, (
PALETTE_UPDATE*)msg->wParam);
1905 case Update_PlaySound:
1907 IFCALLRESULT(TRUE, proxy->PlaySound, msg->context, (
PLAY_SOUND_UPDATE*)msg->wParam);
1910 case Update_RefreshRect:
1911 rc = IFCALLRESULT(TRUE, proxy->RefreshRect, msg->context, (BYTE)(
size_t)msg->wParam,
1915 case Update_SuppressOutput:
1916 rc = IFCALLRESULT(TRUE, proxy->SuppressOutput, msg->context, (BYTE)(
size_t)msg->wParam,
1920 case Update_SurfaceCommand:
1921 rc = IFCALLRESULT(TRUE, proxy->SurfaceCommand, msg->context, (
wStream*)msg->wParam);
1924 case Update_SurfaceBits:
1925 rc = IFCALLRESULT(TRUE, proxy->SurfaceBits, msg->context,
1929 case Update_SurfaceFrameMarker:
1930 rc = IFCALLRESULT(TRUE, proxy->SurfaceFrameMarker, msg->context,
1934 case Update_SurfaceFrameAcknowledge:
1935 rc = IFCALLRESULT(TRUE, proxy->SurfaceFrameAcknowledge, msg->context,
1936 (UINT32)(
size_t)msg->wParam);
1939 case Update_SetKeyboardIndicators:
1940 rc = IFCALLRESULT(TRUE, proxy->SetKeyboardIndicators, msg->context,
1941 (UINT16)(
size_t)msg->wParam);
1944 case Update_SetKeyboardImeStatus:
1946 const UINT16 imeId = ((size_t)msg->wParam) >> 16 & 0xFFFF;
1947 const UINT32 imeState = ((size_t)msg->wParam) & 0xFFFF;
1948 const UINT32 imeConvMode = ((size_t)msg->lParam) & 0xFFFFFFFFUL;
1949 rc = IFCALLRESULT(TRUE, proxy->SetKeyboardImeStatus, msg->context, imeId, imeState,
1961static BOOL update_message_free_primary_update_class(wMessage* msg,
int type)
1968 case PrimaryUpdate_DstBlt:
1972 case PrimaryUpdate_PatBlt:
1976 case PrimaryUpdate_ScrBlt:
1980 case PrimaryUpdate_OpaqueRect:
1984 case PrimaryUpdate_DrawNineGrid:
1988 case PrimaryUpdate_MultiDstBlt:
1992 case PrimaryUpdate_MultiPatBlt:
1996 case PrimaryUpdate_MultiScrBlt:
2000 case PrimaryUpdate_MultiOpaqueRect:
2004 case PrimaryUpdate_MultiDrawNineGrid:
2008 case PrimaryUpdate_LineTo:
2012 case PrimaryUpdate_Polyline:
2015 free(wParam->points);
2020 case PrimaryUpdate_MemBlt:
2024 case PrimaryUpdate_Mem3Blt:
2028 case PrimaryUpdate_SaveBitmap:
2032 case PrimaryUpdate_GlyphIndex:
2036 case PrimaryUpdate_FastIndex:
2040 case PrimaryUpdate_FastGlyph:
2043 free(wParam->glyphData.aj);
2048 case PrimaryUpdate_PolygonSC:
2051 free(wParam->points);
2056 case PrimaryUpdate_PolygonCB:
2059 free(wParam->points);
2064 case PrimaryUpdate_EllipseSC:
2068 case PrimaryUpdate_EllipseCB:
2079static BOOL update_message_process_primary_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2087 case PrimaryUpdate_DstBlt:
2088 return IFCALLRESULT(TRUE, proxy->DstBlt, msg->context, (
DSTBLT_ORDER*)msg->wParam);
2090 case PrimaryUpdate_PatBlt:
2091 return IFCALLRESULT(TRUE, proxy->PatBlt, msg->context, (
PATBLT_ORDER*)msg->wParam);
2093 case PrimaryUpdate_ScrBlt:
2094 return IFCALLRESULT(TRUE, proxy->ScrBlt, msg->context, (
SCRBLT_ORDER*)msg->wParam);
2096 case PrimaryUpdate_OpaqueRect:
2097 return IFCALLRESULT(TRUE, proxy->OpaqueRect, msg->context,
2100 case PrimaryUpdate_DrawNineGrid:
2101 return IFCALLRESULT(TRUE, proxy->DrawNineGrid, msg->context,
2104 case PrimaryUpdate_MultiDstBlt:
2105 return IFCALLRESULT(TRUE, proxy->MultiDstBlt, msg->context,
2108 case PrimaryUpdate_MultiPatBlt:
2109 return IFCALLRESULT(TRUE, proxy->MultiPatBlt, msg->context,
2112 case PrimaryUpdate_MultiScrBlt:
2113 return IFCALLRESULT(TRUE, proxy->MultiScrBlt, msg->context,
2116 case PrimaryUpdate_MultiOpaqueRect:
2117 return IFCALLRESULT(TRUE, proxy->MultiOpaqueRect, msg->context,
2120 case PrimaryUpdate_MultiDrawNineGrid:
2121 return IFCALLRESULT(TRUE, proxy->MultiDrawNineGrid, msg->context,
2124 case PrimaryUpdate_LineTo:
2125 return IFCALLRESULT(TRUE, proxy->LineTo, msg->context, (
LINE_TO_ORDER*)msg->wParam);
2127 case PrimaryUpdate_Polyline:
2128 return IFCALLRESULT(TRUE, proxy->Polyline, msg->context, (
POLYLINE_ORDER*)msg->wParam);
2130 case PrimaryUpdate_MemBlt:
2131 return IFCALLRESULT(TRUE, proxy->MemBlt, msg->context, (
MEMBLT_ORDER*)msg->wParam);
2133 case PrimaryUpdate_Mem3Blt:
2134 return IFCALLRESULT(TRUE, proxy->Mem3Blt, msg->context, (
MEM3BLT_ORDER*)msg->wParam);
2136 case PrimaryUpdate_SaveBitmap:
2137 return IFCALLRESULT(TRUE, proxy->SaveBitmap, msg->context,
2140 case PrimaryUpdate_GlyphIndex:
2141 return IFCALLRESULT(TRUE, proxy->GlyphIndex, msg->context,
2144 case PrimaryUpdate_FastIndex:
2145 return IFCALLRESULT(TRUE, proxy->FastIndex, msg->context,
2148 case PrimaryUpdate_FastGlyph:
2149 return IFCALLRESULT(TRUE, proxy->FastGlyph, msg->context,
2152 case PrimaryUpdate_PolygonSC:
2153 return IFCALLRESULT(TRUE, proxy->PolygonSC, msg->context,
2156 case PrimaryUpdate_PolygonCB:
2157 return IFCALLRESULT(TRUE, proxy->PolygonCB, msg->context,
2160 case PrimaryUpdate_EllipseSC:
2161 return IFCALLRESULT(TRUE, proxy->EllipseSC, msg->context,
2164 case PrimaryUpdate_EllipseCB:
2165 return IFCALLRESULT(TRUE, proxy->EllipseCB, msg->context,
2173static BOOL update_message_free_secondary_update_class(wMessage* msg,
int type)
2175 rdpContext* context =
nullptr;
2180 context = msg->context;
2184 case SecondaryUpdate_CacheBitmap:
2187 free_cache_bitmap_order(context, wParam);
2191 case SecondaryUpdate_CacheBitmapV2:
2194 free_cache_bitmap_v2_order(context, wParam);
2198 case SecondaryUpdate_CacheBitmapV3:
2201 free_cache_bitmap_v3_order(context, wParam);
2205 case SecondaryUpdate_CacheColorTable:
2208 free_cache_color_table_order(context, wParam);
2212 case SecondaryUpdate_CacheGlyph:
2215 free_cache_glyph_order(context, wParam);
2219 case SecondaryUpdate_CacheGlyphV2:
2222 free_cache_glyph_v2_order(context, wParam);
2226 case SecondaryUpdate_CacheBrush:
2229 free_cache_brush_order(context, wParam);
2240static BOOL update_message_process_secondary_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2248 case SecondaryUpdate_CacheBitmap:
2249 return IFCALLRESULT(TRUE, proxy->CacheBitmap, msg->context,
2252 case SecondaryUpdate_CacheBitmapV2:
2253 return IFCALLRESULT(TRUE, proxy->CacheBitmapV2, msg->context,
2256 case SecondaryUpdate_CacheBitmapV3:
2257 return IFCALLRESULT(TRUE, proxy->CacheBitmapV3, msg->context,
2260 case SecondaryUpdate_CacheColorTable:
2261 return IFCALLRESULT(TRUE, proxy->CacheColorTable, msg->context,
2264 case SecondaryUpdate_CacheGlyph:
2265 return IFCALLRESULT(TRUE, proxy->CacheGlyph, msg->context,
2268 case SecondaryUpdate_CacheGlyphV2:
2269 return IFCALLRESULT(TRUE, proxy->CacheGlyphV2, msg->context,
2272 case SecondaryUpdate_CacheBrush:
2273 return IFCALLRESULT(TRUE, proxy->CacheBrush, msg->context,
2281static BOOL update_message_free_altsec_update_class(wMessage* msg,
int type)
2288 case AltSecUpdate_CreateOffscreenBitmap:
2291 free(wParam->deleteList.indices);
2296 case AltSecUpdate_SwitchSurface:
2300 case AltSecUpdate_CreateNineGridBitmap:
2304 case AltSecUpdate_FrameMarker:
2308 case AltSecUpdate_StreamBitmapFirst:
2312 case AltSecUpdate_StreamBitmapNext:
2316 case AltSecUpdate_DrawGdiPlusFirst:
2320 case AltSecUpdate_DrawGdiPlusNext:
2324 case AltSecUpdate_DrawGdiPlusEnd:
2328 case AltSecUpdate_DrawGdiPlusCacheFirst:
2332 case AltSecUpdate_DrawGdiPlusCacheNext:
2336 case AltSecUpdate_DrawGdiPlusCacheEnd:
2347static BOOL update_message_process_altsec_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2355 case AltSecUpdate_CreateOffscreenBitmap:
2356 return IFCALLRESULT(TRUE, proxy->CreateOffscreenBitmap, msg->context,
2359 case AltSecUpdate_SwitchSurface:
2360 return IFCALLRESULT(TRUE, proxy->SwitchSurface, msg->context,
2363 case AltSecUpdate_CreateNineGridBitmap:
2364 return IFCALLRESULT(TRUE, proxy->CreateNineGridBitmap, msg->context,
2367 case AltSecUpdate_FrameMarker:
2368 return IFCALLRESULT(TRUE, proxy->FrameMarker, msg->context,
2371 case AltSecUpdate_StreamBitmapFirst:
2372 return IFCALLRESULT(TRUE, proxy->StreamBitmapFirst, msg->context,
2375 case AltSecUpdate_StreamBitmapNext:
2376 return IFCALLRESULT(TRUE, proxy->StreamBitmapNext, msg->context,
2379 case AltSecUpdate_DrawGdiPlusFirst:
2380 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusFirst, msg->context,
2383 case AltSecUpdate_DrawGdiPlusNext:
2384 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusNext, msg->context,
2387 case AltSecUpdate_DrawGdiPlusEnd:
2388 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusEnd, msg->context,
2391 case AltSecUpdate_DrawGdiPlusCacheFirst:
2392 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusCacheFirst, msg->context,
2395 case AltSecUpdate_DrawGdiPlusCacheNext:
2396 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusCacheNext, msg->context,
2399 case AltSecUpdate_DrawGdiPlusCacheEnd:
2400 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusCacheEnd, msg->context,
2408static BOOL update_message_free_window_update_class(wMessage* msg,
int type)
2415 case WindowUpdate_WindowCreate:
2417 window_state_order_free(msg->lParam);
2420 case WindowUpdate_WindowUpdate:
2422 window_state_order_free(msg->lParam);
2425 case WindowUpdate_WindowIcon:
2430 if (windowIcon->iconInfo->cbBitsColor > 0)
2432 free(windowIcon->iconInfo->bitsColor);
2435 if (windowIcon->iconInfo->cbBitsMask > 0)
2437 free(windowIcon->iconInfo->bitsMask);
2440 if (windowIcon->iconInfo->cbColorTable > 0)
2442 free(windowIcon->iconInfo->colorTable);
2446 free(windowIcon->iconInfo);
2451 case WindowUpdate_WindowCachedIcon:
2456 case WindowUpdate_WindowDelete:
2460 case WindowUpdate_NotifyIconCreate:
2462 notify_icon_state_order_free(msg->lParam);
2465 case WindowUpdate_NotifyIconUpdate:
2467 notify_icon_state_order_free(msg->lParam);
2470 case WindowUpdate_NotifyIconDelete:
2474 case WindowUpdate_MonitoredDesktop:
2478 free(lParam->windowIds);
2483 case WindowUpdate_NonMonitoredDesktop:
2494static BOOL update_message_process_window_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2502 case WindowUpdate_WindowCreate:
2503 return IFCALLRESULT(TRUE, proxy->WindowCreate, msg->context,
2506 case WindowUpdate_WindowUpdate:
2507 return IFCALLRESULT(TRUE, proxy->WindowCreate, msg->context,
2510 case WindowUpdate_WindowIcon:
2514 return IFCALLRESULT(TRUE, proxy->WindowIcon, msg->context, orderInfo, windowIcon);
2517 case WindowUpdate_WindowCachedIcon:
2518 return IFCALLRESULT(TRUE, proxy->WindowCachedIcon, msg->context,
2522 case WindowUpdate_WindowDelete:
2523 return IFCALLRESULT(TRUE, proxy->WindowDelete, msg->context,
2526 case WindowUpdate_NotifyIconCreate:
2527 return IFCALLRESULT(TRUE, proxy->NotifyIconCreate, msg->context,
2531 case WindowUpdate_NotifyIconUpdate:
2532 return IFCALLRESULT(TRUE, proxy->NotifyIconUpdate, msg->context,
2536 case WindowUpdate_NotifyIconDelete:
2537 return IFCALLRESULT(TRUE, proxy->NotifyIconDelete, msg->context,
2540 case WindowUpdate_MonitoredDesktop:
2541 return IFCALLRESULT(TRUE, proxy->MonitoredDesktop, msg->context,
2545 case WindowUpdate_NonMonitoredDesktop:
2546 return IFCALLRESULT(TRUE, proxy->NonMonitoredDesktop, msg->context,
2554static BOOL update_message_free_pointer_update_class(wMessage* msg,
int type)
2556 rdpContext* context =
nullptr;
2561 context = msg->context;
2565 case PointerUpdate_PointerPosition:
2568 free_pointer_position_update(context, wParam);
2572 case PointerUpdate_PointerSystem:
2575 free_pointer_system_update(context, wParam);
2579 case PointerUpdate_PointerCached:
2582 free_pointer_cached_update(context, wParam);
2586 case PointerUpdate_PointerColor:
2589 free_pointer_color_update(context, wParam);
2593 case PointerUpdate_PointerNew:
2596 free_pointer_new_update(context, wParam);
2607static BOOL update_message_process_pointer_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2615 case PointerUpdate_PointerPosition:
2616 return IFCALLRESULT(TRUE, proxy->PointerPosition, msg->context,
2619 case PointerUpdate_PointerSystem:
2620 return IFCALLRESULT(TRUE, proxy->PointerSystem, msg->context,
2623 case PointerUpdate_PointerColor:
2624 return IFCALLRESULT(TRUE, proxy->PointerColor, msg->context,
2627 case PointerUpdate_PointerNew:
2628 return IFCALLRESULT(TRUE, proxy->PointerNew, msg->context,
2631 case PointerUpdate_PointerCached:
2632 return IFCALLRESULT(TRUE, proxy->PointerCached, msg->context,
2640static BOOL update_message_free_class(wMessage* msg,
int msgClass,
int msgType)
2642 BOOL status = FALSE;
2647 status = update_message_free_update_class(msg, msgType);
2650 case PrimaryUpdate_Class:
2651 status = update_message_free_primary_update_class(msg, msgType);
2654 case SecondaryUpdate_Class:
2655 status = update_message_free_secondary_update_class(msg, msgType);
2658 case AltSecUpdate_Class:
2659 status = update_message_free_altsec_update_class(msg, msgType);
2662 case WindowUpdate_Class:
2663 status = update_message_free_window_update_class(msg, msgType);
2666 case PointerUpdate_Class:
2667 status = update_message_free_pointer_update_class(msg, msgType);
2675 WLog_ERR(TAG,
"Unknown message: class: %d type: %d", msgClass, msgType);
2680static int update_message_process_class(rdpUpdateProxy* proxy, wMessage* msg,
int msgClass,
2683 BOOL status = FALSE;
2688 status = update_message_process_update_class(proxy, msg, msgType);
2691 case PrimaryUpdate_Class:
2692 status = update_message_process_primary_update_class(proxy, msg, msgType);
2695 case SecondaryUpdate_Class:
2696 status = update_message_process_secondary_update_class(proxy, msg, msgType);
2699 case AltSecUpdate_Class:
2700 status = update_message_process_altsec_update_class(proxy, msg, msgType);
2703 case WindowUpdate_Class:
2704 status = update_message_process_window_update_class(proxy, msg, msgType);
2707 case PointerUpdate_Class:
2708 status = update_message_process_pointer_update_class(proxy, msg, msgType);
2718 WLog_ERR(TAG,
"message: class: %d type: %d failed", msgClass, msgType);
2725int update_message_queue_process_message(rdpUpdate* update, wMessage* message)
2732 if (!update || !message)
2735 if (message->id == WMQ_QUIT)
2738 msgClass = GetMessageClass(message->id);
2739 msgType = GetMessageType(message->id);
2740 status = update_message_process_class(up->proxy, message, msgClass, msgType);
2741 update_message_free_class(message, msgClass, msgType);
2749int update_message_queue_free_message(wMessage* message)
2757 if (message->id == WMQ_QUIT)
2760 msgClass = GetMessageClass(message->id);
2761 msgType = GetMessageType(message->id);
2762 return update_message_free_class(message, msgClass, msgType);
2765int update_message_queue_process_pending_messages(rdpUpdate* update)
2768 wMessage message = WINPR_C_ARRAY_INIT;
2771 wMessageQueue* queue = up->queue;
2773 while (MessageQueue_Peek(queue, &message, TRUE))
2775 status = update_message_queue_process_message(update, &message);
2784static BOOL update_message_register_interface(rdpUpdateProxy* message, rdpUpdate* update)
2786 rdpPrimaryUpdate* primary =
nullptr;
2787 rdpSecondaryUpdate* secondary =
nullptr;
2788 rdpAltSecUpdate* altsec =
nullptr;
2789 rdpWindowUpdate* window =
nullptr;
2790 rdpPointerUpdate* pointer =
nullptr;
2792 if (!message || !update)
2795 primary = update->primary;
2796 secondary = update->secondary;
2797 altsec = update->altsec;
2798 window = update->window;
2799 pointer = update->pointer;
2801 if (!primary || !secondary || !altsec || !window || !pointer)
2805 message->BeginPaint = update->BeginPaint;
2806 message->EndPaint = update->EndPaint;
2807 message->SetBounds = update->SetBounds;
2808 message->Synchronize = update->Synchronize;
2809 message->DesktopResize = update->DesktopResize;
2810 message->BitmapUpdate = update->BitmapUpdate;
2811 message->Palette = update->Palette;
2812 message->PlaySound = update->PlaySound;
2813 message->SetKeyboardIndicators = update->SetKeyboardIndicators;
2814 message->SetKeyboardImeStatus = update->SetKeyboardImeStatus;
2815 message->RefreshRect = update->RefreshRect;
2816 message->SuppressOutput = update->SuppressOutput;
2817 message->SurfaceCommand = update->SurfaceCommand;
2818 message->SurfaceBits = update->SurfaceBits;
2819 message->SurfaceFrameMarker = update->SurfaceFrameMarker;
2820 message->SurfaceFrameAcknowledge = update->SurfaceFrameAcknowledge;
2821 update->BeginPaint = update_message_BeginPaint;
2822 update->EndPaint = update_message_EndPaint;
2823 update->SetBounds = update_message_SetBounds;
2824 update->Synchronize = update_message_Synchronize;
2825 update->DesktopResize = update_message_DesktopResize;
2826 update->BitmapUpdate = update_message_BitmapUpdate;
2827 update->Palette = update_message_Palette;
2828 update->PlaySound = update_message_PlaySound;
2829 update->SetKeyboardIndicators = update_message_SetKeyboardIndicators;
2830 update->SetKeyboardImeStatus = update_message_SetKeyboardImeStatus;
2831 update->RefreshRect = update_message_RefreshRect;
2832 update->SuppressOutput = update_message_SuppressOutput;
2833 update->SurfaceCommand = update_message_SurfaceCommand;
2834 update->SurfaceBits = update_message_SurfaceBits;
2835 update->SurfaceFrameMarker = update_message_SurfaceFrameMarker;
2836 update->SurfaceFrameAcknowledge = update_message_SurfaceFrameAcknowledge;
2838 message->DstBlt = primary->DstBlt;
2839 message->PatBlt = primary->PatBlt;
2840 message->ScrBlt = primary->ScrBlt;
2841 message->OpaqueRect = primary->OpaqueRect;
2842 message->DrawNineGrid = primary->DrawNineGrid;
2843 message->MultiDstBlt = primary->MultiDstBlt;
2844 message->MultiPatBlt = primary->MultiPatBlt;
2845 message->MultiScrBlt = primary->MultiScrBlt;
2846 message->MultiOpaqueRect = primary->MultiOpaqueRect;
2847 message->MultiDrawNineGrid = primary->MultiDrawNineGrid;
2848 message->LineTo = primary->LineTo;
2849 message->Polyline = primary->Polyline;
2850 message->MemBlt = primary->MemBlt;
2851 message->Mem3Blt = primary->Mem3Blt;
2852 message->SaveBitmap = primary->SaveBitmap;
2853 message->GlyphIndex = primary->GlyphIndex;
2854 message->FastIndex = primary->FastIndex;
2855 message->FastGlyph = primary->FastGlyph;
2856 message->PolygonSC = primary->PolygonSC;
2857 message->PolygonCB = primary->PolygonCB;
2858 message->EllipseSC = primary->EllipseSC;
2859 message->EllipseCB = primary->EllipseCB;
2860 primary->DstBlt = update_message_DstBlt;
2861 primary->PatBlt = update_message_PatBlt;
2862 primary->ScrBlt = update_message_ScrBlt;
2863 primary->OpaqueRect = update_message_OpaqueRect;
2864 primary->DrawNineGrid = update_message_DrawNineGrid;
2865 primary->MultiDstBlt = update_message_MultiDstBlt;
2866 primary->MultiPatBlt = update_message_MultiPatBlt;
2867 primary->MultiScrBlt = update_message_MultiScrBlt;
2868 primary->MultiOpaqueRect = update_message_MultiOpaqueRect;
2869 primary->MultiDrawNineGrid = update_message_MultiDrawNineGrid;
2870 primary->LineTo = update_message_LineTo;
2871 primary->Polyline = update_message_Polyline;
2872 primary->MemBlt = update_message_MemBlt;
2873 primary->Mem3Blt = update_message_Mem3Blt;
2874 primary->SaveBitmap = update_message_SaveBitmap;
2875 primary->GlyphIndex = update_message_GlyphIndex;
2876 primary->FastIndex = update_message_FastIndex;
2877 primary->FastGlyph = update_message_FastGlyph;
2878 primary->PolygonSC = update_message_PolygonSC;
2879 primary->PolygonCB = update_message_PolygonCB;
2880 primary->EllipseSC = update_message_EllipseSC;
2881 primary->EllipseCB = update_message_EllipseCB;
2883 message->CacheBitmap = secondary->CacheBitmap;
2884 message->CacheBitmapV2 = secondary->CacheBitmapV2;
2885 message->CacheBitmapV3 = secondary->CacheBitmapV3;
2886 message->CacheColorTable = secondary->CacheColorTable;
2887 message->CacheGlyph = secondary->CacheGlyph;
2888 message->CacheGlyphV2 = secondary->CacheGlyphV2;
2889 message->CacheBrush = secondary->CacheBrush;
2890 secondary->CacheBitmap = update_message_CacheBitmap;
2891 secondary->CacheBitmapV2 = update_message_CacheBitmapV2;
2892 secondary->CacheBitmapV3 = update_message_CacheBitmapV3;
2893 secondary->CacheColorTable = update_message_CacheColorTable;
2894 secondary->CacheGlyph = update_message_CacheGlyph;
2895 secondary->CacheGlyphV2 = update_message_CacheGlyphV2;
2896 secondary->CacheBrush = update_message_CacheBrush;
2898 message->CreateOffscreenBitmap = altsec->CreateOffscreenBitmap;
2899 message->SwitchSurface = altsec->SwitchSurface;
2900 message->CreateNineGridBitmap = altsec->CreateNineGridBitmap;
2901 message->FrameMarker = altsec->FrameMarker;
2902 message->StreamBitmapFirst = altsec->StreamBitmapFirst;
2903 message->StreamBitmapNext = altsec->StreamBitmapNext;
2904 message->DrawGdiPlusFirst = altsec->DrawGdiPlusFirst;
2905 message->DrawGdiPlusNext = altsec->DrawGdiPlusNext;
2906 message->DrawGdiPlusEnd = altsec->DrawGdiPlusEnd;
2907 message->DrawGdiPlusCacheFirst = altsec->DrawGdiPlusCacheFirst;
2908 message->DrawGdiPlusCacheNext = altsec->DrawGdiPlusCacheNext;
2909 message->DrawGdiPlusCacheEnd = altsec->DrawGdiPlusCacheEnd;
2910 altsec->CreateOffscreenBitmap = update_message_CreateOffscreenBitmap;
2911 altsec->SwitchSurface = update_message_SwitchSurface;
2912 altsec->CreateNineGridBitmap = update_message_CreateNineGridBitmap;
2913 altsec->FrameMarker = update_message_FrameMarker;
2914 altsec->StreamBitmapFirst = update_message_StreamBitmapFirst;
2915 altsec->StreamBitmapNext = update_message_StreamBitmapNext;
2916 altsec->DrawGdiPlusFirst = update_message_DrawGdiPlusFirst;
2917 altsec->DrawGdiPlusNext = update_message_DrawGdiPlusNext;
2918 altsec->DrawGdiPlusEnd = update_message_DrawGdiPlusEnd;
2919 altsec->DrawGdiPlusCacheFirst = update_message_DrawGdiPlusCacheFirst;
2920 altsec->DrawGdiPlusCacheNext = update_message_DrawGdiPlusCacheNext;
2921 altsec->DrawGdiPlusCacheEnd = update_message_DrawGdiPlusCacheEnd;
2923 message->WindowCreate = window->WindowCreate;
2924 message->WindowUpdate = window->WindowUpdate;
2925 message->WindowIcon = window->WindowIcon;
2926 message->WindowCachedIcon = window->WindowCachedIcon;
2927 message->WindowDelete = window->WindowDelete;
2928 message->NotifyIconCreate = window->NotifyIconCreate;
2929 message->NotifyIconUpdate = window->NotifyIconUpdate;
2930 message->NotifyIconDelete = window->NotifyIconDelete;
2931 message->MonitoredDesktop = window->MonitoredDesktop;
2932 message->NonMonitoredDesktop = window->NonMonitoredDesktop;
2933 window->WindowCreate = update_message_WindowCreate;
2934 window->WindowUpdate = update_message_WindowUpdate;
2935 window->WindowIcon = update_message_WindowIcon;
2936 window->WindowCachedIcon = update_message_WindowCachedIcon;
2937 window->WindowDelete = update_message_WindowDelete;
2938 window->NotifyIconCreate = update_message_NotifyIconCreate;
2939 window->NotifyIconUpdate = update_message_NotifyIconUpdate;
2940 window->NotifyIconDelete = update_message_NotifyIconDelete;
2941 window->MonitoredDesktop = update_message_MonitoredDesktop;
2942 window->NonMonitoredDesktop = update_message_NonMonitoredDesktop;
2944 message->PointerPosition = pointer->PointerPosition;
2945 message->PointerSystem = pointer->PointerSystem;
2946 message->PointerColor = pointer->PointerColor;
2947 message->PointerLarge = pointer->PointerLarge;
2948 message->PointerNew = pointer->PointerNew;
2949 message->PointerCached = pointer->PointerCached;
2950 pointer->PointerPosition = update_message_PointerPosition;
2951 pointer->PointerSystem = update_message_PointerSystem;
2952 pointer->PointerColor = update_message_PointerColor;
2953 pointer->PointerLarge = update_message_PointerLarge;
2954 pointer->PointerNew = update_message_PointerNew;
2955 pointer->PointerCached = update_message_PointerCached;
2959static DWORD WINAPI update_message_proxy_thread(LPVOID arg)
2961 rdpUpdate* update = (rdpUpdate*)arg;
2962 wMessage message = WINPR_C_ARRAY_INIT;
2965 while (MessageQueue_Wait(up->queue))
2969 if (MessageQueue_Peek(up->queue, &message, TRUE))
2970 status = update_message_queue_process_message(update, &message);
2980rdpUpdateProxy* update_message_proxy_new(rdpUpdate* update)
2982 rdpUpdateProxy* message =
nullptr;
2987 if (!(message = (rdpUpdateProxy*)calloc(1,
sizeof(rdpUpdateProxy))))
2990 message->update = update;
2991 update_message_register_interface(message, update);
2993 if (!(message->thread =
2994 CreateThread(
nullptr, 0, update_message_proxy_thread, update, 0,
nullptr)))
2996 WLog_ERR(TAG,
"Failed to create proxy thread");
3004void update_message_proxy_free(rdpUpdateProxy* message)
3009 if (MessageQueue_PostQuit(up->queue, 0))
3010 (void)WaitForSingleObject(message->thread, INFINITE);
3012 (void)CloseHandle(message->thread);
3018static int input_message_free_input_class(wMessage* msg,
int type)
3026 case Input_SynchronizeEvent:
3029 case Input_KeyboardEvent:
3032 case Input_UnicodeKeyboardEvent:
3035 case Input_MouseEvent:
3038 case Input_ExtendedMouseEvent:
3041 case Input_FocusInEvent:
3044 case Input_KeyboardPauseEvent:
3055static int input_message_process_input_class(rdpInputProxy* proxy, wMessage* msg,
int type)
3064 case Input_SynchronizeEvent:
3065 IFCALL(proxy->SynchronizeEvent, msg->context, (UINT32)(
size_t)msg->wParam);
3068 case Input_KeyboardEvent:
3069 IFCALL(proxy->KeyboardEvent, msg->context, (UINT16)(
size_t)msg->wParam,
3070 (UINT8)(
size_t)msg->lParam);
3073 case Input_UnicodeKeyboardEvent:
3074 IFCALL(proxy->UnicodeKeyboardEvent, msg->context, (UINT16)(
size_t)msg->wParam,
3075 (UINT16)(
size_t)msg->lParam);
3078 case Input_MouseEvent:
3083 pos = (UINT32)(
size_t)msg->lParam;
3084 x = ((pos & 0xFFFF0000) >> 16);
3085 y = (pos & 0x0000FFFF);
3086 IFCALL(proxy->MouseEvent, msg->context, (UINT16)(
size_t)msg->wParam, x, y);
3090 case Input_ExtendedMouseEvent:
3095 pos = (UINT32)(
size_t)msg->lParam;
3096 x = ((pos & 0xFFFF0000) >> 16);
3097 y = (pos & 0x0000FFFF);
3098 IFCALL(proxy->ExtendedMouseEvent, msg->context, (UINT16)(
size_t)msg->wParam, x, y);
3102 case Input_FocusInEvent:
3103 IFCALL(proxy->FocusInEvent, msg->context, (UINT16)(
size_t)msg->wParam);
3106 case Input_KeyboardPauseEvent:
3107 IFCALL(proxy->KeyboardPauseEvent, msg->context);
3118static int input_message_free_class(wMessage* msg,
int msgClass,
int msgType)
3125 status = input_message_free_input_class(msg, msgType);
3134 WLog_ERR(TAG,
"Unknown event: class: %d type: %d", msgClass, msgType);
3139static int input_message_process_class(rdpInputProxy* proxy, wMessage* msg,
int msgClass,
3147 status = input_message_process_input_class(proxy, msg, msgType);
3156 WLog_ERR(TAG,
"Unknown event: class: %d type: %d", msgClass, msgType);
3161int input_message_queue_free_message(wMessage* message)
3170 if (message->id == WMQ_QUIT)
3173 msgClass = GetMessageClass(message->id);
3174 msgType = GetMessageType(message->id);
3175 status = input_message_free_class(message, msgClass, msgType);
3183int input_message_queue_process_message(rdpInput* input, wMessage* message)
3193 if (message->id == WMQ_QUIT)
3196 msgClass = GetMessageClass(message->id);
3197 msgType = GetMessageType(message->id);
3198 status = input_message_process_class(in->proxy, message, msgClass, msgType);
3199 input_message_free_class(message, msgClass, msgType);
3207int input_message_queue_process_pending_messages(rdpInput* input)
3210 wMessage message = WINPR_C_ARRAY_INIT;
3216 wMessageQueue* queue = in->queue;
3218 while (MessageQueue_Peek(queue, &message, TRUE))
3220 status = input_message_queue_process_message(input, &message);