/src/FreeRDP/channels/rail/client/rail_orders.c
Line | Count | Source |
1 | | /** |
2 | | * FreeRDP: A Remote Desktop Protocol Implementation |
3 | | * Remote Applications Integrated Locally (RAIL) Orders |
4 | | * |
5 | | * Copyright 2009 Marc-Andre Moreau <marcandre.moreau@gmail.com> |
6 | | * Copyright 2011 Roman Barabanov <romanbarabanov@gmail.com> |
7 | | * Copyright 2015 Thincast Technologies GmbH |
8 | | * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com> |
9 | | * Copyright 2017 Armin Novak <armin.novak@thincast.com> |
10 | | * Copyright 2017 Thincast Technologies GmbH |
11 | | * |
12 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
13 | | * you may not use this file except in compliance with the License. |
14 | | * You may obtain a copy of the License at |
15 | | * |
16 | | * http://www.apache.org/licenses/LICENSE-2.0 |
17 | | * |
18 | | * Unless required by applicable law or agreed to in writing, software |
19 | | * distributed under the License is distributed on an "AS IS" BASIS, |
20 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
21 | | * See the License for the specific language governing permissions and |
22 | | * limitations under the License. |
23 | | */ |
24 | | |
25 | | #include <freerdp/config.h> |
26 | | |
27 | | #include <winpr/crt.h> |
28 | | #include <winpr/cast.h> |
29 | | |
30 | | #include <freerdp/channels/log.h> |
31 | | #include <freerdp/freerdp.h> |
32 | | |
33 | | #include "rail_orders.h" |
34 | | |
35 | | static BOOL rail_is_feature_supported(const rdpContext* context, UINT32 featureMask); |
36 | | |
37 | | /** |
38 | | * Function description |
39 | | * |
40 | | * @return 0 on success, otherwise a Win32 error code |
41 | | */ |
42 | | UINT rail_send_pdu(railPlugin* rail, wStream* s, UINT16 orderType) |
43 | 0 | { |
44 | 0 | char buffer[128] = WINPR_C_ARRAY_INIT; |
45 | |
|
46 | 0 | if (!rail || !s) |
47 | 0 | { |
48 | 0 | Stream_Free(s, TRUE); |
49 | 0 | return ERROR_INVALID_PARAMETER; |
50 | 0 | } |
51 | | |
52 | 0 | const UINT16 orderLength = (UINT16)Stream_GetPosition(s); |
53 | 0 | Stream_ResetPosition(s); |
54 | 0 | if (!rail_write_pdu_header(s, orderType, orderLength)) |
55 | 0 | goto fail; |
56 | 0 | if (!Stream_SetPosition(s, orderLength)) |
57 | 0 | goto fail; |
58 | 0 | WLog_Print(rail->log, WLOG_DEBUG, "Sending %s PDU, length: %" PRIu16 "", |
59 | 0 | rail_get_order_type_string_full(orderType, buffer, sizeof(buffer)), orderLength); |
60 | 0 | return rail_send_channel_data(rail, s); |
61 | | |
62 | 0 | fail: |
63 | 0 | Stream_Free(s, TRUE); |
64 | 0 | return ERROR_INVALID_DATA; |
65 | 0 | } |
66 | | |
67 | | /** |
68 | | * Function description |
69 | | * |
70 | | * @return 0 on success, otherwise a Win32 error code |
71 | | */ |
72 | | static UINT rail_read_server_exec_result_order(wStream* s, RAIL_EXEC_RESULT_ORDER* execResult) |
73 | 204 | { |
74 | 204 | if (!s || !execResult) |
75 | 0 | return ERROR_INVALID_PARAMETER; |
76 | | |
77 | 204 | if (!Stream_CheckAndLogRequiredLength(TAG, s, RAIL_EXEC_RESULT_ORDER_LENGTH)) |
78 | 1 | return ERROR_INVALID_DATA; |
79 | | |
80 | 203 | Stream_Read_UINT16(s, execResult->flags); /* flags (2 bytes) */ |
81 | 203 | Stream_Read_UINT16(s, execResult->execResult); /* execResult (2 bytes) */ |
82 | 203 | Stream_Read_UINT32(s, execResult->rawResult); /* rawResult (4 bytes) */ |
83 | 203 | Stream_Seek_UINT16(s); /* padding (2 bytes) */ |
84 | 203 | return rail_read_unicode_string(s, &execResult->exeOrFile) |
85 | 203 | ? CHANNEL_RC_OK |
86 | 203 | : ERROR_INTERNAL_ERROR; /* exeOrFile */ |
87 | 204 | } |
88 | | |
89 | | /** |
90 | | * Function description |
91 | | * |
92 | | * @return 0 on success, otherwise a Win32 error code |
93 | | */ |
94 | | static UINT rail_read_server_minmaxinfo_order(wStream* s, RAIL_MINMAXINFO_ORDER* minmaxinfo) |
95 | 243 | { |
96 | 243 | if (!s || !minmaxinfo) |
97 | 0 | return ERROR_INVALID_PARAMETER; |
98 | | |
99 | 243 | if (!Stream_CheckAndLogRequiredLength(TAG, s, RAIL_MINMAXINFO_ORDER_LENGTH)) |
100 | 1 | return ERROR_INVALID_DATA; |
101 | | |
102 | 242 | Stream_Read_UINT32(s, minmaxinfo->windowId); /* windowId (4 bytes) */ |
103 | 242 | Stream_Read_INT16(s, minmaxinfo->maxWidth); /* maxWidth (2 bytes) */ |
104 | 242 | Stream_Read_INT16(s, minmaxinfo->maxHeight); /* maxHeight (2 bytes) */ |
105 | 242 | Stream_Read_INT16(s, minmaxinfo->maxPosX); /* maxPosX (2 bytes) */ |
106 | 242 | Stream_Read_INT16(s, minmaxinfo->maxPosY); /* maxPosY (2 bytes) */ |
107 | 242 | Stream_Read_INT16(s, minmaxinfo->minTrackWidth); /* minTrackWidth (2 bytes) */ |
108 | 242 | Stream_Read_INT16(s, minmaxinfo->minTrackHeight); /* minTrackHeight (2 bytes) */ |
109 | 242 | Stream_Read_INT16(s, minmaxinfo->maxTrackWidth); /* maxTrackWidth (2 bytes) */ |
110 | 242 | Stream_Read_INT16(s, minmaxinfo->maxTrackHeight); /* maxTrackHeight (2 bytes) */ |
111 | 242 | return CHANNEL_RC_OK; |
112 | 243 | } |
113 | | |
114 | | /** |
115 | | * Function description |
116 | | * |
117 | | * @return 0 on success, otherwise a Win32 error code |
118 | | */ |
119 | | static UINT rail_read_server_localmovesize_order(wStream* s, |
120 | | RAIL_LOCALMOVESIZE_ORDER* localMoveSize) |
121 | 181 | { |
122 | 181 | UINT16 isMoveSizeStart = 0; |
123 | | |
124 | 181 | if (!s || !localMoveSize) |
125 | 0 | return ERROR_INVALID_PARAMETER; |
126 | | |
127 | 181 | if (!Stream_CheckAndLogRequiredLength(TAG, s, RAIL_LOCALMOVESIZE_ORDER_LENGTH)) |
128 | 1 | return ERROR_INVALID_DATA; |
129 | | |
130 | 180 | Stream_Read_UINT32(s, localMoveSize->windowId); /* windowId (4 bytes) */ |
131 | 180 | Stream_Read_UINT16(s, isMoveSizeStart); /* isMoveSizeStart (2 bytes) */ |
132 | 180 | localMoveSize->isMoveSizeStart = (isMoveSizeStart != 0); |
133 | 180 | Stream_Read_UINT16(s, localMoveSize->moveSizeType); /* moveSizeType (2 bytes) */ |
134 | 180 | Stream_Read_INT16(s, localMoveSize->posX); /* posX (2 bytes) */ |
135 | 180 | Stream_Read_INT16(s, localMoveSize->posY); /* posY (2 bytes) */ |
136 | 180 | return CHANNEL_RC_OK; |
137 | 181 | } |
138 | | |
139 | | /** |
140 | | * Function description |
141 | | * |
142 | | * @return 0 on success, otherwise a Win32 error code |
143 | | */ |
144 | | static UINT rail_read_server_get_appid_resp_order(wStream* s, |
145 | | RAIL_GET_APPID_RESP_ORDER* getAppidResp) |
146 | 48 | { |
147 | 48 | if (!s || !getAppidResp) |
148 | 0 | return ERROR_INVALID_PARAMETER; |
149 | | |
150 | 48 | if (!Stream_CheckAndLogRequiredLength(TAG, s, RAIL_GET_APPID_RESP_ORDER_LENGTH)) |
151 | 1 | return ERROR_INVALID_DATA; |
152 | | |
153 | 47 | Stream_Read_UINT32(s, getAppidResp->windowId); /* windowId (4 bytes) */ |
154 | 47 | if (!Stream_Read_UTF16_String( |
155 | 47 | s, getAppidResp->applicationId, |
156 | 47 | ARRAYSIZE(getAppidResp->applicationId))) /* applicationId (260 UNICODE chars) */ |
157 | 0 | return ERROR_INVALID_DATA; |
158 | 47 | return CHANNEL_RC_OK; |
159 | 47 | } |
160 | | |
161 | | /** |
162 | | * Function description |
163 | | * |
164 | | * @return 0 on success, otherwise a Win32 error code |
165 | | */ |
166 | | static UINT rail_read_langbar_info_order(wStream* s, RAIL_LANGBAR_INFO_ORDER* langbarInfo) |
167 | 0 | { |
168 | 0 | if (!s || !langbarInfo) |
169 | 0 | return ERROR_INVALID_PARAMETER; |
170 | | |
171 | 0 | if (!Stream_CheckAndLogRequiredLength(TAG, s, RAIL_LANGBAR_INFO_ORDER_LENGTH)) |
172 | 0 | return ERROR_INVALID_DATA; |
173 | | |
174 | 0 | Stream_Read_UINT32(s, langbarInfo->languageBarStatus); /* languageBarStatus (4 bytes) */ |
175 | 0 | return CHANNEL_RC_OK; |
176 | 0 | } |
177 | | |
178 | | static UINT rail_write_client_status_order(wStream* s, const RAIL_CLIENT_STATUS_ORDER* clientStatus) |
179 | 0 | { |
180 | 0 | if (!s || !clientStatus) |
181 | 0 | return ERROR_INVALID_PARAMETER; |
182 | | |
183 | 0 | Stream_Write_UINT32(s, clientStatus->flags); /* flags (4 bytes) */ |
184 | 0 | return ERROR_SUCCESS; |
185 | 0 | } |
186 | | |
187 | | /** |
188 | | * Function description |
189 | | * |
190 | | * @return 0 on success, otherwise a Win32 error code |
191 | | */ |
192 | | static UINT rail_write_client_exec_order(wStream* s, UINT16 flags, |
193 | | const RAIL_UNICODE_STRING* exeOrFile, |
194 | | const RAIL_UNICODE_STRING* workingDir, |
195 | | const RAIL_UNICODE_STRING* arguments) |
196 | 0 | { |
197 | 0 | UINT error = 0; |
198 | |
|
199 | 0 | if (!s || !exeOrFile || !workingDir || !arguments) |
200 | 0 | return ERROR_INVALID_PARAMETER; |
201 | | |
202 | | /* [MS-RDPERP] 2.2.2.3.1 Client Execute PDU (TS_RAIL_ORDER_EXEC) |
203 | | * Check argument limits */ |
204 | 0 | if ((exeOrFile->length > 520) || (workingDir->length > 520) || (arguments->length > 16000)) |
205 | 0 | { |
206 | 0 | WLog_ERR(TAG, |
207 | 0 | "TS_RAIL_ORDER_EXEC argument limits exceeded: ExeOrFile=%" PRIu16 |
208 | 0 | " [max=520], WorkingDir=%" PRIu16 " [max=520], Arguments=%" PRIu16 " [max=16000]", |
209 | 0 | exeOrFile->length, workingDir->length, arguments->length); |
210 | 0 | return ERROR_BAD_ARGUMENTS; |
211 | 0 | } |
212 | | |
213 | 0 | Stream_Write_UINT16(s, flags); /* flags (2 bytes) */ |
214 | 0 | Stream_Write_UINT16(s, exeOrFile->length); /* exeOrFileLength (2 bytes) */ |
215 | 0 | Stream_Write_UINT16(s, workingDir->length); /* workingDirLength (2 bytes) */ |
216 | 0 | Stream_Write_UINT16(s, arguments->length); /* argumentsLength (2 bytes) */ |
217 | |
|
218 | 0 | if ((error = rail_write_unicode_string_value(s, exeOrFile))) |
219 | 0 | { |
220 | 0 | WLog_ERR(TAG, "rail_write_unicode_string_value failed with error %" PRIu32 "", error); |
221 | 0 | return error; |
222 | 0 | } |
223 | | |
224 | 0 | if ((error = rail_write_unicode_string_value(s, workingDir))) |
225 | 0 | { |
226 | 0 | WLog_ERR(TAG, "rail_write_unicode_string_value failed with error %" PRIu32 "", error); |
227 | 0 | return error; |
228 | 0 | } |
229 | | |
230 | 0 | if ((error = rail_write_unicode_string_value(s, arguments))) |
231 | 0 | { |
232 | 0 | WLog_ERR(TAG, "rail_write_unicode_string_value failed with error %" PRIu32 "", error); |
233 | 0 | return error; |
234 | 0 | } |
235 | | |
236 | 0 | return error; |
237 | 0 | } |
238 | | |
239 | | static UINT rail_write_client_activate_order(wStream* s, const RAIL_ACTIVATE_ORDER* activate) |
240 | 0 | { |
241 | 0 | BYTE enabled = 0; |
242 | |
|
243 | 0 | if (!s || !activate) |
244 | 0 | return ERROR_INVALID_PARAMETER; |
245 | | |
246 | 0 | Stream_Write_UINT32(s, activate->windowId); /* windowId (4 bytes) */ |
247 | 0 | enabled = activate->enabled ? 1 : 0; |
248 | 0 | Stream_Write_UINT8(s, enabled); /* enabled (1 byte) */ |
249 | 0 | return ERROR_SUCCESS; |
250 | 0 | } |
251 | | |
252 | | static UINT rail_write_client_sysmenu_order(wStream* s, const RAIL_SYSMENU_ORDER* sysmenu) |
253 | 0 | { |
254 | 0 | if (!s || !sysmenu) |
255 | 0 | return ERROR_INVALID_PARAMETER; |
256 | | |
257 | 0 | Stream_Write_UINT32(s, sysmenu->windowId); /* windowId (4 bytes) */ |
258 | 0 | Stream_Write_INT16(s, sysmenu->left); /* left (2 bytes) */ |
259 | 0 | Stream_Write_INT16(s, sysmenu->top); /* top (2 bytes) */ |
260 | 0 | return ERROR_SUCCESS; |
261 | 0 | } |
262 | | |
263 | | static UINT rail_write_client_syscommand_order(wStream* s, const RAIL_SYSCOMMAND_ORDER* syscommand) |
264 | 0 | { |
265 | 0 | if (!s || !syscommand) |
266 | 0 | return ERROR_INVALID_PARAMETER; |
267 | | |
268 | 0 | Stream_Write_UINT32(s, syscommand->windowId); /* windowId (4 bytes) */ |
269 | 0 | Stream_Write_UINT16(s, syscommand->command); /* command (2 bytes) */ |
270 | 0 | return ERROR_SUCCESS; |
271 | 0 | } |
272 | | |
273 | | static UINT rail_write_client_notify_event_order(wStream* s, |
274 | | const RAIL_NOTIFY_EVENT_ORDER* notifyEvent) |
275 | 0 | { |
276 | 0 | if (!s || !notifyEvent) |
277 | 0 | return ERROR_INVALID_PARAMETER; |
278 | | |
279 | 0 | Stream_Write_UINT32(s, notifyEvent->windowId); /* windowId (4 bytes) */ |
280 | 0 | Stream_Write_UINT32(s, notifyEvent->notifyIconId); /* notifyIconId (4 bytes) */ |
281 | 0 | Stream_Write_UINT32(s, notifyEvent->message); /* notifyIconId (4 bytes) */ |
282 | 0 | return ERROR_SUCCESS; |
283 | 0 | } |
284 | | |
285 | | static UINT rail_write_client_window_move_order(wStream* s, |
286 | | const RAIL_WINDOW_MOVE_ORDER* windowMove) |
287 | 0 | { |
288 | 0 | if (!s || !windowMove) |
289 | 0 | return ERROR_INVALID_PARAMETER; |
290 | | |
291 | 0 | Stream_Write_UINT32(s, windowMove->windowId); /* windowId (4 bytes) */ |
292 | 0 | Stream_Write_INT16(s, windowMove->left); /* left (2 bytes) */ |
293 | 0 | Stream_Write_INT16(s, windowMove->top); /* top (2 bytes) */ |
294 | 0 | Stream_Write_INT16(s, windowMove->right); /* right (2 bytes) */ |
295 | 0 | Stream_Write_INT16(s, windowMove->bottom); /* bottom (2 bytes) */ |
296 | 0 | return ERROR_SUCCESS; |
297 | 0 | } |
298 | | |
299 | | static UINT rail_write_client_get_appid_req_order(wStream* s, |
300 | | const RAIL_GET_APPID_REQ_ORDER* getAppidReq) |
301 | 0 | { |
302 | 0 | if (!s || !getAppidReq) |
303 | 0 | return ERROR_INVALID_PARAMETER; |
304 | | |
305 | 0 | Stream_Write_UINT32(s, getAppidReq->windowId); /* windowId (4 bytes) */ |
306 | 0 | return ERROR_SUCCESS; |
307 | 0 | } |
308 | | |
309 | | static UINT rail_write_langbar_info_order(wStream* s, const RAIL_LANGBAR_INFO_ORDER* langbarInfo) |
310 | 0 | { |
311 | 0 | if (!s || !langbarInfo) |
312 | 0 | return ERROR_INVALID_PARAMETER; |
313 | | |
314 | 0 | Stream_Write_UINT32(s, langbarInfo->languageBarStatus); /* languageBarStatus (4 bytes) */ |
315 | 0 | return ERROR_SUCCESS; |
316 | 0 | } |
317 | | |
318 | | static UINT rail_write_languageime_info_order(wStream* s, |
319 | | const RAIL_LANGUAGEIME_INFO_ORDER* langImeInfo) |
320 | 0 | { |
321 | 0 | if (!s || !langImeInfo) |
322 | 0 | return ERROR_INVALID_PARAMETER; |
323 | | |
324 | 0 | Stream_Write_UINT32(s, langImeInfo->ProfileType); |
325 | 0 | Stream_Write_UINT16(s, WINPR_ASSERTING_INT_CAST(UINT16, langImeInfo->LanguageID)); |
326 | 0 | Stream_Write(s, &langImeInfo->LanguageProfileCLSID, sizeof(langImeInfo->LanguageProfileCLSID)); |
327 | 0 | Stream_Write(s, &langImeInfo->ProfileGUID, sizeof(langImeInfo->ProfileGUID)); |
328 | 0 | Stream_Write_UINT32(s, langImeInfo->KeyboardLayout); |
329 | 0 | return ERROR_SUCCESS; |
330 | 0 | } |
331 | | |
332 | | static UINT rail_write_compartment_info_order(wStream* s, |
333 | | const RAIL_COMPARTMENT_INFO_ORDER* compartmentInfo) |
334 | 0 | { |
335 | 0 | if (!s || !compartmentInfo) |
336 | 0 | return ERROR_INVALID_PARAMETER; |
337 | | |
338 | 0 | Stream_Write_UINT32(s, compartmentInfo->ImeState); |
339 | 0 | Stream_Write_UINT32(s, compartmentInfo->ImeConvMode); |
340 | 0 | Stream_Write_UINT32(s, compartmentInfo->ImeSentenceMode); |
341 | 0 | Stream_Write_UINT32(s, compartmentInfo->KanaMode); |
342 | 0 | return ERROR_SUCCESS; |
343 | 0 | } |
344 | | |
345 | | /** |
346 | | * Function description |
347 | | * |
348 | | * @return 0 on success, otherwise a Win32 error code |
349 | | */ |
350 | | static UINT rail_recv_handshake_order(railPlugin* rail, wStream* s) |
351 | 41 | { |
352 | 41 | RailClientContext* context = rail_get_client_interface(rail); |
353 | 41 | RAIL_HANDSHAKE_ORDER serverHandshake = WINPR_C_ARRAY_INIT; |
354 | 41 | UINT error = 0; |
355 | | |
356 | 41 | if (!context || !s) |
357 | 0 | return ERROR_INVALID_PARAMETER; |
358 | | |
359 | 41 | if ((error = rail_read_handshake_order(s, &serverHandshake))) |
360 | 1 | { |
361 | 1 | WLog_ERR(TAG, "rail_read_handshake_order failed with error %" PRIu32 "!", error); |
362 | 1 | return error; |
363 | 1 | } |
364 | | |
365 | 40 | rail->channelBuildNumber = serverHandshake.buildNumber; |
366 | | |
367 | 40 | if (context->custom) |
368 | 0 | { |
369 | 0 | IFCALLRET(context->ServerHandshake, error, context, &serverHandshake); |
370 | |
|
371 | 0 | if (error) |
372 | 0 | WLog_ERR(TAG, "context.ServerHandshake failed with error %" PRIu32 "", error); |
373 | 0 | } |
374 | | |
375 | 40 | return error; |
376 | 41 | } |
377 | | |
378 | | static UINT rail_read_compartment_info_order(wStream* s, |
379 | | RAIL_COMPARTMENT_INFO_ORDER* compartmentInfo) |
380 | 0 | { |
381 | 0 | if (!Stream_CheckAndLogRequiredLength(TAG, s, RAIL_COMPARTMENT_INFO_ORDER_LENGTH)) |
382 | 0 | return ERROR_INVALID_DATA; |
383 | | |
384 | 0 | Stream_Read_UINT32(s, compartmentInfo->ImeState); /* ImeState (4 bytes) */ |
385 | 0 | Stream_Read_UINT32(s, compartmentInfo->ImeConvMode); /* ImeConvMode (4 bytes) */ |
386 | 0 | Stream_Read_UINT32(s, compartmentInfo->ImeSentenceMode); /* ImeSentenceMode (4 bytes) */ |
387 | 0 | Stream_Read_UINT32(s, compartmentInfo->KanaMode); /* KANAMode (4 bytes) */ |
388 | 0 | return CHANNEL_RC_OK; |
389 | 0 | } |
390 | | |
391 | | static UINT rail_recv_compartmentinfo_order(railPlugin* rail, wStream* s) |
392 | 1 | { |
393 | 1 | RailClientContext* context = rail_get_client_interface(rail); |
394 | 1 | RAIL_COMPARTMENT_INFO_ORDER pdu = WINPR_C_ARRAY_INIT; |
395 | 1 | UINT error = 0; |
396 | | |
397 | 1 | if (!context || !s) |
398 | 0 | return ERROR_INVALID_PARAMETER; |
399 | | |
400 | 1 | if (!rail_is_feature_supported(rail->rdpcontext, RAIL_LEVEL_LANGUAGE_IME_SYNC_SUPPORTED)) |
401 | 1 | return ERROR_BAD_CONFIGURATION; |
402 | | |
403 | 0 | if ((error = rail_read_compartment_info_order(s, &pdu))) |
404 | 0 | return error; |
405 | | |
406 | 0 | if (context->custom) |
407 | 0 | { |
408 | 0 | IFCALLRET(context->ClientCompartmentInfo, error, context, &pdu); |
409 | |
|
410 | 0 | if (error) |
411 | 0 | WLog_ERR(TAG, "context.ClientCompartmentInfo failed with error %" PRIu32 "", error); |
412 | 0 | } |
413 | |
|
414 | 0 | return error; |
415 | 0 | } |
416 | | |
417 | | BOOL rail_is_feature_supported(const rdpContext* context, UINT32 featureMask) |
418 | 4 | { |
419 | 4 | UINT32 supported = 0; |
420 | 4 | UINT32 masked = 0; |
421 | | |
422 | 4 | if (!context || !context->settings) |
423 | 4 | return FALSE; |
424 | | |
425 | 0 | const UINT32 level = |
426 | 0 | freerdp_settings_get_uint32(context->settings, FreeRDP_RemoteApplicationSupportLevel); |
427 | 0 | const UINT32 mask = |
428 | 0 | freerdp_settings_get_uint32(context->settings, FreeRDP_RemoteApplicationSupportMask); |
429 | 0 | supported = level & mask; |
430 | 0 | masked = (supported & featureMask); |
431 | |
|
432 | 0 | if (masked != featureMask) |
433 | 0 | { |
434 | 0 | char maskstr[256] = WINPR_C_ARRAY_INIT; |
435 | 0 | char actualstr[256] = WINPR_C_ARRAY_INIT; |
436 | |
|
437 | 0 | WLog_WARN(TAG, "have %s, require %s", |
438 | 0 | freerdp_rail_support_flags_to_string(supported, actualstr, sizeof(actualstr)), |
439 | 0 | freerdp_rail_support_flags_to_string(featureMask, maskstr, sizeof(maskstr))); |
440 | 0 | return FALSE; |
441 | 0 | } |
442 | | |
443 | 0 | return TRUE; |
444 | 0 | } |
445 | | |
446 | | /** |
447 | | * Function description |
448 | | * |
449 | | * @return 0 on success, otherwise a Win32 error code |
450 | | */ |
451 | | static UINT rail_recv_handshake_ex_order(railPlugin* rail, wStream* s) |
452 | 1 | { |
453 | 1 | RailClientContext* context = rail_get_client_interface(rail); |
454 | 1 | RAIL_HANDSHAKE_EX_ORDER serverHandshake = WINPR_C_ARRAY_INIT; |
455 | 1 | UINT error = 0; |
456 | | |
457 | 1 | if (!rail || !context || !s) |
458 | 0 | return ERROR_INVALID_PARAMETER; |
459 | | |
460 | 1 | if (!rail_is_feature_supported(rail->rdpcontext, RAIL_LEVEL_HANDSHAKE_EX_SUPPORTED)) |
461 | 1 | return ERROR_BAD_CONFIGURATION; |
462 | | |
463 | 0 | if ((error = rail_read_handshake_ex_order(s, &serverHandshake))) |
464 | 0 | { |
465 | 0 | WLog_ERR(TAG, "rail_read_handshake_ex_order failed with error %" PRIu32 "!", error); |
466 | 0 | return error; |
467 | 0 | } |
468 | | |
469 | 0 | rail->channelBuildNumber = serverHandshake.buildNumber; |
470 | 0 | rail->channelFlags = serverHandshake.railHandshakeFlags; |
471 | |
|
472 | 0 | { |
473 | 0 | char buffer[192] = WINPR_C_ARRAY_INIT; |
474 | 0 | WLog_DBG(TAG, "HandshakeFlags=%s [buildNumber=0x%08" PRIx32 "]", |
475 | 0 | rail_handshake_ex_flags_to_string(rail->channelFlags, buffer, sizeof(buffer)), |
476 | 0 | rail->channelBuildNumber); |
477 | 0 | } |
478 | |
|
479 | 0 | if (context->custom) |
480 | 0 | { |
481 | 0 | IFCALLRET(context->ServerHandshakeEx, error, context, &serverHandshake); |
482 | |
|
483 | 0 | if (error) |
484 | 0 | WLog_ERR(TAG, "context.ServerHandshakeEx failed with error %" PRIu32 "", error); |
485 | 0 | } |
486 | |
|
487 | 0 | return error; |
488 | 0 | } |
489 | | |
490 | | /** |
491 | | * Function description |
492 | | * |
493 | | * @return 0 on success, otherwise a Win32 error code |
494 | | */ |
495 | | static UINT rail_recv_exec_result_order(railPlugin* rail, wStream* s) |
496 | 204 | { |
497 | 204 | RailClientContext* context = rail_get_client_interface(rail); |
498 | 204 | RAIL_EXEC_RESULT_ORDER execResult = WINPR_C_ARRAY_INIT; |
499 | 204 | UINT error = 0; |
500 | | |
501 | 204 | if (!context || !s) |
502 | 0 | return ERROR_INVALID_PARAMETER; |
503 | | |
504 | 204 | if ((error = rail_read_server_exec_result_order(s, &execResult))) |
505 | 119 | { |
506 | 119 | WLog_ERR(TAG, "rail_read_server_exec_result_order failed with error %" PRIu32 "!", error); |
507 | 119 | goto fail; |
508 | 119 | } |
509 | | |
510 | 85 | if (context->custom) |
511 | 0 | { |
512 | 0 | IFCALLRET(context->ServerExecuteResult, error, context, &execResult); |
513 | |
|
514 | 0 | if (error) |
515 | 0 | WLog_ERR(TAG, "context.ServerExecuteResult failed with error %" PRIu32 "", error); |
516 | 0 | } |
517 | | |
518 | 204 | fail: |
519 | 204 | rail_unicode_string_free(&execResult.exeOrFile); |
520 | 204 | return error; |
521 | 85 | } |
522 | | |
523 | | /** |
524 | | * Function description |
525 | | * |
526 | | * @return 0 on success, otherwise a Win32 error code |
527 | | */ |
528 | | static UINT rail_recv_server_sysparam_order(railPlugin* rail, wStream* s) |
529 | 329 | { |
530 | 329 | RailClientContext* context = rail_get_client_interface(rail); |
531 | | |
532 | 329 | if (!context || !s) |
533 | 0 | return ERROR_INVALID_PARAMETER; |
534 | | |
535 | 329 | const BOOL extendedSpiSupported = rail_is_extended_spi_supported(rail->channelFlags); |
536 | 329 | RAIL_SYSPARAM_ORDER sysparam = WINPR_C_ARRAY_INIT; |
537 | 329 | UINT error = rail_read_sysparam_order(s, &sysparam, extendedSpiSupported); |
538 | 329 | if (error) |
539 | 57 | { |
540 | 57 | WLog_ERR(TAG, "rail_read_sysparam_order failed with error %" PRIu32 "!", error); |
541 | 57 | goto fail; |
542 | 57 | } |
543 | | |
544 | 272 | if (context->custom) |
545 | 0 | { |
546 | 0 | IFCALLRET(context->ServerSystemParam, error, context, &sysparam); |
547 | |
|
548 | 0 | if (error) |
549 | 0 | WLog_ERR(TAG, "context.ServerSystemParam failed with error %" PRIu32 "", error); |
550 | 0 | } |
551 | 329 | fail: |
552 | 329 | rail_unicode_string_free(&sysparam.highContrast.colorScheme); |
553 | | |
554 | 329 | return error; |
555 | 272 | } |
556 | | |
557 | | /** |
558 | | * Function description |
559 | | * |
560 | | * @return 0 on success, otherwise a Win32 error code |
561 | | */ |
562 | | static UINT rail_recv_server_minmaxinfo_order(railPlugin* rail, wStream* s) |
563 | 243 | { |
564 | 243 | RailClientContext* context = rail_get_client_interface(rail); |
565 | 243 | RAIL_MINMAXINFO_ORDER minMaxInfo = WINPR_C_ARRAY_INIT; |
566 | 243 | UINT error = 0; |
567 | | |
568 | 243 | if (!context || !s) |
569 | 0 | return ERROR_INVALID_PARAMETER; |
570 | | |
571 | 243 | if ((error = rail_read_server_minmaxinfo_order(s, &minMaxInfo))) |
572 | 1 | { |
573 | 1 | WLog_ERR(TAG, "rail_read_server_minmaxinfo_order failed with error %" PRIu32 "!", error); |
574 | 1 | return error; |
575 | 1 | } |
576 | | |
577 | 242 | if (context->custom) |
578 | 0 | { |
579 | 0 | IFCALLRET(context->ServerMinMaxInfo, error, context, &minMaxInfo); |
580 | |
|
581 | 0 | if (error) |
582 | 0 | WLog_ERR(TAG, "context.ServerMinMaxInfo failed with error %" PRIu32 "", error); |
583 | 0 | } |
584 | | |
585 | 242 | return error; |
586 | 243 | } |
587 | | |
588 | | /** |
589 | | * Function description |
590 | | * |
591 | | * @return 0 on success, otherwise a Win32 error code |
592 | | */ |
593 | | static UINT rail_recv_server_localmovesize_order(railPlugin* rail, wStream* s) |
594 | 181 | { |
595 | 181 | RailClientContext* context = rail_get_client_interface(rail); |
596 | 181 | RAIL_LOCALMOVESIZE_ORDER localMoveSize = WINPR_C_ARRAY_INIT; |
597 | 181 | UINT error = 0; |
598 | | |
599 | 181 | if (!context || !s) |
600 | 0 | return ERROR_INVALID_PARAMETER; |
601 | | |
602 | 181 | if ((error = rail_read_server_localmovesize_order(s, &localMoveSize))) |
603 | 1 | { |
604 | 1 | WLog_ERR(TAG, "rail_read_server_localmovesize_order failed with error %" PRIu32 "!", error); |
605 | 1 | return error; |
606 | 1 | } |
607 | | |
608 | 180 | if (context->custom) |
609 | 0 | { |
610 | 0 | IFCALLRET(context->ServerLocalMoveSize, error, context, &localMoveSize); |
611 | |
|
612 | 0 | if (error) |
613 | 0 | WLog_ERR(TAG, "context.ServerLocalMoveSize failed with error %" PRIu32 "", error); |
614 | 0 | } |
615 | | |
616 | 180 | return error; |
617 | 181 | } |
618 | | |
619 | | /** |
620 | | * Function description |
621 | | * |
622 | | * @return 0 on success, otherwise a Win32 error code |
623 | | */ |
624 | | static UINT rail_recv_server_get_appid_resp_order(railPlugin* rail, wStream* s) |
625 | 48 | { |
626 | 48 | RailClientContext* context = rail_get_client_interface(rail); |
627 | 48 | RAIL_GET_APPID_RESP_ORDER getAppIdResp = WINPR_C_ARRAY_INIT; |
628 | 48 | UINT error = 0; |
629 | | |
630 | 48 | if (!context || !s) |
631 | 0 | return ERROR_INVALID_PARAMETER; |
632 | | |
633 | 48 | if ((error = rail_read_server_get_appid_resp_order(s, &getAppIdResp))) |
634 | 1 | { |
635 | 1 | WLog_ERR(TAG, "rail_read_server_get_appid_resp_order failed with error %" PRIu32 "!", |
636 | 1 | error); |
637 | 1 | return error; |
638 | 1 | } |
639 | | |
640 | 47 | if (context->custom) |
641 | 0 | { |
642 | 0 | IFCALLRET(context->ServerGetAppIdResponse, error, context, &getAppIdResp); |
643 | |
|
644 | 0 | if (error) |
645 | 0 | WLog_ERR(TAG, "context.ServerGetAppIdResponse failed with error %" PRIu32 "", error); |
646 | 0 | } |
647 | | |
648 | 47 | return error; |
649 | 48 | } |
650 | | |
651 | | /** |
652 | | * Function description |
653 | | * |
654 | | * @return 0 on success, otherwise a Win32 error code |
655 | | */ |
656 | | static UINT rail_recv_langbar_info_order(railPlugin* rail, wStream* s) |
657 | 1 | { |
658 | 1 | RailClientContext* context = rail_get_client_interface(rail); |
659 | 1 | RAIL_LANGBAR_INFO_ORDER langBarInfo = WINPR_C_ARRAY_INIT; |
660 | 1 | UINT error = 0; |
661 | | |
662 | 1 | if (!context) |
663 | 0 | return ERROR_INVALID_PARAMETER; |
664 | | |
665 | 1 | if (!rail_is_feature_supported(rail->rdpcontext, RAIL_LEVEL_DOCKED_LANGBAR_SUPPORTED)) |
666 | 1 | return ERROR_BAD_CONFIGURATION; |
667 | | |
668 | 0 | if ((error = rail_read_langbar_info_order(s, &langBarInfo))) |
669 | 0 | { |
670 | 0 | WLog_ERR(TAG, "rail_read_langbar_info_order failed with error %" PRIu32 "!", error); |
671 | 0 | return error; |
672 | 0 | } |
673 | | |
674 | 0 | if (context->custom) |
675 | 0 | { |
676 | 0 | IFCALLRET(context->ServerLanguageBarInfo, error, context, &langBarInfo); |
677 | |
|
678 | 0 | if (error) |
679 | 0 | WLog_ERR(TAG, "context.ServerLanguageBarInfo failed with error %" PRIu32 "", error); |
680 | 0 | } |
681 | |
|
682 | 0 | return error; |
683 | 0 | } |
684 | | |
685 | | static UINT rail_read_taskbar_info_order(wStream* s, RAIL_TASKBAR_INFO_ORDER* taskbarInfo) |
686 | 0 | { |
687 | 0 | if (!s || !taskbarInfo) |
688 | 0 | return ERROR_INVALID_PARAMETER; |
689 | | |
690 | 0 | if (!Stream_CheckAndLogRequiredLength(TAG, s, RAIL_TASKBAR_INFO_ORDER_LENGTH)) |
691 | 0 | return ERROR_INVALID_DATA; |
692 | | |
693 | 0 | Stream_Read_UINT32(s, taskbarInfo->TaskbarMessage); |
694 | 0 | Stream_Read_UINT32(s, taskbarInfo->WindowIdTab); |
695 | 0 | Stream_Read_UINT32(s, taskbarInfo->Body); |
696 | 0 | return CHANNEL_RC_OK; |
697 | 0 | } |
698 | | |
699 | | static UINT rail_recv_taskbar_info_order(railPlugin* rail, wStream* s) |
700 | 1 | { |
701 | 1 | RailClientContext* context = rail_get_client_interface(rail); |
702 | 1 | RAIL_TASKBAR_INFO_ORDER taskBarInfo = WINPR_C_ARRAY_INIT; |
703 | 1 | UINT error = 0; |
704 | | |
705 | 1 | if (!context) |
706 | 0 | return ERROR_INVALID_PARAMETER; |
707 | | |
708 | | /* 2.2.2.14.1 Taskbar Tab Info PDU (TS_RAIL_ORDER_TASKBARINFO) |
709 | | * server -> client message only supported if announced. */ |
710 | 1 | if (!rail_is_feature_supported(rail->rdpcontext, RAIL_LEVEL_SHELL_INTEGRATION_SUPPORTED)) |
711 | 1 | return ERROR_BAD_CONFIGURATION; |
712 | | |
713 | 0 | if ((error = rail_read_taskbar_info_order(s, &taskBarInfo))) |
714 | 0 | { |
715 | 0 | WLog_ERR(TAG, "rail_read_langbar_info_order failed with error %" PRIu32 "!", error); |
716 | 0 | return error; |
717 | 0 | } |
718 | | |
719 | 0 | if (context->custom) |
720 | 0 | { |
721 | 0 | IFCALLRET(context->ServerTaskBarInfo, error, context, &taskBarInfo); |
722 | |
|
723 | 0 | if (error) |
724 | 0 | WLog_ERR(TAG, "context.ServerTaskBarInfo failed with error %" PRIu32 "", error); |
725 | 0 | } |
726 | |
|
727 | 0 | return error; |
728 | 0 | } |
729 | | |
730 | | static UINT rail_read_zorder_sync_order(wStream* s, RAIL_ZORDER_SYNC* zorder) |
731 | 0 | { |
732 | 0 | if (!s || !zorder) |
733 | 0 | return ERROR_INVALID_PARAMETER; |
734 | | |
735 | 0 | if (!Stream_CheckAndLogRequiredLength(TAG, s, RAIL_Z_ORDER_SYNC_ORDER_LENGTH)) |
736 | 0 | return ERROR_INVALID_DATA; |
737 | | |
738 | 0 | Stream_Read_UINT32(s, zorder->windowIdMarker); |
739 | 0 | return CHANNEL_RC_OK; |
740 | 0 | } |
741 | | |
742 | | static UINT rail_recv_zorder_sync_order(railPlugin* rail, wStream* s) |
743 | 1 | { |
744 | 1 | RailClientContext* context = rail_get_client_interface(rail); |
745 | 1 | RAIL_ZORDER_SYNC zorder = WINPR_C_ARRAY_INIT; |
746 | 1 | UINT error = 0; |
747 | | |
748 | 1 | if (!context) |
749 | 0 | return ERROR_INVALID_PARAMETER; |
750 | | |
751 | 1 | if ((rail->clientStatus.flags & TS_RAIL_CLIENTSTATUS_ZORDER_SYNC) == 0) |
752 | 1 | return ERROR_INVALID_DATA; |
753 | | |
754 | 0 | if ((error = rail_read_zorder_sync_order(s, &zorder))) |
755 | 0 | { |
756 | 0 | WLog_ERR(TAG, "rail_read_zorder_sync_order failed with error %" PRIu32 "!", error); |
757 | 0 | return error; |
758 | 0 | } |
759 | | |
760 | 0 | if (context->custom) |
761 | 0 | { |
762 | 0 | IFCALLRET(context->ServerZOrderSync, error, context, &zorder); |
763 | |
|
764 | 0 | if (error) |
765 | 0 | WLog_ERR(TAG, "context.ServerZOrderSync failed with error %" PRIu32 "", error); |
766 | 0 | } |
767 | |
|
768 | 0 | return error; |
769 | 0 | } |
770 | | |
771 | | static UINT rail_read_cloak_order(wStream* s, RAIL_CLOAK* cloak) |
772 | 0 | { |
773 | 0 | BYTE cloaked = 0; |
774 | |
|
775 | 0 | if (!Stream_CheckAndLogRequiredLength(TAG, s, RAIL_CLOAK_ORDER_LENGTH)) |
776 | 0 | return ERROR_INVALID_DATA; |
777 | | |
778 | 0 | Stream_Read_UINT32(s, cloak->windowId); /* WindowId (4 bytes) */ |
779 | 0 | Stream_Read_UINT8(s, cloaked); /* Cloaked (1 byte) */ |
780 | 0 | cloak->cloak = (cloaked != 0); |
781 | 0 | return CHANNEL_RC_OK; |
782 | 0 | } |
783 | | |
784 | | static UINT rail_recv_cloak_order(railPlugin* rail, wStream* s) |
785 | 1 | { |
786 | 1 | RailClientContext* context = rail_get_client_interface(rail); |
787 | 1 | RAIL_CLOAK cloak = WINPR_C_ARRAY_INIT; |
788 | 1 | UINT error = 0; |
789 | | |
790 | 1 | if (!context) |
791 | 0 | return ERROR_INVALID_PARAMETER; |
792 | | |
793 | | /* 2.2.2.12.1 Window Cloak State Change PDU (TS_RAIL_ORDER_CLOAK) |
794 | | * server -> client message only supported if announced. */ |
795 | 1 | if ((rail->clientStatus.flags & TS_RAIL_CLIENTSTATUS_BIDIRECTIONAL_CLOAK_SUPPORTED) == 0) |
796 | 1 | return ERROR_INVALID_DATA; |
797 | | |
798 | 0 | if ((error = rail_read_cloak_order(s, &cloak))) |
799 | 0 | { |
800 | 0 | WLog_ERR(TAG, "rail_read_zorder_sync_order failed with error %" PRIu32 "!", error); |
801 | 0 | return error; |
802 | 0 | } |
803 | | |
804 | 0 | if (context->custom) |
805 | 0 | { |
806 | 0 | IFCALLRET(context->ServerCloak, error, context, &cloak); |
807 | |
|
808 | 0 | if (error) |
809 | 0 | WLog_ERR(TAG, "context.ServerZOrderSync failed with error %" PRIu32 "", error); |
810 | 0 | } |
811 | |
|
812 | 0 | return error; |
813 | 0 | } |
814 | | |
815 | | static UINT rail_read_power_display_request_order(wStream* s, RAIL_POWER_DISPLAY_REQUEST* power) |
816 | 0 | { |
817 | 0 | UINT32 active = 0; |
818 | |
|
819 | 0 | if (!s || !power) |
820 | 0 | return ERROR_INVALID_PARAMETER; |
821 | | |
822 | 0 | if (!Stream_CheckAndLogRequiredLength(TAG, s, RAIL_POWER_DISPLAY_REQUEST_ORDER_LENGTH)) |
823 | 0 | return ERROR_INVALID_DATA; |
824 | | |
825 | 0 | Stream_Read_UINT32(s, active); |
826 | 0 | power->active = active != 0; |
827 | 0 | return CHANNEL_RC_OK; |
828 | 0 | } |
829 | | |
830 | | static UINT rail_recv_power_display_request_order(railPlugin* rail, wStream* s) |
831 | 1 | { |
832 | 1 | RailClientContext* context = rail_get_client_interface(rail); |
833 | 1 | RAIL_POWER_DISPLAY_REQUEST power = WINPR_C_ARRAY_INIT; |
834 | 1 | UINT error = 0; |
835 | | |
836 | 1 | if (!context) |
837 | 0 | return ERROR_INVALID_PARAMETER; |
838 | | |
839 | | /* 2.2.2.13.1 Power Display Request PDU(TS_RAIL_ORDER_POWER_DISPLAY_REQUEST) |
840 | | */ |
841 | 1 | if ((rail->clientStatus.flags & TS_RAIL_CLIENTSTATUS_POWER_DISPLAY_REQUEST_SUPPORTED) == 0) |
842 | 1 | return ERROR_INVALID_DATA; |
843 | | |
844 | 0 | if ((error = rail_read_power_display_request_order(s, &power))) |
845 | 0 | { |
846 | 0 | WLog_ERR(TAG, "rail_read_zorder_sync_order failed with error %" PRIu32 "!", error); |
847 | 0 | return error; |
848 | 0 | } |
849 | | |
850 | 0 | if (context->custom) |
851 | 0 | { |
852 | 0 | IFCALLRET(context->ServerPowerDisplayRequest, error, context, &power); |
853 | |
|
854 | 0 | if (error) |
855 | 0 | WLog_ERR(TAG, "context.ServerPowerDisplayRequest failed with error %" PRIu32 "", error); |
856 | 0 | } |
857 | |
|
858 | 0 | return error; |
859 | 0 | } |
860 | | |
861 | | static UINT rail_read_get_application_id_extended_response_order(wStream* s, |
862 | | RAIL_GET_APPID_RESP_EX* id) |
863 | 144 | { |
864 | 144 | if (!s || !id) |
865 | 0 | return ERROR_INVALID_PARAMETER; |
866 | | |
867 | 144 | if (!Stream_CheckAndLogRequiredLength(TAG, s, 4)) |
868 | 1 | return ERROR_INVALID_DATA; |
869 | | |
870 | 143 | Stream_Read_UINT32(s, id->windowID); |
871 | | |
872 | 143 | if (!Stream_Read_UTF16_String(s, id->applicationID, ARRAYSIZE(id->applicationID))) |
873 | 18 | return ERROR_INVALID_DATA; |
874 | | |
875 | 125 | if (_wcsnlen(id->applicationID, ARRAYSIZE(id->applicationID)) >= ARRAYSIZE(id->applicationID)) |
876 | 6 | return ERROR_INVALID_DATA; |
877 | | |
878 | 119 | if (!Stream_CheckAndLogRequiredLength(TAG, s, 4)) |
879 | 11 | return ERROR_INVALID_DATA; |
880 | | |
881 | 108 | Stream_Read_UINT32(s, id->processId); |
882 | | |
883 | 108 | if (!Stream_Read_UTF16_String(s, id->processImageName, ARRAYSIZE(id->processImageName))) |
884 | 18 | return ERROR_INVALID_DATA; |
885 | | |
886 | 90 | if (_wcsnlen(id->processImageName, ARRAYSIZE(id->processImageName)) >= |
887 | 90 | ARRAYSIZE(id->processImageName)) |
888 | 8 | return ERROR_INVALID_DATA; |
889 | | |
890 | 82 | return CHANNEL_RC_OK; |
891 | 90 | } |
892 | | |
893 | | static UINT rail_recv_get_application_id_extended_response_order(railPlugin* rail, wStream* s) |
894 | 144 | { |
895 | 144 | RailClientContext* context = rail_get_client_interface(rail); |
896 | 144 | RAIL_GET_APPID_RESP_EX id = WINPR_C_ARRAY_INIT; |
897 | 144 | UINT error = 0; |
898 | | |
899 | 144 | if (!context) |
900 | 0 | return ERROR_INVALID_PARAMETER; |
901 | | |
902 | 144 | if ((error = rail_read_get_application_id_extended_response_order(s, &id))) |
903 | 62 | { |
904 | 62 | WLog_ERR(TAG, |
905 | 62 | "rail_read_get_application_id_extended_response_order failed with error %" PRIu32 |
906 | 62 | "!", |
907 | 62 | error); |
908 | 62 | return error; |
909 | 62 | } |
910 | | |
911 | 82 | if (context->custom) |
912 | 0 | { |
913 | 0 | IFCALLRET(context->ServerGetAppidResponseExtended, error, context, &id); |
914 | |
|
915 | 0 | if (error) |
916 | 0 | WLog_ERR(TAG, "context.ServerGetAppidResponseExtended failed with error %" PRIu32 "", |
917 | 0 | error); |
918 | 0 | } |
919 | | |
920 | 82 | return error; |
921 | 144 | } |
922 | | |
923 | | static UINT rail_read_textscaleinfo_order(wStream* s, UINT32* pTextScaleFactor) |
924 | 16 | { |
925 | 16 | WINPR_ASSERT(pTextScaleFactor); |
926 | | |
927 | 16 | if (!Stream_CheckAndLogRequiredLength(TAG, s, 4)) |
928 | 1 | return ERROR_INVALID_DATA; |
929 | | |
930 | 15 | Stream_Read_UINT32(s, *pTextScaleFactor); |
931 | 15 | return CHANNEL_RC_OK; |
932 | 16 | } |
933 | | |
934 | | static UINT rail_recv_textscaleinfo_order(railPlugin* rail, wStream* s) |
935 | 16 | { |
936 | 16 | RailClientContext* context = rail_get_client_interface(rail); |
937 | 16 | UINT32 TextScaleFactor = 0; |
938 | 16 | UINT error = 0; |
939 | | |
940 | 16 | if (!context) |
941 | 0 | return ERROR_INVALID_PARAMETER; |
942 | | |
943 | 16 | if ((error = rail_read_textscaleinfo_order(s, &TextScaleFactor))) |
944 | 1 | return error; |
945 | | |
946 | 15 | if (context->custom) |
947 | 0 | { |
948 | 0 | IFCALLRET(context->ClientTextScale, error, context, TextScaleFactor); |
949 | |
|
950 | 0 | if (error) |
951 | 0 | WLog_ERR(TAG, "context.ClientTextScale failed with error %" PRIu32 "", error); |
952 | 0 | } |
953 | | |
954 | 15 | return error; |
955 | 16 | } |
956 | | |
957 | | static UINT rail_read_caretblinkinfo_order(wStream* s, UINT32* pCaretBlinkRate) |
958 | 43 | { |
959 | 43 | WINPR_ASSERT(pCaretBlinkRate); |
960 | | |
961 | 43 | if (!Stream_CheckAndLogRequiredLength(TAG, s, 4)) |
962 | 1 | return ERROR_INVALID_DATA; |
963 | | |
964 | 42 | Stream_Read_UINT32(s, *pCaretBlinkRate); |
965 | 42 | return CHANNEL_RC_OK; |
966 | 43 | } |
967 | | |
968 | | static UINT rail_recv_caretblinkinfo_order(railPlugin* rail, wStream* s) |
969 | 43 | { |
970 | 43 | RailClientContext* context = rail_get_client_interface(rail); |
971 | 43 | UINT32 CaretBlinkRate = 0; |
972 | 43 | UINT error = 0; |
973 | | |
974 | 43 | if (!context) |
975 | 0 | return ERROR_INVALID_PARAMETER; |
976 | 43 | if ((error = rail_read_caretblinkinfo_order(s, &CaretBlinkRate))) |
977 | 1 | return error; |
978 | | |
979 | 42 | if (context->custom) |
980 | 0 | { |
981 | 0 | IFCALLRET(context->ClientCaretBlinkRate, error, context, CaretBlinkRate); |
982 | |
|
983 | 0 | if (error) |
984 | 0 | WLog_ERR(TAG, "context.ClientCaretBlinkRate failed with error %" PRIu32 "", error); |
985 | 0 | } |
986 | | |
987 | 42 | return error; |
988 | 43 | } |
989 | | |
990 | | /** |
991 | | * Function description |
992 | | * |
993 | | * @return 0 on success, otherwise a Win32 error code |
994 | | */ |
995 | | UINT rail_order_recv(LPVOID userdata, wStream* s) |
996 | 1.32k | { |
997 | 1.32k | char buffer[128] = WINPR_C_ARRAY_INIT; |
998 | 1.32k | railPlugin* rail = userdata; |
999 | 1.32k | UINT16 orderType = 0; |
1000 | 1.32k | UINT16 orderLength = 0; |
1001 | 1.32k | UINT error = CHANNEL_RC_OK; |
1002 | | |
1003 | 1.32k | if (!rail || !s) |
1004 | 0 | { |
1005 | 0 | error = ERROR_INVALID_PARAMETER; |
1006 | 0 | goto fail; |
1007 | 0 | } |
1008 | | |
1009 | 1.32k | if ((error = rail_read_pdu_header(s, &orderType, &orderLength))) |
1010 | 55 | { |
1011 | 55 | WLog_ERR(TAG, "rail_read_pdu_header failed with error %" PRIu32 "!", error); |
1012 | 55 | error = ERROR_INVALID_DATA; |
1013 | 55 | goto fail; |
1014 | 55 | } |
1015 | | |
1016 | 1.27k | WLog_Print(rail->log, WLOG_DEBUG, "Received %s PDU, length:%" PRIu16 "", |
1017 | 1.27k | rail_get_order_type_string_full(orderType, buffer, sizeof(buffer)), orderLength); |
1018 | | |
1019 | 1.27k | switch (orderType) |
1020 | 1.27k | { |
1021 | 41 | case TS_RAIL_ORDER_HANDSHAKE: |
1022 | 41 | error = rail_recv_handshake_order(rail, s); |
1023 | 41 | break; |
1024 | | |
1025 | 1 | case TS_RAIL_ORDER_COMPARTMENTINFO: |
1026 | 1 | error = rail_recv_compartmentinfo_order(rail, s); |
1027 | 1 | break; |
1028 | | |
1029 | 1 | case TS_RAIL_ORDER_HANDSHAKE_EX: |
1030 | 1 | error = rail_recv_handshake_ex_order(rail, s); |
1031 | 1 | break; |
1032 | | |
1033 | 204 | case TS_RAIL_ORDER_EXEC_RESULT: |
1034 | 204 | error = rail_recv_exec_result_order(rail, s); |
1035 | 204 | break; |
1036 | | |
1037 | 329 | case TS_RAIL_ORDER_SYSPARAM: |
1038 | 329 | error = rail_recv_server_sysparam_order(rail, s); |
1039 | 329 | break; |
1040 | | |
1041 | 243 | case TS_RAIL_ORDER_MINMAXINFO: |
1042 | 243 | error = rail_recv_server_minmaxinfo_order(rail, s); |
1043 | 243 | break; |
1044 | | |
1045 | 181 | case TS_RAIL_ORDER_LOCALMOVESIZE: |
1046 | 181 | error = rail_recv_server_localmovesize_order(rail, s); |
1047 | 181 | break; |
1048 | | |
1049 | 48 | case TS_RAIL_ORDER_GET_APPID_RESP: |
1050 | 48 | error = rail_recv_server_get_appid_resp_order(rail, s); |
1051 | 48 | break; |
1052 | | |
1053 | 1 | case TS_RAIL_ORDER_LANGBARINFO: |
1054 | 1 | error = rail_recv_langbar_info_order(rail, s); |
1055 | 1 | break; |
1056 | | |
1057 | 1 | case TS_RAIL_ORDER_TASKBARINFO: |
1058 | 1 | error = rail_recv_taskbar_info_order(rail, s); |
1059 | 1 | break; |
1060 | | |
1061 | 1 | case TS_RAIL_ORDER_ZORDER_SYNC: |
1062 | 1 | error = rail_recv_zorder_sync_order(rail, s); |
1063 | 1 | break; |
1064 | | |
1065 | 1 | case TS_RAIL_ORDER_CLOAK: |
1066 | 1 | error = rail_recv_cloak_order(rail, s); |
1067 | 1 | break; |
1068 | | |
1069 | 1 | case TS_RAIL_ORDER_POWER_DISPLAY_REQUEST: |
1070 | 1 | error = rail_recv_power_display_request_order(rail, s); |
1071 | 1 | break; |
1072 | | |
1073 | 144 | case TS_RAIL_ORDER_GET_APPID_RESP_EX: |
1074 | 144 | error = rail_recv_get_application_id_extended_response_order(rail, s); |
1075 | 144 | break; |
1076 | | |
1077 | 16 | case TS_RAIL_ORDER_TEXTSCALEINFO: |
1078 | 16 | error = rail_recv_textscaleinfo_order(rail, s); |
1079 | 16 | break; |
1080 | | |
1081 | 43 | case TS_RAIL_ORDER_CARETBLINKINFO: |
1082 | 43 | error = rail_recv_caretblinkinfo_order(rail, s); |
1083 | 43 | break; |
1084 | | |
1085 | 16 | default: |
1086 | 16 | WLog_ERR(TAG, "Unknown RAIL PDU %s received.", |
1087 | 16 | rail_get_order_type_string_full(orderType, buffer, sizeof(buffer))); |
1088 | 16 | return ERROR_INVALID_DATA; |
1089 | 1.27k | } |
1090 | | |
1091 | 1.25k | if (error != CHANNEL_RC_OK) |
1092 | 251 | { |
1093 | 251 | char ebuffer[128] = WINPR_C_ARRAY_INIT; |
1094 | 251 | WLog_Print(rail->log, WLOG_ERROR, "Failed to process rail %s PDU, length:%" PRIu16 "", |
1095 | 251 | rail_get_order_type_string_full(orderType, ebuffer, sizeof(ebuffer)), |
1096 | 251 | orderLength); |
1097 | 251 | } |
1098 | | |
1099 | 1.31k | fail: |
1100 | 1.31k | Stream_Free(s, TRUE); |
1101 | 1.31k | return error; |
1102 | 1.25k | } |
1103 | | |
1104 | | /** |
1105 | | * Function description |
1106 | | * |
1107 | | * @return 0 on success, otherwise a Win32 error code |
1108 | | */ |
1109 | | UINT rail_send_handshake_order(railPlugin* rail, const RAIL_HANDSHAKE_ORDER* handshake) |
1110 | 0 | { |
1111 | 0 | if (!rail || !handshake) |
1112 | 0 | return ERROR_INVALID_PARAMETER; |
1113 | | |
1114 | 0 | wStream* s = rail_pdu_init(RAIL_HANDSHAKE_ORDER_LENGTH); |
1115 | |
|
1116 | 0 | if (!s) |
1117 | 0 | { |
1118 | 0 | WLog_ERR(TAG, "rail_pdu_init failed!"); |
1119 | 0 | return CHANNEL_RC_NO_MEMORY; |
1120 | 0 | } |
1121 | | |
1122 | 0 | rail_write_handshake_order(s, handshake); |
1123 | 0 | return rail_send_pdu(rail, s, TS_RAIL_ORDER_HANDSHAKE); |
1124 | 0 | } |
1125 | | |
1126 | | /** |
1127 | | * Function description |
1128 | | * |
1129 | | * @return 0 on success, otherwise a Win32 error code |
1130 | | */ |
1131 | | UINT rail_send_handshake_ex_order(railPlugin* rail, const RAIL_HANDSHAKE_EX_ORDER* handshakeEx) |
1132 | 0 | { |
1133 | 0 | if (!rail || !handshakeEx) |
1134 | 0 | return ERROR_INVALID_PARAMETER; |
1135 | | |
1136 | 0 | wStream* s = rail_pdu_init(RAIL_HANDSHAKE_EX_ORDER_LENGTH); |
1137 | |
|
1138 | 0 | if (!s) |
1139 | 0 | { |
1140 | 0 | WLog_ERR(TAG, "rail_pdu_init failed!"); |
1141 | 0 | return CHANNEL_RC_NO_MEMORY; |
1142 | 0 | } |
1143 | | |
1144 | 0 | rail_write_handshake_ex_order(s, handshakeEx); |
1145 | 0 | return rail_send_pdu(rail, s, TS_RAIL_ORDER_HANDSHAKE_EX); |
1146 | 0 | } |
1147 | | |
1148 | | /** |
1149 | | * Function description |
1150 | | * |
1151 | | * @return 0 on success, otherwise a Win32 error code |
1152 | | */ |
1153 | | UINT rail_send_client_status_order(railPlugin* rail, const RAIL_CLIENT_STATUS_ORDER* clientStatus) |
1154 | 0 | { |
1155 | 0 | wStream* s = nullptr; |
1156 | 0 | UINT error = 0; |
1157 | |
|
1158 | 0 | if (!rail || !clientStatus) |
1159 | 0 | return ERROR_INVALID_PARAMETER; |
1160 | | |
1161 | 0 | rail->clientStatus = *clientStatus; |
1162 | 0 | s = rail_pdu_init(RAIL_CLIENT_STATUS_ORDER_LENGTH); |
1163 | |
|
1164 | 0 | if (!s) |
1165 | 0 | { |
1166 | 0 | WLog_ERR(TAG, "rail_pdu_init failed!"); |
1167 | 0 | return CHANNEL_RC_NO_MEMORY; |
1168 | 0 | } |
1169 | | |
1170 | 0 | error = rail_write_client_status_order(s, clientStatus); |
1171 | |
|
1172 | 0 | if (ERROR_SUCCESS != error) |
1173 | 0 | { |
1174 | |
|
1175 | 0 | Stream_Free(s, TRUE); |
1176 | 0 | return error; |
1177 | 0 | } |
1178 | | |
1179 | 0 | return rail_send_pdu(rail, s, TS_RAIL_ORDER_CLIENTSTATUS); |
1180 | 0 | } |
1181 | | |
1182 | | /** |
1183 | | * Function description |
1184 | | * |
1185 | | * @return 0 on success, otherwise a Win32 error code |
1186 | | */ |
1187 | | UINT rail_send_client_exec_order(railPlugin* rail, UINT16 flags, |
1188 | | const RAIL_UNICODE_STRING* exeOrFile, |
1189 | | const RAIL_UNICODE_STRING* workingDir, |
1190 | | const RAIL_UNICODE_STRING* arguments) |
1191 | 0 | { |
1192 | 0 | wStream* s = nullptr; |
1193 | 0 | UINT error = 0; |
1194 | 0 | size_t length = 0; |
1195 | |
|
1196 | 0 | if (!rail || !exeOrFile || !workingDir || !arguments) |
1197 | 0 | return ERROR_INVALID_PARAMETER; |
1198 | | |
1199 | 0 | length = RAIL_EXEC_ORDER_LENGTH + exeOrFile->length + workingDir->length + arguments->length; |
1200 | 0 | s = rail_pdu_init(length); |
1201 | |
|
1202 | 0 | if (!s) |
1203 | 0 | { |
1204 | 0 | WLog_ERR(TAG, "rail_pdu_init failed!"); |
1205 | 0 | return CHANNEL_RC_NO_MEMORY; |
1206 | 0 | } |
1207 | | |
1208 | 0 | if ((error = rail_write_client_exec_order(s, flags, exeOrFile, workingDir, arguments))) |
1209 | 0 | { |
1210 | 0 | WLog_ERR(TAG, "rail_write_client_exec_order failed with error %" PRIu32 "!", error); |
1211 | 0 | goto out; |
1212 | 0 | } |
1213 | | |
1214 | 0 | return rail_send_pdu(rail, s, TS_RAIL_ORDER_EXEC); |
1215 | | |
1216 | 0 | out: |
1217 | 0 | Stream_Free(s, TRUE); |
1218 | 0 | return error; |
1219 | 0 | } |
1220 | | |
1221 | | /** |
1222 | | * Function description |
1223 | | * |
1224 | | * @return 0 on success, otherwise a Win32 error code |
1225 | | */ |
1226 | | UINT rail_send_client_activate_order(railPlugin* rail, const RAIL_ACTIVATE_ORDER* activate) |
1227 | 0 | { |
1228 | 0 | wStream* s = nullptr; |
1229 | 0 | UINT error = 0; |
1230 | |
|
1231 | 0 | if (!rail || !activate) |
1232 | 0 | return ERROR_INVALID_PARAMETER; |
1233 | | |
1234 | 0 | s = rail_pdu_init(RAIL_ACTIVATE_ORDER_LENGTH); |
1235 | |
|
1236 | 0 | if (!s) |
1237 | 0 | { |
1238 | 0 | WLog_ERR(TAG, "rail_pdu_init failed!"); |
1239 | 0 | return CHANNEL_RC_NO_MEMORY; |
1240 | 0 | } |
1241 | | |
1242 | 0 | error = rail_write_client_activate_order(s, activate); |
1243 | |
|
1244 | 0 | if (ERROR_SUCCESS != error) |
1245 | 0 | { |
1246 | |
|
1247 | 0 | Stream_Free(s, TRUE); |
1248 | 0 | return error; |
1249 | 0 | } |
1250 | | |
1251 | 0 | return rail_send_pdu(rail, s, TS_RAIL_ORDER_ACTIVATE); |
1252 | 0 | } |
1253 | | |
1254 | | /** |
1255 | | * Function description |
1256 | | * |
1257 | | * @return 0 on success, otherwise a Win32 error code |
1258 | | */ |
1259 | | UINT rail_send_client_sysmenu_order(railPlugin* rail, const RAIL_SYSMENU_ORDER* sysmenu) |
1260 | 0 | { |
1261 | 0 | wStream* s = nullptr; |
1262 | 0 | UINT error = 0; |
1263 | |
|
1264 | 0 | if (!rail || !sysmenu) |
1265 | 0 | return ERROR_INVALID_PARAMETER; |
1266 | | |
1267 | 0 | s = rail_pdu_init(RAIL_SYSMENU_ORDER_LENGTH); |
1268 | |
|
1269 | 0 | if (!s) |
1270 | 0 | { |
1271 | 0 | WLog_ERR(TAG, "rail_pdu_init failed!"); |
1272 | 0 | return CHANNEL_RC_NO_MEMORY; |
1273 | 0 | } |
1274 | | |
1275 | 0 | error = rail_write_client_sysmenu_order(s, sysmenu); |
1276 | |
|
1277 | 0 | if (ERROR_SUCCESS != error) |
1278 | 0 | { |
1279 | |
|
1280 | 0 | Stream_Free(s, TRUE); |
1281 | 0 | return error; |
1282 | 0 | } |
1283 | | |
1284 | 0 | return rail_send_pdu(rail, s, TS_RAIL_ORDER_SYSMENU); |
1285 | 0 | } |
1286 | | |
1287 | | /** |
1288 | | * Function description |
1289 | | * |
1290 | | * @return 0 on success, otherwise a Win32 error code |
1291 | | */ |
1292 | | UINT rail_send_client_syscommand_order(railPlugin* rail, const RAIL_SYSCOMMAND_ORDER* syscommand) |
1293 | 0 | { |
1294 | 0 | wStream* s = nullptr; |
1295 | 0 | UINT error = 0; |
1296 | |
|
1297 | 0 | if (!rail || !syscommand) |
1298 | 0 | return ERROR_INVALID_PARAMETER; |
1299 | | |
1300 | 0 | s = rail_pdu_init(RAIL_SYSCOMMAND_ORDER_LENGTH); |
1301 | |
|
1302 | 0 | if (!s) |
1303 | 0 | { |
1304 | 0 | WLog_ERR(TAG, "rail_pdu_init failed!"); |
1305 | 0 | return CHANNEL_RC_NO_MEMORY; |
1306 | 0 | } |
1307 | | |
1308 | 0 | error = rail_write_client_syscommand_order(s, syscommand); |
1309 | |
|
1310 | 0 | if (ERROR_SUCCESS != error) |
1311 | 0 | { |
1312 | |
|
1313 | 0 | Stream_Free(s, TRUE); |
1314 | 0 | return error; |
1315 | 0 | } |
1316 | | |
1317 | 0 | return rail_send_pdu(rail, s, TS_RAIL_ORDER_SYSCOMMAND); |
1318 | 0 | } |
1319 | | |
1320 | | /** |
1321 | | * Function description |
1322 | | * |
1323 | | * @return 0 on success, otherwise a Win32 error code |
1324 | | */ |
1325 | | UINT rail_send_client_notify_event_order(railPlugin* rail, |
1326 | | const RAIL_NOTIFY_EVENT_ORDER* notifyEvent) |
1327 | 0 | { |
1328 | 0 | wStream* s = nullptr; |
1329 | 0 | UINT error = 0; |
1330 | |
|
1331 | 0 | if (!rail || !notifyEvent) |
1332 | 0 | return ERROR_INVALID_PARAMETER; |
1333 | | |
1334 | 0 | s = rail_pdu_init(RAIL_NOTIFY_EVENT_ORDER_LENGTH); |
1335 | |
|
1336 | 0 | if (!s) |
1337 | 0 | { |
1338 | 0 | WLog_ERR(TAG, "rail_pdu_init failed!"); |
1339 | 0 | return CHANNEL_RC_NO_MEMORY; |
1340 | 0 | } |
1341 | | |
1342 | 0 | error = rail_write_client_notify_event_order(s, notifyEvent); |
1343 | |
|
1344 | 0 | if (ERROR_SUCCESS != error) |
1345 | 0 | { |
1346 | |
|
1347 | 0 | Stream_Free(s, TRUE); |
1348 | 0 | return error; |
1349 | 0 | } |
1350 | | |
1351 | 0 | return rail_send_pdu(rail, s, TS_RAIL_ORDER_NOTIFY_EVENT); |
1352 | 0 | } |
1353 | | |
1354 | | /** |
1355 | | * Function description |
1356 | | * |
1357 | | * @return 0 on success, otherwise a Win32 error code |
1358 | | */ |
1359 | | UINT rail_send_client_window_move_order(railPlugin* rail, const RAIL_WINDOW_MOVE_ORDER* windowMove) |
1360 | 0 | { |
1361 | 0 | wStream* s = nullptr; |
1362 | 0 | UINT error = 0; |
1363 | |
|
1364 | 0 | if (!rail || !windowMove) |
1365 | 0 | return ERROR_INVALID_PARAMETER; |
1366 | | |
1367 | 0 | s = rail_pdu_init(RAIL_WINDOW_MOVE_ORDER_LENGTH); |
1368 | |
|
1369 | 0 | if (!s) |
1370 | 0 | { |
1371 | 0 | WLog_ERR(TAG, "rail_pdu_init failed!"); |
1372 | 0 | return CHANNEL_RC_NO_MEMORY; |
1373 | 0 | } |
1374 | | |
1375 | 0 | error = rail_write_client_window_move_order(s, windowMove); |
1376 | |
|
1377 | 0 | if (ERROR_SUCCESS != error) |
1378 | 0 | { |
1379 | |
|
1380 | 0 | Stream_Free(s, TRUE); |
1381 | 0 | return error; |
1382 | 0 | } |
1383 | | |
1384 | 0 | return rail_send_pdu(rail, s, TS_RAIL_ORDER_WINDOWMOVE); |
1385 | 0 | } |
1386 | | |
1387 | | /** |
1388 | | * Function description |
1389 | | * |
1390 | | * @return 0 on success, otherwise a Win32 error code |
1391 | | */ |
1392 | | UINT rail_send_client_get_appid_req_order(railPlugin* rail, |
1393 | | const RAIL_GET_APPID_REQ_ORDER* getAppIdReq) |
1394 | 0 | { |
1395 | 0 | wStream* s = nullptr; |
1396 | 0 | UINT error = 0; |
1397 | |
|
1398 | 0 | if (!rail || !getAppIdReq) |
1399 | 0 | return ERROR_INVALID_PARAMETER; |
1400 | | |
1401 | 0 | s = rail_pdu_init(RAIL_GET_APPID_REQ_ORDER_LENGTH); |
1402 | |
|
1403 | 0 | if (!s) |
1404 | 0 | { |
1405 | 0 | WLog_ERR(TAG, "rail_pdu_init failed!"); |
1406 | 0 | return CHANNEL_RC_NO_MEMORY; |
1407 | 0 | } |
1408 | | |
1409 | 0 | error = rail_write_client_get_appid_req_order(s, getAppIdReq); |
1410 | |
|
1411 | 0 | if (ERROR_SUCCESS != error) |
1412 | 0 | { |
1413 | |
|
1414 | 0 | Stream_Free(s, TRUE); |
1415 | 0 | return error; |
1416 | 0 | } |
1417 | 0 | return rail_send_pdu(rail, s, TS_RAIL_ORDER_GET_APPID_REQ); |
1418 | 0 | } |
1419 | | |
1420 | | /** |
1421 | | * Function description |
1422 | | * |
1423 | | * @return 0 on success, otherwise a Win32 error code |
1424 | | */ |
1425 | | UINT rail_send_client_langbar_info_order(railPlugin* rail, |
1426 | | const RAIL_LANGBAR_INFO_ORDER* langBarInfo) |
1427 | 0 | { |
1428 | 0 | wStream* s = nullptr; |
1429 | 0 | UINT error = 0; |
1430 | |
|
1431 | 0 | if (!rail || !langBarInfo) |
1432 | 0 | return ERROR_INVALID_PARAMETER; |
1433 | | |
1434 | 0 | if (!rail_is_feature_supported(rail->rdpcontext, RAIL_LEVEL_DOCKED_LANGBAR_SUPPORTED)) |
1435 | 0 | return ERROR_BAD_CONFIGURATION; |
1436 | | |
1437 | 0 | s = rail_pdu_init(RAIL_LANGBAR_INFO_ORDER_LENGTH); |
1438 | |
|
1439 | 0 | if (!s) |
1440 | 0 | { |
1441 | 0 | WLog_ERR(TAG, "rail_pdu_init failed!"); |
1442 | 0 | return CHANNEL_RC_NO_MEMORY; |
1443 | 0 | } |
1444 | | |
1445 | 0 | error = rail_write_langbar_info_order(s, langBarInfo); |
1446 | |
|
1447 | 0 | if (ERROR_SUCCESS != error) |
1448 | 0 | { |
1449 | |
|
1450 | 0 | Stream_Free(s, TRUE); |
1451 | 0 | return error; |
1452 | 0 | } |
1453 | 0 | return rail_send_pdu(rail, s, TS_RAIL_ORDER_LANGBARINFO); |
1454 | 0 | } |
1455 | | |
1456 | | UINT rail_send_client_languageime_info_order(railPlugin* rail, |
1457 | | const RAIL_LANGUAGEIME_INFO_ORDER* langImeInfo) |
1458 | 0 | { |
1459 | 0 | wStream* s = nullptr; |
1460 | 0 | UINT error = 0; |
1461 | |
|
1462 | 0 | if (!rail || !langImeInfo) |
1463 | 0 | return ERROR_INVALID_PARAMETER; |
1464 | | |
1465 | 0 | if (!rail_is_feature_supported(rail->rdpcontext, RAIL_LEVEL_LANGUAGE_IME_SYNC_SUPPORTED)) |
1466 | 0 | return ERROR_BAD_CONFIGURATION; |
1467 | | |
1468 | 0 | s = rail_pdu_init(RAIL_LANGUAGEIME_INFO_ORDER_LENGTH); |
1469 | |
|
1470 | 0 | if (!s) |
1471 | 0 | { |
1472 | 0 | WLog_ERR(TAG, "rail_pdu_init failed!"); |
1473 | 0 | return CHANNEL_RC_NO_MEMORY; |
1474 | 0 | } |
1475 | | |
1476 | 0 | error = rail_write_languageime_info_order(s, langImeInfo); |
1477 | |
|
1478 | 0 | if (ERROR_SUCCESS != error) |
1479 | 0 | { |
1480 | |
|
1481 | 0 | Stream_Free(s, TRUE); |
1482 | 0 | return error; |
1483 | 0 | } |
1484 | 0 | return rail_send_pdu(rail, s, TS_RAIL_ORDER_LANGUAGEIMEINFO); |
1485 | 0 | } |
1486 | | |
1487 | | UINT rail_send_client_compartment_info_order(railPlugin* rail, |
1488 | | const RAIL_COMPARTMENT_INFO_ORDER* compartmentInfo) |
1489 | 0 | { |
1490 | 0 | wStream* s = nullptr; |
1491 | 0 | UINT error = 0; |
1492 | |
|
1493 | 0 | if (!rail || !compartmentInfo) |
1494 | 0 | return ERROR_INVALID_PARAMETER; |
1495 | | |
1496 | 0 | if (!rail_is_feature_supported(rail->rdpcontext, RAIL_LEVEL_LANGUAGE_IME_SYNC_SUPPORTED)) |
1497 | 0 | return ERROR_BAD_CONFIGURATION; |
1498 | | |
1499 | 0 | s = rail_pdu_init(RAIL_COMPARTMENT_INFO_ORDER_LENGTH); |
1500 | |
|
1501 | 0 | if (!s) |
1502 | 0 | { |
1503 | 0 | WLog_ERR(TAG, "rail_pdu_init failed!"); |
1504 | 0 | return CHANNEL_RC_NO_MEMORY; |
1505 | 0 | } |
1506 | | |
1507 | 0 | error = rail_write_compartment_info_order(s, compartmentInfo); |
1508 | |
|
1509 | 0 | if (ERROR_SUCCESS != error) |
1510 | 0 | { |
1511 | 0 | Stream_Free(s, TRUE); |
1512 | 0 | return error; |
1513 | 0 | } |
1514 | 0 | return rail_send_pdu(rail, s, TS_RAIL_ORDER_COMPARTMENTINFO); |
1515 | 0 | } |
1516 | | |
1517 | | UINT rail_send_client_cloak_order(railPlugin* rail, const RAIL_CLOAK* cloak) |
1518 | 0 | { |
1519 | 0 | if (!rail || !cloak) |
1520 | 0 | return ERROR_INVALID_PARAMETER; |
1521 | | |
1522 | 0 | wStream* s = rail_pdu_init(5); |
1523 | |
|
1524 | 0 | if (!s) |
1525 | 0 | { |
1526 | 0 | WLog_ERR(TAG, "rail_pdu_init failed!"); |
1527 | 0 | return CHANNEL_RC_NO_MEMORY; |
1528 | 0 | } |
1529 | | |
1530 | 0 | Stream_Write_UINT32(s, cloak->windowId); |
1531 | 0 | Stream_Write_UINT8(s, cloak->cloak ? 1 : 0); |
1532 | 0 | return rail_send_pdu(rail, s, TS_RAIL_ORDER_CLOAK); |
1533 | 0 | } |
1534 | | |
1535 | | UINT rail_send_client_snap_arrange_order(railPlugin* rail, const RAIL_SNAP_ARRANGE* snap) |
1536 | 0 | { |
1537 | 0 | if (!rail) |
1538 | 0 | return ERROR_INVALID_PARAMETER; |
1539 | | |
1540 | | /* 2.2.2.7.5 Client Window Snap PDU (TS_RAIL_ORDER_SNAP_ARRANGE) */ |
1541 | 0 | if ((rail->channelFlags & TS_RAIL_ORDER_HANDSHAKE_EX_FLAGS_SNAP_ARRANGE_SUPPORTED) == 0) |
1542 | 0 | { |
1543 | 0 | RAIL_WINDOW_MOVE_ORDER move = WINPR_C_ARRAY_INIT; |
1544 | 0 | move.top = snap->top; |
1545 | 0 | move.left = snap->left; |
1546 | 0 | move.right = snap->right; |
1547 | 0 | move.bottom = snap->bottom; |
1548 | 0 | move.windowId = snap->windowId; |
1549 | 0 | return rail_send_client_window_move_order(rail, &move); |
1550 | 0 | } |
1551 | | |
1552 | 0 | wStream* s = rail_pdu_init(12); |
1553 | |
|
1554 | 0 | if (!s) |
1555 | 0 | { |
1556 | 0 | WLog_ERR(TAG, "rail_pdu_init failed!"); |
1557 | 0 | return CHANNEL_RC_NO_MEMORY; |
1558 | 0 | } |
1559 | | |
1560 | 0 | Stream_Write_UINT32(s, snap->windowId); |
1561 | 0 | Stream_Write_INT16(s, snap->left); |
1562 | 0 | Stream_Write_INT16(s, snap->top); |
1563 | 0 | Stream_Write_INT16(s, snap->right); |
1564 | 0 | Stream_Write_INT16(s, snap->bottom); |
1565 | 0 | return rail_send_pdu(rail, s, TS_RAIL_ORDER_SNAP_ARRANGE); |
1566 | 0 | } |
1567 | | |
1568 | | UINT rail_send_client_text_scale_order(railPlugin* rail, UINT32 textScale) |
1569 | 0 | { |
1570 | 0 | if (!rail) |
1571 | 0 | return ERROR_INVALID_PARAMETER; |
1572 | | |
1573 | 0 | wStream* s = rail_pdu_init(4); |
1574 | |
|
1575 | 0 | if (!s) |
1576 | 0 | { |
1577 | 0 | WLog_ERR(TAG, "rail_pdu_init failed!"); |
1578 | 0 | return CHANNEL_RC_NO_MEMORY; |
1579 | 0 | } |
1580 | | |
1581 | 0 | Stream_Write_UINT32(s, textScale); |
1582 | 0 | return rail_send_pdu(rail, s, TS_RAIL_ORDER_TEXTSCALEINFO); |
1583 | 0 | } |
1584 | | |
1585 | | UINT rail_send_client_caret_blink_rate_order(railPlugin* rail, UINT32 rate) |
1586 | 0 | { |
1587 | 0 | if (!rail) |
1588 | 0 | return ERROR_INVALID_PARAMETER; |
1589 | | |
1590 | 0 | wStream* s = rail_pdu_init(4); |
1591 | |
|
1592 | 0 | if (!s) |
1593 | 0 | { |
1594 | 0 | WLog_ERR(TAG, "rail_pdu_init failed!"); |
1595 | 0 | return CHANNEL_RC_NO_MEMORY; |
1596 | 0 | } |
1597 | | |
1598 | 0 | Stream_Write_UINT32(s, rate); |
1599 | 0 | return rail_send_pdu(rail, s, TS_RAIL_ORDER_CARETBLINKINFO); |
1600 | 0 | } |