Пример #1
0
        private void Timer1_Tick(object sender, EventArgs e)
        {
            if (firstInit)
            {
                firstInit = false;
                myINIT();
            }
            string serverStatus = Network.getServerStatus();

            if (serverStatus.Contains("normal"))
            {
                label6.Text      = "验证服务器状态:正常";
                label6.ForeColor = Color.Green;
            }
            else if (serverStatus.Contains("stop"))
            {
                label6.Text      = "验证服务器状态:停止工作";
                label6.ForeColor = Color.Red;
            }
            else
            {
                label6.Text      = "验证服务器状态:未知";
                label6.ForeColor = Color.Gray;
            }
            bool ok             = true;
            bool hasclient      = false;
            bool hasCheatClient = false;

            Process[] ps        = Process.GetProcesses();
            int       clientcnt = 0;

            foreach (Process p in ps)
            {
                if (p.Id == lastid)
                {
                    hasclient = true;
                }

                if (p.ProcessName == "java")
                {
                    //Shell.WriteLine("{0} : {1}", p.ProcessName, p.Id);
                    //Shell.WriteLine("{0}",ProcessExtensions.GetCommandLineArgs(p));
                    string cline = ProcessExtensions.GetCommandLineArgs(p);
                    //Shell.WriteLine("test:" + p.MainWindowTitle);
                    if (p.MainWindowTitle.Contains("LiquidBounce"))
                    {
                        //Shell.WriteLine("LiquidBounce!!!");
                        hasCheatClient = true;
                        ok             = false;
                    }
                    if (p.Id == lastid && p.MainWindowTitle != "" && !p.MainWindowTitle.Contains("Minecraft 1.8.9"))
                    {
                        //Shell.WriteLine("Minecraft 1.8.9!!Title:{0}", p.MainWindowTitle);
                        hasCheatClient = true;
                        ok             = false;
                    }
                    if (CommandLineProcessor.isMCProcess(cline))
                    {
                        //Shell.WriteLine(p.MainWindowTitle);
                        //Shell.WriteLine("{0} : {1}", p.ProcessName, p.Id);

                        if (!CommandLineProcessor.isVailidClient(cline))
                        {
                            ok             = false;
                            hasCheatClient = true;
                            break;
                        }
                        else
                        {
                            Shell.WriteLine("{0} : {1}", p.ProcessName, p.Id);
                            clientcnt++;
                            hasclient = true;
                            string uname = CommandLineProcessor.getClientName();
                            label4.Text      = "当前状态:欢迎您 " + uname;
                            label4.ForeColor = Color.Green;
                            if (p.Id != lastid)
                            {
                                StopProcessProtect();
                                if (!ProcessProtect(p.Id))
                                {
                                    Shell.WriteLine("Protect Process Failed");
                                }
                                lastid = p.Id;
                            }
                        }
                    }
                }
            }

            if (!hasclient)
            {
                ok               = false;
                label4.Text      = "当前状态:等待游戏启动";
                label4.ForeColor = Color.Black;
            }

            if (ok && gok && !firstPost && Network.getCanexit(CommandLineProcessor.getClientUUID()))
            {
                exited = true;
                //Application.Exit();
            }
            if (ok && gok)
            {
                //network upload uuid
                //Shell.WriteLine("OK");
                string res = Network.UUIDBeat(CommandLineProcessor.getClientUUID());
                firstPost = false;
                //Shell.WriteLine(res);
            }
            else if (hasCheatClient || clientcnt > 1)
            {
                Shell.WriteLine("hasCC:{0} clientcnt:{1}", hasCheatClient.ToString(), clientcnt.ToString());
                Network.setCancelUUID(CommandLineProcessor.getClientUUID());
                Shell.WriteLine("错误:有其他客户端启动,即将退出");
                timer1.Enabled   = false;
                label4.Text      = "当前状态:作弊检测!";
                label4.ForeColor = Color.Red;
                MessageBox.Show("错误:有其他客户端启动,即将退出,请关闭其他客户端后再试");
                gok = false;
                Application.Exit();
            }
        }
Пример #2
0
 public Form1()
 {
     InitializeComponent();
     CommandLineProcessor.getVerifyMD5();
 }