From ea9e2198673186289b5ef7f0fc74d9a650e49e9d Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 20 Mar 2024 09:34:05 +0100 Subject: [PATCH] [channels,rail] print handshakeEx flags --- channels/rail/client/rail_orders.c | 7 +++++++ channels/rail/rail_common.c | 28 ++++++++++++++++++++++++++++ include/freerdp/rail.h | 3 +++ 3 files changed, 38 insertions(+) diff --git a/channels/rail/client/rail_orders.c b/channels/rail/client/rail_orders.c index 7ac432e38..b186eb323 100644 --- a/channels/rail/client/rail_orders.c +++ b/channels/rail/client/rail_orders.c @@ -469,6 +469,13 @@ static UINT rail_recv_handshake_ex_order(railPlugin* rail, wStream* s) rail->channelBuildNumber = serverHandshake.buildNumber; rail->channelFlags = serverHandshake.railHandshakeFlags; + { + char buffer[192] = { 0 }; + WLog_DBG(TAG, "HandshakeFlags=%s [buildNumber=0x%08" PRIx32 "]", + rail_handshake_ex_flags_to_string(rail->channelFlags, buffer, sizeof(buffer)), + rail->channelBuildNumber); + } + if (rail->sendHandshake) { RAIL_HANDSHAKE_ORDER clientHandshake = { 0 }; diff --git a/channels/rail/rail_common.c b/channels/rail/rail_common.c index fb6bc80ca..6deb968fe 100644 --- a/channels/rail/rail_common.c +++ b/channels/rail/rail_common.c @@ -589,3 +589,31 @@ BOOL rail_is_extended_spi_supported(UINT32 channelFlags) { return (channelFlags & TS_RAIL_ORDER_HANDSHAKE_EX_FLAGS_EXTENDED_SPI_SUPPORTED) ? TRUE : FALSE; } + +const char* rail_handshake_ex_flags_to_string(UINT32 flags, char* buffer, size_t len) +{ + if (len < 1) + return NULL; + + _snprintf(buffer, len, "{"); + char* fbuffer = &buffer[1]; + len--; + + if (flags & TS_RAIL_ORDER_HANDSHAKEEX_FLAGS_HIDEF) + winpr_str_append("HIDEF", fbuffer, len, "|"); + if (flags & TS_RAIL_ORDER_HANDSHAKE_EX_FLAGS_EXTENDED_SPI_SUPPORTED) + winpr_str_append("EXTENDED_SPI_SUPPORTED", fbuffer, len, "|"); + if (flags & TS_RAIL_ORDER_HANDSHAKE_EX_FLAGS_SNAP_ARRANGE_SUPPORTED) + winpr_str_append("SNAP_ARRANGE_SUPPORTED", fbuffer, len, "|"); + if (flags & TS_RAIL_ORDER_HANDSHAKE_EX_FLAGS_TEXT_SCALE_SUPPORTED) + winpr_str_append("TEXT_SCALE_SUPPORTED", fbuffer, len, "|"); + if (flags & TS_RAIL_ORDER_HANDSHAKE_EX_FLAGS_CARET_BLINK_SUPPORTED) + winpr_str_append("CARET_BLINK_SUPPORTED", fbuffer, len, "|"); + if (flags & TS_RAIL_ORDER_HANDSHAKE_EX_FLAGS_EXTENDED_SPI_2_SUPPORTED) + winpr_str_append("EXTENDED_SPI_2_SUPPORTED", fbuffer, len, "|"); + + char number[16] = { 0 }; + _snprintf(number, sizeof(number), "[0x%08" PRIx32 "]", flags); + winpr_str_append(number, buffer, len, "}"); + return buffer; +} diff --git a/include/freerdp/rail.h b/include/freerdp/rail.h index 66ad34b47..b3cd702d4 100644 --- a/include/freerdp/rail.h +++ b/include/freerdp/rail.h @@ -583,6 +583,9 @@ typedef enum FREERDP_API BOOL utf8_string_to_rail_string(const char* string, RAIL_UNICODE_STRING* unicode_string); + FREERDP_API const char* rail_handshake_ex_flags_to_string(UINT32 flags, char* buffer, + size_t len); + #ifdef __cplusplus } #endif