jmuehlner commented on a change in pull request #243: GUACAMOLE-249: Migrate to FreeRDP 2.x URL: https://github.com/apache/guacamole-server/pull/243#discussion_r364073127
########## File path: src/protocols/rdp/channels/rail.c ########## @@ -0,0 +1,197 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "channels/rail.h" +#include "plugins/channels.h" +#include "rdp.h" +#include "settings.h" + +#include <freerdp/client/rail.h> +#include <freerdp/event.h> +#include <freerdp/freerdp.h> +#include <freerdp/rail.h> +#include <guacamole/client.h> +#include <winpr/wtypes.h> +#include <winpr/wtsapi.h> + +#include <stddef.h> +#include <string.h> + +/** + * Completes initialization of the RemoteApp session, sending client system + * parameters and executing the desired RemoteApp command using the Client + * System Parameters Update PDU and Client Execute PDU respectively. These PDUs + * MUST be sent for the desired RemoteApp to run, and MUST NOT be sent until + * after a Handshake or HandshakeEx PDU has been received. See: + * + * https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdperp/60344497-883f-4711-8b9a-828d1c580195 (System Parameters Update PDU) + * https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdperp/98a6e3c3-c2a9-42cc-ad91-0d9a6c211138 (Client Execute PDU) + * + * @param rail + * The RailClientContext structure used by FreeRDP to handle the RAIL + * channel for the current RDP session. + * + * @return + * CHANNEL_RC_OK (zero) if the PDUs were sent successfully, an error code + * (non-zero) otherwise. + */ +static UINT guac_rdp_rail_complete_handshake(RailClientContext* rail) { + + guac_client* client = (guac_client*) rail->custom; + guac_rdp_client* rdp_client = (guac_rdp_client*) client->data; + + RAIL_SYSPARAM_ORDER sysparam = { + .workArea = { + .left = 0, + .top = 0, + .right = rdp_client->settings->width, + .bottom = rdp_client->settings->height + }, + .dragFullWindows = FALSE + }; + + /* Send client system parameters */ + UINT status = rail->ClientSystemParam(rail, &sysparam); + if (status != CHANNEL_RC_OK) + return status; + + RAIL_EXEC_ORDER exec = { + .RemoteApplicationProgram = rdp_client->settings->remote_app, + .RemoteApplicationWorkingDir = rdp_client->settings->remote_app_dir, + .RemoteApplicationArguments = rdp_client->settings->remote_app_args, + }; + + /* Execute desired RemoteApp command */ + return rail->ClientExecute(rail, &exec); + +} + +/** + * Callback which is invoked when a Handshake PDU is received from the RDP + * server. No communication for RemoteApp may occur until the Handshake PDU + * (or, alternatively, the HandshakeEx PDU) is received. See: + * + * https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdperp/cec4eb83-b304-43c9-8378-b5b8f5e7082a + * + * @param rail + * The RailClientContext structure used by FreeRDP to handle the RAIL + * channel for the current RDP session. + * + * @param handshake Review comment: This isn't used for anything? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
