2012-10-17 11:42:13 +04:00
|
|
|
|
/**
|
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
|
|
|
* .rdp file
|
|
|
|
|
*
|
|
|
|
|
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
2022-02-16 13:20:38 +03:00
|
|
|
|
#include <freerdp/config.h>
|
2012-10-17 11:42:13 +04:00
|
|
|
|
|
2017-11-14 18:10:52 +03:00
|
|
|
|
#include <errno.h>
|
2019-09-26 17:58:41 +03:00
|
|
|
|
#include <ctype.h>
|
2021-04-12 12:06:45 +03:00
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
#include <winpr/string.h>
|
2021-05-31 12:42:03 +03:00
|
|
|
|
#include <winpr/file.h>
|
2017-11-14 18:10:52 +03:00
|
|
|
|
|
2012-10-17 11:42:13 +04:00
|
|
|
|
#include <freerdp/client/file.h>
|
2012-11-26 23:31:31 +04:00
|
|
|
|
#include <freerdp/client/cmdline.h>
|
2012-10-17 11:42:13 +04:00
|
|
|
|
|
2021-04-12 12:06:45 +03:00
|
|
|
|
#include <freerdp/channels/urbdrc.h>
|
2021-09-23 15:52:03 +03:00
|
|
|
|
#include <freerdp/channels/rdpecam.h>
|
2021-04-12 12:06:45 +03:00
|
|
|
|
|
2012-10-17 11:42:13 +04:00
|
|
|
|
/**
|
|
|
|
|
* Remote Desktop Plus - Overview of .rdp file settings:
|
|
|
|
|
* http://www.donkz.nl/files/rdpsettings.html
|
|
|
|
|
*
|
|
|
|
|
* RDP Settings for Remote Desktop Services in Windows Server 2008 R2:
|
|
|
|
|
* http://technet.microsoft.com/en-us/library/ff393699/
|
2021-04-12 12:06:45 +03:00
|
|
|
|
*
|
|
|
|
|
* https://docs.microsoft.com/en-us/windows-server/remote/remote-desktop-services/clients/rdp-files
|
2012-10-17 11:42:13 +04:00
|
|
|
|
*/
|
2012-10-28 04:25:11 +04:00
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
2019-11-06 17:24:51 +03:00
|
|
|
|
#include <unistd.h>
|
2012-10-28 04:25:11 +04:00
|
|
|
|
#endif
|
|
|
|
|
|
2017-08-29 10:09:38 +03:00
|
|
|
|
#include <winpr/wtypes.h>
|
2012-10-28 04:25:11 +04:00
|
|
|
|
#include <winpr/crt.h>
|
2019-08-23 10:57:26 +03:00
|
|
|
|
#include <winpr/path.h>
|
2014-09-12 19:13:01 +04:00
|
|
|
|
#include <freerdp/log.h>
|
|
|
|
|
#define TAG CLIENT_TAG("common")
|
2012-10-28 04:25:11 +04:00
|
|
|
|
|
2019-07-18 11:59:59 +03:00
|
|
|
|
/*#define DEBUG_CLIENT_FILE 1*/
|
2012-10-28 20:12:36 +04:00
|
|
|
|
|
2019-08-23 10:57:26 +03:00
|
|
|
|
static const BYTE BOM_UTF16_LE[2] = { 0xFF, 0xFE };
|
2012-10-28 04:25:11 +04:00
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
#define INVALID_INTEGER_VALUE 0xFFFFFFFF
|
2012-10-28 05:30:08 +04:00
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
#define RDP_FILE_LINE_FLAG_FORMATTED 0x00000001
|
|
|
|
|
#define RDP_FILE_LINE_FLAG_STANDARD 0x00000002
|
|
|
|
|
#define RDP_FILE_LINE_FLAG_TYPE_STRING 0x00000010
|
|
|
|
|
#define RDP_FILE_LINE_FLAG_TYPE_INTEGER 0x00000020
|
|
|
|
|
#define RDP_FILE_LINE_FLAG_TYPE_BINARY 0x00000040
|
2019-07-15 11:08:39 +03:00
|
|
|
|
|
|
|
|
|
struct rdp_file_line
|
|
|
|
|
{
|
|
|
|
|
char* text;
|
|
|
|
|
char* name;
|
|
|
|
|
LPSTR sValue;
|
|
|
|
|
PBYTE bValue;
|
2019-08-14 10:46:47 +03:00
|
|
|
|
|
|
|
|
|
size_t index;
|
|
|
|
|
|
|
|
|
|
long iValue;
|
|
|
|
|
DWORD flags;
|
2019-07-15 11:08:39 +03:00
|
|
|
|
int valueLength;
|
|
|
|
|
};
|
|
|
|
|
typedef struct rdp_file_line rdpFileLine;
|
|
|
|
|
|
|
|
|
|
struct rdp_file
|
|
|
|
|
{
|
2019-07-17 16:48:26 +03:00
|
|
|
|
DWORD UseMultiMon; /* use multimon */
|
2021-04-12 12:06:45 +03:00
|
|
|
|
LPSTR SelectedMonitors; /* selectedmonitors */
|
|
|
|
|
DWORD MaximizeToCurrentDisplays; /* maximizetocurrentdisplays */
|
|
|
|
|
DWORD SingleMonInWindowedMode; /* singlemoninwindowedmode */
|
2019-07-17 16:48:26 +03:00
|
|
|
|
DWORD ScreenModeId; /* screen mode id */
|
|
|
|
|
DWORD SpanMonitors; /* span monitors */
|
|
|
|
|
DWORD SmartSizing; /* smartsizing */
|
2021-04-12 12:06:45 +03:00
|
|
|
|
DWORD DynamicResolution; /* dynamic resolution */
|
2019-07-17 16:48:26 +03:00
|
|
|
|
DWORD EnableSuperSpan; /* enablesuperpan */
|
2019-07-15 11:08:39 +03:00
|
|
|
|
DWORD SuperSpanAccelerationFactor; /* superpanaccelerationfactor */
|
|
|
|
|
|
2021-06-02 13:29:55 +03:00
|
|
|
|
DWORD DesktopWidth; /* desktopwidth */
|
|
|
|
|
DWORD DesktopHeight; /* desktopheight */
|
|
|
|
|
DWORD DesktopSizeId; /* desktop size id */
|
|
|
|
|
DWORD SessionBpp; /* session bpp */
|
2021-04-12 12:06:45 +03:00
|
|
|
|
DWORD DesktopScaleFactor; /* desktopscalefactor */
|
2019-07-15 11:08:39 +03:00
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
DWORD Compression; /* compression */
|
|
|
|
|
DWORD KeyboardHook; /* keyboardhook */
|
2019-07-15 11:08:39 +03:00
|
|
|
|
DWORD DisableCtrlAltDel; /* disable ctrl+alt+del */
|
|
|
|
|
|
2021-06-02 13:29:55 +03:00
|
|
|
|
DWORD AudioMode; /* audiomode */
|
|
|
|
|
DWORD AudioQualityMode; /* audioqualitymode */
|
|
|
|
|
DWORD AudioCaptureMode; /* audiocapturemode */
|
2021-04-12 12:06:45 +03:00
|
|
|
|
DWORD EncodeRedirectedVideoCapture; /* encode redirected video capture */
|
|
|
|
|
DWORD RedirectedVideoCaptureEncodingQuality; /* redirected video capture encoding quality */
|
2021-06-02 13:29:55 +03:00
|
|
|
|
DWORD VideoPlaybackMode; /* videoplaybackmode */
|
2019-07-15 11:08:39 +03:00
|
|
|
|
|
|
|
|
|
DWORD ConnectionType; /* connection type */
|
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
DWORD NetworkAutoDetect; /* networkautodetect */
|
2019-07-15 11:08:39 +03:00
|
|
|
|
DWORD BandwidthAutoDetect; /* bandwidthautodetect */
|
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
DWORD PinConnectionBar; /* pinconnectionbar */
|
2019-07-15 11:08:39 +03:00
|
|
|
|
DWORD DisplayConnectionBar; /* displayconnectionbar */
|
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
DWORD WorkspaceId; /* workspaceid */
|
2019-07-15 11:08:39 +03:00
|
|
|
|
DWORD EnableWorkspaceReconnect; /* enableworkspacereconnect */
|
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
DWORD DisableWallpaper; /* disable wallpaper */
|
|
|
|
|
DWORD AllowFontSmoothing; /* allow font smoothing */
|
2019-07-15 11:08:39 +03:00
|
|
|
|
DWORD AllowDesktopComposition; /* allow desktop composition */
|
2019-07-17 16:48:26 +03:00
|
|
|
|
DWORD DisableFullWindowDrag; /* disable full window drag */
|
|
|
|
|
DWORD DisableMenuAnims; /* disable menu anims */
|
|
|
|
|
DWORD DisableThemes; /* disable themes */
|
|
|
|
|
DWORD DisableCursorSetting; /* disable cursor setting */
|
2019-07-15 11:08:39 +03:00
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
DWORD BitmapCacheSize; /* bitmapcachesize */
|
2019-07-15 11:08:39 +03:00
|
|
|
|
DWORD BitmapCachePersistEnable; /* bitmapcachepersistenable */
|
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
|
DWORD ServerPort; /* server port */
|
2019-08-14 10:46:47 +03:00
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
LPSTR Username; /* username */
|
|
|
|
|
LPSTR Domain; /* domain */
|
|
|
|
|
LPSTR Password; /*password*/
|
2019-07-15 11:08:39 +03:00
|
|
|
|
PBYTE Password51; /* password 51 */
|
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
LPSTR FullAddress; /* full address */
|
2019-07-15 11:08:39 +03:00
|
|
|
|
LPSTR AlternateFullAddress; /* alternate full address */
|
2019-07-17 16:48:26 +03:00
|
|
|
|
|
2019-08-14 10:46:47 +03:00
|
|
|
|
LPSTR UsbDevicesToRedirect; /* usbdevicestoredirect */
|
2019-07-17 16:48:26 +03:00
|
|
|
|
DWORD RedirectDrives; /* redirectdrives */
|
|
|
|
|
DWORD RedirectPrinters; /* redirectprinters */
|
|
|
|
|
DWORD RedirectComPorts; /* redirectcomports */
|
|
|
|
|
DWORD RedirectSmartCards; /* redirectsmartcards */
|
2021-04-12 11:38:40 +03:00
|
|
|
|
LPSTR RedirectCameras; /* camerastoredirect */
|
2019-07-17 16:48:26 +03:00
|
|
|
|
DWORD RedirectClipboard; /* redirectclipboard */
|
|
|
|
|
DWORD RedirectPosDevices; /* redirectposdevices */
|
|
|
|
|
DWORD RedirectDirectX; /* redirectdirectx */
|
|
|
|
|
DWORD DisablePrinterRedirection; /* disableprinterredirection */
|
2019-07-15 11:08:39 +03:00
|
|
|
|
DWORD DisableClipboardRedirection; /* disableclipboardredirection */
|
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
DWORD ConnectToConsole; /* connect to console */
|
|
|
|
|
DWORD AdministrativeSession; /* administrative session */
|
2019-07-15 11:08:39 +03:00
|
|
|
|
DWORD AutoReconnectionEnabled; /* autoreconnection enabled */
|
|
|
|
|
DWORD AutoReconnectMaxRetries; /* autoreconnect max retries */
|
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
DWORD PublicMode; /* public mode */
|
|
|
|
|
DWORD AuthenticationLevel; /* authentication level */
|
|
|
|
|
DWORD PromptCredentialOnce; /* promptcredentialonce */
|
|
|
|
|
DWORD PromptForCredentials; /* prompt for credentials */
|
2019-07-15 11:08:39 +03:00
|
|
|
|
DWORD NegotiateSecurityLayer; /* negotiate security layer */
|
2019-07-17 16:48:26 +03:00
|
|
|
|
DWORD EnableCredSSPSupport; /* enablecredsspsupport */
|
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
|
DWORD RemoteApplicationMode; /* remoteapplicationmode */
|
|
|
|
|
LPSTR LoadBalanceInfo; /* loadbalanceinfo */
|
2019-08-14 10:46:47 +03:00
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
LPSTR RemoteApplicationName; /* remoteapplicationname */
|
|
|
|
|
LPSTR RemoteApplicationIcon; /* remoteapplicationicon */
|
|
|
|
|
LPSTR RemoteApplicationProgram; /* remoteapplicationprogram */
|
|
|
|
|
LPSTR RemoteApplicationFile; /* remoteapplicationfile */
|
|
|
|
|
LPSTR RemoteApplicationGuid; /* remoteapplicationguid */
|
|
|
|
|
LPSTR RemoteApplicationCmdLine; /* remoteapplicationcmdline */
|
|
|
|
|
DWORD RemoteApplicationExpandCmdLine; /* remoteapplicationexpandcmdline */
|
2019-07-15 11:08:39 +03:00
|
|
|
|
DWORD RemoteApplicationExpandWorkingDir; /* remoteapplicationexpandworkingdir */
|
2019-07-17 16:48:26 +03:00
|
|
|
|
DWORD DisableConnectionSharing; /* disableconnectionsharing */
|
|
|
|
|
DWORD DisableRemoteAppCapsCheck; /* disableremoteappcapscheck */
|
2019-07-15 11:08:39 +03:00
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
LPSTR AlternateShell; /* alternate shell */
|
2019-07-15 11:08:39 +03:00
|
|
|
|
LPSTR ShellWorkingDirectory; /* shell working directory */
|
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
LPSTR GatewayHostname; /* gatewayhostname */
|
|
|
|
|
DWORD GatewayUsageMethod; /* gatewayusagemethod */
|
2019-07-15 11:08:39 +03:00
|
|
|
|
DWORD GatewayProfileUsageMethod; /* gatewayprofileusagemethod */
|
2019-07-17 16:48:26 +03:00
|
|
|
|
DWORD GatewayCredentialsSource; /* gatewaycredentialssource */
|
2019-07-15 11:08:39 +03:00
|
|
|
|
|
|
|
|
|
DWORD UseRedirectionServerName; /* use redirection server name */
|
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
|
LPSTR GatewayAccessToken; /* gatewayaccesstoken */
|
2019-07-15 11:08:39 +03:00
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
LPSTR DrivesToRedirect; /* drivestoredirect */
|
2019-07-15 11:08:39 +03:00
|
|
|
|
LPSTR DevicesToRedirect; /* devicestoredirect */
|
2019-07-17 16:48:26 +03:00
|
|
|
|
LPSTR WinPosStr; /* winposstr */
|
2019-07-15 11:08:39 +03:00
|
|
|
|
|
|
|
|
|
LPSTR PreconnectionBlob; /* pcb */
|
|
|
|
|
|
2019-08-14 10:46:47 +03:00
|
|
|
|
LPSTR KdcProxyName; /* kdcproxyname */
|
|
|
|
|
DWORD RdgIsKdcProxy; /* rdgiskdcproxy */
|
|
|
|
|
|
|
|
|
|
DWORD align1;
|
|
|
|
|
|
2019-07-18 10:29:06 +03:00
|
|
|
|
size_t lineCount;
|
|
|
|
|
size_t lineSize;
|
2019-07-15 11:08:39 +03:00
|
|
|
|
rdpFileLine* lines;
|
|
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
|
ADDIN_ARGV* args;
|
2019-07-15 11:30:16 +03:00
|
|
|
|
void* context;
|
2019-09-24 11:01:08 +03:00
|
|
|
|
|
|
|
|
|
DWORD flags;
|
2019-07-15 11:08:39 +03:00
|
|
|
|
};
|
|
|
|
|
|
2020-05-15 17:55:58 +03:00
|
|
|
|
static void freerdp_client_file_string_check_free(LPSTR str);
|
2015-06-17 23:08:02 +03:00
|
|
|
|
/*
|
|
|
|
|
* Set an integer in a rdpFile
|
|
|
|
|
*
|
2019-07-18 14:53:30 +03:00
|
|
|
|
* @return FALSE if a standard name was set, TRUE for a non-standard name, FALSE on error
|
2015-06-17 23:08:02 +03:00
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2019-07-18 14:53:30 +03:00
|
|
|
|
static BOOL freerdp_client_rdp_file_set_integer(rdpFile* file, const char* name, long value,
|
2019-11-06 17:24:51 +03:00
|
|
|
|
SSIZE_T index)
|
2012-10-28 04:25:11 +04:00
|
|
|
|
{
|
2019-07-18 14:53:30 +03:00
|
|
|
|
BOOL standard = TRUE;
|
2012-10-28 20:12:36 +04:00
|
|
|
|
#ifdef DEBUG_CLIENT_FILE
|
2022-09-29 15:55:27 +03:00
|
|
|
|
WLog_DBG(TAG, "%s:i:%ld", name, value);
|
2012-10-28 20:12:36 +04:00
|
|
|
|
#endif
|
|
|
|
|
|
2019-07-18 14:53:30 +03:00
|
|
|
|
if (value < 0)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2012-10-28 04:25:11 +04:00
|
|
|
|
if (_stricmp(name, "use multimon") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->UseMultiMon = (UINT32)value;
|
2021-04-12 12:06:45 +03:00
|
|
|
|
else if (_stricmp(name, "maximizetocurrentdisplays") == 0)
|
|
|
|
|
file->MaximizeToCurrentDisplays = (UINT32)value;
|
|
|
|
|
else if (_stricmp(name, "singlemoninwindowedmode") == 0)
|
|
|
|
|
file->SingleMonInWindowedMode = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "screen mode id") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->ScreenModeId = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "span monitors") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->SpanMonitors = (UINT32)value;
|
2014-06-16 23:01:09 +04:00
|
|
|
|
else if (_stricmp(name, "smart sizing") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->SmartSizing = (UINT32)value;
|
2021-04-12 12:06:45 +03:00
|
|
|
|
else if (_stricmp(name, "dynamic resolution") == 0)
|
|
|
|
|
file->DynamicResolution = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "enablesuperpan") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->EnableSuperSpan = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "superpanaccelerationfactor") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->SuperSpanAccelerationFactor = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "desktopwidth") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->DesktopWidth = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "desktopheight") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->DesktopHeight = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "desktop size id") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->DesktopSizeId = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "session bpp") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->SessionBpp = (UINT32)value;
|
2021-04-12 12:06:45 +03:00
|
|
|
|
else if (_stricmp(name, "desktopscalefactor") == 0)
|
|
|
|
|
file->DesktopScaleFactor = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "compression") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->Compression = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "keyboardhook") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->KeyboardHook = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "disable ctrl+alt+del") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->DisableCtrlAltDel = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "audiomode") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->AudioMode = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "audioqualitymode") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->AudioQualityMode = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "audiocapturemode") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->AudioCaptureMode = (UINT32)value;
|
2021-04-12 12:06:45 +03:00
|
|
|
|
else if (_stricmp(name, "encode redirected video capture") == 0)
|
|
|
|
|
file->EncodeRedirectedVideoCapture = (UINT32)value;
|
|
|
|
|
else if (_stricmp(name, "redirected video capture encoding quality") == 0)
|
|
|
|
|
file->RedirectedVideoCaptureEncodingQuality = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "videoplaybackmode") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->VideoPlaybackMode = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "connection type") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->ConnectionType = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "networkautodetect") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->NetworkAutoDetect = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "bandwidthautodetect") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->BandwidthAutoDetect = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "pinconnectionbar") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->PinConnectionBar = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "displayconnectionbar") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->DisplayConnectionBar = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "workspaceid") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->WorkspaceId = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "enableworkspacereconnect") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->EnableWorkspaceReconnect = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "disable wallpaper") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->DisableWallpaper = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "allow font smoothing") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->AllowFontSmoothing = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "allow desktop composition") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->AllowDesktopComposition = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "disable full window drag") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->DisableFullWindowDrag = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "disable menu anims") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->DisableMenuAnims = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "disable themes") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->DisableThemes = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "disable cursor setting") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->DisableCursorSetting = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "bitmapcachesize") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->BitmapCacheSize = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "bitmapcachepersistenable") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->BitmapCachePersistEnable = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "server port") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->ServerPort = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "redirectdrives") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->RedirectDrives = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "redirectprinters") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->RedirectPrinters = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "redirectcomports") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->RedirectComPorts = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "redirectsmartcards") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->RedirectSmartCards = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "redirectclipboard") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->RedirectClipboard = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "redirectposdevices") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->RedirectPosDevices = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "redirectdirectx") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->RedirectDirectX = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "disableprinterredirection") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->DisablePrinterRedirection = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "disableclipboardredirection") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->DisableClipboardRedirection = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "connect to console") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->ConnectToConsole = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "administrative session") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->AdministrativeSession = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "autoreconnection enabled") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->AutoReconnectionEnabled = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "autoreconnect max retries") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->AutoReconnectMaxRetries = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "public mode") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->PublicMode = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "authentication level") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->AuthenticationLevel = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "promptcredentialonce") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->PromptCredentialOnce = (UINT32)value;
|
2019-08-20 11:07:10 +03:00
|
|
|
|
else if ((_stricmp(name, "prompt for credentials") == 0))
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->PromptForCredentials = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "negotiate security layer") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->NegotiateSecurityLayer = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "enablecredsspsupport") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->EnableCredSSPSupport = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "remoteapplicationmode") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->RemoteApplicationMode = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "remoteapplicationexpandcmdline") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->RemoteApplicationExpandCmdLine = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "remoteapplicationexpandworkingdir") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->RemoteApplicationExpandWorkingDir = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "disableconnectionsharing") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->DisableConnectionSharing = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "disableremoteappcapscheck") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->DisableRemoteAppCapsCheck = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "gatewayusagemethod") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->GatewayUsageMethod = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "gatewayprofileusagemethod") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->GatewayProfileUsageMethod = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "gatewaycredentialssource") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->GatewayCredentialsSource = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "use redirection server name") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->UseRedirectionServerName = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "rdgiskdcproxy") == 0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->RdgIsKdcProxy = (UINT32)value;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else
|
2019-07-18 14:53:30 +03:00
|
|
|
|
standard = FALSE;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
|
2013-12-05 00:37:42 +04:00
|
|
|
|
if (index >= 0)
|
|
|
|
|
{
|
|
|
|
|
file->lines[index].name = _strdup(name);
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
if (!file->lines[index].name)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
return FALSE;
|
2013-12-05 00:37:42 +04:00
|
|
|
|
|
2019-07-18 14:53:30 +03:00
|
|
|
|
file->lines[index].iValue = value;
|
2013-12-05 00:37:42 +04:00
|
|
|
|
file->lines[index].flags = RDP_FILE_LINE_FLAG_FORMATTED;
|
|
|
|
|
file->lines[index].flags |= RDP_FILE_LINE_FLAG_TYPE_INTEGER;
|
|
|
|
|
|
2019-07-18 14:53:30 +03:00
|
|
|
|
if (standard)
|
2013-12-05 00:37:42 +04:00
|
|
|
|
file->lines[index].flags |= RDP_FILE_LINE_FLAG_STANDARD;
|
|
|
|
|
|
|
|
|
|
file->lines[index].valueLength = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-18 14:53:30 +03:00
|
|
|
|
return !standard;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-23 20:22:48 +03:00
|
|
|
|
static BOOL freerdp_client_parse_rdp_file_integer(rdpFile* file, const char* name,
|
2019-11-06 17:24:51 +03:00
|
|
|
|
const char* value, SSIZE_T index)
|
2012-10-28 06:46:37 +04:00
|
|
|
|
{
|
2019-09-11 12:45:59 +03:00
|
|
|
|
char* endptr;
|
2017-11-14 18:10:52 +03:00
|
|
|
|
long ivalue;
|
|
|
|
|
errno = 0;
|
2019-09-11 12:45:59 +03:00
|
|
|
|
ivalue = strtol(value, &endptr, 0);
|
2017-11-14 18:10:52 +03:00
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
|
if ((endptr == NULL) || (errno != 0) || (endptr == value) || (ivalue > INT32_MAX) ||
|
|
|
|
|
(ivalue < INT32_MIN))
|
2018-12-11 11:27:32 +03:00
|
|
|
|
{
|
2019-09-24 11:01:08 +03:00
|
|
|
|
if (file->flags & RDP_FILE_FLAG_PARSE_INT_RELAXED)
|
|
|
|
|
{
|
|
|
|
|
WLog_WARN(TAG, "Integer option %s has invalid value %s, using default", name, value);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
WLog_ERR(TAG, "Failed to convert RDP file integer option %s [value=%s]", name, value);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2018-12-11 11:27:32 +03:00
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2019-07-18 14:53:30 +03:00
|
|
|
|
freerdp_client_rdp_file_set_integer(file, name, ivalue, index);
|
2015-06-17 23:08:02 +03:00
|
|
|
|
return TRUE;
|
2012-10-28 06:46:37 +04:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param file rdpFile
|
|
|
|
|
* @param name name of the string
|
|
|
|
|
* @param value value of the string to set
|
|
|
|
|
* @param index line index of the rdpFile
|
|
|
|
|
* @return 0 on success, 1 if the key wasn't found (not a standard key), -1 on error
|
|
|
|
|
*/
|
|
|
|
|
|
2017-02-14 14:53:14 +03:00
|
|
|
|
static int freerdp_client_rdp_file_set_string(rdpFile* file, const char* name, const char* value,
|
2019-11-06 17:24:51 +03:00
|
|
|
|
SSIZE_T index)
|
2012-10-28 04:25:11 +04:00
|
|
|
|
{
|
2015-06-22 19:52:13 +03:00
|
|
|
|
int standard = 0;
|
2017-02-14 14:53:14 +03:00
|
|
|
|
LPSTR* tmp = NULL;
|
2012-10-28 20:12:36 +04:00
|
|
|
|
#ifdef DEBUG_CLIENT_FILE
|
2019-07-17 16:48:26 +03:00
|
|
|
|
WLog_DBG(TAG, "%s:s:%s", name, value);
|
2012-10-28 20:12:36 +04:00
|
|
|
|
#endif
|
|
|
|
|
|
2015-06-23 13:17:37 +03:00
|
|
|
|
if (!file)
|
|
|
|
|
return -1;
|
|
|
|
|
|
2012-10-28 04:25:11 +04:00
|
|
|
|
if (_stricmp(name, "username") == 0)
|
2015-06-17 23:08:02 +03:00
|
|
|
|
tmp = &file->Username;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "domain") == 0)
|
2015-06-17 23:08:02 +03:00
|
|
|
|
tmp = &file->Domain;
|
2017-02-10 23:38:52 +03:00
|
|
|
|
else if (_stricmp(name, "password") == 0)
|
|
|
|
|
tmp = &file->Password;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "full address") == 0)
|
2015-06-17 23:08:02 +03:00
|
|
|
|
tmp = &file->FullAddress;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "alternate full address") == 0)
|
2015-06-17 23:08:02 +03:00
|
|
|
|
tmp = &file->AlternateFullAddress;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "usbdevicestoredirect") == 0)
|
2015-06-17 23:08:02 +03:00
|
|
|
|
tmp = &file->UsbDevicesToRedirect;
|
2021-04-12 11:38:40 +03:00
|
|
|
|
else if (_stricmp(name, "camerastoredirect") == 0)
|
|
|
|
|
tmp = &file->RedirectCameras;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "loadbalanceinfo") == 0)
|
2015-06-17 23:08:02 +03:00
|
|
|
|
tmp = &file->LoadBalanceInfo;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "remoteapplicationname") == 0)
|
2015-06-17 23:08:02 +03:00
|
|
|
|
tmp = &file->RemoteApplicationName;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "remoteapplicationicon") == 0)
|
2015-06-17 23:08:02 +03:00
|
|
|
|
tmp = &file->RemoteApplicationIcon;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "remoteapplicationprogram") == 0)
|
2015-06-17 23:08:02 +03:00
|
|
|
|
tmp = &file->RemoteApplicationProgram;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "remoteapplicationfile") == 0)
|
2015-06-17 23:08:02 +03:00
|
|
|
|
tmp = &file->RemoteApplicationFile;
|
2012-11-19 22:26:56 +04:00
|
|
|
|
else if (_stricmp(name, "remoteapplicationguid") == 0)
|
2015-06-17 23:08:02 +03:00
|
|
|
|
tmp = &file->RemoteApplicationGuid;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "remoteapplicationcmdline") == 0)
|
2015-06-17 23:08:02 +03:00
|
|
|
|
tmp = &file->RemoteApplicationCmdLine;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "alternate shell") == 0)
|
2015-06-17 23:08:02 +03:00
|
|
|
|
tmp = &file->AlternateShell;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "shell working directory") == 0)
|
2015-06-17 23:08:02 +03:00
|
|
|
|
tmp = &file->ShellWorkingDirectory;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "gatewayhostname") == 0)
|
2015-06-17 23:08:02 +03:00
|
|
|
|
tmp = &file->GatewayHostname;
|
2018-02-13 16:59:33 +03:00
|
|
|
|
else if (_stricmp(name, "gatewayaccesstoken") == 0)
|
|
|
|
|
tmp = &file->GatewayAccessToken;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "kdcproxyname") == 0)
|
2015-06-17 23:08:02 +03:00
|
|
|
|
tmp = &file->KdcProxyName;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "drivestoredirect") == 0)
|
2015-06-17 23:08:02 +03:00
|
|
|
|
tmp = &file->DrivesToRedirect;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "devicestoredirect") == 0)
|
2015-06-17 23:08:02 +03:00
|
|
|
|
tmp = &file->DevicesToRedirect;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else if (_stricmp(name, "winposstr") == 0)
|
2015-06-17 23:08:02 +03:00
|
|
|
|
tmp = &file->WinPosStr;
|
2018-04-01 05:15:39 +03:00
|
|
|
|
else if (_stricmp(name, "pcb") == 0)
|
|
|
|
|
tmp = &file->PreconnectionBlob;
|
2021-04-12 12:06:45 +03:00
|
|
|
|
else if (_stricmp(name, "selectedmonitors") == 0)
|
|
|
|
|
tmp = &file->SelectedMonitors;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
else
|
2015-06-22 19:52:13 +03:00
|
|
|
|
standard = 1;
|
2015-06-17 23:08:02 +03:00
|
|
|
|
|
2015-06-22 20:31:25 +03:00
|
|
|
|
if (tmp && !(*tmp = _strdup(value)))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
return -1;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
|
2013-12-05 00:37:42 +04:00
|
|
|
|
if (index >= 0)
|
|
|
|
|
{
|
2015-06-23 13:17:37 +03:00
|
|
|
|
if (!file->lines)
|
|
|
|
|
return -1;
|
|
|
|
|
|
2013-12-05 00:37:42 +04:00
|
|
|
|
file->lines[index].name = _strdup(name);
|
|
|
|
|
file->lines[index].sValue = _strdup(value);
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
if (!file->lines[index].name || !file->lines[index].sValue)
|
|
|
|
|
{
|
|
|
|
|
free(file->lines[index].name);
|
|
|
|
|
free(file->lines[index].sValue);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2013-12-05 00:37:42 +04:00
|
|
|
|
|
|
|
|
|
file->lines[index].flags = RDP_FILE_LINE_FLAG_FORMATTED;
|
|
|
|
|
file->lines[index].flags |= RDP_FILE_LINE_FLAG_TYPE_STRING;
|
|
|
|
|
|
2015-06-22 19:52:13 +03:00
|
|
|
|
if (standard == 0)
|
2013-12-05 00:37:42 +04:00
|
|
|
|
file->lines[index].flags |= RDP_FILE_LINE_FLAG_STANDARD;
|
|
|
|
|
|
2013-12-05 01:29:45 +04:00
|
|
|
|
file->lines[index].valueLength = 0;
|
2013-12-05 00:37:42 +04:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-22 19:52:13 +03:00
|
|
|
|
return standard;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-18 10:29:06 +03:00
|
|
|
|
static BOOL freerdp_client_add_option(rdpFile* file, const char* option)
|
2013-09-18 22:01:19 +04:00
|
|
|
|
{
|
2021-04-12 11:38:40 +03:00
|
|
|
|
return freerdp_addin_argv_add_argument(file->args, option);
|
2013-09-18 22:01:19 +04:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-18 11:59:59 +03:00
|
|
|
|
static SSIZE_T freerdp_client_parse_rdp_file_add_line(rdpFile* file, const char* line,
|
|
|
|
|
SSIZE_T index)
|
2013-12-05 00:37:42 +04:00
|
|
|
|
{
|
2013-12-05 01:29:45 +04:00
|
|
|
|
if (index < 0)
|
2019-07-18 10:29:06 +03:00
|
|
|
|
index = (SSIZE_T)file->lineCount;
|
2013-12-05 01:29:45 +04:00
|
|
|
|
|
2013-12-05 00:37:42 +04:00
|
|
|
|
while ((file->lineCount + 1) > file->lineSize)
|
|
|
|
|
{
|
2019-07-18 10:29:06 +03:00
|
|
|
|
size_t new_size;
|
2017-02-14 14:53:14 +03:00
|
|
|
|
rdpFileLine* new_line;
|
2015-03-11 06:32:51 +03:00
|
|
|
|
new_size = file->lineSize * 2;
|
2019-07-17 16:48:26 +03:00
|
|
|
|
new_line = (rdpFileLine*)realloc(file->lines, new_size * sizeof(rdpFileLine));
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2015-03-11 06:32:51 +03:00
|
|
|
|
if (!new_line)
|
|
|
|
|
return -1;
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2015-03-11 06:32:51 +03:00
|
|
|
|
file->lines = new_line;
|
|
|
|
|
file->lineSize = new_size;
|
2013-12-05 00:37:42 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ZeroMemory(&(file->lines[file->lineCount]), sizeof(rdpFileLine));
|
|
|
|
|
file->lines[file->lineCount].text = _strdup(line);
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
if (!file->lines[file->lineCount].text)
|
|
|
|
|
return -1;
|
|
|
|
|
|
2019-07-18 10:29:06 +03:00
|
|
|
|
file->lines[file->lineCount].index = (size_t)index;
|
2013-12-05 00:37:42 +04:00
|
|
|
|
(file->lineCount)++;
|
2013-12-05 01:29:45 +04:00
|
|
|
|
return index;
|
2013-12-05 00:37:42 +04:00
|
|
|
|
}
|
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
|
static BOOL freerdp_client_parse_rdp_file_string(rdpFile* file, char* name, char* value,
|
|
|
|
|
SSIZE_T index)
|
2012-10-28 06:46:37 +04:00
|
|
|
|
{
|
2015-06-17 23:08:02 +03:00
|
|
|
|
BOOL ret = TRUE;
|
2013-11-07 05:07:42 +04:00
|
|
|
|
char* valueA = _strdup(value);
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
if (!valueA)
|
2018-12-11 11:27:32 +03:00
|
|
|
|
{
|
|
|
|
|
WLog_ERR(TAG, "Failed to convert RDP file string option %s [value=%s]", name, value);
|
2015-06-17 23:08:02 +03:00
|
|
|
|
return FALSE;
|
2018-12-11 11:27:32 +03:00
|
|
|
|
}
|
2015-06-17 23:08:02 +03:00
|
|
|
|
|
|
|
|
|
if (freerdp_client_rdp_file_set_string(file, name, valueA, index) == -1)
|
|
|
|
|
ret = FALSE;
|
|
|
|
|
|
2013-12-05 00:37:42 +04:00
|
|
|
|
free(valueA);
|
2015-06-17 23:08:02 +03:00
|
|
|
|
return ret;
|
2012-10-28 06:46:37 +04:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-18 10:29:06 +03:00
|
|
|
|
static BOOL freerdp_client_parse_rdp_file_option(rdpFile* file, const char* option, SSIZE_T index)
|
2013-09-18 22:01:19 +04:00
|
|
|
|
{
|
2019-07-18 14:53:30 +03:00
|
|
|
|
WINPR_UNUSED(index);
|
2015-06-17 23:08:02 +03:00
|
|
|
|
return freerdp_client_add_option(file, option);
|
2013-09-18 22:01:19 +04:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
BOOL freerdp_client_parse_rdp_file_buffer(rdpFile* file, const BYTE* buffer, size_t size)
|
2019-07-15 11:30:16 +03:00
|
|
|
|
{
|
|
|
|
|
return freerdp_client_parse_rdp_file_buffer_ex(file, buffer, size, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-26 17:58:41 +03:00
|
|
|
|
static BOOL trim(char** strptr)
|
|
|
|
|
{
|
|
|
|
|
char* start;
|
|
|
|
|
char* str;
|
|
|
|
|
char* end;
|
|
|
|
|
|
|
|
|
|
start = str = *strptr;
|
|
|
|
|
if (!str)
|
|
|
|
|
return TRUE;
|
|
|
|
|
if (!(~((size_t)str)))
|
|
|
|
|
return TRUE;
|
|
|
|
|
end = str + strlen(str) - 1;
|
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
|
while (isspace(*str))
|
2019-09-26 17:58:41 +03:00
|
|
|
|
str++;
|
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
|
while ((end > str) && isspace(*end))
|
2019-09-26 17:58:41 +03:00
|
|
|
|
end--;
|
|
|
|
|
end[1] = '\0';
|
|
|
|
|
if (start == str)
|
|
|
|
|
*strptr = str;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*strptr = _strdup(str);
|
|
|
|
|
free(start);
|
|
|
|
|
return *strptr != NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static BOOL trim_strings(rdpFile* file)
|
|
|
|
|
{
|
|
|
|
|
if (!trim(&file->Username))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!trim(&file->Domain))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!trim(&file->AlternateFullAddress))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!trim(&file->FullAddress))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!trim(&file->UsbDevicesToRedirect))
|
|
|
|
|
return FALSE;
|
2021-04-12 11:38:40 +03:00
|
|
|
|
if (!trim(&file->RedirectCameras))
|
|
|
|
|
return FALSE;
|
2019-09-26 17:58:41 +03:00
|
|
|
|
if (!trim(&file->LoadBalanceInfo))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!trim(&file->GatewayHostname))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!trim(&file->GatewayAccessToken))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!trim(&file->RemoteApplicationName))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!trim(&file->RemoteApplicationIcon))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!trim(&file->RemoteApplicationProgram))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!trim(&file->RemoteApplicationFile))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!trim(&file->RemoteApplicationGuid))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!trim(&file->RemoteApplicationCmdLine))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!trim(&file->AlternateShell))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!trim(&file->ShellWorkingDirectory))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!trim(&file->DrivesToRedirect))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!trim(&file->DevicesToRedirect))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!trim(&file->DevicesToRedirect))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!trim(&file->WinPosStr))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!trim(&file->PreconnectionBlob))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!trim(&file->KdcProxyName))
|
|
|
|
|
return FALSE;
|
2021-04-12 12:06:45 +03:00
|
|
|
|
if (!trim(&file->SelectedMonitors))
|
|
|
|
|
return FALSE;
|
2019-09-26 17:58:41 +03:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
BOOL freerdp_client_parse_rdp_file_buffer_ex(rdpFile* file, const BYTE* buffer, size_t size,
|
|
|
|
|
rdp_file_fkt_parse parse)
|
2012-10-28 04:25:11 +04:00
|
|
|
|
{
|
2017-02-15 16:22:15 +03:00
|
|
|
|
BOOL rc = FALSE;
|
2019-07-18 14:53:30 +03:00
|
|
|
|
SSIZE_T index;
|
2017-12-20 15:43:14 +03:00
|
|
|
|
size_t length;
|
2012-10-28 06:46:37 +04:00
|
|
|
|
char* line;
|
|
|
|
|
char* type;
|
|
|
|
|
char* context;
|
2019-07-17 16:48:26 +03:00
|
|
|
|
char *d1, *d2;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
char* beg;
|
2019-07-17 16:48:26 +03:00
|
|
|
|
char *name, *value;
|
2017-11-23 20:22:48 +03:00
|
|
|
|
char* copy = NULL;
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2017-11-23 20:22:48 +03:00
|
|
|
|
if (size < 2)
|
2017-02-14 14:53:14 +03:00
|
|
|
|
return FALSE;
|
2012-10-28 06:46:37 +04:00
|
|
|
|
|
2017-11-23 20:22:48 +03:00
|
|
|
|
if ((buffer[0] == BOM_UTF16_LE[0]) && (buffer[1] == BOM_UTF16_LE[1]))
|
|
|
|
|
{
|
2021-07-29 11:07:04 +03:00
|
|
|
|
int clength;
|
2019-07-18 14:53:30 +03:00
|
|
|
|
LPCWSTR uc = (LPCWSTR)(&buffer[2]);
|
2017-12-20 15:43:14 +03:00
|
|
|
|
size = size / 2 - 1;
|
|
|
|
|
|
2019-07-18 14:53:30 +03:00
|
|
|
|
if (size > INT_MAX)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2021-07-29 11:07:04 +03:00
|
|
|
|
clength = (int)size;
|
|
|
|
|
if (ConvertFromUnicode(CP_UTF8, 0, uc, clength, ©, 0, NULL, NULL) < 0)
|
2018-12-11 11:27:32 +03:00
|
|
|
|
{
|
|
|
|
|
WLog_ERR(TAG, "Failed to convert RDP file from UCS2 to UTF8");
|
2017-11-23 20:22:48 +03:00
|
|
|
|
return FALSE;
|
2018-12-11 11:27:32 +03:00
|
|
|
|
}
|
2017-11-23 20:22:48 +03:00
|
|
|
|
}
|
|
|
|
|
else
|
2017-12-20 15:43:14 +03:00
|
|
|
|
{
|
2017-11-23 20:22:48 +03:00
|
|
|
|
copy = calloc(1, size + sizeof(BYTE));
|
2017-12-20 15:43:14 +03:00
|
|
|
|
|
2017-11-23 20:22:48 +03:00
|
|
|
|
if (!copy)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
memcpy(copy, buffer, size);
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-05 00:37:42 +04:00
|
|
|
|
index = 0;
|
2017-02-14 14:53:14 +03:00
|
|
|
|
line = strtok_s(copy, "\r\n", &context);
|
2012-10-28 06:46:37 +04:00
|
|
|
|
|
2013-04-13 02:03:56 +04:00
|
|
|
|
while (line)
|
2012-10-28 06:46:37 +04:00
|
|
|
|
{
|
2017-12-20 15:43:14 +03:00
|
|
|
|
length = strnlen(line, size);
|
2012-10-28 06:46:37 +04:00
|
|
|
|
|
|
|
|
|
if (length > 1)
|
|
|
|
|
{
|
|
|
|
|
beg = line;
|
|
|
|
|
|
2017-11-23 20:22:48 +03:00
|
|
|
|
if (freerdp_client_parse_rdp_file_add_line(file, line, index) == -1)
|
2017-11-24 12:24:47 +03:00
|
|
|
|
goto fail;
|
2013-12-05 00:37:42 +04:00
|
|
|
|
|
2013-09-18 22:01:19 +04:00
|
|
|
|
if (beg[0] == '/')
|
|
|
|
|
{
|
2017-11-23 20:22:48 +03:00
|
|
|
|
if (!freerdp_client_parse_rdp_file_option(file, line, index))
|
2017-11-24 12:24:47 +03:00
|
|
|
|
goto fail;
|
2015-06-17 23:08:02 +03:00
|
|
|
|
|
2013-09-18 22:01:19 +04:00
|
|
|
|
goto next_line; /* FreeRDP option */
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-28 06:46:37 +04:00
|
|
|
|
d1 = strchr(line, ':');
|
|
|
|
|
|
|
|
|
|
if (!d1)
|
|
|
|
|
goto next_line; /* not first delimiter */
|
|
|
|
|
|
|
|
|
|
type = &d1[1];
|
|
|
|
|
d2 = strchr(type, ':');
|
|
|
|
|
|
|
|
|
|
if (!d2)
|
|
|
|
|
goto next_line; /* no second delimiter */
|
|
|
|
|
|
|
|
|
|
if ((d2 - d1) != 2)
|
|
|
|
|
goto next_line; /* improper type length */
|
|
|
|
|
|
|
|
|
|
*d1 = 0;
|
|
|
|
|
*d2 = 0;
|
|
|
|
|
name = beg;
|
|
|
|
|
value = &d2[1];
|
|
|
|
|
|
2019-07-15 11:30:16 +03:00
|
|
|
|
if (parse && parse(file->context, name, *type, value))
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
else if (*type == 'i')
|
2012-10-28 06:46:37 +04:00
|
|
|
|
{
|
|
|
|
|
/* integer type */
|
2017-11-23 20:22:48 +03:00
|
|
|
|
if (!freerdp_client_parse_rdp_file_integer(file, name, value, index))
|
2017-02-15 16:22:15 +03:00
|
|
|
|
goto fail;
|
2012-10-28 06:46:37 +04:00
|
|
|
|
}
|
|
|
|
|
else if (*type == 's')
|
|
|
|
|
{
|
|
|
|
|
/* string type */
|
2017-11-23 20:22:48 +03:00
|
|
|
|
if (!freerdp_client_parse_rdp_file_string(file, name, value, index))
|
2017-02-15 16:22:15 +03:00
|
|
|
|
goto fail;
|
2012-10-28 06:46:37 +04:00
|
|
|
|
}
|
|
|
|
|
else if (*type == 'b')
|
|
|
|
|
{
|
|
|
|
|
/* binary type */
|
2018-12-11 11:27:32 +03:00
|
|
|
|
WLog_ERR(TAG, "Unsupported RDP file binary option %s [value=%s]", name, value);
|
2012-10-28 06:46:37 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-14 14:53:14 +03:00
|
|
|
|
next_line:
|
2012-10-28 06:46:37 +04:00
|
|
|
|
line = strtok_s(NULL, "\r\n", &context);
|
2013-12-05 00:37:42 +04:00
|
|
|
|
index++;
|
2012-10-28 06:46:37 +04:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-26 17:58:41 +03:00
|
|
|
|
rc = trim_strings(file);
|
2017-02-15 16:22:15 +03:00
|
|
|
|
fail:
|
2017-02-14 14:53:14 +03:00
|
|
|
|
free(copy);
|
2017-02-15 16:22:15 +03:00
|
|
|
|
return rc;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-04 22:42:40 +04:00
|
|
|
|
BOOL freerdp_client_parse_rdp_file(rdpFile* file, const char* name)
|
2019-07-15 11:30:16 +03:00
|
|
|
|
{
|
2019-07-17 16:48:26 +03:00
|
|
|
|
return freerdp_client_parse_rdp_file_ex(file, name, NULL);
|
2019-07-15 11:30:16 +03:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
BOOL freerdp_client_parse_rdp_file_ex(rdpFile* file, const char* name, rdp_file_fkt_parse parse)
|
2012-10-28 04:25:11 +04:00
|
|
|
|
{
|
2013-11-05 08:45:19 +04:00
|
|
|
|
BOOL status;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
BYTE* buffer;
|
|
|
|
|
FILE* fp = NULL;
|
|
|
|
|
size_t read_size;
|
2017-08-11 11:07:46 +03:00
|
|
|
|
INT64 file_size;
|
2020-12-22 12:24:27 +03:00
|
|
|
|
const char* fname = name;
|
|
|
|
|
if (_strnicmp(fname, "file://", 7) == 0)
|
|
|
|
|
fname = &name[7];
|
|
|
|
|
|
2021-05-31 12:42:03 +03:00
|
|
|
|
fp = winpr_fopen(fname, "r");
|
2012-10-28 04:25:11 +04:00
|
|
|
|
|
|
|
|
|
if (!fp)
|
2018-12-11 11:27:32 +03:00
|
|
|
|
{
|
|
|
|
|
WLog_ERR(TAG, "Failed to open RDP file %s", name);
|
2012-10-28 04:25:11 +04:00
|
|
|
|
return FALSE;
|
2018-12-11 11:27:32 +03:00
|
|
|
|
}
|
2012-10-28 04:25:11 +04:00
|
|
|
|
|
2017-08-11 11:07:46 +03:00
|
|
|
|
_fseeki64(fp, 0, SEEK_END);
|
|
|
|
|
file_size = _ftelli64(fp);
|
|
|
|
|
_fseeki64(fp, 0, SEEK_SET);
|
2012-10-28 04:25:11 +04:00
|
|
|
|
|
|
|
|
|
if (file_size < 1)
|
2013-08-28 18:13:09 +04:00
|
|
|
|
{
|
2018-12-11 11:27:32 +03:00
|
|
|
|
WLog_ERR(TAG, "RDP file %s is empty", name);
|
2013-08-28 18:13:09 +04:00
|
|
|
|
fclose(fp);
|
2012-10-28 04:25:11 +04:00
|
|
|
|
return FALSE;
|
2013-08-28 18:13:09 +04:00
|
|
|
|
}
|
2012-10-28 04:25:11 +04:00
|
|
|
|
|
2019-07-18 14:53:30 +03:00
|
|
|
|
buffer = (BYTE*)malloc((size_t)file_size + 2);
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
if (!buffer)
|
|
|
|
|
{
|
|
|
|
|
fclose(fp);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2019-07-18 14:53:30 +03:00
|
|
|
|
read_size = fread(buffer, (size_t)file_size, 1, fp);
|
2012-10-28 04:25:11 +04:00
|
|
|
|
|
|
|
|
|
if (!read_size)
|
|
|
|
|
{
|
|
|
|
|
if (!ferror(fp))
|
2019-07-18 14:53:30 +03:00
|
|
|
|
read_size = (size_t)file_size;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2013-08-28 18:13:09 +04:00
|
|
|
|
fclose(fp);
|
2012-10-28 04:25:11 +04:00
|
|
|
|
|
|
|
|
|
if (read_size < 1)
|
|
|
|
|
{
|
2018-12-11 11:27:32 +03:00
|
|
|
|
WLog_ERR(TAG, "Could not read from RDP file %s", name);
|
2012-10-28 04:25:11 +04:00
|
|
|
|
free(buffer);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-13 02:03:56 +04:00
|
|
|
|
buffer[file_size] = '\0';
|
|
|
|
|
buffer[file_size + 1] = '\0';
|
2019-07-18 14:53:30 +03:00
|
|
|
|
status = freerdp_client_parse_rdp_file_buffer_ex(file, buffer, (size_t)file_size, parse);
|
2013-11-05 08:45:19 +04:00
|
|
|
|
free(buffer);
|
|
|
|
|
return status;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
}
|
2012-10-28 05:30:08 +04:00
|
|
|
|
|
2021-04-12 12:06:45 +03:00
|
|
|
|
static INLINE BOOL FILE_POPULATE_STRING(char** _target, const rdpSettings* _settings,
|
|
|
|
|
size_t _option)
|
|
|
|
|
{
|
|
|
|
|
const char* str;
|
|
|
|
|
if (!_target || !_settings)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
str = freerdp_settings_get_string(_settings, _option);
|
|
|
|
|
freerdp_client_file_string_check_free(*_target);
|
2021-06-02 13:29:55 +03:00
|
|
|
|
*_target = (void*)~((size_t)NULL);
|
2021-04-12 12:06:45 +03:00
|
|
|
|
if (str)
|
|
|
|
|
{
|
|
|
|
|
*_target = _strdup(str);
|
|
|
|
|
if (!_target)
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char* freerdp_client_channel_args_to_string(const rdpSettings* settings, const char* channel,
|
|
|
|
|
const char* option)
|
2021-04-12 11:38:40 +03:00
|
|
|
|
{
|
|
|
|
|
ADDIN_ARGV* args = freerdp_dynamic_channel_collection_find(settings, channel);
|
2021-04-12 12:06:45 +03:00
|
|
|
|
const char* filters[] = { option };
|
2021-04-12 11:38:40 +03:00
|
|
|
|
if (!args || (args->argc < 2))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2021-04-12 12:06:45 +03:00
|
|
|
|
return CommandLineToCommaSeparatedValuesEx(args->argc - 1, args->argv + 1, filters,
|
|
|
|
|
ARRAYSIZE(filters));
|
2021-04-12 11:38:40 +03:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-07 19:37:46 +04:00
|
|
|
|
BOOL freerdp_client_populate_rdp_file_from_settings(rdpFile* file, const rdpSettings* settings)
|
2013-04-23 00:08:47 +04:00
|
|
|
|
{
|
2021-04-12 12:06:45 +03:00
|
|
|
|
size_t index;
|
|
|
|
|
UINT32 LoadBalanceInfoLength;
|
|
|
|
|
const char* GatewayHostname = NULL;
|
2021-06-02 13:29:55 +03:00
|
|
|
|
char* redirectCameras = NULL;
|
2021-10-12 12:04:09 +03:00
|
|
|
|
char* redirectUsb = NULL;
|
2021-04-12 12:06:45 +03:00
|
|
|
|
|
|
|
|
|
if (!FILE_POPULATE_STRING(&file->Domain, settings, FreeRDP_Domain) ||
|
|
|
|
|
!FILE_POPULATE_STRING(&file->Username, settings, FreeRDP_Username) ||
|
|
|
|
|
!FILE_POPULATE_STRING(&file->Password, settings, FreeRDP_Password) ||
|
|
|
|
|
!FILE_POPULATE_STRING(&file->FullAddress, settings, FreeRDP_ServerHostname) ||
|
|
|
|
|
!FILE_POPULATE_STRING(&file->AlternateFullAddress, settings, FreeRDP_ServerHostname) ||
|
|
|
|
|
!FILE_POPULATE_STRING(&file->AlternateShell, settings, FreeRDP_AlternateShell) ||
|
|
|
|
|
!FILE_POPULATE_STRING(&file->DrivesToRedirect, settings, FreeRDP_DrivesToRedirect))
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
file->ServerPort = freerdp_settings_get_uint32(settings, FreeRDP_ServerPort);
|
|
|
|
|
|
|
|
|
|
file->DesktopWidth = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
|
|
|
|
|
file->DesktopHeight = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
|
|
|
|
|
file->SessionBpp = freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth);
|
|
|
|
|
file->DesktopScaleFactor = freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor);
|
|
|
|
|
file->DynamicResolution = freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate);
|
|
|
|
|
file->VideoPlaybackMode = freerdp_settings_get_bool(settings, FreeRDP_SupportVideoOptimized);
|
|
|
|
|
|
|
|
|
|
// TODO file->MaximizeToCurrentDisplays;
|
|
|
|
|
// TODO file->SingleMonInWindowedMode;
|
|
|
|
|
// TODO file->EncodeRedirectedVideoCapture;
|
|
|
|
|
// TODO file->RedirectedVideoCaptureEncodingQuality;
|
|
|
|
|
file->ConnectToConsole = freerdp_settings_get_bool(settings, FreeRDP_ConsoleSession);
|
|
|
|
|
file->NegotiateSecurityLayer =
|
|
|
|
|
freerdp_settings_get_bool(settings, FreeRDP_NegotiateSecurityLayer);
|
|
|
|
|
file->EnableCredSSPSupport = freerdp_settings_get_bool(settings, FreeRDP_NlaSecurity);
|
|
|
|
|
|
|
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_RemoteApplicationMode))
|
|
|
|
|
index = FreeRDP_RemoteApplicationWorkingDir;
|
2020-11-12 18:18:17 +03:00
|
|
|
|
else
|
2021-04-12 12:06:45 +03:00
|
|
|
|
index = FreeRDP_ShellWorkingDirectory;
|
|
|
|
|
if (!FILE_POPULATE_STRING(&file->ShellWorkingDirectory, settings, index))
|
|
|
|
|
return FALSE;
|
|
|
|
|
file->ConnectionType = freerdp_settings_get_uint32(settings, FreeRDP_ConnectionType);
|
|
|
|
|
|
|
|
|
|
file->ScreenModeId = freerdp_settings_get_bool(settings, FreeRDP_Fullscreen) ? 2 : 1;
|
2020-01-22 15:13:51 +03:00
|
|
|
|
|
2021-04-12 12:06:45 +03:00
|
|
|
|
LoadBalanceInfoLength = freerdp_settings_get_uint32(settings, FreeRDP_LoadBalanceInfoLength);
|
|
|
|
|
if (LoadBalanceInfoLength > 0)
|
2013-04-23 00:08:47 +04:00
|
|
|
|
{
|
2021-04-12 12:06:45 +03:00
|
|
|
|
const BYTE* LoadBalanceInfo =
|
|
|
|
|
freerdp_settings_get_pointer(settings, FreeRDP_LoadBalanceInfo);
|
|
|
|
|
file->LoadBalanceInfo = calloc(LoadBalanceInfoLength + 1, 1);
|
2020-01-22 15:13:51 +03:00
|
|
|
|
if (!file->LoadBalanceInfo)
|
|
|
|
|
return FALSE;
|
2021-04-12 12:06:45 +03:00
|
|
|
|
memcpy(file->LoadBalanceInfo, LoadBalanceInfo, LoadBalanceInfoLength);
|
2013-04-23 00:08:47 +04:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-12 12:06:45 +03:00
|
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_AudioPlayback))
|
2020-01-22 15:13:51 +03:00
|
|
|
|
file->AudioMode = AUDIO_MODE_REDIRECT;
|
2021-04-12 12:06:45 +03:00
|
|
|
|
else if (freerdp_settings_get_bool(settings, FreeRDP_RemoteConsoleAudio))
|
2020-01-22 15:13:51 +03:00
|
|
|
|
file->AudioMode = AUDIO_MODE_PLAY_ON_SERVER;
|
|
|
|
|
else
|
|
|
|
|
file->AudioMode = AUDIO_MODE_NONE;
|
|
|
|
|
|
2020-11-12 18:18:17 +03:00
|
|
|
|
/* The gateway hostname should also contain a port specifier unless it is the default port 443
|
|
|
|
|
*/
|
2021-04-12 12:06:45 +03:00
|
|
|
|
GatewayHostname = freerdp_settings_get_string(settings, FreeRDP_GatewayHostname);
|
|
|
|
|
if (GatewayHostname)
|
2020-11-12 18:18:17 +03:00
|
|
|
|
{
|
2021-04-12 12:06:45 +03:00
|
|
|
|
const UINT32 GatewayPort = freerdp_settings_get_uint32(settings, FreeRDP_GatewayPort);
|
2020-11-12 18:18:17 +03:00
|
|
|
|
freerdp_client_file_string_check_free(file->GatewayHostname);
|
2021-04-12 12:06:45 +03:00
|
|
|
|
if (GatewayPort == 443)
|
|
|
|
|
file->GatewayHostname = _strdup(GatewayHostname);
|
2020-11-12 18:18:17 +03:00
|
|
|
|
else
|
|
|
|
|
{
|
2021-04-12 12:06:45 +03:00
|
|
|
|
int length = _scprintf("%s:%" PRIu32, GatewayHostname, GatewayPort);
|
2020-11-12 18:18:17 +03:00
|
|
|
|
if (length < 0)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
file->GatewayHostname = (char*)malloc((size_t)length + 1);
|
|
|
|
|
if (!file->GatewayHostname)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2021-04-12 12:06:45 +03:00
|
|
|
|
if (sprintf_s(file->GatewayHostname, (size_t)length + 1, "%s:%" PRIu32, GatewayHostname,
|
|
|
|
|
GatewayPort) < 0)
|
2020-11-12 18:18:17 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
if (!file->GatewayHostname)
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-12 12:06:45 +03:00
|
|
|
|
file->AudioCaptureMode = freerdp_settings_get_bool(settings, FreeRDP_AudioCapture);
|
|
|
|
|
file->BitmapCachePersistEnable =
|
|
|
|
|
freerdp_settings_get_bool(settings, FreeRDP_BitmapCachePersistEnabled);
|
|
|
|
|
file->Compression = freerdp_settings_get_bool(settings, FreeRDP_CompressionEnabled);
|
|
|
|
|
file->AuthenticationLevel = freerdp_settings_get_uint32(settings, FreeRDP_AuthenticationLevel);
|
|
|
|
|
file->GatewayUsageMethod = freerdp_settings_get_uint32(settings, FreeRDP_GatewayUsageMethod);
|
|
|
|
|
file->PromptCredentialOnce =
|
|
|
|
|
freerdp_settings_get_bool(settings, FreeRDP_GatewayUseSameCredentials);
|
|
|
|
|
file->PromptForCredentials = freerdp_settings_get_bool(settings, FreeRDP_PromptForCredentials);
|
|
|
|
|
file->RemoteApplicationMode =
|
|
|
|
|
freerdp_settings_get_bool(settings, FreeRDP_RemoteApplicationMode);
|
|
|
|
|
if (!FILE_POPULATE_STRING(&file->GatewayAccessToken, settings, FreeRDP_GatewayAccessToken) ||
|
|
|
|
|
!FILE_POPULATE_STRING(&file->RemoteApplicationProgram, settings,
|
|
|
|
|
FreeRDP_RemoteApplicationProgram) ||
|
|
|
|
|
!FILE_POPULATE_STRING(&file->RemoteApplicationName, settings,
|
|
|
|
|
FreeRDP_RemoteApplicationName) ||
|
|
|
|
|
!FILE_POPULATE_STRING(&file->RemoteApplicationIcon, settings,
|
|
|
|
|
FreeRDP_RemoteApplicationIcon) ||
|
|
|
|
|
!FILE_POPULATE_STRING(&file->RemoteApplicationFile, settings,
|
|
|
|
|
FreeRDP_RemoteApplicationFile) ||
|
|
|
|
|
!FILE_POPULATE_STRING(&file->RemoteApplicationGuid, settings,
|
|
|
|
|
FreeRDP_RemoteApplicationGuid) ||
|
|
|
|
|
!FILE_POPULATE_STRING(&file->RemoteApplicationCmdLine, settings,
|
|
|
|
|
FreeRDP_RemoteApplicationCmdLine))
|
|
|
|
|
return FALSE;
|
|
|
|
|
file->SpanMonitors = freerdp_settings_get_bool(settings, FreeRDP_SpanMonitors);
|
|
|
|
|
file->UseMultiMon = freerdp_settings_get_bool(settings, FreeRDP_UseMultimon);
|
|
|
|
|
file->AllowDesktopComposition =
|
|
|
|
|
freerdp_settings_get_bool(settings, FreeRDP_AllowDesktopComposition);
|
|
|
|
|
file->AllowFontSmoothing = freerdp_settings_get_bool(settings, FreeRDP_AllowFontSmoothing);
|
|
|
|
|
file->DisableWallpaper = freerdp_settings_get_bool(settings, FreeRDP_DisableWallpaper);
|
|
|
|
|
file->DisableFullWindowDrag =
|
|
|
|
|
freerdp_settings_get_bool(settings, FreeRDP_DisableFullWindowDrag);
|
|
|
|
|
file->DisableMenuAnims = freerdp_settings_get_bool(settings, FreeRDP_DisableMenuAnims);
|
|
|
|
|
file->DisableThemes = freerdp_settings_get_bool(settings, FreeRDP_DisableThemes);
|
|
|
|
|
file->BandwidthAutoDetect =
|
|
|
|
|
(freerdp_settings_get_uint32(settings, FreeRDP_ConnectionType) >= 7) ? TRUE : FALSE;
|
|
|
|
|
file->NetworkAutoDetect =
|
|
|
|
|
freerdp_settings_get_bool(settings, FreeRDP_NetworkAutoDetect) ? 0 : 1;
|
|
|
|
|
file->AutoReconnectionEnabled =
|
|
|
|
|
freerdp_settings_get_bool(settings, FreeRDP_AutoReconnectionEnabled);
|
|
|
|
|
file->RedirectSmartCards = freerdp_settings_get_bool(settings, FreeRDP_RedirectSmartCards);
|
2021-06-02 13:29:55 +03:00
|
|
|
|
|
2021-09-23 15:52:03 +03:00
|
|
|
|
redirectCameras =
|
|
|
|
|
freerdp_client_channel_args_to_string(settings, RDPECAM_DVC_CHANNEL_NAME, "device:");
|
2021-06-02 13:29:55 +03:00
|
|
|
|
if (redirectCameras)
|
2021-04-12 12:06:45 +03:00
|
|
|
|
{
|
2021-09-23 15:52:03 +03:00
|
|
|
|
char* str =
|
|
|
|
|
freerdp_client_channel_args_to_string(settings, RDPECAM_DVC_CHANNEL_NAME, "encode:");
|
2021-04-12 12:06:45 +03:00
|
|
|
|
file->EncodeRedirectedVideoCapture = 0;
|
|
|
|
|
if (str)
|
|
|
|
|
{
|
|
|
|
|
unsigned long val;
|
|
|
|
|
errno = 0;
|
|
|
|
|
val = strtoul(str, NULL, 0);
|
|
|
|
|
if ((val < UINT32_MAX) && (errno == 0))
|
|
|
|
|
file->EncodeRedirectedVideoCapture = val;
|
|
|
|
|
}
|
|
|
|
|
free(str);
|
|
|
|
|
|
2021-09-23 15:52:03 +03:00
|
|
|
|
str = freerdp_client_channel_args_to_string(settings, RDPECAM_DVC_CHANNEL_NAME, "quality:");
|
2021-04-12 12:06:45 +03:00
|
|
|
|
file->RedirectedVideoCaptureEncodingQuality = 0;
|
|
|
|
|
if (str)
|
|
|
|
|
{
|
|
|
|
|
unsigned long val;
|
|
|
|
|
errno = 0;
|
|
|
|
|
val = strtoul(str, NULL, 0);
|
|
|
|
|
if ((val <= 2) && (errno == 0))
|
|
|
|
|
{
|
|
|
|
|
file->RedirectedVideoCaptureEncodingQuality = val;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
free(str);
|
2021-06-02 13:29:55 +03:00
|
|
|
|
|
|
|
|
|
file->RedirectCameras = redirectCameras;
|
2021-04-12 12:06:45 +03:00
|
|
|
|
}
|
|
|
|
|
#ifdef CHANNEL_URBDRC_CLIENT
|
2021-10-12 12:04:09 +03:00
|
|
|
|
redirectUsb = freerdp_client_channel_args_to_string(settings, URBDRC_CHANNEL_NAME, "device:");
|
|
|
|
|
if (redirectUsb)
|
|
|
|
|
file->UsbDevicesToRedirect = redirectUsb;
|
|
|
|
|
|
2021-04-12 12:06:45 +03:00
|
|
|
|
#endif
|
|
|
|
|
file->RedirectClipboard = freerdp_settings_get_bool(settings, FreeRDP_RedirectClipboard);
|
|
|
|
|
file->RedirectPrinters = freerdp_settings_get_bool(settings, FreeRDP_RedirectPrinters);
|
|
|
|
|
file->RedirectDrives = freerdp_settings_get_bool(settings, FreeRDP_RedirectDrives);
|
|
|
|
|
file->RedirectComPorts = (freerdp_settings_get_bool(settings, FreeRDP_RedirectSerialPorts) ||
|
|
|
|
|
freerdp_settings_get_bool(settings, FreeRDP_RedirectParallelPorts));
|
|
|
|
|
if (!FILE_POPULATE_STRING(&file->DrivesToRedirect, settings, FreeRDP_DrivesToRedirect) ||
|
|
|
|
|
!FILE_POPULATE_STRING(&file->PreconnectionBlob, settings, FreeRDP_PreconnectionBlob))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
size_t offset = 0;
|
|
|
|
|
UINT32 x, count = freerdp_settings_get_uint32(settings, FreeRDP_NumMonitorIds);
|
|
|
|
|
const UINT32* MonitorIds = freerdp_settings_get_pointer(settings, FreeRDP_MonitorIds);
|
|
|
|
|
/* String size: 10 char UINT32 max string length, 1 char separator, one element NULL */
|
|
|
|
|
size_t size = count * (10 + 1) + 1;
|
|
|
|
|
|
|
|
|
|
char* str = calloc(size, sizeof(char));
|
|
|
|
|
for (x = 0; x < count; x++)
|
|
|
|
|
{
|
|
|
|
|
int rc = _snprintf(&str[offset], size - offset, "%" PRIu32 ",", MonitorIds[x]);
|
|
|
|
|
if (rc <= 0)
|
|
|
|
|
{
|
|
|
|
|
free(str);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
offset += (size_t)rc;
|
|
|
|
|
}
|
|
|
|
|
if (offset > 0)
|
|
|
|
|
str[offset - 1] = '\0';
|
|
|
|
|
freerdp_client_file_string_check_free(file->SelectedMonitors);
|
|
|
|
|
file->SelectedMonitors = str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
file->KeyboardHook = freerdp_settings_get_uint32(settings, FreeRDP_KeyboardHook);
|
2020-01-22 15:13:51 +03:00
|
|
|
|
|
2013-04-23 00:08:47 +04:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-07 19:37:46 +04:00
|
|
|
|
BOOL freerdp_client_write_rdp_file(const rdpFile* file, const char* name, BOOL unicode)
|
2013-04-23 00:08:47 +04:00
|
|
|
|
{
|
2013-12-05 03:25:55 +04:00
|
|
|
|
FILE* fp;
|
2019-02-07 16:38:16 +03:00
|
|
|
|
size_t size;
|
2013-04-23 00:08:47 +04:00
|
|
|
|
char* buffer;
|
2013-12-05 03:25:55 +04:00
|
|
|
|
int status = 0;
|
2013-04-23 00:08:47 +04:00
|
|
|
|
WCHAR* unicodestr = NULL;
|
2019-02-07 16:38:16 +03:00
|
|
|
|
size = freerdp_client_write_rdp_file_buffer(file, NULL, 0);
|
2019-07-18 14:53:30 +03:00
|
|
|
|
if (size == 0)
|
|
|
|
|
return FALSE;
|
|
|
|
|
buffer = (char*)calloc((size_t)(size + 1), sizeof(char));
|
2013-09-18 22:01:19 +04:00
|
|
|
|
|
2019-07-18 14:53:30 +03:00
|
|
|
|
if (freerdp_client_write_rdp_file_buffer(file, buffer, (size_t)size + 1) != size)
|
2013-04-23 00:08:47 +04:00
|
|
|
|
{
|
2019-07-17 16:48:26 +03:00
|
|
|
|
WLog_ERR(TAG, "freerdp_client_write_rdp_file: error writing to output buffer");
|
2014-04-26 08:19:28 +04:00
|
|
|
|
free(buffer);
|
2013-12-05 03:25:55 +04:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2013-09-18 22:01:19 +04:00
|
|
|
|
|
2021-05-31 12:42:03 +03:00
|
|
|
|
fp = winpr_fopen(name, "w+b");
|
2013-04-23 00:08:47 +04:00
|
|
|
|
|
2013-12-05 03:25:55 +04:00
|
|
|
|
if (fp)
|
|
|
|
|
{
|
|
|
|
|
if (unicode)
|
|
|
|
|
{
|
2019-02-07 16:38:16 +03:00
|
|
|
|
int length;
|
2019-05-08 15:35:25 +03:00
|
|
|
|
|
2019-02-07 16:38:16 +03:00
|
|
|
|
if (size > INT_MAX)
|
|
|
|
|
{
|
|
|
|
|
free(buffer);
|
|
|
|
|
free(unicodestr);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
length = (int)size;
|
2013-12-05 03:25:55 +04:00
|
|
|
|
ConvertToUnicode(CP_UTF8, 0, buffer, length, &unicodestr, 0);
|
2013-04-23 00:08:47 +04:00
|
|
|
|
|
2013-12-05 03:25:55 +04:00
|
|
|
|
/* Write multi-byte header */
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if ((length < 0) || (fwrite(BOM_UTF16_LE, sizeof(BYTE), 2, fp) != 2) ||
|
2019-02-07 16:38:16 +03:00
|
|
|
|
(fwrite(unicodestr, 2, (size_t)length, fp) != (size_t)length))
|
2015-06-26 16:58:01 +03:00
|
|
|
|
{
|
|
|
|
|
free(buffer);
|
|
|
|
|
free(unicodestr);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2013-04-23 00:08:47 +04:00
|
|
|
|
|
2013-12-05 03:25:55 +04:00
|
|
|
|
free(unicodestr);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-07-18 14:53:30 +03:00
|
|
|
|
if (fwrite(buffer, 1, (size_t)size, fp) != (size_t)size)
|
2015-06-26 16:58:01 +03:00
|
|
|
|
{
|
|
|
|
|
free(buffer);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2013-04-23 00:08:47 +04:00
|
|
|
|
}
|
2013-12-05 03:25:55 +04:00
|
|
|
|
|
2015-06-26 16:58:01 +03:00
|
|
|
|
fflush(fp);
|
2013-12-05 03:25:55 +04:00
|
|
|
|
status = fclose(fp);
|
2013-04-23 00:08:47 +04:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-11 10:07:39 +03:00
|
|
|
|
free(buffer);
|
2013-12-05 03:25:55 +04:00
|
|
|
|
return (status == 0) ? TRUE : FALSE;
|
2013-04-23 00:08:47 +04:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-16 15:50:14 +03:00
|
|
|
|
#if __GNUC__
|
2019-09-22 17:37:52 +03:00
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
|
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
2021-06-16 15:50:14 +03:00
|
|
|
|
#endif
|
2019-07-18 14:53:30 +03:00
|
|
|
|
static SSIZE_T freerdp_client_write_setting_to_buffer(char** buffer, size_t* bufferSize,
|
2019-11-06 17:24:51 +03:00
|
|
|
|
const char* fmt, ...)
|
2013-12-05 03:25:55 +04:00
|
|
|
|
{
|
2019-07-18 11:59:59 +03:00
|
|
|
|
va_list ap;
|
2019-07-18 14:53:30 +03:00
|
|
|
|
SSIZE_T len;
|
2019-08-14 10:46:47 +03:00
|
|
|
|
char* buf;
|
|
|
|
|
size_t bufSize;
|
|
|
|
|
|
|
|
|
|
if (!buffer || !bufferSize || !fmt)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
buf = *buffer;
|
|
|
|
|
bufSize = *bufferSize;
|
2019-07-18 11:59:59 +03:00
|
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
|
len = vsnprintf(buf, bufSize, fmt, ap);
|
|
|
|
|
va_end(ap);
|
|
|
|
|
if (len < 0)
|
|
|
|
|
return -1;
|
2013-12-05 03:25:55 +04:00
|
|
|
|
|
2019-07-18 11:59:59 +03:00
|
|
|
|
/* _snprintf doesn't add the ending \0 to its return value */
|
|
|
|
|
++len;
|
2013-12-05 03:25:55 +04:00
|
|
|
|
|
2019-07-18 11:59:59 +03:00
|
|
|
|
/* we just want to know the size - return it */
|
|
|
|
|
if (!buf && !bufSize)
|
|
|
|
|
return len;
|
2013-12-05 03:25:55 +04:00
|
|
|
|
|
2019-08-14 10:46:47 +03:00
|
|
|
|
if (!buf)
|
|
|
|
|
return -1;
|
|
|
|
|
|
2019-07-18 11:59:59 +03:00
|
|
|
|
/* update buffer size and buffer position and replace \0 with \n */
|
2019-07-18 14:53:30 +03:00
|
|
|
|
if (bufSize >= (size_t)len)
|
2013-12-05 03:25:55 +04:00
|
|
|
|
{
|
2019-07-18 14:53:30 +03:00
|
|
|
|
*bufferSize -= (size_t)len;
|
2019-07-18 11:59:59 +03:00
|
|
|
|
buf[len - 1] = '\n';
|
|
|
|
|
*buffer = buf + len;
|
2013-04-23 02:39:18 +04:00
|
|
|
|
}
|
2019-07-18 11:59:59 +03:00
|
|
|
|
else
|
|
|
|
|
return -1;
|
2013-04-23 02:39:18 +04:00
|
|
|
|
|
2019-07-18 11:59:59 +03:00
|
|
|
|
return len;
|
|
|
|
|
}
|
2021-06-16 15:50:14 +03:00
|
|
|
|
#if __GNUC__
|
2019-09-22 17:37:52 +03:00
|
|
|
|
#pragma GCC diagnostic pop
|
2021-06-16 15:50:14 +03:00
|
|
|
|
#endif
|
2013-04-23 02:39:18 +04:00
|
|
|
|
|
2019-07-18 11:59:59 +03:00
|
|
|
|
size_t freerdp_client_write_rdp_file_buffer(const rdpFile* file, char* buffer, size_t size)
|
|
|
|
|
{
|
|
|
|
|
size_t totalSize = 0;
|
|
|
|
|
|
|
|
|
|
/* either buffer and size are null or non-null */
|
|
|
|
|
if ((!buffer || !size) && (buffer || size))
|
2019-07-18 14:53:30 +03:00
|
|
|
|
return 0;
|
2019-07-18 11:59:59 +03:00
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
|
#define WRITE_SETTING_(fmt_, param_) \
|
|
|
|
|
{ \
|
2019-07-18 14:53:30 +03:00
|
|
|
|
SSIZE_T res = freerdp_client_write_setting_to_buffer(&buffer, &size, fmt_, param_); \
|
2019-11-06 17:24:51 +03:00
|
|
|
|
if (res < 0) \
|
|
|
|
|
return 0; \
|
2019-07-18 14:53:30 +03:00
|
|
|
|
totalSize += (size_t)res; \
|
2019-07-18 11:59:59 +03:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-18 11:00:21 +03:00
|
|
|
|
#define WRITE_SETTING_INT(fmt_, param_) \
|
|
|
|
|
do \
|
|
|
|
|
{ \
|
|
|
|
|
if (~(param_)) \
|
|
|
|
|
WRITE_SETTING_(fmt_, param_) \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
#define WRITE_SETTING_STR(fmt_, param_) \
|
|
|
|
|
do \
|
|
|
|
|
{ \
|
|
|
|
|
if (~(size_t)(param_)) \
|
|
|
|
|
WRITE_SETTING_(fmt_, param_) \
|
|
|
|
|
} while (0)
|
2019-07-18 14:53:30 +03:00
|
|
|
|
|
2019-07-18 11:59:59 +03:00
|
|
|
|
/* integer parameters */
|
2019-11-06 17:24:51 +03:00
|
|
|
|
WRITE_SETTING_INT("use multimon:i:%" PRIu32, file->UseMultiMon);
|
2021-04-12 12:06:45 +03:00
|
|
|
|
WRITE_SETTING_INT("maximizetocurrentdisplays:i:%" PRIu32, file->MaximizeToCurrentDisplays);
|
|
|
|
|
WRITE_SETTING_INT("singlemoninwindowedmode:i:%" PRIu32, file->SingleMonInWindowedMode);
|
2019-11-06 17:24:51 +03:00
|
|
|
|
WRITE_SETTING_INT("screen mode id:i:%" PRIu32, file->ScreenModeId);
|
|
|
|
|
WRITE_SETTING_INT("span monitors:i:%" PRIu32, file->SpanMonitors);
|
|
|
|
|
WRITE_SETTING_INT("smart sizing:i:%" PRIu32, file->SmartSizing);
|
2021-04-12 12:06:45 +03:00
|
|
|
|
WRITE_SETTING_INT("dynamic resolution:i:%" PRIu32, file->DynamicResolution);
|
2019-11-06 17:24:51 +03:00
|
|
|
|
WRITE_SETTING_INT("enablesuperpan:i:%" PRIu32, file->EnableSuperSpan);
|
|
|
|
|
WRITE_SETTING_INT("superpanaccelerationfactor:i:%" PRIu32, file->SuperSpanAccelerationFactor);
|
|
|
|
|
WRITE_SETTING_INT("desktopwidth:i:%" PRIu32, file->DesktopWidth);
|
|
|
|
|
WRITE_SETTING_INT("desktopheight:i:%" PRIu32, file->DesktopHeight);
|
|
|
|
|
WRITE_SETTING_INT("desktop size id:i:%" PRIu32, file->DesktopSizeId);
|
|
|
|
|
WRITE_SETTING_INT("session bpp:i:%" PRIu32, file->SessionBpp);
|
2021-04-12 12:06:45 +03:00
|
|
|
|
WRITE_SETTING_INT("desktopscalefactor:i:%" PRIu32, file->DesktopScaleFactor);
|
2019-11-06 17:24:51 +03:00
|
|
|
|
WRITE_SETTING_INT("compression:i:%" PRIu32, file->Compression);
|
|
|
|
|
WRITE_SETTING_INT("keyboardhook:i:%" PRIu32, file->KeyboardHook);
|
|
|
|
|
WRITE_SETTING_INT("disable ctrl+alt+del:i:%" PRIu32, file->DisableCtrlAltDel);
|
|
|
|
|
WRITE_SETTING_INT("audiomode:i:%" PRIu32, file->AudioMode);
|
|
|
|
|
WRITE_SETTING_INT("audioqualitymode:i:%" PRIu32, file->AudioQualityMode);
|
|
|
|
|
WRITE_SETTING_INT("audiocapturemode:i:%" PRIu32, file->AudioCaptureMode);
|
2021-04-12 12:06:45 +03:00
|
|
|
|
WRITE_SETTING_INT("encode redirected video capture:i:%" PRIu32,
|
|
|
|
|
file->EncodeRedirectedVideoCapture);
|
|
|
|
|
WRITE_SETTING_INT("redirected video capture encoding quality:i:%" PRIu32,
|
|
|
|
|
file->RedirectedVideoCaptureEncodingQuality);
|
2019-11-06 17:24:51 +03:00
|
|
|
|
WRITE_SETTING_INT("videoplaybackmode:i:%" PRIu32, file->VideoPlaybackMode);
|
|
|
|
|
WRITE_SETTING_INT("connection type:i:%" PRIu32, file->ConnectionType);
|
|
|
|
|
WRITE_SETTING_INT("networkautodetect:i:%" PRIu32, file->NetworkAutoDetect);
|
|
|
|
|
WRITE_SETTING_INT("bandwidthautodetect:i:%" PRIu32, file->BandwidthAutoDetect);
|
|
|
|
|
WRITE_SETTING_INT("pinconnectionbar:i:%" PRIu32, file->PinConnectionBar);
|
|
|
|
|
WRITE_SETTING_INT("displayconnectionbar:i:%" PRIu32, file->DisplayConnectionBar);
|
|
|
|
|
WRITE_SETTING_INT("workspaceid:i:%" PRIu32, file->WorkspaceId);
|
|
|
|
|
WRITE_SETTING_INT("enableworkspacereconnect:i:%" PRIu32, file->EnableWorkspaceReconnect);
|
|
|
|
|
WRITE_SETTING_INT("disable wallpaper:i:%" PRIu32, file->DisableWallpaper);
|
|
|
|
|
WRITE_SETTING_INT("allow font smoothing:i:%" PRIu32, file->AllowFontSmoothing);
|
|
|
|
|
WRITE_SETTING_INT("allow desktop composition:i:%" PRIu32, file->AllowDesktopComposition);
|
|
|
|
|
WRITE_SETTING_INT("disable full window drag:i:%" PRIu32, file->DisableFullWindowDrag);
|
|
|
|
|
WRITE_SETTING_INT("disable menu anims:i:%" PRIu32, file->DisableMenuAnims);
|
|
|
|
|
WRITE_SETTING_INT("disable themes:i:%" PRIu32, file->DisableThemes);
|
|
|
|
|
WRITE_SETTING_INT("disable cursor setting:i:%" PRIu32, file->DisableCursorSetting);
|
|
|
|
|
WRITE_SETTING_INT("bitmapcachesize:i:%" PRIu32, file->BitmapCacheSize);
|
|
|
|
|
WRITE_SETTING_INT("bitmapcachepersistenable:i:%" PRIu32, file->BitmapCachePersistEnable);
|
|
|
|
|
WRITE_SETTING_INT("server port:i:%" PRIu32, file->ServerPort);
|
|
|
|
|
WRITE_SETTING_INT("redirectdrives:i:%" PRIu32, file->RedirectDrives);
|
|
|
|
|
WRITE_SETTING_INT("redirectprinters:i:%" PRIu32, file->RedirectPrinters);
|
|
|
|
|
WRITE_SETTING_INT("redirectcomports:i:%" PRIu32, file->RedirectComPorts);
|
|
|
|
|
WRITE_SETTING_INT("redirectsmartcards:i:%" PRIu32, file->RedirectSmartCards);
|
|
|
|
|
WRITE_SETTING_INT("redirectclipboard:i:%" PRIu32, file->RedirectClipboard);
|
|
|
|
|
WRITE_SETTING_INT("redirectposdevices:i:%" PRIu32, file->RedirectPosDevices);
|
|
|
|
|
WRITE_SETTING_INT("redirectdirectx:i:%" PRIu32, file->RedirectDirectX);
|
|
|
|
|
WRITE_SETTING_INT("disableprinterredirection:i:%" PRIu32, file->DisablePrinterRedirection);
|
|
|
|
|
WRITE_SETTING_INT("disableclipboardredirection:i:%" PRIu32, file->DisableClipboardRedirection);
|
|
|
|
|
WRITE_SETTING_INT("connect to console:i:%" PRIu32, file->ConnectToConsole);
|
|
|
|
|
WRITE_SETTING_INT("administrative session:i:%" PRIu32, file->AdministrativeSession);
|
|
|
|
|
WRITE_SETTING_INT("autoreconnection enabled:i:%" PRIu32, file->AutoReconnectionEnabled);
|
|
|
|
|
WRITE_SETTING_INT("autoreconnect max retries:i:%" PRIu32, file->AutoReconnectMaxRetries);
|
|
|
|
|
WRITE_SETTING_INT("public mode:i:%" PRIu32, file->PublicMode);
|
|
|
|
|
WRITE_SETTING_INT("authentication level:i:%" PRId32, file->AuthenticationLevel);
|
|
|
|
|
WRITE_SETTING_INT("promptcredentialonce:i:%" PRIu32, file->PromptCredentialOnce);
|
|
|
|
|
WRITE_SETTING_INT("prompt for credentials:i:%" PRIu32, file->PromptForCredentials);
|
|
|
|
|
WRITE_SETTING_INT("negotiate security layer:i:%" PRIu32, file->NegotiateSecurityLayer);
|
|
|
|
|
WRITE_SETTING_INT("enablecredsspsupport:i:%" PRIu32, file->EnableCredSSPSupport);
|
|
|
|
|
WRITE_SETTING_INT("remoteapplicationmode:i:%" PRIu32, file->RemoteApplicationMode);
|
|
|
|
|
WRITE_SETTING_INT("remoteapplicationexpandcmdline:i:%" PRIu32,
|
|
|
|
|
file->RemoteApplicationExpandCmdLine);
|
|
|
|
|
WRITE_SETTING_INT("remoteapplicationexpandworkingdir:i:%" PRIu32,
|
|
|
|
|
file->RemoteApplicationExpandWorkingDir);
|
|
|
|
|
WRITE_SETTING_INT("disableconnectionsharing:i:%" PRIu32, file->DisableConnectionSharing);
|
|
|
|
|
WRITE_SETTING_INT("disableremoteappcapscheck:i:%" PRIu32, file->DisableRemoteAppCapsCheck);
|
|
|
|
|
WRITE_SETTING_INT("gatewayusagemethod:i:%" PRIu32, file->GatewayUsageMethod);
|
|
|
|
|
WRITE_SETTING_INT("gatewayprofileusagemethod:i:%" PRIu32, file->GatewayProfileUsageMethod);
|
|
|
|
|
WRITE_SETTING_INT("gatewaycredentialssource:i:%" PRIu32, file->GatewayCredentialsSource);
|
|
|
|
|
WRITE_SETTING_INT("use redirection server name:i:%" PRIu32, file->UseRedirectionServerName);
|
|
|
|
|
WRITE_SETTING_INT("rdgiskdcproxy:i:%" PRIu32, file->RdgIsKdcProxy);
|
2019-07-18 11:59:59 +03:00
|
|
|
|
|
|
|
|
|
/* string parameters */
|
2019-07-18 14:53:30 +03:00
|
|
|
|
WRITE_SETTING_STR("username:s:%s", file->Username);
|
|
|
|
|
WRITE_SETTING_STR("domain:s:%s", file->Domain);
|
|
|
|
|
WRITE_SETTING_STR("password:s:%s", file->Password);
|
|
|
|
|
WRITE_SETTING_STR("full address:s:%s", file->FullAddress);
|
|
|
|
|
WRITE_SETTING_STR("alternate full address:s:%s", file->AlternateFullAddress);
|
|
|
|
|
WRITE_SETTING_STR("usbdevicestoredirect:s:%s", file->UsbDevicesToRedirect);
|
2021-04-12 11:38:40 +03:00
|
|
|
|
WRITE_SETTING_STR("camerastoredirect:s:%s", file->RedirectCameras);
|
2019-07-18 14:53:30 +03:00
|
|
|
|
WRITE_SETTING_STR("loadbalanceinfo:s:%s", file->LoadBalanceInfo);
|
|
|
|
|
WRITE_SETTING_STR("remoteapplicationname:s:%s", file->RemoteApplicationName);
|
|
|
|
|
WRITE_SETTING_STR("remoteapplicationicon:s:%s", file->RemoteApplicationIcon);
|
|
|
|
|
WRITE_SETTING_STR("remoteapplicationprogram:s:%s", file->RemoteApplicationProgram);
|
|
|
|
|
WRITE_SETTING_STR("remoteapplicationfile:s:%s", file->RemoteApplicationFile);
|
|
|
|
|
WRITE_SETTING_STR("remoteapplicationguid:s:%s", file->RemoteApplicationGuid);
|
|
|
|
|
WRITE_SETTING_STR("remoteapplicationcmdline:s:%s", file->RemoteApplicationCmdLine);
|
|
|
|
|
WRITE_SETTING_STR("alternate shell:s:%s", file->AlternateShell);
|
|
|
|
|
WRITE_SETTING_STR("shell working directory:s:%s", file->ShellWorkingDirectory);
|
|
|
|
|
WRITE_SETTING_STR("gatewayhostname:s:%s", file->GatewayHostname);
|
|
|
|
|
WRITE_SETTING_STR("gatewayaccesstoken:s:%s", file->GatewayAccessToken);
|
|
|
|
|
WRITE_SETTING_STR("kdcproxyname:s:%s", file->KdcProxyName);
|
|
|
|
|
WRITE_SETTING_STR("drivestoredirect:s:%s", file->DrivesToRedirect);
|
|
|
|
|
WRITE_SETTING_STR("devicestoredirect:s:%s", file->DevicesToRedirect);
|
|
|
|
|
WRITE_SETTING_STR("winposstr:s:%s", file->WinPosStr);
|
|
|
|
|
WRITE_SETTING_STR("pcb:s:%s", file->PreconnectionBlob);
|
2021-04-12 12:06:45 +03:00
|
|
|
|
WRITE_SETTING_STR("selectedmonitors:s:%s", file->SelectedMonitors);
|
2019-07-18 11:59:59 +03:00
|
|
|
|
|
|
|
|
|
return totalSize;
|
2013-04-23 00:08:47 +04:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-12 12:06:45 +03:00
|
|
|
|
static ADDIN_ARGV* rdp_file_to_args(const char* channel, const char* values)
|
|
|
|
|
{
|
|
|
|
|
size_t count, x;
|
|
|
|
|
char** p = NULL;
|
|
|
|
|
ADDIN_ARGV* args = freerdp_addin_argv_new(0, NULL);
|
|
|
|
|
if (!args)
|
|
|
|
|
return NULL;
|
|
|
|
|
if (!freerdp_addin_argv_add_argument(args, channel))
|
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
|
|
p = CommandLineParseCommaSeparatedValues(values, &count);
|
|
|
|
|
for (x = 0; x < count; x++)
|
|
|
|
|
{
|
|
|
|
|
BOOL rc;
|
|
|
|
|
const char* val = p[x];
|
|
|
|
|
const size_t len = strlen(val) + 8;
|
|
|
|
|
char* str = calloc(len, sizeof(char));
|
|
|
|
|
if (!str)
|
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
|
|
_snprintf(str, len, "device:%s", val);
|
|
|
|
|
rc = freerdp_addin_argv_add_argument(args, str);
|
|
|
|
|
free(str);
|
|
|
|
|
if (!rc)
|
|
|
|
|
goto fail;
|
|
|
|
|
}
|
|
|
|
|
free(p);
|
|
|
|
|
return args;
|
|
|
|
|
|
|
|
|
|
fail:
|
|
|
|
|
free(p);
|
|
|
|
|
freerdp_addin_argv_free(args);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2012-10-28 05:30:08 +04:00
|
|
|
|
BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings* settings)
|
|
|
|
|
{
|
2019-09-05 13:20:40 +03:00
|
|
|
|
BOOL setDefaultConnectionType = TRUE;
|
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (~((size_t)file->Domain))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_Domain, file->Domain))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2012-10-28 05:30:08 +04:00
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (~((size_t)file->Username))
|
2012-10-28 05:30:08 +04:00
|
|
|
|
{
|
2013-08-28 18:16:03 +04:00
|
|
|
|
char* user = NULL;
|
|
|
|
|
char* domain = NULL;
|
2012-10-28 05:30:08 +04:00
|
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
|
if (!freerdp_parse_username(file->Username, &user, &domain))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
return FALSE;
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_Username, user))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
return FALSE;
|
2013-04-23 00:08:47 +04:00
|
|
|
|
|
2013-09-18 01:03:35 +04:00
|
|
|
|
if (domain)
|
2015-06-17 23:08:02 +03:00
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_Domain, domain))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2013-08-28 18:16:03 +04:00
|
|
|
|
|
2015-05-11 10:07:39 +03:00
|
|
|
|
free(user);
|
|
|
|
|
free(domain);
|
2012-10-28 05:30:08 +04:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-10 23:38:52 +03:00
|
|
|
|
if (~((size_t)file->Password))
|
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_Password, file->Password))
|
2017-02-10 23:38:52 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-12 18:49:29 +04:00
|
|
|
|
{
|
2019-07-18 10:29:06 +03:00
|
|
|
|
const char* address = NULL;
|
2014-06-12 18:49:29 +04:00
|
|
|
|
|
2019-07-18 10:29:06 +03:00
|
|
|
|
/* With MSTSC alternate full address always wins,
|
|
|
|
|
* so mimic this. */
|
2019-07-18 11:59:59 +03:00
|
|
|
|
if (~((size_t)file->AlternateFullAddress))
|
2019-07-18 10:29:06 +03:00
|
|
|
|
address = file->AlternateFullAddress;
|
2019-07-18 11:59:59 +03:00
|
|
|
|
else if (~((size_t)file->FullAddress))
|
2019-07-18 10:29:06 +03:00
|
|
|
|
address = file->FullAddress;
|
2014-06-12 18:49:29 +04:00
|
|
|
|
|
2019-07-18 10:29:06 +03:00
|
|
|
|
if (address)
|
|
|
|
|
{
|
|
|
|
|
int port = -1;
|
|
|
|
|
char* host = NULL;
|
2014-06-12 18:49:29 +04:00
|
|
|
|
|
2019-07-18 10:29:06 +03:00
|
|
|
|
if (!freerdp_parse_hostname(address, &host, &port))
|
|
|
|
|
return FALSE;
|
2019-05-06 10:51:42 +03:00
|
|
|
|
|
2019-07-18 10:29:06 +03:00
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_ServerHostname, host))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
2019-07-18 10:29:06 +03:00
|
|
|
|
|
|
|
|
|
free(host);
|
|
|
|
|
|
|
|
|
|
if (port > 0)
|
|
|
|
|
{
|
2019-07-18 11:59:59 +03:00
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_ServerPort, (UINT32)port))
|
2019-07-18 10:29:06 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2019-05-06 10:51:42 +03:00
|
|
|
|
}
|
2014-06-12 18:49:29 +04:00
|
|
|
|
}
|
|
|
|
|
|
2012-10-28 05:30:08 +04:00
|
|
|
|
if (~file->ServerPort)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_ServerPort, file->ServerPort))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2013-04-23 02:39:18 +04:00
|
|
|
|
|
2019-11-29 11:09:30 +03:00
|
|
|
|
if (~file->DesktopSizeId)
|
|
|
|
|
{
|
|
|
|
|
switch (file->DesktopSizeId)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, 640))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, 480))
|
|
|
|
|
return FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, 800))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, 600))
|
|
|
|
|
return FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, 1024))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, 768))
|
|
|
|
|
return FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, 1280))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, 1024))
|
|
|
|
|
return FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, 1600))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, 1200))
|
|
|
|
|
return FALSE;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
WLog_WARN(TAG, "Unsupported 'desktop size id' value %" PRIu32, file->DesktopSizeId);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-10-28 05:30:08 +04:00
|
|
|
|
if (~file->DesktopWidth)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, file->DesktopWidth))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2012-10-28 05:30:08 +04:00
|
|
|
|
if (~file->DesktopHeight)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, file->DesktopHeight))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2012-10-28 05:30:08 +04:00
|
|
|
|
if (~file->SessionBpp)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_ColorDepth, file->SessionBpp))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2012-10-28 05:30:08 +04:00
|
|
|
|
if (~file->ConnectToConsole)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_ConsoleSession,
|
|
|
|
|
file->ConnectToConsole != 0))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2012-10-28 05:30:08 +04:00
|
|
|
|
if (~file->AdministrativeSession)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_ConsoleSession,
|
2019-11-06 17:24:51 +03:00
|
|
|
|
file->AdministrativeSession != 0))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2012-10-28 05:30:08 +04:00
|
|
|
|
if (~file->NegotiateSecurityLayer)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_NegotiateSecurityLayer,
|
2019-11-06 17:24:51 +03:00
|
|
|
|
file->NegotiateSecurityLayer != 0))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2012-10-28 05:30:08 +04:00
|
|
|
|
if (~file->EnableCredSSPSupport)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_NlaSecurity,
|
|
|
|
|
file->EnableCredSSPSupport != 0))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (~((size_t)file->AlternateShell))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_AlternateShell, file->AlternateShell))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (~((size_t)file->ShellWorkingDirectory))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
{
|
2020-11-12 18:18:17 +03:00
|
|
|
|
/* ShellWorkingDir is used for either, shell working dir or remote app working dir */
|
|
|
|
|
size_t targetId = (~file->RemoteApplicationMode && file->RemoteApplicationMode != 0)
|
|
|
|
|
? FreeRDP_RemoteApplicationWorkingDir
|
|
|
|
|
: FreeRDP_ShellWorkingDirectory;
|
|
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_string(settings, targetId, file->ShellWorkingDirectory))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2014-05-11 01:28:34 +04:00
|
|
|
|
|
2013-09-17 23:42:36 +04:00
|
|
|
|
if (~file->ScreenModeId)
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Screen Mode Id:
|
|
|
|
|
* http://technet.microsoft.com/en-us/library/ff393692/
|
|
|
|
|
*
|
|
|
|
|
* This setting corresponds to the selection in the Display
|
|
|
|
|
* configuration slider on the Display tab under Options in RDC.
|
|
|
|
|
*
|
|
|
|
|
* Values:
|
|
|
|
|
*
|
2014-05-29 19:48:38 +04:00
|
|
|
|
* 1: The remote session will appear in a window.
|
|
|
|
|
* 2: The remote session will appear full screen.
|
2013-09-17 23:42:36 +04:00
|
|
|
|
*/
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_Fullscreen,
|
|
|
|
|
(file->ScreenModeId == 2) ? TRUE : FALSE))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
2013-09-17 23:42:36 +04:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-07 16:38:16 +03:00
|
|
|
|
if (~(file->SmartSizing))
|
2014-04-30 01:33:59 +04:00
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SmartSizing,
|
|
|
|
|
(file->SmartSizing == 1) ? TRUE : FALSE))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
2019-11-28 20:59:15 +03:00
|
|
|
|
/**
|
|
|
|
|
* SmartSizingWidth and SmartSizingHeight:
|
|
|
|
|
*
|
|
|
|
|
* Adding this option to use the DesktopHeight and DesktopWidth as
|
|
|
|
|
* parameters for the SmartSizingWidth and SmartSizingHeight, as there
|
|
|
|
|
* are no options for that in standard RDP files.
|
|
|
|
|
*
|
|
|
|
|
* Equivalent of doing /smart-sizing:WxH
|
|
|
|
|
*/
|
|
|
|
|
if (((~(file->DesktopWidth) && ~(file->DesktopHeight)) || ~(file->DesktopSizeId)) &&
|
|
|
|
|
(file->SmartSizing == 1))
|
|
|
|
|
{
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_SmartSizingWidth,
|
|
|
|
|
file->DesktopWidth))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_SmartSizingHeight,
|
|
|
|
|
file->DesktopHeight))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2014-04-30 01:33:59 +04:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (~((size_t)file->LoadBalanceInfo))
|
2013-04-11 19:51:10 +04:00
|
|
|
|
{
|
2021-04-12 12:06:45 +03:00
|
|
|
|
const size_t len = strlen(file->LoadBalanceInfo);
|
|
|
|
|
if (!freerdp_settings_set_pointer_len(settings, FreeRDP_LoadBalanceInfo,
|
|
|
|
|
file->LoadBalanceInfo, len))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
return FALSE;
|
2013-04-11 19:51:10 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-17 23:42:36 +04:00
|
|
|
|
if (~file->AuthenticationLevel)
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Authentication Level:
|
|
|
|
|
* http://technet.microsoft.com/en-us/library/ff393709/
|
|
|
|
|
*
|
|
|
|
|
* This setting corresponds to the selection in the If server authentication
|
|
|
|
|
* fails drop-down list on the Advanced tab under Options in RDC.
|
|
|
|
|
*
|
|
|
|
|
* Values:
|
|
|
|
|
*
|
2019-07-17 16:48:26 +03:00
|
|
|
|
* 0: If server authentication fails, connect to the computer without warning (Connect and
|
|
|
|
|
* don’t warn me). 1: If server authentication fails, do not establish a connection (Do not
|
|
|
|
|
* connect). 2: If server authentication fails, show a warning and allow me to connect or
|
|
|
|
|
* refuse the connection (Warn me). 3: No authentication requirement is specified.
|
2013-09-17 23:42:36 +04:00
|
|
|
|
*/
|
2021-04-12 12:06:45 +03:00
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_AuthenticationLevel,
|
|
|
|
|
file->AuthenticationLevel))
|
|
|
|
|
return FALSE;
|
2013-09-17 23:42:36 +04:00
|
|
|
|
}
|
|
|
|
|
|
2012-11-26 23:31:31 +04:00
|
|
|
|
if (~file->ConnectionType)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-09-05 13:20:40 +03:00
|
|
|
|
if (!freerdp_set_connection_type(settings, file->ConnectionType))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
2019-09-05 13:20:40 +03:00
|
|
|
|
setDefaultConnectionType = FALSE;
|
2019-05-06 10:51:42 +03:00
|
|
|
|
}
|
2012-11-26 23:31:31 +04:00
|
|
|
|
|
|
|
|
|
if (~file->AudioMode)
|
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
|
switch (file->AudioMode)
|
2012-11-26 23:31:31 +04:00
|
|
|
|
{
|
2019-07-30 10:39:45 +03:00
|
|
|
|
case AUDIO_MODE_REDIRECT:
|
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteConsoleAudio, FALSE))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AudioPlayback, TRUE))
|
|
|
|
|
return FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case AUDIO_MODE_PLAY_ON_SERVER:
|
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteConsoleAudio, TRUE))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AudioPlayback, FALSE))
|
|
|
|
|
return FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case AUDIO_MODE_NONE:
|
|
|
|
|
default:
|
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AudioPlayback, FALSE))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteConsoleAudio, FALSE))
|
|
|
|
|
return FALSE;
|
|
|
|
|
break;
|
2012-11-26 23:31:31 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-30 13:30:15 +03:00
|
|
|
|
if (~file->AudioCaptureMode)
|
|
|
|
|
{
|
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AudioCapture, file->AudioCaptureMode != 0))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-17 23:58:48 +04:00
|
|
|
|
if (~file->Compression)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_CompressionEnabled,
|
|
|
|
|
file->Compression != 0))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2013-09-17 23:58:48 +04:00
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (~((size_t)file->GatewayHostname))
|
2014-06-12 18:49:29 +04:00
|
|
|
|
{
|
|
|
|
|
int port = -1;
|
|
|
|
|
char* host = NULL;
|
|
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
|
if (!freerdp_parse_hostname(file->GatewayHostname, &host, &port))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
return FALSE;
|
2014-06-12 18:49:29 +04:00
|
|
|
|
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_GatewayHostname, host))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
return FALSE;
|
2014-06-12 18:49:29 +04:00
|
|
|
|
|
|
|
|
|
free(host);
|
2019-05-06 10:51:42 +03:00
|
|
|
|
|
|
|
|
|
if (port > 0)
|
|
|
|
|
{
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_GatewayPort, (UINT32)port))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2014-06-12 18:49:29 +04:00
|
|
|
|
}
|
2013-07-03 23:07:12 +04:00
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (~((size_t)file->GatewayAccessToken))
|
2018-02-13 16:59:33 +03:00
|
|
|
|
{
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_GatewayAccessToken,
|
|
|
|
|
file->GatewayAccessToken))
|
2018-02-13 16:59:33 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-28 20:12:36 +04:00
|
|
|
|
if (~file->GatewayUsageMethod)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
|
|
|
|
if (!freerdp_set_gateway_usage_method(settings, file->GatewayUsageMethod))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2013-07-03 23:07:12 +04:00
|
|
|
|
|
2012-10-28 20:12:36 +04:00
|
|
|
|
if (~file->PromptCredentialOnce)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GatewayUseSameCredentials,
|
2019-11-06 17:24:51 +03:00
|
|
|
|
file->PromptCredentialOnce != 0))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2019-07-15 11:08:39 +03:00
|
|
|
|
if (~file->PromptForCredentials)
|
|
|
|
|
{
|
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_PromptForCredentials,
|
2019-11-06 17:24:51 +03:00
|
|
|
|
file->PromptForCredentials != 0))
|
2019-07-15 11:08:39 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-28 05:30:08 +04:00
|
|
|
|
if (~file->RemoteApplicationMode)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteApplicationMode,
|
2019-11-06 17:24:51 +03:00
|
|
|
|
file->RemoteApplicationMode != 0))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (~((size_t)file->RemoteApplicationProgram))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_RemoteApplicationProgram,
|
|
|
|
|
file->RemoteApplicationProgram))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (~((size_t)file->RemoteApplicationName))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_RemoteApplicationName,
|
|
|
|
|
file->RemoteApplicationName))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (~((size_t)file->RemoteApplicationIcon))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_RemoteApplicationIcon,
|
|
|
|
|
file->RemoteApplicationIcon))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (~((size_t)file->RemoteApplicationFile))
|
2019-07-18 11:59:59 +03:00
|
|
|
|
{
|
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_RemoteApplicationFile,
|
|
|
|
|
file->RemoteApplicationFile))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (~((size_t)file->RemoteApplicationGuid))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
{
|
2019-05-09 14:50:39 +03:00
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_RemoteApplicationGuid,
|
2019-07-17 16:48:26 +03:00
|
|
|
|
file->RemoteApplicationGuid))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (~((size_t)file->RemoteApplicationCmdLine))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_RemoteApplicationCmdLine,
|
|
|
|
|
file->RemoteApplicationCmdLine))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2012-10-28 05:30:08 +04:00
|
|
|
|
|
2012-12-13 23:38:02 +04:00
|
|
|
|
if (~file->SpanMonitors)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-07-18 14:53:30 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SpanMonitors, file->SpanMonitors != 0))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2012-12-13 23:38:02 +04:00
|
|
|
|
if (~file->UseMultiMon)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-07-18 14:53:30 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_UseMultimon, file->UseMultiMon != 0))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2012-12-13 23:38:02 +04:00
|
|
|
|
|
2013-09-17 22:56:23 +04:00
|
|
|
|
if (~file->AllowFontSmoothing)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AllowFontSmoothing,
|
2019-11-06 17:24:51 +03:00
|
|
|
|
file->AllowFontSmoothing != 0))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2013-09-17 22:56:23 +04:00
|
|
|
|
if (~file->DisableWallpaper)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DisableWallpaper,
|
|
|
|
|
file->DisableWallpaper != 0))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2013-09-17 22:56:23 +04:00
|
|
|
|
if (~file->DisableFullWindowDrag)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DisableFullWindowDrag,
|
2019-11-06 17:24:51 +03:00
|
|
|
|
file->DisableFullWindowDrag != 0))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2013-09-17 22:56:23 +04:00
|
|
|
|
if (~file->DisableMenuAnims)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DisableMenuAnims,
|
|
|
|
|
file->DisableMenuAnims != 0))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2013-09-17 22:56:23 +04:00
|
|
|
|
if (~file->DisableThemes)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-07-18 14:53:30 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DisableThemes, file->DisableThemes != 0))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2013-09-17 22:56:23 +04:00
|
|
|
|
if (~file->AllowDesktopComposition)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AllowDesktopComposition,
|
2019-11-06 17:24:51 +03:00
|
|
|
|
file->AllowDesktopComposition != 0))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2013-09-17 22:56:23 +04:00
|
|
|
|
|
|
|
|
|
if (~file->BitmapCachePersistEnable)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_BitmapCachePersistEnabled,
|
2019-11-06 17:24:51 +03:00
|
|
|
|
file->BitmapCachePersistEnable != 0))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2013-09-17 22:56:23 +04:00
|
|
|
|
|
2013-09-17 23:42:36 +04:00
|
|
|
|
if (~file->DisableRemoteAppCapsCheck)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DisableRemoteAppCapsCheck,
|
2019-08-22 17:00:46 +03:00
|
|
|
|
file->DisableRemoteAppCapsCheck != 0))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (~file->BandwidthAutoDetect)
|
|
|
|
|
{
|
2019-09-05 13:20:40 +03:00
|
|
|
|
if (file->BandwidthAutoDetect != 0)
|
|
|
|
|
{
|
2020-05-04 11:57:19 +03:00
|
|
|
|
if ((~file->NetworkAutoDetect) && (file->NetworkAutoDetect != 0))
|
|
|
|
|
{
|
|
|
|
|
WLog_WARN(TAG,
|
|
|
|
|
"Got networkautodetect:i:%" PRIu32 " and bandwidthautodetect:i:%" PRIu32
|
|
|
|
|
". Correcting to networkautodetect:i:0",
|
|
|
|
|
file->NetworkAutoDetect, file->BandwidthAutoDetect);
|
|
|
|
|
WLog_WARN(TAG,
|
|
|
|
|
"Add networkautodetect:i:0 to your RDP file to eliminate this warning.");
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-05 13:20:40 +03:00
|
|
|
|
if (!freerdp_set_connection_type(settings, CONNECTION_TYPE_AUTODETECT))
|
|
|
|
|
return FALSE;
|
|
|
|
|
setDefaultConnectionType = FALSE;
|
|
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_NetworkAutoDetect,
|
2020-05-04 11:57:19 +03:00
|
|
|
|
(file->BandwidthAutoDetect != 0) ||
|
|
|
|
|
(file->NetworkAutoDetect == 0)))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2013-09-17 23:42:36 +04:00
|
|
|
|
|
2019-07-09 16:02:49 +03:00
|
|
|
|
if (~file->NetworkAutoDetect)
|
|
|
|
|
{
|
2019-09-05 13:20:40 +03:00
|
|
|
|
if (file->NetworkAutoDetect == 0)
|
2019-08-22 17:00:46 +03:00
|
|
|
|
{
|
2020-05-04 11:57:19 +03:00
|
|
|
|
if ((~file->BandwidthAutoDetect) && (file->BandwidthAutoDetect == 0))
|
2019-09-05 13:20:40 +03:00
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
|
WLog_WARN(TAG,
|
|
|
|
|
"Got networkautodetect:i:%" PRIu32 " and bandwidthautodetect:i:%" PRIu32
|
2020-05-04 11:57:19 +03:00
|
|
|
|
". Correcting to bandwidthautodetect:i:1",
|
|
|
|
|
file->NetworkAutoDetect, file->BandwidthAutoDetect);
|
|
|
|
|
WLog_WARN(
|
|
|
|
|
TAG, "Add bandwidthautodetect:i:1 to your RDP file to eliminate this warning.");
|
2019-09-05 13:20:40 +03:00
|
|
|
|
}
|
2019-08-22 17:00:46 +03:00
|
|
|
|
|
2019-09-05 13:20:40 +03:00
|
|
|
|
if (!freerdp_set_connection_type(settings, CONNECTION_TYPE_AUTODETECT))
|
|
|
|
|
return FALSE;
|
2020-05-04 11:57:19 +03:00
|
|
|
|
|
2019-09-05 13:20:40 +03:00
|
|
|
|
setDefaultConnectionType = FALSE;
|
|
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_NetworkAutoDetect,
|
2020-05-04 11:57:19 +03:00
|
|
|
|
(file->BandwidthAutoDetect != 0) ||
|
|
|
|
|
(file->NetworkAutoDetect == 0)))
|
2019-07-09 16:02:49 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-17 23:42:36 +04:00
|
|
|
|
if (~file->AutoReconnectionEnabled)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AutoReconnectionEnabled,
|
2019-11-06 17:24:51 +03:00
|
|
|
|
file->AutoReconnectionEnabled != 0))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2013-09-17 23:58:48 +04:00
|
|
|
|
if (~file->AutoReconnectMaxRetries)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_AutoReconnectMaxRetries,
|
|
|
|
|
file->AutoReconnectMaxRetries))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2013-09-17 23:42:36 +04:00
|
|
|
|
|
|
|
|
|
if (~file->RedirectSmartCards)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectSmartCards,
|
2019-11-06 17:24:51 +03:00
|
|
|
|
file->RedirectSmartCards != 0))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2013-09-17 23:42:36 +04:00
|
|
|
|
|
|
|
|
|
if (~file->RedirectClipboard)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectClipboard,
|
2019-11-06 17:24:51 +03:00
|
|
|
|
file->RedirectClipboard != 0))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2013-09-17 23:42:36 +04:00
|
|
|
|
|
|
|
|
|
if (~file->RedirectPrinters)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectPrinters,
|
|
|
|
|
file->RedirectPrinters != 0))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2013-09-17 23:42:36 +04:00
|
|
|
|
|
|
|
|
|
if (~file->RedirectDrives)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-07-18 14:53:30 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectDrives, file->RedirectDrives != 0))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2013-09-17 23:42:36 +04:00
|
|
|
|
|
|
|
|
|
if (~file->RedirectPosDevices)
|
|
|
|
|
{
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectSerialPorts,
|
2019-11-06 17:24:51 +03:00
|
|
|
|
file->RedirectComPorts != 0) ||
|
2019-07-17 16:48:26 +03:00
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_RedirectParallelPorts,
|
2019-11-06 17:24:51 +03:00
|
|
|
|
file->RedirectComPorts != 0))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
2013-09-17 23:42:36 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (~file->RedirectComPorts)
|
|
|
|
|
{
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectSerialPorts,
|
2019-11-06 17:24:51 +03:00
|
|
|
|
file->RedirectComPorts != 0) ||
|
2019-07-17 16:48:26 +03:00
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_RedirectParallelPorts,
|
2019-11-06 17:24:51 +03:00
|
|
|
|
file->RedirectComPorts != 0))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
2013-09-17 23:42:36 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (~file->RedirectDirectX)
|
|
|
|
|
{
|
|
|
|
|
/* What is this?! */
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (~((size_t)file->DevicesToRedirect))
|
2013-09-17 23:42:36 +04:00
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Devices to redirect:
|
|
|
|
|
* http://technet.microsoft.com/en-us/library/ff393728/
|
|
|
|
|
*
|
|
|
|
|
* This setting corresponds to the selections for Other supported Plug and Play
|
|
|
|
|
* (PnP) devices under More on the Local Resources tab under Options in RDC.
|
|
|
|
|
*
|
|
|
|
|
* Values:
|
|
|
|
|
*
|
|
|
|
|
* '*':
|
|
|
|
|
* Redirect all supported Plug and Play devices.
|
|
|
|
|
*
|
|
|
|
|
* 'DynamicDevices':
|
|
|
|
|
* Redirect any supported Plug and Play devices that are connected later.
|
|
|
|
|
*
|
|
|
|
|
* The hardware ID for the supported Plug and Play device:
|
|
|
|
|
* Redirect the specified supported Plug and Play device.
|
|
|
|
|
*
|
|
|
|
|
* Examples:
|
|
|
|
|
* devicestoredirect:s:*
|
|
|
|
|
* devicestoredirect:s:DynamicDevices
|
|
|
|
|
* devicestoredirect:s:USB\VID_04A9&PID_30C1\6&4BD985D&0&2;,DynamicDevices
|
|
|
|
|
*
|
|
|
|
|
*/
|
2019-07-29 17:37:06 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DeviceRedirection, TRUE))
|
2019-05-09 14:50:39 +03:00
|
|
|
|
return FALSE;
|
2013-09-17 23:42:36 +04:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (~((size_t)file->DrivesToRedirect))
|
2013-09-17 23:58:48 +04:00
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_DrivesToRedirect,
|
|
|
|
|
file->DrivesToRedirect))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
2013-09-17 23:58:48 +04:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
|
if (~((size_t)file->RedirectCameras))
|
|
|
|
|
{
|
2021-10-07 10:22:27 +03:00
|
|
|
|
union
|
|
|
|
|
{
|
|
|
|
|
char** c;
|
|
|
|
|
const char** cc;
|
|
|
|
|
} cnv;
|
2021-04-12 11:38:40 +03:00
|
|
|
|
BOOL status;
|
2021-09-23 15:52:03 +03:00
|
|
|
|
ADDIN_ARGV* args = rdp_file_to_args(RDPECAM_DVC_CHANNEL_NAME, file->RedirectCameras);
|
2021-04-12 12:06:45 +03:00
|
|
|
|
if (!args)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (~file->EncodeRedirectedVideoCapture)
|
|
|
|
|
{
|
|
|
|
|
char encode[64];
|
|
|
|
|
_snprintf(encode, sizeof(encode), "encode:%" PRIu32,
|
|
|
|
|
file->EncodeRedirectedVideoCapture);
|
|
|
|
|
freerdp_addin_argv_add_argument(args, encode);
|
|
|
|
|
}
|
|
|
|
|
if (~file->RedirectedVideoCaptureEncodingQuality)
|
|
|
|
|
{
|
|
|
|
|
char quality[64];
|
|
|
|
|
_snprintf(quality, sizeof(quality), "quality:%" PRIu32,
|
|
|
|
|
file->RedirectedVideoCaptureEncodingQuality);
|
|
|
|
|
freerdp_addin_argv_add_argument(args, quality);
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-07 10:22:27 +03:00
|
|
|
|
cnv.c = args->argv;
|
|
|
|
|
status = freerdp_client_add_dynamic_channel(settings, args->argc, cnv.cc);
|
2021-04-12 12:06:45 +03:00
|
|
|
|
freerdp_addin_argv_free(args);
|
|
|
|
|
/* Ignore return */ WINPR_UNUSED(status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef CHANNEL_URBDRC_CLIENT
|
|
|
|
|
if (~((size_t)file->UsbDevicesToRedirect))
|
|
|
|
|
{
|
2021-10-07 10:22:27 +03:00
|
|
|
|
union
|
|
|
|
|
{
|
|
|
|
|
char** c;
|
|
|
|
|
const char** cc;
|
|
|
|
|
} cnv;
|
2021-04-12 12:06:45 +03:00
|
|
|
|
BOOL status;
|
|
|
|
|
ADDIN_ARGV* args = rdp_file_to_args(URBDRC_CHANNEL_NAME, file->UsbDevicesToRedirect);
|
|
|
|
|
if (!args)
|
|
|
|
|
return FALSE;
|
2021-10-07 10:22:27 +03:00
|
|
|
|
cnv.c = args->argv;
|
|
|
|
|
status = freerdp_client_add_dynamic_channel(settings, args->argc, cnv.cc);
|
2021-04-12 12:06:45 +03:00
|
|
|
|
freerdp_addin_argv_free(args);
|
2021-04-12 11:38:40 +03:00
|
|
|
|
/* Ignore return */ WINPR_UNUSED(status);
|
|
|
|
|
}
|
2021-04-12 12:06:45 +03:00
|
|
|
|
#endif
|
2021-04-12 11:38:40 +03:00
|
|
|
|
|
2014-07-09 00:32:28 +04:00
|
|
|
|
if (~file->KeyboardHook)
|
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardHook, file->KeyboardHook))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
2014-07-09 00:32:28 +04:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-12 12:06:45 +03:00
|
|
|
|
if (~(size_t)file->SelectedMonitors)
|
|
|
|
|
{
|
|
|
|
|
size_t count = 0, x;
|
|
|
|
|
char** args = CommandLineParseCommaSeparatedValues(file->SelectedMonitors, &count);
|
|
|
|
|
UINT32* list;
|
|
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_pointer_len(settings, FreeRDP_MonitorIds, NULL, count))
|
|
|
|
|
{
|
|
|
|
|
free(args);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2021-05-18 13:16:21 +03:00
|
|
|
|
list = freerdp_settings_get_pointer_writable(settings, FreeRDP_MonitorIds);
|
2021-04-12 12:06:45 +03:00
|
|
|
|
if (!list && (count > 0))
|
|
|
|
|
{
|
|
|
|
|
free(args);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
for (x = 0; x < count; x++)
|
|
|
|
|
{
|
2021-05-11 09:06:00 +03:00
|
|
|
|
unsigned long val;
|
2021-04-12 12:06:45 +03:00
|
|
|
|
errno = 0;
|
|
|
|
|
val = strtoul(args[x], NULL, 0);
|
2021-05-11 09:06:00 +03:00
|
|
|
|
if ((val >= UINT32_MAX) && (errno != 0))
|
2021-04-12 12:06:45 +03:00
|
|
|
|
{
|
|
|
|
|
free(args);
|
|
|
|
|
free(list);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
list[x] = val;
|
|
|
|
|
}
|
|
|
|
|
free(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (~file->DynamicResolution)
|
|
|
|
|
{
|
|
|
|
|
const BOOL val = file->DynamicResolution != 0;
|
|
|
|
|
if (val)
|
|
|
|
|
{
|
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportDisplayControl, TRUE))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DynamicResolutionUpdate, val))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (~file->DesktopScaleFactor)
|
|
|
|
|
{
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopScaleFactor,
|
|
|
|
|
file->DesktopScaleFactor))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (~file->VideoPlaybackMode)
|
|
|
|
|
{
|
|
|
|
|
if (file->VideoPlaybackMode != 0)
|
|
|
|
|
{
|
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportGeometryTracking, TRUE) ||
|
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_SupportVideoOptimized, TRUE))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportVideoOptimized, FALSE))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// TODO file->MaximizeToCurrentDisplays;
|
|
|
|
|
// TODO file->SingleMonInWindowedMode;
|
|
|
|
|
// TODO file->EncodeRedirectedVideoCapture;
|
|
|
|
|
// TODO file->RedirectedVideoCaptureEncodingQuality;
|
|
|
|
|
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (~((size_t)file->PreconnectionBlob))
|
2018-04-01 05:15:39 +03:00
|
|
|
|
{
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_PreconnectionBlob,
|
|
|
|
|
file->PreconnectionBlob) ||
|
2021-02-11 23:05:53 +03:00
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_SendPreconnectionPdu, TRUE))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
2018-04-01 05:15:39 +03:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
|
if (file->args->argc > 1)
|
2013-09-18 22:01:19 +04:00
|
|
|
|
{
|
2021-04-12 12:06:45 +03:00
|
|
|
|
const char* ConnectionFile = freerdp_settings_get_string(settings, FreeRDP_ConnectionFile);
|
2013-11-10 22:29:20 +04:00
|
|
|
|
settings->ConnectionFile = NULL;
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2021-04-12 12:06:45 +03:00
|
|
|
|
if (freerdp_client_settings_parse_command_line(settings, file->args->argc, file->args->argv,
|
|
|
|
|
FALSE) < 0)
|
2015-06-17 23:08:02 +03:00
|
|
|
|
return FALSE;
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2021-04-12 12:06:45 +03:00
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_ConnectionFile, ConnectionFile))
|
|
|
|
|
return FALSE;
|
2013-09-18 22:01:19 +04:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-05 13:20:40 +03:00
|
|
|
|
if (setDefaultConnectionType)
|
|
|
|
|
{
|
|
|
|
|
if (!freerdp_set_connection_type(settings, CONNECTION_TYPE_AUTODETECT))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-28 05:30:08 +04:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-18 14:53:30 +03:00
|
|
|
|
static rdpFileLine* freerdp_client_rdp_file_find_line_index(rdpFile* file, SSIZE_T index)
|
2013-12-05 01:29:45 +04:00
|
|
|
|
{
|
|
|
|
|
rdpFileLine* line;
|
2019-07-18 14:53:30 +03:00
|
|
|
|
if (index < 0)
|
|
|
|
|
return NULL;
|
2013-12-05 01:29:45 +04:00
|
|
|
|
line = &(file->lines[index]);
|
|
|
|
|
return line;
|
|
|
|
|
}
|
2019-08-23 10:57:26 +03:00
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
static rdpFileLine* freerdp_client_rdp_file_find_line_by_name(rdpFile* file, const char* name)
|
2013-12-05 01:29:45 +04:00
|
|
|
|
{
|
2019-07-18 10:29:06 +03:00
|
|
|
|
size_t index;
|
2013-12-05 01:29:45 +04:00
|
|
|
|
BOOL bFound = FALSE;
|
|
|
|
|
rdpFileLine* line = NULL;
|
|
|
|
|
|
|
|
|
|
for (index = 0; index < file->lineCount; index++)
|
|
|
|
|
{
|
|
|
|
|
line = &(file->lines[index]);
|
|
|
|
|
|
|
|
|
|
if (line->flags & RDP_FILE_LINE_FLAG_FORMATTED)
|
|
|
|
|
{
|
2019-09-11 11:23:17 +03:00
|
|
|
|
if (_stricmp(name, line->name) == 0)
|
2013-12-05 01:29:45 +04:00
|
|
|
|
{
|
|
|
|
|
bFound = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (bFound) ? line : NULL;
|
|
|
|
|
}
|
2015-06-17 23:08:02 +03:00
|
|
|
|
/**
|
|
|
|
|
* Set a string option to a rdpFile
|
|
|
|
|
* @param file rdpFile
|
|
|
|
|
* @param name name of the option
|
|
|
|
|
* @param value value of the option
|
|
|
|
|
* @return 0 on success
|
|
|
|
|
*/
|
2013-12-05 01:29:45 +04:00
|
|
|
|
int freerdp_client_rdp_file_set_string_option(rdpFile* file, const char* name, const char* value)
|
|
|
|
|
{
|
|
|
|
|
int length;
|
|
|
|
|
char* text;
|
|
|
|
|
rdpFileLine* line;
|
|
|
|
|
length = _scprintf("%s:s:%s", name, value);
|
2019-07-18 14:53:30 +03:00
|
|
|
|
if (length < 0)
|
|
|
|
|
return -1;
|
|
|
|
|
text = (char*)malloc((size_t)length + 1);
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
if (!text)
|
|
|
|
|
return -1;
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2019-07-18 14:53:30 +03:00
|
|
|
|
sprintf_s(text, (size_t)length + 1, "%s:s:%s", name, value ? value : "");
|
2013-12-05 01:29:45 +04:00
|
|
|
|
text[length] = '\0';
|
2015-06-17 23:08:02 +03:00
|
|
|
|
line = freerdp_client_rdp_file_find_line_by_name(file, name);
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2013-12-05 01:29:45 +04:00
|
|
|
|
if (line)
|
|
|
|
|
{
|
|
|
|
|
free(line->sValue);
|
|
|
|
|
line->sValue = _strdup(value);
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
if (!line->sValue)
|
|
|
|
|
goto out_fail;
|
2013-12-05 01:29:45 +04:00
|
|
|
|
|
|
|
|
|
free(line->text);
|
|
|
|
|
line->text = text;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-07-18 14:53:30 +03:00
|
|
|
|
SSIZE_T index = freerdp_client_parse_rdp_file_add_line(file, text, -1);
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
if (index == -1)
|
|
|
|
|
goto out_fail;
|
2013-12-05 01:29:45 +04:00
|
|
|
|
|
2022-04-28 10:56:11 +03:00
|
|
|
|
if (!freerdp_client_rdp_file_find_line_index(file, index))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
goto out_fail;
|
|
|
|
|
|
|
|
|
|
if (freerdp_client_rdp_file_set_string(file, name, value, index) == -1)
|
|
|
|
|
goto out_fail;
|
2013-12-05 01:29:45 +04:00
|
|
|
|
|
|
|
|
|
free(text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
2015-06-17 23:08:02 +03:00
|
|
|
|
out_fail:
|
|
|
|
|
free(text);
|
|
|
|
|
return -1;
|
2013-12-05 01:29:45 +04:00
|
|
|
|
}
|
2019-07-18 14:53:30 +03:00
|
|
|
|
|
2013-12-06 18:14:55 +04:00
|
|
|
|
const char* freerdp_client_rdp_file_get_string_option(rdpFile* file, const char* name)
|
2013-12-05 01:29:45 +04:00
|
|
|
|
{
|
|
|
|
|
rdpFileLine* line;
|
|
|
|
|
line = freerdp_client_rdp_file_find_line_by_name(file, name);
|
|
|
|
|
|
|
|
|
|
if (!line)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
if (!(line->flags & RDP_FILE_LINE_FLAG_TYPE_STRING))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
return line->sValue;
|
|
|
|
|
}
|
2019-07-18 14:53:30 +03:00
|
|
|
|
|
2013-12-05 01:29:45 +04:00
|
|
|
|
int freerdp_client_rdp_file_set_integer_option(rdpFile* file, const char* name, int value)
|
|
|
|
|
{
|
2019-07-18 14:53:30 +03:00
|
|
|
|
SSIZE_T index;
|
|
|
|
|
char* text;
|
|
|
|
|
rdpFileLine* line;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
const int length = _scprintf("%s:i:%d", name, value);
|
2019-07-18 14:53:30 +03:00
|
|
|
|
|
|
|
|
|
if (length < 0)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
text = (char*)malloc((size_t)length + 1);
|
|
|
|
|
line = freerdp_client_rdp_file_find_line_by_name(file, name);
|
2017-02-20 20:31:58 +03:00
|
|
|
|
|
|
|
|
|
if (!text)
|
|
|
|
|
return -1;
|
|
|
|
|
|
2019-07-18 14:53:30 +03:00
|
|
|
|
sprintf_s(text, (size_t)length + 1, "%s:i:%d", name, value);
|
2013-12-05 01:29:45 +04:00
|
|
|
|
text[length] = '\0';
|
|
|
|
|
|
|
|
|
|
if (line)
|
|
|
|
|
{
|
|
|
|
|
line->iValue = value;
|
|
|
|
|
free(line->text);
|
|
|
|
|
line->text = text;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
index = freerdp_client_parse_rdp_file_add_line(file, text, -1);
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
if (index < 0)
|
|
|
|
|
{
|
|
|
|
|
free(text);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
|
if (!freerdp_client_rdp_file_find_line_index(file, index))
|
|
|
|
|
{
|
|
|
|
|
free(text);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2013-12-05 01:29:45 +04:00
|
|
|
|
|
2019-07-18 14:53:30 +03:00
|
|
|
|
freerdp_client_rdp_file_set_integer(file, name, value, index);
|
2013-12-05 01:29:45 +04:00
|
|
|
|
free(text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2019-07-18 14:53:30 +03:00
|
|
|
|
|
2013-12-05 01:29:45 +04:00
|
|
|
|
int freerdp_client_rdp_file_get_integer_option(rdpFile* file, const char* name)
|
|
|
|
|
{
|
|
|
|
|
rdpFileLine* line;
|
|
|
|
|
line = freerdp_client_rdp_file_find_line_by_name(file, name);
|
|
|
|
|
|
|
|
|
|
if (!line)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
if (!(line->flags & RDP_FILE_LINE_FLAG_TYPE_INTEGER))
|
|
|
|
|
return -1;
|
|
|
|
|
|
2019-07-18 14:53:30 +03:00
|
|
|
|
return (int)line->iValue;
|
2013-12-05 01:29:45 +04:00
|
|
|
|
}
|
2019-07-18 14:53:30 +03:00
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
static void freerdp_client_file_string_check_free(LPSTR str)
|
2013-11-05 08:45:19 +04:00
|
|
|
|
{
|
2019-07-17 16:48:26 +03:00
|
|
|
|
if (~((size_t)str))
|
2013-11-05 08:45:19 +04:00
|
|
|
|
free(str);
|
|
|
|
|
}
|
2019-09-24 11:01:08 +03:00
|
|
|
|
|
|
|
|
|
rdpFile* freerdp_client_rdp_file_new(void)
|
2012-10-28 05:30:08 +04:00
|
|
|
|
{
|
2019-09-24 11:01:08 +03:00
|
|
|
|
return freerdp_client_rdp_file_new_ex(0);
|
|
|
|
|
}
|
2013-09-18 22:01:19 +04:00
|
|
|
|
|
2019-09-24 11:01:08 +03:00
|
|
|
|
rdpFile* freerdp_client_rdp_file_new_ex(DWORD flags)
|
|
|
|
|
{
|
|
|
|
|
rdpFile* file = (rdpFile*)malloc(sizeof(rdpFile));
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2019-09-24 11:01:08 +03:00
|
|
|
|
if (!file)
|
|
|
|
|
return NULL;
|
2015-06-17 23:08:02 +03:00
|
|
|
|
|
2019-09-24 11:01:08 +03:00
|
|
|
|
file->flags = flags;
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2019-09-24 11:01:08 +03:00
|
|
|
|
FillMemory(file, sizeof(rdpFile), 0xFF);
|
|
|
|
|
file->lines = NULL;
|
|
|
|
|
file->lineCount = 0;
|
|
|
|
|
file->lineSize = 32;
|
2020-11-13 12:44:09 +03:00
|
|
|
|
file->GatewayProfileUsageMethod = 1;
|
2019-09-24 11:01:08 +03:00
|
|
|
|
file->lines = (rdpFileLine*)calloc(file->lineSize, sizeof(rdpFileLine));
|
2013-09-18 22:01:19 +04:00
|
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
|
file->args = freerdp_addin_argv_new(0, NULL);
|
|
|
|
|
if (!file->lines || !file->args)
|
2019-09-24 11:01:08 +03:00
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
|
|
if (!freerdp_client_add_option(file, "freerdp"))
|
|
|
|
|
goto fail;
|
2012-10-28 05:30:08 +04:00
|
|
|
|
|
|
|
|
|
return file;
|
2019-09-24 11:01:08 +03:00
|
|
|
|
fail:
|
2020-03-23 17:21:47 +03:00
|
|
|
|
freerdp_client_rdp_file_free(file);
|
2019-09-24 11:01:08 +03:00
|
|
|
|
return NULL;
|
2012-10-28 05:30:08 +04:00
|
|
|
|
}
|
|
|
|
|
void freerdp_client_rdp_file_free(rdpFile* file)
|
|
|
|
|
{
|
2013-09-18 22:01:19 +04:00
|
|
|
|
if (file)
|
|
|
|
|
{
|
2013-12-05 00:37:42 +04:00
|
|
|
|
if (file->lineCount)
|
|
|
|
|
{
|
2019-07-18 14:53:30 +03:00
|
|
|
|
size_t i;
|
2013-12-05 00:37:42 +04:00
|
|
|
|
for (i = 0; i < file->lineCount; i++)
|
|
|
|
|
{
|
|
|
|
|
free(file->lines[i].text);
|
|
|
|
|
free(file->lines[i].name);
|
|
|
|
|
free(file->lines[i].sValue);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-03-23 17:21:47 +03:00
|
|
|
|
free(file->lines);
|
2013-12-05 00:37:42 +04:00
|
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
|
freerdp_addin_argv_free(file->args);
|
2013-09-18 22:01:19 +04:00
|
|
|
|
|
2013-11-05 08:45:19 +04:00
|
|
|
|
freerdp_client_file_string_check_free(file->Username);
|
|
|
|
|
freerdp_client_file_string_check_free(file->Domain);
|
2017-02-10 23:38:52 +03:00
|
|
|
|
freerdp_client_file_string_check_free(file->Password);
|
2013-11-05 08:45:19 +04:00
|
|
|
|
freerdp_client_file_string_check_free(file->FullAddress);
|
|
|
|
|
freerdp_client_file_string_check_free(file->AlternateFullAddress);
|
|
|
|
|
freerdp_client_file_string_check_free(file->UsbDevicesToRedirect);
|
2021-04-12 11:38:40 +03:00
|
|
|
|
freerdp_client_file_string_check_free(file->RedirectCameras);
|
2021-04-12 12:06:45 +03:00
|
|
|
|
freerdp_client_file_string_check_free(file->SelectedMonitors);
|
2013-11-05 08:45:19 +04:00
|
|
|
|
freerdp_client_file_string_check_free(file->LoadBalanceInfo);
|
|
|
|
|
freerdp_client_file_string_check_free(file->RemoteApplicationName);
|
|
|
|
|
freerdp_client_file_string_check_free(file->RemoteApplicationIcon);
|
|
|
|
|
freerdp_client_file_string_check_free(file->RemoteApplicationProgram);
|
|
|
|
|
freerdp_client_file_string_check_free(file->RemoteApplicationFile);
|
|
|
|
|
freerdp_client_file_string_check_free(file->RemoteApplicationGuid);
|
|
|
|
|
freerdp_client_file_string_check_free(file->RemoteApplicationCmdLine);
|
|
|
|
|
freerdp_client_file_string_check_free(file->AlternateShell);
|
|
|
|
|
freerdp_client_file_string_check_free(file->ShellWorkingDirectory);
|
|
|
|
|
freerdp_client_file_string_check_free(file->GatewayHostname);
|
2018-02-13 16:59:33 +03:00
|
|
|
|
freerdp_client_file_string_check_free(file->GatewayAccessToken);
|
2013-11-05 08:45:19 +04:00
|
|
|
|
freerdp_client_file_string_check_free(file->KdcProxyName);
|
|
|
|
|
freerdp_client_file_string_check_free(file->DrivesToRedirect);
|
|
|
|
|
freerdp_client_file_string_check_free(file->DevicesToRedirect);
|
|
|
|
|
freerdp_client_file_string_check_free(file->WinPosStr);
|
2013-09-18 22:01:19 +04:00
|
|
|
|
free(file);
|
|
|
|
|
}
|
2012-10-28 05:30:08 +04:00
|
|
|
|
}
|
2019-07-15 11:30:16 +03:00
|
|
|
|
|
|
|
|
|
void freerdp_client_rdp_file_set_callback_context(rdpFile* file, void* context)
|
|
|
|
|
{
|
|
|
|
|
file->context = context;
|
|
|
|
|
}
|