2011-07-01 04:31:07 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-07-07 21:37:48 +04:00
|
|
|
* RDP Settings
|
2011-07-01 04:31:07 +04:00
|
|
|
*
|
|
|
|
* Copyright 2009-2011 Jay Sorg
|
2023-02-09 10:48:11 +03:00
|
|
|
* Copyright 2023 Armin Novak <anovak@thincast.com>
|
|
|
|
* Copyright 2023 Thincast Technologies GmbH
|
2011-07-01 04:31:07 +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.
|
|
|
|
*/
|
|
|
|
|
2022-02-16 13:20:38 +03:00
|
|
|
#include <freerdp/config.h>
|
2023-10-16 13:59:19 +03:00
|
|
|
|
|
|
|
#include "settings.h"
|
|
|
|
|
2023-02-03 13:40:35 +03:00
|
|
|
#include <freerdp/crypto/certificate.h>
|
2012-08-15 01:09:01 +04:00
|
|
|
|
2015-06-11 00:33:58 +03:00
|
|
|
#include <ctype.h>
|
|
|
|
|
2012-10-09 07:42:01 +04:00
|
|
|
#include <winpr/crt.h>
|
2013-03-22 23:52:43 +04:00
|
|
|
#include <winpr/file.h>
|
|
|
|
#include <winpr/path.h>
|
2012-10-26 02:38:51 +04:00
|
|
|
#include <winpr/sysinfo.h>
|
2012-10-09 07:42:01 +04:00
|
|
|
#include <winpr/registry.h>
|
2023-11-02 17:38:13 +03:00
|
|
|
#include <winpr/wtsapi.h>
|
2012-10-09 07:42:01 +04:00
|
|
|
|
2011-07-07 21:37:48 +04:00
|
|
|
#include <freerdp/settings.h>
|
2015-11-05 16:02:07 +03:00
|
|
|
#include <freerdp/build-config.h>
|
2015-06-10 19:57:05 +03:00
|
|
|
#include <ctype.h>
|
|
|
|
|
2023-02-03 13:40:35 +03:00
|
|
|
#include "../crypto/certificate.h"
|
|
|
|
#include "../crypto/privatekey.h"
|
|
|
|
#include "capabilities.h"
|
2020-05-15 13:22:37 +03:00
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
#define TAG FREERDP_TAG("settings")
|
|
|
|
|
2021-04-28 16:00:24 +03:00
|
|
|
#ifdef _MSC_VER
|
2012-10-14 09:17:25 +04:00
|
|
|
#pragma warning(push)
|
2019-11-06 17:24:51 +03:00
|
|
|
#pragma warning(disable : 4244)
|
2012-10-14 11:22:58 +04:00
|
|
|
#endif
|
2012-10-14 09:17:25 +04:00
|
|
|
|
2011-12-01 02:40:36 +04:00
|
|
|
static const char client_dll[] = "C:\\Windows\\System32\\mstscax.dll";
|
2011-07-10 20:10:24 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
#define SERVER_KEY "Software\\" FREERDP_VENDOR_STRING "\\" FREERDP_PRODUCT_STRING "\\Server"
|
|
|
|
#define CLIENT_KEY "Software\\" FREERDP_VENDOR_STRING "\\" FREERDP_PRODUCT_STRING "\\Client"
|
2015-06-24 12:12:59 +03:00
|
|
|
#define BITMAP_CACHE_KEY CLIENT_KEY "\\BitmapCacheV2"
|
|
|
|
#define GLYPH_CACHE_KEY CLIENT_KEY "\\GlyphCache"
|
|
|
|
#define POINTER_CACHE_KEY CLIENT_KEY "\\PointerCache"
|
|
|
|
|
2021-03-08 14:48:22 +03:00
|
|
|
static BOOL settings_reg_query_dword_val(HKEY hKey, const TCHAR* sub, DWORD* value)
|
2012-06-16 01:06:26 +04:00
|
|
|
{
|
|
|
|
DWORD dwType;
|
|
|
|
DWORD dwSize;
|
2021-03-08 14:48:22 +03:00
|
|
|
|
|
|
|
dwSize = sizeof(DWORD);
|
|
|
|
if (RegQueryValueEx(hKey, sub, NULL, &dwType, (BYTE*)value, &dwSize) != ERROR_SUCCESS)
|
|
|
|
return FALSE;
|
2022-02-15 15:52:12 +03:00
|
|
|
if (dwType != REG_DWORD)
|
|
|
|
return FALSE;
|
2021-03-08 14:48:22 +03:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL settings_reg_query_word_val(HKEY hKey, const TCHAR* sub, UINT16* value)
|
|
|
|
{
|
|
|
|
DWORD dwValue;
|
|
|
|
|
|
|
|
if (!settings_reg_query_dword_val(hKey, sub, &dwValue))
|
|
|
|
return FALSE;
|
|
|
|
|
2022-02-15 15:52:12 +03:00
|
|
|
if (dwValue > UINT16_MAX)
|
|
|
|
return FALSE;
|
|
|
|
|
2021-10-07 10:22:27 +03:00
|
|
|
*value = (UINT16)dwValue;
|
2021-03-08 14:48:22 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL settings_reg_query_bool_val(HKEY hKey, const TCHAR* sub, BOOL* value)
|
|
|
|
{
|
|
|
|
DWORD dwValue;
|
|
|
|
|
|
|
|
if (!settings_reg_query_dword_val(hKey, sub, &dwValue))
|
|
|
|
return FALSE;
|
|
|
|
*value = dwValue != 0;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2023-10-16 20:37:36 +03:00
|
|
|
static BOOL settings_reg_query_dword(rdpSettings* settings, FreeRDP_Settings_Keys_UInt32 id,
|
|
|
|
HKEY hKey, const TCHAR* sub)
|
2021-03-08 14:48:22 +03:00
|
|
|
{
|
2012-06-16 01:06:26 +04:00
|
|
|
DWORD dwValue;
|
2021-03-08 14:48:22 +03:00
|
|
|
|
|
|
|
if (!settings_reg_query_dword_val(hKey, sub, &dwValue))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return freerdp_settings_set_uint32(settings, id, dwValue);
|
|
|
|
}
|
|
|
|
|
2023-10-16 20:37:36 +03:00
|
|
|
static BOOL settings_reg_query_bool(rdpSettings* settings, FreeRDP_Settings_Keys_Bool id, HKEY hKey,
|
|
|
|
const TCHAR* sub)
|
2021-03-08 14:48:22 +03:00
|
|
|
{
|
|
|
|
DWORD dwValue;
|
|
|
|
|
|
|
|
if (!settings_reg_query_dword_val(hKey, sub, &dwValue))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return freerdp_settings_set_bool(settings, id, dwValue != 0 ? TRUE : FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void settings_client_load_hkey_local_machine(rdpSettings* settings)
|
|
|
|
{
|
|
|
|
HKEY hKey;
|
|
|
|
LONG status;
|
2019-11-06 17:24:51 +03:00
|
|
|
status = RegOpenKeyExA(HKEY_LOCAL_MACHINE, CLIENT_KEY, 0, KEY_READ | KEY_WOW64_64KEY, &hKey);
|
2012-06-16 01:06:26 +04:00
|
|
|
|
2012-10-11 22:59:01 +04:00
|
|
|
if (status == ERROR_SUCCESS)
|
|
|
|
{
|
2021-03-08 14:48:22 +03:00
|
|
|
settings_reg_query_dword(settings, FreeRDP_DesktopWidth, hKey, _T("DesktopWidth"));
|
|
|
|
settings_reg_query_dword(settings, FreeRDP_DesktopHeight, hKey, _T("DesktopHeight"));
|
|
|
|
settings_reg_query_bool(settings, FreeRDP_Fullscreen, hKey, _T("Fullscreen"));
|
|
|
|
settings_reg_query_dword(settings, FreeRDP_ColorDepth, hKey, _T("ColorDepth"));
|
|
|
|
settings_reg_query_dword(settings, FreeRDP_KeyboardType, hKey, _T("KeyboardType"));
|
|
|
|
settings_reg_query_dword(settings, FreeRDP_KeyboardSubType, hKey, _T("KeyboardSubType"));
|
|
|
|
settings_reg_query_dword(settings, FreeRDP_KeyboardFunctionKey, hKey,
|
|
|
|
_T("KeyboardFunctionKeys"));
|
|
|
|
settings_reg_query_dword(settings, FreeRDP_KeyboardLayout, hKey, _T("KeyboardLayout"));
|
|
|
|
settings_reg_query_bool(settings, FreeRDP_ExtSecurity, hKey, _T("ExtSecurity"));
|
|
|
|
settings_reg_query_bool(settings, FreeRDP_NlaSecurity, hKey, _T("NlaSecurity"));
|
|
|
|
settings_reg_query_bool(settings, FreeRDP_TlsSecurity, hKey, _T("TlsSecurity"));
|
|
|
|
settings_reg_query_bool(settings, FreeRDP_RdpSecurity, hKey, _T("RdpSecurity"));
|
|
|
|
settings_reg_query_bool(settings, FreeRDP_MstscCookieMode, hKey, _T("MstscCookieMode"));
|
|
|
|
settings_reg_query_dword(settings, FreeRDP_CookieMaxLength, hKey, _T("CookieMaxLength"));
|
|
|
|
settings_reg_query_bool(settings, FreeRDP_BitmapCacheEnabled, hKey, _T("BitmapCache"));
|
2023-10-16 20:37:36 +03:00
|
|
|
settings_reg_query_dword(settings, FreeRDP_OffscreenSupportLevel, hKey,
|
|
|
|
_T("OffscreenBitmapCache"));
|
2021-03-08 14:48:22 +03:00
|
|
|
settings_reg_query_dword(settings, FreeRDP_OffscreenCacheSize, hKey,
|
|
|
|
_T("OffscreenBitmapCacheSize"));
|
|
|
|
settings_reg_query_dword(settings, FreeRDP_OffscreenCacheEntries, hKey,
|
|
|
|
_T("OffscreenBitmapCacheEntries"));
|
2012-10-11 22:59:01 +04:00
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
2012-06-16 01:06:26 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
status =
|
|
|
|
RegOpenKeyExA(HKEY_LOCAL_MACHINE, BITMAP_CACHE_KEY, 0, KEY_READ | KEY_WOW64_64KEY, &hKey);
|
2012-06-16 01:06:26 +04:00
|
|
|
|
2012-10-11 22:59:01 +04:00
|
|
|
if (status == ERROR_SUCCESS)
|
|
|
|
{
|
2020-11-19 12:09:34 +03:00
|
|
|
unsigned x;
|
|
|
|
|
2021-03-08 14:48:22 +03:00
|
|
|
settings_reg_query_dword(settings, FreeRDP_BitmapCacheV2NumCells, hKey, _T("NumCells"));
|
2020-11-19 12:09:34 +03:00
|
|
|
for (x = 0; x < 5; x++)
|
|
|
|
{
|
2022-02-17 17:18:18 +03:00
|
|
|
DWORD val;
|
2020-11-19 12:09:34 +03:00
|
|
|
TCHAR numentries[64] = { 0 };
|
|
|
|
TCHAR persist[64] = { 0 };
|
|
|
|
BITMAP_CACHE_V2_CELL_INFO cache = { 0 };
|
|
|
|
_sntprintf(numentries, ARRAYSIZE(numentries), _T("Cell%uNumEntries"), x);
|
|
|
|
_sntprintf(persist, ARRAYSIZE(persist), _T("Cell%uPersistent"), x);
|
2022-02-17 17:18:18 +03:00
|
|
|
if (!settings_reg_query_dword_val(hKey, numentries, &val) ||
|
2021-03-08 14:48:22 +03:00
|
|
|
!settings_reg_query_bool_val(hKey, persist, &cache.persistent) ||
|
|
|
|
!freerdp_settings_set_pointer_array(settings, FreeRDP_BitmapCacheV2CellInfo, x,
|
2020-11-19 12:09:34 +03:00
|
|
|
&cache))
|
|
|
|
WLog_WARN(TAG, "Failed to load registry keys to settings!");
|
2022-02-17 17:18:18 +03:00
|
|
|
cache.numEntries = val;
|
2020-11-19 12:09:34 +03:00
|
|
|
}
|
|
|
|
|
2021-03-08 14:48:22 +03:00
|
|
|
settings_reg_query_bool(settings, FreeRDP_AllowCacheWaitingList, hKey,
|
|
|
|
_T("AllowCacheWaitingList"));
|
2012-10-12 23:47:51 +04:00
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
status =
|
|
|
|
RegOpenKeyExA(HKEY_LOCAL_MACHINE, GLYPH_CACHE_KEY, 0, KEY_READ | KEY_WOW64_64KEY, &hKey);
|
2012-10-12 23:47:51 +04:00
|
|
|
|
|
|
|
if (status == ERROR_SUCCESS)
|
|
|
|
{
|
2020-11-19 12:09:34 +03:00
|
|
|
unsigned x;
|
|
|
|
UINT32 GlyphSupportLevel = 0;
|
2021-03-08 14:48:22 +03:00
|
|
|
settings_reg_query_dword(settings, FreeRDP_GlyphSupportLevel, hKey, _T("SupportLevel"));
|
2020-11-19 12:09:34 +03:00
|
|
|
for (x = 0; x < 10; x++)
|
|
|
|
{
|
|
|
|
GLYPH_CACHE_DEFINITION cache = { 0 };
|
|
|
|
TCHAR numentries[64] = { 0 };
|
|
|
|
TCHAR maxsize[64] = { 0 };
|
2021-03-08 14:48:22 +03:00
|
|
|
_sntprintf(numentries, ARRAYSIZE(numentries), _T("Cache%uNumEntries"), x);
|
|
|
|
_sntprintf(maxsize, ARRAYSIZE(maxsize), _T("Cache%uMaxCellSize"), x);
|
2020-11-19 12:09:34 +03:00
|
|
|
|
2021-03-08 14:48:22 +03:00
|
|
|
settings_reg_query_word_val(hKey, numentries, &cache.cacheEntries);
|
|
|
|
settings_reg_query_word_val(hKey, maxsize, &cache.cacheMaximumCellSize);
|
2020-11-19 12:09:34 +03:00
|
|
|
if (!freerdp_settings_set_pointer_array(settings, FreeRDP_GlyphCache, x, &cache))
|
|
|
|
WLog_WARN(TAG, "Failed to store GlyphCache %" PRIuz, x);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
GLYPH_CACHE_DEFINITION cache = { 0 };
|
2021-03-08 14:48:22 +03:00
|
|
|
settings_reg_query_word_val(hKey, _T("FragCacheNumEntries"), &cache.cacheEntries);
|
|
|
|
settings_reg_query_word_val(hKey, _T("FragCacheMaxCellSize"),
|
|
|
|
&cache.cacheMaximumCellSize);
|
2020-11-19 12:09:34 +03:00
|
|
|
if (!freerdp_settings_set_pointer_array(settings, FreeRDP_FragCache, x, &cache))
|
|
|
|
WLog_WARN(TAG, "Failed to store FragCache");
|
|
|
|
}
|
|
|
|
|
2012-10-12 23:47:51 +04:00
|
|
|
RegCloseKey(hKey);
|
2020-11-19 12:09:34 +03:00
|
|
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_GlyphSupportLevel, GlyphSupportLevel))
|
|
|
|
WLog_WARN(TAG, "Failed to load registry keys to settings!");
|
2012-10-12 23:47:51 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
status =
|
|
|
|
RegOpenKeyExA(HKEY_LOCAL_MACHINE, POINTER_CACHE_KEY, 0, KEY_READ | KEY_WOW64_64KEY, &hKey);
|
2012-10-12 23:47:51 +04:00
|
|
|
|
|
|
|
if (status == ERROR_SUCCESS)
|
|
|
|
{
|
2022-12-05 18:29:01 +03:00
|
|
|
settings_reg_query_dword(settings, FreeRDP_LargePointerFlag, hKey, _T("LargePointer"));
|
2021-03-08 14:48:22 +03:00
|
|
|
settings_reg_query_dword(settings, FreeRDP_PointerCacheSize, hKey, _T("PointerCacheSize"));
|
2022-11-22 17:04:54 +03:00
|
|
|
settings_reg_query_dword(settings, FreeRDP_ColorPointerCacheSize, hKey,
|
|
|
|
_T("ColorPointerCacheSize"));
|
2012-10-11 22:59:01 +04:00
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
2012-06-16 01:06:26 +04:00
|
|
|
}
|
|
|
|
|
2018-07-10 13:21:38 +03:00
|
|
|
static void settings_server_load_hkey_local_machine(rdpSettings* settings)
|
2012-07-25 04:46:21 +04:00
|
|
|
{
|
|
|
|
HKEY hKey;
|
|
|
|
LONG status;
|
2020-11-19 12:09:34 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
status = RegOpenKeyExA(HKEY_LOCAL_MACHINE, SERVER_KEY, 0, KEY_READ | KEY_WOW64_64KEY, &hKey);
|
2012-07-25 04:46:21 +04:00
|
|
|
|
|
|
|
if (status != ERROR_SUCCESS)
|
|
|
|
return;
|
|
|
|
|
2021-03-08 14:48:22 +03:00
|
|
|
settings_reg_query_bool(settings, FreeRDP_ExtSecurity, hKey, _T("ExtSecurity"));
|
|
|
|
settings_reg_query_bool(settings, FreeRDP_NlaSecurity, hKey, _T("NlaSecurity"));
|
2023-10-16 20:37:36 +03:00
|
|
|
settings_reg_query_bool(settings, FreeRDP_TlsSecurity, hKey, _T("TlsSecurity"));
|
|
|
|
settings_reg_query_dword(settings, FreeRDP_TlsSecLevel, hKey, _T("TlsSecLevel"));
|
2021-03-08 14:48:22 +03:00
|
|
|
settings_reg_query_bool(settings, FreeRDP_RdpSecurity, hKey, _T("RdpSecurity"));
|
2020-11-19 12:09:34 +03:00
|
|
|
|
2021-03-08 14:48:22 +03:00
|
|
|
RegCloseKey(hKey);
|
2012-07-25 04:46:21 +04:00
|
|
|
}
|
|
|
|
|
2018-07-10 13:21:38 +03:00
|
|
|
static void settings_load_hkey_local_machine(rdpSettings* settings)
|
2012-07-25 04:46:21 +04:00
|
|
|
{
|
2020-11-19 12:09:34 +03:00
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_ServerMode))
|
2012-07-25 04:46:21 +04:00
|
|
|
settings_server_load_hkey_local_machine(settings);
|
|
|
|
else
|
|
|
|
settings_client_load_hkey_local_machine(settings);
|
|
|
|
}
|
|
|
|
|
2018-07-10 13:21:38 +03:00
|
|
|
static BOOL settings_get_computer_name(rdpSettings* settings)
|
2012-10-26 02:38:51 +04:00
|
|
|
{
|
2022-01-10 18:55:48 +03:00
|
|
|
CHAR computerName[256] = { 0 };
|
2020-09-01 12:15:44 +03:00
|
|
|
DWORD nSize = sizeof(computerName);
|
2012-10-26 02:38:51 +04:00
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
if (!GetComputerNameExA(ComputerNameNetBIOS, computerName, &nSize))
|
|
|
|
return FALSE;
|
|
|
|
|
2017-02-24 23:58:08 +03:00
|
|
|
if (nSize > MAX_COMPUTERNAME_LENGTH)
|
|
|
|
computerName[MAX_COMPUTERNAME_LENGTH] = '\0';
|
|
|
|
|
2020-09-01 12:15:44 +03:00
|
|
|
return freerdp_settings_set_string(settings, FreeRDP_ComputerName, computerName);
|
2012-10-26 02:38:51 +04:00
|
|
|
}
|
|
|
|
|
2023-12-07 20:06:43 +03:00
|
|
|
void freerdp_settings_print_warnings(const rdpSettings* settings)
|
|
|
|
{
|
|
|
|
const UINT32 level = freerdp_settings_get_uint32(settings, FreeRDP_GlyphSupportLevel);
|
|
|
|
if (level != GLYPH_SUPPORT_NONE)
|
|
|
|
{
|
|
|
|
char buffer[32] = { 0 };
|
|
|
|
WLog_WARN(TAG, "[experimental] enabled GlyphSupportLevel %s, expect visual artefacts!",
|
|
|
|
freerdp_settings_glyph_level_string(level, buffer, sizeof(buffer)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-22 18:54:42 +03:00
|
|
|
BOOL freerdp_settings_set_default_order_support(rdpSettings* settings)
|
|
|
|
{
|
2020-11-19 12:09:34 +03:00
|
|
|
BYTE* OrderSupport = freerdp_settings_get_pointer_writable(settings, FreeRDP_OrderSupport);
|
|
|
|
if (!OrderSupport)
|
2018-11-22 18:54:42 +03:00
|
|
|
return FALSE;
|
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
ZeroMemory(OrderSupport, 32);
|
|
|
|
OrderSupport[NEG_DSTBLT_INDEX] = TRUE;
|
|
|
|
OrderSupport[NEG_PATBLT_INDEX] = TRUE;
|
|
|
|
OrderSupport[NEG_SCRBLT_INDEX] = TRUE;
|
|
|
|
OrderSupport[NEG_OPAQUE_RECT_INDEX] = TRUE;
|
|
|
|
OrderSupport[NEG_DRAWNINEGRID_INDEX] = FALSE;
|
|
|
|
OrderSupport[NEG_MULTIDSTBLT_INDEX] = FALSE;
|
|
|
|
OrderSupport[NEG_MULTIPATBLT_INDEX] = FALSE;
|
|
|
|
OrderSupport[NEG_MULTISCRBLT_INDEX] = FALSE;
|
|
|
|
OrderSupport[NEG_MULTIOPAQUERECT_INDEX] = TRUE;
|
|
|
|
OrderSupport[NEG_MULTI_DRAWNINEGRID_INDEX] = FALSE;
|
|
|
|
OrderSupport[NEG_LINETO_INDEX] = TRUE;
|
|
|
|
OrderSupport[NEG_POLYLINE_INDEX] = TRUE;
|
|
|
|
OrderSupport[NEG_MEMBLT_INDEX] =
|
2022-05-02 15:20:12 +03:00
|
|
|
freerdp_settings_get_bool(settings, FreeRDP_BitmapCacheEnabled) ? 1 : 0;
|
2020-11-19 12:09:34 +03:00
|
|
|
OrderSupport[NEG_MEM3BLT_INDEX] =
|
2022-05-02 15:20:12 +03:00
|
|
|
freerdp_settings_get_bool(settings, FreeRDP_BitmapCacheEnabled) ? 1 : 0;
|
2020-11-19 12:09:34 +03:00
|
|
|
OrderSupport[NEG_MEMBLT_V2_INDEX] =
|
2022-05-02 15:20:12 +03:00
|
|
|
freerdp_settings_get_bool(settings, FreeRDP_BitmapCacheEnabled) ? 1 : 0;
|
2020-11-19 12:09:34 +03:00
|
|
|
OrderSupport[NEG_MEM3BLT_V2_INDEX] =
|
2022-05-02 15:20:12 +03:00
|
|
|
freerdp_settings_get_bool(settings, FreeRDP_BitmapCacheEnabled) ? 1 : 0;
|
2020-11-19 12:09:34 +03:00
|
|
|
OrderSupport[NEG_SAVEBITMAP_INDEX] = FALSE;
|
|
|
|
OrderSupport[NEG_GLYPH_INDEX_INDEX] =
|
|
|
|
freerdp_settings_get_uint32(settings, FreeRDP_GlyphSupportLevel) != GLYPH_SUPPORT_NONE;
|
|
|
|
OrderSupport[NEG_FAST_INDEX_INDEX] =
|
|
|
|
freerdp_settings_get_uint32(settings, FreeRDP_GlyphSupportLevel) != GLYPH_SUPPORT_NONE;
|
|
|
|
OrderSupport[NEG_FAST_GLYPH_INDEX] =
|
|
|
|
freerdp_settings_get_uint32(settings, FreeRDP_GlyphSupportLevel) != GLYPH_SUPPORT_NONE;
|
|
|
|
OrderSupport[NEG_POLYGON_SC_INDEX] = FALSE;
|
|
|
|
OrderSupport[NEG_POLYGON_CB_INDEX] = FALSE;
|
|
|
|
OrderSupport[NEG_ELLIPSE_SC_INDEX] = FALSE;
|
|
|
|
OrderSupport[NEG_ELLIPSE_CB_INDEX] = FALSE;
|
2018-11-22 18:54:42 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2022-06-27 13:05:24 +03:00
|
|
|
BOOL freerdp_capability_buffer_allocate(rdpSettings* settings, UINT32 count)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(count > 0);
|
|
|
|
WINPR_ASSERT(count == 32);
|
|
|
|
|
|
|
|
freerdp_capability_buffer_free(settings);
|
|
|
|
WINPR_ASSERT(settings->ReceivedCapabilitiesSize == 0);
|
|
|
|
|
|
|
|
settings->ReceivedCapabilitiesSize = count;
|
2023-06-05 13:16:57 +03:00
|
|
|
void* tmp = realloc(settings->ReceivedCapabilities, count * sizeof(BYTE));
|
2022-06-27 13:05:24 +03:00
|
|
|
if (!tmp)
|
|
|
|
return FALSE;
|
|
|
|
memset(tmp, 0, count * sizeof(BYTE));
|
|
|
|
settings->ReceivedCapabilities = tmp;
|
|
|
|
|
2022-10-05 10:30:37 +03:00
|
|
|
tmp = realloc(settings->ReceivedCapabilityData, count * sizeof(BYTE*));
|
|
|
|
if (!tmp)
|
|
|
|
return FALSE;
|
|
|
|
memset(tmp, 0, count * sizeof(BYTE*));
|
|
|
|
settings->ReceivedCapabilityData = tmp;
|
|
|
|
|
|
|
|
tmp = realloc(settings->ReceivedCapabilityDataSizes, count * sizeof(UINT32));
|
|
|
|
if (!tmp)
|
|
|
|
return FALSE;
|
|
|
|
memset(tmp, 0, count * sizeof(UINT32));
|
|
|
|
settings->ReceivedCapabilityDataSizes = tmp;
|
|
|
|
|
|
|
|
return (settings->ReceivedCapabilities && settings->ReceivedCapabilityData &&
|
|
|
|
settings->ReceivedCapabilityDataSizes);
|
2022-06-27 13:05:24 +03:00
|
|
|
}
|
|
|
|
|
2013-10-13 02:20:25 +04:00
|
|
|
rdpSettings* freerdp_settings_new(DWORD flags)
|
2011-07-07 21:37:48 +04:00
|
|
|
{
|
2015-06-02 10:07:17 +03:00
|
|
|
char* base;
|
2022-10-21 10:50:20 +03:00
|
|
|
char* issuers[] = { "FreeRDP", "FreeRDP-licenser" };
|
2023-11-02 17:38:13 +03:00
|
|
|
const BOOL server = (flags & FREERDP_SETTINGS_SERVER_MODE) != 0 ? TRUE : FALSE;
|
|
|
|
const BOOL remote = (flags & FREERDP_SETTINGS_REMOTE_MODE) != 0 ? TRUE : FALSE;
|
2022-06-27 13:05:24 +03:00
|
|
|
rdpSettings* settings = (rdpSettings*)calloc(1, sizeof(rdpSettings));
|
2016-10-10 10:06:05 +03:00
|
|
|
|
2015-03-23 19:25:23 +03:00
|
|
|
if (!settings)
|
|
|
|
return NULL;
|
2012-11-01 04:38:48 +04:00
|
|
|
|
2023-05-09 12:31:16 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_ClipboardFeatureMask,
|
|
|
|
CLIPRDR_FLAG_DEFAULT_MASK))
|
|
|
|
goto out_fail;
|
2022-10-21 10:50:20 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_ServerLicenseCompanyName, "FreeRDP"))
|
|
|
|
goto out_fail;
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_ServerLicenseProductName,
|
|
|
|
"FreeRDP-licensing-server"))
|
|
|
|
goto out_fail;
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_ServerLicenseProductVersion, 1))
|
|
|
|
goto out_fail;
|
|
|
|
if (!freerdp_server_license_issuers_copy(settings, issuers, ARRAYSIZE(issuers)))
|
|
|
|
goto out_fail;
|
|
|
|
|
2023-04-13 13:21:07 +03:00
|
|
|
if (!freerdp_settings_set_uint16(settings, FreeRDP_SupportedColorDepths,
|
|
|
|
RNS_UD_32BPP_SUPPORT | RNS_UD_24BPP_SUPPORT |
|
|
|
|
RNS_UD_16BPP_SUPPORT | RNS_UD_15BPP_SUPPORT))
|
|
|
|
goto out_fail;
|
|
|
|
|
2021-09-10 16:46:33 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_UnicodeInput, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_HasHorizontalWheel, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_HasExtendedMouseEvent, TRUE) ||
|
2023-10-12 14:54:53 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_HasQoeEvent, TRUE) ||
|
2023-10-12 14:09:44 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_HasRelativeMouseEvent, TRUE) ||
|
2022-11-10 11:20:21 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_HiDefRemoteApp, TRUE) ||
|
2020-11-19 12:09:34 +03:00
|
|
|
!freerdp_settings_set_uint32(
|
|
|
|
settings, FreeRDP_RemoteApplicationSupportMask,
|
|
|
|
RAIL_LEVEL_SUPPORTED | RAIL_LEVEL_DOCKED_LANGBAR_SUPPORTED |
|
|
|
|
RAIL_LEVEL_SHELL_INTEGRATION_SUPPORTED | RAIL_LEVEL_LANGUAGE_IME_SYNC_SUPPORTED |
|
|
|
|
RAIL_LEVEL_SERVER_TO_CLIENT_IME_SYNC_SUPPORTED |
|
|
|
|
RAIL_LEVEL_HIDE_MINIMIZED_APPS_SUPPORTED | RAIL_LEVEL_WINDOW_CLOAKING_SUPPORTED |
|
|
|
|
RAIL_LEVEL_HANDSHAKE_EX_SUPPORTED) ||
|
2022-10-14 14:39:58 +03:00
|
|
|
!freerdp_settings_set_uint16(settings, FreeRDP_TextANSICodePage, CP_UTF8) ||
|
|
|
|
!freerdp_settings_set_uint16(settings, FreeRDP_OrderSupportFlags,
|
|
|
|
NEGOTIATE_ORDER_SUPPORT | ZERO_BOUNDS_DELTA_SUPPORT |
|
|
|
|
COLOR_INDEX_SUPPORT) ||
|
2020-11-19 12:09:34 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_SupportHeartbeatPdu, TRUE) ||
|
2023-11-02 17:38:13 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_ServerMode, server) ||
|
2020-11-19 12:09:34 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_WaitForOutputBufferFlush, TRUE) ||
|
2023-02-20 15:26:44 +03:00
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_ClusterInfoFlags, REDIRECTION_SUPPORTED) ||
|
2020-11-19 12:09:34 +03:00
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, 1024) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, 768) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_Workarea, FALSE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_Fullscreen, FALSE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GrabKeyboard, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_Decorations, TRUE) ||
|
2023-10-12 14:07:11 +03:00
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_RdpVersion, RDP_VERSION_10_12) ||
|
2023-05-11 10:41:59 +03:00
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_ColorDepth, 32) ||
|
2023-03-08 04:06:47 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_AadSecurity, FALSE) ||
|
2020-11-19 12:09:34 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_ExtSecurity, FALSE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_NlaSecurity, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_TlsSecurity, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_RdpSecurity, TRUE) ||
|
2023-03-07 13:58:28 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_RdstlsSecurity, FALSE) ||
|
2020-11-19 12:09:34 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_NegotiateSecurityLayer, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_RestrictedAdminModeRequired, FALSE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_MstscCookieMode, FALSE) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_CookieMaxLength,
|
|
|
|
DEFAULT_COOKIE_MAX_LENGTH) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_ClientBuild,
|
|
|
|
18363) || /* Windows 10, Version 1909 */
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardType, 4) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardSubType, 0) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardFunctionKey, 12) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardLayout, 0) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardHook,
|
|
|
|
KEYBOARD_HOOK_FULLSCREEN_ONLY) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_UseRdpSecurityLayer, FALSE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_SaltedChecksum, TRUE) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_ServerPort, 3389) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_GatewayPort, 443) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_DesktopResize, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_ToggleFullscreen, TRUE) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_DesktopPosX, UINT32_MAX) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_DesktopPosY, UINT32_MAX) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_SoftwareGdi, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_UnmapButtons, FALSE) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_PerformanceFlags, PERF_FLAG_NONE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_AllowFontSmoothing, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_AllowDesktopComposition, FALSE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_DisableWallpaper, FALSE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_DisableFullWindowDrag, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_DisableMenuAnims, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_DisableThemes, FALSE) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_ConnectionType, CONNECTION_TYPE_LAN) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_NetworkAutoDetect, TRUE) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_EncryptionMethods, ENCRYPTION_METHOD_NONE) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_EncryptionLevel, ENCRYPTION_LEVEL_NONE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_FIPSMode, FALSE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_CompressionEnabled, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_LogonNotify, TRUE) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_BrushSupportLevel, BRUSH_COLOR_FULL) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_CompressionLevel, PACKET_COMPR_TYPE_RDP61) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_Authentication, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_AuthenticationOnly, FALSE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_CredentialsFromStdin, FALSE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_DisableCredentialsDelegation, FALSE) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_AuthenticationLevel, 2) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_ChannelCount, 0) ||
|
2022-02-02 01:23:34 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_CertificateCallbackPreferPEM, FALSE) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_KeySpec, AT_KEYEXCHANGE))
|
2020-11-19 12:09:34 +03:00
|
|
|
goto out_fail;
|
|
|
|
|
2022-06-27 13:05:24 +03:00
|
|
|
if (!freerdp_settings_set_pointer_len(settings, FreeRDP_ChannelDefArray, NULL,
|
|
|
|
CHANNEL_MAX_COUNT))
|
|
|
|
goto out_fail;
|
2016-10-10 10:06:05 +03:00
|
|
|
|
2022-06-27 13:05:24 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportMonitorLayoutPdu, FALSE))
|
2016-10-10 10:06:05 +03:00
|
|
|
goto out_fail;
|
2015-12-14 20:29:23 +03:00
|
|
|
|
2022-06-27 13:05:24 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_MonitorCount, 0))
|
|
|
|
goto out_fail;
|
2016-10-10 10:06:05 +03:00
|
|
|
|
2022-06-27 13:05:24 +03:00
|
|
|
if (!freerdp_settings_set_pointer_len(settings, FreeRDP_MonitorDefArray, NULL, 32))
|
2016-10-10 10:06:05 +03:00
|
|
|
goto out_fail;
|
2015-12-14 20:29:23 +03:00
|
|
|
|
2022-06-27 13:05:24 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_MonitorLocalShiftX, 0))
|
|
|
|
goto out_fail;
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_MonitorLocalShiftY, 0))
|
|
|
|
goto out_fail;
|
2016-10-10 10:06:05 +03:00
|
|
|
|
2022-07-07 17:06:54 +03:00
|
|
|
if (!freerdp_settings_set_pointer_len(settings, FreeRDP_MonitorIds, NULL, 0))
|
2016-10-10 10:06:05 +03:00
|
|
|
goto out_fail;
|
2015-12-14 20:29:23 +03:00
|
|
|
|
2023-02-20 15:26:44 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_MultitransportFlags,
|
2023-02-21 10:54:15 +03:00
|
|
|
TRANSPORT_TYPE_UDP_FECR))
|
2023-02-20 15:26:44 +03:00
|
|
|
goto out_fail;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportMultitransport, TRUE))
|
|
|
|
goto out_fail;
|
|
|
|
|
2015-12-14 20:29:23 +03:00
|
|
|
if (!settings_get_computer_name(settings))
|
|
|
|
goto out_fail;
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!freerdp_settings_set_pointer_len(settings, FreeRDP_RdpServerCertificate, NULL, 1))
|
|
|
|
goto out_fail;
|
|
|
|
|
2022-06-27 13:05:24 +03:00
|
|
|
if (!freerdp_capability_buffer_allocate(settings, 32))
|
2016-10-10 10:06:05 +03:00
|
|
|
goto out_fail;
|
2015-12-14 20:29:23 +03:00
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
{
|
|
|
|
char tmp[32] = { 0 };
|
|
|
|
if (!freerdp_settings_set_string_len(settings, FreeRDP_ClientProductId, tmp, sizeof(tmp)))
|
|
|
|
goto out_fail;
|
|
|
|
}
|
2016-10-10 10:06:05 +03:00
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
{
|
|
|
|
char ClientHostname[33] = { 0 };
|
2022-03-15 17:19:41 +03:00
|
|
|
DWORD size = sizeof(ClientHostname) - 2;
|
|
|
|
GetComputerNameA(ClientHostname, &size);
|
2020-11-19 12:09:34 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_ClientHostname, ClientHostname))
|
|
|
|
goto out_fail;
|
|
|
|
}
|
2022-11-22 17:04:54 +03:00
|
|
|
|
|
|
|
/* [MS-RDPBCGR] 2.2.7.1.5 Pointer Capability Set (TS_POINTER_CAPABILITYSET)
|
|
|
|
*
|
|
|
|
* if we are in server mode send a reasonable large cache size,
|
|
|
|
* if we are in client mode just set the value to the maximum we want to
|
|
|
|
* support and during capability exchange that size will be limited to the
|
2022-12-05 18:46:02 +03:00
|
|
|
* sizes the server supports
|
|
|
|
*
|
|
|
|
* We have chosen 128 cursors in cache which is at worst 128 * 576kB (384x384 pixel cursor with
|
|
|
|
* 32bit color depth)
|
|
|
|
* */
|
2022-11-22 17:04:54 +03:00
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_ServerMode))
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_PointerCacheSize, 25) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_ColorPointerCacheSize, 25))
|
|
|
|
goto out_fail;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-12-05 18:46:02 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_PointerCacheSize, 128) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_ColorPointerCacheSize, 128))
|
2022-11-22 17:04:54 +03:00
|
|
|
goto out_fail;
|
|
|
|
}
|
|
|
|
|
2022-12-05 18:46:02 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_LargePointerFlag,
|
2020-11-19 12:09:34 +03:00
|
|
|
(LARGE_POINTER_FLAG_96x96 | LARGE_POINTER_FLAG_384x384)) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_SoundBeepsEnabled, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_DrawGdiPlusEnabled, FALSE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_DrawAllowSkipAlpha, TRUE) ||
|
2022-11-25 11:46:24 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_DrawAllowColorSubsampling, FALSE) ||
|
2020-11-19 12:09:34 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_DrawAllowDynamicColorFidelity, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_FrameMarkerCommandEnabled, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_SurfaceFrameMarkerEnabled, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_AllowCacheWaitingList, TRUE) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_BitmapCacheV2NumCells, 5))
|
2016-10-10 10:06:05 +03:00
|
|
|
goto out_fail;
|
2019-11-06 17:24:51 +03:00
|
|
|
settings->BitmapCacheV2CellInfo =
|
2020-09-07 11:42:28 +03:00
|
|
|
(BITMAP_CACHE_V2_CELL_INFO*)calloc(6, sizeof(BITMAP_CACHE_V2_CELL_INFO));
|
2016-10-10 10:06:05 +03:00
|
|
|
|
2015-12-14 20:29:23 +03:00
|
|
|
if (!settings->BitmapCacheV2CellInfo)
|
2016-10-10 10:06:05 +03:00
|
|
|
goto out_fail;
|
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
{
|
|
|
|
BITMAP_CACHE_V2_CELL_INFO cache = { 0 };
|
|
|
|
cache.numEntries = 600;
|
|
|
|
if (!freerdp_settings_set_pointer_array(settings, FreeRDP_BitmapCacheV2CellInfo, 0,
|
|
|
|
&cache) ||
|
|
|
|
!freerdp_settings_set_pointer_array(settings, FreeRDP_BitmapCacheV2CellInfo, 1, &cache))
|
|
|
|
goto out_fail;
|
|
|
|
cache.numEntries = 2048;
|
|
|
|
if (!freerdp_settings_set_pointer_array(settings, FreeRDP_BitmapCacheV2CellInfo, 2,
|
|
|
|
&cache) ||
|
|
|
|
!freerdp_settings_set_pointer_array(settings, FreeRDP_BitmapCacheV2CellInfo, 4, &cache))
|
|
|
|
goto out_fail;
|
|
|
|
cache.numEntries = 4096;
|
|
|
|
if (!freerdp_settings_set_pointer_array(settings, FreeRDP_BitmapCacheV2CellInfo, 3, &cache))
|
|
|
|
goto out_fail;
|
|
|
|
}
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_NoBitmapCompressionHeader, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_RefreshRect, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_SuppressOutput, TRUE) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_GlyphSupportLevel, GLYPH_SUPPORT_NONE))
|
|
|
|
goto out_fail;
|
2020-09-07 11:42:28 +03:00
|
|
|
settings->GlyphCache = calloc(10, sizeof(GLYPH_CACHE_DEFINITION));
|
2016-10-10 10:06:05 +03:00
|
|
|
|
|
|
|
if (!settings->GlyphCache)
|
|
|
|
goto out_fail;
|
|
|
|
|
2020-09-07 11:42:28 +03:00
|
|
|
settings->FragCache = calloc(1, sizeof(GLYPH_CACHE_DEFINITION));
|
2016-10-10 10:06:05 +03:00
|
|
|
|
|
|
|
if (!settings->FragCache)
|
|
|
|
goto out_fail;
|
|
|
|
|
2023-02-03 13:40:35 +03:00
|
|
|
for (size_t x = 0; x < 10; x++)
|
2020-11-19 12:09:34 +03:00
|
|
|
{
|
|
|
|
GLYPH_CACHE_DEFINITION cache = { 0 };
|
|
|
|
cache.cacheEntries = 254;
|
|
|
|
switch (x)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
cache.cacheMaximumCellSize = 4;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 3:
|
|
|
|
cache.cacheMaximumCellSize = 8;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
cache.cacheMaximumCellSize = 16;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
cache.cacheMaximumCellSize = 32;
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
cache.cacheMaximumCellSize = 64;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
cache.cacheMaximumCellSize = 128;
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
cache.cacheMaximumCellSize = 256;
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
cache.cacheMaximumCellSize = 256;
|
|
|
|
break;
|
|
|
|
}
|
2016-10-10 10:06:05 +03:00
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
if (!freerdp_settings_set_pointer_array(settings, FreeRDP_GlyphCache, x, &cache))
|
|
|
|
goto out_fail;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
GLYPH_CACHE_DEFINITION cache = { 0 };
|
|
|
|
cache.cacheEntries = 256;
|
|
|
|
cache.cacheMaximumCellSize = 256;
|
|
|
|
if (!freerdp_settings_set_pointer_array(settings, FreeRDP_FragCache, 0, &cache))
|
|
|
|
goto out_fail;
|
|
|
|
}
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_OffscreenSupportLevel, 0) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_OffscreenCacheSize, 7680) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_OffscreenCacheEntries, 2000) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_DrawNineGridCacheSize, 2560) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_DrawNineGridCacheEntries, 256) ||
|
|
|
|
!freerdp_settings_set_string(settings, FreeRDP_ClientDir, client_dll) ||
|
|
|
|
!freerdp_settings_get_string(settings, FreeRDP_ClientDir) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_RemoteWndSupportLevel,
|
|
|
|
WINDOW_LEVEL_SUPPORTED | WINDOW_LEVEL_SUPPORTED_EX) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_RemoteAppNumIconCaches, 3) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_RemoteAppNumIconCacheEntries, 12) ||
|
2023-11-02 18:41:00 +03:00
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_VCChunkSize,
|
2023-11-02 17:38:13 +03:00
|
|
|
(server && !remote) ? CHANNEL_CHUNK_MAX_LENGTH
|
|
|
|
: CHANNEL_CHUNK_LENGTH) ||
|
2022-12-05 18:46:02 +03:00
|
|
|
/* [MS-RDPBCGR] 2.2.7.2.7 Large Pointer Capability Set (TS_LARGE_POINTER_CAPABILITYSET)
|
|
|
|
requires at least this size */
|
2020-11-19 12:09:34 +03:00
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_MultifragMaxRequestSize,
|
2023-11-02 17:38:13 +03:00
|
|
|
server ? 0 : 608299) ||
|
2020-11-19 12:09:34 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GatewayUseSameCredentials, FALSE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GatewayBypassLocal, FALSE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GatewayRpcTransport, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GatewayHttpTransport, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GatewayUdpTransport, TRUE) ||
|
2021-03-05 14:59:33 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GatewayHttpUseWebsockets, TRUE) ||
|
2022-11-23 13:00:57 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GatewayHttpExtAuthSspiNtlm, FALSE) ||
|
2023-06-26 20:24:58 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GatewayArmTransport, FALSE) ||
|
2020-11-19 12:09:34 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_FastPathInput, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_FastPathOutput, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_LongCredentialsSupported, TRUE) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_FrameAcknowledge, 2) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_MouseMotion, TRUE) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_NSCodecColorLossLevel, 3) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_NSCodecAllowSubsampling, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_NSCodecAllowDynamicColorFidelity, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_AutoReconnectionEnabled, FALSE) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_AutoReconnectMaxRetries, 20) ||
|
2023-08-12 10:20:25 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GfxThinClient, FALSE) ||
|
2022-11-17 18:47:17 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GfxSmallCache, TRUE) ||
|
2020-11-19 12:09:34 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GfxProgressive, FALSE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GfxProgressiveV2, FALSE) ||
|
2021-07-01 11:43:19 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GfxPlanar, TRUE) ||
|
2020-11-19 12:09:34 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GfxH264, FALSE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GfxAVC444, FALSE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GfxSendQoeAck, FALSE))
|
2016-10-10 10:06:05 +03:00
|
|
|
goto out_fail;
|
2020-11-19 12:09:34 +03:00
|
|
|
{
|
|
|
|
ARC_CS_PRIVATE_PACKET cookie = { 0 };
|
|
|
|
if (!freerdp_settings_set_pointer_len(settings, FreeRDP_ClientAutoReconnectCookie, &cookie,
|
2022-04-19 15:29:17 +03:00
|
|
|
1))
|
2020-11-19 12:09:34 +03:00
|
|
|
goto out_fail;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
ARC_SC_PRIVATE_PACKET cookie = { 0 };
|
|
|
|
if (!freerdp_settings_set_pointer_len(settings, FreeRDP_ServerAutoReconnectCookie, &cookie,
|
2022-04-19 15:29:17 +03:00
|
|
|
1))
|
2020-11-19 12:09:34 +03:00
|
|
|
goto out_fail;
|
|
|
|
}
|
2016-10-10 10:06:05 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
settings->ClientTimeZone = (LPTIME_ZONE_INFORMATION)calloc(1, sizeof(TIME_ZONE_INFORMATION));
|
2015-12-14 20:29:23 +03:00
|
|
|
|
|
|
|
if (!settings->ClientTimeZone)
|
2016-10-10 10:06:05 +03:00
|
|
|
goto out_fail;
|
2015-12-14 20:29:23 +03:00
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_TcpKeepAlive, TRUE) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_TcpKeepAliveRetries, 3) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_TcpKeepAliveDelay, 5) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_TcpKeepAliveInterval, 2) ||
|
2021-06-02 17:51:49 +03:00
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_TcpAckTimeout, 9000) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_TcpConnectTimeout, 15000))
|
2020-11-19 12:09:34 +03:00
|
|
|
goto out_fail;
|
2019-11-07 15:02:57 +03:00
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
if (!freerdp_settings_get_bool(settings, FreeRDP_ServerMode))
|
2011-07-07 21:37:48 +04:00
|
|
|
{
|
2020-11-19 12:09:34 +03:00
|
|
|
BOOL rc;
|
|
|
|
char* path;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectClipboard, TRUE))
|
|
|
|
goto out_fail;
|
2016-03-09 16:10:31 +03:00
|
|
|
/* these values are used only by the client part */
|
2020-11-19 12:09:34 +03:00
|
|
|
path = GetKnownPath(KNOWN_PATH_HOME);
|
|
|
|
rc = freerdp_settings_set_string(settings, FreeRDP_HomePath, path);
|
|
|
|
free(path);
|
2016-10-10 10:06:05 +03:00
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
if (!rc || !freerdp_settings_get_string(settings, FreeRDP_HomePath))
|
2016-10-10 10:06:05 +03:00
|
|
|
goto out_fail;
|
2016-03-09 16:10:31 +03:00
|
|
|
|
|
|
|
/* For default FreeRDP continue using same config directory
|
|
|
|
* as in old releases.
|
|
|
|
* Custom builds use <Vendor>/<Product> as config folder. */
|
|
|
|
if (_stricmp(FREERDP_VENDOR_STRING, FREERDP_PRODUCT_STRING))
|
2015-06-02 10:48:32 +03:00
|
|
|
{
|
2021-07-29 11:07:04 +03:00
|
|
|
BOOL res = TRUE;
|
2019-11-06 17:24:51 +03:00
|
|
|
base = GetKnownSubPath(KNOWN_PATH_XDG_CONFIG_HOME, FREERDP_VENDOR_STRING);
|
2016-10-10 10:06:05 +03:00
|
|
|
|
2016-03-09 16:10:31 +03:00
|
|
|
if (base)
|
|
|
|
{
|
2020-11-19 12:09:34 +03:00
|
|
|
char* combined = GetCombinedPath(base, FREERDP_PRODUCT_STRING);
|
2021-07-29 11:07:04 +03:00
|
|
|
res = freerdp_settings_set_string(settings, FreeRDP_ConfigPath, combined);
|
2020-11-19 12:09:34 +03:00
|
|
|
free(combined);
|
2016-03-09 16:10:31 +03:00
|
|
|
}
|
2016-10-10 10:06:05 +03:00
|
|
|
|
|
|
|
free(base);
|
2021-07-29 11:07:04 +03:00
|
|
|
if (!res)
|
2020-11-19 12:09:34 +03:00
|
|
|
goto out_fail;
|
2016-10-10 10:06:05 +03:00
|
|
|
}
|
2014-03-17 18:26:22 +04:00
|
|
|
else
|
2016-10-10 10:06:05 +03:00
|
|
|
{
|
2021-07-29 11:07:04 +03:00
|
|
|
BOOL res;
|
2019-02-07 16:22:28 +03:00
|
|
|
size_t i;
|
2021-07-29 11:07:04 +03:00
|
|
|
char* cpath;
|
2022-06-27 13:05:24 +03:00
|
|
|
char product[sizeof(FREERDP_PRODUCT_STRING)] = { 0 };
|
2012-11-18 09:08:03 +04:00
|
|
|
|
2016-10-10 10:06:05 +03:00
|
|
|
for (i = 0; i < sizeof(product); i++)
|
2016-03-09 16:10:31 +03:00
|
|
|
product[i] = tolower(FREERDP_PRODUCT_STRING[i]);
|
2012-06-16 01:06:26 +04:00
|
|
|
|
2021-07-29 11:07:04 +03:00
|
|
|
cpath = GetKnownSubPath(KNOWN_PATH_XDG_CONFIG_HOME, product);
|
|
|
|
res = freerdp_settings_set_string(settings, FreeRDP_ConfigPath, cpath);
|
|
|
|
free(cpath);
|
|
|
|
if (!res)
|
2020-11-19 12:09:34 +03:00
|
|
|
goto out_fail;
|
2015-06-02 10:48:32 +03:00
|
|
|
}
|
2013-04-23 02:39:18 +04:00
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
if (!freerdp_settings_get_string(settings, FreeRDP_ConfigPath))
|
2016-10-10 10:06:05 +03:00
|
|
|
goto out_fail;
|
2011-07-07 21:37:48 +04:00
|
|
|
}
|
|
|
|
|
2015-12-14 20:29:23 +03:00
|
|
|
settings_load_hkey_local_machine(settings);
|
2011-07-07 21:37:48 +04:00
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_ActionScript, "~/.config/freerdp/action.sh"))
|
|
|
|
goto out_fail;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SmartcardLogon, FALSE))
|
|
|
|
goto out_fail;
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_TlsSecLevel, 1))
|
|
|
|
goto out_fail;
|
2018-11-22 18:54:42 +03:00
|
|
|
settings->OrderSupport = calloc(1, 32);
|
|
|
|
|
2022-07-05 16:57:55 +03:00
|
|
|
freerdp_settings_set_uint16(settings, FreeRDP_TLSMinVersion, TLS1_VERSION);
|
|
|
|
freerdp_settings_set_uint16(settings, FreeRDP_TLSMaxVersion, 0);
|
|
|
|
|
2018-11-22 18:54:42 +03:00
|
|
|
if (!settings->OrderSupport)
|
|
|
|
goto out_fail;
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_default_order_support(settings))
|
|
|
|
goto out_fail;
|
|
|
|
|
2023-01-19 19:39:17 +03:00
|
|
|
const BOOL enable = freerdp_settings_get_bool(settings, FreeRDP_ServerMode);
|
|
|
|
|
2022-06-27 13:05:24 +03:00
|
|
|
{
|
2023-10-16 20:37:36 +03:00
|
|
|
const FreeRDP_Settings_Keys_Bool keys[] = {
|
|
|
|
FreeRDP_SupportDynamicTimeZone, FreeRDP_SupportGraphicsPipeline,
|
|
|
|
FreeRDP_SupportStatusInfoPdu, FreeRDP_SupportErrorInfoPdu, FreeRDP_SupportAsymetricKeys
|
|
|
|
};
|
2022-06-27 13:05:24 +03:00
|
|
|
|
2023-01-19 19:39:17 +03:00
|
|
|
for (size_t x = 0; x < ARRAYSIZE(keys); x++)
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, keys[x], enable))
|
|
|
|
goto out_fail;
|
|
|
|
}
|
2022-06-27 13:05:24 +03:00
|
|
|
}
|
2023-01-20 11:03:16 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportSkipChannelJoin, TRUE))
|
|
|
|
goto out_fail;
|
2023-01-19 19:39:17 +03:00
|
|
|
|
2011-07-07 21:37:48 +04:00
|
|
|
return settings;
|
2015-03-23 19:25:23 +03:00
|
|
|
out_fail:
|
2020-01-07 12:49:17 +03:00
|
|
|
freerdp_settings_free(settings);
|
2016-10-10 10:06:05 +03:00
|
|
|
return NULL;
|
2011-07-07 21:37:48 +04:00
|
|
|
}
|
|
|
|
|
2019-07-16 10:54:31 +03:00
|
|
|
static void freerdp_settings_free_internal(rdpSettings* settings)
|
2011-07-07 21:37:48 +04:00
|
|
|
{
|
2022-10-21 10:50:20 +03:00
|
|
|
freerdp_server_license_issuers_free(settings);
|
2016-10-10 10:06:05 +03:00
|
|
|
freerdp_target_net_addresses_free(settings);
|
|
|
|
freerdp_device_collection_free(settings);
|
|
|
|
freerdp_static_channel_collection_free(settings);
|
|
|
|
freerdp_dynamic_channel_collection_free(settings);
|
2020-05-15 13:22:37 +03:00
|
|
|
|
2022-06-27 13:05:24 +03:00
|
|
|
freerdp_capability_buffer_free(settings);
|
2020-05-15 13:22:37 +03:00
|
|
|
|
|
|
|
/* Free all strings, set other pointers NULL */
|
|
|
|
freerdp_settings_free_keys(settings, TRUE);
|
2019-07-16 10:54:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void freerdp_settings_free(rdpSettings* settings)
|
|
|
|
{
|
|
|
|
if (!settings)
|
|
|
|
return;
|
|
|
|
|
|
|
|
freerdp_settings_free_internal(settings);
|
2016-10-10 10:06:05 +03:00
|
|
|
free(settings);
|
2011-07-07 21:37:48 +04:00
|
|
|
}
|
2012-10-14 09:17:25 +04:00
|
|
|
|
2020-05-15 13:22:37 +03:00
|
|
|
static BOOL freerdp_settings_int_buffer_copy(rdpSettings* _settings, const rdpSettings* settings)
|
2019-07-16 10:54:31 +03:00
|
|
|
{
|
2020-05-15 13:22:37 +03:00
|
|
|
BOOL rc = FALSE;
|
2019-07-16 10:54:31 +03:00
|
|
|
UINT32 index;
|
|
|
|
|
2020-05-15 13:22:37 +03:00
|
|
|
if (!_settings || !settings)
|
2019-07-16 10:54:31 +03:00
|
|
|
return FALSE;
|
|
|
|
|
2022-06-30 11:15:45 +03:00
|
|
|
{
|
|
|
|
const void* data = freerdp_settings_get_pointer(settings, FreeRDP_LoadBalanceInfo);
|
|
|
|
const UINT32 len = freerdp_settings_get_uint32(settings, FreeRDP_LoadBalanceInfoLength);
|
|
|
|
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_LoadBalanceInfo, data, len))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
const void* data = freerdp_settings_get_pointer(settings, FreeRDP_ServerRandom);
|
|
|
|
const UINT32 len = freerdp_settings_get_uint32(settings, FreeRDP_ServerRandomLength);
|
|
|
|
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_ServerRandom, data, len))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
const void* data = freerdp_settings_get_pointer(settings, FreeRDP_ClientRandom);
|
|
|
|
const UINT32 len = freerdp_settings_get_uint32(settings, FreeRDP_ClientRandomLength);
|
|
|
|
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_ClientRandom, data, len))
|
|
|
|
return FALSE;
|
|
|
|
}
|
2022-10-21 10:50:20 +03:00
|
|
|
if (!freerdp_server_license_issuers_copy(_settings, settings->ServerLicenseProductIssuers,
|
|
|
|
settings->ServerLicenseProductIssuersCount))
|
|
|
|
return FALSE;
|
|
|
|
|
2022-06-30 11:15:45 +03:00
|
|
|
{
|
|
|
|
const void* data = freerdp_settings_get_pointer(settings, FreeRDP_ServerCertificate);
|
|
|
|
const UINT32 len = freerdp_settings_get_uint32(settings, FreeRDP_ServerCertificateLength);
|
|
|
|
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_ServerCertificate, data, len))
|
|
|
|
return FALSE;
|
|
|
|
}
|
2019-07-16 10:54:31 +03:00
|
|
|
if (settings->RdpServerCertificate)
|
|
|
|
{
|
2023-02-03 13:40:35 +03:00
|
|
|
rdpCertificate* cert = freerdp_certificate_clone(settings->RdpServerCertificate);
|
|
|
|
if (!cert)
|
|
|
|
goto out_fail;
|
2022-06-27 13:05:24 +03:00
|
|
|
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_RdpServerCertificate, cert, 1))
|
|
|
|
goto out_fail;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_RdpServerCertificate, NULL, 0))
|
2019-07-16 10:54:31 +03:00
|
|
|
goto out_fail;
|
|
|
|
}
|
|
|
|
|
2019-07-16 13:27:11 +03:00
|
|
|
if (settings->RdpServerRsaKey)
|
|
|
|
{
|
2023-02-03 17:15:18 +03:00
|
|
|
rdpPrivateKey* key = freerdp_key_clone(settings->RdpServerRsaKey);
|
2023-02-03 13:40:35 +03:00
|
|
|
if (!key)
|
|
|
|
goto out_fail;
|
2022-06-27 13:05:24 +03:00
|
|
|
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_RdpServerRsaKey, key, 1))
|
|
|
|
goto out_fail;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_RdpServerRsaKey, NULL, 0))
|
2019-07-16 13:27:11 +03:00
|
|
|
goto out_fail;
|
|
|
|
}
|
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
if (!freerdp_settings_set_uint32(_settings, FreeRDP_ChannelCount,
|
|
|
|
freerdp_settings_get_uint32(settings, FreeRDP_ChannelCount)))
|
|
|
|
goto out_fail;
|
|
|
|
if (!freerdp_settings_set_uint32(
|
|
|
|
_settings, FreeRDP_ChannelDefArraySize,
|
|
|
|
freerdp_settings_get_uint32(settings, FreeRDP_ChannelDefArraySize)))
|
|
|
|
goto out_fail;
|
2019-07-16 10:54:31 +03:00
|
|
|
|
2022-06-27 13:05:24 +03:00
|
|
|
const UINT32 defArraySize = freerdp_settings_get_uint32(settings, FreeRDP_ChannelDefArraySize);
|
|
|
|
const CHANNEL_DEF* defArray = freerdp_settings_get_pointer(settings, FreeRDP_ChannelDefArray);
|
|
|
|
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_ChannelDefArray, defArray,
|
|
|
|
defArraySize))
|
|
|
|
goto out_fail;
|
2019-07-16 10:54:31 +03:00
|
|
|
|
2022-06-30 11:15:45 +03:00
|
|
|
{
|
|
|
|
const UINT32 count = freerdp_settings_get_uint32(settings, FreeRDP_MonitorDefArraySize);
|
|
|
|
const rdpMonitor* monitors =
|
|
|
|
freerdp_settings_get_pointer(settings, FreeRDP_MonitorDefArray);
|
2019-07-16 10:54:31 +03:00
|
|
|
|
2022-06-30 11:15:45 +03:00
|
|
|
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_MonitorDefArray, monitors, count))
|
|
|
|
goto out_fail;
|
|
|
|
}
|
2019-07-16 10:54:31 +03:00
|
|
|
|
2022-06-27 13:05:24 +03:00
|
|
|
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_MonitorIds, NULL, 16))
|
|
|
|
goto out_fail;
|
2019-07-16 10:54:31 +03:00
|
|
|
|
2022-06-27 13:05:24 +03:00
|
|
|
const UINT32 monitorIdSize = freerdp_settings_get_uint32(settings, FreeRDP_NumMonitorIds);
|
|
|
|
const UINT32* monitorIds = freerdp_settings_get_pointer(settings, FreeRDP_MonitorIds);
|
|
|
|
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_MonitorIds, monitorIds, monitorIdSize))
|
2019-07-16 10:54:31 +03:00
|
|
|
goto out_fail;
|
|
|
|
|
|
|
|
_settings->OrderSupport = malloc(32);
|
|
|
|
|
|
|
|
if (!_settings->OrderSupport)
|
|
|
|
goto out_fail;
|
|
|
|
|
2022-06-27 13:05:24 +03:00
|
|
|
if (!freerdp_capability_buffer_copy(_settings, settings))
|
2019-07-16 10:54:31 +03:00
|
|
|
goto out_fail;
|
|
|
|
CopyMemory(_settings->OrderSupport, settings->OrderSupport, 32);
|
|
|
|
|
2022-06-27 13:05:24 +03:00
|
|
|
const UINT32 cellInfoSize =
|
|
|
|
freerdp_settings_get_uint32(settings, FreeRDP_BitmapCacheV2NumCells);
|
|
|
|
const BITMAP_CACHE_V2_CELL_INFO* cellInfo =
|
|
|
|
freerdp_settings_get_pointer(settings, FreeRDP_BitmapCacheV2CellInfo);
|
|
|
|
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_BitmapCacheV2CellInfo, cellInfo,
|
|
|
|
cellInfoSize))
|
2019-07-16 10:54:31 +03:00
|
|
|
goto out_fail;
|
|
|
|
|
2022-06-27 13:05:24 +03:00
|
|
|
const UINT32 glyphCacheCount = 10;
|
|
|
|
const GLYPH_CACHE_DEFINITION* glyphCache =
|
|
|
|
freerdp_settings_get_pointer(settings, FreeRDP_GlyphCache);
|
|
|
|
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_GlyphCache, glyphCache,
|
|
|
|
glyphCacheCount))
|
2019-07-16 10:54:31 +03:00
|
|
|
goto out_fail;
|
|
|
|
|
2022-06-27 13:05:24 +03:00
|
|
|
const UINT32 fragCacheCount = 1;
|
|
|
|
const GLYPH_CACHE_DEFINITION* fragCache =
|
|
|
|
freerdp_settings_get_pointer(settings, FreeRDP_FragCache);
|
|
|
|
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_FragCache, fragCache, fragCacheCount))
|
2019-07-16 10:54:31 +03:00
|
|
|
goto out_fail;
|
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
if (!freerdp_settings_set_pointer_len(
|
|
|
|
_settings, FreeRDP_ClientAutoReconnectCookie,
|
2022-04-19 15:29:17 +03:00
|
|
|
freerdp_settings_get_pointer(settings, FreeRDP_ClientAutoReconnectCookie), 1))
|
2019-07-16 10:54:31 +03:00
|
|
|
goto out_fail;
|
2020-11-19 12:09:34 +03:00
|
|
|
if (!freerdp_settings_set_pointer_len(
|
|
|
|
_settings, FreeRDP_ServerAutoReconnectCookie,
|
2022-04-19 15:29:17 +03:00
|
|
|
freerdp_settings_get_pointer(settings, FreeRDP_ServerAutoReconnectCookie), 1))
|
2019-07-16 10:54:31 +03:00
|
|
|
goto out_fail;
|
|
|
|
|
2022-06-27 13:05:24 +03:00
|
|
|
const TIME_ZONE_INFORMATION* tz =
|
|
|
|
freerdp_settings_get_pointer(settings, FreeRDP_ClientTimeZone);
|
|
|
|
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_ClientTimeZone, tz, 1))
|
2019-07-16 10:54:31 +03:00
|
|
|
goto out_fail;
|
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
if (!freerdp_settings_set_uint32(
|
|
|
|
_settings, FreeRDP_RedirectionPasswordLength,
|
|
|
|
freerdp_settings_get_uint32(settings, FreeRDP_RedirectionPasswordLength)))
|
|
|
|
goto out_fail;
|
2022-06-27 13:05:24 +03:00
|
|
|
const UINT32 redirectionPasswordLength =
|
|
|
|
freerdp_settings_get_uint32(settings, FreeRDP_RedirectionPasswordLength);
|
|
|
|
const BYTE* pwd = freerdp_settings_get_pointer(settings, FreeRDP_RedirectionPassword);
|
|
|
|
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_RedirectionPassword, pwd,
|
|
|
|
redirectionPasswordLength))
|
|
|
|
goto out_fail;
|
2019-08-14 13:34:12 +03:00
|
|
|
|
2022-06-27 13:05:24 +03:00
|
|
|
const UINT32 RedirectionTsvUrlLength =
|
|
|
|
freerdp_settings_get_uint32(settings, FreeRDP_RedirectionTsvUrlLength);
|
|
|
|
const BYTE* RedirectionTsvUrl =
|
|
|
|
freerdp_settings_get_pointer(settings, FreeRDP_RedirectionTsvUrl);
|
|
|
|
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_RedirectionTsvUrl, RedirectionTsvUrl,
|
|
|
|
RedirectionTsvUrlLength))
|
|
|
|
goto out_fail;
|
2019-08-14 13:34:12 +03:00
|
|
|
|
2024-01-04 17:47:40 +03:00
|
|
|
const UINT32 nrports = freerdp_settings_get_uint32(settings, FreeRDP_TargetNetAddressCount);
|
|
|
|
if (!freerdp_target_net_adresses_reset(_settings, nrports))
|
|
|
|
return FALSE;
|
2019-07-16 10:54:31 +03:00
|
|
|
|
2024-01-04 17:47:40 +03:00
|
|
|
for (UINT32 i = 0; i < nrports; i++)
|
2019-07-16 10:54:31 +03:00
|
|
|
{
|
2024-01-04 17:47:40 +03:00
|
|
|
const char* address =
|
|
|
|
freerdp_settings_get_pointer_array(settings, FreeRDP_TargetNetAddresses, i);
|
|
|
|
const UINT32* port =
|
|
|
|
freerdp_settings_get_pointer_array(settings, FreeRDP_TargetNetPorts, i);
|
|
|
|
if (!freerdp_settings_set_pointer_array(_settings, FreeRDP_TargetNetAddresses, i, address))
|
|
|
|
return FALSE;
|
|
|
|
if (!freerdp_settings_set_pointer_array(_settings, FreeRDP_TargetNetPorts, i, port))
|
|
|
|
return FALSE;
|
2019-07-16 10:54:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2022-04-28 09:00:39 +03:00
|
|
|
const UINT32 len = freerdp_settings_get_uint32(_settings, FreeRDP_DeviceArraySize);
|
|
|
|
const UINT32 count = freerdp_settings_get_uint32(settings, FreeRDP_DeviceCount);
|
2019-07-16 10:54:31 +03:00
|
|
|
|
2022-04-28 09:00:39 +03:00
|
|
|
if (len < count)
|
|
|
|
goto out_fail;
|
|
|
|
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_DeviceArray, NULL, len))
|
2019-07-16 10:54:31 +03:00
|
|
|
goto out_fail;
|
2023-07-06 14:46:31 +03:00
|
|
|
if (!freerdp_settings_set_uint32(_settings, FreeRDP_DeviceCount, count))
|
|
|
|
goto out_fail;
|
2019-07-16 10:54:31 +03:00
|
|
|
|
2022-04-28 09:00:39 +03:00
|
|
|
for (index = 0; index < count; index++)
|
|
|
|
{
|
|
|
|
const RDPDR_DEVICE* argv =
|
|
|
|
freerdp_settings_get_pointer_array(settings, FreeRDP_DeviceArray, index);
|
|
|
|
if (!freerdp_settings_set_pointer_array(_settings, FreeRDP_DeviceArray, index, argv))
|
|
|
|
goto out_fail;
|
|
|
|
}
|
2019-07-16 10:54:31 +03:00
|
|
|
}
|
|
|
|
{
|
2022-04-28 09:00:39 +03:00
|
|
|
const UINT32 len = freerdp_settings_get_uint32(_settings, FreeRDP_StaticChannelArraySize);
|
|
|
|
const UINT32 count = freerdp_settings_get_uint32(settings, FreeRDP_StaticChannelCount);
|
2019-07-16 10:54:31 +03:00
|
|
|
|
2022-04-28 09:00:39 +03:00
|
|
|
if (len < count)
|
|
|
|
goto out_fail;
|
|
|
|
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_StaticChannelArray, NULL, len))
|
2019-07-16 10:54:31 +03:00
|
|
|
goto out_fail;
|
2023-07-06 14:46:31 +03:00
|
|
|
if (!freerdp_settings_set_uint32(_settings, FreeRDP_StaticChannelCount, count))
|
|
|
|
goto out_fail;
|
2019-07-16 10:54:31 +03:00
|
|
|
|
2022-04-28 09:00:39 +03:00
|
|
|
for (index = 0; index < count; index++)
|
|
|
|
{
|
|
|
|
const ADDIN_ARGV* argv =
|
|
|
|
freerdp_settings_get_pointer_array(settings, FreeRDP_StaticChannelArray, index);
|
|
|
|
if (!freerdp_settings_set_pointer_array(_settings, FreeRDP_StaticChannelArray, index,
|
|
|
|
argv))
|
|
|
|
goto out_fail;
|
|
|
|
}
|
2019-07-16 10:54:31 +03:00
|
|
|
}
|
|
|
|
{
|
2022-04-28 09:00:39 +03:00
|
|
|
const UINT32 len = freerdp_settings_get_uint32(_settings, FreeRDP_DynamicChannelArraySize);
|
|
|
|
const UINT32 count = freerdp_settings_get_uint32(settings, FreeRDP_DynamicChannelCount);
|
2019-07-16 10:54:31 +03:00
|
|
|
|
2022-04-28 09:00:39 +03:00
|
|
|
if (len < count)
|
|
|
|
goto out_fail;
|
2023-07-06 14:46:31 +03:00
|
|
|
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_DynamicChannelArray, NULL, len))
|
2019-07-16 10:54:31 +03:00
|
|
|
goto out_fail;
|
2022-04-28 09:00:39 +03:00
|
|
|
if (!freerdp_settings_set_uint32(_settings, FreeRDP_DynamicChannelCount, count))
|
|
|
|
goto out_fail;
|
|
|
|
|
|
|
|
for (index = 0; index < count; index++)
|
|
|
|
{
|
|
|
|
const ADDIN_ARGV* argv =
|
|
|
|
freerdp_settings_get_pointer_array(settings, FreeRDP_DynamicChannelArray, index);
|
|
|
|
if (!freerdp_settings_set_pointer_array(_settings, FreeRDP_DynamicChannelArray, index,
|
|
|
|
argv))
|
|
|
|
goto out_fail;
|
|
|
|
}
|
2019-07-16 10:54:31 +03:00
|
|
|
}
|
|
|
|
|
2020-11-19 12:09:34 +03:00
|
|
|
rc = freerdp_settings_set_string(_settings, FreeRDP_ActionScript,
|
|
|
|
freerdp_settings_get_string(settings, FreeRDP_ActionScript));
|
|
|
|
|
2020-05-15 13:22:37 +03:00
|
|
|
out_fail:
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL freerdp_settings_copy(rdpSettings* _settings, const rdpSettings* settings)
|
|
|
|
{
|
|
|
|
BOOL rc;
|
|
|
|
|
|
|
|
if (!settings || !_settings)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* This is required to free all non string buffers */
|
|
|
|
freerdp_settings_free_internal(_settings);
|
|
|
|
/* This copies everything except allocated non string buffers. reset all allocated buffers to
|
|
|
|
* NULL to fix issues during cleanup */
|
|
|
|
rc = freerdp_settings_clone_keys(_settings, settings);
|
|
|
|
|
|
|
|
_settings->LoadBalanceInfo = NULL;
|
|
|
|
_settings->ServerRandom = NULL;
|
|
|
|
_settings->ClientRandom = NULL;
|
2021-10-18 15:12:22 +03:00
|
|
|
_settings->ServerCertificate = NULL;
|
2020-05-15 13:22:37 +03:00
|
|
|
_settings->RdpServerCertificate = NULL;
|
|
|
|
_settings->RdpServerRsaKey = NULL;
|
|
|
|
_settings->ChannelDefArray = NULL;
|
|
|
|
_settings->MonitorDefArray = NULL;
|
|
|
|
_settings->MonitorIds = NULL;
|
|
|
|
_settings->OrderSupport = NULL;
|
|
|
|
_settings->BitmapCacheV2CellInfo = NULL;
|
|
|
|
_settings->GlyphCache = NULL;
|
|
|
|
_settings->FragCache = NULL;
|
|
|
|
_settings->ClientAutoReconnectCookie = NULL;
|
|
|
|
_settings->ServerAutoReconnectCookie = NULL;
|
|
|
|
_settings->ClientTimeZone = NULL;
|
|
|
|
_settings->RedirectionPassword = NULL;
|
|
|
|
_settings->RedirectionTsvUrl = NULL;
|
|
|
|
_settings->TargetNetAddresses = NULL;
|
2024-01-04 17:47:40 +03:00
|
|
|
_settings->TargetNetPorts = NULL;
|
2020-05-15 13:22:37 +03:00
|
|
|
_settings->DeviceArray = NULL;
|
|
|
|
_settings->StaticChannelArray = NULL;
|
|
|
|
_settings->DynamicChannelArray = NULL;
|
2022-10-05 10:30:37 +03:00
|
|
|
_settings->ReceivedCapabilities = NULL;
|
|
|
|
_settings->ReceivedCapabilityData = NULL;
|
|
|
|
_settings->ReceivedCapabilityDataSizes = NULL;
|
2020-11-19 12:09:34 +03:00
|
|
|
|
2022-10-21 10:50:20 +03:00
|
|
|
_settings->ServerLicenseProductIssuersCount = 0;
|
|
|
|
_settings->ServerLicenseProductIssuers = NULL;
|
|
|
|
|
2020-05-15 13:22:37 +03:00
|
|
|
if (!rc)
|
|
|
|
goto out_fail;
|
|
|
|
|
|
|
|
/* Begin copying */
|
|
|
|
if (!freerdp_settings_int_buffer_copy(_settings, settings))
|
|
|
|
goto out_fail;
|
2019-07-16 10:54:31 +03:00
|
|
|
return TRUE;
|
2019-07-16 13:27:39 +03:00
|
|
|
out_fail:
|
|
|
|
freerdp_settings_free_internal(_settings);
|
|
|
|
return FALSE;
|
2019-07-16 10:54:31 +03:00
|
|
|
}
|
|
|
|
|
2019-07-17 15:51:11 +03:00
|
|
|
rdpSettings* freerdp_settings_clone(const rdpSettings* settings)
|
2019-07-16 10:54:31 +03:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
rdpSettings* _settings = (rdpSettings*)calloc(1, sizeof(rdpSettings));
|
2019-07-16 10:54:31 +03:00
|
|
|
|
|
|
|
if (!freerdp_settings_copy(_settings, settings))
|
|
|
|
goto out_fail;
|
|
|
|
|
|
|
|
return _settings;
|
|
|
|
out_fail:
|
2020-05-15 13:22:37 +03:00
|
|
|
freerdp_settings_free(_settings);
|
2019-07-16 10:54:31 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
2021-04-28 16:00:24 +03:00
|
|
|
#ifdef _MSC_VER
|
2012-10-14 09:17:25 +04:00
|
|
|
#pragma warning(pop)
|
2012-10-14 11:22:58 +04:00
|
|
|
#endif
|
2023-04-04 18:04:30 +03:00
|
|
|
|
|
|
|
static void zfree(WCHAR* str, size_t len)
|
|
|
|
{
|
|
|
|
if (str)
|
|
|
|
memset(str, 0, len * sizeof(WCHAR));
|
|
|
|
free(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL identity_set_from_settings_with_pwd(SEC_WINNT_AUTH_IDENTITY* identity,
|
2023-10-16 10:32:27 +03:00
|
|
|
const rdpSettings* settings,
|
|
|
|
FreeRDP_Settings_Keys_String UserId,
|
|
|
|
FreeRDP_Settings_Keys_String DomainId,
|
|
|
|
const WCHAR* Password, size_t pwdLen)
|
2023-04-04 18:04:30 +03:00
|
|
|
{
|
|
|
|
WINPR_ASSERT(identity);
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
|
|
|
|
size_t UserLen = 0;
|
|
|
|
size_t DomainLen = 0;
|
|
|
|
|
|
|
|
WCHAR* Username = freerdp_settings_get_string_as_utf16(settings, UserId, &UserLen);
|
|
|
|
WCHAR* Domain = freerdp_settings_get_string_as_utf16(settings, DomainId, &DomainLen);
|
|
|
|
|
|
|
|
const int rc = sspi_SetAuthIdentityWithLengthW(identity, Username, UserLen, Domain, DomainLen,
|
|
|
|
Password, pwdLen);
|
|
|
|
zfree(Username, UserLen);
|
|
|
|
zfree(Domain, DomainLen);
|
|
|
|
if (rc < 0)
|
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL identity_set_from_settings(SEC_WINNT_AUTH_IDENTITY_W* identity, const rdpSettings* settings,
|
2023-10-16 10:32:27 +03:00
|
|
|
FreeRDP_Settings_Keys_String UserId,
|
2023-10-16 20:37:36 +03:00
|
|
|
FreeRDP_Settings_Keys_String DomainId,
|
|
|
|
FreeRDP_Settings_Keys_String PwdId)
|
2023-04-04 18:04:30 +03:00
|
|
|
{
|
|
|
|
WINPR_ASSERT(identity);
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
|
|
|
|
size_t PwdLen = 0;
|
|
|
|
|
|
|
|
WCHAR* Password = freerdp_settings_get_string_as_utf16(settings, PwdId, &PwdLen);
|
|
|
|
|
|
|
|
const BOOL rc =
|
|
|
|
identity_set_from_settings_with_pwd(identity, settings, UserId, DomainId, Password, PwdLen);
|
|
|
|
zfree(Password, PwdLen);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL identity_set_from_smartcard_hash(SEC_WINNT_AUTH_IDENTITY_W* identity,
|
2023-10-16 10:32:27 +03:00
|
|
|
const rdpSettings* settings,
|
|
|
|
FreeRDP_Settings_Keys_String userId,
|
2023-10-16 20:37:36 +03:00
|
|
|
FreeRDP_Settings_Keys_String domainId,
|
|
|
|
FreeRDP_Settings_Keys_String pwdId, const BYTE* certSha1,
|
|
|
|
size_t sha1len)
|
2023-04-04 18:04:30 +03:00
|
|
|
{
|
|
|
|
#ifdef _WIN32
|
|
|
|
CERT_CREDENTIAL_INFO certInfo = { sizeof(CERT_CREDENTIAL_INFO), { 0 } };
|
|
|
|
LPWSTR marshalledCredentials = NULL;
|
|
|
|
|
|
|
|
memcpy(certInfo.rgbHashOfCert, certSha1, MIN(sha1len, sizeof(certInfo.rgbHashOfCert)));
|
|
|
|
|
|
|
|
if (!CredMarshalCredentialW(CertCredential, &certInfo, &marshalledCredentials))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "error marshalling cert credentials");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t pwdLen = 0;
|
|
|
|
WCHAR* Password = freerdp_settings_get_string_as_utf16(settings, pwdId, &pwdLen);
|
|
|
|
const int rc = sspi_SetAuthIdentityWithLengthW(
|
|
|
|
identity, marshalledCredentials, _wcslen(marshalledCredentials), NULL, 0, Password, pwdLen);
|
|
|
|
zfree(Password, pwdLen);
|
|
|
|
CredFree(marshalledCredentials);
|
|
|
|
if (rc < 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
#else
|
|
|
|
if (!identity_set_from_settings(identity, settings, userId, domainId, pwdId))
|
|
|
|
return FALSE;
|
|
|
|
#endif /* _WIN32 */
|
2023-04-13 15:20:29 +03:00
|
|
|
return TRUE;
|
2023-04-04 18:04:30 +03:00
|
|
|
}
|
2023-12-07 20:06:43 +03:00
|
|
|
|
|
|
|
const char* freerdp_settings_glyph_level_string(UINT32 level, char* buffer, size_t size)
|
|
|
|
{
|
|
|
|
const char* str = "GLYPH_SUPPORT_UNKNOWN";
|
|
|
|
switch (level)
|
|
|
|
{
|
|
|
|
case GLYPH_SUPPORT_NONE:
|
|
|
|
str = "GLYPH_SUPPORT_NONE";
|
|
|
|
break;
|
|
|
|
case GLYPH_SUPPORT_PARTIAL:
|
|
|
|
str = "GLYPH_SUPPORT_PARTIAL";
|
|
|
|
break;
|
|
|
|
case GLYPH_SUPPORT_FULL:
|
|
|
|
str = "GLYPH_SUPPORT_FULL";
|
|
|
|
break;
|
|
|
|
case GLYPH_SUPPORT_ENCODE:
|
|
|
|
str = "GLYPH_SUPPORT_ENCODE";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
_snprintf(buffer, size, "%s[0x%08" PRIx32 "]", str, level);
|
|
|
|
return buffer;
|
|
|
|
}
|
2024-01-04 17:47:40 +03:00
|
|
|
|
|
|
|
BOOL freerdp_target_net_adresses_reset(rdpSettings* settings, size_t size)
|
|
|
|
{
|
|
|
|
freerdp_target_net_addresses_free(settings);
|
|
|
|
|
|
|
|
if (size > 0)
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_pointer_len_(settings, FreeRDP_TargetNetPorts, -1, NULL, size,
|
|
|
|
sizeof(UINT32)))
|
|
|
|
return FALSE;
|
|
|
|
if (!freerdp_settings_set_pointer_len_(settings, FreeRDP_TargetNetAddresses,
|
|
|
|
FreeRDP_TargetNetAddressCount, NULL, size,
|
|
|
|
sizeof(char*)))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|