Пример #1
0
        public MainForm()
        {
            InitializeComponent();

            FormClosed += new FormClosedEventHandler(MainForm_FormClosed);

            this.KeyPreview = true;

            try
            {
                username = File.ReadAllText(Core.AppPath + "myusername.txt");

                label2.Text = username;

                connectedAsusernameToolStripMenuItem.Text = "Connected as: " + username;

                try
                {
                    FileManagement fm = new FileManagement();
                    fm.createFolder(0, username, null, null);
                }
                catch (Exception)
                {
                    ReportForm ef = new ReportForm();
                    ef.label2.Text = "Failed to connect to server." + Environment.NewLine + "Program terminating.";
                    ef.Show();

                    string grabProc;
                    try
                    {
                        grabProc = File.ReadAllText(Core.AppPath + "chosengameexec.txt");
                        grabProc = grabProc.Substring(0, grabProc.Length - 4);

                        RuntimeChecker.IsGameRunning(grabProc);
                    }
                    catch (Exception)
                    {
                        ReportForm ef2 = new ReportForm();
                        ef2.label2.Text = "Upload failed.";
                        ef2.Show();
                    }
                    Environment.Exit(0);
                }

                if (Directory.Exists(Core.AppPath + "acscreens") == false)
                {
                    Directory.CreateDirectory(Core.AppPath + "acscreens");
                }
            }

            catch (FileNotFoundException)
            {
                /* user does not need to know about this error */
            }
        }
Пример #2
0
        private void DrawCommandTweakSettings(Rect region)
        {
            var listing  = new Listing_Standard();
            var viewPort = new Rect(0f, 0f, region.width - 16f, Text.LineHeight * 48f);

            GUI.BeginGroup(region);
            Widgets.BeginScrollView(region.AtZero(), ref _commandTweakPos, viewPort);
            listing.Begin(viewPort);

            listing.GroupHeader(_balanceGroupHeader, false);
            listing.CheckboxLabeled(_coinRateLabel, ref TkSettings.ShowCoinRate);
            listing.DrawDescription(_coinRateDescription);


            listing.GroupHeader(_commandHandlerGroupHeader);

            if (TkSettings.Commands)
            {
                (Rect prefixLabel, Rect prefixField) = listing.Split();
                UiHelper.Label(prefixLabel, _commandPrefixLabel);
                listing.DrawDescription(_commandPrefixDescription);
                TkSettings.Prefix = CommandHelper.ValidatePrefix(Widgets.TextField(prefixField, TkSettings.Prefix));

                (Rect buyPrefixLabel, Rect buyPrefixField) = listing.Split();
                UiHelper.Label(buyPrefixLabel, _purchasePrefixLabel);
                listing.DrawDescription(_purchasePrefixDescription);
                TkSettings.BuyPrefix = CommandHelper.ValidatePrefix(Widgets.TextField(buyPrefixField, TkSettings.BuyPrefix));
            }

            listing.CheckboxLabeled(_commandParserLabel, ref TkSettings.Commands);
            listing.DrawDescription(_commandParserDescription);

            if (TkSettings.Commands)
            {
                listing.CheckboxLabeled(_toolkitStyleLabel, ref TkSettings.ToolkitStyleCommands);
                listing.DrawDescription(_toolkitStyleDescription);
            }

            if (UiHelper.LabeledPaintableCheckbox(listing.GetRect(Text.LineHeight), _commandRouterLabel, ref TkSettings.CommandRouter))
            {
                RuntimeChecker.ValidateTicker();
            }

            listing.DrawDescription(_commandRouterDescription);
            listing.DrawExperimentalNotice();

            listing.GroupHeader(_installedModsGroupHeader);
            listing.CheckboxLabeled(_decorateUtilsLabel, ref TkSettings.DecorateMods);
            listing.DrawDescription(_decorateUtilsDescription);

            listing.CheckboxLabeled(_versionedModListLabel, ref TkSettings.VersionedModList);
            listing.DrawDescription(_versionedModListDescription);


            listing.GroupHeader(_buyItemGroupHeader);
            listing.CheckboxLabeled(_buyItemBalanceLabel, ref TkSettings.BuyItemBalance);
            listing.DrawDescription(_buyItemBalanceDescription);
            listing.CheckboxLabeled(_itemSyntaxLabel, ref TkSettings.ForceFullItem);
            listing.DrawDescription(_itemSyntaxDescription);


            listing.GroupHeader(_lookupGroupHeader);

            (Rect limitLabel, Rect limitField) = listing.Split();
            var buffer = TkSettings.LookupLimit.ToString();

            UiHelper.Label(limitLabel, _lookupLimitLabel);
            Widgets.TextFieldNumeric(limitField, ref TkSettings.LookupLimit, ref buffer);
            listing.DrawDescription(_lookupLimitDescription);

            GUI.EndGroup();
            Widgets.EndScrollView();
            listing.End();
        }
Пример #3
0
        private void MainForm_FormClosing(System.Object sender, System.Windows.Forms.FormClosingEventArgs e)
        {
            try
            {
                if (ProcessManagement.ProcessIsRunning(File.ReadAllText(Core.AppPath + "chosengameexec.txt")))
                {
                    int gameclosedtimestamp = TextHandling.GetUnixTimestamp();

                    GameReport report = new GameReport();

                    report.WriteLine("Anticheat closed while game was running! at " + DateTime.Now.TimeOfDay + " timestamp: " + gameclosedtimestamp + Environment.NewLine + "On match ID: " + getID + Environment.NewLine);

                    File.WriteAllText(Core.AppPath + "acscreens\\gameclosed.txt", report.toFile());

                    try
                    {
                        FileManagement fm = new FileManagement();
                        fm.postFile(username, null, null, Core.AppPath + "acscreens\\gameclosed.txt");
                    }

                    catch (Exception)
                    {
                        ReportForm ef = new ReportForm();
                        ef.label2.Text = "Upload failed.";
                        ef.Show();
                    }

                    File.Delete(Core.AppPath + "acscreens\\gameclosed.txt");

                    string grabName;
                    grabName = File.ReadAllText(Core.AppPath + "chosengameexec.txt");
                    string grabProc;
                    grabProc = grabName;
                    grabProc = grabProc.Substring(0, grabProc.Length - 4);

                    RuntimeChecker.IsGameRunning(grabProc);
                    ProcessManagement.TriggerTaskmanager(true);

                    notifyIcon1.Visible = false;

                    Environment.Exit(0);
                }
            }

            catch (FileNotFoundException)
            {
                /* user does not need to know about this error */
                try
                {
                    string grabName;
                    grabName = File.ReadAllText(Core.AppPath + "chosengameexec.txt");
                    string grabProc;
                    grabProc = grabName;
                    grabProc = grabProc.Substring(0, grabProc.Length - 4);

                    RuntimeChecker.IsGameRunning(grabProc);
                    ProcessManagement.TriggerTaskmanager(true);
                    notifyIcon1.Visible = false;
                    Environment.Exit(0);
                }
                catch (Exception)
                {
                    ProcessManagement.TriggerTaskmanager(true);
                    notifyIcon1.Visible = false;
                    Environment.Exit(0);
                }
            }
            ProcessManagement.TriggerTaskmanager(true);
            notifyIcon1.Visible = false;
            Environment.Exit(0);
        }
Пример #4
0
        private void startRoutine(DialogResult getdr)
        {
            if (label4.Text.Equals("Scanning"))
            {
                ErrorForm ef = new ErrorForm();
                ef.label2.Text = "Routine is already running!";
                ef.Show();
                return;
            }

            if (label4.Text.Equals("Uploading"))
            {
                ErrorForm ef = new ErrorForm();
                ef.label2.Text = "Please wait until uploading ends!";
                ef.Show();
                return;
            }

            else
            {
                try
                {
                    getID = int.Parse(TextBox1.Text);

                    if (getID == 0)
                    {
                        ErrorForm ef = new ErrorForm();
                        ef.label2.Text = "Match ID cannot be 0.";
                        ef.Show();
                        return;
                    }

                    File.WriteAllText(Core.AppPath + "matchid.txt", TextBox1.Text);
                }
                catch (Exception)
                {
                    ErrorForm ef = new ErrorForm();
                    ef.label2.Text = "Invalid Match ID.";
                    ef.Show();
                    return;
                }

                DialogResult dr = getdr;

                if (dr == DialogResult.Cancel)
                {
                    //we continue
                }

                else if (dr == DialogResult.OK)
                {
                    noGameSelectedToolStripMenuItem.Text = "Scanning game: " + selectedGame;

                    label4.Text = "Scanning";

                    this.Hide();
                    this.WindowState = FormWindowState.Minimized;

                    string grabName;
                    grabName = File.ReadAllText(Core.AppPath + "chosengameexec.txt");

                    if (grabName.Equals("steam://run/730"))
                    {
                        grabName = "csgo.exe";
                    }

                    else if (grabName.Equals("steam://run/440"))
                    {
                        grabName = "hl2.exe";
                    }

                    else if (grabName.Equals("steam://run/570"))
                    {
                        grabName = "dota.exe";
                    }

                    else if (grabName.Equals("Shootmania"))
                    {
                        string read = string.Empty;

                        try
                        {
                            read = File.ReadAllText(Core.AppPath + "chosengamefullexec.txt");
                        }
                        catch (Exception) { }

                        if (!read.Contains("ManiaPlanet"))
                        {
                            OpenFileDialog ofd = new OpenFileDialog();
                            ofd.Filter = "maniaplanet.exe|maniaplanet.exe| Exe Files (.exe)|*.exe";
                            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                string fullPath = ofd.InitialDirectory + ofd.FileName;
                                string execName = ofd.SafeFileName;
                                File.WriteAllText(Core.AppPath + "chosengamefullexec.txt", fullPath);
                                File.WriteAllText(Core.AppPath + "chosengameexec.txt", execName);
                            }
                            else
                            {
                                label4.Text = "Idle";

                                this.Show();
                                this.WindowState = FormWindowState.Normal;
                                this.Activate();

                                return;
                            }
                        }

                        File.WriteAllText(Core.AppPath + "chosengameexec.txt", "ManiaPlanet.exe");
                    }

                    if (ProcessManagement.ProcessIsRunning(grabName))
                    {
                        grabName = grabName.Substring(0, grabName.Length - 4);
                        RuntimeChecker.IsGameRunning(grabName); //kills old process and opens new one with anticheat
                        ProcessManagement.TriggerTaskmanager(true);
                        Thread.Sleep(1000);
                    }

                    bool primaryFail = false;

                    try
                    {
                        RuntimeChecker checker = new RuntimeChecker(ServerType.PrimaryServer, username);
                        checker.OnStopped += new CheckerStoppedEvent(checker_OnStopped);
                    }
                    catch (Exception)
                    {
                        primaryFail = true;
                    }

                    if (primaryFail == true)
                    {
                        this.Show();
                        this.WindowState = FormWindowState.Normal;

                        ReportForm ef = new ReportForm();
                        ef.label2.Text = "A error has occurred!";
                        ef.Show();

                        checker_OnStopped();

                        ProcessManagement.TriggerTaskmanager(false);
                        ProcessManagement.TaskManagerIsRunning();

                        button5.Image = ESA_AC.Properties.Resources.startscan_normal;

                        label4.Text = "Uploading";

                        try
                        {
                            if (File.Exists(Core.AppPath + "acscreens\\log_" + getID + "_" + selectedGame + "_" + RuntimeChecker.getTimeZip + ".zip"))
                            {
                                using (FileStream fsread = new FileStream(Core.AppPath + "acscreens\\log_" + getID + "_" + selectedGame + "_" + RuntimeChecker.getTimeZip + ".zip", FileMode.Open, FileAccess.Read, FileShare.Read))
                                {
                                    if (File.Exists(Core.AppPath + "acscreens\\log_" + getID + "_" + selectedGame + "_" + RuntimeChecker.getTimeZip + ".zip"))
                                    {
                                        FileManagement fm = new FileManagement();
                                        fm.postFile(username, selectedGame, getID.ToString(), Core.AppPath + "acscreens\\log_" + getID + "_" + selectedGame + "_" + RuntimeChecker.getTimeZip + ".zip");

                                        fsread.Close();

                                        File.Delete(Core.AppPath + "acscreens\\log_" + getID + "_" + selectedGame + "_" + RuntimeChecker.getTimeZip + ".zip");
                                    }
                                    else
                                    {
                                        File.WriteAllText(Core.AppPath + "acscreens\\warning.txt", "Anticheat zip log has been deleted.");

                                        FileManagement fm = new FileManagement();
                                        fm.postFile(username, selectedGame, getID.ToString(), Core.AppPath + "acscreens\\warning.txt");

                                        File.Delete(Core.AppPath + "acscreens\\warning.txt");
                                    }
                                }
                            }
                            else
                            {
                                File.WriteAllText(Core.AppPath + "acscreens\\warning.txt", "Anticheat zip log has been deleted.");

                                FileManagement fm = new FileManagement();
                                fm.postFile(username, selectedGame, getID.ToString(), Core.AppPath + "acscreens\\warning.txt");

                                File.Delete(Core.AppPath + "acscreens\\warning.txt");
                            }
                        }
                        catch (Exception)
                        {
                            ReportForm ef2 = new ReportForm();
                            ef2.label2.Text = "Upload failed.";
                            ef2.Show();
                        }

                        ProcessManagement.TriggerTaskmanager(true);

                        noGameSelectedToolStripMenuItem.Text = "No game currently selected";

                        selectedGame = "";

                        label4.Text = "Idle";
                    }
                }
            }
        }