20#include <freerdp/config.h>
26#include <winpr/string.h>
27#include <winpr/file.h>
28#include <winpr/cast.h>
30#include <freerdp/utils/warnings.h>
32#include <freerdp/client.h>
33#include <freerdp/client/file.h>
34#include <freerdp/client/cmdline.h>
36#include <freerdp/channels/urbdrc.h>
37#include <freerdp/channels/rdpecam.h>
38#include <freerdp/channels/location.h>
53#include <winpr/wtypes.h>
55#include <winpr/path.h>
56#include <freerdp/log.h>
57#define TAG CLIENT_TAG("common")
61static const BYTE BOM_UTF16_LE[2] = { 0xFF, 0xFE };
65#define RDP_FILE_LINE_FLAG_FORMATTED 0x00000001
67#define RDP_FILE_LINE_FLAG_TYPE_STRING 0x00000010
68#define RDP_FILE_LINE_FLAG_TYPE_INTEGER 0x00000020
83typedef struct rdp_file_line rdpFileLine;
88 LPSTR SelectedMonitors;
89 DWORD MaximizeToCurrentDisplays;
90 DWORD SingleMonInWindowedMode;
94 DWORD DynamicResolution;
95 DWORD EnableSuperSpan;
96 DWORD SuperSpanAccelerationFactor;
102 DWORD DesktopScaleFactor;
106 DWORD DisableCtrlAltDel;
109 DWORD AudioQualityMode;
110 DWORD AudioCaptureMode;
111 DWORD EncodeRedirectedVideoCapture;
112 DWORD RedirectedVideoCaptureEncodingQuality;
113 DWORD VideoPlaybackMode;
115 DWORD ConnectionType;
117 DWORD NetworkAutoDetect;
118 DWORD BandwidthAutoDetect;
120 DWORD PinConnectionBar;
121 DWORD DisplayConnectionBar;
124 DWORD EnableWorkspaceReconnect;
126 DWORD DisableWallpaper;
127 DWORD AllowFontSmoothing;
128 DWORD AllowDesktopComposition;
129 DWORD DisableFullWindowDrag;
130 DWORD DisableMenuAnims;
132 DWORD DisableCursorSetting;
134 DWORD BitmapCacheSize;
135 DWORD BitmapCachePersistEnable;
144 LPSTR AlternateFullAddress;
146 LPSTR UsbDevicesToRedirect;
147 DWORD RedirectDrives;
148 DWORD RedirectPrinters;
149 DWORD RedirectComPorts;
150 DWORD RedirectLocation;
151 DWORD RedirectSmartCards;
152 DWORD RedirectWebauthN;
153 LPSTR RedirectCameras;
154 DWORD RedirectClipboard;
155 DWORD RedirectPosDevices;
156 DWORD RedirectDirectX;
157 DWORD DisablePrinterRedirection;
158 DWORD DisableClipboardRedirection;
160 DWORD ConnectToConsole;
161 DWORD AdministrativeSession;
162 DWORD AutoReconnectionEnabled;
163 DWORD AutoReconnectMaxRetries;
166 DWORD AuthenticationLevel;
167 DWORD PromptCredentialOnce;
168 DWORD PromptForCredentials;
169 DWORD NegotiateSecurityLayer;
170 DWORD EnableCredSSPSupport;
171 DWORD EnableRdsAadAuth;
173 DWORD RemoteApplicationMode;
174 LPSTR LoadBalanceInfo;
176 LPSTR RemoteApplicationName;
177 LPSTR RemoteApplicationIcon;
178 LPSTR RemoteApplicationProgram;
179 LPSTR RemoteApplicationFile;
180 LPSTR RemoteApplicationGuid;
181 LPSTR RemoteApplicationCmdLine;
182 DWORD RemoteApplicationExpandCmdLine;
183 DWORD RemoteApplicationExpandWorkingDir;
184 DWORD DisableConnectionSharing;
185 DWORD DisableRemoteAppCapsCheck;
187 LPSTR AlternateShell;
188 LPSTR ShellWorkingDirectory;
190 LPSTR GatewayHostname;
191 DWORD GatewayUsageMethod;
192 DWORD GatewayProfileUsageMethod;
193 DWORD GatewayCredentialsSource;
195 LPSTR ResourceProvider;
197 LPSTR WvdEndpointPool;
201 LPSTR diagnosticserviceurl;
202 LPSTR hubdiscoverygeourl;
205 DWORD UseRedirectionServerName;
207 LPSTR GatewayAccessToken;
209 LPSTR EndpointFedAuthToken;
211 LPSTR DrivesToRedirect;
212 LPSTR DevicesToRedirect;
215 LPSTR PreconnectionBlob;
232static const char key_str_username[] =
"username";
233static const char key_str_domain[] =
"domain";
234static const char key_str_password[] =
"password";
235static const char key_str_full_address[] =
"full address";
236static const char key_str_alternate_full_address[] =
"alternate full address";
237static const char key_str_usbdevicestoredirect[] =
"usbdevicestoredirect";
238static const char key_str_camerastoredirect[] =
"camerastoredirect";
239static const char key_str_loadbalanceinfo[] =
"loadbalanceinfo";
240static const char key_str_remoteapplicationname[] =
"remoteapplicationname";
241static const char key_str_remoteapplicationicon[] =
"remoteapplicationicon";
242static const char key_str_remoteapplicationprogram[] =
"remoteapplicationprogram";
243static const char key_str_remoteapplicationfile[] =
"remoteapplicationfile";
244static const char key_str_remoteapplicationguid[] =
"remoteapplicationguid";
245static const char key_str_remoteapplicationcmdline[] =
"remoteapplicationcmdline";
246static const char key_str_alternate_shell[] =
"alternate shell";
247static const char key_str_shell_working_directory[] =
"shell working directory";
248static const char key_str_gatewayhostname[] =
"gatewayhostname";
249static const char key_str_gatewayaccesstoken[] =
"gatewayaccesstoken";
250static const char key_str_endpointfedauth[] =
"endpointfedauth";
251static const char key_str_resourceprovider[] =
"resourceprovider";
252static const char str_resourceprovider_arm[] =
"arm";
253static const char key_str_kdcproxyname[] =
"kdcproxyname";
254static const char key_str_drivestoredirect[] =
"drivestoredirect";
255static const char key_str_devicestoredirect[] =
"devicestoredirect";
256static const char key_str_winposstr[] =
"winposstr";
257static const char key_str_pcb[] =
"pcb";
258static const char key_str_selectedmonitors[] =
"selectedmonitors";
260static const char key_str_wvd[] =
"wvd endpoint pool";
261static const char key_str_geo[] =
"geo";
262static const char key_str_armpath[] =
"armpath";
263static const char key_str_aadtenantid[] =
"aadtenantid";
265static const char key_str_diagnosticserviceurl[] =
"diagnosticserviceurl";
266static const char key_str_hubdiscoverygeourl[] =
"hubdiscoverygeourl";
268static const char key_str_activityhint[] =
"activityhint";
270static const char key_int_rdgiskdcproxy[] =
"rdgiskdcproxy";
271static const char key_int_use_redirection_server_name[] =
"use redirection server name";
272static const char key_int_gatewaycredentialssource[] =
"gatewaycredentialssource";
273static const char key_int_gatewayprofileusagemethod[] =
"gatewayprofileusagemethod";
274static const char key_int_gatewayusagemethod[] =
"gatewayusagemethod";
275static const char key_int_disableremoteappcapscheck[] =
"disableremoteappcapscheck";
276static const char key_int_disableconnectionsharing[] =
"disableconnectionsharing";
277static const char key_int_remoteapplicationexpandworkingdir[] =
"remoteapplicationexpandworkingdir";
278static const char key_int_remoteapplicationexpandcmdline[] =
"remoteapplicationexpandcmdline";
279static const char key_int_remoteapplicationmode[] =
"remoteapplicationmode";
280static const char key_int_enablecredsspsupport[] =
"enablecredsspsupport";
281static const char key_int_enablerdsaadauth[] =
"enablerdsaadauth";
282static const char key_int_negotiate_security_layer[] =
"negotiate security layer";
283static const char key_int_prompt_for_credentials[] =
"prompt for credentials";
284static const char key_int_promptcredentialonce[] =
"promptcredentialonce";
285static const char key_int_authentication_level[] =
"authentication level";
286static const char key_int_public_mode[] =
"public mode";
287static const char key_int_autoreconnect_max_retries[] =
"autoreconnect max retries";
288static const char key_int_autoreconnection_enabled[] =
"autoreconnection enabled";
289static const char key_int_administrative_session[] =
"administrative session";
290static const char key_int_connect_to_console[] =
"connect to console";
291static const char key_int_disableclipboardredirection[] =
"disableclipboardredirection";
292static const char key_int_disableprinterredirection[] =
"disableprinterredirection";
293static const char key_int_redirectdirectx[] =
"redirectdirectx";
294static const char key_int_redirectposdevices[] =
"redirectposdevices";
295static const char key_int_redirectclipboard[] =
"redirectclipboard";
296static const char key_int_redirectsmartcards[] =
"redirectsmartcards";
297static const char key_int_redirectcomports[] =
"redirectcomports";
298static const char key_int_redirectlocation[] =
"redirectlocation";
299static const char key_int_redirectprinters[] =
"redirectprinters";
300static const char key_int_redirectdrives[] =
"redirectdrives";
301static const char key_int_server_port[] =
"server port";
302static const char key_int_bitmapcachepersistenable[] =
"bitmapcachepersistenable";
303static const char key_int_bitmapcachesize[] =
"bitmapcachesize";
304static const char key_int_disable_cursor_setting[] =
"disable cursor setting";
305static const char key_int_disable_themes[] =
"disable themes";
306static const char key_int_disable_menu_anims[] =
"disable menu anims";
307static const char key_int_disable_full_window_drag[] =
"disable full window drag";
308static const char key_int_allow_desktop_composition[] =
"allow desktop composition";
309static const char key_int_allow_font_smoothing[] =
"allow font smoothing";
310static const char key_int_disable_wallpaper[] =
"disable wallpaper";
311static const char key_int_enableworkspacereconnect[] =
"enableworkspacereconnect";
312static const char key_int_workspaceid[] =
"workspaceid";
313static const char key_int_displayconnectionbar[] =
"displayconnectionbar";
314static const char key_int_pinconnectionbar[] =
"pinconnectionbar";
315static const char key_int_bandwidthautodetect[] =
"bandwidthautodetect";
316static const char key_int_networkautodetect[] =
"networkautodetect";
317static const char key_int_connection_type[] =
"connection type";
318static const char key_int_videoplaybackmode[] =
"videoplaybackmode";
319static const char key_int_redirected_video_capture_encoding_quality[] =
320 "redirected video capture encoding quality";
321static const char key_int_encode_redirected_video_capture[] =
"encode redirected video capture";
322static const char key_int_audiocapturemode[] =
"audiocapturemode";
323static const char key_int_audioqualitymode[] =
"audioqualitymode";
324static const char key_int_audiomode[] =
"audiomode";
325static const char key_int_disable_ctrl_alt_del[] =
"disable ctrl+alt+del";
326static const char key_int_keyboardhook[] =
"keyboardhook";
327static const char key_int_compression[] =
"compression";
328static const char key_int_desktopscalefactor[] =
"desktopscalefactor";
329static const char key_int_session_bpp[] =
"session bpp";
330static const char key_int_desktop_size_id[] =
"desktop size id";
331static const char key_int_desktopheight[] =
"desktopheight";
332static const char key_int_desktopwidth[] =
"desktopwidth";
333static const char key_int_superpanaccelerationfactor[] =
"superpanaccelerationfactor";
334static const char key_int_enablesuperpan[] =
"enablesuperpan";
335static const char key_int_dynamic_resolution[] =
"dynamic resolution";
336static const char key_int_smart_sizing[] =
"smart sizing";
337static const char key_int_span_monitors[] =
"span monitors";
338static const char key_int_screen_mode_id[] =
"screen mode id";
339static const char key_int_singlemoninwindowedmode[] =
"singlemoninwindowedmode";
340static const char key_int_maximizetocurrentdisplays[] =
"maximizetocurrentdisplays";
341static const char key_int_use_multimon[] =
"use multimon";
342static const char key_int_redirectwebauthn[] =
"redirectwebauthn";
345static BOOL is_pointer_used(
void* ptr)
347 return ~((size_t)ptr) != 0;
351static BOOL utils_str_is_empty(
const char* str)
355 if (strlen(str) == 0)
361static SSIZE_T freerdp_client_rdp_file_add_line(rdpFile* file);
364static rdpFileLine* freerdp_client_rdp_file_find_line_by_name(
const rdpFile* file,
366static void freerdp_client_file_string_check_free(LPSTR str);
369static BOOL freerdp_client_rdp_file_find_integer_entry(rdpFile* file,
const char* name,
370 DWORD** outValue, rdpFileLine** outLine)
374 WINPR_ASSERT(outValue);
375 WINPR_ASSERT(outLine);
380 if (_stricmp(name, key_int_use_multimon) == 0)
381 *outValue = &file->UseMultiMon;
382 else if (_stricmp(name, key_int_maximizetocurrentdisplays) == 0)
383 *outValue = &file->MaximizeToCurrentDisplays;
384 else if (_stricmp(name, key_int_singlemoninwindowedmode) == 0)
385 *outValue = &file->SingleMonInWindowedMode;
386 else if (_stricmp(name, key_int_screen_mode_id) == 0)
387 *outValue = &file->ScreenModeId;
388 else if (_stricmp(name, key_int_span_monitors) == 0)
389 *outValue = &file->SpanMonitors;
390 else if (_stricmp(name, key_int_smart_sizing) == 0)
391 *outValue = &file->SmartSizing;
392 else if (_stricmp(name, key_int_dynamic_resolution) == 0)
393 *outValue = &file->DynamicResolution;
394 else if (_stricmp(name, key_int_enablesuperpan) == 0)
395 *outValue = &file->EnableSuperSpan;
396 else if (_stricmp(name, key_int_superpanaccelerationfactor) == 0)
397 *outValue = &file->SuperSpanAccelerationFactor;
398 else if (_stricmp(name, key_int_desktopwidth) == 0)
399 *outValue = &file->DesktopWidth;
400 else if (_stricmp(name, key_int_desktopheight) == 0)
401 *outValue = &file->DesktopHeight;
402 else if (_stricmp(name, key_int_desktop_size_id) == 0)
403 *outValue = &file->DesktopSizeId;
404 else if (_stricmp(name, key_int_session_bpp) == 0)
405 *outValue = &file->SessionBpp;
406 else if (_stricmp(name, key_int_desktopscalefactor) == 0)
407 *outValue = &file->DesktopScaleFactor;
408 else if (_stricmp(name, key_int_compression) == 0)
409 *outValue = &file->Compression;
410 else if (_stricmp(name, key_int_keyboardhook) == 0)
411 *outValue = &file->KeyboardHook;
412 else if (_stricmp(name, key_int_disable_ctrl_alt_del) == 0)
413 *outValue = &file->DisableCtrlAltDel;
414 else if (_stricmp(name, key_int_audiomode) == 0)
415 *outValue = &file->AudioMode;
416 else if (_stricmp(name, key_int_audioqualitymode) == 0)
417 *outValue = &file->AudioQualityMode;
418 else if (_stricmp(name, key_int_audiocapturemode) == 0)
419 *outValue = &file->AudioCaptureMode;
420 else if (_stricmp(name, key_int_encode_redirected_video_capture) == 0)
421 *outValue = &file->EncodeRedirectedVideoCapture;
422 else if (_stricmp(name, key_int_redirected_video_capture_encoding_quality) == 0)
423 *outValue = &file->RedirectedVideoCaptureEncodingQuality;
424 else if (_stricmp(name, key_int_videoplaybackmode) == 0)
425 *outValue = &file->VideoPlaybackMode;
426 else if (_stricmp(name, key_int_connection_type) == 0)
427 *outValue = &file->ConnectionType;
428 else if (_stricmp(name, key_int_networkautodetect) == 0)
429 *outValue = &file->NetworkAutoDetect;
430 else if (_stricmp(name, key_int_bandwidthautodetect) == 0)
431 *outValue = &file->BandwidthAutoDetect;
432 else if (_stricmp(name, key_int_pinconnectionbar) == 0)
433 *outValue = &file->PinConnectionBar;
434 else if (_stricmp(name, key_int_displayconnectionbar) == 0)
435 *outValue = &file->DisplayConnectionBar;
436 else if (_stricmp(name, key_int_workspaceid) == 0)
437 *outValue = &file->WorkspaceId;
438 else if (_stricmp(name, key_int_enableworkspacereconnect) == 0)
439 *outValue = &file->EnableWorkspaceReconnect;
440 else if (_stricmp(name, key_int_disable_wallpaper) == 0)
441 *outValue = &file->DisableWallpaper;
442 else if (_stricmp(name, key_int_allow_font_smoothing) == 0)
443 *outValue = &file->AllowFontSmoothing;
444 else if (_stricmp(name, key_int_allow_desktop_composition) == 0)
445 *outValue = &file->AllowDesktopComposition;
446 else if (_stricmp(name, key_int_disable_full_window_drag) == 0)
447 *outValue = &file->DisableFullWindowDrag;
448 else if (_stricmp(name, key_int_disable_menu_anims) == 0)
449 *outValue = &file->DisableMenuAnims;
450 else if (_stricmp(name, key_int_disable_themes) == 0)
451 *outValue = &file->DisableThemes;
452 else if (_stricmp(name, key_int_disable_cursor_setting) == 0)
453 *outValue = &file->DisableCursorSetting;
454 else if (_stricmp(name, key_int_bitmapcachesize) == 0)
455 *outValue = &file->BitmapCacheSize;
456 else if (_stricmp(name, key_int_bitmapcachepersistenable) == 0)
457 *outValue = &file->BitmapCachePersistEnable;
458 else if (_stricmp(name, key_int_server_port) == 0)
459 *outValue = &file->ServerPort;
460 else if (_stricmp(name, key_int_redirectdrives) == 0)
461 *outValue = &file->RedirectDrives;
462 else if (_stricmp(name, key_int_redirectprinters) == 0)
463 *outValue = &file->RedirectPrinters;
464 else if (_stricmp(name, key_int_redirectcomports) == 0)
465 *outValue = &file->RedirectComPorts;
466 else if (_stricmp(name, key_int_redirectlocation) == 0)
467 *outValue = &file->RedirectLocation;
468 else if (_stricmp(name, key_int_redirectsmartcards) == 0)
469 *outValue = &file->RedirectSmartCards;
470 else if (_stricmp(name, key_int_redirectclipboard) == 0)
471 *outValue = &file->RedirectClipboard;
472 else if (_stricmp(name, key_int_redirectposdevices) == 0)
473 *outValue = &file->RedirectPosDevices;
474 else if (_stricmp(name, key_int_redirectdirectx) == 0)
475 *outValue = &file->RedirectDirectX;
476 else if (_stricmp(name, key_int_disableprinterredirection) == 0)
477 *outValue = &file->DisablePrinterRedirection;
478 else if (_stricmp(name, key_int_disableclipboardredirection) == 0)
479 *outValue = &file->DisableClipboardRedirection;
480 else if (_stricmp(name, key_int_connect_to_console) == 0)
481 *outValue = &file->ConnectToConsole;
482 else if (_stricmp(name, key_int_administrative_session) == 0)
483 *outValue = &file->AdministrativeSession;
484 else if (_stricmp(name, key_int_autoreconnection_enabled) == 0)
485 *outValue = &file->AutoReconnectionEnabled;
486 else if (_stricmp(name, key_int_autoreconnect_max_retries) == 0)
487 *outValue = &file->AutoReconnectMaxRetries;
488 else if (_stricmp(name, key_int_public_mode) == 0)
489 *outValue = &file->PublicMode;
490 else if (_stricmp(name, key_int_authentication_level) == 0)
491 *outValue = &file->AuthenticationLevel;
492 else if (_stricmp(name, key_int_promptcredentialonce) == 0)
493 *outValue = &file->PromptCredentialOnce;
494 else if ((_stricmp(name, key_int_prompt_for_credentials) == 0))
495 *outValue = &file->PromptForCredentials;
496 else if (_stricmp(name, key_int_negotiate_security_layer) == 0)
497 *outValue = &file->NegotiateSecurityLayer;
498 else if (_stricmp(name, key_int_enablecredsspsupport) == 0)
499 *outValue = &file->EnableCredSSPSupport;
500 else if (_stricmp(name, key_int_enablerdsaadauth) == 0)
501 *outValue = &file->EnableRdsAadAuth;
502 else if (_stricmp(name, key_int_remoteapplicationmode) == 0)
503 *outValue = &file->RemoteApplicationMode;
504 else if (_stricmp(name, key_int_remoteapplicationexpandcmdline) == 0)
505 *outValue = &file->RemoteApplicationExpandCmdLine;
506 else if (_stricmp(name, key_int_remoteapplicationexpandworkingdir) == 0)
507 *outValue = &file->RemoteApplicationExpandWorkingDir;
508 else if (_stricmp(name, key_int_disableconnectionsharing) == 0)
509 *outValue = &file->DisableConnectionSharing;
510 else if (_stricmp(name, key_int_disableremoteappcapscheck) == 0)
511 *outValue = &file->DisableRemoteAppCapsCheck;
512 else if (_stricmp(name, key_int_gatewayusagemethod) == 0)
513 *outValue = &file->GatewayUsageMethod;
514 else if (_stricmp(name, key_int_gatewayprofileusagemethod) == 0)
515 *outValue = &file->GatewayProfileUsageMethod;
516 else if (_stricmp(name, key_int_gatewaycredentialssource) == 0)
517 *outValue = &file->GatewayCredentialsSource;
518 else if (_stricmp(name, key_int_use_redirection_server_name) == 0)
519 *outValue = &file->UseRedirectionServerName;
520 else if (_stricmp(name, key_int_rdgiskdcproxy) == 0)
521 *outValue = &file->RdgIsKdcProxy;
522 else if (_stricmp(name, key_int_redirectwebauthn) == 0)
523 *outValue = &file->RedirectWebauthN;
526 rdpFileLine* line = freerdp_client_rdp_file_find_line_by_name(file, name);
529 if (!(line->flags & RDP_FILE_LINE_FLAG_TYPE_INTEGER))
539static BOOL freerdp_client_rdp_file_find_string_entry(rdpFile* file,
const char* name,
540 LPSTR** outValue, rdpFileLine** outLine)
544 WINPR_ASSERT(outValue);
545 WINPR_ASSERT(outLine);
550 if (_stricmp(name, key_str_username) == 0)
551 *outValue = &file->Username;
552 else if (_stricmp(name, key_str_domain) == 0)
553 *outValue = &file->Domain;
554 else if (_stricmp(name, key_str_password) == 0)
555 *outValue = &file->Password;
556 else if (_stricmp(name, key_str_full_address) == 0)
557 *outValue = &file->FullAddress;
558 else if (_stricmp(name, key_str_alternate_full_address) == 0)
559 *outValue = &file->AlternateFullAddress;
560 else if (_stricmp(name, key_str_usbdevicestoredirect) == 0)
561 *outValue = &file->UsbDevicesToRedirect;
562 else if (_stricmp(name, key_str_camerastoredirect) == 0)
563 *outValue = &file->RedirectCameras;
564 else if (_stricmp(name, key_str_loadbalanceinfo) == 0)
565 *outValue = &file->LoadBalanceInfo;
566 else if (_stricmp(name, key_str_remoteapplicationname) == 0)
567 *outValue = &file->RemoteApplicationName;
568 else if (_stricmp(name, key_str_remoteapplicationicon) == 0)
569 *outValue = &file->RemoteApplicationIcon;
570 else if (_stricmp(name, key_str_remoteapplicationprogram) == 0)
571 *outValue = &file->RemoteApplicationProgram;
572 else if (_stricmp(name, key_str_remoteapplicationfile) == 0)
573 *outValue = &file->RemoteApplicationFile;
574 else if (_stricmp(name, key_str_remoteapplicationguid) == 0)
575 *outValue = &file->RemoteApplicationGuid;
576 else if (_stricmp(name, key_str_remoteapplicationcmdline) == 0)
577 *outValue = &file->RemoteApplicationCmdLine;
578 else if (_stricmp(name, key_str_alternate_shell) == 0)
579 *outValue = &file->AlternateShell;
580 else if (_stricmp(name, key_str_shell_working_directory) == 0)
581 *outValue = &file->ShellWorkingDirectory;
582 else if (_stricmp(name, key_str_gatewayhostname) == 0)
583 *outValue = &file->GatewayHostname;
584 else if (_stricmp(name, key_str_resourceprovider) == 0)
585 *outValue = &file->ResourceProvider;
586 else if (_stricmp(name, key_str_wvd) == 0)
587 *outValue = &file->WvdEndpointPool;
588 else if (_stricmp(name, key_str_geo) == 0)
589 *outValue = &file->geo;
590 else if (_stricmp(name, key_str_armpath) == 0)
591 *outValue = &file->armpath;
592 else if (_stricmp(name, key_str_aadtenantid) == 0)
593 *outValue = &file->aadtenantid;
594 else if (_stricmp(name, key_str_diagnosticserviceurl) == 0)
595 *outValue = &file->diagnosticserviceurl;
596 else if (_stricmp(name, key_str_hubdiscoverygeourl) == 0)
597 *outValue = &file->hubdiscoverygeourl;
598 else if (_stricmp(name, key_str_activityhint) == 0)
599 *outValue = &file->activityhint;
600 else if (_stricmp(name, key_str_gatewayaccesstoken) == 0)
601 *outValue = &file->GatewayAccessToken;
602 else if (_stricmp(name, key_str_endpointfedauth) == 0)
603 *outValue = &file->EndpointFedAuthToken;
604 else if (_stricmp(name, key_str_kdcproxyname) == 0)
605 *outValue = &file->KdcProxyName;
606 else if (_stricmp(name, key_str_drivestoredirect) == 0)
607 *outValue = &file->DrivesToRedirect;
608 else if (_stricmp(name, key_str_devicestoredirect) == 0)
609 *outValue = &file->DevicesToRedirect;
610 else if (_stricmp(name, key_str_winposstr) == 0)
611 *outValue = &file->WinPosStr;
612 else if (_stricmp(name, key_str_pcb) == 0)
613 *outValue = &file->PreconnectionBlob;
614 else if (_stricmp(name, key_str_selectedmonitors) == 0)
615 *outValue = &file->SelectedMonitors;
618 rdpFileLine* line = freerdp_client_rdp_file_find_line_by_name(file, name);
621 if (!(line->flags & RDP_FILE_LINE_FLAG_TYPE_STRING))
637static BOOL freerdp_client_rdp_file_set_integer(rdpFile* file,
const char* name,
long value)
639 DWORD* targetValue =
nullptr;
640 rdpFileLine* line =
nullptr;
641#ifdef DEBUG_CLIENT_FILE
642 WLog_DBG(TAG,
"%s:i:%ld", name, value);
648 if (!freerdp_client_rdp_file_find_integer_entry(file, name, &targetValue, &line))
650 SSIZE_T index = freerdp_client_rdp_file_add_line(file);
653 line = &file->lines[index];
658 *targetValue = (DWORD)value;
665 line->name = _strdup(name);
669 line->name =
nullptr;
673 line->iValue = value;
674 line->flags = RDP_FILE_LINE_FLAG_FORMATTED;
675 line->flags |= RDP_FILE_LINE_FLAG_TYPE_INTEGER;
676 line->valueLength = 0;
684static BOOL freerdp_client_parse_rdp_file_integer(rdpFile* file,
const char* name,
687 char* endptr =
nullptr;
690 ivalue = strtol(value, &endptr, 0);
692 if ((endptr ==
nullptr) || (errno != 0) || (endptr == value) || (ivalue > INT32_MAX) ||
693 (ivalue < INT32_MIN))
695 if (file->flags & RDP_FILE_FLAG_PARSE_INT_RELAXED)
697 WLog_WARN(TAG,
"Integer option %s has invalid value %s, using default", name, value);
702 WLog_ERR(TAG,
"Failed to convert RDP file integer option %s [value=%s]", name, value);
707 return freerdp_client_rdp_file_set_integer(file, name, ivalue);
718static BOOL freerdp_client_rdp_file_set_string(rdpFile* file,
const char* name,
const char* value)
720 LPSTR* targetValue =
nullptr;
721 rdpFileLine* line =
nullptr;
722#ifdef DEBUG_CLIENT_FILE
723 WLog_DBG(TAG,
"%s:s:%s", name, value);
729 if (!freerdp_client_rdp_file_find_string_entry(file, name, &targetValue, &line))
731 SSIZE_T index = freerdp_client_rdp_file_add_line(file);
734 line = &file->lines[index];
739 if ((uintptr_t)(*targetValue) != UINTPTR_MAX)
742 *targetValue = _strdup(value);
743 return ((*targetValue) !=
nullptr);
750 line->name = _strdup(name);
751 line->sValue = _strdup(value);
752 if (!line->name || !line->sValue)
756 line->name =
nullptr;
757 line->sValue =
nullptr;
761 line->flags = RDP_FILE_LINE_FLAG_FORMATTED;
762 line->flags |= RDP_FILE_LINE_FLAG_TYPE_STRING;
763 line->valueLength = 0;
771static BOOL freerdp_client_add_option(rdpFile* file,
const char* option)
773 return freerdp_addin_argv_add_argument(file->args, option);
777static SSIZE_T freerdp_client_rdp_file_add_line(rdpFile* file)
779 SSIZE_T index = (SSIZE_T)file->lineCount;
781 while ((file->lineCount + 1) > file->lineSize)
783 size_t new_size = file->lineCount + 2048;
784 rdpFileLine* new_line = (rdpFileLine*)realloc(file->lines, new_size *
sizeof(rdpFileLine));
789 file->lines = new_line;
790 file->lineSize = new_size;
793 ZeroMemory(&(file->lines[file->lineCount]),
sizeof(rdpFileLine));
794 file->lines[file->lineCount].index = (size_t)index;
799BOOL freerdp_client_parse_rdp_file_buffer(rdpFile* file,
const BYTE* buffer,
size_t size)
801 return freerdp_client_parse_rdp_file_buffer_ex(file, buffer, size,
nullptr);
805static BOOL trim(
char** strptr)
807 char* start =
nullptr;
811 start = str = *strptr;
814 if (!(is_pointer_used(str)))
816 end = str + strlen(str) - 1;
818 while (isspace(*str))
821 while ((end > str) && isspace(*end))
828 *strptr = _strdup(str);
830 return *strptr !=
nullptr;
837static BOOL trim_strings(rdpFile* file)
839 if (!trim(&file->Username))
841 if (!trim(&file->Domain))
843 if (!trim(&file->AlternateFullAddress))
845 if (!trim(&file->FullAddress))
847 if (!trim(&file->UsbDevicesToRedirect))
849 if (!trim(&file->RedirectCameras))
851 if (!trim(&file->LoadBalanceInfo))
853 if (!trim(&file->GatewayHostname))
855 if (!trim(&file->GatewayAccessToken))
857 if (!trim(&file->EndpointFedAuthToken))
859 if (!trim(&file->RemoteApplicationName))
861 if (!trim(&file->RemoteApplicationIcon))
863 if (!trim(&file->RemoteApplicationProgram))
865 if (!trim(&file->RemoteApplicationFile))
867 if (!trim(&file->RemoteApplicationGuid))
869 if (!trim(&file->RemoteApplicationCmdLine))
871 if (!trim(&file->AlternateShell))
873 if (!trim(&file->ShellWorkingDirectory))
875 if (!trim(&file->DrivesToRedirect))
877 if (!trim(&file->DevicesToRedirect))
879 if (!trim(&file->WinPosStr))
881 if (!trim(&file->PreconnectionBlob))
883 if (!trim(&file->KdcProxyName))
885 if (!trim(&file->SelectedMonitors))
888 for (
size_t i = 0; i < file->lineCount; ++i)
890 rdpFileLine* curLine = &file->lines[i];
891 if (curLine->flags & RDP_FILE_LINE_FLAG_TYPE_STRING)
893 if (!trim(&curLine->sValue))
902static BOOL parse_line(rdpFile* file,
char* line,
size_t length, rdp_file_fkt_parse parse)
907 const char* beg = line;
908#if !defined(WITHOUT_FREERDP_3x_DEPRECATED)
909#if defined(WITH_EMBEDDED_CLI_IN_RDP_FILES)
912 freerdp_warn_deprecated(WLog_Get(TAG),
"Parsing CLI options within an RDP file",
913 "Will be removed in FreeRDP 4.0");
914 if (!freerdp_client_add_option(file, line))
922 char* d1 = strchr(line,
':');
927 const char* type = &d1[1];
928 char* d2 = strchr(type,
':');
938 const char* name = beg;
939 const char* value = &d2[1];
941 if (parse && parse(file->context, name, *type, value))
947 return freerdp_client_parse_rdp_file_integer(file, name, value);
952 return freerdp_client_rdp_file_set_string(file, name, value);
957 WLog_ERR(TAG,
"Unsupported RDP file binary option %s [value=%s]", name, value);
963BOOL freerdp_client_parse_rdp_file_buffer_ex(rdpFile* file,
const BYTE* buffer,
size_t size,
964 rdp_file_fkt_parse parse)
967 char* copy =
nullptr;
974 if ((buffer[0] == BOM_UTF16_LE[0]) && (buffer[1] == BOM_UTF16_LE[1]))
977 const size_t nobomsize = size - 2;
978 WCHAR* uc = calloc(nobomsize + 2, 1);
981 memcpy(uc, &buffer[2], nobomsize);
982 const size_t charlen = nobomsize /
sizeof(WCHAR);
983 copy = ConvertWCharNToUtf8Alloc(uc, charlen, &size);
984 winpr_znfree(uc, nobomsize);
987 WLog_ERR(TAG,
"Failed to convert RDP file from UCS2 to UTF8");
993 copy = calloc(1, size +
sizeof(BYTE));
998 memcpy(copy, buffer, size);
1001 char* context =
nullptr;
1002 char* line = strtok_s(copy,
"\r\n", &context);
1006 const size_t length = strnlen(line, size);
1008 if (!parse_line(file, line, length, parse))
1011 line = strtok_s(
nullptr,
"\r\n", &context);
1014 rc = trim_strings(file);
1020BOOL freerdp_client_parse_rdp_file(rdpFile* file,
const char* name)
1022 return freerdp_client_parse_rdp_file_ex(file, name,
nullptr);
1025BOOL freerdp_client_parse_rdp_file_ex(rdpFile* file,
const char* name, rdp_file_fkt_parse parse)
1028 BYTE* buffer =
nullptr;
1030 size_t read_size = 0;
1031 INT64 file_size = 0;
1032 const char* fname = name;
1037 if (_strnicmp(fname,
"file://", 7) == 0)
1040 fp = winpr_fopen(fname,
"r");
1043 WLog_ERR(TAG,
"Failed to open RDP file %s", name);
1047 if (_fseeki64(fp, 0, SEEK_END) < 0)
1049 file_size = _ftelli64(fp);
1050 if (_fseeki64(fp, 0, SEEK_SET) < 0)
1055 WLog_ERR(TAG,
"RDP file %s is empty", name);
1059 buffer = (BYTE*)malloc((
size_t)file_size + 2);
1064 read_size = fread(buffer, (
size_t)file_size, 1, fp);
1069 read_size = (size_t)file_size;
1074 WLog_ERR(TAG,
"Could not read from RDP file %s", name);
1078 buffer[file_size] =
'\0';
1079 buffer[file_size + 1] =
'\0';
1080 status = freerdp_client_parse_rdp_file_buffer_ex(file, buffer, (
size_t)file_size, parse);
1088static inline void freerdp_client_file_string_reset(
char** target)
1090 WINPR_ASSERT(target);
1091 freerdp_client_file_string_check_free(*target);
1092 *target = (
char*)UINTPTR_MAX;
1096static inline BOOL FILE_POPULATE_STRING(
char** _target,
const rdpSettings* _settings,
1097 FreeRDP_Settings_Keys_String _option)
1099 WINPR_ASSERT(_target);
1100 WINPR_ASSERT(_settings);
1103 freerdp_client_file_string_reset(_target);
1106 char* copy = _strdup(str);
1115static char* freerdp_client_channel_args_to_string(
const rdpSettings* settings,
const char* channel,
1118 ADDIN_ARGV* args = freerdp_dynamic_channel_collection_find(settings, channel);
1119 const char* filters[] = { option };
1120 if (!args || (args->argc < 2))
1123 return CommandLineToCommaSeparatedValuesEx(args->argc - 1, args->argv + 1, filters,
1124 ARRAYSIZE(filters));
1128static BOOL rdp_opt_duplicate(
const rdpSettings* _settings, FreeRDP_Settings_Keys_String _id,
1131 WINPR_ASSERT(_settings);
1137 *_key = _strdup(tmp);
1145BOOL freerdp_client_populate_rdp_file_from_settings(rdpFile* file,
const rdpSettings* settings)
1147 FreeRDP_Settings_Keys_String index = FreeRDP_STRING_UNUSED;
1148 UINT32 LoadBalanceInfoLength = 0;
1149 const char* GatewayHostname =
nullptr;
1150 char* redirectCameras =
nullptr;
1152 if (!file || !settings)
1155 if (!FILE_POPULATE_STRING(&file->Domain, settings, FreeRDP_Domain) ||
1156 !FILE_POPULATE_STRING(&file->Username, settings, FreeRDP_Username) ||
1157 !FILE_POPULATE_STRING(&file->Password, settings, FreeRDP_Password) ||
1158 !FILE_POPULATE_STRING(&file->FullAddress, settings, FreeRDP_ServerHostname) ||
1159 !FILE_POPULATE_STRING(&file->AlternateFullAddress, settings, FreeRDP_ServerHostname) ||
1160 !FILE_POPULATE_STRING(&file->AlternateShell, settings, FreeRDP_AlternateShell) ||
1161 !FILE_POPULATE_STRING(&file->DrivesToRedirect, settings, FreeRDP_DrivesToRedirect))
1170 file->DynamicResolution = WINPR_ASSERTING_INT_CAST(
1172 file->VideoPlaybackMode = WINPR_ASSERTING_INT_CAST(
1179 file->ConnectToConsole = WINPR_ASSERTING_INT_CAST(
1181 file->NegotiateSecurityLayer = WINPR_ASSERTING_INT_CAST(
1186 file->EnableCredSSPSupport = WINPR_ASSERTING_INT_CAST(UINT32, nla);
1187 file->EnableRdsAadAuth =
1191 index = FreeRDP_RemoteApplicationWorkingDir;
1193 index = FreeRDP_ShellWorkingDirectory;
1194 if (!FILE_POPULATE_STRING(&file->ShellWorkingDirectory, settings, index))
1202 if (LoadBalanceInfoLength > 0)
1204 const BYTE* LoadBalanceInfo =
1206 file->LoadBalanceInfo = calloc(LoadBalanceInfoLength + 1, 1);
1207 if (!file->LoadBalanceInfo)
1209 memcpy(file->LoadBalanceInfo, LoadBalanceInfo, LoadBalanceInfoLength);
1213 file->AudioMode = AUDIO_MODE_REDIRECT;
1215 file->AudioMode = AUDIO_MODE_PLAY_ON_SERVER;
1217 file->AudioMode = AUDIO_MODE_NONE;
1222 if (GatewayHostname)
1225 freerdp_client_file_string_check_free(file->GatewayHostname);
1226 if (GatewayPort == 443)
1227 file->GatewayHostname = _strdup(GatewayHostname);
1230 int length = _scprintf(
"%s:%" PRIu32, GatewayHostname, GatewayPort);
1234 file->GatewayHostname = (
char*)malloc((
size_t)length + 1);
1235 if (!file->GatewayHostname)
1238 if (sprintf_s(file->GatewayHostname, (
size_t)length + 1,
"%s:%" PRIu32, GatewayHostname,
1242 if (!file->GatewayHostname)
1247 file->ResourceProvider = _strdup(str_resourceprovider_arm);
1249 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdWvdEndpointPool, &file->WvdEndpointPool))
1251 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdGeo, &file->geo))
1253 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdArmpath, &file->armpath))
1255 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdAadtenantid, &file->aadtenantid))
1257 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdDiagnosticserviceurl,
1258 &file->diagnosticserviceurl))
1260 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdHubdiscoverygeourl,
1261 &file->hubdiscoverygeourl))
1263 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdActivityhint, &file->activityhint))
1266 file->AudioCaptureMode =
1268 file->BitmapCachePersistEnable = WINPR_ASSERTING_INT_CAST(
1270 file->Compression = WINPR_ASSERTING_INT_CAST(
1273 file->GatewayUsageMethod = freerdp_get_gateway_usage_method(settings);
1274 file->GatewayCredentialsSource =
1276 file->PromptCredentialOnce = WINPR_ASSERTING_INT_CAST(
1278 file->PromptForCredentials = WINPR_ASSERTING_INT_CAST(
1280 file->RemoteApplicationMode = WINPR_ASSERTING_INT_CAST(
1282 if (!FILE_POPULATE_STRING(&file->GatewayAccessToken, settings, FreeRDP_GatewayAccessToken) ||
1283 !FILE_POPULATE_STRING(&file->EndpointFedAuthToken, settings,
1284 FreeRDP_EndpointFedAuthToken) ||
1285 !FILE_POPULATE_STRING(&file->RemoteApplicationProgram, settings,
1286 FreeRDP_RemoteApplicationProgram) ||
1287 !FILE_POPULATE_STRING(&file->RemoteApplicationName, settings,
1288 FreeRDP_RemoteApplicationName) ||
1289 !FILE_POPULATE_STRING(&file->RemoteApplicationIcon, settings,
1290 FreeRDP_RemoteApplicationIcon) ||
1291 !FILE_POPULATE_STRING(&file->RemoteApplicationFile, settings,
1292 FreeRDP_RemoteApplicationFile) ||
1293 !FILE_POPULATE_STRING(&file->RemoteApplicationGuid, settings,
1294 FreeRDP_RemoteApplicationGuid) ||
1295 !FILE_POPULATE_STRING(&file->RemoteApplicationCmdLine, settings,
1296 FreeRDP_RemoteApplicationCmdLine))
1298 file->SpanMonitors =
1302 file->AllowDesktopComposition = WINPR_ASSERTING_INT_CAST(
1304 file->AllowFontSmoothing = WINPR_ASSERTING_INT_CAST(
1306 file->DisableWallpaper = WINPR_ASSERTING_INT_CAST(
1308 file->DisableFullWindowDrag = WINPR_ASSERTING_INT_CAST(
1310 file->DisableMenuAnims = WINPR_ASSERTING_INT_CAST(
1312 file->DisableThemes = WINPR_ASSERTING_INT_CAST(
1315 CONNECTION_TYPE_AUTODETECT);
1316 file->NetworkAutoDetect =
1318 file->AutoReconnectionEnabled = WINPR_ASSERTING_INT_CAST(
1320 file->RedirectSmartCards = WINPR_ASSERTING_INT_CAST(
1322 file->RedirectWebauthN = WINPR_ASSERTING_INT_CAST(
1326 freerdp_client_channel_args_to_string(settings, RDPECAM_DVC_CHANNEL_NAME,
"device:");
1327 if (redirectCameras)
1330 freerdp_client_channel_args_to_string(settings, RDPECAM_DVC_CHANNEL_NAME,
"encode:");
1331 file->EncodeRedirectedVideoCapture = 0;
1334 unsigned long val = 0;
1336 val = strtoul(str,
nullptr, 0);
1337 if ((val < UINT32_MAX) && (errno == 0))
1338 file->EncodeRedirectedVideoCapture = (UINT32)val;
1342 str = freerdp_client_channel_args_to_string(settings, RDPECAM_DVC_CHANNEL_NAME,
"quality:");
1343 file->RedirectedVideoCaptureEncodingQuality = 0;
1346 unsigned long val = 0;
1348 val = strtoul(str,
nullptr, 0);
1349 if ((val <= 2) && (errno == 0))
1351 file->RedirectedVideoCaptureEncodingQuality = (UINT32)val;
1356 file->RedirectCameras = redirectCameras;
1359 freerdp_client_file_string_reset(&file->RedirectCameras);
1361#ifdef CHANNEL_URBDRC_CLIENT
1363 freerdp_client_channel_args_to_string(settings, URBDRC_CHANNEL_NAME,
"device:");
1365 file->UsbDevicesToRedirect = redirectUsb;
1367 freerdp_client_file_string_reset(&file->UsbDevicesToRedirect);
1370 file->RedirectClipboard =
1377 file->RedirectLocation =
1379 if (!FILE_POPULATE_STRING(&file->DrivesToRedirect, settings, FreeRDP_DrivesToRedirect) ||
1380 !FILE_POPULATE_STRING(&file->PreconnectionBlob, settings, FreeRDP_PreconnectionBlob) ||
1381 !FILE_POPULATE_STRING(&file->KdcProxyName, settings, FreeRDP_KerberosKdcUrl))
1389 size_t size = count * (10 + 1) + 1;
1391 char* str = calloc(size,
sizeof(
char));
1392 for (UINT32 x = 0; x < count; x++)
1394 int rc = _snprintf(&str[offset], size - offset,
"%" PRIu32
",", MonitorIds[x]);
1400 offset += (size_t)rc;
1403 str[offset - 1] =
'\0';
1404 freerdp_client_file_string_check_free(file->SelectedMonitors);
1405 file->SelectedMonitors = str;
1413BOOL freerdp_client_write_rdp_file(
const rdpFile* file,
const char* name, BOOL unicode)
1416 WCHAR* unicodestr =
nullptr;
1421 const size_t size = freerdp_client_write_rdp_file_buffer(file,
nullptr, 0);
1424 char* buffer = calloc(size + 1ULL,
sizeof(
char));
1428 if (freerdp_client_write_rdp_file_buffer(file, buffer, size + 1) != size)
1430 WLog_ERR(TAG,
"freerdp_client_write_rdp_file: error writing to output buffer");
1435 FILE* fp = winpr_fopen(name,
"w+b");
1442 unicodestr = ConvertUtf8NToWCharAlloc(buffer, size, &len);
1452 if ((fwrite(BOM_UTF16_LE,
sizeof(BYTE), 2, fp) != 2) ||
1453 (fwrite(unicodestr,
sizeof(WCHAR), len, fp) != len))
1465 if (fwrite(buffer, 1, size, fp) != size)
1474 status = fclose(fp);
1478 return (status == 0);
1481WINPR_ATTR_FORMAT_ARG(3, 4)
1482static SSIZE_T freerdp_client_write_setting_to_buffer(
char** buffer,
size_t* bufferSize,
1483 WINPR_FORMAT_ARG const
char* fmt, ...)
1485 va_list ap = WINPR_C_ARRAY_INIT;
1487 char* buf =
nullptr;
1490 if (!buffer || !bufferSize || !fmt)
1494 bufSize = *bufferSize;
1497 len = vsnprintf(buf, bufSize, fmt, ap);
1506 if (!buf && !bufSize)
1513 if (bufSize >= (
size_t)len)
1515 *bufferSize -= (size_t)len;
1516 buf[len - 1] =
'\n';
1517 *buffer = buf + len;
1526static SSIZE_T write_int_parameters(
const rdpFile* file,
char* buffer,
size_t size)
1535 const struct intentry_t settings[] = {
1536 { key_int_use_multimon, file->UseMultiMon },
1537 { key_int_maximizetocurrentdisplays, file->MaximizeToCurrentDisplays },
1538 { key_int_singlemoninwindowedmode, file->SingleMonInWindowedMode },
1539 { key_int_screen_mode_id, file->ScreenModeId },
1540 { key_int_span_monitors, file->SpanMonitors },
1541 { key_int_smart_sizing, file->SmartSizing },
1542 { key_int_dynamic_resolution, file->DynamicResolution },
1543 { key_int_enablesuperpan, file->EnableSuperSpan },
1544 { key_int_superpanaccelerationfactor, file->SuperSpanAccelerationFactor },
1545 { key_int_desktopwidth, file->DesktopWidth },
1546 { key_int_desktopheight, file->DesktopHeight },
1547 { key_int_desktop_size_id, file->DesktopSizeId },
1548 { key_int_session_bpp, file->SessionBpp },
1549 { key_int_desktopscalefactor, file->DesktopScaleFactor },
1550 { key_int_compression, file->Compression },
1551 { key_int_keyboardhook, file->KeyboardHook },
1552 { key_int_disable_ctrl_alt_del, file->DisableCtrlAltDel },
1553 { key_int_audiomode, file->AudioMode },
1554 { key_int_audioqualitymode, file->AudioQualityMode },
1555 { key_int_audiocapturemode, file->AudioCaptureMode },
1556 { key_int_encode_redirected_video_capture, file->EncodeRedirectedVideoCapture },
1557 { key_int_redirected_video_capture_encoding_quality,
1558 file->RedirectedVideoCaptureEncodingQuality },
1559 { key_int_videoplaybackmode, file->VideoPlaybackMode },
1560 { key_int_connection_type, file->ConnectionType },
1561 { key_int_networkautodetect, file->NetworkAutoDetect },
1562 { key_int_bandwidthautodetect, file->BandwidthAutoDetect },
1563 { key_int_pinconnectionbar, file->PinConnectionBar },
1564 { key_int_displayconnectionbar, file->DisplayConnectionBar },
1565 { key_int_workspaceid, file->WorkspaceId },
1566 { key_int_enableworkspacereconnect, file->EnableWorkspaceReconnect },
1567 { key_int_disable_wallpaper, file->DisableWallpaper },
1568 { key_int_allow_font_smoothing, file->AllowFontSmoothing },
1569 { key_int_allow_desktop_composition, file->AllowDesktopComposition },
1570 { key_int_disable_full_window_drag, file->DisableFullWindowDrag },
1571 { key_int_disable_menu_anims, file->DisableMenuAnims },
1572 { key_int_disable_themes, file->DisableThemes },
1573 { key_int_disable_cursor_setting, file->DisableCursorSetting },
1574 { key_int_bitmapcachesize, file->BitmapCacheSize },
1575 { key_int_bitmapcachepersistenable, file->BitmapCachePersistEnable },
1576 { key_int_server_port, file->ServerPort },
1577 { key_int_redirectdrives, file->RedirectDrives },
1578 { key_int_redirectprinters, file->RedirectPrinters },
1579 { key_int_redirectcomports, file->RedirectComPorts },
1580 { key_int_redirectlocation, file->RedirectLocation },
1581 { key_int_redirectsmartcards, file->RedirectSmartCards },
1582 { key_int_redirectclipboard, file->RedirectClipboard },
1583 { key_int_redirectposdevices, file->RedirectPosDevices },
1584 { key_int_redirectdirectx, file->RedirectDirectX },
1585 { key_int_disableprinterredirection, file->DisablePrinterRedirection },
1586 { key_int_disableclipboardredirection, file->DisableClipboardRedirection },
1587 { key_int_connect_to_console, file->ConnectToConsole },
1588 { key_int_administrative_session, file->AdministrativeSession },
1589 { key_int_autoreconnection_enabled, file->AutoReconnectionEnabled },
1590 { key_int_autoreconnect_max_retries, file->AutoReconnectMaxRetries },
1591 { key_int_public_mode, file->PublicMode },
1592 { key_int_authentication_level, file->AuthenticationLevel },
1593 { key_int_promptcredentialonce, file->PromptCredentialOnce },
1594 { key_int_prompt_for_credentials, file->PromptForCredentials },
1595 { key_int_negotiate_security_layer, file->NegotiateSecurityLayer },
1596 { key_int_enablecredsspsupport, file->EnableCredSSPSupport },
1597 { key_int_enablerdsaadauth, file->EnableRdsAadAuth },
1598 { key_int_remoteapplicationmode, file->RemoteApplicationMode },
1599 { key_int_remoteapplicationexpandcmdline, file->RemoteApplicationExpandCmdLine },
1600 { key_int_remoteapplicationexpandworkingdir, file->RemoteApplicationExpandWorkingDir },
1601 { key_int_disableconnectionsharing, file->DisableConnectionSharing },
1602 { key_int_disableremoteappcapscheck, file->DisableRemoteAppCapsCheck },
1603 { key_int_gatewayusagemethod, file->GatewayUsageMethod },
1604 { key_int_gatewayprofileusagemethod, file->GatewayProfileUsageMethod },
1605 { key_int_gatewaycredentialssource, file->GatewayCredentialsSource },
1606 { key_int_use_redirection_server_name, file->UseRedirectionServerName },
1607 { key_int_rdgiskdcproxy, file->RdgIsKdcProxy },
1608 { key_int_redirectwebauthn, file->RedirectWebauthN }
1611 SSIZE_T totalSize = 0;
1612 for (
size_t x = 0; x < ARRAYSIZE(settings); x++)
1614 const struct intentry_t* cur = &settings[x];
1617 const SSIZE_T res = freerdp_client_write_setting_to_buffer(
1618 &buffer, &size,
"%s:i:%" PRIu32, cur->key, cur->val);
1629static SSIZE_T write_string_parameters(
const rdpFile* file,
char* buffer,
size_t size)
1638 const struct strentry_t settings[] = {
1639 { key_str_username, file->Username },
1640 { key_str_domain, file->Domain },
1641 { key_str_password, file->Password },
1642 { key_str_full_address, file->FullAddress },
1643 { key_str_alternate_full_address, file->AlternateFullAddress },
1644 { key_str_usbdevicestoredirect, file->UsbDevicesToRedirect },
1645 { key_str_camerastoredirect, file->RedirectCameras },
1646 { key_str_loadbalanceinfo, file->LoadBalanceInfo },
1647 { key_str_remoteapplicationname, file->RemoteApplicationName },
1648 { key_str_remoteapplicationicon, file->RemoteApplicationIcon },
1649 { key_str_remoteapplicationprogram, file->RemoteApplicationProgram },
1650 { key_str_remoteapplicationfile, file->RemoteApplicationFile },
1651 { key_str_remoteapplicationguid, file->RemoteApplicationGuid },
1652 { key_str_remoteapplicationcmdline, file->RemoteApplicationCmdLine },
1653 { key_str_alternate_shell, file->AlternateShell },
1654 { key_str_shell_working_directory, file->ShellWorkingDirectory },
1655 { key_str_gatewayhostname, file->GatewayHostname },
1656 { key_str_resourceprovider, file->ResourceProvider },
1657 { key_str_wvd, file->WvdEndpointPool },
1658 { key_str_geo, file->geo },
1659 { key_str_armpath, file->armpath },
1660 { key_str_aadtenantid, file->aadtenantid },
1661 { key_str_diagnosticserviceurl, file->diagnosticserviceurl },
1662 { key_str_hubdiscoverygeourl, file->hubdiscoverygeourl },
1663 { key_str_activityhint, file->activityhint },
1664 { key_str_gatewayaccesstoken, file->GatewayAccessToken },
1665 { key_str_endpointfedauth, file->EndpointFedAuthToken },
1666 { key_str_kdcproxyname, file->KdcProxyName },
1667 { key_str_drivestoredirect, file->DrivesToRedirect },
1668 { key_str_devicestoredirect, file->DevicesToRedirect },
1669 { key_str_winposstr, file->WinPosStr },
1670 { key_str_pcb, file->PreconnectionBlob },
1671 { key_str_selectedmonitors, file->SelectedMonitors }
1674 SSIZE_T totalSize = 0;
1675 for (
size_t x = 0; x < ARRAYSIZE(settings); x++)
1677 const struct strentry_t* cur = &settings[x];
1678 if (~(
size_t)(cur->val))
1680 const SSIZE_T res = freerdp_client_write_setting_to_buffer(&buffer, &size,
"%s:s:%s",
1681 cur->key, cur->val);
1692static SSIZE_T write_custom_parameters(
const rdpFile* file,
char* buffer,
size_t size)
1696 SSIZE_T totalSize = 0;
1698 for (
size_t i = 0; i < file->lineCount; ++i)
1701 const rdpFileLine* curLine = &file->lines[i];
1703 if (curLine->flags & RDP_FILE_LINE_FLAG_TYPE_INTEGER)
1704 res = freerdp_client_write_setting_to_buffer(&buffer, &size,
"%s:i:%" PRIu32,
1705 curLine->name, (UINT32)curLine->iValue);
1706 else if (curLine->flags & RDP_FILE_LINE_FLAG_TYPE_STRING)
1707 res = freerdp_client_write_setting_to_buffer(&buffer, &size,
"%s:s:%s", curLine->name,
1717size_t freerdp_client_write_rdp_file_buffer(
const rdpFile* file,
char* buffer,
size_t size)
1719 size_t totalSize = 0;
1725 if ((!buffer || !size) && (buffer || size))
1729 const SSIZE_T intsize = write_int_parameters(file, buffer, size);
1732 totalSize += (size_t)intsize;
1737 const SSIZE_T stringsize = write_string_parameters(file, buffer, size);
1740 totalSize += (size_t)stringsize;
1742 buffer += stringsize;
1745 const SSIZE_T customsize = write_custom_parameters(file, buffer, size);
1748 totalSize += (size_t)customsize;
1752WINPR_ATTR_MALLOC(freerdp_addin_argv_free, 1)
1753static
ADDIN_ARGV* rdp_file_to_args(const
char* channel, const
char* values)
1757 ADDIN_ARGV* args = freerdp_addin_argv_new(0,
nullptr);
1760 if (!freerdp_addin_argv_add_argument(args, channel))
1763 p = CommandLineParseCommaSeparatedValues(values, &count);
1764 for (
size_t x = 0; x < count; x++)
1767 const char* val = p[x];
1768 const size_t len = strlen(val) + 8;
1769 char* str = calloc(len,
sizeof(
char));
1773 (void)_snprintf(str, len,
"device:%s", val);
1774 rc = freerdp_addin_argv_add_argument(args, str);
1779 CommandLineParserFree(p);
1783 CommandLineParserFree(p);
1784 freerdp_addin_argv_free(args);
1788BOOL freerdp_client_populate_settings_from_rdp_file_unchecked(
const rdpFile* file,
1789 rdpSettings* settings)
1791 if (!file || !settings)
1797 if (~file->BandwidthAutoDetect)
1799 if (file->BandwidthAutoDetect != 0)
1801 if ((~file->NetworkAutoDetect) && (file->NetworkAutoDetect == 0))
1804 "Got networkautodetect:i:%" PRIu32
" and bandwidthautodetect:i:%" PRIu32
1805 ". Correcting to networkautodetect:i:1",
1806 file->NetworkAutoDetect, file->BandwidthAutoDetect);
1808 "Add networkautodetect:i:1 to your RDP file to eliminate this warning.");
1812 (file->BandwidthAutoDetect != 0) ||
1813 (file->NetworkAutoDetect != 0)))
1817 if (~file->NetworkAutoDetect)
1819 if (file->NetworkAutoDetect != 0)
1821 if ((~file->BandwidthAutoDetect) && (file->BandwidthAutoDetect == 0))
1824 "Got networkautodetect:i:%" PRIu32
" and bandwidthautodetect:i:%" PRIu32
1825 ". Correcting to bandwidthautodetect:i:1",
1826 file->NetworkAutoDetect, file->BandwidthAutoDetect);
1828 TAG,
"Add bandwidthautodetect:i:1 to your RDP file to eliminate this warning.");
1832 (file->BandwidthAutoDetect != 0) ||
1833 (file->NetworkAutoDetect != 0)))
1837 if (is_pointer_used(file->Domain))
1843 if (is_pointer_used(file->Username))
1845 char* user =
nullptr;
1846 char* domain =
nullptr;
1848 if (!freerdp_parse_username(file->Username, &user, &domain))
1854 if (!(is_pointer_used(file->Domain)) && domain)
1864 if (is_pointer_used(file->Password))
1871 const char* address =
nullptr;
1875 if (is_pointer_used(file->AlternateFullAddress))
1876 address = file->AlternateFullAddress;
1877 else if (is_pointer_used(file->FullAddress))
1878 address = file->FullAddress;
1883 char* host =
nullptr;
1885 if (!freerdp_parse_hostname(address, &host, &port))
1901 if (~file->ServerPort)
1907 if (~file->DesktopSizeId)
1909 switch (file->DesktopSizeId)
1942 WLog_WARN(TAG,
"Unsupported 'desktop size id' value %" PRIu32, file->DesktopSizeId);
1947 if (~file->DesktopWidth)
1953 if (~file->DesktopHeight)
1959 if (~file->SessionBpp)
1965 if (~file->ConnectToConsole)
1968 file->ConnectToConsole != 0))
1972 if (~file->AdministrativeSession)
1975 file->AdministrativeSession != 0))
1979 if (~file->NegotiateSecurityLayer)
1982 file->NegotiateSecurityLayer != 0))
1986 if (~file->EnableCredSSPSupport)
1989 file->EnableCredSSPSupport != 0))
1992 file->EnableCredSSPSupport != 0))
1996 if (~file->EnableRdsAadAuth)
1998 const BOOL val = file->EnableRdsAadAuth != 0;
2003 if (is_pointer_used(file->AlternateShell))
2009 if (is_pointer_used(file->ShellWorkingDirectory))
2012 FreeRDP_Settings_Keys_String targetId =
2013 (~file->RemoteApplicationMode && file->RemoteApplicationMode != 0)
2014 ? FreeRDP_RemoteApplicationWorkingDir
2015 : FreeRDP_ShellWorkingDirectory;
2021 if (~file->ScreenModeId)
2039 if (~(file->SmartSizing))
2052 if (((~(file->DesktopWidth) && ~(file->DesktopHeight)) || ~(file->DesktopSizeId)) &&
2053 (file->SmartSizing == 1))
2056 file->DesktopWidth))
2059 file->DesktopHeight))
2064 if (is_pointer_used(file->LoadBalanceInfo))
2066 const size_t len = strlen(file->LoadBalanceInfo);
2068 file->LoadBalanceInfo, len))
2072 if (~file->AuthenticationLevel)
2089 file->AuthenticationLevel))
2093 if (~file->ConnectionType)
2099 if (~file->AudioMode)
2101 switch (file->AudioMode)
2103 case AUDIO_MODE_REDIRECT:
2109 case AUDIO_MODE_PLAY_ON_SERVER:
2115 case AUDIO_MODE_NONE:
2125 if (~file->AudioCaptureMode)
2131 if (~file->Compression)
2134 file->Compression != 0))
2138 if (is_pointer_used(file->GatewayHostname))
2141 char* host =
nullptr;
2143 if (!freerdp_parse_hostname(file->GatewayHostname, &host, &port))
2158 if (is_pointer_used(file->ResourceProvider))
2160 if (_stricmp(file->ResourceProvider, str_resourceprovider_arm) == 0)
2167 if (is_pointer_used(file->WvdEndpointPool))
2170 file->WvdEndpointPool))
2174 if (is_pointer_used(file->geo))
2180 if (is_pointer_used(file->armpath))
2186 if (is_pointer_used(file->aadtenantid))
2193 if (is_pointer_used(file->diagnosticserviceurl))
2196 file->diagnosticserviceurl))
2200 if (is_pointer_used(file->hubdiscoverygeourl))
2203 file->hubdiscoverygeourl))
2207 if (is_pointer_used(file->activityhint))
2210 file->activityhint))
2214 if (is_pointer_used(file->GatewayAccessToken))
2217 file->GatewayAccessToken))
2221 if (is_pointer_used(file->EndpointFedAuthToken))
2224 file->EndpointFedAuthToken))
2228 if (~file->GatewayUsageMethod)
2234 if (~file->GatewayCredentialsSource)
2236 if (file->GatewayCredentialsSource > 5)
2238 WLog_WARN(TAG,
"ignoring gatewaycredentialssource value outside range 0..5");
2241 file->GatewayCredentialsSource))
2245 if (~file->PromptCredentialOnce)
2248 file->PromptCredentialOnce != 0))
2252 if (~file->PromptForCredentials)
2255 file->PromptForCredentials != 0))
2259 if (~file->RemoteApplicationMode)
2262 file->RemoteApplicationMode != 0))
2266 if (is_pointer_used(file->RemoteApplicationProgram))
2269 file->RemoteApplicationProgram))
2273 if (is_pointer_used(file->RemoteApplicationName))
2276 file->RemoteApplicationName))
2280 if (is_pointer_used(file->RemoteApplicationIcon))
2283 file->RemoteApplicationIcon))
2287 if (is_pointer_used(file->RemoteApplicationFile))
2290 file->RemoteApplicationFile))
2294 if (is_pointer_used(file->RemoteApplicationGuid))
2297 file->RemoteApplicationGuid))
2301 if (is_pointer_used(file->RemoteApplicationCmdLine))
2304 file->RemoteApplicationCmdLine))
2308 if (~file->SpanMonitors)
2314 if (~file->UseMultiMon)
2320 if (~file->AllowFontSmoothing)
2323 file->AllowFontSmoothing != 0))
2327 if (~file->DisableWallpaper)
2330 file->DisableWallpaper != 0))
2334 if (~file->DisableFullWindowDrag)
2337 file->DisableFullWindowDrag != 0))
2341 if (~file->DisableMenuAnims)
2344 file->DisableMenuAnims != 0))
2348 if (~file->DisableThemes)
2354 if (~file->AllowDesktopComposition)
2357 file->AllowDesktopComposition != 0))
2361 if (~file->BitmapCachePersistEnable)
2364 file->BitmapCachePersistEnable != 0))
2368 if (~file->DisableRemoteAppCapsCheck)
2371 file->DisableRemoteAppCapsCheck != 0))
2375 if (~file->AutoReconnectionEnabled)
2378 file->AutoReconnectionEnabled != 0))
2382 if (~file->AutoReconnectMaxRetries)
2385 file->AutoReconnectMaxRetries))
2389 if (~file->RedirectSmartCards)
2392 file->RedirectSmartCards != 0))
2396 if (~file->RedirectWebauthN)
2399 file->RedirectWebauthN != 0))
2403 if (~file->RedirectClipboard)
2406 file->RedirectClipboard != 0))
2410 if (~file->RedirectPrinters)
2413 file->RedirectPrinters != 0))
2417 if (~file->RedirectDrives)
2423 if (~file->RedirectPosDevices)
2426 file->RedirectComPorts != 0) ||
2428 file->RedirectComPorts != 0))
2432 if (~file->RedirectComPorts)
2435 file->RedirectComPorts != 0) ||
2437 file->RedirectComPorts != 0))
2441 if (~file->RedirectLocation && (file->RedirectLocation != 0))
2447 freerdp_client_add_dynamic_channel(settings, count, (
const char*
const*)ptr);
2448 CommandLineParserFree(ptr);
2453 if (~file->RedirectDirectX)
2458 if ((is_pointer_used(file->DevicesToRedirect)) && !utils_str_is_empty(file->DevicesToRedirect))
2488 if ((is_pointer_used(file->DrivesToRedirect)) && !utils_str_is_empty(file->DrivesToRedirect))
2491 file->DrivesToRedirect))
2495 if ((is_pointer_used(file->RedirectCameras)) && !utils_str_is_empty(file->RedirectCameras))
2497#if defined(CHANNEL_RDPECAM_CLIENT)
2501 const char*
const* cc;
2503 ADDIN_ARGV* args = rdp_file_to_args(RDPECAM_DVC_CHANNEL_NAME, file->RedirectCameras);
2508 if (~file->EncodeRedirectedVideoCapture)
2510 char encode[64] = WINPR_C_ARRAY_INIT;
2511 (void)_snprintf(encode,
sizeof(encode),
"encode:%" PRIu32,
2512 file->EncodeRedirectedVideoCapture);
2513 if (!freerdp_addin_argv_add_argument(args, encode))
2516 if (~file->RedirectedVideoCaptureEncodingQuality)
2518 char quality[64] = WINPR_C_ARRAY_INIT;
2519 (void)_snprintf(quality,
sizeof(quality),
"quality:%" PRIu32,
2520 file->RedirectedVideoCaptureEncodingQuality);
2521 if (!freerdp_addin_argv_add_argument(args, quality))
2527 status = freerdp_client_add_dynamic_channel(
2528 settings, WINPR_ASSERTING_INT_CAST(
size_t, args->argc), cnv.cc);
2529 freerdp_addin_argv_free(args);
2535 "This build does not support [MS-RDPECAM] camera redirection channel. Ignoring '%s'",
2536 key_str_camerastoredirect);
2540 if ((is_pointer_used(file->UsbDevicesToRedirect)) &&
2541 !utils_str_is_empty(file->UsbDevicesToRedirect))
2543#ifdef CHANNEL_URBDRC_CLIENT
2547 const char*
const* cc;
2549 ADDIN_ARGV* args = rdp_file_to_args(URBDRC_CHANNEL_NAME, file->UsbDevicesToRedirect);
2553 const BOOL status = freerdp_client_add_dynamic_channel(
2554 settings, WINPR_ASSERTING_INT_CAST(
size_t, args->argc), cnv.cc);
2555 freerdp_addin_argv_free(args);
2560 "This build does not support [MS-RDPEUSB] usb redirection channel. Ignoring '%s'",
2561 key_str_usbdevicestoredirect);
2565 if (~file->KeyboardHook)
2571 if (~(
size_t)file->SelectedMonitors)
2574 char** ptr = CommandLineParseCommaSeparatedValues(file->SelectedMonitors, &count);
2575 UINT32* list =
nullptr;
2579 CommandLineParserFree(ptr);
2583 if (!list && (count > 0))
2585 CommandLineParserFree(ptr);
2588 for (
size_t x = 0; x < count; x++)
2590 unsigned long val = 0;
2592 val = strtoul(ptr[x],
nullptr, 0);
2593 if ((val >= UINT32_MAX) && (errno != 0))
2595 CommandLineParserFree(ptr);
2598 list[x] = (UINT32)val;
2600 CommandLineParserFree(ptr);
2603 if (~file->DynamicResolution)
2605 const BOOL val = file->DynamicResolution != 0;
2612 if (~file->DesktopScaleFactor)
2615 file->DesktopScaleFactor))
2619 if (~file->VideoPlaybackMode)
2621 if (file->VideoPlaybackMode != 0)
2638 if (is_pointer_used(file->PreconnectionBlob))
2641 file->PreconnectionBlob) ||
2646 if (is_pointer_used(file->KdcProxyName))
2652 if (~file->RdgIsKdcProxy)
2655 file->RdgIsKdcProxy != 0))
2659 if (file->args->argc > 1)
2661 WCHAR* ConnectionFile =
2664 if (freerdp_client_settings_parse_command_line(settings, file->args->argc, file->args->argv,
2667 free(ConnectionFile);
2673 free(ConnectionFile);
2682static BOOL freerdp_apply_connection_type_from_file(
const rdpFile* file, rdpSettings* settings,
2685 struct network_settings
2687 FreeRDP_Settings_Keys_Bool id;
2693 const struct network_settings config[] = { { FreeRDP_DisableWallpaper,
2694 (~file->DisableWallpaper) == 0,
2695 { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
2696 { FreeRDP_AllowFontSmoothing,
2697 (~file->AllowFontSmoothing) == 0,
2698 { FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE } },
2699 { FreeRDP_AllowDesktopComposition,
2700 (~file->AllowDesktopComposition) == 0,
2701 { FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE } },
2702 { FreeRDP_DisableFullWindowDrag,
2703 (~file->DisableFullWindowDrag) == 0,
2704 { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
2705 { FreeRDP_DisableMenuAnims,
2706 (~file->DisableMenuAnims) == 0,
2707 { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
2708 { FreeRDP_DisableThemes,
2709 (~file->DisableThemes) == 0,
2710 { TRUE, FALSE, FALSE, FALSE, FALSE, FALSE,
2715 case CONNECTION_TYPE_INVALID:
2718 case CONNECTION_TYPE_MODEM:
2719 case CONNECTION_TYPE_BROADBAND_LOW:
2720 case CONNECTION_TYPE_BROADBAND_HIGH:
2721 case CONNECTION_TYPE_SATELLITE:
2722 case CONNECTION_TYPE_WAN:
2723 case CONNECTION_TYPE_LAN:
2724 case CONNECTION_TYPE_AUTODETECT:
2727 WLog_WARN(TAG,
"Unknown ConnectionType %" PRIu32
", aborting", type);
2731 for (
size_t x = 0; x < ARRAYSIZE(config); x++)
2733 const struct network_settings* cur = &config[x];
2744static BOOL freerdp_set_connection_type_from_file(
const rdpFile* file, rdpSettings* settings,
2753 case CONNECTION_TYPE_INVALID:
2754 case CONNECTION_TYPE_MODEM:
2755 case CONNECTION_TYPE_BROADBAND_LOW:
2756 case CONNECTION_TYPE_SATELLITE:
2757 case CONNECTION_TYPE_BROADBAND_HIGH:
2758 case CONNECTION_TYPE_WAN:
2759 case CONNECTION_TYPE_LAN:
2760 if (!freerdp_apply_connection_type_from_file(file, settings, type))
2763 case CONNECTION_TYPE_AUTODETECT:
2764 if (!freerdp_apply_connection_type_from_file(file, settings, type))
2778 WLog_WARN(TAG,
"Unknown ConnectionType %" PRIu32
", aborting", type);
2785BOOL freerdp_client_populate_settings_from_rdp_file(
const rdpFile* file, rdpSettings* settings)
2787 if (!freerdp_client_populate_settings_from_rdp_file_unchecked(file, settings))
2791 if ((~file->ConnectionType) == 0)
2794 type = CONNECTION_TYPE_AUTODETECT;
2796 return freerdp_set_connection_type_from_file(file, settings, type);
2800static rdpFileLine* freerdp_client_rdp_file_find_line_by_name(
const rdpFile* file,
const char* name)
2802 BOOL bFound = FALSE;
2803 rdpFileLine* line =
nullptr;
2805 for (
size_t index = 0; index < file->lineCount; index++)
2807 line = &(file->lines[index]);
2809 if (line->flags & RDP_FILE_LINE_FLAG_FORMATTED)
2811 if (_stricmp(name, line->name) == 0)
2819 return (bFound) ? line :
nullptr;
2828int freerdp_client_rdp_file_set_string_option(rdpFile* file,
const char* name,
const char* value)
2830 return freerdp_client_rdp_file_set_string(file, name, value);
2833const char* freerdp_client_rdp_file_get_string_option(
const rdpFile* file,
const char* name)
2835 LPSTR* value =
nullptr;
2836 rdpFileLine* line =
nullptr;
2838 rdpFile* wfile = WINPR_CAST_CONST_PTR_AWAY(file, rdpFile*);
2839 if (freerdp_client_rdp_file_find_string_entry(wfile, name, &value, &line))
2841 if (value && ~(
size_t)(*value))
2844 return line->sValue;
2850int freerdp_client_rdp_file_set_integer_option(rdpFile* file,
const char* name,
int value)
2852 return freerdp_client_rdp_file_set_integer(file, name, value);
2855int freerdp_client_rdp_file_get_integer_option(
const rdpFile* file,
const char* name)
2857 DWORD* value =
nullptr;
2858 rdpFileLine* line =
nullptr;
2860 rdpFile* wfile = WINPR_CAST_CONST_PTR_AWAY(file, rdpFile*);
2861 if (freerdp_client_rdp_file_find_integer_entry(wfile, name, &value, &line))
2863 if (value && ~(*value))
2864 return WINPR_ASSERTING_INT_CAST(
int, *value);
2866 return (
int)line->iValue;
2872static void freerdp_client_file_string_check_free(LPSTR str)
2874 if (is_pointer_used(str))
2878rdpFile* freerdp_client_rdp_file_new(
void)
2880 return freerdp_client_rdp_file_new_ex(0);
2883rdpFile* freerdp_client_rdp_file_new_ex(DWORD flags)
2885 rdpFile* file = (rdpFile*)calloc(1,
sizeof(rdpFile));
2890 file->flags = flags;
2892 FillMemory(file,
sizeof(rdpFile), 0xFF);
2893 file->lines =
nullptr;
2894 file->lineCount = 0;
2895 file->lineSize = 32;
2896 file->GatewayProfileUsageMethod = 1;
2897 file->lines = (rdpFileLine*)calloc(file->lineSize,
sizeof(rdpFileLine));
2899 file->args = freerdp_addin_argv_new(0,
nullptr);
2900 if (!file->lines || !file->args)
2903 if (!freerdp_client_add_option(file,
"freerdp"))
2908 WINPR_PRAGMA_DIAG_PUSH
2909 WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
2910 freerdp_client_rdp_file_free(file);
2911 WINPR_PRAGMA_DIAG_POP
2915void freerdp_client_rdp_file_free(rdpFile* file)
2919 for (
size_t i = 0; i < file->lineCount; i++)
2921 rdpFileLine* cur = &file->lines[i];
2928 freerdp_addin_argv_free(file->args);
2930 freerdp_client_file_string_check_free(file->SelectedMonitors);
2931 freerdp_client_file_string_check_free(file->Username);
2932 freerdp_client_file_string_check_free(file->Domain);
2933 freerdp_client_file_string_check_free(file->Password);
2934 freerdp_client_file_string_check_free(file->FullAddress);
2935 freerdp_client_file_string_check_free(file->AlternateFullAddress);
2936 freerdp_client_file_string_check_free(file->UsbDevicesToRedirect);
2937 freerdp_client_file_string_check_free(file->RedirectCameras);
2938 freerdp_client_file_string_check_free(file->LoadBalanceInfo);
2939 freerdp_client_file_string_check_free(file->RemoteApplicationName);
2940 freerdp_client_file_string_check_free(file->RemoteApplicationIcon);
2941 freerdp_client_file_string_check_free(file->RemoteApplicationProgram);
2942 freerdp_client_file_string_check_free(file->RemoteApplicationFile);
2943 freerdp_client_file_string_check_free(file->RemoteApplicationGuid);
2944 freerdp_client_file_string_check_free(file->RemoteApplicationCmdLine);
2945 freerdp_client_file_string_check_free(file->AlternateShell);
2946 freerdp_client_file_string_check_free(file->ShellWorkingDirectory);
2947 freerdp_client_file_string_check_free(file->GatewayHostname);
2948 freerdp_client_file_string_check_free(file->ResourceProvider);
2949 freerdp_client_file_string_check_free(file->WvdEndpointPool);
2950 freerdp_client_file_string_check_free(file->geo);
2951 freerdp_client_file_string_check_free(file->armpath);
2952 freerdp_client_file_string_check_free(file->aadtenantid);
2953 freerdp_client_file_string_check_free(file->diagnosticserviceurl);
2954 freerdp_client_file_string_check_free(file->hubdiscoverygeourl);
2955 freerdp_client_file_string_check_free(file->activityhint);
2956 freerdp_client_file_string_check_free(file->GatewayAccessToken);
2957 freerdp_client_file_string_check_free(file->EndpointFedAuthToken);
2958 freerdp_client_file_string_check_free(file->DrivesToRedirect);
2959 freerdp_client_file_string_check_free(file->DevicesToRedirect);
2960 freerdp_client_file_string_check_free(file->WinPosStr);
2961 freerdp_client_file_string_check_free(file->PreconnectionBlob);
2962 freerdp_client_file_string_check_free(file->KdcProxyName);
2968void freerdp_client_rdp_file_set_callback_context(rdpFile* file,
void* context)
2970 file->context = context;
#define LOCATION_CHANNEL_NAME
WINPR_ATTR_NODISCARD FREERDP_API const void * freerdp_settings_get_pointer(const rdpSettings *settings, FreeRDP_Settings_Keys_Pointer id)
Returns a immutable pointer settings value.
WINPR_ATTR_NODISCARD FREERDP_API const char * freerdp_settings_get_string(const rdpSettings *settings, FreeRDP_Settings_Keys_String id)
Returns a immutable string settings value.
WINPR_ATTR_NODISCARD FREERDP_API BOOL freerdp_settings_set_bool(rdpSettings *settings, FreeRDP_Settings_Keys_Bool id, BOOL val)
Sets a BOOL settings value.
WINPR_ATTR_NODISCARD 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.
WINPR_ATTR_NODISCARD FREERDP_API void * freerdp_settings_get_pointer_writable(rdpSettings *settings, FreeRDP_Settings_Keys_Pointer id)
Returns a mutable pointer settings value.
WINPR_ATTR_NODISCARD FREERDP_API BOOL freerdp_settings_set_uint32(rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id, UINT32 val)
Sets a UINT32 settings value.
WINPR_ATTR_NODISCARD 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.
WINPR_ATTR_NODISCARD FREERDP_API UINT32 freerdp_settings_get_uint32(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id)
Returns a UINT32 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.
WINPR_ATTR_NODISCARD FREERDP_API BOOL freerdp_set_gateway_usage_method(rdpSettings *settings, UINT32 GatewayUsageMethod)
WINPR_ATTR_NODISCARD FREERDP_API BOOL freerdp_settings_set_string(rdpSettings *settings, FreeRDP_Settings_Keys_String id, const char *val)
Sets a string settings value. The param is copied.
WINPR_ATTR_NODISCARD FREERDP_API BOOL freerdp_settings_get_bool(const rdpSettings *settings, FreeRDP_Settings_Keys_Bool id)
Returns a boolean settings value.