2012-10-14 11:43:10 +04:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
|
|
* FreeRDP Client Common
|
|
|
|
*
|
|
|
|
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
|
|
|
*
|
|
|
|
* Licensed 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.
|
|
|
|
*/
|
|
|
|
|
2022-02-16 13:20:38 +03:00
|
|
|
#include <freerdp/config.h>
|
2012-10-14 11:43:10 +04:00
|
|
|
|
2015-12-17 18:43:55 +03:00
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
2022-12-30 21:07:46 +03:00
|
|
|
#include <limits.h>
|
|
|
|
#include <float.h>
|
2015-12-17 18:43:55 +03:00
|
|
|
|
2013-06-14 01:52:24 +04:00
|
|
|
#include <freerdp/client.h>
|
2013-06-14 00:18:19 +04:00
|
|
|
|
2023-03-14 12:39:18 +03:00
|
|
|
#include <freerdp/freerdp.h>
|
2013-09-20 00:25:10 +04:00
|
|
|
#include <freerdp/addin.h>
|
2014-06-30 17:40:24 +04:00
|
|
|
#include <freerdp/assistance.h>
|
2013-06-14 05:34:46 +04:00
|
|
|
#include <freerdp/client/file.h>
|
2015-12-17 18:43:55 +03:00
|
|
|
#include <freerdp/utils/passphrase.h>
|
2013-06-14 05:34:46 +04:00
|
|
|
#include <freerdp/client/cmdline.h>
|
2013-09-20 00:25:10 +04:00
|
|
|
#include <freerdp/client/channels.h>
|
2022-10-14 19:58:30 +03:00
|
|
|
#include <freerdp/utils/smartcardlogon.h>
|
2013-06-14 05:34:46 +04:00
|
|
|
|
2022-01-19 13:05:41 +03:00
|
|
|
#if defined(CHANNEL_AINPUT_CLIENT)
|
|
|
|
#include <freerdp/client/ainput.h>
|
|
|
|
#include <freerdp/channels/ainput.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CHANNEL_VIDEO_CLIENT)
|
|
|
|
#include <freerdp/client/video.h>
|
|
|
|
#include <freerdp/channels/video.h>
|
|
|
|
#include <freerdp/gdi/video.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CHANNEL_RDPGFX_CLIENT)
|
|
|
|
#include <freerdp/client/rdpgfx.h>
|
|
|
|
#include <freerdp/channels/rdpgfx.h>
|
|
|
|
#include <freerdp/gdi/gfx.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CHANNEL_GEOMETRY_CLIENT)
|
|
|
|
#include <freerdp/client/geometry.h>
|
|
|
|
#include <freerdp/channels/geometry.h>
|
|
|
|
#include <freerdp/gdi/video.h>
|
|
|
|
#endif
|
|
|
|
|
2015-12-17 18:43:55 +03:00
|
|
|
#include <freerdp/log.h>
|
|
|
|
#define TAG CLIENT_TAG("common")
|
|
|
|
|
2023-03-08 04:06:47 +03:00
|
|
|
#define OAUTH2_CLIENT_ID "5177bc73-fd99-4c77-a90c-76844c9b6999"
|
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
static BOOL freerdp_client_common_new(freerdp* instance, rdpContext* context)
|
2013-06-16 01:01:10 +04:00
|
|
|
{
|
2021-09-21 10:56:56 +03:00
|
|
|
RDP_CLIENT_ENTRY_POINTS* pEntryPoints;
|
|
|
|
|
|
|
|
WINPR_ASSERT(instance);
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
|
2022-06-28 18:01:45 +03:00
|
|
|
instance->LoadChannels = freerdp_client_load_channels;
|
2023-02-15 18:39:42 +03:00
|
|
|
instance->AuthenticateEx = client_cli_authenticate_ex;
|
|
|
|
instance->ChooseSmartcard = client_cli_choose_smartcard;
|
|
|
|
instance->VerifyCertificateEx = client_cli_verify_certificate_ex;
|
|
|
|
instance->VerifyChangedCertificateEx = client_cli_verify_changed_certificate_ex;
|
|
|
|
instance->PresentGatewayMessage = client_cli_present_gateway_message;
|
|
|
|
instance->LogonErrorInfo = client_cli_logon_error_info;
|
2023-03-08 04:06:47 +03:00
|
|
|
instance->GetAadAuthCode = client_cli_get_aad_auth_code;
|
2022-06-28 18:01:45 +03:00
|
|
|
|
2021-09-21 10:56:56 +03:00
|
|
|
pEntryPoints = instance->pClientEntryPoints;
|
|
|
|
WINPR_ASSERT(pEntryPoints);
|
2023-02-15 18:39:42 +03:00
|
|
|
return IFCALLRESULT(TRUE, pEntryPoints->ClientNew, instance, context);
|
2013-06-16 01:01:10 +04:00
|
|
|
}
|
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
static void freerdp_client_common_free(freerdp* instance, rdpContext* context)
|
2013-06-16 01:01:10 +04:00
|
|
|
{
|
2021-09-21 10:56:56 +03:00
|
|
|
RDP_CLIENT_ENTRY_POINTS* pEntryPoints;
|
|
|
|
|
|
|
|
WINPR_ASSERT(instance);
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
|
|
|
|
pEntryPoints = instance->pClientEntryPoints;
|
|
|
|
WINPR_ASSERT(pEntryPoints);
|
2017-09-25 14:29:23 +03:00
|
|
|
IFCALL(pEntryPoints->ClientFree, instance, context);
|
2013-06-16 01:01:10 +04:00
|
|
|
}
|
|
|
|
|
2013-06-14 05:34:46 +04:00
|
|
|
/* Common API */
|
|
|
|
|
2022-03-23 15:18:35 +03:00
|
|
|
rdpContext* freerdp_client_context_new(const RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
|
2013-06-14 06:11:23 +04:00
|
|
|
{
|
|
|
|
freerdp* instance;
|
|
|
|
rdpContext* context;
|
|
|
|
|
2016-08-03 19:44:15 +03:00
|
|
|
if (!pEntryPoints)
|
|
|
|
return NULL;
|
2013-06-14 06:11:23 +04:00
|
|
|
|
2016-08-03 19:44:15 +03:00
|
|
|
IFCALL(pEntryPoints->GlobalInit);
|
2013-06-14 06:11:23 +04:00
|
|
|
instance = freerdp_new();
|
2015-05-06 23:32:45 +03:00
|
|
|
|
2015-03-23 19:25:23 +03:00
|
|
|
if (!instance)
|
|
|
|
return NULL;
|
|
|
|
|
2013-06-14 06:11:23 +04:00
|
|
|
instance->ContextSize = pEntryPoints->ContextSize;
|
2013-06-16 01:01:10 +04:00
|
|
|
instance->ContextNew = freerdp_client_common_new;
|
|
|
|
instance->ContextFree = freerdp_client_common_free;
|
2019-11-06 17:24:51 +03:00
|
|
|
instance->pClientEntryPoints = (RDP_CLIENT_ENTRY_POINTS*)malloc(pEntryPoints->Size);
|
2015-05-06 23:32:45 +03:00
|
|
|
|
2015-03-23 19:25:23 +03:00
|
|
|
if (!instance->pClientEntryPoints)
|
|
|
|
goto out_fail;
|
|
|
|
|
2013-06-16 01:01:10 +04:00
|
|
|
CopyMemory(instance->pClientEntryPoints, pEntryPoints, pEntryPoints->Size);
|
2015-05-06 23:32:45 +03:00
|
|
|
|
2022-03-23 15:18:35 +03:00
|
|
|
if (!freerdp_context_new_ex(instance, pEntryPoints->settings))
|
2015-03-23 19:25:23 +03:00
|
|
|
goto out_fail2;
|
2013-06-14 06:11:23 +04:00
|
|
|
|
|
|
|
context = instance->context;
|
2013-07-11 19:53:15 +04:00
|
|
|
context->instance = instance;
|
2016-08-04 14:25:12 +03:00
|
|
|
|
2022-10-13 14:32:21 +03:00
|
|
|
#if defined(WITH_CHANNELS)
|
2019-11-06 17:24:51 +03:00
|
|
|
if (freerdp_register_addin_provider(freerdp_channels_load_static_addin_entry, 0) !=
|
|
|
|
CHANNEL_RC_OK)
|
2016-08-04 14:25:12 +03:00
|
|
|
goto out_fail2;
|
2022-10-13 14:32:21 +03:00
|
|
|
#endif
|
2016-08-04 14:25:12 +03:00
|
|
|
|
2013-06-14 06:11:23 +04:00
|
|
|
return context;
|
2015-03-23 19:25:23 +03:00
|
|
|
out_fail2:
|
|
|
|
free(instance->pClientEntryPoints);
|
|
|
|
out_fail:
|
|
|
|
freerdp_free(instance);
|
|
|
|
return NULL;
|
2013-06-14 06:11:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void freerdp_client_context_free(rdpContext* context)
|
|
|
|
{
|
2016-08-03 19:44:15 +03:00
|
|
|
freerdp* instance;
|
|
|
|
|
|
|
|
if (!context)
|
|
|
|
return;
|
|
|
|
|
|
|
|
instance = context->instance;
|
2013-11-01 05:12:06 +04:00
|
|
|
|
2013-10-23 01:05:41 +04:00
|
|
|
if (instance)
|
|
|
|
{
|
2016-08-04 14:25:12 +03:00
|
|
|
RDP_CLIENT_ENTRY_POINTS* pEntryPoints = instance->pClientEntryPoints;
|
2013-10-23 01:05:41 +04:00
|
|
|
freerdp_context_free(instance);
|
2016-08-04 14:25:12 +03:00
|
|
|
|
|
|
|
if (pEntryPoints)
|
|
|
|
IFCALL(pEntryPoints->GlobalUninit);
|
|
|
|
|
2013-10-23 01:05:41 +04:00
|
|
|
free(instance->pClientEntryPoints);
|
|
|
|
freerdp_free(instance);
|
|
|
|
}
|
2013-06-14 06:11:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int freerdp_client_start(rdpContext* context)
|
|
|
|
{
|
2016-08-03 19:44:15 +03:00
|
|
|
RDP_CLIENT_ENTRY_POINTS* pEntryPoints;
|
|
|
|
|
|
|
|
if (!context || !context->instance || !context->instance->pClientEntryPoints)
|
|
|
|
return ERROR_BAD_ARGUMENTS;
|
|
|
|
|
|
|
|
pEntryPoints = context->instance->pClientEntryPoints;
|
2016-08-04 14:25:12 +03:00
|
|
|
return IFCALLRESULT(CHANNEL_RC_OK, pEntryPoints->ClientStart, context);
|
2013-06-14 06:11:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int freerdp_client_stop(rdpContext* context)
|
|
|
|
{
|
2016-08-03 19:44:15 +03:00
|
|
|
RDP_CLIENT_ENTRY_POINTS* pEntryPoints;
|
|
|
|
|
|
|
|
if (!context || !context->instance || !context->instance->pClientEntryPoints)
|
|
|
|
return ERROR_BAD_ARGUMENTS;
|
|
|
|
|
|
|
|
pEntryPoints = context->instance->pClientEntryPoints;
|
2016-08-04 14:25:12 +03:00
|
|
|
return IFCALLRESULT(CHANNEL_RC_OK, pEntryPoints->ClientStop, context);
|
2013-06-14 06:11:23 +04:00
|
|
|
}
|
|
|
|
|
2013-06-14 23:07:17 +04:00
|
|
|
freerdp* freerdp_client_get_instance(rdpContext* context)
|
|
|
|
{
|
2016-08-03 19:44:15 +03:00
|
|
|
if (!context || !context->instance)
|
|
|
|
return NULL;
|
|
|
|
|
2013-06-14 23:07:17 +04:00
|
|
|
return context->instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
HANDLE freerdp_client_get_thread(rdpContext* context)
|
|
|
|
{
|
2016-08-03 19:44:15 +03:00
|
|
|
if (!context)
|
|
|
|
return NULL;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
return ((rdpClientContext*)context)->thread;
|
2013-06-14 23:07:17 +04:00
|
|
|
}
|
|
|
|
|
2014-07-28 19:52:40 +04:00
|
|
|
static BOOL freerdp_client_settings_post_process(rdpSettings* settings)
|
2014-07-26 23:23:39 +04:00
|
|
|
{
|
2014-07-28 19:52:40 +04:00
|
|
|
/* Moved GatewayUseSameCredentials logic outside of cmdline.c, so
|
2014-07-26 23:23:39 +04:00
|
|
|
* that the rdp file also triggers this functionality */
|
|
|
|
if (settings->GatewayEnabled)
|
|
|
|
{
|
|
|
|
if (settings->GatewayUseSameCredentials)
|
|
|
|
{
|
|
|
|
if (settings->Username)
|
2014-07-28 19:52:40 +04:00
|
|
|
{
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_GatewayUsername,
|
|
|
|
settings->Username))
|
2014-07-28 19:57:51 +04:00
|
|
|
goto out_error;
|
2014-07-28 19:52:40 +04:00
|
|
|
}
|
2016-08-03 19:44:15 +03:00
|
|
|
|
2014-07-26 23:23:39 +04:00
|
|
|
if (settings->Domain)
|
2014-07-28 19:52:40 +04:00
|
|
|
{
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_GatewayDomain, settings->Domain))
|
2014-07-28 19:57:51 +04:00
|
|
|
goto out_error;
|
2014-07-28 19:52:40 +04:00
|
|
|
}
|
2016-08-03 19:44:15 +03:00
|
|
|
|
2022-03-24 13:07:11 +03:00
|
|
|
if (freerdp_settings_get_string(settings, FreeRDP_Password))
|
2014-07-28 19:52:40 +04:00
|
|
|
{
|
2022-03-24 13:07:11 +03:00
|
|
|
if (!freerdp_settings_set_string(
|
|
|
|
settings, FreeRDP_GatewayPassword,
|
|
|
|
freerdp_settings_get_string(settings, FreeRDP_Password)))
|
2014-07-28 19:57:51 +04:00
|
|
|
goto out_error;
|
2014-07-28 19:52:40 +04:00
|
|
|
}
|
2014-07-26 23:23:39 +04:00
|
|
|
}
|
|
|
|
}
|
2016-02-01 17:09:51 +03:00
|
|
|
|
2014-07-28 23:24:48 +04:00
|
|
|
/* Moved logic for Multimon and Span monitors to force fullscreen, so
|
|
|
|
* that the rdp file also triggers this functionality */
|
|
|
|
if (settings->SpanMonitors)
|
|
|
|
{
|
|
|
|
settings->UseMultimon = TRUE;
|
|
|
|
settings->Fullscreen = TRUE;
|
|
|
|
}
|
|
|
|
else if (settings->UseMultimon)
|
|
|
|
{
|
|
|
|
settings->Fullscreen = TRUE;
|
|
|
|
}
|
2016-02-01 17:09:51 +03:00
|
|
|
|
2022-01-23 19:28:49 +03:00
|
|
|
/* deal with the smartcard / smartcard logon stuff */
|
|
|
|
if (settings->SmartcardLogon)
|
|
|
|
{
|
|
|
|
settings->TlsSecurity = TRUE;
|
|
|
|
settings->RedirectSmartCards = TRUE;
|
|
|
|
settings->DeviceRedirection = TRUE;
|
|
|
|
freerdp_settings_set_bool(settings, FreeRDP_PasswordIsSmartcardPin, TRUE);
|
|
|
|
}
|
|
|
|
|
2014-07-28 19:52:40 +04:00
|
|
|
return TRUE;
|
2014-07-28 19:57:51 +04:00
|
|
|
out_error:
|
|
|
|
free(settings->GatewayUsername);
|
|
|
|
free(settings->GatewayDomain);
|
|
|
|
free(settings->GatewayPassword);
|
|
|
|
return FALSE;
|
2014-07-26 23:23:39 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
int freerdp_client_settings_parse_command_line(rdpSettings* settings, int argc, char** argv,
|
|
|
|
BOOL allowUnknown)
|
2013-06-14 05:34:46 +04:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
|
2013-10-13 05:07:12 +04:00
|
|
|
if (argc < 1)
|
2013-06-14 05:34:46 +04:00
|
|
|
return 0;
|
|
|
|
|
2013-10-13 05:07:12 +04:00
|
|
|
if (!argv)
|
2013-06-14 05:34:46 +04:00
|
|
|
return -1;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
status =
|
|
|
|
freerdp_client_settings_parse_command_line_arguments(settings, argc, argv, allowUnknown);
|
2013-06-14 05:34:46 +04:00
|
|
|
|
2014-07-28 19:52:40 +04:00
|
|
|
if (status < 0)
|
|
|
|
return status;
|
|
|
|
|
2014-07-25 00:07:14 +04:00
|
|
|
/* This function will call logic that is applicable to the settings
|
|
|
|
* from command line parsing AND the rdp file parsing */
|
2015-05-06 23:32:45 +03:00
|
|
|
if (!freerdp_client_settings_post_process(settings))
|
2014-07-28 20:49:18 +04:00
|
|
|
status = -1;
|
2014-06-29 02:33:46 +04:00
|
|
|
|
2021-04-22 13:55:41 +03:00
|
|
|
WLog_DBG(TAG, "This is %s %s", freerdp_get_version_string(), freerdp_get_build_config());
|
2013-06-14 05:34:46 +04:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
int freerdp_client_settings_parse_connection_file(rdpSettings* settings, const char* filename)
|
2013-06-14 05:34:46 +04:00
|
|
|
{
|
|
|
|
rdpFile* file;
|
2015-06-17 23:08:02 +03:00
|
|
|
int ret = -1;
|
2013-06-14 05:34:46 +04:00
|
|
|
file = freerdp_client_rdp_file_new();
|
2016-08-03 19:44:15 +03:00
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
if (!file)
|
|
|
|
return -1;
|
2016-08-03 19:44:15 +03:00
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
if (!freerdp_client_parse_rdp_file(file, filename))
|
|
|
|
goto out;
|
2016-08-03 19:44:15 +03:00
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
if (!freerdp_client_populate_settings_from_rdp_file(file, settings))
|
|
|
|
goto out;
|
2013-06-14 05:34:46 +04:00
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
ret = 0;
|
|
|
|
out:
|
|
|
|
freerdp_client_rdp_file_free(file);
|
|
|
|
return ret;
|
2013-06-14 05:34:46 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
int freerdp_client_settings_parse_connection_file_buffer(rdpSettings* settings, const BYTE* buffer,
|
|
|
|
size_t size)
|
2013-06-14 05:34:46 +04:00
|
|
|
{
|
|
|
|
rdpFile* file;
|
2013-09-18 01:03:35 +04:00
|
|
|
int status = -1;
|
2013-06-14 05:34:46 +04:00
|
|
|
file = freerdp_client_rdp_file_new();
|
2016-08-03 19:44:15 +03:00
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
if (!file)
|
|
|
|
return -1;
|
2013-09-18 01:03:35 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (freerdp_client_parse_rdp_file_buffer(file, buffer, size) &&
|
|
|
|
freerdp_client_populate_settings_from_rdp_file(file, settings))
|
2013-09-18 01:03:35 +04:00
|
|
|
{
|
|
|
|
status = 0;
|
|
|
|
}
|
2013-07-06 07:20:56 +04:00
|
|
|
|
2013-06-14 05:34:46 +04:00
|
|
|
freerdp_client_rdp_file_free(file);
|
2013-09-18 01:03:35 +04:00
|
|
|
return status;
|
2013-07-06 07:20:56 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
int freerdp_client_settings_write_connection_file(const rdpSettings* settings, const char* filename,
|
|
|
|
BOOL unicode)
|
2013-07-06 07:20:56 +04:00
|
|
|
{
|
2013-09-18 01:03:35 +04:00
|
|
|
rdpFile* file;
|
2015-06-17 23:08:02 +03:00
|
|
|
int ret = -1;
|
2013-09-18 01:03:35 +04:00
|
|
|
file = freerdp_client_rdp_file_new();
|
2016-08-03 19:44:15 +03:00
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
if (!file)
|
|
|
|
return -1;
|
2013-07-06 07:20:56 +04:00
|
|
|
|
2013-12-05 03:25:55 +04:00
|
|
|
if (!freerdp_client_populate_rdp_file_from_settings(file, settings))
|
2015-06-17 23:08:02 +03:00
|
|
|
goto out;
|
2013-12-05 03:25:55 +04:00
|
|
|
|
|
|
|
if (!freerdp_client_write_rdp_file(file, filename, unicode))
|
2015-06-17 23:08:02 +03:00
|
|
|
goto out;
|
2013-12-05 03:25:55 +04:00
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
ret = 0;
|
|
|
|
out:
|
2013-09-18 01:03:35 +04:00
|
|
|
freerdp_client_rdp_file_free(file);
|
2015-06-17 23:08:02 +03:00
|
|
|
return ret;
|
2013-06-14 05:34:46 +04:00
|
|
|
}
|
2014-06-29 02:33:46 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
int freerdp_client_settings_parse_assistance_file(rdpSettings* settings, int argc, char* argv[])
|
2014-06-29 02:33:46 +04:00
|
|
|
{
|
2018-11-08 11:27:57 +03:00
|
|
|
int status, x;
|
2018-08-17 15:40:12 +03:00
|
|
|
int ret = -1;
|
2018-11-08 11:27:57 +03:00
|
|
|
char* filename;
|
|
|
|
char* password = NULL;
|
2014-06-29 02:33:46 +04:00
|
|
|
rdpAssistanceFile* file;
|
2018-11-08 11:27:57 +03:00
|
|
|
|
2018-11-22 13:19:12 +03:00
|
|
|
if (!settings || !argv || (argc < 2))
|
2018-11-08 11:27:57 +03:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
filename = argv[1];
|
|
|
|
|
|
|
|
for (x = 2; x < argc; x++)
|
|
|
|
{
|
|
|
|
const char* key = strstr(argv[x], "assistance:");
|
|
|
|
|
|
|
|
if (key)
|
|
|
|
password = strchr(key, ':') + 1;
|
|
|
|
}
|
|
|
|
|
2014-06-30 20:51:27 +04:00
|
|
|
file = freerdp_assistance_file_new();
|
2014-06-29 02:33:46 +04:00
|
|
|
|
|
|
|
if (!file)
|
|
|
|
return -1;
|
|
|
|
|
2018-11-08 11:27:57 +03:00
|
|
|
status = freerdp_assistance_parse_file(file, filename, password);
|
2014-06-29 02:33:46 +04:00
|
|
|
|
|
|
|
if (status < 0)
|
2018-08-17 15:40:12 +03:00
|
|
|
goto out;
|
2014-06-29 02:33:46 +04:00
|
|
|
|
2018-11-12 15:40:40 +03:00
|
|
|
if (!freerdp_assistance_populate_settings_from_assistance_file(file, settings))
|
2018-08-17 15:40:12 +03:00
|
|
|
goto out;
|
2014-06-29 02:33:46 +04:00
|
|
|
|
2018-08-17 15:40:12 +03:00
|
|
|
ret = 0;
|
|
|
|
out:
|
2014-06-30 20:51:27 +04:00
|
|
|
freerdp_assistance_file_free(file);
|
2018-08-17 15:40:12 +03:00
|
|
|
return ret;
|
2014-06-29 02:33:46 +04:00
|
|
|
}
|
2014-07-29 00:58:32 +04:00
|
|
|
|
2015-12-17 18:43:55 +03:00
|
|
|
/** Callback set in the rdp_freerdp structure, and used to get the user's password,
|
|
|
|
* if required to establish the connection.
|
|
|
|
* This function is actually called in credssp_ntlmssp_client_init()
|
|
|
|
* @see rdp_server_accept_nego() and rdp_check_fds()
|
|
|
|
* @param instance - pointer to the rdp_freerdp structure that contains the connection settings
|
|
|
|
* @param username - unused
|
2019-11-06 17:24:51 +03:00
|
|
|
* @param password - on return: pointer to a character string that will be filled by the password
|
|
|
|
* entered by the user. Note that this character string will be allocated inside the function, and
|
|
|
|
* needs to be deallocated by the caller using free(), even in case this function fails.
|
2015-12-17 18:43:55 +03:00
|
|
|
* @param domain - unused
|
2019-11-06 17:24:51 +03:00
|
|
|
* @return TRUE if a password was successfully entered. See freerdp_passphrase_read() for more
|
|
|
|
* details.
|
2015-12-17 18:43:55 +03:00
|
|
|
*/
|
2021-09-06 16:12:12 +03:00
|
|
|
static BOOL client_cli_authenticate_raw(freerdp* instance, rdp_auth_reason reason, char** username,
|
2016-08-03 19:44:15 +03:00
|
|
|
char** password, char** domain)
|
2015-12-17 18:43:55 +03:00
|
|
|
{
|
|
|
|
static const size_t password_size = 512;
|
2022-03-09 11:09:53 +03:00
|
|
|
const char* auth[] = { "Username: ", "Domain: ", "Password: " };
|
|
|
|
const char* authPin[] = { "Username: ", "Domain: ", "Smartcard-Pin: " };
|
2019-11-06 17:24:51 +03:00
|
|
|
const char* gw[] = { "GatewayUsername: ", "GatewayDomain: ", "GatewayPassword: " };
|
2021-09-06 16:12:12 +03:00
|
|
|
const char** prompt;
|
2022-03-09 11:09:53 +03:00
|
|
|
BOOL pinOnly = FALSE;
|
2021-09-06 16:12:12 +03:00
|
|
|
|
2022-03-23 15:18:35 +03:00
|
|
|
WINPR_ASSERT(instance);
|
|
|
|
WINPR_ASSERT(instance->context);
|
|
|
|
WINPR_ASSERT(instance->context->settings);
|
|
|
|
|
2021-09-06 16:12:12 +03:00
|
|
|
switch (reason)
|
|
|
|
{
|
2022-03-09 11:09:53 +03:00
|
|
|
case AUTH_SMARTCARD_PIN:
|
|
|
|
prompt = authPin;
|
|
|
|
pinOnly = TRUE;
|
|
|
|
break;
|
2021-09-06 16:12:12 +03:00
|
|
|
case AUTH_TLS:
|
|
|
|
case AUTH_RDP:
|
2022-03-09 11:09:53 +03:00
|
|
|
case AUTH_NLA:
|
2021-09-06 16:12:12 +03:00
|
|
|
prompt = auth;
|
|
|
|
break;
|
|
|
|
case GW_AUTH_HTTP:
|
|
|
|
case GW_AUTH_RDG:
|
|
|
|
case GW_AUTH_RPC:
|
|
|
|
prompt = gw;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
2015-12-17 18:43:55 +03:00
|
|
|
|
|
|
|
if (!username || !password || !domain)
|
|
|
|
return FALSE;
|
|
|
|
|
2022-03-09 11:09:53 +03:00
|
|
|
if (!*username && !pinOnly)
|
2015-12-17 18:43:55 +03:00
|
|
|
{
|
|
|
|
size_t username_size = 0;
|
|
|
|
printf("%s", prompt[0]);
|
2023-02-25 13:08:26 +03:00
|
|
|
fflush(stdout);
|
2016-08-03 19:44:15 +03:00
|
|
|
|
2023-02-25 13:08:26 +03:00
|
|
|
if (freerdp_interruptible_get_line(instance->context, username, &username_size, stdin) < 0)
|
2015-12-17 18:43:55 +03:00
|
|
|
{
|
2023-02-25 13:08:26 +03:00
|
|
|
WLog_ERR(TAG, "freerdp_interruptible_get_line returned %s [%d]", strerror(errno),
|
|
|
|
errno);
|
2015-12-17 18:43:55 +03:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*username)
|
|
|
|
{
|
|
|
|
*username = StrSep(username, "\r");
|
|
|
|
*username = StrSep(username, "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-09 11:09:53 +03:00
|
|
|
if (!*domain && !pinOnly)
|
2015-12-17 18:43:55 +03:00
|
|
|
{
|
|
|
|
size_t domain_size = 0;
|
|
|
|
printf("%s", prompt[1]);
|
2023-02-25 13:08:26 +03:00
|
|
|
fflush(stdout);
|
2016-08-03 19:44:15 +03:00
|
|
|
|
2023-02-25 13:08:26 +03:00
|
|
|
if (freerdp_interruptible_get_line(instance->context, domain, &domain_size, stdin) < 0)
|
2015-12-17 18:43:55 +03:00
|
|
|
{
|
2023-02-25 13:08:26 +03:00
|
|
|
WLog_ERR(TAG, "freerdp_interruptible_get_line returned %s [%d]", strerror(errno),
|
|
|
|
errno);
|
2015-12-17 18:43:55 +03:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*domain)
|
|
|
|
{
|
|
|
|
*domain = StrSep(domain, "\r");
|
|
|
|
*domain = StrSep(domain, "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!*password)
|
|
|
|
{
|
|
|
|
*password = calloc(password_size, sizeof(char));
|
2016-08-03 19:44:15 +03:00
|
|
|
|
2015-12-17 18:43:55 +03:00
|
|
|
if (!*password)
|
|
|
|
goto fail;
|
|
|
|
|
2023-02-25 13:08:26 +03:00
|
|
|
if (freerdp_passphrase_read(instance->context, prompt[2], *password, password_size,
|
2022-03-23 15:18:35 +03:00
|
|
|
instance->context->settings->CredentialsFromStdin) == NULL)
|
2015-12-17 18:43:55 +03:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
fail:
|
|
|
|
free(*username);
|
|
|
|
free(*domain);
|
|
|
|
free(*password);
|
|
|
|
*username = NULL;
|
|
|
|
*domain = NULL;
|
|
|
|
*password = NULL;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-09-06 16:12:12 +03:00
|
|
|
BOOL client_cli_authenticate_ex(freerdp* instance, char** username, char** password, char** domain,
|
|
|
|
rdp_auth_reason reason)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(instance);
|
|
|
|
WINPR_ASSERT(username);
|
|
|
|
WINPR_ASSERT(password);
|
|
|
|
WINPR_ASSERT(domain);
|
|
|
|
|
|
|
|
switch (reason)
|
|
|
|
{
|
|
|
|
case AUTH_NLA:
|
|
|
|
break;
|
2022-02-02 01:23:34 +03:00
|
|
|
|
2021-09-06 16:12:12 +03:00
|
|
|
case AUTH_TLS:
|
|
|
|
case AUTH_RDP:
|
2022-02-02 01:23:34 +03:00
|
|
|
case AUTH_SMARTCARD_PIN: /* in this case password is pin code */
|
2021-09-06 16:12:12 +03:00
|
|
|
if ((*username) && (*password))
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
case GW_AUTH_HTTP:
|
|
|
|
case GW_AUTH_RDG:
|
|
|
|
case GW_AUTH_RPC:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return client_cli_authenticate_raw(instance, reason, username, password, domain);
|
|
|
|
}
|
|
|
|
|
2023-02-14 23:00:27 +03:00
|
|
|
BOOL client_cli_choose_smartcard(freerdp* instance, SmartcardCertInfo** cert_list, DWORD count,
|
|
|
|
DWORD* choice, BOOL gateway)
|
2022-10-14 19:58:30 +03:00
|
|
|
{
|
|
|
|
unsigned long answer;
|
|
|
|
char* p = NULL;
|
|
|
|
|
|
|
|
printf("Multiple smartcards are available for use:\n");
|
|
|
|
for (DWORD i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
const SmartcardCertInfo* cert = cert_list[i];
|
2022-10-28 09:09:27 +03:00
|
|
|
char* reader = ConvertWCharToUtf8Alloc(cert->reader, NULL);
|
|
|
|
char* container_name = ConvertWCharToUtf8Alloc(cert->containerName, NULL);
|
2022-10-14 19:58:30 +03:00
|
|
|
|
|
|
|
printf("[%" PRIu32
|
|
|
|
"] %s\n\tReader: %s\n\tUser: %s@%s\n\tSubject: %s\n\tIssuer: %s\n\tUPN: %s\n",
|
2022-10-16 18:36:20 +03:00
|
|
|
i, container_name, reader, cert->userHint, cert->domainHint, cert->subject,
|
2022-10-14 19:58:30 +03:00
|
|
|
cert->issuer, cert->upn);
|
|
|
|
|
|
|
|
free(reader);
|
2022-10-16 18:36:20 +03:00
|
|
|
free(container_name);
|
2022-10-14 19:58:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
char input[10] = { 0 };
|
|
|
|
|
2022-10-16 22:54:59 +03:00
|
|
|
printf("\nChoose a smartcard to use for %s (0 - %" PRIu32 "): ",
|
|
|
|
gateway ? "gateway authentication" : "logon", count - 1);
|
2022-10-14 19:58:30 +03:00
|
|
|
fflush(stdout);
|
|
|
|
if (!fgets(input, 10, stdin))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "could not read from stdin");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
answer = strtoul(input, &p, 10);
|
|
|
|
if ((*p == '\n' && p != input) && answer < count)
|
|
|
|
{
|
|
|
|
*choice = answer;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-06 16:12:12 +03:00
|
|
|
#if defined(WITH_FREERDP_DEPRECATED)
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL client_cli_authenticate(freerdp* instance, char** username, char** password, char** domain)
|
2015-12-17 18:43:55 +03:00
|
|
|
{
|
2018-09-04 16:49:21 +03:00
|
|
|
if (instance->settings->SmartcardLogon)
|
|
|
|
{
|
|
|
|
WLog_INFO(TAG, "Authentication via smartcard");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2015-12-17 18:43:55 +03:00
|
|
|
return client_cli_authenticate_raw(instance, FALSE, username, password, domain);
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL client_cli_gw_authenticate(freerdp* instance, char** username, char** password, char** domain)
|
2015-12-17 18:43:55 +03:00
|
|
|
{
|
|
|
|
return client_cli_authenticate_raw(instance, TRUE, username, password, domain);
|
|
|
|
}
|
2021-09-06 16:12:12 +03:00
|
|
|
#endif
|
2015-12-17 18:43:55 +03:00
|
|
|
|
2023-02-25 13:08:26 +03:00
|
|
|
static DWORD client_cli_accept_certificate(freerdp* instance)
|
2015-12-17 18:43:55 +03:00
|
|
|
{
|
2021-10-06 10:43:37 +03:00
|
|
|
int answer;
|
2015-12-17 18:43:55 +03:00
|
|
|
|
2023-02-25 13:08:26 +03:00
|
|
|
WINPR_ASSERT(instance);
|
|
|
|
WINPR_ASSERT(instance->context);
|
|
|
|
|
|
|
|
const rdpSettings* settings = instance->context->settings;
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
|
2016-02-19 12:22:38 +03:00
|
|
|
if (settings->CredentialsFromStdin)
|
|
|
|
return 0;
|
|
|
|
|
2015-12-17 18:43:55 +03:00
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
printf("Do you trust the above certificate? (Y/T/N) ");
|
2017-01-31 23:33:44 +03:00
|
|
|
fflush(stdout);
|
2023-02-25 13:08:26 +03:00
|
|
|
answer = freerdp_interruptible_getc(instance->context, stdin);
|
2015-12-17 18:43:55 +03:00
|
|
|
|
2023-02-25 13:08:26 +03:00
|
|
|
if ((answer == EOF) || feof(stdin))
|
2015-12-17 18:43:55 +03:00
|
|
|
{
|
|
|
|
printf("\nError: Could not read answer from stdin.");
|
2016-08-03 19:44:15 +03:00
|
|
|
|
2015-12-17 18:43:55 +03:00
|
|
|
if (settings->CredentialsFromStdin)
|
|
|
|
printf(" - Run without parameter \"--from-stdin\" to set trust.");
|
2016-08-03 19:44:15 +03:00
|
|
|
|
2015-12-17 18:43:55 +03:00
|
|
|
printf("\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-08-03 19:44:15 +03:00
|
|
|
switch (answer)
|
2015-12-17 18:43:55 +03:00
|
|
|
{
|
|
|
|
case 'y':
|
|
|
|
case 'Y':
|
2023-02-25 13:08:26 +03:00
|
|
|
answer = freerdp_interruptible_getc(instance->context, stdin);
|
|
|
|
if (answer == EOF)
|
|
|
|
return 0;
|
2015-12-17 18:43:55 +03:00
|
|
|
return 1;
|
2016-08-03 19:44:15 +03:00
|
|
|
|
2015-12-17 18:43:55 +03:00
|
|
|
case 't':
|
|
|
|
case 'T':
|
2023-02-25 13:08:26 +03:00
|
|
|
answer = freerdp_interruptible_getc(instance->context, stdin);
|
|
|
|
if (answer == EOF)
|
|
|
|
return 0;
|
2015-12-17 18:43:55 +03:00
|
|
|
return 2;
|
2016-08-03 19:44:15 +03:00
|
|
|
|
2015-12-17 18:43:55 +03:00
|
|
|
case 'n':
|
|
|
|
case 'N':
|
2023-02-25 13:08:26 +03:00
|
|
|
answer = freerdp_interruptible_getc(instance->context, stdin);
|
|
|
|
if (answer == EOF)
|
|
|
|
return 0;
|
2015-12-17 18:43:55 +03:00
|
|
|
return 0;
|
2016-08-03 19:44:15 +03:00
|
|
|
|
2015-12-17 18:43:55 +03:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2016-08-03 19:44:15 +03:00
|
|
|
|
2015-12-17 18:43:55 +03:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Callback set in the rdp_freerdp structure, and used to make a certificate validation
|
|
|
|
* when the connection requires it.
|
|
|
|
* This function will actually be called by tls_verify_certificate().
|
2023-01-14 05:25:26 +03:00
|
|
|
* @see rdp_client_connect() and freerdp_tls_connect()
|
2018-11-30 13:04:20 +03:00
|
|
|
* @deprecated Use client_cli_verify_certificate_ex
|
2015-12-17 18:43:55 +03:00
|
|
|
* @param instance - pointer to the rdp_freerdp structure that contains the connection settings
|
|
|
|
* @param common_name
|
|
|
|
* @param subject
|
|
|
|
* @param issuer
|
|
|
|
* @param fingerprint
|
|
|
|
* @param host_mismatch Indicates the certificate host does not match.
|
|
|
|
* @return 1 if the certificate is trusted, 2 if temporary trusted, 0 otherwise.
|
|
|
|
*/
|
2021-07-28 16:18:03 +03:00
|
|
|
#if defined(WITH_FREERDP_DEPRECATED)
|
2019-11-06 17:24:51 +03:00
|
|
|
DWORD client_cli_verify_certificate(freerdp* instance, const char* common_name, const char* subject,
|
|
|
|
const char* issuer, const char* fingerprint, BOOL host_mismatch)
|
2015-12-17 18:43:55 +03:00
|
|
|
{
|
2019-02-07 19:53:21 +03:00
|
|
|
WINPR_UNUSED(common_name);
|
|
|
|
WINPR_UNUSED(host_mismatch);
|
|
|
|
|
2018-11-30 13:04:20 +03:00
|
|
|
printf("WARNING: This callback is deprecated, migrate to client_cli_verify_certificate_ex\n");
|
2015-12-17 18:43:55 +03:00
|
|
|
printf("Certificate details:\n");
|
|
|
|
printf("\tSubject: %s\n", subject);
|
|
|
|
printf("\tIssuer: %s\n", issuer);
|
|
|
|
printf("\tThumbprint: %s\n", fingerprint);
|
|
|
|
printf("The above X.509 certificate could not be verified, possibly because you do not have\n"
|
2016-08-03 19:44:15 +03:00
|
|
|
"the CA certificate in your certificate store, or the certificate has expired.\n"
|
2017-11-21 13:47:33 +03:00
|
|
|
"Please look at the OpenSSL documentation on how to add a private CA to the store.\n");
|
2023-02-25 13:08:26 +03:00
|
|
|
return client_cli_accept_certificate(instance);
|
2015-12-17 18:43:55 +03:00
|
|
|
}
|
2021-07-28 16:18:03 +03:00
|
|
|
#endif
|
2015-12-17 18:43:55 +03:00
|
|
|
|
2018-11-30 13:04:20 +03:00
|
|
|
/** Callback set in the rdp_freerdp structure, and used to make a certificate validation
|
|
|
|
* when the connection requires it.
|
|
|
|
* This function will actually be called by tls_verify_certificate().
|
2023-01-14 05:25:26 +03:00
|
|
|
* @see rdp_client_connect() and freerdp_tls_connect()
|
2018-11-30 13:04:20 +03:00
|
|
|
* @param instance pointer to the rdp_freerdp structure that contains the connection settings
|
|
|
|
* @param host The host currently connecting to
|
|
|
|
* @param port The port currently connecting to
|
|
|
|
* @param common_name The common name of the certificate, should match host or an alias of it
|
|
|
|
* @param subject The subject of the certificate
|
|
|
|
* @param issuer The certificate issuer name
|
|
|
|
* @param fingerprint The fingerprint of the certificate
|
|
|
|
* @param flags See VERIFY_CERT_FLAG_* for possible values.
|
|
|
|
*
|
|
|
|
* @return 1 if the certificate is trusted, 2 if temporary trusted, 0 otherwise.
|
|
|
|
*/
|
|
|
|
DWORD client_cli_verify_certificate_ex(freerdp* instance, const char* host, UINT16 port,
|
2019-11-06 17:24:51 +03:00
|
|
|
const char* common_name, const char* subject,
|
|
|
|
const char* issuer, const char* fingerprint, DWORD flags)
|
2018-11-30 13:04:20 +03:00
|
|
|
{
|
|
|
|
const char* type = "RDP-Server";
|
2022-03-23 15:18:35 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(instance);
|
|
|
|
WINPR_ASSERT(instance->context);
|
|
|
|
WINPR_ASSERT(instance->context->settings);
|
|
|
|
|
2018-11-30 13:04:20 +03:00
|
|
|
if (flags & VERIFY_CERT_FLAG_GATEWAY)
|
|
|
|
type = "RDP-Gateway";
|
|
|
|
|
|
|
|
if (flags & VERIFY_CERT_FLAG_REDIRECT)
|
|
|
|
type = "RDP-Redirect";
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
printf("Certificate details for %s:%" PRIu16 " (%s):\n", host, port, type);
|
2018-11-30 13:04:20 +03:00
|
|
|
printf("\tCommon Name: %s\n", common_name);
|
|
|
|
printf("\tSubject: %s\n", subject);
|
|
|
|
printf("\tIssuer: %s\n", issuer);
|
2021-04-13 12:01:43 +03:00
|
|
|
/* Newer versions of FreeRDP allow exposing the whole PEM by setting
|
|
|
|
* FreeRDP_CertificateCallbackPreferPEM to TRUE
|
|
|
|
*/
|
|
|
|
if (flags & VERIFY_CERT_FLAG_FP_IS_PEM)
|
|
|
|
{
|
|
|
|
printf("\t----------- Certificate --------------\n");
|
|
|
|
printf("%s\n", fingerprint);
|
|
|
|
printf("\t--------------------------------------\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
printf("\tThumbprint: %s\n", fingerprint);
|
2020-04-21 10:06:39 +03:00
|
|
|
|
2018-11-30 13:04:20 +03:00
|
|
|
printf("The above X.509 certificate could not be verified, possibly because you do not have\n"
|
|
|
|
"the CA certificate in your certificate store, or the certificate has expired.\n"
|
|
|
|
"Please look at the OpenSSL documentation on how to add a private CA to the store.\n");
|
2023-02-25 13:08:26 +03:00
|
|
|
return client_cli_accept_certificate(instance);
|
2018-11-30 13:04:20 +03:00
|
|
|
}
|
|
|
|
|
2015-12-17 18:43:55 +03:00
|
|
|
/** Callback set in the rdp_freerdp structure, and used to make a certificate validation
|
|
|
|
* when a stored certificate does not match the remote counterpart.
|
|
|
|
* This function will actually be called by tls_verify_certificate().
|
2023-01-14 05:25:26 +03:00
|
|
|
* @see rdp_client_connect() and freerdp_tls_connect()
|
2018-11-30 13:04:20 +03:00
|
|
|
* @deprecated Use client_cli_verify_changed_certificate_ex
|
2015-12-17 18:43:55 +03:00
|
|
|
* @param instance - pointer to the rdp_freerdp structure that contains the connection settings
|
|
|
|
* @param common_name
|
|
|
|
* @param subject
|
|
|
|
* @param issuer
|
|
|
|
* @param fingerprint
|
|
|
|
* @param old_subject
|
|
|
|
* @param old_issuer
|
|
|
|
* @param old_fingerprint
|
|
|
|
* @return 1 if the certificate is trusted, 2 if temporary trusted, 0 otherwise.
|
|
|
|
*/
|
2021-07-28 16:18:03 +03:00
|
|
|
#if defined(WITH_FREERDP_DEPRECATED)
|
2019-11-06 17:24:51 +03:00
|
|
|
DWORD client_cli_verify_changed_certificate(freerdp* instance, const char* common_name,
|
|
|
|
const char* subject, const char* issuer,
|
|
|
|
const char* fingerprint, const char* old_subject,
|
|
|
|
const char* old_issuer, const char* old_fingerprint)
|
2015-12-17 18:43:55 +03:00
|
|
|
{
|
2019-02-07 19:53:21 +03:00
|
|
|
WINPR_UNUSED(common_name);
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
printf("WARNING: This callback is deprecated, migrate to "
|
|
|
|
"client_cli_verify_changed_certificate_ex\n");
|
2015-12-17 18:43:55 +03:00
|
|
|
printf("!!! Certificate has changed !!!\n");
|
|
|
|
printf("\n");
|
|
|
|
printf("New Certificate details:\n");
|
|
|
|
printf("\tSubject: %s\n", subject);
|
|
|
|
printf("\tIssuer: %s\n", issuer);
|
|
|
|
printf("\tThumbprint: %s\n", fingerprint);
|
|
|
|
printf("\n");
|
|
|
|
printf("Old Certificate details:\n");
|
|
|
|
printf("\tSubject: %s\n", old_subject);
|
|
|
|
printf("\tIssuer: %s\n", old_issuer);
|
|
|
|
printf("\tThumbprint: %s\n", old_fingerprint);
|
|
|
|
printf("\n");
|
2019-11-06 17:24:51 +03:00
|
|
|
printf("The above X.509 certificate does not match the certificate used for previous "
|
|
|
|
"connections.\n"
|
2016-08-03 19:44:15 +03:00
|
|
|
"This may indicate that the certificate has been tampered with.\n"
|
|
|
|
"Please contact the administrator of the RDP server and clarify.\n");
|
2023-02-25 13:08:26 +03:00
|
|
|
return client_cli_accept_certificate(instance);
|
2015-12-17 18:43:55 +03:00
|
|
|
}
|
2021-07-28 16:18:03 +03:00
|
|
|
#endif
|
2015-12-17 18:43:55 +03:00
|
|
|
|
2018-11-30 13:04:20 +03:00
|
|
|
/** Callback set in the rdp_freerdp structure, and used to make a certificate validation
|
|
|
|
* when a stored certificate does not match the remote counterpart.
|
|
|
|
* This function will actually be called by tls_verify_certificate().
|
2023-01-14 05:25:26 +03:00
|
|
|
* @see rdp_client_connect() and freerdp_tls_connect()
|
2019-11-06 17:24:51 +03:00
|
|
|
* @param instance pointer to the rdp_freerdp structure that contains the connection
|
|
|
|
* settings
|
2018-11-30 13:04:20 +03:00
|
|
|
* @param host The host currently connecting to
|
|
|
|
* @param port The port currently connecting to
|
|
|
|
* @param common_name The common name of the certificate, should match host or an alias of it
|
|
|
|
* @param subject The subject of the certificate
|
|
|
|
* @param issuer The certificate issuer name
|
|
|
|
* @param fingerprint The fingerprint of the certificate
|
|
|
|
* @param old_subject The subject of the previous certificate
|
|
|
|
* @param old_issuer The previous certificate issuer name
|
|
|
|
* @param old_fingerprint The fingerprint of the previous certificate
|
|
|
|
* @param flags See VERIFY_CERT_FLAG_* for possible values.
|
|
|
|
*
|
|
|
|
* @return 1 if the certificate is trusted, 2 if temporary trusted, 0 otherwise.
|
|
|
|
*/
|
2019-11-06 17:24:51 +03:00
|
|
|
DWORD client_cli_verify_changed_certificate_ex(freerdp* instance, const char* host, UINT16 port,
|
|
|
|
const char* common_name, const char* subject,
|
|
|
|
const char* issuer, const char* fingerprint,
|
|
|
|
const char* old_subject, const char* old_issuer,
|
|
|
|
const char* old_fingerprint, DWORD flags)
|
2018-11-30 13:04:20 +03:00
|
|
|
{
|
|
|
|
const char* type = "RDP-Server";
|
|
|
|
|
2022-03-23 15:18:35 +03:00
|
|
|
WINPR_ASSERT(instance);
|
|
|
|
WINPR_ASSERT(instance->context);
|
|
|
|
WINPR_ASSERT(instance->context->settings);
|
|
|
|
|
2018-11-30 13:04:20 +03:00
|
|
|
if (flags & VERIFY_CERT_FLAG_GATEWAY)
|
|
|
|
type = "RDP-Gateway";
|
|
|
|
|
|
|
|
if (flags & VERIFY_CERT_FLAG_REDIRECT)
|
|
|
|
type = "RDP-Redirect";
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
printf("!!!Certificate for %s:%" PRIu16 " (%s) has changed!!!\n", host, port, type);
|
2018-11-30 13:04:20 +03:00
|
|
|
printf("\n");
|
|
|
|
printf("New Certificate details:\n");
|
|
|
|
printf("\tCommon Name: %s\n", common_name);
|
|
|
|
printf("\tSubject: %s\n", subject);
|
|
|
|
printf("\tIssuer: %s\n", issuer);
|
2021-04-13 12:01:43 +03:00
|
|
|
/* Newer versions of FreeRDP allow exposing the whole PEM by setting
|
|
|
|
* FreeRDP_CertificateCallbackPreferPEM to TRUE
|
|
|
|
*/
|
|
|
|
if (flags & VERIFY_CERT_FLAG_FP_IS_PEM)
|
|
|
|
{
|
|
|
|
printf("\t----------- Certificate --------------\n");
|
|
|
|
printf("%s\n", fingerprint);
|
|
|
|
printf("\t--------------------------------------\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
printf("\tThumbprint: %s\n", fingerprint);
|
2018-11-30 13:04:20 +03:00
|
|
|
printf("\n");
|
|
|
|
printf("Old Certificate details:\n");
|
|
|
|
printf("\tSubject: %s\n", old_subject);
|
|
|
|
printf("\tIssuer: %s\n", old_issuer);
|
2021-04-13 12:01:43 +03:00
|
|
|
/* Newer versions of FreeRDP allow exposing the whole PEM by setting
|
|
|
|
* FreeRDP_CertificateCallbackPreferPEM to TRUE
|
|
|
|
*/
|
|
|
|
if (flags & VERIFY_CERT_FLAG_FP_IS_PEM)
|
|
|
|
{
|
|
|
|
printf("\t----------- Certificate --------------\n");
|
|
|
|
printf("%s\n", old_fingerprint);
|
|
|
|
printf("\t--------------------------------------\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
printf("\tThumbprint: %s\n", old_fingerprint);
|
2018-11-30 13:04:20 +03:00
|
|
|
printf("\n");
|
2020-04-21 10:06:39 +03:00
|
|
|
if (flags & VERIFY_CERT_FLAG_MATCH_LEGACY_SHA1)
|
|
|
|
{
|
|
|
|
printf("\tA matching entry with legacy SHA1 was found in local known_hosts2 store.\n");
|
|
|
|
printf("\tIf you just upgraded from a FreeRDP version before 2.0 this is expected.\n");
|
|
|
|
printf("\tThe hashing algorithm has been upgraded from SHA1 to SHA256.\n");
|
|
|
|
printf("\tAll manually accepted certificates must be reconfirmed!\n");
|
|
|
|
printf("\n");
|
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
printf("The above X.509 certificate does not match the certificate used for previous "
|
|
|
|
"connections.\n"
|
2018-11-30 13:04:20 +03:00
|
|
|
"This may indicate that the certificate has been tampered with.\n"
|
|
|
|
"Please contact the administrator of the RDP server and clarify.\n");
|
2023-02-25 13:08:26 +03:00
|
|
|
return client_cli_accept_certificate(instance);
|
2018-11-30 13:04:20 +03:00
|
|
|
}
|
|
|
|
|
2020-08-03 13:06:08 +03:00
|
|
|
BOOL client_cli_present_gateway_message(freerdp* instance, UINT32 type, BOOL isDisplayMandatory,
|
|
|
|
BOOL isConsentMandatory, size_t length,
|
|
|
|
const WCHAR* message)
|
|
|
|
{
|
2021-10-06 10:43:37 +03:00
|
|
|
int answer;
|
2020-08-04 10:11:41 +03:00
|
|
|
const char* msgType = (type == GATEWAY_MESSAGE_CONSENT) ? "Consent message" : "Service message";
|
2020-08-03 13:06:08 +03:00
|
|
|
|
2022-03-23 15:18:35 +03:00
|
|
|
WINPR_ASSERT(instance);
|
|
|
|
WINPR_ASSERT(instance->context);
|
|
|
|
WINPR_ASSERT(instance->context->settings);
|
|
|
|
|
2020-08-03 13:06:08 +03:00
|
|
|
if (!isDisplayMandatory && !isConsentMandatory)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
printf("%s:\n", msgType);
|
|
|
|
#if defined(WIN32)
|
|
|
|
printf("%.*S\n", (int)length, message);
|
|
|
|
#else
|
|
|
|
{
|
2022-10-28 09:09:27 +03:00
|
|
|
LPSTR msg = ConvertWCharNToUtf8Alloc(message, length / sizeof(WCHAR), NULL);
|
|
|
|
if (!msg)
|
2020-08-03 13:06:08 +03:00
|
|
|
{
|
|
|
|
printf("Failed to convert message!\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
printf("%s\n", msg);
|
|
|
|
free(msg);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
while (isConsentMandatory)
|
|
|
|
{
|
|
|
|
printf("I understand and agree to the terms of this policy (Y/N) \n");
|
|
|
|
fflush(stdout);
|
2023-02-25 13:08:26 +03:00
|
|
|
answer = freerdp_interruptible_getc(instance->context, stdin);
|
2020-08-03 13:06:08 +03:00
|
|
|
|
2023-02-25 13:08:26 +03:00
|
|
|
if ((answer == EOF) || feof(stdin))
|
2020-08-03 13:06:08 +03:00
|
|
|
{
|
|
|
|
printf("\nError: Could not read answer from stdin.\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (answer)
|
|
|
|
{
|
|
|
|
case 'y':
|
|
|
|
case 'Y':
|
2023-02-25 13:08:26 +03:00
|
|
|
answer = freerdp_interruptible_getc(instance->context, stdin);
|
|
|
|
if (answer == EOF)
|
|
|
|
return FALSE;
|
2020-08-03 13:06:08 +03:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case 'n':
|
|
|
|
case 'N':
|
2023-02-25 13:08:26 +03:00
|
|
|
freerdp_interruptible_getc(instance->context, stdin);
|
2020-08-03 13:06:08 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2023-03-08 16:25:57 +03:00
|
|
|
BOOL client_cli_get_aad_auth_code(freerdp* instance, const char* hostname, char** code)
|
2023-03-08 04:06:47 +03:00
|
|
|
{
|
|
|
|
size_t len = 0;
|
|
|
|
char* p = NULL;
|
|
|
|
|
2023-03-08 16:25:57 +03:00
|
|
|
WINPR_ASSERT(instance);
|
2023-03-08 04:06:47 +03:00
|
|
|
WINPR_ASSERT(hostname);
|
|
|
|
WINPR_ASSERT(code);
|
|
|
|
*code = NULL;
|
|
|
|
|
|
|
|
printf(
|
|
|
|
"Browse to: "
|
|
|
|
"https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=" OAUTH2_CLIENT_ID
|
|
|
|
"&response_type=code"
|
|
|
|
"&scope=ms-device-service%%3A%%2F%%2Ftermsrv.wvd.microsoft.com%%2Fname%%2F%s%%2Fuser_"
|
|
|
|
"impersonation"
|
|
|
|
"&redirect_uri=ms-appx-web%%3a%%2f%%2fMicrosoft.AAD.BrokerPlugin%%2f5177bc73-fd99-4c77-"
|
|
|
|
"a90c-76844c9b6999\n",
|
|
|
|
hostname);
|
|
|
|
printf("Paste authorization code here: ");
|
|
|
|
|
2023-03-09 00:09:27 +03:00
|
|
|
if (freerdp_interruptible_get_line(instance->context, code, &len, stdin) < 0)
|
2023-03-08 04:06:47 +03:00
|
|
|
return FALSE;
|
|
|
|
p = strpbrk(*code, "\r\n");
|
|
|
|
if (p)
|
|
|
|
*p = 0;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-09-24 11:30:59 +03:00
|
|
|
BOOL client_auto_reconnect(freerdp* instance)
|
2018-09-24 17:24:32 +03:00
|
|
|
{
|
|
|
|
return client_auto_reconnect_ex(instance, NULL);
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL client_auto_reconnect_ex(freerdp* instance, BOOL (*window_events)(freerdp* instance))
|
2018-09-24 11:30:59 +03:00
|
|
|
{
|
2022-03-07 16:48:08 +03:00
|
|
|
BOOL retry = TRUE;
|
2020-11-26 17:38:17 +03:00
|
|
|
UINT32 error;
|
2018-09-24 11:30:59 +03:00
|
|
|
UINT32 maxRetries;
|
|
|
|
UINT32 numRetries = 0;
|
|
|
|
rdpSettings* settings;
|
|
|
|
|
2022-03-23 15:18:35 +03:00
|
|
|
if (!instance)
|
2018-09-24 11:30:59 +03:00
|
|
|
return FALSE;
|
|
|
|
|
2022-03-23 15:18:35 +03:00
|
|
|
WINPR_ASSERT(instance->context);
|
|
|
|
|
|
|
|
settings = instance->context->settings;
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
|
2018-09-24 11:30:59 +03:00
|
|
|
maxRetries = settings->AutoReconnectMaxRetries;
|
|
|
|
|
|
|
|
/* Only auto reconnect on network disconnects. */
|
2020-11-26 17:38:17 +03:00
|
|
|
error = freerdp_error_info(instance);
|
|
|
|
switch (error)
|
|
|
|
{
|
|
|
|
case ERRINFO_GRAPHICS_SUBSYSTEM_FAILED:
|
|
|
|
/* A network disconnect was detected */
|
|
|
|
WLog_WARN(TAG, "Disconnected by server hitting a bug or resource limit [%s]",
|
|
|
|
freerdp_get_error_info_string(error));
|
|
|
|
break;
|
|
|
|
case ERRINFO_SUCCESS:
|
|
|
|
/* A network disconnect was detected */
|
|
|
|
WLog_INFO(TAG, "Network disconnect!");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
2018-09-24 11:30:59 +03:00
|
|
|
|
|
|
|
if (!settings->AutoReconnectionEnabled)
|
|
|
|
{
|
|
|
|
/* No auto-reconnect - just quit */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Perform an auto-reconnect. */
|
2022-03-07 16:48:08 +03:00
|
|
|
while (retry)
|
2018-09-24 11:30:59 +03:00
|
|
|
{
|
2018-09-24 17:24:32 +03:00
|
|
|
UINT32 x;
|
|
|
|
|
2018-09-24 11:30:59 +03:00
|
|
|
/* Quit retrying if max retries has been exceeded */
|
|
|
|
if ((maxRetries > 0) && (numRetries++ >= maxRetries))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Attempt the next reconnect */
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_INFO(TAG, "Attempting reconnect (%" PRIu32 " of %" PRIu32 ")", numRetries, maxRetries);
|
2018-09-24 11:30:59 +03:00
|
|
|
|
|
|
|
if (freerdp_reconnect(instance))
|
|
|
|
return TRUE;
|
|
|
|
|
2022-03-17 22:45:53 +03:00
|
|
|
switch (freerdp_get_last_error(instance->context))
|
2022-03-07 16:48:08 +03:00
|
|
|
{
|
|
|
|
case FREERDP_ERROR_CONNECT_CANCELLED:
|
|
|
|
WLog_WARN(TAG, "Autoreconnect aborted by user");
|
|
|
|
retry = FALSE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2018-09-24 17:24:32 +03:00
|
|
|
for (x = 0; x < 50; x++)
|
|
|
|
{
|
|
|
|
if (!IFCALLRESULT(TRUE, window_events, instance))
|
|
|
|
return FALSE;
|
|
|
|
|
2022-03-07 16:48:08 +03:00
|
|
|
Sleep(10);
|
2018-09-24 17:24:32 +03:00
|
|
|
}
|
2018-09-24 11:30:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
WLog_ERR(TAG, "Maximum reconnect retries exceeded");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2022-01-19 14:11:48 +03:00
|
|
|
|
|
|
|
int freerdp_client_common_stop(rdpContext* context)
|
|
|
|
{
|
|
|
|
rdpClientContext* cctx = (rdpClientContext*)context;
|
|
|
|
WINPR_ASSERT(cctx);
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
freerdp_abort_connect_context(&cctx->context);
|
2022-01-19 14:11:48 +03:00
|
|
|
|
|
|
|
if (cctx->thread)
|
|
|
|
{
|
|
|
|
WaitForSingleObject(cctx->thread, INFINITE);
|
|
|
|
CloseHandle(cctx->thread);
|
|
|
|
cctx->thread = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2022-01-19 13:05:41 +03:00
|
|
|
|
2022-10-13 12:59:40 +03:00
|
|
|
#if defined(CHANNEL_ENCOMSP_CLIENT)
|
2022-09-12 14:23:06 +03:00
|
|
|
BOOL freerdp_client_encomsp_toggle_control(EncomspClientContext* encomsp)
|
|
|
|
{
|
|
|
|
rdpClientContext* cctx;
|
|
|
|
BOOL state;
|
|
|
|
|
2022-09-22 11:27:52 +03:00
|
|
|
if (!encomsp)
|
|
|
|
return FALSE;
|
|
|
|
|
2022-09-12 14:23:06 +03:00
|
|
|
cctx = (rdpClientContext*)encomsp->custom;
|
|
|
|
|
|
|
|
state = cctx->controlToggle;
|
|
|
|
cctx->controlToggle = !cctx->controlToggle;
|
|
|
|
return freerdp_client_encomsp_set_control(encomsp, state);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL freerdp_client_encomsp_set_control(EncomspClientContext* encomsp, BOOL control)
|
|
|
|
{
|
|
|
|
ENCOMSP_CHANGE_PARTICIPANT_CONTROL_LEVEL_PDU pdu = { 0 };
|
|
|
|
|
|
|
|
if (!encomsp)
|
|
|
|
return FALSE;
|
|
|
|
|
2022-09-18 22:09:23 +03:00
|
|
|
pdu.ParticipantId = encomsp->participantId;
|
2022-09-12 14:23:06 +03:00
|
|
|
pdu.Flags = ENCOMSP_REQUEST_VIEW;
|
|
|
|
|
|
|
|
if (control)
|
|
|
|
pdu.Flags |= ENCOMSP_REQUEST_INTERACT;
|
|
|
|
|
|
|
|
encomsp->ChangeParticipantControlLevel(encomsp, &pdu);
|
2022-10-13 12:59:40 +03:00
|
|
|
|
2022-09-12 14:23:06 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT
|
|
|
|
client_encomsp_participant_created(EncomspClientContext* context,
|
|
|
|
const ENCOMSP_PARTICIPANT_CREATED_PDU* participantCreated)
|
|
|
|
{
|
|
|
|
rdpClientContext* cctx;
|
|
|
|
rdpSettings* settings;
|
|
|
|
BOOL request;
|
|
|
|
|
|
|
|
if (!context || !context->custom || !participantCreated)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
cctx = (rdpClientContext*)context->custom;
|
|
|
|
WINPR_ASSERT(cctx);
|
|
|
|
|
|
|
|
settings = cctx->context.settings;
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
|
2022-09-18 22:09:23 +03:00
|
|
|
if (participantCreated->Flags & ENCOMSP_IS_PARTICIPANT)
|
|
|
|
context->participantId = participantCreated->ParticipantId;
|
|
|
|
|
2022-09-12 14:23:06 +03:00
|
|
|
request = freerdp_settings_get_bool(settings, FreeRDP_RemoteAssistanceRequestControl);
|
|
|
|
if (request && (participantCreated->Flags & ENCOMSP_MAY_VIEW) &&
|
|
|
|
!(participantCreated->Flags & ENCOMSP_MAY_INTERACT))
|
|
|
|
{
|
|
|
|
if (!freerdp_client_encomsp_set_control(context, TRUE))
|
|
|
|
return ERROR_INTERNAL_ERROR;
|
2022-09-13 20:41:12 +03:00
|
|
|
|
2022-09-14 05:18:53 +03:00
|
|
|
/* if auto-request-control setting is enabled then only request control once upon connect,
|
|
|
|
* otherwise it will auto request control again every time server turns off control which
|
|
|
|
* is a bit annoying */
|
2022-09-13 20:41:12 +03:00
|
|
|
freerdp_settings_set_bool(settings, FreeRDP_RemoteAssistanceRequestControl, FALSE);
|
2022-09-12 14:23:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return CHANNEL_RC_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void client_encomsp_init(rdpClientContext* cctx, EncomspClientContext* encomsp)
|
|
|
|
{
|
|
|
|
cctx->encomsp = encomsp;
|
|
|
|
encomsp->custom = (void*)cctx;
|
|
|
|
encomsp->ParticipantCreated = client_encomsp_participant_created;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void client_encomsp_uninit(rdpClientContext* cctx, EncomspClientContext* encomsp)
|
|
|
|
{
|
|
|
|
if (encomsp)
|
|
|
|
{
|
|
|
|
encomsp->custom = NULL;
|
|
|
|
encomsp->ParticipantCreated = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cctx)
|
|
|
|
cctx->encomsp = NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-01-19 13:05:41 +03:00
|
|
|
void freerdp_client_OnChannelConnectedEventHandler(void* context,
|
|
|
|
const ChannelConnectedEventArgs* e)
|
|
|
|
{
|
|
|
|
rdpClientContext* cctx = (rdpClientContext*)context;
|
|
|
|
|
|
|
|
WINPR_ASSERT(cctx);
|
|
|
|
WINPR_ASSERT(e);
|
|
|
|
|
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#if defined(CHANNEL_AINPUT_CLIENT)
|
|
|
|
else if (strcmp(e->name, AINPUT_DVC_CHANNEL_NAME) == 0)
|
|
|
|
cctx->ainput = (AInputClientContext*)e->pInterface;
|
|
|
|
#endif
|
|
|
|
#if defined(CHANNEL_RDPEI_CLIENT)
|
|
|
|
else if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0)
|
|
|
|
{
|
|
|
|
cctx->rdpei = (RdpeiClientContext*)e->pInterface;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if defined(CHANNEL_RDPGFX_CLIENT)
|
|
|
|
else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0)
|
|
|
|
{
|
|
|
|
gdi_graphics_pipeline_init(cctx->context.gdi, (RdpgfxClientContext*)e->pInterface);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if defined(CHANNEL_GEOMETRY_CLIENT)
|
|
|
|
else if (strcmp(e->name, GEOMETRY_DVC_CHANNEL_NAME) == 0)
|
|
|
|
{
|
|
|
|
gdi_video_geometry_init(cctx->context.gdi, (GeometryClientContext*)e->pInterface);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if defined(CHANNEL_VIDEO_CLIENT)
|
|
|
|
else if (strcmp(e->name, VIDEO_CONTROL_DVC_CHANNEL_NAME) == 0)
|
|
|
|
{
|
|
|
|
gdi_video_control_init(cctx->context.gdi, (VideoClientContext*)e->pInterface);
|
|
|
|
}
|
|
|
|
else if (strcmp(e->name, VIDEO_DATA_DVC_CHANNEL_NAME) == 0)
|
|
|
|
{
|
|
|
|
gdi_video_data_init(cctx->context.gdi, (VideoClientContext*)e->pInterface);
|
|
|
|
}
|
|
|
|
#endif
|
2022-09-12 14:23:06 +03:00
|
|
|
#if defined(CHANNEL_ENCOMSP_CLIENT)
|
|
|
|
else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0)
|
|
|
|
{
|
|
|
|
client_encomsp_init(cctx, (EncomspClientContext*)e->pInterface);
|
|
|
|
}
|
|
|
|
#endif
|
2022-01-19 13:05:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void freerdp_client_OnChannelDisconnectedEventHandler(void* context,
|
|
|
|
const ChannelDisconnectedEventArgs* e)
|
|
|
|
{
|
|
|
|
rdpClientContext* cctx = (rdpClientContext*)context;
|
|
|
|
|
|
|
|
WINPR_ASSERT(cctx);
|
|
|
|
WINPR_ASSERT(e);
|
|
|
|
|
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#if defined(CHANNEL_AINPUT_CLIENT)
|
|
|
|
else if (strcmp(e->name, AINPUT_DVC_CHANNEL_NAME) == 0)
|
|
|
|
cctx->ainput = NULL;
|
|
|
|
#endif
|
|
|
|
#if defined(CHANNEL_RDPEI_CLIENT)
|
|
|
|
else if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0)
|
|
|
|
{
|
|
|
|
cctx->rdpei = NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if defined(CHANNEL_RDPGFX_CLIENT)
|
|
|
|
else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0)
|
|
|
|
{
|
|
|
|
gdi_graphics_pipeline_uninit(cctx->context.gdi, (RdpgfxClientContext*)e->pInterface);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if defined(CHANNEL_GEOMETRY_CLIENT)
|
|
|
|
else if (strcmp(e->name, GEOMETRY_DVC_CHANNEL_NAME) == 0)
|
|
|
|
{
|
|
|
|
gdi_video_geometry_uninit(cctx->context.gdi, (GeometryClientContext*)e->pInterface);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if defined(CHANNEL_VIDEO_CLIENT)
|
|
|
|
else if (strcmp(e->name, VIDEO_CONTROL_DVC_CHANNEL_NAME) == 0)
|
|
|
|
{
|
|
|
|
gdi_video_control_uninit(cctx->context.gdi, (VideoClientContext*)e->pInterface);
|
|
|
|
}
|
|
|
|
else if (strcmp(e->name, VIDEO_DATA_DVC_CHANNEL_NAME) == 0)
|
|
|
|
{
|
|
|
|
gdi_video_data_uninit(cctx->context.gdi, (VideoClientContext*)e->pInterface);
|
|
|
|
}
|
|
|
|
#endif
|
2022-09-12 14:23:06 +03:00
|
|
|
#if defined(CHANNEL_ENCOMSP_CLIENT)
|
|
|
|
else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0)
|
|
|
|
{
|
|
|
|
client_encomsp_uninit(cctx, (EncomspClientContext*)e->pInterface);
|
|
|
|
}
|
|
|
|
#endif
|
2022-01-19 13:05:41 +03:00
|
|
|
}
|
2022-01-19 14:24:45 +03:00
|
|
|
|
|
|
|
BOOL freerdp_client_send_wheel_event(rdpClientContext* cctx, UINT16 mflags)
|
|
|
|
{
|
|
|
|
BOOL handled = FALSE;
|
|
|
|
|
|
|
|
WINPR_ASSERT(cctx);
|
|
|
|
|
|
|
|
#if defined(CHANNEL_AINPUT_CLIENT)
|
|
|
|
if (cctx->ainput)
|
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
UINT64 flags = 0;
|
|
|
|
INT32 x = 0, y = 0;
|
2022-01-21 17:47:40 +03:00
|
|
|
INT32 value = mflags & 0xFF;
|
|
|
|
|
|
|
|
if (mflags & PTR_FLAGS_WHEEL_NEGATIVE)
|
|
|
|
value = -1 * (0x100 - value);
|
|
|
|
|
2022-01-21 19:24:32 +03:00
|
|
|
/* We have discrete steps, scale this so we can also support high
|
|
|
|
* resolution wheels. */
|
|
|
|
value *= 0x10000;
|
|
|
|
|
2022-01-19 14:24:45 +03:00
|
|
|
if (mflags & PTR_FLAGS_WHEEL)
|
|
|
|
{
|
|
|
|
flags |= AINPUT_FLAGS_WHEEL;
|
2022-01-21 17:47:40 +03:00
|
|
|
y = value;
|
2022-01-19 14:24:45 +03:00
|
|
|
}
|
2022-01-21 17:47:40 +03:00
|
|
|
|
2022-01-19 14:24:45 +03:00
|
|
|
if (mflags & PTR_FLAGS_HWHEEL)
|
|
|
|
{
|
|
|
|
flags |= AINPUT_FLAGS_WHEEL;
|
2022-01-21 17:47:40 +03:00
|
|
|
x = value;
|
2022-01-19 14:24:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
WINPR_ASSERT(cctx->ainput->AInputSendInputEvent);
|
|
|
|
rc = cctx->ainput->AInputSendInputEvent(cctx->ainput, flags, x, y);
|
|
|
|
if (rc == CHANNEL_RC_OK)
|
|
|
|
handled = TRUE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (!handled)
|
|
|
|
freerdp_input_send_mouse_event(cctx->context.input, mflags, 0, 0);
|
2022-01-21 17:53:10 +03:00
|
|
|
|
2022-01-19 14:24:45 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(CHANNEL_AINPUT_CLIENT)
|
|
|
|
static INLINE BOOL ainput_send_diff_event(rdpClientContext* cctx, UINT64 flags, INT32 x, INT32 y)
|
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
|
|
|
|
WINPR_ASSERT(cctx);
|
|
|
|
WINPR_ASSERT(cctx->ainput);
|
|
|
|
WINPR_ASSERT(cctx->ainput->AInputSendInputEvent);
|
|
|
|
|
|
|
|
rc = cctx->ainput->AInputSendInputEvent(cctx->ainput, flags, x, y);
|
|
|
|
|
|
|
|
return rc == CHANNEL_RC_OK;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
BOOL freerdp_client_send_button_event(rdpClientContext* cctx, BOOL relative, UINT16 mflags, INT32 x,
|
|
|
|
INT32 y)
|
|
|
|
{
|
|
|
|
BOOL handled = FALSE;
|
|
|
|
|
|
|
|
WINPR_ASSERT(cctx);
|
|
|
|
|
|
|
|
#if defined(CHANNEL_AINPUT_CLIENT)
|
|
|
|
if (cctx->ainput)
|
|
|
|
{
|
|
|
|
UINT64 flags = 0;
|
2022-01-26 16:21:53 +03:00
|
|
|
BOOL relativeInput =
|
|
|
|
freerdp_settings_get_bool(cctx->context.settings, FreeRDP_MouseUseRelativeMove);
|
|
|
|
|
|
|
|
if (cctx->mouse_grabbed && relativeInput)
|
|
|
|
flags |= AINPUT_FLAGS_HAVE_REL;
|
2022-01-19 14:24:45 +03:00
|
|
|
|
|
|
|
if (relative)
|
|
|
|
flags |= AINPUT_FLAGS_REL;
|
2022-01-26 16:21:53 +03:00
|
|
|
|
2022-01-19 14:24:45 +03:00
|
|
|
if (mflags & PTR_FLAGS_DOWN)
|
|
|
|
flags |= AINPUT_FLAGS_DOWN;
|
|
|
|
if (mflags & PTR_FLAGS_BUTTON1)
|
|
|
|
flags |= AINPUT_FLAGS_BUTTON1;
|
|
|
|
if (mflags & PTR_FLAGS_BUTTON2)
|
|
|
|
flags |= AINPUT_FLAGS_BUTTON2;
|
|
|
|
if (mflags & PTR_FLAGS_BUTTON3)
|
|
|
|
flags |= AINPUT_FLAGS_BUTTON3;
|
|
|
|
if (mflags & PTR_FLAGS_MOVE)
|
|
|
|
flags |= AINPUT_FLAGS_MOVE;
|
|
|
|
handled = ainput_send_diff_event(cctx, flags, x, y);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!handled)
|
|
|
|
{
|
2022-01-21 17:53:10 +03:00
|
|
|
if (relative)
|
|
|
|
{
|
|
|
|
cctx->lastX += x;
|
|
|
|
cctx->lastY += y;
|
2022-03-16 16:38:20 +03:00
|
|
|
WLog_WARN(TAG, "Relative mouse input channel not available, sending absolute!");
|
2022-01-21 17:53:10 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cctx->lastX = x;
|
|
|
|
cctx->lastY = y;
|
|
|
|
}
|
|
|
|
freerdp_input_send_mouse_event(cctx->context.input, mflags, (UINT16)cctx->lastX,
|
|
|
|
(UINT16)cctx->lastY);
|
2022-01-19 14:24:45 +03:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL freerdp_client_send_extended_button_event(rdpClientContext* cctx, BOOL relative, UINT16 mflags,
|
|
|
|
INT32 x, INT32 y)
|
|
|
|
{
|
2022-01-21 17:53:10 +03:00
|
|
|
BOOL handled = FALSE;
|
2022-01-19 14:24:45 +03:00
|
|
|
WINPR_ASSERT(cctx);
|
|
|
|
|
|
|
|
#if defined(CHANNEL_AINPUT_CLIENT)
|
|
|
|
if (cctx->ainput)
|
|
|
|
{
|
|
|
|
UINT64 flags = 0;
|
|
|
|
|
|
|
|
if (relative)
|
|
|
|
flags |= AINPUT_FLAGS_REL;
|
|
|
|
if (mflags & PTR_XFLAGS_DOWN)
|
|
|
|
flags |= AINPUT_FLAGS_DOWN;
|
|
|
|
if (mflags & PTR_XFLAGS_BUTTON1)
|
|
|
|
flags |= AINPUT_XFLAGS_BUTTON1;
|
|
|
|
if (mflags & PTR_XFLAGS_BUTTON2)
|
|
|
|
flags |= AINPUT_XFLAGS_BUTTON2;
|
|
|
|
|
2022-01-21 21:26:30 +03:00
|
|
|
handled = ainput_send_diff_event(cctx, flags, x, y);
|
2022-01-19 14:24:45 +03:00
|
|
|
}
|
|
|
|
#endif
|
2022-01-21 17:53:10 +03:00
|
|
|
|
|
|
|
if (!handled)
|
|
|
|
{
|
|
|
|
if (relative)
|
|
|
|
{
|
|
|
|
cctx->lastX += x;
|
|
|
|
cctx->lastY += y;
|
2022-03-16 16:38:20 +03:00
|
|
|
WLog_WARN(TAG, "Relative mouse input channel not available, sending absolute!");
|
2022-01-21 17:53:10 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cctx->lastX = x;
|
|
|
|
cctx->lastY = y;
|
|
|
|
}
|
|
|
|
freerdp_input_send_extended_mouse_event(cctx->context.input, mflags, (UINT16)cctx->lastX,
|
|
|
|
(UINT16)cctx->lastY);
|
|
|
|
}
|
2022-01-19 14:24:45 +03:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2022-12-30 21:07:46 +03:00
|
|
|
|
|
|
|
static BOOL freerdp_handle_touch_up(rdpClientContext* cctx, const FreeRDP_TouchContact* contact)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(cctx);
|
|
|
|
WINPR_ASSERT(contact);
|
|
|
|
|
|
|
|
#if defined(CHANNEL_RDPEI_CLIENT)
|
|
|
|
RdpeiClientContext* rdpei = cctx->rdpei;
|
|
|
|
|
|
|
|
if (!rdpei)
|
|
|
|
{
|
|
|
|
UINT16 flags = 0;
|
|
|
|
flags |= PTR_FLAGS_BUTTON1;
|
|
|
|
|
|
|
|
WINPR_ASSERT(contact->x <= UINT16_MAX);
|
|
|
|
WINPR_ASSERT(contact->y <= UINT16_MAX);
|
|
|
|
return freerdp_client_send_button_event(cctx, FALSE, flags, contact->x, contact->y);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int contactId;
|
|
|
|
|
|
|
|
if (rdpei->TouchRawEvent)
|
|
|
|
{
|
|
|
|
const UINT32 flags = RDPINPUT_CONTACT_FLAG_UP;
|
|
|
|
const UINT32 contactFlags = ((contact->flags & FREERDP_TOUCH_HAS_PRESSURE) != 0)
|
|
|
|
? CONTACT_DATA_PRESSURE_PRESENT
|
|
|
|
: 0;
|
|
|
|
rdpei->TouchRawEvent(rdpei, contact->id, contact->x, contact->y, &contactId, flags,
|
|
|
|
contactFlags, contact->pressure);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(rdpei->TouchEnd);
|
|
|
|
rdpei->TouchEnd(rdpei, contact->id, contact->x, contact->y, &contactId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
WLog_WARN(TAG, "Touch event detected but RDPEI support not compiled in. Recompile with "
|
|
|
|
"-DWITH_CHANNELS=ON");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL freerdp_handle_touch_down(rdpClientContext* cctx, const FreeRDP_TouchContact* contact)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(cctx);
|
|
|
|
WINPR_ASSERT(contact);
|
|
|
|
|
|
|
|
#if defined(CHANNEL_RDPEI_CLIENT)
|
|
|
|
RdpeiClientContext* rdpei = cctx->rdpei;
|
|
|
|
|
|
|
|
// Emulate mouse click if touch is not possible, like in login screen
|
|
|
|
if (!rdpei)
|
|
|
|
{
|
|
|
|
UINT16 flags = 0;
|
|
|
|
flags |= PTR_FLAGS_DOWN;
|
|
|
|
flags |= PTR_FLAGS_MOVE;
|
|
|
|
flags |= PTR_FLAGS_BUTTON1;
|
|
|
|
|
2022-12-30 13:25:28 +03:00
|
|
|
WINPR_ASSERT(contact->x <= UINT16_MAX);
|
|
|
|
WINPR_ASSERT(contact->y <= UINT16_MAX);
|
|
|
|
return freerdp_client_send_button_event(cctx, FALSE, flags, contact->x, contact->y);
|
2022-12-30 21:07:46 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int contactId;
|
|
|
|
|
|
|
|
if (rdpei->TouchRawEvent)
|
|
|
|
{
|
|
|
|
const UINT32 flags = RDPINPUT_CONTACT_FLAG_DOWN;
|
|
|
|
const UINT32 contactFlags = ((contact->flags & FREERDP_TOUCH_HAS_PRESSURE) != 0)
|
|
|
|
? CONTACT_DATA_PRESSURE_PRESENT
|
|
|
|
: 0;
|
|
|
|
rdpei->TouchRawEvent(rdpei, contact->id, contact->x, contact->y, &contactId, flags,
|
|
|
|
contactFlags, contact->pressure);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(rdpei->TouchBegin);
|
|
|
|
rdpei->TouchBegin(rdpei, contact->id, contact->x, contact->y, &contactId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
WLog_WARN(TAG, "Touch event detected but RDPEI support not compiled in. Recompile with "
|
|
|
|
"-DWITH_CHANNELS=ON");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL freerdp_handle_touch_motion(rdpClientContext* cctx, const FreeRDP_TouchContact* contact)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(cctx);
|
|
|
|
WINPR_ASSERT(contact);
|
|
|
|
|
|
|
|
#if defined(CHANNEL_RDPEI_CLIENT)
|
|
|
|
RdpeiClientContext* rdpei = cctx->rdpei;
|
|
|
|
|
|
|
|
if (!rdpei)
|
|
|
|
{
|
|
|
|
UINT16 flags = 0;
|
|
|
|
flags |= PTR_FLAGS_MOVE;
|
|
|
|
|
2022-12-30 13:25:28 +03:00
|
|
|
WINPR_ASSERT(contact->x <= UINT16_MAX);
|
|
|
|
WINPR_ASSERT(contact->y <= UINT16_MAX);
|
|
|
|
return freerdp_client_send_button_event(cctx, FALSE, flags, contact->x, contact->y);
|
2022-12-30 21:07:46 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int contactId;
|
|
|
|
|
|
|
|
if (rdpei->TouchRawEvent)
|
|
|
|
{
|
|
|
|
const UINT32 flags = RDPINPUT_CONTACT_FLAG_UPDATE;
|
|
|
|
const UINT32 contactFlags = ((contact->flags & FREERDP_TOUCH_HAS_PRESSURE) != 0)
|
|
|
|
? CONTACT_DATA_PRESSURE_PRESENT
|
|
|
|
: 0;
|
|
|
|
rdpei->TouchRawEvent(rdpei, contact->id, contact->x, contact->y, &contactId, flags,
|
|
|
|
contactFlags, contact->pressure);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(rdpei->TouchUpdate);
|
|
|
|
rdpei->TouchUpdate(rdpei, contact->id, contact->x, contact->y, &contactId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
WLog_WARN(TAG, "Touch event detected but RDPEI support not compiled in. Recompile with "
|
|
|
|
"-DWITH_CHANNELS=ON");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL freerdp_client_touch_update(rdpClientContext* cctx, UINT32 flags, INT32 touchId,
|
|
|
|
UINT32 pressure, INT32 x, INT32 y,
|
|
|
|
const FreeRDP_TouchContact** ppcontact)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(cctx);
|
|
|
|
WINPR_ASSERT(ppcontact);
|
|
|
|
|
|
|
|
for (size_t i = 0; i < ARRAYSIZE(cctx->contacts); i++)
|
|
|
|
{
|
|
|
|
FreeRDP_TouchContact* contact = &cctx->contacts[i];
|
|
|
|
|
|
|
|
if (contact->id == touchId)
|
|
|
|
{
|
2022-12-30 13:25:28 +03:00
|
|
|
*ppcontact = contact;
|
2022-12-30 21:07:46 +03:00
|
|
|
|
|
|
|
contact->flags = flags;
|
|
|
|
contact->pressure = pressure;
|
|
|
|
contact->x = x;
|
2022-12-30 13:25:28 +03:00
|
|
|
contact->y = y;
|
2022-12-30 21:07:46 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL freerdp_client_handle_touch(rdpClientContext* cctx, UINT32 flags, INT32 finger,
|
|
|
|
UINT32 pressure, INT32 x, INT32 y)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(cctx);
|
|
|
|
|
|
|
|
const FreeRDP_TouchContact* contact = NULL;
|
|
|
|
|
|
|
|
if (!freerdp_client_touch_update(cctx, flags, finger, pressure, x, y, &contact))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
switch (flags)
|
|
|
|
{
|
|
|
|
case FREERDP_TOUCH_DOWN:
|
|
|
|
return freerdp_handle_touch_down(cctx, contact);
|
|
|
|
case FREERDP_TOUCH_UP:
|
|
|
|
return freerdp_handle_touch_up(cctx, contact);
|
|
|
|
case FREERDP_TOUCH_MOTION:
|
|
|
|
return freerdp_handle_touch_motion(cctx, contact);
|
|
|
|
default:
|
|
|
|
WLog_WARN(TAG, "Unhandled FreeRDPTouchEventType %d, ignoring", flags);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-22 13:17:44 +03:00
|
|
|
BOOL freerdp_client_load_channels(freerdp* instance)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(instance);
|
|
|
|
WINPR_ASSERT(instance->context);
|
|
|
|
|
|
|
|
if (!freerdp_client_load_addins(instance->context->channels, instance->context->settings))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Failed to load addins [%l08X]", GetLastError());
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
2023-02-14 21:44:18 +03:00
|
|
|
|
|
|
|
int client_cli_logon_error_info(freerdp* instance, UINT32 data, UINT32 type)
|
|
|
|
{
|
|
|
|
const char* str_data = freerdp_get_logon_error_info_data(data);
|
|
|
|
const char* str_type = freerdp_get_logon_error_info_type(type);
|
|
|
|
|
|
|
|
if (!instance || !instance->context)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
WLog_INFO(TAG, "Logon Error Info %s [%s]", str_data, str_type);
|
|
|
|
return 1;
|
|
|
|
}
|