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;
145 LPSTR AlternateFullAddress;
147 LPSTR UsbDevicesToRedirect;
148 DWORD RedirectDrives;
149 DWORD RedirectPrinters;
150 DWORD RedirectComPorts;
151 DWORD RedirectLocation;
152 DWORD RedirectSmartCards;
153 DWORD RedirectWebauthN;
154 LPSTR RedirectCameras;
155 DWORD RedirectClipboard;
156 DWORD RedirectPosDevices;
157 DWORD RedirectDirectX;
158 DWORD DisablePrinterRedirection;
159 DWORD DisableClipboardRedirection;
161 DWORD ConnectToConsole;
162 DWORD AdministrativeSession;
163 DWORD AutoReconnectionEnabled;
164 DWORD AutoReconnectMaxRetries;
167 DWORD AuthenticationLevel;
168 DWORD PromptCredentialOnce;
169 DWORD PromptForCredentials;
170 DWORD NegotiateSecurityLayer;
171 DWORD EnableCredSSPSupport;
172 DWORD EnableRdsAadAuth;
174 DWORD RemoteApplicationMode;
175 LPSTR LoadBalanceInfo;
177 LPSTR RemoteApplicationName;
178 LPSTR RemoteApplicationIcon;
179 LPSTR RemoteApplicationProgram;
180 LPSTR RemoteApplicationFile;
181 LPSTR RemoteApplicationGuid;
182 LPSTR RemoteApplicationCmdLine;
183 DWORD RemoteApplicationExpandCmdLine;
184 DWORD RemoteApplicationExpandWorkingDir;
185 DWORD DisableConnectionSharing;
186 DWORD DisableRemoteAppCapsCheck;
188 LPSTR AlternateShell;
189 LPSTR ShellWorkingDirectory;
191 LPSTR GatewayHostname;
192 DWORD GatewayUsageMethod;
193 DWORD GatewayProfileUsageMethod;
194 DWORD GatewayCredentialsSource;
196 LPSTR ResourceProvider;
198 LPSTR WvdEndpointPool;
202 LPSTR diagnosticserviceurl;
203 LPSTR hubdiscoverygeourl;
206 DWORD UseRedirectionServerName;
208 LPSTR GatewayAccessToken;
210 LPSTR EndpointFedAuthToken;
212 LPSTR DrivesToRedirect;
213 LPSTR DevicesToRedirect;
216 LPSTR PreconnectionBlob;
233static const char key_str_username[] =
"username";
234static const char key_str_domain[] =
"domain";
235static const char key_str_password[] =
"password";
236static const char key_str_full_address[] =
"full address";
237static const char key_str_alternate_full_address[] =
"alternate full address";
238static const char key_str_usbdevicestoredirect[] =
"usbdevicestoredirect";
239static const char key_str_camerastoredirect[] =
"camerastoredirect";
240static const char key_str_loadbalanceinfo[] =
"loadbalanceinfo";
241static const char key_str_remoteapplicationname[] =
"remoteapplicationname";
242static const char key_str_remoteapplicationicon[] =
"remoteapplicationicon";
243static const char key_str_remoteapplicationprogram[] =
"remoteapplicationprogram";
244static const char key_str_remoteapplicationfile[] =
"remoteapplicationfile";
245static const char key_str_remoteapplicationguid[] =
"remoteapplicationguid";
246static const char key_str_remoteapplicationcmdline[] =
"remoteapplicationcmdline";
247static const char key_str_alternate_shell[] =
"alternate shell";
248static const char key_str_shell_working_directory[] =
"shell working directory";
249static const char key_str_gatewayhostname[] =
"gatewayhostname";
250static const char key_str_gatewayaccesstoken[] =
"gatewayaccesstoken";
251static const char key_str_endpointfedauth[] =
"endpointfedauth";
252static const char key_str_resourceprovider[] =
"resourceprovider";
253static const char str_resourceprovider_arm[] =
"arm";
254static const char key_str_kdcproxyname[] =
"kdcproxyname";
255static const char key_str_drivestoredirect[] =
"drivestoredirect";
256static const char key_str_devicestoredirect[] =
"devicestoredirect";
257static const char key_str_winposstr[] =
"winposstr";
258static const char key_str_pcb[] =
"pcb";
259static const char key_str_selectedmonitors[] =
"selectedmonitors";
261static const char key_str_wvd[] =
"wvd endpoint pool";
262static const char key_str_geo[] =
"geo";
263static const char key_str_armpath[] =
"armpath";
264static const char key_str_aadtenantid[] =
"aadtenantid";
266static const char key_str_diagnosticserviceurl[] =
"diagnosticserviceurl";
267static const char key_str_hubdiscoverygeourl[] =
"hubdiscoverygeourl";
269static const char key_str_activityhint[] =
"activityhint";
271static const char key_int_rdgiskdcproxy[] =
"rdgiskdcproxy";
272static const char key_int_use_redirection_server_name[] =
"use redirection server name";
273static const char key_int_gatewaycredentialssource[] =
"gatewaycredentialssource";
274static const char key_int_gatewayprofileusagemethod[] =
"gatewayprofileusagemethod";
275static const char key_int_gatewayusagemethod[] =
"gatewayusagemethod";
276static const char key_int_disableremoteappcapscheck[] =
"disableremoteappcapscheck";
277static const char key_int_disableconnectionsharing[] =
"disableconnectionsharing";
278static const char key_int_remoteapplicationexpandworkingdir[] =
"remoteapplicationexpandworkingdir";
279static const char key_int_remoteapplicationexpandcmdline[] =
"remoteapplicationexpandcmdline";
280static const char key_int_remoteapplicationmode[] =
"remoteapplicationmode";
281static const char key_int_enablecredsspsupport[] =
"enablecredsspsupport";
282static const char key_int_enablerdsaadauth[] =
"enablerdsaadauth";
283static const char key_int_negotiate_security_layer[] =
"negotiate security layer";
284static const char key_int_prompt_for_credentials[] =
"prompt for credentials";
285static const char key_int_promptcredentialonce[] =
"promptcredentialonce";
286static const char key_int_authentication_level[] =
"authentication level";
287static const char key_int_public_mode[] =
"public mode";
288static const char key_int_autoreconnect_max_retries[] =
"autoreconnect max retries";
289static const char key_int_autoreconnection_enabled[] =
"autoreconnection enabled";
290static const char key_int_administrative_session[] =
"administrative session";
291static const char key_int_connect_to_console[] =
"connect to console";
292static const char key_int_disableclipboardredirection[] =
"disableclipboardredirection";
293static const char key_int_disableprinterredirection[] =
"disableprinterredirection";
294static const char key_int_redirectdirectx[] =
"redirectdirectx";
295static const char key_int_redirectposdevices[] =
"redirectposdevices";
296static const char key_int_redirectclipboard[] =
"redirectclipboard";
297static const char key_int_redirectsmartcards[] =
"redirectsmartcards";
298static const char key_int_redirectcomports[] =
"redirectcomports";
299static const char key_int_redirectlocation[] =
"redirectlocation";
300static const char key_int_redirectprinters[] =
"redirectprinters";
301static const char key_int_redirectdrives[] =
"redirectdrives";
302static const char key_int_server_port[] =
"server port";
303static const char key_int_bitmapcachepersistenable[] =
"bitmapcachepersistenable";
304static const char key_int_bitmapcachesize[] =
"bitmapcachesize";
305static const char key_int_disable_cursor_setting[] =
"disable cursor setting";
306static const char key_int_disable_themes[] =
"disable themes";
307static const char key_int_disable_menu_anims[] =
"disable menu anims";
308static const char key_int_disable_full_window_drag[] =
"disable full window drag";
309static const char key_int_allow_desktop_composition[] =
"allow desktop composition";
310static const char key_int_allow_font_smoothing[] =
"allow font smoothing";
311static const char key_int_disable_wallpaper[] =
"disable wallpaper";
312static const char key_int_enableworkspacereconnect[] =
"enableworkspacereconnect";
313static const char key_int_workspaceid[] =
"workspaceid";
314static const char key_int_displayconnectionbar[] =
"displayconnectionbar";
315static const char key_int_pinconnectionbar[] =
"pinconnectionbar";
316static const char key_int_bandwidthautodetect[] =
"bandwidthautodetect";
317static const char key_int_networkautodetect[] =
"networkautodetect";
318static const char key_int_connection_type[] =
"connection type";
319static const char key_int_videoplaybackmode[] =
"videoplaybackmode";
320static const char key_int_redirected_video_capture_encoding_quality[] =
321 "redirected video capture encoding quality";
322static const char key_int_encode_redirected_video_capture[] =
"encode redirected video capture";
323static const char key_int_audiocapturemode[] =
"audiocapturemode";
324static const char key_int_audioqualitymode[] =
"audioqualitymode";
325static const char key_int_audiomode[] =
"audiomode";
326static const char key_int_disable_ctrl_alt_del[] =
"disable ctrl+alt+del";
327static const char key_int_keyboardhook[] =
"keyboardhook";
328static const char key_int_compression[] =
"compression";
329static const char key_int_desktopscalefactor[] =
"desktopscalefactor";
330static const char key_int_session_bpp[] =
"session bpp";
331static const char key_int_desktop_size_id[] =
"desktop size id";
332static const char key_int_desktopheight[] =
"desktopheight";
333static const char key_int_desktopwidth[] =
"desktopwidth";
334static const char key_int_superpanaccelerationfactor[] =
"superpanaccelerationfactor";
335static const char key_int_enablesuperpan[] =
"enablesuperpan";
336static const char key_int_dynamic_resolution[] =
"dynamic resolution";
337static const char key_int_smart_sizing[] =
"smart sizing";
338static const char key_int_span_monitors[] =
"span monitors";
339static const char key_int_screen_mode_id[] =
"screen mode id";
340static const char key_int_singlemoninwindowedmode[] =
"singlemoninwindowedmode";
341static const char key_int_maximizetocurrentdisplays[] =
"maximizetocurrentdisplays";
342static const char key_int_use_multimon[] =
"use multimon";
343static const char key_int_redirectwebauthn[] =
"redirectwebauthn";
345static BOOL utils_str_is_empty(
const char* str)
349 if (strlen(str) == 0)
354static SSIZE_T freerdp_client_rdp_file_add_line(rdpFile* file);
355static rdpFileLine* freerdp_client_rdp_file_find_line_by_name(
const rdpFile* file,
357static void freerdp_client_file_string_check_free(LPSTR str);
359static BOOL freerdp_client_rdp_file_find_integer_entry(rdpFile* file,
const char* name,
360 DWORD** outValue, rdpFileLine** outLine)
364 WINPR_ASSERT(outValue);
365 WINPR_ASSERT(outLine);
370 if (_stricmp(name, key_int_use_multimon) == 0)
371 *outValue = &file->UseMultiMon;
372 else if (_stricmp(name, key_int_maximizetocurrentdisplays) == 0)
373 *outValue = &file->MaximizeToCurrentDisplays;
374 else if (_stricmp(name, key_int_singlemoninwindowedmode) == 0)
375 *outValue = &file->SingleMonInWindowedMode;
376 else if (_stricmp(name, key_int_screen_mode_id) == 0)
377 *outValue = &file->ScreenModeId;
378 else if (_stricmp(name, key_int_span_monitors) == 0)
379 *outValue = &file->SpanMonitors;
380 else if (_stricmp(name, key_int_smart_sizing) == 0)
381 *outValue = &file->SmartSizing;
382 else if (_stricmp(name, key_int_dynamic_resolution) == 0)
383 *outValue = &file->DynamicResolution;
384 else if (_stricmp(name, key_int_enablesuperpan) == 0)
385 *outValue = &file->EnableSuperSpan;
386 else if (_stricmp(name, key_int_superpanaccelerationfactor) == 0)
387 *outValue = &file->SuperSpanAccelerationFactor;
388 else if (_stricmp(name, key_int_desktopwidth) == 0)
389 *outValue = &file->DesktopWidth;
390 else if (_stricmp(name, key_int_desktopheight) == 0)
391 *outValue = &file->DesktopHeight;
392 else if (_stricmp(name, key_int_desktop_size_id) == 0)
393 *outValue = &file->DesktopSizeId;
394 else if (_stricmp(name, key_int_session_bpp) == 0)
395 *outValue = &file->SessionBpp;
396 else if (_stricmp(name, key_int_desktopscalefactor) == 0)
397 *outValue = &file->DesktopScaleFactor;
398 else if (_stricmp(name, key_int_compression) == 0)
399 *outValue = &file->Compression;
400 else if (_stricmp(name, key_int_keyboardhook) == 0)
401 *outValue = &file->KeyboardHook;
402 else if (_stricmp(name, key_int_disable_ctrl_alt_del) == 0)
403 *outValue = &file->DisableCtrlAltDel;
404 else if (_stricmp(name, key_int_audiomode) == 0)
405 *outValue = &file->AudioMode;
406 else if (_stricmp(name, key_int_audioqualitymode) == 0)
407 *outValue = &file->AudioQualityMode;
408 else if (_stricmp(name, key_int_audiocapturemode) == 0)
409 *outValue = &file->AudioCaptureMode;
410 else if (_stricmp(name, key_int_encode_redirected_video_capture) == 0)
411 *outValue = &file->EncodeRedirectedVideoCapture;
412 else if (_stricmp(name, key_int_redirected_video_capture_encoding_quality) == 0)
413 *outValue = &file->RedirectedVideoCaptureEncodingQuality;
414 else if (_stricmp(name, key_int_videoplaybackmode) == 0)
415 *outValue = &file->VideoPlaybackMode;
416 else if (_stricmp(name, key_int_connection_type) == 0)
417 *outValue = &file->ConnectionType;
418 else if (_stricmp(name, key_int_networkautodetect) == 0)
419 *outValue = &file->NetworkAutoDetect;
420 else if (_stricmp(name, key_int_bandwidthautodetect) == 0)
421 *outValue = &file->BandwidthAutoDetect;
422 else if (_stricmp(name, key_int_pinconnectionbar) == 0)
423 *outValue = &file->PinConnectionBar;
424 else if (_stricmp(name, key_int_displayconnectionbar) == 0)
425 *outValue = &file->DisplayConnectionBar;
426 else if (_stricmp(name, key_int_workspaceid) == 0)
427 *outValue = &file->WorkspaceId;
428 else if (_stricmp(name, key_int_enableworkspacereconnect) == 0)
429 *outValue = &file->EnableWorkspaceReconnect;
430 else if (_stricmp(name, key_int_disable_wallpaper) == 0)
431 *outValue = &file->DisableWallpaper;
432 else if (_stricmp(name, key_int_allow_font_smoothing) == 0)
433 *outValue = &file->AllowFontSmoothing;
434 else if (_stricmp(name, key_int_allow_desktop_composition) == 0)
435 *outValue = &file->AllowDesktopComposition;
436 else if (_stricmp(name, key_int_disable_full_window_drag) == 0)
437 *outValue = &file->DisableFullWindowDrag;
438 else if (_stricmp(name, key_int_disable_menu_anims) == 0)
439 *outValue = &file->DisableMenuAnims;
440 else if (_stricmp(name, key_int_disable_themes) == 0)
441 *outValue = &file->DisableThemes;
442 else if (_stricmp(name, key_int_disable_cursor_setting) == 0)
443 *outValue = &file->DisableCursorSetting;
444 else if (_stricmp(name, key_int_bitmapcachesize) == 0)
445 *outValue = &file->BitmapCacheSize;
446 else if (_stricmp(name, key_int_bitmapcachepersistenable) == 0)
447 *outValue = &file->BitmapCachePersistEnable;
448 else if (_stricmp(name, key_int_server_port) == 0)
449 *outValue = &file->ServerPort;
450 else if (_stricmp(name, key_int_redirectdrives) == 0)
451 *outValue = &file->RedirectDrives;
452 else if (_stricmp(name, key_int_redirectprinters) == 0)
453 *outValue = &file->RedirectPrinters;
454 else if (_stricmp(name, key_int_redirectcomports) == 0)
455 *outValue = &file->RedirectComPorts;
456 else if (_stricmp(name, key_int_redirectlocation) == 0)
457 *outValue = &file->RedirectLocation;
458 else if (_stricmp(name, key_int_redirectsmartcards) == 0)
459 *outValue = &file->RedirectSmartCards;
460 else if (_stricmp(name, key_int_redirectclipboard) == 0)
461 *outValue = &file->RedirectClipboard;
462 else if (_stricmp(name, key_int_redirectposdevices) == 0)
463 *outValue = &file->RedirectPosDevices;
464 else if (_stricmp(name, key_int_redirectdirectx) == 0)
465 *outValue = &file->RedirectDirectX;
466 else if (_stricmp(name, key_int_disableprinterredirection) == 0)
467 *outValue = &file->DisablePrinterRedirection;
468 else if (_stricmp(name, key_int_disableclipboardredirection) == 0)
469 *outValue = &file->DisableClipboardRedirection;
470 else if (_stricmp(name, key_int_connect_to_console) == 0)
471 *outValue = &file->ConnectToConsole;
472 else if (_stricmp(name, key_int_administrative_session) == 0)
473 *outValue = &file->AdministrativeSession;
474 else if (_stricmp(name, key_int_autoreconnection_enabled) == 0)
475 *outValue = &file->AutoReconnectionEnabled;
476 else if (_stricmp(name, key_int_autoreconnect_max_retries) == 0)
477 *outValue = &file->AutoReconnectMaxRetries;
478 else if (_stricmp(name, key_int_public_mode) == 0)
479 *outValue = &file->PublicMode;
480 else if (_stricmp(name, key_int_authentication_level) == 0)
481 *outValue = &file->AuthenticationLevel;
482 else if (_stricmp(name, key_int_promptcredentialonce) == 0)
483 *outValue = &file->PromptCredentialOnce;
484 else if ((_stricmp(name, key_int_prompt_for_credentials) == 0))
485 *outValue = &file->PromptForCredentials;
486 else if (_stricmp(name, key_int_negotiate_security_layer) == 0)
487 *outValue = &file->NegotiateSecurityLayer;
488 else if (_stricmp(name, key_int_enablecredsspsupport) == 0)
489 *outValue = &file->EnableCredSSPSupport;
490 else if (_stricmp(name, key_int_enablerdsaadauth) == 0)
491 *outValue = &file->EnableRdsAadAuth;
492 else if (_stricmp(name, key_int_remoteapplicationmode) == 0)
493 *outValue = &file->RemoteApplicationMode;
494 else if (_stricmp(name, key_int_remoteapplicationexpandcmdline) == 0)
495 *outValue = &file->RemoteApplicationExpandCmdLine;
496 else if (_stricmp(name, key_int_remoteapplicationexpandworkingdir) == 0)
497 *outValue = &file->RemoteApplicationExpandWorkingDir;
498 else if (_stricmp(name, key_int_disableconnectionsharing) == 0)
499 *outValue = &file->DisableConnectionSharing;
500 else if (_stricmp(name, key_int_disableremoteappcapscheck) == 0)
501 *outValue = &file->DisableRemoteAppCapsCheck;
502 else if (_stricmp(name, key_int_gatewayusagemethod) == 0)
503 *outValue = &file->GatewayUsageMethod;
504 else if (_stricmp(name, key_int_gatewayprofileusagemethod) == 0)
505 *outValue = &file->GatewayProfileUsageMethod;
506 else if (_stricmp(name, key_int_gatewaycredentialssource) == 0)
507 *outValue = &file->GatewayCredentialsSource;
508 else if (_stricmp(name, key_int_use_redirection_server_name) == 0)
509 *outValue = &file->UseRedirectionServerName;
510 else if (_stricmp(name, key_int_rdgiskdcproxy) == 0)
511 *outValue = &file->RdgIsKdcProxy;
512 else if (_stricmp(name, key_int_redirectwebauthn) == 0)
513 *outValue = &file->RedirectWebauthN;
516 rdpFileLine* line = freerdp_client_rdp_file_find_line_by_name(file, name);
519 if (!(line->flags & RDP_FILE_LINE_FLAG_TYPE_INTEGER))
528static BOOL freerdp_client_rdp_file_find_string_entry(rdpFile* file,
const char* name,
529 LPSTR** outValue, rdpFileLine** outLine)
533 WINPR_ASSERT(outValue);
534 WINPR_ASSERT(outLine);
539 if (_stricmp(name, key_str_username) == 0)
540 *outValue = &file->Username;
541 else if (_stricmp(name, key_str_domain) == 0)
542 *outValue = &file->Domain;
543 else if (_stricmp(name, key_str_password) == 0)
544 *outValue = &file->Password;
545 else if (_stricmp(name, key_str_full_address) == 0)
546 *outValue = &file->FullAddress;
547 else if (_stricmp(name, key_str_alternate_full_address) == 0)
548 *outValue = &file->AlternateFullAddress;
549 else if (_stricmp(name, key_str_usbdevicestoredirect) == 0)
550 *outValue = &file->UsbDevicesToRedirect;
551 else if (_stricmp(name, key_str_camerastoredirect) == 0)
552 *outValue = &file->RedirectCameras;
553 else if (_stricmp(name, key_str_loadbalanceinfo) == 0)
554 *outValue = &file->LoadBalanceInfo;
555 else if (_stricmp(name, key_str_remoteapplicationname) == 0)
556 *outValue = &file->RemoteApplicationName;
557 else if (_stricmp(name, key_str_remoteapplicationicon) == 0)
558 *outValue = &file->RemoteApplicationIcon;
559 else if (_stricmp(name, key_str_remoteapplicationprogram) == 0)
560 *outValue = &file->RemoteApplicationProgram;
561 else if (_stricmp(name, key_str_remoteapplicationfile) == 0)
562 *outValue = &file->RemoteApplicationFile;
563 else if (_stricmp(name, key_str_remoteapplicationguid) == 0)
564 *outValue = &file->RemoteApplicationGuid;
565 else if (_stricmp(name, key_str_remoteapplicationcmdline) == 0)
566 *outValue = &file->RemoteApplicationCmdLine;
567 else if (_stricmp(name, key_str_alternate_shell) == 0)
568 *outValue = &file->AlternateShell;
569 else if (_stricmp(name, key_str_shell_working_directory) == 0)
570 *outValue = &file->ShellWorkingDirectory;
571 else if (_stricmp(name, key_str_gatewayhostname) == 0)
572 *outValue = &file->GatewayHostname;
573 else if (_stricmp(name, key_str_resourceprovider) == 0)
574 *outValue = &file->ResourceProvider;
575 else if (_stricmp(name, key_str_wvd) == 0)
576 *outValue = &file->WvdEndpointPool;
577 else if (_stricmp(name, key_str_geo) == 0)
578 *outValue = &file->geo;
579 else if (_stricmp(name, key_str_armpath) == 0)
580 *outValue = &file->armpath;
581 else if (_stricmp(name, key_str_aadtenantid) == 0)
582 *outValue = &file->aadtenantid;
583 else if (_stricmp(name, key_str_diagnosticserviceurl) == 0)
584 *outValue = &file->diagnosticserviceurl;
585 else if (_stricmp(name, key_str_hubdiscoverygeourl) == 0)
586 *outValue = &file->hubdiscoverygeourl;
587 else if (_stricmp(name, key_str_activityhint) == 0)
588 *outValue = &file->activityhint;
589 else if (_stricmp(name, key_str_gatewayaccesstoken) == 0)
590 *outValue = &file->GatewayAccessToken;
591 else if (_stricmp(name, key_str_endpointfedauth) == 0)
592 *outValue = &file->EndpointFedAuthToken;
593 else if (_stricmp(name, key_str_kdcproxyname) == 0)
594 *outValue = &file->KdcProxyName;
595 else if (_stricmp(name, key_str_drivestoredirect) == 0)
596 *outValue = &file->DrivesToRedirect;
597 else if (_stricmp(name, key_str_devicestoredirect) == 0)
598 *outValue = &file->DevicesToRedirect;
599 else if (_stricmp(name, key_str_winposstr) == 0)
600 *outValue = &file->WinPosStr;
601 else if (_stricmp(name, key_str_pcb) == 0)
602 *outValue = &file->PreconnectionBlob;
603 else if (_stricmp(name, key_str_selectedmonitors) == 0)
604 *outValue = &file->SelectedMonitors;
607 rdpFileLine* line = freerdp_client_rdp_file_find_line_by_name(file, name);
610 if (!(line->flags & RDP_FILE_LINE_FLAG_TYPE_STRING))
625static BOOL freerdp_client_rdp_file_set_integer(rdpFile* file,
const char* name,
long value)
627 DWORD* targetValue =
nullptr;
628 rdpFileLine* line =
nullptr;
629#ifdef DEBUG_CLIENT_FILE
630 WLog_DBG(TAG,
"%s:i:%ld", name, value);
636 if (!freerdp_client_rdp_file_find_integer_entry(file, name, &targetValue, &line))
638 SSIZE_T index = freerdp_client_rdp_file_add_line(file);
641 line = &file->lines[index];
646 *targetValue = (DWORD)value;
653 line->name = _strdup(name);
657 line->name =
nullptr;
661 line->iValue = value;
662 line->flags = RDP_FILE_LINE_FLAG_FORMATTED;
663 line->flags |= RDP_FILE_LINE_FLAG_TYPE_INTEGER;
664 line->valueLength = 0;
671static BOOL freerdp_client_parse_rdp_file_integer(rdpFile* file,
const char* name,
674 char* endptr =
nullptr;
677 ivalue = strtol(value, &endptr, 0);
679 if ((endptr ==
nullptr) || (errno != 0) || (endptr == value) || (ivalue > INT32_MAX) ||
680 (ivalue < INT32_MIN))
682 if (file->flags & RDP_FILE_FLAG_PARSE_INT_RELAXED)
684 WLog_WARN(TAG,
"Integer option %s has invalid value %s, using default", name, value);
689 WLog_ERR(TAG,
"Failed to convert RDP file integer option %s [value=%s]", name, value);
694 return freerdp_client_rdp_file_set_integer(file, name, ivalue);
705static BOOL freerdp_client_rdp_file_set_string(rdpFile* file,
const char* name,
const char* value)
707 LPSTR* targetValue =
nullptr;
708 rdpFileLine* line =
nullptr;
709#ifdef DEBUG_CLIENT_FILE
710 WLog_DBG(TAG,
"%s:s:%s", name, value);
716 if (!freerdp_client_rdp_file_find_string_entry(file, name, &targetValue, &line))
718 SSIZE_T index = freerdp_client_rdp_file_add_line(file);
721 line = &file->lines[index];
726 if ((uintptr_t)(*targetValue) != UINTPTR_MAX)
729 *targetValue = _strdup(value);
730 return ((*targetValue) !=
nullptr);
737 line->name = _strdup(name);
738 line->sValue = _strdup(value);
739 if (!line->name || !line->sValue)
743 line->name =
nullptr;
744 line->sValue =
nullptr;
748 line->flags = RDP_FILE_LINE_FLAG_FORMATTED;
749 line->flags |= RDP_FILE_LINE_FLAG_TYPE_STRING;
750 line->valueLength = 0;
757static BOOL freerdp_client_add_option(rdpFile* file,
const char* option)
759 return freerdp_addin_argv_add_argument(file->args, option);
762static SSIZE_T freerdp_client_rdp_file_add_line(rdpFile* file)
764 SSIZE_T index = (SSIZE_T)file->lineCount;
766 while ((file->lineCount + 1) > file->lineSize)
768 size_t new_size = file->lineCount + 2048;
769 rdpFileLine* new_line = (rdpFileLine*)realloc(file->lines, new_size *
sizeof(rdpFileLine));
774 file->lines = new_line;
775 file->lineSize = new_size;
778 ZeroMemory(&(file->lines[file->lineCount]),
sizeof(rdpFileLine));
779 file->lines[file->lineCount].index = (size_t)index;
784BOOL freerdp_client_parse_rdp_file_buffer(rdpFile* file,
const BYTE* buffer,
size_t size)
786 return freerdp_client_parse_rdp_file_buffer_ex(file, buffer, size,
nullptr);
789static BOOL trim(
char** strptr)
791 char* start =
nullptr;
795 start = str = *strptr;
798 if (!(~((
size_t)str)))
800 end = str + strlen(str) - 1;
802 while (isspace(*str))
805 while ((end > str) && isspace(*end))
812 *strptr = _strdup(str);
814 return *strptr !=
nullptr;
820static BOOL trim_strings(rdpFile* file)
822 if (!trim(&file->Username))
824 if (!trim(&file->Domain))
826 if (!trim(&file->AlternateFullAddress))
828 if (!trim(&file->FullAddress))
830 if (!trim(&file->UsbDevicesToRedirect))
832 if (!trim(&file->RedirectCameras))
834 if (!trim(&file->LoadBalanceInfo))
836 if (!trim(&file->GatewayHostname))
838 if (!trim(&file->GatewayAccessToken))
840 if (!trim(&file->EndpointFedAuthToken))
842 if (!trim(&file->RemoteApplicationName))
844 if (!trim(&file->RemoteApplicationIcon))
846 if (!trim(&file->RemoteApplicationProgram))
848 if (!trim(&file->RemoteApplicationFile))
850 if (!trim(&file->RemoteApplicationGuid))
852 if (!trim(&file->RemoteApplicationCmdLine))
854 if (!trim(&file->AlternateShell))
856 if (!trim(&file->ShellWorkingDirectory))
858 if (!trim(&file->DrivesToRedirect))
860 if (!trim(&file->DevicesToRedirect))
862 if (!trim(&file->WinPosStr))
864 if (!trim(&file->PreconnectionBlob))
866 if (!trim(&file->KdcProxyName))
868 if (!trim(&file->SelectedMonitors))
871 for (
size_t i = 0; i < file->lineCount; ++i)
873 rdpFileLine* curLine = &file->lines[i];
874 if (curLine->flags & RDP_FILE_LINE_FLAG_TYPE_STRING)
876 if (!trim(&curLine->sValue))
884static BOOL parse_line(rdpFile* file,
char* line,
size_t length, rdp_file_fkt_parse parse)
889 const char* beg = line;
890#if !defined(WITHOUT_FREERDP_3x_DEPRECATED)
891#if defined(WITH_EMBEDDED_CLI_IN_RDP_FILES)
894 freerdp_warn_deprecated(WLog_Get(TAG),
"Parsing CLI options within an RDP file",
895 "Will be removed in FreeRDP 4.0");
896 if (!freerdp_client_add_option(file, line))
904 char* d1 = strchr(line,
':');
909 const char* type = &d1[1];
910 char* d2 = strchr(type,
':');
920 const char* name = beg;
921 const char* value = &d2[1];
923 if (parse && parse(file->context, name, *type, value))
929 return freerdp_client_parse_rdp_file_integer(file, name, value);
934 return freerdp_client_rdp_file_set_string(file, name, value);
939 WLog_ERR(TAG,
"Unsupported RDP file binary option %s [value=%s]", name, value);
945BOOL freerdp_client_parse_rdp_file_buffer_ex(rdpFile* file,
const BYTE* buffer,
size_t size,
946 rdp_file_fkt_parse parse)
949 char* copy =
nullptr;
956 if ((buffer[0] == BOM_UTF16_LE[0]) && (buffer[1] == BOM_UTF16_LE[1]))
958 LPCWSTR uc = (LPCWSTR)(&buffer[2]);
959 const size_t charlen = size /
sizeof(WCHAR) - 1;
960 copy = ConvertWCharNToUtf8Alloc(uc, charlen, &size);
963 WLog_ERR(TAG,
"Failed to convert RDP file from UCS2 to UTF8");
969 copy = calloc(1, size +
sizeof(BYTE));
974 memcpy(copy, buffer, size);
977 char* context =
nullptr;
978 char* line = strtok_s(copy,
"\r\n", &context);
982 const size_t length = strnlen(line, size);
984 if (!parse_line(file, line, length, parse))
987 line = strtok_s(
nullptr,
"\r\n", &context);
990 rc = trim_strings(file);
996BOOL freerdp_client_parse_rdp_file(rdpFile* file,
const char* name)
998 return freerdp_client_parse_rdp_file_ex(file, name,
nullptr);
1001BOOL freerdp_client_parse_rdp_file_ex(rdpFile* file,
const char* name, rdp_file_fkt_parse parse)
1004 BYTE* buffer =
nullptr;
1006 size_t read_size = 0;
1007 INT64 file_size = 0;
1008 const char* fname = name;
1013 if (_strnicmp(fname,
"file://", 7) == 0)
1016 fp = winpr_fopen(fname,
"r");
1019 WLog_ERR(TAG,
"Failed to open RDP file %s", name);
1023 if (_fseeki64(fp, 0, SEEK_END) < 0)
1025 file_size = _ftelli64(fp);
1026 if (_fseeki64(fp, 0, SEEK_SET) < 0)
1031 WLog_ERR(TAG,
"RDP file %s is empty", name);
1035 buffer = (BYTE*)malloc((
size_t)file_size + 2);
1040 read_size = fread(buffer, (
size_t)file_size, 1, fp);
1045 read_size = (size_t)file_size;
1050 WLog_ERR(TAG,
"Could not read from RDP file %s", name);
1054 buffer[file_size] =
'\0';
1055 buffer[file_size + 1] =
'\0';
1056 status = freerdp_client_parse_rdp_file_buffer_ex(file, buffer, (
size_t)file_size, parse);
1064static inline void freerdp_client_file_string_reset(
char** target)
1066 WINPR_ASSERT(target);
1067 freerdp_client_file_string_check_free(*target);
1068 *target = (
char*)UINTPTR_MAX;
1071static inline BOOL FILE_POPULATE_STRING(
char** _target,
const rdpSettings* _settings,
1072 FreeRDP_Settings_Keys_String _option)
1074 WINPR_ASSERT(_target);
1075 WINPR_ASSERT(_settings);
1078 freerdp_client_file_string_reset(_target);
1081 char* copy = _strdup(str);
1089static char* freerdp_client_channel_args_to_string(
const rdpSettings* settings,
const char* channel,
1092 ADDIN_ARGV* args = freerdp_dynamic_channel_collection_find(settings, channel);
1093 const char* filters[] = { option };
1094 if (!args || (args->argc < 2))
1097 return CommandLineToCommaSeparatedValuesEx(args->argc - 1, args->argv + 1, filters,
1098 ARRAYSIZE(filters));
1101static BOOL rdp_opt_duplicate(
const rdpSettings* _settings, FreeRDP_Settings_Keys_String _id,
1104 WINPR_ASSERT(_settings);
1110 *_key = _strdup(tmp);
1118BOOL freerdp_client_populate_rdp_file_from_settings(rdpFile* file,
const rdpSettings* settings)
1120 FreeRDP_Settings_Keys_String index = FreeRDP_STRING_UNUSED;
1121 UINT32 LoadBalanceInfoLength = 0;
1122 const char* GatewayHostname =
nullptr;
1123 char* redirectCameras =
nullptr;
1125 if (!file || !settings)
1128 if (!FILE_POPULATE_STRING(&file->Domain, settings, FreeRDP_Domain) ||
1129 !FILE_POPULATE_STRING(&file->Username, settings, FreeRDP_Username) ||
1130 !FILE_POPULATE_STRING(&file->Password, settings, FreeRDP_Password) ||
1131 !FILE_POPULATE_STRING(&file->FullAddress, settings, FreeRDP_ServerHostname) ||
1132 !FILE_POPULATE_STRING(&file->AlternateFullAddress, settings, FreeRDP_ServerHostname) ||
1133 !FILE_POPULATE_STRING(&file->AlternateShell, settings, FreeRDP_AlternateShell) ||
1134 !FILE_POPULATE_STRING(&file->DrivesToRedirect, settings, FreeRDP_DrivesToRedirect))
1143 file->DynamicResolution = WINPR_ASSERTING_INT_CAST(
1145 file->VideoPlaybackMode = WINPR_ASSERTING_INT_CAST(
1152 file->ConnectToConsole = WINPR_ASSERTING_INT_CAST(
1154 file->NegotiateSecurityLayer = WINPR_ASSERTING_INT_CAST(
1156 file->EnableCredSSPSupport =
1158 file->EnableRdsAadAuth =
1162 index = FreeRDP_RemoteApplicationWorkingDir;
1164 index = FreeRDP_ShellWorkingDirectory;
1165 if (!FILE_POPULATE_STRING(&file->ShellWorkingDirectory, settings, index))
1172 if (LoadBalanceInfoLength > 0)
1174 const BYTE* LoadBalanceInfo =
1176 file->LoadBalanceInfo = calloc(LoadBalanceInfoLength + 1, 1);
1177 if (!file->LoadBalanceInfo)
1179 memcpy(file->LoadBalanceInfo, LoadBalanceInfo, LoadBalanceInfoLength);
1183 file->AudioMode = AUDIO_MODE_REDIRECT;
1185 file->AudioMode = AUDIO_MODE_PLAY_ON_SERVER;
1187 file->AudioMode = AUDIO_MODE_NONE;
1192 if (GatewayHostname)
1195 freerdp_client_file_string_check_free(file->GatewayHostname);
1196 if (GatewayPort == 443)
1197 file->GatewayHostname = _strdup(GatewayHostname);
1200 int length = _scprintf(
"%s:%" PRIu32, GatewayHostname, GatewayPort);
1204 file->GatewayHostname = (
char*)malloc((
size_t)length + 1);
1205 if (!file->GatewayHostname)
1208 if (sprintf_s(file->GatewayHostname, (
size_t)length + 1,
"%s:%" PRIu32, GatewayHostname,
1212 if (!file->GatewayHostname)
1217 file->ResourceProvider = _strdup(str_resourceprovider_arm);
1219 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdWvdEndpointPool, &file->WvdEndpointPool))
1221 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdGeo, &file->geo))
1223 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdArmpath, &file->armpath))
1225 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdAadtenantid, &file->aadtenantid))
1227 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdDiagnosticserviceurl,
1228 &file->diagnosticserviceurl))
1230 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdHubdiscoverygeourl,
1231 &file->hubdiscoverygeourl))
1233 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdActivityhint, &file->activityhint))
1236 file->AudioCaptureMode =
1238 file->BitmapCachePersistEnable = WINPR_ASSERTING_INT_CAST(
1240 file->Compression = WINPR_ASSERTING_INT_CAST(
1243 file->GatewayUsageMethod = freerdp_get_gateway_usage_method(settings);
1244 file->GatewayCredentialsSource =
1246 file->PromptCredentialOnce = WINPR_ASSERTING_INT_CAST(
1248 file->PromptForCredentials = WINPR_ASSERTING_INT_CAST(
1250 file->RemoteApplicationMode = WINPR_ASSERTING_INT_CAST(
1252 if (!FILE_POPULATE_STRING(&file->GatewayAccessToken, settings, FreeRDP_GatewayAccessToken) ||
1253 !FILE_POPULATE_STRING(&file->EndpointFedAuthToken, settings,
1254 FreeRDP_EndpointFedAuthToken) ||
1255 !FILE_POPULATE_STRING(&file->RemoteApplicationProgram, settings,
1256 FreeRDP_RemoteApplicationProgram) ||
1257 !FILE_POPULATE_STRING(&file->RemoteApplicationName, settings,
1258 FreeRDP_RemoteApplicationName) ||
1259 !FILE_POPULATE_STRING(&file->RemoteApplicationIcon, settings,
1260 FreeRDP_RemoteApplicationIcon) ||
1261 !FILE_POPULATE_STRING(&file->RemoteApplicationFile, settings,
1262 FreeRDP_RemoteApplicationFile) ||
1263 !FILE_POPULATE_STRING(&file->RemoteApplicationGuid, settings,
1264 FreeRDP_RemoteApplicationGuid) ||
1265 !FILE_POPULATE_STRING(&file->RemoteApplicationCmdLine, settings,
1266 FreeRDP_RemoteApplicationCmdLine))
1268 file->SpanMonitors =
1272 file->AllowDesktopComposition = WINPR_ASSERTING_INT_CAST(
1274 file->AllowFontSmoothing = WINPR_ASSERTING_INT_CAST(
1276 file->DisableWallpaper = WINPR_ASSERTING_INT_CAST(
1278 file->DisableFullWindowDrag = WINPR_ASSERTING_INT_CAST(
1280 file->DisableMenuAnims = WINPR_ASSERTING_INT_CAST(
1282 file->DisableThemes = WINPR_ASSERTING_INT_CAST(
1285 CONNECTION_TYPE_AUTODETECT);
1286 file->NetworkAutoDetect =
1288 file->AutoReconnectionEnabled = WINPR_ASSERTING_INT_CAST(
1290 file->RedirectSmartCards = WINPR_ASSERTING_INT_CAST(
1292 file->RedirectWebauthN = WINPR_ASSERTING_INT_CAST(
1296 freerdp_client_channel_args_to_string(settings, RDPECAM_DVC_CHANNEL_NAME,
"device:");
1297 if (redirectCameras)
1300 freerdp_client_channel_args_to_string(settings, RDPECAM_DVC_CHANNEL_NAME,
"encode:");
1301 file->EncodeRedirectedVideoCapture = 0;
1304 unsigned long val = 0;
1306 val = strtoul(str,
nullptr, 0);
1307 if ((val < UINT32_MAX) && (errno == 0))
1308 file->EncodeRedirectedVideoCapture = (UINT32)val;
1312 str = freerdp_client_channel_args_to_string(settings, RDPECAM_DVC_CHANNEL_NAME,
"quality:");
1313 file->RedirectedVideoCaptureEncodingQuality = 0;
1316 unsigned long val = 0;
1318 val = strtoul(str,
nullptr, 0);
1319 if ((val <= 2) && (errno == 0))
1321 file->RedirectedVideoCaptureEncodingQuality = (UINT32)val;
1326 file->RedirectCameras = redirectCameras;
1329 freerdp_client_file_string_reset(&file->RedirectCameras);
1331#ifdef CHANNEL_URBDRC_CLIENT
1333 freerdp_client_channel_args_to_string(settings, URBDRC_CHANNEL_NAME,
"device:");
1335 file->UsbDevicesToRedirect = redirectUsb;
1337 freerdp_client_file_string_reset(&file->UsbDevicesToRedirect);
1340 file->RedirectClipboard =
1347 file->RedirectLocation =
1349 if (!FILE_POPULATE_STRING(&file->DrivesToRedirect, settings, FreeRDP_DrivesToRedirect) ||
1350 !FILE_POPULATE_STRING(&file->PreconnectionBlob, settings, FreeRDP_PreconnectionBlob) ||
1351 !FILE_POPULATE_STRING(&file->KdcProxyName, settings, FreeRDP_KerberosKdcUrl))
1359 size_t size = count * (10 + 1) + 1;
1361 char* str = calloc(size,
sizeof(
char));
1362 for (UINT32 x = 0; x < count; x++)
1364 int rc = _snprintf(&str[offset], size - offset,
"%" PRIu32
",", MonitorIds[x]);
1370 offset += (size_t)rc;
1373 str[offset - 1] =
'\0';
1374 freerdp_client_file_string_check_free(file->SelectedMonitors);
1375 file->SelectedMonitors = str;
1383BOOL freerdp_client_write_rdp_file(
const rdpFile* file,
const char* name, BOOL unicode)
1386 WCHAR* unicodestr =
nullptr;
1391 const size_t size = freerdp_client_write_rdp_file_buffer(file,
nullptr, 0);
1394 char* buffer = calloc(size + 1ULL,
sizeof(
char));
1398 if (freerdp_client_write_rdp_file_buffer(file, buffer, size + 1) != size)
1400 WLog_ERR(TAG,
"freerdp_client_write_rdp_file: error writing to output buffer");
1405 FILE* fp = winpr_fopen(name,
"w+b");
1412 unicodestr = ConvertUtf8NToWCharAlloc(buffer, size, &len);
1422 if ((fwrite(BOM_UTF16_LE,
sizeof(BYTE), 2, fp) != 2) ||
1423 (fwrite(unicodestr,
sizeof(WCHAR), len, fp) != len))
1435 if (fwrite(buffer, 1, size, fp) != size)
1444 status = fclose(fp);
1448 return (status == 0);
1451WINPR_ATTR_FORMAT_ARG(3, 4)
1452static SSIZE_T freerdp_client_write_setting_to_buffer(
char** buffer,
size_t* bufferSize,
1453 WINPR_FORMAT_ARG const
char* fmt, ...)
1455 va_list ap = WINPR_C_ARRAY_INIT;
1457 char* buf =
nullptr;
1460 if (!buffer || !bufferSize || !fmt)
1464 bufSize = *bufferSize;
1467 len = vsnprintf(buf, bufSize, fmt, ap);
1476 if (!buf && !bufSize)
1483 if (bufSize >= (
size_t)len)
1485 *bufferSize -= (size_t)len;
1486 buf[len - 1] =
'\n';
1487 *buffer = buf + len;
1495static SSIZE_T write_int_parameters(
const rdpFile* file,
char* buffer,
size_t size)
1504 const struct intentry_t settings[] = {
1505 { key_int_use_multimon, file->UseMultiMon },
1506 { key_int_maximizetocurrentdisplays, file->MaximizeToCurrentDisplays },
1507 { key_int_singlemoninwindowedmode, file->SingleMonInWindowedMode },
1508 { key_int_screen_mode_id, file->ScreenModeId },
1509 { key_int_span_monitors, file->SpanMonitors },
1510 { key_int_smart_sizing, file->SmartSizing },
1511 { key_int_dynamic_resolution, file->DynamicResolution },
1512 { key_int_enablesuperpan, file->EnableSuperSpan },
1513 { key_int_superpanaccelerationfactor, file->SuperSpanAccelerationFactor },
1514 { key_int_desktopwidth, file->DesktopWidth },
1515 { key_int_desktopheight, file->DesktopHeight },
1516 { key_int_desktop_size_id, file->DesktopSizeId },
1517 { key_int_session_bpp, file->SessionBpp },
1518 { key_int_desktopscalefactor, file->DesktopScaleFactor },
1519 { key_int_compression, file->Compression },
1520 { key_int_keyboardhook, file->KeyboardHook },
1521 { key_int_disable_ctrl_alt_del, file->DisableCtrlAltDel },
1522 { key_int_audiomode, file->AudioMode },
1523 { key_int_audioqualitymode, file->AudioQualityMode },
1524 { key_int_audiocapturemode, file->AudioCaptureMode },
1525 { key_int_encode_redirected_video_capture, file->EncodeRedirectedVideoCapture },
1526 { key_int_redirected_video_capture_encoding_quality,
1527 file->RedirectedVideoCaptureEncodingQuality },
1528 { key_int_videoplaybackmode, file->VideoPlaybackMode },
1529 { key_int_connection_type, file->ConnectionType },
1530 { key_int_networkautodetect, file->NetworkAutoDetect },
1531 { key_int_bandwidthautodetect, file->BandwidthAutoDetect },
1532 { key_int_pinconnectionbar, file->PinConnectionBar },
1533 { key_int_displayconnectionbar, file->DisplayConnectionBar },
1534 { key_int_workspaceid, file->WorkspaceId },
1535 { key_int_enableworkspacereconnect, file->EnableWorkspaceReconnect },
1536 { key_int_disable_wallpaper, file->DisableWallpaper },
1537 { key_int_allow_font_smoothing, file->AllowFontSmoothing },
1538 { key_int_allow_desktop_composition, file->AllowDesktopComposition },
1539 { key_int_disable_full_window_drag, file->DisableFullWindowDrag },
1540 { key_int_disable_menu_anims, file->DisableMenuAnims },
1541 { key_int_disable_themes, file->DisableThemes },
1542 { key_int_disable_cursor_setting, file->DisableCursorSetting },
1543 { key_int_bitmapcachesize, file->BitmapCacheSize },
1544 { key_int_bitmapcachepersistenable, file->BitmapCachePersistEnable },
1545 { key_int_server_port, file->ServerPort },
1546 { key_int_redirectdrives, file->RedirectDrives },
1547 { key_int_redirectprinters, file->RedirectPrinters },
1548 { key_int_redirectcomports, file->RedirectComPorts },
1549 { key_int_redirectlocation, file->RedirectLocation },
1550 { key_int_redirectsmartcards, file->RedirectSmartCards },
1551 { key_int_redirectclipboard, file->RedirectClipboard },
1552 { key_int_redirectposdevices, file->RedirectPosDevices },
1553 { key_int_redirectdirectx, file->RedirectDirectX },
1554 { key_int_disableprinterredirection, file->DisablePrinterRedirection },
1555 { key_int_disableclipboardredirection, file->DisableClipboardRedirection },
1556 { key_int_connect_to_console, file->ConnectToConsole },
1557 { key_int_administrative_session, file->AdministrativeSession },
1558 { key_int_autoreconnection_enabled, file->AutoReconnectionEnabled },
1559 { key_int_autoreconnect_max_retries, file->AutoReconnectMaxRetries },
1560 { key_int_public_mode, file->PublicMode },
1561 { key_int_authentication_level, file->AuthenticationLevel },
1562 { key_int_promptcredentialonce, file->PromptCredentialOnce },
1563 { key_int_prompt_for_credentials, file->PromptForCredentials },
1564 { key_int_negotiate_security_layer, file->NegotiateSecurityLayer },
1565 { key_int_enablecredsspsupport, file->EnableCredSSPSupport },
1566 { key_int_enablerdsaadauth, file->EnableRdsAadAuth },
1567 { key_int_remoteapplicationmode, file->RemoteApplicationMode },
1568 { key_int_remoteapplicationexpandcmdline, file->RemoteApplicationExpandCmdLine },
1569 { key_int_remoteapplicationexpandworkingdir, file->RemoteApplicationExpandWorkingDir },
1570 { key_int_disableconnectionsharing, file->DisableConnectionSharing },
1571 { key_int_disableremoteappcapscheck, file->DisableRemoteAppCapsCheck },
1572 { key_int_gatewayusagemethod, file->GatewayUsageMethod },
1573 { key_int_gatewayprofileusagemethod, file->GatewayProfileUsageMethod },
1574 { key_int_gatewaycredentialssource, file->GatewayCredentialsSource },
1575 { key_int_use_redirection_server_name, file->UseRedirectionServerName },
1576 { key_int_rdgiskdcproxy, file->RdgIsKdcProxy },
1577 { key_int_redirectwebauthn, file->RedirectWebauthN }
1580 SSIZE_T totalSize = 0;
1581 for (
size_t x = 0; x < ARRAYSIZE(settings); x++)
1583 const struct intentry_t* cur = &settings[x];
1586 const SSIZE_T res = freerdp_client_write_setting_to_buffer(
1587 &buffer, &size,
"%s:i:%" PRIu32, cur->key, cur->val);
1597static SSIZE_T write_string_parameters(
const rdpFile* file,
char* buffer,
size_t size)
1606 const struct strentry_t settings[] = {
1607 { key_str_username, file->Username },
1608 { key_str_domain, file->Domain },
1609 { key_str_password, file->Password },
1610 { key_str_full_address, file->FullAddress },
1611 { key_str_alternate_full_address, file->AlternateFullAddress },
1612 { key_str_usbdevicestoredirect, file->UsbDevicesToRedirect },
1613 { key_str_camerastoredirect, file->RedirectCameras },
1614 { key_str_loadbalanceinfo, file->LoadBalanceInfo },
1615 { key_str_remoteapplicationname, file->RemoteApplicationName },
1616 { key_str_remoteapplicationicon, file->RemoteApplicationIcon },
1617 { key_str_remoteapplicationprogram, file->RemoteApplicationProgram },
1618 { key_str_remoteapplicationfile, file->RemoteApplicationFile },
1619 { key_str_remoteapplicationguid, file->RemoteApplicationGuid },
1620 { key_str_remoteapplicationcmdline, file->RemoteApplicationCmdLine },
1621 { key_str_alternate_shell, file->AlternateShell },
1622 { key_str_shell_working_directory, file->ShellWorkingDirectory },
1623 { key_str_gatewayhostname, file->GatewayHostname },
1624 { key_str_resourceprovider, file->ResourceProvider },
1625 { key_str_wvd, file->WvdEndpointPool },
1626 { key_str_geo, file->geo },
1627 { key_str_armpath, file->armpath },
1628 { key_str_aadtenantid, file->aadtenantid },
1629 { key_str_diagnosticserviceurl, file->diagnosticserviceurl },
1630 { key_str_hubdiscoverygeourl, file->hubdiscoverygeourl },
1631 { key_str_activityhint, file->activityhint },
1632 { key_str_gatewayaccesstoken, file->GatewayAccessToken },
1633 { key_str_endpointfedauth, file->EndpointFedAuthToken },
1634 { key_str_kdcproxyname, file->KdcProxyName },
1635 { key_str_drivestoredirect, file->DrivesToRedirect },
1636 { key_str_devicestoredirect, file->DevicesToRedirect },
1637 { key_str_winposstr, file->WinPosStr },
1638 { key_str_pcb, file->PreconnectionBlob },
1639 { key_str_selectedmonitors, file->SelectedMonitors }
1642 SSIZE_T totalSize = 0;
1643 for (
size_t x = 0; x < ARRAYSIZE(settings); x++)
1645 const struct strentry_t* cur = &settings[x];
1646 if (~(
size_t)(cur->val))
1648 const SSIZE_T res = freerdp_client_write_setting_to_buffer(&buffer, &size,
"%s:s:%s",
1649 cur->key, cur->val);
1659static SSIZE_T write_custom_parameters(
const rdpFile* file,
char* buffer,
size_t size)
1663 SSIZE_T totalSize = 0;
1665 for (
size_t i = 0; i < file->lineCount; ++i)
1668 const rdpFileLine* curLine = &file->lines[i];
1670 if (curLine->flags & RDP_FILE_LINE_FLAG_TYPE_INTEGER)
1671 res = freerdp_client_write_setting_to_buffer(&buffer, &size,
"%s:i:%" PRIu32,
1672 curLine->name, (UINT32)curLine->iValue);
1673 else if (curLine->flags & RDP_FILE_LINE_FLAG_TYPE_STRING)
1674 res = freerdp_client_write_setting_to_buffer(&buffer, &size,
"%s:s:%s", curLine->name,
1684size_t freerdp_client_write_rdp_file_buffer(
const rdpFile* file,
char* buffer,
size_t size)
1686 size_t totalSize = 0;
1692 if ((!buffer || !size) && (buffer || size))
1696 const SSIZE_T intsize = write_int_parameters(file, buffer, size);
1699 totalSize += (size_t)intsize;
1704 const SSIZE_T stringsize = write_string_parameters(file, buffer, size);
1707 totalSize += (size_t)stringsize;
1709 buffer += stringsize;
1712 const SSIZE_T customsize = write_custom_parameters(file, buffer, size);
1715 totalSize += (size_t)customsize;
1719static ADDIN_ARGV* rdp_file_to_args(
const char* channel,
const char* values)
1723 ADDIN_ARGV* args = freerdp_addin_argv_new(0,
nullptr);
1726 if (!freerdp_addin_argv_add_argument(args, channel))
1729 p = CommandLineParseCommaSeparatedValues(values, &count);
1730 for (
size_t x = 0; x < count; x++)
1733 const char* val = p[x];
1734 const size_t len = strlen(val) + 8;
1735 char* str = calloc(len,
sizeof(
char));
1739 (void)_snprintf(str, len,
"device:%s", val);
1740 rc = freerdp_addin_argv_add_argument(args, str);
1745 CommandLineParserFree(p);
1749 CommandLineParserFree(p);
1750 freerdp_addin_argv_free(args);
1754BOOL freerdp_client_populate_settings_from_rdp_file_unchecked(
const rdpFile* file,
1755 rdpSettings* settings)
1757 if (!file || !settings)
1763 if (~file->BandwidthAutoDetect)
1765 if (file->BandwidthAutoDetect != 0)
1767 if ((~file->NetworkAutoDetect) && (file->NetworkAutoDetect == 0))
1770 "Got networkautodetect:i:%" PRIu32
" and bandwidthautodetect:i:%" PRIu32
1771 ". Correcting to networkautodetect:i:1",
1772 file->NetworkAutoDetect, file->BandwidthAutoDetect);
1774 "Add networkautodetect:i:1 to your RDP file to eliminate this warning.");
1778 (file->BandwidthAutoDetect != 0) ||
1779 (file->NetworkAutoDetect != 0)))
1783 if (~file->NetworkAutoDetect)
1785 if (file->NetworkAutoDetect != 0)
1787 if ((~file->BandwidthAutoDetect) && (file->BandwidthAutoDetect == 0))
1790 "Got networkautodetect:i:%" PRIu32
" and bandwidthautodetect:i:%" PRIu32
1791 ". Correcting to bandwidthautodetect:i:1",
1792 file->NetworkAutoDetect, file->BandwidthAutoDetect);
1794 TAG,
"Add bandwidthautodetect:i:1 to your RDP file to eliminate this warning.");
1798 (file->BandwidthAutoDetect != 0) ||
1799 (file->NetworkAutoDetect != 0)))
1803 if (~((
size_t)file->Domain))
1809 if (~((
size_t)file->Username))
1811 char* user =
nullptr;
1812 char* domain =
nullptr;
1814 if (!freerdp_parse_username(file->Username, &user, &domain))
1820 if (!(~((
size_t)file->Domain)) && domain)
1830 if (~((
size_t)file->Password))
1837 const char* address =
nullptr;
1841 if (~((
size_t)file->AlternateFullAddress))
1842 address = file->AlternateFullAddress;
1843 else if (~((
size_t)file->FullAddress))
1844 address = file->FullAddress;
1849 char* host =
nullptr;
1851 if (!freerdp_parse_hostname(address, &host, &port))
1867 if (~file->ServerPort)
1873 if (~file->DesktopSizeId)
1875 switch (file->DesktopSizeId)
1908 WLog_WARN(TAG,
"Unsupported 'desktop size id' value %" PRIu32, file->DesktopSizeId);
1913 if (~file->DesktopWidth)
1919 if (~file->DesktopHeight)
1925 if (~file->SessionBpp)
1931 if (~file->ConnectToConsole)
1934 file->ConnectToConsole != 0))
1938 if (~file->AdministrativeSession)
1941 file->AdministrativeSession != 0))
1945 if (~file->NegotiateSecurityLayer)
1948 file->NegotiateSecurityLayer != 0))
1952 if (~file->EnableCredSSPSupport)
1955 file->EnableCredSSPSupport != 0))
1959 if (~file->EnableRdsAadAuth)
1961 const BOOL val = file->EnableRdsAadAuth != 0;
1966 if (~((
size_t)file->AlternateShell))
1972 if (~((
size_t)file->ShellWorkingDirectory))
1975 FreeRDP_Settings_Keys_String targetId =
1976 (~file->RemoteApplicationMode && file->RemoteApplicationMode != 0)
1977 ? FreeRDP_RemoteApplicationWorkingDir
1978 : FreeRDP_ShellWorkingDirectory;
1984 if (~file->ScreenModeId)
2002 if (~(file->SmartSizing))
2015 if (((~(file->DesktopWidth) && ~(file->DesktopHeight)) || ~(file->DesktopSizeId)) &&
2016 (file->SmartSizing == 1))
2019 file->DesktopWidth))
2022 file->DesktopHeight))
2027 if (~((
size_t)file->LoadBalanceInfo))
2029 const size_t len = strlen(file->LoadBalanceInfo);
2031 file->LoadBalanceInfo, len))
2035 if (~file->AuthenticationLevel)
2052 file->AuthenticationLevel))
2056 if (~file->ConnectionType)
2062 if (~file->AudioMode)
2064 switch (file->AudioMode)
2066 case AUDIO_MODE_REDIRECT:
2072 case AUDIO_MODE_PLAY_ON_SERVER:
2078 case AUDIO_MODE_NONE:
2088 if (~file->AudioCaptureMode)
2094 if (~file->Compression)
2097 file->Compression != 0))
2101 if (~((
size_t)file->GatewayHostname))
2104 char* host =
nullptr;
2106 if (!freerdp_parse_hostname(file->GatewayHostname, &host, &port))
2121 if (~((
size_t)file->ResourceProvider))
2123 if (_stricmp(file->ResourceProvider, str_resourceprovider_arm) == 0)
2130 if (~((
size_t)file->WvdEndpointPool))
2133 file->WvdEndpointPool))
2137 if (~((
size_t)file->geo))
2143 if (~((
size_t)file->armpath))
2149 if (~((
size_t)file->aadtenantid))
2156 if (~((
size_t)file->diagnosticserviceurl))
2159 file->diagnosticserviceurl))
2163 if (~((
size_t)file->hubdiscoverygeourl))
2166 file->hubdiscoverygeourl))
2170 if (~((
size_t)file->activityhint))
2173 file->activityhint))
2177 if (~((
size_t)file->GatewayAccessToken))
2180 file->GatewayAccessToken))
2184 if (~((
size_t)file->EndpointFedAuthToken))
2187 file->EndpointFedAuthToken))
2191 if (~file->GatewayUsageMethod)
2197 if (~file->PromptCredentialOnce)
2200 file->PromptCredentialOnce != 0))
2204 if (~file->PromptForCredentials)
2207 file->PromptForCredentials != 0))
2211 if (~file->RemoteApplicationMode)
2214 file->RemoteApplicationMode != 0))
2218 if (~((
size_t)file->RemoteApplicationProgram))
2221 file->RemoteApplicationProgram))
2225 if (~((
size_t)file->RemoteApplicationName))
2228 file->RemoteApplicationName))
2232 if (~((
size_t)file->RemoteApplicationIcon))
2235 file->RemoteApplicationIcon))
2239 if (~((
size_t)file->RemoteApplicationFile))
2242 file->RemoteApplicationFile))
2246 if (~((
size_t)file->RemoteApplicationGuid))
2249 file->RemoteApplicationGuid))
2253 if (~((
size_t)file->RemoteApplicationCmdLine))
2256 file->RemoteApplicationCmdLine))
2260 if (~file->SpanMonitors)
2266 if (~file->UseMultiMon)
2272 if (~file->AllowFontSmoothing)
2275 file->AllowFontSmoothing != 0))
2279 if (~file->DisableWallpaper)
2282 file->DisableWallpaper != 0))
2286 if (~file->DisableFullWindowDrag)
2289 file->DisableFullWindowDrag != 0))
2293 if (~file->DisableMenuAnims)
2296 file->DisableMenuAnims != 0))
2300 if (~file->DisableThemes)
2306 if (~file->AllowDesktopComposition)
2309 file->AllowDesktopComposition != 0))
2313 if (~file->BitmapCachePersistEnable)
2316 file->BitmapCachePersistEnable != 0))
2320 if (~file->DisableRemoteAppCapsCheck)
2323 file->DisableRemoteAppCapsCheck != 0))
2327 if (~file->AutoReconnectionEnabled)
2330 file->AutoReconnectionEnabled != 0))
2334 if (~file->AutoReconnectMaxRetries)
2337 file->AutoReconnectMaxRetries))
2341 if (~file->RedirectSmartCards)
2344 file->RedirectSmartCards != 0))
2348 if (~file->RedirectWebauthN)
2351 file->RedirectWebauthN != 0))
2355 if (~file->RedirectClipboard)
2358 file->RedirectClipboard != 0))
2362 if (~file->RedirectPrinters)
2365 file->RedirectPrinters != 0))
2369 if (~file->RedirectDrives)
2375 if (~file->RedirectPosDevices)
2378 file->RedirectComPorts != 0) ||
2380 file->RedirectComPorts != 0))
2384 if (~file->RedirectComPorts)
2387 file->RedirectComPorts != 0) ||
2389 file->RedirectComPorts != 0))
2393 if (~file->RedirectLocation && (file->RedirectLocation != 0))
2399 freerdp_client_add_dynamic_channel(settings, count, (
const char*
const*)ptr);
2400 CommandLineParserFree(ptr);
2405 if (~file->RedirectDirectX)
2410 if ((~((
size_t)file->DevicesToRedirect)) && !utils_str_is_empty(file->DevicesToRedirect))
2440 if ((~((
size_t)file->DrivesToRedirect)) && !utils_str_is_empty(file->DrivesToRedirect))
2443 file->DrivesToRedirect))
2447 if ((~((
size_t)file->RedirectCameras)) && !utils_str_is_empty(file->RedirectCameras))
2449#if defined(CHANNEL_RDPECAM_CLIENT)
2453 const char*
const* cc;
2455 ADDIN_ARGV* args = rdp_file_to_args(RDPECAM_DVC_CHANNEL_NAME, file->RedirectCameras);
2460 if (~file->EncodeRedirectedVideoCapture)
2462 char encode[64] = WINPR_C_ARRAY_INIT;
2463 (void)_snprintf(encode,
sizeof(encode),
"encode:%" PRIu32,
2464 file->EncodeRedirectedVideoCapture);
2465 if (!freerdp_addin_argv_add_argument(args, encode))
2468 if (~file->RedirectedVideoCaptureEncodingQuality)
2470 char quality[64] = WINPR_C_ARRAY_INIT;
2471 (void)_snprintf(quality,
sizeof(quality),
"quality:%" PRIu32,
2472 file->RedirectedVideoCaptureEncodingQuality);
2473 if (!freerdp_addin_argv_add_argument(args, quality))
2479 status = freerdp_client_add_dynamic_channel(
2480 settings, WINPR_ASSERTING_INT_CAST(
size_t, args->argc), cnv.cc);
2481 freerdp_addin_argv_free(args);
2487 "This build does not support [MS-RDPECAM] camera redirection channel. Ignoring '%s'",
2488 key_str_camerastoredirect);
2492 if ((~((
size_t)file->UsbDevicesToRedirect)) && !utils_str_is_empty(file->UsbDevicesToRedirect))
2494#ifdef CHANNEL_URBDRC_CLIENT
2498 const char*
const* cc;
2500 ADDIN_ARGV* args = rdp_file_to_args(URBDRC_CHANNEL_NAME, file->UsbDevicesToRedirect);
2504 const BOOL status = freerdp_client_add_dynamic_channel(
2505 settings, WINPR_ASSERTING_INT_CAST(
size_t, args->argc), cnv.cc);
2506 freerdp_addin_argv_free(args);
2511 "This build does not support [MS-RDPEUSB] usb redirection channel. Ignoring '%s'",
2512 key_str_usbdevicestoredirect);
2516 if (~file->KeyboardHook)
2522 if (~(
size_t)file->SelectedMonitors)
2525 char** ptr = CommandLineParseCommaSeparatedValues(file->SelectedMonitors, &count);
2526 UINT32* list =
nullptr;
2530 CommandLineParserFree(ptr);
2534 if (!list && (count > 0))
2536 CommandLineParserFree(ptr);
2539 for (
size_t x = 0; x < count; x++)
2541 unsigned long val = 0;
2543 val = strtoul(ptr[x],
nullptr, 0);
2544 if ((val >= UINT32_MAX) && (errno != 0))
2546 CommandLineParserFree(ptr);
2549 list[x] = (UINT32)val;
2551 CommandLineParserFree(ptr);
2554 if (~file->DynamicResolution)
2556 const BOOL val = file->DynamicResolution != 0;
2563 if (~file->DesktopScaleFactor)
2566 file->DesktopScaleFactor))
2570 if (~file->VideoPlaybackMode)
2572 if (file->VideoPlaybackMode != 0)
2589 if (~((
size_t)file->PreconnectionBlob))
2592 file->PreconnectionBlob) ||
2597 if (~((
size_t)file->KdcProxyName))
2603 if (~file->RdgIsKdcProxy)
2606 file->RdgIsKdcProxy != 0))
2610 if (file->args->argc > 1)
2612 WCHAR* ConnectionFile =
2615 if (freerdp_client_settings_parse_command_line(settings, file->args->argc, file->args->argv,
2618 free(ConnectionFile);
2624 free(ConnectionFile);
2632static BOOL freerdp_apply_connection_type_from_file(
const rdpFile* file, rdpSettings* settings,
2635 struct network_settings
2637 FreeRDP_Settings_Keys_Bool id;
2643 const struct network_settings config[] = { { FreeRDP_DisableWallpaper,
2644 (~file->DisableWallpaper) == 0,
2645 { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
2646 { FreeRDP_AllowFontSmoothing,
2647 (~file->AllowFontSmoothing) == 0,
2648 { FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE } },
2649 { FreeRDP_AllowDesktopComposition,
2650 (~file->AllowDesktopComposition) == 0,
2651 { FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE } },
2652 { FreeRDP_DisableFullWindowDrag,
2653 (~file->DisableFullWindowDrag) == 0,
2654 { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
2655 { FreeRDP_DisableMenuAnims,
2656 (~file->DisableMenuAnims) == 0,
2657 { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
2658 { FreeRDP_DisableThemes,
2659 (~file->DisableThemes) == 0,
2660 { TRUE, FALSE, FALSE, FALSE, FALSE, FALSE,
2665 case CONNECTION_TYPE_INVALID:
2668 case CONNECTION_TYPE_MODEM:
2669 case CONNECTION_TYPE_BROADBAND_LOW:
2670 case CONNECTION_TYPE_BROADBAND_HIGH:
2671 case CONNECTION_TYPE_SATELLITE:
2672 case CONNECTION_TYPE_WAN:
2673 case CONNECTION_TYPE_LAN:
2674 case CONNECTION_TYPE_AUTODETECT:
2677 WLog_WARN(TAG,
"Unknown ConnectionType %" PRIu32
", aborting", type);
2681 for (
size_t x = 0; x < ARRAYSIZE(config); x++)
2683 const struct network_settings* cur = &config[x];
2693static BOOL freerdp_set_connection_type_from_file(
const rdpFile* file, rdpSettings* settings,
2702 case CONNECTION_TYPE_INVALID:
2703 case CONNECTION_TYPE_MODEM:
2704 case CONNECTION_TYPE_BROADBAND_LOW:
2705 case CONNECTION_TYPE_SATELLITE:
2706 case CONNECTION_TYPE_BROADBAND_HIGH:
2707 case CONNECTION_TYPE_WAN:
2708 case CONNECTION_TYPE_LAN:
2709 if (!freerdp_apply_connection_type_from_file(file, settings, type))
2712 case CONNECTION_TYPE_AUTODETECT:
2713 if (!freerdp_apply_connection_type_from_file(file, settings, type))
2727 WLog_WARN(TAG,
"Unknown ConnectionType %" PRIu32
", aborting", type);
2734BOOL freerdp_client_populate_settings_from_rdp_file(
const rdpFile* file, rdpSettings* settings)
2736 if (!freerdp_client_populate_settings_from_rdp_file_unchecked(file, settings))
2740 if ((~file->ConnectionType) == 0)
2743 type = CONNECTION_TYPE_AUTODETECT;
2745 return freerdp_set_connection_type_from_file(file, settings, type);
2748static rdpFileLine* freerdp_client_rdp_file_find_line_by_name(
const rdpFile* file,
const char* name)
2750 BOOL bFound = FALSE;
2751 rdpFileLine* line =
nullptr;
2753 for (
size_t index = 0; index < file->lineCount; index++)
2755 line = &(file->lines[index]);
2757 if (line->flags & RDP_FILE_LINE_FLAG_FORMATTED)
2759 if (_stricmp(name, line->name) == 0)
2767 return (bFound) ? line :
nullptr;
2776int freerdp_client_rdp_file_set_string_option(rdpFile* file,
const char* name,
const char* value)
2778 return freerdp_client_rdp_file_set_string(file, name, value);
2781const char* freerdp_client_rdp_file_get_string_option(
const rdpFile* file,
const char* name)
2783 LPSTR* value =
nullptr;
2784 rdpFileLine* line =
nullptr;
2786 rdpFile* wfile = WINPR_CAST_CONST_PTR_AWAY(file, rdpFile*);
2787 if (freerdp_client_rdp_file_find_string_entry(wfile, name, &value, &line))
2789 if (value && ~(
size_t)(*value))
2792 return line->sValue;
2798int freerdp_client_rdp_file_set_integer_option(rdpFile* file,
const char* name,
int value)
2800 return freerdp_client_rdp_file_set_integer(file, name, value);
2803int freerdp_client_rdp_file_get_integer_option(
const rdpFile* file,
const char* name)
2805 DWORD* value =
nullptr;
2806 rdpFileLine* line =
nullptr;
2808 rdpFile* wfile = WINPR_CAST_CONST_PTR_AWAY(file, rdpFile*);
2809 if (freerdp_client_rdp_file_find_integer_entry(wfile, name, &value, &line))
2811 if (value && ~(*value))
2812 return WINPR_ASSERTING_INT_CAST(
int, *value);
2814 return (
int)line->iValue;
2820static void freerdp_client_file_string_check_free(LPSTR str)
2826rdpFile* freerdp_client_rdp_file_new(
void)
2828 return freerdp_client_rdp_file_new_ex(0);
2831rdpFile* freerdp_client_rdp_file_new_ex(DWORD flags)
2833 rdpFile* file = (rdpFile*)calloc(1,
sizeof(rdpFile));
2838 file->flags = flags;
2840 FillMemory(file,
sizeof(rdpFile), 0xFF);
2841 file->lines =
nullptr;
2842 file->lineCount = 0;
2843 file->lineSize = 32;
2844 file->GatewayProfileUsageMethod = 1;
2845 file->lines = (rdpFileLine*)calloc(file->lineSize,
sizeof(rdpFileLine));
2847 file->args = freerdp_addin_argv_new(0,
nullptr);
2848 if (!file->lines || !file->args)
2851 if (!freerdp_client_add_option(file,
"freerdp"))
2856 WINPR_PRAGMA_DIAG_PUSH
2857 WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
2858 freerdp_client_rdp_file_free(file);
2859 WINPR_PRAGMA_DIAG_POP
2862void freerdp_client_rdp_file_free(rdpFile* file)
2866 if (file->lineCount)
2868 for (
size_t i = 0; i < file->lineCount; i++)
2870 free(file->lines[i].name);
2871 free(file->lines[i].sValue);
2876 freerdp_addin_argv_free(file->args);
2878 freerdp_client_file_string_check_free(file->Username);
2879 freerdp_client_file_string_check_free(file->Domain);
2880 freerdp_client_file_string_check_free(file->Password);
2881 freerdp_client_file_string_check_free(file->FullAddress);
2882 freerdp_client_file_string_check_free(file->AlternateFullAddress);
2883 freerdp_client_file_string_check_free(file->UsbDevicesToRedirect);
2884 freerdp_client_file_string_check_free(file->RedirectCameras);
2885 freerdp_client_file_string_check_free(file->SelectedMonitors);
2886 freerdp_client_file_string_check_free(file->LoadBalanceInfo);
2887 freerdp_client_file_string_check_free(file->RemoteApplicationName);
2888 freerdp_client_file_string_check_free(file->RemoteApplicationIcon);
2889 freerdp_client_file_string_check_free(file->RemoteApplicationProgram);
2890 freerdp_client_file_string_check_free(file->RemoteApplicationFile);
2891 freerdp_client_file_string_check_free(file->RemoteApplicationGuid);
2892 freerdp_client_file_string_check_free(file->RemoteApplicationCmdLine);
2893 freerdp_client_file_string_check_free(file->AlternateShell);
2894 freerdp_client_file_string_check_free(file->ShellWorkingDirectory);
2895 freerdp_client_file_string_check_free(file->GatewayHostname);
2896 freerdp_client_file_string_check_free(file->GatewayAccessToken);
2897 freerdp_client_file_string_check_free(file->KdcProxyName);
2898 freerdp_client_file_string_check_free(file->DrivesToRedirect);
2899 freerdp_client_file_string_check_free(file->DevicesToRedirect);
2900 freerdp_client_file_string_check_free(file->WinPosStr);
2901 freerdp_client_file_string_check_free(file->ResourceProvider);
2902 freerdp_client_file_string_check_free(file->WvdEndpointPool);
2903 freerdp_client_file_string_check_free(file->geo);
2904 freerdp_client_file_string_check_free(file->armpath);
2905 freerdp_client_file_string_check_free(file->aadtenantid);
2906 freerdp_client_file_string_check_free(file->diagnosticserviceurl);
2907 freerdp_client_file_string_check_free(file->hubdiscoverygeourl);
2908 freerdp_client_file_string_check_free(file->activityhint);
2913void freerdp_client_rdp_file_set_callback_context(rdpFile* file,
void* context)
2915 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.