| 1 | /** |
| 2 | * FreeRDP: A Remote Desktop Protocol Implementation |
| 3 | * Remote Assistance Virtual Channel |
| 4 | * |
| 5 | * Copyright 2014 Marc-Andre Moreau <[email protected]> |
| 6 | * Copyright 2015 Thincast Technologies GmbH |
| 7 | * Copyright 2015 DI (FH) Martin Haimberger <[email protected]> |
| 8 | * |
| 9 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 | * you may not use this file except in compliance with the License. |
| 11 | * You may obtain a copy of the License at |
| 12 | * |
| 13 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | * |
| 15 | * Unless required by applicable law or agreed to in writing, software |
| 16 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | * See the License for the specific language governing permissions and |
| 19 | * limitations under the License. |
| 20 | */ |
| 21 | |
| 22 | #include <freerdp/config.h>cxx . . $ `<file>/build/include/freerdp/config.h`/ |
| 23 | |
| 24 | #include <winpr/crt.h>cxx . . $ `<file>/winpr/include/winpr/crt.h`/ |
| 25 | #include <winpr/print.h>cxx . . $ `<file>/winpr/include/winpr/print.h`/ |
| 26 | #include <winpr/stream.h>cxx . . $ `<file>/winpr/include/winpr/stream.h`/ |
| 27 | |
| 28 | #include <freerdp/freerdp.h>cxx . . $ `<file>/include/freerdp/freerdp.h`/ |
| 29 | |
| 30 | #include "remdesk_main.h"cxx . . $ `<file>/channels/remdesk/server/remdesk_main.h`/ |
| 31 | #include "remdesk_common.h"cxx . . $ `<file>/channels/remdesk/common/remdesk_common.h`/ |
| 32 | |
| 33 | /** |
| 34 | * Function description |
| 35 | * |
| 36 | * @return 0 on success, otherwise a Win32 error code |
| 37 | */ |
| 38 | static UINTcxx . . $ UINT# remdesk_virtual_channel_writecxx . . $ remdesk_virtual_channel_write(d4e13ff973d5559b).(RemdeskServerContextcxx . . $ RemdeskServerContext#* context, wStreamcxx . . $ wStream#* s) |
| 39 | { |
| 40 | const size_t len = Stream_Lengthcxx . . $ Stream_Length(ebc7f695a8644dc0).(s); |
| 41 | WINPR_ASSERTcxx . . $ `winpr/include/winpr/assert-api.h:76:9`!(len <= UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:124:10`!); |
| 42 | ULONGcxx . . $ ULONG# BytesWritten = 0; |
| 43 | BOOLcxx . . $ BOOL# status = WTSVirtualChannelWritecxx . . $ WTSVirtualChannelWrite(9756dc71c9112dcc).(context->privcxx . . $ s_remdesk_server_context#priv.->ChannelHandlecxx . . $ s_remdesk_server_private#ChannelHandle., Stream_BufferAscxx . . $ `winpr/include/winpr/stream.h:1282:9`!(s, char), |
| 44 | (UINT32cxx . . $ UINT32#)len, &BytesWritten); |
| 45 | return (status) ? CHANNEL_RC_OKcxx . . $ `winpr/include/winpr/wtsapi.h:159:9`! : ERROR_INTERNAL_ERRORcxx . . $ `winpr/include/winpr/error.h:985:9`!; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Function description |
| 50 | * |
| 51 | * @return 0 on success, otherwise a Win32 error code |
| 52 | */ |
| 53 | static UINTcxx . . $ UINT# remdesk_send_ctl_result_pducxx . . $ remdesk_send_ctl_result_pdu(e1b7a6e69974320d).(RemdeskServerContextcxx . . $ RemdeskServerContext#* context, UINT32cxx . . $ UINT32# result) |
| 54 | { |
| 55 | wStreamcxx . . $ wStream#* s = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 56 | REMDESK_CTL_RESULT_PDUcxx . . $ REMDESK_CTL_RESULT_PDU# pdu; |
| 57 | UINTcxx . . $ UINT# error = 0; |
| 58 | pdu.resultcxx . . $ $anonymous_type_2420c9dcff76f817_2#result. = result; |
| 59 | |
| 60 | if ((error = remdesk_prepare_ctl_headercxx . . $ remdesk_prepare_ctl_header(392ed5bfdedf0817).(&(pdu.ctlHeadercxx . . $ $anonymous_type_2420c9dcff76f817_2#ctlHeader.), REMDESK_CTL_RESULTcxx . . $ `include/freerdp/channels/remdesk.h:104:9`!, 4))) |
| 61 | { |
| 62 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "remdesk_prepare_ctl_header failed with error %" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`! "!", error); |
| 63 | return error; |
| 64 | } |
| 65 | |
| 66 | s = Stream_Newcxx . . $ Stream_New(af7e1125a927123a).(nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!, REMDESK_CHANNEL_CTL_SIZEcxx . . $ `include/freerdp/channels/remdesk.h:94:9`! + pdu.ctlHeadercxx . . $ $anonymous_type_2420c9dcff76f817_2#ctlHeader..chcxx . . $ $anonymous_type_2420c9dcff76f817_1#ch..DataLengthcxx . . $ $anonymous_type_2420c9dcff76f817_0#DataLength.); |
| 67 | |
| 68 | if (!s) |
| 69 | { |
| 70 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "Stream_New failed!"); |
| 71 | return CHANNEL_RC_NO_MEMORYcxx . . $ `winpr/include/winpr/wtsapi.h:171:9`!; |
| 72 | } |
| 73 | |
| 74 | if ((error = remdesk_write_ctl_headercxx . . $ remdesk_write_ctl_header(81e24ca5827d1ffa).(s, &(pdu.ctlHeadercxx . . $ $anonymous_type_2420c9dcff76f817_2#ctlHeader.)))) |
| 75 | { |
| 76 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "remdesk_write_ctl_header failed with error %" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`! "!", error); |
| 77 | goto out; |
| 78 | } |
| 79 | |
| 80 | Stream_Write_UINT32cxx . . $ `winpr/include/winpr/stream.h:1070:9`!(s, pdu.result); /* result (4 bytes) */ |
| 81 | Stream_SealLengthcxx . . $ Stream_SealLength(141d0e356bb21ff3).(s); |
| 82 | |
| 83 | if ((error = remdesk_virtual_channel_writecxx . . $ remdesk_virtual_channel_write(d4e13ff973d5559b).(context, s))) |
| 84 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "remdesk_virtual_channel_write failed with error %" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`! "!", error); |
| 85 | |
| 86 | out: |
| 87 | Stream_Freecxx . . $ Stream_Free(31813de2214206e2).(s, TRUEcxx . . $ `winpr/include/winpr/wtypes.h:126:9`!); |
| 88 | return error; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Function description |
| 93 | * |
| 94 | * @return 0 on success, otherwise a Win32 error code |
| 95 | */ |
| 96 | static UINTcxx . . $ UINT# remdesk_send_ctl_version_info_pducxx . . $ remdesk_send_ctl_version_info_pdu(d429844bc1ed1e28).(RemdeskServerContextcxx . . $ RemdeskServerContext#* context) |
| 97 | { |
| 98 | wStreamcxx . . $ wStream#* s = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 99 | REMDESK_CTL_VERSION_INFO_PDUcxx . . $ REMDESK_CTL_VERSION_INFO_PDU# pdu; |
| 100 | UINTcxx . . $ UINT# error = 0; |
| 101 | |
| 102 | if ((error = remdesk_prepare_ctl_headercxx . . $ remdesk_prepare_ctl_header(392ed5bfdedf0817).(&(pdu.ctlHeadercxx . . $ $anonymous_type_2420c9dcff76f817_3#ctlHeader.), REMDESK_CTL_VERSIONINFOcxx . . $ `include/freerdp/channels/remdesk.h:108:9`!, 8))) |
| 103 | { |
| 104 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "remdesk_prepare_ctl_header failed with error %" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`! "!", error); |
| 105 | return error; |
| 106 | } |
| 107 | |
| 108 | pdu.versionMajorcxx . . $ $anonymous_type_2420c9dcff76f817_3#versionMajor. = 1; |
| 109 | pdu.versionMinorcxx . . $ $anonymous_type_2420c9dcff76f817_3#versionMinor. = 2; |
| 110 | s = Stream_Newcxx . . $ Stream_New(af7e1125a927123a).(nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!, REMDESK_CHANNEL_CTL_SIZEcxx . . $ `include/freerdp/channels/remdesk.h:94:9`! + pdu.ctlHeadercxx . . $ $anonymous_type_2420c9dcff76f817_3#ctlHeader..chcxx . . $ $anonymous_type_2420c9dcff76f817_1#ch..DataLengthcxx . . $ $anonymous_type_2420c9dcff76f817_0#DataLength.); |
| 111 | |
| 112 | if (!s) |
| 113 | { |
| 114 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "Stream_New failed!"); |
| 115 | return CHANNEL_RC_NO_MEMORYcxx . . $ `winpr/include/winpr/wtsapi.h:171:9`!; |
| 116 | } |
| 117 | |
| 118 | if ((error = remdesk_write_ctl_headercxx . . $ remdesk_write_ctl_header(81e24ca5827d1ffa).(s, &(pdu.ctlHeadercxx . . $ $anonymous_type_2420c9dcff76f817_3#ctlHeader.)))) |
| 119 | { |
| 120 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "remdesk_write_ctl_header failed with error %" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`! "!", error); |
| 121 | goto out; |
| 122 | } |
| 123 | |
| 124 | Stream_Write_UINT32cxx . . $ `winpr/include/winpr/stream.h:1070:9`!(s, pdu.versionMajor); /* versionMajor (4 bytes) */ |
| 125 | Stream_Write_UINT32cxx . . $ `winpr/include/winpr/stream.h:1070:9`!(s, pdu.versionMinor); /* versionMinor (4 bytes) */ |
| 126 | Stream_SealLengthcxx . . $ Stream_SealLength(141d0e356bb21ff3).(s); |
| 127 | |
| 128 | if ((error = remdesk_virtual_channel_writecxx . . $ remdesk_virtual_channel_write(d4e13ff973d5559b).(context, s))) |
| 129 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "remdesk_virtual_channel_write failed with error %" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`! "!", error); |
| 130 | |
| 131 | out: |
| 132 | Stream_Freecxx . . $ Stream_Free(31813de2214206e2).(s, TRUEcxx . . $ `winpr/include/winpr/wtypes.h:126:9`!); |
| 133 | return error; |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * Function description |
| 138 | * |
| 139 | * @return 0 on success, otherwise a Win32 error code |
| 140 | */ |
| 141 | static UINTcxx . . $ UINT# remdesk_recv_ctl_version_info_pducxx . . $ remdesk_recv_ctl_version_info_pdu(ad95bbaac276365e).(WINPR_ATTR_UNUSEDcxx . . $ `winpr/include/winpr/platform.h:713:9`! RemdeskServerContextcxx . . $ RemdeskServerContext#* context, |
| 142 | wStreamcxx . . $ wStream#* s, |
| 143 | WINPR_ATTR_UNUSEDcxx . . $ `winpr/include/winpr/platform.h:713:9`! REMDESK_CHANNEL_HEADERcxx . . $ REMDESK_CHANNEL_HEADER#* header) |
| 144 | { |
| 145 | UINT32cxx . . $ UINT32# versionMajor = 0; |
| 146 | UINT32cxx . . $ UINT32# versionMinor = 0; |
| 147 | |
| 148 | if (!Stream_CheckAndLogRequiredLengthcxx . . $ `winpr/include/winpr/stream.h:127:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, s, 8)) |
| 149 | return ERROR_INVALID_DATAcxx . . $ `winpr/include/winpr/error.h:198:9`!; |
| 150 | |
| 151 | Stream_Read_UINT32cxx . . $ `winpr/include/winpr/stream.h:683:9`!(s, versionMajor); /* versionMajor (4 bytes) */ |
| 152 | Stream_Read_UINT32cxx . . $ `winpr/include/winpr/stream.h:683:9`!(s, versionMinor); /* versionMinor (4 bytes) */ |
| 153 | if ((versionMajor != 1) || (versionMinor != 2)) |
| 154 | { |
| 155 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "REMOTEDESKTOP_CTL_VERSIONINFO_PACKET invalid version %" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`! ".%" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`!, |
| 156 | versionMajor, versionMinor); |
| 157 | return ERROR_INVALID_DATAcxx . . $ `winpr/include/winpr/error.h:198:9`!; |
| 158 | } |
| 159 | |
| 160 | return CHANNEL_RC_OKcxx . . $ `winpr/include/winpr/wtsapi.h:159:9`!; |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * Function description |
| 165 | * |
| 166 | * @return 0 on success, otherwise a Win32 error code |
| 167 | */ |
| 168 | static UINTcxx . . $ UINT# remdesk_recv_ctl_remote_control_desktop_pducxx . . $ remdesk_recv_ctl_remote_control_desktop_pdu(ad95bbaac276365e).(RemdeskServerContextcxx . . $ RemdeskServerContext#* context, wStreamcxx . . $ wStream#* s, |
| 169 | REMDESK_CHANNEL_HEADERcxx . . $ REMDESK_CHANNEL_HEADER#* header) |
| 170 | { |
| 171 | size_t cchStringW = 0; |
| 172 | REMDESK_CTL_REMOTE_CONTROL_DESKTOP_PDUcxx . . $ REMDESK_CTL_REMOTE_CONTROL_DESKTOP_PDU# pdu = WINPR_C_ARRAY_INITcxx . . $ `winpr/include/winpr/platform.h:87:9`!; |
| 173 | UINTcxx . . $ UINT# error = 0; |
| 174 | |
| 175 | size_t cchMax = header->DataLengthcxx . . $ $anonymous_type_2420c9dcff76f817_0#DataLength. - 4; |
| 176 | const size_t remaining = Stream_GetRemainingLengthcxx . . $ Stream_GetRemainingLength(ebc7f695a8644dc0).(s); |
| 177 | if (cchMax > remaining) |
| 178 | cchMax = remaining; |
| 179 | cchMax /= sizeof(WCHARcxx . . $ WCHAR#); |
| 180 | |
| 181 | const WCHARcxx . . $ WCHAR#* pStringW = Stream_ConstPointercxx . . $ Stream_ConstPointer(9836e785806967e).(s); |
| 182 | const WCHARcxx . . $ WCHAR#* raConnectionStringW = pStringW; |
| 183 | |
| 184 | while ((cchStringW < cchMax) && pStringW[cchStringW]) |
| 185 | cchStringW++; |
| 186 | |
| 187 | if ((cchStringW >= cchMax) || !cchStringW) |
| 188 | return ERROR_INVALID_DATAcxx . . $ `winpr/include/winpr/error.h:198:9`!; |
| 189 | |
| 190 | cchStringW++; |
| 191 | const size_t cbRaConnectionStringW = cchStringW * sizeof(WCHARcxx . . $ WCHAR#); |
| 192 | pdu.raConnectionStringcxx . . $ $anonymous_type_2420c9dcff76f817_5#raConnectionString. = ConvertWCharNToUtf8Alloccxx . . $ ConvertWCharNToUtf8Alloc(a270be1c8376c5bd).( |
| 193 | raConnectionStringW, cbRaConnectionStringW / sizeof(WCHARcxx . . $ WCHAR#), nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!); |
| 194 | if (!pdu.raConnectionStringcxx . . $ $anonymous_type_2420c9dcff76f817_5#raConnectionString.) |
| 195 | return ERROR_INTERNAL_ERRORcxx . . $ `winpr/include/winpr/error.h:985:9`!; |
| 196 | |
| 197 | WLog_INFOcxx . . $ `winpr/include/winpr/wlog.h:343:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "RaConnectionString: %s", pdu.raConnectionString); |
| 198 | freecxx . . $ free(5d22bdacc48458e8).(pdu.raConnectionStringcxx . . $ $anonymous_type_2420c9dcff76f817_5#raConnectionString.); |
| 199 | |
| 200 | if ((error = remdesk_send_ctl_result_pducxx . . $ remdesk_send_ctl_result_pdu(e1b7a6e69974320d).(context, 0))) |
| 201 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "remdesk_send_ctl_result_pdu failed with error %" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`! "!", error); |
| 202 | |
| 203 | return error; |
| 204 | } |
| 205 | |
| 206 | /** |
| 207 | * Function description |
| 208 | * |
| 209 | * @return 0 on success, otherwise a Win32 error code |
| 210 | */ |
| 211 | static UINTcxx . . $ UINT# remdesk_recv_ctl_authenticate_pducxx . . $ remdesk_recv_ctl_authenticate_pdu(ad95bbaac276365e).(WINPR_ATTR_UNUSEDcxx . . $ `winpr/include/winpr/platform.h:713:9`! RemdeskServerContextcxx . . $ RemdeskServerContext#* context, |
| 212 | wStreamcxx . . $ wStream#* s, REMDESK_CHANNEL_HEADERcxx . . $ REMDESK_CHANNEL_HEADER#* header) |
| 213 | { |
| 214 | size_t cchTmpStringW = 0; |
| 215 | const WCHARcxx . . $ WCHAR#* expertBlobW = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 216 | REMDESK_CTL_AUTHENTICATE_PDUcxx . . $ REMDESK_CTL_AUTHENTICATE_PDU# pdu = WINPR_C_ARRAY_INITcxx . . $ `winpr/include/winpr/platform.h:87:9`!; |
| 217 | |
| 218 | size_t cchRemaining = header->DataLengthcxx . . $ $anonymous_type_2420c9dcff76f817_0#DataLength. - 4; |
| 219 | const size_t remaining = Stream_GetRemainingLengthcxx . . $ Stream_GetRemainingLength(ebc7f695a8644dc0).(s); |
| 220 | if (cchRemaining > remaining) |
| 221 | cchRemaining = remaining; |
| 222 | cchRemaining /= sizeof(WCHARcxx . . $ WCHAR#); |
| 223 | |
| 224 | const WCHARcxx . . $ WCHAR#* pStringW = Stream_ConstPointercxx . . $ Stream_ConstPointer(9836e785806967e).(s); |
| 225 | const WCHARcxx . . $ WCHAR#* raConnectionStringW = pStringW; |
| 226 | |
| 227 | while ((cchTmpStringW < cchRemaining) && pStringW[cchTmpStringW]) |
| 228 | cchTmpStringW++; |
| 229 | |
| 230 | if ((cchTmpStringW >= cchRemaining) || !cchTmpStringW) |
| 231 | return ERROR_INVALID_DATAcxx . . $ `winpr/include/winpr/error.h:198:9`!; |
| 232 | |
| 233 | cchTmpStringW++; |
| 234 | const size_t cbRaConnectionStringW = cchTmpStringW * sizeof(WCHARcxx . . $ WCHAR#); |
| 235 | pStringW += cchTmpStringW; |
| 236 | expertBlobW = pStringW; |
| 237 | cchRemaining -= cchTmpStringW; |
| 238 | |
| 239 | size_t cchStringW = 0; |
| 240 | while ((cchStringW < cchRemaining) && pStringW[cchStringW]) |
| 241 | cchStringW++; |
| 242 | |
| 243 | if ((cchStringW >= cchRemaining) || !cchStringW) |
| 244 | return ERROR_INVALID_DATAcxx . . $ `winpr/include/winpr/error.h:198:9`!; |
| 245 | |
| 246 | cchStringW++; |
| 247 | const size_t cbExpertBlobW = cchStringW * sizeof(WCHARcxx . . $ WCHAR#); |
| 248 | pdu.raConnectionStringcxx . . $ $anonymous_type_2420c9dcff76f817_4#raConnectionString. = ConvertWCharNToUtf8Alloccxx . . $ ConvertWCharNToUtf8Alloc(a270be1c8376c5bd).( |
| 249 | raConnectionStringW, cbRaConnectionStringW / sizeof(WCHARcxx . . $ WCHAR#), nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!); |
| 250 | if (!pdu.raConnectionStringcxx . . $ $anonymous_type_2420c9dcff76f817_4#raConnectionString.) |
| 251 | return ERROR_INTERNAL_ERRORcxx . . $ `winpr/include/winpr/error.h:985:9`!; |
| 252 | |
| 253 | pdu.expertBlobcxx . . $ $anonymous_type_2420c9dcff76f817_4#expertBlob. = ConvertWCharNToUtf8Alloccxx . . $ ConvertWCharNToUtf8Alloc(a270be1c8376c5bd).(expertBlobW, cbExpertBlobW / sizeof(WCHARcxx . . $ WCHAR#), nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!); |
| 254 | if (!pdu.expertBlobcxx . . $ $anonymous_type_2420c9dcff76f817_4#expertBlob.) |
| 255 | { |
| 256 | freecxx . . $ free(5d22bdacc48458e8).(pdu.raConnectionStringcxx . . $ $anonymous_type_2420c9dcff76f817_4#raConnectionString.); |
| 257 | return ERROR_INTERNAL_ERRORcxx . . $ `winpr/include/winpr/error.h:985:9`!; |
| 258 | } |
| 259 | |
| 260 | WLog_INFOcxx . . $ `winpr/include/winpr/wlog.h:343:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "RaConnectionString: %s ExpertBlob: %s", pdu.raConnectionString, pdu.expertBlob); |
| 261 | freecxx . . $ free(5d22bdacc48458e8).(pdu.raConnectionStringcxx . . $ $anonymous_type_2420c9dcff76f817_4#raConnectionString.); |
| 262 | freecxx . . $ free(5d22bdacc48458e8).(pdu.expertBlobcxx . . $ $anonymous_type_2420c9dcff76f817_4#expertBlob.); |
| 263 | return CHANNEL_RC_OKcxx . . $ `winpr/include/winpr/wtsapi.h:159:9`!; |
| 264 | } |
| 265 | |
| 266 | /** |
| 267 | * Function description |
| 268 | * |
| 269 | * @return 0 on success, otherwise a Win32 error code |
| 270 | */ |
| 271 | static UINTcxx . . $ UINT# remdesk_recv_ctl_verify_password_pducxx . . $ remdesk_recv_ctl_verify_password_pdu(ad95bbaac276365e).(RemdeskServerContextcxx . . $ RemdeskServerContext#* context, wStreamcxx . . $ wStream#* s, |
| 272 | REMDESK_CHANNEL_HEADERcxx . . $ REMDESK_CHANNEL_HEADER#* header) |
| 273 | { |
| 274 | REMDESK_CTL_VERIFY_PASSWORD_PDUcxx . . $ REMDESK_CTL_VERIFY_PASSWORD_PDU# pdu = WINPR_C_ARRAY_INITcxx . . $ `winpr/include/winpr/platform.h:87:9`!; |
| 275 | |
| 276 | if (!Stream_CheckAndLogRequiredLengthcxx . . $ `winpr/include/winpr/stream.h:127:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, s, 8)) |
| 277 | return ERROR_INVALID_DATAcxx . . $ `winpr/include/winpr/error.h:198:9`!; |
| 278 | |
| 279 | const WCHARcxx . . $ WCHAR#* expertBlobW = Stream_ConstPointercxx . . $ Stream_ConstPointer(9836e785806967e).(s); |
| 280 | |
| 281 | size_t cbExpertBlobW = header->DataLengthcxx . . $ $anonymous_type_2420c9dcff76f817_0#DataLength. - 4; |
| 282 | const size_t remaining = Stream_GetRemainingLengthcxx . . $ Stream_GetRemainingLength(ebc7f695a8644dc0).(s); |
| 283 | if (cbExpertBlobW > remaining) |
| 284 | cbExpertBlobW = remaining; |
| 285 | |
| 286 | pdu.expertBlobcxx . . $ $anonymous_type_2420c9dcff76f817_6#expertBlob. = ConvertWCharNToUtf8Alloccxx . . $ ConvertWCharNToUtf8Alloc(a270be1c8376c5bd).(expertBlobW, cbExpertBlobW / sizeof(WCHARcxx . . $ WCHAR#), nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!); |
| 287 | if (!pdu.expertBlobcxx . . $ $anonymous_type_2420c9dcff76f817_6#expertBlob.) |
| 288 | return ERROR_INTERNAL_ERRORcxx . . $ `winpr/include/winpr/error.h:985:9`!; |
| 289 | |
| 290 | WLog_INFOcxx . . $ `winpr/include/winpr/wlog.h:343:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "ExpertBlob: %s", pdu.expertBlob); |
| 291 | |
| 292 | // TODO: Callback? |
| 293 | |
| 294 | freecxx . . $ free(5d22bdacc48458e8).(pdu.expertBlobcxx . . $ $anonymous_type_2420c9dcff76f817_6#expertBlob.); |
| 295 | return remdesk_send_ctl_result_pducxx . . $ remdesk_send_ctl_result_pdu(e1b7a6e69974320d).(context, 0); |
| 296 | } |
| 297 | |
| 298 | /** |
| 299 | * Function description |
| 300 | * |
| 301 | * @return 0 on success, otherwise a Win32 error code |
| 302 | */ |
| 303 | static UINTcxx . . $ UINT# remdesk_recv_ctl_pducxx . . $ remdesk_recv_ctl_pdu(ad95bbaac276365e).(RemdeskServerContextcxx . . $ RemdeskServerContext#* context, wStreamcxx . . $ wStream#* s, |
| 304 | REMDESK_CHANNEL_HEADERcxx . . $ REMDESK_CHANNEL_HEADER#* header) |
| 305 | { |
| 306 | UINTcxx . . $ UINT# error = CHANNEL_RC_OKcxx . . $ `winpr/include/winpr/wtsapi.h:159:9`!; |
| 307 | UINT32cxx . . $ UINT32# msgType = 0; |
| 308 | |
| 309 | if (!Stream_CheckAndLogRequiredLengthcxx . . $ `winpr/include/winpr/stream.h:127:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, s, 4)) |
| 310 | return ERROR_INVALID_DATAcxx . . $ `winpr/include/winpr/error.h:198:9`!; |
| 311 | |
| 312 | if (header->DataLengthcxx . . $ $anonymous_type_2420c9dcff76f817_0#DataLength. < 4) |
| 313 | return ERROR_INVALID_DATAcxx . . $ `winpr/include/winpr/error.h:198:9`!; |
| 314 | |
| 315 | Stream_Read_UINT32cxx . . $ `winpr/include/winpr/stream.h:683:9`!(s, msgType); /* msgType (4 bytes) */ |
| 316 | WLog_INFOcxx . . $ `winpr/include/winpr/wlog.h:343:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "msgType: %" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`! "", msgType); |
| 317 | |
| 318 | switch (msgType) |
| 319 | { |
| 320 | case REMDESK_CTL_REMOTE_CONTROL_DESKTOPcxx . . $ `include/freerdp/channels/remdesk.h:103:9`!: |
| 321 | if ((error = remdesk_recv_ctl_remote_control_desktop_pducxx . . $ remdesk_recv_ctl_remote_control_desktop_pdu(ad95bbaac276365e).(context, s, header))) |
| 322 | { |
| 323 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, |
| 324 | "remdesk_recv_ctl_remote_control_desktop_pdu failed with error %" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`! |
| 325 | "!", |
| 326 | error); |
| 327 | return error; |
| 328 | } |
| 329 | |
| 330 | break; |
| 331 | |
| 332 | case REMDESK_CTL_AUTHENTICATEcxx . . $ `include/freerdp/channels/remdesk.h:105:9`!: |
| 333 | if ((error = remdesk_recv_ctl_authenticate_pducxx . . $ remdesk_recv_ctl_authenticate_pdu(ad95bbaac276365e).(context, s, header))) |
| 334 | { |
| 335 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "remdesk_recv_ctl_authenticate_pdu failed with error %" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`! "!", |
| 336 | error); |
| 337 | return error; |
| 338 | } |
| 339 | |
| 340 | break; |
| 341 | |
| 342 | case REMDESK_CTL_DISCONNECTcxx . . $ `include/freerdp/channels/remdesk.h:107:9`!: |
| 343 | break; |
| 344 | |
| 345 | case REMDESK_CTL_VERSIONINFOcxx . . $ `include/freerdp/channels/remdesk.h:108:9`!: |
| 346 | if ((error = remdesk_recv_ctl_version_info_pducxx . . $ remdesk_recv_ctl_version_info_pdu(ad95bbaac276365e).(context, s, header))) |
| 347 | { |
| 348 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "remdesk_recv_ctl_version_info_pdu failed with error %" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`! "!", |
| 349 | error); |
| 350 | return error; |
| 351 | } |
| 352 | |
| 353 | break; |
| 354 | |
| 355 | case REMDESK_CTL_ISCONNECTEDcxx . . $ `include/freerdp/channels/remdesk.h:109:9`!: |
| 356 | break; |
| 357 | |
| 358 | case REMDESK_CTL_VERIFY_PASSWORDcxx . . $ `include/freerdp/channels/remdesk.h:110:9`!: |
| 359 | if ((error = remdesk_recv_ctl_verify_password_pducxx . . $ remdesk_recv_ctl_verify_password_pdu(ad95bbaac276365e).(context, s, header))) |
| 360 | { |
| 361 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "remdesk_recv_ctl_verify_password_pdu failed with error %" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`! "!", |
| 362 | error); |
| 363 | return error; |
| 364 | } |
| 365 | |
| 366 | break; |
| 367 | |
| 368 | case REMDESK_CTL_EXPERT_ON_VISTAcxx . . $ `include/freerdp/channels/remdesk.h:111:9`!: |
| 369 | break; |
| 370 | |
| 371 | case REMDESK_CTL_RANOVICE_NAMEcxx . . $ `include/freerdp/channels/remdesk.h:112:9`!: |
| 372 | break; |
| 373 | |
| 374 | case REMDESK_CTL_RAEXPERT_NAMEcxx . . $ `include/freerdp/channels/remdesk.h:113:9`!: |
| 375 | break; |
| 376 | |
| 377 | case REMDESK_CTL_TOKENcxx . . $ `include/freerdp/channels/remdesk.h:114:9`!: |
| 378 | break; |
| 379 | |
| 380 | default: |
| 381 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "remdesk_recv_control_pdu: unknown msgType: %" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`! "", msgType); |
| 382 | error = ERROR_INVALID_DATAcxx . . $ `winpr/include/winpr/error.h:198:9`!; |
| 383 | break; |
| 384 | } |
| 385 | |
| 386 | return error; |
| 387 | } |
| 388 | |
| 389 | /** |
| 390 | * Function description |
| 391 | * |
| 392 | * @return 0 on success, otherwise a Win32 error code |
| 393 | */ |
| 394 | static UINTcxx . . $ UINT# remdesk_server_receive_pducxx . . $ remdesk_server_receive_pdu(d4e13ff973d5559b).(RemdeskServerContextcxx . . $ RemdeskServerContext#* context, wStreamcxx . . $ wStream#* s) |
| 395 | { |
| 396 | UINTcxx . . $ UINT# error = CHANNEL_RC_OKcxx . . $ `winpr/include/winpr/wtsapi.h:159:9`!; |
| 397 | REMDESK_CHANNEL_HEADERcxx . . $ REMDESK_CHANNEL_HEADER# header; |
| 398 | |
| 399 | if ((error = remdesk_read_channel_headercxx . . $ remdesk_read_channel_header(21b6382422964d34).(s, &header))) |
| 400 | { |
| 401 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "remdesk_read_channel_header failed with error %" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`! "!", error); |
| 402 | return error; |
| 403 | } |
| 404 | |
| 405 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(header.ChannelNamecxx . . $ $anonymous_type_2420c9dcff76f817_0#ChannelName., "RC_CTL") == 0) |
| 406 | { |
| 407 | if ((error = remdesk_recv_ctl_pducxx . . $ remdesk_recv_ctl_pdu(ad95bbaac276365e).(context, s, &header))) |
| 408 | { |
| 409 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "remdesk_recv_ctl_pdu failed with error %" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`! "!", error); |
| 410 | return error; |
| 411 | } |
| 412 | } |
| 413 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(header.ChannelNamecxx . . $ $anonymous_type_2420c9dcff76f817_0#ChannelName., "70") == 0) |
| 414 | { |
| 415 | } |
| 416 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(header.ChannelNamecxx . . $ $anonymous_type_2420c9dcff76f817_0#ChannelName., "71") == 0) |
| 417 | { |
| 418 | } |
| 419 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(header.ChannelNamecxx . . $ $anonymous_type_2420c9dcff76f817_0#ChannelName., ".") == 0) |
| 420 | { |
| 421 | } |
| 422 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(header.ChannelNamecxx . . $ $anonymous_type_2420c9dcff76f817_0#ChannelName., "1000.") == 0) |
| 423 | { |
| 424 | } |
| 425 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(header.ChannelNamecxx . . $ $anonymous_type_2420c9dcff76f817_0#ChannelName., "RA_FX") == 0) |
| 426 | { |
| 427 | } |
| 428 | else |
| 429 | { |
| 430 | } |
| 431 | |
| 432 | return error; |
| 433 | } |
| 434 | |
| 435 | static DWORDcxx . . $ DWORD# WINAPIcxx . . $ `winpr/include/winpr/wtypes.h:84:9`! remdesk_server_threadcxx . . $ remdesk_server_thread(6769d0e399bf81e3).(LPVOIDcxx . . $ LPVOID# arg) |
| 436 | { |
| 437 | void* buffer = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 438 | HANDLEcxx . . $ HANDLE# events[8] = WINPR_C_ARRAY_INITcxx . . $ `winpr/include/winpr/platform.h:87:9`!; |
| 439 | HANDLEcxx . . $ HANDLE# ChannelEvent = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 440 | DWORDcxx . . $ DWORD# BytesReturned = 0; |
| 441 | UINTcxx . . $ UINT# error = 0; |
| 442 | RemdeskServerContextcxx . . $ RemdeskServerContext#* context = (RemdeskServerContextcxx . . $ RemdeskServerContext#*)arg; |
| 443 | WINPR_ASSERTcxx . . $ `winpr/include/winpr/assert-api.h:76:9`!(context); |
| 444 | wStreamcxx . . $ wStream#* s = Stream_Newcxx . . $ Stream_New(af7e1125a927123a).(nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!, 4096); |
| 445 | |
| 446 | if (!s) |
| 447 | { |
| 448 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "Stream_New failed!"); |
| 449 | error = CHANNEL_RC_NO_MEMORYcxx . . $ `winpr/include/winpr/wtsapi.h:171:9`!; |
| 450 | goto out; |
| 451 | } |
| 452 | |
| 453 | if (WTSVirtualChannelQuerycxx . . $ WTSVirtualChannelQuery(70096c24a3175ce7).(context->privcxx . . $ s_remdesk_server_context#priv.->ChannelHandlecxx . . $ s_remdesk_server_private#ChannelHandle., WTSVirtualEventHandlecxx . . $ WTSVirtualEventHandle., &buffer, |
| 454 | &BytesReturned) == TRUEcxx . . $ `winpr/include/winpr/wtypes.h:126:9`!) |
| 455 | { |
| 456 | if (BytesReturned == sizeof(HANDLEcxx . . $ HANDLE#)) |
| 457 | ChannelEvent = *(HANDLEcxx . . $ HANDLE#*)buffer; |
| 458 | |
| 459 | WTSFreeMemorycxx . . $ WTSFreeMemory(5d22bdacc48458e8).(buffer); |
| 460 | } |
| 461 | else |
| 462 | { |
| 463 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "WTSVirtualChannelQuery failed!"); |
| 464 | error = ERROR_INTERNAL_ERRORcxx . . $ `winpr/include/winpr/error.h:985:9`!; |
| 465 | goto out; |
| 466 | } |
| 467 | |
| 468 | { |
| 469 | DWORDcxx . . $ DWORD# nCount = 0; |
| 470 | events[nCount++] = ChannelEvent; |
| 471 | events[nCount++] = context->privcxx . . $ s_remdesk_server_context#priv.->StopEventcxx . . $ s_remdesk_server_private#StopEvent.; |
| 472 | |
| 473 | if ((error = remdesk_send_ctl_version_info_pducxx . . $ remdesk_send_ctl_version_info_pdu(d429844bc1ed1e28).(context))) |
| 474 | { |
| 475 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "remdesk_send_ctl_version_info_pdu failed with error %" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`! "!", |
| 476 | error); |
| 477 | goto out; |
| 478 | } |
| 479 | |
| 480 | while (1) |
| 481 | { |
| 482 | DWORDcxx . . $ DWORD# status = WaitForMultipleObjectscxx . . $ WaitForMultipleObjects(b9c7375e997c2ab5).(nCount, events, FALSEcxx . . $ `winpr/include/winpr/wtypes.h:122:9`!, INFINITEcxx . . $ `winpr/include/winpr/synch.h:212:9`!); |
| 483 | |
| 484 | if (status == WAIT_FAILEDcxx . . $ `winpr/include/winpr/synch.h:222:9`!) |
| 485 | { |
| 486 | error = GetLastErrorcxx . . $ GetLastError(db52760e79bf9054).(); |
| 487 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "WaitForMultipleObjects failed with error %" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`! "", error); |
| 488 | break; |
| 489 | } |
| 490 | |
| 491 | status = WaitForSingleObjectcxx . . $ WaitForSingleObject(35feec062aeef876).(context->privcxx . . $ s_remdesk_server_context#priv.->StopEventcxx . . $ s_remdesk_server_private#StopEvent., 0); |
| 492 | |
| 493 | if (status == WAIT_FAILEDcxx . . $ `winpr/include/winpr/synch.h:222:9`!) |
| 494 | { |
| 495 | error = GetLastErrorcxx . . $ GetLastError(db52760e79bf9054).(); |
| 496 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "WaitForSingleObject failed with error %" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`! "", error); |
| 497 | break; |
| 498 | } |
| 499 | |
| 500 | if (status == WAIT_OBJECT_0cxx . . $ `winpr/include/winpr/synch.h:214:9`!) |
| 501 | { |
| 502 | break; |
| 503 | } |
| 504 | |
| 505 | const size_t len = Stream_Capacitycxx . . $ Stream_Capacity(ebc7f695a8644dc0).(s); |
| 506 | if (len > UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:124:10`!) |
| 507 | { |
| 508 | error = ERROR_INTERNAL_ERRORcxx . . $ `winpr/include/winpr/error.h:985:9`!; |
| 509 | break; |
| 510 | } |
| 511 | if (WTSVirtualChannelReadcxx . . $ WTSVirtualChannelRead(e93370262f880ed8).(context->privcxx . . $ s_remdesk_server_context#priv.->ChannelHandlecxx . . $ s_remdesk_server_private#ChannelHandle., 0, Stream_BufferAscxx . . $ `winpr/include/winpr/stream.h:1282:9`!(s, char), |
| 512 | (UINT32cxx . . $ UINT32#)len, &BytesReturned)) |
| 513 | { |
| 514 | if (BytesReturned) |
| 515 | Stream_Seekcxx . . $ Stream_Seek(e1fedc387646b1c9).(s, BytesReturned); |
| 516 | } |
| 517 | else |
| 518 | { |
| 519 | if (!Stream_EnsureRemainingCapacitycxx . . $ Stream_EnsureRemainingCapacity(db6c6e3e90d014c4).(s, BytesReturned)) |
| 520 | { |
| 521 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "Stream_EnsureRemainingCapacity failed!"); |
| 522 | error = CHANNEL_RC_NO_MEMORYcxx . . $ `winpr/include/winpr/wtsapi.h:171:9`!; |
| 523 | break; |
| 524 | } |
| 525 | } |
| 526 | |
| 527 | if (Stream_GetPositioncxx . . $ Stream_GetPosition(ebc7f695a8644dc0).(s) >= 8) |
| 528 | { |
| 529 | const UINT32cxx . . $ UINT32#* pHeader = Stream_BufferAscxx . . $ `winpr/include/winpr/stream.h:1282:9`!(s, UINT32); |
| 530 | const UINT32cxx . . $ UINT32# PduLength = pHeader[0] + pHeader[1] + 8; |
| 531 | |
| 532 | if (PduLength >= Stream_GetPositioncxx . . $ Stream_GetPosition(ebc7f695a8644dc0).(s)) |
| 533 | { |
| 534 | Stream_SealLengthcxx . . $ Stream_SealLength(141d0e356bb21ff3).(s); |
| 535 | Stream_ResetPositioncxx . . $ Stream_ResetPosition(141d0e356bb21ff3).(s); |
| 536 | |
| 537 | error = remdesk_server_receive_pducxx . . $ remdesk_server_receive_pdu(d4e13ff973d5559b).(context, s); |
| 538 | if (error) |
| 539 | { |
| 540 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "remdesk_server_receive_pdu failed with error %" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`! "!", |
| 541 | error); |
| 542 | break; |
| 543 | } |
| 544 | |
| 545 | Stream_ResetPositioncxx . . $ Stream_ResetPosition(141d0e356bb21ff3).(s); |
| 546 | } |
| 547 | } |
| 548 | } |
| 549 | } |
| 550 | out: |
| 551 | Stream_Freecxx . . $ Stream_Free(31813de2214206e2).(s, TRUEcxx . . $ `winpr/include/winpr/wtypes.h:126:9`!); |
| 552 | |
| 553 | if (error && context->rdpcontextcxx . . $ s_remdesk_server_context#rdpcontext.) |
| 554 | setChannelErrorcxx . . $ setChannelError(5de635fef11cc662).(context->rdpcontextcxx . . $ s_remdesk_server_context#rdpcontext., error, "remdesk_server_thread reported an error"); |
| 555 | |
| 556 | ExitThreadcxx . . $ ExitThread(cb2f890c2fdad230).(error); |
| 557 | return error; |
| 558 | } |
| 559 | |
| 560 | /** |
| 561 | * Function description |
| 562 | * |
| 563 | * @return 0 on success, otherwise a Win32 error code |
| 564 | */ |
| 565 | static UINTcxx . . $ UINT# remdesk_server_startcxx . . $ remdesk_server_start(d429844bc1ed1e28).(RemdeskServerContextcxx . . $ RemdeskServerContext#* context) |
| 566 | { |
| 567 | context->privcxx . . $ s_remdesk_server_context#priv.->ChannelHandlecxx . . $ s_remdesk_server_private#ChannelHandle. = |
| 568 | WTSVirtualChannelOpencxx . . $ WTSVirtualChannelOpen(3b34528582f32a2c).(context->vcmcxx . . $ s_remdesk_server_context#vcm., WTS_CURRENT_SESSIONcxx . . $ `winpr/include/winpr/wtsapi.h:269:9`!, REMDESK_SVC_CHANNEL_NAMEcxx . . $ `include/freerdp/channels/remdesk.h:36:9`!); |
| 569 | |
| 570 | if (!context->privcxx . . $ s_remdesk_server_context#priv.->ChannelHandlecxx . . $ s_remdesk_server_private#ChannelHandle.) |
| 571 | { |
| 572 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "WTSVirtualChannelOpen failed!"); |
| 573 | return ERROR_INTERNAL_ERRORcxx . . $ `winpr/include/winpr/error.h:985:9`!; |
| 574 | } |
| 575 | |
| 576 | if (!(context->privcxx . . $ s_remdesk_server_context#priv.->StopEventcxx . . $ s_remdesk_server_private#StopEvent. = CreateEventcxx . . $ `winpr/include/winpr/synch.h:147:9`!(nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!, TRUEcxx . . $ `winpr/include/winpr/wtypes.h:126:9`!, FALSEcxx . . $ `winpr/include/winpr/wtypes.h:122:9`!, nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!))) |
| 577 | { |
| 578 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "CreateEvent failed!"); |
| 579 | return ERROR_INTERNAL_ERRORcxx . . $ `winpr/include/winpr/error.h:985:9`!; |
| 580 | } |
| 581 | |
| 582 | if (!(context->privcxx . . $ s_remdesk_server_context#priv.->Threadcxx . . $ s_remdesk_server_private#Thread. = |
| 583 | CreateThreadcxx . . $ CreateThread(b708535bf8f563fd).(nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!, 0, remdesk_server_threadcxx . . $ remdesk_server_thread(6769d0e399bf81e3)., (void*)context, 0, nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!))) |
| 584 | { |
| 585 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "CreateThread failed!"); |
| 586 | (void)CloseHandlecxx . . $ CloseHandle(dedf1e9b1c614a07).(context->privcxx . . $ s_remdesk_server_context#priv.->StopEventcxx . . $ s_remdesk_server_private#StopEvent.); |
| 587 | context->privcxx . . $ s_remdesk_server_context#priv.->StopEventcxx . . $ s_remdesk_server_private#StopEvent. = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 588 | return ERROR_INTERNAL_ERRORcxx . . $ `winpr/include/winpr/error.h:985:9`!; |
| 589 | } |
| 590 | |
| 591 | return CHANNEL_RC_OKcxx . . $ `winpr/include/winpr/wtsapi.h:159:9`!; |
| 592 | } |
| 593 | |
| 594 | /** |
| 595 | * Function description |
| 596 | * |
| 597 | * @return 0 on success, otherwise a Win32 error code |
| 598 | */ |
| 599 | static UINTcxx . . $ UINT# remdesk_server_stopcxx . . $ remdesk_server_stop(d429844bc1ed1e28).(RemdeskServerContextcxx . . $ RemdeskServerContext#* context) |
| 600 | { |
| 601 | UINTcxx . . $ UINT# error = 0; |
| 602 | (void)SetEventcxx . . $ SetEvent(dedf1e9b1c614a07).(context->privcxx . . $ s_remdesk_server_context#priv.->StopEventcxx . . $ s_remdesk_server_private#StopEvent.); |
| 603 | |
| 604 | if (WaitForSingleObjectcxx . . $ WaitForSingleObject(35feec062aeef876).(context->privcxx . . $ s_remdesk_server_context#priv.->Threadcxx . . $ s_remdesk_server_private#Thread., INFINITEcxx . . $ `winpr/include/winpr/synch.h:212:9`!) == WAIT_FAILEDcxx . . $ `winpr/include/winpr/synch.h:222:9`!) |
| 605 | { |
| 606 | error = GetLastErrorcxx . . $ GetLastError(db52760e79bf9054).(); |
| 607 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `channels/remdesk/server/remdesk_main.h:30:9`!, "WaitForSingleObject failed with error %" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`! "!", error); |
| 608 | return error; |
| 609 | } |
| 610 | |
| 611 | (void)CloseHandlecxx . . $ CloseHandle(dedf1e9b1c614a07).(context->privcxx . . $ s_remdesk_server_context#priv.->Threadcxx . . $ s_remdesk_server_private#Thread.); |
| 612 | (void)CloseHandlecxx . . $ CloseHandle(dedf1e9b1c614a07).(context->privcxx . . $ s_remdesk_server_context#priv.->StopEventcxx . . $ s_remdesk_server_private#StopEvent.); |
| 613 | return CHANNEL_RC_OKcxx . . $ `winpr/include/winpr/wtsapi.h:159:9`!; |
| 614 | } |
| 615 | |
| 616 | RemdeskServerContextcxx . . $ RemdeskServerContext#* remdesk_server_context_newcxx . . $ remdesk_server_context_new(af4d04b1064e3f28).(HANDLEcxx . . $ HANDLE# vcm) |
| 617 | { |
| 618 | RemdeskServerContextcxx . . $ RemdeskServerContext#* context = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 619 | context = (RemdeskServerContextcxx . . $ RemdeskServerContext#*)calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(RemdeskServerContextcxx . . $ RemdeskServerContext#)); |
| 620 | |
| 621 | if (context) |
| 622 | { |
| 623 | context->vcmcxx . . $ s_remdesk_server_context#vcm. = vcm; |
| 624 | context->Startcxx . . $ s_remdesk_server_context#Start. = remdesk_server_startcxx . . $ remdesk_server_start(d429844bc1ed1e28).; |
| 625 | context->Stopcxx . . $ s_remdesk_server_context#Stop. = remdesk_server_stopcxx . . $ remdesk_server_stop(d429844bc1ed1e28).; |
| 626 | context->privcxx . . $ s_remdesk_server_context#priv. = (RemdeskServerPrivatecxx . . $ RemdeskServerPrivate#*)calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(RemdeskServerPrivatecxx . . $ RemdeskServerPrivate#)); |
| 627 | |
| 628 | if (!context->privcxx . . $ s_remdesk_server_context#priv.) |
| 629 | { |
| 630 | freecxx . . $ free(5d22bdacc48458e8).(context); |
| 631 | return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 632 | } |
| 633 | |
| 634 | context->privcxx . . $ s_remdesk_server_context#priv.->Versioncxx . . $ s_remdesk_server_private#Version. = 1; |
| 635 | } |
| 636 | |
| 637 | return context; |
| 638 | } |
| 639 | |
| 640 | void remdesk_server_context_freecxx . . $ remdesk_server_context_free(508e14738be27eea).(RemdeskServerContextcxx . . $ RemdeskServerContext#* context) |
| 641 | { |
| 642 | if (context) |
| 643 | { |
| 644 | if (context->privcxx . . $ s_remdesk_server_context#priv.->ChannelHandlecxx . . $ s_remdesk_server_private#ChannelHandle. != INVALID_HANDLE_VALUEcxx . . $ `winpr/include/winpr/file.h:41:9`!) |
| 645 | (void)WTSVirtualChannelClosecxx . . $ WTSVirtualChannelClose(dedf1e9b1c614a07).(context->privcxx . . $ s_remdesk_server_context#priv.->ChannelHandlecxx . . $ s_remdesk_server_private#ChannelHandle.); |
| 646 | |
| 647 | freecxx . . $ free(5d22bdacc48458e8).(context->privcxx . . $ s_remdesk_server_context#priv.); |
| 648 | freecxx . . $ free(5d22bdacc48458e8).(context); |
| 649 | } |
| 650 | } |