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_SetPosition(wParam, 0);
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)
721 if (!context || !context->update || !polygonSC)
738 CopyMemory(wParam->points, polygonSC,
sizeof(
DELTA_POINT) * wParam->numPoints);
740 up = update_cast(context->update);
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)
750 if (!context || !context->update || !polygonCB)
767 CopyMemory(wParam->points, polygonCB,
sizeof(
DELTA_POINT) * wParam->numPoints);
768 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
770 up = update_cast(context->update);
771 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, PolygonCB),
772 (
void*)wParam,
nullptr);
775static BOOL update_message_EllipseSC(rdpContext* context,
const ELLIPSE_SC_ORDER* ellipseSC)
780 if (!context || !context->update || !ellipseSC)
790 up = update_cast(context->update);
791 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, EllipseSC),
792 (
void*)wParam,
nullptr);
795static BOOL update_message_EllipseCB(rdpContext* context,
const ELLIPSE_CB_ORDER* ellipseCB)
800 if (!context || !context->update || !ellipseCB)
809 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
811 up = update_cast(context->update);
812 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, EllipseCB),
813 (
void*)wParam,
nullptr);
818static BOOL update_message_CacheBitmap(rdpContext* context,
824 if (!context || !context->update || !cacheBitmapOrder)
827 wParam = copy_cache_bitmap_order(context, cacheBitmapOrder);
832 up = update_cast(context->update);
833 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(SecondaryUpdate, CacheBitmap),
834 (
void*)wParam,
nullptr);
837static BOOL update_message_CacheBitmapV2(rdpContext* context,
843 if (!context || !context->update || !cacheBitmapV2Order)
846 wParam = copy_cache_bitmap_v2_order(context, cacheBitmapV2Order);
851 up = update_cast(context->update);
852 return MessageQueue_Post(up->queue, (
void*)context,
853 MakeMessageId(SecondaryUpdate, CacheBitmapV2), (
void*)wParam,
nullptr);
856static BOOL update_message_CacheBitmapV3(rdpContext* context,
862 if (!context || !context->update || !cacheBitmapV3Order)
865 wParam = copy_cache_bitmap_v3_order(context, cacheBitmapV3Order);
870 up = update_cast(context->update);
871 return MessageQueue_Post(up->queue, (
void*)context,
872 MakeMessageId(SecondaryUpdate, CacheBitmapV3), (
void*)wParam,
nullptr);
875static BOOL update_message_CacheColorTable(rdpContext* context,
881 if (!context || !context->update || !cacheColorTableOrder)
884 wParam = copy_cache_color_table_order(context, cacheColorTableOrder);
889 up = update_cast(context->update);
890 return MessageQueue_Post(up->queue, (
void*)context,
891 MakeMessageId(SecondaryUpdate, CacheColorTable), (
void*)wParam,
895static BOOL update_message_CacheGlyph(rdpContext* context,
const CACHE_GLYPH_ORDER* cacheGlyphOrder)
900 if (!context || !context->update || !cacheGlyphOrder)
903 wParam = copy_cache_glyph_order(context, cacheGlyphOrder);
908 up = update_cast(context->update);
909 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(SecondaryUpdate, CacheGlyph),
910 (
void*)wParam,
nullptr);
913static BOOL update_message_CacheGlyphV2(rdpContext* context,
919 if (!context || !context->update || !cacheGlyphV2Order)
922 wParam = copy_cache_glyph_v2_order(context, cacheGlyphV2Order);
927 up = update_cast(context->update);
928 return MessageQueue_Post(up->queue, (
void*)context,
929 MakeMessageId(SecondaryUpdate, CacheGlyphV2), (
void*)wParam,
nullptr);
932static BOOL update_message_CacheBrush(rdpContext* context,
const CACHE_BRUSH_ORDER* cacheBrushOrder)
937 if (!context || !context->update || !cacheBrushOrder)
940 wParam = copy_cache_brush_order(context, cacheBrushOrder);
945 up = update_cast(context->update);
946 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(SecondaryUpdate, CacheBrush),
947 (
void*)wParam,
nullptr);
953update_message_CreateOffscreenBitmap(rdpContext* context,
959 if (!context || !context->update || !createOffscreenBitmap)
968 wParam->deleteList.cIndices = createOffscreenBitmap->deleteList.cIndices;
969 wParam->deleteList.sIndices = wParam->deleteList.cIndices;
970 wParam->deleteList.indices = (UINT16*)calloc(wParam->deleteList.cIndices,
sizeof(UINT16));
972 if (!wParam->deleteList.indices)
978 CopyMemory(wParam->deleteList.indices, createOffscreenBitmap->deleteList.indices,
979 wParam->deleteList.cIndices);
981 up = update_cast(context->update);
982 return MessageQueue_Post(up->queue, (
void*)context,
983 MakeMessageId(AltSecUpdate, CreateOffscreenBitmap), (
void*)wParam,
987static BOOL update_message_SwitchSurface(rdpContext* context,
993 if (!context || !context->update || !switchSurface)
1003 up = update_cast(context->update);
1004 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(AltSecUpdate, SwitchSurface),
1005 (
void*)wParam,
nullptr);
1009update_message_CreateNineGridBitmap(rdpContext* context,
1015 if (!context || !context->update || !createNineGridBitmap)
1025 up = update_cast(context->update);
1026 return MessageQueue_Post(up->queue, (
void*)context,
1027 MakeMessageId(AltSecUpdate, CreateNineGridBitmap), (
void*)wParam,
1031static BOOL update_message_FrameMarker(rdpContext* context,
const FRAME_MARKER_ORDER* frameMarker)
1036 if (!context || !context->update || !frameMarker)
1046 up = update_cast(context->update);
1047 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(AltSecUpdate, FrameMarker),
1048 (
void*)wParam,
nullptr);
1051static BOOL update_message_StreamBitmapFirst(rdpContext* context,
1057 if (!context || !context->update || !streamBitmapFirst)
1068 up = update_cast(context->update);
1069 return MessageQueue_Post(up->queue, (
void*)context,
1070 MakeMessageId(AltSecUpdate, StreamBitmapFirst), (
void*)wParam,
1074static BOOL update_message_StreamBitmapNext(rdpContext* context,
1080 if (!context || !context->update || !streamBitmapNext)
1091 up = update_cast(context->update);
1092 return MessageQueue_Post(up->queue, (
void*)context,
1093 MakeMessageId(AltSecUpdate, StreamBitmapNext), (
void*)wParam,
nullptr);
1096static BOOL update_message_DrawGdiPlusFirst(rdpContext* context,
1102 if (!context || !context->update || !drawGdiPlusFirst)
1112 up = update_cast(context->update);
1113 return MessageQueue_Post(up->queue, (
void*)context,
1114 MakeMessageId(AltSecUpdate, DrawGdiPlusFirst), (
void*)wParam,
nullptr);
1117static BOOL update_message_DrawGdiPlusNext(rdpContext* context,
1123 if (!context || !context->update || !drawGdiPlusNext)
1134 up = update_cast(context->update);
1135 return MessageQueue_Post(up->queue, (
void*)context,
1136 MakeMessageId(AltSecUpdate, DrawGdiPlusNext), (
void*)wParam,
nullptr);
1139static BOOL update_message_DrawGdiPlusEnd(rdpContext* context,
1145 if (!context || !context->update || !drawGdiPlusEnd)
1156 up = update_cast(context->update);
1157 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(AltSecUpdate, DrawGdiPlusEnd),
1158 (
void*)wParam,
nullptr);
1162update_message_DrawGdiPlusCacheFirst(rdpContext* context,
1168 if (!context || !context->update || !drawGdiPlusCacheFirst)
1179 up = update_cast(context->update);
1180 return MessageQueue_Post(up->queue, (
void*)context,
1181 MakeMessageId(AltSecUpdate, DrawGdiPlusCacheFirst), (
void*)wParam,
1186update_message_DrawGdiPlusCacheNext(rdpContext* context,
1192 if (!context || !context->update || !drawGdiPlusCacheNext)
1203 up = update_cast(context->update);
1204 return MessageQueue_Post(up->queue, (
void*)context,
1205 MakeMessageId(AltSecUpdate, DrawGdiPlusCacheNext), (
void*)wParam,
1210update_message_DrawGdiPlusCacheEnd(rdpContext* context,
1216 if (!context || !context->update || !drawGdiPlusCacheEnd)
1227 up = update_cast(context->update);
1228 return MessageQueue_Post(up->queue, (
void*)context,
1229 MakeMessageId(AltSecUpdate, DrawGdiPlusCacheEnd), (
void*)wParam,
1235static BOOL update_message_WindowCreate(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1242 if (!context || !context->update || !orderInfo || !windowState)
1261 up = update_cast(context->update);
1262 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(WindowUpdate, WindowCreate),
1263 (
void*)wParam, (
void*)lParam);
1266static BOOL update_message_WindowUpdate(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1273 if (!context || !context->update || !orderInfo || !windowState)
1292 up = update_cast(context->update);
1293 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(WindowUpdate, WindowUpdate),
1294 (
void*)wParam, (
void*)lParam);
1297static BOOL update_message_WindowIcon(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1304 if (!context || !context->update || !orderInfo || !windowIcon)
1318 lParam->iconInfo = calloc(1,
sizeof(
ICON_INFO));
1320 if (!lParam->iconInfo)
1324 WLog_VRB(TAG,
"update_message_WindowIcon");
1326 if (windowIcon->iconInfo->cbBitsColor > 0)
1328 lParam->iconInfo->bitsColor = (BYTE*)malloc(windowIcon->iconInfo->cbBitsColor);
1330 if (!lParam->iconInfo->bitsColor)
1333 CopyMemory(lParam->iconInfo->bitsColor, windowIcon->iconInfo->bitsColor,
1334 windowIcon->iconInfo->cbBitsColor);
1337 if (windowIcon->iconInfo->cbBitsMask > 0)
1339 lParam->iconInfo->bitsMask = (BYTE*)malloc(windowIcon->iconInfo->cbBitsMask);
1341 if (!lParam->iconInfo->bitsMask)
1344 CopyMemory(lParam->iconInfo->bitsMask, windowIcon->iconInfo->bitsMask,
1345 windowIcon->iconInfo->cbBitsMask);
1348 if (windowIcon->iconInfo->cbColorTable > 0)
1350 lParam->iconInfo->colorTable = (BYTE*)malloc(windowIcon->iconInfo->cbColorTable);
1352 if (!lParam->iconInfo->colorTable)
1355 CopyMemory(lParam->iconInfo->colorTable, windowIcon->iconInfo->colorTable,
1356 windowIcon->iconInfo->cbColorTable);
1359 up = update_cast(context->update);
1360 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(WindowUpdate, WindowIcon),
1361 (
void*)wParam, (
void*)lParam);
1364 if (lParam && lParam->iconInfo)
1366 free(lParam->iconInfo->bitsColor);
1367 free(lParam->iconInfo->bitsMask);
1368 free(lParam->iconInfo->colorTable);
1369 free(lParam->iconInfo);
1377static BOOL update_message_WindowCachedIcon(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1384 if (!context || !context->update || !orderInfo || !windowCachedIcon)
1403 up = update_cast(context->update);
1404 return MessageQueue_Post(up->queue, (
void*)context,
1405 MakeMessageId(WindowUpdate, WindowCachedIcon), (
void*)wParam,
1409static BOOL update_message_WindowDelete(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo)
1414 if (!context || !context->update || !orderInfo)
1424 up = update_cast(context->update);
1425 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(WindowUpdate, WindowDelete),
1426 (
void*)wParam,
nullptr);
1429static BOOL update_message_NotifyIconCreate(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1436 if (!context || !context->update || !orderInfo || !notifyIconState)
1455 up = update_cast(context->update);
1456 return MessageQueue_Post(up->queue, (
void*)context,
1457 MakeMessageId(WindowUpdate, NotifyIconCreate), (
void*)wParam,
1461static BOOL update_message_NotifyIconUpdate(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1468 if (!context || !context->update || !orderInfo || !notifyIconState)
1487 up = update_cast(context->update);
1488 return MessageQueue_Post(up->queue, (
void*)context,
1489 MakeMessageId(WindowUpdate, NotifyIconUpdate), (
void*)wParam,
1493static BOOL update_message_NotifyIconDelete(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo)
1498 if (!context || !context->update || !orderInfo)
1508 up = update_cast(context->update);
1509 return MessageQueue_Post(up->queue, (
void*)context,
1510 MakeMessageId(WindowUpdate, NotifyIconDelete), (
void*)wParam,
nullptr);
1513static BOOL update_message_MonitoredDesktop(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1520 if (!context || !context->update || !orderInfo || !monitoredDesktop)
1538 lParam->windowIds =
nullptr;
1540 if (lParam->numWindowIds)
1542 lParam->windowIds = (UINT32*)calloc(lParam->numWindowIds,
sizeof(UINT32));
1543 CopyMemory(lParam->windowIds, monitoredDesktop->windowIds, lParam->numWindowIds);
1546 up = update_cast(context->update);
1547 return MessageQueue_Post(up->queue, (
void*)context,
1548 MakeMessageId(WindowUpdate, MonitoredDesktop), (
void*)wParam,
1552static BOOL update_message_NonMonitoredDesktop(rdpContext* context,
1558 if (!context || !context->update || !orderInfo)
1568 up = update_cast(context->update);
1569 return MessageQueue_Post(up->queue, (
void*)context,
1570 MakeMessageId(WindowUpdate, NonMonitoredDesktop), (
void*)wParam,
1576static BOOL update_message_PointerPosition(rdpContext* context,
1582 if (!context || !context->update || !pointerPosition)
1585 wParam = copy_pointer_position_update(context, pointerPosition);
1590 up = update_cast(context->update);
1591 return MessageQueue_Post(up->queue, (
void*)context,
1592 MakeMessageId(PointerUpdate, PointerPosition), (
void*)wParam,
nullptr);
1595static BOOL update_message_PointerSystem(rdpContext* context,
1601 if (!context || !context->update || !pointerSystem)
1604 wParam = copy_pointer_system_update(context, pointerSystem);
1609 up = update_cast(context->update);
1610 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerSystem),
1611 (
void*)wParam,
nullptr);
1614static BOOL update_message_PointerColor(rdpContext* context,
1620 if (!context || !context->update || !pointerColor)
1623 wParam = copy_pointer_color_update(context, pointerColor);
1628 up = update_cast(context->update);
1629 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerColor),
1630 (
void*)wParam,
nullptr);
1633static BOOL update_message_PointerLarge(rdpContext* context,
const POINTER_LARGE_UPDATE* pointer)
1638 if (!context || !context->update || !pointer)
1641 wParam = copy_pointer_large_update(context, pointer);
1646 up = update_cast(context->update);
1647 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerLarge),
1648 (
void*)wParam,
nullptr);
1651static BOOL update_message_PointerNew(rdpContext* context,
const POINTER_NEW_UPDATE* pointerNew)
1656 if (!context || !context->update || !pointerNew)
1659 wParam = copy_pointer_new_update(context, pointerNew);
1664 up = update_cast(context->update);
1665 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerNew),
1666 (
void*)wParam,
nullptr);
1669static BOOL update_message_PointerCached(rdpContext* context,
1675 if (!context || !context->update || !pointerCached)
1678 wParam = copy_pointer_cached_update(context, pointerCached);
1683 up = update_cast(context->update);
1684 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerCached),
1685 (
void*)wParam,
nullptr);
1689static BOOL update_message_free_update_class(wMessage* msg,
int type)
1691 rdpContext* context =
nullptr;
1696 context = (rdpContext*)msg->context;
1700 case Update_BeginPaint:
1703 case Update_EndPaint:
1706 case Update_SetBounds:
1710 case Update_Synchronize:
1713 case Update_DesktopResize:
1716 case Update_BitmapUpdate:
1719 free_bitmap_update(context, wParam);
1723 case Update_Palette:
1726 free_palette_update(context, palette);
1730 case Update_PlaySound:
1734 case Update_RefreshRect:
1738 case Update_SuppressOutput:
1742 case Update_SurfaceCommand:
1745 Stream_Free(s, TRUE);
1749 case Update_SurfaceBits:
1752 free_surface_bits_command(context, wParam);
1756 case Update_SurfaceFrameMarker:
1760 case Update_SurfaceFrameAcknowledge:
1761 case Update_SetKeyboardIndicators:
1762 case Update_SetKeyboardImeStatus:
1772static BOOL update_message_process_update_class(rdpUpdateProxy* proxy, wMessage* msg,
int type)
1781 case Update_BeginPaint:
1782 rc = IFCALLRESULT(TRUE, proxy->BeginPaint, msg->context);
1785 case Update_EndPaint:
1786 rc = IFCALLRESULT(TRUE, proxy->EndPaint, msg->context);
1789 case Update_SetBounds:
1790 rc = IFCALLRESULT(TRUE, proxy->SetBounds, msg->context, (rdpBounds*)msg->wParam);
1793 case Update_Synchronize:
1794 rc = IFCALLRESULT(TRUE, proxy->Synchronize, msg->context);
1797 case Update_DesktopResize:
1798 rc = IFCALLRESULT(TRUE, proxy->DesktopResize, msg->context);
1801 case Update_BitmapUpdate:
1802 rc = IFCALLRESULT(TRUE, proxy->BitmapUpdate, msg->context, (
BITMAP_UPDATE*)msg->wParam);
1805 case Update_Palette:
1806 rc = IFCALLRESULT(TRUE, proxy->Palette, msg->context, (
PALETTE_UPDATE*)msg->wParam);
1809 case Update_PlaySound:
1811 IFCALLRESULT(TRUE, proxy->PlaySound, msg->context, (
PLAY_SOUND_UPDATE*)msg->wParam);
1814 case Update_RefreshRect:
1815 rc = IFCALLRESULT(TRUE, proxy->RefreshRect, msg->context, (BYTE)(
size_t)msg->wParam,
1819 case Update_SuppressOutput:
1820 rc = IFCALLRESULT(TRUE, proxy->SuppressOutput, msg->context, (BYTE)(
size_t)msg->wParam,
1824 case Update_SurfaceCommand:
1825 rc = IFCALLRESULT(TRUE, proxy->SurfaceCommand, msg->context, (
wStream*)msg->wParam);
1828 case Update_SurfaceBits:
1829 rc = IFCALLRESULT(TRUE, proxy->SurfaceBits, msg->context,
1833 case Update_SurfaceFrameMarker:
1834 rc = IFCALLRESULT(TRUE, proxy->SurfaceFrameMarker, msg->context,
1838 case Update_SurfaceFrameAcknowledge:
1839 rc = IFCALLRESULT(TRUE, proxy->SurfaceFrameAcknowledge, msg->context,
1840 (UINT32)(
size_t)msg->wParam);
1843 case Update_SetKeyboardIndicators:
1844 rc = IFCALLRESULT(TRUE, proxy->SetKeyboardIndicators, msg->context,
1845 (UINT16)(
size_t)msg->wParam);
1848 case Update_SetKeyboardImeStatus:
1850 const UINT16 imeId = ((size_t)msg->wParam) >> 16 & 0xFFFF;
1851 const UINT32 imeState = ((size_t)msg->wParam) & 0xFFFF;
1852 const UINT32 imeConvMode = ((size_t)msg->lParam) & 0xFFFFFFFFUL;
1853 rc = IFCALLRESULT(TRUE, proxy->SetKeyboardImeStatus, msg->context, imeId, imeState,
1865static BOOL update_message_free_primary_update_class(wMessage* msg,
int type)
1872 case PrimaryUpdate_DstBlt:
1876 case PrimaryUpdate_PatBlt:
1880 case PrimaryUpdate_ScrBlt:
1884 case PrimaryUpdate_OpaqueRect:
1888 case PrimaryUpdate_DrawNineGrid:
1892 case PrimaryUpdate_MultiDstBlt:
1896 case PrimaryUpdate_MultiPatBlt:
1900 case PrimaryUpdate_MultiScrBlt:
1904 case PrimaryUpdate_MultiOpaqueRect:
1908 case PrimaryUpdate_MultiDrawNineGrid:
1912 case PrimaryUpdate_LineTo:
1916 case PrimaryUpdate_Polyline:
1919 free(wParam->points);
1924 case PrimaryUpdate_MemBlt:
1928 case PrimaryUpdate_Mem3Blt:
1932 case PrimaryUpdate_SaveBitmap:
1936 case PrimaryUpdate_GlyphIndex:
1940 case PrimaryUpdate_FastIndex:
1944 case PrimaryUpdate_FastGlyph:
1947 free(wParam->glyphData.aj);
1952 case PrimaryUpdate_PolygonSC:
1955 free(wParam->points);
1960 case PrimaryUpdate_PolygonCB:
1963 free(wParam->points);
1968 case PrimaryUpdate_EllipseSC:
1972 case PrimaryUpdate_EllipseCB:
1983static BOOL update_message_process_primary_update_class(rdpUpdateProxy* proxy, wMessage* msg,
1991 case PrimaryUpdate_DstBlt:
1992 return IFCALLRESULT(TRUE, proxy->DstBlt, msg->context, (
DSTBLT_ORDER*)msg->wParam);
1994 case PrimaryUpdate_PatBlt:
1995 return IFCALLRESULT(TRUE, proxy->PatBlt, msg->context, (
PATBLT_ORDER*)msg->wParam);
1997 case PrimaryUpdate_ScrBlt:
1998 return IFCALLRESULT(TRUE, proxy->ScrBlt, msg->context, (
SCRBLT_ORDER*)msg->wParam);
2000 case PrimaryUpdate_OpaqueRect:
2001 return IFCALLRESULT(TRUE, proxy->OpaqueRect, msg->context,
2004 case PrimaryUpdate_DrawNineGrid:
2005 return IFCALLRESULT(TRUE, proxy->DrawNineGrid, msg->context,
2008 case PrimaryUpdate_MultiDstBlt:
2009 return IFCALLRESULT(TRUE, proxy->MultiDstBlt, msg->context,
2012 case PrimaryUpdate_MultiPatBlt:
2013 return IFCALLRESULT(TRUE, proxy->MultiPatBlt, msg->context,
2016 case PrimaryUpdate_MultiScrBlt:
2017 return IFCALLRESULT(TRUE, proxy->MultiScrBlt, msg->context,
2020 case PrimaryUpdate_MultiOpaqueRect:
2021 return IFCALLRESULT(TRUE, proxy->MultiOpaqueRect, msg->context,
2024 case PrimaryUpdate_MultiDrawNineGrid:
2025 return IFCALLRESULT(TRUE, proxy->MultiDrawNineGrid, msg->context,
2028 case PrimaryUpdate_LineTo:
2029 return IFCALLRESULT(TRUE, proxy->LineTo, msg->context, (
LINE_TO_ORDER*)msg->wParam);
2031 case PrimaryUpdate_Polyline:
2032 return IFCALLRESULT(TRUE, proxy->Polyline, msg->context, (
POLYLINE_ORDER*)msg->wParam);
2034 case PrimaryUpdate_MemBlt:
2035 return IFCALLRESULT(TRUE, proxy->MemBlt, msg->context, (
MEMBLT_ORDER*)msg->wParam);
2037 case PrimaryUpdate_Mem3Blt:
2038 return IFCALLRESULT(TRUE, proxy->Mem3Blt, msg->context, (
MEM3BLT_ORDER*)msg->wParam);
2040 case PrimaryUpdate_SaveBitmap:
2041 return IFCALLRESULT(TRUE, proxy->SaveBitmap, msg->context,
2044 case PrimaryUpdate_GlyphIndex:
2045 return IFCALLRESULT(TRUE, proxy->GlyphIndex, msg->context,
2048 case PrimaryUpdate_FastIndex:
2049 return IFCALLRESULT(TRUE, proxy->FastIndex, msg->context,
2052 case PrimaryUpdate_FastGlyph:
2053 return IFCALLRESULT(TRUE, proxy->FastGlyph, msg->context,
2056 case PrimaryUpdate_PolygonSC:
2057 return IFCALLRESULT(TRUE, proxy->PolygonSC, msg->context,
2060 case PrimaryUpdate_PolygonCB:
2061 return IFCALLRESULT(TRUE, proxy->PolygonCB, msg->context,
2064 case PrimaryUpdate_EllipseSC:
2065 return IFCALLRESULT(TRUE, proxy->EllipseSC, msg->context,
2068 case PrimaryUpdate_EllipseCB:
2069 return IFCALLRESULT(TRUE, proxy->EllipseCB, msg->context,
2077static BOOL update_message_free_secondary_update_class(wMessage* msg,
int type)
2079 rdpContext* context =
nullptr;
2084 context = msg->context;
2088 case SecondaryUpdate_CacheBitmap:
2091 free_cache_bitmap_order(context, wParam);
2095 case SecondaryUpdate_CacheBitmapV2:
2098 free_cache_bitmap_v2_order(context, wParam);
2102 case SecondaryUpdate_CacheBitmapV3:
2105 free_cache_bitmap_v3_order(context, wParam);
2109 case SecondaryUpdate_CacheColorTable:
2112 free_cache_color_table_order(context, wParam);
2116 case SecondaryUpdate_CacheGlyph:
2119 free_cache_glyph_order(context, wParam);
2123 case SecondaryUpdate_CacheGlyphV2:
2126 free_cache_glyph_v2_order(context, wParam);
2130 case SecondaryUpdate_CacheBrush:
2133 free_cache_brush_order(context, wParam);
2144static BOOL update_message_process_secondary_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2152 case SecondaryUpdate_CacheBitmap:
2153 return IFCALLRESULT(TRUE, proxy->CacheBitmap, msg->context,
2156 case SecondaryUpdate_CacheBitmapV2:
2157 return IFCALLRESULT(TRUE, proxy->CacheBitmapV2, msg->context,
2160 case SecondaryUpdate_CacheBitmapV3:
2161 return IFCALLRESULT(TRUE, proxy->CacheBitmapV3, msg->context,
2164 case SecondaryUpdate_CacheColorTable:
2165 return IFCALLRESULT(TRUE, proxy->CacheColorTable, msg->context,
2168 case SecondaryUpdate_CacheGlyph:
2169 return IFCALLRESULT(TRUE, proxy->CacheGlyph, msg->context,
2172 case SecondaryUpdate_CacheGlyphV2:
2173 return IFCALLRESULT(TRUE, proxy->CacheGlyphV2, msg->context,
2176 case SecondaryUpdate_CacheBrush:
2177 return IFCALLRESULT(TRUE, proxy->CacheBrush, msg->context,
2185static BOOL update_message_free_altsec_update_class(wMessage* msg,
int type)
2192 case AltSecUpdate_CreateOffscreenBitmap:
2195 free(wParam->deleteList.indices);
2200 case AltSecUpdate_SwitchSurface:
2204 case AltSecUpdate_CreateNineGridBitmap:
2208 case AltSecUpdate_FrameMarker:
2212 case AltSecUpdate_StreamBitmapFirst:
2216 case AltSecUpdate_StreamBitmapNext:
2220 case AltSecUpdate_DrawGdiPlusFirst:
2224 case AltSecUpdate_DrawGdiPlusNext:
2228 case AltSecUpdate_DrawGdiPlusEnd:
2232 case AltSecUpdate_DrawGdiPlusCacheFirst:
2236 case AltSecUpdate_DrawGdiPlusCacheNext:
2240 case AltSecUpdate_DrawGdiPlusCacheEnd:
2251static BOOL update_message_process_altsec_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2259 case AltSecUpdate_CreateOffscreenBitmap:
2260 return IFCALLRESULT(TRUE, proxy->CreateOffscreenBitmap, msg->context,
2263 case AltSecUpdate_SwitchSurface:
2264 return IFCALLRESULT(TRUE, proxy->SwitchSurface, msg->context,
2267 case AltSecUpdate_CreateNineGridBitmap:
2268 return IFCALLRESULT(TRUE, proxy->CreateNineGridBitmap, msg->context,
2271 case AltSecUpdate_FrameMarker:
2272 return IFCALLRESULT(TRUE, proxy->FrameMarker, msg->context,
2275 case AltSecUpdate_StreamBitmapFirst:
2276 return IFCALLRESULT(TRUE, proxy->StreamBitmapFirst, msg->context,
2279 case AltSecUpdate_StreamBitmapNext:
2280 return IFCALLRESULT(TRUE, proxy->StreamBitmapNext, msg->context,
2283 case AltSecUpdate_DrawGdiPlusFirst:
2284 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusFirst, msg->context,
2287 case AltSecUpdate_DrawGdiPlusNext:
2288 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusNext, msg->context,
2291 case AltSecUpdate_DrawGdiPlusEnd:
2292 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusEnd, msg->context,
2295 case AltSecUpdate_DrawGdiPlusCacheFirst:
2296 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusCacheFirst, msg->context,
2299 case AltSecUpdate_DrawGdiPlusCacheNext:
2300 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusCacheNext, msg->context,
2303 case AltSecUpdate_DrawGdiPlusCacheEnd:
2304 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusCacheEnd, msg->context,
2312static BOOL update_message_free_window_update_class(wMessage* msg,
int type)
2319 case WindowUpdate_WindowCreate:
2324 case WindowUpdate_WindowUpdate:
2329 case WindowUpdate_WindowIcon:
2334 if (windowIcon->iconInfo->cbBitsColor > 0)
2336 free(windowIcon->iconInfo->bitsColor);
2339 if (windowIcon->iconInfo->cbBitsMask > 0)
2341 free(windowIcon->iconInfo->bitsMask);
2344 if (windowIcon->iconInfo->cbColorTable > 0)
2346 free(windowIcon->iconInfo->colorTable);
2350 free(windowIcon->iconInfo);
2355 case WindowUpdate_WindowCachedIcon:
2360 case WindowUpdate_WindowDelete:
2364 case WindowUpdate_NotifyIconCreate:
2369 case WindowUpdate_NotifyIconUpdate:
2374 case WindowUpdate_NotifyIconDelete:
2378 case WindowUpdate_MonitoredDesktop:
2382 free(lParam->windowIds);
2387 case WindowUpdate_NonMonitoredDesktop:
2398static BOOL update_message_process_window_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2406 case WindowUpdate_WindowCreate:
2407 return IFCALLRESULT(TRUE, proxy->WindowCreate, msg->context,
2410 case WindowUpdate_WindowUpdate:
2411 return IFCALLRESULT(TRUE, proxy->WindowCreate, msg->context,
2414 case WindowUpdate_WindowIcon:
2418 return IFCALLRESULT(TRUE, proxy->WindowIcon, msg->context, orderInfo, windowIcon);
2421 case WindowUpdate_WindowCachedIcon:
2422 return IFCALLRESULT(TRUE, proxy->WindowCachedIcon, msg->context,
2426 case WindowUpdate_WindowDelete:
2427 return IFCALLRESULT(TRUE, proxy->WindowDelete, msg->context,
2430 case WindowUpdate_NotifyIconCreate:
2431 return IFCALLRESULT(TRUE, proxy->NotifyIconCreate, msg->context,
2435 case WindowUpdate_NotifyIconUpdate:
2436 return IFCALLRESULT(TRUE, proxy->NotifyIconUpdate, msg->context,
2440 case WindowUpdate_NotifyIconDelete:
2441 return IFCALLRESULT(TRUE, proxy->NotifyIconDelete, msg->context,
2444 case WindowUpdate_MonitoredDesktop:
2445 return IFCALLRESULT(TRUE, proxy->MonitoredDesktop, msg->context,
2449 case WindowUpdate_NonMonitoredDesktop:
2450 return IFCALLRESULT(TRUE, proxy->NonMonitoredDesktop, msg->context,
2458static BOOL update_message_free_pointer_update_class(wMessage* msg,
int type)
2460 rdpContext* context =
nullptr;
2465 context = msg->context;
2469 case PointerUpdate_PointerPosition:
2472 free_pointer_position_update(context, wParam);
2476 case PointerUpdate_PointerSystem:
2479 free_pointer_system_update(context, wParam);
2483 case PointerUpdate_PointerCached:
2486 free_pointer_cached_update(context, wParam);
2490 case PointerUpdate_PointerColor:
2493 free_pointer_color_update(context, wParam);
2497 case PointerUpdate_PointerNew:
2500 free_pointer_new_update(context, wParam);
2511static BOOL update_message_process_pointer_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2519 case PointerUpdate_PointerPosition:
2520 return IFCALLRESULT(TRUE, proxy->PointerPosition, msg->context,
2523 case PointerUpdate_PointerSystem:
2524 return IFCALLRESULT(TRUE, proxy->PointerSystem, msg->context,
2527 case PointerUpdate_PointerColor:
2528 return IFCALLRESULT(TRUE, proxy->PointerColor, msg->context,
2531 case PointerUpdate_PointerNew:
2532 return IFCALLRESULT(TRUE, proxy->PointerNew, msg->context,
2535 case PointerUpdate_PointerCached:
2536 return IFCALLRESULT(TRUE, proxy->PointerCached, msg->context,
2544static BOOL update_message_free_class(wMessage* msg,
int msgClass,
int msgType)
2546 BOOL status = FALSE;
2551 status = update_message_free_update_class(msg, msgType);
2554 case PrimaryUpdate_Class:
2555 status = update_message_free_primary_update_class(msg, msgType);
2558 case SecondaryUpdate_Class:
2559 status = update_message_free_secondary_update_class(msg, msgType);
2562 case AltSecUpdate_Class:
2563 status = update_message_free_altsec_update_class(msg, msgType);
2566 case WindowUpdate_Class:
2567 status = update_message_free_window_update_class(msg, msgType);
2570 case PointerUpdate_Class:
2571 status = update_message_free_pointer_update_class(msg, msgType);
2579 WLog_ERR(TAG,
"Unknown message: class: %d type: %d", msgClass, msgType);
2584static int update_message_process_class(rdpUpdateProxy* proxy, wMessage* msg,
int msgClass,
2587 BOOL status = FALSE;
2592 status = update_message_process_update_class(proxy, msg, msgType);
2595 case PrimaryUpdate_Class:
2596 status = update_message_process_primary_update_class(proxy, msg, msgType);
2599 case SecondaryUpdate_Class:
2600 status = update_message_process_secondary_update_class(proxy, msg, msgType);
2603 case AltSecUpdate_Class:
2604 status = update_message_process_altsec_update_class(proxy, msg, msgType);
2607 case WindowUpdate_Class:
2608 status = update_message_process_window_update_class(proxy, msg, msgType);
2611 case PointerUpdate_Class:
2612 status = update_message_process_pointer_update_class(proxy, msg, msgType);
2622 WLog_ERR(TAG,
"message: class: %d type: %d failed", msgClass, msgType);
2629int update_message_queue_process_message(rdpUpdate* update, wMessage* message)
2636 if (!update || !message)
2639 if (message->id == WMQ_QUIT)
2642 msgClass = GetMessageClass(message->id);
2643 msgType = GetMessageType(message->id);
2644 status = update_message_process_class(up->proxy, message, msgClass, msgType);
2645 update_message_free_class(message, msgClass, msgType);
2653int update_message_queue_free_message(wMessage* message)
2661 if (message->id == WMQ_QUIT)
2664 msgClass = GetMessageClass(message->id);
2665 msgType = GetMessageType(message->id);
2666 return update_message_free_class(message, msgClass, msgType);
2669int update_message_queue_process_pending_messages(rdpUpdate* update)
2672 wMessage message = WINPR_C_ARRAY_INIT;
2675 wMessageQueue* queue = up->queue;
2677 while (MessageQueue_Peek(queue, &message, TRUE))
2679 status = update_message_queue_process_message(update, &message);
2688static BOOL update_message_register_interface(rdpUpdateProxy* message, rdpUpdate* update)
2690 rdpPrimaryUpdate* primary =
nullptr;
2691 rdpSecondaryUpdate* secondary =
nullptr;
2692 rdpAltSecUpdate* altsec =
nullptr;
2693 rdpWindowUpdate* window =
nullptr;
2694 rdpPointerUpdate* pointer =
nullptr;
2696 if (!message || !update)
2699 primary = update->primary;
2700 secondary = update->secondary;
2701 altsec = update->altsec;
2702 window = update->window;
2703 pointer = update->pointer;
2705 if (!primary || !secondary || !altsec || !window || !pointer)
2709 message->BeginPaint = update->BeginPaint;
2710 message->EndPaint = update->EndPaint;
2711 message->SetBounds = update->SetBounds;
2712 message->Synchronize = update->Synchronize;
2713 message->DesktopResize = update->DesktopResize;
2714 message->BitmapUpdate = update->BitmapUpdate;
2715 message->Palette = update->Palette;
2716 message->PlaySound = update->PlaySound;
2717 message->SetKeyboardIndicators = update->SetKeyboardIndicators;
2718 message->SetKeyboardImeStatus = update->SetKeyboardImeStatus;
2719 message->RefreshRect = update->RefreshRect;
2720 message->SuppressOutput = update->SuppressOutput;
2721 message->SurfaceCommand = update->SurfaceCommand;
2722 message->SurfaceBits = update->SurfaceBits;
2723 message->SurfaceFrameMarker = update->SurfaceFrameMarker;
2724 message->SurfaceFrameAcknowledge = update->SurfaceFrameAcknowledge;
2725 update->BeginPaint = update_message_BeginPaint;
2726 update->EndPaint = update_message_EndPaint;
2727 update->SetBounds = update_message_SetBounds;
2728 update->Synchronize = update_message_Synchronize;
2729 update->DesktopResize = update_message_DesktopResize;
2730 update->BitmapUpdate = update_message_BitmapUpdate;
2731 update->Palette = update_message_Palette;
2732 update->PlaySound = update_message_PlaySound;
2733 update->SetKeyboardIndicators = update_message_SetKeyboardIndicators;
2734 update->SetKeyboardImeStatus = update_message_SetKeyboardImeStatus;
2735 update->RefreshRect = update_message_RefreshRect;
2736 update->SuppressOutput = update_message_SuppressOutput;
2737 update->SurfaceCommand = update_message_SurfaceCommand;
2738 update->SurfaceBits = update_message_SurfaceBits;
2739 update->SurfaceFrameMarker = update_message_SurfaceFrameMarker;
2740 update->SurfaceFrameAcknowledge = update_message_SurfaceFrameAcknowledge;
2742 message->DstBlt = primary->DstBlt;
2743 message->PatBlt = primary->PatBlt;
2744 message->ScrBlt = primary->ScrBlt;
2745 message->OpaqueRect = primary->OpaqueRect;
2746 message->DrawNineGrid = primary->DrawNineGrid;
2747 message->MultiDstBlt = primary->MultiDstBlt;
2748 message->MultiPatBlt = primary->MultiPatBlt;
2749 message->MultiScrBlt = primary->MultiScrBlt;
2750 message->MultiOpaqueRect = primary->MultiOpaqueRect;
2751 message->MultiDrawNineGrid = primary->MultiDrawNineGrid;
2752 message->LineTo = primary->LineTo;
2753 message->Polyline = primary->Polyline;
2754 message->MemBlt = primary->MemBlt;
2755 message->Mem3Blt = primary->Mem3Blt;
2756 message->SaveBitmap = primary->SaveBitmap;
2757 message->GlyphIndex = primary->GlyphIndex;
2758 message->FastIndex = primary->FastIndex;
2759 message->FastGlyph = primary->FastGlyph;
2760 message->PolygonSC = primary->PolygonSC;
2761 message->PolygonCB = primary->PolygonCB;
2762 message->EllipseSC = primary->EllipseSC;
2763 message->EllipseCB = primary->EllipseCB;
2764 primary->DstBlt = update_message_DstBlt;
2765 primary->PatBlt = update_message_PatBlt;
2766 primary->ScrBlt = update_message_ScrBlt;
2767 primary->OpaqueRect = update_message_OpaqueRect;
2768 primary->DrawNineGrid = update_message_DrawNineGrid;
2769 primary->MultiDstBlt = update_message_MultiDstBlt;
2770 primary->MultiPatBlt = update_message_MultiPatBlt;
2771 primary->MultiScrBlt = update_message_MultiScrBlt;
2772 primary->MultiOpaqueRect = update_message_MultiOpaqueRect;
2773 primary->MultiDrawNineGrid = update_message_MultiDrawNineGrid;
2774 primary->LineTo = update_message_LineTo;
2775 primary->Polyline = update_message_Polyline;
2776 primary->MemBlt = update_message_MemBlt;
2777 primary->Mem3Blt = update_message_Mem3Blt;
2778 primary->SaveBitmap = update_message_SaveBitmap;
2779 primary->GlyphIndex = update_message_GlyphIndex;
2780 primary->FastIndex = update_message_FastIndex;
2781 primary->FastGlyph = update_message_FastGlyph;
2782 primary->PolygonSC = update_message_PolygonSC;
2783 primary->PolygonCB = update_message_PolygonCB;
2784 primary->EllipseSC = update_message_EllipseSC;
2785 primary->EllipseCB = update_message_EllipseCB;
2787 message->CacheBitmap = secondary->CacheBitmap;
2788 message->CacheBitmapV2 = secondary->CacheBitmapV2;
2789 message->CacheBitmapV3 = secondary->CacheBitmapV3;
2790 message->CacheColorTable = secondary->CacheColorTable;
2791 message->CacheGlyph = secondary->CacheGlyph;
2792 message->CacheGlyphV2 = secondary->CacheGlyphV2;
2793 message->CacheBrush = secondary->CacheBrush;
2794 secondary->CacheBitmap = update_message_CacheBitmap;
2795 secondary->CacheBitmapV2 = update_message_CacheBitmapV2;
2796 secondary->CacheBitmapV3 = update_message_CacheBitmapV3;
2797 secondary->CacheColorTable = update_message_CacheColorTable;
2798 secondary->CacheGlyph = update_message_CacheGlyph;
2799 secondary->CacheGlyphV2 = update_message_CacheGlyphV2;
2800 secondary->CacheBrush = update_message_CacheBrush;
2802 message->CreateOffscreenBitmap = altsec->CreateOffscreenBitmap;
2803 message->SwitchSurface = altsec->SwitchSurface;
2804 message->CreateNineGridBitmap = altsec->CreateNineGridBitmap;
2805 message->FrameMarker = altsec->FrameMarker;
2806 message->StreamBitmapFirst = altsec->StreamBitmapFirst;
2807 message->StreamBitmapNext = altsec->StreamBitmapNext;
2808 message->DrawGdiPlusFirst = altsec->DrawGdiPlusFirst;
2809 message->DrawGdiPlusNext = altsec->DrawGdiPlusNext;
2810 message->DrawGdiPlusEnd = altsec->DrawGdiPlusEnd;
2811 message->DrawGdiPlusCacheFirst = altsec->DrawGdiPlusCacheFirst;
2812 message->DrawGdiPlusCacheNext = altsec->DrawGdiPlusCacheNext;
2813 message->DrawGdiPlusCacheEnd = altsec->DrawGdiPlusCacheEnd;
2814 altsec->CreateOffscreenBitmap = update_message_CreateOffscreenBitmap;
2815 altsec->SwitchSurface = update_message_SwitchSurface;
2816 altsec->CreateNineGridBitmap = update_message_CreateNineGridBitmap;
2817 altsec->FrameMarker = update_message_FrameMarker;
2818 altsec->StreamBitmapFirst = update_message_StreamBitmapFirst;
2819 altsec->StreamBitmapNext = update_message_StreamBitmapNext;
2820 altsec->DrawGdiPlusFirst = update_message_DrawGdiPlusFirst;
2821 altsec->DrawGdiPlusNext = update_message_DrawGdiPlusNext;
2822 altsec->DrawGdiPlusEnd = update_message_DrawGdiPlusEnd;
2823 altsec->DrawGdiPlusCacheFirst = update_message_DrawGdiPlusCacheFirst;
2824 altsec->DrawGdiPlusCacheNext = update_message_DrawGdiPlusCacheNext;
2825 altsec->DrawGdiPlusCacheEnd = update_message_DrawGdiPlusCacheEnd;
2827 message->WindowCreate = window->WindowCreate;
2828 message->WindowUpdate = window->WindowUpdate;
2829 message->WindowIcon = window->WindowIcon;
2830 message->WindowCachedIcon = window->WindowCachedIcon;
2831 message->WindowDelete = window->WindowDelete;
2832 message->NotifyIconCreate = window->NotifyIconCreate;
2833 message->NotifyIconUpdate = window->NotifyIconUpdate;
2834 message->NotifyIconDelete = window->NotifyIconDelete;
2835 message->MonitoredDesktop = window->MonitoredDesktop;
2836 message->NonMonitoredDesktop = window->NonMonitoredDesktop;
2837 window->WindowCreate = update_message_WindowCreate;
2838 window->WindowUpdate = update_message_WindowUpdate;
2839 window->WindowIcon = update_message_WindowIcon;
2840 window->WindowCachedIcon = update_message_WindowCachedIcon;
2841 window->WindowDelete = update_message_WindowDelete;
2842 window->NotifyIconCreate = update_message_NotifyIconCreate;
2843 window->NotifyIconUpdate = update_message_NotifyIconUpdate;
2844 window->NotifyIconDelete = update_message_NotifyIconDelete;
2845 window->MonitoredDesktop = update_message_MonitoredDesktop;
2846 window->NonMonitoredDesktop = update_message_NonMonitoredDesktop;
2848 message->PointerPosition = pointer->PointerPosition;
2849 message->PointerSystem = pointer->PointerSystem;
2850 message->PointerColor = pointer->PointerColor;
2851 message->PointerLarge = pointer->PointerLarge;
2852 message->PointerNew = pointer->PointerNew;
2853 message->PointerCached = pointer->PointerCached;
2854 pointer->PointerPosition = update_message_PointerPosition;
2855 pointer->PointerSystem = update_message_PointerSystem;
2856 pointer->PointerColor = update_message_PointerColor;
2857 pointer->PointerLarge = update_message_PointerLarge;
2858 pointer->PointerNew = update_message_PointerNew;
2859 pointer->PointerCached = update_message_PointerCached;
2863static DWORD WINAPI update_message_proxy_thread(LPVOID arg)
2865 rdpUpdate* update = (rdpUpdate*)arg;
2866 wMessage message = WINPR_C_ARRAY_INIT;
2869 while (MessageQueue_Wait(up->queue))
2873 if (MessageQueue_Peek(up->queue, &message, TRUE))
2874 status = update_message_queue_process_message(update, &message);
2884rdpUpdateProxy* update_message_proxy_new(rdpUpdate* update)
2886 rdpUpdateProxy* message =
nullptr;
2891 if (!(message = (rdpUpdateProxy*)calloc(1,
sizeof(rdpUpdateProxy))))
2894 message->update = update;
2895 update_message_register_interface(message, update);
2897 if (!(message->thread =
2898 CreateThread(
nullptr, 0, update_message_proxy_thread, update, 0,
nullptr)))
2900 WLog_ERR(TAG,
"Failed to create proxy thread");
2908void update_message_proxy_free(rdpUpdateProxy* message)
2913 if (MessageQueue_PostQuit(up->queue, 0))
2914 (void)WaitForSingleObject(message->thread, INFINITE);
2916 (void)CloseHandle(message->thread);
2922static int input_message_free_input_class(wMessage* msg,
int type)
2930 case Input_SynchronizeEvent:
2933 case Input_KeyboardEvent:
2936 case Input_UnicodeKeyboardEvent:
2939 case Input_MouseEvent:
2942 case Input_ExtendedMouseEvent:
2945 case Input_FocusInEvent:
2948 case Input_KeyboardPauseEvent:
2959static int input_message_process_input_class(rdpInputProxy* proxy, wMessage* msg,
int type)
2968 case Input_SynchronizeEvent:
2969 IFCALL(proxy->SynchronizeEvent, msg->context, (UINT32)(
size_t)msg->wParam);
2972 case Input_KeyboardEvent:
2973 IFCALL(proxy->KeyboardEvent, msg->context, (UINT16)(
size_t)msg->wParam,
2974 (UINT8)(
size_t)msg->lParam);
2977 case Input_UnicodeKeyboardEvent:
2978 IFCALL(proxy->UnicodeKeyboardEvent, msg->context, (UINT16)(
size_t)msg->wParam,
2979 (UINT16)(
size_t)msg->lParam);
2982 case Input_MouseEvent:
2987 pos = (UINT32)(
size_t)msg->lParam;
2988 x = ((pos & 0xFFFF0000) >> 16);
2989 y = (pos & 0x0000FFFF);
2990 IFCALL(proxy->MouseEvent, msg->context, (UINT16)(
size_t)msg->wParam, x, y);
2994 case Input_ExtendedMouseEvent:
2999 pos = (UINT32)(
size_t)msg->lParam;
3000 x = ((pos & 0xFFFF0000) >> 16);
3001 y = (pos & 0x0000FFFF);
3002 IFCALL(proxy->ExtendedMouseEvent, msg->context, (UINT16)(
size_t)msg->wParam, x, y);
3006 case Input_FocusInEvent:
3007 IFCALL(proxy->FocusInEvent, msg->context, (UINT16)(
size_t)msg->wParam);
3010 case Input_KeyboardPauseEvent:
3011 IFCALL(proxy->KeyboardPauseEvent, msg->context);
3022static int input_message_free_class(wMessage* msg,
int msgClass,
int msgType)
3029 status = input_message_free_input_class(msg, msgType);
3038 WLog_ERR(TAG,
"Unknown event: class: %d type: %d", msgClass, msgType);
3043static int input_message_process_class(rdpInputProxy* proxy, wMessage* msg,
int msgClass,
3051 status = input_message_process_input_class(proxy, msg, msgType);
3060 WLog_ERR(TAG,
"Unknown event: class: %d type: %d", msgClass, msgType);
3065int input_message_queue_free_message(wMessage* message)
3074 if (message->id == WMQ_QUIT)
3077 msgClass = GetMessageClass(message->id);
3078 msgType = GetMessageType(message->id);
3079 status = input_message_free_class(message, msgClass, msgType);
3087int input_message_queue_process_message(rdpInput* input, wMessage* message)
3097 if (message->id == WMQ_QUIT)
3100 msgClass = GetMessageClass(message->id);
3101 msgType = GetMessageType(message->id);
3102 status = input_message_process_class(in->proxy, message, msgClass, msgType);
3103 input_message_free_class(message, msgClass, msgType);
3111int input_message_queue_process_pending_messages(rdpInput* input)
3114 wMessage message = WINPR_C_ARRAY_INIT;
3120 wMessageQueue* queue = in->queue;
3122 while (MessageQueue_Peek(queue, &message, TRUE))
3124 status = input_message_queue_process_message(input, &message);