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