@@ -1201,9 +1201,16 @@ static BOOL wfreerdp_client_new(freerdp* instance, rdpContext* context)
12011201
12021202 #pragma region Myrtille
12031203
1204- // no console in release build (use logs instead)
1204+ // no console in release build (use logs instead) or windowless mode
12051205 #if defined(WITH_DEBUG ) || defined(_DEBUG )
1206- wfc -> isConsole = wf_create_console ();
1206+ if (wfc -> context .settings -> MyrtilleShowWindow )
1207+ {
1208+ wfc -> isConsole = wf_create_console ();
1209+ }
1210+ else
1211+ {
1212+ wfc -> isConsole = FALSE;
1213+ }
12071214 #else
12081215 wfc -> isConsole = FALSE;
12091216 #endif
@@ -1391,3 +1398,115 @@ int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
13911398
13921399 return 0 ;
13931400}
1401+
1402+ #pragma region Myrtille
1403+
1404+ INT WINAPI StartRdpClient ()
1405+ {
1406+ int status ;
1407+ HANDLE thread ;
1408+ wfContext * wfc ;
1409+ DWORD dwExitCode ;
1410+ rdpContext * context ;
1411+ rdpSettings * settings ;
1412+ LPWSTR cmd ;
1413+ char * * argv = NULL ;
1414+ RDP_CLIENT_ENTRY_POINTS clientEntryPoints = { 0 };
1415+ int ret = 1 ;
1416+ int argc = 0 , i ;
1417+ LPWSTR * args = NULL ;
1418+
1419+ //WINPR_UNUSED(hInstance);
1420+ //WINPR_UNUSED(hPrevInstance);
1421+ //WINPR_UNUSED(lpCmdLine);
1422+ //WINPR_UNUSED(nCmdShow);
1423+
1424+ #pragma region Myrtille
1425+
1426+ // if debugging, give time to attach debugger to process
1427+ //Sleep(10000);
1428+
1429+ #pragma endregion
1430+
1431+ RdpClientEntry (& clientEntryPoints );
1432+
1433+ context = freerdp_client_context_new (& clientEntryPoints );
1434+ if (!context )
1435+ return -1 ;
1436+
1437+ cmd = GetCommandLineW ();
1438+
1439+ if (!cmd )
1440+ goto out ;
1441+
1442+ args = CommandLineToArgvW (cmd , & argc );
1443+
1444+ if (!args || (argc <= 0 ))
1445+ goto out ;
1446+
1447+ argv = calloc ((size_t )argc , sizeof (char * ));
1448+
1449+ if (!argv )
1450+ goto out ;
1451+
1452+ for (i = 0 ; i < argc ; i ++ )
1453+ {
1454+ int size = WideCharToMultiByte (CP_UTF8 , 0 , args [i ], -1 , NULL , 0 , NULL , NULL );
1455+ if (size <= 0 )
1456+ goto out ;
1457+ argv [i ] = calloc ((size_t )size , sizeof (char ));
1458+
1459+ if (!argv [i ])
1460+ goto out ;
1461+
1462+ if (WideCharToMultiByte (CP_UTF8 , 0 , args [i ], -1 , argv [i ], size , NULL , NULL ) != size )
1463+ goto out ;
1464+ }
1465+
1466+ settings = context -> settings ;
1467+ wfc = (wfContext * )context ;
1468+
1469+ if (!settings || !wfc )
1470+ goto out ;
1471+
1472+ status = freerdp_client_settings_parse_command_line (settings , argc , argv , FALSE);
1473+
1474+ if (status )
1475+ {
1476+ freerdp_client_settings_command_line_status_print (settings , status , argc , argv );
1477+ goto out ;
1478+ }
1479+
1480+ if (freerdp_client_start (context ) != 0 )
1481+ goto out ;
1482+
1483+ thread = freerdp_client_get_thread (context );
1484+
1485+ if (thread )
1486+ {
1487+ if (WaitForSingleObject (thread , INFINITE ) == WAIT_OBJECT_0 )
1488+ {
1489+ GetExitCodeThread (thread , & dwExitCode );
1490+ ret = (int )dwExitCode ;
1491+ }
1492+ }
1493+
1494+ if (freerdp_client_stop (context ) != 0 )
1495+ goto out ;
1496+
1497+ out :
1498+ freerdp_client_context_free (context );
1499+
1500+ if (argv )
1501+ {
1502+ for (i = 0 ; i < argc ; i ++ )
1503+ free (argv [i ]);
1504+
1505+ free (argv );
1506+ }
1507+
1508+ LocalFree (args );
1509+ return ret ;
1510+ }
1511+
1512+ #pragma endregion
0 commit comments