20#include <freerdp/config.h>
26#include <winpr/string.h>
27#include <winpr/file.h>
28#include <winpr/cast.h>
30#include <freerdp/client.h>
31#include <freerdp/client/file.h>
32#include <freerdp/client/cmdline.h>
34#include <freerdp/channels/urbdrc.h>
35#include <freerdp/channels/rdpecam.h>
36#include <freerdp/channels/location.h>
51#include <winpr/wtypes.h>
53#include <winpr/path.h>
54#include <freerdp/log.h>
55#define TAG CLIENT_TAG("common")
59static const BYTE BOM_UTF16_LE[2] = { 0xFF, 0xFE };
63#define RDP_FILE_LINE_FLAG_FORMATTED 0x00000001
65#define RDP_FILE_LINE_FLAG_TYPE_STRING 0x00000010
66#define RDP_FILE_LINE_FLAG_TYPE_INTEGER 0x00000020
81typedef struct rdp_file_line rdpFileLine;
86 LPSTR SelectedMonitors;
87 DWORD MaximizeToCurrentDisplays;
88 DWORD SingleMonInWindowedMode;
92 DWORD DynamicResolution;
93 DWORD EnableSuperSpan;
94 DWORD SuperSpanAccelerationFactor;
100 DWORD DesktopScaleFactor;
104 DWORD DisableCtrlAltDel;
107 DWORD AudioQualityMode;
108 DWORD AudioCaptureMode;
109 DWORD EncodeRedirectedVideoCapture;
110 DWORD RedirectedVideoCaptureEncodingQuality;
111 DWORD VideoPlaybackMode;
113 DWORD ConnectionType;
115 DWORD NetworkAutoDetect;
116 DWORD BandwidthAutoDetect;
118 DWORD PinConnectionBar;
119 DWORD DisplayConnectionBar;
122 DWORD EnableWorkspaceReconnect;
124 DWORD DisableWallpaper;
125 DWORD AllowFontSmoothing;
126 DWORD AllowDesktopComposition;
127 DWORD DisableFullWindowDrag;
128 DWORD DisableMenuAnims;
130 DWORD DisableCursorSetting;
132 DWORD BitmapCacheSize;
133 DWORD BitmapCachePersistEnable;
143 LPSTR AlternateFullAddress;
145 LPSTR UsbDevicesToRedirect;
146 DWORD RedirectDrives;
147 DWORD RedirectPrinters;
148 DWORD RedirectComPorts;
149 DWORD RedirectLocation;
150 DWORD RedirectSmartCards;
151 DWORD RedirectWebauthN;
152 LPSTR RedirectCameras;
153 DWORD RedirectClipboard;
154 DWORD RedirectPosDevices;
155 DWORD RedirectDirectX;
156 DWORD DisablePrinterRedirection;
157 DWORD DisableClipboardRedirection;
159 DWORD ConnectToConsole;
160 DWORD AdministrativeSession;
161 DWORD AutoReconnectionEnabled;
162 DWORD AutoReconnectMaxRetries;
165 DWORD AuthenticationLevel;
166 DWORD PromptCredentialOnce;
167 DWORD PromptForCredentials;
168 DWORD NegotiateSecurityLayer;
169 DWORD EnableCredSSPSupport;
170 DWORD EnableRdsAadAuth;
172 DWORD RemoteApplicationMode;
173 LPSTR LoadBalanceInfo;
175 LPSTR RemoteApplicationName;
176 LPSTR RemoteApplicationIcon;
177 LPSTR RemoteApplicationProgram;
178 LPSTR RemoteApplicationFile;
179 LPSTR RemoteApplicationGuid;
180 LPSTR RemoteApplicationCmdLine;
181 DWORD RemoteApplicationExpandCmdLine;
182 DWORD RemoteApplicationExpandWorkingDir;
183 DWORD DisableConnectionSharing;
184 DWORD DisableRemoteAppCapsCheck;
186 LPSTR AlternateShell;
187 LPSTR ShellWorkingDirectory;
189 LPSTR GatewayHostname;
190 DWORD GatewayUsageMethod;
191 DWORD GatewayProfileUsageMethod;
192 DWORD GatewayCredentialsSource;
194 LPSTR ResourceProvider;
196 LPSTR WvdEndpointPool;
200 LPSTR diagnosticserviceurl;
201 LPSTR hubdiscoverygeourl;
204 DWORD UseRedirectionServerName;
206 LPSTR GatewayAccessToken;
208 LPSTR DrivesToRedirect;
209 LPSTR DevicesToRedirect;
212 LPSTR PreconnectionBlob;
229static const char key_str_username[] =
"username";
230static const char key_str_domain[] =
"domain";
231static const char key_str_password[] =
"password";
232static const char key_str_full_address[] =
"full address";
233static const char key_str_alternate_full_address[] =
"alternate full address";
234static const char key_str_usbdevicestoredirect[] =
"usbdevicestoredirect";
235static const char key_str_camerastoredirect[] =
"camerastoredirect";
236static const char key_str_loadbalanceinfo[] =
"loadbalanceinfo";
237static const char key_str_remoteapplicationname[] =
"remoteapplicationname";
238static const char key_str_remoteapplicationicon[] =
"remoteapplicationicon";
239static const char key_str_remoteapplicationprogram[] =
"remoteapplicationprogram";
240static const char key_str_remoteapplicationfile[] =
"remoteapplicationfile";
241static const char key_str_remoteapplicationguid[] =
"remoteapplicationguid";
242static const char key_str_remoteapplicationcmdline[] =
"remoteapplicationcmdline";
243static const char key_str_alternate_shell[] =
"alternate shell";
244static const char key_str_shell_working_directory[] =
"shell working directory";
245static const char key_str_gatewayhostname[] =
"gatewayhostname";
246static const char key_str_gatewayaccesstoken[] =
"gatewayaccesstoken";
247static const char key_str_resourceprovider[] =
"resourceprovider";
248static const char str_resourceprovider_arm[] =
"arm";
249static const char key_str_kdcproxyname[] =
"kdcproxyname";
250static const char key_str_drivestoredirect[] =
"drivestoredirect";
251static const char key_str_devicestoredirect[] =
"devicestoredirect";
252static const char key_str_winposstr[] =
"winposstr";
253static const char key_str_pcb[] =
"pcb";
254static const char key_str_selectedmonitors[] =
"selectedmonitors";
256static const char key_str_wvd[] =
"wvd endpoint pool";
257static const char key_str_geo[] =
"geo";
258static const char key_str_armpath[] =
"armpath";
259static const char key_str_aadtenantid[] =
"aadtenantid";
261static const char key_str_diagnosticserviceurl[] =
"diagnosticserviceurl";
262static const char key_str_hubdiscoverygeourl[] =
"hubdiscoverygeourl";
264static const char key_str_activityhint[] =
"activityhint";
266static const char key_int_rdgiskdcproxy[] =
"rdgiskdcproxy";
267static const char key_int_use_redirection_server_name[] =
"use redirection server name";
268static const char key_int_gatewaycredentialssource[] =
"gatewaycredentialssource";
269static const char key_int_gatewayprofileusagemethod[] =
"gatewayprofileusagemethod";
270static const char key_int_gatewayusagemethod[] =
"gatewayusagemethod";
271static const char key_int_disableremoteappcapscheck[] =
"disableremoteappcapscheck";
272static const char key_int_disableconnectionsharing[] =
"disableconnectionsharing";
273static const char key_int_remoteapplicationexpandworkingdir[] =
"remoteapplicationexpandworkingdir";
274static const char key_int_remoteapplicationexpandcmdline[] =
"remoteapplicationexpandcmdline";
275static const char key_int_remoteapplicationmode[] =
"remoteapplicationmode";
276static const char key_int_enablecredsspsupport[] =
"enablecredsspsupport";
277static const char key_int_enablerdsaadauth[] =
"enablerdsaadauth";
278static const char key_int_negotiate_security_layer[] =
"negotiate security layer";
279static const char key_int_prompt_for_credentials[] =
"prompt for credentials";
280static const char key_int_promptcredentialonce[] =
"promptcredentialonce";
281static const char key_int_authentication_level[] =
"authentication level";
282static const char key_int_public_mode[] =
"public mode";
283static const char key_int_autoreconnect_max_retries[] =
"autoreconnect max retries";
284static const char key_int_autoreconnection_enabled[] =
"autoreconnection enabled";
285static const char key_int_administrative_session[] =
"administrative session";
286static const char key_int_connect_to_console[] =
"connect to console";
287static const char key_int_disableclipboardredirection[] =
"disableclipboardredirection";
288static const char key_int_disableprinterredirection[] =
"disableprinterredirection";
289static const char key_int_redirectdirectx[] =
"redirectdirectx";
290static const char key_int_redirectposdevices[] =
"redirectposdevices";
291static const char key_int_redirectclipboard[] =
"redirectclipboard";
292static const char key_int_redirectsmartcards[] =
"redirectsmartcards";
293static const char key_int_redirectcomports[] =
"redirectcomports";
294static const char key_int_redirectlocation[] =
"redirectlocation";
295static const char key_int_redirectprinters[] =
"redirectprinters";
296static const char key_int_redirectdrives[] =
"redirectdrives";
297static const char key_int_server_port[] =
"server port";
298static const char key_int_bitmapcachepersistenable[] =
"bitmapcachepersistenable";
299static const char key_int_bitmapcachesize[] =
"bitmapcachesize";
300static const char key_int_disable_cursor_setting[] =
"disable cursor setting";
301static const char key_int_disable_themes[] =
"disable themes";
302static const char key_int_disable_menu_anims[] =
"disable menu anims";
303static const char key_int_disable_full_window_drag[] =
"disable full window drag";
304static const char key_int_allow_desktop_composition[] =
"allow desktop composition";
305static const char key_int_allow_font_smoothing[] =
"allow font smoothing";
306static const char key_int_disable_wallpaper[] =
"disable wallpaper";
307static const char key_int_enableworkspacereconnect[] =
"enableworkspacereconnect";
308static const char key_int_workspaceid[] =
"workspaceid";
309static const char key_int_displayconnectionbar[] =
"displayconnectionbar";
310static const char key_int_pinconnectionbar[] =
"pinconnectionbar";
311static const char key_int_bandwidthautodetect[] =
"bandwidthautodetect";
312static const char key_int_networkautodetect[] =
"networkautodetect";
313static const char key_int_connection_type[] =
"connection type";
314static const char key_int_videoplaybackmode[] =
"videoplaybackmode";
315static const char key_int_redirected_video_capture_encoding_quality[] =
316 "redirected video capture encoding quality";
317static const char key_int_encode_redirected_video_capture[] =
"encode redirected video capture";
318static const char key_int_audiocapturemode[] =
"audiocapturemode";
319static const char key_int_audioqualitymode[] =
"audioqualitymode";
320static const char key_int_audiomode[] =
"audiomode";
321static const char key_int_disable_ctrl_alt_del[] =
"disable ctrl+alt+del";
322static const char key_int_keyboardhook[] =
"keyboardhook";
323static const char key_int_compression[] =
"compression";
324static const char key_int_desktopscalefactor[] =
"desktopscalefactor";
325static const char key_int_session_bpp[] =
"session bpp";
326static const char key_int_desktop_size_id[] =
"desktop size id";
327static const char key_int_desktopheight[] =
"desktopheight";
328static const char key_int_desktopwidth[] =
"desktopwidth";
329static const char key_int_superpanaccelerationfactor[] =
"superpanaccelerationfactor";
330static const char key_int_enablesuperpan[] =
"enablesuperpan";
331static const char key_int_dynamic_resolution[] =
"dynamic resolution";
332static const char key_int_smart_sizing[] =
"smart sizing";
333static const char key_int_span_monitors[] =
"span monitors";
334static const char key_int_screen_mode_id[] =
"screen mode id";
335static const char key_int_singlemoninwindowedmode[] =
"singlemoninwindowedmode";
336static const char key_int_maximizetocurrentdisplays[] =
"maximizetocurrentdisplays";
337static const char key_int_use_multimon[] =
"use multimon";
338static const char key_int_redirectwebauthn[] =
"redirectwebauthn";
340static BOOL utils_str_is_empty(
const char* str)
344 if (strlen(str) == 0)
349static SSIZE_T freerdp_client_rdp_file_add_line(rdpFile* file);
350static rdpFileLine* freerdp_client_rdp_file_find_line_by_name(
const rdpFile* file,
352static void freerdp_client_file_string_check_free(LPSTR str);
354static BOOL freerdp_client_rdp_file_find_integer_entry(rdpFile* file,
const char* name,
355 DWORD** outValue, rdpFileLine** outLine)
359 WINPR_ASSERT(outValue);
360 WINPR_ASSERT(outLine);
365 if (_stricmp(name, key_int_use_multimon) == 0)
366 *outValue = &file->UseMultiMon;
367 else if (_stricmp(name, key_int_maximizetocurrentdisplays) == 0)
368 *outValue = &file->MaximizeToCurrentDisplays;
369 else if (_stricmp(name, key_int_singlemoninwindowedmode) == 0)
370 *outValue = &file->SingleMonInWindowedMode;
371 else if (_stricmp(name, key_int_screen_mode_id) == 0)
372 *outValue = &file->ScreenModeId;
373 else if (_stricmp(name, key_int_span_monitors) == 0)
374 *outValue = &file->SpanMonitors;
375 else if (_stricmp(name, key_int_smart_sizing) == 0)
376 *outValue = &file->SmartSizing;
377 else if (_stricmp(name, key_int_dynamic_resolution) == 0)
378 *outValue = &file->DynamicResolution;
379 else if (_stricmp(name, key_int_enablesuperpan) == 0)
380 *outValue = &file->EnableSuperSpan;
381 else if (_stricmp(name, key_int_superpanaccelerationfactor) == 0)
382 *outValue = &file->SuperSpanAccelerationFactor;
383 else if (_stricmp(name, key_int_desktopwidth) == 0)
384 *outValue = &file->DesktopWidth;
385 else if (_stricmp(name, key_int_desktopheight) == 0)
386 *outValue = &file->DesktopHeight;
387 else if (_stricmp(name, key_int_desktop_size_id) == 0)
388 *outValue = &file->DesktopSizeId;
389 else if (_stricmp(name, key_int_session_bpp) == 0)
390 *outValue = &file->SessionBpp;
391 else if (_stricmp(name, key_int_desktopscalefactor) == 0)
392 *outValue = &file->DesktopScaleFactor;
393 else if (_stricmp(name, key_int_compression) == 0)
394 *outValue = &file->Compression;
395 else if (_stricmp(name, key_int_keyboardhook) == 0)
396 *outValue = &file->KeyboardHook;
397 else if (_stricmp(name, key_int_disable_ctrl_alt_del) == 0)
398 *outValue = &file->DisableCtrlAltDel;
399 else if (_stricmp(name, key_int_audiomode) == 0)
400 *outValue = &file->AudioMode;
401 else if (_stricmp(name, key_int_audioqualitymode) == 0)
402 *outValue = &file->AudioQualityMode;
403 else if (_stricmp(name, key_int_audiocapturemode) == 0)
404 *outValue = &file->AudioCaptureMode;
405 else if (_stricmp(name, key_int_encode_redirected_video_capture) == 0)
406 *outValue = &file->EncodeRedirectedVideoCapture;
407 else if (_stricmp(name, key_int_redirected_video_capture_encoding_quality) == 0)
408 *outValue = &file->RedirectedVideoCaptureEncodingQuality;
409 else if (_stricmp(name, key_int_videoplaybackmode) == 0)
410 *outValue = &file->VideoPlaybackMode;
411 else if (_stricmp(name, key_int_connection_type) == 0)
412 *outValue = &file->ConnectionType;
413 else if (_stricmp(name, key_int_networkautodetect) == 0)
414 *outValue = &file->NetworkAutoDetect;
415 else if (_stricmp(name, key_int_bandwidthautodetect) == 0)
416 *outValue = &file->BandwidthAutoDetect;
417 else if (_stricmp(name, key_int_pinconnectionbar) == 0)
418 *outValue = &file->PinConnectionBar;
419 else if (_stricmp(name, key_int_displayconnectionbar) == 0)
420 *outValue = &file->DisplayConnectionBar;
421 else if (_stricmp(name, key_int_workspaceid) == 0)
422 *outValue = &file->WorkspaceId;
423 else if (_stricmp(name, key_int_enableworkspacereconnect) == 0)
424 *outValue = &file->EnableWorkspaceReconnect;
425 else if (_stricmp(name, key_int_disable_wallpaper) == 0)
426 *outValue = &file->DisableWallpaper;
427 else if (_stricmp(name, key_int_allow_font_smoothing) == 0)
428 *outValue = &file->AllowFontSmoothing;
429 else if (_stricmp(name, key_int_allow_desktop_composition) == 0)
430 *outValue = &file->AllowDesktopComposition;
431 else if (_stricmp(name, key_int_disable_full_window_drag) == 0)
432 *outValue = &file->DisableFullWindowDrag;
433 else if (_stricmp(name, key_int_disable_menu_anims) == 0)
434 *outValue = &file->DisableMenuAnims;
435 else if (_stricmp(name, key_int_disable_themes) == 0)
436 *outValue = &file->DisableThemes;
437 else if (_stricmp(name, key_int_disable_cursor_setting) == 0)
438 *outValue = &file->DisableCursorSetting;
439 else if (_stricmp(name, key_int_bitmapcachesize) == 0)
440 *outValue = &file->BitmapCacheSize;
441 else if (_stricmp(name, key_int_bitmapcachepersistenable) == 0)
442 *outValue = &file->BitmapCachePersistEnable;
443 else if (_stricmp(name, key_int_server_port) == 0)
444 *outValue = &file->ServerPort;
445 else if (_stricmp(name, key_int_redirectdrives) == 0)
446 *outValue = &file->RedirectDrives;
447 else if (_stricmp(name, key_int_redirectprinters) == 0)
448 *outValue = &file->RedirectPrinters;
449 else if (_stricmp(name, key_int_redirectcomports) == 0)
450 *outValue = &file->RedirectComPorts;
451 else if (_stricmp(name, key_int_redirectlocation) == 0)
452 *outValue = &file->RedirectLocation;
453 else if (_stricmp(name, key_int_redirectsmartcards) == 0)
454 *outValue = &file->RedirectSmartCards;
455 else if (_stricmp(name, key_int_redirectclipboard) == 0)
456 *outValue = &file->RedirectClipboard;
457 else if (_stricmp(name, key_int_redirectposdevices) == 0)
458 *outValue = &file->RedirectPosDevices;
459 else if (_stricmp(name, key_int_redirectdirectx) == 0)
460 *outValue = &file->RedirectDirectX;
461 else if (_stricmp(name, key_int_disableprinterredirection) == 0)
462 *outValue = &file->DisablePrinterRedirection;
463 else if (_stricmp(name, key_int_disableclipboardredirection) == 0)
464 *outValue = &file->DisableClipboardRedirection;
465 else if (_stricmp(name, key_int_connect_to_console) == 0)
466 *outValue = &file->ConnectToConsole;
467 else if (_stricmp(name, key_int_administrative_session) == 0)
468 *outValue = &file->AdministrativeSession;
469 else if (_stricmp(name, key_int_autoreconnection_enabled) == 0)
470 *outValue = &file->AutoReconnectionEnabled;
471 else if (_stricmp(name, key_int_autoreconnect_max_retries) == 0)
472 *outValue = &file->AutoReconnectMaxRetries;
473 else if (_stricmp(name, key_int_public_mode) == 0)
474 *outValue = &file->PublicMode;
475 else if (_stricmp(name, key_int_authentication_level) == 0)
476 *outValue = &file->AuthenticationLevel;
477 else if (_stricmp(name, key_int_promptcredentialonce) == 0)
478 *outValue = &file->PromptCredentialOnce;
479 else if ((_stricmp(name, key_int_prompt_for_credentials) == 0))
480 *outValue = &file->PromptForCredentials;
481 else if (_stricmp(name, key_int_negotiate_security_layer) == 0)
482 *outValue = &file->NegotiateSecurityLayer;
483 else if (_stricmp(name, key_int_enablecredsspsupport) == 0)
484 *outValue = &file->EnableCredSSPSupport;
485 else if (_stricmp(name, key_int_enablerdsaadauth) == 0)
486 *outValue = &file->EnableRdsAadAuth;
487 else if (_stricmp(name, key_int_remoteapplicationmode) == 0)
488 *outValue = &file->RemoteApplicationMode;
489 else if (_stricmp(name, key_int_remoteapplicationexpandcmdline) == 0)
490 *outValue = &file->RemoteApplicationExpandCmdLine;
491 else if (_stricmp(name, key_int_remoteapplicationexpandworkingdir) == 0)
492 *outValue = &file->RemoteApplicationExpandWorkingDir;
493 else if (_stricmp(name, key_int_disableconnectionsharing) == 0)
494 *outValue = &file->DisableConnectionSharing;
495 else if (_stricmp(name, key_int_disableremoteappcapscheck) == 0)
496 *outValue = &file->DisableRemoteAppCapsCheck;
497 else if (_stricmp(name, key_int_gatewayusagemethod) == 0)
498 *outValue = &file->GatewayUsageMethod;
499 else if (_stricmp(name, key_int_gatewayprofileusagemethod) == 0)
500 *outValue = &file->GatewayProfileUsageMethod;
501 else if (_stricmp(name, key_int_gatewaycredentialssource) == 0)
502 *outValue = &file->GatewayCredentialsSource;
503 else if (_stricmp(name, key_int_use_redirection_server_name) == 0)
504 *outValue = &file->UseRedirectionServerName;
505 else if (_stricmp(name, key_int_rdgiskdcproxy) == 0)
506 *outValue = &file->RdgIsKdcProxy;
507 else if (_stricmp(name, key_int_redirectwebauthn) == 0)
508 *outValue = &file->RedirectWebauthN;
511 rdpFileLine* line = freerdp_client_rdp_file_find_line_by_name(file, name);
514 if (!(line->flags & RDP_FILE_LINE_FLAG_TYPE_INTEGER))
523static BOOL freerdp_client_rdp_file_find_string_entry(rdpFile* file,
const char* name,
524 LPSTR** outValue, rdpFileLine** outLine)
528 WINPR_ASSERT(outValue);
529 WINPR_ASSERT(outLine);
534 if (_stricmp(name, key_str_username) == 0)
535 *outValue = &file->Username;
536 else if (_stricmp(name, key_str_domain) == 0)
537 *outValue = &file->Domain;
538 else if (_stricmp(name, key_str_password) == 0)
539 *outValue = &file->Password;
540 else if (_stricmp(name, key_str_full_address) == 0)
541 *outValue = &file->FullAddress;
542 else if (_stricmp(name, key_str_alternate_full_address) == 0)
543 *outValue = &file->AlternateFullAddress;
544 else if (_stricmp(name, key_str_usbdevicestoredirect) == 0)
545 *outValue = &file->UsbDevicesToRedirect;
546 else if (_stricmp(name, key_str_camerastoredirect) == 0)
547 *outValue = &file->RedirectCameras;
548 else if (_stricmp(name, key_str_loadbalanceinfo) == 0)
549 *outValue = &file->LoadBalanceInfo;
550 else if (_stricmp(name, key_str_remoteapplicationname) == 0)
551 *outValue = &file->RemoteApplicationName;
552 else if (_stricmp(name, key_str_remoteapplicationicon) == 0)
553 *outValue = &file->RemoteApplicationIcon;
554 else if (_stricmp(name, key_str_remoteapplicationprogram) == 0)
555 *outValue = &file->RemoteApplicationProgram;
556 else if (_stricmp(name, key_str_remoteapplicationfile) == 0)
557 *outValue = &file->RemoteApplicationFile;
558 else if (_stricmp(name, key_str_remoteapplicationguid) == 0)
559 *outValue = &file->RemoteApplicationGuid;
560 else if (_stricmp(name, key_str_remoteapplicationcmdline) == 0)
561 *outValue = &file->RemoteApplicationCmdLine;
562 else if (_stricmp(name, key_str_alternate_shell) == 0)
563 *outValue = &file->AlternateShell;
564 else if (_stricmp(name, key_str_shell_working_directory) == 0)
565 *outValue = &file->ShellWorkingDirectory;
566 else if (_stricmp(name, key_str_gatewayhostname) == 0)
567 *outValue = &file->GatewayHostname;
568 else if (_stricmp(name, key_str_resourceprovider) == 0)
569 *outValue = &file->ResourceProvider;
570 else if (_stricmp(name, key_str_wvd) == 0)
571 *outValue = &file->WvdEndpointPool;
572 else if (_stricmp(name, key_str_geo) == 0)
573 *outValue = &file->geo;
574 else if (_stricmp(name, key_str_armpath) == 0)
575 *outValue = &file->armpath;
576 else if (_stricmp(name, key_str_aadtenantid) == 0)
577 *outValue = &file->aadtenantid;
578 else if (_stricmp(name, key_str_diagnosticserviceurl) == 0)
579 *outValue = &file->diagnosticserviceurl;
580 else if (_stricmp(name, key_str_hubdiscoverygeourl) == 0)
581 *outValue = &file->hubdiscoverygeourl;
582 else if (_stricmp(name, key_str_activityhint) == 0)
583 *outValue = &file->activityhint;
584 else if (_stricmp(name, key_str_gatewayaccesstoken) == 0)
585 *outValue = &file->GatewayAccessToken;
586 else if (_stricmp(name, key_str_kdcproxyname) == 0)
587 *outValue = &file->KdcProxyName;
588 else if (_stricmp(name, key_str_drivestoredirect) == 0)
589 *outValue = &file->DrivesToRedirect;
590 else if (_stricmp(name, key_str_devicestoredirect) == 0)
591 *outValue = &file->DevicesToRedirect;
592 else if (_stricmp(name, key_str_winposstr) == 0)
593 *outValue = &file->WinPosStr;
594 else if (_stricmp(name, key_str_pcb) == 0)
595 *outValue = &file->PreconnectionBlob;
596 else if (_stricmp(name, key_str_selectedmonitors) == 0)
597 *outValue = &file->SelectedMonitors;
600 rdpFileLine* line = freerdp_client_rdp_file_find_line_by_name(file, name);
603 if (!(line->flags & RDP_FILE_LINE_FLAG_TYPE_STRING))
618static BOOL freerdp_client_rdp_file_set_integer(rdpFile* file,
const char* name,
long value)
620 DWORD* targetValue =
nullptr;
621 rdpFileLine* line =
nullptr;
622#ifdef DEBUG_CLIENT_FILE
623 WLog_DBG(TAG,
"%s:i:%ld", name, value);
629 if (!freerdp_client_rdp_file_find_integer_entry(file, name, &targetValue, &line))
631 SSIZE_T index = freerdp_client_rdp_file_add_line(file);
634 line = &file->lines[index];
639 *targetValue = (DWORD)value;
646 line->name = _strdup(name);
650 line->name =
nullptr;
654 line->iValue = value;
655 line->flags = RDP_FILE_LINE_FLAG_FORMATTED;
656 line->flags |= RDP_FILE_LINE_FLAG_TYPE_INTEGER;
657 line->valueLength = 0;
664static BOOL freerdp_client_parse_rdp_file_integer(rdpFile* file,
const char* name,
667 char* endptr =
nullptr;
670 ivalue = strtol(value, &endptr, 0);
672 if ((endptr ==
nullptr) || (errno != 0) || (endptr == value) || (ivalue > INT32_MAX) ||
673 (ivalue < INT32_MIN))
675 if (file->flags & RDP_FILE_FLAG_PARSE_INT_RELAXED)
677 WLog_WARN(TAG,
"Integer option %s has invalid value %s, using default", name, value);
682 WLog_ERR(TAG,
"Failed to convert RDP file integer option %s [value=%s]", name, value);
687 return freerdp_client_rdp_file_set_integer(file, name, ivalue);
698static BOOL freerdp_client_rdp_file_set_string(rdpFile* file,
const char* name,
const char* value)
700 LPSTR* targetValue =
nullptr;
701 rdpFileLine* line =
nullptr;
702#ifdef DEBUG_CLIENT_FILE
703 WLog_DBG(TAG,
"%s:s:%s", name, value);
709 if (!freerdp_client_rdp_file_find_string_entry(file, name, &targetValue, &line))
711 SSIZE_T index = freerdp_client_rdp_file_add_line(file);
714 line = &file->lines[index];
719 if ((uintptr_t)(*targetValue) != UINTPTR_MAX)
722 *targetValue = _strdup(value);
723 return ((*targetValue) !=
nullptr);
730 line->name = _strdup(name);
731 line->sValue = _strdup(value);
732 if (!line->name || !line->sValue)
736 line->name =
nullptr;
737 line->sValue =
nullptr;
741 line->flags = RDP_FILE_LINE_FLAG_FORMATTED;
742 line->flags |= RDP_FILE_LINE_FLAG_TYPE_STRING;
743 line->valueLength = 0;
750static BOOL freerdp_client_add_option(rdpFile* file,
const char* option)
752 return freerdp_addin_argv_add_argument(file->args, option);
755static SSIZE_T freerdp_client_rdp_file_add_line(rdpFile* file)
757 SSIZE_T index = (SSIZE_T)file->lineCount;
759 while ((file->lineCount + 1) > file->lineSize)
761 size_t new_size = file->lineCount + 2048;
762 rdpFileLine* new_line = (rdpFileLine*)realloc(file->lines, new_size *
sizeof(rdpFileLine));
767 file->lines = new_line;
768 file->lineSize = new_size;
771 ZeroMemory(&(file->lines[file->lineCount]),
sizeof(rdpFileLine));
772 file->lines[file->lineCount].index = (size_t)index;
777static BOOL freerdp_client_parse_rdp_file_string(rdpFile* file,
char* name,
char* value)
779 return freerdp_client_rdp_file_set_string(file, name, value);
782static BOOL freerdp_client_parse_rdp_file_option(rdpFile* file,
const char* option)
784 return freerdp_client_add_option(file, option);
787BOOL freerdp_client_parse_rdp_file_buffer(rdpFile* file,
const BYTE* buffer,
size_t size)
789 return freerdp_client_parse_rdp_file_buffer_ex(file, buffer, size,
nullptr);
792static BOOL trim(
char** strptr)
794 char* start =
nullptr;
798 start = str = *strptr;
801 if (!(~((
size_t)str)))
803 end = str + strlen(str) - 1;
805 while (isspace(*str))
808 while ((end > str) && isspace(*end))
815 *strptr = _strdup(str);
817 return *strptr !=
nullptr;
823static BOOL trim_strings(rdpFile* file)
825 if (!trim(&file->Username))
827 if (!trim(&file->Domain))
829 if (!trim(&file->AlternateFullAddress))
831 if (!trim(&file->FullAddress))
833 if (!trim(&file->UsbDevicesToRedirect))
835 if (!trim(&file->RedirectCameras))
837 if (!trim(&file->LoadBalanceInfo))
839 if (!trim(&file->GatewayHostname))
841 if (!trim(&file->GatewayAccessToken))
843 if (!trim(&file->RemoteApplicationName))
845 if (!trim(&file->RemoteApplicationIcon))
847 if (!trim(&file->RemoteApplicationProgram))
849 if (!trim(&file->RemoteApplicationFile))
851 if (!trim(&file->RemoteApplicationGuid))
853 if (!trim(&file->RemoteApplicationCmdLine))
855 if (!trim(&file->AlternateShell))
857 if (!trim(&file->ShellWorkingDirectory))
859 if (!trim(&file->DrivesToRedirect))
861 if (!trim(&file->DevicesToRedirect))
863 if (!trim(&file->DevicesToRedirect))
865 if (!trim(&file->WinPosStr))
867 if (!trim(&file->PreconnectionBlob))
869 if (!trim(&file->KdcProxyName))
871 if (!trim(&file->SelectedMonitors))
874 for (
size_t i = 0; i < file->lineCount; ++i)
876 rdpFileLine* curLine = &file->lines[i];
877 if (curLine->flags & RDP_FILE_LINE_FLAG_TYPE_STRING)
879 if (!trim(&curLine->sValue))
887BOOL freerdp_client_parse_rdp_file_buffer_ex(rdpFile* file,
const BYTE* buffer,
size_t size,
888 rdp_file_fkt_parse parse)
892 char* line =
nullptr;
893 char* type =
nullptr;
894 char* context =
nullptr;
898 char* name =
nullptr;
899 char* value =
nullptr;
900 char* copy =
nullptr;
907 if ((buffer[0] == BOM_UTF16_LE[0]) && (buffer[1] == BOM_UTF16_LE[1]))
909 LPCWSTR uc = (LPCWSTR)(&buffer[2]);
910 size = size /
sizeof(WCHAR) - 1;
912 copy = ConvertWCharNToUtf8Alloc(uc, size,
nullptr);
915 WLog_ERR(TAG,
"Failed to convert RDP file from UCS2 to UTF8");
921 copy = calloc(1, size +
sizeof(BYTE));
926 memcpy(copy, buffer, size);
929 line = strtok_s(copy,
"\r\n", &context);
933 length = strnlen(line, size);
940 if (!freerdp_client_parse_rdp_file_option(file, line))
946 d1 = strchr(line,
':');
952 d2 = strchr(type,
':');
965 if (parse && parse(file->context, name, *type, value))
968 else if (*type ==
'i')
971 if (!freerdp_client_parse_rdp_file_integer(file, name, value))
974 else if (*type ==
's')
977 if (!freerdp_client_parse_rdp_file_string(file, name, value))
980 else if (*type ==
'b')
983 WLog_ERR(TAG,
"Unsupported RDP file binary option %s [value=%s]", name, value);
988 line = strtok_s(
nullptr,
"\r\n", &context);
991 rc = trim_strings(file);
997BOOL freerdp_client_parse_rdp_file(rdpFile* file,
const char* name)
999 return freerdp_client_parse_rdp_file_ex(file, name,
nullptr);
1002BOOL freerdp_client_parse_rdp_file_ex(rdpFile* file,
const char* name, rdp_file_fkt_parse parse)
1005 BYTE* buffer =
nullptr;
1007 size_t read_size = 0;
1008 INT64 file_size = 0;
1009 const char* fname = name;
1014 if (_strnicmp(fname,
"file://", 7) == 0)
1017 fp = winpr_fopen(fname,
"r");
1020 WLog_ERR(TAG,
"Failed to open RDP file %s", name);
1024 (void)_fseeki64(fp, 0, SEEK_END);
1025 file_size = _ftelli64(fp);
1026 (void)_fseeki64(fp, 0, SEEK_SET);
1030 WLog_ERR(TAG,
"RDP file %s is empty", name);
1035 buffer = (BYTE*)malloc((
size_t)file_size + 2);
1043 read_size = fread(buffer, (
size_t)file_size, 1, fp);
1048 read_size = (size_t)file_size;
1055 WLog_ERR(TAG,
"Could not read from RDP file %s", name);
1060 buffer[file_size] =
'\0';
1061 buffer[file_size + 1] =
'\0';
1062 status = freerdp_client_parse_rdp_file_buffer_ex(file, buffer, (
size_t)file_size, parse);
1067static inline void freerdp_client_file_string_reset(
char** target)
1069 WINPR_ASSERT(target);
1070 freerdp_client_file_string_check_free(*target);
1071 *target = (
char*)UINTPTR_MAX;
1074static inline BOOL FILE_POPULATE_STRING(
char** _target,
const rdpSettings* _settings,
1075 FreeRDP_Settings_Keys_String _option)
1077 WINPR_ASSERT(_target);
1078 WINPR_ASSERT(_settings);
1081 freerdp_client_file_string_reset(_target);
1084 char* copy = _strdup(str);
1092static char* freerdp_client_channel_args_to_string(
const rdpSettings* settings,
const char* channel,
1095 ADDIN_ARGV* args = freerdp_dynamic_channel_collection_find(settings, channel);
1096 const char* filters[] = { option };
1097 if (!args || (args->argc < 2))
1100 return CommandLineToCommaSeparatedValuesEx(args->argc - 1, args->argv + 1, filters,
1101 ARRAYSIZE(filters));
1104static BOOL rdp_opt_duplicate(
const rdpSettings* _settings, FreeRDP_Settings_Keys_String _id,
1107 WINPR_ASSERT(_settings);
1113 *_key = _strdup(tmp);
1121BOOL freerdp_client_populate_rdp_file_from_settings(rdpFile* file,
const rdpSettings* settings)
1123 FreeRDP_Settings_Keys_String index = FreeRDP_STRING_UNUSED;
1124 UINT32 LoadBalanceInfoLength = 0;
1125 const char* GatewayHostname =
nullptr;
1126 char* redirectCameras =
nullptr;
1128 if (!file || !settings)
1131 if (!FILE_POPULATE_STRING(&file->Domain, settings, FreeRDP_Domain) ||
1132 !FILE_POPULATE_STRING(&file->Username, settings, FreeRDP_Username) ||
1133 !FILE_POPULATE_STRING(&file->Password, settings, FreeRDP_Password) ||
1134 !FILE_POPULATE_STRING(&file->FullAddress, settings, FreeRDP_ServerHostname) ||
1135 !FILE_POPULATE_STRING(&file->AlternateFullAddress, settings, FreeRDP_ServerHostname) ||
1136 !FILE_POPULATE_STRING(&file->AlternateShell, settings, FreeRDP_AlternateShell) ||
1137 !FILE_POPULATE_STRING(&file->DrivesToRedirect, settings, FreeRDP_DrivesToRedirect))
1146 file->DynamicResolution = WINPR_ASSERTING_INT_CAST(
1148 file->VideoPlaybackMode = WINPR_ASSERTING_INT_CAST(
1155 file->ConnectToConsole = WINPR_ASSERTING_INT_CAST(
1157 file->NegotiateSecurityLayer = WINPR_ASSERTING_INT_CAST(
1159 file->EnableCredSSPSupport =
1161 file->EnableRdsAadAuth =
1165 index = FreeRDP_RemoteApplicationWorkingDir;
1167 index = FreeRDP_ShellWorkingDirectory;
1168 if (!FILE_POPULATE_STRING(&file->ShellWorkingDirectory, settings, index))
1175 if (LoadBalanceInfoLength > 0)
1177 const BYTE* LoadBalanceInfo =
1179 file->LoadBalanceInfo = calloc(LoadBalanceInfoLength + 1, 1);
1180 if (!file->LoadBalanceInfo)
1182 memcpy(file->LoadBalanceInfo, LoadBalanceInfo, LoadBalanceInfoLength);
1186 file->AudioMode = AUDIO_MODE_REDIRECT;
1188 file->AudioMode = AUDIO_MODE_PLAY_ON_SERVER;
1190 file->AudioMode = AUDIO_MODE_NONE;
1195 if (GatewayHostname)
1198 freerdp_client_file_string_check_free(file->GatewayHostname);
1199 if (GatewayPort == 443)
1200 file->GatewayHostname = _strdup(GatewayHostname);
1203 int length = _scprintf(
"%s:%" PRIu32, GatewayHostname, GatewayPort);
1207 file->GatewayHostname = (
char*)malloc((
size_t)length + 1);
1208 if (!file->GatewayHostname)
1211 if (sprintf_s(file->GatewayHostname, (
size_t)length + 1,
"%s:%" PRIu32, GatewayHostname,
1215 if (!file->GatewayHostname)
1220 file->ResourceProvider = _strdup(str_resourceprovider_arm);
1222 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdWvdEndpointPool, &file->WvdEndpointPool))
1224 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdGeo, &file->geo))
1226 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdArmpath, &file->armpath))
1228 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdAadtenantid, &file->aadtenantid))
1230 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdDiagnosticserviceurl,
1231 &file->diagnosticserviceurl))
1233 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdHubdiscoverygeourl,
1234 &file->hubdiscoverygeourl))
1236 if (!rdp_opt_duplicate(settings, FreeRDP_GatewayAvdActivityhint, &file->activityhint))
1239 file->AudioCaptureMode =
1241 file->BitmapCachePersistEnable = WINPR_ASSERTING_INT_CAST(
1243 file->Compression = WINPR_ASSERTING_INT_CAST(
1247 file->GatewayCredentialsSource =
1249 file->PromptCredentialOnce = WINPR_ASSERTING_INT_CAST(
1251 file->PromptForCredentials = WINPR_ASSERTING_INT_CAST(
1253 file->RemoteApplicationMode = WINPR_ASSERTING_INT_CAST(
1255 if (!FILE_POPULATE_STRING(&file->GatewayAccessToken, settings, FreeRDP_GatewayAccessToken) ||
1256 !FILE_POPULATE_STRING(&file->RemoteApplicationProgram, settings,
1257 FreeRDP_RemoteApplicationProgram) ||
1258 !FILE_POPULATE_STRING(&file->RemoteApplicationName, settings,
1259 FreeRDP_RemoteApplicationName) ||
1260 !FILE_POPULATE_STRING(&file->RemoteApplicationIcon, settings,
1261 FreeRDP_RemoteApplicationIcon) ||
1262 !FILE_POPULATE_STRING(&file->RemoteApplicationFile, settings,
1263 FreeRDP_RemoteApplicationFile) ||
1264 !FILE_POPULATE_STRING(&file->RemoteApplicationGuid, settings,
1265 FreeRDP_RemoteApplicationGuid) ||
1266 !FILE_POPULATE_STRING(&file->RemoteApplicationCmdLine, settings,
1267 FreeRDP_RemoteApplicationCmdLine))
1269 file->SpanMonitors =
1273 file->AllowDesktopComposition = WINPR_ASSERTING_INT_CAST(
1275 file->AllowFontSmoothing = WINPR_ASSERTING_INT_CAST(
1277 file->DisableWallpaper = WINPR_ASSERTING_INT_CAST(
1279 file->DisableFullWindowDrag = WINPR_ASSERTING_INT_CAST(
1281 file->DisableMenuAnims = WINPR_ASSERTING_INT_CAST(
1283 file->DisableThemes = WINPR_ASSERTING_INT_CAST(
1286 CONNECTION_TYPE_AUTODETECT);
1287 file->NetworkAutoDetect =
1289 file->AutoReconnectionEnabled = WINPR_ASSERTING_INT_CAST(
1291 file->RedirectSmartCards = WINPR_ASSERTING_INT_CAST(
1293 file->RedirectWebauthN = WINPR_ASSERTING_INT_CAST(
1297 freerdp_client_channel_args_to_string(settings, RDPECAM_DVC_CHANNEL_NAME,
"device:");
1298 if (redirectCameras)
1301 freerdp_client_channel_args_to_string(settings, RDPECAM_DVC_CHANNEL_NAME,
"encode:");
1302 file->EncodeRedirectedVideoCapture = 0;
1305 unsigned long val = 0;
1307 val = strtoul(str,
nullptr, 0);
1308 if ((val < UINT32_MAX) && (errno == 0))
1309 file->EncodeRedirectedVideoCapture = (UINT32)val;
1313 str = freerdp_client_channel_args_to_string(settings, RDPECAM_DVC_CHANNEL_NAME,
"quality:");
1314 file->RedirectedVideoCaptureEncodingQuality = 0;
1317 unsigned long val = 0;
1319 val = strtoul(str,
nullptr, 0);
1320 if ((val <= 2) && (errno == 0))
1322 file->RedirectedVideoCaptureEncodingQuality = (UINT32)val;
1327 file->RedirectCameras = redirectCameras;
1330 freerdp_client_file_string_reset(&file->RedirectCameras);
1332#ifdef CHANNEL_URBDRC_CLIENT
1334 freerdp_client_channel_args_to_string(settings, URBDRC_CHANNEL_NAME,
"device:");
1336 file->UsbDevicesToRedirect = redirectUsb;
1338 freerdp_client_file_string_reset(&file->UsbDevicesToRedirect);
1341 file->RedirectClipboard =
1348 file->RedirectLocation =
1350 if (!FILE_POPULATE_STRING(&file->DrivesToRedirect, settings, FreeRDP_DrivesToRedirect) ||
1351 !FILE_POPULATE_STRING(&file->PreconnectionBlob, settings, FreeRDP_PreconnectionBlob) ||
1352 !FILE_POPULATE_STRING(&file->KdcProxyName, settings, FreeRDP_KerberosKdcUrl))
1360 size_t size = count * (10 + 1) + 1;
1362 char* str = calloc(size,
sizeof(
char));
1363 for (UINT32 x = 0; x < count; x++)
1365 int rc = _snprintf(&str[offset], size - offset,
"%" PRIu32
",", MonitorIds[x]);
1371 offset += (size_t)rc;
1374 str[offset - 1] =
'\0';
1375 freerdp_client_file_string_check_free(file->SelectedMonitors);
1376 file->SelectedMonitors = str;
1384BOOL freerdp_client_write_rdp_file(
const rdpFile* file,
const char* name, BOOL unicode)
1387 WCHAR* unicodestr =
nullptr;
1392 const size_t size = freerdp_client_write_rdp_file_buffer(file,
nullptr, 0);
1395 char* buffer = calloc(size + 1ULL,
sizeof(
char));
1397 if (freerdp_client_write_rdp_file_buffer(file, buffer, size + 1) != size)
1399 WLog_ERR(TAG,
"freerdp_client_write_rdp_file: error writing to output buffer");
1404 FILE* fp = winpr_fopen(name,
"w+b");
1411 unicodestr = ConvertUtf8NToWCharAlloc(buffer, size, &len);
1421 if ((fwrite(BOM_UTF16_LE,
sizeof(BYTE), 2, fp) != 2) ||
1422 (fwrite(unicodestr,
sizeof(WCHAR), len, fp) != len))
1434 if (fwrite(buffer, 1, size, fp) != size)
1443 status = fclose(fp);
1447 return (status == 0);
1450WINPR_ATTR_FORMAT_ARG(3, 4)
1451static SSIZE_T freerdp_client_write_setting_to_buffer(
char** buffer,
size_t* bufferSize,
1452 WINPR_FORMAT_ARG const
char* fmt, ...)
1454 va_list ap = WINPR_C_ARRAY_INIT;
1456 char* buf =
nullptr;
1459 if (!buffer || !bufferSize || !fmt)
1463 bufSize = *bufferSize;
1466 len = vsnprintf(buf, bufSize, fmt, ap);
1475 if (!buf && !bufSize)
1482 if (bufSize >= (
size_t)len)
1484 *bufferSize -= (size_t)len;
1485 buf[len - 1] =
'\n';
1486 *buffer = buf + len;
1494static SSIZE_T write_int_parameters(
const rdpFile* file,
char* buffer,
size_t size)
1503 const struct intentry_t settings[] = {
1504 { key_int_use_multimon, file->UseMultiMon },
1505 { key_int_maximizetocurrentdisplays, file->MaximizeToCurrentDisplays },
1506 { key_int_singlemoninwindowedmode, file->SingleMonInWindowedMode },
1507 { key_int_screen_mode_id, file->ScreenModeId },
1508 { key_int_span_monitors, file->SpanMonitors },
1509 { key_int_smart_sizing, file->SmartSizing },
1510 { key_int_dynamic_resolution, file->DynamicResolution },
1511 { key_int_enablesuperpan, file->EnableSuperSpan },
1512 { key_int_superpanaccelerationfactor, file->SuperSpanAccelerationFactor },
1513 { key_int_desktopwidth, file->DesktopWidth },
1514 { key_int_desktopheight, file->DesktopHeight },
1515 { key_int_desktop_size_id, file->DesktopSizeId },
1516 { key_int_session_bpp, file->SessionBpp },
1517 { key_int_desktopscalefactor, file->DesktopScaleFactor },
1518 { key_int_compression, file->Compression },
1519 { key_int_keyboardhook, file->KeyboardHook },
1520 { key_int_disable_ctrl_alt_del, file->DisableCtrlAltDel },
1521 { key_int_audiomode, file->AudioMode },
1522 { key_int_audioqualitymode, file->AudioQualityMode },
1523 { key_int_audiocapturemode, file->AudioCaptureMode },
1524 { key_int_encode_redirected_video_capture, file->EncodeRedirectedVideoCapture },
1525 { key_int_redirected_video_capture_encoding_quality,
1526 file->RedirectedVideoCaptureEncodingQuality },
1527 { key_int_videoplaybackmode, file->VideoPlaybackMode },
1528 { key_int_connection_type, file->ConnectionType },
1529 { key_int_networkautodetect, file->NetworkAutoDetect },
1530 { key_int_bandwidthautodetect, file->BandwidthAutoDetect },
1531 { key_int_pinconnectionbar, file->PinConnectionBar },
1532 { key_int_displayconnectionbar, file->DisplayConnectionBar },
1533 { key_int_workspaceid, file->WorkspaceId },
1534 { key_int_enableworkspacereconnect, file->EnableWorkspaceReconnect },
1535 { key_int_disable_wallpaper, file->DisableWallpaper },
1536 { key_int_allow_font_smoothing, file->AllowFontSmoothing },
1537 { key_int_allow_desktop_composition, file->AllowDesktopComposition },
1538 { key_int_disable_full_window_drag, file->DisableFullWindowDrag },
1539 { key_int_disable_menu_anims, file->DisableMenuAnims },
1540 { key_int_disable_themes, file->DisableThemes },
1541 { key_int_disable_cursor_setting, file->DisableCursorSetting },
1542 { key_int_bitmapcachesize, file->BitmapCacheSize },
1543 { key_int_bitmapcachepersistenable, file->BitmapCachePersistEnable },
1544 { key_int_server_port, file->ServerPort },
1545 { key_int_redirectdrives, file->RedirectDrives },
1546 { key_int_redirectprinters, file->RedirectPrinters },
1547 { key_int_redirectcomports, file->RedirectComPorts },
1548 { key_int_redirectlocation, file->RedirectLocation },
1549 { key_int_redirectsmartcards, file->RedirectSmartCards },
1550 { key_int_redirectclipboard, file->RedirectClipboard },
1551 { key_int_redirectposdevices, file->RedirectPosDevices },
1552 { key_int_redirectdirectx, file->RedirectDirectX },
1553 { key_int_disableprinterredirection, file->DisablePrinterRedirection },
1554 { key_int_disableclipboardredirection, file->DisableClipboardRedirection },
1555 { key_int_connect_to_console, file->ConnectToConsole },
1556 { key_int_administrative_session, file->AdministrativeSession },
1557 { key_int_autoreconnection_enabled, file->AutoReconnectionEnabled },
1558 { key_int_autoreconnect_max_retries, file->AutoReconnectMaxRetries },
1559 { key_int_public_mode, file->PublicMode },
1560 { key_int_authentication_level, file->AuthenticationLevel },
1561 { key_int_promptcredentialonce, file->PromptCredentialOnce },
1562 { key_int_prompt_for_credentials, file->PromptForCredentials },
1563 { key_int_negotiate_security_layer, file->NegotiateSecurityLayer },
1564 { key_int_enablecredsspsupport, file->EnableCredSSPSupport },
1565 { key_int_enablerdsaadauth, file->EnableRdsAadAuth },
1566 { key_int_remoteapplicationmode, file->RemoteApplicationMode },
1567 { key_int_remoteapplicationexpandcmdline, file->RemoteApplicationExpandCmdLine },
1568 { key_int_remoteapplicationexpandworkingdir, file->RemoteApplicationExpandWorkingDir },
1569 { key_int_disableconnectionsharing, file->DisableConnectionSharing },
1570 { key_int_disableremoteappcapscheck, file->DisableRemoteAppCapsCheck },
1571 { key_int_gatewayusagemethod, file->GatewayUsageMethod },
1572 { key_int_gatewayprofileusagemethod, file->GatewayProfileUsageMethod },
1573 { key_int_gatewaycredentialssource, file->GatewayCredentialsSource },
1574 { key_int_use_redirection_server_name, file->UseRedirectionServerName },
1575 { key_int_rdgiskdcproxy, file->RdgIsKdcProxy },
1576 { key_int_redirectwebauthn, file->RedirectWebauthN }
1579 SSIZE_T totalSize = 0;
1580 for (
size_t x = 0; x < ARRAYSIZE(settings); x++)
1582 const struct intentry_t* cur = &settings[x];
1585 const SSIZE_T res = freerdp_client_write_setting_to_buffer(
1586 &buffer, &size,
"%s:i:%" PRIu32, cur->key, cur->val);
1596static SSIZE_T write_string_parameters(
const rdpFile* file,
char* buffer,
size_t size)
1605 const struct strentry_t settings[] = {
1606 { key_str_username, file->Username },
1607 { key_str_domain, file->Domain },
1608 { key_str_password, file->Password },
1609 { key_str_full_address, file->FullAddress },
1610 { key_str_alternate_full_address, file->AlternateFullAddress },
1611 { key_str_usbdevicestoredirect, file->UsbDevicesToRedirect },
1612 { key_str_camerastoredirect, file->RedirectCameras },
1613 { key_str_loadbalanceinfo, file->LoadBalanceInfo },
1614 { key_str_remoteapplicationname, file->RemoteApplicationName },
1615 { key_str_remoteapplicationicon, file->RemoteApplicationIcon },
1616 { key_str_remoteapplicationprogram, file->RemoteApplicationProgram },
1617 { key_str_remoteapplicationfile, file->RemoteApplicationFile },
1618 { key_str_remoteapplicationguid, file->RemoteApplicationGuid },
1619 { key_str_remoteapplicationcmdline, file->RemoteApplicationCmdLine },
1620 { key_str_alternate_shell, file->AlternateShell },
1621 { key_str_shell_working_directory, file->ShellWorkingDirectory },
1622 { key_str_gatewayhostname, file->GatewayHostname },
1623 { key_str_resourceprovider, file->ResourceProvider },
1624 { key_str_wvd, file->WvdEndpointPool },
1625 { key_str_geo, file->geo },
1626 { key_str_armpath, file->armpath },
1627 { key_str_aadtenantid, file->aadtenantid },
1628 { key_str_diagnosticserviceurl, file->diagnosticserviceurl },
1629 { key_str_hubdiscoverygeourl, file->hubdiscoverygeourl },
1630 { key_str_activityhint, file->activityhint },
1631 { key_str_gatewayaccesstoken, file->GatewayAccessToken },
1632 { key_str_kdcproxyname, file->KdcProxyName },
1633 { key_str_drivestoredirect, file->DrivesToRedirect },
1634 { key_str_devicestoredirect, file->DevicesToRedirect },
1635 { key_str_winposstr, file->WinPosStr },
1636 { key_str_pcb, file->PreconnectionBlob },
1637 { key_str_selectedmonitors, file->SelectedMonitors }
1640 SSIZE_T totalSize = 0;
1641 for (
size_t x = 0; x < ARRAYSIZE(settings); x++)
1643 const struct strentry_t* cur = &settings[x];
1644 if (~(
size_t)(cur->val))
1646 const SSIZE_T res = freerdp_client_write_setting_to_buffer(&buffer, &size,
"%s:s:%s",
1647 cur->key, cur->val);
1657static SSIZE_T write_custom_parameters(
const rdpFile* file,
char* buffer,
size_t size)
1661 SSIZE_T totalSize = 0;
1663 for (
size_t i = 0; i < file->lineCount; ++i)
1666 const rdpFileLine* curLine = &file->lines[i];
1668 if (curLine->flags & RDP_FILE_LINE_FLAG_TYPE_INTEGER)
1669 res = freerdp_client_write_setting_to_buffer(&buffer, &size,
"%s:i:%" PRIu32,
1670 curLine->name, (UINT32)curLine->iValue);
1671 else if (curLine->flags & RDP_FILE_LINE_FLAG_TYPE_STRING)
1672 res = freerdp_client_write_setting_to_buffer(&buffer, &size,
"%s:s:%s", curLine->name,
1682size_t freerdp_client_write_rdp_file_buffer(
const rdpFile* file,
char* buffer,
size_t size)
1684 size_t totalSize = 0;
1690 if ((!buffer || !size) && (buffer || size))
1694 const SSIZE_T intsize = write_int_parameters(file, buffer, size);
1697 totalSize += (size_t)intsize;
1702 const SSIZE_T stringsize = write_string_parameters(file, buffer, size);
1705 totalSize += (size_t)stringsize;
1707 buffer += stringsize;
1710 const SSIZE_T customsize = write_custom_parameters(file, buffer, size);
1713 totalSize += (size_t)customsize;
1717static ADDIN_ARGV* rdp_file_to_args(
const char* channel,
const char* values)
1721 ADDIN_ARGV* args = freerdp_addin_argv_new(0,
nullptr);
1724 if (!freerdp_addin_argv_add_argument(args, channel))
1727 p = CommandLineParseCommaSeparatedValues(values, &count);
1728 for (
size_t x = 0; x < count; x++)
1731 const char* val = p[x];
1732 const size_t len = strlen(val) + 8;
1733 char* str = calloc(len,
sizeof(
char));
1737 (void)_snprintf(str, len,
"device:%s", val);
1738 rc = freerdp_addin_argv_add_argument(args, str);
1743 CommandLineParserFree(p);
1747 CommandLineParserFree(p);
1748 freerdp_addin_argv_free(args);
1752BOOL freerdp_client_populate_settings_from_rdp_file_unchecked(
const rdpFile* file,
1753 rdpSettings* settings)
1755 if (!file || !settings)
1761 if (~file->BandwidthAutoDetect)
1763 if (file->BandwidthAutoDetect != 0)
1765 if ((~file->NetworkAutoDetect) && (file->NetworkAutoDetect == 0))
1768 "Got networkautodetect:i:%" PRIu32
" and bandwidthautodetect:i:%" PRIu32
1769 ". Correcting to networkautodetect:i:1",
1770 file->NetworkAutoDetect, file->BandwidthAutoDetect);
1772 "Add networkautodetect:i:1 to your RDP file to eliminate this warning.");
1776 (file->BandwidthAutoDetect != 0) ||
1777 (file->NetworkAutoDetect != 0)))
1781 if (~file->NetworkAutoDetect)
1783 if (file->NetworkAutoDetect != 0)
1785 if ((~file->BandwidthAutoDetect) && (file->BandwidthAutoDetect == 0))
1788 "Got networkautodetect:i:%" PRIu32
" and bandwidthautodetect:i:%" PRIu32
1789 ". Correcting to bandwidthautodetect:i:1",
1790 file->NetworkAutoDetect, file->BandwidthAutoDetect);
1792 TAG,
"Add bandwidthautodetect:i:1 to your RDP file to eliminate this warning.");
1796 (file->BandwidthAutoDetect != 0) ||
1797 (file->NetworkAutoDetect != 0)))
1801 if (~((
size_t)file->Domain))
1807 if (~((
size_t)file->Username))
1809 char* user =
nullptr;
1810 char* domain =
nullptr;
1812 if (!freerdp_parse_username(file->Username, &user, &domain))
1818 if (!(~((
size_t)file->Domain)) && domain)
1828 if (~((
size_t)file->Password))
1835 const char* address =
nullptr;
1839 if (~((
size_t)file->AlternateFullAddress))
1840 address = file->AlternateFullAddress;
1841 else if (~((
size_t)file->FullAddress))
1842 address = file->FullAddress;
1847 char* host =
nullptr;
1849 if (!freerdp_parse_hostname(address, &host, &port))
1865 if (~file->ServerPort)
1871 if (~file->DesktopSizeId)
1873 switch (file->DesktopSizeId)
1906 WLog_WARN(TAG,
"Unsupported 'desktop size id' value %" PRIu32, file->DesktopSizeId);
1911 if (~file->DesktopWidth)
1917 if (~file->DesktopHeight)
1923 if (~file->SessionBpp)
1929 if (~file->ConnectToConsole)
1932 file->ConnectToConsole != 0))
1936 if (~file->AdministrativeSession)
1939 file->AdministrativeSession != 0))
1943 if (~file->NegotiateSecurityLayer)
1946 file->NegotiateSecurityLayer != 0))
1950 if (~file->EnableCredSSPSupport)
1953 file->EnableCredSSPSupport != 0))
1957 if (~file->EnableRdsAadAuth)
1959 const BOOL val = file->EnableRdsAadAuth != 0;
1964 if (~((
size_t)file->AlternateShell))
1970 if (~((
size_t)file->ShellWorkingDirectory))
1973 FreeRDP_Settings_Keys_String targetId =
1974 (~file->RemoteApplicationMode && file->RemoteApplicationMode != 0)
1975 ? FreeRDP_RemoteApplicationWorkingDir
1976 : FreeRDP_ShellWorkingDirectory;
1982 if (~file->ScreenModeId)
2000 if (~(file->SmartSizing))
2013 if (((~(file->DesktopWidth) && ~(file->DesktopHeight)) || ~(file->DesktopSizeId)) &&
2014 (file->SmartSizing == 1))
2017 file->DesktopWidth))
2020 file->DesktopHeight))
2025 if (~((
size_t)file->LoadBalanceInfo))
2027 const size_t len = strlen(file->LoadBalanceInfo);
2029 file->LoadBalanceInfo, len))
2033 if (~file->AuthenticationLevel)
2050 file->AuthenticationLevel))
2054 if (~file->ConnectionType)
2060 if (~file->AudioMode)
2062 switch (file->AudioMode)
2064 case AUDIO_MODE_REDIRECT:
2070 case AUDIO_MODE_PLAY_ON_SERVER:
2076 case AUDIO_MODE_NONE:
2086 if (~file->AudioCaptureMode)
2092 if (~file->Compression)
2095 file->Compression != 0))
2099 if (~((
size_t)file->GatewayHostname))
2102 char* host =
nullptr;
2104 if (!freerdp_parse_hostname(file->GatewayHostname, &host, &port))
2119 if (~((
size_t)file->ResourceProvider))
2121 if (_stricmp(file->ResourceProvider, str_resourceprovider_arm) == 0)
2128 if (~((
size_t)file->WvdEndpointPool))
2131 file->WvdEndpointPool))
2135 if (~((
size_t)file->geo))
2141 if (~((
size_t)file->armpath))
2147 if (~((
size_t)file->aadtenantid))
2154 if (~((
size_t)file->diagnosticserviceurl))
2157 file->diagnosticserviceurl))
2161 if (~((
size_t)file->hubdiscoverygeourl))
2164 file->hubdiscoverygeourl))
2168 if (~((
size_t)file->activityhint))
2171 file->activityhint))
2175 if (~((
size_t)file->GatewayAccessToken))
2178 file->GatewayAccessToken))
2182 if (~file->GatewayUsageMethod)
2188 if (~file->PromptCredentialOnce)
2191 file->PromptCredentialOnce != 0))
2195 if (~file->PromptForCredentials)
2198 file->PromptForCredentials != 0))
2202 if (~file->RemoteApplicationMode)
2205 file->RemoteApplicationMode != 0))
2209 if (~((
size_t)file->RemoteApplicationProgram))
2212 file->RemoteApplicationProgram))
2216 if (~((
size_t)file->RemoteApplicationName))
2219 file->RemoteApplicationName))
2223 if (~((
size_t)file->RemoteApplicationIcon))
2226 file->RemoteApplicationIcon))
2230 if (~((
size_t)file->RemoteApplicationFile))
2233 file->RemoteApplicationFile))
2237 if (~((
size_t)file->RemoteApplicationGuid))
2240 file->RemoteApplicationGuid))
2244 if (~((
size_t)file->RemoteApplicationCmdLine))
2247 file->RemoteApplicationCmdLine))
2251 if (~file->SpanMonitors)
2257 if (~file->UseMultiMon)
2263 if (~file->AllowFontSmoothing)
2266 file->AllowFontSmoothing != 0))
2270 if (~file->DisableWallpaper)
2273 file->DisableWallpaper != 0))
2277 if (~file->DisableFullWindowDrag)
2280 file->DisableFullWindowDrag != 0))
2284 if (~file->DisableMenuAnims)
2287 file->DisableMenuAnims != 0))
2291 if (~file->DisableThemes)
2297 if (~file->AllowDesktopComposition)
2300 file->AllowDesktopComposition != 0))
2304 if (~file->BitmapCachePersistEnable)
2307 file->BitmapCachePersistEnable != 0))
2311 if (~file->DisableRemoteAppCapsCheck)
2314 file->DisableRemoteAppCapsCheck != 0))
2318 if (~file->AutoReconnectionEnabled)
2321 file->AutoReconnectionEnabled != 0))
2325 if (~file->AutoReconnectMaxRetries)
2328 file->AutoReconnectMaxRetries))
2332 if (~file->RedirectSmartCards)
2335 file->RedirectSmartCards != 0))
2339 if (~file->RedirectWebauthN)
2342 file->RedirectWebauthN != 0))
2346 if (~file->RedirectClipboard)
2349 file->RedirectClipboard != 0))
2353 if (~file->RedirectPrinters)
2356 file->RedirectPrinters != 0))
2360 if (~file->RedirectDrives)
2366 if (~file->RedirectPosDevices)
2369 file->RedirectComPorts != 0) ||
2371 file->RedirectComPorts != 0))
2375 if (~file->RedirectComPorts)
2378 file->RedirectComPorts != 0) ||
2380 file->RedirectComPorts != 0))
2384 if (~file->RedirectLocation && (file->RedirectLocation != 0))
2390 freerdp_client_add_dynamic_channel(settings, count, (
const char*
const*)ptr);
2391 CommandLineParserFree(ptr);
2396 if (~file->RedirectDirectX)
2401 if ((~((
size_t)file->DevicesToRedirect)) && !utils_str_is_empty(file->DevicesToRedirect))
2431 if ((~((
size_t)file->DrivesToRedirect)) && !utils_str_is_empty(file->DrivesToRedirect))
2434 file->DrivesToRedirect))
2438 if ((~((
size_t)file->RedirectCameras)) && !utils_str_is_empty(file->RedirectCameras))
2440#if defined(CHANNEL_RDPECAM_CLIENT)
2444 const char*
const* cc;
2446 ADDIN_ARGV* args = rdp_file_to_args(RDPECAM_DVC_CHANNEL_NAME, file->RedirectCameras);
2451 if (~file->EncodeRedirectedVideoCapture)
2453 char encode[64] = WINPR_C_ARRAY_INIT;
2454 (void)_snprintf(encode,
sizeof(encode),
"encode:%" PRIu32,
2455 file->EncodeRedirectedVideoCapture);
2456 if (!freerdp_addin_argv_add_argument(args, encode))
2459 if (~file->RedirectedVideoCaptureEncodingQuality)
2461 char quality[64] = WINPR_C_ARRAY_INIT;
2462 (void)_snprintf(quality,
sizeof(quality),
"quality:%" PRIu32,
2463 file->RedirectedVideoCaptureEncodingQuality);
2464 if (!freerdp_addin_argv_add_argument(args, quality))
2470 status = freerdp_client_add_dynamic_channel(
2471 settings, WINPR_ASSERTING_INT_CAST(
size_t, args->argc), cnv.cc);
2472 freerdp_addin_argv_free(args);
2478 "This build does not support [MS-RDPECAM] camera redirection channel. Ignoring '%s'",
2479 key_str_camerastoredirect);
2483 if ((~((
size_t)file->UsbDevicesToRedirect)) && !utils_str_is_empty(file->UsbDevicesToRedirect))
2485#ifdef CHANNEL_URBDRC_CLIENT
2489 const char*
const* cc;
2491 ADDIN_ARGV* args = rdp_file_to_args(URBDRC_CHANNEL_NAME, file->UsbDevicesToRedirect);
2495 const BOOL status = freerdp_client_add_dynamic_channel(
2496 settings, WINPR_ASSERTING_INT_CAST(
size_t, args->argc), cnv.cc);
2497 freerdp_addin_argv_free(args);
2502 "This build does not support [MS-RDPEUSB] usb redirection channel. Ignoring '%s'",
2503 key_str_usbdevicestoredirect);
2507 if (~file->KeyboardHook)
2513 if (~(
size_t)file->SelectedMonitors)
2516 char** ptr = CommandLineParseCommaSeparatedValues(file->SelectedMonitors, &count);
2517 UINT32* list =
nullptr;
2521 CommandLineParserFree(ptr);
2525 if (!list && (count > 0))
2527 CommandLineParserFree(ptr);
2530 for (
size_t x = 0; x < count; x++)
2532 unsigned long val = 0;
2534 val = strtoul(ptr[x],
nullptr, 0);
2535 if ((val >= UINT32_MAX) && (errno != 0))
2537 CommandLineParserFree(ptr);
2541 list[x] = (UINT32)val;
2543 CommandLineParserFree(ptr);
2546 if (~file->DynamicResolution)
2548 const BOOL val = file->DynamicResolution != 0;
2555 if (~file->DesktopScaleFactor)
2558 file->DesktopScaleFactor))
2562 if (~file->VideoPlaybackMode)
2564 if (file->VideoPlaybackMode != 0)
2581 if (~((
size_t)file->PreconnectionBlob))
2584 file->PreconnectionBlob) ||
2589 if (~((
size_t)file->KdcProxyName))
2595 if (~file->RdgIsKdcProxy)
2598 file->RdgIsKdcProxy != 0))
2602 if (file->args->argc > 1)
2604 WCHAR* ConnectionFile =
2607 if (freerdp_client_settings_parse_command_line(settings, file->args->argc, file->args->argv,
2610 free(ConnectionFile);
2616 free(ConnectionFile);
2624static BOOL freerdp_apply_connection_type_from_file(
const rdpFile* file, rdpSettings* settings,
2627 struct network_settings
2629 FreeRDP_Settings_Keys_Bool id;
2635 const struct network_settings config[] = { { FreeRDP_DisableWallpaper,
2636 (~file->DisableWallpaper) == 0,
2637 { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
2638 { FreeRDP_AllowFontSmoothing,
2639 (~file->AllowFontSmoothing) == 0,
2640 { FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE } },
2641 { FreeRDP_AllowDesktopComposition,
2642 (~file->AllowDesktopComposition) == 0,
2643 { FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE } },
2644 { FreeRDP_DisableFullWindowDrag,
2645 (~file->DisableFullWindowDrag) == 0,
2646 { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
2647 { FreeRDP_DisableMenuAnims,
2648 (~file->DisableMenuAnims) == 0,
2649 { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
2650 { FreeRDP_DisableThemes,
2651 (~file->DisableThemes) == 0,
2652 { TRUE, FALSE, FALSE, FALSE, FALSE, FALSE,
2657 case CONNECTION_TYPE_INVALID:
2660 case CONNECTION_TYPE_MODEM:
2661 case CONNECTION_TYPE_BROADBAND_LOW:
2662 case CONNECTION_TYPE_BROADBAND_HIGH:
2663 case CONNECTION_TYPE_SATELLITE:
2664 case CONNECTION_TYPE_WAN:
2665 case CONNECTION_TYPE_LAN:
2666 case CONNECTION_TYPE_AUTODETECT:
2669 WLog_WARN(TAG,
"Unknown ConnectionType %" PRIu32
", aborting", type);
2673 for (
size_t x = 0; x < ARRAYSIZE(config); x++)
2675 const struct network_settings* cur = &config[x];
2685static BOOL freerdp_set_connection_type_from_file(
const rdpFile* file, rdpSettings* settings,
2694 case CONNECTION_TYPE_INVALID:
2695 case CONNECTION_TYPE_MODEM:
2696 case CONNECTION_TYPE_BROADBAND_LOW:
2697 case CONNECTION_TYPE_SATELLITE:
2698 case CONNECTION_TYPE_BROADBAND_HIGH:
2699 case CONNECTION_TYPE_WAN:
2700 case CONNECTION_TYPE_LAN:
2701 if (!freerdp_apply_connection_type_from_file(file, settings, type))
2704 case CONNECTION_TYPE_AUTODETECT:
2705 if (!freerdp_apply_connection_type_from_file(file, settings, type))
2719 WLog_WARN(TAG,
"Unknown ConnectionType %" PRIu32
", aborting", type);
2726BOOL freerdp_client_populate_settings_from_rdp_file(
const rdpFile* file, rdpSettings* settings)
2728 if (!freerdp_client_populate_settings_from_rdp_file_unchecked(file, settings))
2732 if ((~file->ConnectionType) == 0)
2735 type = CONNECTION_TYPE_AUTODETECT;
2737 return freerdp_set_connection_type_from_file(file, settings, type);
2740static rdpFileLine* freerdp_client_rdp_file_find_line_by_name(
const rdpFile* file,
const char* name)
2742 BOOL bFound = FALSE;
2743 rdpFileLine* line =
nullptr;
2745 for (
size_t index = 0; index < file->lineCount; index++)
2747 line = &(file->lines[index]);
2749 if (line->flags & RDP_FILE_LINE_FLAG_FORMATTED)
2751 if (_stricmp(name, line->name) == 0)
2759 return (bFound) ? line :
nullptr;
2768int freerdp_client_rdp_file_set_string_option(rdpFile* file,
const char* name,
const char* value)
2770 return freerdp_client_rdp_file_set_string(file, name, value);
2773const char* freerdp_client_rdp_file_get_string_option(
const rdpFile* file,
const char* name)
2775 LPSTR* value =
nullptr;
2776 rdpFileLine* line =
nullptr;
2778 rdpFile* wfile = WINPR_CAST_CONST_PTR_AWAY(file, rdpFile*);
2779 if (freerdp_client_rdp_file_find_string_entry(wfile, name, &value, &line))
2781 if (value && ~(
size_t)(*value))
2784 return line->sValue;
2790int freerdp_client_rdp_file_set_integer_option(rdpFile* file,
const char* name,
int value)
2792 return freerdp_client_rdp_file_set_integer(file, name, value);
2795int freerdp_client_rdp_file_get_integer_option(
const rdpFile* file,
const char* name)
2797 DWORD* value =
nullptr;
2798 rdpFileLine* line =
nullptr;
2800 rdpFile* wfile = WINPR_CAST_CONST_PTR_AWAY(file, rdpFile*);
2801 if (freerdp_client_rdp_file_find_integer_entry(wfile, name, &value, &line))
2803 if (value && ~(*value))
2804 return WINPR_ASSERTING_INT_CAST(
int, *value);
2806 return (
int)line->iValue;
2812static void freerdp_client_file_string_check_free(LPSTR str)
2818rdpFile* freerdp_client_rdp_file_new(
void)
2820 return freerdp_client_rdp_file_new_ex(0);
2823rdpFile* freerdp_client_rdp_file_new_ex(DWORD flags)
2825 rdpFile* file = (rdpFile*)calloc(1,
sizeof(rdpFile));
2830 file->flags = flags;
2832 FillMemory(file,
sizeof(rdpFile), 0xFF);
2833 file->lines =
nullptr;
2834 file->lineCount = 0;
2835 file->lineSize = 32;
2836 file->GatewayProfileUsageMethod = 1;
2837 file->lines = (rdpFileLine*)calloc(file->lineSize,
sizeof(rdpFileLine));
2839 file->args = freerdp_addin_argv_new(0,
nullptr);
2840 if (!file->lines || !file->args)
2843 if (!freerdp_client_add_option(file,
"freerdp"))
2848 WINPR_PRAGMA_DIAG_PUSH
2849 WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
2850 freerdp_client_rdp_file_free(file);
2851 WINPR_PRAGMA_DIAG_POP
2854void freerdp_client_rdp_file_free(rdpFile* file)
2858 if (file->lineCount)
2860 for (
size_t i = 0; i < file->lineCount; i++)
2862 free(file->lines[i].name);
2863 free(file->lines[i].sValue);
2868 freerdp_addin_argv_free(file->args);
2870 freerdp_client_file_string_check_free(file->Username);
2871 freerdp_client_file_string_check_free(file->Domain);
2872 freerdp_client_file_string_check_free(file->Password);
2873 freerdp_client_file_string_check_free(file->FullAddress);
2874 freerdp_client_file_string_check_free(file->AlternateFullAddress);
2875 freerdp_client_file_string_check_free(file->UsbDevicesToRedirect);
2876 freerdp_client_file_string_check_free(file->RedirectCameras);
2877 freerdp_client_file_string_check_free(file->SelectedMonitors);
2878 freerdp_client_file_string_check_free(file->LoadBalanceInfo);
2879 freerdp_client_file_string_check_free(file->RemoteApplicationName);
2880 freerdp_client_file_string_check_free(file->RemoteApplicationIcon);
2881 freerdp_client_file_string_check_free(file->RemoteApplicationProgram);
2882 freerdp_client_file_string_check_free(file->RemoteApplicationFile);
2883 freerdp_client_file_string_check_free(file->RemoteApplicationGuid);
2884 freerdp_client_file_string_check_free(file->RemoteApplicationCmdLine);
2885 freerdp_client_file_string_check_free(file->AlternateShell);
2886 freerdp_client_file_string_check_free(file->ShellWorkingDirectory);
2887 freerdp_client_file_string_check_free(file->GatewayHostname);
2888 freerdp_client_file_string_check_free(file->GatewayAccessToken);
2889 freerdp_client_file_string_check_free(file->KdcProxyName);
2890 freerdp_client_file_string_check_free(file->DrivesToRedirect);
2891 freerdp_client_file_string_check_free(file->DevicesToRedirect);
2892 freerdp_client_file_string_check_free(file->WinPosStr);
2893 freerdp_client_file_string_check_free(file->ResourceProvider);
2894 freerdp_client_file_string_check_free(file->WvdEndpointPool);
2895 freerdp_client_file_string_check_free(file->geo);
2896 freerdp_client_file_string_check_free(file->armpath);
2897 freerdp_client_file_string_check_free(file->aadtenantid);
2898 freerdp_client_file_string_check_free(file->diagnosticserviceurl);
2899 freerdp_client_file_string_check_free(file->hubdiscoverygeourl);
2900 freerdp_client_file_string_check_free(file->activityhint);
2905void freerdp_client_rdp_file_set_callback_context(rdpFile* file,
void* context)
2907 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.
FREERDP_API BOOL freerdp_settings_set_uint32(rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id, UINT32 val)
Sets a UINT32 settings value.
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 const char * freerdp_settings_get_string(const rdpSettings *settings, FreeRDP_Settings_Keys_String id)
Returns a immutable string settings value.
FREERDP_API BOOL freerdp_settings_set_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 void * freerdp_settings_get_pointer_writable(rdpSettings *settings, FreeRDP_Settings_Keys_Pointer id)
Returns a mutable pointer settings value.
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 BOOL freerdp_set_gateway_usage_method(rdpSettings *settings, UINT32 GatewayUsageMethod)
WINPR_ATTR_NODISCARD FREERDP_API WCHAR * freerdp_settings_get_string_as_utf16(const rdpSettings *settings, FreeRDP_Settings_Keys_String id, size_t *pCharLen)
Return an allocated UTF16 string.
FREERDP_API BOOL freerdp_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 BOOL freerdp_settings_get_bool(const rdpSettings *settings, FreeRDP_Settings_Keys_Bool id)
Returns a boolean settings value.
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.