コード例 #1
0
ファイル: Login.cs プロジェクト: zneel/TheNoobBot
        private bool AttachProcess()
        {
            try
            {
                // Fight against cracked version, use sneaky strings name. Constant UpdateCheck equal "TNBAuth".
                Process[] Updater = Process.GetProcesses();
                for (int i = 0; i < Updater.Length; i++)
                {
                    Application.DoEvents();
                    Process AbortUpdate = Updater[i];
                    if (AbortUpdate.MainWindowTitle != Others.DecryptString(UpdateCheck) && AbortUpdate.ProcessName != Others.DecryptString(UpdateCheck))
                    {
                        continue;
                    }
                    AbortUpdate.Kill();
                    break;
                }

                if (SessionList.SelectedIndex < 0)
                {
                    MessageBox.Show(
                        nManager.Translate.Get(nManager.Translate.Id.Please_select_game_Process_and_connect_to_the_game) +
                        ".", nManager.Translate.Get(nManager.Translate.Id.Stop),
                        MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }

                Pulsator.Dispose();

                if (SessionList.SelectedIndex >= 0)
                {
                    string[] idStringArray =
                        SessionList.SelectedItem.ToString().Replace(" ", "").Split('-');

                    int idProcess = Others.ToInt32(idStringArray[0]);

                    if (!Hook.IsInGame(idProcess) && !nManagerSetting.AutoStartLoggingInfoProvided)
                    {
                        MessageBox.Show(nManager.Translate.Get(nManager.Translate.Id.Please_connect_to_the_game) + ".",
                                        nManager.Translate.Get(nManager.Translate.Id.Stop), MessageBoxButtons.OK,
                                        MessageBoxIcon.Stop);
                        return(false);
                    }
                    if (Hook.WowIsUsed(idProcess) && !nManagerSetting.AutoStartLoggingInfoProvided)
                    {
                        DialogResult resulMb =
                            MessageBox.Show(
                                nManager.Translate.Get(
                                    nManager.Translate.Id.The_Game_is_currently_used_by_TheNoobBot_or_contains_traces) +
                                "\n\n" +
                                nManager.Translate.Get(
                                    nManager.Translate.Id.If_no_others_session_of_TheNoobBot_is_currently_active),
                                nManager.Translate.Get(nManager.Translate.Id.Use_this_Game) + "?" + @" - " +
                                Hook.PlayerName(idProcess), MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                        if (resulMb == DialogResult.No)
                        {
                            return(false);
                        }
                    }

                    Pulsator.Pulse(idProcess, KeyNManager);
                    Logging.Write("Select game process: " + SessionList.SelectedItem);
                    if (Pulsator.IsActive)
                    {
                        if (Usefuls.InGame && !Usefuls.IsLoading)
                        {
                            return(true);
                        }
                        if (nManagerSetting.AutoStartLoggingInfoProvided)
                        {
                            Others.LoginToWoW();
                            if (Usefuls.InGame && !Usefuls.IsLoading)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logging.WriteError("AttachProcess(): " + ex);
            }
            return(false);
        }