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);
740 wParam->points =
nullptr;
743 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, PolygonSC),
744 (
void*)wParam,
nullptr);
747static BOOL update_message_PolygonCB(rdpContext* context,
POLYGON_CB_ORDER* polygonCB)
749 if (!context || !context->update || !polygonCB)
757 *wParam = *polygonCB;
758 if (polygonCB->numPoints > 0)
768 CopyMemory(wParam->points, polygonCB->points,
sizeof(
DELTA_POINT) * wParam->numPoints);
771 wParam->points =
nullptr;
773 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
776 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, PolygonCB),
777 (
void*)wParam,
nullptr);
780static BOOL update_message_EllipseSC(rdpContext* context,
const ELLIPSE_SC_ORDER* ellipseSC)
782 if (!context || !context->update || !ellipseSC)
793 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, EllipseSC),
794 (
void*)wParam,
nullptr);
797static BOOL update_message_EllipseCB(rdpContext* context,
const ELLIPSE_CB_ORDER* ellipseCB)
802 if (!context || !context->update || !ellipseCB)
811 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
813 up = update_cast(context->update);
814 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, EllipseCB),
815 (
void*)wParam,
nullptr);
820static BOOL update_message_CacheBitmap(rdpContext* context,
826 if (!context || !context->update || !cacheBitmapOrder)
829 wParam = copy_cache_bitmap_order(context, cacheBitmapOrder);
834 up = update_cast(context->update);
835 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(SecondaryUpdate, CacheBitmap),
836 (
void*)wParam,
nullptr);
839static BOOL update_message_CacheBitmapV2(rdpContext* context,
845 if (!context || !context->update || !cacheBitmapV2Order)
848 wParam = copy_cache_bitmap_v2_order(context, cacheBitmapV2Order);
853 up = update_cast(context->update);
854 return MessageQueue_Post(up->queue, (
void*)context,
855 MakeMessageId(SecondaryUpdate, CacheBitmapV2), (
void*)wParam,
nullptr);
858static BOOL update_message_CacheBitmapV3(rdpContext* context,
864 if (!context || !context->update || !cacheBitmapV3Order)
867 wParam = copy_cache_bitmap_v3_order(context, cacheBitmapV3Order);
872 up = update_cast(context->update);
873 return MessageQueue_Post(up->queue, (
void*)context,
874 MakeMessageId(SecondaryUpdate, CacheBitmapV3), (
void*)wParam,
nullptr);
877static BOOL update_message_CacheColorTable(rdpContext* context,
883 if (!context || !context->update || !cacheColorTableOrder)
886 wParam = copy_cache_color_table_order(context, cacheColorTableOrder);
891 up = update_cast(context->update);
892 return MessageQueue_Post(up->queue, (
void*)context,
893 MakeMessageId(SecondaryUpdate, CacheColorTable), (
void*)wParam,
897static BOOL update_message_CacheGlyph(rdpContext* context,
const CACHE_GLYPH_ORDER* cacheGlyphOrder)
902 if (!context || !context->update || !cacheGlyphOrder)
905 wParam = copy_cache_glyph_order(context, cacheGlyphOrder);
910 up = update_cast(context->update);
911 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(SecondaryUpdate, CacheGlyph),
912 (
void*)wParam,
nullptr);
915static BOOL update_message_CacheGlyphV2(rdpContext* context,
921 if (!context || !context->update || !cacheGlyphV2Order)
924 wParam = copy_cache_glyph_v2_order(context, cacheGlyphV2Order);
929 up = update_cast(context->update);
930 return MessageQueue_Post(up->queue, (
void*)context,
931 MakeMessageId(SecondaryUpdate, CacheGlyphV2), (
void*)wParam,
nullptr);
934static BOOL update_message_CacheBrush(rdpContext* context,
const CACHE_BRUSH_ORDER* cacheBrushOrder)
939 if (!context || !context->update || !cacheBrushOrder)
942 wParam = copy_cache_brush_order(context, cacheBrushOrder);
947 up = update_cast(context->update);
948 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(SecondaryUpdate, CacheBrush),
949 (
void*)wParam,
nullptr);
955update_message_CreateOffscreenBitmap(rdpContext* context,
961 if (!context || !context->update || !createOffscreenBitmap)
970 wParam->deleteList.cIndices = createOffscreenBitmap->deleteList.cIndices;
971 wParam->deleteList.sIndices = wParam->deleteList.cIndices;
972 wParam->deleteList.indices = (UINT16*)calloc(wParam->deleteList.cIndices,
sizeof(UINT16));
974 if (!wParam->deleteList.indices)
980 CopyMemory(wParam->deleteList.indices, createOffscreenBitmap->deleteList.indices,
981 wParam->deleteList.cIndices);
983 up = update_cast(context->update);
984 return MessageQueue_Post(up->queue, (
void*)context,
985 MakeMessageId(AltSecUpdate, CreateOffscreenBitmap), (
void*)wParam,
989static BOOL update_message_SwitchSurface(rdpContext* context,
995 if (!context || !context->update || !switchSurface)
1005 up = update_cast(context->update);
1006 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(AltSecUpdate, SwitchSurface),
1007 (
void*)wParam,
nullptr);
1011update_message_CreateNineGridBitmap(rdpContext* context,
1017 if (!context || !context->update || !createNineGridBitmap)
1027 up = update_cast(context->update);
1028 return MessageQueue_Post(up->queue, (
void*)context,
1029 MakeMessageId(AltSecUpdate, CreateNineGridBitmap), (
void*)wParam,
1033static BOOL update_message_FrameMarker(rdpContext* context,
const FRAME_MARKER_ORDER* frameMarker)
1038 if (!context || !context->update || !frameMarker)
1048 up = update_cast(context->update);
1049 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(AltSecUpdate, FrameMarker),
1050 (
void*)wParam,
nullptr);
1053static BOOL update_message_StreamBitmapFirst(rdpContext* context,
1059 if (!context || !context->update || !streamBitmapFirst)
1070 up = update_cast(context->update);
1071 return MessageQueue_Post(up->queue, (
void*)context,
1072 MakeMessageId(AltSecUpdate, StreamBitmapFirst), (
void*)wParam,
1076static BOOL update_message_StreamBitmapNext(rdpContext* context,
1082 if (!context || !context->update || !streamBitmapNext)
1093 up = update_cast(context->update);
1094 return MessageQueue_Post(up->queue, (
void*)context,
1095 MakeMessageId(AltSecUpdate, StreamBitmapNext), (
void*)wParam,
nullptr);
1098static BOOL update_message_DrawGdiPlusFirst(rdpContext* context,
1104 if (!context || !context->update || !drawGdiPlusFirst)
1114 up = update_cast(context->update);
1115 return MessageQueue_Post(up->queue, (
void*)context,
1116 MakeMessageId(AltSecUpdate, DrawGdiPlusFirst), (
void*)wParam,
nullptr);
1119static BOOL update_message_DrawGdiPlusNext(rdpContext* context,
1125 if (!context || !context->update || !drawGdiPlusNext)
1136 up = update_cast(context->update);
1137 return MessageQueue_Post(up->queue, (
void*)context,
1138 MakeMessageId(AltSecUpdate, DrawGdiPlusNext), (
void*)wParam,
nullptr);
1141static BOOL update_message_DrawGdiPlusEnd(rdpContext* context,
1147 if (!context || !context->update || !drawGdiPlusEnd)
1158 up = update_cast(context->update);
1159 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(AltSecUpdate, DrawGdiPlusEnd),
1160 (
void*)wParam,
nullptr);
1164update_message_DrawGdiPlusCacheFirst(rdpContext* context,
1170 if (!context || !context->update || !drawGdiPlusCacheFirst)
1181 up = update_cast(context->update);
1182 return MessageQueue_Post(up->queue, (
void*)context,
1183 MakeMessageId(AltSecUpdate, DrawGdiPlusCacheFirst), (
void*)wParam,
1188update_message_DrawGdiPlusCacheNext(rdpContext* context,
1194 if (!context || !context->update || !drawGdiPlusCacheNext)
1205 up = update_cast(context->update);
1206 return MessageQueue_Post(up->queue, (
void*)context,
1207 MakeMessageId(AltSecUpdate, DrawGdiPlusCacheNext), (
void*)wParam,
1212update_message_DrawGdiPlusCacheEnd(rdpContext* context,
1218 if (!context || !context->update || !drawGdiPlusCacheEnd)
1229 up = update_cast(context->update);
1230 return MessageQueue_Post(up->queue, (
void*)context,
1231 MakeMessageId(AltSecUpdate, DrawGdiPlusCacheEnd), (
void*)wParam,
1239 WINPR_ASSERT(((str->length == 0) && (str->string ==
nullptr)) ||
1240 (str->length == _wcsnlen(str->string, str->length)));
1242 .length = str->length };
1250 free(order->windowRects);
1251 free(order->visibilityRects);
1252 rail_unicode_string_free(&order->titleInfo);
1253 rail_unicode_string_free(&order->OverlayDescription);
1265 clone->titleInfo = rail_unicode_string_clone(&order->titleInfo);
1266 clone->OverlayDescription = rail_unicode_string_clone(&order->OverlayDescription);
1267 clone->windowRects = rectangles_clone(order->windowRects, order->numWindowRects);
1268 clone->visibilityRects = rectangles_clone(order->visibilityRects, order->numVisibilityRects);
1269 if ((!clone->windowRects && (clone->numWindowRects > 0)) ||
1270 (!clone->visibilityRects && (clone->numVisibilityRects > 0)) ||
1271 (!clone->titleInfo.string && (clone->titleInfo.length > 0)) ||
1272 (!clone->OverlayDescription.string && (clone->OverlayDescription.length > 0)))
1274 window_state_order_free(clone);
1280static BOOL update_message_WindowCreate(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1283 if (!context || !context->update || !orderInfo || !windowState)
1291 *wParam = *orderInfo;
1302 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(WindowUpdate, WindowCreate),
1303 (
void*)wParam, (
void*)lParam);
1306static BOOL update_message_WindowUpdate(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1309 if (!context || !context->update || !orderInfo || !windowState)
1317 *wParam = *orderInfo;
1328 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(WindowUpdate, WindowUpdate),
1329 (
void*)wParam, (
void*)lParam);
1332static BOOL update_message_WindowIcon(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1335 if (!context || !context->update || !orderInfo || !windowIcon)
1343 *wParam = *orderInfo;
1350 *lParam = *windowIcon;
1351 lParam->iconInfo = calloc(1,
sizeof(
ICON_INFO));
1353 if (!lParam->iconInfo)
1356 *lParam->iconInfo = *windowIcon->iconInfo;
1358 WLog_VRB(TAG,
"update_message_WindowIcon");
1360 if (windowIcon->iconInfo->cbBitsColor > 0)
1362 lParam->iconInfo->bitsColor = (BYTE*)malloc(windowIcon->iconInfo->cbBitsColor);
1364 if (!lParam->iconInfo->bitsColor)
1367 CopyMemory(lParam->iconInfo->bitsColor, windowIcon->iconInfo->bitsColor,
1368 windowIcon->iconInfo->cbBitsColor);
1371 if (windowIcon->iconInfo->cbBitsMask > 0)
1373 lParam->iconInfo->bitsMask = (BYTE*)malloc(windowIcon->iconInfo->cbBitsMask);
1375 if (!lParam->iconInfo->bitsMask)
1378 CopyMemory(lParam->iconInfo->bitsMask, windowIcon->iconInfo->bitsMask,
1379 windowIcon->iconInfo->cbBitsMask);
1382 if (windowIcon->iconInfo->cbColorTable > 0)
1384 lParam->iconInfo->colorTable = (BYTE*)malloc(windowIcon->iconInfo->cbColorTable);
1386 if (!lParam->iconInfo->colorTable)
1389 CopyMemory(lParam->iconInfo->colorTable, windowIcon->iconInfo->colorTable,
1390 windowIcon->iconInfo->cbColorTable);
1394 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(WindowUpdate, WindowIcon),
1395 (
void*)wParam, (
void*)lParam);
1398 if (lParam && lParam->iconInfo)
1400 free(lParam->iconInfo->bitsColor);
1401 free(lParam->iconInfo->bitsMask);
1402 free(lParam->iconInfo->colorTable);
1403 free(lParam->iconInfo);
1411static BOOL update_message_WindowCachedIcon(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1418 if (!context || !context->update || !orderInfo || !windowCachedIcon)
1437 up = update_cast(context->update);
1438 return MessageQueue_Post(up->queue, (
void*)context,
1439 MakeMessageId(WindowUpdate, WindowCachedIcon), (
void*)wParam,
1443static BOOL update_message_WindowDelete(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo)
1448 if (!context || !context->update || !orderInfo)
1458 up = update_cast(context->update);
1459 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(WindowUpdate, WindowDelete),
1460 (
void*)wParam,
nullptr);
1468 rail_unicode_string_free(¬ify->toolTip);
1469 rail_unicode_string_free(¬ify->infoTip.text);
1470 rail_unicode_string_free(¬ify->infoTip.title);
1471 free(notify->icon.bitsColor);
1472 free(notify->icon.bitsMask);
1473 free(notify->icon.colorTable);
1479 dst->bitsColor =
nullptr;
1480 dst->bitsMask =
nullptr;
1481 dst->colorTable =
nullptr;
1483 if (src->cbBitsColor > 0)
1485 dst->bitsColor = (BYTE*)malloc(src->cbBitsColor);
1486 if (!dst->bitsColor)
1488 CopyMemory(dst->bitsColor, src->bitsColor, src->cbBitsColor);
1491 if (src->cbBitsMask > 0)
1493 dst->bitsMask = (BYTE*)malloc(src->cbBitsMask);
1496 CopyMemory(dst->bitsMask, src->bitsMask, src->cbBitsMask);
1499 if (src->cbColorTable > 0)
1501 dst->colorTable = (BYTE*)malloc(src->cbColorTable);
1502 if (!dst->colorTable)
1504 CopyMemory(dst->colorTable, src->colorTable, src->cbColorTable);
1517 clone->toolTip = rail_unicode_string_clone(&order->toolTip);
1518 clone->infoTip.text = rail_unicode_string_clone(&order->infoTip.text);
1519 clone->infoTip.title = rail_unicode_string_clone(&order->infoTip.title);
1521 if (!icon_info_clone(&clone->icon, &order->icon) ||
1522 (!clone->toolTip.string && (order->toolTip.length > 0)) ||
1523 (!clone->infoTip.text.string && (order->infoTip.text.length > 0)) ||
1524 (!clone->infoTip.title.string && (order->infoTip.title.length > 0)))
1526 notify_icon_state_order_free(clone);
1533static BOOL update_message_NotifyIconCreate(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1540 if (!context || !context->update || !orderInfo || !notifyIconState)
1549 lParam = notify_icon_state_order_clone(notifyIconState);
1557 up = update_cast(context->update);
1558 return MessageQueue_Post(up->queue, (
void*)context,
1559 MakeMessageId(WindowUpdate, NotifyIconCreate), (
void*)wParam,
1563static BOOL update_message_NotifyIconUpdate(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1570 if (!context || !context->update || !orderInfo || !notifyIconState)
1579 lParam = notify_icon_state_order_clone(notifyIconState);
1587 up = update_cast(context->update);
1588 return MessageQueue_Post(up->queue, (
void*)context,
1589 MakeMessageId(WindowUpdate, NotifyIconUpdate), (
void*)wParam,
1593static BOOL update_message_NotifyIconDelete(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo)
1598 if (!context || !context->update || !orderInfo)
1608 up = update_cast(context->update);
1609 return MessageQueue_Post(up->queue, (
void*)context,
1610 MakeMessageId(WindowUpdate, NotifyIconDelete), (
void*)wParam,
nullptr);
1613static BOOL update_message_MonitoredDesktop(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1620 if (!context || !context->update || !orderInfo || !monitoredDesktop)
1638 lParam->windowIds =
nullptr;
1640 if (lParam->numWindowIds)
1642 lParam->windowIds = (UINT32*)calloc(lParam->numWindowIds,
sizeof(UINT32));
1643 CopyMemory(lParam->windowIds, monitoredDesktop->windowIds, lParam->numWindowIds);
1646 up = update_cast(context->update);
1647 return MessageQueue_Post(up->queue, (
void*)context,
1648 MakeMessageId(WindowUpdate, MonitoredDesktop), (
void*)wParam,
1652static BOOL update_message_NonMonitoredDesktop(rdpContext* context,
1658 if (!context || !context->update || !orderInfo)
1668 up = update_cast(context->update);
1669 return MessageQueue_Post(up->queue, (
void*)context,
1670 MakeMessageId(WindowUpdate, NonMonitoredDesktop), (
void*)wParam,
1676static BOOL update_message_PointerPosition(rdpContext* context,
1682 if (!context || !context->update || !pointerPosition)
1685 wParam = copy_pointer_position_update(context, pointerPosition);
1690 up = update_cast(context->update);
1691 return MessageQueue_Post(up->queue, (
void*)context,
1692 MakeMessageId(PointerUpdate, PointerPosition), (
void*)wParam,
nullptr);
1695static BOOL update_message_PointerSystem(rdpContext* context,
1701 if (!context || !context->update || !pointerSystem)
1704 wParam = copy_pointer_system_update(context, pointerSystem);
1709 up = update_cast(context->update);
1710 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerSystem),
1711 (
void*)wParam,
nullptr);
1714static BOOL update_message_PointerColor(rdpContext* context,
1720 if (!context || !context->update || !pointerColor)
1723 wParam = copy_pointer_color_update(context, pointerColor);
1728 up = update_cast(context->update);
1729 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerColor),
1730 (
void*)wParam,
nullptr);
1733static BOOL update_message_PointerLarge(rdpContext* context,
const POINTER_LARGE_UPDATE* pointer)
1738 if (!context || !context->update || !pointer)
1741 wParam = copy_pointer_large_update(context, pointer);
1746 up = update_cast(context->update);
1747 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerLarge),
1748 (
void*)wParam,
nullptr);
1751static BOOL update_message_PointerNew(rdpContext* context,
const POINTER_NEW_UPDATE* pointerNew)
1756 if (!context || !context->update || !pointerNew)
1759 wParam = copy_pointer_new_update(context, pointerNew);
1764 up = update_cast(context->update);
1765 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerNew),
1766 (
void*)wParam,
nullptr);
1769static BOOL update_message_PointerCached(rdpContext* context,
1775 if (!context || !context->update || !pointerCached)
1778 wParam = copy_pointer_cached_update(context, pointerCached);
1783 up = update_cast(context->update);
1784 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerCached),
1785 (
void*)wParam,
nullptr);
1789static BOOL update_message_free_update_class(wMessage* msg,
int type)
1791 rdpContext* context =
nullptr;
1796 context = (rdpContext*)msg->context;
1800 case Update_BeginPaint:
1803 case Update_EndPaint:
1806 case Update_SetBounds:
1810 case Update_Synchronize:
1813 case Update_DesktopResize:
1816 case Update_BitmapUpdate:
1819 free_bitmap_update(context, wParam);
1823 case Update_Palette:
1826 free_palette_update(context, palette);
1830 case Update_PlaySound:
1834 case Update_RefreshRect:
1838 case Update_SuppressOutput:
1842 case Update_SurfaceCommand:
1845 Stream_Free(s, TRUE);
1849 case Update_SurfaceBits:
1852 free_surface_bits_command(context, wParam);
1856 case Update_SurfaceFrameMarker:
1860 case Update_SurfaceFrameAcknowledge:
1861 case Update_SetKeyboardIndicators:
1862 case Update_SetKeyboardImeStatus:
1872static BOOL update_message_process_update_class(rdpUpdateProxy* proxy, wMessage* msg,
int type)
1881 case Update_BeginPaint:
1882 rc = IFCALLRESULT(TRUE, proxy->BeginPaint, msg->context);
1885 case Update_EndPaint:
1886 rc = IFCALLRESULT(TRUE, proxy->EndPaint, msg->context);
1889 case Update_SetBounds:
1890 rc = IFCALLRESULT(TRUE, proxy->SetBounds, msg->context, (rdpBounds*)msg->wParam);
1893 case Update_Synchronize:
1894 rc = IFCALLRESULT(TRUE, proxy->Synchronize, msg->context);
1897 case Update_DesktopResize:
1898 rc = IFCALLRESULT(TRUE, proxy->DesktopResize, msg->context);
1901 case Update_BitmapUpdate:
1902 rc = IFCALLRESULT(TRUE, proxy->BitmapUpdate, msg->context, (
BITMAP_UPDATE*)msg->wParam);
1905 case Update_Palette:
1906 rc = IFCALLRESULT(TRUE, proxy->Palette, msg->context, (
PALETTE_UPDATE*)msg->wParam);
1909 case Update_PlaySound:
1911 IFCALLRESULT(TRUE, proxy->PlaySound, msg->context, (
PLAY_SOUND_UPDATE*)msg->wParam);
1914 case Update_RefreshRect:
1915 rc = IFCALLRESULT(TRUE, proxy->RefreshRect, msg->context, (BYTE)(
size_t)msg->wParam,
1919 case Update_SuppressOutput:
1920 rc = IFCALLRESULT(TRUE, proxy->SuppressOutput, msg->context, (BYTE)(
size_t)msg->wParam,
1924 case Update_SurfaceCommand:
1925 rc = IFCALLRESULT(TRUE, proxy->SurfaceCommand, msg->context, (
wStream*)msg->wParam);
1928 case Update_SurfaceBits:
1929 rc = IFCALLRESULT(TRUE, proxy->SurfaceBits, msg->context,
1933 case Update_SurfaceFrameMarker:
1934 rc = IFCALLRESULT(TRUE, proxy->SurfaceFrameMarker, msg->context,
1938 case Update_SurfaceFrameAcknowledge:
1939 rc = IFCALLRESULT(TRUE, proxy->SurfaceFrameAcknowledge, msg->context,
1940 (UINT32)(
size_t)msg->wParam);
1943 case Update_SetKeyboardIndicators:
1944 rc = IFCALLRESULT(TRUE, proxy->SetKeyboardIndicators, msg->context,
1945 (UINT16)(
size_t)msg->wParam);
1948 case Update_SetKeyboardImeStatus:
1950 const UINT16 imeId = ((size_t)msg->wParam) >> 16 & 0xFFFF;
1951 const UINT32 imeState = ((size_t)msg->wParam) & 0xFFFF;
1952 const UINT32 imeConvMode = ((size_t)msg->lParam) & 0xFFFFFFFFUL;
1953 rc = IFCALLRESULT(TRUE, proxy->SetKeyboardImeStatus, msg->context, imeId, imeState,
1965static BOOL update_message_free_primary_update_class(wMessage* msg,
int type)
1972 case PrimaryUpdate_DstBlt:
1976 case PrimaryUpdate_PatBlt:
1980 case PrimaryUpdate_ScrBlt:
1984 case PrimaryUpdate_OpaqueRect:
1988 case PrimaryUpdate_DrawNineGrid:
1992 case PrimaryUpdate_MultiDstBlt:
1996 case PrimaryUpdate_MultiPatBlt:
2000 case PrimaryUpdate_MultiScrBlt:
2004 case PrimaryUpdate_MultiOpaqueRect:
2008 case PrimaryUpdate_MultiDrawNineGrid:
2012 case PrimaryUpdate_LineTo:
2016 case PrimaryUpdate_Polyline:
2019 free(wParam->points);
2024 case PrimaryUpdate_MemBlt:
2028 case PrimaryUpdate_Mem3Blt:
2032 case PrimaryUpdate_SaveBitmap:
2036 case PrimaryUpdate_GlyphIndex:
2040 case PrimaryUpdate_FastIndex:
2044 case PrimaryUpdate_FastGlyph:
2047 free(wParam->glyphData.aj);
2052 case PrimaryUpdate_PolygonSC:
2055 free(wParam->points);
2060 case PrimaryUpdate_PolygonCB:
2063 free(wParam->points);
2068 case PrimaryUpdate_EllipseSC:
2072 case PrimaryUpdate_EllipseCB:
2083static BOOL update_message_process_primary_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2091 case PrimaryUpdate_DstBlt:
2092 return IFCALLRESULT(TRUE, proxy->DstBlt, msg->context, (
DSTBLT_ORDER*)msg->wParam);
2094 case PrimaryUpdate_PatBlt:
2095 return IFCALLRESULT(TRUE, proxy->PatBlt, msg->context, (
PATBLT_ORDER*)msg->wParam);
2097 case PrimaryUpdate_ScrBlt:
2098 return IFCALLRESULT(TRUE, proxy->ScrBlt, msg->context, (
SCRBLT_ORDER*)msg->wParam);
2100 case PrimaryUpdate_OpaqueRect:
2101 return IFCALLRESULT(TRUE, proxy->OpaqueRect, msg->context,
2104 case PrimaryUpdate_DrawNineGrid:
2105 return IFCALLRESULT(TRUE, proxy->DrawNineGrid, msg->context,
2108 case PrimaryUpdate_MultiDstBlt:
2109 return IFCALLRESULT(TRUE, proxy->MultiDstBlt, msg->context,
2112 case PrimaryUpdate_MultiPatBlt:
2113 return IFCALLRESULT(TRUE, proxy->MultiPatBlt, msg->context,
2116 case PrimaryUpdate_MultiScrBlt:
2117 return IFCALLRESULT(TRUE, proxy->MultiScrBlt, msg->context,
2120 case PrimaryUpdate_MultiOpaqueRect:
2121 return IFCALLRESULT(TRUE, proxy->MultiOpaqueRect, msg->context,
2124 case PrimaryUpdate_MultiDrawNineGrid:
2125 return IFCALLRESULT(TRUE, proxy->MultiDrawNineGrid, msg->context,
2128 case PrimaryUpdate_LineTo:
2129 return IFCALLRESULT(TRUE, proxy->LineTo, msg->context, (
LINE_TO_ORDER*)msg->wParam);
2131 case PrimaryUpdate_Polyline:
2132 return IFCALLRESULT(TRUE, proxy->Polyline, msg->context, (
POLYLINE_ORDER*)msg->wParam);
2134 case PrimaryUpdate_MemBlt:
2135 return IFCALLRESULT(TRUE, proxy->MemBlt, msg->context, (
MEMBLT_ORDER*)msg->wParam);
2137 case PrimaryUpdate_Mem3Blt:
2138 return IFCALLRESULT(TRUE, proxy->Mem3Blt, msg->context, (
MEM3BLT_ORDER*)msg->wParam);
2140 case PrimaryUpdate_SaveBitmap:
2141 return IFCALLRESULT(TRUE, proxy->SaveBitmap, msg->context,
2144 case PrimaryUpdate_GlyphIndex:
2145 return IFCALLRESULT(TRUE, proxy->GlyphIndex, msg->context,
2148 case PrimaryUpdate_FastIndex:
2149 return IFCALLRESULT(TRUE, proxy->FastIndex, msg->context,
2152 case PrimaryUpdate_FastGlyph:
2153 return IFCALLRESULT(TRUE, proxy->FastGlyph, msg->context,
2156 case PrimaryUpdate_PolygonSC:
2157 return IFCALLRESULT(TRUE, proxy->PolygonSC, msg->context,
2160 case PrimaryUpdate_PolygonCB:
2161 return IFCALLRESULT(TRUE, proxy->PolygonCB, msg->context,
2164 case PrimaryUpdate_EllipseSC:
2165 return IFCALLRESULT(TRUE, proxy->EllipseSC, msg->context,
2168 case PrimaryUpdate_EllipseCB:
2169 return IFCALLRESULT(TRUE, proxy->EllipseCB, msg->context,
2177static BOOL update_message_free_secondary_update_class(wMessage* msg,
int type)
2179 rdpContext* context =
nullptr;
2184 context = msg->context;
2188 case SecondaryUpdate_CacheBitmap:
2191 free_cache_bitmap_order(context, wParam);
2195 case SecondaryUpdate_CacheBitmapV2:
2198 free_cache_bitmap_v2_order(context, wParam);
2202 case SecondaryUpdate_CacheBitmapV3:
2205 free_cache_bitmap_v3_order(context, wParam);
2209 case SecondaryUpdate_CacheColorTable:
2212 free_cache_color_table_order(context, wParam);
2216 case SecondaryUpdate_CacheGlyph:
2219 free_cache_glyph_order(context, wParam);
2223 case SecondaryUpdate_CacheGlyphV2:
2226 free_cache_glyph_v2_order(context, wParam);
2230 case SecondaryUpdate_CacheBrush:
2233 free_cache_brush_order(context, wParam);
2244static BOOL update_message_process_secondary_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2252 case SecondaryUpdate_CacheBitmap:
2253 return IFCALLRESULT(TRUE, proxy->CacheBitmap, msg->context,
2256 case SecondaryUpdate_CacheBitmapV2:
2257 return IFCALLRESULT(TRUE, proxy->CacheBitmapV2, msg->context,
2260 case SecondaryUpdate_CacheBitmapV3:
2261 return IFCALLRESULT(TRUE, proxy->CacheBitmapV3, msg->context,
2264 case SecondaryUpdate_CacheColorTable:
2265 return IFCALLRESULT(TRUE, proxy->CacheColorTable, msg->context,
2268 case SecondaryUpdate_CacheGlyph:
2269 return IFCALLRESULT(TRUE, proxy->CacheGlyph, msg->context,
2272 case SecondaryUpdate_CacheGlyphV2:
2273 return IFCALLRESULT(TRUE, proxy->CacheGlyphV2, msg->context,
2276 case SecondaryUpdate_CacheBrush:
2277 return IFCALLRESULT(TRUE, proxy->CacheBrush, msg->context,
2285static BOOL update_message_free_altsec_update_class(wMessage* msg,
int type)
2292 case AltSecUpdate_CreateOffscreenBitmap:
2295 free(wParam->deleteList.indices);
2300 case AltSecUpdate_SwitchSurface:
2304 case AltSecUpdate_CreateNineGridBitmap:
2308 case AltSecUpdate_FrameMarker:
2312 case AltSecUpdate_StreamBitmapFirst:
2316 case AltSecUpdate_StreamBitmapNext:
2320 case AltSecUpdate_DrawGdiPlusFirst:
2324 case AltSecUpdate_DrawGdiPlusNext:
2328 case AltSecUpdate_DrawGdiPlusEnd:
2332 case AltSecUpdate_DrawGdiPlusCacheFirst:
2336 case AltSecUpdate_DrawGdiPlusCacheNext:
2340 case AltSecUpdate_DrawGdiPlusCacheEnd:
2351static BOOL update_message_process_altsec_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2359 case AltSecUpdate_CreateOffscreenBitmap:
2360 return IFCALLRESULT(TRUE, proxy->CreateOffscreenBitmap, msg->context,
2363 case AltSecUpdate_SwitchSurface:
2364 return IFCALLRESULT(TRUE, proxy->SwitchSurface, msg->context,
2367 case AltSecUpdate_CreateNineGridBitmap:
2368 return IFCALLRESULT(TRUE, proxy->CreateNineGridBitmap, msg->context,
2371 case AltSecUpdate_FrameMarker:
2372 return IFCALLRESULT(TRUE, proxy->FrameMarker, msg->context,
2375 case AltSecUpdate_StreamBitmapFirst:
2376 return IFCALLRESULT(TRUE, proxy->StreamBitmapFirst, msg->context,
2379 case AltSecUpdate_StreamBitmapNext:
2380 return IFCALLRESULT(TRUE, proxy->StreamBitmapNext, msg->context,
2383 case AltSecUpdate_DrawGdiPlusFirst:
2384 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusFirst, msg->context,
2387 case AltSecUpdate_DrawGdiPlusNext:
2388 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusNext, msg->context,
2391 case AltSecUpdate_DrawGdiPlusEnd:
2392 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusEnd, msg->context,
2395 case AltSecUpdate_DrawGdiPlusCacheFirst:
2396 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusCacheFirst, msg->context,
2399 case AltSecUpdate_DrawGdiPlusCacheNext:
2400 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusCacheNext, msg->context,
2403 case AltSecUpdate_DrawGdiPlusCacheEnd:
2404 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusCacheEnd, msg->context,
2412static BOOL update_message_free_window_update_class(wMessage* msg,
int type)
2419 case WindowUpdate_WindowCreate:
2421 window_state_order_free(msg->lParam);
2424 case WindowUpdate_WindowUpdate:
2426 window_state_order_free(msg->lParam);
2429 case WindowUpdate_WindowIcon:
2434 if (windowIcon->iconInfo->cbBitsColor > 0)
2436 free(windowIcon->iconInfo->bitsColor);
2439 if (windowIcon->iconInfo->cbBitsMask > 0)
2441 free(windowIcon->iconInfo->bitsMask);
2444 if (windowIcon->iconInfo->cbColorTable > 0)
2446 free(windowIcon->iconInfo->colorTable);
2450 free(windowIcon->iconInfo);
2455 case WindowUpdate_WindowCachedIcon:
2460 case WindowUpdate_WindowDelete:
2464 case WindowUpdate_NotifyIconCreate:
2466 notify_icon_state_order_free(msg->lParam);
2469 case WindowUpdate_NotifyIconUpdate:
2471 notify_icon_state_order_free(msg->lParam);
2474 case WindowUpdate_NotifyIconDelete:
2478 case WindowUpdate_MonitoredDesktop:
2482 free(lParam->windowIds);
2487 case WindowUpdate_NonMonitoredDesktop:
2498static BOOL update_message_process_window_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2506 case WindowUpdate_WindowCreate:
2507 return IFCALLRESULT(TRUE, proxy->WindowCreate, msg->context,
2510 case WindowUpdate_WindowUpdate:
2511 return IFCALLRESULT(TRUE, proxy->WindowCreate, msg->context,
2514 case WindowUpdate_WindowIcon:
2518 return IFCALLRESULT(TRUE, proxy->WindowIcon, msg->context, orderInfo, windowIcon);
2521 case WindowUpdate_WindowCachedIcon:
2522 return IFCALLRESULT(TRUE, proxy->WindowCachedIcon, msg->context,
2526 case WindowUpdate_WindowDelete:
2527 return IFCALLRESULT(TRUE, proxy->WindowDelete, msg->context,
2530 case WindowUpdate_NotifyIconCreate:
2531 return IFCALLRESULT(TRUE, proxy->NotifyIconCreate, msg->context,
2535 case WindowUpdate_NotifyIconUpdate:
2536 return IFCALLRESULT(TRUE, proxy->NotifyIconUpdate, msg->context,
2540 case WindowUpdate_NotifyIconDelete:
2541 return IFCALLRESULT(TRUE, proxy->NotifyIconDelete, msg->context,
2544 case WindowUpdate_MonitoredDesktop:
2545 return IFCALLRESULT(TRUE, proxy->MonitoredDesktop, msg->context,
2549 case WindowUpdate_NonMonitoredDesktop:
2550 return IFCALLRESULT(TRUE, proxy->NonMonitoredDesktop, msg->context,
2558static BOOL update_message_free_pointer_update_class(wMessage* msg,
int type)
2560 rdpContext* context =
nullptr;
2565 context = msg->context;
2569 case PointerUpdate_PointerPosition:
2572 free_pointer_position_update(context, wParam);
2576 case PointerUpdate_PointerSystem:
2579 free_pointer_system_update(context, wParam);
2583 case PointerUpdate_PointerCached:
2586 free_pointer_cached_update(context, wParam);
2590 case PointerUpdate_PointerColor:
2593 free_pointer_color_update(context, wParam);
2597 case PointerUpdate_PointerNew:
2600 free_pointer_new_update(context, wParam);
2611static BOOL update_message_process_pointer_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2619 case PointerUpdate_PointerPosition:
2620 return IFCALLRESULT(TRUE, proxy->PointerPosition, msg->context,
2623 case PointerUpdate_PointerSystem:
2624 return IFCALLRESULT(TRUE, proxy->PointerSystem, msg->context,
2627 case PointerUpdate_PointerColor:
2628 return IFCALLRESULT(TRUE, proxy->PointerColor, msg->context,
2631 case PointerUpdate_PointerNew:
2632 return IFCALLRESULT(TRUE, proxy->PointerNew, msg->context,
2635 case PointerUpdate_PointerCached:
2636 return IFCALLRESULT(TRUE, proxy->PointerCached, msg->context,
2644static BOOL update_message_free_class(wMessage* msg,
int msgClass,
int msgType)
2646 BOOL status = FALSE;
2651 status = update_message_free_update_class(msg, msgType);
2654 case PrimaryUpdate_Class:
2655 status = update_message_free_primary_update_class(msg, msgType);
2658 case SecondaryUpdate_Class:
2659 status = update_message_free_secondary_update_class(msg, msgType);
2662 case AltSecUpdate_Class:
2663 status = update_message_free_altsec_update_class(msg, msgType);
2666 case WindowUpdate_Class:
2667 status = update_message_free_window_update_class(msg, msgType);
2670 case PointerUpdate_Class:
2671 status = update_message_free_pointer_update_class(msg, msgType);
2679 WLog_ERR(TAG,
"Unknown message: class: %d type: %d", msgClass, msgType);
2684static int update_message_process_class(rdpUpdateProxy* proxy, wMessage* msg,
int msgClass,
2687 BOOL status = FALSE;
2692 status = update_message_process_update_class(proxy, msg, msgType);
2695 case PrimaryUpdate_Class:
2696 status = update_message_process_primary_update_class(proxy, msg, msgType);
2699 case SecondaryUpdate_Class:
2700 status = update_message_process_secondary_update_class(proxy, msg, msgType);
2703 case AltSecUpdate_Class:
2704 status = update_message_process_altsec_update_class(proxy, msg, msgType);
2707 case WindowUpdate_Class:
2708 status = update_message_process_window_update_class(proxy, msg, msgType);
2711 case PointerUpdate_Class:
2712 status = update_message_process_pointer_update_class(proxy, msg, msgType);
2722 WLog_ERR(TAG,
"message: class: %d type: %d failed", msgClass, msgType);
2729int update_message_queue_process_message(rdpUpdate* update, wMessage* message)
2736 if (!update || !message)
2739 if (message->id == WMQ_QUIT)
2742 msgClass = GetMessageClass(message->id);
2743 msgType = GetMessageType(message->id);
2744 status = update_message_process_class(up->proxy, message, msgClass, msgType);
2745 update_message_free_class(message, msgClass, msgType);
2753int update_message_queue_free_message(wMessage* message)
2761 if (message->id == WMQ_QUIT)
2764 msgClass = GetMessageClass(message->id);
2765 msgType = GetMessageType(message->id);
2766 return update_message_free_class(message, msgClass, msgType);
2769int update_message_queue_process_pending_messages(rdpUpdate* update)
2772 wMessage message = WINPR_C_ARRAY_INIT;
2775 wMessageQueue* queue = up->queue;
2777 while (MessageQueue_Peek(queue, &message, TRUE))
2779 status = update_message_queue_process_message(update, &message);
2788static BOOL update_message_register_interface(rdpUpdateProxy* message, rdpUpdate* update)
2790 rdpPrimaryUpdate* primary =
nullptr;
2791 rdpSecondaryUpdate* secondary =
nullptr;
2792 rdpAltSecUpdate* altsec =
nullptr;
2793 rdpWindowUpdate* window =
nullptr;
2794 rdpPointerUpdate* pointer =
nullptr;
2796 if (!message || !update)
2799 primary = update->primary;
2800 secondary = update->secondary;
2801 altsec = update->altsec;
2802 window = update->window;
2803 pointer = update->pointer;
2805 if (!primary || !secondary || !altsec || !window || !pointer)
2809 message->BeginPaint = update->BeginPaint;
2810 message->EndPaint = update->EndPaint;
2811 message->SetBounds = update->SetBounds;
2812 message->Synchronize = update->Synchronize;
2813 message->DesktopResize = update->DesktopResize;
2814 message->BitmapUpdate = update->BitmapUpdate;
2815 message->Palette = update->Palette;
2816 message->PlaySound = update->PlaySound;
2817 message->SetKeyboardIndicators = update->SetKeyboardIndicators;
2818 message->SetKeyboardImeStatus = update->SetKeyboardImeStatus;
2819 message->RefreshRect = update->RefreshRect;
2820 message->SuppressOutput = update->SuppressOutput;
2821 message->SurfaceCommand = update->SurfaceCommand;
2822 message->SurfaceBits = update->SurfaceBits;
2823 message->SurfaceFrameMarker = update->SurfaceFrameMarker;
2824 message->SurfaceFrameAcknowledge = update->SurfaceFrameAcknowledge;
2825 update->BeginPaint = update_message_BeginPaint;
2826 update->EndPaint = update_message_EndPaint;
2827 update->SetBounds = update_message_SetBounds;
2828 update->Synchronize = update_message_Synchronize;
2829 update->DesktopResize = update_message_DesktopResize;
2830 update->BitmapUpdate = update_message_BitmapUpdate;
2831 update->Palette = update_message_Palette;
2832 update->PlaySound = update_message_PlaySound;
2833 update->SetKeyboardIndicators = update_message_SetKeyboardIndicators;
2834 update->SetKeyboardImeStatus = update_message_SetKeyboardImeStatus;
2835 update->RefreshRect = update_message_RefreshRect;
2836 update->SuppressOutput = update_message_SuppressOutput;
2837 update->SurfaceCommand = update_message_SurfaceCommand;
2838 update->SurfaceBits = update_message_SurfaceBits;
2839 update->SurfaceFrameMarker = update_message_SurfaceFrameMarker;
2840 update->SurfaceFrameAcknowledge = update_message_SurfaceFrameAcknowledge;
2842 message->DstBlt = primary->DstBlt;
2843 message->PatBlt = primary->PatBlt;
2844 message->ScrBlt = primary->ScrBlt;
2845 message->OpaqueRect = primary->OpaqueRect;
2846 message->DrawNineGrid = primary->DrawNineGrid;
2847 message->MultiDstBlt = primary->MultiDstBlt;
2848 message->MultiPatBlt = primary->MultiPatBlt;
2849 message->MultiScrBlt = primary->MultiScrBlt;
2850 message->MultiOpaqueRect = primary->MultiOpaqueRect;
2851 message->MultiDrawNineGrid = primary->MultiDrawNineGrid;
2852 message->LineTo = primary->LineTo;
2853 message->Polyline = primary->Polyline;
2854 message->MemBlt = primary->MemBlt;
2855 message->Mem3Blt = primary->Mem3Blt;
2856 message->SaveBitmap = primary->SaveBitmap;
2857 message->GlyphIndex = primary->GlyphIndex;
2858 message->FastIndex = primary->FastIndex;
2859 message->FastGlyph = primary->FastGlyph;
2860 message->PolygonSC = primary->PolygonSC;
2861 message->PolygonCB = primary->PolygonCB;
2862 message->EllipseSC = primary->EllipseSC;
2863 message->EllipseCB = primary->EllipseCB;
2864 primary->DstBlt = update_message_DstBlt;
2865 primary->PatBlt = update_message_PatBlt;
2866 primary->ScrBlt = update_message_ScrBlt;
2867 primary->OpaqueRect = update_message_OpaqueRect;
2868 primary->DrawNineGrid = update_message_DrawNineGrid;
2869 primary->MultiDstBlt = update_message_MultiDstBlt;
2870 primary->MultiPatBlt = update_message_MultiPatBlt;
2871 primary->MultiScrBlt = update_message_MultiScrBlt;
2872 primary->MultiOpaqueRect = update_message_MultiOpaqueRect;
2873 primary->MultiDrawNineGrid = update_message_MultiDrawNineGrid;
2874 primary->LineTo = update_message_LineTo;
2875 primary->Polyline = update_message_Polyline;
2876 primary->MemBlt = update_message_MemBlt;
2877 primary->Mem3Blt = update_message_Mem3Blt;
2878 primary->SaveBitmap = update_message_SaveBitmap;
2879 primary->GlyphIndex = update_message_GlyphIndex;
2880 primary->FastIndex = update_message_FastIndex;
2881 primary->FastGlyph = update_message_FastGlyph;
2882 primary->PolygonSC = update_message_PolygonSC;
2883 primary->PolygonCB = update_message_PolygonCB;
2884 primary->EllipseSC = update_message_EllipseSC;
2885 primary->EllipseCB = update_message_EllipseCB;
2887 message->CacheBitmap = secondary->CacheBitmap;
2888 message->CacheBitmapV2 = secondary->CacheBitmapV2;
2889 message->CacheBitmapV3 = secondary->CacheBitmapV3;
2890 message->CacheColorTable = secondary->CacheColorTable;
2891 message->CacheGlyph = secondary->CacheGlyph;
2892 message->CacheGlyphV2 = secondary->CacheGlyphV2;
2893 message->CacheBrush = secondary->CacheBrush;
2894 secondary->CacheBitmap = update_message_CacheBitmap;
2895 secondary->CacheBitmapV2 = update_message_CacheBitmapV2;
2896 secondary->CacheBitmapV3 = update_message_CacheBitmapV3;
2897 secondary->CacheColorTable = update_message_CacheColorTable;
2898 secondary->CacheGlyph = update_message_CacheGlyph;
2899 secondary->CacheGlyphV2 = update_message_CacheGlyphV2;
2900 secondary->CacheBrush = update_message_CacheBrush;
2902 message->CreateOffscreenBitmap = altsec->CreateOffscreenBitmap;
2903 message->SwitchSurface = altsec->SwitchSurface;
2904 message->CreateNineGridBitmap = altsec->CreateNineGridBitmap;
2905 message->FrameMarker = altsec->FrameMarker;
2906 message->StreamBitmapFirst = altsec->StreamBitmapFirst;
2907 message->StreamBitmapNext = altsec->StreamBitmapNext;
2908 message->DrawGdiPlusFirst = altsec->DrawGdiPlusFirst;
2909 message->DrawGdiPlusNext = altsec->DrawGdiPlusNext;
2910 message->DrawGdiPlusEnd = altsec->DrawGdiPlusEnd;
2911 message->DrawGdiPlusCacheFirst = altsec->DrawGdiPlusCacheFirst;
2912 message->DrawGdiPlusCacheNext = altsec->DrawGdiPlusCacheNext;
2913 message->DrawGdiPlusCacheEnd = altsec->DrawGdiPlusCacheEnd;
2914 altsec->CreateOffscreenBitmap = update_message_CreateOffscreenBitmap;
2915 altsec->SwitchSurface = update_message_SwitchSurface;
2916 altsec->CreateNineGridBitmap = update_message_CreateNineGridBitmap;
2917 altsec->FrameMarker = update_message_FrameMarker;
2918 altsec->StreamBitmapFirst = update_message_StreamBitmapFirst;
2919 altsec->StreamBitmapNext = update_message_StreamBitmapNext;
2920 altsec->DrawGdiPlusFirst = update_message_DrawGdiPlusFirst;
2921 altsec->DrawGdiPlusNext = update_message_DrawGdiPlusNext;
2922 altsec->DrawGdiPlusEnd = update_message_DrawGdiPlusEnd;
2923 altsec->DrawGdiPlusCacheFirst = update_message_DrawGdiPlusCacheFirst;
2924 altsec->DrawGdiPlusCacheNext = update_message_DrawGdiPlusCacheNext;
2925 altsec->DrawGdiPlusCacheEnd = update_message_DrawGdiPlusCacheEnd;
2927 message->WindowCreate = window->WindowCreate;
2928 message->WindowUpdate = window->WindowUpdate;
2929 message->WindowIcon = window->WindowIcon;
2930 message->WindowCachedIcon = window->WindowCachedIcon;
2931 message->WindowDelete = window->WindowDelete;
2932 message->NotifyIconCreate = window->NotifyIconCreate;
2933 message->NotifyIconUpdate = window->NotifyIconUpdate;
2934 message->NotifyIconDelete = window->NotifyIconDelete;
2935 message->MonitoredDesktop = window->MonitoredDesktop;
2936 message->NonMonitoredDesktop = window->NonMonitoredDesktop;
2937 window->WindowCreate = update_message_WindowCreate;
2938 window->WindowUpdate = update_message_WindowUpdate;
2939 window->WindowIcon = update_message_WindowIcon;
2940 window->WindowCachedIcon = update_message_WindowCachedIcon;
2941 window->WindowDelete = update_message_WindowDelete;
2942 window->NotifyIconCreate = update_message_NotifyIconCreate;
2943 window->NotifyIconUpdate = update_message_NotifyIconUpdate;
2944 window->NotifyIconDelete = update_message_NotifyIconDelete;
2945 window->MonitoredDesktop = update_message_MonitoredDesktop;
2946 window->NonMonitoredDesktop = update_message_NonMonitoredDesktop;
2948 message->PointerPosition = pointer->PointerPosition;
2949 message->PointerSystem = pointer->PointerSystem;
2950 message->PointerColor = pointer->PointerColor;
2951 message->PointerLarge = pointer->PointerLarge;
2952 message->PointerNew = pointer->PointerNew;
2953 message->PointerCached = pointer->PointerCached;
2954 pointer->PointerPosition = update_message_PointerPosition;
2955 pointer->PointerSystem = update_message_PointerSystem;
2956 pointer->PointerColor = update_message_PointerColor;
2957 pointer->PointerLarge = update_message_PointerLarge;
2958 pointer->PointerNew = update_message_PointerNew;
2959 pointer->PointerCached = update_message_PointerCached;
2963static DWORD WINAPI update_message_proxy_thread(LPVOID arg)
2965 rdpUpdate* update = (rdpUpdate*)arg;
2966 wMessage message = WINPR_C_ARRAY_INIT;
2969 while (MessageQueue_Wait(up->queue))
2973 if (MessageQueue_Peek(up->queue, &message, TRUE))
2974 status = update_message_queue_process_message(update, &message);
2984rdpUpdateProxy* update_message_proxy_new(rdpUpdate* update)
2986 rdpUpdateProxy* message =
nullptr;
2991 if (!(message = (rdpUpdateProxy*)calloc(1,
sizeof(rdpUpdateProxy))))
2994 message->update = update;
2995 update_message_register_interface(message, update);
2997 if (!(message->thread =
2998 CreateThread(
nullptr, 0, update_message_proxy_thread, update, 0,
nullptr)))
3000 WLog_ERR(TAG,
"Failed to create proxy thread");
3008void update_message_proxy_free(rdpUpdateProxy* message)
3013 if (MessageQueue_PostQuit(up->queue, 0))
3014 (void)WaitForSingleObject(message->thread, INFINITE);
3016 (void)CloseHandle(message->thread);
3022static int input_message_free_input_class(wMessage* msg,
int type)
3030 case Input_SynchronizeEvent:
3033 case Input_KeyboardEvent:
3036 case Input_UnicodeKeyboardEvent:
3039 case Input_MouseEvent:
3042 case Input_ExtendedMouseEvent:
3045 case Input_FocusInEvent:
3048 case Input_KeyboardPauseEvent:
3059static int input_message_process_input_class(rdpInputProxy* proxy, wMessage* msg,
int type)
3068 case Input_SynchronizeEvent:
3069 IFCALL(proxy->SynchronizeEvent, msg->context, (UINT32)(
size_t)msg->wParam);
3072 case Input_KeyboardEvent:
3073 IFCALL(proxy->KeyboardEvent, msg->context, (UINT16)(
size_t)msg->wParam,
3074 (UINT8)(
size_t)msg->lParam);
3077 case Input_UnicodeKeyboardEvent:
3078 IFCALL(proxy->UnicodeKeyboardEvent, msg->context, (UINT16)(
size_t)msg->wParam,
3079 (UINT16)(
size_t)msg->lParam);
3082 case Input_MouseEvent:
3087 pos = (UINT32)(
size_t)msg->lParam;
3088 x = ((pos & 0xFFFF0000) >> 16);
3089 y = (pos & 0x0000FFFF);
3090 IFCALL(proxy->MouseEvent, msg->context, (UINT16)(
size_t)msg->wParam, x, y);
3094 case Input_ExtendedMouseEvent:
3099 pos = (UINT32)(
size_t)msg->lParam;
3100 x = ((pos & 0xFFFF0000) >> 16);
3101 y = (pos & 0x0000FFFF);
3102 IFCALL(proxy->ExtendedMouseEvent, msg->context, (UINT16)(
size_t)msg->wParam, x, y);
3106 case Input_FocusInEvent:
3107 IFCALL(proxy->FocusInEvent, msg->context, (UINT16)(
size_t)msg->wParam);
3110 case Input_KeyboardPauseEvent:
3111 IFCALL(proxy->KeyboardPauseEvent, msg->context);
3122static int input_message_free_class(wMessage* msg,
int msgClass,
int msgType)
3129 status = input_message_free_input_class(msg, msgType);
3138 WLog_ERR(TAG,
"Unknown event: class: %d type: %d", msgClass, msgType);
3143static int input_message_process_class(rdpInputProxy* proxy, wMessage* msg,
int msgClass,
3151 status = input_message_process_input_class(proxy, msg, msgType);
3160 WLog_ERR(TAG,
"Unknown event: class: %d type: %d", msgClass, msgType);
3165int input_message_queue_free_message(wMessage* message)
3174 if (message->id == WMQ_QUIT)
3177 msgClass = GetMessageClass(message->id);
3178 msgType = GetMessageType(message->id);
3179 status = input_message_free_class(message, msgClass, msgType);
3187int input_message_queue_process_message(rdpInput* input, wMessage* message)
3197 if (message->id == WMQ_QUIT)
3200 msgClass = GetMessageClass(message->id);
3201 msgType = GetMessageType(message->id);
3202 status = input_message_process_class(in->proxy, message, msgClass, msgType);
3203 input_message_free_class(message, msgClass, msgType);
3211int input_message_queue_process_pending_messages(rdpInput* input)
3214 wMessage message = WINPR_C_ARRAY_INIT;
3220 wMessageQueue* queue = in->queue;
3222 while (MessageQueue_Peek(queue, &message, TRUE))
3224 status = input_message_queue_process_message(input, &message);