Exemplo n.º 1
0
 private void WriteToClient(NamedPipeMessages.ExcludeFromAntiVirusRequest.Response response)
 {
     NamedPipeMessages.Message message = response.ToMessage();
     if (!this.connection.TrySendResponse(message))
     {
         this.tracer.RelatedError("Failed to send line to client: {0}", message);
     }
 }
Exemplo n.º 2
0
        private bool ExcludeFromAntiVirusThroughService(string path, out string errorMessage)
        {
            errorMessage = string.Empty;

            NamedPipeMessages.ExcludeFromAntiVirusRequest request = new NamedPipeMessages.ExcludeFromAntiVirusRequest();
            request.ExclusionPath = path;

            using (NamedPipeClient client = new NamedPipeClient(this.ServicePipeName))
            {
                if (!client.Connect())
                {
                    errorMessage = "Unable to exclude from antivirus because GVFS.Service is not responding. " + GVFSVerb.StartServiceInstructions;
                    return(false);
                }

                try
                {
                    client.SendRequest(request.ToMessage());
                    NamedPipeMessages.Message response = client.ReadResponse();
                    if (response.Header == NamedPipeMessages.ExcludeFromAntiVirusRequest.Response.Header)
                    {
                        NamedPipeMessages.ExcludeFromAntiVirusRequest.Response message = NamedPipeMessages.ExcludeFromAntiVirusRequest.Response.FromMessage(response);

                        if (!string.IsNullOrEmpty(message.ErrorMessage))
                        {
                            errorMessage = message.ErrorMessage;
                            return(false);
                        }

                        return(message.State == NamedPipeMessages.CompletionState.Success);
                    }
                    else
                    {
                        errorMessage = string.Format("GVFS.Service responded with unexpected message: {0}", response);
                        return(false);
                    }
                }
                catch (BrokenPipeException e)
                {
                    errorMessage = "Unable to communicate with GVFS.Service: " + e.ToString();
                    return(false);
                }
            }
        }
Exemplo n.º 3
0
        public void Run()
        {
            string errorMessage;

            NamedPipeMessages.CompletionState state = NamedPipeMessages.CompletionState.Success;

            bool isExcluded;

            CheckAntiVirusExclusion(this.tracer, this.request.ExclusionPath, out isExcluded, out errorMessage);

            if (!isExcluded)
            {
                state = NamedPipeMessages.CompletionState.Failure;
            }

            NamedPipeMessages.ExcludeFromAntiVirusRequest.Response response = new NamedPipeMessages.ExcludeFromAntiVirusRequest.Response();

            response.State        = state;
            response.ErrorMessage = errorMessage;

            this.WriteToClient(response.ToMessage(), this.connection, this.tracer);
        }