2012-11-18 09:08:03 +04:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
|
|
* Settings Management
|
|
|
|
*
|
|
|
|
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
2016-02-26 16:50:27 +03:00
|
|
|
* Copyright 2016 Armin Novak <armin.novak@gmail.com>
|
2012-11-18 09:08:03 +04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2020-04-11 12:55:11 +03:00
|
|
|
#include <errno.h>
|
2012-11-18 09:08:03 +04:00
|
|
|
|
2012-12-05 23:00:49 +04:00
|
|
|
#include <winpr/crt.h>
|
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
#include "../core/settings.h"
|
|
|
|
#include "../core/certificate.h"
|
2012-11-18 09:08:03 +04:00
|
|
|
#include <freerdp/settings.h>
|
2013-04-25 00:33:43 +04:00
|
|
|
#include <freerdp/freerdp.h>
|
2014-09-12 16:36:29 +04:00
|
|
|
#include <freerdp/log.h>
|
|
|
|
|
|
|
|
#define TAG FREERDP_TAG("common")
|
2012-11-18 09:08:03 +04:00
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
BOOL freerdp_addin_argv_add_argument_ex(ADDIN_ARGV* args, const char* argument, size_t len)
|
2012-12-05 23:00:49 +04:00
|
|
|
{
|
2021-04-12 11:38:40 +03:00
|
|
|
char* str;
|
2018-08-22 14:40:41 +03:00
|
|
|
char** new_argv;
|
2012-12-05 23:00:49 +04:00
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
if (!args || !argument)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (len == 0)
|
|
|
|
len = strlen(argument);
|
|
|
|
|
|
|
|
new_argv = (char**)realloc(args->argv, sizeof(char*) * (args->argc + 1));
|
|
|
|
|
|
|
|
if (!new_argv)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
args->argv = new_argv;
|
|
|
|
|
|
|
|
str = calloc(len + 1, sizeof(char));
|
|
|
|
if (!str)
|
|
|
|
return FALSE;
|
|
|
|
memcpy(str, argument, len);
|
|
|
|
args->argv[args->argc++] = str;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL freerdp_addin_argv_add_argument(ADDIN_ARGV* args, const char* argument)
|
|
|
|
{
|
|
|
|
return freerdp_addin_argv_add_argument_ex(args, argument, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL freerdp_addin_argv_del_argument(ADDIN_ARGV* args, const char* argument)
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
if (!args || !argument)
|
|
|
|
return FALSE;
|
|
|
|
for (x = 0; x < args->argc; x++)
|
|
|
|
{
|
|
|
|
char* arg = args->argv[x];
|
|
|
|
if (strcmp(argument, arg) == 0)
|
|
|
|
{
|
|
|
|
free(arg);
|
|
|
|
memmove_s(&args->argv[x], (args->argc - x) * sizeof(char*), &args->argv[x + 1],
|
|
|
|
(args->argc - x - 1) * sizeof(char*));
|
|
|
|
args->argv[args->argc - 1] = NULL;
|
|
|
|
args->argc--;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int freerdp_addin_set_argument(ADDIN_ARGV* args, const char* argument)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
if (!args || !argument)
|
|
|
|
return -2;
|
|
|
|
|
2012-12-05 23:00:49 +04:00
|
|
|
for (i = 0; i < args->argc; i++)
|
|
|
|
{
|
|
|
|
if (strcmp(args->argv[i], argument) == 0)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
if (!freerdp_addin_argv_add_argument(args, argument))
|
2015-03-11 08:52:24 +03:00
|
|
|
return -1;
|
2012-12-05 23:00:49 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
int freerdp_addin_replace_argument(ADDIN_ARGV* args, const char* previous, const char* argument)
|
2012-12-05 23:00:49 +04:00
|
|
|
{
|
|
|
|
int i;
|
2021-04-12 11:38:40 +03:00
|
|
|
|
|
|
|
if (!args || !previous || !argument)
|
|
|
|
return -2;
|
2012-12-05 23:00:49 +04:00
|
|
|
|
|
|
|
for (i = 0; i < args->argc; i++)
|
|
|
|
{
|
|
|
|
if (strcmp(args->argv[i], previous) == 0)
|
|
|
|
{
|
|
|
|
free(args->argv[i]);
|
2018-08-22 14:40:41 +03:00
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
if (!(args->argv[i] = _strdup(argument)))
|
|
|
|
return -1;
|
2012-12-05 23:00:49 +04:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
if (!freerdp_addin_argv_add_argument(args, argument))
|
2015-06-17 23:08:02 +03:00
|
|
|
return -1;
|
2012-12-05 23:00:49 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
int freerdp_addin_set_argument_value(ADDIN_ARGV* args, const char* option, const char* value)
|
2012-12-05 23:00:49 +04:00
|
|
|
{
|
2021-04-12 11:38:40 +03:00
|
|
|
BOOL rc;
|
2012-12-05 23:00:49 +04:00
|
|
|
int i;
|
|
|
|
char* p;
|
|
|
|
char* str;
|
2019-10-29 12:18:09 +03:00
|
|
|
size_t length;
|
2021-04-12 11:38:40 +03:00
|
|
|
if (!args || !option || !value)
|
|
|
|
return -2;
|
2012-12-05 23:00:49 +04:00
|
|
|
length = strlen(option) + strlen(value) + 1;
|
2021-04-12 11:38:40 +03:00
|
|
|
str = (char*)calloc(length + 1, sizeof(char));
|
2018-08-22 14:40:41 +03:00
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
if (!str)
|
|
|
|
return -1;
|
2018-08-22 14:40:41 +03:00
|
|
|
|
2012-12-05 23:00:49 +04:00
|
|
|
sprintf_s(str, length + 1, "%s:%s", option, value);
|
|
|
|
|
|
|
|
for (i = 0; i < args->argc; i++)
|
|
|
|
{
|
|
|
|
p = strchr(args->argv[i], ':');
|
|
|
|
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
if (strncmp(args->argv[i], option, p - args->argv[i]) == 0)
|
|
|
|
{
|
|
|
|
free(args->argv[i]);
|
|
|
|
args->argv[i] = str;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
rc = freerdp_addin_argv_add_argument(args, str);
|
|
|
|
free(str);
|
|
|
|
if (!rc)
|
2015-03-11 08:52:24 +03:00
|
|
|
return -1;
|
2012-12-05 23:00:49 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
int freerdp_addin_replace_argument_value(ADDIN_ARGV* args, const char* previous, const char* option,
|
|
|
|
const char* value)
|
2012-12-05 23:00:49 +04:00
|
|
|
{
|
|
|
|
int i;
|
2021-04-12 11:38:40 +03:00
|
|
|
BOOL rc;
|
2012-12-05 23:00:49 +04:00
|
|
|
char* str;
|
2019-10-29 12:18:09 +03:00
|
|
|
size_t length;
|
2021-04-12 11:38:40 +03:00
|
|
|
if (!args || !previous || !option || !value)
|
|
|
|
return -2;
|
2012-12-05 23:00:49 +04:00
|
|
|
length = strlen(option) + strlen(value) + 1;
|
2021-04-12 11:38:40 +03:00
|
|
|
str = (char*)calloc(length + 1, sizeof(char));
|
2018-08-22 14:40:41 +03:00
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
if (!str)
|
|
|
|
return -1;
|
2018-08-22 14:40:41 +03:00
|
|
|
|
2012-12-05 23:00:49 +04:00
|
|
|
sprintf_s(str, length + 1, "%s:%s", option, value);
|
|
|
|
|
|
|
|
for (i = 0; i < args->argc; i++)
|
|
|
|
{
|
|
|
|
if (strcmp(args->argv[i], previous) == 0)
|
|
|
|
{
|
|
|
|
free(args->argv[i]);
|
|
|
|
args->argv[i] = str;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
rc = freerdp_addin_argv_add_argument(args, str);
|
|
|
|
free(str);
|
|
|
|
if (!rc)
|
2015-03-11 08:52:24 +03:00
|
|
|
return -1;
|
2012-12-05 23:00:49 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
BOOL freerdp_device_collection_add(rdpSettings* settings, RDPDR_DEVICE* device)
|
2012-11-18 09:08:03 +04:00
|
|
|
{
|
2015-03-10 15:10:39 +03:00
|
|
|
if (!settings->DeviceArray)
|
2015-06-18 14:00:10 +03:00
|
|
|
return FALSE;
|
2015-03-10 15:10:39 +03:00
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
if (freerdp_settings_get_uint32(settings, FreeRDP_DeviceArraySize) <
|
|
|
|
(settings->DeviceCount + 1))
|
2012-11-18 09:08:03 +04:00
|
|
|
{
|
2015-03-11 08:52:24 +03:00
|
|
|
UINT32 new_size;
|
2018-08-22 14:40:41 +03:00
|
|
|
RDPDR_DEVICE** new_array;
|
2020-11-19 12:09:34 +03:00
|
|
|
new_size = freerdp_settings_get_uint32(settings, FreeRDP_DeviceArraySize) * 2;
|
2019-11-06 17:24:51 +03:00
|
|
|
new_array =
|
|
|
|
(RDPDR_DEVICE**)realloc(settings->DeviceArray, new_size * sizeof(RDPDR_DEVICE*));
|
2018-08-22 14:40:41 +03:00
|
|
|
|
2015-03-11 08:52:24 +03:00
|
|
|
if (!new_array)
|
2015-06-18 14:00:10 +03:00
|
|
|
return FALSE;
|
2018-08-22 14:40:41 +03:00
|
|
|
|
2015-03-11 08:52:24 +03:00
|
|
|
settings->DeviceArray = new_array;
|
2020-11-19 12:09:34 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DeviceArraySize, new_size))
|
|
|
|
return FALSE;
|
2012-11-18 09:08:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
settings->DeviceArray[settings->DeviceCount++] = device;
|
2015-06-18 14:00:10 +03:00
|
|
|
return TRUE;
|
2012-11-18 09:08:03 +04:00
|
|
|
}
|
|
|
|
|
2013-02-15 04:38:45 +04:00
|
|
|
RDPDR_DEVICE* freerdp_device_collection_find(rdpSettings* settings, const char* name)
|
|
|
|
{
|
2014-02-11 07:12:13 +04:00
|
|
|
UINT32 index;
|
2013-02-15 04:38:45 +04:00
|
|
|
RDPDR_DEVICE* device;
|
|
|
|
|
|
|
|
for (index = 0; index < settings->DeviceCount; index++)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
device = (RDPDR_DEVICE*)settings->DeviceArray[index];
|
2013-02-15 04:38:45 +04:00
|
|
|
|
2014-03-26 19:05:12 +04:00
|
|
|
if (!device->Name)
|
2013-09-06 14:35:33 +04:00
|
|
|
continue;
|
|
|
|
|
2013-02-15 04:38:45 +04:00
|
|
|
if (strcmp(device->Name, name) == 0)
|
|
|
|
return device;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-02-26 16:50:27 +03:00
|
|
|
RDPDR_DEVICE* freerdp_device_collection_find_type(rdpSettings* settings, UINT32 type)
|
|
|
|
{
|
|
|
|
UINT32 index;
|
|
|
|
RDPDR_DEVICE* device;
|
|
|
|
|
|
|
|
for (index = 0; index < settings->DeviceCount; index++)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
device = (RDPDR_DEVICE*)settings->DeviceArray[index];
|
2016-02-26 16:50:27 +03:00
|
|
|
|
|
|
|
if (device->Type == type)
|
|
|
|
return device;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-10-19 06:42:50 +04:00
|
|
|
RDPDR_DEVICE* freerdp_device_clone(RDPDR_DEVICE* device)
|
|
|
|
{
|
|
|
|
if (device->Type == RDPDR_DTYP_FILESYSTEM)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
RDPDR_DRIVE* drive = (RDPDR_DRIVE*)device;
|
|
|
|
RDPDR_DRIVE* _drive = (RDPDR_DRIVE*)calloc(1, sizeof(RDPDR_DRIVE));
|
2014-03-26 19:05:12 +04:00
|
|
|
|
2014-03-26 02:13:08 +04:00
|
|
|
if (!_drive)
|
|
|
|
return NULL;
|
2013-10-19 06:42:50 +04:00
|
|
|
|
|
|
|
_drive->Id = drive->Id;
|
|
|
|
_drive->Type = drive->Type;
|
|
|
|
_drive->Name = _strdup(drive->Name);
|
2018-08-22 14:40:41 +03:00
|
|
|
|
2014-03-26 02:13:08 +04:00
|
|
|
if (!_drive->Name)
|
|
|
|
goto out_fs_name_error;
|
2014-03-26 19:05:12 +04:00
|
|
|
|
2013-10-19 06:42:50 +04:00
|
|
|
_drive->Path = _strdup(drive->Path);
|
2018-08-22 14:40:41 +03:00
|
|
|
|
2014-03-26 02:13:08 +04:00
|
|
|
if (!_drive->Path)
|
|
|
|
goto out_fs_path_error;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
return (RDPDR_DEVICE*)_drive;
|
2018-08-22 14:40:41 +03:00
|
|
|
out_fs_path_error:
|
2014-03-26 02:13:08 +04:00
|
|
|
free(_drive->Name);
|
2018-08-22 14:40:41 +03:00
|
|
|
out_fs_name_error:
|
2014-03-26 02:13:08 +04:00
|
|
|
free(_drive);
|
|
|
|
return NULL;
|
2013-10-19 06:42:50 +04:00
|
|
|
}
|
2014-03-26 02:13:08 +04:00
|
|
|
|
|
|
|
if (device->Type == RDPDR_DTYP_PRINT)
|
2013-10-19 06:42:50 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
RDPDR_PRINTER* printer = (RDPDR_PRINTER*)device;
|
|
|
|
RDPDR_PRINTER* _printer = (RDPDR_PRINTER*)calloc(1, sizeof(RDPDR_PRINTER));
|
2014-03-26 19:05:12 +04:00
|
|
|
|
2014-03-26 02:13:08 +04:00
|
|
|
if (!_printer)
|
|
|
|
return NULL;
|
2013-10-19 06:42:50 +04:00
|
|
|
|
|
|
|
_printer->Id = printer->Id;
|
|
|
|
_printer->Type = printer->Type;
|
2014-03-26 19:05:12 +04:00
|
|
|
|
|
|
|
if (printer->Name)
|
|
|
|
{
|
|
|
|
_printer->Name = _strdup(printer->Name);
|
2018-08-22 14:40:41 +03:00
|
|
|
|
2014-03-26 19:05:12 +04:00
|
|
|
if (!_printer->Name)
|
|
|
|
goto out_print_name_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (printer->DriverName)
|
|
|
|
{
|
|
|
|
_printer->DriverName = _strdup(printer->DriverName);
|
2018-08-22 14:40:41 +03:00
|
|
|
|
2014-03-26 19:05:12 +04:00
|
|
|
if (!_printer->DriverName)
|
|
|
|
goto out_print_path_error;
|
|
|
|
}
|
2014-03-26 02:13:08 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
return (RDPDR_DEVICE*)_printer;
|
2018-08-22 14:40:41 +03:00
|
|
|
out_print_path_error:
|
2014-03-26 02:13:08 +04:00
|
|
|
free(_printer->Name);
|
2018-08-22 14:40:41 +03:00
|
|
|
out_print_name_error:
|
2014-03-26 02:13:08 +04:00
|
|
|
free(_printer);
|
|
|
|
return NULL;
|
2013-10-19 06:42:50 +04:00
|
|
|
}
|
2014-03-26 02:13:08 +04:00
|
|
|
|
|
|
|
if (device->Type == RDPDR_DTYP_SMARTCARD)
|
2013-10-19 06:42:50 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
RDPDR_SMARTCARD* smartcard = (RDPDR_SMARTCARD*)device;
|
|
|
|
RDPDR_SMARTCARD* _smartcard = (RDPDR_SMARTCARD*)calloc(1, sizeof(RDPDR_SMARTCARD));
|
2014-03-26 19:05:12 +04:00
|
|
|
|
2014-03-26 02:13:08 +04:00
|
|
|
if (!_smartcard)
|
|
|
|
return NULL;
|
2013-10-19 06:42:50 +04:00
|
|
|
|
|
|
|
_smartcard->Id = smartcard->Id;
|
|
|
|
_smartcard->Type = smartcard->Type;
|
2014-03-26 19:05:12 +04:00
|
|
|
|
|
|
|
if (smartcard->Name)
|
|
|
|
{
|
|
|
|
_smartcard->Name = _strdup(smartcard->Name);
|
2018-08-22 14:40:41 +03:00
|
|
|
|
2014-03-26 19:05:12 +04:00
|
|
|
if (!_smartcard->Name)
|
|
|
|
goto out_smartc_name_error;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
return (RDPDR_DEVICE*)_smartcard;
|
2018-08-22 14:40:41 +03:00
|
|
|
out_smartc_name_error:
|
2014-03-26 02:13:08 +04:00
|
|
|
free(_smartcard);
|
|
|
|
return NULL;
|
2013-10-19 06:42:50 +04:00
|
|
|
}
|
2014-03-26 02:13:08 +04:00
|
|
|
|
|
|
|
if (device->Type == RDPDR_DTYP_SERIAL)
|
2013-10-19 06:42:50 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
RDPDR_SERIAL* serial = (RDPDR_SERIAL*)device;
|
|
|
|
RDPDR_SERIAL* _serial = (RDPDR_SERIAL*)calloc(1, sizeof(RDPDR_SERIAL));
|
2014-03-26 19:05:12 +04:00
|
|
|
|
2014-03-26 02:13:08 +04:00
|
|
|
if (!_serial)
|
|
|
|
return NULL;
|
2013-10-19 06:42:50 +04:00
|
|
|
|
|
|
|
_serial->Id = serial->Id;
|
|
|
|
_serial->Type = serial->Type;
|
2014-03-26 19:05:12 +04:00
|
|
|
|
|
|
|
if (serial->Name)
|
|
|
|
{
|
|
|
|
_serial->Name = _strdup(serial->Name);
|
2018-08-22 14:40:41 +03:00
|
|
|
|
2014-03-26 19:05:12 +04:00
|
|
|
if (!_serial->Name)
|
|
|
|
goto out_serial_name_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (serial->Path)
|
|
|
|
{
|
|
|
|
_serial->Path = _strdup(serial->Path);
|
2018-08-22 14:40:41 +03:00
|
|
|
|
2014-03-26 19:05:12 +04:00
|
|
|
if (!_serial->Path)
|
|
|
|
goto out_serial_path_error;
|
|
|
|
}
|
2014-03-26 02:13:08 +04:00
|
|
|
|
2014-06-18 20:20:21 +04:00
|
|
|
if (serial->Driver)
|
|
|
|
{
|
|
|
|
_serial->Driver = _strdup(serial->Driver);
|
2018-08-22 14:40:41 +03:00
|
|
|
|
2014-06-18 20:20:21 +04:00
|
|
|
if (!_serial->Driver)
|
|
|
|
goto out_serial_driver_error;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
return (RDPDR_DEVICE*)_serial;
|
2018-08-22 14:40:41 +03:00
|
|
|
out_serial_driver_error:
|
2014-06-18 20:20:21 +04:00
|
|
|
free(_serial->Path);
|
2018-08-22 14:40:41 +03:00
|
|
|
out_serial_path_error:
|
2014-03-26 02:13:08 +04:00
|
|
|
free(_serial->Name);
|
2018-08-22 14:40:41 +03:00
|
|
|
out_serial_name_error:
|
2014-03-26 02:13:08 +04:00
|
|
|
free(_serial);
|
|
|
|
return NULL;
|
2013-10-19 06:42:50 +04:00
|
|
|
}
|
2014-03-26 02:13:08 +04:00
|
|
|
|
|
|
|
if (device->Type == RDPDR_DTYP_PARALLEL)
|
2013-10-19 06:42:50 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
RDPDR_PARALLEL* parallel = (RDPDR_PARALLEL*)device;
|
|
|
|
RDPDR_PARALLEL* _parallel = (RDPDR_PARALLEL*)calloc(1, sizeof(RDPDR_PARALLEL));
|
2014-03-26 19:05:12 +04:00
|
|
|
|
2014-03-26 02:13:08 +04:00
|
|
|
if (!_parallel)
|
|
|
|
return NULL;
|
2013-10-19 06:42:50 +04:00
|
|
|
|
|
|
|
_parallel->Id = parallel->Id;
|
|
|
|
_parallel->Type = parallel->Type;
|
2014-03-26 19:05:12 +04:00
|
|
|
|
|
|
|
if (parallel->Name)
|
|
|
|
{
|
|
|
|
_parallel->Name = _strdup(parallel->Name);
|
2018-08-22 14:40:41 +03:00
|
|
|
|
2014-03-26 19:05:12 +04:00
|
|
|
if (!_parallel->Name)
|
|
|
|
goto out_parallel_name_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parallel->Path)
|
|
|
|
{
|
|
|
|
_parallel->Path = _strdup(parallel->Path);
|
2018-08-22 14:40:41 +03:00
|
|
|
|
2014-03-26 19:05:12 +04:00
|
|
|
if (!_parallel->Path)
|
|
|
|
goto out_parallel_path_error;
|
|
|
|
}
|
2014-03-26 02:13:08 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
return (RDPDR_DEVICE*)_parallel;
|
2018-08-22 14:40:41 +03:00
|
|
|
out_parallel_path_error:
|
2014-03-26 02:13:08 +04:00
|
|
|
free(_parallel->Name);
|
2018-08-22 14:40:41 +03:00
|
|
|
out_parallel_name_error:
|
2014-03-26 02:13:08 +04:00
|
|
|
free(_parallel);
|
|
|
|
return NULL;
|
2013-10-19 06:42:50 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG, "unknown device type %" PRIu32 "", device->Type);
|
2014-03-26 02:13:08 +04:00
|
|
|
return NULL;
|
2013-10-19 06:42:50 +04:00
|
|
|
}
|
|
|
|
|
2012-11-19 22:26:56 +04:00
|
|
|
void freerdp_device_collection_free(rdpSettings* settings)
|
|
|
|
{
|
2014-02-11 07:12:13 +04:00
|
|
|
UINT32 index;
|
2012-11-19 22:26:56 +04:00
|
|
|
RDPDR_DEVICE* device;
|
|
|
|
|
|
|
|
for (index = 0; index < settings->DeviceCount; index++)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
device = (RDPDR_DEVICE*)settings->DeviceArray[index];
|
2012-11-19 22:26:56 +04:00
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
if (!device)
|
|
|
|
continue;
|
|
|
|
|
2012-11-19 22:26:56 +04:00
|
|
|
free(device->Name);
|
|
|
|
|
|
|
|
if (settings->DeviceArray[index]->Type == RDPDR_DTYP_FILESYSTEM)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
free(((RDPDR_DRIVE*)device)->Path);
|
2012-11-19 22:26:56 +04:00
|
|
|
}
|
|
|
|
else if (settings->DeviceArray[index]->Type == RDPDR_DTYP_PRINT)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
else if (settings->DeviceArray[index]->Type == RDPDR_DTYP_SMARTCARD)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
else if (settings->DeviceArray[index]->Type == RDPDR_DTYP_SERIAL)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
free(((RDPDR_SERIAL*)device)->Path);
|
|
|
|
free(((RDPDR_SERIAL*)device)->Driver);
|
2012-11-19 22:26:56 +04:00
|
|
|
}
|
|
|
|
else if (settings->DeviceArray[index]->Type == RDPDR_DTYP_PARALLEL)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
free(((RDPDR_PARALLEL*)device)->Path);
|
2012-11-19 22:26:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
free(device);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(settings->DeviceArray);
|
2020-11-19 12:09:34 +03:00
|
|
|
freerdp_settings_set_uint32(settings, FreeRDP_DeviceArraySize, 0);
|
2012-11-19 22:26:56 +04:00
|
|
|
settings->DeviceArray = NULL;
|
|
|
|
settings->DeviceCount = 0;
|
|
|
|
}
|
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
BOOL freerdp_static_channel_collection_del(rdpSettings* settings, const char* name)
|
|
|
|
{
|
|
|
|
UINT32 x;
|
|
|
|
const UINT32 count = freerdp_settings_get_uint32(settings, FreeRDP_StaticChannelCount);
|
|
|
|
if (!settings || !settings->StaticChannelArray)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
for (x = 0; x < count; x++)
|
|
|
|
{
|
|
|
|
ADDIN_ARGV* cur = settings->StaticChannelArray[x];
|
|
|
|
if (cur && (cur->argc > 0))
|
|
|
|
{
|
|
|
|
if (strcmp(name, cur->argv[0]) == 0)
|
|
|
|
{
|
|
|
|
memmove_s(&settings->StaticChannelArray[x], (count - x) * sizeof(ADDIN_ARGV*),
|
|
|
|
&settings->StaticChannelArray[x + 1],
|
|
|
|
(count - x - 1) * sizeof(ADDIN_ARGV*));
|
|
|
|
return freerdp_settings_set_uint32(settings, FreeRDP_StaticChannelCount, count - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
BOOL freerdp_static_channel_collection_add(rdpSettings* settings, ADDIN_ARGV* channel)
|
2012-11-18 09:08:03 +04:00
|
|
|
{
|
2020-11-19 12:09:34 +03:00
|
|
|
UINT32 count;
|
2015-03-10 15:10:39 +03:00
|
|
|
if (!settings->StaticChannelArray)
|
2015-06-16 16:42:07 +03:00
|
|
|
return FALSE;
|
2015-03-10 15:10:39 +03:00
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
if (freerdp_settings_get_uint32(settings, FreeRDP_StaticChannelArraySize) <
|
|
|
|
(freerdp_settings_get_uint32(settings, FreeRDP_StaticChannelCount) + 1))
|
2012-11-18 09:08:03 +04:00
|
|
|
{
|
2015-03-11 08:52:24 +03:00
|
|
|
UINT32 new_size;
|
2018-08-22 14:40:41 +03:00
|
|
|
ADDIN_ARGV** new_array;
|
2020-11-19 12:09:34 +03:00
|
|
|
new_size = freerdp_settings_get_uint32(settings, FreeRDP_StaticChannelArraySize) * 2;
|
2019-11-06 17:24:51 +03:00
|
|
|
new_array =
|
|
|
|
(ADDIN_ARGV**)realloc(settings->StaticChannelArray, new_size * sizeof(ADDIN_ARGV*));
|
2018-08-22 14:40:41 +03:00
|
|
|
|
2015-03-11 08:52:24 +03:00
|
|
|
if (!new_array)
|
2015-06-16 16:42:07 +03:00
|
|
|
return FALSE;
|
2018-08-22 14:40:41 +03:00
|
|
|
|
2015-03-11 08:52:24 +03:00
|
|
|
settings->StaticChannelArray = new_array;
|
2020-11-19 12:09:34 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_StaticChannelArraySize, new_size))
|
|
|
|
return FALSE;
|
2012-11-18 09:08:03 +04:00
|
|
|
}
|
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
count = freerdp_settings_get_uint32(settings, FreeRDP_StaticChannelCount);
|
|
|
|
settings->StaticChannelArray[count++] = channel;
|
|
|
|
return freerdp_settings_set_uint32(settings, FreeRDP_StaticChannelCount, count);
|
2012-11-18 09:08:03 +04:00
|
|
|
}
|
|
|
|
|
2012-11-21 18:30:06 +04:00
|
|
|
ADDIN_ARGV* freerdp_static_channel_collection_find(rdpSettings* settings, const char* name)
|
|
|
|
{
|
2014-02-11 07:12:13 +04:00
|
|
|
UINT32 index;
|
2012-11-21 18:30:06 +04:00
|
|
|
ADDIN_ARGV* channel;
|
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
for (index = 0; index < freerdp_settings_get_uint32(settings, FreeRDP_StaticChannelCount);
|
|
|
|
index++)
|
2012-11-21 18:30:06 +04:00
|
|
|
{
|
|
|
|
channel = settings->StaticChannelArray[index];
|
|
|
|
|
|
|
|
if (strcmp(channel->argv[0], name) == 0)
|
|
|
|
return channel;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-11-19 22:26:56 +04:00
|
|
|
void freerdp_static_channel_collection_free(rdpSettings* settings)
|
|
|
|
{
|
2014-02-11 07:12:13 +04:00
|
|
|
UINT32 i;
|
2012-11-19 22:26:56 +04:00
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
for (i = 0; i < freerdp_settings_get_uint32(settings, FreeRDP_StaticChannelCount); i++)
|
2012-11-19 22:26:56 +04:00
|
|
|
{
|
2021-04-12 11:38:40 +03:00
|
|
|
freerdp_addin_argv_free(settings->StaticChannelArray[i]);
|
2012-11-19 22:26:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
free(settings->StaticChannelArray);
|
2020-11-19 12:09:34 +03:00
|
|
|
freerdp_settings_set_uint32(settings, FreeRDP_StaticChannelArraySize, 0);
|
2012-11-19 22:26:56 +04:00
|
|
|
settings->StaticChannelArray = NULL;
|
2020-11-19 12:09:34 +03:00
|
|
|
freerdp_settings_set_uint32(settings, FreeRDP_StaticChannelCount, 0);
|
2012-11-19 22:26:56 +04:00
|
|
|
}
|
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
BOOL freerdp_dynamic_channel_collection_del(rdpSettings* settings, const char* name)
|
|
|
|
{
|
|
|
|
UINT32 x;
|
|
|
|
const UINT32 count = freerdp_settings_get_uint32(settings, FreeRDP_DynamicChannelCount);
|
|
|
|
if (!settings || !settings->DynamicChannelArray)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
for (x = 0; x < count; x++)
|
|
|
|
{
|
|
|
|
ADDIN_ARGV* cur = settings->DynamicChannelArray[x];
|
|
|
|
if (cur && (cur->argc > 0))
|
|
|
|
{
|
|
|
|
if (strcmp(name, cur->argv[0]))
|
|
|
|
{
|
|
|
|
memmove_s(&settings->DynamicChannelArray[x], (count - x) * sizeof(ADDIN_ARGV*),
|
|
|
|
&settings->DynamicChannelArray[x + 1],
|
|
|
|
(count - x - 1) * sizeof(ADDIN_ARGV*));
|
|
|
|
return freerdp_settings_set_uint32(settings, FreeRDP_DynamicChannelCount,
|
|
|
|
count - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
BOOL freerdp_dynamic_channel_collection_add(rdpSettings* settings, ADDIN_ARGV* channel)
|
2012-11-18 09:08:03 +04:00
|
|
|
{
|
2020-11-19 12:09:34 +03:00
|
|
|
UINT32 count;
|
2015-03-10 15:10:39 +03:00
|
|
|
if (!settings->DynamicChannelArray)
|
2015-06-16 16:42:07 +03:00
|
|
|
return FALSE;
|
2015-03-10 15:10:39 +03:00
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
if (freerdp_settings_get_uint32(settings, FreeRDP_DynamicChannelArraySize) <
|
|
|
|
(freerdp_settings_get_uint32(settings, FreeRDP_DynamicChannelCount) + 1))
|
2012-11-18 09:08:03 +04:00
|
|
|
{
|
2018-08-22 14:40:41 +03:00
|
|
|
ADDIN_ARGV** new_array;
|
2020-11-19 12:09:34 +03:00
|
|
|
const size_t size =
|
|
|
|
freerdp_settings_get_uint32(settings, FreeRDP_DynamicChannelArraySize) * 2;
|
|
|
|
new_array = realloc(settings->DynamicChannelArray, sizeof(ADDIN_ARGV*) * size);
|
2015-03-13 14:17:22 +03:00
|
|
|
|
2015-03-11 08:52:24 +03:00
|
|
|
if (!new_array)
|
2015-06-16 16:42:07 +03:00
|
|
|
return FALSE;
|
|
|
|
|
2015-03-11 08:52:24 +03:00
|
|
|
settings->DynamicChannelArray = new_array;
|
2020-11-19 12:09:34 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DynamicChannelArraySize, size))
|
|
|
|
return FALSE;
|
2012-11-18 09:08:03 +04:00
|
|
|
}
|
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
count = freerdp_settings_get_uint32(settings, FreeRDP_DynamicChannelCount);
|
|
|
|
settings->DynamicChannelArray[count++] = channel;
|
|
|
|
return freerdp_settings_set_uint32(settings, FreeRDP_DynamicChannelCount, count);
|
2012-11-18 09:08:03 +04:00
|
|
|
}
|
2012-11-19 22:26:56 +04:00
|
|
|
|
2012-11-21 18:30:06 +04:00
|
|
|
ADDIN_ARGV* freerdp_dynamic_channel_collection_find(rdpSettings* settings, const char* name)
|
|
|
|
{
|
2014-02-11 07:12:13 +04:00
|
|
|
UINT32 index;
|
2012-11-21 18:30:06 +04:00
|
|
|
ADDIN_ARGV* channel;
|
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
for (index = 0; index < freerdp_settings_get_uint32(settings, FreeRDP_DynamicChannelCount);
|
|
|
|
index++)
|
2012-11-21 18:30:06 +04:00
|
|
|
{
|
|
|
|
channel = settings->DynamicChannelArray[index];
|
|
|
|
|
|
|
|
if (strcmp(channel->argv[0], name) == 0)
|
|
|
|
return channel;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
void freerdp_addin_argv_free(ADDIN_ARGV* args)
|
2013-10-19 06:42:50 +04:00
|
|
|
{
|
|
|
|
int index;
|
2021-04-12 11:38:40 +03:00
|
|
|
if (!args)
|
|
|
|
return;
|
2015-02-07 01:35:14 +03:00
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
if (args->argv)
|
|
|
|
{
|
|
|
|
for (index = 0; index < args->argc; index++)
|
|
|
|
free(args->argv[index]);
|
|
|
|
free(args->argv);
|
|
|
|
}
|
2013-10-19 06:42:50 +04:00
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
free(args);
|
|
|
|
}
|
2015-02-07 01:35:14 +03:00
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
ADDIN_ARGV* freerdp_addin_argv_new(size_t argc, const char* argv[])
|
|
|
|
{
|
|
|
|
ADDIN_ARGV* args = calloc(1, sizeof(ADDIN_ARGV));
|
|
|
|
if (!args)
|
|
|
|
return NULL;
|
|
|
|
if (argc == 0)
|
|
|
|
return args;
|
2013-10-19 06:42:50 +04:00
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
args->argc = argc;
|
|
|
|
args->argv = calloc(argc, sizeof(char*));
|
|
|
|
if (!args->argv)
|
|
|
|
goto fail;
|
2015-02-07 01:35:14 +03:00
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
if (argv)
|
|
|
|
{
|
|
|
|
size_t x;
|
|
|
|
for (x = 0; x < argc; x++)
|
|
|
|
{
|
|
|
|
args->argv[x] = _strdup(argv[x]);
|
|
|
|
if (!args->argv[x])
|
|
|
|
goto fail;
|
|
|
|
}
|
2013-10-19 06:42:50 +04:00
|
|
|
}
|
2021-04-12 11:38:40 +03:00
|
|
|
return args;
|
2013-10-19 06:42:50 +04:00
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
fail:
|
|
|
|
freerdp_addin_argv_free(args);
|
2014-03-26 02:13:08 +04:00
|
|
|
return NULL;
|
2013-10-19 06:42:50 +04:00
|
|
|
}
|
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
ADDIN_ARGV* freerdp_addin_argv_clone(const ADDIN_ARGV* args)
|
|
|
|
{
|
|
|
|
if (!args)
|
|
|
|
return NULL;
|
|
|
|
return freerdp_addin_argv_new(args->argc, (const char**)args->argv);
|
|
|
|
}
|
|
|
|
|
2012-11-19 22:26:56 +04:00
|
|
|
void freerdp_dynamic_channel_collection_free(rdpSettings* settings)
|
|
|
|
{
|
2014-06-20 21:52:13 +04:00
|
|
|
UINT32 i;
|
2012-11-19 22:26:56 +04:00
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
for (i = 0; i < freerdp_settings_get_uint32(settings, FreeRDP_DynamicChannelCount); i++)
|
2012-11-19 22:26:56 +04:00
|
|
|
{
|
2021-04-12 11:38:40 +03:00
|
|
|
freerdp_addin_argv_free(settings->DynamicChannelArray[i]);
|
2012-11-19 22:26:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
free(settings->DynamicChannelArray);
|
2020-11-19 12:09:34 +03:00
|
|
|
freerdp_settings_set_uint32(settings, FreeRDP_DynamicChannelArraySize, 0);
|
2012-11-19 22:26:56 +04:00
|
|
|
settings->DynamicChannelArray = NULL;
|
2020-11-19 12:09:34 +03:00
|
|
|
freerdp_settings_set_uint32(settings, FreeRDP_DynamicChannelCount, 0);
|
2012-11-19 22:26:56 +04:00
|
|
|
}
|
2013-03-20 23:33:33 +04:00
|
|
|
|
2013-11-04 01:25:56 +04:00
|
|
|
void freerdp_target_net_addresses_free(rdpSettings* settings)
|
|
|
|
{
|
|
|
|
UINT32 index;
|
|
|
|
|
|
|
|
for (index = 0; index < settings->TargetNetAddressCount; index++)
|
|
|
|
free(settings->TargetNetAddresses[index]);
|
|
|
|
|
|
|
|
free(settings->TargetNetAddresses);
|
2015-05-06 23:32:45 +03:00
|
|
|
free(settings->TargetNetPorts);
|
2013-11-04 01:25:56 +04:00
|
|
|
settings->TargetNetAddressCount = 0;
|
|
|
|
settings->TargetNetAddresses = NULL;
|
2015-05-06 23:32:45 +03:00
|
|
|
settings->TargetNetPorts = NULL;
|
2013-11-04 01:25:56 +04:00
|
|
|
}
|
|
|
|
|
2013-09-17 22:56:23 +04:00
|
|
|
void freerdp_performance_flags_make(rdpSettings* settings)
|
|
|
|
{
|
2020-11-19 12:09:34 +03:00
|
|
|
UINT32 PerformanceFlags = PERF_FLAG_NONE;
|
2013-09-17 22:56:23 +04:00
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_AllowFontSmoothing))
|
|
|
|
PerformanceFlags |= PERF_ENABLE_FONT_SMOOTHING;
|
2013-09-17 22:56:23 +04:00
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_AllowDesktopComposition))
|
|
|
|
PerformanceFlags |= PERF_ENABLE_DESKTOP_COMPOSITION;
|
2013-09-17 22:56:23 +04:00
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_DisableWallpaper))
|
|
|
|
PerformanceFlags |= PERF_DISABLE_WALLPAPER;
|
2013-09-17 22:56:23 +04:00
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_DisableFullWindowDrag))
|
|
|
|
PerformanceFlags |= PERF_DISABLE_FULLWINDOWDRAG;
|
2013-09-17 22:56:23 +04:00
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_DisableMenuAnims))
|
|
|
|
PerformanceFlags |= PERF_DISABLE_MENUANIMATIONS;
|
2013-09-17 22:56:23 +04:00
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_DisableThemes))
|
|
|
|
PerformanceFlags |= PERF_DISABLE_THEMING;
|
|
|
|
freerdp_settings_set_uint32(settings, FreeRDP_PerformanceFlags, PerformanceFlags);
|
2013-09-17 22:56:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void freerdp_performance_flags_split(rdpSettings* settings)
|
|
|
|
{
|
2020-11-19 12:09:34 +03:00
|
|
|
freerdp_settings_set_bool(settings, FreeRDP_AllowFontSmoothing,
|
|
|
|
(freerdp_settings_get_uint32(settings, FreeRDP_PerformanceFlags) &
|
|
|
|
PERF_ENABLE_FONT_SMOOTHING)
|
|
|
|
? TRUE
|
|
|
|
: FALSE);
|
|
|
|
freerdp_settings_set_bool(settings, FreeRDP_AllowDesktopComposition,
|
|
|
|
(freerdp_settings_get_uint32(settings, FreeRDP_PerformanceFlags) &
|
|
|
|
PERF_ENABLE_DESKTOP_COMPOSITION)
|
|
|
|
? TRUE
|
|
|
|
: FALSE);
|
|
|
|
freerdp_settings_set_bool(
|
|
|
|
settings, FreeRDP_DisableWallpaper,
|
|
|
|
(freerdp_settings_get_uint32(settings, FreeRDP_PerformanceFlags) & PERF_DISABLE_WALLPAPER)
|
|
|
|
? TRUE
|
|
|
|
: FALSE);
|
|
|
|
freerdp_settings_set_bool(settings, FreeRDP_DisableFullWindowDrag,
|
|
|
|
(freerdp_settings_get_uint32(settings, FreeRDP_PerformanceFlags) &
|
|
|
|
PERF_DISABLE_FULLWINDOWDRAG)
|
|
|
|
? TRUE
|
|
|
|
: FALSE);
|
|
|
|
freerdp_settings_set_bool(settings, FreeRDP_DisableMenuAnims,
|
|
|
|
(freerdp_settings_get_uint32(settings, FreeRDP_PerformanceFlags) &
|
|
|
|
PERF_DISABLE_MENUANIMATIONS)
|
|
|
|
? TRUE
|
|
|
|
: FALSE);
|
|
|
|
freerdp_settings_set_bool(
|
|
|
|
settings, FreeRDP_DisableThemes,
|
|
|
|
(freerdp_settings_get_uint32(settings, FreeRDP_PerformanceFlags) & PERF_DISABLE_THEMING)
|
|
|
|
? TRUE
|
|
|
|
: FALSE);
|
2013-09-17 22:56:23 +04:00
|
|
|
}
|
|
|
|
|
2019-05-06 10:51:42 +03:00
|
|
|
BOOL freerdp_set_gateway_usage_method(rdpSettings* settings, UINT32 GatewayUsageMethod)
|
2014-04-25 01:05:10 +04:00
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_GatewayUsageMethod, GatewayUsageMethod))
|
2019-05-06 10:51:42 +03:00
|
|
|
return FALSE;
|
2014-04-25 01:05:10 +04:00
|
|
|
|
|
|
|
if (GatewayUsageMethod == TSC_PROXY_MODE_NONE_DIRECT)
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GatewayEnabled, FALSE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GatewayBypassLocal, FALSE))
|
2019-05-06 10:51:42 +03:00
|
|
|
return FALSE;
|
2014-04-25 01:05:10 +04:00
|
|
|
}
|
|
|
|
else if (GatewayUsageMethod == TSC_PROXY_MODE_DIRECT)
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GatewayEnabled, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GatewayBypassLocal, FALSE))
|
2019-05-06 10:51:42 +03:00
|
|
|
return FALSE;
|
2014-04-25 01:05:10 +04:00
|
|
|
}
|
|
|
|
else if (GatewayUsageMethod == TSC_PROXY_MODE_DETECT)
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GatewayEnabled, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GatewayBypassLocal, TRUE))
|
2019-05-06 10:51:42 +03:00
|
|
|
return FALSE;
|
2014-04-25 01:05:10 +04:00
|
|
|
}
|
|
|
|
else if (GatewayUsageMethod == TSC_PROXY_MODE_DEFAULT)
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* This corresponds to "Automatically detect RD Gateway server settings",
|
|
|
|
* which means the client attempts to use gateway group policy settings
|
|
|
|
* http://technet.microsoft.com/en-us/library/cc770601.aspx
|
|
|
|
*/
|
2019-05-08 15:35:25 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GatewayEnabled, FALSE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GatewayBypassLocal, FALSE))
|
2019-05-06 10:51:42 +03:00
|
|
|
return FALSE;
|
2014-04-25 01:05:10 +04:00
|
|
|
}
|
|
|
|
else if (GatewayUsageMethod == TSC_PROXY_MODE_NONE_DETECT)
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GatewayEnabled, FALSE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GatewayBypassLocal, FALSE))
|
2019-05-06 10:51:42 +03:00
|
|
|
return FALSE;
|
2014-04-25 01:05:10 +04:00
|
|
|
}
|
2019-05-06 10:51:42 +03:00
|
|
|
|
|
|
|
return TRUE;
|
2014-04-25 01:05:10 +04:00
|
|
|
}
|
|
|
|
|
2018-08-22 14:40:41 +03:00
|
|
|
void freerdp_update_gateway_usage_method(rdpSettings* settings, UINT32 GatewayEnabled,
|
2019-11-06 17:24:51 +03:00
|
|
|
UINT32 GatewayBypassLocal)
|
2014-05-30 20:55:17 +04:00
|
|
|
{
|
|
|
|
UINT32 GatewayUsageMethod = 0;
|
|
|
|
|
|
|
|
if (!GatewayEnabled && !GatewayBypassLocal)
|
|
|
|
GatewayUsageMethod = TSC_PROXY_MODE_NONE_DIRECT;
|
|
|
|
else if (GatewayEnabled && !GatewayBypassLocal)
|
|
|
|
GatewayUsageMethod = TSC_PROXY_MODE_DIRECT;
|
|
|
|
else if (GatewayEnabled && GatewayBypassLocal)
|
|
|
|
GatewayUsageMethod = TSC_PROXY_MODE_DETECT;
|
|
|
|
|
|
|
|
freerdp_set_gateway_usage_method(settings, GatewayUsageMethod);
|
|
|
|
}
|
2019-05-08 15:35:25 +03:00
|
|
|
|
2019-11-07 14:39:22 +03:00
|
|
|
BOOL freerdp_get_param_bool(const rdpSettings* settings, int id)
|
2019-05-08 15:35:25 +03:00
|
|
|
{
|
|
|
|
return freerdp_settings_get_bool(settings, (size_t)id);
|
|
|
|
}
|
|
|
|
|
|
|
|
int freerdp_set_param_bool(rdpSettings* settings, int id, BOOL param)
|
|
|
|
{
|
|
|
|
return freerdp_settings_set_bool(settings, (size_t)id, param) ? 0 : -1;
|
|
|
|
}
|
|
|
|
|
2019-11-07 14:39:22 +03:00
|
|
|
int freerdp_get_param_int(const rdpSettings* settings, int id)
|
2019-05-08 15:35:25 +03:00
|
|
|
{
|
|
|
|
return freerdp_settings_get_int32(settings, (size_t)id);
|
|
|
|
}
|
|
|
|
|
|
|
|
int freerdp_set_param_int(rdpSettings* settings, int id, int param)
|
|
|
|
{
|
|
|
|
return freerdp_settings_set_int32(settings, (size_t)id, param) ? 0 : -1;
|
|
|
|
}
|
|
|
|
|
2019-11-07 14:39:22 +03:00
|
|
|
UINT32 freerdp_get_param_uint32(const rdpSettings* settings, int id)
|
2019-05-08 15:35:25 +03:00
|
|
|
{
|
|
|
|
return freerdp_settings_get_uint32(settings, (size_t)id);
|
|
|
|
}
|
|
|
|
|
|
|
|
int freerdp_set_param_uint32(rdpSettings* settings, int id, UINT32 param)
|
|
|
|
{
|
|
|
|
return freerdp_settings_set_uint32(settings, (size_t)id, param) ? 0 : -1;
|
|
|
|
}
|
|
|
|
|
2019-11-07 14:39:22 +03:00
|
|
|
UINT64 freerdp_get_param_uint64(const rdpSettings* settings, int id)
|
2019-05-08 15:35:25 +03:00
|
|
|
{
|
|
|
|
return freerdp_settings_get_uint64(settings, (size_t)id);
|
|
|
|
}
|
|
|
|
|
|
|
|
int freerdp_set_param_uint64(rdpSettings* settings, int id, UINT64 param)
|
|
|
|
{
|
|
|
|
return freerdp_settings_set_uint64(settings, (size_t)id, param) ? 0 : -1;
|
|
|
|
}
|
|
|
|
|
2019-11-07 14:39:22 +03:00
|
|
|
char* freerdp_get_param_string(const rdpSettings* settings, int id)
|
2019-05-08 15:35:25 +03:00
|
|
|
{
|
|
|
|
return (char*)freerdp_settings_get_string(settings, (size_t)id);
|
|
|
|
}
|
|
|
|
|
|
|
|
int freerdp_set_param_string(rdpSettings* settings, int id, const char* param)
|
|
|
|
{
|
|
|
|
return freerdp_settings_set_string(settings, (size_t)id, param) ? 0 : -1;
|
|
|
|
}
|
2020-04-11 12:55:11 +03:00
|
|
|
|
|
|
|
static BOOL value_to_uint(const char* value, ULONGLONG* result, ULONGLONG min, ULONGLONG max)
|
|
|
|
{
|
|
|
|
unsigned long long rc;
|
|
|
|
|
|
|
|
if (!value || !result)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
rc = _strtoui64(value, NULL, 0);
|
|
|
|
|
|
|
|
if (errno != 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if ((rc < min) || (rc > max))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*result = rc;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL value_to_int(const char* value, LONGLONG* result, LONGLONG min, LONGLONG max)
|
|
|
|
{
|
|
|
|
long long rc;
|
|
|
|
|
|
|
|
if (!value || !result)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
rc = _strtoi64(value, NULL, 0);
|
|
|
|
|
|
|
|
if (errno != 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if ((rc < min) || (rc > max))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*result = rc;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL parsing_fail(const char* key, const char* type, const char* value)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Failed to parse key [%s] of type [%s]: value [%s]", key, type, value);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL freerdp_settings_set_value_for_name(rdpSettings* settings, const char* name, const char* value)
|
|
|
|
{
|
|
|
|
ULONGLONG uval;
|
|
|
|
LONGLONG ival;
|
|
|
|
SSIZE_T index, type;
|
|
|
|
if (!settings || !name)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
index = freerdp_settings_get_key_for_name(name);
|
|
|
|
if (index < 0)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Invalid settings key [%s]", name);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
type = freerdp_settings_get_type_for_key((size_t)index);
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
|
|
|
|
case RDP_SETTINGS_TYPE_BOOL:
|
|
|
|
{
|
|
|
|
BOOL val = _strnicmp(value, "TRUE", 5) == 0;
|
|
|
|
if (!val && _strnicmp(value, "FALSE", 5) != 0)
|
|
|
|
return parsing_fail(name, "BOOL", value);
|
|
|
|
return freerdp_settings_set_bool(settings, index, val);
|
|
|
|
}
|
|
|
|
case RDP_SETTINGS_TYPE_UINT16:
|
|
|
|
if (!value_to_uint(value, &uval, 0, UINT16_MAX))
|
|
|
|
return parsing_fail(name, "UINT16", value);
|
|
|
|
if (!freerdp_settings_set_uint16(settings, index, uval))
|
|
|
|
return parsing_fail(name, "UINT16", value);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case RDP_SETTINGS_TYPE_INT16:
|
|
|
|
if (!value_to_int(value, &ival, INT16_MIN, INT16_MAX))
|
|
|
|
return parsing_fail(name, "INT16", value);
|
|
|
|
if (!freerdp_settings_set_int16(settings, index, ival))
|
|
|
|
return parsing_fail(name, "INT16", value);
|
|
|
|
return TRUE;
|
|
|
|
case RDP_SETTINGS_TYPE_UINT32:
|
|
|
|
if (!value_to_uint(value, &uval, 0, UINT32_MAX))
|
|
|
|
return parsing_fail(name, "UINT32", value);
|
|
|
|
if (!freerdp_settings_set_uint32(settings, index, uval))
|
|
|
|
return parsing_fail(name, "UINT32", value);
|
|
|
|
return TRUE;
|
|
|
|
case RDP_SETTINGS_TYPE_INT32:
|
|
|
|
if (!value_to_int(value, &ival, INT32_MIN, INT32_MAX))
|
|
|
|
return parsing_fail(name, "INT32", value);
|
|
|
|
if (!freerdp_settings_set_int32(settings, index, ival))
|
|
|
|
return parsing_fail(name, "INT32", value);
|
|
|
|
return TRUE;
|
|
|
|
case RDP_SETTINGS_TYPE_UINT64:
|
|
|
|
if (!value_to_uint(value, &uval, 0, UINT64_MAX))
|
|
|
|
return parsing_fail(name, "UINT64", value);
|
|
|
|
if (!freerdp_settings_set_uint64(settings, index, uval))
|
|
|
|
return parsing_fail(name, "UINT64", value);
|
|
|
|
return TRUE;
|
|
|
|
case RDP_SETTINGS_TYPE_INT64:
|
|
|
|
if (!value_to_int(value, &ival, INT64_MIN, INT64_MAX))
|
|
|
|
return parsing_fail(name, "INT64", value);
|
|
|
|
if (!freerdp_settings_set_int64(settings, index, ival))
|
|
|
|
return parsing_fail(name, "INT64", value);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case RDP_SETTINGS_TYPE_STRING:
|
|
|
|
return freerdp_settings_set_string(settings, index, value);
|
|
|
|
case RDP_SETTINGS_TYPE_POINTER:
|
|
|
|
return parsing_fail(name, "POINTER", value);
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2020-12-15 18:11:22 +03:00
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
static BOOL freerdp_settings_set_pointer_len_(rdpSettings* settings, size_t id, SSIZE_T lenId,
|
|
|
|
const void* data, size_t len)
|
|
|
|
{
|
|
|
|
BOOL rc;
|
|
|
|
void* copy;
|
|
|
|
void* old = freerdp_settings_get_pointer_writable(settings, id);
|
|
|
|
free(old);
|
|
|
|
if (!freerdp_settings_set_pointer(settings, id, NULL))
|
|
|
|
return FALSE;
|
|
|
|
if (lenId >= 0)
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_uint32(settings, lenId, 0))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (len == 0)
|
|
|
|
return TRUE;
|
|
|
|
copy = calloc(len, 1);
|
|
|
|
if (!copy)
|
|
|
|
return FALSE;
|
|
|
|
if (data)
|
|
|
|
memcpy(copy, data, len);
|
|
|
|
rc = freerdp_settings_set_pointer(settings, id, copy);
|
|
|
|
if (!rc)
|
|
|
|
{
|
|
|
|
free(copy);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (lenId < 0)
|
|
|
|
return TRUE;
|
|
|
|
return freerdp_settings_set_uint32(settings, lenId, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
const void* freerdp_settings_get_pointer(const rdpSettings* settings, size_t id)
|
|
|
|
{
|
|
|
|
return freerdp_settings_get_pointer_writable(settings, id);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL freerdp_settings_set_pointer_len(rdpSettings* settings, size_t id, const void* data,
|
|
|
|
size_t len)
|
|
|
|
{
|
|
|
|
if (!settings)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
switch (id)
|
|
|
|
{
|
|
|
|
case FreeRDP_RdpServerCertificate:
|
|
|
|
certificate_free(settings->RdpServerCertificate);
|
|
|
|
settings->RdpServerCertificate = data;
|
|
|
|
return TRUE;
|
|
|
|
case FreeRDP_RdpServerRsaKey:
|
|
|
|
key_free(settings->RdpServerRsaKey);
|
|
|
|
settings->RdpServerRsaKey = (rdpRsaKey*)data;
|
|
|
|
return TRUE;
|
|
|
|
case FreeRDP_RedirectionPassword:
|
|
|
|
return freerdp_settings_set_pointer_len_(settings, id,
|
|
|
|
FreeRDP_RedirectionPasswordLength, data, len);
|
|
|
|
case FreeRDP_RedirectionTsvUrl:
|
|
|
|
return freerdp_settings_set_pointer_len_(settings, id, FreeRDP_RedirectionTsvUrlLength,
|
|
|
|
data, len);
|
|
|
|
case FreeRDP_LoadBalanceInfo:
|
|
|
|
return freerdp_settings_set_pointer_len_(settings, id, FreeRDP_LoadBalanceInfoLength,
|
|
|
|
data, len);
|
|
|
|
case FreeRDP_ServerRandom:
|
|
|
|
return freerdp_settings_set_pointer_len_(settings, id, FreeRDP_ServerRandomLength, data,
|
|
|
|
len);
|
|
|
|
case FreeRDP_ClientRandom:
|
|
|
|
return freerdp_settings_set_pointer_len_(settings, id, FreeRDP_ClientRandomLength, data,
|
|
|
|
len);
|
|
|
|
case FreeRDP_ServerCertificate:
|
|
|
|
return freerdp_settings_set_pointer_len_(settings, id, FreeRDP_ServerCertificateLength,
|
|
|
|
data, len);
|
|
|
|
case FreeRDP_TargetNetAddresses:
|
|
|
|
if (data == NULL)
|
|
|
|
{
|
|
|
|
freerdp_target_net_addresses_free(settings);
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_TargetNetAddressCount, len))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return freerdp_settings_set_pointer_len_(settings, FreeRDP_TargetNetAddresses,
|
|
|
|
FreeRDP_TargetNetAddressCount, data, len);
|
|
|
|
|
|
|
|
case FreeRDP_TargetNetPorts:
|
|
|
|
if (data == NULL)
|
|
|
|
{
|
|
|
|
freerdp_target_net_addresses_free(settings);
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_TargetNetAddressCount, len))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return freerdp_settings_set_pointer_len_(settings, FreeRDP_TargetNetPorts,
|
|
|
|
FreeRDP_TargetNetAddressCount, data, len);
|
|
|
|
case FreeRDP_ClientAutoReconnectCookie:
|
|
|
|
case FreeRDP_ServerAutoReconnectCookie:
|
|
|
|
case FreeRDP_ChannelDefArray:
|
|
|
|
case FreeRDP_MonitorDefArray:
|
|
|
|
case FreeRDP_MonitorIds:
|
|
|
|
case FreeRDP_ReceivedCapabilities:
|
|
|
|
case FreeRDP_OrderSupport:
|
|
|
|
case FreeRDP_ClientTimeZone:
|
|
|
|
case FreeRDP_BitmapCacheV2CellInfo:
|
|
|
|
case FreeRDP_GlyphCache:
|
|
|
|
case FreeRDP_FragCache:
|
|
|
|
return freerdp_settings_set_pointer_len_(settings, id, -1, data, len);
|
|
|
|
default:
|
|
|
|
if ((data == NULL) && (len == 0))
|
|
|
|
{
|
|
|
|
freerdp_settings_set_pointer(settings, id, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
WLog_WARN(TAG, "Invalid id %" PRIuz " for %s", id, __FUNCTION__);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void* freerdp_settings_get_pointer_array_writable(const rdpSettings* settings, size_t id,
|
|
|
|
size_t offset)
|
|
|
|
{
|
|
|
|
if (!settings)
|
|
|
|
return NULL;
|
|
|
|
switch (id)
|
|
|
|
{
|
|
|
|
case FreeRDP_OrderSupport:
|
|
|
|
if (offset >= 32)
|
|
|
|
return FALSE;
|
|
|
|
return &settings->OrderSupport[offset];
|
|
|
|
case FreeRDP_MonitorIds:
|
|
|
|
if (offset > freerdp_settings_get_uint32(settings, FreeRDP_NumMonitorIds))
|
|
|
|
return NULL;
|
|
|
|
return &settings->MonitorIds[offset];
|
|
|
|
case FreeRDP_MonitorDefArray:
|
|
|
|
if (offset > freerdp_settings_get_uint32(settings, FreeRDP_MonitorDefArraySize))
|
|
|
|
return NULL;
|
|
|
|
return &settings->MonitorDefArray[offset];
|
|
|
|
|
|
|
|
case FreeRDP_ChannelDefArray:
|
|
|
|
if (offset > freerdp_settings_get_uint32(settings, FreeRDP_ChannelDefArraySize))
|
|
|
|
return NULL;
|
|
|
|
return &settings->ChannelDefArray[offset];
|
|
|
|
case FreeRDP_DeviceArray:
|
|
|
|
if (offset > freerdp_settings_get_uint32(settings, FreeRDP_DeviceArraySize))
|
|
|
|
return NULL;
|
|
|
|
return &settings->DeviceArray[offset];
|
|
|
|
case FreeRDP_StaticChannelArray:
|
|
|
|
if (offset > freerdp_settings_get_uint32(settings, FreeRDP_StaticChannelArraySize))
|
|
|
|
return NULL;
|
|
|
|
return settings->StaticChannelArray[offset];
|
|
|
|
case FreeRDP_DynamicChannelArray:
|
|
|
|
if (offset > freerdp_settings_get_uint32(settings, FreeRDP_DynamicChannelArraySize))
|
|
|
|
return NULL;
|
|
|
|
return settings->DynamicChannelArray[offset];
|
|
|
|
case FreeRDP_FragCache:
|
|
|
|
if (offset >= 1)
|
|
|
|
return NULL;
|
|
|
|
return &settings->FragCache[offset];
|
|
|
|
case FreeRDP_GlyphCache:
|
|
|
|
if (offset >= 10)
|
|
|
|
return NULL;
|
|
|
|
return &settings->GlyphCache[offset];
|
|
|
|
case FreeRDP_BitmapCacheV2CellInfo:
|
|
|
|
/* TODO: BitmapCacheV2NumCells should be limited to 4
|
|
|
|
if (offset > freerdp_settings_get_uint32(settings, FreeRDP_BitmapCacheV2NumCells))
|
|
|
|
return NULL;
|
|
|
|
*/
|
|
|
|
|
|
|
|
return &settings->BitmapCacheV2CellInfo[offset];
|
|
|
|
case FreeRDP_ReceivedCapabilities:
|
|
|
|
if (offset > settings->ReceivedCapabilitiesSize)
|
|
|
|
return 0;
|
|
|
|
return &settings->ReceivedCapabilities[offset];
|
|
|
|
default:
|
|
|
|
WLog_WARN(TAG, "Invalid id %" PRIuz " for %s", id, __FUNCTION__);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL freerdp_settings_set_pointer_array(rdpSettings* settings, size_t id, size_t offset,
|
|
|
|
const void* data)
|
|
|
|
{
|
|
|
|
if (!settings)
|
|
|
|
return FALSE;
|
|
|
|
switch (id)
|
|
|
|
{
|
|
|
|
case FreeRDP_TargetNetAddresses:
|
|
|
|
if ((offset >= settings->TargetNetAddressCount) || !data)
|
|
|
|
return FALSE;
|
|
|
|
free(settings->TargetNetAddresses[offset]);
|
|
|
|
settings->TargetNetAddresses[offset] = _strdup((const char*)data);
|
|
|
|
return settings->TargetNetAddresses[offset] != NULL;
|
|
|
|
case FreeRDP_TargetNetPorts:
|
|
|
|
if ((offset >= settings->TargetNetAddressCount) || !data)
|
|
|
|
return FALSE;
|
|
|
|
settings->TargetNetPorts[offset] = *((const UINT32*)data);
|
|
|
|
return TRUE;
|
|
|
|
case FreeRDP_BitmapCacheV2CellInfo:
|
|
|
|
if ((offset > 5) || !data)
|
|
|
|
return FALSE;
|
|
|
|
settings->BitmapCacheV2CellInfo[offset] = *(const BITMAP_CACHE_V2_CELL_INFO*)data;
|
|
|
|
return TRUE;
|
|
|
|
case FreeRDP_OrderSupport:
|
|
|
|
if ((offset >= 32) || !data)
|
|
|
|
return FALSE;
|
|
|
|
settings->OrderSupport[offset] = *(const BOOL*)data;
|
|
|
|
return TRUE;
|
|
|
|
case FreeRDP_GlyphCache:
|
|
|
|
if ((offset >= 10) || !data)
|
|
|
|
return FALSE;
|
|
|
|
settings->GlyphCache[offset] = *(const GLYPH_CACHE_DEFINITION*)data;
|
|
|
|
return TRUE;
|
|
|
|
case FreeRDP_FragCache:
|
|
|
|
if ((offset >= 1) || !data)
|
|
|
|
return FALSE;
|
|
|
|
settings->FragCache[offset] = *(const GLYPH_CACHE_DEFINITION*)data;
|
|
|
|
return TRUE;
|
|
|
|
case FreeRDP_MonitorIds:
|
|
|
|
if ((offset > freerdp_settings_get_uint32(settings, FreeRDP_NumMonitorIds)) || !data)
|
|
|
|
return FALSE;
|
|
|
|
settings->MonitorIds[offset] = *(const UINT32*)data;
|
|
|
|
return TRUE;
|
|
|
|
case FreeRDP_ChannelDefArray:
|
|
|
|
if (offset > freerdp_settings_get_uint32(settings, FreeRDP_ChannelDefArraySize))
|
|
|
|
return FALSE;
|
|
|
|
settings->ChannelDefArray[offset] = *(const CHANNEL_DEF*)data;
|
|
|
|
return TRUE;
|
|
|
|
default:
|
|
|
|
WLog_WARN(TAG, "Invalid id %" PRIuz " for %s", id, __FUNCTION__);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const void* freerdp_settings_get_pointer_array(const rdpSettings* settings, size_t id,
|
|
|
|
size_t offset)
|
|
|
|
{
|
|
|
|
return freerdp_settings_get_pointer_array_writable(settings, id, offset);
|
|
|
|
}
|
|
|
|
|
2020-12-15 18:11:22 +03:00
|
|
|
UINT32 freerdp_settings_get_codecs_flags(const rdpSettings* settings)
|
|
|
|
{
|
|
|
|
UINT32 flags = FREERDP_CODEC_ALL;
|
|
|
|
if (settings->RemoteFxCodec == FALSE)
|
|
|
|
{
|
|
|
|
flags &= ~FREERDP_CODEC_REMOTEFX;
|
|
|
|
}
|
|
|
|
if (settings->NSCodec == FALSE)
|
|
|
|
{
|
|
|
|
flags &= ~FREERDP_CODEC_NSCODEC;
|
|
|
|
}
|
|
|
|
/*TODO: check other codecs flags */
|
|
|
|
return flags;
|
2020-11-19 12:09:34 +03:00
|
|
|
}
|
2021-04-12 11:38:40 +03:00
|
|
|
|
|
|
|
ADDIN_ARGV* freerdp_static_channel_clone(ADDIN_ARGV* channel)
|
|
|
|
{
|
|
|
|
return freerdp_addin_argv_clone(channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
ADDIN_ARGV* freerdp_dynamic_channel_clone(ADDIN_ARGV* channel)
|
|
|
|
{
|
|
|
|
return freerdp_addin_argv_clone(channel);
|
|
|
|
}
|