diff --git a/README.md b/README.md index 40829db..395a219 100644 --- a/README.md +++ b/README.md @@ -271,7 +271,7 @@ details. This project makes use of the following third-party libraries: -- [Named Pipe Wrapper](https://github.com/acdvorak/named-pipe-wrapper), as `YAMDCC.IPC`, - for communication between the service and UI program. +- A modified version of Twosense's fork of [Named Pipe Wrapper](https://github.com/twosense/named-pipe-wrapper) + for communication between the service and UI program (called `YAMDCC.IPC` in the source files). - [WinRing0](https://github.com/QCute/WinRing0) for low-level hardware access required to read/write the EC. diff --git a/YAMDCC.GUI/packages.lock.json b/YAMDCC.GUI/packages.lock.json index 245e00a..8bf1cfb 100644 --- a/YAMDCC.GUI/packages.lock.json +++ b/YAMDCC.GUI/packages.lock.json @@ -14,96 +14,6 @@ "resolved": "4.5.0", "contentHash": "221clPs1445HkTBZPL+K9sDBdJRB8UN8rgjO3ztB0CQ26z//fmJXtlsr6whGatscsKGBrhJl5bwJuKSA8mwFOw==" }, - "MessagePack": { - "type": "Transitive", - "resolved": "2.5.171", - "contentHash": "eX0wTFtE4teu2iDWm/eEGqvVEeO9dqaRXu6MXu1MnhQ/wBkixEjh+1SlKaSh41LL5L7WUJlK04EBpz8FSaGOqw==", - "dependencies": { - "MessagePack.Annotations": "2.5.171", - "Microsoft.Bcl.AsyncInterfaces": "6.0.0", - "Microsoft.NET.StringTools": "17.6.3", - "System.Collections.Immutable": "6.0.0", - "System.Runtime.CompilerServices.Unsafe": "6.0.0", - "System.Threading.Tasks.Extensions": "4.5.4" - } - }, - "MessagePack.Annotations": { - "type": "Transitive", - "resolved": "2.5.171", - "contentHash": "iS5Zb6uiPn3QJVL814+xWlWeH/rW+p2qPoECjOhL7RV71ppld4vDpej5rq4YrxGdLtR66zf+AQwW919sPVMWgw==" - }, - "Microsoft.Bcl.AsyncInterfaces": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "UcSjPsst+DfAdJGVDsu346FX0ci0ah+lw3WRtn18NUwEqRt70HaOQ7lI72vy3+1LxtqI3T5GWwV39rQSrCzAeg==", - "dependencies": { - "System.Threading.Tasks.Extensions": "4.5.4" - } - }, - "Microsoft.NET.StringTools": { - "type": "Transitive", - "resolved": "17.6.3", - "contentHash": "N0ZIanl1QCgvUumEL1laasU0a7sOE5ZwLZVTn0pAePnfhq8P7SvTjF8Axq+CnavuQkmdQpGNXQ1efZtu5kDFbA==", - "dependencies": { - "System.Memory": "4.5.5", - "System.Runtime.CompilerServices.Unsafe": "6.0.0" - } - }, - "System.Buffers": { - "type": "Transitive", - "resolved": "4.5.1", - "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" - }, - "System.CodeDom": { - "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "WTlRjL6KWIMr/pAaq3rYqh0TJlzpouaQ/W1eelssHgtlwHAH25jXTkUphTYx9HaIIf7XA6qs/0+YhtLEQRkJ+Q==" - }, - "System.Collections.Immutable": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "l4zZJ1WU2hqpQQHXz1rvC3etVZN+2DLmQMO79FhOTZHMn8tDRr+WU287sbomD0BETlmKDn0ygUgVy9k5xkkJdA==", - "dependencies": { - "System.Memory": "4.5.4", - "System.Runtime.CompilerServices.Unsafe": "6.0.0" - } - }, - "System.Management": { - "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "jrK22i5LRzxZCfGb+tGmke2VH7oE0DvcDlJ1HAKYU8cPmD8XnpUT0bYn2Gy98GEhGjtfbR/sxKTVb+dE770pfA==", - "dependencies": { - "System.CodeDom": "8.0.0" - } - }, - "System.Memory": { - "type": "Transitive", - "resolved": "4.5.5", - "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Numerics.Vectors": "4.5.0", - "System.Runtime.CompilerServices.Unsafe": "4.5.3" - } - }, - "System.Numerics.Vectors": { - "type": "Transitive", - "resolved": "4.5.0", - "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" - }, - "System.Runtime.CompilerServices.Unsafe": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg==" - }, - "System.Threading.Tasks.Extensions": { - "type": "Transitive", - "resolved": "4.5.4", - "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", - "dependencies": { - "System.Runtime.CompilerServices.Unsafe": "4.5.3" - } - }, "yamdcc.config": { "type": "Project", "dependencies": { @@ -121,7 +31,6 @@ "yamdcc.ipc": { "type": "Project", "dependencies": { - "MessagePack": "[2.5.171, )", "Microsoft.CSharp": "[4.7.0, )", "System.Data.DataSetExtensions": "[4.5.0, )" } @@ -138,7 +47,6 @@ "dependencies": { "Microsoft.CSharp": "[4.7.0, )", "System.Data.DataSetExtensions": "[4.5.0, )", - "System.Management": "[8.0.0, )", "YAMDCC.Config": "[1.0.0, )", "YAMDCC.ECAccess": "[1.0.0, )", "YAMDCC.IPC": "[1.0.0, )", diff --git a/YAMDCC.IPC/IO/PipeStreamReader.cs b/YAMDCC.IPC/IO/PipeStreamReader.cs index e154473..b9325d0 100644 --- a/YAMDCC.IPC/IO/PipeStreamReader.cs +++ b/YAMDCC.IPC/IO/PipeStreamReader.cs @@ -1,32 +1,37 @@ -using MessagePack; using System; using System.IO; using System.IO.Pipes; using System.Net; using System.Runtime.Serialization; +using System.Runtime.Serialization.Formatters.Binary; +using System.Text; namespace YAMDCC.IPC.IO { /// - /// Wraps a object and reads from it. Deserializes - /// binary data sent by a into a .NET CLR - /// object specified by . + /// Wraps a object and reads from it. + /// Deserializes binary data sent by a + /// into a .NET CLR object specified by . /// - /// Reference type to deserialize data to - public class PipeStreamReader + /// + /// Reference type to deserialize data to + /// + public class PipeStreamReader where T : class { /// /// Gets the underlying PipeStream object. /// - public PipeStream BaseStream { get; } + public PipeStream BaseStream { get; private set; } /// /// Gets a value indicating whether the pipe is connected or not. /// public bool IsConnected { get; private set; } + private readonly BinaryFormatter _binaryFormatter = new BinaryFormatter(); + /// - /// Constructs a new PipeStreamReader object that + /// Constructs a new object that /// reads data from the given . /// /// Pipe to read from @@ -41,9 +46,16 @@ public PipeStreamReader(PipeStream stream) /// /// Reads the length of the next message (in bytes) from the client. /// - /// Number of bytes of data the client will be sending. - /// The pipe is disconnected, waiting to connect, or the handle has not been set. - /// Any I/O error occurred. + /// + /// Number of bytes of data the client will be sending. + /// + /// + /// The pipe is disconnected, waiting to connect, + /// or the handle has not been set. + /// + /// + /// Any I/O error occurred. + /// private int ReadLength() { const int lensize = sizeof(int); @@ -59,14 +71,17 @@ private int ReadLength() : IPAddress.NetworkToHostOrder(BitConverter.ToInt32(lenbuf, 0)); } + /// + /// An object in the graph of type parameter + /// is not marked as serializable. + /// private T ReadObject(int len) { byte[] data = new byte[len]; BaseStream.Read(data, 0, len); - using (MemoryStream memoryStream = new MemoryStream(data)) { - return MessagePackSerializer.Deserialize(memoryStream); + return (T) _binaryFormatter.Deserialize(memoryStream); } } @@ -86,8 +101,22 @@ private T ReadObject(int len) /// public T ReadObject() { + if (typeof(T) == typeof(string)) + { + return (T) ReadString(); + } int len = ReadLength(); return len == 0 ? default : ReadObject(len); } + + private object ReadString() + { + const int bufferSize = 1024; + byte[] data = new byte[bufferSize]; + BaseStream.Read(data, 0, bufferSize); + string message = Encoding.Unicode.GetString(data).TrimEnd('\0'); + + return message.Length > 0 ? message : null; + } } } diff --git a/YAMDCC.IPC/IO/PipeStreamWrapper.cs b/YAMDCC.IPC/IO/PipeStreamWrapper.cs index c6a9ddc..6a2e5f2 100644 --- a/YAMDCC.IPC/IO/PipeStreamWrapper.cs +++ b/YAMDCC.IPC/IO/PipeStreamWrapper.cs @@ -8,28 +8,39 @@ namespace YAMDCC.IPC.IO /// /// Wraps a object to read and write .NET CLR objects. /// - /// Reference type to read from and write to the pipe + /// + /// Reference type to read from and write to the pipe + /// public class PipeStreamWrapper : PipeStreamWrapper where TRdWr : class { /// - /// Constructs a new PipeStreamWrapper object that reads from and writes to the given . + /// Constructs a new PipeStreamWrapper object that + /// reads from and writes to the given . /// - /// Stream to read from and write to + /// + /// Stream to read from and write to + /// public PipeStreamWrapper(PipeStream stream) : base(stream) { } } /// /// Wraps a object to read and write .NET CLR objects. /// - /// Reference type to read from the pipe - /// Reference type to write to the pipe + /// + /// Reference type to read from the pipe + /// + /// + /// Reference type to write to the pipe + /// public class PipeStreamWrapper + where TRd : class + where TWr : class { /// /// Gets the underlying PipeStream object. /// - public readonly PipeStream BaseStream; + public PipeStream BaseStream { get; private set; } /// /// Gets a value indicating whether the @@ -65,8 +76,8 @@ public class PipeStreamWrapper private readonly PipeStreamWriter _writer; /// - /// Constructs a new PipeStreamWrapper object that reads from - /// and writes to the given . + /// Constructs a new PipeStreamWrapper object that reads + /// from and writes to the given . /// /// Stream to read from and write to public PipeStreamWrapper(PipeStream stream) @@ -77,8 +88,8 @@ public PipeStreamWrapper(PipeStream stream) } /// - /// Reads the next object from the pipe. This method blocks until an - /// object is sent or the pipe is disconnected. + /// Reads the next object from the pipe. This method blocks + /// until an object is sent or the pipe is disconnected. /// /// /// The next object read from the pipe, or @@ -88,20 +99,20 @@ public PipeStreamWrapper(PipeStream stream) /// An object in the graph of type parameter /// is not marked as serializable. /// - public TRd ReadObject() => - _reader.ReadObject(); + public TRd ReadObject() => _reader.ReadObject(); /// - /// Writes an object to the pipe. This - /// method blocks until all data is sent. + /// Writes an object to the pipe. + /// This method blocks until all data is sent. /// - /// Object to write to the pipe + /// + /// Object to write to the pipe + /// /// /// An object in the graph of type parameter /// is not marked as serializable. /// - public void WriteObject(TWr obj) => - _writer.WriteObject(obj); + public void WriteObject(TWr obj) => _writer.WriteObject(obj); /// /// Waits for the other end of the pipe to read all sent bytes. @@ -115,14 +126,12 @@ public void WriteObject(TWr obj) => /// /// The pipe is broken or another I/O error occurred. /// - public void WaitForPipeDrain() => - _writer.WaitForPipeDrain(); + public void WaitForPipeDrain() => _writer.WaitForPipeDrain(); /// - /// Closes the current stream and releases any resources (such as - /// sockets and file handles) associated with the current stream. + /// Closes the current stream and releases any resources + /// (such as sockets and file handles) associated with the current stream. /// - public void Close() => - BaseStream.Close(); + public void Close() => BaseStream.Close(); } } diff --git a/YAMDCC.IPC/IO/PipeStreamWriter.cs b/YAMDCC.IPC/IO/PipeStreamWriter.cs index c58e679..1b0b632 100644 --- a/YAMDCC.IPC/IO/PipeStreamWriter.cs +++ b/YAMDCC.IPC/IO/PipeStreamWriter.cs @@ -1,50 +1,51 @@ -using MessagePack; using System; using System.IO; using System.IO.Pipes; using System.Net; using System.Runtime.Serialization; +using System.Runtime.Serialization.Formatters.Binary; +using System.Text; namespace YAMDCC.IPC.IO { /// - /// Wraps a object and writes to it. Serializes - /// .NET CLR objects specified by into - /// binary form and sends them over the named pipe for a + /// Wraps a object and writes to it. + /// Serializes .NET CLR objects specified by + /// into binary form and sends them over the named pipe for a /// to read and deserialize. /// /// Reference type to serialize - public class PipeStreamWriter + public class PipeStreamWriter where T : class { /// /// Gets the underlying PipeStream object. /// - public PipeStream BaseStream { get; } + public PipeStream BaseStream { get; private set; } + + private readonly BinaryFormatter _binaryFormatter = new BinaryFormatter(); /// /// Constructs a new PipeStreamWriter object /// that writes to given . /// /// Pipe to write to - public PipeStreamWriter(PipeStream stream) => + public PipeStreamWriter(PipeStream stream) + { BaseStream = stream; + } #region Private stream writers + + /// + /// An object in the graph of type parameter + /// is not marked as serializable. + /// private byte[] Serialize(T obj) { - try - { - using (MemoryStream memoryStream = new MemoryStream()) - { - MessagePackSerializer.Serialize(memoryStream, obj); - return memoryStream.ToArray(); - } - } - catch + using (MemoryStream memoryStream = new MemoryStream()) { - // if any exception in the serialize, it will stop named - // pipe wrapper, so there will ignore any exception. - return Array.Empty(); + _binaryFormatter.Serialize(memoryStream, obj); + return memoryStream.ToArray(); } } @@ -57,24 +58,33 @@ private void WriteLength(int len) private void WriteObject(byte[] data) => BaseStream.Write(data, 0, data.Length); - private void Flush() => - BaseStream.Flush(); + private void Flush() => BaseStream.Flush(); #endregion /// - /// Writes an object to the pipe. This - /// method blocks until all data is sent. + /// Writes an object to the pipe. + /// This method blocks until all data is sent. /// - /// Object to write to the pipe + /// + /// Object to write to the pipe + /// /// /// An object in the graph of type parameter /// is not marked as serializable. /// public void WriteObject(T obj) { - byte[] data = Serialize(obj); - WriteLength(data.Length); + byte[] data; + if (typeof(T) == typeof(string)) + { + data = Encoding.Unicode.GetBytes(obj.ToString()); + } + else + { + data = Serialize(obj); + WriteLength(data.Length); + } WriteObject(data); Flush(); } @@ -91,7 +101,6 @@ public void WriteObject(T obj) /// /// The pipe is broken or another I/O error occurred. /// - public void WaitForPipeDrain() => - BaseStream.WaitForPipeDrain(); + public void WaitForPipeDrain() => BaseStream.WaitForPipeDrain(); } } diff --git a/YAMDCC.IPC/NamedPipeClient.cs b/YAMDCC.IPC/NamedPipeClient.cs index 49cc933..140c7fe 100644 --- a/YAMDCC.IPC/NamedPipeClient.cs +++ b/YAMDCC.IPC/NamedPipeClient.cs @@ -1,5 +1,7 @@ using System; +using System.IO; using System.IO.Pipes; +using System.Runtime.InteropServices; using System.Threading; using YAMDCC.IPC.IO; using YAMDCC.IPC.Threading; @@ -12,7 +14,7 @@ namespace YAMDCC.IPC /// /// Reference type to read from and write to the named pipe /// - public class NamedPipeClient : NamedPipeClient + public class NamedPipeClient : NamedPipeClient where TRdWr : class { /// /// Constructs a new NamedPipeClient to connect to the @@ -20,9 +22,7 @@ public class NamedPipeClient : NamedPipeClient /// . /// /// Name of the server's pipe - /// server name default is local. - public NamedPipeClient(string pipeName, string serverName = ".") - : base(pipeName, serverName) { } + public NamedPipeClient(string pipeName) : base(pipeName) { } } /// @@ -30,7 +30,9 @@ public NamedPipeClient(string pipeName, string serverName = ".") /// /// Reference type to read from the named pipe /// Reference type to write to the named pipe - public class NamedPipeClient : IDisposable + public class NamedPipeClient + where TRd : class + where TWr : class { /// /// Gets or sets whether the client should attempt to reconnect when the pipe breaks @@ -39,6 +41,12 @@ public class NamedPipeClient : IDisposable /// public bool AutoReconnect; + /// + /// Gets or sets how long the client waits between a reconnection attempt. + /// Default value is 0. + /// + public int AutoReconnectDelay; + /// /// Invoked whenever a message is received from the server. /// @@ -61,22 +69,16 @@ public class NamedPipeClient : IDisposable private readonly AutoResetEvent _disconnected = new AutoResetEvent(false); private volatile bool _closedExplicitly; - private bool _disposed; - - /// - /// The server name, which client will connect to. - /// - private readonly string _serverName; /// - /// Constructs a new NamedPipeClient to connect to the named pipe server specified by . + /// Constructs a new to connect to the + /// specified by + /// . /// /// Name of the server's pipe - /// the Name of the server, default is local machine - public NamedPipeClient(string pipeName, string serverName = ".") + public NamedPipeClient(string pipeName) { _pipeName = pipeName; - _serverName = serverName; AutoReconnect = true; } @@ -96,8 +98,7 @@ public void Start() /// Sends a message to the server over a named pipe. /// /// Message to send to the server. - public void PushMessage(TWr message) => - _connection?.PushMessage(message); + public void PushMessage(TWr message) => _connection?.PushMessage(message); /// /// Closes the named pipe. @@ -170,12 +171,12 @@ public void WaitForDisconnection(TimeSpan timeout) => private void ListenSync() { // Get the name of the data pipe that should be used from now on by this NamedPipeClient - PipeStreamWrapper handshake = PipeClientFactory.Connect(_pipeName, _serverName); + PipeStreamWrapper handshake = PipeClientFactory.Connect(_pipeName); string dataPipeName = handshake.ReadObject(); handshake.Close(); // Connect to the actual data pipe - NamedPipeClientStream dataPipe = PipeClientFactory.CreateAndConnectPipe(dataPipeName, _serverName); + NamedPipeClientStream dataPipe = PipeClientFactory.CreateAndConnectPipe(dataPipeName); // Create a Connection object for the data pipe _connection = ConnectionFactory.CreateConnection(dataPipe); @@ -189,80 +190,94 @@ private void ListenSync() private void OnDisconnected(NamedPipeConnection connection) { - Disconnected?.Invoke(connection); + if (Disconnected != null) + Disconnected(connection); _disconnected.Set(); // Reconnect if (AutoReconnect && !_closedExplicitly) + { + Thread.Sleep(AutoReconnectDelay); Start(); + } } - private void OnReceiveMessage(NamedPipeConnection connection, TRd message) => - ServerMessage?.Invoke(connection, message); + private void OnReceiveMessage(NamedPipeConnection connection, TRd message) + { + if (ServerMessage != null) + ServerMessage(connection, message); + } /// - /// Invoked on the UI thread. + /// Invoked on the UI thread. /// - private void ConnectionOnError(NamedPipeConnection connection, Exception exception) => + private void ConnectionOnError(NamedPipeConnection connection, Exception exception) + { OnError(exception); + } /// - /// Invoked on the UI thread. + /// Invoked on the UI thread. /// /// - private void OnError(Exception exception) => - Error?.Invoke(exception); + private void OnError(Exception exception) + { + if (Error != null) + Error(exception); + } #endregion + } - #region Cleanup/Dispose code - /// - /// The destructor for the . - /// - ~NamedPipeClient() + internal static class PipeClientFactory + { + [return: MarshalAs(UnmanagedType.Bool)] + [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] + private static extern bool WaitNamedPipe(string name, int timeout); + + public static bool NamedPipeExists(string pipeName) { - Dispose(false); + try + { + bool exists = WaitNamedPipe(pipeName, -1); + if (!exists) + { + int error = Marshal.GetLastWin32Error(); + if (error == 0 || error == 2) + { + return false; + } + } + return true; + } + catch (Exception) + { + return false; + } } - /// - /// Releases all resources associated with the - /// . - /// - public void Dispose() + public static PipeStreamWrapper Connect(string pipeName) + where TRd : class + where TWr : class { - Dispose(true); - GC.SuppressFinalize(this); + return new PipeStreamWrapper(CreateAndConnectPipe(pipeName)); } - protected virtual void Dispose(bool disposing) + public static NamedPipeClientStream CreateAndConnectPipe(string pipeName, int timeout = 10) { - if (_disposed) return; - - if (disposing) + string normalizedPath = Path.GetFullPath(string.Format(@"\\.\pipe\{0}", pipeName)); + while (!NamedPipeExists(normalizedPath)) { - _connected.Dispose(); - _disconnected.Dispose(); + Thread.Sleep(timeout); } - - _disposed = true; - } - #endregion - } - - internal static class PipeClientFactory - { - public static PipeStreamWrapper Connect(string pipeName, string serverName) => - new PipeStreamWrapper(CreateAndConnectPipe(pipeName, serverName)); - - public static NamedPipeClientStream CreateAndConnectPipe(string pipeName, string serverName) - { - NamedPipeClientStream pipe = CreatePipe(pipeName, serverName); - pipe.Connect(); + NamedPipeClientStream pipe = CreatePipe(pipeName); + pipe.Connect(1000); return pipe; } - private static NamedPipeClientStream CreatePipe(string pipeName, string serverName) => - new NamedPipeClientStream(serverName, pipeName, PipeDirection.InOut, PipeOptions.Asynchronous | PipeOptions.WriteThrough); + private static NamedPipeClientStream CreatePipe(string pipeName) => + new NamedPipeClientStream(".", pipeName, PipeDirection.InOut, + PipeOptions.Asynchronous | PipeOptions.WriteThrough); } } diff --git a/YAMDCC.IPC/NamedPipeConnection.cs b/YAMDCC.IPC/NamedPipeConnection.cs index d609129..f5c707a 100644 --- a/YAMDCC.IPC/NamedPipeConnection.cs +++ b/YAMDCC.IPC/NamedPipeConnection.cs @@ -1,6 +1,7 @@ using System; -using System.Collections.Concurrent; +using System.Collections.Generic; using System.IO.Pipes; +using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Threading; using YAMDCC.IPC.IO; @@ -11,9 +12,11 @@ namespace YAMDCC.IPC /// /// Represents a connection between a named pipe client and server. /// - /// Reference type to read from the named pipe - /// Reference type to write to the named pipe - public sealed class NamedPipeConnection : IDisposable + /// Reference type to read from the named pipe + /// Reference type to write to the named pipe + public sealed class NamedPipeConnection + where TRd : class + where TWr : class { /// /// Gets the connection's unique identifier. @@ -25,6 +28,11 @@ public sealed class NamedPipeConnection : IDisposable /// public readonly string Name; + /// + /// Gets the connection's handle. + /// + public readonly SafeHandle Handle; + /// /// Gets a value indicating whether the pipe is connected or not. /// @@ -33,35 +41,31 @@ public sealed class NamedPipeConnection : IDisposable /// /// Invoked when the named pipe connection terminates. /// - public event ConnectionEventHandler Disconnected; + public event ConnectionEventHandler Disconnected; /// /// Invoked whenever a message is received from the other end of the pipe. /// - public event ConnectionMessageEventHandler ReceiveMessage; + public event ConnectionMessageEventHandler ReceiveMessage; /// /// Invoked when an exception is thrown during any read/write operation over the named pipe. /// - public event ConnectionExceptionEventHandler Error; + public event ConnectionExceptionEventHandler Error; - private readonly PipeStreamWrapper _streamWrapper; + private readonly PipeStreamWrapper _streamWrapper; private readonly AutoResetEvent _writeSignal = new AutoResetEvent(false); - /// - /// To support Multithread, we should use BlockingCollection. - /// - private readonly BlockingCollection _writeQueue - = new BlockingCollection(); + private readonly Queue _writeQueue = new Queue(); private bool _notifiedSucceeded; - private bool _disposed; internal NamedPipeConnection(int id, string name, PipeStream serverStream) { ID = id; Name = name; - _streamWrapper = new PipeStreamWrapper(serverStream); + Handle = serverStream.SafePipeHandle; + _streamWrapper = new PipeStreamWrapper(serverStream); } /// @@ -71,12 +75,12 @@ internal NamedPipeConnection(int id, string name, PipeStream serverStream) public void Open() { Worker readWorker = new Worker(); - readWorker.Succeeded += OnSucceed; + readWorker.Succeeded += OnSucceeded; readWorker.Error += OnError; readWorker.DoWork(ReadPipe); Worker writeWorker = new Worker(); - writeWorker.Succeeded += OnSucceed; + writeWorker.Succeeded += OnSucceeded; writeWorker.Error += OnError; writeWorker.DoWork(WritePipe); } @@ -87,9 +91,9 @@ public void Open() /// at the next available opportunity. /// /// - public void PushMessage(TWrite message) + public void PushMessage(TWr message) { - _writeQueue.Add(message); + _writeQueue.Enqueue(message); _writeSignal.Set(); } @@ -105,11 +109,13 @@ public void Close() /// /// Invoked on the UI thread. /// - private void OnSucceed() + private void OnSucceeded() { // Only notify observers once if (_notifiedSucceeded) + { return; + } _notifiedSucceeded = true; @@ -126,94 +132,80 @@ private void OnError(Exception exception) => /// /// Invoked on the background thread. /// - /// An object in the graph of type parameter is not marked as serializable. + /// An object in the graph of type parameter is not marked as serializable. private void ReadPipe() { while (IsConnected && _streamWrapper.CanRead) { - try + TRd obj = _streamWrapper.ReadObject(); + if (obj == null) { - TRead obj = _streamWrapper.ReadObject(); - if (obj == null) - { - Close(); - return; - } - ReceiveMessage?.Invoke(this, obj); - } - catch - { - //we must igonre exception, otherwise, the namepipe wrapper will stop work. + Close(); + return; } + ReceiveMessage?.Invoke(this, obj); } } /// /// Invoked on the background thread. /// - /// An object in the graph of type parameter is not marked as serializable. + /// An object in the graph of type parameter is not marked as serializable. private void WritePipe() { while (IsConnected && _streamWrapper.CanWrite) { - try + _writeSignal.WaitOne(); + while (_writeQueue.Count > 0) { - _streamWrapper.WriteObject(_writeQueue.Take()); + _streamWrapper.WriteObject(_writeQueue.Dequeue()); _streamWrapper.WaitForPipeDrain(); } - catch - { - //we must igonre exception, otherwise, the namepipe wrapper will stop work. - } } } - - /// - /// Releases all resources associated with the - /// . - /// - public void Dispose() - { - if (_disposed) return; - - _writeQueue.Dispose(); - _writeSignal.Dispose(); - - _disposed = true; - } } internal static class ConnectionFactory { private static int _lastId; - public static NamedPipeConnection CreateConnection(PipeStream pipeStream) => - new NamedPipeConnection(++_lastId, "Client " + _lastId, pipeStream); + public static NamedPipeConnection CreateConnection(PipeStream pipeStream) + where TRd : class + where TWr : class + { + return new NamedPipeConnection(++_lastId, "Client " + _lastId, pipeStream); + } } /// /// Handles new connections. /// /// The newly established connection - /// Reference type - /// Reference type - public delegate void ConnectionEventHandler(NamedPipeConnection connection); + /// Reference type + /// Reference type + public delegate void ConnectionEventHandler(NamedPipeConnection connection) + where TRd : class + where TWr : class; /// /// Handles messages received from a named pipe. /// - /// Reference type - /// Reference type + /// Reference type + /// Reference type /// Connection that received the message /// Message sent by the other end of the pipe - public delegate void ConnectionMessageEventHandler(NamedPipeConnection connection, TRead message); + public delegate void ConnectionMessageEventHandler(NamedPipeConnection connection, TRd message) + where TRd : class + where TWr : class; /// /// Handles exceptions thrown during read/write operations. /// - /// Reference type - /// Reference type + /// Reference type + /// Reference type /// Connection that threw the exception /// The exception that was thrown - public delegate void ConnectionExceptionEventHandler(NamedPipeConnection connection, Exception exception); + public delegate void ConnectionExceptionEventHandler(NamedPipeConnection connection, Exception exception) + where TRd : class + where TWr : class; } diff --git a/YAMDCC.IPC/NamedPipeServer.cs b/YAMDCC.IPC/NamedPipeServer.cs index 546938d..d9d5a92 100644 --- a/YAMDCC.IPC/NamedPipeServer.cs +++ b/YAMDCC.IPC/NamedPipeServer.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO.Pipes; +using System.Linq; using YAMDCC.IPC.IO; using YAMDCC.IPC.Threading; @@ -20,18 +21,28 @@ public class NamedPipeServer : Server /// Constructs a new object /// that listens for client connections on the given . /// - /// The name of the pipe to listen on. - public NamedPipeServer(string pipeName) : base(pipeName, null) { } + /// + /// The name of the pipe to listen on. + /// + public NamedPipeServer(string pipeName) : base(pipeName) { } /// /// Constructs a new object /// that listens for client connections on the given , - /// with the given . + /// with the given . /// - /// Name of the pipe to listen on - /// The access control object for the pipe - public NamedPipeServer(string pipeName, PipeSecurity pipeSecurity) - : base(pipeName, pipeSecurity) { } + /// + /// The name of the pipe to listen on. + /// + /// + /// The size of input and output buffer. + /// + /// + /// The object that determines the access control + /// and audit security for the pipe. + /// + public NamedPipeServer(string pipeName, int bufferSize, PipeSecurity security) + : base(pipeName, bufferSize, security) { } } /// @@ -41,6 +52,8 @@ public NamedPipeServer(string pipeName, PipeSecurity pipeSecurity) /// Reference type to read from the named pipe /// Reference type to write to the named pipe public class Server + where TRd : class + where TWr : class { /// /// Invoked whenever a client connects to the server. @@ -63,29 +76,40 @@ public class Server public event PipeExceptionEventHandler Error; private readonly string _pipeName; - private readonly PipeSecurity _pipeSecurity; - private readonly List> _connections - = new List>(); + private readonly int _bufferSize; + private readonly PipeSecurity _security; + private readonly List> _connections = new List>(); private int _nextPipeId; private volatile bool _shouldKeepRunning; + /// + /// Constructs a new NamedPipeServer object that listens for client connections on the given . + /// + /// Name of the pipe to listen on + public Server(string pipeName) + { + _pipeName = pipeName; + } + /// /// Constructs a new NamedPipeServer object that listens /// for client connections on the given . /// /// Name of the pipe to listen on - /// The access control object for the pipe - public Server(string pipeName, PipeSecurity pipeSecurity) + /// Size of input and output buffer + /// And object that determine the access control and audit security for the pipe + public Server(string pipeName, int bufferSize, PipeSecurity security) { _pipeName = pipeName; - _pipeSecurity = pipeSecurity; + _bufferSize = bufferSize; + _security = security; } /// - /// Begins listening for client connections in a separate - /// background thread. This method returns immediately. + /// Begins listening for client connections in a separate background thread. + /// This method returns immediately. /// public void Start() { @@ -96,9 +120,9 @@ public void Start() } /// - /// Sends a message to all connected clients asynchronously. This - /// method returns immediately, possibly before the message has been - /// sent to all clients. + /// Sends a message to all connected clients asynchronously. + /// This method returns immediately, possibly before the + /// message has been sent to all clients. /// /// public void PushMessage(TWr message) @@ -113,18 +137,97 @@ public void PushMessage(TWr message) } /// - /// push message to the given client. + /// Sends a message to a specific client asynchronously. + /// This method returns immediately, possibly before the message has been sent to all clients. /// /// - /// - public void PushMessage(TWr message, string clientName) + /// Specific client ID to send to. + public void PushMessage(TWr message, int targetId) { lock (_connections) { + // Can we speed this up with Linq or does that add overhead? foreach (NamedPipeConnection client in _connections) { - if (client.Name == clientName) + if (client.ID == targetId) + { client.PushMessage(message); + break; + } + } + } + } + + /// + /// Sends a message to a specific clients asynchronously. + /// This method returns immediately, possibly before the message has been sent to all clients. + /// + /// + /// A list of client ID's to send to. + public void PushMessage(TWr message, List targetIds) + { + lock (_connections) + { + // Can we speed this up with Linq or does that add overhead? + foreach (NamedPipeConnection client in _connections) + { + if (targetIds.Contains(client.ID)) + { + client.PushMessage(message); + } + } + } + } + + /// + /// Sends a message to a specific clients asynchronously. + /// This method returns immediately, possibly before the message has been sent to all clients. + /// + /// + /// An array of client ID's to send to. + public void PushMessage(TWr message, int[] targetIds) + { + PushMessage(message, targetIds.ToList()); + } + + /// + /// Sends a message to a specific client asynchronously. + /// This method returns immediately, possibly before the message has been sent to all clients. + /// + /// + /// Specific client name to send to. + public void PushMessage(TWr message, string targetName) + { + lock (_connections) + { + // Can we speed this up with Linq or does that add overhead? + foreach (NamedPipeConnection client in _connections) + { + if (client.Name.Equals(targetName)) + { + client.PushMessage(message); + break; + } + } + } + } + + /// + /// Sends a message to a specific client asynchronously. + /// This method returns immediately, possibly before the message has been sent to all clients. + /// + /// + /// A list of client names to send to. + public void PushMessage(TWr message, List targetNames) + { + lock (_connections) + { + foreach (NamedPipeConnection client in _connections) + { + if (targetNames.Contains(client.Name)) + { + client.PushMessage(message); + } } } } @@ -146,9 +249,7 @@ public void Stop() // If background thread is still listening for a client to connect, // initiate a dummy connection that will allow the thread to exit. - //dummy connection will use the local server name. - NamedPipeClient dummyClient - = new NamedPipeClient(_pipeName, "."); + NamedPipeClient dummyClient = new NamedPipeClient(_pipeName); dummyClient.Start(); dummyClient.WaitForConnection(TimeSpan.FromSeconds(2)); dummyClient.Stop(); @@ -161,30 +262,33 @@ private void ListenSync() { while (_shouldKeepRunning) { - WaitForConnection(_pipeName, _pipeSecurity); + WaitForConnection(); } } - private void WaitForConnection(string pipeName, PipeSecurity pipeSecurity) + private void WaitForConnection() { NamedPipeServerStream handshakePipe = null; NamedPipeServerStream dataPipe = null; NamedPipeConnection connection = null; - string connectionPipeName = GetNextConnectionPipeName(pipeName); + string connectionPipeName = GetNextConnectionPipeName(); try { + dataPipe = CreatePipe(connectionPipeName); + // Send the client the name of the data pipe to use - handshakePipe = PipeServerFactory.CreateAndConnectPipe(pipeName, pipeSecurity); + handshakePipe = CreateAndConnectPipe(); + PipeStreamWrapper handshakeWrapper = new PipeStreamWrapper(handshakePipe); + handshakeWrapper.WriteObject(connectionPipeName); handshakeWrapper.WaitForPipeDrain(); handshakeWrapper.Close(); // Wait for the client to connect to the data pipe - dataPipe = PipeServerFactory.CreatePipe(connectionPipeName, pipeSecurity); dataPipe.WaitForConnection(); // Add the client's connection to the list of connections @@ -213,6 +317,20 @@ PipeStreamWrapper handshakeWrapper } } + private NamedPipeServerStream CreateAndConnectPipe() + { + return _security == null + ? PipeServerFactory.CreateAndConnectPipe(_pipeName) + : PipeServerFactory.CreateAndConnectPipe(_pipeName, _bufferSize, _security); + } + + private NamedPipeServerStream CreatePipe(string connectionPipeName) + { + return _security == null + ? PipeServerFactory.CreatePipe(connectionPipeName) + : PipeServerFactory.CreatePipe(connectionPipeName, _bufferSize, _security); + } + private void ClientOnConnected(NamedPipeConnection connection) => ClientConnected?.Invoke(connection); @@ -221,8 +339,7 @@ private void ClientOnReceiveMessage(NamedPipeConnection connection, TR private void ClientOnDisconnected(NamedPipeConnection connection) { - if (connection == null) - return; + if (connection == null) return; lock (_connections) { @@ -245,12 +362,13 @@ private void ConnectionOnError(NamedPipeConnection connection, Excepti private void OnError(Exception exception) => Error?.Invoke(exception); - private string GetNextConnectionPipeName(string pipeName) => - $"{pipeName}_{++_nextPipeId}"; + private string GetNextConnectionPipeName() => + $"{_pipeName}_{++_nextPipeId}"; private static void Cleanup(NamedPipeServerStream pipe) { if (pipe == null) return; + using (NamedPipeServerStream x = pipe) { x.Close(); @@ -259,19 +377,4 @@ private static void Cleanup(NamedPipeServerStream pipe) #endregion } - - internal static class PipeServerFactory - { - public static NamedPipeServerStream CreateAndConnectPipe(string pipeName, PipeSecurity pipeSecurity) - { - NamedPipeServerStream pipe = CreatePipe(pipeName, pipeSecurity); - pipe.WaitForConnection(); - return pipe; - } - - public static NamedPipeServerStream CreatePipe(string pipeName, PipeSecurity pipeSecurity) => - new NamedPipeServerStream( - pipeName, PipeDirection.InOut, 1, PipeTransmissionMode.Byte, - PipeOptions.Asynchronous | PipeOptions.WriteThrough, 0, 0, pipeSecurity); - } } diff --git a/YAMDCC.IPC/PipeExceptionEventHandler.cs b/YAMDCC.IPC/PipeExceptionEventHandler.cs index a7dbeda..dfe91a3 100644 --- a/YAMDCC.IPC/PipeExceptionEventHandler.cs +++ b/YAMDCC.IPC/PipeExceptionEventHandler.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace YAMDCC.IPC { @@ -7,4 +7,4 @@ namespace YAMDCC.IPC /// /// Exception that was thrown public delegate void PipeExceptionEventHandler(Exception exception); -} +} \ No newline at end of file diff --git a/YAMDCC.IPC/PipeServerFactory.cs b/YAMDCC.IPC/PipeServerFactory.cs new file mode 100644 index 0000000..a49888d --- /dev/null +++ b/YAMDCC.IPC/PipeServerFactory.cs @@ -0,0 +1,35 @@ +using System.IO.Pipes; + +namespace YAMDCC.IPC +{ + internal static class PipeServerFactory + { + public static NamedPipeServerStream CreateAndConnectPipe(string pipeName) + { + NamedPipeServerStream pipe = CreatePipe(pipeName); + pipe.WaitForConnection(); + + return pipe; + } + + public static NamedPipeServerStream CreatePipe(string pipeName) + { + return new NamedPipeServerStream(pipeName, PipeDirection.InOut, 1, PipeTransmissionMode.Message, + PipeOptions.Asynchronous); + } + + public static NamedPipeServerStream CreateAndConnectPipe(string pipeName, int bufferSize, PipeSecurity security) + { + NamedPipeServerStream pipe = CreatePipe(pipeName, bufferSize, security); + pipe.WaitForConnection(); + + return pipe; + } + + public static NamedPipeServerStream CreatePipe(string pipeName, int bufferSize, PipeSecurity security) + { + return new NamedPipeServerStream(pipeName, PipeDirection.InOut, 1, PipeTransmissionMode.Message, + PipeOptions.Asynchronous, bufferSize, bufferSize, security); + } + } +} diff --git a/YAMDCC.IPC/ServiceCommand.cs b/YAMDCC.IPC/ServiceCommand.cs index 7ea3121..f57a1b6 100644 --- a/YAMDCC.IPC/ServiceCommand.cs +++ b/YAMDCC.IPC/ServiceCommand.cs @@ -1,4 +1,4 @@ -using MessagePack; +using System; namespace YAMDCC.IPC { @@ -109,13 +109,12 @@ public enum Command /// /// Represents a command to send to the YAMDCC Service. /// - [MessagePackObject] + [Serializable] public class ServiceCommand { /// /// The to send to the service. /// - [Key(0)] public Command Command; /// @@ -123,7 +122,6 @@ public class ServiceCommand /// The number of parameters for a service command vary depending on the /// specific command sent to the service. /// - [Key(1)] public string Arguments; public ServiceCommand(Command command, string args) diff --git a/YAMDCC.IPC/ServiceResponse.cs b/YAMDCC.IPC/ServiceResponse.cs index 081ee47..c2eb34f 100644 --- a/YAMDCC.IPC/ServiceResponse.cs +++ b/YAMDCC.IPC/ServiceResponse.cs @@ -1,4 +1,4 @@ -using MessagePack; +using System; namespace YAMDCC.IPC { @@ -40,19 +40,17 @@ public enum Response /// /// Represents a response to a . /// - [MessagePackObject] + [Serializable] public class ServiceResponse { /// /// The to send to the service. /// - [Key(0)] public Response Response; /// /// The value associated with the . /// - [Key(1)] public string Value; /// diff --git a/YAMDCC.IPC/Threading/Worker.cs b/YAMDCC.IPC/Threading/Worker.cs index 0b91372..01036cd 100644 --- a/YAMDCC.IPC/Threading/Worker.cs +++ b/YAMDCC.IPC/Threading/Worker.cs @@ -39,11 +39,9 @@ private void DoWorkImpl(object oAction) } } - private void Succeed() => - Succeeded?.Invoke(); + private void Succeed() => Succeeded?.Invoke(); - private void Fail(Exception exception) => - Error?.Invoke(exception); + private void Fail(Exception exception) => Error?.Invoke(exception); private void Callback(Action action) => Task.Factory.StartNew(action, CancellationToken.None, diff --git a/YAMDCC.IPC/YAMDCC.IPC.csproj b/YAMDCC.IPC/YAMDCC.IPC.csproj index a231ee9..f3efa78 100644 --- a/YAMDCC.IPC/YAMDCC.IPC.csproj +++ b/YAMDCC.IPC/YAMDCC.IPC.csproj @@ -1,18 +1,17 @@ - + net48 Library Named Pipe Wrapper library Named Pipe Wrapper library A simple, easy to use, strongly-typed wrapper around .NET named pipes, modified for MSI Fan Control. - Copyright © 2013 Andrew C. Dvorak, 2023-2024 Sparronator9999 + Copyright © 2013 Andrew C. Dvorak, 2014-2018 ReliableHosting, 2020-2021 Twosense, 2023-2024 Sparronator9999 MIT - 0.6.9.420 - 0.6.9.420 + 1.6.0.0 + 1.6.0.0 true - diff --git a/YAMDCC.IPC/packages.lock.json b/YAMDCC.IPC/packages.lock.json index ddba742..c84714b 100644 --- a/YAMDCC.IPC/packages.lock.json +++ b/YAMDCC.IPC/packages.lock.json @@ -2,20 +2,6 @@ "version": 1, "dependencies": { ".NETFramework,Version=v4.8": { - "MessagePack": { - "type": "Direct", - "requested": "[2.5.171, )", - "resolved": "2.5.171", - "contentHash": "eX0wTFtE4teu2iDWm/eEGqvVEeO9dqaRXu6MXu1MnhQ/wBkixEjh+1SlKaSh41LL5L7WUJlK04EBpz8FSaGOqw==", - "dependencies": { - "MessagePack.Annotations": "2.5.171", - "Microsoft.Bcl.AsyncInterfaces": "6.0.0", - "Microsoft.NET.StringTools": "17.6.3", - "System.Collections.Immutable": "6.0.0", - "System.Runtime.CompilerServices.Unsafe": "6.0.0", - "System.Threading.Tasks.Extensions": "4.5.4" - } - }, "Microsoft.CSharp": { "type": "Direct", "requested": "[4.7.0, )", @@ -27,70 +13,6 @@ "requested": "[4.5.0, )", "resolved": "4.5.0", "contentHash": "221clPs1445HkTBZPL+K9sDBdJRB8UN8rgjO3ztB0CQ26z//fmJXtlsr6whGatscsKGBrhJl5bwJuKSA8mwFOw==" - }, - "MessagePack.Annotations": { - "type": "Transitive", - "resolved": "2.5.171", - "contentHash": "iS5Zb6uiPn3QJVL814+xWlWeH/rW+p2qPoECjOhL7RV71ppld4vDpej5rq4YrxGdLtR66zf+AQwW919sPVMWgw==" - }, - "Microsoft.Bcl.AsyncInterfaces": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "UcSjPsst+DfAdJGVDsu346FX0ci0ah+lw3WRtn18NUwEqRt70HaOQ7lI72vy3+1LxtqI3T5GWwV39rQSrCzAeg==", - "dependencies": { - "System.Threading.Tasks.Extensions": "4.5.4" - } - }, - "Microsoft.NET.StringTools": { - "type": "Transitive", - "resolved": "17.6.3", - "contentHash": "N0ZIanl1QCgvUumEL1laasU0a7sOE5ZwLZVTn0pAePnfhq8P7SvTjF8Axq+CnavuQkmdQpGNXQ1efZtu5kDFbA==", - "dependencies": { - "System.Memory": "4.5.5", - "System.Runtime.CompilerServices.Unsafe": "6.0.0" - } - }, - "System.Buffers": { - "type": "Transitive", - "resolved": "4.5.1", - "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" - }, - "System.Collections.Immutable": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "l4zZJ1WU2hqpQQHXz1rvC3etVZN+2DLmQMO79FhOTZHMn8tDRr+WU287sbomD0BETlmKDn0ygUgVy9k5xkkJdA==", - "dependencies": { - "System.Memory": "4.5.4", - "System.Runtime.CompilerServices.Unsafe": "6.0.0" - } - }, - "System.Memory": { - "type": "Transitive", - "resolved": "4.5.5", - "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Numerics.Vectors": "4.5.0", - "System.Runtime.CompilerServices.Unsafe": "4.5.3" - } - }, - "System.Numerics.Vectors": { - "type": "Transitive", - "resolved": "4.5.0", - "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" - }, - "System.Runtime.CompilerServices.Unsafe": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg==" - }, - "System.Threading.Tasks.Extensions": { - "type": "Transitive", - "resolved": "4.5.4", - "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", - "dependencies": { - "System.Runtime.CompilerServices.Unsafe": "4.5.3" - } } } } diff --git a/YAMDCC.Service/YAMDCC.Service.csproj b/YAMDCC.Service/YAMDCC.Service.csproj index ff9fb2b..a289a7a 100644 --- a/YAMDCC.Service/YAMDCC.Service.csproj +++ b/YAMDCC.Service/YAMDCC.Service.csproj @@ -69,7 +69,6 @@ - diff --git a/YAMDCC.Service/packages.lock.json b/YAMDCC.Service/packages.lock.json index e3e6589..0074083 100644 --- a/YAMDCC.Service/packages.lock.json +++ b/YAMDCC.Service/packages.lock.json @@ -14,97 +14,6 @@ "resolved": "4.5.0", "contentHash": "221clPs1445HkTBZPL+K9sDBdJRB8UN8rgjO3ztB0CQ26z//fmJXtlsr6whGatscsKGBrhJl5bwJuKSA8mwFOw==" }, - "System.Management": { - "type": "Direct", - "requested": "[8.0.0, )", - "resolved": "8.0.0", - "contentHash": "jrK22i5LRzxZCfGb+tGmke2VH7oE0DvcDlJ1HAKYU8cPmD8XnpUT0bYn2Gy98GEhGjtfbR/sxKTVb+dE770pfA==", - "dependencies": { - "System.CodeDom": "8.0.0" - } - }, - "MessagePack": { - "type": "Transitive", - "resolved": "2.5.171", - "contentHash": "eX0wTFtE4teu2iDWm/eEGqvVEeO9dqaRXu6MXu1MnhQ/wBkixEjh+1SlKaSh41LL5L7WUJlK04EBpz8FSaGOqw==", - "dependencies": { - "MessagePack.Annotations": "2.5.171", - "Microsoft.Bcl.AsyncInterfaces": "6.0.0", - "Microsoft.NET.StringTools": "17.6.3", - "System.Collections.Immutable": "6.0.0", - "System.Runtime.CompilerServices.Unsafe": "6.0.0", - "System.Threading.Tasks.Extensions": "4.5.4" - } - }, - "MessagePack.Annotations": { - "type": "Transitive", - "resolved": "2.5.171", - "contentHash": "iS5Zb6uiPn3QJVL814+xWlWeH/rW+p2qPoECjOhL7RV71ppld4vDpej5rq4YrxGdLtR66zf+AQwW919sPVMWgw==" - }, - "Microsoft.Bcl.AsyncInterfaces": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "UcSjPsst+DfAdJGVDsu346FX0ci0ah+lw3WRtn18NUwEqRt70HaOQ7lI72vy3+1LxtqI3T5GWwV39rQSrCzAeg==", - "dependencies": { - "System.Threading.Tasks.Extensions": "4.5.4" - } - }, - "Microsoft.NET.StringTools": { - "type": "Transitive", - "resolved": "17.6.3", - "contentHash": "N0ZIanl1QCgvUumEL1laasU0a7sOE5ZwLZVTn0pAePnfhq8P7SvTjF8Axq+CnavuQkmdQpGNXQ1efZtu5kDFbA==", - "dependencies": { - "System.Memory": "4.5.5", - "System.Runtime.CompilerServices.Unsafe": "6.0.0" - } - }, - "System.Buffers": { - "type": "Transitive", - "resolved": "4.5.1", - "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" - }, - "System.CodeDom": { - "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "WTlRjL6KWIMr/pAaq3rYqh0TJlzpouaQ/W1eelssHgtlwHAH25jXTkUphTYx9HaIIf7XA6qs/0+YhtLEQRkJ+Q==" - }, - "System.Collections.Immutable": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "l4zZJ1WU2hqpQQHXz1rvC3etVZN+2DLmQMO79FhOTZHMn8tDRr+WU287sbomD0BETlmKDn0ygUgVy9k5xkkJdA==", - "dependencies": { - "System.Memory": "4.5.4", - "System.Runtime.CompilerServices.Unsafe": "6.0.0" - } - }, - "System.Memory": { - "type": "Transitive", - "resolved": "4.5.5", - "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Numerics.Vectors": "4.5.0", - "System.Runtime.CompilerServices.Unsafe": "4.5.3" - } - }, - "System.Numerics.Vectors": { - "type": "Transitive", - "resolved": "4.5.0", - "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" - }, - "System.Runtime.CompilerServices.Unsafe": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg==" - }, - "System.Threading.Tasks.Extensions": { - "type": "Transitive", - "resolved": "4.5.4", - "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", - "dependencies": { - "System.Runtime.CompilerServices.Unsafe": "4.5.3" - } - }, "yamdcc.config": { "type": "Project", "dependencies": { @@ -122,7 +31,6 @@ "yamdcc.ipc": { "type": "Project", "dependencies": { - "MessagePack": "[2.5.171, )", "Microsoft.CSharp": "[4.7.0, )", "System.Data.DataSetExtensions": "[4.5.0, )" } diff --git a/YAMDCC.Service/svcFanControl.cs b/YAMDCC.Service/svcFanControl.cs index 41c1d06..7393aaf 100644 --- a/YAMDCC.Service/svcFanControl.cs +++ b/YAMDCC.Service/svcFanControl.cs @@ -76,7 +76,7 @@ public svcFanControl() PipeSecurity security = new PipeSecurity(); security.AddAccessRule(new PipeAccessRule("Administrators", PipeAccessRights.ReadWrite, AccessControlType.Allow)); - IPCServer = new Server("YAMDCC-Server", security); + IPCServer = new Server("YAMDCC-Server", 0, security); } #region Events