Exemple #1
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;
            }
        }
Exemple #2
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);
        }