22#include <freerdp/config.h>
24#include <winpr/assert.h>
30#include <freerdp/log.h>
31#include <freerdp/freerdp.h>
34#include <winpr/stream.h>
35#include <winpr/collections.h>
37#include "../cache/pointer.h"
38#include "../cache/bitmap.h"
39#include "../cache/palette.h"
40#include "../cache/glyph.h"
41#include "../cache/brush.h"
42#include "../cache/cache.h"
44#define TAG FREERDP_TAG("core.message")
48static BOOL update_message_BeginPaint(rdpContext* context)
52 if (!context || !context->update)
55 up = update_cast(context->update);
56 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, BeginPaint),
nullptr,
60static BOOL update_message_EndPaint(rdpContext* context)
64 if (!context || !context->update)
67 up = update_cast(context->update);
68 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, EndPaint),
nullptr,
72static BOOL update_message_SetBounds(rdpContext* context,
const rdpBounds* bounds)
74 rdpBounds* wParam =
nullptr;
77 if (!context || !context->update)
82 wParam = (rdpBounds*)malloc(
sizeof(rdpBounds));
87 CopyMemory(wParam, bounds,
sizeof(rdpBounds));
90 up = update_cast(context->update);
91 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, SetBounds),
92 (
void*)wParam,
nullptr);
95static BOOL update_message_Synchronize(rdpContext* context)
99 if (!context || !context->update)
102 up = update_cast(context->update);
103 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, Synchronize),
nullptr,
107static BOOL update_message_DesktopResize(rdpContext* context)
111 if (!context || !context->update)
114 up = update_cast(context->update);
115 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, DesktopResize),
119static BOOL update_message_BitmapUpdate(rdpContext* context,
const BITMAP_UPDATE* bitmap)
124 if (!context || !context->update || !bitmap)
127 wParam = copy_bitmap_update(context, bitmap);
132 up = update_cast(context->update);
133 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, BitmapUpdate),
134 (
void*)wParam,
nullptr);
137static BOOL update_message_Palette(rdpContext* context,
const PALETTE_UPDATE* palette)
142 if (!context || !context->update || !palette)
145 wParam = copy_palette_update(context, palette);
150 up = update_cast(context->update);
151 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, Palette),
152 (
void*)wParam,
nullptr);
155static BOOL update_message_PlaySound(rdpContext* context,
const PLAY_SOUND_UPDATE* playSound)
160 if (!context || !context->update || !playSound)
170 up = update_cast(context->update);
171 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, PlaySound),
172 (
void*)wParam,
nullptr);
175static BOOL update_message_SetKeyboardIndicators(rdpContext* context, UINT16 led_flags)
179 if (!context || !context->update)
182 up = update_cast(context->update);
183 return MessageQueue_Post(up->queue, (
void*)context,
184 MakeMessageId(Update, SetKeyboardIndicators), (
void*)(
size_t)led_flags,
188static BOOL update_message_SetKeyboardImeStatus(rdpContext* context, UINT16 imeId, UINT32 imeState,
193 if (!context || !context->update)
196 up = update_cast(context->update);
197 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, SetKeyboardImeStatus),
198 (
void*)(
size_t)((((UINT32)imeId << 16UL) & 0xFFFF0000) | imeState),
199 (
void*)(
size_t)imeConvMode);
202static BOOL update_message_RefreshRect(rdpContext* context, BYTE count,
const RECTANGLE_16* areas)
207 if (!context || !context->update || !areas)
215 CopyMemory(lParam, areas,
sizeof(
RECTANGLE_16) * count);
217 up = update_cast(context->update);
218 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, RefreshRect),
219 (
void*)(
size_t)count, (
void*)lParam);
222static BOOL update_message_SuppressOutput(rdpContext* context, BYTE allow,
const RECTANGLE_16* area)
227 if (!context || !context->update)
240 up = update_cast(context->update);
241 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, SuppressOutput),
242 (
void*)(
size_t)allow, (
void*)lParam);
245static BOOL update_message_SurfaceCommand(rdpContext* context,
wStream* s)
250 if (!context || !context->update || !s)
253 wParam = Stream_New(
nullptr, Stream_GetRemainingLength(s));
258 Stream_Copy(s, wParam, Stream_GetRemainingLength(s));
259 Stream_ResetPosition(wParam);
261 up = update_cast(context->update);
262 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, SurfaceCommand),
263 (
void*)wParam,
nullptr);
266static BOOL update_message_SurfaceBits(rdpContext* context,
272 if (!context || !context->update || !surfaceBitsCommand)
275 wParam = copy_surface_bits_command(context, surfaceBitsCommand);
280 up = update_cast(context->update);
281 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, SurfaceBits),
282 (
void*)wParam,
nullptr);
285static BOOL update_message_SurfaceFrameMarker(rdpContext* context,
291 if (!context || !context->update || !surfaceFrameMarker)
301 up = update_cast(context->update);
302 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(Update, SurfaceFrameMarker),
303 (
void*)wParam,
nullptr);
306static BOOL update_message_SurfaceFrameAcknowledge(rdpContext* context, UINT32 frameId)
310 if (!context || !context->update)
313 up = update_cast(context->update);
314 return MessageQueue_Post(up->queue, (
void*)context,
315 MakeMessageId(Update, SurfaceFrameAcknowledge), (
void*)(
size_t)frameId,
321static BOOL update_message_DstBlt(rdpContext* context,
const DSTBLT_ORDER* dstBlt)
326 if (!context || !context->update || !dstBlt)
336 up = update_cast(context->update);
337 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, DstBlt),
338 (
void*)wParam,
nullptr);
341static BOOL update_message_PatBlt(rdpContext* context,
PATBLT_ORDER* patBlt)
346 if (!context || !context->update || !patBlt)
355 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
357 up = update_cast(context->update);
358 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, PatBlt),
359 (
void*)wParam,
nullptr);
362static BOOL update_message_ScrBlt(rdpContext* context,
const SCRBLT_ORDER* scrBlt)
367 if (!context || !context->update || !scrBlt)
377 up = update_cast(context->update);
378 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, ScrBlt),
379 (
void*)wParam,
nullptr);
382static BOOL update_message_OpaqueRect(rdpContext* context,
const OPAQUE_RECT_ORDER* opaqueRect)
387 if (!context || !context->update || !opaqueRect)
397 up = update_cast(context->update);
398 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, OpaqueRect),
399 (
void*)wParam,
nullptr);
402static BOOL update_message_DrawNineGrid(rdpContext* context,
408 if (!context || !context->update || !drawNineGrid)
418 up = update_cast(context->update);
419 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, DrawNineGrid),
420 (
void*)wParam,
nullptr);
423static BOOL update_message_MultiDstBlt(rdpContext* context,
const MULTI_DSTBLT_ORDER* multiDstBlt)
428 if (!context || !context->update || !multiDstBlt)
438 up = update_cast(context->update);
439 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, MultiDstBlt),
440 (
void*)wParam,
nullptr);
443static BOOL update_message_MultiPatBlt(rdpContext* context,
const MULTI_PATBLT_ORDER* multiPatBlt)
448 if (!context || !context->update || !multiPatBlt)
457 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
459 up = update_cast(context->update);
460 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, MultiPatBlt),
461 (
void*)wParam,
nullptr);
464static BOOL update_message_MultiScrBlt(rdpContext* context,
const MULTI_SCRBLT_ORDER* multiScrBlt)
469 if (!context || !context->update || !multiScrBlt)
479 up = update_cast(context->update);
480 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, MultiScrBlt),
481 (
void*)wParam,
nullptr);
484static BOOL update_message_MultiOpaqueRect(rdpContext* context,
490 if (!context || !context->update || !multiOpaqueRect)
500 up = update_cast(context->update);
501 return MessageQueue_Post(up->queue, (
void*)context,
502 MakeMessageId(PrimaryUpdate, MultiOpaqueRect), (
void*)wParam,
nullptr);
505static BOOL update_message_MultiDrawNineGrid(rdpContext* context,
511 if (!context || !context->update || !multiDrawNineGrid)
522 up = update_cast(context->update);
523 return MessageQueue_Post(up->queue, (
void*)context,
524 MakeMessageId(PrimaryUpdate, MultiDrawNineGrid), (
void*)wParam,
528static BOOL update_message_LineTo(rdpContext* context,
const LINE_TO_ORDER* lineTo)
533 if (!context || !context->update || !lineTo)
543 up = update_cast(context->update);
544 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, LineTo),
545 (
void*)wParam,
nullptr);
548static BOOL update_message_Polyline(rdpContext* context,
const POLYLINE_ORDER* polyline)
553 if (!context || !context->update || !polyline)
570 CopyMemory(wParam->points, polyline->points,
sizeof(
DELTA_POINT) * wParam->numDeltaEntries);
572 up = update_cast(context->update);
573 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, Polyline),
574 (
void*)wParam,
nullptr);
577static BOOL update_message_MemBlt(rdpContext* context,
MEMBLT_ORDER* memBlt)
582 if (!context || !context->update || !memBlt)
592 up = update_cast(context->update);
593 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, MemBlt),
594 (
void*)wParam,
nullptr);
597static BOOL update_message_Mem3Blt(rdpContext* context,
MEM3BLT_ORDER* mem3Blt)
602 if (!context || !context->update || !mem3Blt)
611 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
613 up = update_cast(context->update);
614 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, Mem3Blt),
615 (
void*)wParam,
nullptr);
618static BOOL update_message_SaveBitmap(rdpContext* context,
const SAVE_BITMAP_ORDER* saveBitmap)
623 if (!context || !context->update || !saveBitmap)
633 up = update_cast(context->update);
634 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, SaveBitmap),
635 (
void*)wParam,
nullptr);
638static BOOL update_message_GlyphIndex(rdpContext* context,
GLYPH_INDEX_ORDER* glyphIndex)
643 if (!context || !context->update || !glyphIndex)
652 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
654 up = update_cast(context->update);
655 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, GlyphIndex),
656 (
void*)wParam,
nullptr);
659static BOOL update_message_FastIndex(rdpContext* context,
const FAST_INDEX_ORDER* fastIndex)
664 if (!context || !context->update || !fastIndex)
674 up = update_cast(context->update);
675 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, FastIndex),
676 (
void*)wParam,
nullptr);
679static BOOL update_message_FastGlyph(rdpContext* context,
const FAST_GLYPH_ORDER* fastGlyph)
684 if (!context || !context->update || !fastGlyph)
694 if (wParam->cbData > 1)
696 wParam->glyphData.aj = (BYTE*)malloc(fastGlyph->glyphData.cb);
698 if (!wParam->glyphData.aj)
704 CopyMemory(wParam->glyphData.aj, fastGlyph->glyphData.aj, fastGlyph->glyphData.cb);
708 wParam->glyphData.aj =
nullptr;
711 up = update_cast(context->update);
712 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, FastGlyph),
713 (
void*)wParam,
nullptr);
716static BOOL update_message_PolygonSC(rdpContext* context,
const POLYGON_SC_ORDER* polygonSC)
718 if (!context || !context->update || !polygonSC)
726 *wParam = *polygonSC;
727 if (polygonSC->numPoints > 0)
737 CopyMemory(wParam->points, polygonSC->points,
sizeof(
DELTA_POINT) * wParam->numPoints);
741 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, PolygonSC),
742 (
void*)wParam,
nullptr);
745static BOOL update_message_PolygonCB(rdpContext* context,
POLYGON_CB_ORDER* polygonCB)
747 if (!context || !context->update || !polygonCB)
755 *wParam = *polygonCB;
756 if (polygonCB->numPoints > 0)
766 CopyMemory(wParam->points, polygonCB->points,
sizeof(
DELTA_POINT) * wParam->numPoints);
769 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
772 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, PolygonCB),
773 (
void*)wParam,
nullptr);
776static BOOL update_message_EllipseSC(rdpContext* context,
const ELLIPSE_SC_ORDER* ellipseSC)
778 if (!context || !context->update || !ellipseSC)
789 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, EllipseSC),
790 (
void*)wParam,
nullptr);
793static BOOL update_message_EllipseCB(rdpContext* context,
const ELLIPSE_CB_ORDER* ellipseCB)
798 if (!context || !context->update || !ellipseCB)
807 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
809 up = update_cast(context->update);
810 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, EllipseCB),
811 (
void*)wParam,
nullptr);
816static BOOL update_message_CacheBitmap(rdpContext* context,
822 if (!context || !context->update || !cacheBitmapOrder)
825 wParam = copy_cache_bitmap_order(context, cacheBitmapOrder);
830 up = update_cast(context->update);
831 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(SecondaryUpdate, CacheBitmap),
832 (
void*)wParam,
nullptr);
835static BOOL update_message_CacheBitmapV2(rdpContext* context,
841 if (!context || !context->update || !cacheBitmapV2Order)
844 wParam = copy_cache_bitmap_v2_order(context, cacheBitmapV2Order);
849 up = update_cast(context->update);
850 return MessageQueue_Post(up->queue, (
void*)context,
851 MakeMessageId(SecondaryUpdate, CacheBitmapV2), (
void*)wParam,
nullptr);
854static BOOL update_message_CacheBitmapV3(rdpContext* context,
860 if (!context || !context->update || !cacheBitmapV3Order)
863 wParam = copy_cache_bitmap_v3_order(context, cacheBitmapV3Order);
868 up = update_cast(context->update);
869 return MessageQueue_Post(up->queue, (
void*)context,
870 MakeMessageId(SecondaryUpdate, CacheBitmapV3), (
void*)wParam,
nullptr);
873static BOOL update_message_CacheColorTable(rdpContext* context,
879 if (!context || !context->update || !cacheColorTableOrder)
882 wParam = copy_cache_color_table_order(context, cacheColorTableOrder);
887 up = update_cast(context->update);
888 return MessageQueue_Post(up->queue, (
void*)context,
889 MakeMessageId(SecondaryUpdate, CacheColorTable), (
void*)wParam,
893static BOOL update_message_CacheGlyph(rdpContext* context,
const CACHE_GLYPH_ORDER* cacheGlyphOrder)
898 if (!context || !context->update || !cacheGlyphOrder)
901 wParam = copy_cache_glyph_order(context, cacheGlyphOrder);
906 up = update_cast(context->update);
907 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(SecondaryUpdate, CacheGlyph),
908 (
void*)wParam,
nullptr);
911static BOOL update_message_CacheGlyphV2(rdpContext* context,
917 if (!context || !context->update || !cacheGlyphV2Order)
920 wParam = copy_cache_glyph_v2_order(context, cacheGlyphV2Order);
925 up = update_cast(context->update);
926 return MessageQueue_Post(up->queue, (
void*)context,
927 MakeMessageId(SecondaryUpdate, CacheGlyphV2), (
void*)wParam,
nullptr);
930static BOOL update_message_CacheBrush(rdpContext* context,
const CACHE_BRUSH_ORDER* cacheBrushOrder)
935 if (!context || !context->update || !cacheBrushOrder)
938 wParam = copy_cache_brush_order(context, cacheBrushOrder);
943 up = update_cast(context->update);
944 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(SecondaryUpdate, CacheBrush),
945 (
void*)wParam,
nullptr);
951update_message_CreateOffscreenBitmap(rdpContext* context,
957 if (!context || !context->update || !createOffscreenBitmap)
966 wParam->deleteList.cIndices = createOffscreenBitmap->deleteList.cIndices;
967 wParam->deleteList.sIndices = wParam->deleteList.cIndices;
968 wParam->deleteList.indices = (UINT16*)calloc(wParam->deleteList.cIndices,
sizeof(UINT16));
970 if (!wParam->deleteList.indices)
976 CopyMemory(wParam->deleteList.indices, createOffscreenBitmap->deleteList.indices,
977 wParam->deleteList.cIndices);
979 up = update_cast(context->update);
980 return MessageQueue_Post(up->queue, (
void*)context,
981 MakeMessageId(AltSecUpdate, CreateOffscreenBitmap), (
void*)wParam,
985static BOOL update_message_SwitchSurface(rdpContext* context,
991 if (!context || !context->update || !switchSurface)
1001 up = update_cast(context->update);
1002 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(AltSecUpdate, SwitchSurface),
1003 (
void*)wParam,
nullptr);
1007update_message_CreateNineGridBitmap(rdpContext* context,
1013 if (!context || !context->update || !createNineGridBitmap)
1023 up = update_cast(context->update);
1024 return MessageQueue_Post(up->queue, (
void*)context,
1025 MakeMessageId(AltSecUpdate, CreateNineGridBitmap), (
void*)wParam,
1029static BOOL update_message_FrameMarker(rdpContext* context,
const FRAME_MARKER_ORDER* frameMarker)
1034 if (!context || !context->update || !frameMarker)
1044 up = update_cast(context->update);
1045 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(AltSecUpdate, FrameMarker),
1046 (
void*)wParam,
nullptr);
1049static BOOL update_message_StreamBitmapFirst(rdpContext* context,
1055 if (!context || !context->update || !streamBitmapFirst)
1066 up = update_cast(context->update);
1067 return MessageQueue_Post(up->queue, (
void*)context,
1068 MakeMessageId(AltSecUpdate, StreamBitmapFirst), (
void*)wParam,
1072static BOOL update_message_StreamBitmapNext(rdpContext* context,
1078 if (!context || !context->update || !streamBitmapNext)
1089 up = update_cast(context->update);
1090 return MessageQueue_Post(up->queue, (
void*)context,
1091 MakeMessageId(AltSecUpdate, StreamBitmapNext), (
void*)wParam,
nullptr);
1094static BOOL update_message_DrawGdiPlusFirst(rdpContext* context,
1100 if (!context || !context->update || !drawGdiPlusFirst)
1110 up = update_cast(context->update);
1111 return MessageQueue_Post(up->queue, (
void*)context,
1112 MakeMessageId(AltSecUpdate, DrawGdiPlusFirst), (
void*)wParam,
nullptr);
1115static BOOL update_message_DrawGdiPlusNext(rdpContext* context,
1121 if (!context || !context->update || !drawGdiPlusNext)
1132 up = update_cast(context->update);
1133 return MessageQueue_Post(up->queue, (
void*)context,
1134 MakeMessageId(AltSecUpdate, DrawGdiPlusNext), (
void*)wParam,
nullptr);
1137static BOOL update_message_DrawGdiPlusEnd(rdpContext* context,
1143 if (!context || !context->update || !drawGdiPlusEnd)
1154 up = update_cast(context->update);
1155 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(AltSecUpdate, DrawGdiPlusEnd),
1156 (
void*)wParam,
nullptr);
1160update_message_DrawGdiPlusCacheFirst(rdpContext* context,
1166 if (!context || !context->update || !drawGdiPlusCacheFirst)
1177 up = update_cast(context->update);
1178 return MessageQueue_Post(up->queue, (
void*)context,
1179 MakeMessageId(AltSecUpdate, DrawGdiPlusCacheFirst), (
void*)wParam,
1184update_message_DrawGdiPlusCacheNext(rdpContext* context,
1190 if (!context || !context->update || !drawGdiPlusCacheNext)
1201 up = update_cast(context->update);
1202 return MessageQueue_Post(up->queue, (
void*)context,
1203 MakeMessageId(AltSecUpdate, DrawGdiPlusCacheNext), (
void*)wParam,
1208update_message_DrawGdiPlusCacheEnd(rdpContext* context,
1214 if (!context || !context->update || !drawGdiPlusCacheEnd)
1225 up = update_cast(context->update);
1226 return MessageQueue_Post(up->queue, (
void*)context,
1227 MakeMessageId(AltSecUpdate, DrawGdiPlusCacheEnd), (
void*)wParam,
1235 WINPR_ASSERT(((str->length == 0) && (str->string ==
nullptr)) ||
1236 (str->length == _wcsnlen(str->string, str->length)));
1238 .length = str->length };
1246 free(order->windowRects);
1247 free(order->visibilityRects);
1248 rail_unicode_string_free(&order->titleInfo);
1249 rail_unicode_string_free(&order->OverlayDescription);
1261 clone->titleInfo = rail_unicode_string_clone(&order->titleInfo);
1262 clone->OverlayDescription = rail_unicode_string_clone(&order->OverlayDescription);
1263 clone->windowRects = rectangles_clone(order->windowRects, order->numWindowRects);
1264 clone->visibilityRects = rectangles_clone(order->visibilityRects, order->numVisibilityRects);
1265 if (!clone->windowRects || !clone->visibilityRects ||
1266 (!clone->titleInfo.string && (clone->titleInfo.length > 0)) ||
1267 (!clone->OverlayDescription.string && (clone->OverlayDescription.length > 0)))
1269 window_state_order_free(clone);
1275static BOOL update_message_WindowCreate(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1278 if (!context || !context->update || !orderInfo || !windowState)
1286 *wParam = *orderInfo;
1297 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(WindowUpdate, WindowCreate),
1298 (
void*)wParam, (
void*)lParam);
1301static BOOL update_message_WindowUpdate(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1304 if (!context || !context->update || !orderInfo || !windowState)
1312 *wParam = *orderInfo;
1323 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(WindowUpdate, WindowUpdate),
1324 (
void*)wParam, (
void*)lParam);
1327static BOOL update_message_WindowIcon(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1330 if (!context || !context->update || !orderInfo || !windowIcon)
1338 *wParam = *orderInfo;
1345 *lParam = *windowIcon;
1346 lParam->iconInfo = calloc(1,
sizeof(
ICON_INFO));
1348 if (!lParam->iconInfo)
1351 *lParam->iconInfo = *windowIcon->iconInfo;
1353 WLog_VRB(TAG,
"update_message_WindowIcon");
1355 if (windowIcon->iconInfo->cbBitsColor > 0)
1357 lParam->iconInfo->bitsColor = (BYTE*)malloc(windowIcon->iconInfo->cbBitsColor);
1359 if (!lParam->iconInfo->bitsColor)
1362 CopyMemory(lParam->iconInfo->bitsColor, windowIcon->iconInfo->bitsColor,
1363 windowIcon->iconInfo->cbBitsColor);
1366 if (windowIcon->iconInfo->cbBitsMask > 0)
1368 lParam->iconInfo->bitsMask = (BYTE*)malloc(windowIcon->iconInfo->cbBitsMask);
1370 if (!lParam->iconInfo->bitsMask)
1373 CopyMemory(lParam->iconInfo->bitsMask, windowIcon->iconInfo->bitsMask,
1374 windowIcon->iconInfo->cbBitsMask);
1377 if (windowIcon->iconInfo->cbColorTable > 0)
1379 lParam->iconInfo->colorTable = (BYTE*)malloc(windowIcon->iconInfo->cbColorTable);
1381 if (!lParam->iconInfo->colorTable)
1384 CopyMemory(lParam->iconInfo->colorTable, windowIcon->iconInfo->colorTable,
1385 windowIcon->iconInfo->cbColorTable);
1389 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(WindowUpdate, WindowIcon),
1390 (
void*)wParam, (
void*)lParam);
1393 if (lParam && lParam->iconInfo)
1395 free(lParam->iconInfo->bitsColor);
1396 free(lParam->iconInfo->bitsMask);
1397 free(lParam->iconInfo->colorTable);
1398 free(lParam->iconInfo);
1406static BOOL update_message_WindowCachedIcon(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1413 if (!context || !context->update || !orderInfo || !windowCachedIcon)
1432 up = update_cast(context->update);
1433 return MessageQueue_Post(up->queue, (
void*)context,
1434 MakeMessageId(WindowUpdate, WindowCachedIcon), (
void*)wParam,
1438static BOOL update_message_WindowDelete(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo)
1443 if (!context || !context->update || !orderInfo)
1453 up = update_cast(context->update);
1454 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(WindowUpdate, WindowDelete),
1455 (
void*)wParam,
nullptr);
1458static BOOL update_message_NotifyIconCreate(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1465 if (!context || !context->update || !orderInfo || !notifyIconState)
1484 up = update_cast(context->update);
1485 return MessageQueue_Post(up->queue, (
void*)context,
1486 MakeMessageId(WindowUpdate, NotifyIconCreate), (
void*)wParam,
1490static BOOL update_message_NotifyIconUpdate(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1497 if (!context || !context->update || !orderInfo || !notifyIconState)
1516 up = update_cast(context->update);
1517 return MessageQueue_Post(up->queue, (
void*)context,
1518 MakeMessageId(WindowUpdate, NotifyIconUpdate), (
void*)wParam,
1522static BOOL update_message_NotifyIconDelete(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo)
1527 if (!context || !context->update || !orderInfo)
1537 up = update_cast(context->update);
1538 return MessageQueue_Post(up->queue, (
void*)context,
1539 MakeMessageId(WindowUpdate, NotifyIconDelete), (
void*)wParam,
nullptr);
1542static BOOL update_message_MonitoredDesktop(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1549 if (!context || !context->update || !orderInfo || !monitoredDesktop)
1567 lParam->windowIds =
nullptr;
1569 if (lParam->numWindowIds)
1571 lParam->windowIds = (UINT32*)calloc(lParam->numWindowIds,
sizeof(UINT32));
1572 CopyMemory(lParam->windowIds, monitoredDesktop->windowIds, lParam->numWindowIds);
1575 up = update_cast(context->update);
1576 return MessageQueue_Post(up->queue, (
void*)context,
1577 MakeMessageId(WindowUpdate, MonitoredDesktop), (
void*)wParam,
1581static BOOL update_message_NonMonitoredDesktop(rdpContext* context,
1587 if (!context || !context->update || !orderInfo)
1597 up = update_cast(context->update);
1598 return MessageQueue_Post(up->queue, (
void*)context,
1599 MakeMessageId(WindowUpdate, NonMonitoredDesktop), (
void*)wParam,
1605static BOOL update_message_PointerPosition(rdpContext* context,
1611 if (!context || !context->update || !pointerPosition)
1614 wParam = copy_pointer_position_update(context, pointerPosition);
1619 up = update_cast(context->update);
1620 return MessageQueue_Post(up->queue, (
void*)context,
1621 MakeMessageId(PointerUpdate, PointerPosition), (
void*)wParam,
nullptr);
1624static BOOL update_message_PointerSystem(rdpContext* context,
1630 if (!context || !context->update || !pointerSystem)
1633 wParam = copy_pointer_system_update(context, pointerSystem);
1638 up = update_cast(context->update);
1639 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerSystem),
1640 (
void*)wParam,
nullptr);
1643static BOOL update_message_PointerColor(rdpContext* context,
1649 if (!context || !context->update || !pointerColor)
1652 wParam = copy_pointer_color_update(context, pointerColor);
1657 up = update_cast(context->update);
1658 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerColor),
1659 (
void*)wParam,
nullptr);
1662static BOOL update_message_PointerLarge(rdpContext* context,
const POINTER_LARGE_UPDATE* pointer)
1667 if (!context || !context->update || !pointer)
1670 wParam = copy_pointer_large_update(context, pointer);
1675 up = update_cast(context->update);
1676 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerLarge),
1677 (
void*)wParam,
nullptr);
1680static BOOL update_message_PointerNew(rdpContext* context,
const POINTER_NEW_UPDATE* pointerNew)
1685 if (!context || !context->update || !pointerNew)
1688 wParam = copy_pointer_new_update(context, pointerNew);
1693 up = update_cast(context->update);
1694 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerNew),
1695 (
void*)wParam,
nullptr);
1698static BOOL update_message_PointerCached(rdpContext* context,
1704 if (!context || !context->update || !pointerCached)
1707 wParam = copy_pointer_cached_update(context, pointerCached);
1712 up = update_cast(context->update);
1713 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerCached),
1714 (
void*)wParam,
nullptr);
1718static BOOL update_message_free_update_class(wMessage* msg,
int type)
1720 rdpContext* context =
nullptr;
1725 context = (rdpContext*)msg->context;
1729 case Update_BeginPaint:
1732 case Update_EndPaint:
1735 case Update_SetBounds:
1739 case Update_Synchronize:
1742 case Update_DesktopResize:
1745 case Update_BitmapUpdate:
1748 free_bitmap_update(context, wParam);
1752 case Update_Palette:
1755 free_palette_update(context, palette);
1759 case Update_PlaySound:
1763 case Update_RefreshRect:
1767 case Update_SuppressOutput:
1771 case Update_SurfaceCommand:
1774 Stream_Free(s, TRUE);
1778 case Update_SurfaceBits:
1781 free_surface_bits_command(context, wParam);
1785 case Update_SurfaceFrameMarker:
1789 case Update_SurfaceFrameAcknowledge:
1790 case Update_SetKeyboardIndicators:
1791 case Update_SetKeyboardImeStatus:
1801static BOOL update_message_process_update_class(rdpUpdateProxy* proxy, wMessage* msg,
int type)
1810 case Update_BeginPaint:
1811 rc = IFCALLRESULT(TRUE, proxy->BeginPaint, msg->context);
1814 case Update_EndPaint:
1815 rc = IFCALLRESULT(TRUE, proxy->EndPaint, msg->context);
1818 case Update_SetBounds:
1819 rc = IFCALLRESULT(TRUE, proxy->SetBounds, msg->context, (rdpBounds*)msg->wParam);
1822 case Update_Synchronize:
1823 rc = IFCALLRESULT(TRUE, proxy->Synchronize, msg->context);
1826 case Update_DesktopResize:
1827 rc = IFCALLRESULT(TRUE, proxy->DesktopResize, msg->context);
1830 case Update_BitmapUpdate:
1831 rc = IFCALLRESULT(TRUE, proxy->BitmapUpdate, msg->context, (
BITMAP_UPDATE*)msg->wParam);
1834 case Update_Palette:
1835 rc = IFCALLRESULT(TRUE, proxy->Palette, msg->context, (
PALETTE_UPDATE*)msg->wParam);
1838 case Update_PlaySound:
1840 IFCALLRESULT(TRUE, proxy->PlaySound, msg->context, (
PLAY_SOUND_UPDATE*)msg->wParam);
1843 case Update_RefreshRect:
1844 rc = IFCALLRESULT(TRUE, proxy->RefreshRect, msg->context, (BYTE)(
size_t)msg->wParam,
1848 case Update_SuppressOutput:
1849 rc = IFCALLRESULT(TRUE, proxy->SuppressOutput, msg->context, (BYTE)(
size_t)msg->wParam,
1853 case Update_SurfaceCommand:
1854 rc = IFCALLRESULT(TRUE, proxy->SurfaceCommand, msg->context, (
wStream*)msg->wParam);
1857 case Update_SurfaceBits:
1858 rc = IFCALLRESULT(TRUE, proxy->SurfaceBits, msg->context,
1862 case Update_SurfaceFrameMarker:
1863 rc = IFCALLRESULT(TRUE, proxy->SurfaceFrameMarker, msg->context,
1867 case Update_SurfaceFrameAcknowledge:
1868 rc = IFCALLRESULT(TRUE, proxy->SurfaceFrameAcknowledge, msg->context,
1869 (UINT32)(
size_t)msg->wParam);
1872 case Update_SetKeyboardIndicators:
1873 rc = IFCALLRESULT(TRUE, proxy->SetKeyboardIndicators, msg->context,
1874 (UINT16)(
size_t)msg->wParam);
1877 case Update_SetKeyboardImeStatus:
1879 const UINT16 imeId = ((size_t)msg->wParam) >> 16 & 0xFFFF;
1880 const UINT32 imeState = ((size_t)msg->wParam) & 0xFFFF;
1881 const UINT32 imeConvMode = ((size_t)msg->lParam) & 0xFFFFFFFFUL;
1882 rc = IFCALLRESULT(TRUE, proxy->SetKeyboardImeStatus, msg->context, imeId, imeState,
1894static BOOL update_message_free_primary_update_class(wMessage* msg,
int type)
1901 case PrimaryUpdate_DstBlt:
1905 case PrimaryUpdate_PatBlt:
1909 case PrimaryUpdate_ScrBlt:
1913 case PrimaryUpdate_OpaqueRect:
1917 case PrimaryUpdate_DrawNineGrid:
1921 case PrimaryUpdate_MultiDstBlt:
1925 case PrimaryUpdate_MultiPatBlt:
1929 case PrimaryUpdate_MultiScrBlt:
1933 case PrimaryUpdate_MultiOpaqueRect:
1937 case PrimaryUpdate_MultiDrawNineGrid:
1941 case PrimaryUpdate_LineTo:
1945 case PrimaryUpdate_Polyline:
1948 free(wParam->points);
1953 case PrimaryUpdate_MemBlt:
1957 case PrimaryUpdate_Mem3Blt:
1961 case PrimaryUpdate_SaveBitmap:
1965 case PrimaryUpdate_GlyphIndex:
1969 case PrimaryUpdate_FastIndex:
1973 case PrimaryUpdate_FastGlyph:
1976 free(wParam->glyphData.aj);
1981 case PrimaryUpdate_PolygonSC:
1984 free(wParam->points);
1989 case PrimaryUpdate_PolygonCB:
1992 free(wParam->points);
1997 case PrimaryUpdate_EllipseSC:
2001 case PrimaryUpdate_EllipseCB:
2012static BOOL update_message_process_primary_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2020 case PrimaryUpdate_DstBlt:
2021 return IFCALLRESULT(TRUE, proxy->DstBlt, msg->context, (
DSTBLT_ORDER*)msg->wParam);
2023 case PrimaryUpdate_PatBlt:
2024 return IFCALLRESULT(TRUE, proxy->PatBlt, msg->context, (
PATBLT_ORDER*)msg->wParam);
2026 case PrimaryUpdate_ScrBlt:
2027 return IFCALLRESULT(TRUE, proxy->ScrBlt, msg->context, (
SCRBLT_ORDER*)msg->wParam);
2029 case PrimaryUpdate_OpaqueRect:
2030 return IFCALLRESULT(TRUE, proxy->OpaqueRect, msg->context,
2033 case PrimaryUpdate_DrawNineGrid:
2034 return IFCALLRESULT(TRUE, proxy->DrawNineGrid, msg->context,
2037 case PrimaryUpdate_MultiDstBlt:
2038 return IFCALLRESULT(TRUE, proxy->MultiDstBlt, msg->context,
2041 case PrimaryUpdate_MultiPatBlt:
2042 return IFCALLRESULT(TRUE, proxy->MultiPatBlt, msg->context,
2045 case PrimaryUpdate_MultiScrBlt:
2046 return IFCALLRESULT(TRUE, proxy->MultiScrBlt, msg->context,
2049 case PrimaryUpdate_MultiOpaqueRect:
2050 return IFCALLRESULT(TRUE, proxy->MultiOpaqueRect, msg->context,
2053 case PrimaryUpdate_MultiDrawNineGrid:
2054 return IFCALLRESULT(TRUE, proxy->MultiDrawNineGrid, msg->context,
2057 case PrimaryUpdate_LineTo:
2058 return IFCALLRESULT(TRUE, proxy->LineTo, msg->context, (
LINE_TO_ORDER*)msg->wParam);
2060 case PrimaryUpdate_Polyline:
2061 return IFCALLRESULT(TRUE, proxy->Polyline, msg->context, (
POLYLINE_ORDER*)msg->wParam);
2063 case PrimaryUpdate_MemBlt:
2064 return IFCALLRESULT(TRUE, proxy->MemBlt, msg->context, (
MEMBLT_ORDER*)msg->wParam);
2066 case PrimaryUpdate_Mem3Blt:
2067 return IFCALLRESULT(TRUE, proxy->Mem3Blt, msg->context, (
MEM3BLT_ORDER*)msg->wParam);
2069 case PrimaryUpdate_SaveBitmap:
2070 return IFCALLRESULT(TRUE, proxy->SaveBitmap, msg->context,
2073 case PrimaryUpdate_GlyphIndex:
2074 return IFCALLRESULT(TRUE, proxy->GlyphIndex, msg->context,
2077 case PrimaryUpdate_FastIndex:
2078 return IFCALLRESULT(TRUE, proxy->FastIndex, msg->context,
2081 case PrimaryUpdate_FastGlyph:
2082 return IFCALLRESULT(TRUE, proxy->FastGlyph, msg->context,
2085 case PrimaryUpdate_PolygonSC:
2086 return IFCALLRESULT(TRUE, proxy->PolygonSC, msg->context,
2089 case PrimaryUpdate_PolygonCB:
2090 return IFCALLRESULT(TRUE, proxy->PolygonCB, msg->context,
2093 case PrimaryUpdate_EllipseSC:
2094 return IFCALLRESULT(TRUE, proxy->EllipseSC, msg->context,
2097 case PrimaryUpdate_EllipseCB:
2098 return IFCALLRESULT(TRUE, proxy->EllipseCB, msg->context,
2106static BOOL update_message_free_secondary_update_class(wMessage* msg,
int type)
2108 rdpContext* context =
nullptr;
2113 context = msg->context;
2117 case SecondaryUpdate_CacheBitmap:
2120 free_cache_bitmap_order(context, wParam);
2124 case SecondaryUpdate_CacheBitmapV2:
2127 free_cache_bitmap_v2_order(context, wParam);
2131 case SecondaryUpdate_CacheBitmapV3:
2134 free_cache_bitmap_v3_order(context, wParam);
2138 case SecondaryUpdate_CacheColorTable:
2141 free_cache_color_table_order(context, wParam);
2145 case SecondaryUpdate_CacheGlyph:
2148 free_cache_glyph_order(context, wParam);
2152 case SecondaryUpdate_CacheGlyphV2:
2155 free_cache_glyph_v2_order(context, wParam);
2159 case SecondaryUpdate_CacheBrush:
2162 free_cache_brush_order(context, wParam);
2173static BOOL update_message_process_secondary_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2181 case SecondaryUpdate_CacheBitmap:
2182 return IFCALLRESULT(TRUE, proxy->CacheBitmap, msg->context,
2185 case SecondaryUpdate_CacheBitmapV2:
2186 return IFCALLRESULT(TRUE, proxy->CacheBitmapV2, msg->context,
2189 case SecondaryUpdate_CacheBitmapV3:
2190 return IFCALLRESULT(TRUE, proxy->CacheBitmapV3, msg->context,
2193 case SecondaryUpdate_CacheColorTable:
2194 return IFCALLRESULT(TRUE, proxy->CacheColorTable, msg->context,
2197 case SecondaryUpdate_CacheGlyph:
2198 return IFCALLRESULT(TRUE, proxy->CacheGlyph, msg->context,
2201 case SecondaryUpdate_CacheGlyphV2:
2202 return IFCALLRESULT(TRUE, proxy->CacheGlyphV2, msg->context,
2205 case SecondaryUpdate_CacheBrush:
2206 return IFCALLRESULT(TRUE, proxy->CacheBrush, msg->context,
2214static BOOL update_message_free_altsec_update_class(wMessage* msg,
int type)
2221 case AltSecUpdate_CreateOffscreenBitmap:
2224 free(wParam->deleteList.indices);
2229 case AltSecUpdate_SwitchSurface:
2233 case AltSecUpdate_CreateNineGridBitmap:
2237 case AltSecUpdate_FrameMarker:
2241 case AltSecUpdate_StreamBitmapFirst:
2245 case AltSecUpdate_StreamBitmapNext:
2249 case AltSecUpdate_DrawGdiPlusFirst:
2253 case AltSecUpdate_DrawGdiPlusNext:
2257 case AltSecUpdate_DrawGdiPlusEnd:
2261 case AltSecUpdate_DrawGdiPlusCacheFirst:
2265 case AltSecUpdate_DrawGdiPlusCacheNext:
2269 case AltSecUpdate_DrawGdiPlusCacheEnd:
2280static BOOL update_message_process_altsec_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2288 case AltSecUpdate_CreateOffscreenBitmap:
2289 return IFCALLRESULT(TRUE, proxy->CreateOffscreenBitmap, msg->context,
2292 case AltSecUpdate_SwitchSurface:
2293 return IFCALLRESULT(TRUE, proxy->SwitchSurface, msg->context,
2296 case AltSecUpdate_CreateNineGridBitmap:
2297 return IFCALLRESULT(TRUE, proxy->CreateNineGridBitmap, msg->context,
2300 case AltSecUpdate_FrameMarker:
2301 return IFCALLRESULT(TRUE, proxy->FrameMarker, msg->context,
2304 case AltSecUpdate_StreamBitmapFirst:
2305 return IFCALLRESULT(TRUE, proxy->StreamBitmapFirst, msg->context,
2308 case AltSecUpdate_StreamBitmapNext:
2309 return IFCALLRESULT(TRUE, proxy->StreamBitmapNext, msg->context,
2312 case AltSecUpdate_DrawGdiPlusFirst:
2313 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusFirst, msg->context,
2316 case AltSecUpdate_DrawGdiPlusNext:
2317 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusNext, msg->context,
2320 case AltSecUpdate_DrawGdiPlusEnd:
2321 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusEnd, msg->context,
2324 case AltSecUpdate_DrawGdiPlusCacheFirst:
2325 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusCacheFirst, msg->context,
2328 case AltSecUpdate_DrawGdiPlusCacheNext:
2329 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusCacheNext, msg->context,
2332 case AltSecUpdate_DrawGdiPlusCacheEnd:
2333 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusCacheEnd, msg->context,
2341static BOOL update_message_free_window_update_class(wMessage* msg,
int type)
2348 case WindowUpdate_WindowCreate:
2350 window_state_order_free(msg->lParam);
2353 case WindowUpdate_WindowUpdate:
2355 window_state_order_free(msg->lParam);
2358 case WindowUpdate_WindowIcon:
2363 if (windowIcon->iconInfo->cbBitsColor > 0)
2365 free(windowIcon->iconInfo->bitsColor);
2368 if (windowIcon->iconInfo->cbBitsMask > 0)
2370 free(windowIcon->iconInfo->bitsMask);
2373 if (windowIcon->iconInfo->cbColorTable > 0)
2375 free(windowIcon->iconInfo->colorTable);
2379 free(windowIcon->iconInfo);
2384 case WindowUpdate_WindowCachedIcon:
2389 case WindowUpdate_WindowDelete:
2393 case WindowUpdate_NotifyIconCreate:
2398 case WindowUpdate_NotifyIconUpdate:
2403 case WindowUpdate_NotifyIconDelete:
2407 case WindowUpdate_MonitoredDesktop:
2411 free(lParam->windowIds);
2416 case WindowUpdate_NonMonitoredDesktop:
2427static BOOL update_message_process_window_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2435 case WindowUpdate_WindowCreate:
2436 return IFCALLRESULT(TRUE, proxy->WindowCreate, msg->context,
2439 case WindowUpdate_WindowUpdate:
2440 return IFCALLRESULT(TRUE, proxy->WindowCreate, msg->context,
2443 case WindowUpdate_WindowIcon:
2447 return IFCALLRESULT(TRUE, proxy->WindowIcon, msg->context, orderInfo, windowIcon);
2450 case WindowUpdate_WindowCachedIcon:
2451 return IFCALLRESULT(TRUE, proxy->WindowCachedIcon, msg->context,
2455 case WindowUpdate_WindowDelete:
2456 return IFCALLRESULT(TRUE, proxy->WindowDelete, msg->context,
2459 case WindowUpdate_NotifyIconCreate:
2460 return IFCALLRESULT(TRUE, proxy->NotifyIconCreate, msg->context,
2464 case WindowUpdate_NotifyIconUpdate:
2465 return IFCALLRESULT(TRUE, proxy->NotifyIconUpdate, msg->context,
2469 case WindowUpdate_NotifyIconDelete:
2470 return IFCALLRESULT(TRUE, proxy->NotifyIconDelete, msg->context,
2473 case WindowUpdate_MonitoredDesktop:
2474 return IFCALLRESULT(TRUE, proxy->MonitoredDesktop, msg->context,
2478 case WindowUpdate_NonMonitoredDesktop:
2479 return IFCALLRESULT(TRUE, proxy->NonMonitoredDesktop, msg->context,
2487static BOOL update_message_free_pointer_update_class(wMessage* msg,
int type)
2489 rdpContext* context =
nullptr;
2494 context = msg->context;
2498 case PointerUpdate_PointerPosition:
2501 free_pointer_position_update(context, wParam);
2505 case PointerUpdate_PointerSystem:
2508 free_pointer_system_update(context, wParam);
2512 case PointerUpdate_PointerCached:
2515 free_pointer_cached_update(context, wParam);
2519 case PointerUpdate_PointerColor:
2522 free_pointer_color_update(context, wParam);
2526 case PointerUpdate_PointerNew:
2529 free_pointer_new_update(context, wParam);
2540static BOOL update_message_process_pointer_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2548 case PointerUpdate_PointerPosition:
2549 return IFCALLRESULT(TRUE, proxy->PointerPosition, msg->context,
2552 case PointerUpdate_PointerSystem:
2553 return IFCALLRESULT(TRUE, proxy->PointerSystem, msg->context,
2556 case PointerUpdate_PointerColor:
2557 return IFCALLRESULT(TRUE, proxy->PointerColor, msg->context,
2560 case PointerUpdate_PointerNew:
2561 return IFCALLRESULT(TRUE, proxy->PointerNew, msg->context,
2564 case PointerUpdate_PointerCached:
2565 return IFCALLRESULT(TRUE, proxy->PointerCached, msg->context,
2573static BOOL update_message_free_class(wMessage* msg,
int msgClass,
int msgType)
2575 BOOL status = FALSE;
2580 status = update_message_free_update_class(msg, msgType);
2583 case PrimaryUpdate_Class:
2584 status = update_message_free_primary_update_class(msg, msgType);
2587 case SecondaryUpdate_Class:
2588 status = update_message_free_secondary_update_class(msg, msgType);
2591 case AltSecUpdate_Class:
2592 status = update_message_free_altsec_update_class(msg, msgType);
2595 case WindowUpdate_Class:
2596 status = update_message_free_window_update_class(msg, msgType);
2599 case PointerUpdate_Class:
2600 status = update_message_free_pointer_update_class(msg, msgType);
2608 WLog_ERR(TAG,
"Unknown message: class: %d type: %d", msgClass, msgType);
2613static int update_message_process_class(rdpUpdateProxy* proxy, wMessage* msg,
int msgClass,
2616 BOOL status = FALSE;
2621 status = update_message_process_update_class(proxy, msg, msgType);
2624 case PrimaryUpdate_Class:
2625 status = update_message_process_primary_update_class(proxy, msg, msgType);
2628 case SecondaryUpdate_Class:
2629 status = update_message_process_secondary_update_class(proxy, msg, msgType);
2632 case AltSecUpdate_Class:
2633 status = update_message_process_altsec_update_class(proxy, msg, msgType);
2636 case WindowUpdate_Class:
2637 status = update_message_process_window_update_class(proxy, msg, msgType);
2640 case PointerUpdate_Class:
2641 status = update_message_process_pointer_update_class(proxy, msg, msgType);
2651 WLog_ERR(TAG,
"message: class: %d type: %d failed", msgClass, msgType);
2658int update_message_queue_process_message(rdpUpdate* update, wMessage* message)
2665 if (!update || !message)
2668 if (message->id == WMQ_QUIT)
2671 msgClass = GetMessageClass(message->id);
2672 msgType = GetMessageType(message->id);
2673 status = update_message_process_class(up->proxy, message, msgClass, msgType);
2674 update_message_free_class(message, msgClass, msgType);
2682int update_message_queue_free_message(wMessage* message)
2690 if (message->id == WMQ_QUIT)
2693 msgClass = GetMessageClass(message->id);
2694 msgType = GetMessageType(message->id);
2695 return update_message_free_class(message, msgClass, msgType);
2698int update_message_queue_process_pending_messages(rdpUpdate* update)
2701 wMessage message = WINPR_C_ARRAY_INIT;
2704 wMessageQueue* queue = up->queue;
2706 while (MessageQueue_Peek(queue, &message, TRUE))
2708 status = update_message_queue_process_message(update, &message);
2717static BOOL update_message_register_interface(rdpUpdateProxy* message, rdpUpdate* update)
2719 rdpPrimaryUpdate* primary =
nullptr;
2720 rdpSecondaryUpdate* secondary =
nullptr;
2721 rdpAltSecUpdate* altsec =
nullptr;
2722 rdpWindowUpdate* window =
nullptr;
2723 rdpPointerUpdate* pointer =
nullptr;
2725 if (!message || !update)
2728 primary = update->primary;
2729 secondary = update->secondary;
2730 altsec = update->altsec;
2731 window = update->window;
2732 pointer = update->pointer;
2734 if (!primary || !secondary || !altsec || !window || !pointer)
2738 message->BeginPaint = update->BeginPaint;
2739 message->EndPaint = update->EndPaint;
2740 message->SetBounds = update->SetBounds;
2741 message->Synchronize = update->Synchronize;
2742 message->DesktopResize = update->DesktopResize;
2743 message->BitmapUpdate = update->BitmapUpdate;
2744 message->Palette = update->Palette;
2745 message->PlaySound = update->PlaySound;
2746 message->SetKeyboardIndicators = update->SetKeyboardIndicators;
2747 message->SetKeyboardImeStatus = update->SetKeyboardImeStatus;
2748 message->RefreshRect = update->RefreshRect;
2749 message->SuppressOutput = update->SuppressOutput;
2750 message->SurfaceCommand = update->SurfaceCommand;
2751 message->SurfaceBits = update->SurfaceBits;
2752 message->SurfaceFrameMarker = update->SurfaceFrameMarker;
2753 message->SurfaceFrameAcknowledge = update->SurfaceFrameAcknowledge;
2754 update->BeginPaint = update_message_BeginPaint;
2755 update->EndPaint = update_message_EndPaint;
2756 update->SetBounds = update_message_SetBounds;
2757 update->Synchronize = update_message_Synchronize;
2758 update->DesktopResize = update_message_DesktopResize;
2759 update->BitmapUpdate = update_message_BitmapUpdate;
2760 update->Palette = update_message_Palette;
2761 update->PlaySound = update_message_PlaySound;
2762 update->SetKeyboardIndicators = update_message_SetKeyboardIndicators;
2763 update->SetKeyboardImeStatus = update_message_SetKeyboardImeStatus;
2764 update->RefreshRect = update_message_RefreshRect;
2765 update->SuppressOutput = update_message_SuppressOutput;
2766 update->SurfaceCommand = update_message_SurfaceCommand;
2767 update->SurfaceBits = update_message_SurfaceBits;
2768 update->SurfaceFrameMarker = update_message_SurfaceFrameMarker;
2769 update->SurfaceFrameAcknowledge = update_message_SurfaceFrameAcknowledge;
2771 message->DstBlt = primary->DstBlt;
2772 message->PatBlt = primary->PatBlt;
2773 message->ScrBlt = primary->ScrBlt;
2774 message->OpaqueRect = primary->OpaqueRect;
2775 message->DrawNineGrid = primary->DrawNineGrid;
2776 message->MultiDstBlt = primary->MultiDstBlt;
2777 message->MultiPatBlt = primary->MultiPatBlt;
2778 message->MultiScrBlt = primary->MultiScrBlt;
2779 message->MultiOpaqueRect = primary->MultiOpaqueRect;
2780 message->MultiDrawNineGrid = primary->MultiDrawNineGrid;
2781 message->LineTo = primary->LineTo;
2782 message->Polyline = primary->Polyline;
2783 message->MemBlt = primary->MemBlt;
2784 message->Mem3Blt = primary->Mem3Blt;
2785 message->SaveBitmap = primary->SaveBitmap;
2786 message->GlyphIndex = primary->GlyphIndex;
2787 message->FastIndex = primary->FastIndex;
2788 message->FastGlyph = primary->FastGlyph;
2789 message->PolygonSC = primary->PolygonSC;
2790 message->PolygonCB = primary->PolygonCB;
2791 message->EllipseSC = primary->EllipseSC;
2792 message->EllipseCB = primary->EllipseCB;
2793 primary->DstBlt = update_message_DstBlt;
2794 primary->PatBlt = update_message_PatBlt;
2795 primary->ScrBlt = update_message_ScrBlt;
2796 primary->OpaqueRect = update_message_OpaqueRect;
2797 primary->DrawNineGrid = update_message_DrawNineGrid;
2798 primary->MultiDstBlt = update_message_MultiDstBlt;
2799 primary->MultiPatBlt = update_message_MultiPatBlt;
2800 primary->MultiScrBlt = update_message_MultiScrBlt;
2801 primary->MultiOpaqueRect = update_message_MultiOpaqueRect;
2802 primary->MultiDrawNineGrid = update_message_MultiDrawNineGrid;
2803 primary->LineTo = update_message_LineTo;
2804 primary->Polyline = update_message_Polyline;
2805 primary->MemBlt = update_message_MemBlt;
2806 primary->Mem3Blt = update_message_Mem3Blt;
2807 primary->SaveBitmap = update_message_SaveBitmap;
2808 primary->GlyphIndex = update_message_GlyphIndex;
2809 primary->FastIndex = update_message_FastIndex;
2810 primary->FastGlyph = update_message_FastGlyph;
2811 primary->PolygonSC = update_message_PolygonSC;
2812 primary->PolygonCB = update_message_PolygonCB;
2813 primary->EllipseSC = update_message_EllipseSC;
2814 primary->EllipseCB = update_message_EllipseCB;
2816 message->CacheBitmap = secondary->CacheBitmap;
2817 message->CacheBitmapV2 = secondary->CacheBitmapV2;
2818 message->CacheBitmapV3 = secondary->CacheBitmapV3;
2819 message->CacheColorTable = secondary->CacheColorTable;
2820 message->CacheGlyph = secondary->CacheGlyph;
2821 message->CacheGlyphV2 = secondary->CacheGlyphV2;
2822 message->CacheBrush = secondary->CacheBrush;
2823 secondary->CacheBitmap = update_message_CacheBitmap;
2824 secondary->CacheBitmapV2 = update_message_CacheBitmapV2;
2825 secondary->CacheBitmapV3 = update_message_CacheBitmapV3;
2826 secondary->CacheColorTable = update_message_CacheColorTable;
2827 secondary->CacheGlyph = update_message_CacheGlyph;
2828 secondary->CacheGlyphV2 = update_message_CacheGlyphV2;
2829 secondary->CacheBrush = update_message_CacheBrush;
2831 message->CreateOffscreenBitmap = altsec->CreateOffscreenBitmap;
2832 message->SwitchSurface = altsec->SwitchSurface;
2833 message->CreateNineGridBitmap = altsec->CreateNineGridBitmap;
2834 message->FrameMarker = altsec->FrameMarker;
2835 message->StreamBitmapFirst = altsec->StreamBitmapFirst;
2836 message->StreamBitmapNext = altsec->StreamBitmapNext;
2837 message->DrawGdiPlusFirst = altsec->DrawGdiPlusFirst;
2838 message->DrawGdiPlusNext = altsec->DrawGdiPlusNext;
2839 message->DrawGdiPlusEnd = altsec->DrawGdiPlusEnd;
2840 message->DrawGdiPlusCacheFirst = altsec->DrawGdiPlusCacheFirst;
2841 message->DrawGdiPlusCacheNext = altsec->DrawGdiPlusCacheNext;
2842 message->DrawGdiPlusCacheEnd = altsec->DrawGdiPlusCacheEnd;
2843 altsec->CreateOffscreenBitmap = update_message_CreateOffscreenBitmap;
2844 altsec->SwitchSurface = update_message_SwitchSurface;
2845 altsec->CreateNineGridBitmap = update_message_CreateNineGridBitmap;
2846 altsec->FrameMarker = update_message_FrameMarker;
2847 altsec->StreamBitmapFirst = update_message_StreamBitmapFirst;
2848 altsec->StreamBitmapNext = update_message_StreamBitmapNext;
2849 altsec->DrawGdiPlusFirst = update_message_DrawGdiPlusFirst;
2850 altsec->DrawGdiPlusNext = update_message_DrawGdiPlusNext;
2851 altsec->DrawGdiPlusEnd = update_message_DrawGdiPlusEnd;
2852 altsec->DrawGdiPlusCacheFirst = update_message_DrawGdiPlusCacheFirst;
2853 altsec->DrawGdiPlusCacheNext = update_message_DrawGdiPlusCacheNext;
2854 altsec->DrawGdiPlusCacheEnd = update_message_DrawGdiPlusCacheEnd;
2856 message->WindowCreate = window->WindowCreate;
2857 message->WindowUpdate = window->WindowUpdate;
2858 message->WindowIcon = window->WindowIcon;
2859 message->WindowCachedIcon = window->WindowCachedIcon;
2860 message->WindowDelete = window->WindowDelete;
2861 message->NotifyIconCreate = window->NotifyIconCreate;
2862 message->NotifyIconUpdate = window->NotifyIconUpdate;
2863 message->NotifyIconDelete = window->NotifyIconDelete;
2864 message->MonitoredDesktop = window->MonitoredDesktop;
2865 message->NonMonitoredDesktop = window->NonMonitoredDesktop;
2866 window->WindowCreate = update_message_WindowCreate;
2867 window->WindowUpdate = update_message_WindowUpdate;
2868 window->WindowIcon = update_message_WindowIcon;
2869 window->WindowCachedIcon = update_message_WindowCachedIcon;
2870 window->WindowDelete = update_message_WindowDelete;
2871 window->NotifyIconCreate = update_message_NotifyIconCreate;
2872 window->NotifyIconUpdate = update_message_NotifyIconUpdate;
2873 window->NotifyIconDelete = update_message_NotifyIconDelete;
2874 window->MonitoredDesktop = update_message_MonitoredDesktop;
2875 window->NonMonitoredDesktop = update_message_NonMonitoredDesktop;
2877 message->PointerPosition = pointer->PointerPosition;
2878 message->PointerSystem = pointer->PointerSystem;
2879 message->PointerColor = pointer->PointerColor;
2880 message->PointerLarge = pointer->PointerLarge;
2881 message->PointerNew = pointer->PointerNew;
2882 message->PointerCached = pointer->PointerCached;
2883 pointer->PointerPosition = update_message_PointerPosition;
2884 pointer->PointerSystem = update_message_PointerSystem;
2885 pointer->PointerColor = update_message_PointerColor;
2886 pointer->PointerLarge = update_message_PointerLarge;
2887 pointer->PointerNew = update_message_PointerNew;
2888 pointer->PointerCached = update_message_PointerCached;
2892static DWORD WINAPI update_message_proxy_thread(LPVOID arg)
2894 rdpUpdate* update = (rdpUpdate*)arg;
2895 wMessage message = WINPR_C_ARRAY_INIT;
2898 while (MessageQueue_Wait(up->queue))
2902 if (MessageQueue_Peek(up->queue, &message, TRUE))
2903 status = update_message_queue_process_message(update, &message);
2913rdpUpdateProxy* update_message_proxy_new(rdpUpdate* update)
2915 rdpUpdateProxy* message =
nullptr;
2920 if (!(message = (rdpUpdateProxy*)calloc(1,
sizeof(rdpUpdateProxy))))
2923 message->update = update;
2924 update_message_register_interface(message, update);
2926 if (!(message->thread =
2927 CreateThread(
nullptr, 0, update_message_proxy_thread, update, 0,
nullptr)))
2929 WLog_ERR(TAG,
"Failed to create proxy thread");
2937void update_message_proxy_free(rdpUpdateProxy* message)
2942 if (MessageQueue_PostQuit(up->queue, 0))
2943 (void)WaitForSingleObject(message->thread, INFINITE);
2945 (void)CloseHandle(message->thread);
2951static int input_message_free_input_class(wMessage* msg,
int type)
2959 case Input_SynchronizeEvent:
2962 case Input_KeyboardEvent:
2965 case Input_UnicodeKeyboardEvent:
2968 case Input_MouseEvent:
2971 case Input_ExtendedMouseEvent:
2974 case Input_FocusInEvent:
2977 case Input_KeyboardPauseEvent:
2988static int input_message_process_input_class(rdpInputProxy* proxy, wMessage* msg,
int type)
2997 case Input_SynchronizeEvent:
2998 IFCALL(proxy->SynchronizeEvent, msg->context, (UINT32)(
size_t)msg->wParam);
3001 case Input_KeyboardEvent:
3002 IFCALL(proxy->KeyboardEvent, msg->context, (UINT16)(
size_t)msg->wParam,
3003 (UINT8)(
size_t)msg->lParam);
3006 case Input_UnicodeKeyboardEvent:
3007 IFCALL(proxy->UnicodeKeyboardEvent, msg->context, (UINT16)(
size_t)msg->wParam,
3008 (UINT16)(
size_t)msg->lParam);
3011 case Input_MouseEvent:
3016 pos = (UINT32)(
size_t)msg->lParam;
3017 x = ((pos & 0xFFFF0000) >> 16);
3018 y = (pos & 0x0000FFFF);
3019 IFCALL(proxy->MouseEvent, msg->context, (UINT16)(
size_t)msg->wParam, x, y);
3023 case Input_ExtendedMouseEvent:
3028 pos = (UINT32)(
size_t)msg->lParam;
3029 x = ((pos & 0xFFFF0000) >> 16);
3030 y = (pos & 0x0000FFFF);
3031 IFCALL(proxy->ExtendedMouseEvent, msg->context, (UINT16)(
size_t)msg->wParam, x, y);
3035 case Input_FocusInEvent:
3036 IFCALL(proxy->FocusInEvent, msg->context, (UINT16)(
size_t)msg->wParam);
3039 case Input_KeyboardPauseEvent:
3040 IFCALL(proxy->KeyboardPauseEvent, msg->context);
3051static int input_message_free_class(wMessage* msg,
int msgClass,
int msgType)
3058 status = input_message_free_input_class(msg, msgType);
3067 WLog_ERR(TAG,
"Unknown event: class: %d type: %d", msgClass, msgType);
3072static int input_message_process_class(rdpInputProxy* proxy, wMessage* msg,
int msgClass,
3080 status = input_message_process_input_class(proxy, msg, msgType);
3089 WLog_ERR(TAG,
"Unknown event: class: %d type: %d", msgClass, msgType);
3094int input_message_queue_free_message(wMessage* message)
3103 if (message->id == WMQ_QUIT)
3106 msgClass = GetMessageClass(message->id);
3107 msgType = GetMessageType(message->id);
3108 status = input_message_free_class(message, msgClass, msgType);
3116int input_message_queue_process_message(rdpInput* input, wMessage* message)
3126 if (message->id == WMQ_QUIT)
3129 msgClass = GetMessageClass(message->id);
3130 msgType = GetMessageType(message->id);
3131 status = input_message_process_class(in->proxy, message, msgClass, msgType);
3132 input_message_free_class(message, msgClass, msgType);
3140int input_message_queue_process_pending_messages(rdpInput* input)
3143 wMessage message = WINPR_C_ARRAY_INIT;
3149 wMessageQueue* queue = in->queue;
3151 while (MessageQueue_Peek(queue, &message, TRUE))
3153 status = input_message_queue_process_message(input, &message);