20#include <freerdp/config.h>
26#include <winpr/string.h>
27#include <winpr/file.h>
28#include <winpr/cast.h>
30#include <freerdp/client.h>
31#include <freerdp/client/file.h>
32#include <freerdp/client/cmdline.h>
34#include <freerdp/channels/urbdrc.h>
35#include <freerdp/channels/rdpecam.h>
36#include <freerdp/channels/location.h>
51#include <winpr/wtypes.h>
53#include <winpr/path.h>
54#include <freerdp/log.h>
55#define TAG CLIENT_TAG("common")
59static const BYTE BOM_UTF16_LE[2] = { 0xFF, 0xFE };
63#define RDP_FILE_LINE_FLAG_FORMATTED 0x00000001
65#define RDP_FILE_LINE_FLAG_TYPE_STRING 0x00000010
66#define RDP_FILE_LINE_FLAG_TYPE_INTEGER 0x00000020
81typedef struct rdp_file_line rdpFileLine;
86 LPSTR SelectedMonitors;
87 DWORD MaximizeToCurrentDisplays;
88 DWORD SingleMonInWindowedMode;
92 DWORD DynamicResolution;
93 DWORD EnableSuperSpan;
94 DWORD SuperSpanAccelerationFactor;
100 DWORD DesktopScaleFactor;
104 DWORD DisableCtrlAltDel;
107 DWORD AudioQualityMode;
108 DWORD AudioCaptureMode;
109 DWORD EncodeRedirectedVideoCapture;
110 DWORD RedirectedVideoCaptureEncodingQuality;
111 DWORD VideoPlaybackMode;
113 DWORD ConnectionType;
115 DWORD NetworkAutoDetect;
116 DWORD BandwidthAutoDetect;
118 DWORD PinConnectionBar;
119 DWORD DisplayConnectionBar;
122 DWORD EnableWorkspaceReconnect;
124 DWORD DisableWallpaper;
125 DWORD AllowFontSmoothing;
126 DWORD AllowDesktopComposition;
127 DWORD DisableFullWindowDrag;
128 DWORD DisableMenuAnims;
130 DWORD DisableCursorSetting;
132 DWORD BitmapCacheSize;
133 DWORD BitmapCachePersistEnable;
143 LPSTR AlternateFullAddress;
145 LPSTR UsbDevicesToRedirect;
146 DWORD RedirectDrives;
147 DWORD RedirectPrinters;
148 DWORD RedirectComPorts;
149 DWORD RedirectLocation;
150 DWORD RedirectSmartCards;
151 DWORD RedirectWebauthN;
152 LPSTR RedirectCameras;
153 DWORD RedirectClipboard;
154 DWORD RedirectPosDevices;
155 DWORD RedirectDirectX;
156 DWORD DisablePrinterRedirection;
157 DWORD DisableClipboardRedirection;
159 DWORD ConnectToConsole;
160 DWORD AdministrativeSession;
161 DWORD AutoReconnectionEnabled;
162 DWORD AutoReconnectMaxRetries;
165 DWORD AuthenticationLevel;
166 DWORD PromptCredentialOnce;
167 DWORD PromptForCredentials;
168 DWORD NegotiateSecurityLayer;
169 DWORD EnableCredSSPSupport;
170 DWORD EnableRdsAadAuth;
172 DWORD RemoteApplicationMode;
173 LPSTR LoadBalanceInfo;
175 LPSTR RemoteApplicationName;
176 LPSTR RemoteApplicationIcon;
177 LPSTR RemoteApplicationProgram;
178 LPSTR RemoteApplicationFile;
179 LPSTR RemoteApplicationGuid;
180 LPSTR RemoteApplicationCmdLine;
181 DWORD RemoteApplicationExpandCmdLine;
182 DWORD RemoteApplicationExpandWorkingDir;
183 DWORD DisableConnectionSharing;
184 DWORD DisableRemoteAppCapsCheck;
186 LPSTR AlternateShell;
187 LPSTR ShellWorkingDirectory;
189 LPSTR GatewayHostname;
190 DWORD GatewayUsageMethod;
191 DWORD GatewayProfileUsageMethod;
192 DWORD GatewayCredentialsSource;
194 LPSTR ResourceProvider;
196 LPSTR WvdEndpointPool;
200 LPSTR diagnosticserviceurl;
201 LPSTR hubdiscoverygeourl;
204 DWORD UseRedirectionServerName;
206 LPSTR GatewayAccessToken;
208 LPSTR DrivesToRedirect;
209 LPSTR DevicesToRedirect;
212 LPSTR PreconnectionBlob;
229static const char key_str_username[] =
"username";
230static const char key_str_domain[] =
"domain";
231static const char key_str_password[] =
"password";
232static const char key_str_full_address[] =
"full address";
233static const char key_str_alternate_full_address[] =
"alternate full address";
234static const char key_str_usbdevicestoredirect[] =
"usbdevicestoredirect";
235static const char key_str_camerastoredirect[] =
"camerastoredirect";
236static const char key_str_loadbalanceinfo[] =
"loadbalanceinfo";
237static const char key_str_remoteapplicationname[] =
"remoteapplicationname";
238static const char key_str_remoteapplicationicon[] =
"remoteapplicationicon";
239static const char key_str_remoteapplicationprogram[] =
"remoteapplicationprogram";
240static const char key_str_remoteapplicationfile[] =
"remoteapplicationfile";
241static const char key_str_remoteapplicationguid[] =
"remoteapplicationguid";
242static const char key_str_remoteapplicationcmdline[] =
"remoteapplicationcmdline";
243static const char key_str_alternate_shell[] =
"alternate shell";
244static const char key_str_shell_working_directory[] =
"shell working directory";
245static const char key_str_gatewayhostname[] =
"gatewayhostname";
246static const char key_str_gatewayaccesstoken[] =
"gatewayaccesstoken";
247static const char key_str_resourceprovider[] =
"resourceprovider";
248static const char str_resourceprovider_arm[] =
"arm";
249static const char key_str_kdcproxyname[] =
"kdcproxyname";
250static const char key_str_drivestoredirect[] =
"drivestoredirect";
251static const char key_str_devicestoredirect[] =
"devicestoredirect";
252static const char key_str_winposstr[] =
"winposstr";
253static const char key_str_pcb[] =
"pcb";
254static const char key_str_selectedmonitors[] =
"selectedmonitors";
256static const char key_str_wvd[] =
"wvd endpoint pool";
257static const char key_str_geo[] =
"geo";
258static const char key_str_armpath[] =
"armpath";
259static const char key_str_aadtenantid[] =
"aadtenantid";
261static const char key_str_diagnosticserviceurl[] =
"diagnosticserviceurl";
262static const char key_str_hubdiscoverygeourl[] =
"hubdiscoverygeourl";
264static const char key_str_activityhint[] =
"activityhint";
266static const char key_int_rdgiskdcproxy[] =
"rdgiskdcproxy";
267static const char key_int_use_redirection_server_name[] =
"use redirection server name";
268static const char key_int_gatewaycredentialssource[] =
"gatewaycredentialssource";
269static const char key_int_gatewayprofileusagemethod[] =
"gatewayprofileusagemethod";
270static const char key_int_gatewayusagemethod[] =
"gatewayusagemethod";
271static const char key_int_disableremoteappcapscheck[] =
"disableremoteappcapscheck";
272static const char key_int_disableconnectionsharing[] =
"disableconnectionsharing";
273static const char key_int_remoteapplicationexpandworkingdir[] =
"remoteapplicationexpandworkingdir";
274static const char key_int_remoteapplicationexpandcmdline[] =
"remoteapplicationexpandcmdline";
275static const char key_int_remoteapplicationmode[] =
"remoteapplicationmode";
276static const char key_int_enablecredsspsupport[] =
"enablecredsspsupport";
277static const char key_int_enablerdsaadauth[] =
"enablerdsaadauth";
278static const char key_int_negotiate_security_layer[] =
"negotiate security layer";
279static const char key_int_prompt_for_credentials[] =
"prompt for credentials";
280static const char key_int_promptcredentialonce[] =
"promptcredentialonce";
281static const char key_int_authentication_level[] =
"authentication level";
282static const char key_int_public_mode[] =
"public mode";
283static const char key_int_autoreconnect_max_retries[] =
"autoreconnect max retries";
284static const char key_int_autoreconnection_enabled[] =
"autoreconnection enabled";
285static const char key_int_administrative_session[] =
"administrative session";
286static const char key_int_connect_to_console[] =
"connect to console";
287static const char key_int_disableclipboardredirection[] =
"disableclipboardredirection";
288static const char key_int_disableprinterredirection[] =
"disableprinterredirection";
289static const char key_int_redirectdirectx[] =
"redirectdirectx";
290static const char key_int_redirectposdevices[] =
"redirectposdevices";
291static const char key_int_redirectclipboard[] =
"redirectclipboard";
292static const char key_int_redirectsmartcards[] =
"redirectsmartcards";
293static const char key_int_redirectcomports[] =
"redirectcomports";
294static const char key_int_redirectlocation[] =
"redirectlocation";
295static const char key_int_redirectprinters[] =
"redirectprinters";
296static const char key_int_redirectdrives[] =
"redirectdrives";
297static const char key_int_server_port[] =
"server port";
298static const char key_int_bitmapcachepersistenable[] =
"bitmapcachepersistenable";
299static const char key_int_bitmapcachesize[] =
"bitmapcachesize";
300static const char key_int_disable_cursor_setting[] =
"disable cursor setting";
301static const char key_int_disable_themes[] =
"disable themes";
302static const char key_int_disable_menu_anims[] =
"disable menu anims";
303static const char key_int_disable_full_window_drag[] =
"disable full window drag";
304static const char key_int_allow_desktop_composition[] =
"allow desktop composition";
305static const char key_int_allow_font_smoothing[] =
"allow font smoothing";
306static const char key_int_disable_wallpaper[] =
"disable wallpaper";
307static const char key_int_enableworkspacereconnect[] =
"enableworkspacereconnect";
308static const char key_int_workspaceid[] =
"workspaceid";
309static const char key_int_displayconnectionbar[] =
"displayconnectionbar";
310static const char key_int_pinconnectionbar[] =
"pinconnectionbar";
311static const char key_int_bandwidthautodetect[] =
"bandwidthautodetect";
312static const char key_int_networkautodetect[] =
"networkautodetect";
313static const char key_int_connection_type[] =
"connection type";
314static const char key_int_videoplaybackmode[] =
"videoplaybackmode";
315static const char key_int_redirected_video_capture_encoding_quality[] =
316 "redirected video capture encoding quality";
317static const char key_int_encode_redirected_video_capture[] =
"encode redirected video capture";
318static const char key_int_audiocapturemode[] =
"audiocapturemode";
319static const char key_int_audioqualitymode[] =
"audioqualitymode";
320static const char key_int_audiomode[] =
"audiomode";
321static const char key_int_disable_ctrl_alt_del[] =
"disable ctrl+alt+del";
322static const char key_int_keyboardhook[] =
"keyboardhook";
323static const char key_int_compression[] =
"compression";
324static const char key_int_desktopscalefactor[] =
"desktopscalefactor";
325static const char key_int_session_bpp[] =
"session bpp";
326static const char key_int_desktop_size_id[] =
"desktop size id";
327static const char key_int_desktopheight[] =
"desktopheight";
328static const char key_int_desktopwidth[] =
"desktopwidth";
329static const char key_int_superpanaccelerationfactor[] =
"superpanaccelerationfactor";
330static const char key_int_enablesuperpan[] =
"enablesuperpan";
331static const char key_int_dynamic_resolution[] =
"dynamic resolution";
332static const char key_int_smart_sizing[] =
"smart sizing";
333static const char key_int_span_monitors[] =
"span monitors";
334static const char key_int_screen_mode_id[] =
"screen mode id";
335static const char key_int_singlemoninwindowedmode[] =
"singlemoninwindowedmode";
336static const char key_int_maximizetocurrentdisplays[] =
"maximizetocurrentdisplays";
337static const char key_int_use_multimon[] =
"use multimon";
338static const char key_int_redirectwebauthn[] =
"redirectwebauthn";
340static BOOL utils_str_is_empty(
const char* str)
344 if (strlen(str) == 0)
349static SSIZE_T freerdp_client_rdp_file_add_line(rdpFile* file);
350static rdpFileLine* freerdp_client_rdp_file_find_line_by_name(
const rdpFile* file,
352static void freerdp_client_file_string_check_free(LPSTR str);
354static BOOL freerdp_client_rdp_file_find_integer_entry(rdpFile* file,
const char* name,
355 DWORD** outValue, rdpFileLine** outLine)
359 WINPR_ASSERT(outValue);
360 WINPR_ASSERT(outLine);
365 if (_stricmp(name, key_int_use_multimon) == 0)
366 *outValue = &file->UseMultiMon;
367 else if (_stricmp(name, key_int_maximizetocurrentdisplays) == 0)
368 *outValue = &file->MaximizeToCurrentDisplays;
369 else if (_stricmp(name, key_int_singlemoninwindowedmode) == 0)
370 *outValue = &file->SingleMonInWindowedMode;
371 else if (_stricmp(name, key_int_screen_mode_id) == 0)
372 *outValue = &file->ScreenModeId;
373 else if (_stricmp(name, key_int_span_monitors) == 0)
374 *outValue = &file->SpanMonitors;
375 else if (_stricmp(name, key_int_smart_sizing) == 0)
376 *outValue = &file->SmartSizing;
377 else if (_stricmp(name, key_int_dynamic_resolution) == 0)
378 *outValue = &file->DynamicResolution;
379 else if (_stricmp(name, key_int_enablesuperpan) == 0)
380 *outValue = &file->EnableSuperSpan;
381 else if (_stricmp(name, key_int_superpanaccelerationfactor) == 0)
382 *outValue = &file->SuperSpanAccelerationFactor;
383 else if (_stricmp(name, key_int_desktopwidth) == 0)
384 *outValue = &file->DesktopWidth;
385 else if (_stricmp(name, key_int_desktopheight) == 0)
386 *outValue = &file->DesktopHeight;
387 else if (_stricmp(name, key_int_desktop_size_id) == 0)
388 *outValue = &file->DesktopSizeId;
389 else if (_stricmp(name, key_int_session_bpp) == 0)
390 *outValue = &file->SessionBpp;
391 else if (_stricmp(name, key_int_desktopscalefactor) == 0)
392 *outValue = &file->DesktopScaleFactor;
393 else if (_stricmp(name, key_int_compression) == 0)
394 *outValue = &file->Compression;
395 else if (_stricmp(name, key_int_keyboardhook) == 0)
396 *outValue = &file->KeyboardHook;
397 else if (_stricmp(name, key_int_disable_ctrl_alt_del) == 0)
398 *outValue = &file->DisableCtrlAltDel;
399 else if (_stricmp(name, key_int_audiomode) == 0)
400 *outValue = &file->AudioMode;
401 else if (_stricmp(name, key_int_audioqualitymode) == 0)
402 *outValue = &file->AudioQualityMode;
403 else if (_stricmp(name, key_int_audiocapturemode) == 0)
404 *outValue = &file->AudioCaptureMode;
405 else if (_stricmp(name, key_int_encode_redirected_video_capture) == 0)
406 *outValue = &file->EncodeRedirectedVideoCapture;
407 else if (_stricmp(name, key_int_redirected_video_capture_encoding_quality) == 0)
408 *outValue = &file->RedirectedVideoCaptureEncodingQuality;
409 else if (_stricmp(name, key_int_videoplaybackmode) == 0)
410 *outValue = &file->VideoPlaybackMode;
411 else if (_stricmp(name, key_int_connection_type) == 0)
412 *outValue = &file->ConnectionType;
413 else if (_stricmp(name, key_int_networkautodetect) == 0)
414 *outValue = &file->NetworkAutoDetect;
415 else if (_stricmp(name, key_int_bandwidthautodetect) == 0)
416 *outValue = &file->BandwidthAutoDetect;
417 else if (_stricmp(name, key_int_pinconnectionbar) == 0)
418 *outValue = &file->PinConnectionBar;
419 else if (_stricmp(name, key_int_displayconnectionbar) == 0)
420 *outValue = &file->DisplayConnectionBar;
421 else if (_stricmp(name, key_int_workspaceid) == 0)
422 *outValue = &file->WorkspaceId;
423 else if (_stricmp(name, key_int_enableworkspacereconnect) == 0)
424 *outValue = &file->EnableWorkspaceReconnect;
425 else if (_stricmp(name, key_int_disable_wallpaper) == 0)
426 *outValue = &file->DisableWallpaper;
427 else if (_stricmp(name, key_int_allow_font_smoothing) == 0)
428 *outValue = &file->AllowFontSmoothing;
429 else if (_stricmp(name, key_int_allow_desktop_composition) == 0)
430 *outValue = &file->AllowDesktopComposition;
431 else if (_stricmp(name, key_int_disable_full_window_drag) == 0)
432 *outValue = &file->DisableFullWindowDrag;
433 else if (_stricmp(name, key_int_disable_menu_anims) == 0)
434 *outValue = &file->DisableMenuAnims;
435 else if (_stricmp(name, key_int_disable_themes) == 0)
436 *outValue = &file->DisableThemes;
437 else if (_stricmp(name, key_int_disable_cursor_setting) == 0)
438 *outValue = &file->DisableCursorSetting;
439 else if (_stricmp(name, key_int_bitmapcachesize) == 0)
440 *outValue = &file->BitmapCacheSize;
441 else if (_stricmp(name, key_int_bitmapcachepersistenable) == 0)
442 *outValue = &file->BitmapCachePersistEnable;
443 else if (_stricmp(name, key_int_server_port) == 0)
444 *outValue = &file->ServerPort;
445 else if (_stricmp(name, key_int_redirectdrives) == 0)
446 *outValue = &file->RedirectDrives;
447 else if (_stricmp(name, key_int_redirectprinters) == 0)
448 *outValue = &file->RedirectPrinters;
449 else if (_stricmp(name, key_int_redirectcomports) == 0)
450 *outValue = &file->RedirectComPorts;
451 else if (_stricmp(name, key_int_redirectlocation) == 0)
452 *outValue = &file->RedirectLocation;
453 else if (_stricmp(name, key_int_redirectsmartcards) == 0)
454 *outValue = &file->RedirectSmartCards;
455 else if (_stricmp(name, key_int_redirectclipboard) == 0)
456 *outValue = &file->RedirectClipboard;
457 else if (_stricmp(name, key_int_redirectposdevices) == 0)
458 *outValue = &file->RedirectPosDevices;
459 else if (_stricmp(name, key_int_redirectdirectx) == 0)
460 *outValue = &file->RedirectDirectX;
461 else if (_stricmp(name, key_int_disableprinterredirection) == 0)
462 *outValue = &file->DisablePrinterRedirection;
463 else if (_stricmp(name, key_int_disableclipboardredirection) == 0)
464 *outValue = &file->DisableClipboardRedirection;
465 else if (_stricmp(name, key_int_connect_to_console) == 0)
466 *outValue = &file->ConnectToConsole;
467 else if (_stricmp(name, key_int_administrative_session) == 0)
468 *outValue = &file->AdministrativeSession;
469 else if (_stricmp(name, key_int_autoreconnection_enabled) == 0)
470 *outValue = &file->AutoReconnectionEnabled;
471 else if (_stricmp(name, key_int_autoreconnect_max_retries) == 0)
472 *outValue = &file->AutoReconnectMaxRetries;
473 else if (_stricmp(name, key_int_public_mode) == 0)
474 *outValue = &file->PublicMode;
475 else if (_stricmp(name, key_int_authentication_level) == 0)
476 *outValue = &file->AuthenticationLevel;
477 else if (_stricmp(name, key_int_promptcredentialonce) == 0)
478 *outValue = &file->PromptCredentialOnce;
479 else if ((_stricmp(name, key_int_prompt_for_credentials) == 0))
480 *outValue = &file->PromptForCredentials;
481 else if (_stricmp(name, key_int_negotiate_security_layer) == 0)
482 *outValue = &file->NegotiateSecurityLayer;
483 else if (_stricmp(name, key_int_enablecredsspsupport) == 0)
484 *outValue = &file->EnableCredSSPSupport;
485 else if (_stricmp(name, key_int_enablerdsaadauth) == 0)
486 *outValue = &file->EnableRdsAadAuth;
487 else if (_stricmp(name, key_int_remoteapplicationmode) == 0)
488 *outValue = &file->RemoteApplicationMode;
489 else if (_stricmp(name, key_int_remoteapplicationexpandcmdline) == 0)
490 *outValue = &file->RemoteApplicationExpandCmdLine;
491 else if (_stricmp(name, key_int_remoteapplicationexpandworkingdir) == 0)
492 *outValue = &file->RemoteApplicationExpandWorkingDir;
493 else if (_stricmp(name, key_int_disableconnectionsharing) == 0)
494 *outValue = &file->DisableConnectionSharing;
495 else if (_stricmp(name, key_int_disableremoteappcapscheck) == 0)
496 *outValue = &file->DisableRemoteAppCapsCheck;
497 else if (_stricmp(name, key_int_gatewayusagemethod) == 0)
498 *outValue = &file->GatewayUsageMethod;
499 else if (_stricmp(name, key_int_gatewayprofileusagemethod) == 0)
500 *outValue = &file->GatewayProfileUsageMethod;
501 else if (_stricmp(name, key_int_gatewaycredentialssource) == 0)
502 *outValue = &file->GatewayCredentialsSource;
503 else if (_stricmp(name, key_int_use_redirection_server_name) == 0)
504 *outValue = &file->UseRedirectionServerName;
505 else if (_stricmp(name, key_int_rdgiskdcproxy) == 0)
506 *outValue = &file->RdgIsKdcProxy;
507 else if (_stricmp(name, key_int_redirectwebauthn) == 0)
508 *outValue = &file->RedirectWebauthN;
511 rdpFileLine* line = freerdp_client_rdp_file_find_line_by_name(file, name);
514 if (!(line->flags & RDP_FILE_LINE_FLAG_TYPE_INTEGER))
523static BOOL freerdp_client_rdp_file_find_string_entry(rdpFile* file,
const char* name,
524 LPSTR** outValue, rdpFileLine** outLine)
528 WINPR_ASSERT(outValue);
529 WINPR_ASSERT(outLine);
534 if (_stricmp(name, key_str_username) == 0)
535 *outValue = &file->Username;
536 else if (_stricmp(name, key_str_domain) == 0)
537 *outValue = &file->Domain;
538 else if (_stricmp(name, key_str_password) == 0)
539 *outValue = &file->Password;
540 else if (_stricmp(name, key_str_full_address) == 0)
541 *outValue = &file->FullAddress;
542 else if (_stricmp(name, key_str_alternate_full_address) == 0)
543 *outValue = &file->AlternateFullAddress;
544 else if (_stricmp(name, key_str_usbdevicestoredirect) == 0)
545 *outValue = &file->UsbDevicesToRedirect;
546 else if (_stricmp(name, key_str_camerastoredirect) == 0)
547 *outValue = &file->RedirectCameras;
548 else if (_stricmp(name, key_str_loadbalanceinfo) == 0)
549 *outValue = &file->LoadBalanceInfo;
550 else if (_stricmp(name, key_str_remoteapplicationname) == 0)
551 *outValue = &file->RemoteApplicationName;
552 else if (_stricmp(name, key_str_remoteapplicationicon) == 0)
553 *outValue = &file->RemoteApplicationIcon;
554 else if (_stricmp(name, key_str_remoteapplicationprogram) == 0)
555 *outValue = &file->RemoteApplicationProgram;
556 else if (_stricmp(name, key_str_remoteapplicationfile) == 0)
557 *outValue = &file->RemoteApplicationFile;
558 else if (_stricmp(name, key_str_remoteapplicationguid) == 0)
559 *outValue = &file->RemoteApplicationGuid;
560 else if (_stricmp(name, key_str_remoteapplicationcmdline) == 0)
561 *outValue = &file->RemoteApplicationCmdLine;
562 else if (_stricmp(name, key_str_alternate_shell) == 0)
563 *outValue = &file->AlternateShell;
564 else if (_stricmp(name, key_str_shell_working_directory) == 0)
565 *outValue = &file->ShellWorkingDirectory;
566 else if (_stricmp(name, key_str_gatewayhostname) == 0)
567 *outValue = &file->GatewayHostname;
568 else if (_stricmp(name, key_str_resourceprovider) == 0)
569 *outValue = &file->ResourceProvider;
570 else if (_stricmp(name, key_str_wvd) == 0)
571 *outValue = &file->WvdEndpointPool;
572 else if (_stricmp(name, key_str_geo) == 0)
573 *outValue = &file->geo;
574 else if (_stricmp(name, key_str_armpath) == 0)
575 *outValue = &file->armpath;
576 else if (_stricmp(name, key_str_aadtenantid) == 0)
577 *outValue = &file->aadtenantid;
578 else if (_stricmp(name, key_str_diagnosticserviceurl) == 0)
579 *outValue = &file->diagnosticserviceurl;
580 else if (_stricmp(name, key_str_hubdiscoverygeourl) == 0)
581 *outValue = &file->hubdiscoverygeourl;
582 else if (_stricmp(name, key_str_activityhint) == 0)
583 *outValue = &file->activityhint;
584 else if (_stricmp(name, key_str_gatewayaccesstoken) == 0)
585 *outValue = &file->GatewayAccessToken;
586 else if (_stricmp(name, key_str_kdcproxyname) == 0)
587 *outValue = &file->KdcProxyName;
588 else if (_stricmp(name, key_str_drivestoredirect) == 0)
589 *outValue = &file->DrivesToRedirect;
590 else if (_stricmp(name, key_str_devicestoredirect) == 0)
591 *outValue = &file->DevicesToRedirect;
592 else if (_stricmp(name, key_str_winposstr) == 0)
593 *outValue = &file->WinPosStr;
594 else if (_stricmp(name, key_str_pcb) == 0)
595 *outValue = &file->PreconnectionBlob;
596 else if (_stricmp(name, key_str_selectedmonitors) == 0)
597 *outValue = &file->SelectedMonitors;
600 rdpFileLine* line = freerdp_client_rdp_file_find_line_by_name(file, name);
603 if (!(line->flags & RDP_FILE_LINE_FLAG_TYPE_STRING))
618static BOOL freerdp_client_rdp_file_set_integer(rdpFile* file,
const char* name,
long value)
620 DWORD* targetValue = NULL;
621 rdpFileLine* line = NULL;
622#ifdef DEBUG_CLIENT_FILE
623 WLog_DBG(TAG,
"%s:i:%ld", name, value);
629 if (!freerdp_client_rdp_file_find_integer_entry(file, name, &targetValue, &line))
631 SSIZE_T index = freerdp_client_rdp_file_add_line(file);
634 line = &file->lines[index];
639 *targetValue = (DWORD)value;
646 line->name = _strdup(name);
654 line->iValue = value;
655 line->flags = RDP_FILE_LINE_FLAG_FORMATTED;
656 line->flags |= RDP_FILE_LINE_FLAG_TYPE_INTEGER;
657 line->valueLength = 0;
664static BOOL freerdp_client_parse_rdp_file_integer(rdpFile* file,
const char* name,
670 ivalue = strtol(value, &endptr, 0);
672 if ((endptr == NULL) || (errno != 0) || (endptr == value) || (ivalue > INT32_MAX) ||
673 (ivalue < INT32_MIN))
675 if (file->flags & RDP_FILE_FLAG_PARSE_INT_RELAXED)
677 WLog_WARN(TAG,
"Integer option %s has invalid value %s, using default", name, value);
682 WLog_ERR(TAG,
"Failed to convert RDP file integer option %s [value=%s]", name, value);
687 return freerdp_client_rdp_file_set_integer(file, name, ivalue);
698static BOOL freerdp_client_rdp_file_set_string(rdpFile* file,
const char* name,
const char* value)
700 LPSTR* targetValue = NULL;
701 rdpFileLine* line = NULL;
702#ifdef DEBUG_CLIENT_FILE
703 WLog_DBG(TAG,
"%s:s:%s", name, value);
709 if (!freerdp_client_rdp_file_find_string_entry(file, name, &targetValue, &line))
711 SSIZE_T index = freerdp_client_rdp_file_add_line(file);
714 line = &file->lines[index];
719 *targetValue = _strdup(value);
729 line->name = _strdup(name);
730 line->sValue = _strdup(value);
731 if (!line->name || !line->sValue)
740 line->flags = RDP_FILE_LINE_FLAG_FORMATTED;
741 line->flags |= RDP_FILE_LINE_FLAG_TYPE_STRING;
742 line->valueLength = 0;
749static BOOL freerdp_client_add_option(rdpFile* file,
const char* option)
751 return freerdp_addin_argv_add_argument(file->args, option);
754static SSIZE_T freerdp_client_rdp_file_add_line(rdpFile* file)
756 SSIZE_T index = (SSIZE_T)file->lineCount;
758 while ((file->lineCount + 1) > file->lineSize)
760 size_t new_size = file->lineCount + 2048;
761 rdpFileLine* new_line = (rdpFileLine*)realloc(file->lines, new_size *
sizeof(rdpFileLine));
766 file->lines = new_line;
767 file->lineSize = new_size;
770 ZeroMemory(&(file->lines[file->lineCount]),
sizeof(rdpFileLine));
771 file->lines[file->lineCount].index = (size_t)index;
776static BOOL freerdp_client_parse_rdp_file_string(rdpFile* file,
char* name,
char* value)
778 return freerdp_client_rdp_file_set_string(file, name, value);
781static BOOL freerdp_client_parse_rdp_file_option(rdpFile* file,
const char* option)
783 return freerdp_client_add_option(file, option);
786BOOL freerdp_client_parse_rdp_file_buffer(rdpFile* file,
const BYTE* buffer,
size_t size)
788 return freerdp_client_parse_rdp_file_buffer_ex(file, buffer, size, NULL);
791static BOOL trim(
char** strptr)
797 start = str = *strptr;
800 if (!(~((
size_t)str)))
802 end = str + strlen(str) - 1;
804 while (isspace(*str))
807 while ((end > str) && isspace(*end))
814 *strptr = _strdup(str);
816 return *strptr != NULL;
822static BOOL trim_strings(rdpFile* file)
824 if (!trim(&file->Username))
826 if (!trim(&file->Domain))
828 if (!trim(&file->AlternateFullAddress))
830 if (!trim(&file->FullAddress))
832 if (!trim(&file->UsbDevicesToRedirect))
834 if (!trim(&file->RedirectCameras))
836 if (!trim(&file->LoadBalanceInfo))
838 if (!trim(&file->GatewayHostname))
840 if (!trim(&file->GatewayAccessToken))
842 if (!trim(&file->RemoteApplicationName))
844 if (!trim(&file->RemoteApplicationIcon))
846 if (!trim(&file->RemoteApplicationProgram))
848 if (!trim(&file->RemoteApplicationFile))
850 if (!trim(&file->RemoteApplicationGuid))
852 if (!trim(&file->RemoteApplicationCmdLine))
854 if (!trim(&file->AlternateShell))
856 if (!trim(&file->ShellWorkingDirectory))
858 if (!trim(&file->DrivesToRedirect))
860 if (!trim(&file->DevicesToRedirect))
862 if (!trim(&file->DevicesToRedirect))
864 if (!trim(&file->WinPosStr))
866 if (!trim(&file->PreconnectionBlob))
868 if (!trim(&file->KdcProxyName))
870 if (!trim(&file->SelectedMonitors))
873 for (
size_t i = 0; i < file->lineCount; ++i)
875 rdpFileLine* curLine = &file->lines[i];
876 if (curLine->flags & RDP_FILE_LINE_FLAG_TYPE_STRING)
878 if (!trim(&curLine->sValue))
886BOOL freerdp_client_parse_rdp_file_buffer_ex(rdpFile* file,
const BYTE* buffer,
size_t size,
887 rdp_file_fkt_parse parse)
893 char* context = NULL;
906 if ((buffer[0] == BOM_UTF16_LE[0]) && (buffer[1] == BOM_UTF16_LE[1]))
908 LPCWSTR uc = (LPCWSTR)(&buffer[2]);
909 size = size /
sizeof(WCHAR) - 1;
911 copy = ConvertWCharNToUtf8Alloc(uc, size, NULL);
914 WLog_ERR(TAG,
"Failed to convert RDP file from UCS2 to UTF8");
920 copy = calloc(1, size +
sizeof(BYTE));
925 memcpy(copy, buffer, size);
928 line = strtok_s(copy,
"\r\n", &context);
932 length = strnlen(line, size);
939 if (!freerdp_client_parse_rdp_file_option(file, line))
945 d1 = strchr(line,
':');
951 d2 = strchr(type,
':');
964 if (parse && parse(file->context, name, *type, value))
967 else if (*type ==
'i')
970 if (!freerdp_client_parse_rdp_file_integer(file, name, value))
973 else if (*type ==
's')
976 if (!freerdp_client_parse_rdp_file_string(file, name, value))
979 else if (*type ==
'b')
982 WLog_ERR(TAG,
"Unsupported RDP file binary option %s [value=%s]", name, value);
987 line = strtok_s(NULL,
"\r\n", &context);
990 rc = trim_strings(file);
996BOOL freerdp_client_parse_rdp_file(rdpFile* file,
const char* name)
998 return freerdp_client_parse_rdp_file_ex(file, name, NULL);
1001BOOL freerdp_client_parse_rdp_file_ex(rdpFile* file,
const char* name, rdp_file_fkt_parse parse)
1004 BYTE* buffer = NULL;
1006 size_t read_size = 0;
1007 INT64 file_size = 0;
1008 const char* fname = name;
1013 if (_strnicmp(fname,
"file://", 7) == 0)
1016 fp = winpr_fopen(fname,
"r");
1019 WLog_ERR(TAG,
"Failed to open RDP file %s", name);
1023 (void)_fseeki64(fp, 0, SEEK_END);
1024 file_size = _ftelli64(fp);
1025 (void)_fseeki64(fp, 0, SEEK_SET);
1029 WLog_ERR(TAG,
"RDP file %s is empty", name);
1034 buffer = (BYTE*)malloc((
size_t)file_size + 2);
1042 read_size = fread(buffer, (
size_t)file_size, 1, fp);
1047 read_size = (size_t)file_size;
1054 WLog_ERR(TAG,
"Could not read from RDP file %s", name);
1059 buffer[file_size] =
'\0';
1060 buffer[file_size + 1] =
'\0';
1061 status = freerdp_client_parse_rdp_file_buffer_ex(file, buffer, (
size_t)file_size, parse);
1066static INLINE
void freerdp_client_file_string_reset(
char** target)
1068 WINPR_ASSERT(target);
1069 freerdp_client_file_string_check_free(*target);
1070 *target = (
void*)~((
size_t)NULL);
1073static INLINE BOOL FILE_POPULATE_STRING(
char** _target,
const rdpSettings* _settings,
1074 FreeRDP_Settings_Keys_String _option)
1076 WINPR_ASSERT(_target);
1077 WINPR_ASSERT(_settings);
1080 freerdp_client_file_string_reset(_target);
1083 char* copy = _strdup(str);
1091static char* freerdp_client_channel_args_to_string(
const rdpSettings* settings,
const char* channel,
1094 ADDIN_ARGV* args = freerdp_dynamic_channel_collection_find(settings, channel);
1095 const char* filters[] = { option };
1096 if (!args || (args->argc < 2))
1099 return CommandLineToCommaSeparatedValuesEx(args->argc - 1, args->argv + 1, filters,
1100 ARRAYSIZE(filters));
1103static BOOL rdp_opt_duplicate(
const rdpSettings* _settings, FreeRDP_Settings_Keys_String _id,
1106 WINPR_ASSERT(_settings);
1112 *_key = _strdup(tmp);
1120BOOL freerdp_client_populate_rdp_file_from_settings(rdpFile* file,
const rdpSettings* settings)
1122 FreeRDP_Settings_Keys_String index = FreeRDP_STRING_UNUSED;
1123 UINT32 LoadBalanceInfoLength = 0;
1124 const char* GatewayHostname = NULL;
1125 char* redirectCameras = NULL;
1127 if (!file || !settings)
1130 if (!FILE_POPULATE_STRING(&file->Domain, settings, FreeRDP_Domain) ||
1131 !FILE_POPULATE_STRING(&file->Username, settings, FreeRDP_Username) ||
1132 !FILE_POPULATE_STRING(&file->Password, settings, FreeRDP_Password) ||
1133 !FILE_POPULATE_STRING(&file->FullAddress, settings, FreeRDP_ServerHostname) ||
1134 !FILE_POPULATE_STRING(&file->AlternateFullAddress, settings, FreeRDP_ServerHostname) ||
1135 !FILE_POPULATE_STRING(&file->AlternateShell, settings, FreeRDP_AlternateShell) ||
1136 !FILE_POPULATE_STRING(&file->DrivesToRedirect, settings, FreeRDP_DrivesToRedirect))
1145 file->DynamicResolution = WINPR_ASSERTING_INT_CAST(
1147 file->VideoPlaybackMode = WINPR_ASSERTING_INT_CAST(
1154 file->ConnectToConsole = WINPR_ASSERTING_INT_CAST(
1156 file->NegotiateSecurityLayer = WINPR_ASSERTING_INT_CAST(
1158 file->EnableCredSSPSupport =
1160 file->EnableRdsAadAuth =
1164 index = FreeRDP_RemoteApplicationWorkingDir;
1166 index = FreeRDP_ShellWorkingDirectory;
1167 if (!FILE_POPULATE_STRING(&file->ShellWorkingDirectory, settings, index))
1174 if (LoadBalanceInfoLength > 0)
1176 const BYTE* LoadBalanceInfo =
1178 file->LoadBalanceInfo = calloc(LoadBalanceInfoLength + 1, 1);
1179 if (!file->LoadBalanceInfo)
1181 memcpy(file->LoadBalanceInfo, LoadBalanceInfo, LoadBalanceInfoLength);
1185 file->AudioMode = AUDIO_MODE_REDIRECT;
1187 file->AudioMode = AUDIO_MODE_PLAY_ON_SERVER;
1189 file->AudioMode = AUDIO_MODE_NONE;
1194 if (GatewayHostname)
1197 freerdp_client_file_string_check_free(file->GatewayHostname);
1198 if (GatewayPort == 443)
1199 file->GatewayHostname = _strdup(GatewayHostname);
1202 int length = _scprintf(
"%s:%" PRIu32, GatewayHostname, GatewayPort);
1206 file->GatewayHostname = (
char*)malloc((
size_t)length + 1);
1207 if (!file->GatewayHostname)
1210 if (sprintf_s(file->GatewayHostname, (
size_t)length + 1,
"%s:%" PRIu32, GatewayHostname,
1214 if (!file->GatewayHostname)
1219 file->ResourceProvider = _strdup(str_resourceprovider_arm);
1221 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdWvdEndpointPool, &file->WvdEndpointPool))
1223 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdGeo, &file->geo))
1225 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdArmpath, &file->armpath))
1227 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdAadtenantid, &file->aadtenantid))
1229 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdDiagnosticserviceurl,
1230 &file->diagnosticserviceurl))
1232 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdHubdiscoverygeourl,
1233 &file->hubdiscoverygeourl))
1235 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdActivityhint, &file->activityhint))
1238 file->AudioCaptureMode =
1240 file->BitmapCachePersistEnable = WINPR_ASSERTING_INT_CAST(
1242 file->Compression = WINPR_ASSERTING_INT_CAST(
1246 file->GatewayCredentialsSource =
1248 file->PromptCredentialOnce = WINPR_ASSERTING_INT_CAST(
1250 file->PromptForCredentials = WINPR_ASSERTING_INT_CAST(
1252 file->RemoteApplicationMode = WINPR_ASSERTING_INT_CAST(
1254 if (!FILE_POPULATE_STRING(&file->GatewayAccessToken, settings, FreeRDP_GatewayAccessToken) ||
1255 !FILE_POPULATE_STRING(&file->RemoteApplicationProgram, settings,
1256 FreeRDP_RemoteApplicationProgram) ||
1257 !FILE_POPULATE_STRING(&file->RemoteApplicationName, settings,
1258 FreeRDP_RemoteApplicationName) ||
1259 !FILE_POPULATE_STRING(&file->RemoteApplicationIcon, settings,
1260 FreeRDP_RemoteApplicationIcon) ||
1261 !FILE_POPULATE_STRING(&file->RemoteApplicationFile, settings,
1262 FreeRDP_RemoteApplicationFile) ||
1263 !FILE_POPULATE_STRING(&file->RemoteApplicationGuid, settings,
1264 FreeRDP_RemoteApplicationGuid) ||
1265 !FILE_POPULATE_STRING(&file->RemoteApplicationCmdLine, settings,
1266 FreeRDP_RemoteApplicationCmdLine))
1268 file->SpanMonitors =
1272 file->AllowDesktopComposition = WINPR_ASSERTING_INT_CAST(
1274 file->AllowFontSmoothing = WINPR_ASSERTING_INT_CAST(
1276 file->DisableWallpaper = WINPR_ASSERTING_INT_CAST(
1278 file->DisableFullWindowDrag = WINPR_ASSERTING_INT_CAST(
1280 file->DisableMenuAnims = WINPR_ASSERTING_INT_CAST(
1282 file->DisableThemes = WINPR_ASSERTING_INT_CAST(
1285 CONNECTION_TYPE_AUTODETECT)
1288 file->NetworkAutoDetect =
1290 file->AutoReconnectionEnabled = WINPR_ASSERTING_INT_CAST(
1292 file->RedirectSmartCards = WINPR_ASSERTING_INT_CAST(
1294 file->RedirectWebauthN = WINPR_ASSERTING_INT_CAST(
1298 freerdp_client_channel_args_to_string(settings, RDPECAM_DVC_CHANNEL_NAME,
"device:");
1299 if (redirectCameras)
1302 freerdp_client_channel_args_to_string(settings, RDPECAM_DVC_CHANNEL_NAME,
"encode:");
1303 file->EncodeRedirectedVideoCapture = 0;
1306 unsigned long val = 0;
1308 val = strtoul(str, NULL, 0);
1309 if ((val < UINT32_MAX) && (errno == 0))
1310 file->EncodeRedirectedVideoCapture = (UINT32)val;
1314 str = freerdp_client_channel_args_to_string(settings, RDPECAM_DVC_CHANNEL_NAME,
"quality:");
1315 file->RedirectedVideoCaptureEncodingQuality = 0;
1318 unsigned long val = 0;
1320 val = strtoul(str, NULL, 0);
1321 if ((val <= 2) && (errno == 0))
1323 file->RedirectedVideoCaptureEncodingQuality = (UINT32)val;
1328 file->RedirectCameras = redirectCameras;
1331 freerdp_client_file_string_reset(&file->RedirectCameras);
1333#ifdef CHANNEL_URBDRC_CLIENT
1335 freerdp_client_channel_args_to_string(settings, URBDRC_CHANNEL_NAME,
"device:");
1337 file->UsbDevicesToRedirect = redirectUsb;
1339 freerdp_client_file_string_reset(&file->UsbDevicesToRedirect);
1342 file->RedirectClipboard =
1349 file->RedirectLocation =
1351 if (!FILE_POPULATE_STRING(&file->DrivesToRedirect, settings, FreeRDP_DrivesToRedirect) ||
1352 !FILE_POPULATE_STRING(&file->PreconnectionBlob, settings, FreeRDP_PreconnectionBlob) ||
1353 !FILE_POPULATE_STRING(&file->KdcProxyName, settings, FreeRDP_KerberosKdcUrl))
1361 size_t size = count * (10 + 1) + 1;
1363 char* str = calloc(size,
sizeof(
char));
1364 for (UINT32 x = 0; x < count; x++)
1366 int rc = _snprintf(&str[offset], size - offset,
"%" PRIu32
",", MonitorIds[x]);
1372 offset += (size_t)rc;
1375 str[offset - 1] =
'\0';
1376 freerdp_client_file_string_check_free(file->SelectedMonitors);
1377 file->SelectedMonitors = str;
1385BOOL freerdp_client_write_rdp_file(
const rdpFile* file,
const char* name, BOOL unicode)
1388 WCHAR* unicodestr = NULL;
1393 const size_t size = freerdp_client_write_rdp_file_buffer(file, NULL, 0);
1396 char* buffer = calloc(size + 1ULL,
sizeof(
char));
1398 if (freerdp_client_write_rdp_file_buffer(file, buffer, size + 1) != size)
1400 WLog_ERR(TAG,
"freerdp_client_write_rdp_file: error writing to output buffer");
1405 FILE* fp = winpr_fopen(name,
"w+b");
1412 unicodestr = ConvertUtf8NToWCharAlloc(buffer, size, &len);
1422 if ((fwrite(BOM_UTF16_LE,
sizeof(BYTE), 2, fp) != 2) ||
1423 (fwrite(unicodestr,
sizeof(WCHAR), len, fp) != len))
1435 if (fwrite(buffer, 1, size, fp) != size)
1444 status = fclose(fp);
1448 return (status == 0) ? TRUE : FALSE;
1451WINPR_ATTR_FORMAT_ARG(3, 4)
1452static SSIZE_T freerdp_client_write_setting_to_buffer(
char** buffer,
size_t* bufferSize,
1453 WINPR_FORMAT_ARG const
char* fmt, ...)
1460 if (!buffer || !bufferSize || !fmt)
1464 bufSize = *bufferSize;
1467 len = vsnprintf(buf, bufSize, fmt, ap);
1476 if (!buf && !bufSize)
1483 if (bufSize >= (
size_t)len)
1485 *bufferSize -= (size_t)len;
1486 buf[len - 1] =
'\n';
1487 *buffer = buf + len;
1495static SSIZE_T write_int_parameters(
const rdpFile* file,
char* buffer,
size_t size)
1504 const struct intentry_t settings[] = {
1505 { key_int_use_multimon, file->UseMultiMon },
1506 { key_int_maximizetocurrentdisplays, file->MaximizeToCurrentDisplays },
1507 { key_int_singlemoninwindowedmode, file->SingleMonInWindowedMode },
1508 { key_int_screen_mode_id, file->ScreenModeId },
1509 { key_int_span_monitors, file->SpanMonitors },
1510 { key_int_smart_sizing, file->SmartSizing },
1511 { key_int_dynamic_resolution, file->DynamicResolution },
1512 { key_int_enablesuperpan, file->EnableSuperSpan },
1513 { key_int_superpanaccelerationfactor, file->SuperSpanAccelerationFactor },
1514 { key_int_desktopwidth, file->DesktopWidth },
1515 { key_int_desktopheight, file->DesktopHeight },
1516 { key_int_desktop_size_id, file->DesktopSizeId },
1517 { key_int_session_bpp, file->SessionBpp },
1518 { key_int_desktopscalefactor, file->DesktopScaleFactor },
1519 { key_int_compression, file->Compression },
1520 { key_int_keyboardhook, file->KeyboardHook },
1521 { key_int_disable_ctrl_alt_del, file->DisableCtrlAltDel },
1522 { key_int_audiomode, file->AudioMode },
1523 { key_int_audioqualitymode, file->AudioQualityMode },
1524 { key_int_audiocapturemode, file->AudioCaptureMode },
1525 { key_int_encode_redirected_video_capture, file->EncodeRedirectedVideoCapture },
1526 { key_int_redirected_video_capture_encoding_quality,
1527 file->RedirectedVideoCaptureEncodingQuality },
1528 { key_int_videoplaybackmode, file->VideoPlaybackMode },
1529 { key_int_connection_type, file->ConnectionType },
1530 { key_int_networkautodetect, file->NetworkAutoDetect },
1531 { key_int_bandwidthautodetect, file->BandwidthAutoDetect },
1532 { key_int_pinconnectionbar, file->PinConnectionBar },
1533 { key_int_displayconnectionbar, file->DisplayConnectionBar },
1534 { key_int_workspaceid, file->WorkspaceId },
1535 { key_int_enableworkspacereconnect, file->EnableWorkspaceReconnect },
1536 { key_int_disable_wallpaper, file->DisableWallpaper },
1537 { key_int_allow_font_smoothing, file->AllowFontSmoothing },
1538 { key_int_allow_desktop_composition, file->AllowDesktopComposition },
1539 { key_int_disable_full_window_drag, file->DisableFullWindowDrag },
1540 { key_int_disable_menu_anims, file->DisableMenuAnims },
1541 { key_int_disable_themes, file->DisableThemes },
1542 { key_int_disable_cursor_setting, file->DisableCursorSetting },
1543 { key_int_bitmapcachesize, file->BitmapCacheSize },
1544 { key_int_bitmapcachepersistenable, file->BitmapCachePersistEnable },
1545 { key_int_server_port, file->ServerPort },
1546 { key_int_redirectdrives, file->RedirectDrives },
1547 { key_int_redirectprinters, file->RedirectPrinters },
1548 { key_int_redirectcomports, file->RedirectComPorts },
1549 { key_int_redirectlocation, file->RedirectLocation },
1550 { key_int_redirectsmartcards, file->RedirectSmartCards },
1551 { key_int_redirectclipboard, file->RedirectClipboard },
1552 { key_int_redirectposdevices, file->RedirectPosDevices },
1553 { key_int_redirectdirectx, file->RedirectDirectX },
1554 { key_int_disableprinterredirection, file->DisablePrinterRedirection },
1555 { key_int_disableclipboardredirection, file->DisableClipboardRedirection },
1556 { key_int_connect_to_console, file->ConnectToConsole },
1557 { key_int_administrative_session, file->AdministrativeSession },
1558 { key_int_autoreconnection_enabled, file->AutoReconnectionEnabled },
1559 { key_int_autoreconnect_max_retries, file->AutoReconnectMaxRetries },
1560 { key_int_public_mode, file->PublicMode },
1561 { key_int_authentication_level, file->AuthenticationLevel },
1562 { key_int_promptcredentialonce, file->PromptCredentialOnce },
1563 { key_int_prompt_for_credentials, file->PromptForCredentials },
1564 { key_int_negotiate_security_layer, file->NegotiateSecurityLayer },
1565 { key_int_enablecredsspsupport, file->EnableCredSSPSupport },
1566 { key_int_enablerdsaadauth, file->EnableRdsAadAuth },
1567 { key_int_remoteapplicationmode, file->RemoteApplicationMode },
1568 { key_int_remoteapplicationexpandcmdline, file->RemoteApplicationExpandCmdLine },
1569 { key_int_remoteapplicationexpandworkingdir, file->RemoteApplicationExpandWorkingDir },
1570 { key_int_disableconnectionsharing, file->DisableConnectionSharing },
1571 { key_int_disableremoteappcapscheck, file->DisableRemoteAppCapsCheck },
1572 { key_int_gatewayusagemethod, file->GatewayUsageMethod },
1573 { key_int_gatewayprofileusagemethod, file->GatewayProfileUsageMethod },
1574 { key_int_gatewaycredentialssource, file->GatewayCredentialsSource },
1575 { key_int_use_redirection_server_name, file->UseRedirectionServerName },
1576 { key_int_rdgiskdcproxy, file->RdgIsKdcProxy },
1577 { key_int_redirectwebauthn, file->RedirectWebauthN }
1580 SSIZE_T totalSize = 0;
1581 for (
size_t x = 0; x < ARRAYSIZE(settings); x++)
1583 const struct intentry_t* cur = &settings[x];
1586 const SSIZE_T res = freerdp_client_write_setting_to_buffer(
1587 &buffer, &size,
"%s:i:%" PRIu32, cur->key, cur->val);
1597static SSIZE_T write_string_parameters(
const rdpFile* file,
char* buffer,
size_t size)
1606 const struct strentry_t settings[] = {
1607 { key_str_username, file->Username },
1608 { key_str_domain, file->Domain },
1609 { key_str_password, file->Password },
1610 { key_str_full_address, file->FullAddress },
1611 { key_str_alternate_full_address, file->AlternateFullAddress },
1612 { key_str_usbdevicestoredirect, file->UsbDevicesToRedirect },
1613 { key_str_camerastoredirect, file->RedirectCameras },
1614 { key_str_loadbalanceinfo, file->LoadBalanceInfo },
1615 { key_str_remoteapplicationname, file->RemoteApplicationName },
1616 { key_str_remoteapplicationicon, file->RemoteApplicationIcon },
1617 { key_str_remoteapplicationprogram, file->RemoteApplicationProgram },
1618 { key_str_remoteapplicationfile, file->RemoteApplicationFile },
1619 { key_str_remoteapplicationguid, file->RemoteApplicationGuid },
1620 { key_str_remoteapplicationcmdline, file->RemoteApplicationCmdLine },
1621 { key_str_alternate_shell, file->AlternateShell },
1622 { key_str_shell_working_directory, file->ShellWorkingDirectory },
1623 { key_str_gatewayhostname, file->GatewayHostname },
1624 { key_str_resourceprovider, file->ResourceProvider },
1625 { key_str_wvd, file->WvdEndpointPool },
1626 { key_str_geo, file->geo },
1627 { key_str_armpath, file->armpath },
1628 { key_str_aadtenantid, file->aadtenantid },
1629 { key_str_diagnosticserviceurl, file->diagnosticserviceurl },
1630 { key_str_hubdiscoverygeourl, file->hubdiscoverygeourl },
1631 { key_str_activityhint, file->activityhint },
1632 { key_str_gatewayaccesstoken, file->GatewayAccessToken },
1633 { key_str_kdcproxyname, file->KdcProxyName },
1634 { key_str_drivestoredirect, file->DrivesToRedirect },
1635 { key_str_devicestoredirect, file->DevicesToRedirect },
1636 { key_str_winposstr, file->WinPosStr },
1637 { key_str_pcb, file->PreconnectionBlob },
1638 { key_str_selectedmonitors, file->SelectedMonitors }
1641 SSIZE_T totalSize = 0;
1642 for (
size_t x = 0; x < ARRAYSIZE(settings); x++)
1644 const struct strentry_t* cur = &settings[x];
1645 if (~(
size_t)(cur->val))
1647 const SSIZE_T res = freerdp_client_write_setting_to_buffer(&buffer, &size,
"%s:s:%s",
1648 cur->key, cur->val);
1658static SSIZE_T write_custom_parameters(
const rdpFile* file,
char* buffer,
size_t size)
1662 SSIZE_T totalSize = 0;
1664 for (
size_t i = 0; i < file->lineCount; ++i)
1667 const rdpFileLine* curLine = &file->lines[i];
1669 if (curLine->flags & RDP_FILE_LINE_FLAG_TYPE_INTEGER)
1670 res = freerdp_client_write_setting_to_buffer(&buffer, &size,
"%s:i:%" PRIu32,
1671 curLine->name, (UINT32)curLine->iValue);
1672 else if (curLine->flags & RDP_FILE_LINE_FLAG_TYPE_STRING)
1673 res = freerdp_client_write_setting_to_buffer(&buffer, &size,
"%s:s:%s", curLine->name,
1683size_t freerdp_client_write_rdp_file_buffer(
const rdpFile* file,
char* buffer,
size_t size)
1685 size_t totalSize = 0;
1691 if ((!buffer || !size) && (buffer || size))
1695 const SSIZE_T intsize = write_int_parameters(file, buffer, size);
1698 totalSize += (size_t)intsize;
1703 const SSIZE_T stringsize = write_string_parameters(file, buffer, size);
1706 totalSize += (size_t)stringsize;
1708 buffer += stringsize;
1711 const SSIZE_T customsize = write_custom_parameters(file, buffer, size);
1714 totalSize += (size_t)customsize;
1718static ADDIN_ARGV* rdp_file_to_args(
const char* channel,
const char* values)
1722 ADDIN_ARGV* args = freerdp_addin_argv_new(0, NULL);
1725 if (!freerdp_addin_argv_add_argument(args, channel))
1728 p = CommandLineParseCommaSeparatedValues(values, &count);
1729 for (
size_t x = 0; x < count; x++)
1732 const char* val = p[x];
1733 const size_t len = strlen(val) + 8;
1734 char* str = calloc(len,
sizeof(
char));
1738 (void)_snprintf(str, len,
"device:%s", val);
1739 rc = freerdp_addin_argv_add_argument(args, str);
1744 CommandLineParserFree(p);
1748 CommandLineParserFree(p);
1749 freerdp_addin_argv_free(args);
1753BOOL freerdp_client_populate_settings_from_rdp_file_unchecked(
const rdpFile* file,
1754 rdpSettings* settings)
1756 if (!file || !settings)
1762 if (~file->BandwidthAutoDetect)
1764 if (file->BandwidthAutoDetect != 0)
1766 if ((~file->NetworkAutoDetect) && (file->NetworkAutoDetect == 0))
1769 "Got networkautodetect:i:%" PRIu32
" and bandwidthautodetect:i:%" PRIu32
1770 ". Correcting to networkautodetect:i:1",
1771 file->NetworkAutoDetect, file->BandwidthAutoDetect);
1773 "Add networkautodetect:i:1 to your RDP file to eliminate this warning.");
1777 (file->BandwidthAutoDetect != 0) ||
1778 (file->NetworkAutoDetect != 0)))
1782 if (~file->NetworkAutoDetect)
1784 if (file->NetworkAutoDetect != 0)
1786 if ((~file->BandwidthAutoDetect) && (file->BandwidthAutoDetect == 0))
1789 "Got networkautodetect:i:%" PRIu32
" and bandwidthautodetect:i:%" PRIu32
1790 ". Correcting to bandwidthautodetect:i:1",
1791 file->NetworkAutoDetect, file->BandwidthAutoDetect);
1793 TAG,
"Add bandwidthautodetect:i:1 to your RDP file to eliminate this warning.");
1797 (file->BandwidthAutoDetect != 0) ||
1798 (file->NetworkAutoDetect != 0)))
1802 if (~((
size_t)file->Domain))
1808 if (~((
size_t)file->Username))
1811 char* domain = NULL;
1813 if (!freerdp_parse_username(file->Username, &user, &domain))
1819 if (!(~((
size_t)file->Domain)) && domain)
1829 if (~((
size_t)file->Password))
1836 const char* address = NULL;
1840 if (~((
size_t)file->AlternateFullAddress))
1841 address = file->AlternateFullAddress;
1842 else if (~((
size_t)file->FullAddress))
1843 address = file->FullAddress;
1850 if (!freerdp_parse_hostname(address, &host, &port))
1866 if (~file->ServerPort)
1872 if (~file->DesktopSizeId)
1874 switch (file->DesktopSizeId)
1907 WLog_WARN(TAG,
"Unsupported 'desktop size id' value %" PRIu32, file->DesktopSizeId);
1912 if (~file->DesktopWidth)
1918 if (~file->DesktopHeight)
1924 if (~file->SessionBpp)
1930 if (~file->ConnectToConsole)
1933 file->ConnectToConsole != 0))
1937 if (~file->AdministrativeSession)
1940 file->AdministrativeSession != 0))
1944 if (~file->NegotiateSecurityLayer)
1947 file->NegotiateSecurityLayer != 0))
1951 if (~file->EnableCredSSPSupport)
1954 file->EnableCredSSPSupport != 0))
1958 if (~file->EnableRdsAadAuth)
1964 if (~((
size_t)file->AlternateShell))
1970 if (~((
size_t)file->ShellWorkingDirectory))
1973 FreeRDP_Settings_Keys_String targetId =
1974 (~file->RemoteApplicationMode && file->RemoteApplicationMode != 0)
1975 ? FreeRDP_RemoteApplicationWorkingDir
1976 : FreeRDP_ShellWorkingDirectory;
1982 if (~file->ScreenModeId)
1997 (file->ScreenModeId == 2) ? TRUE : FALSE))
2001 if (~(file->SmartSizing))
2004 (file->SmartSizing == 1) ? TRUE : FALSE))
2015 if (((~(file->DesktopWidth) && ~(file->DesktopHeight)) || ~(file->DesktopSizeId)) &&
2016 (file->SmartSizing == 1))
2019 file->DesktopWidth))
2022 file->DesktopHeight))
2027 if (~((
size_t)file->LoadBalanceInfo))
2029 const size_t len = strlen(file->LoadBalanceInfo);
2031 file->LoadBalanceInfo, len))
2035 if (~file->AuthenticationLevel)
2052 file->AuthenticationLevel))
2056 if (~file->ConnectionType)
2062 if (~file->AudioMode)
2064 switch (file->AudioMode)
2066 case AUDIO_MODE_REDIRECT:
2072 case AUDIO_MODE_PLAY_ON_SERVER:
2078 case AUDIO_MODE_NONE:
2088 if (~file->AudioCaptureMode)
2094 if (~file->Compression)
2097 file->Compression != 0))
2101 if (~((
size_t)file->GatewayHostname))
2106 if (!freerdp_parse_hostname(file->GatewayHostname, &host, &port))
2121 if (~((
size_t)file->ResourceProvider))
2123 if (_stricmp(file->ResourceProvider, str_resourceprovider_arm) == 0)
2130 if (~((
size_t)file->WvdEndpointPool))
2133 file->WvdEndpointPool))
2137 if (~((
size_t)file->geo))
2143 if (~((
size_t)file->armpath))
2149 if (~((
size_t)file->aadtenantid))
2156 if (~((
size_t)file->diagnosticserviceurl))
2159 file->diagnosticserviceurl))
2163 if (~((
size_t)file->hubdiscoverygeourl))
2166 file->hubdiscoverygeourl))
2170 if (~((
size_t)file->activityhint))
2173 file->activityhint))
2177 if (~((
size_t)file->GatewayAccessToken))
2180 file->GatewayAccessToken))
2184 if (~file->GatewayUsageMethod)
2190 if (~file->PromptCredentialOnce)
2193 file->PromptCredentialOnce != 0))
2197 if (~file->PromptForCredentials)
2200 file->PromptForCredentials != 0))
2204 if (~file->RemoteApplicationMode)
2207 file->RemoteApplicationMode != 0))
2211 if (~((
size_t)file->RemoteApplicationProgram))
2214 file->RemoteApplicationProgram))
2218 if (~((
size_t)file->RemoteApplicationName))
2221 file->RemoteApplicationName))
2225 if (~((
size_t)file->RemoteApplicationIcon))
2228 file->RemoteApplicationIcon))
2232 if (~((
size_t)file->RemoteApplicationFile))
2235 file->RemoteApplicationFile))
2239 if (~((
size_t)file->RemoteApplicationGuid))
2242 file->RemoteApplicationGuid))
2246 if (~((
size_t)file->RemoteApplicationCmdLine))
2249 file->RemoteApplicationCmdLine))
2253 if (~file->SpanMonitors)
2259 if (~file->UseMultiMon)
2265 if (~file->AllowFontSmoothing)
2268 file->AllowFontSmoothing != 0))
2272 if (~file->DisableWallpaper)
2275 file->DisableWallpaper != 0))
2279 if (~file->DisableFullWindowDrag)
2282 file->DisableFullWindowDrag != 0))
2286 if (~file->DisableMenuAnims)
2289 file->DisableMenuAnims != 0))
2293 if (~file->DisableThemes)
2299 if (~file->AllowDesktopComposition)
2302 file->AllowDesktopComposition != 0))
2306 if (~file->BitmapCachePersistEnable)
2309 file->BitmapCachePersistEnable != 0))
2313 if (~file->DisableRemoteAppCapsCheck)
2316 file->DisableRemoteAppCapsCheck != 0))
2320 if (~file->AutoReconnectionEnabled)
2323 file->AutoReconnectionEnabled != 0))
2327 if (~file->AutoReconnectMaxRetries)
2330 file->AutoReconnectMaxRetries))
2334 if (~file->RedirectSmartCards)
2337 file->RedirectSmartCards != 0))
2341 if (~file->RedirectWebauthN)
2344 file->RedirectWebauthN != 0))
2348 if (~file->RedirectClipboard)
2351 file->RedirectClipboard != 0))
2355 if (~file->RedirectPrinters)
2358 file->RedirectPrinters != 0))
2362 if (~file->RedirectDrives)
2368 if (~file->RedirectPosDevices)
2371 file->RedirectComPorts != 0) ||
2373 file->RedirectComPorts != 0))
2377 if (~file->RedirectComPorts)
2380 file->RedirectComPorts != 0) ||
2382 file->RedirectComPorts != 0))
2386 if (~file->RedirectLocation && (file->RedirectLocation != 0))
2392 freerdp_client_add_dynamic_channel(settings, count, (
const char*
const*)ptr);
2393 CommandLineParserFree(ptr);
2398 if (~file->RedirectDirectX)
2403 if ((~((
size_t)file->DevicesToRedirect)) && !utils_str_is_empty(file->DevicesToRedirect))
2433 if ((~((
size_t)file->DrivesToRedirect)) && !utils_str_is_empty(file->DrivesToRedirect))
2436 file->DrivesToRedirect))
2440 if ((~((
size_t)file->RedirectCameras)) && !utils_str_is_empty(file->RedirectCameras))
2442#if defined(CHANNEL_RDPECAM_CLIENT)
2446 const char*
const* cc;
2448 ADDIN_ARGV* args = rdp_file_to_args(RDPECAM_DVC_CHANNEL_NAME, file->RedirectCameras);
2453 if (~file->EncodeRedirectedVideoCapture)
2455 char encode[64] = { 0 };
2456 (void)_snprintf(encode,
sizeof(encode),
"encode:%" PRIu32,
2457 file->EncodeRedirectedVideoCapture);
2458 if (!freerdp_addin_argv_add_argument(args, encode))
2461 if (~file->RedirectedVideoCaptureEncodingQuality)
2463 char quality[64] = { 0 };
2464 (void)_snprintf(quality,
sizeof(quality),
"quality:%" PRIu32,
2465 file->RedirectedVideoCaptureEncodingQuality);
2466 if (!freerdp_addin_argv_add_argument(args, quality))
2472 status = freerdp_client_add_dynamic_channel(
2473 settings, WINPR_ASSERTING_INT_CAST(
size_t, args->argc), cnv.cc);
2474 freerdp_addin_argv_free(args);
2480 "This build does not support [MS-RDPECAM] camera redirection channel. Ignoring '%s'",
2481 key_str_camerastoredirect);
2485 if ((~((
size_t)file->UsbDevicesToRedirect)) && !utils_str_is_empty(file->UsbDevicesToRedirect))
2487#ifdef CHANNEL_URBDRC_CLIENT
2491 const char*
const* cc;
2493 ADDIN_ARGV* args = rdp_file_to_args(URBDRC_CHANNEL_NAME, file->UsbDevicesToRedirect);
2497 const BOOL status = freerdp_client_add_dynamic_channel(
2498 settings, WINPR_ASSERTING_INT_CAST(
size_t, args->argc), cnv.cc);
2499 freerdp_addin_argv_free(args);
2504 "This build does not support [MS-RDPEUSB] usb redirection channel. Ignoring '%s'",
2505 key_str_usbdevicestoredirect);
2509 if (~file->KeyboardHook)
2515 if (~(
size_t)file->SelectedMonitors)
2518 char** ptr = CommandLineParseCommaSeparatedValues(file->SelectedMonitors, &count);
2519 UINT32* list = NULL;
2523 CommandLineParserFree(ptr);
2527 if (!list && (count > 0))
2529 CommandLineParserFree(ptr);
2532 for (
size_t x = 0; x < count; x++)
2534 unsigned long val = 0;
2536 val = strtoul(ptr[x], NULL, 0);
2537 if ((val >= UINT32_MAX) && (errno != 0))
2539 CommandLineParserFree(ptr);
2543 list[x] = (UINT32)val;
2545 CommandLineParserFree(ptr);
2548 if (~file->DynamicResolution)
2550 const BOOL val = file->DynamicResolution != 0;
2557 if (~file->DesktopScaleFactor)
2560 file->DesktopScaleFactor))
2564 if (~file->VideoPlaybackMode)
2566 if (file->VideoPlaybackMode != 0)
2583 if (~((
size_t)file->PreconnectionBlob))
2586 file->PreconnectionBlob) ||
2591 if (~((
size_t)file->KdcProxyName))
2597 if (~file->RdgIsKdcProxy)
2600 file->RdgIsKdcProxy != 0))
2604 if (file->args->argc > 1)
2606 WCHAR* ConnectionFile =
2609 if (freerdp_client_settings_parse_command_line(settings, file->args->argc, file->args->argv,
2612 free(ConnectionFile);
2618 free(ConnectionFile);
2626static BOOL freerdp_apply_connection_type_from_file(
const rdpFile* file, rdpSettings* settings,
2629 struct network_settings
2631 FreeRDP_Settings_Keys_Bool id;
2637 const struct network_settings config[] = { { FreeRDP_DisableWallpaper,
2638 (~file->DisableWallpaper) == 0,
2639 { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
2640 { FreeRDP_AllowFontSmoothing,
2641 (~file->AllowFontSmoothing) == 0,
2642 { FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE } },
2643 { FreeRDP_AllowDesktopComposition,
2644 (~file->AllowDesktopComposition) == 0,
2645 { FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE } },
2646 { FreeRDP_DisableFullWindowDrag,
2647 (~file->DisableFullWindowDrag) == 0,
2648 { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
2649 { FreeRDP_DisableMenuAnims,
2650 (~file->DisableMenuAnims) == 0,
2651 { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
2652 { FreeRDP_DisableThemes,
2653 (~file->DisableThemes) == 0,
2654 { TRUE, FALSE, FALSE, FALSE, FALSE, FALSE,
2659 case CONNECTION_TYPE_INVALID:
2662 case CONNECTION_TYPE_MODEM:
2663 case CONNECTION_TYPE_BROADBAND_LOW:
2664 case CONNECTION_TYPE_BROADBAND_HIGH:
2665 case CONNECTION_TYPE_SATELLITE:
2666 case CONNECTION_TYPE_WAN:
2667 case CONNECTION_TYPE_LAN:
2668 case CONNECTION_TYPE_AUTODETECT:
2671 WLog_WARN(TAG,
"Unknown ConnectionType %" PRIu32
", aborting", type);
2675 for (
size_t x = 0; x < ARRAYSIZE(config); x++)
2677 const struct network_settings* cur = &config[x];
2687static BOOL freerdp_set_connection_type_from_file(
const rdpFile* file, rdpSettings* settings,
2696 case CONNECTION_TYPE_INVALID:
2697 case CONNECTION_TYPE_MODEM:
2698 case CONNECTION_TYPE_BROADBAND_LOW:
2699 case CONNECTION_TYPE_SATELLITE:
2700 case CONNECTION_TYPE_BROADBAND_HIGH:
2701 case CONNECTION_TYPE_WAN:
2702 case CONNECTION_TYPE_LAN:
2703 if (!freerdp_apply_connection_type_from_file(file, settings, type))
2706 case CONNECTION_TYPE_AUTODETECT:
2707 if (!freerdp_apply_connection_type_from_file(file, settings, type))
2721 WLog_WARN(TAG,
"Unknown ConnectionType %" PRIu32
", aborting", type);
2728BOOL freerdp_client_populate_settings_from_rdp_file(
const rdpFile* file, rdpSettings* settings)
2730 if (!freerdp_client_populate_settings_from_rdp_file_unchecked(file, settings))
2734 if ((~file->ConnectionType) == 0)
2737 type = CONNECTION_TYPE_AUTODETECT;
2739 return freerdp_set_connection_type_from_file(file, settings, type);
2742static rdpFileLine* freerdp_client_rdp_file_find_line_by_name(
const rdpFile* file,
const char* name)
2744 BOOL bFound = FALSE;
2745 rdpFileLine* line = NULL;
2747 for (
size_t index = 0; index < file->lineCount; index++)
2749 line = &(file->lines[index]);
2751 if (line->flags & RDP_FILE_LINE_FLAG_FORMATTED)
2753 if (_stricmp(name, line->name) == 0)
2761 return (bFound) ? line : NULL;
2770int freerdp_client_rdp_file_set_string_option(rdpFile* file,
const char* name,
const char* value)
2772 return freerdp_client_rdp_file_set_string(file, name, value);
2775const char* freerdp_client_rdp_file_get_string_option(
const rdpFile* file,
const char* name)
2777 LPSTR* value = NULL;
2778 rdpFileLine* line = NULL;
2780 rdpFile* wfile = WINPR_CAST_CONST_PTR_AWAY(file, rdpFile*);
2781 if (freerdp_client_rdp_file_find_string_entry(wfile, name, &value, &line))
2783 if (value && ~(
size_t)(*value))
2786 return line->sValue;
2792int freerdp_client_rdp_file_set_integer_option(rdpFile* file,
const char* name,
int value)
2794 return freerdp_client_rdp_file_set_integer(file, name, value);
2797int freerdp_client_rdp_file_get_integer_option(
const rdpFile* file,
const char* name)
2799 DWORD* value = NULL;
2800 rdpFileLine* line = NULL;
2802 rdpFile* wfile = WINPR_CAST_CONST_PTR_AWAY(file, rdpFile*);
2803 if (freerdp_client_rdp_file_find_integer_entry(wfile, name, &value, &line))
2805 if (value && ~(*value))
2806 return WINPR_ASSERTING_INT_CAST(
int, *value);
2808 return (
int)line->iValue;
2814static void freerdp_client_file_string_check_free(LPSTR str)
2820rdpFile* freerdp_client_rdp_file_new(
void)
2822 return freerdp_client_rdp_file_new_ex(0);
2825rdpFile* freerdp_client_rdp_file_new_ex(DWORD flags)
2827 rdpFile* file = (rdpFile*)calloc(1,
sizeof(rdpFile));
2832 file->flags = flags;
2834 FillMemory(file,
sizeof(rdpFile), 0xFF);
2836 file->lineCount = 0;
2837 file->lineSize = 32;
2838 file->GatewayProfileUsageMethod = 1;
2839 file->lines = (rdpFileLine*)calloc(file->lineSize,
sizeof(rdpFileLine));
2841 file->args = freerdp_addin_argv_new(0, NULL);
2842 if (!file->lines || !file->args)
2845 if (!freerdp_client_add_option(file,
"freerdp"))
2850 WINPR_PRAGMA_DIAG_PUSH
2851 WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
2852 freerdp_client_rdp_file_free(file);
2853 WINPR_PRAGMA_DIAG_POP
2856void freerdp_client_rdp_file_free(rdpFile* file)
2860 if (file->lineCount)
2862 for (
size_t i = 0; i < file->lineCount; i++)
2864 free(file->lines[i].name);
2865 free(file->lines[i].sValue);
2870 freerdp_addin_argv_free(file->args);
2872 freerdp_client_file_string_check_free(file->Username);
2873 freerdp_client_file_string_check_free(file->Domain);
2874 freerdp_client_file_string_check_free(file->Password);
2875 freerdp_client_file_string_check_free(file->FullAddress);
2876 freerdp_client_file_string_check_free(file->AlternateFullAddress);
2877 freerdp_client_file_string_check_free(file->UsbDevicesToRedirect);
2878 freerdp_client_file_string_check_free(file->RedirectCameras);
2879 freerdp_client_file_string_check_free(file->SelectedMonitors);
2880 freerdp_client_file_string_check_free(file->LoadBalanceInfo);
2881 freerdp_client_file_string_check_free(file->RemoteApplicationName);
2882 freerdp_client_file_string_check_free(file->RemoteApplicationIcon);
2883 freerdp_client_file_string_check_free(file->RemoteApplicationProgram);
2884 freerdp_client_file_string_check_free(file->RemoteApplicationFile);
2885 freerdp_client_file_string_check_free(file->RemoteApplicationGuid);
2886 freerdp_client_file_string_check_free(file->RemoteApplicationCmdLine);
2887 freerdp_client_file_string_check_free(file->AlternateShell);
2888 freerdp_client_file_string_check_free(file->ShellWorkingDirectory);
2889 freerdp_client_file_string_check_free(file->GatewayHostname);
2890 freerdp_client_file_string_check_free(file->GatewayAccessToken);
2891 freerdp_client_file_string_check_free(file->KdcProxyName);
2892 freerdp_client_file_string_check_free(file->DrivesToRedirect);
2893 freerdp_client_file_string_check_free(file->DevicesToRedirect);
2894 freerdp_client_file_string_check_free(file->WinPosStr);
2895 freerdp_client_file_string_check_free(file->ResourceProvider);
2896 freerdp_client_file_string_check_free(file->WvdEndpointPool);
2897 freerdp_client_file_string_check_free(file->geo);
2898 freerdp_client_file_string_check_free(file->armpath);
2899 freerdp_client_file_string_check_free(file->aadtenantid);
2900 freerdp_client_file_string_check_free(file->diagnosticserviceurl);
2901 freerdp_client_file_string_check_free(file->hubdiscoverygeourl);
2902 freerdp_client_file_string_check_free(file->activityhint);
2907void freerdp_client_rdp_file_set_callback_context(rdpFile* file,
void* context)
2909 file->context = context;
#define LOCATION_CHANNEL_NAME
FREERDP_API UINT32 freerdp_settings_get_uint32(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id)
Returns a UINT32 settings value.
FREERDP_API BOOL freerdp_settings_set_string(rdpSettings *settings, FreeRDP_Settings_Keys_String id, const char *param)
Sets a string settings value. The param is copied.
FREERDP_API BOOL freerdp_settings_get_bool(const rdpSettings *settings, FreeRDP_Settings_Keys_Bool id)
Returns a boolean settings value.
FREERDP_API BOOL freerdp_settings_set_pointer_len(rdpSettings *settings, FreeRDP_Settings_Keys_Pointer id, const void *data, size_t len)
Set a pointer to value data.
FREERDP_API void * freerdp_settings_get_pointer_writable(rdpSettings *settings, FreeRDP_Settings_Keys_Pointer id)
Returns a mutable pointer settings value.
FREERDP_API WCHAR * freerdp_settings_get_string_as_utf16(const rdpSettings *settings, FreeRDP_Settings_Keys_String id, size_t *pCharLen)
Return an allocated UTF16 string.
FREERDP_API BOOL freerdp_set_gateway_usage_method(rdpSettings *settings, UINT32 GatewayUsageMethod)
FREERDP_API BOOL freerdp_settings_set_string_from_utf16(rdpSettings *settings, FreeRDP_Settings_Keys_String id, const WCHAR *param)
Sets a string settings value. The param is converted to UTF-8 and the copy stored.
FREERDP_API const void * freerdp_settings_get_pointer(const rdpSettings *settings, FreeRDP_Settings_Keys_Pointer id)
Returns a immutable pointer settings value.
FREERDP_API BOOL freerdp_settings_set_uint32(rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id, UINT32 param)
Sets a UINT32 settings value.
FREERDP_API const char * freerdp_settings_get_string(const rdpSettings *settings, FreeRDP_Settings_Keys_String id)
Returns a immutable string settings value.
FREERDP_API BOOL freerdp_settings_set_bool(rdpSettings *settings, FreeRDP_Settings_Keys_Bool id, BOOL param)
Sets a BOOL settings value.