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]))
976 LPCWSTR uc = WINPR_PACKED_ALIGN_CAST(LPCWSTR, (&buffer[2]));
977 const size_t charlen = size /
sizeof(WCHAR) - 1;
978 copy = ConvertWCharNToUtf8Alloc(uc, charlen, &size);
981 WLog_ERR(TAG,
"Failed to convert RDP file from UCS2 to UTF8");
987 copy = calloc(1, size +
sizeof(BYTE));
992 memcpy(copy, buffer, size);
995 char* context =
nullptr;
996 char* line = strtok_s(copy,
"\r\n", &context);
1000 const size_t length = strnlen(line, size);
1002 if (!parse_line(file, line, length, parse))
1005 line = strtok_s(
nullptr,
"\r\n", &context);
1008 rc = trim_strings(file);
1014BOOL freerdp_client_parse_rdp_file(rdpFile* file,
const char* name)
1016 return freerdp_client_parse_rdp_file_ex(file, name,
nullptr);
1019BOOL freerdp_client_parse_rdp_file_ex(rdpFile* file,
const char* name, rdp_file_fkt_parse parse)
1022 BYTE* buffer =
nullptr;
1024 size_t read_size = 0;
1025 INT64 file_size = 0;
1026 const char* fname = name;
1031 if (_strnicmp(fname,
"file://", 7) == 0)
1034 fp = winpr_fopen(fname,
"r");
1037 WLog_ERR(TAG,
"Failed to open RDP file %s", name);
1041 if (_fseeki64(fp, 0, SEEK_END) < 0)
1043 file_size = _ftelli64(fp);
1044 if (_fseeki64(fp, 0, SEEK_SET) < 0)
1049 WLog_ERR(TAG,
"RDP file %s is empty", name);
1053 buffer = (BYTE*)malloc((
size_t)file_size + 2);
1058 read_size = fread(buffer, (
size_t)file_size, 1, fp);
1063 read_size = (size_t)file_size;
1068 WLog_ERR(TAG,
"Could not read from RDP file %s", name);
1072 buffer[file_size] =
'\0';
1073 buffer[file_size + 1] =
'\0';
1074 status = freerdp_client_parse_rdp_file_buffer_ex(file, buffer, (
size_t)file_size, parse);
1082static inline void freerdp_client_file_string_reset(
char** target)
1084 WINPR_ASSERT(target);
1085 freerdp_client_file_string_check_free(*target);
1086 *target = (
char*)UINTPTR_MAX;
1090static inline BOOL FILE_POPULATE_STRING(
char** _target,
const rdpSettings* _settings,
1091 FreeRDP_Settings_Keys_String _option)
1093 WINPR_ASSERT(_target);
1094 WINPR_ASSERT(_settings);
1097 freerdp_client_file_string_reset(_target);
1100 char* copy = _strdup(str);
1109static char* freerdp_client_channel_args_to_string(
const rdpSettings* settings,
const char* channel,
1112 ADDIN_ARGV* args = freerdp_dynamic_channel_collection_find(settings, channel);
1113 const char* filters[] = { option };
1114 if (!args || (args->argc < 2))
1117 return CommandLineToCommaSeparatedValuesEx(args->argc - 1, args->argv + 1, filters,
1118 ARRAYSIZE(filters));
1122static BOOL rdp_opt_duplicate(
const rdpSettings* _settings, FreeRDP_Settings_Keys_String _id,
1125 WINPR_ASSERT(_settings);
1131 *_key = _strdup(tmp);
1139BOOL freerdp_client_populate_rdp_file_from_settings(rdpFile* file,
const rdpSettings* settings)
1141 FreeRDP_Settings_Keys_String index = FreeRDP_STRING_UNUSED;
1142 UINT32 LoadBalanceInfoLength = 0;
1143 const char* GatewayHostname =
nullptr;
1144 char* redirectCameras =
nullptr;
1146 if (!file || !settings)
1149 if (!FILE_POPULATE_STRING(&file->Domain, settings, FreeRDP_Domain) ||
1150 !FILE_POPULATE_STRING(&file->Username, settings, FreeRDP_Username) ||
1151 !FILE_POPULATE_STRING(&file->Password, settings, FreeRDP_Password) ||
1152 !FILE_POPULATE_STRING(&file->FullAddress, settings, FreeRDP_ServerHostname) ||
1153 !FILE_POPULATE_STRING(&file->AlternateFullAddress, settings, FreeRDP_ServerHostname) ||
1154 !FILE_POPULATE_STRING(&file->AlternateShell, settings, FreeRDP_AlternateShell) ||
1155 !FILE_POPULATE_STRING(&file->DrivesToRedirect, settings, FreeRDP_DrivesToRedirect))
1164 file->DynamicResolution = WINPR_ASSERTING_INT_CAST(
1166 file->VideoPlaybackMode = WINPR_ASSERTING_INT_CAST(
1173 file->ConnectToConsole = WINPR_ASSERTING_INT_CAST(
1175 file->NegotiateSecurityLayer = WINPR_ASSERTING_INT_CAST(
1177 file->EnableCredSSPSupport =
1179 file->EnableRdsAadAuth =
1183 index = FreeRDP_RemoteApplicationWorkingDir;
1185 index = FreeRDP_ShellWorkingDirectory;
1186 if (!FILE_POPULATE_STRING(&file->ShellWorkingDirectory, settings, index))
1193 if (LoadBalanceInfoLength > 0)
1195 const BYTE* LoadBalanceInfo =
1197 file->LoadBalanceInfo = calloc(LoadBalanceInfoLength + 1, 1);
1198 if (!file->LoadBalanceInfo)
1200 memcpy(file->LoadBalanceInfo, LoadBalanceInfo, LoadBalanceInfoLength);
1204 file->AudioMode = AUDIO_MODE_REDIRECT;
1206 file->AudioMode = AUDIO_MODE_PLAY_ON_SERVER;
1208 file->AudioMode = AUDIO_MODE_NONE;
1213 if (GatewayHostname)
1216 freerdp_client_file_string_check_free(file->GatewayHostname);
1217 if (GatewayPort == 443)
1218 file->GatewayHostname = _strdup(GatewayHostname);
1221 int length = _scprintf(
"%s:%" PRIu32, GatewayHostname, GatewayPort);
1225 file->GatewayHostname = (
char*)malloc((
size_t)length + 1);
1226 if (!file->GatewayHostname)
1229 if (sprintf_s(file->GatewayHostname, (
size_t)length + 1,
"%s:%" PRIu32, GatewayHostname,
1233 if (!file->GatewayHostname)
1238 file->ResourceProvider = _strdup(str_resourceprovider_arm);
1240 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdWvdEndpointPool, &file->WvdEndpointPool))
1242 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdGeo, &file->geo))
1244 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdArmpath, &file->armpath))
1246 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdAadtenantid, &file->aadtenantid))
1248 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdDiagnosticserviceurl,
1249 &file->diagnosticserviceurl))
1251 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdHubdiscoverygeourl,
1252 &file->hubdiscoverygeourl))
1254 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdActivityhint, &file->activityhint))
1257 file->AudioCaptureMode =
1259 file->BitmapCachePersistEnable = WINPR_ASSERTING_INT_CAST(
1261 file->Compression = WINPR_ASSERTING_INT_CAST(
1264 file->GatewayUsageMethod = freerdp_get_gateway_usage_method(settings);
1265 file->GatewayCredentialsSource =
1267 file->PromptCredentialOnce = WINPR_ASSERTING_INT_CAST(
1269 file->PromptForCredentials = WINPR_ASSERTING_INT_CAST(
1271 file->RemoteApplicationMode = WINPR_ASSERTING_INT_CAST(
1273 if (!FILE_POPULATE_STRING(&file->GatewayAccessToken, settings, FreeRDP_GatewayAccessToken) ||
1274 !FILE_POPULATE_STRING(&file->EndpointFedAuthToken, settings,
1275 FreeRDP_EndpointFedAuthToken) ||
1276 !FILE_POPULATE_STRING(&file->RemoteApplicationProgram, settings,
1277 FreeRDP_RemoteApplicationProgram) ||
1278 !FILE_POPULATE_STRING(&file->RemoteApplicationName, settings,
1279 FreeRDP_RemoteApplicationName) ||
1280 !FILE_POPULATE_STRING(&file->RemoteApplicationIcon, settings,
1281 FreeRDP_RemoteApplicationIcon) ||
1282 !FILE_POPULATE_STRING(&file->RemoteApplicationFile, settings,
1283 FreeRDP_RemoteApplicationFile) ||
1284 !FILE_POPULATE_STRING(&file->RemoteApplicationGuid, settings,
1285 FreeRDP_RemoteApplicationGuid) ||
1286 !FILE_POPULATE_STRING(&file->RemoteApplicationCmdLine, settings,
1287 FreeRDP_RemoteApplicationCmdLine))
1289 file->SpanMonitors =
1293 file->AllowDesktopComposition = WINPR_ASSERTING_INT_CAST(
1295 file->AllowFontSmoothing = WINPR_ASSERTING_INT_CAST(
1297 file->DisableWallpaper = WINPR_ASSERTING_INT_CAST(
1299 file->DisableFullWindowDrag = WINPR_ASSERTING_INT_CAST(
1301 file->DisableMenuAnims = WINPR_ASSERTING_INT_CAST(
1303 file->DisableThemes = WINPR_ASSERTING_INT_CAST(
1306 CONNECTION_TYPE_AUTODETECT);
1307 file->NetworkAutoDetect =
1309 file->AutoReconnectionEnabled = WINPR_ASSERTING_INT_CAST(
1311 file->RedirectSmartCards = WINPR_ASSERTING_INT_CAST(
1313 file->RedirectWebauthN = WINPR_ASSERTING_INT_CAST(
1317 freerdp_client_channel_args_to_string(settings, RDPECAM_DVC_CHANNEL_NAME,
"device:");
1318 if (redirectCameras)
1321 freerdp_client_channel_args_to_string(settings, RDPECAM_DVC_CHANNEL_NAME,
"encode:");
1322 file->EncodeRedirectedVideoCapture = 0;
1325 unsigned long val = 0;
1327 val = strtoul(str,
nullptr, 0);
1328 if ((val < UINT32_MAX) && (errno == 0))
1329 file->EncodeRedirectedVideoCapture = (UINT32)val;
1333 str = freerdp_client_channel_args_to_string(settings, RDPECAM_DVC_CHANNEL_NAME,
"quality:");
1334 file->RedirectedVideoCaptureEncodingQuality = 0;
1337 unsigned long val = 0;
1339 val = strtoul(str,
nullptr, 0);
1340 if ((val <= 2) && (errno == 0))
1342 file->RedirectedVideoCaptureEncodingQuality = (UINT32)val;
1347 file->RedirectCameras = redirectCameras;
1350 freerdp_client_file_string_reset(&file->RedirectCameras);
1352#ifdef CHANNEL_URBDRC_CLIENT
1354 freerdp_client_channel_args_to_string(settings, URBDRC_CHANNEL_NAME,
"device:");
1356 file->UsbDevicesToRedirect = redirectUsb;
1358 freerdp_client_file_string_reset(&file->UsbDevicesToRedirect);
1361 file->RedirectClipboard =
1368 file->RedirectLocation =
1370 if (!FILE_POPULATE_STRING(&file->DrivesToRedirect, settings, FreeRDP_DrivesToRedirect) ||
1371 !FILE_POPULATE_STRING(&file->PreconnectionBlob, settings, FreeRDP_PreconnectionBlob) ||
1372 !FILE_POPULATE_STRING(&file->KdcProxyName, settings, FreeRDP_KerberosKdcUrl))
1380 size_t size = count * (10 + 1) + 1;
1382 char* str = calloc(size,
sizeof(
char));
1383 for (UINT32 x = 0; x < count; x++)
1385 int rc = _snprintf(&str[offset], size - offset,
"%" PRIu32
",", MonitorIds[x]);
1391 offset += (size_t)rc;
1394 str[offset - 1] =
'\0';
1395 freerdp_client_file_string_check_free(file->SelectedMonitors);
1396 file->SelectedMonitors = str;
1404BOOL freerdp_client_write_rdp_file(
const rdpFile* file,
const char* name, BOOL unicode)
1407 WCHAR* unicodestr =
nullptr;
1412 const size_t size = freerdp_client_write_rdp_file_buffer(file,
nullptr, 0);
1415 char* buffer = calloc(size + 1ULL,
sizeof(
char));
1419 if (freerdp_client_write_rdp_file_buffer(file, buffer, size + 1) != size)
1421 WLog_ERR(TAG,
"freerdp_client_write_rdp_file: error writing to output buffer");
1426 FILE* fp = winpr_fopen(name,
"w+b");
1433 unicodestr = ConvertUtf8NToWCharAlloc(buffer, size, &len);
1443 if ((fwrite(BOM_UTF16_LE,
sizeof(BYTE), 2, fp) != 2) ||
1444 (fwrite(unicodestr,
sizeof(WCHAR), len, fp) != len))
1456 if (fwrite(buffer, 1, size, fp) != size)
1465 status = fclose(fp);
1469 return (status == 0);
1472WINPR_ATTR_FORMAT_ARG(3, 4)
1473static SSIZE_T freerdp_client_write_setting_to_buffer(
char** buffer,
size_t* bufferSize,
1474 WINPR_FORMAT_ARG const
char* fmt, ...)
1476 va_list ap = WINPR_C_ARRAY_INIT;
1478 char* buf =
nullptr;
1481 if (!buffer || !bufferSize || !fmt)
1485 bufSize = *bufferSize;
1488 len = vsnprintf(buf, bufSize, fmt, ap);
1497 if (!buf && !bufSize)
1504 if (bufSize >= (
size_t)len)
1506 *bufferSize -= (size_t)len;
1507 buf[len - 1] =
'\n';
1508 *buffer = buf + len;
1517static SSIZE_T write_int_parameters(
const rdpFile* file,
char* buffer,
size_t size)
1526 const struct intentry_t settings[] = {
1527 { key_int_use_multimon, file->UseMultiMon },
1528 { key_int_maximizetocurrentdisplays, file->MaximizeToCurrentDisplays },
1529 { key_int_singlemoninwindowedmode, file->SingleMonInWindowedMode },
1530 { key_int_screen_mode_id, file->ScreenModeId },
1531 { key_int_span_monitors, file->SpanMonitors },
1532 { key_int_smart_sizing, file->SmartSizing },
1533 { key_int_dynamic_resolution, file->DynamicResolution },
1534 { key_int_enablesuperpan, file->EnableSuperSpan },
1535 { key_int_superpanaccelerationfactor, file->SuperSpanAccelerationFactor },
1536 { key_int_desktopwidth, file->DesktopWidth },
1537 { key_int_desktopheight, file->DesktopHeight },
1538 { key_int_desktop_size_id, file->DesktopSizeId },
1539 { key_int_session_bpp, file->SessionBpp },
1540 { key_int_desktopscalefactor, file->DesktopScaleFactor },
1541 { key_int_compression, file->Compression },
1542 { key_int_keyboardhook, file->KeyboardHook },
1543 { key_int_disable_ctrl_alt_del, file->DisableCtrlAltDel },
1544 { key_int_audiomode, file->AudioMode },
1545 { key_int_audioqualitymode, file->AudioQualityMode },
1546 { key_int_audiocapturemode, file->AudioCaptureMode },
1547 { key_int_encode_redirected_video_capture, file->EncodeRedirectedVideoCapture },
1548 { key_int_redirected_video_capture_encoding_quality,
1549 file->RedirectedVideoCaptureEncodingQuality },
1550 { key_int_videoplaybackmode, file->VideoPlaybackMode },
1551 { key_int_connection_type, file->ConnectionType },
1552 { key_int_networkautodetect, file->NetworkAutoDetect },
1553 { key_int_bandwidthautodetect, file->BandwidthAutoDetect },
1554 { key_int_pinconnectionbar, file->PinConnectionBar },
1555 { key_int_displayconnectionbar, file->DisplayConnectionBar },
1556 { key_int_workspaceid, file->WorkspaceId },
1557 { key_int_enableworkspacereconnect, file->EnableWorkspaceReconnect },
1558 { key_int_disable_wallpaper, file->DisableWallpaper },
1559 { key_int_allow_font_smoothing, file->AllowFontSmoothing },
1560 { key_int_allow_desktop_composition, file->AllowDesktopComposition },
1561 { key_int_disable_full_window_drag, file->DisableFullWindowDrag },
1562 { key_int_disable_menu_anims, file->DisableMenuAnims },
1563 { key_int_disable_themes, file->DisableThemes },
1564 { key_int_disable_cursor_setting, file->DisableCursorSetting },
1565 { key_int_bitmapcachesize, file->BitmapCacheSize },
1566 { key_int_bitmapcachepersistenable, file->BitmapCachePersistEnable },
1567 { key_int_server_port, file->ServerPort },
1568 { key_int_redirectdrives, file->RedirectDrives },
1569 { key_int_redirectprinters, file->RedirectPrinters },
1570 { key_int_redirectcomports, file->RedirectComPorts },
1571 { key_int_redirectlocation, file->RedirectLocation },
1572 { key_int_redirectsmartcards, file->RedirectSmartCards },
1573 { key_int_redirectclipboard, file->RedirectClipboard },
1574 { key_int_redirectposdevices, file->RedirectPosDevices },
1575 { key_int_redirectdirectx, file->RedirectDirectX },
1576 { key_int_disableprinterredirection, file->DisablePrinterRedirection },
1577 { key_int_disableclipboardredirection, file->DisableClipboardRedirection },
1578 { key_int_connect_to_console, file->ConnectToConsole },
1579 { key_int_administrative_session, file->AdministrativeSession },
1580 { key_int_autoreconnection_enabled, file->AutoReconnectionEnabled },
1581 { key_int_autoreconnect_max_retries, file->AutoReconnectMaxRetries },
1582 { key_int_public_mode, file->PublicMode },
1583 { key_int_authentication_level, file->AuthenticationLevel },
1584 { key_int_promptcredentialonce, file->PromptCredentialOnce },
1585 { key_int_prompt_for_credentials, file->PromptForCredentials },
1586 { key_int_negotiate_security_layer, file->NegotiateSecurityLayer },
1587 { key_int_enablecredsspsupport, file->EnableCredSSPSupport },
1588 { key_int_enablerdsaadauth, file->EnableRdsAadAuth },
1589 { key_int_remoteapplicationmode, file->RemoteApplicationMode },
1590 { key_int_remoteapplicationexpandcmdline, file->RemoteApplicationExpandCmdLine },
1591 { key_int_remoteapplicationexpandworkingdir, file->RemoteApplicationExpandWorkingDir },
1592 { key_int_disableconnectionsharing, file->DisableConnectionSharing },
1593 { key_int_disableremoteappcapscheck, file->DisableRemoteAppCapsCheck },
1594 { key_int_gatewayusagemethod, file->GatewayUsageMethod },
1595 { key_int_gatewayprofileusagemethod, file->GatewayProfileUsageMethod },
1596 { key_int_gatewaycredentialssource, file->GatewayCredentialsSource },
1597 { key_int_use_redirection_server_name, file->UseRedirectionServerName },
1598 { key_int_rdgiskdcproxy, file->RdgIsKdcProxy },
1599 { key_int_redirectwebauthn, file->RedirectWebauthN }
1602 SSIZE_T totalSize = 0;
1603 for (
size_t x = 0; x < ARRAYSIZE(settings); x++)
1605 const struct intentry_t* cur = &settings[x];
1608 const SSIZE_T res = freerdp_client_write_setting_to_buffer(
1609 &buffer, &size,
"%s:i:%" PRIu32, cur->key, cur->val);
1620static SSIZE_T write_string_parameters(
const rdpFile* file,
char* buffer,
size_t size)
1629 const struct strentry_t settings[] = {
1630 { key_str_username, file->Username },
1631 { key_str_domain, file->Domain },
1632 { key_str_password, file->Password },
1633 { key_str_full_address, file->FullAddress },
1634 { key_str_alternate_full_address, file->AlternateFullAddress },
1635 { key_str_usbdevicestoredirect, file->UsbDevicesToRedirect },
1636 { key_str_camerastoredirect, file->RedirectCameras },
1637 { key_str_loadbalanceinfo, file->LoadBalanceInfo },
1638 { key_str_remoteapplicationname, file->RemoteApplicationName },
1639 { key_str_remoteapplicationicon, file->RemoteApplicationIcon },
1640 { key_str_remoteapplicationprogram, file->RemoteApplicationProgram },
1641 { key_str_remoteapplicationfile, file->RemoteApplicationFile },
1642 { key_str_remoteapplicationguid, file->RemoteApplicationGuid },
1643 { key_str_remoteapplicationcmdline, file->RemoteApplicationCmdLine },
1644 { key_str_alternate_shell, file->AlternateShell },
1645 { key_str_shell_working_directory, file->ShellWorkingDirectory },
1646 { key_str_gatewayhostname, file->GatewayHostname },
1647 { key_str_resourceprovider, file->ResourceProvider },
1648 { key_str_wvd, file->WvdEndpointPool },
1649 { key_str_geo, file->geo },
1650 { key_str_armpath, file->armpath },
1651 { key_str_aadtenantid, file->aadtenantid },
1652 { key_str_diagnosticserviceurl, file->diagnosticserviceurl },
1653 { key_str_hubdiscoverygeourl, file->hubdiscoverygeourl },
1654 { key_str_activityhint, file->activityhint },
1655 { key_str_gatewayaccesstoken, file->GatewayAccessToken },
1656 { key_str_endpointfedauth, file->EndpointFedAuthToken },
1657 { key_str_kdcproxyname, file->KdcProxyName },
1658 { key_str_drivestoredirect, file->DrivesToRedirect },
1659 { key_str_devicestoredirect, file->DevicesToRedirect },
1660 { key_str_winposstr, file->WinPosStr },
1661 { key_str_pcb, file->PreconnectionBlob },
1662 { key_str_selectedmonitors, file->SelectedMonitors }
1665 SSIZE_T totalSize = 0;
1666 for (
size_t x = 0; x < ARRAYSIZE(settings); x++)
1668 const struct strentry_t* cur = &settings[x];
1669 if (~(
size_t)(cur->val))
1671 const SSIZE_T res = freerdp_client_write_setting_to_buffer(&buffer, &size,
"%s:s:%s",
1672 cur->key, cur->val);
1683static SSIZE_T write_custom_parameters(
const rdpFile* file,
char* buffer,
size_t size)
1687 SSIZE_T totalSize = 0;
1689 for (
size_t i = 0; i < file->lineCount; ++i)
1692 const rdpFileLine* curLine = &file->lines[i];
1694 if (curLine->flags & RDP_FILE_LINE_FLAG_TYPE_INTEGER)
1695 res = freerdp_client_write_setting_to_buffer(&buffer, &size,
"%s:i:%" PRIu32,
1696 curLine->name, (UINT32)curLine->iValue);
1697 else if (curLine->flags & RDP_FILE_LINE_FLAG_TYPE_STRING)
1698 res = freerdp_client_write_setting_to_buffer(&buffer, &size,
"%s:s:%s", curLine->name,
1708size_t freerdp_client_write_rdp_file_buffer(
const rdpFile* file,
char* buffer,
size_t size)
1710 size_t totalSize = 0;
1716 if ((!buffer || !size) && (buffer || size))
1720 const SSIZE_T intsize = write_int_parameters(file, buffer, size);
1723 totalSize += (size_t)intsize;
1728 const SSIZE_T stringsize = write_string_parameters(file, buffer, size);
1731 totalSize += (size_t)stringsize;
1733 buffer += stringsize;
1736 const SSIZE_T customsize = write_custom_parameters(file, buffer, size);
1739 totalSize += (size_t)customsize;
1743WINPR_ATTR_MALLOC(freerdp_addin_argv_free, 1)
1744static
ADDIN_ARGV* rdp_file_to_args(const
char* channel, const
char* values)
1748 ADDIN_ARGV* args = freerdp_addin_argv_new(0,
nullptr);
1751 if (!freerdp_addin_argv_add_argument(args, channel))
1754 p = CommandLineParseCommaSeparatedValues(values, &count);
1755 for (
size_t x = 0; x < count; x++)
1758 const char* val = p[x];
1759 const size_t len = strlen(val) + 8;
1760 char* str = calloc(len,
sizeof(
char));
1764 (void)_snprintf(str, len,
"device:%s", val);
1765 rc = freerdp_addin_argv_add_argument(args, str);
1770 CommandLineParserFree(p);
1774 CommandLineParserFree(p);
1775 freerdp_addin_argv_free(args);
1779BOOL freerdp_client_populate_settings_from_rdp_file_unchecked(
const rdpFile* file,
1780 rdpSettings* settings)
1782 if (!file || !settings)
1788 if (~file->BandwidthAutoDetect)
1790 if (file->BandwidthAutoDetect != 0)
1792 if ((~file->NetworkAutoDetect) && (file->NetworkAutoDetect == 0))
1795 "Got networkautodetect:i:%" PRIu32
" and bandwidthautodetect:i:%" PRIu32
1796 ". Correcting to networkautodetect:i:1",
1797 file->NetworkAutoDetect, file->BandwidthAutoDetect);
1799 "Add networkautodetect:i:1 to your RDP file to eliminate this warning.");
1803 (file->BandwidthAutoDetect != 0) ||
1804 (file->NetworkAutoDetect != 0)))
1808 if (~file->NetworkAutoDetect)
1810 if (file->NetworkAutoDetect != 0)
1812 if ((~file->BandwidthAutoDetect) && (file->BandwidthAutoDetect == 0))
1815 "Got networkautodetect:i:%" PRIu32
" and bandwidthautodetect:i:%" PRIu32
1816 ". Correcting to bandwidthautodetect:i:1",
1817 file->NetworkAutoDetect, file->BandwidthAutoDetect);
1819 TAG,
"Add bandwidthautodetect:i:1 to your RDP file to eliminate this warning.");
1823 (file->BandwidthAutoDetect != 0) ||
1824 (file->NetworkAutoDetect != 0)))
1828 if (is_pointer_used(file->Domain))
1834 if (is_pointer_used(file->Username))
1836 char* user =
nullptr;
1837 char* domain =
nullptr;
1839 if (!freerdp_parse_username(file->Username, &user, &domain))
1845 if (!(is_pointer_used(file->Domain)) && domain)
1855 if (is_pointer_used(file->Password))
1862 const char* address =
nullptr;
1866 if (is_pointer_used(file->AlternateFullAddress))
1867 address = file->AlternateFullAddress;
1868 else if (is_pointer_used(file->FullAddress))
1869 address = file->FullAddress;
1874 char* host =
nullptr;
1876 if (!freerdp_parse_hostname(address, &host, &port))
1892 if (~file->ServerPort)
1898 if (~file->DesktopSizeId)
1900 switch (file->DesktopSizeId)
1933 WLog_WARN(TAG,
"Unsupported 'desktop size id' value %" PRIu32, file->DesktopSizeId);
1938 if (~file->DesktopWidth)
1944 if (~file->DesktopHeight)
1950 if (~file->SessionBpp)
1956 if (~file->ConnectToConsole)
1959 file->ConnectToConsole != 0))
1963 if (~file->AdministrativeSession)
1966 file->AdministrativeSession != 0))
1970 if (~file->NegotiateSecurityLayer)
1973 file->NegotiateSecurityLayer != 0))
1977 if (~file->EnableCredSSPSupport)
1980 file->EnableCredSSPSupport != 0))
1984 if (~file->EnableRdsAadAuth)
1986 const BOOL val = file->EnableRdsAadAuth != 0;
1991 if (is_pointer_used(file->AlternateShell))
1997 if (is_pointer_used(file->ShellWorkingDirectory))
2000 FreeRDP_Settings_Keys_String targetId =
2001 (~file->RemoteApplicationMode && file->RemoteApplicationMode != 0)
2002 ? FreeRDP_RemoteApplicationWorkingDir
2003 : FreeRDP_ShellWorkingDirectory;
2009 if (~file->ScreenModeId)
2027 if (~(file->SmartSizing))
2040 if (((~(file->DesktopWidth) && ~(file->DesktopHeight)) || ~(file->DesktopSizeId)) &&
2041 (file->SmartSizing == 1))
2044 file->DesktopWidth))
2047 file->DesktopHeight))
2052 if (is_pointer_used(file->LoadBalanceInfo))
2054 const size_t len = strlen(file->LoadBalanceInfo);
2056 file->LoadBalanceInfo, len))
2060 if (~file->AuthenticationLevel)
2077 file->AuthenticationLevel))
2081 if (~file->ConnectionType)
2087 if (~file->AudioMode)
2089 switch (file->AudioMode)
2091 case AUDIO_MODE_REDIRECT:
2097 case AUDIO_MODE_PLAY_ON_SERVER:
2103 case AUDIO_MODE_NONE:
2113 if (~file->AudioCaptureMode)
2119 if (~file->Compression)
2122 file->Compression != 0))
2126 if (is_pointer_used(file->GatewayHostname))
2129 char* host =
nullptr;
2131 if (!freerdp_parse_hostname(file->GatewayHostname, &host, &port))
2146 if (is_pointer_used(file->ResourceProvider))
2148 if (_stricmp(file->ResourceProvider, str_resourceprovider_arm) == 0)
2155 if (is_pointer_used(file->WvdEndpointPool))
2158 file->WvdEndpointPool))
2162 if (is_pointer_used(file->geo))
2168 if (is_pointer_used(file->armpath))
2174 if (is_pointer_used(file->aadtenantid))
2181 if (is_pointer_used(file->diagnosticserviceurl))
2184 file->diagnosticserviceurl))
2188 if (is_pointer_used(file->hubdiscoverygeourl))
2191 file->hubdiscoverygeourl))
2195 if (is_pointer_used(file->activityhint))
2198 file->activityhint))
2202 if (is_pointer_used(file->GatewayAccessToken))
2205 file->GatewayAccessToken))
2209 if (is_pointer_used(file->EndpointFedAuthToken))
2212 file->EndpointFedAuthToken))
2216 if (~file->GatewayUsageMethod)
2222 if (~file->GatewayCredentialsSource)
2224 if (file->GatewayCredentialsSource > 5)
2226 WLog_WARN(TAG,
"ignoring gatewaycredentialssource value outside range 0..5");
2229 file->GatewayCredentialsSource))
2233 if (~file->PromptCredentialOnce)
2236 file->PromptCredentialOnce != 0))
2240 if (~file->PromptForCredentials)
2243 file->PromptForCredentials != 0))
2247 if (~file->RemoteApplicationMode)
2250 file->RemoteApplicationMode != 0))
2254 if (is_pointer_used(file->RemoteApplicationProgram))
2257 file->RemoteApplicationProgram))
2261 if (is_pointer_used(file->RemoteApplicationName))
2264 file->RemoteApplicationName))
2268 if (is_pointer_used(file->RemoteApplicationIcon))
2271 file->RemoteApplicationIcon))
2275 if (is_pointer_used(file->RemoteApplicationFile))
2278 file->RemoteApplicationFile))
2282 if (is_pointer_used(file->RemoteApplicationGuid))
2285 file->RemoteApplicationGuid))
2289 if (is_pointer_used(file->RemoteApplicationCmdLine))
2292 file->RemoteApplicationCmdLine))
2296 if (~file->SpanMonitors)
2302 if (~file->UseMultiMon)
2308 if (~file->AllowFontSmoothing)
2311 file->AllowFontSmoothing != 0))
2315 if (~file->DisableWallpaper)
2318 file->DisableWallpaper != 0))
2322 if (~file->DisableFullWindowDrag)
2325 file->DisableFullWindowDrag != 0))
2329 if (~file->DisableMenuAnims)
2332 file->DisableMenuAnims != 0))
2336 if (~file->DisableThemes)
2342 if (~file->AllowDesktopComposition)
2345 file->AllowDesktopComposition != 0))
2349 if (~file->BitmapCachePersistEnable)
2352 file->BitmapCachePersistEnable != 0))
2356 if (~file->DisableRemoteAppCapsCheck)
2359 file->DisableRemoteAppCapsCheck != 0))
2363 if (~file->AutoReconnectionEnabled)
2366 file->AutoReconnectionEnabled != 0))
2370 if (~file->AutoReconnectMaxRetries)
2373 file->AutoReconnectMaxRetries))
2377 if (~file->RedirectSmartCards)
2380 file->RedirectSmartCards != 0))
2384 if (~file->RedirectWebauthN)
2387 file->RedirectWebauthN != 0))
2391 if (~file->RedirectClipboard)
2394 file->RedirectClipboard != 0))
2398 if (~file->RedirectPrinters)
2401 file->RedirectPrinters != 0))
2405 if (~file->RedirectDrives)
2411 if (~file->RedirectPosDevices)
2414 file->RedirectComPorts != 0) ||
2416 file->RedirectComPorts != 0))
2420 if (~file->RedirectComPorts)
2423 file->RedirectComPorts != 0) ||
2425 file->RedirectComPorts != 0))
2429 if (~file->RedirectLocation && (file->RedirectLocation != 0))
2435 freerdp_client_add_dynamic_channel(settings, count, (
const char*
const*)ptr);
2436 CommandLineParserFree(ptr);
2441 if (~file->RedirectDirectX)
2446 if ((is_pointer_used(file->DevicesToRedirect)) && !utils_str_is_empty(file->DevicesToRedirect))
2476 if ((is_pointer_used(file->DrivesToRedirect)) && !utils_str_is_empty(file->DrivesToRedirect))
2479 file->DrivesToRedirect))
2483 if ((is_pointer_used(file->RedirectCameras)) && !utils_str_is_empty(file->RedirectCameras))
2485#if defined(CHANNEL_RDPECAM_CLIENT)
2489 const char*
const* cc;
2491 ADDIN_ARGV* args = rdp_file_to_args(RDPECAM_DVC_CHANNEL_NAME, file->RedirectCameras);
2496 if (~file->EncodeRedirectedVideoCapture)
2498 char encode[64] = WINPR_C_ARRAY_INIT;
2499 (void)_snprintf(encode,
sizeof(encode),
"encode:%" PRIu32,
2500 file->EncodeRedirectedVideoCapture);
2501 if (!freerdp_addin_argv_add_argument(args, encode))
2504 if (~file->RedirectedVideoCaptureEncodingQuality)
2506 char quality[64] = WINPR_C_ARRAY_INIT;
2507 (void)_snprintf(quality,
sizeof(quality),
"quality:%" PRIu32,
2508 file->RedirectedVideoCaptureEncodingQuality);
2509 if (!freerdp_addin_argv_add_argument(args, quality))
2515 status = freerdp_client_add_dynamic_channel(
2516 settings, WINPR_ASSERTING_INT_CAST(
size_t, args->argc), cnv.cc);
2517 freerdp_addin_argv_free(args);
2523 "This build does not support [MS-RDPECAM] camera redirection channel. Ignoring '%s'",
2524 key_str_camerastoredirect);
2528 if ((is_pointer_used(file->UsbDevicesToRedirect)) &&
2529 !utils_str_is_empty(file->UsbDevicesToRedirect))
2531#ifdef CHANNEL_URBDRC_CLIENT
2535 const char*
const* cc;
2537 ADDIN_ARGV* args = rdp_file_to_args(URBDRC_CHANNEL_NAME, file->UsbDevicesToRedirect);
2541 const BOOL status = freerdp_client_add_dynamic_channel(
2542 settings, WINPR_ASSERTING_INT_CAST(
size_t, args->argc), cnv.cc);
2543 freerdp_addin_argv_free(args);
2548 "This build does not support [MS-RDPEUSB] usb redirection channel. Ignoring '%s'",
2549 key_str_usbdevicestoredirect);
2553 if (~file->KeyboardHook)
2559 if (~(
size_t)file->SelectedMonitors)
2562 char** ptr = CommandLineParseCommaSeparatedValues(file->SelectedMonitors, &count);
2563 UINT32* list =
nullptr;
2567 CommandLineParserFree(ptr);
2571 if (!list && (count > 0))
2573 CommandLineParserFree(ptr);
2576 for (
size_t x = 0; x < count; x++)
2578 unsigned long val = 0;
2580 val = strtoul(ptr[x],
nullptr, 0);
2581 if ((val >= UINT32_MAX) && (errno != 0))
2583 CommandLineParserFree(ptr);
2586 list[x] = (UINT32)val;
2588 CommandLineParserFree(ptr);
2591 if (~file->DynamicResolution)
2593 const BOOL val = file->DynamicResolution != 0;
2600 if (~file->DesktopScaleFactor)
2603 file->DesktopScaleFactor))
2607 if (~file->VideoPlaybackMode)
2609 if (file->VideoPlaybackMode != 0)
2626 if (is_pointer_used(file->PreconnectionBlob))
2629 file->PreconnectionBlob) ||
2634 if (is_pointer_used(file->KdcProxyName))
2640 if (~file->RdgIsKdcProxy)
2643 file->RdgIsKdcProxy != 0))
2647 if (file->args->argc > 1)
2649 WCHAR* ConnectionFile =
2652 if (freerdp_client_settings_parse_command_line(settings, file->args->argc, file->args->argv,
2655 free(ConnectionFile);
2661 free(ConnectionFile);
2670static BOOL freerdp_apply_connection_type_from_file(
const rdpFile* file, rdpSettings* settings,
2673 struct network_settings
2675 FreeRDP_Settings_Keys_Bool id;
2681 const struct network_settings config[] = { { FreeRDP_DisableWallpaper,
2682 (~file->DisableWallpaper) == 0,
2683 { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
2684 { FreeRDP_AllowFontSmoothing,
2685 (~file->AllowFontSmoothing) == 0,
2686 { FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE } },
2687 { FreeRDP_AllowDesktopComposition,
2688 (~file->AllowDesktopComposition) == 0,
2689 { FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE } },
2690 { FreeRDP_DisableFullWindowDrag,
2691 (~file->DisableFullWindowDrag) == 0,
2692 { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
2693 { FreeRDP_DisableMenuAnims,
2694 (~file->DisableMenuAnims) == 0,
2695 { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
2696 { FreeRDP_DisableThemes,
2697 (~file->DisableThemes) == 0,
2698 { TRUE, FALSE, FALSE, FALSE, FALSE, FALSE,
2703 case CONNECTION_TYPE_INVALID:
2706 case CONNECTION_TYPE_MODEM:
2707 case CONNECTION_TYPE_BROADBAND_LOW:
2708 case CONNECTION_TYPE_BROADBAND_HIGH:
2709 case CONNECTION_TYPE_SATELLITE:
2710 case CONNECTION_TYPE_WAN:
2711 case CONNECTION_TYPE_LAN:
2712 case CONNECTION_TYPE_AUTODETECT:
2715 WLog_WARN(TAG,
"Unknown ConnectionType %" PRIu32
", aborting", type);
2719 for (
size_t x = 0; x < ARRAYSIZE(config); x++)
2721 const struct network_settings* cur = &config[x];
2732static BOOL freerdp_set_connection_type_from_file(
const rdpFile* file, rdpSettings* settings,
2741 case CONNECTION_TYPE_INVALID:
2742 case CONNECTION_TYPE_MODEM:
2743 case CONNECTION_TYPE_BROADBAND_LOW:
2744 case CONNECTION_TYPE_SATELLITE:
2745 case CONNECTION_TYPE_BROADBAND_HIGH:
2746 case CONNECTION_TYPE_WAN:
2747 case CONNECTION_TYPE_LAN:
2748 if (!freerdp_apply_connection_type_from_file(file, settings, type))
2751 case CONNECTION_TYPE_AUTODETECT:
2752 if (!freerdp_apply_connection_type_from_file(file, settings, type))
2766 WLog_WARN(TAG,
"Unknown ConnectionType %" PRIu32
", aborting", type);
2773BOOL freerdp_client_populate_settings_from_rdp_file(
const rdpFile* file, rdpSettings* settings)
2775 if (!freerdp_client_populate_settings_from_rdp_file_unchecked(file, settings))
2779 if ((~file->ConnectionType) == 0)
2782 type = CONNECTION_TYPE_AUTODETECT;
2784 return freerdp_set_connection_type_from_file(file, settings, type);
2788static rdpFileLine* freerdp_client_rdp_file_find_line_by_name(
const rdpFile* file,
const char* name)
2790 BOOL bFound = FALSE;
2791 rdpFileLine* line =
nullptr;
2793 for (
size_t index = 0; index < file->lineCount; index++)
2795 line = &(file->lines[index]);
2797 if (line->flags & RDP_FILE_LINE_FLAG_FORMATTED)
2799 if (_stricmp(name, line->name) == 0)
2807 return (bFound) ? line :
nullptr;
2816int freerdp_client_rdp_file_set_string_option(rdpFile* file,
const char* name,
const char* value)
2818 return freerdp_client_rdp_file_set_string(file, name, value);
2821const char* freerdp_client_rdp_file_get_string_option(
const rdpFile* file,
const char* name)
2823 LPSTR* value =
nullptr;
2824 rdpFileLine* line =
nullptr;
2826 rdpFile* wfile = WINPR_CAST_CONST_PTR_AWAY(file, rdpFile*);
2827 if (freerdp_client_rdp_file_find_string_entry(wfile, name, &value, &line))
2829 if (value && ~(
size_t)(*value))
2832 return line->sValue;
2838int freerdp_client_rdp_file_set_integer_option(rdpFile* file,
const char* name,
int value)
2840 return freerdp_client_rdp_file_set_integer(file, name, value);
2843int freerdp_client_rdp_file_get_integer_option(
const rdpFile* file,
const char* name)
2845 DWORD* value =
nullptr;
2846 rdpFileLine* line =
nullptr;
2848 rdpFile* wfile = WINPR_CAST_CONST_PTR_AWAY(file, rdpFile*);
2849 if (freerdp_client_rdp_file_find_integer_entry(wfile, name, &value, &line))
2851 if (value && ~(*value))
2852 return WINPR_ASSERTING_INT_CAST(
int, *value);
2854 return (
int)line->iValue;
2860static void freerdp_client_file_string_check_free(LPSTR str)
2862 if (is_pointer_used(str))
2866rdpFile* freerdp_client_rdp_file_new(
void)
2868 return freerdp_client_rdp_file_new_ex(0);
2871rdpFile* freerdp_client_rdp_file_new_ex(DWORD flags)
2873 rdpFile* file = (rdpFile*)calloc(1,
sizeof(rdpFile));
2878 file->flags = flags;
2880 FillMemory(file,
sizeof(rdpFile), 0xFF);
2881 file->lines =
nullptr;
2882 file->lineCount = 0;
2883 file->lineSize = 32;
2884 file->GatewayProfileUsageMethod = 1;
2885 file->lines = (rdpFileLine*)calloc(file->lineSize,
sizeof(rdpFileLine));
2887 file->args = freerdp_addin_argv_new(0,
nullptr);
2888 if (!file->lines || !file->args)
2891 if (!freerdp_client_add_option(file,
"freerdp"))
2896 WINPR_PRAGMA_DIAG_PUSH
2897 WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
2898 freerdp_client_rdp_file_free(file);
2899 WINPR_PRAGMA_DIAG_POP
2903void freerdp_client_rdp_file_free(rdpFile* file)
2907 for (
size_t i = 0; i < file->lineCount; i++)
2909 rdpFileLine* cur = &file->lines[i];
2916 freerdp_addin_argv_free(file->args);
2918 freerdp_client_file_string_check_free(file->SelectedMonitors);
2919 freerdp_client_file_string_check_free(file->Username);
2920 freerdp_client_file_string_check_free(file->Domain);
2921 freerdp_client_file_string_check_free(file->Password);
2922 freerdp_client_file_string_check_free(file->FullAddress);
2923 freerdp_client_file_string_check_free(file->AlternateFullAddress);
2924 freerdp_client_file_string_check_free(file->UsbDevicesToRedirect);
2925 freerdp_client_file_string_check_free(file->RedirectCameras);
2926 freerdp_client_file_string_check_free(file->LoadBalanceInfo);
2927 freerdp_client_file_string_check_free(file->RemoteApplicationName);
2928 freerdp_client_file_string_check_free(file->RemoteApplicationIcon);
2929 freerdp_client_file_string_check_free(file->RemoteApplicationProgram);
2930 freerdp_client_file_string_check_free(file->RemoteApplicationFile);
2931 freerdp_client_file_string_check_free(file->RemoteApplicationGuid);
2932 freerdp_client_file_string_check_free(file->RemoteApplicationCmdLine);
2933 freerdp_client_file_string_check_free(file->AlternateShell);
2934 freerdp_client_file_string_check_free(file->ShellWorkingDirectory);
2935 freerdp_client_file_string_check_free(file->GatewayHostname);
2936 freerdp_client_file_string_check_free(file->ResourceProvider);
2937 freerdp_client_file_string_check_free(file->WvdEndpointPool);
2938 freerdp_client_file_string_check_free(file->geo);
2939 freerdp_client_file_string_check_free(file->armpath);
2940 freerdp_client_file_string_check_free(file->aadtenantid);
2941 freerdp_client_file_string_check_free(file->diagnosticserviceurl);
2942 freerdp_client_file_string_check_free(file->hubdiscoverygeourl);
2943 freerdp_client_file_string_check_free(file->activityhint);
2944 freerdp_client_file_string_check_free(file->GatewayAccessToken);
2945 freerdp_client_file_string_check_free(file->EndpointFedAuthToken);
2946 freerdp_client_file_string_check_free(file->DrivesToRedirect);
2947 freerdp_client_file_string_check_free(file->DevicesToRedirect);
2948 freerdp_client_file_string_check_free(file->WinPosStr);
2949 freerdp_client_file_string_check_free(file->PreconnectionBlob);
2950 freerdp_client_file_string_check_free(file->KdcProxyName);
2956void freerdp_client_rdp_file_set_callback_context(rdpFile* file,
void* context)
2958 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.