コード例 #1
0
        static internal TcpLaunchOptions CreateFromXml(Xml.LaunchOptions.TcpLaunchOptions source)
        {
            var options = new TcpLaunchOptions(RequireAttribute(source.Hostname, "Hostname"), LaunchOptions.RequirePortAttribute(source.Port, "Port"), source.Secure);

            options.InitializeCommonOptions(source);

            return(options);
        }
コード例 #2
0
        public override void InitStreams(LaunchOptions options, out StreamReader reader, out StreamWriter writer)
        {
            TcpLaunchOptions tcpOptions = (TcpLaunchOptions)options;

            _client = new TcpClient();
            _client.ConnectAsync(tcpOptions.Hostname, tcpOptions.Port).Wait();

            if (tcpOptions.Secure)
            {
                RemoteCertificateValidationCallback callback;

                if (tcpOptions.ServerCertificateValidationCallback == null)
                {
                    //if no callback specified, accept any certificate
                    callback = delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
                    {
                        return(sslPolicyErrors == SslPolicyErrors.None);
                    };
                }
                else
                {
                    //else use the callback specified
                    callback = (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) => tcpOptions.ServerCertificateValidationCallback(sender, certificate, chain, sslPolicyErrors);
                }

                var certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
                certStore.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);

                SslStream sslStream = new SslStream(
                    _client.GetStream(),
                    false /* leaveInnerStreamOpen */,
                    callback,
                    null /*UserCertificateSelectionCallback */
                    );

                sslStream.AuthenticateAsClientAsync(tcpOptions.Hostname, certStore.Certificates, System.Security.Authentication.SslProtocols.Tls, false /* checkCertificateRevocation */).Wait();
                reader = new StreamReader(sslStream);
                writer = new StreamWriter(sslStream);
            }
            else
            {
                reader = new StreamReader(_client.GetStream());
                writer = new StreamWriter(_client.GetStream());
            }
        }
コード例 #3
0
        public static LaunchOptions GetInstance(string registryRoot, string exePath, string args, string dir, string options, IDeviceAppLauncherEventCallback eventCallback, TargetEngine targetEngine)
        {
            if (string.IsNullOrWhiteSpace(exePath))
            {
                throw new ArgumentNullException("exePath");
            }

            if (string.IsNullOrWhiteSpace(options))
            {
                throw new InvalidLaunchOptionsException(MICoreResources.Error_StringIsNullOrEmpty);
            }

            if (string.IsNullOrEmpty(registryRoot))
            {
                throw new ArgumentNullException("registryRoot");
            }

            Logger.WriteTextBlock("LaunchOptions", options);

            LaunchOptions launchOptions      = null;
            Guid          clsidLauncher      = Guid.Empty;
            object        launcherXmlOptions = null;

            try
            {
                using (XmlReader reader = OpenXml(options))
                {
                    switch (reader.LocalName)
                    {
                    case "LocalLaunchOptions":
                    {
                        var serializer       = new Microsoft.Xml.Serialization.GeneratedAssembly.LocalLaunchOptionsSerializer();
                        var xmlLaunchOptions = (Xml.LaunchOptions.LocalLaunchOptions)Deserialize(serializer, reader);
                        launchOptions = LocalLaunchOptions.CreateFromXml(xmlLaunchOptions);
                    }
                    break;

                    case "SerialPortLaunchOptions":
                    {
                        var serializer       = new Microsoft.Xml.Serialization.GeneratedAssembly.SerialPortLaunchOptionsSerializer();
                        var xmlLaunchOptions = (Xml.LaunchOptions.SerialPortLaunchOptions)Deserialize(serializer, reader);
                        launchOptions = SerialLaunchOptions.CreateFromXml(xmlLaunchOptions);
                    }
                    break;

                    case "PipeLaunchOptions":
                    {
                        var serializer       = new Microsoft.Xml.Serialization.GeneratedAssembly.PipeLaunchOptionsSerializer();
                        var xmlLaunchOptions = (Xml.LaunchOptions.PipeLaunchOptions)Deserialize(serializer, reader);
                        launchOptions = PipeLaunchOptions.CreateFromXml(xmlLaunchOptions);
                    }
                    break;

                    case "TcpLaunchOptions":
                    {
                        var serializer       = new Microsoft.Xml.Serialization.GeneratedAssembly.TcpLaunchOptionsSerializer();
                        var xmlLaunchOptions = (Xml.LaunchOptions.TcpLaunchOptions)Deserialize(serializer, reader);
                        launchOptions = TcpLaunchOptions.CreateFromXml(xmlLaunchOptions);
                    }
                    break;

                    case "IOSLaunchOptions":
                    {
                        var serializer = new Microsoft.Xml.Serialization.GeneratedAssembly.IOSLaunchOptionsSerializer();
                        launcherXmlOptions = Deserialize(serializer, reader);
                        clsidLauncher      = new Guid("316783D1-1824-4847-B3D3-FB048960EDCF");
                    }
                    break;

                    case "AndroidLaunchOptions":
                    {
                        var serializer = new Microsoft.Xml.Serialization.GeneratedAssembly.AndroidLaunchOptionsSerializer();
                        launcherXmlOptions = Deserialize(serializer, reader);
                        clsidLauncher      = new Guid("C9A403DA-D3AA-4632-A572-E81FF6301E9B");
                    }
                    break;

                    default:
                    {
                        throw new XmlException(string.Format(CultureInfo.CurrentCulture, MICoreResources.Error_UnknownXmlElement, reader.LocalName));
                    }
                    }

                    // Read any remaining bits of XML to catch other errors
                    while (reader.NodeType != XmlNodeType.None)
                    {
                        reader.Read();
                    }
                }
            }
            catch (XmlException e)
            {
                throw new InvalidLaunchOptionsException(e.Message);
            }

            if (clsidLauncher != Guid.Empty)
            {
                launchOptions = ExecuteLauncher(registryRoot, clsidLauncher, exePath, args, dir, launcherXmlOptions, eventCallback, targetEngine);
            }

            if (targetEngine == TargetEngine.Native)
            {
                if (launchOptions.ExePath == null)
                {
                    launchOptions.ExePath = exePath;
                }
            }

            if (string.IsNullOrEmpty(launchOptions.ExeArguments))
            {
                launchOptions.ExeArguments = args;
            }

            if (string.IsNullOrEmpty(launchOptions.WorkingDirectory))
            {
                launchOptions.WorkingDirectory = dir;
            }

            if (launchOptions._setupCommands == null)
            {
                launchOptions._setupCommands = new List <LaunchCommand>(capacity: 0).AsReadOnly();
            }

            launchOptions._initializationComplete = true;
            return(launchOptions);
        }
コード例 #4
0
ファイル: LaunchOptions.cs プロジェクト: hungdluit/MIEngine
        internal static TcpLaunchOptions CreateFromXml(Xml.LaunchOptions.TcpLaunchOptions source)
        {
            var options = new TcpLaunchOptions(RequireAttribute(source.Hostname, "Hostname"), LaunchOptions.RequirePortAttribute(source.Port, "Port"), source.Secure);
            options.InitializeCommonOptions(source);

            return options;
        }
コード例 #5
0
ファイル: Launcher.cs プロジェクト: lsgxeva/MIEngine
        void IPlatformAppLauncher.SetupForDebugging(out LaunchOptions debuggerLaunchOptions)
        {
            if (_launchOptions == null)
            {
                Debug.Fail("Why is SetupForDebugging being called before ParseLaunchOptions?");
                throw new InvalidOperationException();
            }

            _client = VcRemoteClient.GetInstance(_launchOptions);

            _remotePorts = _client.StartDebugListener();

            if (_launchOptions.IOSDebugTarget == IOSDebugTarget.Device)
            {
                _appRemotePath = _client.GetRemoteAppPath();
            }

            debuggerLaunchOptions = new TcpLaunchOptions(_launchOptions.RemoteMachineName, _remotePorts.DebugListenerPort, _launchOptions.Secure);
            (debuggerLaunchOptions as TcpLaunchOptions).ServerCertificateValidationCallback = _client.ServerCertificateValidationCallback;
            debuggerLaunchOptions.TargetArchitecture = _launchOptions.TargetArchitecture;
            debuggerLaunchOptions.AdditionalSOLibSearchPath = _launchOptions.AdditionalSOLibSearchPath;
            debuggerLaunchOptions.DebuggerMIMode = MIMode.Lldb;
            debuggerLaunchOptions.CustomLaunchSetupCommands = GetCustomLaunchSetupCommands();
            debuggerLaunchOptions.LaunchCompleteCommand = GetLaunchCompleteCommand();
        }