public CommunicatingApplicationHook(System.Diagnostics.Process targetProcess)
            : base(targetProcess)
        {
            remoteProcess = new Native.Process.RemoteProcess(targetProcess);
            IPC.NamedPipes.NamedPipeServer server = new IPC.NamedPipes.NamedPipeServer();

            PipeId = Guid.NewGuid().ToString();

            Thread t = new Thread(() =>
            {
                server.ConnectionRecieved += (s, e) =>
                {
                    connection = e.Value;
                    while (e.Value.IsConnected)
                    {
                        var msg = e.Value.Receive();
                        if (e.Value.IsConnected && msg != null)
                        {
                            MessageReceived.RaiseEvent(this, msg);
                        }
                    }
                    ConnectionClosed.RaiseEvent(this);
                };
                server.Start(new IPC.NamedPipes.NamedPipeInitialisation(PipeId));
            });
            t.Start();
        }
Exemple #2
0
        public CommunicatingApplicationHook(System.Diagnostics.Process targetProcess)
            : base(targetProcess)
        {
            remoteProcess = new Native.Process.RemoteProcess(targetProcess);
            IPC.NamedPipes.NamedPipeServer server = new IPC.NamedPipes.NamedPipeServer();

            PipeId = Guid.NewGuid().ToString();

            Thread t = new Thread(() =>
            {
                server.ConnectionRecieved += (s, e) =>
                {
                    connection = e.Value;
                    while (e.Value.IsConnected)
                    {
                        var msg = e.Value.Receive();
                        if (e.Value.IsConnected && msg != null)
                        {
                            MessageReceived.RaiseEvent(this, msg);
                        }
                    }
                    ConnectionClosed.RaiseEvent(this);
                };
                server.Start(new IPC.NamedPipes.NamedPipeInitialisation(PipeId));
            });

            t.Start();
        }