22 #include <freerdp/config.h>
24 #include <winpr/assert.h>
28 #include "transport.h"
30 #include <freerdp/log.h>
31 #include <freerdp/freerdp.h>
33 #include <winpr/crt.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")
48 static 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), NULL,
60 static 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), NULL,
72 static BOOL update_message_SetBounds(rdpContext* context,
const rdpBounds* bounds)
74 rdpBounds* wParam = NULL;
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),
95 static 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), NULL,
107 static 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), NULL,
119 static 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, NULL);
137 static 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, NULL);
155 static 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, NULL);
175 static 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,
188 static 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)((imeId << 16UL) | imeState),
199 (
void*)(
size_t)imeConvMode);
202 static 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);
222 static 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);
245 static BOOL update_message_SurfaceCommand(rdpContext* context,
wStream* s)
250 if (!context || !context->update || !s)
253 wParam = Stream_New(NULL, 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, NULL);
266 static 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, NULL);
285 static 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, NULL);
306 static 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,
321 static 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, NULL);
341 static 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, NULL);
362 static 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, NULL);
382 static 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, NULL);
402 static 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, NULL);
423 static 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, NULL);
443 static 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, NULL);
464 static 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, NULL);
484 static 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, NULL);
505 static 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, NULL);
527 static BOOL update_message_LineTo(rdpContext* context,
const LINE_TO_ORDER* lineTo)
532 if (!context || !context->update || !lineTo)
542 up = update_cast(context->update);
543 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, LineTo),
544 (
void*)wParam, NULL);
547 static BOOL update_message_Polyline(rdpContext* context,
const POLYLINE_ORDER* polyline)
552 if (!context || !context->update || !polyline)
569 CopyMemory(wParam->points, polyline->points,
sizeof(
DELTA_POINT) * wParam->numDeltaEntries);
571 up = update_cast(context->update);
572 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, Polyline),
573 (
void*)wParam, NULL);
576 static BOOL update_message_MemBlt(rdpContext* context,
MEMBLT_ORDER* memBlt)
581 if (!context || !context->update || !memBlt)
591 up = update_cast(context->update);
592 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, MemBlt),
593 (
void*)wParam, NULL);
596 static BOOL update_message_Mem3Blt(rdpContext* context,
MEM3BLT_ORDER* mem3Blt)
601 if (!context || !context->update || !mem3Blt)
610 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
612 up = update_cast(context->update);
613 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, Mem3Blt),
614 (
void*)wParam, NULL);
617 static BOOL update_message_SaveBitmap(rdpContext* context,
const SAVE_BITMAP_ORDER* saveBitmap)
622 if (!context || !context->update || !saveBitmap)
632 up = update_cast(context->update);
633 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, SaveBitmap),
634 (
void*)wParam, NULL);
637 static BOOL update_message_GlyphIndex(rdpContext* context,
GLYPH_INDEX_ORDER* glyphIndex)
642 if (!context || !context->update || !glyphIndex)
651 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
653 up = update_cast(context->update);
654 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, GlyphIndex),
655 (
void*)wParam, NULL);
658 static BOOL update_message_FastIndex(rdpContext* context,
const FAST_INDEX_ORDER* fastIndex)
663 if (!context || !context->update || !fastIndex)
673 up = update_cast(context->update);
674 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, FastIndex),
675 (
void*)wParam, NULL);
678 static BOOL update_message_FastGlyph(rdpContext* context,
const FAST_GLYPH_ORDER* fastGlyph)
683 if (!context || !context->update || !fastGlyph)
693 if (wParam->cbData > 1)
695 wParam->glyphData.aj = (BYTE*)malloc(fastGlyph->glyphData.cb);
697 if (!wParam->glyphData.aj)
703 CopyMemory(wParam->glyphData.aj, fastGlyph->glyphData.aj, fastGlyph->glyphData.cb);
707 wParam->glyphData.aj = NULL;
710 up = update_cast(context->update);
711 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, FastGlyph),
712 (
void*)wParam, NULL);
715 static BOOL update_message_PolygonSC(rdpContext* context,
const POLYGON_SC_ORDER* polygonSC)
720 if (!context || !context->update || !polygonSC)
737 CopyMemory(wParam->points, polygonSC,
sizeof(
DELTA_POINT) * wParam->numPoints);
739 up = update_cast(context->update);
740 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, PolygonSC),
741 (
void*)wParam, NULL);
744 static BOOL update_message_PolygonCB(rdpContext* context,
POLYGON_CB_ORDER* polygonCB)
749 if (!context || !context->update || !polygonCB)
766 CopyMemory(wParam->points, polygonCB,
sizeof(
DELTA_POINT) * wParam->numPoints);
767 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
769 up = update_cast(context->update);
770 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, PolygonCB),
771 (
void*)wParam, NULL);
774 static BOOL update_message_EllipseSC(rdpContext* context,
const ELLIPSE_SC_ORDER* ellipseSC)
779 if (!context || !context->update || !ellipseSC)
789 up = update_cast(context->update);
790 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, EllipseSC),
791 (
void*)wParam, NULL);
794 static BOOL update_message_EllipseCB(rdpContext* context,
const ELLIPSE_CB_ORDER* ellipseCB)
799 if (!context || !context->update || !ellipseCB)
808 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
810 up = update_cast(context->update);
811 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PrimaryUpdate, EllipseCB),
812 (
void*)wParam, NULL);
817 static BOOL update_message_CacheBitmap(rdpContext* context,
823 if (!context || !context->update || !cacheBitmapOrder)
826 wParam = copy_cache_bitmap_order(context, cacheBitmapOrder);
831 up = update_cast(context->update);
832 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(SecondaryUpdate, CacheBitmap),
833 (
void*)wParam, NULL);
836 static BOOL update_message_CacheBitmapV2(rdpContext* context,
842 if (!context || !context->update || !cacheBitmapV2Order)
845 wParam = copy_cache_bitmap_v2_order(context, cacheBitmapV2Order);
850 up = update_cast(context->update);
851 return MessageQueue_Post(up->queue, (
void*)context,
852 MakeMessageId(SecondaryUpdate, CacheBitmapV2), (
void*)wParam, NULL);
855 static BOOL update_message_CacheBitmapV3(rdpContext* context,
861 if (!context || !context->update || !cacheBitmapV3Order)
864 wParam = copy_cache_bitmap_v3_order(context, cacheBitmapV3Order);
869 up = update_cast(context->update);
870 return MessageQueue_Post(up->queue, (
void*)context,
871 MakeMessageId(SecondaryUpdate, CacheBitmapV3), (
void*)wParam, NULL);
874 static BOOL update_message_CacheColorTable(rdpContext* context,
880 if (!context || !context->update || !cacheColorTableOrder)
883 wParam = copy_cache_color_table_order(context, cacheColorTableOrder);
888 up = update_cast(context->update);
889 return MessageQueue_Post(up->queue, (
void*)context,
890 MakeMessageId(SecondaryUpdate, CacheColorTable), (
void*)wParam, NULL);
893 static 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, NULL);
911 static 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, NULL);
930 static 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, NULL);
951 update_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,
985 static 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, NULL);
1007 update_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,
1029 static 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, NULL);
1049 static 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, NULL);
1071 static BOOL update_message_StreamBitmapNext(rdpContext* context,
1077 if (!context || !context->update || !streamBitmapNext)
1088 up = update_cast(context->update);
1089 return MessageQueue_Post(up->queue, (
void*)context,
1090 MakeMessageId(AltSecUpdate, StreamBitmapNext), (
void*)wParam, NULL);
1093 static BOOL update_message_DrawGdiPlusFirst(rdpContext* context,
1099 if (!context || !context->update || !drawGdiPlusFirst)
1109 up = update_cast(context->update);
1110 return MessageQueue_Post(up->queue, (
void*)context,
1111 MakeMessageId(AltSecUpdate, DrawGdiPlusFirst), (
void*)wParam, NULL);
1114 static BOOL update_message_DrawGdiPlusNext(rdpContext* context,
1120 if (!context || !context->update || !drawGdiPlusNext)
1131 up = update_cast(context->update);
1132 return MessageQueue_Post(up->queue, (
void*)context,
1133 MakeMessageId(AltSecUpdate, DrawGdiPlusNext), (
void*)wParam, NULL);
1136 static BOOL update_message_DrawGdiPlusEnd(rdpContext* context,
1142 if (!context || !context->update || !drawGdiPlusEnd)
1153 up = update_cast(context->update);
1154 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(AltSecUpdate, DrawGdiPlusEnd),
1155 (
void*)wParam, NULL);
1159 update_message_DrawGdiPlusCacheFirst(rdpContext* context,
1165 if (!context || !context->update || !drawGdiPlusCacheFirst)
1176 up = update_cast(context->update);
1177 return MessageQueue_Post(up->queue, (
void*)context,
1178 MakeMessageId(AltSecUpdate, DrawGdiPlusCacheFirst), (
void*)wParam,
1183 update_message_DrawGdiPlusCacheNext(rdpContext* context,
1189 if (!context || !context->update || !drawGdiPlusCacheNext)
1200 up = update_cast(context->update);
1201 return MessageQueue_Post(up->queue, (
void*)context,
1202 MakeMessageId(AltSecUpdate, DrawGdiPlusCacheNext), (
void*)wParam,
1207 update_message_DrawGdiPlusCacheEnd(rdpContext* context,
1213 if (!context || !context->update || !drawGdiPlusCacheEnd)
1224 up = update_cast(context->update);
1225 return MessageQueue_Post(up->queue, (
void*)context,
1226 MakeMessageId(AltSecUpdate, DrawGdiPlusCacheEnd), (
void*)wParam, NULL);
1231 static BOOL update_message_WindowCreate(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1238 if (!context || !context->update || !orderInfo || !windowState)
1257 up = update_cast(context->update);
1258 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(WindowUpdate, WindowCreate),
1259 (
void*)wParam, (
void*)lParam);
1262 static BOOL update_message_WindowUpdate(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1269 if (!context || !context->update || !orderInfo || !windowState)
1288 up = update_cast(context->update);
1289 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(WindowUpdate, WindowUpdate),
1290 (
void*)wParam, (
void*)lParam);
1293 static BOOL update_message_WindowIcon(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1300 if (!context || !context->update || !orderInfo || !windowIcon)
1314 lParam->iconInfo = calloc(1,
sizeof(
ICON_INFO));
1316 if (!lParam->iconInfo)
1320 WLog_VRB(TAG,
"update_message_WindowIcon");
1322 if (windowIcon->iconInfo->cbBitsColor > 0)
1324 lParam->iconInfo->bitsColor = (BYTE*)malloc(windowIcon->iconInfo->cbBitsColor);
1326 if (!lParam->iconInfo->bitsColor)
1329 CopyMemory(lParam->iconInfo->bitsColor, windowIcon->iconInfo->bitsColor,
1330 windowIcon->iconInfo->cbBitsColor);
1333 if (windowIcon->iconInfo->cbBitsMask > 0)
1335 lParam->iconInfo->bitsMask = (BYTE*)malloc(windowIcon->iconInfo->cbBitsMask);
1337 if (!lParam->iconInfo->bitsMask)
1340 CopyMemory(lParam->iconInfo->bitsMask, windowIcon->iconInfo->bitsMask,
1341 windowIcon->iconInfo->cbBitsMask);
1344 if (windowIcon->iconInfo->cbColorTable > 0)
1346 lParam->iconInfo->colorTable = (BYTE*)malloc(windowIcon->iconInfo->cbColorTable);
1348 if (!lParam->iconInfo->colorTable)
1351 CopyMemory(lParam->iconInfo->colorTable, windowIcon->iconInfo->colorTable,
1352 windowIcon->iconInfo->cbColorTable);
1355 up = update_cast(context->update);
1356 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(WindowUpdate, WindowIcon),
1357 (
void*)wParam, (
void*)lParam);
1360 if (lParam && lParam->iconInfo)
1362 free(lParam->iconInfo->bitsColor);
1363 free(lParam->iconInfo->bitsMask);
1364 free(lParam->iconInfo->colorTable);
1365 free(lParam->iconInfo);
1373 static BOOL update_message_WindowCachedIcon(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1380 if (!context || !context->update || !orderInfo || !windowCachedIcon)
1399 up = update_cast(context->update);
1400 return MessageQueue_Post(up->queue, (
void*)context,
1401 MakeMessageId(WindowUpdate, WindowCachedIcon), (
void*)wParam,
1405 static BOOL update_message_WindowDelete(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo)
1410 if (!context || !context->update || !orderInfo)
1420 up = update_cast(context->update);
1421 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(WindowUpdate, WindowDelete),
1422 (
void*)wParam, NULL);
1425 static BOOL update_message_NotifyIconCreate(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1432 if (!context || !context->update || !orderInfo || !notifyIconState)
1451 up = update_cast(context->update);
1452 return MessageQueue_Post(up->queue, (
void*)context,
1453 MakeMessageId(WindowUpdate, NotifyIconCreate), (
void*)wParam,
1457 static BOOL update_message_NotifyIconUpdate(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1464 if (!context || !context->update || !orderInfo || !notifyIconState)
1483 up = update_cast(context->update);
1484 return MessageQueue_Post(up->queue, (
void*)context,
1485 MakeMessageId(WindowUpdate, NotifyIconUpdate), (
void*)wParam,
1489 static BOOL update_message_NotifyIconDelete(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo)
1494 if (!context || !context->update || !orderInfo)
1504 up = update_cast(context->update);
1505 return MessageQueue_Post(up->queue, (
void*)context,
1506 MakeMessageId(WindowUpdate, NotifyIconDelete), (
void*)wParam, NULL);
1509 static BOOL update_message_MonitoredDesktop(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1516 if (!context || !context->update || !orderInfo || !monitoredDesktop)
1534 lParam->windowIds = NULL;
1536 if (lParam->numWindowIds)
1538 lParam->windowIds = (UINT32*)calloc(lParam->numWindowIds,
sizeof(UINT32));
1539 CopyMemory(lParam->windowIds, monitoredDesktop->windowIds, lParam->numWindowIds);
1542 up = update_cast(context->update);
1543 return MessageQueue_Post(up->queue, (
void*)context,
1544 MakeMessageId(WindowUpdate, MonitoredDesktop), (
void*)wParam,
1548 static BOOL update_message_NonMonitoredDesktop(rdpContext* context,
1554 if (!context || !context->update || !orderInfo)
1564 up = update_cast(context->update);
1565 return MessageQueue_Post(up->queue, (
void*)context,
1566 MakeMessageId(WindowUpdate, NonMonitoredDesktop), (
void*)wParam, NULL);
1571 static BOOL update_message_PointerPosition(rdpContext* context,
1577 if (!context || !context->update || !pointerPosition)
1580 wParam = copy_pointer_position_update(context, pointerPosition);
1585 up = update_cast(context->update);
1586 return MessageQueue_Post(up->queue, (
void*)context,
1587 MakeMessageId(PointerUpdate, PointerPosition), (
void*)wParam, NULL);
1590 static BOOL update_message_PointerSystem(rdpContext* context,
1596 if (!context || !context->update || !pointerSystem)
1599 wParam = copy_pointer_system_update(context, pointerSystem);
1604 up = update_cast(context->update);
1605 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerSystem),
1606 (
void*)wParam, NULL);
1609 static BOOL update_message_PointerColor(rdpContext* context,
1615 if (!context || !context->update || !pointerColor)
1618 wParam = copy_pointer_color_update(context, pointerColor);
1623 up = update_cast(context->update);
1624 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerColor),
1625 (
void*)wParam, NULL);
1628 static BOOL update_message_PointerLarge(rdpContext* context,
const POINTER_LARGE_UPDATE* pointer)
1633 if (!context || !context->update || !pointer)
1636 wParam = copy_pointer_large_update(context, pointer);
1641 up = update_cast(context->update);
1642 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerLarge),
1643 (
void*)wParam, NULL);
1646 static BOOL update_message_PointerNew(rdpContext* context,
const POINTER_NEW_UPDATE* pointerNew)
1651 if (!context || !context->update || !pointerNew)
1654 wParam = copy_pointer_new_update(context, pointerNew);
1659 up = update_cast(context->update);
1660 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerNew),
1661 (
void*)wParam, NULL);
1664 static BOOL update_message_PointerCached(rdpContext* context,
1670 if (!context || !context->update || !pointerCached)
1673 wParam = copy_pointer_cached_update(context, pointerCached);
1678 up = update_cast(context->update);
1679 return MessageQueue_Post(up->queue, (
void*)context, MakeMessageId(PointerUpdate, PointerCached),
1680 (
void*)wParam, NULL);
1684 static BOOL update_message_free_update_class(wMessage* msg,
int type)
1686 rdpContext* context = NULL;
1691 context = (rdpContext*)msg->context;
1695 case Update_BeginPaint:
1698 case Update_EndPaint:
1701 case Update_SetBounds:
1705 case Update_Synchronize:
1708 case Update_DesktopResize:
1711 case Update_BitmapUpdate:
1714 free_bitmap_update(context, wParam);
1718 case Update_Palette:
1721 free_palette_update(context, palette);
1725 case Update_PlaySound:
1729 case Update_RefreshRect:
1733 case Update_SuppressOutput:
1737 case Update_SurfaceCommand:
1740 Stream_Free(s, TRUE);
1744 case Update_SurfaceBits:
1747 free_surface_bits_command(context, wParam);
1751 case Update_SurfaceFrameMarker:
1755 case Update_SurfaceFrameAcknowledge:
1756 case Update_SetKeyboardIndicators:
1757 case Update_SetKeyboardImeStatus:
1767 static BOOL update_message_process_update_class(rdpUpdateProxy* proxy, wMessage* msg,
int type)
1776 case Update_BeginPaint:
1777 rc = IFCALLRESULT(TRUE, proxy->BeginPaint, msg->context);
1780 case Update_EndPaint:
1781 rc = IFCALLRESULT(TRUE, proxy->EndPaint, msg->context);
1784 case Update_SetBounds:
1785 rc = IFCALLRESULT(TRUE, proxy->SetBounds, msg->context, (rdpBounds*)msg->wParam);
1788 case Update_Synchronize:
1789 rc = IFCALLRESULT(TRUE, proxy->Synchronize, msg->context);
1792 case Update_DesktopResize:
1793 rc = IFCALLRESULT(TRUE, proxy->DesktopResize, msg->context);
1796 case Update_BitmapUpdate:
1797 rc = IFCALLRESULT(TRUE, proxy->BitmapUpdate, msg->context, (
BITMAP_UPDATE*)msg->wParam);
1800 case Update_Palette:
1801 rc = IFCALLRESULT(TRUE, proxy->Palette, msg->context, (
PALETTE_UPDATE*)msg->wParam);
1804 case Update_PlaySound:
1806 IFCALLRESULT(TRUE, proxy->PlaySound, msg->context, (
PLAY_SOUND_UPDATE*)msg->wParam);
1809 case Update_RefreshRect:
1810 rc = IFCALLRESULT(TRUE, proxy->RefreshRect, msg->context, (BYTE)(
size_t)msg->wParam,
1814 case Update_SuppressOutput:
1815 rc = IFCALLRESULT(TRUE, proxy->SuppressOutput, msg->context, (BYTE)(
size_t)msg->wParam,
1819 case Update_SurfaceCommand:
1820 rc = IFCALLRESULT(TRUE, proxy->SurfaceCommand, msg->context, (
wStream*)msg->wParam);
1823 case Update_SurfaceBits:
1824 rc = IFCALLRESULT(TRUE, proxy->SurfaceBits, msg->context,
1828 case Update_SurfaceFrameMarker:
1829 rc = IFCALLRESULT(TRUE, proxy->SurfaceFrameMarker, msg->context,
1833 case Update_SurfaceFrameAcknowledge:
1834 rc = IFCALLRESULT(TRUE, proxy->SurfaceFrameAcknowledge, msg->context,
1835 (UINT32)(
size_t)msg->wParam);
1838 case Update_SetKeyboardIndicators:
1839 rc = IFCALLRESULT(TRUE, proxy->SetKeyboardIndicators, msg->context,
1840 (UINT16)(
size_t)msg->wParam);
1843 case Update_SetKeyboardImeStatus:
1845 const UINT16 imeId = ((size_t)msg->wParam) >> 16 & 0xFFFF;
1846 const UINT32 imeState = ((size_t)msg->wParam) & 0xFFFF;
1847 const UINT32 imeConvMode = ((size_t)msg->lParam) & 0xFFFFFFFFUL;
1848 rc = IFCALLRESULT(TRUE, proxy->SetKeyboardImeStatus, msg->context, imeId, imeState,
1860 static BOOL update_message_free_primary_update_class(wMessage* msg,
int type)
1867 case PrimaryUpdate_DstBlt:
1871 case PrimaryUpdate_PatBlt:
1875 case PrimaryUpdate_ScrBlt:
1879 case PrimaryUpdate_OpaqueRect:
1883 case PrimaryUpdate_DrawNineGrid:
1887 case PrimaryUpdate_MultiDstBlt:
1891 case PrimaryUpdate_MultiPatBlt:
1895 case PrimaryUpdate_MultiScrBlt:
1899 case PrimaryUpdate_MultiOpaqueRect:
1903 case PrimaryUpdate_MultiDrawNineGrid:
1907 case PrimaryUpdate_LineTo:
1911 case PrimaryUpdate_Polyline:
1914 free(wParam->points);
1919 case PrimaryUpdate_MemBlt:
1923 case PrimaryUpdate_Mem3Blt:
1927 case PrimaryUpdate_SaveBitmap:
1931 case PrimaryUpdate_GlyphIndex:
1935 case PrimaryUpdate_FastIndex:
1939 case PrimaryUpdate_FastGlyph:
1942 free(wParam->glyphData.aj);
1947 case PrimaryUpdate_PolygonSC:
1950 free(wParam->points);
1955 case PrimaryUpdate_PolygonCB:
1958 free(wParam->points);
1963 case PrimaryUpdate_EllipseSC:
1967 case PrimaryUpdate_EllipseCB:
1978 static BOOL update_message_process_primary_update_class(rdpUpdateProxy* proxy, wMessage* msg,
1986 case PrimaryUpdate_DstBlt:
1987 return IFCALLRESULT(TRUE, proxy->DstBlt, msg->context, (
DSTBLT_ORDER*)msg->wParam);
1989 case PrimaryUpdate_PatBlt:
1990 return IFCALLRESULT(TRUE, proxy->PatBlt, msg->context, (
PATBLT_ORDER*)msg->wParam);
1992 case PrimaryUpdate_ScrBlt:
1993 return IFCALLRESULT(TRUE, proxy->ScrBlt, msg->context, (
SCRBLT_ORDER*)msg->wParam);
1995 case PrimaryUpdate_OpaqueRect:
1996 return IFCALLRESULT(TRUE, proxy->OpaqueRect, msg->context,
1999 case PrimaryUpdate_DrawNineGrid:
2000 return IFCALLRESULT(TRUE, proxy->DrawNineGrid, msg->context,
2003 case PrimaryUpdate_MultiDstBlt:
2004 return IFCALLRESULT(TRUE, proxy->MultiDstBlt, msg->context,
2007 case PrimaryUpdate_MultiPatBlt:
2008 return IFCALLRESULT(TRUE, proxy->MultiPatBlt, msg->context,
2011 case PrimaryUpdate_MultiScrBlt:
2012 return IFCALLRESULT(TRUE, proxy->MultiScrBlt, msg->context,
2015 case PrimaryUpdate_MultiOpaqueRect:
2016 return IFCALLRESULT(TRUE, proxy->MultiOpaqueRect, msg->context,
2019 case PrimaryUpdate_MultiDrawNineGrid:
2020 return IFCALLRESULT(TRUE, proxy->MultiDrawNineGrid, msg->context,
2023 case PrimaryUpdate_LineTo:
2024 return IFCALLRESULT(TRUE, proxy->LineTo, msg->context, (
LINE_TO_ORDER*)msg->wParam);
2026 case PrimaryUpdate_Polyline:
2027 return IFCALLRESULT(TRUE, proxy->Polyline, msg->context, (
POLYLINE_ORDER*)msg->wParam);
2029 case PrimaryUpdate_MemBlt:
2030 return IFCALLRESULT(TRUE, proxy->MemBlt, msg->context, (
MEMBLT_ORDER*)msg->wParam);
2032 case PrimaryUpdate_Mem3Blt:
2033 return IFCALLRESULT(TRUE, proxy->Mem3Blt, msg->context, (
MEM3BLT_ORDER*)msg->wParam);
2035 case PrimaryUpdate_SaveBitmap:
2036 return IFCALLRESULT(TRUE, proxy->SaveBitmap, msg->context,
2039 case PrimaryUpdate_GlyphIndex:
2040 return IFCALLRESULT(TRUE, proxy->GlyphIndex, msg->context,
2043 case PrimaryUpdate_FastIndex:
2044 return IFCALLRESULT(TRUE, proxy->FastIndex, msg->context,
2047 case PrimaryUpdate_FastGlyph:
2048 return IFCALLRESULT(TRUE, proxy->FastGlyph, msg->context,
2051 case PrimaryUpdate_PolygonSC:
2052 return IFCALLRESULT(TRUE, proxy->PolygonSC, msg->context,
2055 case PrimaryUpdate_PolygonCB:
2056 return IFCALLRESULT(TRUE, proxy->PolygonCB, msg->context,
2059 case PrimaryUpdate_EllipseSC:
2060 return IFCALLRESULT(TRUE, proxy->EllipseSC, msg->context,
2063 case PrimaryUpdate_EllipseCB:
2064 return IFCALLRESULT(TRUE, proxy->EllipseCB, msg->context,
2072 static BOOL update_message_free_secondary_update_class(wMessage* msg,
int type)
2074 rdpContext* context = NULL;
2079 context = msg->context;
2083 case SecondaryUpdate_CacheBitmap:
2086 free_cache_bitmap_order(context, wParam);
2090 case SecondaryUpdate_CacheBitmapV2:
2093 free_cache_bitmap_v2_order(context, wParam);
2097 case SecondaryUpdate_CacheBitmapV3:
2100 free_cache_bitmap_v3_order(context, wParam);
2104 case SecondaryUpdate_CacheColorTable:
2107 free_cache_color_table_order(context, wParam);
2111 case SecondaryUpdate_CacheGlyph:
2114 free_cache_glyph_order(context, wParam);
2118 case SecondaryUpdate_CacheGlyphV2:
2121 free_cache_glyph_v2_order(context, wParam);
2125 case SecondaryUpdate_CacheBrush:
2128 free_cache_brush_order(context, wParam);
2139 static BOOL update_message_process_secondary_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2147 case SecondaryUpdate_CacheBitmap:
2148 return IFCALLRESULT(TRUE, proxy->CacheBitmap, msg->context,
2151 case SecondaryUpdate_CacheBitmapV2:
2152 return IFCALLRESULT(TRUE, proxy->CacheBitmapV2, msg->context,
2155 case SecondaryUpdate_CacheBitmapV3:
2156 return IFCALLRESULT(TRUE, proxy->CacheBitmapV3, msg->context,
2159 case SecondaryUpdate_CacheColorTable:
2160 return IFCALLRESULT(TRUE, proxy->CacheColorTable, msg->context,
2163 case SecondaryUpdate_CacheGlyph:
2164 return IFCALLRESULT(TRUE, proxy->CacheGlyph, msg->context,
2167 case SecondaryUpdate_CacheGlyphV2:
2168 return IFCALLRESULT(TRUE, proxy->CacheGlyphV2, msg->context,
2171 case SecondaryUpdate_CacheBrush:
2172 return IFCALLRESULT(TRUE, proxy->CacheBrush, msg->context,
2180 static BOOL update_message_free_altsec_update_class(wMessage* msg,
int type)
2187 case AltSecUpdate_CreateOffscreenBitmap:
2190 free(wParam->deleteList.indices);
2195 case AltSecUpdate_SwitchSurface:
2199 case AltSecUpdate_CreateNineGridBitmap:
2203 case AltSecUpdate_FrameMarker:
2207 case AltSecUpdate_StreamBitmapFirst:
2211 case AltSecUpdate_StreamBitmapNext:
2215 case AltSecUpdate_DrawGdiPlusFirst:
2219 case AltSecUpdate_DrawGdiPlusNext:
2223 case AltSecUpdate_DrawGdiPlusEnd:
2227 case AltSecUpdate_DrawGdiPlusCacheFirst:
2231 case AltSecUpdate_DrawGdiPlusCacheNext:
2235 case AltSecUpdate_DrawGdiPlusCacheEnd:
2246 static BOOL update_message_process_altsec_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2254 case AltSecUpdate_CreateOffscreenBitmap:
2255 return IFCALLRESULT(TRUE, proxy->CreateOffscreenBitmap, msg->context,
2258 case AltSecUpdate_SwitchSurface:
2259 return IFCALLRESULT(TRUE, proxy->SwitchSurface, msg->context,
2262 case AltSecUpdate_CreateNineGridBitmap:
2263 return IFCALLRESULT(TRUE, proxy->CreateNineGridBitmap, msg->context,
2266 case AltSecUpdate_FrameMarker:
2267 return IFCALLRESULT(TRUE, proxy->FrameMarker, msg->context,
2270 case AltSecUpdate_StreamBitmapFirst:
2271 return IFCALLRESULT(TRUE, proxy->StreamBitmapFirst, msg->context,
2274 case AltSecUpdate_StreamBitmapNext:
2275 return IFCALLRESULT(TRUE, proxy->StreamBitmapNext, msg->context,
2278 case AltSecUpdate_DrawGdiPlusFirst:
2279 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusFirst, msg->context,
2282 case AltSecUpdate_DrawGdiPlusNext:
2283 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusNext, msg->context,
2286 case AltSecUpdate_DrawGdiPlusEnd:
2287 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusEnd, msg->context,
2290 case AltSecUpdate_DrawGdiPlusCacheFirst:
2291 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusCacheFirst, msg->context,
2294 case AltSecUpdate_DrawGdiPlusCacheNext:
2295 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusCacheNext, msg->context,
2298 case AltSecUpdate_DrawGdiPlusCacheEnd:
2299 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusCacheEnd, msg->context,
2307 static BOOL update_message_free_window_update_class(wMessage* msg,
int type)
2314 case WindowUpdate_WindowCreate:
2319 case WindowUpdate_WindowUpdate:
2324 case WindowUpdate_WindowIcon:
2329 if (windowIcon->iconInfo->cbBitsColor > 0)
2331 free(windowIcon->iconInfo->bitsColor);
2334 if (windowIcon->iconInfo->cbBitsMask > 0)
2336 free(windowIcon->iconInfo->bitsMask);
2339 if (windowIcon->iconInfo->cbColorTable > 0)
2341 free(windowIcon->iconInfo->colorTable);
2345 free(windowIcon->iconInfo);
2350 case WindowUpdate_WindowCachedIcon:
2355 case WindowUpdate_WindowDelete:
2359 case WindowUpdate_NotifyIconCreate:
2364 case WindowUpdate_NotifyIconUpdate:
2369 case WindowUpdate_NotifyIconDelete:
2373 case WindowUpdate_MonitoredDesktop:
2377 free(lParam->windowIds);
2382 case WindowUpdate_NonMonitoredDesktop:
2393 static BOOL update_message_process_window_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2401 case WindowUpdate_WindowCreate:
2402 return IFCALLRESULT(TRUE, proxy->WindowCreate, msg->context,
2405 case WindowUpdate_WindowUpdate:
2406 return IFCALLRESULT(TRUE, proxy->WindowCreate, msg->context,
2409 case WindowUpdate_WindowIcon:
2413 return IFCALLRESULT(TRUE, proxy->WindowIcon, msg->context, orderInfo, windowIcon);
2416 case WindowUpdate_WindowCachedIcon:
2417 return IFCALLRESULT(TRUE, proxy->WindowCachedIcon, msg->context,
2421 case WindowUpdate_WindowDelete:
2422 return IFCALLRESULT(TRUE, proxy->WindowDelete, msg->context,
2425 case WindowUpdate_NotifyIconCreate:
2426 return IFCALLRESULT(TRUE, proxy->NotifyIconCreate, msg->context,
2430 case WindowUpdate_NotifyIconUpdate:
2431 return IFCALLRESULT(TRUE, proxy->NotifyIconUpdate, msg->context,
2435 case WindowUpdate_NotifyIconDelete:
2436 return IFCALLRESULT(TRUE, proxy->NotifyIconDelete, msg->context,
2439 case WindowUpdate_MonitoredDesktop:
2440 return IFCALLRESULT(TRUE, proxy->MonitoredDesktop, msg->context,
2444 case WindowUpdate_NonMonitoredDesktop:
2445 return IFCALLRESULT(TRUE, proxy->NonMonitoredDesktop, msg->context,
2453 static BOOL update_message_free_pointer_update_class(wMessage* msg,
int type)
2455 rdpContext* context = NULL;
2460 context = msg->context;
2464 case PointerUpdate_PointerPosition:
2467 free_pointer_position_update(context, wParam);
2471 case PointerUpdate_PointerSystem:
2474 free_pointer_system_update(context, wParam);
2478 case PointerUpdate_PointerCached:
2481 free_pointer_cached_update(context, wParam);
2485 case PointerUpdate_PointerColor:
2488 free_pointer_color_update(context, wParam);
2492 case PointerUpdate_PointerNew:
2495 free_pointer_new_update(context, wParam);
2506 static BOOL update_message_process_pointer_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2514 case PointerUpdate_PointerPosition:
2515 return IFCALLRESULT(TRUE, proxy->PointerPosition, msg->context,
2518 case PointerUpdate_PointerSystem:
2519 return IFCALLRESULT(TRUE, proxy->PointerSystem, msg->context,
2522 case PointerUpdate_PointerColor:
2523 return IFCALLRESULT(TRUE, proxy->PointerColor, msg->context,
2526 case PointerUpdate_PointerNew:
2527 return IFCALLRESULT(TRUE, proxy->PointerNew, msg->context,
2530 case PointerUpdate_PointerCached:
2531 return IFCALLRESULT(TRUE, proxy->PointerCached, msg->context,
2539 static BOOL update_message_free_class(wMessage* msg,
int msgClass,
int msgType)
2541 BOOL status = FALSE;
2546 status = update_message_free_update_class(msg, msgType);
2549 case PrimaryUpdate_Class:
2550 status = update_message_free_primary_update_class(msg, msgType);
2553 case SecondaryUpdate_Class:
2554 status = update_message_free_secondary_update_class(msg, msgType);
2557 case AltSecUpdate_Class:
2558 status = update_message_free_altsec_update_class(msg, msgType);
2561 case WindowUpdate_Class:
2562 status = update_message_free_window_update_class(msg, msgType);
2565 case PointerUpdate_Class:
2566 status = update_message_free_pointer_update_class(msg, msgType);
2574 WLog_ERR(TAG,
"Unknown message: class: %d type: %d", msgClass, msgType);
2579 static int update_message_process_class(rdpUpdateProxy* proxy, wMessage* msg,
int msgClass,
2582 BOOL status = FALSE;
2587 status = update_message_process_update_class(proxy, msg, msgType);
2590 case PrimaryUpdate_Class:
2591 status = update_message_process_primary_update_class(proxy, msg, msgType);
2594 case SecondaryUpdate_Class:
2595 status = update_message_process_secondary_update_class(proxy, msg, msgType);
2598 case AltSecUpdate_Class:
2599 status = update_message_process_altsec_update_class(proxy, msg, msgType);
2602 case WindowUpdate_Class:
2603 status = update_message_process_window_update_class(proxy, msg, msgType);
2606 case PointerUpdate_Class:
2607 status = update_message_process_pointer_update_class(proxy, msg, msgType);
2617 WLog_ERR(TAG,
"message: class: %d type: %d failed", msgClass, msgType);
2624 int update_message_queue_process_message(rdpUpdate* update, wMessage* message)
2631 if (!update || !message)
2634 if (message->id == WMQ_QUIT)
2637 msgClass = GetMessageClass(message->id);
2638 msgType = GetMessageType(message->id);
2639 status = update_message_process_class(up->proxy, message, msgClass, msgType);
2640 update_message_free_class(message, msgClass, msgType);
2648 int update_message_queue_free_message(wMessage* message)
2656 if (message->id == WMQ_QUIT)
2659 msgClass = GetMessageClass(message->id);
2660 msgType = GetMessageType(message->id);
2661 return update_message_free_class(message, msgClass, msgType);
2664 int update_message_queue_process_pending_messages(rdpUpdate* update)
2667 wMessage message = { 0 };
2670 wMessageQueue* queue = up->queue;
2672 while (MessageQueue_Peek(queue, &message, TRUE))
2674 status = update_message_queue_process_message(update, &message);
2683 static BOOL update_message_register_interface(rdpUpdateProxy* message, rdpUpdate* update)
2685 rdpPrimaryUpdate* primary = NULL;
2686 rdpSecondaryUpdate* secondary = NULL;
2687 rdpAltSecUpdate* altsec = NULL;
2688 rdpWindowUpdate* window = NULL;
2689 rdpPointerUpdate* pointer = NULL;
2691 if (!message || !update)
2694 primary = update->primary;
2695 secondary = update->secondary;
2696 altsec = update->altsec;
2697 window = update->window;
2698 pointer = update->pointer;
2700 if (!primary || !secondary || !altsec || !window || !pointer)
2704 message->BeginPaint = update->BeginPaint;
2705 message->EndPaint = update->EndPaint;
2706 message->SetBounds = update->SetBounds;
2707 message->Synchronize = update->Synchronize;
2708 message->DesktopResize = update->DesktopResize;
2709 message->BitmapUpdate = update->BitmapUpdate;
2710 message->Palette = update->Palette;
2711 message->PlaySound = update->PlaySound;
2712 message->SetKeyboardIndicators = update->SetKeyboardIndicators;
2713 message->SetKeyboardImeStatus = update->SetKeyboardImeStatus;
2714 message->RefreshRect = update->RefreshRect;
2715 message->SuppressOutput = update->SuppressOutput;
2716 message->SurfaceCommand = update->SurfaceCommand;
2717 message->SurfaceBits = update->SurfaceBits;
2718 message->SurfaceFrameMarker = update->SurfaceFrameMarker;
2719 message->SurfaceFrameAcknowledge = update->SurfaceFrameAcknowledge;
2720 update->BeginPaint = update_message_BeginPaint;
2721 update->EndPaint = update_message_EndPaint;
2722 update->SetBounds = update_message_SetBounds;
2723 update->Synchronize = update_message_Synchronize;
2724 update->DesktopResize = update_message_DesktopResize;
2725 update->BitmapUpdate = update_message_BitmapUpdate;
2726 update->Palette = update_message_Palette;
2727 update->PlaySound = update_message_PlaySound;
2728 update->SetKeyboardIndicators = update_message_SetKeyboardIndicators;
2729 update->SetKeyboardImeStatus = update_message_SetKeyboardImeStatus;
2730 update->RefreshRect = update_message_RefreshRect;
2731 update->SuppressOutput = update_message_SuppressOutput;
2732 update->SurfaceCommand = update_message_SurfaceCommand;
2733 update->SurfaceBits = update_message_SurfaceBits;
2734 update->SurfaceFrameMarker = update_message_SurfaceFrameMarker;
2735 update->SurfaceFrameAcknowledge = update_message_SurfaceFrameAcknowledge;
2737 message->DstBlt = primary->DstBlt;
2738 message->PatBlt = primary->PatBlt;
2739 message->ScrBlt = primary->ScrBlt;
2740 message->OpaqueRect = primary->OpaqueRect;
2741 message->DrawNineGrid = primary->DrawNineGrid;
2742 message->MultiDstBlt = primary->MultiDstBlt;
2743 message->MultiPatBlt = primary->MultiPatBlt;
2744 message->MultiScrBlt = primary->MultiScrBlt;
2745 message->MultiOpaqueRect = primary->MultiOpaqueRect;
2746 message->MultiDrawNineGrid = primary->MultiDrawNineGrid;
2747 message->LineTo = primary->LineTo;
2748 message->Polyline = primary->Polyline;
2749 message->MemBlt = primary->MemBlt;
2750 message->Mem3Blt = primary->Mem3Blt;
2751 message->SaveBitmap = primary->SaveBitmap;
2752 message->GlyphIndex = primary->GlyphIndex;
2753 message->FastIndex = primary->FastIndex;
2754 message->FastGlyph = primary->FastGlyph;
2755 message->PolygonSC = primary->PolygonSC;
2756 message->PolygonCB = primary->PolygonCB;
2757 message->EllipseSC = primary->EllipseSC;
2758 message->EllipseCB = primary->EllipseCB;
2759 primary->DstBlt = update_message_DstBlt;
2760 primary->PatBlt = update_message_PatBlt;
2761 primary->ScrBlt = update_message_ScrBlt;
2762 primary->OpaqueRect = update_message_OpaqueRect;
2763 primary->DrawNineGrid = update_message_DrawNineGrid;
2764 primary->MultiDstBlt = update_message_MultiDstBlt;
2765 primary->MultiPatBlt = update_message_MultiPatBlt;
2766 primary->MultiScrBlt = update_message_MultiScrBlt;
2767 primary->MultiOpaqueRect = update_message_MultiOpaqueRect;
2768 primary->MultiDrawNineGrid = update_message_MultiDrawNineGrid;
2769 primary->LineTo = update_message_LineTo;
2770 primary->Polyline = update_message_Polyline;
2771 primary->MemBlt = update_message_MemBlt;
2772 primary->Mem3Blt = update_message_Mem3Blt;
2773 primary->SaveBitmap = update_message_SaveBitmap;
2774 primary->GlyphIndex = update_message_GlyphIndex;
2775 primary->FastIndex = update_message_FastIndex;
2776 primary->FastGlyph = update_message_FastGlyph;
2777 primary->PolygonSC = update_message_PolygonSC;
2778 primary->PolygonCB = update_message_PolygonCB;
2779 primary->EllipseSC = update_message_EllipseSC;
2780 primary->EllipseCB = update_message_EllipseCB;
2782 message->CacheBitmap = secondary->CacheBitmap;
2783 message->CacheBitmapV2 = secondary->CacheBitmapV2;
2784 message->CacheBitmapV3 = secondary->CacheBitmapV3;
2785 message->CacheColorTable = secondary->CacheColorTable;
2786 message->CacheGlyph = secondary->CacheGlyph;
2787 message->CacheGlyphV2 = secondary->CacheGlyphV2;
2788 message->CacheBrush = secondary->CacheBrush;
2789 secondary->CacheBitmap = update_message_CacheBitmap;
2790 secondary->CacheBitmapV2 = update_message_CacheBitmapV2;
2791 secondary->CacheBitmapV3 = update_message_CacheBitmapV3;
2792 secondary->CacheColorTable = update_message_CacheColorTable;
2793 secondary->CacheGlyph = update_message_CacheGlyph;
2794 secondary->CacheGlyphV2 = update_message_CacheGlyphV2;
2795 secondary->CacheBrush = update_message_CacheBrush;
2797 message->CreateOffscreenBitmap = altsec->CreateOffscreenBitmap;
2798 message->SwitchSurface = altsec->SwitchSurface;
2799 message->CreateNineGridBitmap = altsec->CreateNineGridBitmap;
2800 message->FrameMarker = altsec->FrameMarker;
2801 message->StreamBitmapFirst = altsec->StreamBitmapFirst;
2802 message->StreamBitmapNext = altsec->StreamBitmapNext;
2803 message->DrawGdiPlusFirst = altsec->DrawGdiPlusFirst;
2804 message->DrawGdiPlusNext = altsec->DrawGdiPlusNext;
2805 message->DrawGdiPlusEnd = altsec->DrawGdiPlusEnd;
2806 message->DrawGdiPlusCacheFirst = altsec->DrawGdiPlusCacheFirst;
2807 message->DrawGdiPlusCacheNext = altsec->DrawGdiPlusCacheNext;
2808 message->DrawGdiPlusCacheEnd = altsec->DrawGdiPlusCacheEnd;
2809 altsec->CreateOffscreenBitmap = update_message_CreateOffscreenBitmap;
2810 altsec->SwitchSurface = update_message_SwitchSurface;
2811 altsec->CreateNineGridBitmap = update_message_CreateNineGridBitmap;
2812 altsec->FrameMarker = update_message_FrameMarker;
2813 altsec->StreamBitmapFirst = update_message_StreamBitmapFirst;
2814 altsec->StreamBitmapNext = update_message_StreamBitmapNext;
2815 altsec->DrawGdiPlusFirst = update_message_DrawGdiPlusFirst;
2816 altsec->DrawGdiPlusNext = update_message_DrawGdiPlusNext;
2817 altsec->DrawGdiPlusEnd = update_message_DrawGdiPlusEnd;
2818 altsec->DrawGdiPlusCacheFirst = update_message_DrawGdiPlusCacheFirst;
2819 altsec->DrawGdiPlusCacheNext = update_message_DrawGdiPlusCacheNext;
2820 altsec->DrawGdiPlusCacheEnd = update_message_DrawGdiPlusCacheEnd;
2822 message->WindowCreate = window->WindowCreate;
2823 message->WindowUpdate = window->WindowUpdate;
2824 message->WindowIcon = window->WindowIcon;
2825 message->WindowCachedIcon = window->WindowCachedIcon;
2826 message->WindowDelete = window->WindowDelete;
2827 message->NotifyIconCreate = window->NotifyIconCreate;
2828 message->NotifyIconUpdate = window->NotifyIconUpdate;
2829 message->NotifyIconDelete = window->NotifyIconDelete;
2830 message->MonitoredDesktop = window->MonitoredDesktop;
2831 message->NonMonitoredDesktop = window->NonMonitoredDesktop;
2832 window->WindowCreate = update_message_WindowCreate;
2833 window->WindowUpdate = update_message_WindowUpdate;
2834 window->WindowIcon = update_message_WindowIcon;
2835 window->WindowCachedIcon = update_message_WindowCachedIcon;
2836 window->WindowDelete = update_message_WindowDelete;
2837 window->NotifyIconCreate = update_message_NotifyIconCreate;
2838 window->NotifyIconUpdate = update_message_NotifyIconUpdate;
2839 window->NotifyIconDelete = update_message_NotifyIconDelete;
2840 window->MonitoredDesktop = update_message_MonitoredDesktop;
2841 window->NonMonitoredDesktop = update_message_NonMonitoredDesktop;
2843 message->PointerPosition = pointer->PointerPosition;
2844 message->PointerSystem = pointer->PointerSystem;
2845 message->PointerColor = pointer->PointerColor;
2846 message->PointerLarge = pointer->PointerLarge;
2847 message->PointerNew = pointer->PointerNew;
2848 message->PointerCached = pointer->PointerCached;
2849 pointer->PointerPosition = update_message_PointerPosition;
2850 pointer->PointerSystem = update_message_PointerSystem;
2851 pointer->PointerColor = update_message_PointerColor;
2852 pointer->PointerLarge = update_message_PointerLarge;
2853 pointer->PointerNew = update_message_PointerNew;
2854 pointer->PointerCached = update_message_PointerCached;
2858 static DWORD WINAPI update_message_proxy_thread(LPVOID arg)
2860 rdpUpdate* update = (rdpUpdate*)arg;
2861 wMessage message = { 0 };
2864 while (MessageQueue_Wait(up->queue))
2868 if (MessageQueue_Peek(up->queue, &message, TRUE))
2869 status = update_message_queue_process_message(update, &message);
2879 rdpUpdateProxy* update_message_proxy_new(rdpUpdate* update)
2881 rdpUpdateProxy* message = NULL;
2886 if (!(message = (rdpUpdateProxy*)calloc(1,
sizeof(rdpUpdateProxy))))
2889 message->update = update;
2890 update_message_register_interface(message, update);
2892 if (!(message->thread = CreateThread(NULL, 0, update_message_proxy_thread, update, 0, NULL)))
2894 WLog_ERR(TAG,
"Failed to create proxy thread");
2902 void update_message_proxy_free(rdpUpdateProxy* message)
2907 if (MessageQueue_PostQuit(up->queue, 0))
2908 (void)WaitForSingleObject(message->thread, INFINITE);
2910 (void)CloseHandle(message->thread);
2916 static int input_message_free_input_class(wMessage* msg,
int type)
2924 case Input_SynchronizeEvent:
2927 case Input_KeyboardEvent:
2930 case Input_UnicodeKeyboardEvent:
2933 case Input_MouseEvent:
2936 case Input_ExtendedMouseEvent:
2939 case Input_FocusInEvent:
2942 case Input_KeyboardPauseEvent:
2953 static int input_message_process_input_class(rdpInputProxy* proxy, wMessage* msg,
int type)
2962 case Input_SynchronizeEvent:
2963 IFCALL(proxy->SynchronizeEvent, msg->context, (UINT32)(
size_t)msg->wParam);
2966 case Input_KeyboardEvent:
2967 IFCALL(proxy->KeyboardEvent, msg->context, (UINT16)(
size_t)msg->wParam,
2968 (UINT8)(
size_t)msg->lParam);
2971 case Input_UnicodeKeyboardEvent:
2972 IFCALL(proxy->UnicodeKeyboardEvent, msg->context, (UINT16)(
size_t)msg->wParam,
2973 (UINT16)(
size_t)msg->lParam);
2976 case Input_MouseEvent:
2981 pos = (UINT32)(
size_t)msg->lParam;
2982 x = ((pos & 0xFFFF0000) >> 16);
2983 y = (pos & 0x0000FFFF);
2984 IFCALL(proxy->MouseEvent, msg->context, (UINT16)(
size_t)msg->wParam, x, y);
2988 case Input_ExtendedMouseEvent:
2993 pos = (UINT32)(
size_t)msg->lParam;
2994 x = ((pos & 0xFFFF0000) >> 16);
2995 y = (pos & 0x0000FFFF);
2996 IFCALL(proxy->ExtendedMouseEvent, msg->context, (UINT16)(
size_t)msg->wParam, x, y);
3000 case Input_FocusInEvent:
3001 IFCALL(proxy->FocusInEvent, msg->context, (UINT16)(
size_t)msg->wParam);
3004 case Input_KeyboardPauseEvent:
3005 IFCALL(proxy->KeyboardPauseEvent, msg->context);
3016 static int input_message_free_class(wMessage* msg,
int msgClass,
int msgType)
3023 status = input_message_free_input_class(msg, msgType);
3032 WLog_ERR(TAG,
"Unknown event: class: %d type: %d", msgClass, msgType);
3037 static int input_message_process_class(rdpInputProxy* proxy, wMessage* msg,
int msgClass,
3045 status = input_message_process_input_class(proxy, msg, msgType);
3054 WLog_ERR(TAG,
"Unknown event: class: %d type: %d", msgClass, msgType);
3059 int input_message_queue_free_message(wMessage* message)
3068 if (message->id == WMQ_QUIT)
3071 msgClass = GetMessageClass(message->id);
3072 msgType = GetMessageType(message->id);
3073 status = input_message_free_class(message, msgClass, msgType);
3081 int input_message_queue_process_message(rdpInput* input, wMessage* message)
3091 if (message->id == WMQ_QUIT)
3094 msgClass = GetMessageClass(message->id);
3095 msgType = GetMessageType(message->id);
3096 status = input_message_process_class(in->proxy, message, msgClass, msgType);
3097 input_message_free_class(message, msgClass, msgType);
3105 int input_message_queue_process_pending_messages(rdpInput* input)
3109 wMessage message = { 0 };
3110 wMessageQueue* queue = NULL;
3118 while (MessageQueue_Peek(queue, &message, TRUE))
3120 status = input_message_queue_process_message(input, &message);