21 #include <freerdp/config.h>
25 #include <winpr/crt.h>
26 #include <winpr/assert.h>
28 #include <freerdp/log.h>
32 #define TAG FREERDP_TAG("core.window")
34 static void update_free_window_icon_info(
ICON_INFO* iconInfo);
41 if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
44 Stream_Read_UINT16(s, new_len);
46 if (!Stream_CheckAndLogRequiredLength(TAG, s, new_len))
51 free(unicode_string->string);
52 unicode_string->string = NULL;
53 unicode_string->length = 0;
57 new_str = (BYTE*)realloc(unicode_string->string, new_len);
61 free(unicode_string->string);
62 unicode_string->string = NULL;
66 unicode_string->string = new_str;
67 unicode_string->length = new_len;
68 Stream_Read(s, unicode_string->string, unicode_string->length);
76 free(unicode_string->string);
77 unicode_string->string = NULL;
78 unicode_string->length = 0;
80 if (!
string || strlen(
string) < 1)
83 buffer = ConvertUtf8ToWCharAlloc(
string, &len);
85 if (!buffer || (len *
sizeof(WCHAR) > UINT16_MAX))
91 unicode_string->string = (BYTE*)buffer;
92 unicode_string->length = (UINT16)len *
sizeof(WCHAR);
98 WINPR_ASSERT(unicode_string);
101 size_t inLen = unicode_string->length /
sizeof(WCHAR);
102 return ConvertWCharNToUtf8Alloc((
const WCHAR*)unicode_string->string, inLen, &outLen);
108 BYTE* newBitMask = NULL;
110 if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
113 Stream_Read_UINT16(s, iconInfo->cacheEntry);
114 Stream_Read_UINT8(s, iconInfo->cacheId);
115 Stream_Read_UINT8(s, iconInfo->bpp);
117 if ((iconInfo->bpp < 1) || (iconInfo->bpp > 32))
119 WLog_ERR(TAG,
"invalid bpp value %" PRIu32
"", iconInfo->bpp);
123 Stream_Read_UINT16(s, iconInfo->width);
124 Stream_Read_UINT16(s, iconInfo->height);
127 switch (iconInfo->bpp)
132 if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
135 Stream_Read_UINT16(s, iconInfo->cbColorTable);
139 iconInfo->cbColorTable = 0;
143 if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
146 Stream_Read_UINT16(s, iconInfo->cbBitsMask);
147 Stream_Read_UINT16(s, iconInfo->cbBitsColor);
150 if (iconInfo->cbBitsMask > 0)
152 newBitMask = (BYTE*)realloc(iconInfo->bitsMask, iconInfo->cbBitsMask);
156 free(iconInfo->bitsMask);
157 iconInfo->bitsMask = NULL;
161 iconInfo->bitsMask = newBitMask;
162 if (!Stream_CheckAndLogRequiredLength(TAG, s, iconInfo->cbBitsMask))
164 Stream_Read(s, iconInfo->bitsMask, iconInfo->cbBitsMask);
168 free(iconInfo->bitsMask);
169 iconInfo->bitsMask = NULL;
170 iconInfo->cbBitsMask = 0;
174 if (iconInfo->cbColorTable > 0)
176 BYTE* new_tab = NULL;
177 new_tab = (BYTE*)realloc(iconInfo->colorTable, iconInfo->cbColorTable);
181 free(iconInfo->colorTable);
182 iconInfo->colorTable = NULL;
186 iconInfo->colorTable = new_tab;
190 free(iconInfo->colorTable);
191 iconInfo->colorTable = NULL;
194 if (iconInfo->colorTable)
196 if (!Stream_CheckAndLogRequiredLength(TAG, s, iconInfo->cbColorTable))
198 Stream_Read(s, iconInfo->colorTable, iconInfo->cbColorTable);
202 if (iconInfo->cbBitsColor > 0)
204 newBitMask = (BYTE*)realloc(iconInfo->bitsColor, iconInfo->cbBitsColor);
208 free(iconInfo->bitsColor);
209 iconInfo->bitsColor = NULL;
213 iconInfo->bitsColor = newBitMask;
214 if (!Stream_CheckAndLogRequiredLength(TAG, s, iconInfo->cbBitsColor))
216 Stream_Read(s, iconInfo->bitsColor, iconInfo->cbBitsColor);
220 free(iconInfo->bitsColor);
221 iconInfo->bitsColor = NULL;
222 iconInfo->cbBitsColor = 0;
229 if (!Stream_CheckAndLogRequiredLength(TAG, s, 3))
232 Stream_Read_UINT16(s, cachedIconInfo->cacheEntry);
233 Stream_Read_UINT8(s, cachedIconInfo->cacheId);
239 if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
242 Stream_Read_UINT32(s, notifyIconInfoTip->timeout);
243 Stream_Read_UINT32(s, notifyIconInfoTip->flags);
244 return rail_read_unicode_string(s, ¬ifyIconInfoTip->text) &&
245 rail_read_unicode_string(s, ¬ifyIconInfoTip->title);
254 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_OWNER)
256 if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
259 Stream_Read_UINT32(s, windowState->ownerWindowId);
262 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_STYLE)
264 if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
267 Stream_Read_UINT32(s, windowState->style);
268 Stream_Read_UINT32(s, windowState->extendedStyle);
271 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_SHOW)
273 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
276 Stream_Read_UINT8(s, windowState->showState);
279 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_TITLE)
281 if (!rail_read_unicode_string(s, &windowState->titleInfo))
285 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET)
287 if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
290 Stream_Read_INT32(s, windowState->clientOffsetX);
291 Stream_Read_INT32(s, windowState->clientOffsetY);
294 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE)
296 if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
299 Stream_Read_UINT32(s, windowState->clientAreaWidth);
300 Stream_Read_UINT32(s, windowState->clientAreaHeight);
303 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_RESIZE_MARGIN_X)
305 if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
308 Stream_Read_UINT32(s, windowState->resizeMarginLeft);
309 Stream_Read_UINT32(s, windowState->resizeMarginRight);
312 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_RESIZE_MARGIN_Y)
314 if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
317 Stream_Read_UINT32(s, windowState->resizeMarginTop);
318 Stream_Read_UINT32(s, windowState->resizeMarginBottom);
321 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_RP_CONTENT)
323 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
326 Stream_Read_UINT8(s, windowState->RPContent);
329 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_ROOT_PARENT)
331 if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
334 Stream_Read_UINT32(s, windowState->rootParentHandle);
337 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET)
339 if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
342 Stream_Read_INT32(s, windowState->windowOffsetX);
343 Stream_Read_INT32(s, windowState->windowOffsetY);
346 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA)
348 if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
351 Stream_Read_INT32(s, windowState->windowClientDeltaX);
352 Stream_Read_INT32(s, windowState->windowClientDeltaY);
355 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE)
357 if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
360 Stream_Read_UINT32(s, windowState->windowWidth);
361 Stream_Read_UINT32(s, windowState->windowHeight);
364 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS)
366 if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
369 Stream_Read_UINT16(s, windowState->numWindowRects);
371 if (windowState->numWindowRects > 0)
373 size =
sizeof(
RECTANGLE_16) * windowState->numWindowRects;
374 newRect = (
RECTANGLE_16*)realloc(windowState->windowRects, size);
378 free(windowState->windowRects);
379 windowState->windowRects = NULL;
383 windowState->windowRects = newRect;
385 if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, windowState->numWindowRects, 8ull))
389 for (UINT32 i = 0; i < windowState->numWindowRects; i++)
391 Stream_Read_UINT16(s, windowState->windowRects[i].left);
392 Stream_Read_UINT16(s, windowState->windowRects[i].top);
393 Stream_Read_UINT16(s, windowState->windowRects[i].right);
394 Stream_Read_UINT16(s, windowState->windowRects[i].bottom);
399 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VIS_OFFSET)
401 if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
404 Stream_Read_UINT32(s, windowState->visibleOffsetX);
405 Stream_Read_UINT32(s, windowState->visibleOffsetY);
408 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY)
410 if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
413 Stream_Read_UINT16(s, windowState->numVisibilityRects);
415 if (windowState->numVisibilityRects != 0)
417 size =
sizeof(
RECTANGLE_16) * windowState->numVisibilityRects;
418 newRect = (
RECTANGLE_16*)realloc(windowState->visibilityRects, size);
422 free(windowState->visibilityRects);
423 windowState->visibilityRects = NULL;
427 windowState->visibilityRects = newRect;
429 if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, windowState->numVisibilityRects,
434 for (UINT32 i = 0; i < windowState->numVisibilityRects; i++)
436 Stream_Read_UINT16(s, windowState->visibilityRects[i].left);
437 Stream_Read_UINT16(s, windowState->visibilityRects[i].top);
438 Stream_Read_UINT16(s, windowState->visibilityRects[i].right);
439 Stream_Read_UINT16(s,
440 windowState->visibilityRects[i].bottom);
445 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_OVERLAY_DESCRIPTION)
447 if (!rail_read_unicode_string(s, &windowState->OverlayDescription))
451 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_ICON_OVERLAY_NULL)
456 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_TASKBAR_BUTTON)
458 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
461 Stream_Read_UINT8(s, windowState->TaskbarButton);
464 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_ENFORCE_SERVER_ZORDER)
466 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
469 Stream_Read_UINT8(s, windowState->EnforceServerZOrder);
472 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_APPBAR_STATE)
474 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
477 Stream_Read_UINT8(s, windowState->AppBarState);
480 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_APPBAR_EDGE)
482 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
485 Stream_Read_UINT8(s, windowState->AppBarEdge);
494 WINPR_UNUSED(orderInfo);
497 if (!window_icon->iconInfo)
500 return update_read_icon_info(s, window_icon->iconInfo);
506 WINPR_UNUSED(orderInfo);
507 return update_read_cached_icon_info(
508 s, &window_cached_icon->cachedIcon);
516 static BOOL window_order_supported(
const rdpSettings* settings, UINT32 fieldFlags)
518 const UINT32 mask = (WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE | WINDOW_ORDER_FIELD_RP_CONTENT |
519 WINDOW_ORDER_FIELD_ROOT_PARENT);
526 dresult = settings->AllowUnanouncedOrdersFromServer;
528 switch (settings->RemoteWndSupportLevel)
530 case WINDOW_LEVEL_SUPPORTED_EX:
533 case WINDOW_LEVEL_SUPPORTED:
534 return ((fieldFlags & mask) == 0) || dresult;
536 case WINDOW_LEVEL_NOT_SUPPORTED:
544 #define DUMP_APPEND(buffer, size, ...) \
547 char* b = (buffer); \
549 size_t pos = strnlen(b, s); \
550 (void)_snprintf(&b[pos], s - pos, __VA_ARGS__); \
553 static void dump_window_style(
char* buffer,
size_t bufferSize, UINT32 style)
555 DUMP_APPEND(buffer, bufferSize,
" style=<0x%" PRIx32
": ", style);
556 if (style & WS_BORDER)
557 DUMP_APPEND(buffer, bufferSize,
" border");
558 if (style & WS_CAPTION)
559 DUMP_APPEND(buffer, bufferSize,
" caption");
560 if (style & WS_CHILD)
561 DUMP_APPEND(buffer, bufferSize,
" child");
562 if (style & WS_CHILDWINDOW)
563 DUMP_APPEND(buffer, bufferSize,
" childwindow");
564 if (style & WS_CLIPCHILDREN)
565 DUMP_APPEND(buffer, bufferSize,
" clipchildren");
566 if (style & WS_CLIPSIBLINGS)
567 DUMP_APPEND(buffer, bufferSize,
" clipsiblings");
568 if (style & WS_DISABLED)
569 DUMP_APPEND(buffer, bufferSize,
" disabled");
570 if (style & WS_DLGFRAME)
571 DUMP_APPEND(buffer, bufferSize,
" dlgframe");
572 if (style & WS_GROUP)
573 DUMP_APPEND(buffer, bufferSize,
" group");
574 if (style & WS_HSCROLL)
575 DUMP_APPEND(buffer, bufferSize,
" hscroll");
576 if (style & WS_ICONIC)
577 DUMP_APPEND(buffer, bufferSize,
" iconic");
578 if (style & WS_MAXIMIZE)
579 DUMP_APPEND(buffer, bufferSize,
" maximize");
580 if (style & WS_MAXIMIZEBOX)
581 DUMP_APPEND(buffer, bufferSize,
" maximizebox");
582 if (style & WS_MINIMIZE)
583 DUMP_APPEND(buffer, bufferSize,
" minimize");
584 if (style & WS_MINIMIZEBOX)
585 DUMP_APPEND(buffer, bufferSize,
" minimizebox");
586 if (style & WS_POPUP)
587 DUMP_APPEND(buffer, bufferSize,
" popup");
588 if (style & WS_SIZEBOX)
589 DUMP_APPEND(buffer, bufferSize,
" sizebox");
590 if (style & WS_SYSMENU)
591 DUMP_APPEND(buffer, bufferSize,
" sysmenu");
592 if (style & WS_TABSTOP)
593 DUMP_APPEND(buffer, bufferSize,
" tabstop");
594 if (style & WS_THICKFRAME)
595 DUMP_APPEND(buffer, bufferSize,
" thickframe");
596 if (style & WS_VISIBLE)
597 DUMP_APPEND(buffer, bufferSize,
" visible");
598 if (style & WS_VSCROLL)
599 DUMP_APPEND(buffer, bufferSize,
" vscroll");
600 DUMP_APPEND(buffer, bufferSize,
">");
603 static void dump_window_style_ex(
char* buffer,
size_t bufferSize, UINT32 extendedStyle)
605 DUMP_APPEND(buffer, bufferSize,
" styleEx=<0x%" PRIx32
": ", extendedStyle);
606 if (extendedStyle & WS_EX_ACCEPTFILES)
607 DUMP_APPEND(buffer, bufferSize,
" acceptfiles");
608 if (extendedStyle & WS_EX_APPWINDOW)
609 DUMP_APPEND(buffer, bufferSize,
" appwindow");
610 if (extendedStyle & WS_EX_CLIENTEDGE)
611 DUMP_APPEND(buffer, bufferSize,
" clientedge");
612 if (extendedStyle & WS_EX_COMPOSITED)
613 DUMP_APPEND(buffer, bufferSize,
" composited");
614 if (extendedStyle & WS_EX_CONTEXTHELP)
615 DUMP_APPEND(buffer, bufferSize,
" contexthelp");
616 if (extendedStyle & WS_EX_CONTROLPARENT)
617 DUMP_APPEND(buffer, bufferSize,
" controlparent");
618 if (extendedStyle & WS_EX_DLGMODALFRAME)
619 DUMP_APPEND(buffer, bufferSize,
" dlgmodalframe");
620 if (extendedStyle & WS_EX_LAYERED)
621 DUMP_APPEND(buffer, bufferSize,
" layered");
622 if (extendedStyle & WS_EX_LAYOUTRTL)
623 DUMP_APPEND(buffer, bufferSize,
" layoutrtl");
624 if (extendedStyle & WS_EX_LEFT)
625 DUMP_APPEND(buffer, bufferSize,
" left");
626 if (extendedStyle & WS_EX_LEFTSCROLLBAR)
627 DUMP_APPEND(buffer, bufferSize,
" leftscrollbar");
628 if (extendedStyle & WS_EX_LTRREADING)
629 DUMP_APPEND(buffer, bufferSize,
" ltrreading");
630 if (extendedStyle & WS_EX_MDICHILD)
631 DUMP_APPEND(buffer, bufferSize,
" mdichild");
632 if (extendedStyle & WS_EX_NOACTIVATE)
633 DUMP_APPEND(buffer, bufferSize,
" noactivate");
634 if (extendedStyle & WS_EX_NOINHERITLAYOUT)
635 DUMP_APPEND(buffer, bufferSize,
" noinheritlayout");
636 #if defined(WS_EX_NOREDIRECTIONBITMAP)
637 if (extendedStyle & WS_EX_NOREDIRECTIONBITMAP)
638 DUMP_APPEND(buffer, bufferSize,
" noredirectionbitmap");
640 if (extendedStyle & WS_EX_RIGHT)
641 DUMP_APPEND(buffer, bufferSize,
" right");
642 if (extendedStyle & WS_EX_RIGHTSCROLLBAR)
643 DUMP_APPEND(buffer, bufferSize,
" rightscrollbar");
644 if (extendedStyle & WS_EX_RTLREADING)
645 DUMP_APPEND(buffer, bufferSize,
" rtlreading");
646 if (extendedStyle & WS_EX_STATICEDGE)
647 DUMP_APPEND(buffer, bufferSize,
" staticedge");
648 if (extendedStyle & WS_EX_TOOLWINDOW)
649 DUMP_APPEND(buffer, bufferSize,
" toolWindow");
650 if (extendedStyle & WS_EX_TOPMOST)
651 DUMP_APPEND(buffer, bufferSize,
" topMost");
652 if (extendedStyle & WS_EX_TRANSPARENT)
653 DUMP_APPEND(buffer, bufferSize,
" transparent");
654 if (extendedStyle & WS_EX_WINDOWEDGE)
655 DUMP_APPEND(buffer, bufferSize,
" windowedge");
656 DUMP_APPEND(buffer, bufferSize,
">");
659 static void dump_window_state_order(wLog* log,
const char* msg,
const WINDOW_ORDER_INFO* order,
662 char buffer[3000] = { 0 };
663 const size_t bufferSize =
sizeof(buffer) - 1;
665 (void)_snprintf(buffer, bufferSize,
"%s windowId=%" PRIu32
"", msg, order->windowId);
667 if (order->fieldFlags & WINDOW_ORDER_FIELD_OWNER)
668 DUMP_APPEND(buffer, bufferSize,
" owner=%" PRIu32
"", state->ownerWindowId);
669 if (order->fieldFlags & WINDOW_ORDER_FIELD_STYLE)
671 dump_window_style(buffer, bufferSize, state->style);
672 dump_window_style_ex(buffer, bufferSize, state->extendedStyle);
675 if (order->fieldFlags & WINDOW_ORDER_FIELD_SHOW)
677 const char* showStr = NULL;
678 switch (state->showState)
684 showStr =
"minimized";
687 showStr =
"maximized";
693 showStr =
"<unknown>";
696 DUMP_APPEND(buffer, bufferSize,
" show=%s", showStr);
699 if (order->fieldFlags & WINDOW_ORDER_FIELD_TITLE)
701 char* title = rail_string_to_utf8_string(&state->titleInfo);
704 DUMP_APPEND(buffer, bufferSize,
" title=\"%s\"", title);
708 DUMP_APPEND(buffer, bufferSize,
" title=<decode failed>");
710 if (order->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET)
711 DUMP_APPEND(buffer, bufferSize,
" clientOffset=(%" PRId32
",%" PRId32
")",
712 state->clientOffsetX, state->clientOffsetY);
713 if (order->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE)
714 DUMP_APPEND(buffer, bufferSize,
" clientAreaWidth=%" PRIu32
" clientAreaHeight=%" PRIu32
"",
715 state->clientAreaWidth, state->clientAreaHeight);
716 if (order->fieldFlags & WINDOW_ORDER_FIELD_RESIZE_MARGIN_X)
717 DUMP_APPEND(buffer, bufferSize,
718 " resizeMarginLeft=%" PRIu32
" resizeMarginRight=%" PRIu32
"",
719 state->resizeMarginLeft, state->resizeMarginRight);
720 if (order->fieldFlags & WINDOW_ORDER_FIELD_RESIZE_MARGIN_Y)
721 DUMP_APPEND(buffer, bufferSize,
722 " resizeMarginTop=%" PRIu32
" resizeMarginBottom=%" PRIu32
"",
723 state->resizeMarginTop, state->resizeMarginBottom);
724 if (order->fieldFlags & WINDOW_ORDER_FIELD_RP_CONTENT)
725 DUMP_APPEND(buffer, bufferSize,
" rpContent=0x%" PRIx32
"", state->RPContent);
726 if (order->fieldFlags & WINDOW_ORDER_FIELD_ROOT_PARENT)
727 DUMP_APPEND(buffer, bufferSize,
" rootParent=0x%" PRIx32
"", state->rootParentHandle);
728 if (order->fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET)
729 DUMP_APPEND(buffer, bufferSize,
" windowOffset=(%" PRId32
",%" PRId32
")",
730 state->windowOffsetX, state->windowOffsetY);
731 if (order->fieldFlags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA)
732 DUMP_APPEND(buffer, bufferSize,
" windowClientDelta=(%" PRId32
",%" PRId32
")",
733 state->windowClientDeltaX, state->windowClientDeltaY);
734 if (order->fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE)
735 DUMP_APPEND(buffer, bufferSize,
" windowWidth=%" PRIu32
" windowHeight=%" PRIu32
"",
736 state->windowWidth, state->windowHeight);
738 if (order->fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS)
740 DUMP_APPEND(buffer, bufferSize,
" windowRects=(");
741 for (UINT32 i = 0; i < state->numWindowRects; i++)
743 DUMP_APPEND(buffer, bufferSize,
"(%" PRIu16
",%" PRIu16
",%" PRIu16
",%" PRIu16
")",
744 state->windowRects[i].left, state->windowRects[i].top,
745 state->windowRects[i].right, state->windowRects[i].bottom);
747 DUMP_APPEND(buffer, bufferSize,
")");
750 if (order->fieldFlags & WINDOW_ORDER_FIELD_VIS_OFFSET)
751 DUMP_APPEND(buffer, bufferSize,
" visibleOffset=(%" PRId32
",%" PRId32
")",
752 state->visibleOffsetX, state->visibleOffsetY);
754 if (order->fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY)
756 DUMP_APPEND(buffer, bufferSize,
" visibilityRects=(");
757 for (UINT32 i = 0; i < state->numVisibilityRects; i++)
759 DUMP_APPEND(buffer, bufferSize,
"(%" PRIu16
",%" PRIu16
",%" PRIu16
",%" PRIu16
")",
760 state->visibilityRects[i].left, state->visibilityRects[i].top,
761 state->visibilityRects[i].right, state->visibilityRects[i].bottom);
763 DUMP_APPEND(buffer, bufferSize,
")");
766 if (order->fieldFlags & WINDOW_ORDER_FIELD_OVERLAY_DESCRIPTION)
767 DUMP_APPEND(buffer, bufferSize,
" overlayDescr");
769 if (order->fieldFlags & WINDOW_ORDER_FIELD_ICON_OVERLAY_NULL)
770 DUMP_APPEND(buffer, bufferSize,
" iconOverlayNull");
772 if (order->fieldFlags & WINDOW_ORDER_FIELD_TASKBAR_BUTTON)
773 DUMP_APPEND(buffer, bufferSize,
" taskBarButton=0x%" PRIx8
"", state->TaskbarButton);
775 if (order->fieldFlags & WINDOW_ORDER_FIELD_ENFORCE_SERVER_ZORDER)
776 DUMP_APPEND(buffer, bufferSize,
" enforceServerZOrder=0x%" PRIx8
"",
777 state->EnforceServerZOrder);
778 if (order->fieldFlags & WINDOW_ORDER_FIELD_APPBAR_STATE)
779 DUMP_APPEND(buffer, bufferSize,
" appBarState=0x%" PRIx8
"", state->AppBarState);
780 if (order->fieldFlags & WINDOW_ORDER_FIELD_APPBAR_EDGE)
782 const char* appBarEdgeStr = NULL;
783 switch (state->AppBarEdge)
786 appBarEdgeStr =
"left";
789 appBarEdgeStr =
"top";
792 appBarEdgeStr =
"right";
795 appBarEdgeStr =
"bottom";
798 appBarEdgeStr =
"<unknown>";
801 DUMP_APPEND(buffer, bufferSize,
" appBarEdge=%s", appBarEdgeStr);
804 WLog_Print(log, WLOG_DEBUG, buffer);
807 static BOOL update_recv_window_info_order(rdpUpdate* update,
wStream* s,
811 rdpContext* context = update->context;
812 rdpWindowUpdate* window = update->window;
817 WINPR_ASSERT(context);
818 WINPR_ASSERT(window);
819 WINPR_ASSERT(orderInfo);
821 if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
824 Stream_Read_UINT32(s, orderInfo->windowId);
826 if (orderInfo->fieldFlags & WINDOW_ORDER_ICON)
829 result = update_read_window_icon_order(s, orderInfo, &window_icon);
833 WLog_Print(up->log, WLOG_DEBUG,
"WindowIcon windowId=0x%" PRIx32
"",
834 orderInfo->windowId);
835 IFCALLRET(window->WindowIcon, result, context, orderInfo, &window_icon);
838 update_free_window_icon_info(window_icon.iconInfo);
839 free(window_icon.iconInfo);
841 else if (orderInfo->fieldFlags & WINDOW_ORDER_CACHED_ICON)
844 result = update_read_window_cached_icon_order(s, orderInfo, &window_cached_icon);
848 WLog_Print(up->log, WLOG_DEBUG,
"WindowCachedIcon windowId=0x%" PRIx32
"",
849 orderInfo->windowId);
850 IFCALLRET(window->WindowCachedIcon, result, context, orderInfo, &window_cached_icon);
853 else if (orderInfo->fieldFlags & WINDOW_ORDER_STATE_DELETED)
855 update_read_window_delete_order(s, orderInfo);
856 WLog_Print(up->log, WLOG_DEBUG,
"WindowDelete windowId=0x%" PRIx32
"", orderInfo->windowId);
857 IFCALLRET(window->WindowDelete, result, context, orderInfo);
862 result = update_read_window_state_order(s, orderInfo, &windowState);
866 if (orderInfo->fieldFlags & WINDOW_ORDER_STATE_NEW)
868 dump_window_state_order(up->log,
"WindowCreate", orderInfo, &windowState);
869 IFCALLRET(window->WindowCreate, result, context, orderInfo, &windowState);
873 dump_window_state_order(up->log,
"WindowUpdate", orderInfo, &windowState);
874 IFCALLRET(window->WindowUpdate, result, context, orderInfo, &windowState);
877 update_free_window_state(&windowState);
886 free(notify->toolTip.string);
887 free(notify->infoTip.text.string);
888 free(notify->infoTip.title.string);
889 update_free_window_icon_info(¬ify->icon);
896 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_VERSION)
898 if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
901 Stream_Read_UINT32(s, notify_icon_state->version);
904 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_TIP)
906 if (!rail_read_unicode_string(s,
907 ¬ify_icon_state->toolTip))
911 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_INFO_TIP)
913 if (!update_read_notify_icon_infotip(
914 s, ¬ify_icon_state->infoTip))
918 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_STATE)
920 if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
923 Stream_Read_UINT32(s, notify_icon_state->state);
926 if (orderInfo->fieldFlags & WINDOW_ORDER_ICON)
928 if (!update_read_icon_info(s, ¬ify_icon_state->icon))
932 if (orderInfo->fieldFlags & WINDOW_ORDER_CACHED_ICON)
934 if (!update_read_cached_icon_info(
935 s, ¬ify_icon_state->cachedIcon))
947 static BOOL update_recv_notification_icon_info_order(rdpUpdate* update,
wStream* s,
951 rdpContext* context = update->context;
952 rdpWindowUpdate* window = update->window;
956 WINPR_ASSERT(orderInfo);
957 WINPR_ASSERT(context);
958 WINPR_ASSERT(window);
960 if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
963 Stream_Read_UINT32(s, orderInfo->windowId);
964 Stream_Read_UINT32(s, orderInfo->notifyIconId);
966 if (orderInfo->fieldFlags & WINDOW_ORDER_STATE_DELETED)
968 update_read_notification_icon_delete_order(s, orderInfo);
969 WLog_Print(up->log, WLOG_DEBUG,
"NotifyIconDelete");
970 IFCALLRET(window->NotifyIconDelete, result, context, orderInfo);
975 result = update_read_notification_icon_state_order(s, orderInfo, ¬ify_icon_state);
980 if (orderInfo->fieldFlags & WINDOW_ORDER_STATE_NEW)
982 WLog_Print(up->log, WLOG_DEBUG,
"NotifyIconCreate");
983 IFCALLRET(window->NotifyIconCreate, result, context, orderInfo, ¬ify_icon_state);
987 WLog_Print(up->log, WLOG_DEBUG,
"NotifyIconUpdate");
988 IFCALLRET(window->NotifyIconUpdate, result, context, orderInfo, ¬ify_icon_state);
991 update_notify_icon_state_order_free(¬ify_icon_state);
1002 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_ACTIVE_WND)
1004 if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
1007 Stream_Read_UINT32(s, monitored_desktop->activeWindowId);
1010 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_ZORDER)
1012 UINT32* newid = NULL;
1014 if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
1017 Stream_Read_UINT8(s, monitored_desktop->numWindowIds);
1019 if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, monitored_desktop->numWindowIds, 4ull))
1022 if (monitored_desktop->numWindowIds > 0)
1024 size =
sizeof(UINT32) * monitored_desktop->numWindowIds;
1025 newid = (UINT32*)realloc(monitored_desktop->windowIds, size);
1029 free(monitored_desktop->windowIds);
1030 monitored_desktop->windowIds = NULL;
1034 monitored_desktop->windowIds = newid;
1037 for (UINT32 i = 0; i < monitored_desktop->numWindowIds; i++)
1039 Stream_Read_UINT32(s, monitored_desktop->windowIds[i]);
1052 static void dump_monitored_desktop(wLog* log,
const char* msg,
const WINDOW_ORDER_INFO* orderInfo,
1055 char buffer[1000] = { 0 };
1056 const size_t bufferSize =
sizeof(buffer) - 1;
1058 DUMP_APPEND(buffer, bufferSize,
"%s", msg);
1060 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_ACTIVE_WND)
1061 DUMP_APPEND(buffer, bufferSize,
" activeWindowId=0x%" PRIx32
"", monitored->activeWindowId);
1063 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_ZORDER)
1065 DUMP_APPEND(buffer, bufferSize,
" windows=(");
1066 for (UINT32 i = 0; i < monitored->numWindowIds; i++)
1068 DUMP_APPEND(buffer, bufferSize,
"0x%" PRIx32
",", monitored->windowIds[i]);
1070 DUMP_APPEND(buffer, bufferSize,
")");
1072 WLog_Print(log, WLOG_DEBUG, buffer);
1075 static BOOL update_recv_desktop_info_order(rdpUpdate* update,
wStream* s,
1079 rdpContext* context = update->context;
1080 rdpWindowUpdate* window = update->window;
1084 WINPR_ASSERT(orderInfo);
1085 WINPR_ASSERT(context);
1086 WINPR_ASSERT(window);
1088 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_NONE)
1090 update_read_desktop_non_monitored_order(s, orderInfo);
1091 WLog_Print(up->log, WLOG_DEBUG,
"NonMonitoredDesktop, windowId=0x%" PRIx32
"",
1092 orderInfo->windowId);
1093 IFCALLRET(window->NonMonitoredDesktop, result, context, orderInfo);
1098 result = update_read_desktop_actively_monitored_order(s, orderInfo, &monitored_desktop);
1102 dump_monitored_desktop(up->log,
"ActivelyMonitoredDesktop", orderInfo,
1103 &monitored_desktop);
1104 IFCALLRET(window->MonitoredDesktop, result, context, orderInfo, &monitored_desktop);
1107 free(monitored_desktop.windowIds);
1113 void update_free_window_icon_info(
ICON_INFO* iconInfo)
1118 free(iconInfo->bitsColor);
1119 iconInfo->bitsColor = NULL;
1120 free(iconInfo->bitsMask);
1121 iconInfo->bitsMask = NULL;
1122 free(iconInfo->colorTable);
1123 iconInfo->colorTable = NULL;
1126 BOOL update_recv_altsec_window_order(rdpUpdate* update,
wStream* s)
1129 size_t remaining = 0;
1130 UINT16 orderSize = 0;
1134 remaining = Stream_GetRemainingLength(s);
1136 if (!Stream_CheckAndLogRequiredLength(TAG, s, 6))
1139 Stream_Read_UINT16(s, orderSize);
1140 Stream_Read_UINT32(s, orderInfo.fieldFlags);
1142 if (remaining + 1 < orderSize)
1144 WLog_Print(up->log, WLOG_ERROR,
"Stream short orderSize");
1148 if (!window_order_supported(update->context->settings, orderInfo.fieldFlags))
1150 WLog_INFO(TAG,
"Window order %08" PRIx32
" not supported!", orderInfo.fieldFlags);
1154 if (orderInfo.fieldFlags & WINDOW_ORDER_TYPE_WINDOW)
1155 rc = update_recv_window_info_order(update, s, &orderInfo);
1156 else if (orderInfo.fieldFlags & WINDOW_ORDER_TYPE_NOTIFY)
1157 rc = update_recv_notification_icon_info_order(update, s, &orderInfo);
1158 else if (orderInfo.fieldFlags & WINDOW_ORDER_TYPE_DESKTOP)
1159 rc = update_recv_desktop_info_order(update, s, &orderInfo);
1162 WLog_Print(up->log, WLOG_ERROR,
"windoworder flags %08" PRIx32
" failed",
1163 orderInfo.fieldFlags);