Exemple #1
0
        private static void HandleRequest(string request, IPC.IConnection connection)
        {
            if (!connection.IsConnected)
            {
                throw new InvalidOperationException("Pipe connection was broken while handling request");
            }

            var message = NamedPipeMessages.Message.FromString(request);

            switch (message.Header)
            {
            case NamedPipeMessages.InjectionCompleteNotification.InjectionComplete:
                var msg     = new NamedPipeMessages.InjectionCompleteNotification(message.Body);
                var reqData = msg.RequestData;
                if (reqData.Completed)
                {
                    InjectionCompleted(reqData.PID);
                }
                else
                {
                    throw new InjectionLoadException($"Injection into process {reqData.PID} failed.");
                }
                break;

            default:
                throw new InvalidOperationException($"Message type {message.Header} is not supported");
            }
        }
Exemple #2
0
        public void HandleConnection(IPC.IConnection connection)
        {
            Console.WriteLine($"Connection received from pipe {_pipeName}");

            var pipeServer = connection.ServerStream;

            IJsonRpcServiceHost host = BuildServiceHost(_service);

            var serverHandler = new StreamRpcServerHandler(host);

            serverHandler.DefaultFeatures.Set(_session);

            using (var reader = new ByLineTextMessageReader(pipeServer))
                using (var writer = new ByLineTextMessageWriter(pipeServer))
                    using (serverHandler.Attach(reader, writer))
                    {
                        // Wait for exit
                        _session.CancellationToken.WaitHandle.WaitOne();
                    }
        }