Пример #1
0
BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings* settings)
{
    if (~((size_t) file->Domain))
        freerdp_set_param_string(settings, FreeRDP_Domain, file->Domain);

    if (~((size_t) file->Username))
    {
        char* user = NULL;
        char* domain = NULL;

        freerdp_parse_username(file->Username, &user, &domain);
        freerdp_set_param_string(settings, FreeRDP_Username, user);

        if (domain)
            freerdp_set_param_string(settings, FreeRDP_Domain, domain);

        if (user)
            free(user);

        if (domain)
            free(domain);
    }

    if (~file->ServerPort)
        freerdp_set_param_uint32(settings, FreeRDP_ServerPort, file->ServerPort);
    if (~((size_t) file->FullAddress))
        freerdp_set_param_string(settings, FreeRDP_ServerHostname, file->FullAddress);

    if (~file->DesktopWidth)
        freerdp_set_param_uint32(settings, FreeRDP_DesktopWidth, file->DesktopWidth);
    if (~file->DesktopHeight)
        freerdp_set_param_uint32(settings, FreeRDP_DesktopHeight, file->DesktopHeight);
    if (~file->SessionBpp)
        freerdp_set_param_uint32(settings, FreeRDP_ColorDepth, file->SessionBpp);
    if (~file->ConnectToConsole)
        freerdp_set_param_uint32(settings, FreeRDP_ConsoleSession, file->ConnectToConsole);
    if (~file->AdministrativeSession)
        freerdp_set_param_uint32(settings, FreeRDP_ConsoleSession, file->AdministrativeSession);
    if (~file->NegotiateSecurityLayer)
        freerdp_set_param_uint32(settings, FreeRDP_NegotiateSecurityLayer, file->NegotiateSecurityLayer);
    if (~file->EnableCredSSPSupport)
        freerdp_set_param_uint32(settings, FreeRDP_NlaSecurity, file->EnableCredSSPSupport);
    if (~((size_t) file->AlternateShell))
        freerdp_set_param_string(settings, FreeRDP_AlternateShell, file->AlternateShell);
    if (~((size_t) file->ShellWorkingDirectory))
        freerdp_set_param_string(settings, FreeRDP_ShellWorkingDirectory, file->ShellWorkingDirectory);

    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:
         *
         * 0: The remote session will appear in a window.
         * 1: The remote session will appear full screen.
         */

        freerdp_set_param_bool(settings, FreeRDP_Fullscreen,
                               (file->ScreenModeId == 1) ? TRUE : FALSE);
    }

    if (~((size_t) file->LoadBalanceInfo))
    {
        settings->LoadBalanceInfo = (BYTE*) _strdup(file->LoadBalanceInfo);
        settings->LoadBalanceInfoLength = strlen((char*) settings->LoadBalanceInfo);
    }

    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.
         */

        freerdp_set_param_bool(settings, FreeRDP_IgnoreCertificate,
                               (file->AuthenticationLevel == 0) ? TRUE : FALSE);
    }

    if (~file->ConnectionType)
        freerdp_set_param_uint32(settings, FreeRDP_ConnectionType, file->ConnectionType);

    if (~file->AudioMode)
    {
        if (file->AudioMode == AUDIO_MODE_REDIRECT)
        {
            freerdp_set_param_bool(settings, FreeRDP_AudioPlayback, TRUE);
        }
        else if (file->AudioMode == AUDIO_MODE_PLAY_ON_SERVER)
        {
            freerdp_set_param_bool(settings, FreeRDP_RemoteConsoleAudio, TRUE);
        }
        else if (file->AudioMode == AUDIO_MODE_NONE)
        {
            freerdp_set_param_bool(settings, FreeRDP_AudioPlayback, FALSE);
            freerdp_set_param_bool(settings, FreeRDP_RemoteConsoleAudio, FALSE);
        }
    }

    if (~file->Compression)
        freerdp_set_param_bool(settings, FreeRDP_CompressionEnabled, file->Compression);

    if (~((size_t) file->GatewayHostname))
        freerdp_set_param_string(settings, FreeRDP_GatewayHostname, file->GatewayHostname);

    if (~file->GatewayUsageMethod)
    {
        freerdp_set_param_uint32(settings, FreeRDP_GatewayUsageMethod, file->GatewayUsageMethod);

        if (file->GatewayUsageMethod == TSC_PROXY_MODE_DIRECT)
            freerdp_set_param_bool(settings, FreeRDP_GatewayEnabled, TRUE);
        else if (file->GatewayUsageMethod == TSC_PROXY_MODE_DETECT)
            freerdp_set_param_bool(settings, FreeRDP_GatewayEnabled, TRUE);
        else if (file->GatewayUsageMethod == TSC_PROXY_MODE_DEFAULT)
            freerdp_set_param_bool(settings, FreeRDP_GatewayEnabled, TRUE);
        else if (file->GatewayUsageMethod == TSC_PROXY_MODE_NONE_DETECT)
            freerdp_set_param_bool(settings, FreeRDP_GatewayEnabled, FALSE);
    }

    if (~file->PromptCredentialOnce)
        freerdp_set_param_bool(settings, FreeRDP_GatewayUseSameCredentials, TRUE);

    if (~file->RemoteApplicationMode)
        freerdp_set_param_bool(settings, FreeRDP_RemoteApplicationMode, file->RemoteApplicationMode);
    if (~((size_t) file->RemoteApplicationProgram))
        freerdp_set_param_string(settings, FreeRDP_RemoteApplicationProgram, file->RemoteApplicationProgram);
    if (~((size_t) file->RemoteApplicationName))
        freerdp_set_param_string(settings, FreeRDP_RemoteApplicationName, file->RemoteApplicationName);
    if (~((size_t) file->RemoteApplicationIcon))
        freerdp_set_param_string(settings, FreeRDP_RemoteApplicationIcon, file->RemoteApplicationIcon);
    if (~((size_t) file->RemoteApplicationFile))
        freerdp_set_param_string(settings, FreeRDP_RemoteApplicationGuid, file->RemoteApplicationGuid);
    if (~((size_t) file->RemoteApplicationGuid))
        freerdp_set_param_string(settings, FreeRDP_RemoteApplicationGuid, file->RemoteApplicationGuid);
    if (~((size_t) file->RemoteApplicationCmdLine))
        freerdp_set_param_string(settings, FreeRDP_RemoteApplicationCmdLine, file->RemoteApplicationCmdLine);

    if (~file->SpanMonitors)
        freerdp_set_param_bool(settings, FreeRDP_SpanMonitors, file->SpanMonitors);
    if (~file->UseMultiMon)
        freerdp_set_param_bool(settings, FreeRDP_UseMultimon, file->UseMultiMon);

    if (~file->AllowFontSmoothing)
        freerdp_set_param_bool(settings, FreeRDP_AllowFontSmoothing, file->AllowFontSmoothing);
    if (~file->DisableWallpaper)
        freerdp_set_param_bool(settings, FreeRDP_DisableWallpaper, file->DisableWallpaper);
    if (~file->DisableFullWindowDrag)
        freerdp_set_param_bool(settings, FreeRDP_DisableFullWindowDrag, file->DisableFullWindowDrag);
    if (~file->DisableMenuAnims)
        freerdp_set_param_bool(settings, FreeRDP_DisableMenuAnims, file->DisableMenuAnims);
    if (~file->DisableThemes)
        freerdp_set_param_bool(settings, FreeRDP_DisableThemes, file->DisableThemes);
    if (~file->AllowDesktopComposition)
        freerdp_set_param_bool(settings, FreeRDP_DisableCursorShadow, file->AllowDesktopComposition);

    if (~file->BitmapCachePersistEnable)
        freerdp_set_param_bool(settings, FreeRDP_BitmapCachePersistEnabled, file->BitmapCachePersistEnable);

    if (~file->DisableRemoteAppCapsCheck)
        freerdp_set_param_bool(settings, FreeRDP_DisableRemoteAppCapsCheck, file->DisableRemoteAppCapsCheck);

    if (~file->AutoReconnectionEnabled)
        freerdp_set_param_bool(settings, FreeRDP_AutoReconnectionEnabled, file->AutoReconnectionEnabled);
    if (~file->AutoReconnectMaxRetries)
        freerdp_set_param_uint32(settings, FreeRDP_AutoReconnectMaxRetries, file->AutoReconnectMaxRetries);

    if (~file->RedirectSmartCards)
        freerdp_set_param_bool(settings, FreeRDP_RedirectSmartCards, file->RedirectSmartCards);

    if (~file->RedirectClipboard)
        freerdp_set_param_bool(settings, FreeRDP_RedirectClipboard, file->RedirectClipboard);

    if (~file->RedirectPrinters)
        freerdp_set_param_bool(settings, FreeRDP_RedirectPrinters, file->RedirectPrinters);

    if (~file->RedirectDrives)
        freerdp_set_param_bool(settings, FreeRDP_RedirectDrives, file->RedirectDrives);

    if (~file->RedirectPosDevices)
    {
        freerdp_set_param_bool(settings, FreeRDP_RedirectSerialPorts, file->RedirectComPorts);
        freerdp_set_param_bool(settings, FreeRDP_RedirectParallelPorts, file->RedirectComPorts);
    }

    if (~file->RedirectComPorts)
    {
        freerdp_set_param_bool(settings, FreeRDP_RedirectSerialPorts, file->RedirectComPorts);
        freerdp_set_param_bool(settings, FreeRDP_RedirectParallelPorts, file->RedirectComPorts);
    }

    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
         *
         */

        freerdp_set_param_bool(settings, FreeRDP_RedirectDrives, TRUE);
    }

    if (~((size_t) file->DrivesToRedirect))
    {
        /*
         * Drives to redirect:
         *
         * Very similar to DevicesToRedirect, but can contain a
         * comma-separated list of drive letters to redirect.
         */

        freerdp_set_param_bool(settings, FreeRDP_RedirectDrives, TRUE);
    }

    if (file->argc > 1)
    {
        freerdp_client_parse_command_line_arguments(file->argc, file->argv, settings);
    }

    return TRUE;
}
Пример #2
0
BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings* settings)
{
	if (~((size_t) file->Domain))
		freerdp_set_param_string(settings, FreeRDP_Domain, file->Domain);

	if (~((size_t) file->Username))
	{
		char* user;
		char* domain;

		freerdp_parse_username(file->Username, &user, &domain);
		freerdp_set_param_string(settings, FreeRDP_Username, user);

		if (domain != NULL)
			freerdp_set_param_string(settings, FreeRDP_Domain, domain);
	}

	if (~file->ServerPort)
		freerdp_set_param_uint32(settings, FreeRDP_ServerPort, file->ServerPort);
	if (~((size_t) file->FullAddress))
		freerdp_set_param_string(settings, FreeRDP_ServerHostname, file->FullAddress);

	if (~file->DesktopWidth)
		freerdp_set_param_uint32(settings, FreeRDP_DesktopWidth, file->DesktopWidth);
	if (~file->DesktopHeight)
		freerdp_set_param_uint32(settings, FreeRDP_DesktopHeight, file->DesktopHeight);
	if (~file->SessionBpp)
		freerdp_set_param_uint32(settings, FreeRDP_ColorDepth, file->SessionBpp);
	if (~file->ConnectToConsole)
		freerdp_set_param_uint32(settings, FreeRDP_ConsoleSession, file->ConnectToConsole);
	if (~file->AdministrativeSession)
		freerdp_set_param_uint32(settings, FreeRDP_ConsoleSession, file->AdministrativeSession);
	if (~file->NegotiateSecurityLayer)
		freerdp_set_param_uint32(settings, FreeRDP_NegotiateSecurityLayer, file->NegotiateSecurityLayer);
	if (~file->EnableCredSSPSupport)
		freerdp_set_param_uint32(settings, FreeRDP_NlaSecurity, file->EnableCredSSPSupport);
	if (~((size_t) file->AlternateShell))
		freerdp_set_param_string(settings, FreeRDP_AlternateShell, file->AlternateShell);
	if (~((size_t) file->ShellWorkingDirectory))
		freerdp_set_param_string(settings, FreeRDP_ShellWorkingDirectory, file->ShellWorkingDirectory);
	
	if (~((size_t) file->LoadBalanceInfo))
	{
		settings->LoadBalanceInfo = (BYTE*) _strdup(file->LoadBalanceInfo);
		settings->LoadBalanceInfoLength = strlen((char*) settings->LoadBalanceInfo);
	}

	if (~file->ConnectionType)
		freerdp_set_param_uint32(settings, FreeRDP_ConnectionType, file->ConnectionType);

	if (~file->AudioMode)
	{
		if (file->AudioMode == AUDIO_MODE_REDIRECT)
		{
			freerdp_set_param_bool(settings, FreeRDP_AudioPlayback, TRUE);
		}
		else if (file->AudioMode == AUDIO_MODE_PLAY_ON_SERVER)
		{
			freerdp_set_param_bool(settings, FreeRDP_RemoteConsoleAudio, TRUE);
		}
		else if (file->AudioMode == AUDIO_MODE_NONE)
		{
			freerdp_set_param_bool(settings, FreeRDP_AudioPlayback, FALSE);
			freerdp_set_param_bool(settings, FreeRDP_RemoteConsoleAudio, FALSE);
		}
	}

	if (~((size_t) file->GatewayHostname))
		freerdp_set_param_string(settings, FreeRDP_GatewayHostname, file->GatewayHostname);

	if (~file->GatewayUsageMethod)
	{
		freerdp_set_param_uint32(settings, FreeRDP_GatewayUsageMethod, file->GatewayUsageMethod);

		if (file->GatewayUsageMethod == TSC_PROXY_MODE_DIRECT)
			freerdp_set_param_bool(settings, FreeRDP_GatewayEnabled, TRUE);
		else if (file->GatewayUsageMethod == TSC_PROXY_MODE_NONE_DETECT)
			freerdp_set_param_bool(settings, FreeRDP_GatewayEnabled, FALSE);
	}

	if (~file->PromptCredentialOnce)
		freerdp_set_param_bool(settings, FreeRDP_GatewayUseSameCredentials, TRUE);
	
	if (~file->RemoteApplicationMode)
		freerdp_set_param_bool(settings, FreeRDP_RemoteApplicationMode, file->RemoteApplicationMode);
	if (~((size_t) file->RemoteApplicationProgram))
		freerdp_set_param_string(settings, FreeRDP_RemoteApplicationProgram, file->RemoteApplicationProgram);
	if (~((size_t) file->RemoteApplicationName))
		freerdp_set_param_string(settings, FreeRDP_RemoteApplicationName, file->RemoteApplicationName);
	if (~((size_t) file->RemoteApplicationIcon))
		freerdp_set_param_string(settings, FreeRDP_RemoteApplicationIcon, file->RemoteApplicationIcon);
	if (~((size_t) file->RemoteApplicationFile))
		freerdp_set_param_string(settings, FreeRDP_RemoteApplicationGuid, file->RemoteApplicationGuid);
	if (~((size_t) file->RemoteApplicationGuid))
		freerdp_set_param_string(settings, FreeRDP_RemoteApplicationGuid, file->RemoteApplicationGuid);
	if (~((size_t) file->RemoteApplicationCmdLine))
		freerdp_set_param_string(settings, FreeRDP_RemoteApplicationCmdLine, file->RemoteApplicationCmdLine);

	if (~file->SpanMonitors)
		freerdp_set_param_bool(settings, FreeRDP_SpanMonitors, file->SpanMonitors);
	if (~file->UseMultiMon)
		freerdp_set_param_bool(settings, FreeRDP_UseMultimon, file->UseMultiMon);

	return TRUE;
}
Пример #3
0
BOOL wf_pre_connect(freerdp* instance)
{
	wfContext* wfc;
	int desktopWidth;
	int desktopHeight;
	rdpContext* context;
	rdpSettings* settings;

	context = instance->context;
	wfc = (wfContext*) instance->context;
	wfc->instance = instance;
	wfc->codecs = instance->context->codecs;

	settings = instance->settings;

	if (settings->ConnectionFile)
	{
		if (wfc->connectionRdpFile)
		{
			freerdp_client_rdp_file_free(wfc->connectionRdpFile);
		}

		wfc->connectionRdpFile = freerdp_client_rdp_file_new();
		WLog_INFO(TAG,  "Using connection file: %s", settings->ConnectionFile);
		freerdp_client_parse_rdp_file(wfc->connectionRdpFile, settings->ConnectionFile);
		freerdp_client_populate_settings_from_rdp_file(wfc->connectionRdpFile, settings);
	}

	settings->OsMajorType = OSMAJORTYPE_WINDOWS;
	settings->OsMinorType = OSMINORTYPE_WINDOWS_NT;
	settings->OrderSupport[NEG_DSTBLT_INDEX] = TRUE;
	settings->OrderSupport[NEG_PATBLT_INDEX] = TRUE;
	settings->OrderSupport[NEG_SCRBLT_INDEX] = TRUE;
	settings->OrderSupport[NEG_OPAQUE_RECT_INDEX] = TRUE;
	settings->OrderSupport[NEG_DRAWNINEGRID_INDEX] = FALSE;
	settings->OrderSupport[NEG_MULTIDSTBLT_INDEX] = FALSE;
	settings->OrderSupport[NEG_MULTIPATBLT_INDEX] = FALSE;
	settings->OrderSupport[NEG_MULTISCRBLT_INDEX] = FALSE;
	settings->OrderSupport[NEG_MULTIOPAQUERECT_INDEX] = TRUE;
	settings->OrderSupport[NEG_MULTI_DRAWNINEGRID_INDEX] = FALSE;
	settings->OrderSupport[NEG_LINETO_INDEX] = TRUE;
	settings->OrderSupport[NEG_POLYLINE_INDEX] = TRUE;
	settings->OrderSupport[NEG_MEMBLT_INDEX] = TRUE;
	settings->OrderSupport[NEG_MEM3BLT_INDEX] = FALSE;
	settings->OrderSupport[NEG_SAVEBITMAP_INDEX] = FALSE;
	settings->OrderSupport[NEG_GLYPH_INDEX_INDEX] = FALSE;
	settings->OrderSupport[NEG_FAST_INDEX_INDEX] = FALSE;
	settings->OrderSupport[NEG_FAST_GLYPH_INDEX] = FALSE;
	settings->OrderSupport[NEG_POLYGON_SC_INDEX] = FALSE;
	settings->OrderSupport[NEG_POLYGON_CB_INDEX] = FALSE;
	settings->OrderSupport[NEG_ELLIPSE_SC_INDEX] = FALSE;
	settings->OrderSupport[NEG_ELLIPSE_CB_INDEX] = FALSE;

	settings->GlyphSupportLevel = GLYPH_SUPPORT_NONE;

	wfc->fullscreen = settings->Fullscreen;

	if (wfc->fullscreen)
		wfc->fs_toggle = 1;

	wfc->clrconv = (HCLRCONV) malloc(sizeof(CLRCONV));
	ZeroMemory(wfc->clrconv, sizeof(CLRCONV));

	wfc->clrconv->palette = NULL;
	wfc->clrconv->alpha = FALSE;

	instance->context->cache = cache_new(settings);

	desktopWidth = settings->DesktopWidth;
	desktopHeight = settings->DesktopHeight;

	if (wfc->percentscreen > 0)
	{
		desktopWidth = (GetSystemMetrics(SM_CXSCREEN) * wfc->percentscreen) / 100;
		settings->DesktopWidth = desktopWidth;

		desktopHeight = (GetSystemMetrics(SM_CYSCREEN) * wfc->percentscreen) / 100;
		settings->DesktopHeight = desktopHeight;
	}

	if (wfc->fullscreen)
	{
		if (settings->UseMultimon)
		{
			desktopWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
			desktopHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
		}
		else
		{
			desktopWidth = GetSystemMetrics(SM_CXSCREEN);
			desktopHeight = GetSystemMetrics(SM_CYSCREEN);
		}
	}

	/* FIXME: desktopWidth has a limitation that it should be divisible by 4,
	 *        otherwise the screen will crash when connecting to an XP desktop.*/
	desktopWidth = (desktopWidth + 3) & (~3);

	if (desktopWidth != settings->DesktopWidth)
	{
		freerdp_set_param_uint32(settings, FreeRDP_DesktopWidth, desktopWidth);
	}

	if (desktopHeight != settings->DesktopHeight)
	{
		freerdp_set_param_uint32(settings, FreeRDP_DesktopHeight, desktopHeight);
	}

	if ((settings->DesktopWidth < 64) || (settings->DesktopHeight < 64) ||
		(settings->DesktopWidth > 4096) || (settings->DesktopHeight > 4096))
	{
		WLog_ERR(TAG, "invalid dimensions %d %d", settings->DesktopWidth, settings->DesktopHeight);
		return 1;
	}

	freerdp_set_param_uint32(settings, FreeRDP_KeyboardLayout, (int) GetKeyboardLayout(0) & 0x0000FFFF);

	PubSub_SubscribeChannelConnected(instance->context->pubSub,
		(pChannelConnectedEventHandler) wf_OnChannelConnectedEventHandler);

	PubSub_SubscribeChannelDisconnected(instance->context->pubSub,
		(pChannelDisconnectedEventHandler) wf_OnChannelDisconnectedEventHandler);

	freerdp_channels_pre_connect(instance->context->channels, instance);

	return TRUE;
}
Пример #4
0
BOOL wf_pre_connect(freerdp* instance)
{
	wfContext* wfc;
	int desktopWidth;
	int desktopHeight;
	rdpContext* context;
	rdpSettings* settings;

	context = instance->context;
	wfc = (wfContext*) instance->context;
	wfc->instance = instance;

	settings = instance->settings;

	if (settings->ConnectionFile)
	{
		if (wfc->connectionRdpFile)
		{
			freerdp_client_rdp_file_free(wfc->connectionRdpFile);
		}

		wfc->connectionRdpFile = freerdp_client_rdp_file_new();

		fprintf(stderr, "Using connection file: %s\n", settings->ConnectionFile);

		freerdp_client_parse_rdp_file(wfc->connectionRdpFile, settings->ConnectionFile);
		freerdp_client_populate_settings_from_rdp_file(wfc->connectionRdpFile, settings);
	}

	settings->OsMajorType = OSMAJORTYPE_WINDOWS;
	settings->OsMinorType = OSMINORTYPE_WINDOWS_NT;
	settings->OrderSupport[NEG_DSTBLT_INDEX] = TRUE;
	settings->OrderSupport[NEG_PATBLT_INDEX] = TRUE;
	settings->OrderSupport[NEG_SCRBLT_INDEX] = TRUE;
	settings->OrderSupport[NEG_OPAQUE_RECT_INDEX] = TRUE;
	settings->OrderSupport[NEG_DRAWNINEGRID_INDEX] = FALSE;
	settings->OrderSupport[NEG_MULTIDSTBLT_INDEX] = FALSE;
	settings->OrderSupport[NEG_MULTIPATBLT_INDEX] = FALSE;
	settings->OrderSupport[NEG_MULTISCRBLT_INDEX] = FALSE;
	settings->OrderSupport[NEG_MULTIOPAQUERECT_INDEX] = TRUE;
	settings->OrderSupport[NEG_MULTI_DRAWNINEGRID_INDEX] = FALSE;
	settings->OrderSupport[NEG_LINETO_INDEX] = TRUE;
	settings->OrderSupport[NEG_POLYLINE_INDEX] = TRUE;
	settings->OrderSupport[NEG_MEMBLT_INDEX] = TRUE;
	settings->OrderSupport[NEG_MEM3BLT_INDEX] = FALSE;
	settings->OrderSupport[NEG_SAVEBITMAP_INDEX] = FALSE;
	settings->OrderSupport[NEG_GLYPH_INDEX_INDEX] = FALSE;
	settings->OrderSupport[NEG_FAST_INDEX_INDEX] = FALSE;
	settings->OrderSupport[NEG_FAST_GLYPH_INDEX] = FALSE;
	settings->OrderSupport[NEG_POLYGON_SC_INDEX] = FALSE;
	settings->OrderSupport[NEG_POLYGON_CB_INDEX] = FALSE;
	settings->OrderSupport[NEG_ELLIPSE_SC_INDEX] = FALSE;
	settings->OrderSupport[NEG_ELLIPSE_CB_INDEX] = FALSE;

	settings->GlyphSupportLevel = GLYPH_SUPPORT_NONE;

	wfc->fullscreen = settings->Fullscreen;
	wfc->fs_toggle = 1;
	wfc->sw_gdi = settings->SoftwareGdi;

	wfc->clrconv = (HCLRCONV) malloc(sizeof(CLRCONV));
	ZeroMemory(wfc->clrconv, sizeof(CLRCONV));

	wfc->clrconv->palette = NULL;
	wfc->clrconv->alpha = FALSE;

	instance->context->cache = cache_new(settings);

	desktopWidth = settings->DesktopWidth;
	desktopHeight = settings->DesktopHeight;

	if (wfc->percentscreen > 0)
	{
		desktopWidth = (GetSystemMetrics(SM_CXSCREEN) * wfc->percentscreen) / 100;
		settings->DesktopWidth = desktopWidth;

		desktopHeight = (GetSystemMetrics(SM_CYSCREEN) * wfc->percentscreen) / 100;
		settings->DesktopHeight = desktopHeight;
	}
	
	if (wfc->fullscreen)
	{
		if (settings->UseMultimon)
		{
			settings->DesktopWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
			settings->DesktopHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
		}
		else
		{
			settings->DesktopWidth = GetSystemMetrics(SM_CXSCREEN);
			settings->DesktopHeight = GetSystemMetrics(SM_CYSCREEN);
		}
	}

	desktopWidth = (desktopWidth + 3) & (~3);

	if (desktopWidth != settings->DesktopWidth)
	{
		freerdp_set_param_uint32(settings, FreeRDP_DesktopWidth, desktopWidth);
	}

	if (desktopHeight != settings->DesktopHeight)
	{
		freerdp_set_param_uint32(settings, FreeRDP_DesktopHeight, desktopHeight);
	}

	if ((settings->DesktopWidth < 64) || (settings->DesktopHeight < 64) ||
		(settings->DesktopWidth > 4096) || (settings->DesktopHeight > 4096))
	{
		fprintf(stderr, "wf_pre_connect: invalid dimensions %d %d\n", settings->DesktopWidth, settings->DesktopHeight);
		return 1;
	}

	freerdp_set_param_uint32(settings, FreeRDP_KeyboardLayout, (int) GetKeyboardLayout(0) & 0x0000FFFF);
	freerdp_channels_pre_connect(instance->context->channels, instance);

	return TRUE;
}