FreeRDP
Loading...
Searching...
No Matches
message.c
1
22#include <freerdp/config.h>
23
24#include <winpr/assert.h>
25
26#include "rdp.h"
27#include "message.h"
28#include "transport.h"
29
30#include <freerdp/log.h>
31#include <freerdp/freerdp.h>
32
33#include <winpr/crt.h>
34#include <winpr/stream.h>
35#include <winpr/collections.h>
36
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"
43
44#define TAG FREERDP_TAG("core.message")
45
46/* Update */
47
48static BOOL update_message_BeginPaint(rdpContext* context)
49{
50 rdp_update_internal* up = nullptr;
51
52 if (!context || !context->update)
53 return FALSE;
54
55 up = update_cast(context->update);
56 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, BeginPaint), nullptr,
57 nullptr);
58}
59
60static BOOL update_message_EndPaint(rdpContext* context)
61{
62 rdp_update_internal* up = nullptr;
63
64 if (!context || !context->update)
65 return FALSE;
66
67 up = update_cast(context->update);
68 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, EndPaint), nullptr,
69 nullptr);
70}
71
72static BOOL update_message_SetBounds(rdpContext* context, const rdpBounds* bounds)
73{
74 rdpBounds* wParam = nullptr;
75 rdp_update_internal* up = nullptr;
76
77 if (!context || !context->update)
78 return FALSE;
79
80 if (bounds)
81 {
82 wParam = (rdpBounds*)malloc(sizeof(rdpBounds));
83
84 if (!wParam)
85 return FALSE;
86
87 CopyMemory(wParam, bounds, sizeof(rdpBounds));
88 }
89
90 up = update_cast(context->update);
91 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, SetBounds),
92 (void*)wParam, nullptr);
93}
94
95static BOOL update_message_Synchronize(rdpContext* context)
96{
97 rdp_update_internal* up = nullptr;
98
99 if (!context || !context->update)
100 return FALSE;
101
102 up = update_cast(context->update);
103 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, Synchronize), nullptr,
104 nullptr);
105}
106
107static BOOL update_message_DesktopResize(rdpContext* context)
108{
109 rdp_update_internal* up = nullptr;
110
111 if (!context || !context->update)
112 return FALSE;
113
114 up = update_cast(context->update);
115 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, DesktopResize),
116 nullptr, nullptr);
117}
118
119static BOOL update_message_BitmapUpdate(rdpContext* context, const BITMAP_UPDATE* bitmap)
120{
121 BITMAP_UPDATE* wParam = nullptr;
122 rdp_update_internal* up = nullptr;
123
124 if (!context || !context->update || !bitmap)
125 return FALSE;
126
127 wParam = copy_bitmap_update(context, bitmap);
128
129 if (!wParam)
130 return FALSE;
131
132 up = update_cast(context->update);
133 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, BitmapUpdate),
134 (void*)wParam, nullptr);
135}
136
137static BOOL update_message_Palette(rdpContext* context, const PALETTE_UPDATE* palette)
138{
139 PALETTE_UPDATE* wParam = nullptr;
140 rdp_update_internal* up = nullptr;
141
142 if (!context || !context->update || !palette)
143 return FALSE;
144
145 wParam = copy_palette_update(context, palette);
146
147 if (!wParam)
148 return FALSE;
149
150 up = update_cast(context->update);
151 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, Palette),
152 (void*)wParam, nullptr);
153}
154
155static BOOL update_message_PlaySound(rdpContext* context, const PLAY_SOUND_UPDATE* playSound)
156{
157 PLAY_SOUND_UPDATE* wParam = nullptr;
158 rdp_update_internal* up = nullptr;
159
160 if (!context || !context->update || !playSound)
161 return FALSE;
162
163 wParam = (PLAY_SOUND_UPDATE*)malloc(sizeof(PLAY_SOUND_UPDATE));
164
165 if (!wParam)
166 return FALSE;
167
168 CopyMemory(wParam, playSound, sizeof(PLAY_SOUND_UPDATE));
169
170 up = update_cast(context->update);
171 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, PlaySound),
172 (void*)wParam, nullptr);
173}
174
175static BOOL update_message_SetKeyboardIndicators(rdpContext* context, UINT16 led_flags)
176{
177 rdp_update_internal* up = nullptr;
178
179 if (!context || !context->update)
180 return FALSE;
181
182 up = update_cast(context->update);
183 return MessageQueue_Post(up->queue, (void*)context,
184 MakeMessageId(Update, SetKeyboardIndicators), (void*)(size_t)led_flags,
185 nullptr);
186}
187
188static BOOL update_message_SetKeyboardImeStatus(rdpContext* context, UINT16 imeId, UINT32 imeState,
189 UINT32 imeConvMode)
190{
191 rdp_update_internal* up = nullptr;
192
193 if (!context || !context->update)
194 return FALSE;
195
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);
200}
201
202static BOOL update_message_RefreshRect(rdpContext* context, BYTE count, const RECTANGLE_16* areas)
203{
204 RECTANGLE_16* lParam = nullptr;
205 rdp_update_internal* up = nullptr;
206
207 if (!context || !context->update || !areas)
208 return FALSE;
209
210 lParam = (RECTANGLE_16*)calloc(count, sizeof(RECTANGLE_16));
211
212 if (!lParam)
213 return FALSE;
214
215 CopyMemory(lParam, areas, sizeof(RECTANGLE_16) * count);
216
217 up = update_cast(context->update);
218 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, RefreshRect),
219 (void*)(size_t)count, (void*)lParam);
220}
221
222static BOOL update_message_SuppressOutput(rdpContext* context, BYTE allow, const RECTANGLE_16* area)
223{
224 RECTANGLE_16* lParam = nullptr;
225 rdp_update_internal* up = nullptr;
226
227 if (!context || !context->update)
228 return FALSE;
229
230 if (area)
231 {
232 lParam = (RECTANGLE_16*)malloc(sizeof(RECTANGLE_16));
233
234 if (!lParam)
235 return FALSE;
236
237 CopyMemory(lParam, area, sizeof(RECTANGLE_16));
238 }
239
240 up = update_cast(context->update);
241 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, SuppressOutput),
242 (void*)(size_t)allow, (void*)lParam);
243}
244
245static BOOL update_message_SurfaceCommand(rdpContext* context, wStream* s)
246{
247 wStream* wParam = nullptr;
248 rdp_update_internal* up = nullptr;
249
250 if (!context || !context->update || !s)
251 return FALSE;
252
253 wParam = Stream_New(nullptr, Stream_GetRemainingLength(s));
254
255 if (!wParam)
256 return FALSE;
257
258 Stream_Copy(s, wParam, Stream_GetRemainingLength(s));
259 Stream_SetPosition(wParam, 0);
260
261 up = update_cast(context->update);
262 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, SurfaceCommand),
263 (void*)wParam, nullptr);
264}
265
266static BOOL update_message_SurfaceBits(rdpContext* context,
267 const SURFACE_BITS_COMMAND* surfaceBitsCommand)
268{
269 SURFACE_BITS_COMMAND* wParam = nullptr;
270 rdp_update_internal* up = nullptr;
271
272 if (!context || !context->update || !surfaceBitsCommand)
273 return FALSE;
274
275 wParam = copy_surface_bits_command(context, surfaceBitsCommand);
276
277 if (!wParam)
278 return FALSE;
279
280 up = update_cast(context->update);
281 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, SurfaceBits),
282 (void*)wParam, nullptr);
283}
284
285static BOOL update_message_SurfaceFrameMarker(rdpContext* context,
286 const SURFACE_FRAME_MARKER* surfaceFrameMarker)
287{
288 SURFACE_FRAME_MARKER* wParam = nullptr;
289 rdp_update_internal* up = nullptr;
290
291 if (!context || !context->update || !surfaceFrameMarker)
292 return FALSE;
293
294 wParam = (SURFACE_FRAME_MARKER*)malloc(sizeof(SURFACE_FRAME_MARKER));
295
296 if (!wParam)
297 return FALSE;
298
299 CopyMemory(wParam, surfaceFrameMarker, sizeof(SURFACE_FRAME_MARKER));
300
301 up = update_cast(context->update);
302 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, SurfaceFrameMarker),
303 (void*)wParam, nullptr);
304}
305
306static BOOL update_message_SurfaceFrameAcknowledge(rdpContext* context, UINT32 frameId)
307{
308 rdp_update_internal* up = nullptr;
309
310 if (!context || !context->update)
311 return FALSE;
312
313 up = update_cast(context->update);
314 return MessageQueue_Post(up->queue, (void*)context,
315 MakeMessageId(Update, SurfaceFrameAcknowledge), (void*)(size_t)frameId,
316 nullptr);
317}
318
319/* Primary Update */
320
321static BOOL update_message_DstBlt(rdpContext* context, const DSTBLT_ORDER* dstBlt)
322{
323 DSTBLT_ORDER* wParam = nullptr;
324 rdp_update_internal* up = nullptr;
325
326 if (!context || !context->update || !dstBlt)
327 return FALSE;
328
329 wParam = (DSTBLT_ORDER*)malloc(sizeof(DSTBLT_ORDER));
330
331 if (!wParam)
332 return FALSE;
333
334 CopyMemory(wParam, dstBlt, sizeof(DSTBLT_ORDER));
335
336 up = update_cast(context->update);
337 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, DstBlt),
338 (void*)wParam, nullptr);
339}
340
341static BOOL update_message_PatBlt(rdpContext* context, PATBLT_ORDER* patBlt)
342{
343 PATBLT_ORDER* wParam = nullptr;
344 rdp_update_internal* up = nullptr;
345
346 if (!context || !context->update || !patBlt)
347 return FALSE;
348
349 wParam = (PATBLT_ORDER*)malloc(sizeof(PATBLT_ORDER));
350
351 if (!wParam)
352 return FALSE;
353
354 CopyMemory(wParam, patBlt, sizeof(PATBLT_ORDER));
355 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
356
357 up = update_cast(context->update);
358 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, PatBlt),
359 (void*)wParam, nullptr);
360}
361
362static BOOL update_message_ScrBlt(rdpContext* context, const SCRBLT_ORDER* scrBlt)
363{
364 SCRBLT_ORDER* wParam = nullptr;
365 rdp_update_internal* up = nullptr;
366
367 if (!context || !context->update || !scrBlt)
368 return FALSE;
369
370 wParam = (SCRBLT_ORDER*)malloc(sizeof(SCRBLT_ORDER));
371
372 if (!wParam)
373 return FALSE;
374
375 CopyMemory(wParam, scrBlt, sizeof(SCRBLT_ORDER));
376
377 up = update_cast(context->update);
378 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, ScrBlt),
379 (void*)wParam, nullptr);
380}
381
382static BOOL update_message_OpaqueRect(rdpContext* context, const OPAQUE_RECT_ORDER* opaqueRect)
383{
384 OPAQUE_RECT_ORDER* wParam = nullptr;
385 rdp_update_internal* up = nullptr;
386
387 if (!context || !context->update || !opaqueRect)
388 return FALSE;
389
390 wParam = (OPAQUE_RECT_ORDER*)malloc(sizeof(OPAQUE_RECT_ORDER));
391
392 if (!wParam)
393 return FALSE;
394
395 CopyMemory(wParam, opaqueRect, sizeof(OPAQUE_RECT_ORDER));
396
397 up = update_cast(context->update);
398 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, OpaqueRect),
399 (void*)wParam, nullptr);
400}
401
402static BOOL update_message_DrawNineGrid(rdpContext* context,
403 const DRAW_NINE_GRID_ORDER* drawNineGrid)
404{
405 DRAW_NINE_GRID_ORDER* wParam = nullptr;
406 rdp_update_internal* up = nullptr;
407
408 if (!context || !context->update || !drawNineGrid)
409 return FALSE;
410
411 wParam = (DRAW_NINE_GRID_ORDER*)malloc(sizeof(DRAW_NINE_GRID_ORDER));
412
413 if (!wParam)
414 return FALSE;
415
416 CopyMemory(wParam, drawNineGrid, sizeof(DRAW_NINE_GRID_ORDER));
417
418 up = update_cast(context->update);
419 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, DrawNineGrid),
420 (void*)wParam, nullptr);
421}
422
423static BOOL update_message_MultiDstBlt(rdpContext* context, const MULTI_DSTBLT_ORDER* multiDstBlt)
424{
425 MULTI_DSTBLT_ORDER* wParam = nullptr;
426 rdp_update_internal* up = nullptr;
427
428 if (!context || !context->update || !multiDstBlt)
429 return FALSE;
430
431 wParam = (MULTI_DSTBLT_ORDER*)malloc(sizeof(MULTI_DSTBLT_ORDER));
432
433 if (!wParam)
434 return FALSE;
435
436 CopyMemory(wParam, multiDstBlt, sizeof(MULTI_DSTBLT_ORDER));
437
438 up = update_cast(context->update);
439 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, MultiDstBlt),
440 (void*)wParam, nullptr);
441}
442
443static BOOL update_message_MultiPatBlt(rdpContext* context, const MULTI_PATBLT_ORDER* multiPatBlt)
444{
445 MULTI_PATBLT_ORDER* wParam = nullptr;
446 rdp_update_internal* up = nullptr;
447
448 if (!context || !context->update || !multiPatBlt)
449 return FALSE;
450
451 wParam = (MULTI_PATBLT_ORDER*)malloc(sizeof(MULTI_PATBLT_ORDER));
452
453 if (!wParam)
454 return FALSE;
455
456 CopyMemory(wParam, multiPatBlt, sizeof(MULTI_PATBLT_ORDER));
457 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
458
459 up = update_cast(context->update);
460 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, MultiPatBlt),
461 (void*)wParam, nullptr);
462}
463
464static BOOL update_message_MultiScrBlt(rdpContext* context, const MULTI_SCRBLT_ORDER* multiScrBlt)
465{
466 MULTI_SCRBLT_ORDER* wParam = nullptr;
467 rdp_update_internal* up = nullptr;
468
469 if (!context || !context->update || !multiScrBlt)
470 return FALSE;
471
472 wParam = (MULTI_SCRBLT_ORDER*)malloc(sizeof(MULTI_SCRBLT_ORDER));
473
474 if (!wParam)
475 return FALSE;
476
477 CopyMemory(wParam, multiScrBlt, sizeof(MULTI_SCRBLT_ORDER));
478
479 up = update_cast(context->update);
480 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, MultiScrBlt),
481 (void*)wParam, nullptr);
482}
483
484static BOOL update_message_MultiOpaqueRect(rdpContext* context,
485 const MULTI_OPAQUE_RECT_ORDER* multiOpaqueRect)
486{
487 MULTI_OPAQUE_RECT_ORDER* wParam = nullptr;
488 rdp_update_internal* up = nullptr;
489
490 if (!context || !context->update || !multiOpaqueRect)
491 return FALSE;
492
493 wParam = (MULTI_OPAQUE_RECT_ORDER*)malloc(sizeof(MULTI_OPAQUE_RECT_ORDER));
494
495 if (!wParam)
496 return FALSE;
497
498 CopyMemory(wParam, multiOpaqueRect, sizeof(MULTI_OPAQUE_RECT_ORDER));
499
500 up = update_cast(context->update);
501 return MessageQueue_Post(up->queue, (void*)context,
502 MakeMessageId(PrimaryUpdate, MultiOpaqueRect), (void*)wParam, nullptr);
503}
504
505static BOOL update_message_MultiDrawNineGrid(rdpContext* context,
506 const MULTI_DRAW_NINE_GRID_ORDER* multiDrawNineGrid)
507{
508 MULTI_DRAW_NINE_GRID_ORDER* wParam = nullptr;
509 rdp_update_internal* up = nullptr;
510
511 if (!context || !context->update || !multiDrawNineGrid)
512 return FALSE;
513
515
516 if (!wParam)
517 return FALSE;
518
519 CopyMemory(wParam, multiDrawNineGrid, sizeof(MULTI_DRAW_NINE_GRID_ORDER));
520 /* TODO: complete copy */
521
522 up = update_cast(context->update);
523 return MessageQueue_Post(up->queue, (void*)context,
524 MakeMessageId(PrimaryUpdate, MultiDrawNineGrid), (void*)wParam,
525 nullptr);
526}
527
528static BOOL update_message_LineTo(rdpContext* context, const LINE_TO_ORDER* lineTo)
529{
530 LINE_TO_ORDER* wParam = nullptr;
531 rdp_update_internal* up = nullptr;
532
533 if (!context || !context->update || !lineTo)
534 return FALSE;
535
536 wParam = (LINE_TO_ORDER*)malloc(sizeof(LINE_TO_ORDER));
537
538 if (!wParam)
539 return FALSE;
540
541 CopyMemory(wParam, lineTo, sizeof(LINE_TO_ORDER));
542
543 up = update_cast(context->update);
544 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, LineTo),
545 (void*)wParam, nullptr);
546}
547
548static BOOL update_message_Polyline(rdpContext* context, const POLYLINE_ORDER* polyline)
549{
550 POLYLINE_ORDER* wParam = nullptr;
551 rdp_update_internal* up = nullptr;
552
553 if (!context || !context->update || !polyline)
554 return FALSE;
555
556 wParam = (POLYLINE_ORDER*)malloc(sizeof(POLYLINE_ORDER));
557
558 if (!wParam)
559 return FALSE;
560
561 CopyMemory(wParam, polyline, sizeof(POLYLINE_ORDER));
562 wParam->points = (DELTA_POINT*)calloc(wParam->numDeltaEntries, sizeof(DELTA_POINT));
563
564 if (!wParam->points)
565 {
566 free(wParam);
567 return FALSE;
568 }
569
570 CopyMemory(wParam->points, polyline->points, sizeof(DELTA_POINT) * wParam->numDeltaEntries);
571
572 up = update_cast(context->update);
573 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, Polyline),
574 (void*)wParam, nullptr);
575}
576
577static BOOL update_message_MemBlt(rdpContext* context, MEMBLT_ORDER* memBlt)
578{
579 MEMBLT_ORDER* wParam = nullptr;
580 rdp_update_internal* up = nullptr;
581
582 if (!context || !context->update || !memBlt)
583 return FALSE;
584
585 wParam = (MEMBLT_ORDER*)malloc(sizeof(MEMBLT_ORDER));
586
587 if (!wParam)
588 return FALSE;
589
590 CopyMemory(wParam, memBlt, sizeof(MEMBLT_ORDER));
591
592 up = update_cast(context->update);
593 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, MemBlt),
594 (void*)wParam, nullptr);
595}
596
597static BOOL update_message_Mem3Blt(rdpContext* context, MEM3BLT_ORDER* mem3Blt)
598{
599 MEM3BLT_ORDER* wParam = nullptr;
600 rdp_update_internal* up = nullptr;
601
602 if (!context || !context->update || !mem3Blt)
603 return FALSE;
604
605 wParam = (MEM3BLT_ORDER*)malloc(sizeof(MEM3BLT_ORDER));
606
607 if (!wParam)
608 return FALSE;
609
610 CopyMemory(wParam, mem3Blt, sizeof(MEM3BLT_ORDER));
611 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
612
613 up = update_cast(context->update);
614 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, Mem3Blt),
615 (void*)wParam, nullptr);
616}
617
618static BOOL update_message_SaveBitmap(rdpContext* context, const SAVE_BITMAP_ORDER* saveBitmap)
619{
620 SAVE_BITMAP_ORDER* wParam = nullptr;
621 rdp_update_internal* up = nullptr;
622
623 if (!context || !context->update || !saveBitmap)
624 return FALSE;
625
626 wParam = (SAVE_BITMAP_ORDER*)malloc(sizeof(SAVE_BITMAP_ORDER));
627
628 if (!wParam)
629 return FALSE;
630
631 CopyMemory(wParam, saveBitmap, sizeof(SAVE_BITMAP_ORDER));
632
633 up = update_cast(context->update);
634 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, SaveBitmap),
635 (void*)wParam, nullptr);
636}
637
638static BOOL update_message_GlyphIndex(rdpContext* context, GLYPH_INDEX_ORDER* glyphIndex)
639{
640 GLYPH_INDEX_ORDER* wParam = nullptr;
641 rdp_update_internal* up = nullptr;
642
643 if (!context || !context->update || !glyphIndex)
644 return FALSE;
645
646 wParam = (GLYPH_INDEX_ORDER*)malloc(sizeof(GLYPH_INDEX_ORDER));
647
648 if (!wParam)
649 return FALSE;
650
651 CopyMemory(wParam, glyphIndex, sizeof(GLYPH_INDEX_ORDER));
652 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
653
654 up = update_cast(context->update);
655 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, GlyphIndex),
656 (void*)wParam, nullptr);
657}
658
659static BOOL update_message_FastIndex(rdpContext* context, const FAST_INDEX_ORDER* fastIndex)
660{
661 FAST_INDEX_ORDER* wParam = nullptr;
662 rdp_update_internal* up = nullptr;
663
664 if (!context || !context->update || !fastIndex)
665 return FALSE;
666
667 wParam = (FAST_INDEX_ORDER*)malloc(sizeof(FAST_INDEX_ORDER));
668
669 if (!wParam)
670 return FALSE;
671
672 CopyMemory(wParam, fastIndex, sizeof(FAST_INDEX_ORDER));
673
674 up = update_cast(context->update);
675 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, FastIndex),
676 (void*)wParam, nullptr);
677}
678
679static BOOL update_message_FastGlyph(rdpContext* context, const FAST_GLYPH_ORDER* fastGlyph)
680{
681 FAST_GLYPH_ORDER* wParam = nullptr;
682 rdp_update_internal* up = nullptr;
683
684 if (!context || !context->update || !fastGlyph)
685 return FALSE;
686
687 wParam = (FAST_GLYPH_ORDER*)malloc(sizeof(FAST_GLYPH_ORDER));
688
689 if (!wParam)
690 return FALSE;
691
692 CopyMemory(wParam, fastGlyph, sizeof(FAST_GLYPH_ORDER));
693
694 if (wParam->cbData > 1)
695 {
696 wParam->glyphData.aj = (BYTE*)malloc(fastGlyph->glyphData.cb);
697
698 if (!wParam->glyphData.aj)
699 {
700 free(wParam);
701 return FALSE;
702 }
703
704 CopyMemory(wParam->glyphData.aj, fastGlyph->glyphData.aj, fastGlyph->glyphData.cb);
705 }
706 else
707 {
708 wParam->glyphData.aj = nullptr;
709 }
710
711 up = update_cast(context->update);
712 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, FastGlyph),
713 (void*)wParam, nullptr);
714}
715
716static BOOL update_message_PolygonSC(rdpContext* context, const POLYGON_SC_ORDER* polygonSC)
717{
718 POLYGON_SC_ORDER* wParam = nullptr;
719 rdp_update_internal* up = nullptr;
720
721 if (!context || !context->update || !polygonSC)
722 return FALSE;
723
724 wParam = (POLYGON_SC_ORDER*)malloc(sizeof(POLYGON_SC_ORDER));
725
726 if (!wParam)
727 return FALSE;
728
729 CopyMemory(wParam, polygonSC, sizeof(POLYGON_SC_ORDER));
730 wParam->points = (DELTA_POINT*)calloc(wParam->numPoints, sizeof(DELTA_POINT));
731
732 if (!wParam->points)
733 {
734 free(wParam);
735 return FALSE;
736 }
737
738 CopyMemory(wParam->points, polygonSC, sizeof(DELTA_POINT) * wParam->numPoints);
739
740 up = update_cast(context->update);
741 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, PolygonSC),
742 (void*)wParam, nullptr);
743}
744
745static BOOL update_message_PolygonCB(rdpContext* context, POLYGON_CB_ORDER* polygonCB)
746{
747 POLYGON_CB_ORDER* wParam = nullptr;
748 rdp_update_internal* up = nullptr;
749
750 if (!context || !context->update || !polygonCB)
751 return FALSE;
752
753 wParam = (POLYGON_CB_ORDER*)malloc(sizeof(POLYGON_CB_ORDER));
754
755 if (!wParam)
756 return FALSE;
757
758 CopyMemory(wParam, polygonCB, sizeof(POLYGON_CB_ORDER));
759 wParam->points = (DELTA_POINT*)calloc(wParam->numPoints, sizeof(DELTA_POINT));
760
761 if (!wParam->points)
762 {
763 free(wParam);
764 return FALSE;
765 }
766
767 CopyMemory(wParam->points, polygonCB, sizeof(DELTA_POINT) * wParam->numPoints);
768 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
769
770 up = update_cast(context->update);
771 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, PolygonCB),
772 (void*)wParam, nullptr);
773}
774
775static BOOL update_message_EllipseSC(rdpContext* context, const ELLIPSE_SC_ORDER* ellipseSC)
776{
777 ELLIPSE_SC_ORDER* wParam = nullptr;
778 rdp_update_internal* up = nullptr;
779
780 if (!context || !context->update || !ellipseSC)
781 return FALSE;
782
783 wParam = (ELLIPSE_SC_ORDER*)malloc(sizeof(ELLIPSE_SC_ORDER));
784
785 if (!wParam)
786 return FALSE;
787
788 CopyMemory(wParam, ellipseSC, sizeof(ELLIPSE_SC_ORDER));
789
790 up = update_cast(context->update);
791 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, EllipseSC),
792 (void*)wParam, nullptr);
793}
794
795static BOOL update_message_EllipseCB(rdpContext* context, const ELLIPSE_CB_ORDER* ellipseCB)
796{
797 ELLIPSE_CB_ORDER* wParam = nullptr;
798 rdp_update_internal* up = nullptr;
799
800 if (!context || !context->update || !ellipseCB)
801 return FALSE;
802
803 wParam = (ELLIPSE_CB_ORDER*)malloc(sizeof(ELLIPSE_CB_ORDER));
804
805 if (!wParam)
806 return FALSE;
807
808 CopyMemory(wParam, ellipseCB, sizeof(ELLIPSE_CB_ORDER));
809 wParam->brush.data = (BYTE*)wParam->brush.p8x8;
810
811 up = update_cast(context->update);
812 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, EllipseCB),
813 (void*)wParam, nullptr);
814}
815
816/* Secondary Update */
817
818static BOOL update_message_CacheBitmap(rdpContext* context,
819 const CACHE_BITMAP_ORDER* cacheBitmapOrder)
820{
821 CACHE_BITMAP_ORDER* wParam = nullptr;
822 rdp_update_internal* up = nullptr;
823
824 if (!context || !context->update || !cacheBitmapOrder)
825 return FALSE;
826
827 wParam = copy_cache_bitmap_order(context, cacheBitmapOrder);
828
829 if (!wParam)
830 return FALSE;
831
832 up = update_cast(context->update);
833 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(SecondaryUpdate, CacheBitmap),
834 (void*)wParam, nullptr);
835}
836
837static BOOL update_message_CacheBitmapV2(rdpContext* context,
838 CACHE_BITMAP_V2_ORDER* cacheBitmapV2Order)
839{
840 CACHE_BITMAP_V2_ORDER* wParam = nullptr;
841 rdp_update_internal* up = nullptr;
842
843 if (!context || !context->update || !cacheBitmapV2Order)
844 return FALSE;
845
846 wParam = copy_cache_bitmap_v2_order(context, cacheBitmapV2Order);
847
848 if (!wParam)
849 return FALSE;
850
851 up = update_cast(context->update);
852 return MessageQueue_Post(up->queue, (void*)context,
853 MakeMessageId(SecondaryUpdate, CacheBitmapV2), (void*)wParam, nullptr);
854}
855
856static BOOL update_message_CacheBitmapV3(rdpContext* context,
857 CACHE_BITMAP_V3_ORDER* cacheBitmapV3Order)
858{
859 CACHE_BITMAP_V3_ORDER* wParam = nullptr;
860 rdp_update_internal* up = nullptr;
861
862 if (!context || !context->update || !cacheBitmapV3Order)
863 return FALSE;
864
865 wParam = copy_cache_bitmap_v3_order(context, cacheBitmapV3Order);
866
867 if (!wParam)
868 return FALSE;
869
870 up = update_cast(context->update);
871 return MessageQueue_Post(up->queue, (void*)context,
872 MakeMessageId(SecondaryUpdate, CacheBitmapV3), (void*)wParam, nullptr);
873}
874
875static BOOL update_message_CacheColorTable(rdpContext* context,
876 const CACHE_COLOR_TABLE_ORDER* cacheColorTableOrder)
877{
878 CACHE_COLOR_TABLE_ORDER* wParam = nullptr;
879 rdp_update_internal* up = nullptr;
880
881 if (!context || !context->update || !cacheColorTableOrder)
882 return FALSE;
883
884 wParam = copy_cache_color_table_order(context, cacheColorTableOrder);
885
886 if (!wParam)
887 return FALSE;
888
889 up = update_cast(context->update);
890 return MessageQueue_Post(up->queue, (void*)context,
891 MakeMessageId(SecondaryUpdate, CacheColorTable), (void*)wParam,
892 nullptr);
893}
894
895static BOOL update_message_CacheGlyph(rdpContext* context, const CACHE_GLYPH_ORDER* cacheGlyphOrder)
896{
897 CACHE_GLYPH_ORDER* wParam = nullptr;
898 rdp_update_internal* up = nullptr;
899
900 if (!context || !context->update || !cacheGlyphOrder)
901 return FALSE;
902
903 wParam = copy_cache_glyph_order(context, cacheGlyphOrder);
904
905 if (!wParam)
906 return FALSE;
907
908 up = update_cast(context->update);
909 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(SecondaryUpdate, CacheGlyph),
910 (void*)wParam, nullptr);
911}
912
913static BOOL update_message_CacheGlyphV2(rdpContext* context,
914 const CACHE_GLYPH_V2_ORDER* cacheGlyphV2Order)
915{
916 CACHE_GLYPH_V2_ORDER* wParam = nullptr;
917 rdp_update_internal* up = nullptr;
918
919 if (!context || !context->update || !cacheGlyphV2Order)
920 return FALSE;
921
922 wParam = copy_cache_glyph_v2_order(context, cacheGlyphV2Order);
923
924 if (!wParam)
925 return FALSE;
926
927 up = update_cast(context->update);
928 return MessageQueue_Post(up->queue, (void*)context,
929 MakeMessageId(SecondaryUpdate, CacheGlyphV2), (void*)wParam, nullptr);
930}
931
932static BOOL update_message_CacheBrush(rdpContext* context, const CACHE_BRUSH_ORDER* cacheBrushOrder)
933{
934 CACHE_BRUSH_ORDER* wParam = nullptr;
935 rdp_update_internal* up = nullptr;
936
937 if (!context || !context->update || !cacheBrushOrder)
938 return FALSE;
939
940 wParam = copy_cache_brush_order(context, cacheBrushOrder);
941
942 if (!wParam)
943 return FALSE;
944
945 up = update_cast(context->update);
946 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(SecondaryUpdate, CacheBrush),
947 (void*)wParam, nullptr);
948}
949
950/* Alternate Secondary Update */
951
952static BOOL
953update_message_CreateOffscreenBitmap(rdpContext* context,
954 const CREATE_OFFSCREEN_BITMAP_ORDER* createOffscreenBitmap)
955{
956 CREATE_OFFSCREEN_BITMAP_ORDER* wParam = nullptr;
957 rdp_update_internal* up = nullptr;
958
959 if (!context || !context->update || !createOffscreenBitmap)
960 return FALSE;
961
963
964 if (!wParam)
965 return FALSE;
966
967 CopyMemory(wParam, createOffscreenBitmap, sizeof(CREATE_OFFSCREEN_BITMAP_ORDER));
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));
971
972 if (!wParam->deleteList.indices)
973 {
974 free(wParam);
975 return FALSE;
976 }
977
978 CopyMemory(wParam->deleteList.indices, createOffscreenBitmap->deleteList.indices,
979 wParam->deleteList.cIndices);
980
981 up = update_cast(context->update);
982 return MessageQueue_Post(up->queue, (void*)context,
983 MakeMessageId(AltSecUpdate, CreateOffscreenBitmap), (void*)wParam,
984 nullptr);
985}
986
987static BOOL update_message_SwitchSurface(rdpContext* context,
988 const SWITCH_SURFACE_ORDER* switchSurface)
989{
990 SWITCH_SURFACE_ORDER* wParam = nullptr;
991 rdp_update_internal* up = nullptr;
992
993 if (!context || !context->update || !switchSurface)
994 return FALSE;
995
996 wParam = (SWITCH_SURFACE_ORDER*)malloc(sizeof(SWITCH_SURFACE_ORDER));
997
998 if (!wParam)
999 return FALSE;
1000
1001 CopyMemory(wParam, switchSurface, sizeof(SWITCH_SURFACE_ORDER));
1002
1003 up = update_cast(context->update);
1004 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(AltSecUpdate, SwitchSurface),
1005 (void*)wParam, nullptr);
1006}
1007
1008static BOOL
1009update_message_CreateNineGridBitmap(rdpContext* context,
1010 const CREATE_NINE_GRID_BITMAP_ORDER* createNineGridBitmap)
1011{
1012 CREATE_NINE_GRID_BITMAP_ORDER* wParam = nullptr;
1013 rdp_update_internal* up = nullptr;
1014
1015 if (!context || !context->update || !createNineGridBitmap)
1016 return FALSE;
1017
1019
1020 if (!wParam)
1021 return FALSE;
1022
1023 CopyMemory(wParam, createNineGridBitmap, sizeof(CREATE_NINE_GRID_BITMAP_ORDER));
1024
1025 up = update_cast(context->update);
1026 return MessageQueue_Post(up->queue, (void*)context,
1027 MakeMessageId(AltSecUpdate, CreateNineGridBitmap), (void*)wParam,
1028 nullptr);
1029}
1030
1031static BOOL update_message_FrameMarker(rdpContext* context, const FRAME_MARKER_ORDER* frameMarker)
1032{
1033 FRAME_MARKER_ORDER* wParam = nullptr;
1034 rdp_update_internal* up = nullptr;
1035
1036 if (!context || !context->update || !frameMarker)
1037 return FALSE;
1038
1039 wParam = (FRAME_MARKER_ORDER*)malloc(sizeof(FRAME_MARKER_ORDER));
1040
1041 if (!wParam)
1042 return FALSE;
1043
1044 CopyMemory(wParam, frameMarker, sizeof(FRAME_MARKER_ORDER));
1045
1046 up = update_cast(context->update);
1047 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(AltSecUpdate, FrameMarker),
1048 (void*)wParam, nullptr);
1049}
1050
1051static BOOL update_message_StreamBitmapFirst(rdpContext* context,
1052 const STREAM_BITMAP_FIRST_ORDER* streamBitmapFirst)
1053{
1054 STREAM_BITMAP_FIRST_ORDER* wParam = nullptr;
1055 rdp_update_internal* up = nullptr;
1056
1057 if (!context || !context->update || !streamBitmapFirst)
1058 return FALSE;
1059
1060 wParam = (STREAM_BITMAP_FIRST_ORDER*)malloc(sizeof(STREAM_BITMAP_FIRST_ORDER));
1061
1062 if (!wParam)
1063 return FALSE;
1064
1065 CopyMemory(wParam, streamBitmapFirst, sizeof(STREAM_BITMAP_FIRST_ORDER));
1066 /* TODO: complete copy */
1067
1068 up = update_cast(context->update);
1069 return MessageQueue_Post(up->queue, (void*)context,
1070 MakeMessageId(AltSecUpdate, StreamBitmapFirst), (void*)wParam,
1071 nullptr);
1072}
1073
1074static BOOL update_message_StreamBitmapNext(rdpContext* context,
1075 const STREAM_BITMAP_NEXT_ORDER* streamBitmapNext)
1076{
1077 STREAM_BITMAP_NEXT_ORDER* wParam = nullptr;
1078 rdp_update_internal* up = nullptr;
1079
1080 if (!context || !context->update || !streamBitmapNext)
1081 return FALSE;
1082
1083 wParam = (STREAM_BITMAP_NEXT_ORDER*)malloc(sizeof(STREAM_BITMAP_NEXT_ORDER));
1084
1085 if (!wParam)
1086 return FALSE;
1087
1088 CopyMemory(wParam, streamBitmapNext, sizeof(STREAM_BITMAP_NEXT_ORDER));
1089 /* TODO: complete copy */
1090
1091 up = update_cast(context->update);
1092 return MessageQueue_Post(up->queue, (void*)context,
1093 MakeMessageId(AltSecUpdate, StreamBitmapNext), (void*)wParam, nullptr);
1094}
1095
1096static BOOL update_message_DrawGdiPlusFirst(rdpContext* context,
1097 const DRAW_GDIPLUS_FIRST_ORDER* drawGdiPlusFirst)
1098{
1099 DRAW_GDIPLUS_FIRST_ORDER* wParam = nullptr;
1100 rdp_update_internal* up = nullptr;
1101
1102 if (!context || !context->update || !drawGdiPlusFirst)
1103 return FALSE;
1104
1105 wParam = (DRAW_GDIPLUS_FIRST_ORDER*)malloc(sizeof(DRAW_GDIPLUS_FIRST_ORDER));
1106
1107 if (!wParam)
1108 return FALSE;
1109
1110 CopyMemory(wParam, drawGdiPlusFirst, sizeof(DRAW_GDIPLUS_FIRST_ORDER));
1111 /* TODO: complete copy */
1112 up = update_cast(context->update);
1113 return MessageQueue_Post(up->queue, (void*)context,
1114 MakeMessageId(AltSecUpdate, DrawGdiPlusFirst), (void*)wParam, nullptr);
1115}
1116
1117static BOOL update_message_DrawGdiPlusNext(rdpContext* context,
1118 const DRAW_GDIPLUS_NEXT_ORDER* drawGdiPlusNext)
1119{
1120 DRAW_GDIPLUS_NEXT_ORDER* wParam = nullptr;
1121 rdp_update_internal* up = nullptr;
1122
1123 if (!context || !context->update || !drawGdiPlusNext)
1124 return FALSE;
1125
1126 wParam = (DRAW_GDIPLUS_NEXT_ORDER*)malloc(sizeof(DRAW_GDIPLUS_NEXT_ORDER));
1127
1128 if (!wParam)
1129 return FALSE;
1130
1131 CopyMemory(wParam, drawGdiPlusNext, sizeof(DRAW_GDIPLUS_NEXT_ORDER));
1132 /* TODO: complete copy */
1133
1134 up = update_cast(context->update);
1135 return MessageQueue_Post(up->queue, (void*)context,
1136 MakeMessageId(AltSecUpdate, DrawGdiPlusNext), (void*)wParam, nullptr);
1137}
1138
1139static BOOL update_message_DrawGdiPlusEnd(rdpContext* context,
1140 const DRAW_GDIPLUS_END_ORDER* drawGdiPlusEnd)
1141{
1142 DRAW_GDIPLUS_END_ORDER* wParam = nullptr;
1143 rdp_update_internal* up = nullptr;
1144
1145 if (!context || !context->update || !drawGdiPlusEnd)
1146 return FALSE;
1147
1148 wParam = (DRAW_GDIPLUS_END_ORDER*)malloc(sizeof(DRAW_GDIPLUS_END_ORDER));
1149
1150 if (!wParam)
1151 return FALSE;
1152
1153 CopyMemory(wParam, drawGdiPlusEnd, sizeof(DRAW_GDIPLUS_END_ORDER));
1154 /* TODO: complete copy */
1155
1156 up = update_cast(context->update);
1157 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(AltSecUpdate, DrawGdiPlusEnd),
1158 (void*)wParam, nullptr);
1159}
1160
1161static BOOL
1162update_message_DrawGdiPlusCacheFirst(rdpContext* context,
1163 const DRAW_GDIPLUS_CACHE_FIRST_ORDER* drawGdiPlusCacheFirst)
1164{
1165 DRAW_GDIPLUS_CACHE_FIRST_ORDER* wParam = nullptr;
1166 rdp_update_internal* up = nullptr;
1167
1168 if (!context || !context->update || !drawGdiPlusCacheFirst)
1169 return FALSE;
1170
1172
1173 if (!wParam)
1174 return FALSE;
1175
1176 CopyMemory(wParam, drawGdiPlusCacheFirst, sizeof(DRAW_GDIPLUS_CACHE_FIRST_ORDER));
1177 /* TODO: complete copy */
1178
1179 up = update_cast(context->update);
1180 return MessageQueue_Post(up->queue, (void*)context,
1181 MakeMessageId(AltSecUpdate, DrawGdiPlusCacheFirst), (void*)wParam,
1182 nullptr);
1183}
1184
1185static BOOL
1186update_message_DrawGdiPlusCacheNext(rdpContext* context,
1187 const DRAW_GDIPLUS_CACHE_NEXT_ORDER* drawGdiPlusCacheNext)
1188{
1189 DRAW_GDIPLUS_CACHE_NEXT_ORDER* wParam = nullptr;
1190 rdp_update_internal* up = nullptr;
1191
1192 if (!context || !context->update || !drawGdiPlusCacheNext)
1193 return FALSE;
1194
1196
1197 if (!wParam)
1198 return FALSE;
1199
1200 CopyMemory(wParam, drawGdiPlusCacheNext, sizeof(DRAW_GDIPLUS_CACHE_NEXT_ORDER));
1201 /* TODO: complete copy */
1202
1203 up = update_cast(context->update);
1204 return MessageQueue_Post(up->queue, (void*)context,
1205 MakeMessageId(AltSecUpdate, DrawGdiPlusCacheNext), (void*)wParam,
1206 nullptr);
1207}
1208
1209static BOOL
1210update_message_DrawGdiPlusCacheEnd(rdpContext* context,
1211 const DRAW_GDIPLUS_CACHE_END_ORDER* drawGdiPlusCacheEnd)
1212{
1213 DRAW_GDIPLUS_CACHE_END_ORDER* wParam = nullptr;
1214 rdp_update_internal* up = nullptr;
1215
1216 if (!context || !context->update || !drawGdiPlusCacheEnd)
1217 return FALSE;
1218
1220
1221 if (!wParam)
1222 return FALSE;
1223
1224 CopyMemory(wParam, drawGdiPlusCacheEnd, sizeof(DRAW_GDIPLUS_CACHE_END_ORDER));
1225 /* TODO: complete copy */
1226
1227 up = update_cast(context->update);
1228 return MessageQueue_Post(up->queue, (void*)context,
1229 MakeMessageId(AltSecUpdate, DrawGdiPlusCacheEnd), (void*)wParam,
1230 nullptr);
1231}
1232
1233/* Window Update */
1234
1235static BOOL update_message_WindowCreate(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
1236 const WINDOW_STATE_ORDER* windowState)
1237{
1238 WINDOW_ORDER_INFO* wParam = nullptr;
1239 WINDOW_STATE_ORDER* lParam = nullptr;
1240 rdp_update_internal* up = nullptr;
1241
1242 if (!context || !context->update || !orderInfo || !windowState)
1243 return FALSE;
1244
1245 wParam = (WINDOW_ORDER_INFO*)malloc(sizeof(WINDOW_ORDER_INFO));
1246
1247 if (!wParam)
1248 return FALSE;
1249
1250 CopyMemory(wParam, orderInfo, sizeof(WINDOW_ORDER_INFO));
1251 lParam = (WINDOW_STATE_ORDER*)malloc(sizeof(WINDOW_STATE_ORDER));
1252
1253 if (!lParam)
1254 {
1255 free(wParam);
1256 return FALSE;
1257 }
1258
1259 CopyMemory(lParam, windowState, sizeof(WINDOW_STATE_ORDER));
1260
1261 up = update_cast(context->update);
1262 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(WindowUpdate, WindowCreate),
1263 (void*)wParam, (void*)lParam);
1264}
1265
1266static BOOL update_message_WindowUpdate(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
1267 const WINDOW_STATE_ORDER* windowState)
1268{
1269 WINDOW_ORDER_INFO* wParam = nullptr;
1270 WINDOW_STATE_ORDER* lParam = nullptr;
1271 rdp_update_internal* up = nullptr;
1272
1273 if (!context || !context->update || !orderInfo || !windowState)
1274 return FALSE;
1275
1276 wParam = (WINDOW_ORDER_INFO*)malloc(sizeof(WINDOW_ORDER_INFO));
1277
1278 if (!wParam)
1279 return FALSE;
1280
1281 CopyMemory(wParam, orderInfo, sizeof(WINDOW_ORDER_INFO));
1282 lParam = (WINDOW_STATE_ORDER*)malloc(sizeof(WINDOW_STATE_ORDER));
1283
1284 if (!lParam)
1285 {
1286 free(wParam);
1287 return FALSE;
1288 }
1289
1290 CopyMemory(lParam, windowState, sizeof(WINDOW_STATE_ORDER));
1291
1292 up = update_cast(context->update);
1293 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(WindowUpdate, WindowUpdate),
1294 (void*)wParam, (void*)lParam);
1295}
1296
1297static BOOL update_message_WindowIcon(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
1298 const WINDOW_ICON_ORDER* windowIcon)
1299{
1300 WINDOW_ORDER_INFO* wParam = nullptr;
1301 WINDOW_ICON_ORDER* lParam = nullptr;
1302 rdp_update_internal* up = nullptr;
1303
1304 if (!context || !context->update || !orderInfo || !windowIcon)
1305 return FALSE;
1306
1307 wParam = (WINDOW_ORDER_INFO*)malloc(sizeof(WINDOW_ORDER_INFO));
1308
1309 if (!wParam)
1310 return FALSE;
1311
1312 CopyMemory(wParam, orderInfo, sizeof(WINDOW_ORDER_INFO));
1313 lParam = (WINDOW_ICON_ORDER*)calloc(1, sizeof(WINDOW_ICON_ORDER));
1314
1315 if (!lParam)
1316 goto out_fail;
1317
1318 lParam->iconInfo = calloc(1, sizeof(ICON_INFO));
1319
1320 if (!lParam->iconInfo)
1321 goto out_fail;
1322
1323 CopyMemory(lParam, windowIcon, sizeof(WINDOW_ICON_ORDER));
1324 WLog_VRB(TAG, "update_message_WindowIcon");
1325
1326 if (windowIcon->iconInfo->cbBitsColor > 0)
1327 {
1328 lParam->iconInfo->bitsColor = (BYTE*)malloc(windowIcon->iconInfo->cbBitsColor);
1329
1330 if (!lParam->iconInfo->bitsColor)
1331 goto out_fail;
1332
1333 CopyMemory(lParam->iconInfo->bitsColor, windowIcon->iconInfo->bitsColor,
1334 windowIcon->iconInfo->cbBitsColor);
1335 }
1336
1337 if (windowIcon->iconInfo->cbBitsMask > 0)
1338 {
1339 lParam->iconInfo->bitsMask = (BYTE*)malloc(windowIcon->iconInfo->cbBitsMask);
1340
1341 if (!lParam->iconInfo->bitsMask)
1342 goto out_fail;
1343
1344 CopyMemory(lParam->iconInfo->bitsMask, windowIcon->iconInfo->bitsMask,
1345 windowIcon->iconInfo->cbBitsMask);
1346 }
1347
1348 if (windowIcon->iconInfo->cbColorTable > 0)
1349 {
1350 lParam->iconInfo->colorTable = (BYTE*)malloc(windowIcon->iconInfo->cbColorTable);
1351
1352 if (!lParam->iconInfo->colorTable)
1353 goto out_fail;
1354
1355 CopyMemory(lParam->iconInfo->colorTable, windowIcon->iconInfo->colorTable,
1356 windowIcon->iconInfo->cbColorTable);
1357 }
1358
1359 up = update_cast(context->update);
1360 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(WindowUpdate, WindowIcon),
1361 (void*)wParam, (void*)lParam);
1362out_fail:
1363
1364 if (lParam && lParam->iconInfo)
1365 {
1366 free(lParam->iconInfo->bitsColor);
1367 free(lParam->iconInfo->bitsMask);
1368 free(lParam->iconInfo->colorTable);
1369 free(lParam->iconInfo);
1370 }
1371
1372 free(lParam);
1373 free(wParam);
1374 return FALSE;
1375}
1376
1377static BOOL update_message_WindowCachedIcon(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
1378 const WINDOW_CACHED_ICON_ORDER* windowCachedIcon)
1379{
1380 WINDOW_ORDER_INFO* wParam = nullptr;
1381 WINDOW_CACHED_ICON_ORDER* lParam = nullptr;
1382 rdp_update_internal* up = nullptr;
1383
1384 if (!context || !context->update || !orderInfo || !windowCachedIcon)
1385 return FALSE;
1386
1387 wParam = (WINDOW_ORDER_INFO*)malloc(sizeof(WINDOW_ORDER_INFO));
1388
1389 if (!wParam)
1390 return FALSE;
1391
1392 CopyMemory(wParam, orderInfo, sizeof(WINDOW_ORDER_INFO));
1393 lParam = (WINDOW_CACHED_ICON_ORDER*)malloc(sizeof(WINDOW_CACHED_ICON_ORDER));
1394
1395 if (!lParam)
1396 {
1397 free(wParam);
1398 return FALSE;
1399 }
1400
1401 CopyMemory(lParam, windowCachedIcon, sizeof(WINDOW_CACHED_ICON_ORDER));
1402
1403 up = update_cast(context->update);
1404 return MessageQueue_Post(up->queue, (void*)context,
1405 MakeMessageId(WindowUpdate, WindowCachedIcon), (void*)wParam,
1406 (void*)lParam);
1407}
1408
1409static BOOL update_message_WindowDelete(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo)
1410{
1411 WINDOW_ORDER_INFO* wParam = nullptr;
1412 rdp_update_internal* up = nullptr;
1413
1414 if (!context || !context->update || !orderInfo)
1415 return FALSE;
1416
1417 wParam = (WINDOW_ORDER_INFO*)malloc(sizeof(WINDOW_ORDER_INFO));
1418
1419 if (!wParam)
1420 return FALSE;
1421
1422 CopyMemory(wParam, orderInfo, sizeof(WINDOW_ORDER_INFO));
1423
1424 up = update_cast(context->update);
1425 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(WindowUpdate, WindowDelete),
1426 (void*)wParam, nullptr);
1427}
1428
1429static BOOL update_message_NotifyIconCreate(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
1430 const NOTIFY_ICON_STATE_ORDER* notifyIconState)
1431{
1432 WINDOW_ORDER_INFO* wParam = nullptr;
1433 NOTIFY_ICON_STATE_ORDER* lParam = nullptr;
1434 rdp_update_internal* up = nullptr;
1435
1436 if (!context || !context->update || !orderInfo || !notifyIconState)
1437 return FALSE;
1438
1439 wParam = (WINDOW_ORDER_INFO*)malloc(sizeof(WINDOW_ORDER_INFO));
1440
1441 if (!wParam)
1442 return FALSE;
1443
1444 CopyMemory(wParam, orderInfo, sizeof(WINDOW_ORDER_INFO));
1445 lParam = (NOTIFY_ICON_STATE_ORDER*)malloc(sizeof(NOTIFY_ICON_STATE_ORDER));
1446
1447 if (!lParam)
1448 {
1449 free(wParam);
1450 return FALSE;
1451 }
1452
1453 CopyMemory(lParam, notifyIconState, sizeof(NOTIFY_ICON_STATE_ORDER));
1454
1455 up = update_cast(context->update);
1456 return MessageQueue_Post(up->queue, (void*)context,
1457 MakeMessageId(WindowUpdate, NotifyIconCreate), (void*)wParam,
1458 (void*)lParam);
1459}
1460
1461static BOOL update_message_NotifyIconUpdate(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
1462 const NOTIFY_ICON_STATE_ORDER* notifyIconState)
1463{
1464 WINDOW_ORDER_INFO* wParam = nullptr;
1465 NOTIFY_ICON_STATE_ORDER* lParam = nullptr;
1466 rdp_update_internal* up = nullptr;
1467
1468 if (!context || !context->update || !orderInfo || !notifyIconState)
1469 return FALSE;
1470
1471 wParam = (WINDOW_ORDER_INFO*)malloc(sizeof(WINDOW_ORDER_INFO));
1472
1473 if (!wParam)
1474 return FALSE;
1475
1476 CopyMemory(wParam, orderInfo, sizeof(WINDOW_ORDER_INFO));
1477 lParam = (NOTIFY_ICON_STATE_ORDER*)malloc(sizeof(NOTIFY_ICON_STATE_ORDER));
1478
1479 if (!lParam)
1480 {
1481 free(wParam);
1482 return FALSE;
1483 }
1484
1485 CopyMemory(lParam, notifyIconState, sizeof(NOTIFY_ICON_STATE_ORDER));
1486
1487 up = update_cast(context->update);
1488 return MessageQueue_Post(up->queue, (void*)context,
1489 MakeMessageId(WindowUpdate, NotifyIconUpdate), (void*)wParam,
1490 (void*)lParam);
1491}
1492
1493static BOOL update_message_NotifyIconDelete(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo)
1494{
1495 WINDOW_ORDER_INFO* wParam = nullptr;
1496 rdp_update_internal* up = nullptr;
1497
1498 if (!context || !context->update || !orderInfo)
1499 return FALSE;
1500
1501 wParam = (WINDOW_ORDER_INFO*)malloc(sizeof(WINDOW_ORDER_INFO));
1502
1503 if (!wParam)
1504 return FALSE;
1505
1506 CopyMemory(wParam, orderInfo, sizeof(WINDOW_ORDER_INFO));
1507
1508 up = update_cast(context->update);
1509 return MessageQueue_Post(up->queue, (void*)context,
1510 MakeMessageId(WindowUpdate, NotifyIconDelete), (void*)wParam, nullptr);
1511}
1512
1513static BOOL update_message_MonitoredDesktop(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
1514 const MONITORED_DESKTOP_ORDER* monitoredDesktop)
1515{
1516 WINDOW_ORDER_INFO* wParam = nullptr;
1517 MONITORED_DESKTOP_ORDER* lParam = nullptr;
1518 rdp_update_internal* up = nullptr;
1519
1520 if (!context || !context->update || !orderInfo || !monitoredDesktop)
1521 return FALSE;
1522
1523 wParam = (WINDOW_ORDER_INFO*)malloc(sizeof(WINDOW_ORDER_INFO));
1524
1525 if (!wParam)
1526 return FALSE;
1527
1528 CopyMemory(wParam, orderInfo, sizeof(WINDOW_ORDER_INFO));
1529 lParam = (MONITORED_DESKTOP_ORDER*)malloc(sizeof(MONITORED_DESKTOP_ORDER));
1530
1531 if (!lParam)
1532 {
1533 free(wParam);
1534 return FALSE;
1535 }
1536
1537 CopyMemory(lParam, monitoredDesktop, sizeof(MONITORED_DESKTOP_ORDER));
1538 lParam->windowIds = nullptr;
1539
1540 if (lParam->numWindowIds)
1541 {
1542 lParam->windowIds = (UINT32*)calloc(lParam->numWindowIds, sizeof(UINT32));
1543 CopyMemory(lParam->windowIds, monitoredDesktop->windowIds, lParam->numWindowIds);
1544 }
1545
1546 up = update_cast(context->update);
1547 return MessageQueue_Post(up->queue, (void*)context,
1548 MakeMessageId(WindowUpdate, MonitoredDesktop), (void*)wParam,
1549 (void*)lParam);
1550}
1551
1552static BOOL update_message_NonMonitoredDesktop(rdpContext* context,
1553 const WINDOW_ORDER_INFO* orderInfo)
1554{
1555 WINDOW_ORDER_INFO* wParam = nullptr;
1556 rdp_update_internal* up = nullptr;
1557
1558 if (!context || !context->update || !orderInfo)
1559 return FALSE;
1560
1561 wParam = (WINDOW_ORDER_INFO*)malloc(sizeof(WINDOW_ORDER_INFO));
1562
1563 if (!wParam)
1564 return FALSE;
1565
1566 CopyMemory(wParam, orderInfo, sizeof(WINDOW_ORDER_INFO));
1567
1568 up = update_cast(context->update);
1569 return MessageQueue_Post(up->queue, (void*)context,
1570 MakeMessageId(WindowUpdate, NonMonitoredDesktop), (void*)wParam,
1571 nullptr);
1572}
1573
1574/* Pointer Update */
1575
1576static BOOL update_message_PointerPosition(rdpContext* context,
1577 const POINTER_POSITION_UPDATE* pointerPosition)
1578{
1579 POINTER_POSITION_UPDATE* wParam = nullptr;
1580 rdp_update_internal* up = nullptr;
1581
1582 if (!context || !context->update || !pointerPosition)
1583 return FALSE;
1584
1585 wParam = copy_pointer_position_update(context, pointerPosition);
1586
1587 if (!wParam)
1588 return FALSE;
1589
1590 up = update_cast(context->update);
1591 return MessageQueue_Post(up->queue, (void*)context,
1592 MakeMessageId(PointerUpdate, PointerPosition), (void*)wParam, nullptr);
1593}
1594
1595static BOOL update_message_PointerSystem(rdpContext* context,
1596 const POINTER_SYSTEM_UPDATE* pointerSystem)
1597{
1598 POINTER_SYSTEM_UPDATE* wParam = nullptr;
1599 rdp_update_internal* up = nullptr;
1600
1601 if (!context || !context->update || !pointerSystem)
1602 return FALSE;
1603
1604 wParam = copy_pointer_system_update(context, pointerSystem);
1605
1606 if (!wParam)
1607 return FALSE;
1608
1609 up = update_cast(context->update);
1610 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PointerUpdate, PointerSystem),
1611 (void*)wParam, nullptr);
1612}
1613
1614static BOOL update_message_PointerColor(rdpContext* context,
1615 const POINTER_COLOR_UPDATE* pointerColor)
1616{
1617 POINTER_COLOR_UPDATE* wParam = nullptr;
1618 rdp_update_internal* up = nullptr;
1619
1620 if (!context || !context->update || !pointerColor)
1621 return FALSE;
1622
1623 wParam = copy_pointer_color_update(context, pointerColor);
1624
1625 if (!wParam)
1626 return FALSE;
1627
1628 up = update_cast(context->update);
1629 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PointerUpdate, PointerColor),
1630 (void*)wParam, nullptr);
1631}
1632
1633static BOOL update_message_PointerLarge(rdpContext* context, const POINTER_LARGE_UPDATE* pointer)
1634{
1635 POINTER_LARGE_UPDATE* wParam = nullptr;
1636 rdp_update_internal* up = nullptr;
1637
1638 if (!context || !context->update || !pointer)
1639 return FALSE;
1640
1641 wParam = copy_pointer_large_update(context, pointer);
1642
1643 if (!wParam)
1644 return FALSE;
1645
1646 up = update_cast(context->update);
1647 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PointerUpdate, PointerLarge),
1648 (void*)wParam, nullptr);
1649}
1650
1651static BOOL update_message_PointerNew(rdpContext* context, const POINTER_NEW_UPDATE* pointerNew)
1652{
1653 POINTER_NEW_UPDATE* wParam = nullptr;
1654 rdp_update_internal* up = nullptr;
1655
1656 if (!context || !context->update || !pointerNew)
1657 return FALSE;
1658
1659 wParam = copy_pointer_new_update(context, pointerNew);
1660
1661 if (!wParam)
1662 return FALSE;
1663
1664 up = update_cast(context->update);
1665 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PointerUpdate, PointerNew),
1666 (void*)wParam, nullptr);
1667}
1668
1669static BOOL update_message_PointerCached(rdpContext* context,
1670 const POINTER_CACHED_UPDATE* pointerCached)
1671{
1672 POINTER_CACHED_UPDATE* wParam = nullptr;
1673 rdp_update_internal* up = nullptr;
1674
1675 if (!context || !context->update || !pointerCached)
1676 return FALSE;
1677
1678 wParam = copy_pointer_cached_update(context, pointerCached);
1679
1680 if (!wParam)
1681 return FALSE;
1682
1683 up = update_cast(context->update);
1684 return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PointerUpdate, PointerCached),
1685 (void*)wParam, nullptr);
1686}
1687
1688/* Message Queue */
1689static BOOL update_message_free_update_class(wMessage* msg, int type)
1690{
1691 rdpContext* context = nullptr;
1692
1693 if (!msg)
1694 return FALSE;
1695
1696 context = (rdpContext*)msg->context;
1697
1698 switch (type)
1699 {
1700 case Update_BeginPaint:
1701 break;
1702
1703 case Update_EndPaint:
1704 break;
1705
1706 case Update_SetBounds:
1707 free(msg->wParam);
1708 break;
1709
1710 case Update_Synchronize:
1711 break;
1712
1713 case Update_DesktopResize:
1714 break;
1715
1716 case Update_BitmapUpdate:
1717 {
1718 BITMAP_UPDATE* wParam = (BITMAP_UPDATE*)msg->wParam;
1719 free_bitmap_update(context, wParam);
1720 }
1721 break;
1722
1723 case Update_Palette:
1724 {
1725 PALETTE_UPDATE* palette = (PALETTE_UPDATE*)msg->wParam;
1726 free_palette_update(context, palette);
1727 }
1728 break;
1729
1730 case Update_PlaySound:
1731 free(msg->wParam);
1732 break;
1733
1734 case Update_RefreshRect:
1735 free(msg->lParam);
1736 break;
1737
1738 case Update_SuppressOutput:
1739 free(msg->lParam);
1740 break;
1741
1742 case Update_SurfaceCommand:
1743 {
1744 wStream* s = (wStream*)msg->wParam;
1745 Stream_Free(s, TRUE);
1746 }
1747 break;
1748
1749 case Update_SurfaceBits:
1750 {
1751 SURFACE_BITS_COMMAND* wParam = (SURFACE_BITS_COMMAND*)msg->wParam;
1752 free_surface_bits_command(context, wParam);
1753 }
1754 break;
1755
1756 case Update_SurfaceFrameMarker:
1757 free(msg->wParam);
1758 break;
1759
1760 case Update_SurfaceFrameAcknowledge:
1761 case Update_SetKeyboardIndicators:
1762 case Update_SetKeyboardImeStatus:
1763 break;
1764
1765 default:
1766 return FALSE;
1767 }
1768
1769 return TRUE;
1770}
1771
1772static BOOL update_message_process_update_class(rdpUpdateProxy* proxy, wMessage* msg, int type)
1773{
1774 BOOL rc = FALSE;
1775
1776 if (!proxy || !msg)
1777 return FALSE;
1778
1779 switch (type)
1780 {
1781 case Update_BeginPaint:
1782 rc = IFCALLRESULT(TRUE, proxy->BeginPaint, msg->context);
1783 break;
1784
1785 case Update_EndPaint:
1786 rc = IFCALLRESULT(TRUE, proxy->EndPaint, msg->context);
1787 break;
1788
1789 case Update_SetBounds:
1790 rc = IFCALLRESULT(TRUE, proxy->SetBounds, msg->context, (rdpBounds*)msg->wParam);
1791 break;
1792
1793 case Update_Synchronize:
1794 rc = IFCALLRESULT(TRUE, proxy->Synchronize, msg->context);
1795 break;
1796
1797 case Update_DesktopResize:
1798 rc = IFCALLRESULT(TRUE, proxy->DesktopResize, msg->context);
1799 break;
1800
1801 case Update_BitmapUpdate:
1802 rc = IFCALLRESULT(TRUE, proxy->BitmapUpdate, msg->context, (BITMAP_UPDATE*)msg->wParam);
1803 break;
1804
1805 case Update_Palette:
1806 rc = IFCALLRESULT(TRUE, proxy->Palette, msg->context, (PALETTE_UPDATE*)msg->wParam);
1807 break;
1808
1809 case Update_PlaySound:
1810 rc =
1811 IFCALLRESULT(TRUE, proxy->PlaySound, msg->context, (PLAY_SOUND_UPDATE*)msg->wParam);
1812 break;
1813
1814 case Update_RefreshRect:
1815 rc = IFCALLRESULT(TRUE, proxy->RefreshRect, msg->context, (BYTE)(size_t)msg->wParam,
1816 (RECTANGLE_16*)msg->lParam);
1817 break;
1818
1819 case Update_SuppressOutput:
1820 rc = IFCALLRESULT(TRUE, proxy->SuppressOutput, msg->context, (BYTE)(size_t)msg->wParam,
1821 (RECTANGLE_16*)msg->lParam);
1822 break;
1823
1824 case Update_SurfaceCommand:
1825 rc = IFCALLRESULT(TRUE, proxy->SurfaceCommand, msg->context, (wStream*)msg->wParam);
1826 break;
1827
1828 case Update_SurfaceBits:
1829 rc = IFCALLRESULT(TRUE, proxy->SurfaceBits, msg->context,
1830 (SURFACE_BITS_COMMAND*)msg->wParam);
1831 break;
1832
1833 case Update_SurfaceFrameMarker:
1834 rc = IFCALLRESULT(TRUE, proxy->SurfaceFrameMarker, msg->context,
1835 (SURFACE_FRAME_MARKER*)msg->wParam);
1836 break;
1837
1838 case Update_SurfaceFrameAcknowledge:
1839 rc = IFCALLRESULT(TRUE, proxy->SurfaceFrameAcknowledge, msg->context,
1840 (UINT32)(size_t)msg->wParam);
1841 break;
1842
1843 case Update_SetKeyboardIndicators:
1844 rc = IFCALLRESULT(TRUE, proxy->SetKeyboardIndicators, msg->context,
1845 (UINT16)(size_t)msg->wParam);
1846 break;
1847
1848 case Update_SetKeyboardImeStatus:
1849 {
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,
1854 imeConvMode);
1855 }
1856 break;
1857
1858 default:
1859 break;
1860 }
1861
1862 return rc;
1863}
1864
1865static BOOL update_message_free_primary_update_class(wMessage* msg, int type)
1866{
1867 if (!msg)
1868 return FALSE;
1869
1870 switch (type)
1871 {
1872 case PrimaryUpdate_DstBlt:
1873 free(msg->wParam);
1874 break;
1875
1876 case PrimaryUpdate_PatBlt:
1877 free(msg->wParam);
1878 break;
1879
1880 case PrimaryUpdate_ScrBlt:
1881 free(msg->wParam);
1882 break;
1883
1884 case PrimaryUpdate_OpaqueRect:
1885 free(msg->wParam);
1886 break;
1887
1888 case PrimaryUpdate_DrawNineGrid:
1889 free(msg->wParam);
1890 break;
1891
1892 case PrimaryUpdate_MultiDstBlt:
1893 free(msg->wParam);
1894 break;
1895
1896 case PrimaryUpdate_MultiPatBlt:
1897 free(msg->wParam);
1898 break;
1899
1900 case PrimaryUpdate_MultiScrBlt:
1901 free(msg->wParam);
1902 break;
1903
1904 case PrimaryUpdate_MultiOpaqueRect:
1905 free(msg->wParam);
1906 break;
1907
1908 case PrimaryUpdate_MultiDrawNineGrid:
1909 free(msg->wParam);
1910 break;
1911
1912 case PrimaryUpdate_LineTo:
1913 free(msg->wParam);
1914 break;
1915
1916 case PrimaryUpdate_Polyline:
1917 {
1918 POLYLINE_ORDER* wParam = (POLYLINE_ORDER*)msg->wParam;
1919 free(wParam->points);
1920 free(wParam);
1921 }
1922 break;
1923
1924 case PrimaryUpdate_MemBlt:
1925 free(msg->wParam);
1926 break;
1927
1928 case PrimaryUpdate_Mem3Blt:
1929 free(msg->wParam);
1930 break;
1931
1932 case PrimaryUpdate_SaveBitmap:
1933 free(msg->wParam);
1934 break;
1935
1936 case PrimaryUpdate_GlyphIndex:
1937 free(msg->wParam);
1938 break;
1939
1940 case PrimaryUpdate_FastIndex:
1941 free(msg->wParam);
1942 break;
1943
1944 case PrimaryUpdate_FastGlyph:
1945 {
1946 FAST_GLYPH_ORDER* wParam = (FAST_GLYPH_ORDER*)msg->wParam;
1947 free(wParam->glyphData.aj);
1948 free(wParam);
1949 }
1950 break;
1951
1952 case PrimaryUpdate_PolygonSC:
1953 {
1954 POLYGON_SC_ORDER* wParam = (POLYGON_SC_ORDER*)msg->wParam;
1955 free(wParam->points);
1956 free(wParam);
1957 }
1958 break;
1959
1960 case PrimaryUpdate_PolygonCB:
1961 {
1962 POLYGON_CB_ORDER* wParam = (POLYGON_CB_ORDER*)msg->wParam;
1963 free(wParam->points);
1964 free(wParam);
1965 }
1966 break;
1967
1968 case PrimaryUpdate_EllipseSC:
1969 free(msg->wParam);
1970 break;
1971
1972 case PrimaryUpdate_EllipseCB:
1973 free(msg->wParam);
1974 break;
1975
1976 default:
1977 return FALSE;
1978 }
1979
1980 return TRUE;
1981}
1982
1983static BOOL update_message_process_primary_update_class(rdpUpdateProxy* proxy, wMessage* msg,
1984 int type)
1985{
1986 if (!proxy || !msg)
1987 return FALSE;
1988
1989 switch (type)
1990 {
1991 case PrimaryUpdate_DstBlt:
1992 return IFCALLRESULT(TRUE, proxy->DstBlt, msg->context, (DSTBLT_ORDER*)msg->wParam);
1993
1994 case PrimaryUpdate_PatBlt:
1995 return IFCALLRESULT(TRUE, proxy->PatBlt, msg->context, (PATBLT_ORDER*)msg->wParam);
1996
1997 case PrimaryUpdate_ScrBlt:
1998 return IFCALLRESULT(TRUE, proxy->ScrBlt, msg->context, (SCRBLT_ORDER*)msg->wParam);
1999
2000 case PrimaryUpdate_OpaqueRect:
2001 return IFCALLRESULT(TRUE, proxy->OpaqueRect, msg->context,
2002 (OPAQUE_RECT_ORDER*)msg->wParam);
2003
2004 case PrimaryUpdate_DrawNineGrid:
2005 return IFCALLRESULT(TRUE, proxy->DrawNineGrid, msg->context,
2006 (DRAW_NINE_GRID_ORDER*)msg->wParam);
2007
2008 case PrimaryUpdate_MultiDstBlt:
2009 return IFCALLRESULT(TRUE, proxy->MultiDstBlt, msg->context,
2010 (MULTI_DSTBLT_ORDER*)msg->wParam);
2011
2012 case PrimaryUpdate_MultiPatBlt:
2013 return IFCALLRESULT(TRUE, proxy->MultiPatBlt, msg->context,
2014 (MULTI_PATBLT_ORDER*)msg->wParam);
2015
2016 case PrimaryUpdate_MultiScrBlt:
2017 return IFCALLRESULT(TRUE, proxy->MultiScrBlt, msg->context,
2018 (MULTI_SCRBLT_ORDER*)msg->wParam);
2019
2020 case PrimaryUpdate_MultiOpaqueRect:
2021 return IFCALLRESULT(TRUE, proxy->MultiOpaqueRect, msg->context,
2022 (MULTI_OPAQUE_RECT_ORDER*)msg->wParam);
2023
2024 case PrimaryUpdate_MultiDrawNineGrid:
2025 return IFCALLRESULT(TRUE, proxy->MultiDrawNineGrid, msg->context,
2026 (MULTI_DRAW_NINE_GRID_ORDER*)msg->wParam);
2027
2028 case PrimaryUpdate_LineTo:
2029 return IFCALLRESULT(TRUE, proxy->LineTo, msg->context, (LINE_TO_ORDER*)msg->wParam);
2030
2031 case PrimaryUpdate_Polyline:
2032 return IFCALLRESULT(TRUE, proxy->Polyline, msg->context, (POLYLINE_ORDER*)msg->wParam);
2033
2034 case PrimaryUpdate_MemBlt:
2035 return IFCALLRESULT(TRUE, proxy->MemBlt, msg->context, (MEMBLT_ORDER*)msg->wParam);
2036
2037 case PrimaryUpdate_Mem3Blt:
2038 return IFCALLRESULT(TRUE, proxy->Mem3Blt, msg->context, (MEM3BLT_ORDER*)msg->wParam);
2039
2040 case PrimaryUpdate_SaveBitmap:
2041 return IFCALLRESULT(TRUE, proxy->SaveBitmap, msg->context,
2042 (SAVE_BITMAP_ORDER*)msg->wParam);
2043
2044 case PrimaryUpdate_GlyphIndex:
2045 return IFCALLRESULT(TRUE, proxy->GlyphIndex, msg->context,
2046 (GLYPH_INDEX_ORDER*)msg->wParam);
2047
2048 case PrimaryUpdate_FastIndex:
2049 return IFCALLRESULT(TRUE, proxy->FastIndex, msg->context,
2050 (FAST_INDEX_ORDER*)msg->wParam);
2051
2052 case PrimaryUpdate_FastGlyph:
2053 return IFCALLRESULT(TRUE, proxy->FastGlyph, msg->context,
2054 (FAST_GLYPH_ORDER*)msg->wParam);
2055
2056 case PrimaryUpdate_PolygonSC:
2057 return IFCALLRESULT(TRUE, proxy->PolygonSC, msg->context,
2058 (POLYGON_SC_ORDER*)msg->wParam);
2059
2060 case PrimaryUpdate_PolygonCB:
2061 return IFCALLRESULT(TRUE, proxy->PolygonCB, msg->context,
2062 (POLYGON_CB_ORDER*)msg->wParam);
2063
2064 case PrimaryUpdate_EllipseSC:
2065 return IFCALLRESULT(TRUE, proxy->EllipseSC, msg->context,
2066 (ELLIPSE_SC_ORDER*)msg->wParam);
2067
2068 case PrimaryUpdate_EllipseCB:
2069 return IFCALLRESULT(TRUE, proxy->EllipseCB, msg->context,
2070 (ELLIPSE_CB_ORDER*)msg->wParam);
2071
2072 default:
2073 return FALSE;
2074 }
2075}
2076
2077static BOOL update_message_free_secondary_update_class(wMessage* msg, int type)
2078{
2079 rdpContext* context = nullptr;
2080
2081 if (!msg)
2082 return FALSE;
2083
2084 context = msg->context;
2085
2086 switch (type)
2087 {
2088 case SecondaryUpdate_CacheBitmap:
2089 {
2090 CACHE_BITMAP_ORDER* wParam = (CACHE_BITMAP_ORDER*)msg->wParam;
2091 free_cache_bitmap_order(context, wParam);
2092 }
2093 break;
2094
2095 case SecondaryUpdate_CacheBitmapV2:
2096 {
2097 CACHE_BITMAP_V2_ORDER* wParam = (CACHE_BITMAP_V2_ORDER*)msg->wParam;
2098 free_cache_bitmap_v2_order(context, wParam);
2099 }
2100 break;
2101
2102 case SecondaryUpdate_CacheBitmapV3:
2103 {
2104 CACHE_BITMAP_V3_ORDER* wParam = (CACHE_BITMAP_V3_ORDER*)msg->wParam;
2105 free_cache_bitmap_v3_order(context, wParam);
2106 }
2107 break;
2108
2109 case SecondaryUpdate_CacheColorTable:
2110 {
2111 CACHE_COLOR_TABLE_ORDER* wParam = (CACHE_COLOR_TABLE_ORDER*)msg->wParam;
2112 free_cache_color_table_order(context, wParam);
2113 }
2114 break;
2115
2116 case SecondaryUpdate_CacheGlyph:
2117 {
2118 CACHE_GLYPH_ORDER* wParam = (CACHE_GLYPH_ORDER*)msg->wParam;
2119 free_cache_glyph_order(context, wParam);
2120 }
2121 break;
2122
2123 case SecondaryUpdate_CacheGlyphV2:
2124 {
2125 CACHE_GLYPH_V2_ORDER* wParam = (CACHE_GLYPH_V2_ORDER*)msg->wParam;
2126 free_cache_glyph_v2_order(context, wParam);
2127 }
2128 break;
2129
2130 case SecondaryUpdate_CacheBrush:
2131 {
2132 CACHE_BRUSH_ORDER* wParam = (CACHE_BRUSH_ORDER*)msg->wParam;
2133 free_cache_brush_order(context, wParam);
2134 }
2135 break;
2136
2137 default:
2138 return FALSE;
2139 }
2140
2141 return TRUE;
2142}
2143
2144static BOOL update_message_process_secondary_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2145 int type)
2146{
2147 if (!proxy || !msg)
2148 return FALSE;
2149
2150 switch (type)
2151 {
2152 case SecondaryUpdate_CacheBitmap:
2153 return IFCALLRESULT(TRUE, proxy->CacheBitmap, msg->context,
2154 (CACHE_BITMAP_ORDER*)msg->wParam);
2155
2156 case SecondaryUpdate_CacheBitmapV2:
2157 return IFCALLRESULT(TRUE, proxy->CacheBitmapV2, msg->context,
2158 (CACHE_BITMAP_V2_ORDER*)msg->wParam);
2159
2160 case SecondaryUpdate_CacheBitmapV3:
2161 return IFCALLRESULT(TRUE, proxy->CacheBitmapV3, msg->context,
2162 (CACHE_BITMAP_V3_ORDER*)msg->wParam);
2163
2164 case SecondaryUpdate_CacheColorTable:
2165 return IFCALLRESULT(TRUE, proxy->CacheColorTable, msg->context,
2166 (CACHE_COLOR_TABLE_ORDER*)msg->wParam);
2167
2168 case SecondaryUpdate_CacheGlyph:
2169 return IFCALLRESULT(TRUE, proxy->CacheGlyph, msg->context,
2170 (CACHE_GLYPH_ORDER*)msg->wParam);
2171
2172 case SecondaryUpdate_CacheGlyphV2:
2173 return IFCALLRESULT(TRUE, proxy->CacheGlyphV2, msg->context,
2174 (CACHE_GLYPH_V2_ORDER*)msg->wParam);
2175
2176 case SecondaryUpdate_CacheBrush:
2177 return IFCALLRESULT(TRUE, proxy->CacheBrush, msg->context,
2178 (CACHE_BRUSH_ORDER*)msg->wParam);
2179
2180 default:
2181 return FALSE;
2182 }
2183}
2184
2185static BOOL update_message_free_altsec_update_class(wMessage* msg, int type)
2186{
2187 if (!msg)
2188 return FALSE;
2189
2190 switch (type)
2191 {
2192 case AltSecUpdate_CreateOffscreenBitmap:
2193 {
2195 free(wParam->deleteList.indices);
2196 free(wParam);
2197 }
2198 break;
2199
2200 case AltSecUpdate_SwitchSurface:
2201 free(msg->wParam);
2202 break;
2203
2204 case AltSecUpdate_CreateNineGridBitmap:
2205 free(msg->wParam);
2206 break;
2207
2208 case AltSecUpdate_FrameMarker:
2209 free(msg->wParam);
2210 break;
2211
2212 case AltSecUpdate_StreamBitmapFirst:
2213 free(msg->wParam);
2214 break;
2215
2216 case AltSecUpdate_StreamBitmapNext:
2217 free(msg->wParam);
2218 break;
2219
2220 case AltSecUpdate_DrawGdiPlusFirst:
2221 free(msg->wParam);
2222 break;
2223
2224 case AltSecUpdate_DrawGdiPlusNext:
2225 free(msg->wParam);
2226 break;
2227
2228 case AltSecUpdate_DrawGdiPlusEnd:
2229 free(msg->wParam);
2230 break;
2231
2232 case AltSecUpdate_DrawGdiPlusCacheFirst:
2233 free(msg->wParam);
2234 break;
2235
2236 case AltSecUpdate_DrawGdiPlusCacheNext:
2237 free(msg->wParam);
2238 break;
2239
2240 case AltSecUpdate_DrawGdiPlusCacheEnd:
2241 free(msg->wParam);
2242 break;
2243
2244 default:
2245 return FALSE;
2246 }
2247
2248 return TRUE;
2249}
2250
2251static BOOL update_message_process_altsec_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2252 int type)
2253{
2254 if (!proxy || !msg)
2255 return FALSE;
2256
2257 switch (type)
2258 {
2259 case AltSecUpdate_CreateOffscreenBitmap:
2260 return IFCALLRESULT(TRUE, proxy->CreateOffscreenBitmap, msg->context,
2261 (CREATE_OFFSCREEN_BITMAP_ORDER*)msg->wParam);
2262
2263 case AltSecUpdate_SwitchSurface:
2264 return IFCALLRESULT(TRUE, proxy->SwitchSurface, msg->context,
2265 (SWITCH_SURFACE_ORDER*)msg->wParam);
2266
2267 case AltSecUpdate_CreateNineGridBitmap:
2268 return IFCALLRESULT(TRUE, proxy->CreateNineGridBitmap, msg->context,
2269 (CREATE_NINE_GRID_BITMAP_ORDER*)msg->wParam);
2270
2271 case AltSecUpdate_FrameMarker:
2272 return IFCALLRESULT(TRUE, proxy->FrameMarker, msg->context,
2273 (FRAME_MARKER_ORDER*)msg->wParam);
2274
2275 case AltSecUpdate_StreamBitmapFirst:
2276 return IFCALLRESULT(TRUE, proxy->StreamBitmapFirst, msg->context,
2277 (STREAM_BITMAP_FIRST_ORDER*)msg->wParam);
2278
2279 case AltSecUpdate_StreamBitmapNext:
2280 return IFCALLRESULT(TRUE, proxy->StreamBitmapNext, msg->context,
2281 (STREAM_BITMAP_NEXT_ORDER*)msg->wParam);
2282
2283 case AltSecUpdate_DrawGdiPlusFirst:
2284 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusFirst, msg->context,
2285 (DRAW_GDIPLUS_FIRST_ORDER*)msg->wParam);
2286
2287 case AltSecUpdate_DrawGdiPlusNext:
2288 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusNext, msg->context,
2289 (DRAW_GDIPLUS_NEXT_ORDER*)msg->wParam);
2290
2291 case AltSecUpdate_DrawGdiPlusEnd:
2292 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusEnd, msg->context,
2293 (DRAW_GDIPLUS_END_ORDER*)msg->wParam);
2294
2295 case AltSecUpdate_DrawGdiPlusCacheFirst:
2296 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusCacheFirst, msg->context,
2297 (DRAW_GDIPLUS_CACHE_FIRST_ORDER*)msg->wParam);
2298
2299 case AltSecUpdate_DrawGdiPlusCacheNext:
2300 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusCacheNext, msg->context,
2301 (DRAW_GDIPLUS_CACHE_NEXT_ORDER*)msg->wParam);
2302
2303 case AltSecUpdate_DrawGdiPlusCacheEnd:
2304 return IFCALLRESULT(TRUE, proxy->DrawGdiPlusCacheEnd, msg->context,
2305 (DRAW_GDIPLUS_CACHE_END_ORDER*)msg->wParam);
2306
2307 default:
2308 return FALSE;
2309 }
2310}
2311
2312static BOOL update_message_free_window_update_class(wMessage* msg, int type)
2313{
2314 if (!msg)
2315 return FALSE;
2316
2317 switch (type)
2318 {
2319 case WindowUpdate_WindowCreate:
2320 free(msg->wParam);
2321 free(msg->lParam);
2322 break;
2323
2324 case WindowUpdate_WindowUpdate:
2325 free(msg->wParam);
2326 free(msg->lParam);
2327 break;
2328
2329 case WindowUpdate_WindowIcon:
2330 {
2331 WINDOW_ORDER_INFO* orderInfo = (WINDOW_ORDER_INFO*)msg->wParam;
2332 WINDOW_ICON_ORDER* windowIcon = (WINDOW_ICON_ORDER*)msg->lParam;
2333
2334 if (windowIcon->iconInfo->cbBitsColor > 0)
2335 {
2336 free(windowIcon->iconInfo->bitsColor);
2337 }
2338
2339 if (windowIcon->iconInfo->cbBitsMask > 0)
2340 {
2341 free(windowIcon->iconInfo->bitsMask);
2342 }
2343
2344 if (windowIcon->iconInfo->cbColorTable > 0)
2345 {
2346 free(windowIcon->iconInfo->colorTable);
2347 }
2348
2349 free(orderInfo);
2350 free(windowIcon->iconInfo);
2351 free(windowIcon);
2352 }
2353 break;
2354
2355 case WindowUpdate_WindowCachedIcon:
2356 free(msg->wParam);
2357 free(msg->lParam);
2358 break;
2359
2360 case WindowUpdate_WindowDelete:
2361 free(msg->wParam);
2362 break;
2363
2364 case WindowUpdate_NotifyIconCreate:
2365 free(msg->wParam);
2366 free(msg->lParam);
2367 break;
2368
2369 case WindowUpdate_NotifyIconUpdate:
2370 free(msg->wParam);
2371 free(msg->lParam);
2372 break;
2373
2374 case WindowUpdate_NotifyIconDelete:
2375 free(msg->wParam);
2376 break;
2377
2378 case WindowUpdate_MonitoredDesktop:
2379 {
2380 MONITORED_DESKTOP_ORDER* lParam = (MONITORED_DESKTOP_ORDER*)msg->lParam;
2381 free(msg->wParam);
2382 free(lParam->windowIds);
2383 free(lParam);
2384 }
2385 break;
2386
2387 case WindowUpdate_NonMonitoredDesktop:
2388 free(msg->wParam);
2389 break;
2390
2391 default:
2392 return FALSE;
2393 }
2394
2395 return TRUE;
2396}
2397
2398static BOOL update_message_process_window_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2399 int type)
2400{
2401 if (!proxy || !msg)
2402 return FALSE;
2403
2404 switch (type)
2405 {
2406 case WindowUpdate_WindowCreate:
2407 return IFCALLRESULT(TRUE, proxy->WindowCreate, msg->context,
2408 (WINDOW_ORDER_INFO*)msg->wParam, (WINDOW_STATE_ORDER*)msg->lParam);
2409
2410 case WindowUpdate_WindowUpdate:
2411 return IFCALLRESULT(TRUE, proxy->WindowCreate, msg->context,
2412 (WINDOW_ORDER_INFO*)msg->wParam, (WINDOW_STATE_ORDER*)msg->lParam);
2413
2414 case WindowUpdate_WindowIcon:
2415 {
2416 WINDOW_ORDER_INFO* orderInfo = (WINDOW_ORDER_INFO*)msg->wParam;
2417 WINDOW_ICON_ORDER* windowIcon = (WINDOW_ICON_ORDER*)msg->lParam;
2418 return IFCALLRESULT(TRUE, proxy->WindowIcon, msg->context, orderInfo, windowIcon);
2419 }
2420
2421 case WindowUpdate_WindowCachedIcon:
2422 return IFCALLRESULT(TRUE, proxy->WindowCachedIcon, msg->context,
2423 (WINDOW_ORDER_INFO*)msg->wParam,
2424 (WINDOW_CACHED_ICON_ORDER*)msg->lParam);
2425
2426 case WindowUpdate_WindowDelete:
2427 return IFCALLRESULT(TRUE, proxy->WindowDelete, msg->context,
2428 (WINDOW_ORDER_INFO*)msg->wParam);
2429
2430 case WindowUpdate_NotifyIconCreate:
2431 return IFCALLRESULT(TRUE, proxy->NotifyIconCreate, msg->context,
2432 (WINDOW_ORDER_INFO*)msg->wParam,
2433 (NOTIFY_ICON_STATE_ORDER*)msg->lParam);
2434
2435 case WindowUpdate_NotifyIconUpdate:
2436 return IFCALLRESULT(TRUE, proxy->NotifyIconUpdate, msg->context,
2437 (WINDOW_ORDER_INFO*)msg->wParam,
2438 (NOTIFY_ICON_STATE_ORDER*)msg->lParam);
2439
2440 case WindowUpdate_NotifyIconDelete:
2441 return IFCALLRESULT(TRUE, proxy->NotifyIconDelete, msg->context,
2442 (WINDOW_ORDER_INFO*)msg->wParam);
2443
2444 case WindowUpdate_MonitoredDesktop:
2445 return IFCALLRESULT(TRUE, proxy->MonitoredDesktop, msg->context,
2446 (WINDOW_ORDER_INFO*)msg->wParam,
2447 (MONITORED_DESKTOP_ORDER*)msg->lParam);
2448
2449 case WindowUpdate_NonMonitoredDesktop:
2450 return IFCALLRESULT(TRUE, proxy->NonMonitoredDesktop, msg->context,
2451 (WINDOW_ORDER_INFO*)msg->wParam);
2452
2453 default:
2454 return FALSE;
2455 }
2456}
2457
2458static BOOL update_message_free_pointer_update_class(wMessage* msg, int type)
2459{
2460 rdpContext* context = nullptr;
2461
2462 if (!msg)
2463 return FALSE;
2464
2465 context = msg->context;
2466
2467 switch (type)
2468 {
2469 case PointerUpdate_PointerPosition:
2470 {
2471 POINTER_POSITION_UPDATE* wParam = (POINTER_POSITION_UPDATE*)msg->wParam;
2472 free_pointer_position_update(context, wParam);
2473 }
2474 break;
2475
2476 case PointerUpdate_PointerSystem:
2477 {
2478 POINTER_SYSTEM_UPDATE* wParam = (POINTER_SYSTEM_UPDATE*)msg->wParam;
2479 free_pointer_system_update(context, wParam);
2480 }
2481 break;
2482
2483 case PointerUpdate_PointerCached:
2484 {
2485 POINTER_CACHED_UPDATE* wParam = (POINTER_CACHED_UPDATE*)msg->wParam;
2486 free_pointer_cached_update(context, wParam);
2487 }
2488 break;
2489
2490 case PointerUpdate_PointerColor:
2491 {
2492 POINTER_COLOR_UPDATE* wParam = (POINTER_COLOR_UPDATE*)msg->wParam;
2493 free_pointer_color_update(context, wParam);
2494 }
2495 break;
2496
2497 case PointerUpdate_PointerNew:
2498 {
2499 POINTER_NEW_UPDATE* wParam = (POINTER_NEW_UPDATE*)msg->wParam;
2500 free_pointer_new_update(context, wParam);
2501 }
2502 break;
2503
2504 default:
2505 return FALSE;
2506 }
2507
2508 return TRUE;
2509}
2510
2511static BOOL update_message_process_pointer_update_class(rdpUpdateProxy* proxy, wMessage* msg,
2512 int type)
2513{
2514 if (!proxy || !msg)
2515 return FALSE;
2516
2517 switch (type)
2518 {
2519 case PointerUpdate_PointerPosition:
2520 return IFCALLRESULT(TRUE, proxy->PointerPosition, msg->context,
2521 (POINTER_POSITION_UPDATE*)msg->wParam);
2522
2523 case PointerUpdate_PointerSystem:
2524 return IFCALLRESULT(TRUE, proxy->PointerSystem, msg->context,
2525 (POINTER_SYSTEM_UPDATE*)msg->wParam);
2526
2527 case PointerUpdate_PointerColor:
2528 return IFCALLRESULT(TRUE, proxy->PointerColor, msg->context,
2529 (POINTER_COLOR_UPDATE*)msg->wParam);
2530
2531 case PointerUpdate_PointerNew:
2532 return IFCALLRESULT(TRUE, proxy->PointerNew, msg->context,
2533 (POINTER_NEW_UPDATE*)msg->wParam);
2534
2535 case PointerUpdate_PointerCached:
2536 return IFCALLRESULT(TRUE, proxy->PointerCached, msg->context,
2537 (POINTER_CACHED_UPDATE*)msg->wParam);
2538
2539 default:
2540 return FALSE;
2541 }
2542}
2543
2544static BOOL update_message_free_class(wMessage* msg, int msgClass, int msgType)
2545{
2546 BOOL status = FALSE;
2547
2548 switch (msgClass)
2549 {
2550 case Update_Class:
2551 status = update_message_free_update_class(msg, msgType);
2552 break;
2553
2554 case PrimaryUpdate_Class:
2555 status = update_message_free_primary_update_class(msg, msgType);
2556 break;
2557
2558 case SecondaryUpdate_Class:
2559 status = update_message_free_secondary_update_class(msg, msgType);
2560 break;
2561
2562 case AltSecUpdate_Class:
2563 status = update_message_free_altsec_update_class(msg, msgType);
2564 break;
2565
2566 case WindowUpdate_Class:
2567 status = update_message_free_window_update_class(msg, msgType);
2568 break;
2569
2570 case PointerUpdate_Class:
2571 status = update_message_free_pointer_update_class(msg, msgType);
2572 break;
2573
2574 default:
2575 break;
2576 }
2577
2578 if (!status)
2579 WLog_ERR(TAG, "Unknown message: class: %d type: %d", msgClass, msgType);
2580
2581 return status;
2582}
2583
2584static int update_message_process_class(rdpUpdateProxy* proxy, wMessage* msg, int msgClass,
2585 int msgType)
2586{
2587 BOOL status = FALSE;
2588
2589 switch (msgClass)
2590 {
2591 case Update_Class:
2592 status = update_message_process_update_class(proxy, msg, msgType);
2593 break;
2594
2595 case PrimaryUpdate_Class:
2596 status = update_message_process_primary_update_class(proxy, msg, msgType);
2597 break;
2598
2599 case SecondaryUpdate_Class:
2600 status = update_message_process_secondary_update_class(proxy, msg, msgType);
2601 break;
2602
2603 case AltSecUpdate_Class:
2604 status = update_message_process_altsec_update_class(proxy, msg, msgType);
2605 break;
2606
2607 case WindowUpdate_Class:
2608 status = update_message_process_window_update_class(proxy, msg, msgType);
2609 break;
2610
2611 case PointerUpdate_Class:
2612 status = update_message_process_pointer_update_class(proxy, msg, msgType);
2613 break;
2614
2615 default:
2616 status = FALSE;
2617 break;
2618 }
2619
2620 if (!status)
2621 {
2622 WLog_ERR(TAG, "message: class: %d type: %d failed", msgClass, msgType);
2623 return -1;
2624 }
2625
2626 return 0;
2627}
2628
2629int update_message_queue_process_message(rdpUpdate* update, wMessage* message)
2630{
2631 int status = 0;
2632 int msgClass = 0;
2633 int msgType = 0;
2634 rdp_update_internal* up = update_cast(update);
2635
2636 if (!update || !message)
2637 return -1;
2638
2639 if (message->id == WMQ_QUIT)
2640 return 0;
2641
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);
2646
2647 if (status < 0)
2648 return -1;
2649
2650 return 1;
2651}
2652
2653int update_message_queue_free_message(wMessage* message)
2654{
2655 int msgClass = 0;
2656 int msgType = 0;
2657
2658 if (!message)
2659 return -1;
2660
2661 if (message->id == WMQ_QUIT)
2662 return 0;
2663
2664 msgClass = GetMessageClass(message->id);
2665 msgType = GetMessageType(message->id);
2666 return update_message_free_class(message, msgClass, msgType);
2667}
2668
2669int update_message_queue_process_pending_messages(rdpUpdate* update)
2670{
2671 int status = 1;
2672 wMessage message = WINPR_C_ARRAY_INIT;
2673 rdp_update_internal* up = update_cast(update);
2674
2675 wMessageQueue* queue = up->queue;
2676
2677 while (MessageQueue_Peek(queue, &message, TRUE))
2678 {
2679 status = update_message_queue_process_message(update, &message);
2680
2681 if (!status)
2682 break;
2683 }
2684
2685 return status;
2686}
2687
2688static BOOL update_message_register_interface(rdpUpdateProxy* message, rdpUpdate* update)
2689{
2690 rdpPrimaryUpdate* primary = nullptr;
2691 rdpSecondaryUpdate* secondary = nullptr;
2692 rdpAltSecUpdate* altsec = nullptr;
2693 rdpWindowUpdate* window = nullptr;
2694 rdpPointerUpdate* pointer = nullptr;
2695
2696 if (!message || !update)
2697 return FALSE;
2698
2699 primary = update->primary;
2700 secondary = update->secondary;
2701 altsec = update->altsec;
2702 window = update->window;
2703 pointer = update->pointer;
2704
2705 if (!primary || !secondary || !altsec || !window || !pointer)
2706 return FALSE;
2707
2708 /* Update */
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;
2741 /* Primary Update */
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;
2786 /* Secondary Update */
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;
2801 /* Alternate Secondary Update */
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;
2826 /* Window Update */
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;
2847 /* Pointer Update */
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;
2860 return TRUE;
2861}
2862
2863static DWORD WINAPI update_message_proxy_thread(LPVOID arg)
2864{
2865 rdpUpdate* update = (rdpUpdate*)arg;
2866 wMessage message = WINPR_C_ARRAY_INIT;
2867 rdp_update_internal* up = update_cast(update);
2868
2869 while (MessageQueue_Wait(up->queue))
2870 {
2871 int status = 0;
2872
2873 if (MessageQueue_Peek(up->queue, &message, TRUE))
2874 status = update_message_queue_process_message(update, &message);
2875
2876 if (!status)
2877 break;
2878 }
2879
2880 ExitThread(0);
2881 return 0;
2882}
2883
2884rdpUpdateProxy* update_message_proxy_new(rdpUpdate* update)
2885{
2886 rdpUpdateProxy* message = nullptr;
2887
2888 if (!update)
2889 return nullptr;
2890
2891 if (!(message = (rdpUpdateProxy*)calloc(1, sizeof(rdpUpdateProxy))))
2892 return nullptr;
2893
2894 message->update = update;
2895 update_message_register_interface(message, update);
2896
2897 if (!(message->thread =
2898 CreateThread(nullptr, 0, update_message_proxy_thread, update, 0, nullptr)))
2899 {
2900 WLog_ERR(TAG, "Failed to create proxy thread");
2901 free(message);
2902 return nullptr;
2903 }
2904
2905 return message;
2906}
2907
2908void update_message_proxy_free(rdpUpdateProxy* message)
2909{
2910 if (message)
2911 {
2912 rdp_update_internal* up = update_cast(message->update);
2913 if (MessageQueue_PostQuit(up->queue, 0))
2914 (void)WaitForSingleObject(message->thread, INFINITE);
2915
2916 (void)CloseHandle(message->thread);
2917 free(message);
2918 }
2919}
2920
2921/* Event Queue */
2922static int input_message_free_input_class(wMessage* msg, int type)
2923{
2924 int status = 0;
2925
2926 WINPR_UNUSED(msg);
2927
2928 switch (type)
2929 {
2930 case Input_SynchronizeEvent:
2931 break;
2932
2933 case Input_KeyboardEvent:
2934 break;
2935
2936 case Input_UnicodeKeyboardEvent:
2937 break;
2938
2939 case Input_MouseEvent:
2940 break;
2941
2942 case Input_ExtendedMouseEvent:
2943 break;
2944
2945 case Input_FocusInEvent:
2946 break;
2947
2948 case Input_KeyboardPauseEvent:
2949 break;
2950
2951 default:
2952 status = -1;
2953 break;
2954 }
2955
2956 return status;
2957}
2958
2959static int input_message_process_input_class(rdpInputProxy* proxy, wMessage* msg, int type)
2960{
2961 int status = 0;
2962
2963 if (!proxy || !msg)
2964 return -1;
2965
2966 switch (type)
2967 {
2968 case Input_SynchronizeEvent:
2969 IFCALL(proxy->SynchronizeEvent, msg->context, (UINT32)(size_t)msg->wParam);
2970 break;
2971
2972 case Input_KeyboardEvent:
2973 IFCALL(proxy->KeyboardEvent, msg->context, (UINT16)(size_t)msg->wParam,
2974 (UINT8)(size_t)msg->lParam);
2975 break;
2976
2977 case Input_UnicodeKeyboardEvent:
2978 IFCALL(proxy->UnicodeKeyboardEvent, msg->context, (UINT16)(size_t)msg->wParam,
2979 (UINT16)(size_t)msg->lParam);
2980 break;
2981
2982 case Input_MouseEvent:
2983 {
2984 UINT32 pos = 0;
2985 UINT16 x = 0;
2986 UINT16 y = 0;
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);
2991 }
2992 break;
2993
2994 case Input_ExtendedMouseEvent:
2995 {
2996 UINT32 pos = 0;
2997 UINT16 x = 0;
2998 UINT16 y = 0;
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);
3003 }
3004 break;
3005
3006 case Input_FocusInEvent:
3007 IFCALL(proxy->FocusInEvent, msg->context, (UINT16)(size_t)msg->wParam);
3008 break;
3009
3010 case Input_KeyboardPauseEvent:
3011 IFCALL(proxy->KeyboardPauseEvent, msg->context);
3012 break;
3013
3014 default:
3015 status = -1;
3016 break;
3017 }
3018
3019 return status;
3020}
3021
3022static int input_message_free_class(wMessage* msg, int msgClass, int msgType)
3023{
3024 int status = 0;
3025
3026 switch (msgClass)
3027 {
3028 case Input_Class:
3029 status = input_message_free_input_class(msg, msgType);
3030 break;
3031
3032 default:
3033 status = -1;
3034 break;
3035 }
3036
3037 if (status < 0)
3038 WLog_ERR(TAG, "Unknown event: class: %d type: %d", msgClass, msgType);
3039
3040 return status;
3041}
3042
3043static int input_message_process_class(rdpInputProxy* proxy, wMessage* msg, int msgClass,
3044 int msgType)
3045{
3046 int status = 0;
3047
3048 switch (msgClass)
3049 {
3050 case Input_Class:
3051 status = input_message_process_input_class(proxy, msg, msgType);
3052 break;
3053
3054 default:
3055 status = -1;
3056 break;
3057 }
3058
3059 if (status < 0)
3060 WLog_ERR(TAG, "Unknown event: class: %d type: %d", msgClass, msgType);
3061
3062 return status;
3063}
3064
3065int input_message_queue_free_message(wMessage* message)
3066{
3067 int status = 0;
3068 int msgClass = 0;
3069 int msgType = 0;
3070
3071 if (!message)
3072 return -1;
3073
3074 if (message->id == WMQ_QUIT)
3075 return 0;
3076
3077 msgClass = GetMessageClass(message->id);
3078 msgType = GetMessageType(message->id);
3079 status = input_message_free_class(message, msgClass, msgType);
3080
3081 if (status < 0)
3082 return -1;
3083
3084 return 1;
3085}
3086
3087int input_message_queue_process_message(rdpInput* input, wMessage* message)
3088{
3089 int status = 0;
3090 int msgClass = 0;
3091 int msgType = 0;
3092 rdp_input_internal* in = input_cast(input);
3093
3094 if (!message)
3095 return -1;
3096
3097 if (message->id == WMQ_QUIT)
3098 return 0;
3099
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);
3104
3105 if (status < 0)
3106 return -1;
3107
3108 return 1;
3109}
3110
3111int input_message_queue_process_pending_messages(rdpInput* input)
3112{
3113 int status = 1;
3114 wMessage message = WINPR_C_ARRAY_INIT;
3115 rdp_input_internal* in = input_cast(input);
3116
3117 if (!in->queue)
3118 return -1;
3119
3120 wMessageQueue* queue = in->queue;
3121
3122 while (MessageQueue_Peek(queue, &message, TRUE))
3123 {
3124 status = input_message_queue_process_message(input, &message);
3125
3126 if (!status)
3127 break;
3128 }
3129
3130 return status;
3131}