示例#1
0
 private void button1_Click(object sender, System.EventArgs e)
 {
     if (textBox1.Text != "")
     {
         DateTime dt = DateTime.Now;
         // This cycle is used only when you want to run numerous name pipes requests
         // and measure the performance. In the general case it is not needed.
         for (int i = 0; i < 1; i++)
         {
             IInterProcessConnection clientConnection = null;
             try {
                 clientConnection = new ClientPipeConnection("MyPipe", ".");
                 clientConnection.Connect();
                 clientConnection.Write(textBox1.Text);
                 Activity.AppendText(clientConnection.Read() + Environment.NewLine);
                 clientConnection.Close();
             }
             catch (Exception ex) {
                 clientConnection.Dispose();
                 throw (ex);
             }
         }
         this.duration.Text = DateTime.Now.Subtract(dt).Milliseconds.ToString();
     }
 }
示例#2
0
 public static bool SendMessage(string packet, string upl, string Networkname)
 {
     if (packet != "")
     {
         for (int i = 0; i < 1; i++)
         {
             IInterProcessConnection clientConnection = null;
             try
             {
                 clientConnection = new ClientPipeConnection(upl, Networkname);
                 clientConnection.Connect();
                 clientConnection.Write(packet);
                 IPDTPApplication.ChatHistory.Add(clientConnection.Read());
                 Log.LWrite("Packet Sent From Default Server (upl://128.215.52)" + " || To " + upl + " || In Machine (" + Networkname + ")");
                 clientConnection.Close();
                 return(true);
             }
             catch (Exception ex)
             {
                 clientConnection.Dispose();
                 throw (ex);
             }
         }
     }
     else
     {
     }
     return(false);
 }
示例#3
0
        public static bool SendAccess(string file, string DestinationAdress, string destnetname)
        {
            string request = PacketBuilder.RequestBuilder(Process.GetCurrentProcess(), ConnectionDataType.STRING, "ACCESS", file);

            byte[] data   = ServerEncoding.GetBytes(request);
            int    sid    = sessions + 1;
            string packet = PacketBuilder.BuildPacket(AppClient.serverupl, DestinationAdress, "STRING", sid, Process.GetCurrentProcess().Id, Encryption, ServerEncoding, data, destnetname);

            if (packet != "")
            {
                for (int i = 0; i < 1; i++)
                {
                    IInterProcessConnection clientConnection = null;
                    try
                    {
                        clientConnection = new ClientPipeConnection("upl://128.215.52", Networkname);
                        clientConnection.Connect();
                        clientConnection.Write(packet);

                        clientConnection.Close();
                        SetSID(sid, SessionState.WAITINGResponse);
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        clientConnection.Dispose();
                        throw (ex);
                    }
                }
            }
            else
            {
            }
            return(false);
        }
示例#4
0
        static void Main(string[] args)
        {
            string key = "";

            while ((key = Console.ReadLine()) != "exit")
            {
                if (key != "")
                {
                    DateTime dt = DateTime.Now;
                    // This cycle is used only when you want to run numerous name pipes requests
                    // and measure the performance. In the general case it is not needed.
                    for (int i = 0; i < 1; i++)
                    {
                        IInterProcessConnection clientConnection = null;
                        try
                        {
                            clientConnection = new ClientPipeConnection("MyPipe", ".");
                            clientConnection.Connect();

                            clientConnection.Write(key);
                            Console.WriteLine(clientConnection.Read());
                            clientConnection.Close();
                        }
                        catch (Exception ex)
                        {
                            clientConnection.Dispose();
                            throw (ex);
                        }
                    }
                    Console.WriteLine(DateTime.Now.Subtract(dt).Milliseconds.ToString());
                }
            }
        }
示例#5
0
 private void StopServerPipe()
 {
     try {
         ClientPipeConnection pipe = new ClientPipeConnection(PipeName);
         if (pipe.TryConnect())
         {
             pipe.Close();
         }
     } catch {
         // Log exception
     }
 }
示例#6
0
        private void InjectD3D(bool inject)
        {
            try
            {
                // Application path
                //string path = Application.StartupPath;

                // Make IPC command
                int  status = 0;
                bool result = false;
                IInterProcessConnection client = new ClientPipeConnection("S3D IPCChannel", ".");

                client.Connect();
                const int MAX_PATH = 260;
                byte[]    buffer   = new byte[4 + 4 + 2 * MAX_PATH];

                // 4 == inject d3d 2 == uninject
                int commandid = inject ? 4 : 2;
                BitConverter.GetBytes((Int32)commandid).CopyTo(buffer, 0);
                BitConverter.GetBytes((Int32)0).CopyTo(buffer, 4);

                byte[] ccPath = Encoding.Unicode.GetBytes(Application.StartupPath);
                ccPath.CopyTo(buffer, 8);
                int size = 4 + 4 + MAX_PATH;

                //if (state == ConfigData.StereoState.Update)
                //{
                //  ccPath.CopyTo(buffer, 8 + MAX_PATH);
                //  size += MAX_PATH;
                //}

                client.WriteBytes(buffer, 0, size);
                client.Flush();

                buffer = client.ReadBytes();

                result = (BitConverter.ToInt32(buffer, 0) == 0);
                status = BitConverter.ToInt32(buffer, 4);
                string message = BitConverter.ToString(buffer, 8, MAX_PATH);

                var umess = Encoding.Unicode.GetString(buffer, 8, MAX_PATH);

                bool injected = (status & 1) != 0;

                client.Close();
            }
            catch (Exception ex)
            {
                _Failed       = true;
                _ErrorMessage = ex.Message;
            }
        }
示例#7
0
        private bool IsInjectedD3D()
        {
            int status = 0;

            try
            {
                bool result = false;
                IInterProcessConnection client = new ClientPipeConnection("S3D IPCChannel", ".");

                client.Connect();
                const int MAX_PATH = 260;
                byte[]    buffer   = new byte[4 + 4 + 2 * MAX_PATH];

                // 1 == get injection status
                BitConverter.GetBytes((Int32)1).CopyTo(buffer, 0);
                BitConverter.GetBytes((Int32)0).CopyTo(buffer, 4);

                byte[] ccPath = Encoding.Unicode.GetBytes(Application.StartupPath);
                ccPath.CopyTo(buffer, 8);
                int size = 4 + 4 + MAX_PATH;

                //if (state == ConfigData.StereoState.Update)
                //{
                //  ccPath.CopyTo(buffer, 8 + MAX_PATH);
                //  size += MAX_PATH;
                //}

                client.WriteBytes(buffer, 0, size);
                client.Flush();

                buffer = client.ReadBytes();

                result = (BitConverter.ToInt32(buffer, 0) == 0);
                status = BitConverter.ToInt32(buffer, 4);

                client.Close();
            }
            catch (Exception ex)
            {
                _Failed       = true;
                _ErrorMessage = ex.Message;
            }

            bool injected = (status & 1) != 0;

            return(injected);
        }
示例#8
0
        public static bool SendTakeImage(Image img, string DestinationAdress, string destnetname, int sid)
        {
            // get the image base64 string

            byte[] imagebytes = imageToByteArray(img);

            string imageb64 = System.Convert.ToBase64String(imagebytes);

            // begin response
            string response = PacketBuilder.RequestBuilder(Process.GetCurrentProcess(), ConnectionDataType.IMAGE, "TAKE", imageb64);

            byte[] data = ServerEncoding.GetBytes(response);

            string packet = PacketBuilder.BuildPacket(AppClient.serverupl, DestinationAdress, "IMAGE", sid, Process.GetCurrentProcess().Id, Encryption, ServerEncoding, data, destnetname);

            if (packet != "")
            {
                for (int i = 0; i < 1; i++)
                {
                    IInterProcessConnection clientConnection = null;
                    try
                    {
                        clientConnection = new ClientPipeConnection("upl://128.215.52", Networkname);
                        clientConnection.Connect();
                        clientConnection.Write(packet);

                        clientConnection.Close();
                        SetSID(sid, SessionState.OK);
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        clientConnection.Dispose();
                        throw (ex);
                    }
                }
            }
            else
            {
            }
            return(false);
        }
示例#9
0
        static string connectSendMsg(string msg)
        {
            string retMsg = "";
            IInterProcessConnection clientConnection = null;

            try
            {
                clientConnection = new ClientPipeConnection(mXFSPipeName, ".");
                clientConnection.Connect();
                clientConnection.Write(msg);
                retMsg = clientConnection.Read() + "\n";
                clientConnection.Close();
            }
            catch (Exception ex)
            {
                clientConnection.Dispose();
                throw (ex);
            }
            return(retMsg);
        }
示例#10
0
        public static bool SendSET(Type type, string propertyname, object value, string DestinationAdress, string destnetname)
        {
            string content = type.ToString() + "|" + propertyname + "|" + value.ToString();
            string request = PacketBuilder.RequestBuilder(Process.GetCurrentProcess(), ConnectionDataType.VAR, "SET", content);

            byte[] data   = ServerEncoding.GetBytes(request);
            int    sid    = sessions + 1;
            string packet = PacketBuilder.BuildPacket(AppClient.serverupl, DestinationAdress, "VAR", sid, Process.GetCurrentProcess().Id, Encryption, ServerEncoding, data, destnetname);

            if (packet != "")
            {
                for (int i = 0; i < 1; i++)
                {
                    IInterProcessConnection clientConnection = null;
                    try
                    {
                        clientConnection = new ClientPipeConnection("upl://128.215.52", Networkname);
                        clientConnection.Connect();
                        clientConnection.Write(packet);

                        clientConnection.Close();
                        SetSID(sid, SessionState.OK);
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        clientConnection.Dispose();
                        throw (ex);
                    }
                }
            }
            else
            {
            }
            return(false);
        }