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 DrivesToRedirect;
211 LPSTR DevicesToRedirect;
214 LPSTR PreconnectionBlob;
231static const char key_str_username[] =
"username";
232static const char key_str_domain[] =
"domain";
233static const char key_str_password[] =
"password";
234static const char key_str_full_address[] =
"full address";
235static const char key_str_alternate_full_address[] =
"alternate full address";
236static const char key_str_usbdevicestoredirect[] =
"usbdevicestoredirect";
237static const char key_str_camerastoredirect[] =
"camerastoredirect";
238static const char key_str_loadbalanceinfo[] =
"loadbalanceinfo";
239static const char key_str_remoteapplicationname[] =
"remoteapplicationname";
240static const char key_str_remoteapplicationicon[] =
"remoteapplicationicon";
241static const char key_str_remoteapplicationprogram[] =
"remoteapplicationprogram";
242static const char key_str_remoteapplicationfile[] =
"remoteapplicationfile";
243static const char key_str_remoteapplicationguid[] =
"remoteapplicationguid";
244static const char key_str_remoteapplicationcmdline[] =
"remoteapplicationcmdline";
245static const char key_str_alternate_shell[] =
"alternate shell";
246static const char key_str_shell_working_directory[] =
"shell working directory";
247static const char key_str_gatewayhostname[] =
"gatewayhostname";
248static const char key_str_gatewayaccesstoken[] =
"gatewayaccesstoken";
249static const char key_str_resourceprovider[] =
"resourceprovider";
250static const char str_resourceprovider_arm[] =
"arm";
251static const char key_str_kdcproxyname[] =
"kdcproxyname";
252static const char key_str_drivestoredirect[] =
"drivestoredirect";
253static const char key_str_devicestoredirect[] =
"devicestoredirect";
254static const char key_str_winposstr[] =
"winposstr";
255static const char key_str_pcb[] =
"pcb";
256static const char key_str_selectedmonitors[] =
"selectedmonitors";
258static const char key_str_wvd[] =
"wvd endpoint pool";
259static const char key_str_geo[] =
"geo";
260static const char key_str_armpath[] =
"armpath";
261static const char key_str_aadtenantid[] =
"aadtenantid";
263static const char key_str_diagnosticserviceurl[] =
"diagnosticserviceurl";
264static const char key_str_hubdiscoverygeourl[] =
"hubdiscoverygeourl";
266static const char key_str_activityhint[] =
"activityhint";
268static const char key_int_rdgiskdcproxy[] =
"rdgiskdcproxy";
269static const char key_int_use_redirection_server_name[] =
"use redirection server name";
270static const char key_int_gatewaycredentialssource[] =
"gatewaycredentialssource";
271static const char key_int_gatewayprofileusagemethod[] =
"gatewayprofileusagemethod";
272static const char key_int_gatewayusagemethod[] =
"gatewayusagemethod";
273static const char key_int_disableremoteappcapscheck[] =
"disableremoteappcapscheck";
274static const char key_int_disableconnectionsharing[] =
"disableconnectionsharing";
275static const char key_int_remoteapplicationexpandworkingdir[] =
"remoteapplicationexpandworkingdir";
276static const char key_int_remoteapplicationexpandcmdline[] =
"remoteapplicationexpandcmdline";
277static const char key_int_remoteapplicationmode[] =
"remoteapplicationmode";
278static const char key_int_enablecredsspsupport[] =
"enablecredsspsupport";
279static const char key_int_enablerdsaadauth[] =
"enablerdsaadauth";
280static const char key_int_negotiate_security_layer[] =
"negotiate security layer";
281static const char key_int_prompt_for_credentials[] =
"prompt for credentials";
282static const char key_int_promptcredentialonce[] =
"promptcredentialonce";
283static const char key_int_authentication_level[] =
"authentication level";
284static const char key_int_public_mode[] =
"public mode";
285static const char key_int_autoreconnect_max_retries[] =
"autoreconnect max retries";
286static const char key_int_autoreconnection_enabled[] =
"autoreconnection enabled";
287static const char key_int_administrative_session[] =
"administrative session";
288static const char key_int_connect_to_console[] =
"connect to console";
289static const char key_int_disableclipboardredirection[] =
"disableclipboardredirection";
290static const char key_int_disableprinterredirection[] =
"disableprinterredirection";
291static const char key_int_redirectdirectx[] =
"redirectdirectx";
292static const char key_int_redirectposdevices[] =
"redirectposdevices";
293static const char key_int_redirectclipboard[] =
"redirectclipboard";
294static const char key_int_redirectsmartcards[] =
"redirectsmartcards";
295static const char key_int_redirectcomports[] =
"redirectcomports";
296static const char key_int_redirectlocation[] =
"redirectlocation";
297static const char key_int_redirectprinters[] =
"redirectprinters";
298static const char key_int_redirectdrives[] =
"redirectdrives";
299static const char key_int_server_port[] =
"server port";
300static const char key_int_bitmapcachepersistenable[] =
"bitmapcachepersistenable";
301static const char key_int_bitmapcachesize[] =
"bitmapcachesize";
302static const char key_int_disable_cursor_setting[] =
"disable cursor setting";
303static const char key_int_disable_themes[] =
"disable themes";
304static const char key_int_disable_menu_anims[] =
"disable menu anims";
305static const char key_int_disable_full_window_drag[] =
"disable full window drag";
306static const char key_int_allow_desktop_composition[] =
"allow desktop composition";
307static const char key_int_allow_font_smoothing[] =
"allow font smoothing";
308static const char key_int_disable_wallpaper[] =
"disable wallpaper";
309static const char key_int_enableworkspacereconnect[] =
"enableworkspacereconnect";
310static const char key_int_workspaceid[] =
"workspaceid";
311static const char key_int_displayconnectionbar[] =
"displayconnectionbar";
312static const char key_int_pinconnectionbar[] =
"pinconnectionbar";
313static const char key_int_bandwidthautodetect[] =
"bandwidthautodetect";
314static const char key_int_networkautodetect[] =
"networkautodetect";
315static const char key_int_connection_type[] =
"connection type";
316static const char key_int_videoplaybackmode[] =
"videoplaybackmode";
317static const char key_int_redirected_video_capture_encoding_quality[] =
318 "redirected video capture encoding quality";
319static const char key_int_encode_redirected_video_capture[] =
"encode redirected video capture";
320static const char key_int_audiocapturemode[] =
"audiocapturemode";
321static const char key_int_audioqualitymode[] =
"audioqualitymode";
322static const char key_int_audiomode[] =
"audiomode";
323static const char key_int_disable_ctrl_alt_del[] =
"disable ctrl+alt+del";
324static const char key_int_keyboardhook[] =
"keyboardhook";
325static const char key_int_compression[] =
"compression";
326static const char key_int_desktopscalefactor[] =
"desktopscalefactor";
327static const char key_int_session_bpp[] =
"session bpp";
328static const char key_int_desktop_size_id[] =
"desktop size id";
329static const char key_int_desktopheight[] =
"desktopheight";
330static const char key_int_desktopwidth[] =
"desktopwidth";
331static const char key_int_superpanaccelerationfactor[] =
"superpanaccelerationfactor";
332static const char key_int_enablesuperpan[] =
"enablesuperpan";
333static const char key_int_dynamic_resolution[] =
"dynamic resolution";
334static const char key_int_smart_sizing[] =
"smart sizing";
335static const char key_int_span_monitors[] =
"span monitors";
336static const char key_int_screen_mode_id[] =
"screen mode id";
337static const char key_int_singlemoninwindowedmode[] =
"singlemoninwindowedmode";
338static const char key_int_maximizetocurrentdisplays[] =
"maximizetocurrentdisplays";
339static const char key_int_use_multimon[] =
"use multimon";
340static const char key_int_redirectwebauthn[] =
"redirectwebauthn";
342static BOOL utils_str_is_empty(
const char* str)
346 if (strlen(str) == 0)
351static SSIZE_T freerdp_client_rdp_file_add_line(rdpFile* file);
352static rdpFileLine* freerdp_client_rdp_file_find_line_by_name(
const rdpFile* file,
354static void freerdp_client_file_string_check_free(LPSTR str);
356static BOOL freerdp_client_rdp_file_find_integer_entry(rdpFile* file,
const char* name,
357 DWORD** outValue, rdpFileLine** outLine)
361 WINPR_ASSERT(outValue);
362 WINPR_ASSERT(outLine);
367 if (_stricmp(name, key_int_use_multimon) == 0)
368 *outValue = &file->UseMultiMon;
369 else if (_stricmp(name, key_int_maximizetocurrentdisplays) == 0)
370 *outValue = &file->MaximizeToCurrentDisplays;
371 else if (_stricmp(name, key_int_singlemoninwindowedmode) == 0)
372 *outValue = &file->SingleMonInWindowedMode;
373 else if (_stricmp(name, key_int_screen_mode_id) == 0)
374 *outValue = &file->ScreenModeId;
375 else if (_stricmp(name, key_int_span_monitors) == 0)
376 *outValue = &file->SpanMonitors;
377 else if (_stricmp(name, key_int_smart_sizing) == 0)
378 *outValue = &file->SmartSizing;
379 else if (_stricmp(name, key_int_dynamic_resolution) == 0)
380 *outValue = &file->DynamicResolution;
381 else if (_stricmp(name, key_int_enablesuperpan) == 0)
382 *outValue = &file->EnableSuperSpan;
383 else if (_stricmp(name, key_int_superpanaccelerationfactor) == 0)
384 *outValue = &file->SuperSpanAccelerationFactor;
385 else if (_stricmp(name, key_int_desktopwidth) == 0)
386 *outValue = &file->DesktopWidth;
387 else if (_stricmp(name, key_int_desktopheight) == 0)
388 *outValue = &file->DesktopHeight;
389 else if (_stricmp(name, key_int_desktop_size_id) == 0)
390 *outValue = &file->DesktopSizeId;
391 else if (_stricmp(name, key_int_session_bpp) == 0)
392 *outValue = &file->SessionBpp;
393 else if (_stricmp(name, key_int_desktopscalefactor) == 0)
394 *outValue = &file->DesktopScaleFactor;
395 else if (_stricmp(name, key_int_compression) == 0)
396 *outValue = &file->Compression;
397 else if (_stricmp(name, key_int_keyboardhook) == 0)
398 *outValue = &file->KeyboardHook;
399 else if (_stricmp(name, key_int_disable_ctrl_alt_del) == 0)
400 *outValue = &file->DisableCtrlAltDel;
401 else if (_stricmp(name, key_int_audiomode) == 0)
402 *outValue = &file->AudioMode;
403 else if (_stricmp(name, key_int_audioqualitymode) == 0)
404 *outValue = &file->AudioQualityMode;
405 else if (_stricmp(name, key_int_audiocapturemode) == 0)
406 *outValue = &file->AudioCaptureMode;
407 else if (_stricmp(name, key_int_encode_redirected_video_capture) == 0)
408 *outValue = &file->EncodeRedirectedVideoCapture;
409 else if (_stricmp(name, key_int_redirected_video_capture_encoding_quality) == 0)
410 *outValue = &file->RedirectedVideoCaptureEncodingQuality;
411 else if (_stricmp(name, key_int_videoplaybackmode) == 0)
412 *outValue = &file->VideoPlaybackMode;
413 else if (_stricmp(name, key_int_connection_type) == 0)
414 *outValue = &file->ConnectionType;
415 else if (_stricmp(name, key_int_networkautodetect) == 0)
416 *outValue = &file->NetworkAutoDetect;
417 else if (_stricmp(name, key_int_bandwidthautodetect) == 0)
418 *outValue = &file->BandwidthAutoDetect;
419 else if (_stricmp(name, key_int_pinconnectionbar) == 0)
420 *outValue = &file->PinConnectionBar;
421 else if (_stricmp(name, key_int_displayconnectionbar) == 0)
422 *outValue = &file->DisplayConnectionBar;
423 else if (_stricmp(name, key_int_workspaceid) == 0)
424 *outValue = &file->WorkspaceId;
425 else if (_stricmp(name, key_int_enableworkspacereconnect) == 0)
426 *outValue = &file->EnableWorkspaceReconnect;
427 else if (_stricmp(name, key_int_disable_wallpaper) == 0)
428 *outValue = &file->DisableWallpaper;
429 else if (_stricmp(name, key_int_allow_font_smoothing) == 0)
430 *outValue = &file->AllowFontSmoothing;
431 else if (_stricmp(name, key_int_allow_desktop_composition) == 0)
432 *outValue = &file->AllowDesktopComposition;
433 else if (_stricmp(name, key_int_disable_full_window_drag) == 0)
434 *outValue = &file->DisableFullWindowDrag;
435 else if (_stricmp(name, key_int_disable_menu_anims) == 0)
436 *outValue = &file->DisableMenuAnims;
437 else if (_stricmp(name, key_int_disable_themes) == 0)
438 *outValue = &file->DisableThemes;
439 else if (_stricmp(name, key_int_disable_cursor_setting) == 0)
440 *outValue = &file->DisableCursorSetting;
441 else if (_stricmp(name, key_int_bitmapcachesize) == 0)
442 *outValue = &file->BitmapCacheSize;
443 else if (_stricmp(name, key_int_bitmapcachepersistenable) == 0)
444 *outValue = &file->BitmapCachePersistEnable;
445 else if (_stricmp(name, key_int_server_port) == 0)
446 *outValue = &file->ServerPort;
447 else if (_stricmp(name, key_int_redirectdrives) == 0)
448 *outValue = &file->RedirectDrives;
449 else if (_stricmp(name, key_int_redirectprinters) == 0)
450 *outValue = &file->RedirectPrinters;
451 else if (_stricmp(name, key_int_redirectcomports) == 0)
452 *outValue = &file->RedirectComPorts;
453 else if (_stricmp(name, key_int_redirectlocation) == 0)
454 *outValue = &file->RedirectLocation;
455 else if (_stricmp(name, key_int_redirectsmartcards) == 0)
456 *outValue = &file->RedirectSmartCards;
457 else if (_stricmp(name, key_int_redirectclipboard) == 0)
458 *outValue = &file->RedirectClipboard;
459 else if (_stricmp(name, key_int_redirectposdevices) == 0)
460 *outValue = &file->RedirectPosDevices;
461 else if (_stricmp(name, key_int_redirectdirectx) == 0)
462 *outValue = &file->RedirectDirectX;
463 else if (_stricmp(name, key_int_disableprinterredirection) == 0)
464 *outValue = &file->DisablePrinterRedirection;
465 else if (_stricmp(name, key_int_disableclipboardredirection) == 0)
466 *outValue = &file->DisableClipboardRedirection;
467 else if (_stricmp(name, key_int_connect_to_console) == 0)
468 *outValue = &file->ConnectToConsole;
469 else if (_stricmp(name, key_int_administrative_session) == 0)
470 *outValue = &file->AdministrativeSession;
471 else if (_stricmp(name, key_int_autoreconnection_enabled) == 0)
472 *outValue = &file->AutoReconnectionEnabled;
473 else if (_stricmp(name, key_int_autoreconnect_max_retries) == 0)
474 *outValue = &file->AutoReconnectMaxRetries;
475 else if (_stricmp(name, key_int_public_mode) == 0)
476 *outValue = &file->PublicMode;
477 else if (_stricmp(name, key_int_authentication_level) == 0)
478 *outValue = &file->AuthenticationLevel;
479 else if (_stricmp(name, key_int_promptcredentialonce) == 0)
480 *outValue = &file->PromptCredentialOnce;
481 else if ((_stricmp(name, key_int_prompt_for_credentials) == 0))
482 *outValue = &file->PromptForCredentials;
483 else if (_stricmp(name, key_int_negotiate_security_layer) == 0)
484 *outValue = &file->NegotiateSecurityLayer;
485 else if (_stricmp(name, key_int_enablecredsspsupport) == 0)
486 *outValue = &file->EnableCredSSPSupport;
487 else if (_stricmp(name, key_int_enablerdsaadauth) == 0)
488 *outValue = &file->EnableRdsAadAuth;
489 else if (_stricmp(name, key_int_remoteapplicationmode) == 0)
490 *outValue = &file->RemoteApplicationMode;
491 else if (_stricmp(name, key_int_remoteapplicationexpandcmdline) == 0)
492 *outValue = &file->RemoteApplicationExpandCmdLine;
493 else if (_stricmp(name, key_int_remoteapplicationexpandworkingdir) == 0)
494 *outValue = &file->RemoteApplicationExpandWorkingDir;
495 else if (_stricmp(name, key_int_disableconnectionsharing) == 0)
496 *outValue = &file->DisableConnectionSharing;
497 else if (_stricmp(name, key_int_disableremoteappcapscheck) == 0)
498 *outValue = &file->DisableRemoteAppCapsCheck;
499 else if (_stricmp(name, key_int_gatewayusagemethod) == 0)
500 *outValue = &file->GatewayUsageMethod;
501 else if (_stricmp(name, key_int_gatewayprofileusagemethod) == 0)
502 *outValue = &file->GatewayProfileUsageMethod;
503 else if (_stricmp(name, key_int_gatewaycredentialssource) == 0)
504 *outValue = &file->GatewayCredentialsSource;
505 else if (_stricmp(name, key_int_use_redirection_server_name) == 0)
506 *outValue = &file->UseRedirectionServerName;
507 else if (_stricmp(name, key_int_rdgiskdcproxy) == 0)
508 *outValue = &file->RdgIsKdcProxy;
509 else if (_stricmp(name, key_int_redirectwebauthn) == 0)
510 *outValue = &file->RedirectWebauthN;
513 rdpFileLine* line = freerdp_client_rdp_file_find_line_by_name(file, name);
516 if (!(line->flags & RDP_FILE_LINE_FLAG_TYPE_INTEGER))
525static BOOL freerdp_client_rdp_file_find_string_entry(rdpFile* file,
const char* name,
526 LPSTR** outValue, rdpFileLine** outLine)
530 WINPR_ASSERT(outValue);
531 WINPR_ASSERT(outLine);
536 if (_stricmp(name, key_str_username) == 0)
537 *outValue = &file->Username;
538 else if (_stricmp(name, key_str_domain) == 0)
539 *outValue = &file->Domain;
540 else if (_stricmp(name, key_str_password) == 0)
541 *outValue = &file->Password;
542 else if (_stricmp(name, key_str_full_address) == 0)
543 *outValue = &file->FullAddress;
544 else if (_stricmp(name, key_str_alternate_full_address) == 0)
545 *outValue = &file->AlternateFullAddress;
546 else if (_stricmp(name, key_str_usbdevicestoredirect) == 0)
547 *outValue = &file->UsbDevicesToRedirect;
548 else if (_stricmp(name, key_str_camerastoredirect) == 0)
549 *outValue = &file->RedirectCameras;
550 else if (_stricmp(name, key_str_loadbalanceinfo) == 0)
551 *outValue = &file->LoadBalanceInfo;
552 else if (_stricmp(name, key_str_remoteapplicationname) == 0)
553 *outValue = &file->RemoteApplicationName;
554 else if (_stricmp(name, key_str_remoteapplicationicon) == 0)
555 *outValue = &file->RemoteApplicationIcon;
556 else if (_stricmp(name, key_str_remoteapplicationprogram) == 0)
557 *outValue = &file->RemoteApplicationProgram;
558 else if (_stricmp(name, key_str_remoteapplicationfile) == 0)
559 *outValue = &file->RemoteApplicationFile;
560 else if (_stricmp(name, key_str_remoteapplicationguid) == 0)
561 *outValue = &file->RemoteApplicationGuid;
562 else if (_stricmp(name, key_str_remoteapplicationcmdline) == 0)
563 *outValue = &file->RemoteApplicationCmdLine;
564 else if (_stricmp(name, key_str_alternate_shell) == 0)
565 *outValue = &file->AlternateShell;
566 else if (_stricmp(name, key_str_shell_working_directory) == 0)
567 *outValue = &file->ShellWorkingDirectory;
568 else if (_stricmp(name, key_str_gatewayhostname) == 0)
569 *outValue = &file->GatewayHostname;
570 else if (_stricmp(name, key_str_resourceprovider) == 0)
571 *outValue = &file->ResourceProvider;
572 else if (_stricmp(name, key_str_wvd) == 0)
573 *outValue = &file->WvdEndpointPool;
574 else if (_stricmp(name, key_str_geo) == 0)
575 *outValue = &file->geo;
576 else if (_stricmp(name, key_str_armpath) == 0)
577 *outValue = &file->armpath;
578 else if (_stricmp(name, key_str_aadtenantid) == 0)
579 *outValue = &file->aadtenantid;
580 else if (_stricmp(name, key_str_diagnosticserviceurl) == 0)
581 *outValue = &file->diagnosticserviceurl;
582 else if (_stricmp(name, key_str_hubdiscoverygeourl) == 0)
583 *outValue = &file->hubdiscoverygeourl;
584 else if (_stricmp(name, key_str_activityhint) == 0)
585 *outValue = &file->activityhint;
586 else if (_stricmp(name, key_str_gatewayaccesstoken) == 0)
587 *outValue = &file->GatewayAccessToken;
588 else if (_stricmp(name, key_str_kdcproxyname) == 0)
589 *outValue = &file->KdcProxyName;
590 else if (_stricmp(name, key_str_drivestoredirect) == 0)
591 *outValue = &file->DrivesToRedirect;
592 else if (_stricmp(name, key_str_devicestoredirect) == 0)
593 *outValue = &file->DevicesToRedirect;
594 else if (_stricmp(name, key_str_winposstr) == 0)
595 *outValue = &file->WinPosStr;
596 else if (_stricmp(name, key_str_pcb) == 0)
597 *outValue = &file->PreconnectionBlob;
598 else if (_stricmp(name, key_str_selectedmonitors) == 0)
599 *outValue = &file->SelectedMonitors;
602 rdpFileLine* line = freerdp_client_rdp_file_find_line_by_name(file, name);
605 if (!(line->flags & RDP_FILE_LINE_FLAG_TYPE_STRING))
620static BOOL freerdp_client_rdp_file_set_integer(rdpFile* file,
const char* name,
long value)
622 DWORD* targetValue =
nullptr;
623 rdpFileLine* line =
nullptr;
624#ifdef DEBUG_CLIENT_FILE
625 WLog_DBG(TAG,
"%s:i:%ld", name, value);
631 if (!freerdp_client_rdp_file_find_integer_entry(file, name, &targetValue, &line))
633 SSIZE_T index = freerdp_client_rdp_file_add_line(file);
636 line = &file->lines[index];
641 *targetValue = (DWORD)value;
648 line->name = _strdup(name);
652 line->name =
nullptr;
656 line->iValue = value;
657 line->flags = RDP_FILE_LINE_FLAG_FORMATTED;
658 line->flags |= RDP_FILE_LINE_FLAG_TYPE_INTEGER;
659 line->valueLength = 0;
666static BOOL freerdp_client_parse_rdp_file_integer(rdpFile* file,
const char* name,
669 char* endptr =
nullptr;
672 ivalue = strtol(value, &endptr, 0);
674 if ((endptr ==
nullptr) || (errno != 0) || (endptr == value) || (ivalue > INT32_MAX) ||
675 (ivalue < INT32_MIN))
677 if (file->flags & RDP_FILE_FLAG_PARSE_INT_RELAXED)
679 WLog_WARN(TAG,
"Integer option %s has invalid value %s, using default", name, value);
684 WLog_ERR(TAG,
"Failed to convert RDP file integer option %s [value=%s]", name, value);
689 return freerdp_client_rdp_file_set_integer(file, name, ivalue);
700static BOOL freerdp_client_rdp_file_set_string(rdpFile* file,
const char* name,
const char* value)
702 LPSTR* targetValue =
nullptr;
703 rdpFileLine* line =
nullptr;
704#ifdef DEBUG_CLIENT_FILE
705 WLog_DBG(TAG,
"%s:s:%s", name, value);
711 if (!freerdp_client_rdp_file_find_string_entry(file, name, &targetValue, &line))
713 SSIZE_T index = freerdp_client_rdp_file_add_line(file);
716 line = &file->lines[index];
721 if ((uintptr_t)(*targetValue) != UINTPTR_MAX)
724 *targetValue = _strdup(value);
725 return ((*targetValue) !=
nullptr);
732 line->name = _strdup(name);
733 line->sValue = _strdup(value);
734 if (!line->name || !line->sValue)
738 line->name =
nullptr;
739 line->sValue =
nullptr;
743 line->flags = RDP_FILE_LINE_FLAG_FORMATTED;
744 line->flags |= RDP_FILE_LINE_FLAG_TYPE_STRING;
745 line->valueLength = 0;
752static BOOL freerdp_client_add_option(rdpFile* file,
const char* option)
754 return freerdp_addin_argv_add_argument(file->args, option);
757static SSIZE_T freerdp_client_rdp_file_add_line(rdpFile* file)
759 SSIZE_T index = (SSIZE_T)file->lineCount;
761 while ((file->lineCount + 1) > file->lineSize)
763 size_t new_size = file->lineCount + 2048;
764 rdpFileLine* new_line = (rdpFileLine*)realloc(file->lines, new_size *
sizeof(rdpFileLine));
769 file->lines = new_line;
770 file->lineSize = new_size;
773 ZeroMemory(&(file->lines[file->lineCount]),
sizeof(rdpFileLine));
774 file->lines[file->lineCount].index = (size_t)index;
779BOOL freerdp_client_parse_rdp_file_buffer(rdpFile* file,
const BYTE* buffer,
size_t size)
781 return freerdp_client_parse_rdp_file_buffer_ex(file, buffer, size,
nullptr);
784static BOOL trim(
char** strptr)
786 char* start =
nullptr;
790 start = str = *strptr;
793 if (!(~((
size_t)str)))
795 end = str + strlen(str) - 1;
797 while (isspace(*str))
800 while ((end > str) && isspace(*end))
807 *strptr = _strdup(str);
809 return *strptr !=
nullptr;
815static BOOL trim_strings(rdpFile* file)
817 if (!trim(&file->Username))
819 if (!trim(&file->Domain))
821 if (!trim(&file->AlternateFullAddress))
823 if (!trim(&file->FullAddress))
825 if (!trim(&file->UsbDevicesToRedirect))
827 if (!trim(&file->RedirectCameras))
829 if (!trim(&file->LoadBalanceInfo))
831 if (!trim(&file->GatewayHostname))
833 if (!trim(&file->GatewayAccessToken))
835 if (!trim(&file->RemoteApplicationName))
837 if (!trim(&file->RemoteApplicationIcon))
839 if (!trim(&file->RemoteApplicationProgram))
841 if (!trim(&file->RemoteApplicationFile))
843 if (!trim(&file->RemoteApplicationGuid))
845 if (!trim(&file->RemoteApplicationCmdLine))
847 if (!trim(&file->AlternateShell))
849 if (!trim(&file->ShellWorkingDirectory))
851 if (!trim(&file->DrivesToRedirect))
853 if (!trim(&file->DevicesToRedirect))
855 if (!trim(&file->WinPosStr))
857 if (!trim(&file->PreconnectionBlob))
859 if (!trim(&file->KdcProxyName))
861 if (!trim(&file->SelectedMonitors))
864 for (
size_t i = 0; i < file->lineCount; ++i)
866 rdpFileLine* curLine = &file->lines[i];
867 if (curLine->flags & RDP_FILE_LINE_FLAG_TYPE_STRING)
869 if (!trim(&curLine->sValue))
877static BOOL parse_line(rdpFile* file,
char* line,
size_t length, rdp_file_fkt_parse parse)
882 const char* beg = line;
883#if !defined(WITHOUT_FREERDP_3x_DEPRECATED)
884#if defined(WITH_EMBEDDED_CLI_IN_RDP_FILES)
887 freerdp_warn_deprecated(WLog_Get(TAG),
"Parsing CLI options within an RDP file",
888 "Will be removed in FreeRDP 4.0");
889 if (!freerdp_client_add_option(file, line))
897 char* d1 = strchr(line,
':');
902 const char* type = &d1[1];
903 char* d2 = strchr(type,
':');
913 const char* name = beg;
914 const char* value = &d2[1];
916 if (parse && parse(file->context, name, *type, value))
922 return freerdp_client_parse_rdp_file_integer(file, name, value);
927 return freerdp_client_rdp_file_set_string(file, name, value);
932 WLog_ERR(TAG,
"Unsupported RDP file binary option %s [value=%s]", name, value);
938BOOL freerdp_client_parse_rdp_file_buffer_ex(rdpFile* file,
const BYTE* buffer,
size_t size,
939 rdp_file_fkt_parse parse)
942 char* copy =
nullptr;
949 if ((buffer[0] == BOM_UTF16_LE[0]) && (buffer[1] == BOM_UTF16_LE[1]))
951 LPCWSTR uc = (LPCWSTR)(&buffer[2]);
952 const size_t charlen = size /
sizeof(WCHAR) - 1;
953 copy = ConvertWCharNToUtf8Alloc(uc, charlen, &size);
956 WLog_ERR(TAG,
"Failed to convert RDP file from UCS2 to UTF8");
962 copy = calloc(1, size +
sizeof(BYTE));
967 memcpy(copy, buffer, size);
970 char* context =
nullptr;
971 char* line = strtok_s(copy,
"\r\n", &context);
975 const size_t length = strnlen(line, size);
977 if (!parse_line(file, line, length, parse))
980 line = strtok_s(
nullptr,
"\r\n", &context);
983 rc = trim_strings(file);
989BOOL freerdp_client_parse_rdp_file(rdpFile* file,
const char* name)
991 return freerdp_client_parse_rdp_file_ex(file, name,
nullptr);
994BOOL freerdp_client_parse_rdp_file_ex(rdpFile* file,
const char* name, rdp_file_fkt_parse parse)
997 BYTE* buffer =
nullptr;
999 size_t read_size = 0;
1000 INT64 file_size = 0;
1001 const char* fname = name;
1006 if (_strnicmp(fname,
"file://", 7) == 0)
1009 fp = winpr_fopen(fname,
"r");
1012 WLog_ERR(TAG,
"Failed to open RDP file %s", name);
1016 if (_fseeki64(fp, 0, SEEK_END) < 0)
1018 file_size = _ftelli64(fp);
1019 if (_fseeki64(fp, 0, SEEK_SET) < 0)
1024 WLog_ERR(TAG,
"RDP file %s is empty", name);
1028 buffer = (BYTE*)malloc((
size_t)file_size + 2);
1033 read_size = fread(buffer, (
size_t)file_size, 1, fp);
1038 read_size = (size_t)file_size;
1043 WLog_ERR(TAG,
"Could not read from RDP file %s", name);
1047 buffer[file_size] =
'\0';
1048 buffer[file_size + 1] =
'\0';
1049 status = freerdp_client_parse_rdp_file_buffer_ex(file, buffer, (
size_t)file_size, parse);
1057static inline void freerdp_client_file_string_reset(
char** target)
1059 WINPR_ASSERT(target);
1060 freerdp_client_file_string_check_free(*target);
1061 *target = (
char*)UINTPTR_MAX;
1064static inline BOOL FILE_POPULATE_STRING(
char** _target,
const rdpSettings* _settings,
1065 FreeRDP_Settings_Keys_String _option)
1067 WINPR_ASSERT(_target);
1068 WINPR_ASSERT(_settings);
1071 freerdp_client_file_string_reset(_target);
1074 char* copy = _strdup(str);
1082static char* freerdp_client_channel_args_to_string(
const rdpSettings* settings,
const char* channel,
1085 ADDIN_ARGV* args = freerdp_dynamic_channel_collection_find(settings, channel);
1086 const char* filters[] = { option };
1087 if (!args || (args->argc < 2))
1090 return CommandLineToCommaSeparatedValuesEx(args->argc - 1, args->argv + 1, filters,
1091 ARRAYSIZE(filters));
1094static BOOL rdp_opt_duplicate(
const rdpSettings* _settings, FreeRDP_Settings_Keys_String _id,
1097 WINPR_ASSERT(_settings);
1103 *_key = _strdup(tmp);
1111BOOL freerdp_client_populate_rdp_file_from_settings(rdpFile* file,
const rdpSettings* settings)
1113 FreeRDP_Settings_Keys_String index = FreeRDP_STRING_UNUSED;
1114 UINT32 LoadBalanceInfoLength = 0;
1115 const char* GatewayHostname =
nullptr;
1116 char* redirectCameras =
nullptr;
1118 if (!file || !settings)
1121 if (!FILE_POPULATE_STRING(&file->Domain, settings, FreeRDP_Domain) ||
1122 !FILE_POPULATE_STRING(&file->Username, settings, FreeRDP_Username) ||
1123 !FILE_POPULATE_STRING(&file->Password, settings, FreeRDP_Password) ||
1124 !FILE_POPULATE_STRING(&file->FullAddress, settings, FreeRDP_ServerHostname) ||
1125 !FILE_POPULATE_STRING(&file->AlternateFullAddress, settings, FreeRDP_ServerHostname) ||
1126 !FILE_POPULATE_STRING(&file->AlternateShell, settings, FreeRDP_AlternateShell) ||
1127 !FILE_POPULATE_STRING(&file->DrivesToRedirect, settings, FreeRDP_DrivesToRedirect))
1136 file->DynamicResolution = WINPR_ASSERTING_INT_CAST(
1138 file->VideoPlaybackMode = WINPR_ASSERTING_INT_CAST(
1145 file->ConnectToConsole = WINPR_ASSERTING_INT_CAST(
1147 file->NegotiateSecurityLayer = WINPR_ASSERTING_INT_CAST(
1149 file->EnableCredSSPSupport =
1151 file->EnableRdsAadAuth =
1155 index = FreeRDP_RemoteApplicationWorkingDir;
1157 index = FreeRDP_ShellWorkingDirectory;
1158 if (!FILE_POPULATE_STRING(&file->ShellWorkingDirectory, settings, index))
1165 if (LoadBalanceInfoLength > 0)
1167 const BYTE* LoadBalanceInfo =
1169 file->LoadBalanceInfo = calloc(LoadBalanceInfoLength + 1, 1);
1170 if (!file->LoadBalanceInfo)
1172 memcpy(file->LoadBalanceInfo, LoadBalanceInfo, LoadBalanceInfoLength);
1176 file->AudioMode = AUDIO_MODE_REDIRECT;
1178 file->AudioMode = AUDIO_MODE_PLAY_ON_SERVER;
1180 file->AudioMode = AUDIO_MODE_NONE;
1185 if (GatewayHostname)
1188 freerdp_client_file_string_check_free(file->GatewayHostname);
1189 if (GatewayPort == 443)
1190 file->GatewayHostname = _strdup(GatewayHostname);
1193 int length = _scprintf(
"%s:%" PRIu32, GatewayHostname, GatewayPort);
1197 file->GatewayHostname = (
char*)malloc((
size_t)length + 1);
1198 if (!file->GatewayHostname)
1201 if (sprintf_s(file->GatewayHostname, (
size_t)length + 1,
"%s:%" PRIu32, GatewayHostname,
1205 if (!file->GatewayHostname)
1210 file->ResourceProvider = _strdup(str_resourceprovider_arm);
1212 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdWvdEndpointPool, &file->WvdEndpointPool))
1214 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdGeo, &file->geo))
1216 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdArmpath, &file->armpath))
1218 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdAadtenantid, &file->aadtenantid))
1220 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdDiagnosticserviceurl,
1221 &file->diagnosticserviceurl))
1223 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdHubdiscoverygeourl,
1224 &file->hubdiscoverygeourl))
1226 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdActivityhint, &file->activityhint))
1229 file->AudioCaptureMode =
1231 file->BitmapCachePersistEnable = WINPR_ASSERTING_INT_CAST(
1233 file->Compression = WINPR_ASSERTING_INT_CAST(
1236 file->GatewayUsageMethod = freerdp_get_gateway_usage_method(settings);
1237 file->GatewayCredentialsSource =
1239 file->PromptCredentialOnce = WINPR_ASSERTING_INT_CAST(
1241 file->PromptForCredentials = WINPR_ASSERTING_INT_CAST(
1243 file->RemoteApplicationMode = WINPR_ASSERTING_INT_CAST(
1245 if (!FILE_POPULATE_STRING(&file->GatewayAccessToken, settings, FreeRDP_GatewayAccessToken) ||
1246 !FILE_POPULATE_STRING(&file->RemoteApplicationProgram, settings,
1247 FreeRDP_RemoteApplicationProgram) ||
1248 !FILE_POPULATE_STRING(&file->RemoteApplicationName, settings,
1249 FreeRDP_RemoteApplicationName) ||
1250 !FILE_POPULATE_STRING(&file->RemoteApplicationIcon, settings,
1251 FreeRDP_RemoteApplicationIcon) ||
1252 !FILE_POPULATE_STRING(&file->RemoteApplicationFile, settings,
1253 FreeRDP_RemoteApplicationFile) ||
1254 !FILE_POPULATE_STRING(&file->RemoteApplicationGuid, settings,
1255 FreeRDP_RemoteApplicationGuid) ||
1256 !FILE_POPULATE_STRING(&file->RemoteApplicationCmdLine, settings,
1257 FreeRDP_RemoteApplicationCmdLine))
1259 file->SpanMonitors =
1263 file->AllowDesktopComposition = WINPR_ASSERTING_INT_CAST(
1265 file->AllowFontSmoothing = WINPR_ASSERTING_INT_CAST(
1267 file->DisableWallpaper = WINPR_ASSERTING_INT_CAST(
1269 file->DisableFullWindowDrag = WINPR_ASSERTING_INT_CAST(
1271 file->DisableMenuAnims = WINPR_ASSERTING_INT_CAST(
1273 file->DisableThemes = WINPR_ASSERTING_INT_CAST(
1276 CONNECTION_TYPE_AUTODETECT);
1277 file->NetworkAutoDetect =
1279 file->AutoReconnectionEnabled = WINPR_ASSERTING_INT_CAST(
1281 file->RedirectSmartCards = WINPR_ASSERTING_INT_CAST(
1283 file->RedirectWebauthN = WINPR_ASSERTING_INT_CAST(
1287 freerdp_client_channel_args_to_string(settings, RDPECAM_DVC_CHANNEL_NAME,
"device:");
1288 if (redirectCameras)
1291 freerdp_client_channel_args_to_string(settings, RDPECAM_DVC_CHANNEL_NAME,
"encode:");
1292 file->EncodeRedirectedVideoCapture = 0;
1295 unsigned long val = 0;
1297 val = strtoul(str,
nullptr, 0);
1298 if ((val < UINT32_MAX) && (errno == 0))
1299 file->EncodeRedirectedVideoCapture = (UINT32)val;
1303 str = freerdp_client_channel_args_to_string(settings, RDPECAM_DVC_CHANNEL_NAME,
"quality:");
1304 file->RedirectedVideoCaptureEncodingQuality = 0;
1307 unsigned long val = 0;
1309 val = strtoul(str,
nullptr, 0);
1310 if ((val <= 2) && (errno == 0))
1312 file->RedirectedVideoCaptureEncodingQuality = (UINT32)val;
1317 file->RedirectCameras = redirectCameras;
1320 freerdp_client_file_string_reset(&file->RedirectCameras);
1322#ifdef CHANNEL_URBDRC_CLIENT
1324 freerdp_client_channel_args_to_string(settings, URBDRC_CHANNEL_NAME,
"device:");
1326 file->UsbDevicesToRedirect = redirectUsb;
1328 freerdp_client_file_string_reset(&file->UsbDevicesToRedirect);
1331 file->RedirectClipboard =
1338 file->RedirectLocation =
1340 if (!FILE_POPULATE_STRING(&file->DrivesToRedirect, settings, FreeRDP_DrivesToRedirect) ||
1341 !FILE_POPULATE_STRING(&file->PreconnectionBlob, settings, FreeRDP_PreconnectionBlob) ||
1342 !FILE_POPULATE_STRING(&file->KdcProxyName, settings, FreeRDP_KerberosKdcUrl))
1350 size_t size = count * (10 + 1) + 1;
1352 char* str = calloc(size,
sizeof(
char));
1353 for (UINT32 x = 0; x < count; x++)
1355 int rc = _snprintf(&str[offset], size - offset,
"%" PRIu32
",", MonitorIds[x]);
1361 offset += (size_t)rc;
1364 str[offset - 1] =
'\0';
1365 freerdp_client_file_string_check_free(file->SelectedMonitors);
1366 file->SelectedMonitors = str;
1374BOOL freerdp_client_write_rdp_file(
const rdpFile* file,
const char* name, BOOL unicode)
1377 WCHAR* unicodestr =
nullptr;
1382 const size_t size = freerdp_client_write_rdp_file_buffer(file,
nullptr, 0);
1385 char* buffer = calloc(size + 1ULL,
sizeof(
char));
1389 if (freerdp_client_write_rdp_file_buffer(file, buffer, size + 1) != size)
1391 WLog_ERR(TAG,
"freerdp_client_write_rdp_file: error writing to output buffer");
1396 FILE* fp = winpr_fopen(name,
"w+b");
1403 unicodestr = ConvertUtf8NToWCharAlloc(buffer, size, &len);
1413 if ((fwrite(BOM_UTF16_LE,
sizeof(BYTE), 2, fp) != 2) ||
1414 (fwrite(unicodestr,
sizeof(WCHAR), len, fp) != len))
1426 if (fwrite(buffer, 1, size, fp) != size)
1435 status = fclose(fp);
1439 return (status == 0);
1442WINPR_ATTR_FORMAT_ARG(3, 4)
1443static SSIZE_T freerdp_client_write_setting_to_buffer(
char** buffer,
size_t* bufferSize,
1444 WINPR_FORMAT_ARG const
char* fmt, ...)
1446 va_list ap = WINPR_C_ARRAY_INIT;
1448 char* buf =
nullptr;
1451 if (!buffer || !bufferSize || !fmt)
1455 bufSize = *bufferSize;
1458 len = vsnprintf(buf, bufSize, fmt, ap);
1467 if (!buf && !bufSize)
1474 if (bufSize >= (
size_t)len)
1476 *bufferSize -= (size_t)len;
1477 buf[len - 1] =
'\n';
1478 *buffer = buf + len;
1486static SSIZE_T write_int_parameters(
const rdpFile* file,
char* buffer,
size_t size)
1495 const struct intentry_t settings[] = {
1496 { key_int_use_multimon, file->UseMultiMon },
1497 { key_int_maximizetocurrentdisplays, file->MaximizeToCurrentDisplays },
1498 { key_int_singlemoninwindowedmode, file->SingleMonInWindowedMode },
1499 { key_int_screen_mode_id, file->ScreenModeId },
1500 { key_int_span_monitors, file->SpanMonitors },
1501 { key_int_smart_sizing, file->SmartSizing },
1502 { key_int_dynamic_resolution, file->DynamicResolution },
1503 { key_int_enablesuperpan, file->EnableSuperSpan },
1504 { key_int_superpanaccelerationfactor, file->SuperSpanAccelerationFactor },
1505 { key_int_desktopwidth, file->DesktopWidth },
1506 { key_int_desktopheight, file->DesktopHeight },
1507 { key_int_desktop_size_id, file->DesktopSizeId },
1508 { key_int_session_bpp, file->SessionBpp },
1509 { key_int_desktopscalefactor, file->DesktopScaleFactor },
1510 { key_int_compression, file->Compression },
1511 { key_int_keyboardhook, file->KeyboardHook },
1512 { key_int_disable_ctrl_alt_del, file->DisableCtrlAltDel },
1513 { key_int_audiomode, file->AudioMode },
1514 { key_int_audioqualitymode, file->AudioQualityMode },
1515 { key_int_audiocapturemode, file->AudioCaptureMode },
1516 { key_int_encode_redirected_video_capture, file->EncodeRedirectedVideoCapture },
1517 { key_int_redirected_video_capture_encoding_quality,
1518 file->RedirectedVideoCaptureEncodingQuality },
1519 { key_int_videoplaybackmode, file->VideoPlaybackMode },
1520 { key_int_connection_type, file->ConnectionType },
1521 { key_int_networkautodetect, file->NetworkAutoDetect },
1522 { key_int_bandwidthautodetect, file->BandwidthAutoDetect },
1523 { key_int_pinconnectionbar, file->PinConnectionBar },
1524 { key_int_displayconnectionbar, file->DisplayConnectionBar },
1525 { key_int_workspaceid, file->WorkspaceId },
1526 { key_int_enableworkspacereconnect, file->EnableWorkspaceReconnect },
1527 { key_int_disable_wallpaper, file->DisableWallpaper },
1528 { key_int_allow_font_smoothing, file->AllowFontSmoothing },
1529 { key_int_allow_desktop_composition, file->AllowDesktopComposition },
1530 { key_int_disable_full_window_drag, file->DisableFullWindowDrag },
1531 { key_int_disable_menu_anims, file->DisableMenuAnims },
1532 { key_int_disable_themes, file->DisableThemes },
1533 { key_int_disable_cursor_setting, file->DisableCursorSetting },
1534 { key_int_bitmapcachesize, file->BitmapCacheSize },
1535 { key_int_bitmapcachepersistenable, file->BitmapCachePersistEnable },
1536 { key_int_server_port, file->ServerPort },
1537 { key_int_redirectdrives, file->RedirectDrives },
1538 { key_int_redirectprinters, file->RedirectPrinters },
1539 { key_int_redirectcomports, file->RedirectComPorts },
1540 { key_int_redirectlocation, file->RedirectLocation },
1541 { key_int_redirectsmartcards, file->RedirectSmartCards },
1542 { key_int_redirectclipboard, file->RedirectClipboard },
1543 { key_int_redirectposdevices, file->RedirectPosDevices },
1544 { key_int_redirectdirectx, file->RedirectDirectX },
1545 { key_int_disableprinterredirection, file->DisablePrinterRedirection },
1546 { key_int_disableclipboardredirection, file->DisableClipboardRedirection },
1547 { key_int_connect_to_console, file->ConnectToConsole },
1548 { key_int_administrative_session, file->AdministrativeSession },
1549 { key_int_autoreconnection_enabled, file->AutoReconnectionEnabled },
1550 { key_int_autoreconnect_max_retries, file->AutoReconnectMaxRetries },
1551 { key_int_public_mode, file->PublicMode },
1552 { key_int_authentication_level, file->AuthenticationLevel },
1553 { key_int_promptcredentialonce, file->PromptCredentialOnce },
1554 { key_int_prompt_for_credentials, file->PromptForCredentials },
1555 { key_int_negotiate_security_layer, file->NegotiateSecurityLayer },
1556 { key_int_enablecredsspsupport, file->EnableCredSSPSupport },
1557 { key_int_enablerdsaadauth, file->EnableRdsAadAuth },
1558 { key_int_remoteapplicationmode, file->RemoteApplicationMode },
1559 { key_int_remoteapplicationexpandcmdline, file->RemoteApplicationExpandCmdLine },
1560 { key_int_remoteapplicationexpandworkingdir, file->RemoteApplicationExpandWorkingDir },
1561 { key_int_disableconnectionsharing, file->DisableConnectionSharing },
1562 { key_int_disableremoteappcapscheck, file->DisableRemoteAppCapsCheck },
1563 { key_int_gatewayusagemethod, file->GatewayUsageMethod },
1564 { key_int_gatewayprofileusagemethod, file->GatewayProfileUsageMethod },
1565 { key_int_gatewaycredentialssource, file->GatewayCredentialsSource },
1566 { key_int_use_redirection_server_name, file->UseRedirectionServerName },
1567 { key_int_rdgiskdcproxy, file->RdgIsKdcProxy },
1568 { key_int_redirectwebauthn, file->RedirectWebauthN }
1571 SSIZE_T totalSize = 0;
1572 for (
size_t x = 0; x < ARRAYSIZE(settings); x++)
1574 const struct intentry_t* cur = &settings[x];
1577 const SSIZE_T res = freerdp_client_write_setting_to_buffer(
1578 &buffer, &size,
"%s:i:%" PRIu32, cur->key, cur->val);
1588static SSIZE_T write_string_parameters(
const rdpFile* file,
char* buffer,
size_t size)
1597 const struct strentry_t settings[] = {
1598 { key_str_username, file->Username },
1599 { key_str_domain, file->Domain },
1600 { key_str_password, file->Password },
1601 { key_str_full_address, file->FullAddress },
1602 { key_str_alternate_full_address, file->AlternateFullAddress },
1603 { key_str_usbdevicestoredirect, file->UsbDevicesToRedirect },
1604 { key_str_camerastoredirect, file->RedirectCameras },
1605 { key_str_loadbalanceinfo, file->LoadBalanceInfo },
1606 { key_str_remoteapplicationname, file->RemoteApplicationName },
1607 { key_str_remoteapplicationicon, file->RemoteApplicationIcon },
1608 { key_str_remoteapplicationprogram, file->RemoteApplicationProgram },
1609 { key_str_remoteapplicationfile, file->RemoteApplicationFile },
1610 { key_str_remoteapplicationguid, file->RemoteApplicationGuid },
1611 { key_str_remoteapplicationcmdline, file->RemoteApplicationCmdLine },
1612 { key_str_alternate_shell, file->AlternateShell },
1613 { key_str_shell_working_directory, file->ShellWorkingDirectory },
1614 { key_str_gatewayhostname, file->GatewayHostname },
1615 { key_str_resourceprovider, file->ResourceProvider },
1616 { key_str_wvd, file->WvdEndpointPool },
1617 { key_str_geo, file->geo },
1618 { key_str_armpath, file->armpath },
1619 { key_str_aadtenantid, file->aadtenantid },
1620 { key_str_diagnosticserviceurl, file->diagnosticserviceurl },
1621 { key_str_hubdiscoverygeourl, file->hubdiscoverygeourl },
1622 { key_str_activityhint, file->activityhint },
1623 { key_str_gatewayaccesstoken, file->GatewayAccessToken },
1624 { key_str_kdcproxyname, file->KdcProxyName },
1625 { key_str_drivestoredirect, file->DrivesToRedirect },
1626 { key_str_devicestoredirect, file->DevicesToRedirect },
1627 { key_str_winposstr, file->WinPosStr },
1628 { key_str_pcb, file->PreconnectionBlob },
1629 { key_str_selectedmonitors, file->SelectedMonitors }
1632 SSIZE_T totalSize = 0;
1633 for (
size_t x = 0; x < ARRAYSIZE(settings); x++)
1635 const struct strentry_t* cur = &settings[x];
1636 if (~(
size_t)(cur->val))
1638 const SSIZE_T res = freerdp_client_write_setting_to_buffer(&buffer, &size,
"%s:s:%s",
1639 cur->key, cur->val);
1649static SSIZE_T write_custom_parameters(
const rdpFile* file,
char* buffer,
size_t size)
1653 SSIZE_T totalSize = 0;
1655 for (
size_t i = 0; i < file->lineCount; ++i)
1658 const rdpFileLine* curLine = &file->lines[i];
1660 if (curLine->flags & RDP_FILE_LINE_FLAG_TYPE_INTEGER)
1661 res = freerdp_client_write_setting_to_buffer(&buffer, &size,
"%s:i:%" PRIu32,
1662 curLine->name, (UINT32)curLine->iValue);
1663 else if (curLine->flags & RDP_FILE_LINE_FLAG_TYPE_STRING)
1664 res = freerdp_client_write_setting_to_buffer(&buffer, &size,
"%s:s:%s", curLine->name,
1674size_t freerdp_client_write_rdp_file_buffer(
const rdpFile* file,
char* buffer,
size_t size)
1676 size_t totalSize = 0;
1682 if ((!buffer || !size) && (buffer || size))
1686 const SSIZE_T intsize = write_int_parameters(file, buffer, size);
1689 totalSize += (size_t)intsize;
1694 const SSIZE_T stringsize = write_string_parameters(file, buffer, size);
1697 totalSize += (size_t)stringsize;
1699 buffer += stringsize;
1702 const SSIZE_T customsize = write_custom_parameters(file, buffer, size);
1705 totalSize += (size_t)customsize;
1709static ADDIN_ARGV* rdp_file_to_args(
const char* channel,
const char* values)
1713 ADDIN_ARGV* args = freerdp_addin_argv_new(0,
nullptr);
1716 if (!freerdp_addin_argv_add_argument(args, channel))
1719 p = CommandLineParseCommaSeparatedValues(values, &count);
1720 for (
size_t x = 0; x < count; x++)
1723 const char* val = p[x];
1724 const size_t len = strlen(val) + 8;
1725 char* str = calloc(len,
sizeof(
char));
1729 (void)_snprintf(str, len,
"device:%s", val);
1730 rc = freerdp_addin_argv_add_argument(args, str);
1735 CommandLineParserFree(p);
1739 CommandLineParserFree(p);
1740 freerdp_addin_argv_free(args);
1744BOOL freerdp_client_populate_settings_from_rdp_file_unchecked(
const rdpFile* file,
1745 rdpSettings* settings)
1747 if (!file || !settings)
1753 if (~file->BandwidthAutoDetect)
1755 if (file->BandwidthAutoDetect != 0)
1757 if ((~file->NetworkAutoDetect) && (file->NetworkAutoDetect == 0))
1760 "Got networkautodetect:i:%" PRIu32
" and bandwidthautodetect:i:%" PRIu32
1761 ". Correcting to networkautodetect:i:1",
1762 file->NetworkAutoDetect, file->BandwidthAutoDetect);
1764 "Add networkautodetect:i:1 to your RDP file to eliminate this warning.");
1768 (file->BandwidthAutoDetect != 0) ||
1769 (file->NetworkAutoDetect != 0)))
1773 if (~file->NetworkAutoDetect)
1775 if (file->NetworkAutoDetect != 0)
1777 if ((~file->BandwidthAutoDetect) && (file->BandwidthAutoDetect == 0))
1780 "Got networkautodetect:i:%" PRIu32
" and bandwidthautodetect:i:%" PRIu32
1781 ". Correcting to bandwidthautodetect:i:1",
1782 file->NetworkAutoDetect, file->BandwidthAutoDetect);
1784 TAG,
"Add bandwidthautodetect:i:1 to your RDP file to eliminate this warning.");
1788 (file->BandwidthAutoDetect != 0) ||
1789 (file->NetworkAutoDetect != 0)))
1793 if (~((
size_t)file->Domain))
1799 if (~((
size_t)file->Username))
1801 char* user =
nullptr;
1802 char* domain =
nullptr;
1804 if (!freerdp_parse_username(file->Username, &user, &domain))
1810 if (!(~((
size_t)file->Domain)) && domain)
1820 if (~((
size_t)file->Password))
1827 const char* address =
nullptr;
1831 if (~((
size_t)file->AlternateFullAddress))
1832 address = file->AlternateFullAddress;
1833 else if (~((
size_t)file->FullAddress))
1834 address = file->FullAddress;
1839 char* host =
nullptr;
1841 if (!freerdp_parse_hostname(address, &host, &port))
1857 if (~file->ServerPort)
1863 if (~file->DesktopSizeId)
1865 switch (file->DesktopSizeId)
1898 WLog_WARN(TAG,
"Unsupported 'desktop size id' value %" PRIu32, file->DesktopSizeId);
1903 if (~file->DesktopWidth)
1909 if (~file->DesktopHeight)
1915 if (~file->SessionBpp)
1921 if (~file->ConnectToConsole)
1924 file->ConnectToConsole != 0))
1928 if (~file->AdministrativeSession)
1931 file->AdministrativeSession != 0))
1935 if (~file->NegotiateSecurityLayer)
1938 file->NegotiateSecurityLayer != 0))
1942 if (~file->EnableCredSSPSupport)
1945 file->EnableCredSSPSupport != 0))
1949 if (~file->EnableRdsAadAuth)
1951 const BOOL val = file->EnableRdsAadAuth != 0;
1956 if (~((
size_t)file->AlternateShell))
1962 if (~((
size_t)file->ShellWorkingDirectory))
1965 FreeRDP_Settings_Keys_String targetId =
1966 (~file->RemoteApplicationMode && file->RemoteApplicationMode != 0)
1967 ? FreeRDP_RemoteApplicationWorkingDir
1968 : FreeRDP_ShellWorkingDirectory;
1974 if (~file->ScreenModeId)
1992 if (~(file->SmartSizing))
2005 if (((~(file->DesktopWidth) && ~(file->DesktopHeight)) || ~(file->DesktopSizeId)) &&
2006 (file->SmartSizing == 1))
2009 file->DesktopWidth))
2012 file->DesktopHeight))
2017 if (~((
size_t)file->LoadBalanceInfo))
2019 const size_t len = strlen(file->LoadBalanceInfo);
2021 file->LoadBalanceInfo, len))
2025 if (~file->AuthenticationLevel)
2042 file->AuthenticationLevel))
2046 if (~file->ConnectionType)
2052 if (~file->AudioMode)
2054 switch (file->AudioMode)
2056 case AUDIO_MODE_REDIRECT:
2062 case AUDIO_MODE_PLAY_ON_SERVER:
2068 case AUDIO_MODE_NONE:
2078 if (~file->AudioCaptureMode)
2084 if (~file->Compression)
2087 file->Compression != 0))
2091 if (~((
size_t)file->GatewayHostname))
2094 char* host =
nullptr;
2096 if (!freerdp_parse_hostname(file->GatewayHostname, &host, &port))
2111 if (~((
size_t)file->ResourceProvider))
2113 if (_stricmp(file->ResourceProvider, str_resourceprovider_arm) == 0)
2120 if (~((
size_t)file->WvdEndpointPool))
2123 file->WvdEndpointPool))
2127 if (~((
size_t)file->geo))
2133 if (~((
size_t)file->armpath))
2139 if (~((
size_t)file->aadtenantid))
2146 if (~((
size_t)file->diagnosticserviceurl))
2149 file->diagnosticserviceurl))
2153 if (~((
size_t)file->hubdiscoverygeourl))
2156 file->hubdiscoverygeourl))
2160 if (~((
size_t)file->activityhint))
2163 file->activityhint))
2167 if (~((
size_t)file->GatewayAccessToken))
2170 file->GatewayAccessToken))
2174 if (~file->GatewayUsageMethod)
2180 if (~file->PromptCredentialOnce)
2183 file->PromptCredentialOnce != 0))
2187 if (~file->PromptForCredentials)
2190 file->PromptForCredentials != 0))
2194 if (~file->RemoteApplicationMode)
2197 file->RemoteApplicationMode != 0))
2201 if (~((
size_t)file->RemoteApplicationProgram))
2204 file->RemoteApplicationProgram))
2208 if (~((
size_t)file->RemoteApplicationName))
2211 file->RemoteApplicationName))
2215 if (~((
size_t)file->RemoteApplicationIcon))
2218 file->RemoteApplicationIcon))
2222 if (~((
size_t)file->RemoteApplicationFile))
2225 file->RemoteApplicationFile))
2229 if (~((
size_t)file->RemoteApplicationGuid))
2232 file->RemoteApplicationGuid))
2236 if (~((
size_t)file->RemoteApplicationCmdLine))
2239 file->RemoteApplicationCmdLine))
2243 if (~file->SpanMonitors)
2249 if (~file->UseMultiMon)
2255 if (~file->AllowFontSmoothing)
2258 file->AllowFontSmoothing != 0))
2262 if (~file->DisableWallpaper)
2265 file->DisableWallpaper != 0))
2269 if (~file->DisableFullWindowDrag)
2272 file->DisableFullWindowDrag != 0))
2276 if (~file->DisableMenuAnims)
2279 file->DisableMenuAnims != 0))
2283 if (~file->DisableThemes)
2289 if (~file->AllowDesktopComposition)
2292 file->AllowDesktopComposition != 0))
2296 if (~file->BitmapCachePersistEnable)
2299 file->BitmapCachePersistEnable != 0))
2303 if (~file->DisableRemoteAppCapsCheck)
2306 file->DisableRemoteAppCapsCheck != 0))
2310 if (~file->AutoReconnectionEnabled)
2313 file->AutoReconnectionEnabled != 0))
2317 if (~file->AutoReconnectMaxRetries)
2320 file->AutoReconnectMaxRetries))
2324 if (~file->RedirectSmartCards)
2327 file->RedirectSmartCards != 0))
2331 if (~file->RedirectWebauthN)
2334 file->RedirectWebauthN != 0))
2338 if (~file->RedirectClipboard)
2341 file->RedirectClipboard != 0))
2345 if (~file->RedirectPrinters)
2348 file->RedirectPrinters != 0))
2352 if (~file->RedirectDrives)
2358 if (~file->RedirectPosDevices)
2361 file->RedirectComPorts != 0) ||
2363 file->RedirectComPorts != 0))
2367 if (~file->RedirectComPorts)
2370 file->RedirectComPorts != 0) ||
2372 file->RedirectComPorts != 0))
2376 if (~file->RedirectLocation && (file->RedirectLocation != 0))
2382 freerdp_client_add_dynamic_channel(settings, count, (
const char*
const*)ptr);
2383 CommandLineParserFree(ptr);
2388 if (~file->RedirectDirectX)
2393 if ((~((
size_t)file->DevicesToRedirect)) && !utils_str_is_empty(file->DevicesToRedirect))
2423 if ((~((
size_t)file->DrivesToRedirect)) && !utils_str_is_empty(file->DrivesToRedirect))
2426 file->DrivesToRedirect))
2430 if ((~((
size_t)file->RedirectCameras)) && !utils_str_is_empty(file->RedirectCameras))
2432#if defined(CHANNEL_RDPECAM_CLIENT)
2436 const char*
const* cc;
2438 ADDIN_ARGV* args = rdp_file_to_args(RDPECAM_DVC_CHANNEL_NAME, file->RedirectCameras);
2443 if (~file->EncodeRedirectedVideoCapture)
2445 char encode[64] = WINPR_C_ARRAY_INIT;
2446 (void)_snprintf(encode,
sizeof(encode),
"encode:%" PRIu32,
2447 file->EncodeRedirectedVideoCapture);
2448 if (!freerdp_addin_argv_add_argument(args, encode))
2451 if (~file->RedirectedVideoCaptureEncodingQuality)
2453 char quality[64] = WINPR_C_ARRAY_INIT;
2454 (void)_snprintf(quality,
sizeof(quality),
"quality:%" PRIu32,
2455 file->RedirectedVideoCaptureEncodingQuality);
2456 if (!freerdp_addin_argv_add_argument(args, quality))
2462 status = freerdp_client_add_dynamic_channel(
2463 settings, WINPR_ASSERTING_INT_CAST(
size_t, args->argc), cnv.cc);
2464 freerdp_addin_argv_free(args);
2470 "This build does not support [MS-RDPECAM] camera redirection channel. Ignoring '%s'",
2471 key_str_camerastoredirect);
2475 if ((~((
size_t)file->UsbDevicesToRedirect)) && !utils_str_is_empty(file->UsbDevicesToRedirect))
2477#ifdef CHANNEL_URBDRC_CLIENT
2481 const char*
const* cc;
2483 ADDIN_ARGV* args = rdp_file_to_args(URBDRC_CHANNEL_NAME, file->UsbDevicesToRedirect);
2487 const BOOL status = freerdp_client_add_dynamic_channel(
2488 settings, WINPR_ASSERTING_INT_CAST(
size_t, args->argc), cnv.cc);
2489 freerdp_addin_argv_free(args);
2494 "This build does not support [MS-RDPEUSB] usb redirection channel. Ignoring '%s'",
2495 key_str_usbdevicestoredirect);
2499 if (~file->KeyboardHook)
2505 if (~(
size_t)file->SelectedMonitors)
2508 char** ptr = CommandLineParseCommaSeparatedValues(file->SelectedMonitors, &count);
2509 UINT32* list =
nullptr;
2513 CommandLineParserFree(ptr);
2517 if (!list && (count > 0))
2519 CommandLineParserFree(ptr);
2522 for (
size_t x = 0; x < count; x++)
2524 unsigned long val = 0;
2526 val = strtoul(ptr[x],
nullptr, 0);
2527 if ((val >= UINT32_MAX) && (errno != 0))
2529 CommandLineParserFree(ptr);
2532 list[x] = (UINT32)val;
2534 CommandLineParserFree(ptr);
2537 if (~file->DynamicResolution)
2539 const BOOL val = file->DynamicResolution != 0;
2546 if (~file->DesktopScaleFactor)
2549 file->DesktopScaleFactor))
2553 if (~file->VideoPlaybackMode)
2555 if (file->VideoPlaybackMode != 0)
2572 if (~((
size_t)file->PreconnectionBlob))
2575 file->PreconnectionBlob) ||
2580 if (~((
size_t)file->KdcProxyName))
2586 if (~file->RdgIsKdcProxy)
2589 file->RdgIsKdcProxy != 0))
2593 if (file->args->argc > 1)
2595 WCHAR* ConnectionFile =
2598 if (freerdp_client_settings_parse_command_line(settings, file->args->argc, file->args->argv,
2601 free(ConnectionFile);
2607 free(ConnectionFile);
2615static BOOL freerdp_apply_connection_type_from_file(
const rdpFile* file, rdpSettings* settings,
2618 struct network_settings
2620 FreeRDP_Settings_Keys_Bool id;
2626 const struct network_settings config[] = { { FreeRDP_DisableWallpaper,
2627 (~file->DisableWallpaper) == 0,
2628 { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
2629 { FreeRDP_AllowFontSmoothing,
2630 (~file->AllowFontSmoothing) == 0,
2631 { FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE } },
2632 { FreeRDP_AllowDesktopComposition,
2633 (~file->AllowDesktopComposition) == 0,
2634 { FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE } },
2635 { FreeRDP_DisableFullWindowDrag,
2636 (~file->DisableFullWindowDrag) == 0,
2637 { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
2638 { FreeRDP_DisableMenuAnims,
2639 (~file->DisableMenuAnims) == 0,
2640 { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
2641 { FreeRDP_DisableThemes,
2642 (~file->DisableThemes) == 0,
2643 { TRUE, FALSE, FALSE, FALSE, FALSE, FALSE,
2648 case CONNECTION_TYPE_INVALID:
2651 case CONNECTION_TYPE_MODEM:
2652 case CONNECTION_TYPE_BROADBAND_LOW:
2653 case CONNECTION_TYPE_BROADBAND_HIGH:
2654 case CONNECTION_TYPE_SATELLITE:
2655 case CONNECTION_TYPE_WAN:
2656 case CONNECTION_TYPE_LAN:
2657 case CONNECTION_TYPE_AUTODETECT:
2660 WLog_WARN(TAG,
"Unknown ConnectionType %" PRIu32
", aborting", type);
2664 for (
size_t x = 0; x < ARRAYSIZE(config); x++)
2666 const struct network_settings* cur = &config[x];
2676static BOOL freerdp_set_connection_type_from_file(
const rdpFile* file, rdpSettings* settings,
2685 case CONNECTION_TYPE_INVALID:
2686 case CONNECTION_TYPE_MODEM:
2687 case CONNECTION_TYPE_BROADBAND_LOW:
2688 case CONNECTION_TYPE_SATELLITE:
2689 case CONNECTION_TYPE_BROADBAND_HIGH:
2690 case CONNECTION_TYPE_WAN:
2691 case CONNECTION_TYPE_LAN:
2692 if (!freerdp_apply_connection_type_from_file(file, settings, type))
2695 case CONNECTION_TYPE_AUTODETECT:
2696 if (!freerdp_apply_connection_type_from_file(file, settings, type))
2710 WLog_WARN(TAG,
"Unknown ConnectionType %" PRIu32
", aborting", type);
2717BOOL freerdp_client_populate_settings_from_rdp_file(
const rdpFile* file, rdpSettings* settings)
2719 if (!freerdp_client_populate_settings_from_rdp_file_unchecked(file, settings))
2723 if ((~file->ConnectionType) == 0)
2726 type = CONNECTION_TYPE_AUTODETECT;
2728 return freerdp_set_connection_type_from_file(file, settings, type);
2731static rdpFileLine* freerdp_client_rdp_file_find_line_by_name(
const rdpFile* file,
const char* name)
2733 BOOL bFound = FALSE;
2734 rdpFileLine* line =
nullptr;
2736 for (
size_t index = 0; index < file->lineCount; index++)
2738 line = &(file->lines[index]);
2740 if (line->flags & RDP_FILE_LINE_FLAG_FORMATTED)
2742 if (_stricmp(name, line->name) == 0)
2750 return (bFound) ? line :
nullptr;
2759int freerdp_client_rdp_file_set_string_option(rdpFile* file,
const char* name,
const char* value)
2761 return freerdp_client_rdp_file_set_string(file, name, value);
2764const char* freerdp_client_rdp_file_get_string_option(
const rdpFile* file,
const char* name)
2766 LPSTR* value =
nullptr;
2767 rdpFileLine* line =
nullptr;
2769 rdpFile* wfile = WINPR_CAST_CONST_PTR_AWAY(file, rdpFile*);
2770 if (freerdp_client_rdp_file_find_string_entry(wfile, name, &value, &line))
2772 if (value && ~(
size_t)(*value))
2775 return line->sValue;
2781int freerdp_client_rdp_file_set_integer_option(rdpFile* file,
const char* name,
int value)
2783 return freerdp_client_rdp_file_set_integer(file, name, value);
2786int freerdp_client_rdp_file_get_integer_option(
const rdpFile* file,
const char* name)
2788 DWORD* value =
nullptr;
2789 rdpFileLine* line =
nullptr;
2791 rdpFile* wfile = WINPR_CAST_CONST_PTR_AWAY(file, rdpFile*);
2792 if (freerdp_client_rdp_file_find_integer_entry(wfile, name, &value, &line))
2794 if (value && ~(*value))
2795 return WINPR_ASSERTING_INT_CAST(
int, *value);
2797 return (
int)line->iValue;
2803static void freerdp_client_file_string_check_free(LPSTR str)
2809rdpFile* freerdp_client_rdp_file_new(
void)
2811 return freerdp_client_rdp_file_new_ex(0);
2814rdpFile* freerdp_client_rdp_file_new_ex(DWORD flags)
2816 rdpFile* file = (rdpFile*)calloc(1,
sizeof(rdpFile));
2821 file->flags = flags;
2823 FillMemory(file,
sizeof(rdpFile), 0xFF);
2824 file->lines =
nullptr;
2825 file->lineCount = 0;
2826 file->lineSize = 32;
2827 file->GatewayProfileUsageMethod = 1;
2828 file->lines = (rdpFileLine*)calloc(file->lineSize,
sizeof(rdpFileLine));
2830 file->args = freerdp_addin_argv_new(0,
nullptr);
2831 if (!file->lines || !file->args)
2834 if (!freerdp_client_add_option(file,
"freerdp"))
2839 WINPR_PRAGMA_DIAG_PUSH
2840 WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
2841 freerdp_client_rdp_file_free(file);
2842 WINPR_PRAGMA_DIAG_POP
2845void freerdp_client_rdp_file_free(rdpFile* file)
2849 if (file->lineCount)
2851 for (
size_t i = 0; i < file->lineCount; i++)
2853 free(file->lines[i].name);
2854 free(file->lines[i].sValue);
2859 freerdp_addin_argv_free(file->args);
2861 freerdp_client_file_string_check_free(file->Username);
2862 freerdp_client_file_string_check_free(file->Domain);
2863 freerdp_client_file_string_check_free(file->Password);
2864 freerdp_client_file_string_check_free(file->FullAddress);
2865 freerdp_client_file_string_check_free(file->AlternateFullAddress);
2866 freerdp_client_file_string_check_free(file->UsbDevicesToRedirect);
2867 freerdp_client_file_string_check_free(file->RedirectCameras);
2868 freerdp_client_file_string_check_free(file->SelectedMonitors);
2869 freerdp_client_file_string_check_free(file->LoadBalanceInfo);
2870 freerdp_client_file_string_check_free(file->RemoteApplicationName);
2871 freerdp_client_file_string_check_free(file->RemoteApplicationIcon);
2872 freerdp_client_file_string_check_free(file->RemoteApplicationProgram);
2873 freerdp_client_file_string_check_free(file->RemoteApplicationFile);
2874 freerdp_client_file_string_check_free(file->RemoteApplicationGuid);
2875 freerdp_client_file_string_check_free(file->RemoteApplicationCmdLine);
2876 freerdp_client_file_string_check_free(file->AlternateShell);
2877 freerdp_client_file_string_check_free(file->ShellWorkingDirectory);
2878 freerdp_client_file_string_check_free(file->GatewayHostname);
2879 freerdp_client_file_string_check_free(file->GatewayAccessToken);
2880 freerdp_client_file_string_check_free(file->KdcProxyName);
2881 freerdp_client_file_string_check_free(file->DrivesToRedirect);
2882 freerdp_client_file_string_check_free(file->DevicesToRedirect);
2883 freerdp_client_file_string_check_free(file->WinPosStr);
2884 freerdp_client_file_string_check_free(file->ResourceProvider);
2885 freerdp_client_file_string_check_free(file->WvdEndpointPool);
2886 freerdp_client_file_string_check_free(file->geo);
2887 freerdp_client_file_string_check_free(file->armpath);
2888 freerdp_client_file_string_check_free(file->aadtenantid);
2889 freerdp_client_file_string_check_free(file->diagnosticserviceurl);
2890 freerdp_client_file_string_check_free(file->hubdiscoverygeourl);
2891 freerdp_client_file_string_check_free(file->activityhint);
2896void freerdp_client_rdp_file_set_callback_context(rdpFile* file,
void* context)
2898 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.