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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-11-14 18:10:52 +03:00
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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/
|
|
|
|
|
*/
|
2012-10-28 04:25:11 +04:00
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#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>
|
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
|
|
|
|
|
2013-09-18 01:03:35 +04:00
|
|
|
|
//#define DEBUG_CLIENT_FILE 1
|
2012-10-28 20:12:36 +04:00
|
|
|
|
|
2012-10-28 04:25:11 +04:00
|
|
|
|
static BYTE BOM_UTF16_LE[2] = { 0xFF, 0xFE };
|
|
|
|
|
|
2012-10-28 05:30:08 +04:00
|
|
|
|
#define INVALID_INTEGER_VALUE 0xFFFFFFFF
|
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
/*
|
|
|
|
|
* Set an integer in a rdpFile
|
|
|
|
|
*
|
|
|
|
|
* @return 0 if a standard name was set, 1 for a non-standard name, -1 on error
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2017-02-14 14:53:14 +03:00
|
|
|
|
static int freerdp_client_rdp_file_set_integer(rdpFile* file, const char* name, int value,
|
|
|
|
|
int index)
|
2012-10-28 04:25:11 +04:00
|
|
|
|
{
|
2015-06-22 19:52:13 +03:00
|
|
|
|
int standard = 1;
|
2012-10-28 20:12:36 +04:00
|
|
|
|
#ifdef DEBUG_CLIENT_FILE
|
2014-09-12 19:13:01 +04:00
|
|
|
|
WLog_DBG(TAG, "%s:i:%d", name, value);
|
2012-10-28 20:12:36 +04:00
|
|
|
|
#endif
|
|
|
|
|
|
2012-10-28 04:25:11 +04:00
|
|
|
|
if (_stricmp(name, "use multimon") == 0)
|
|
|
|
|
file->UseMultiMon = value;
|
|
|
|
|
else if (_stricmp(name, "screen mode id") == 0)
|
|
|
|
|
file->ScreenModeId = value;
|
|
|
|
|
else if (_stricmp(name, "span monitors") == 0)
|
|
|
|
|
file->SpanMonitors = value;
|
2014-06-16 23:01:09 +04:00
|
|
|
|
else if (_stricmp(name, "smart sizing") == 0)
|
2012-10-28 04:25:11 +04:00
|
|
|
|
file->SmartSizing = value;
|
|
|
|
|
else if (_stricmp(name, "enablesuperpan") == 0)
|
|
|
|
|
file->EnableSuperSpan = value;
|
|
|
|
|
else if (_stricmp(name, "superpanaccelerationfactor") == 0)
|
|
|
|
|
file->SuperSpanAccelerationFactor = value;
|
|
|
|
|
else if (_stricmp(name, "desktopwidth") == 0)
|
|
|
|
|
file->DesktopWidth = value;
|
|
|
|
|
else if (_stricmp(name, "desktopheight") == 0)
|
|
|
|
|
file->DesktopHeight = value;
|
|
|
|
|
else if (_stricmp(name, "desktop size id") == 0)
|
|
|
|
|
file->DesktopSizeId = value;
|
|
|
|
|
else if (_stricmp(name, "session bpp") == 0)
|
|
|
|
|
file->SessionBpp = value;
|
|
|
|
|
else if (_stricmp(name, "compression") == 0)
|
|
|
|
|
file->Compression = value;
|
|
|
|
|
else if (_stricmp(name, "keyboardhook") == 0)
|
|
|
|
|
file->KeyboardHook = value;
|
|
|
|
|
else if (_stricmp(name, "disable ctrl+alt+del") == 0)
|
|
|
|
|
file->DisableCtrlAltDel = value;
|
|
|
|
|
else if (_stricmp(name, "audiomode") == 0)
|
|
|
|
|
file->AudioMode = value;
|
|
|
|
|
else if (_stricmp(name, "audioqualitymode") == 0)
|
|
|
|
|
file->AudioQualityMode = value;
|
|
|
|
|
else if (_stricmp(name, "audiocapturemode") == 0)
|
|
|
|
|
file->AudioCaptureMode = value;
|
|
|
|
|
else if (_stricmp(name, "videoplaybackmode") == 0)
|
|
|
|
|
file->VideoPlaybackMode = value;
|
|
|
|
|
else if (_stricmp(name, "connection type") == 0)
|
|
|
|
|
file->ConnectionType = value;
|
|
|
|
|
else if (_stricmp(name, "networkautodetect") == 0)
|
|
|
|
|
file->NetworkAutoDetect = value;
|
|
|
|
|
else if (_stricmp(name, "bandwidthautodetect") == 0)
|
|
|
|
|
file->BandwidthAutoDetect = value;
|
|
|
|
|
else if (_stricmp(name, "pinconnectionbar") == 0)
|
|
|
|
|
file->PinConnectionBar = value;
|
|
|
|
|
else if (_stricmp(name, "displayconnectionbar") == 0)
|
|
|
|
|
file->DisplayConnectionBar = value;
|
|
|
|
|
else if (_stricmp(name, "workspaceid") == 0)
|
|
|
|
|
file->WorkspaceId = value;
|
|
|
|
|
else if (_stricmp(name, "enableworkspacereconnect") == 0)
|
|
|
|
|
file->EnableWorkspaceReconnect = value;
|
|
|
|
|
else if (_stricmp(name, "disable wallpaper") == 0)
|
|
|
|
|
file->DisableWallpaper = value;
|
|
|
|
|
else if (_stricmp(name, "allow font smoothing") == 0)
|
|
|
|
|
file->AllowFontSmoothing = value;
|
|
|
|
|
else if (_stricmp(name, "allow desktop composition") == 0)
|
|
|
|
|
file->AllowDesktopComposition = value;
|
|
|
|
|
else if (_stricmp(name, "disable full window drag") == 0)
|
|
|
|
|
file->DisableFullWindowDrag = value;
|
|
|
|
|
else if (_stricmp(name, "disable menu anims") == 0)
|
|
|
|
|
file->DisableMenuAnims = value;
|
|
|
|
|
else if (_stricmp(name, "disable themes") == 0)
|
|
|
|
|
file->DisableThemes = value;
|
|
|
|
|
else if (_stricmp(name, "disable cursor setting") == 0)
|
|
|
|
|
file->DisableCursorSetting = value;
|
|
|
|
|
else if (_stricmp(name, "bitmapcachesize") == 0)
|
|
|
|
|
file->BitmapCacheSize = value;
|
|
|
|
|
else if (_stricmp(name, "bitmapcachepersistenable") == 0)
|
|
|
|
|
file->BitmapCachePersistEnable = value;
|
|
|
|
|
else if (_stricmp(name, "server port") == 0)
|
|
|
|
|
file->ServerPort = value;
|
|
|
|
|
else if (_stricmp(name, "redirectdrives") == 0)
|
|
|
|
|
file->RedirectDrives = value;
|
|
|
|
|
else if (_stricmp(name, "redirectprinters") == 0)
|
|
|
|
|
file->RedirectPrinters = value;
|
|
|
|
|
else if (_stricmp(name, "redirectcomports") == 0)
|
|
|
|
|
file->RedirectComPorts = value;
|
|
|
|
|
else if (_stricmp(name, "redirectsmartcards") == 0)
|
|
|
|
|
file->RedirectSmartCards = value;
|
|
|
|
|
else if (_stricmp(name, "redirectclipboard") == 0)
|
|
|
|
|
file->RedirectClipboard = value;
|
|
|
|
|
else if (_stricmp(name, "redirectposdevices") == 0)
|
|
|
|
|
file->RedirectPosDevices = value;
|
|
|
|
|
else if (_stricmp(name, "redirectdirectx") == 0)
|
|
|
|
|
file->RedirectDirectX = value;
|
|
|
|
|
else if (_stricmp(name, "disableprinterredirection") == 0)
|
|
|
|
|
file->DisablePrinterRedirection = value;
|
|
|
|
|
else if (_stricmp(name, "disableclipboardredirection") == 0)
|
|
|
|
|
file->DisableClipboardRedirection = value;
|
|
|
|
|
else if (_stricmp(name, "connect to console") == 0)
|
|
|
|
|
file->ConnectToConsole = value;
|
|
|
|
|
else if (_stricmp(name, "administrative session") == 0)
|
|
|
|
|
file->AdministrativeSession = value;
|
|
|
|
|
else if (_stricmp(name, "autoreconnection enabled") == 0)
|
|
|
|
|
file->AutoReconnectionEnabled = value;
|
|
|
|
|
else if (_stricmp(name, "autoreconnect max retries") == 0)
|
|
|
|
|
file->AutoReconnectMaxRetries = value;
|
|
|
|
|
else if (_stricmp(name, "public mode") == 0)
|
|
|
|
|
file->PublicMode = value;
|
|
|
|
|
else if (_stricmp(name, "authentication level") == 0)
|
|
|
|
|
file->AuthenticationLevel = value;
|
|
|
|
|
else if (_stricmp(name, "promptcredentialonce") == 0)
|
|
|
|
|
file->PromptCredentialOnce = value;
|
|
|
|
|
else if (_stricmp(name, "prompt for credentials") == 0)
|
|
|
|
|
file->PromptForCredentials = value;
|
|
|
|
|
else if (_stricmp(name, "promptcredentialonce") == 0)
|
|
|
|
|
file->PromptForCredentialsOnce = value;
|
|
|
|
|
else if (_stricmp(name, "negotiate security layer") == 0)
|
|
|
|
|
file->NegotiateSecurityLayer = value;
|
|
|
|
|
else if (_stricmp(name, "enablecredsspsupport") == 0)
|
|
|
|
|
file->EnableCredSSPSupport = value;
|
|
|
|
|
else if (_stricmp(name, "remoteapplicationmode") == 0)
|
|
|
|
|
file->RemoteApplicationMode = value;
|
|
|
|
|
else if (_stricmp(name, "remoteapplicationexpandcmdline") == 0)
|
|
|
|
|
file->RemoteApplicationExpandCmdLine = value;
|
|
|
|
|
else if (_stricmp(name, "remoteapplicationexpandworkingdir") == 0)
|
|
|
|
|
file->RemoteApplicationExpandWorkingDir = value;
|
|
|
|
|
else if (_stricmp(name, "disableconnectionsharing") == 0)
|
|
|
|
|
file->DisableConnectionSharing = value;
|
|
|
|
|
else if (_stricmp(name, "disableremoteappcapscheck") == 0)
|
|
|
|
|
file->DisableRemoteAppCapsCheck = value;
|
|
|
|
|
else if (_stricmp(name, "gatewayusagemethod") == 0)
|
|
|
|
|
file->GatewayUsageMethod = value;
|
|
|
|
|
else if (_stricmp(name, "gatewayprofileusagemethod") == 0)
|
|
|
|
|
file->GatewayProfileUsageMethod = value;
|
|
|
|
|
else if (_stricmp(name, "gatewaycredentialssource") == 0)
|
|
|
|
|
file->GatewayCredentialsSource = value;
|
|
|
|
|
else if (_stricmp(name, "use redirection server name") == 0)
|
|
|
|
|
file->UseRedirectionServerName = value;
|
|
|
|
|
else if (_stricmp(name, "rdgiskdcproxy") == 0)
|
|
|
|
|
file->RdgIsKdcProxy = value;
|
|
|
|
|
else
|
2015-06-22 19:52:13 +03:00
|
|
|
|
standard = 1;
|
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)
|
|
|
|
|
return -1;
|
2013-12-05 00:37:42 +04:00
|
|
|
|
|
2017-02-14 14:53:14 +03:00
|
|
|
|
file->lines[index].iValue = (DWORD) 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;
|
|
|
|
|
|
2015-06-22 19:52:13 +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;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-22 19:52:13 +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,
|
2017-02-14 14:53:14 +03:00
|
|
|
|
const char* value, int index)
|
2012-10-28 06:46:37 +04:00
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
|
long ivalue;
|
|
|
|
|
errno = 0;
|
|
|
|
|
ivalue = strtol(value, NULL, 0);
|
|
|
|
|
|
|
|
|
|
if ((errno != 0) || (ivalue < INT32_MIN) || (ivalue > INT32_MAX))
|
2018-12-11 11:27:32 +03:00
|
|
|
|
{
|
|
|
|
|
WLog_ERR(TAG, "Failed to convert RDP file integer option %s [value=%s]", name, value);
|
2017-11-14 18:10:52 +03:00
|
|
|
|
return FALSE;
|
2018-12-11 11:27:32 +03:00
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
if (freerdp_client_rdp_file_set_integer(file, name, ivalue, index) < 0)
|
|
|
|
|
return FALSE;
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
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,
|
|
|
|
|
int 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
|
2014-09-12 19:13:01 +04: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;
|
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;
|
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
|
|
|
|
}
|
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
static BOOL freerdp_client_add_option(rdpFile* file, char* option)
|
2013-09-18 22:01:19 +04:00
|
|
|
|
{
|
|
|
|
|
while ((file->argc + 1) > file->argSize)
|
|
|
|
|
{
|
2015-03-11 06:32:51 +03:00
|
|
|
|
int new_size;
|
2017-02-14 14:53:14 +03:00
|
|
|
|
char** new_argv;
|
2015-03-11 06:32:51 +03:00
|
|
|
|
new_size = file->argSize * 2;
|
|
|
|
|
new_argv = (char**) realloc(file->argv, new_size * sizeof(char*));
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2015-03-11 06:32:51 +03:00
|
|
|
|
if (!new_argv)
|
2015-06-17 23:08:02 +03:00
|
|
|
|
return FALSE;
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2015-03-11 06:32:51 +03:00
|
|
|
|
file->argv = new_argv;
|
|
|
|
|
file->argSize = new_size;
|
2013-09-18 22:01:19 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
file->argv[file->argc] = _strdup(option);
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
if (!file->argv[file->argc])
|
|
|
|
|
return FALSE;
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2013-09-18 22:01:19 +04:00
|
|
|
|
(file->argc)++;
|
2015-06-17 23:08:02 +03:00
|
|
|
|
return TRUE;
|
2013-09-18 22:01:19 +04:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
static int freerdp_client_parse_rdp_file_add_line(rdpFile* file, char* line, int index)
|
2013-12-05 00:37:42 +04:00
|
|
|
|
{
|
2013-12-05 01:29:45 +04:00
|
|
|
|
if (index < 0)
|
|
|
|
|
index = file->lineCount;
|
|
|
|
|
|
2013-12-05 00:37:42 +04:00
|
|
|
|
while ((file->lineCount + 1) > file->lineSize)
|
|
|
|
|
{
|
2015-03-11 06:32:51 +03:00
|
|
|
|
int 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;
|
|
|
|
|
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;
|
|
|
|
|
|
2013-12-05 00:37:42 +04:00
|
|
|
|
file->lines[file->lineCount].index = index;
|
|
|
|
|
(file->lineCount)++;
|
2013-12-05 01:29:45 +04:00
|
|
|
|
return index;
|
2013-12-05 00:37:42 +04:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-23 20:22:48 +03:00
|
|
|
|
static BOOL freerdp_client_parse_rdp_file_string(rdpFile* file, char* name, char* value,
|
2017-02-14 14:53:14 +03:00
|
|
|
|
int 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
|
|
|
|
}
|
|
|
|
|
|
2017-11-23 20:22:48 +03:00
|
|
|
|
static BOOL freerdp_client_parse_rdp_file_option(rdpFile* file, char* option, int index)
|
2013-09-18 22:01:19 +04:00
|
|
|
|
{
|
2015-06-17 23:08:02 +03:00
|
|
|
|
return freerdp_client_add_option(file, option);
|
2013-09-18 22:01:19 +04:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-23 20:22:48 +03:00
|
|
|
|
BOOL freerdp_client_parse_rdp_file_buffer(rdpFile* file, const BYTE* buffer,
|
2017-02-14 14:53:14 +03:00
|
|
|
|
size_t size)
|
2012-10-28 04:25:11 +04:00
|
|
|
|
{
|
2017-02-15 16:22:15 +03:00
|
|
|
|
BOOL rc = FALSE;
|
2013-12-05 00:37:42 +04:00
|
|
|
|
int 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;
|
2017-02-14 14:53:14 +03:00
|
|
|
|
char* d1, *d2;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
char* beg;
|
2017-02-14 14:53:14 +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]))
|
|
|
|
|
{
|
2017-12-20 15:43:14 +03:00
|
|
|
|
size = size / 2 - 1;
|
|
|
|
|
|
|
|
|
|
if (ConvertFromUnicode(CP_UTF8, 0, (LPCWSTR)(&buffer[2]), size, ©, 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];
|
|
|
|
|
|
|
|
|
|
if (*type == 'i')
|
|
|
|
|
{
|
|
|
|
|
/* 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
|
|
|
|
}
|
|
|
|
|
|
2017-02-15 16:22:15 +03:00
|
|
|
|
rc = TRUE;
|
|
|
|
|
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)
|
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;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
fp = fopen(name, "r");
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2013-04-13 02:03:56 +04:00
|
|
|
|
buffer = (BYTE*) malloc(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
|
|
|
|
|
2012-10-28 04:25:11 +04:00
|
|
|
|
read_size = fread(buffer, file_size, 1, fp);
|
|
|
|
|
|
|
|
|
|
if (!read_size)
|
|
|
|
|
{
|
|
|
|
|
if (!ferror(fp))
|
|
|
|
|
read_size = file_size;
|
|
|
|
|
}
|
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';
|
2013-11-05 08:45:19 +04:00
|
|
|
|
status = freerdp_client_parse_rdp_file_buffer(file, buffer, file_size);
|
|
|
|
|
free(buffer);
|
|
|
|
|
return status;
|
2012-10-28 04:25:11 +04:00
|
|
|
|
}
|
2012-10-28 05:30:08 +04:00
|
|
|
|
|
2013-10-17 02:29:52 +04:00
|
|
|
|
#define WRITE_ALL_SETTINGS TRUE
|
2013-10-17 06:55:51 +04:00
|
|
|
|
#define SETTING_MODIFIED(_settings, _field) (WRITE_ALL_SETTINGS || _settings->SettingsModified[FreeRDP_##_field])
|
2013-04-23 02:39:18 +04:00
|
|
|
|
#define SETTING_MODIFIED_SET(_target, _settings, _field) if SETTING_MODIFIED(_settings, _field) _target = _settings->_field
|
2015-06-17 23:08:02 +03:00
|
|
|
|
#define SETTING_MODIFIED_SET_STRING(_target, _settings, _field) do { if SETTING_MODIFIED(_settings, _field) _target = _strdup(_settings->_field); \
|
2017-02-14 14:53:14 +03:00
|
|
|
|
if (!_target) return FALSE; \
|
|
|
|
|
} while (0)
|
2013-04-23 02:39:18 +04: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
|
|
|
|
{
|
2013-11-07 19:37:46 +04:00
|
|
|
|
SETTING_MODIFIED_SET_STRING(file->Domain, settings, Domain);
|
|
|
|
|
SETTING_MODIFIED_SET_STRING(file->Username, settings, Username);
|
2017-02-10 23:38:52 +03:00
|
|
|
|
SETTING_MODIFIED_SET_STRING(file->Password, settings, Password);
|
2013-04-23 02:39:18 +04:00
|
|
|
|
SETTING_MODIFIED_SET(file->ServerPort, settings, ServerPort);
|
2013-11-07 19:37:46 +04:00
|
|
|
|
SETTING_MODIFIED_SET_STRING(file->FullAddress, settings, ServerHostname);
|
2013-04-23 02:39:18 +04:00
|
|
|
|
SETTING_MODIFIED_SET(file->DesktopWidth, settings, DesktopWidth);
|
|
|
|
|
SETTING_MODIFIED_SET(file->DesktopHeight, settings, DesktopHeight);
|
|
|
|
|
SETTING_MODIFIED_SET(file->SessionBpp, settings, ColorDepth);
|
|
|
|
|
SETTING_MODIFIED_SET(file->ConnectToConsole, settings, ConsoleSession);
|
|
|
|
|
SETTING_MODIFIED_SET(file->AdministrativeSession, settings, ConsoleSession);
|
|
|
|
|
SETTING_MODIFIED_SET(file->NegotiateSecurityLayer, settings, NegotiateSecurityLayer);
|
|
|
|
|
SETTING_MODIFIED_SET(file->EnableCredSSPSupport, settings, NlaSecurity);
|
2013-11-07 19:37:46 +04:00
|
|
|
|
SETTING_MODIFIED_SET_STRING(file->AlternateShell, settings, AlternateShell);
|
|
|
|
|
SETTING_MODIFIED_SET_STRING(file->ShellWorkingDirectory, settings, ShellWorkingDirectory);
|
2013-04-23 02:39:18 +04:00
|
|
|
|
SETTING_MODIFIED_SET(file->ConnectionType, settings, ConnectionType);
|
|
|
|
|
|
|
|
|
|
if (SETTING_MODIFIED(settings, AudioPlayback) || SETTING_MODIFIED(settings, RemoteConsoleAudio))
|
2013-04-23 00:08:47 +04:00
|
|
|
|
{
|
2013-04-23 02:39:18 +04:00
|
|
|
|
if (settings->AudioPlayback)
|
|
|
|
|
file->AudioMode = AUDIO_MODE_REDIRECT;
|
|
|
|
|
else if (settings->RemoteConsoleAudio)
|
|
|
|
|
file->AudioMode = AUDIO_MODE_PLAY_ON_SERVER;
|
|
|
|
|
else
|
|
|
|
|
file->AudioMode = AUDIO_MODE_NONE;
|
2013-04-23 00:08:47 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-07 19:37:46 +04:00
|
|
|
|
SETTING_MODIFIED_SET_STRING(file->GatewayHostname, settings, GatewayHostname);
|
2018-02-13 16:59:33 +03:00
|
|
|
|
SETTING_MODIFIED_SET_STRING(file->GatewayAccessToken, settings, GatewayAccessToken);
|
2013-04-23 02:39:18 +04:00
|
|
|
|
SETTING_MODIFIED_SET(file->GatewayUsageMethod, settings, GatewayUsageMethod);
|
|
|
|
|
SETTING_MODIFIED_SET(file->PromptCredentialOnce, settings, GatewayUseSameCredentials);
|
|
|
|
|
SETTING_MODIFIED_SET(file->RemoteApplicationMode, settings, RemoteApplicationMode);
|
2013-11-07 19:37:46 +04:00
|
|
|
|
SETTING_MODIFIED_SET_STRING(file->RemoteApplicationProgram, settings, RemoteApplicationProgram);
|
|
|
|
|
SETTING_MODIFIED_SET_STRING(file->RemoteApplicationName, settings, RemoteApplicationName);
|
|
|
|
|
SETTING_MODIFIED_SET_STRING(file->RemoteApplicationIcon, settings, RemoteApplicationIcon);
|
|
|
|
|
SETTING_MODIFIED_SET_STRING(file->RemoteApplicationFile, settings, RemoteApplicationFile);
|
|
|
|
|
SETTING_MODIFIED_SET_STRING(file->RemoteApplicationGuid, settings, RemoteApplicationGuid);
|
|
|
|
|
SETTING_MODIFIED_SET_STRING(file->RemoteApplicationCmdLine, settings, RemoteApplicationCmdLine);
|
2013-04-23 02:39:18 +04:00
|
|
|
|
SETTING_MODIFIED_SET(file->SpanMonitors, settings, SpanMonitors);
|
|
|
|
|
SETTING_MODIFIED_SET(file->UseMultiMon, settings, UseMultimon);
|
2018-04-01 05:15:39 +03:00
|
|
|
|
SETTING_MODIFIED_SET_STRING(file->PreconnectionBlob, settings, PreconnectionBlob);
|
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);
|
|
|
|
|
buffer = (char*) calloc((size + 1), sizeof(char));
|
2013-09-18 22:01:19 +04:00
|
|
|
|
|
2019-02-07 16:38:16 +03:00
|
|
|
|
if (freerdp_client_write_rdp_file_buffer(file, buffer, size + 1) != size)
|
2013-04-23 00:08:47 +04:00
|
|
|
|
{
|
2014-09-12 19:13:01 +04: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
|
|
|
|
|
2013-12-05 03:25:55 +04:00
|
|
|
|
fp = 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-02-07 16:38:16 +03:00
|
|
|
|
if ((length < 0) ||
|
|
|
|
|
(fwrite(BOM_UTF16_LE, sizeof(BYTE), 2, fp) != 2) ||
|
|
|
|
|
(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-02-07 16:38:16 +03:00
|
|
|
|
if (fwrite(buffer, 1, size, fp) != 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
|
|
|
|
}
|
|
|
|
|
|
2013-12-05 03:25:55 +04:00
|
|
|
|
size_t freerdp_client_write_rdp_file_buffer(const rdpFile* file, char* buffer, size_t size)
|
|
|
|
|
{
|
|
|
|
|
int index;
|
|
|
|
|
int length;
|
|
|
|
|
char* output;
|
|
|
|
|
rdpFileLine* line;
|
|
|
|
|
|
|
|
|
|
if (!buffer)
|
|
|
|
|
size = 0;
|
|
|
|
|
|
|
|
|
|
output = buffer;
|
|
|
|
|
|
|
|
|
|
for (index = 0; index < file->lineCount; index++)
|
|
|
|
|
{
|
|
|
|
|
line = &(file->lines[index]);
|
2014-02-10 10:06:11 +04:00
|
|
|
|
length = (int) strlen(line->text);
|
2013-12-05 03:25:55 +04:00
|
|
|
|
|
|
|
|
|
if (!buffer)
|
|
|
|
|
{
|
|
|
|
|
size += length + 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CopyMemory(output, line->text, length);
|
|
|
|
|
output += length;
|
|
|
|
|
*output = '\n';
|
|
|
|
|
output++;
|
|
|
|
|
}
|
2013-04-23 02:39:18 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-05 03:25:55 +04:00
|
|
|
|
if (buffer)
|
|
|
|
|
size = (output - buffer);
|
2013-04-23 02:39:18 +04:00
|
|
|
|
|
2013-12-05 03:25:55 +04:00
|
|
|
|
return size;
|
2013-04-23 00:08:47 +04:00
|
|
|
|
}
|
|
|
|
|
|
2012-10-28 05:30:08 +04:00
|
|
|
|
BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings* settings)
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
if (~((size_t) file->Username))
|
|
|
|
|
{
|
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
|
|
|
|
if (~((size_t) file->FullAddress))
|
|
|
|
|
{
|
|
|
|
|
int port = -1;
|
|
|
|
|
char* host = NULL;
|
|
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
|
if (!freerdp_parse_hostname(file->FullAddress, &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_ServerHostname, 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-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_ServerPort, (UINT32) port))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
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
|
|
|
|
|
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-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_ConsoleSession, file->ConnectToConsole))
|
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-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_ConsoleSession, file->AdministrativeSession))
|
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,
|
|
|
|
|
file->NegotiateSecurityLayer))
|
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-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_NlaSecurity, file->EnableCredSSPSupport))
|
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 (~((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
|
|
|
|
|
2012-10-28 05:30:08 +04:00
|
|
|
|
if (~((size_t) file->ShellWorkingDirectory))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_ShellWorkingDirectory,
|
|
|
|
|
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;
|
2014-04-30 01:33:59 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-11 19:51:10 +04:00
|
|
|
|
if (~((size_t) file->LoadBalanceInfo))
|
|
|
|
|
{
|
|
|
|
|
settings->LoadBalanceInfo = (BYTE*) _strdup(file->LoadBalanceInfo);
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
if (!settings->LoadBalanceInfo)
|
|
|
|
|
return FALSE;
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2014-02-10 10:06:11 +04:00
|
|
|
|
settings->LoadBalanceInfoLength = (int) strlen((char*) settings->LoadBalanceInfo);
|
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:
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
2018-04-12 23:05:04 +03:00
|
|
|
|
settings->AuthenticationLevel = file->AuthenticationLevel;
|
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-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_ConnectionType, file->ConnectionType))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2012-11-26 23:31:31 +04:00
|
|
|
|
|
|
|
|
|
if (~file->AudioMode)
|
|
|
|
|
{
|
|
|
|
|
if (file->AudioMode == AUDIO_MODE_REDIRECT)
|
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AudioPlayback, TRUE))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
2012-11-26 23:31:31 +04:00
|
|
|
|
}
|
|
|
|
|
else if (file->AudioMode == AUDIO_MODE_PLAY_ON_SERVER)
|
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteConsoleAudio, TRUE))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
2012-11-26 23:31:31 +04:00
|
|
|
|
}
|
|
|
|
|
else if (file->AudioMode == AUDIO_MODE_NONE)
|
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AudioPlayback, FALSE) ||
|
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_RemoteConsoleAudio, FALSE))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
2012-11-26 23:31:31 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-17 23:58:48 +04:00
|
|
|
|
if (~file->Compression)
|
2019-05-06 10:51:42 +03:00
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_CompressionEnabled, file->Compression))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2013-09-17 23:58:48 +04:00
|
|
|
|
|
2012-10-28 05:30:08 +04: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-05-08 15:35:25 +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
|
|
|
|
|
2018-02-13 16:59:33 +03:00
|
|
|
|
if (~((size_t) file->GatewayAccessToken))
|
|
|
|
|
{
|
2019-05-08 15:35:25 +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,
|
|
|
|
|
file->PromptCredentialOnce))
|
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->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,
|
|
|
|
|
file->RemoteApplicationMode))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2012-11-19 22:26:56 +04: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
|
|
|
|
|
2012-11-19 22:26:56 +04: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
|
|
|
|
|
2012-11-19 22:26:56 +04: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
|
|
|
|
|
2012-11-19 22:26:56 +04:00
|
|
|
|
if (~((size_t) file->RemoteApplicationFile))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
{
|
2019-05-09 14:50:39 +03:00
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_RemoteApplicationGuid,
|
|
|
|
|
file->RemoteApplicationGuid))
|
2015-06-17 23:08:02 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2012-11-19 22:26:56 +04: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-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SpanMonitors, file->SpanMonitors))
|
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-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_UseMultimon, file->UseMultiMon))
|
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-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AllowFontSmoothing, file->AllowFontSmoothing))
|
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-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DisableWallpaper, file->DisableWallpaper))
|
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,
|
|
|
|
|
file->DisableFullWindowDrag))
|
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-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DisableMenuAnims, file->DisableMenuAnims))
|
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-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DisableThemes, file->DisableThemes))
|
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,
|
|
|
|
|
file->AllowDesktopComposition))
|
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,
|
|
|
|
|
file->BitmapCachePersistEnable))
|
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,
|
|
|
|
|
file->DisableRemoteAppCapsCheck))
|
2019-05-06 10:51:42 +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,
|
|
|
|
|
file->AutoReconnectionEnabled))
|
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-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectSmartCards, file->RedirectSmartCards))
|
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-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectClipboard, file->RedirectClipboard))
|
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-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectPrinters, file->RedirectPrinters))
|
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-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectDrives, file->RedirectDrives))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2013-09-17 23:42:36 +04:00
|
|
|
|
|
|
|
|
|
if (~file->RedirectPosDevices)
|
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectSerialPorts, file->RedirectComPorts) ||
|
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_RedirectParallelPorts, file->RedirectComPorts))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
2013-09-17 23:42:36 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (~file->RedirectComPorts)
|
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectSerialPorts, file->RedirectComPorts) ||
|
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_RedirectParallelPorts, file->RedirectComPorts))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
2013-09-17 23:42:36 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (~file->RedirectDirectX)
|
|
|
|
|
{
|
|
|
|
|
/* What is this?! */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (~((size_t) file->DevicesToRedirect))
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* 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-05-09 14:50:39 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectDrives, TRUE))
|
|
|
|
|
return FALSE;
|
2013-09-17 23:42:36 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-17 23:58:48 +04:00
|
|
|
|
if (~((size_t) file->DrivesToRedirect))
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* Drives to redirect:
|
|
|
|
|
*
|
|
|
|
|
* Very similar to DevicesToRedirect, but can contain a
|
|
|
|
|
* comma-separated list of drive letters to redirect.
|
|
|
|
|
*/
|
2017-11-17 16:03:57 +03:00
|
|
|
|
const BOOL empty = !file->DrivesToRedirect || (strlen(file->DrivesToRedirect) == 0);
|
2019-05-06 10:51:42 +03:00
|
|
|
|
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectDrives, !empty))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
2013-09-17 23:58:48 +04: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
|
|
|
|
}
|
|
|
|
|
|
2018-04-01 05:15:39 +03:00
|
|
|
|
if (~((size_t) file->PreconnectionBlob))
|
|
|
|
|
{
|
2019-05-08 15:35:25 +03:00
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_PreconnectionBlob, file->PreconnectionBlob) ||
|
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_SendPreconnectionPdu, TRUE) ||
|
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_VmConnectMode, TRUE))
|
2019-05-06 10:51:42 +03:00
|
|
|
|
return FALSE;
|
2018-04-01 05:15:39 +03:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-18 22:01:19 +04:00
|
|
|
|
if (file->argc > 1)
|
|
|
|
|
{
|
2013-11-10 22:29:20 +04:00
|
|
|
|
char* ConnectionFile = settings->ConnectionFile;
|
|
|
|
|
settings->ConnectionFile = NULL;
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
if (freerdp_client_settings_parse_command_line(settings, file->argc, file->argv, FALSE) < 0)
|
|
|
|
|
return FALSE;
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2013-11-10 22:29:20 +04:00
|
|
|
|
settings->ConnectionFile = ConnectionFile;
|
2013-09-18 22:01:19 +04:00
|
|
|
|
}
|
|
|
|
|
|
2012-10-28 05:30:08 +04:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
static rdpFileLine* freerdp_client_rdp_file_find_line_index(rdpFile* file, int index)
|
2013-12-05 01:29:45 +04:00
|
|
|
|
{
|
|
|
|
|
rdpFileLine* line;
|
|
|
|
|
line = &(file->lines[index]);
|
|
|
|
|
return line;
|
|
|
|
|
}
|
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
|
|
|
|
{
|
|
|
|
|
int index;
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp(name, line->name) == 0)
|
|
|
|
|
{
|
|
|
|
|
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 index;
|
|
|
|
|
int length;
|
|
|
|
|
char* text;
|
|
|
|
|
rdpFileLine* line;
|
|
|
|
|
length = _scprintf("%s:s:%s", name, value);
|
|
|
|
|
text = (char*) malloc(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
|
|
|
|
|
2013-12-05 03:25:55 +04:00
|
|
|
|
sprintf_s(text, 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
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
if (!(line = freerdp_client_rdp_file_find_line_index(file, index)))
|
|
|
|
|
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
|
|
|
|
}
|
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;
|
|
|
|
|
}
|
|
|
|
|
int freerdp_client_rdp_file_set_integer_option(rdpFile* file, const char* name, int value)
|
|
|
|
|
{
|
|
|
|
|
int index;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
const int length = _scprintf("%s:i:%d", name, value);
|
|
|
|
|
char* text = (char*) malloc(length + 1);
|
|
|
|
|
rdpFileLine* line = freerdp_client_rdp_file_find_line_by_name(file, name);
|
|
|
|
|
|
|
|
|
|
if (!text)
|
|
|
|
|
return -1;
|
|
|
|
|
|
2013-12-05 03:25:55 +04:00
|
|
|
|
sprintf_s(text, 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
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
if (freerdp_client_rdp_file_set_integer(file, (char*) name, value, index) < 0)
|
|
|
|
|
{
|
|
|
|
|
free(text);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2013-12-05 01:29:45 +04:00
|
|
|
|
|
|
|
|
|
free(text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
return line->iValue;
|
|
|
|
|
}
|
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
|
|
|
|
{
|
|
|
|
|
if (~((size_t) str))
|
|
|
|
|
free(str);
|
|
|
|
|
}
|
2012-10-28 05:30:08 +04:00
|
|
|
|
rdpFile* freerdp_client_rdp_file_new()
|
|
|
|
|
{
|
|
|
|
|
rdpFile* file;
|
|
|
|
|
file = (rdpFile*) malloc(sizeof(rdpFile));
|
2013-09-18 22:01:19 +04:00
|
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
|
{
|
|
|
|
|
FillMemory(file, sizeof(rdpFile), 0xFF);
|
2013-12-05 00:37:42 +04:00
|
|
|
|
file->lineCount = 0;
|
|
|
|
|
file->lineSize = 32;
|
2017-05-30 11:46:43 +03:00
|
|
|
|
file->lines = (rdpFileLine*) calloc(file->lineSize, sizeof(rdpFileLine));
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
if (!file->lines)
|
|
|
|
|
{
|
|
|
|
|
free(file);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-18 22:01:19 +04:00
|
|
|
|
file->argc = 0;
|
|
|
|
|
file->argSize = 32;
|
2017-05-30 11:46:43 +03:00
|
|
|
|
file->argv = (char**) calloc(file->argSize, sizeof(char*));
|
2017-02-14 14:53:14 +03:00
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
if (!file->argv)
|
|
|
|
|
{
|
|
|
|
|
free(file->lines);
|
|
|
|
|
free(file);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2013-09-18 22:01:19 +04:00
|
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
|
if (!freerdp_client_add_option(file, "freerdp"))
|
|
|
|
|
{
|
|
|
|
|
free(file->argv);
|
|
|
|
|
free(file->lines);
|
|
|
|
|
free(file);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2013-09-18 22:01:19 +04:00
|
|
|
|
}
|
2012-10-28 05:30:08 +04:00
|
|
|
|
|
|
|
|
|
return file;
|
|
|
|
|
}
|
|
|
|
|
void freerdp_client_rdp_file_free(rdpFile* file)
|
|
|
|
|
{
|
2013-09-18 22:01:19 +04:00
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
|
{
|
2013-12-05 00:37:42 +04:00
|
|
|
|
if (file->lineCount)
|
|
|
|
|
{
|
|
|
|
|
for (i = 0; i < file->lineCount; i++)
|
|
|
|
|
{
|
|
|
|
|
free(file->lines[i].text);
|
|
|
|
|
free(file->lines[i].name);
|
|
|
|
|
free(file->lines[i].sValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free(file->lines);
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-18 22:01:19 +04:00
|
|
|
|
if (file->argv)
|
|
|
|
|
{
|
|
|
|
|
for (i = 0; i < file->argc; i++)
|
|
|
|
|
free(file->argv[i]);
|
|
|
|
|
|
|
|
|
|
free(file->argv);
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
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
|
|
|
|
}
|