From e775a2a46fb3d04226db29e6c067b98397ba928b Mon Sep 17 00:00:00 2001 From: David Fort Date: Thu, 19 Jan 2017 17:57:44 +0100 Subject: [PATCH 1/2] Treat the result of the Capabilities callback The result was ignored. Plus return the correct value in case of licence error (-1 instead of FALSE). --- libfreerdp/core/peer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libfreerdp/core/peer.c b/libfreerdp/core/peer.c index 0063ddc84..8737eba55 100644 --- a/libfreerdp/core/peer.c +++ b/libfreerdp/core/peer.c @@ -575,7 +575,7 @@ static int peer_recv_callback(rdpTransport* transport, wStream* s, void* extra) { WLog_ERR(TAG, "peer_recv_callback: CONNECTION_STATE_LICENSING - license_send_valid_client_error_packet() fail"); - return FALSE; + return -1; } rdp_server_transition_to_state(rdp, CONNECTION_STATE_CAPABILITIES_EXCHANGE); @@ -585,7 +585,9 @@ static int peer_recv_callback(rdpTransport* transport, wStream* s, void* extra) case CONNECTION_STATE_CAPABILITIES_EXCHANGE: if (!rdp->AwaitCapabilities) { - IFCALL(client->Capabilities, client); + + if (client->Capabilities && !client->Capabilities(client)) + return -1; if (!rdp_send_demand_active(rdp)) { From f68888a9789888b92524d02cabe0505cc2307995 Mon Sep 17 00:00:00 2001 From: David Fort Date: Thu, 19 Jan 2017 17:59:54 +0100 Subject: [PATCH 2/2] Add a callback that allows to adjust monitors layout This callback is useful in server mode when you want to adjust the monitor layout just before the server monitor layout PDU is built and sent. --- include/freerdp/peer.h | 3 +++ libfreerdp/core/activation.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/freerdp/peer.h b/include/freerdp/peer.h index fff7b8ef3..4b2afe0de 100644 --- a/include/freerdp/peer.h +++ b/include/freerdp/peer.h @@ -47,6 +47,7 @@ typedef BOOL (*psPeerCapabilities)(freerdp_peer* peer); typedef BOOL (*psPeerPostConnect)(freerdp_peer* peer); typedef BOOL (*psPeerActivate)(freerdp_peer* peer); typedef BOOL (*psPeerLogon)(freerdp_peer* peer, SEC_WINNT_AUTH_IDENTITY* identity, BOOL automatic); +typedef BOOL (*psPeerAdjustMonitorsLayout)(freerdp_peer* peer); typedef int (*psPeerSendChannelData)(freerdp_peer* peer, UINT16 channelId, BYTE* data, int size); typedef int (*psPeerReceiveChannelData)(freerdp_peer* peer, UINT16 channelId, BYTE* data, int size, @@ -61,6 +62,7 @@ typedef int (*psPeerVirtualChannelWrite)(freerdp_peer* peer, HANDLE hChannel, BY typedef void* (*psPeerVirtualChannelGetData)(freerdp_peer* peer, HANDLE hChannel); typedef int (*psPeerVirtualChannelSetData)(freerdp_peer* peer, HANDLE hChannel, void* data); + struct rdp_freerdp_peer { rdpContext* context; @@ -113,6 +115,7 @@ struct rdp_freerdp_peer psPeerDrainOutputBuffer DrainOutputBuffer; psPeerHasMoreToRead HasMoreToRead; psPeerGetEventHandles GetEventHandles; + psPeerAdjustMonitorsLayout AdjustMonitorsLayout; }; #ifdef __cplusplus diff --git a/libfreerdp/core/activation.c b/libfreerdp/core/activation.c index 2db0566a0..0f4a90a85 100644 --- a/libfreerdp/core/activation.c +++ b/libfreerdp/core/activation.c @@ -365,11 +365,13 @@ BOOL rdp_server_accept_client_control_pdu(rdpRdp* rdp, wStream* s) BOOL rdp_server_accept_client_font_list_pdu(rdpRdp* rdp, wStream* s) { rdpSettings *settings = rdp->settings; + freerdp_peer *peer = rdp->context->peer; if (!rdp_recv_client_font_list_pdu(s)) return FALSE; - if (settings->SupportMonitorLayoutPdu && settings->MonitorCount) + if (settings->SupportMonitorLayoutPdu && settings->MonitorCount && peer->AdjustMonitorsLayout && + peer->AdjustMonitorsLayout(peer)) { /* client supports the monitorLayout PDU, let's send him the monitors if any */ wStream *st; @@ -386,8 +388,6 @@ BOOL rdp_server_accept_client_font_list_pdu(rdpRdp* rdp, wStream* s) } r = rdp_send_data_pdu(rdp, st, DATA_PDU_TYPE_MONITOR_LAYOUT, 0); - Stream_Free(st, TRUE); - if (!r) return FALSE; }