Beispiel #1
0
        //всплывающее окно
        public void Logging(params FormatText[] text_log)
        {
            dispatcher.Invoke(DispatcherPriority.Background, new Action(() =>
            {
                try
                {
                    lock (thread_object)
                    {
                        string tray_text = "";
                        foreach (FormatText log in text_log)
                        {
                            tray_text = log.Text != null ? log.Text : "пустое сообщение";
                        }

                        if (FormatText.baloon_msg.Count() < 5)
                        {
                            FormatText.baloon_msg.Add(new FormatText(tray_text, Brushes.Black, 13, text_log[0].Type));
                        }
                        else
                        {
                            FormatText.baloon_msg.RemoveAt(0);
                            FormatText.baloon_msg.Add(new FormatText(tray_text, Brushes.Black, 13, text_log[0].Type));
                        }
                    }
                }
                catch (Exception ex)
                {
                    CalcMethods.ViewException(ex.Message);
                }
            }));
        }
Beispiel #2
0
 //применяем настройки
 private void ApplySettings()
 {
     try
     {
         Loging.Downloader   = settings.Downloader;
         Loging.UserId_1     = settings.UserId_1;
         Loging.UserId_2     = settings.UserId_2;
         Loging.PathToClient = settings.Filepath;
     }
     catch (Exception ex)
     {
         CalcMethods.ViewException(ex.Message);
     }
 }
Beispiel #3
0
 private void Serializable()
 {
     try
     {
         using (FileStream fs = new FileStream(Environment.CurrentDirectory + "\\settings.xml", FileMode.Truncate))
         {
             formatter.Serialize(fs, CheckBoxSettings);
         }
     }
     catch (Exception ex)
     {
         CalcMethods.ViewException(ex.Message);
     }
 }
Beispiel #4
0
 /// <summary>
 /// Сохранение аккаунта в db
 /// </summary>
 private static void SaveAccounts(Account user, AccountContext db)
 {
     try
     {
         Account acc = db.Accounts.Find(user.ID);
         if (acc != null)
         {
             acc.Nickname        = user.Nickname;
             acc.Mail            = user.Mail;
             acc.Password        = user.Password;
             acc.Server          = user.Server;
             acc.TsaToken        = user.TsaToken;
             db.Entry(acc).State = EntityState.Modified;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         CalcMethods.ViewException(ex.Message);
     }
 }
Beispiel #5
0
        private void Deserializable()
        {
            FileStream fs = new FileStream("settings.xml", FileMode.OpenOrCreate);

            try
            {
                CheckBoxSettings = (MySettings)formatter.Deserialize(fs);
            }
            catch
            {
                CalcMethods.ViewException("Пока не сохранено настроек");
                CheckBoxSettings = new MySettings();
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }
        }
Beispiel #6
0
        //метод обновления комбобоксов
        private void RefreshComboboxes(MainWindow wnd)
        {
            try
            {
                if (wnd == null)
                {
                    return;
                }

                foreach (ComboBox box in comboBoxes)
                {
                    if (box.ItemsSource is ICollectionView)
                    {
                        (box.ItemsSource as ICollectionView).Refresh();
                    }
                }
            }
            catch (Exception ex)
            {
                CalcMethods.ViewException(ex.Message);
            }
        }
Beispiel #7
0
        public static async Task AuthAsync(Account user, AccountContext db)
        {
            try
            {
                String temp     = String.Empty;
                String answer_1 = String.Empty;
                #region АВТОРИЗАЦИЯ НА ПОЧТЕ
                if (user.TsaToken != null)
                {
                    //делаем запрос по сохраненному токену
                    temp = String.Format("client_id=gamecenter.mail.ru&grant_type=password&username={0}&password={1}&tsa_token={2}", user.Mail, user.Password, user.TsaToken);
                    Regex regex_1_1 = new Regex("\"tsa_token\":\".{32}\"");
                    Regex regex_1_2 = new Regex("\"access_token\":\".{48}\"");
                    answer_1 = await POST("https://o2.mail.ru//token", temp);

                    user.TsaToken = regex_1_1.Match(answer_1).Value;
                    user.TsaToken = user.TsaToken.Replace("\"tsa_token\":\"", "");
                    user.TsaToken = user.TsaToken.Replace("\"", "");
                    SaveAccounts(user, db);
                    answer_1 = regex_1_2.Match(answer_1).Value;
                    answer_1 = answer_1.Replace("\"access_token\":\"", "");
                    answer_1 = answer_1.Replace("\"", "");
                }
                else
                {
                    temp     = @"client_id=gamecenter.mail.ru&grant_type=password&username="******"&password="******"https://o2.mail.ru//token", temp);

                    if (answer_1.Contains("second step code check required to authenticate user") || answer_1.Contains("sms send timeout"))
                    {
                        Regex regex_1 = new Regex("\"tsa_token\":\".{32}\"");
                        do
                        {
                            answer_1 = regex_1.Match(answer_1).Value;
                            answer_1 = answer_1.Replace("\"tsa_token\":\"", "");
                            answer_1 = answer_1.Replace("\"", "");
                            //сохраняем полученный tsa токен для будущего использования
                            user.TsaToken = answer_1;
                            SaveAccounts(user, db);
                            //запрашиваем СМС код
                            GetSmsCode smsWindow = new GetSmsCode();
                            if (smsWindow.ShowDialog() == true)
                            {
                                //отправляем запрос с кодом из смс
                                temp     = String.Format("client_id=gamecenter.mail.ru&grant_type=password&username={0}&tsa_token={1}&auth_code={2}&permanent=1", user.Mail, user.TsaToken, smsWindow.smsCode);
                                answer_1 = await POST("https://o2.mail.ru//token", temp);
                            }
                        }while (answer_1.Contains("invalid auth_code was submitted"));
                    }
                    user.TsaToken = new Regex("\"tsa_token\":\".{32}").Match(answer_1).Value.Replace("\"tsa_token\":\"", "");
                    SaveAccounts(user, db);
                    Regex regex_1_1 = new Regex(".access_token...\\S{48}.}");
                    answer_1 = regex_1_1.Match(answer_1).Value;
                    answer_1 = answer_1.Replace("\"access_token\":\"", "");
                    answer_1 = answer_1.Replace("\"}", "");
                }



                temp = @"client_id=gamecenter.mail.ru&access_token=" + answer_1;
                String answer_2 = await POST(@"https://o2.mail.ru/userinfo", temp);

                temp = String.Format("<?xml version=\"1.0\" encoding=\"UTF-8\"?><MrPage2 SessionKey=\"{0}\" Page=\"http://dl.mail.ru/robots.txt\"/>", answer_1);
                Regex  regex_3  = new Regex("Location=\".*\" ErrorCode");
                String answer_3 = regex_3.Match(await POST(@"https://authdl.mail.ru/ec.php?hint=MrPage2", temp)).Value;
                answer_3 = answer_3.Replace("Location=\"", "");
                answer_3 = answer_3.Replace("\" ErrorCode", "");
                answer_3 = answer_3.Replace("&amp;", "&");

                String answer_4 = await GET(answer_3);

                Regex regex_4 = new Regex("Mpop=.*;");
                answer_4 = regex_4.Match(answer_4).Value;
                answer_4 = answer_4.Replace("Mpop=", "");
                answer_4 = answer_4.Replace(";", "");

                temp = String.Format(@"<?xml version=""1.0"" encoding=""UTF-8""?><Auth UserId=""" + UserId_1 + @""" UserId2=""" + UserId_2 + @""" Soft=""1"" Cookie=""{0}"" AppId="""" ChannelId=""27""/>", answer_4);
                String answer_5 = await POST(@"https://authdl.mail.ru/ec.php?hint=Auth", temp);

                #endregion

                #region АВТОРИЗАЦИЯ В ИГРЕ
                temp = String.Format(@"<?xml version=""1.0"" encoding=""UTF-8""?><AutoLogin ProjectId=""61"" SubProjectId=""0"" ShardId=""0"" UserId=""" + UserId_1 + @""" UserId2=""" + UserId_2 + @""" Mpop=""{0}"" FirstLink=""_1lp=1&amp;_1ld=300&amp;_1lnh=1"" RegionData=""""/>", answer_4);
                String answer_6 = await POST(@"https://authdl.mail.ru/sz.php?hint=AutoLogin", temp);

                temp = String.Format(@"<?xml version=""1.0"" encoding=""UTF-8""?><PersList ProjectId=""61"" SubProjectId=""0"" ShardId=""0"" UserId=""" + UserId_1 + @""" UserId2=""" + UserId_2 + @""" Mpop=""{0}""/>", answer_4);
                String answer_7 = await POST(@"https://authdl.mail.ru/sz.php?hint=AutoLogin", temp);

                Regex regex_uid_2 = new Regex("AutoLogin PersId=\"\\d*\"");
                Regex regex_uid_1 = new Regex("Pers Id=\"\\d*\"");
                Regex regex_token = new Regex("Key=\"\\w*\"");

                userId_1 = regex_uid_1.Match(answer_7).Value;
                userId_1 = userId_1.Replace("Pers Id=\"", "");
                userId_1 = userId_1.Replace("\"", "");

                userId_2 = regex_uid_2.Match(answer_6).Value;
                userId_2 = userId_2.Replace("AutoLogin PersId=\"", "");
                userId_2 = userId_2.Replace("\"", "");

                token = regex_token.Match(answer_6).Value;
                token = token.Replace("Key=\"", "");
                token = token.Replace("\"", "");
                #endregion

                #region ЗАПУСК КЛИЕНТА

                Process process = new Process();
                if (!File.Exists(PathToClient + "elementclient.exe"))
                {
                    throw new Exception("Не указан путь к elementclient.exe в настройках!");
                }
                process.StartInfo.WorkingDirectory = PathToClient;
                process.StartInfo.FileName         = "elementclient.exe";
                process.StartInfo.Arguments        = String.Format("startbypatcher user:{0} _user:{1} token2:{2}", userId_1, userId_2, token);
                process.StartInfo.Verb             = "runas";
                process.Start();

                #endregion
            }
            catch (Exception ex)
            {
                CalcMethods.ViewException(ex.Message);
            }
        }
Beispiel #8
0
 //формат офсетов (String -> Int32)
 private void OpenOffsets()
 {
     try
     {
         Offsets.BaseAdress                 = Convert.ToInt32(offsetsFromDb.BA, 16);
         Offsets.GameAdress                 = Convert.ToInt32(offsetsFromDb.GA, 16);
         Offsets.GuiAdress                  = Convert.ToInt32(offsetsFromDb.GuiAdd, 16);
         Offsets.SendPacket                 = Convert.ToInt32(offsetsFromDb.SendPacket, 16);
         Offsets.AutoAttack                 = Convert.ToInt32(offsetsFromDb.AutoAttack, 16);
         Offsets.UseSkill                   = Convert.ToInt32(offsetsFromDb.UseSkill, 16);
         Offsets.Action_1                   = Convert.ToInt32(offsetsFromDb.Action_1, 16);
         Offsets.Action_2                   = Convert.ToInt32(offsetsFromDb.Action_2, 16);
         Offsets.Action_3                   = Convert.ToInt32(offsetsFromDb.Action_3, 16);
         Offsets.InviteCount                = Convert.ToInt32(offsetsFromDb.InviteCount, 16);
         Offsets.InviteStruct               = Convert.ToInt32(offsetsFromDb.InviteStruct, 16);
         Offsets.СhatStart                  = Convert.ToInt32(offsetsFromDb.ChatStart, 16);
         Offsets.СhatNumber                 = Convert.ToInt32(offsetsFromDb.ChatNumber, 16);
         Offsets.InviteWidParty             = Convert.ToInt32(offsetsFromDb.InviteWidParty, 16);
         Offsets.InviteWidPlayer            = Convert.ToInt32(offsetsFromDb.InviteWidPlayer, 16);
         Offsets.OffsetToGameAdress         = Convert.ToInt32(offsetsFromDb.OffsetToGameAdress, 16);
         Offsets.OffsetToPersStruct         = Convert.ToInt32(offsetsFromDb.OffsetToPersStruct, 16);
         Offsets.OffsetToParty              = Convert.ToInt32(offsetsFromDb.OffsetToParty, 16);
         Offsets.OffsetToCountParty         = Convert.ToInt32(offsetsFromDb.OffsetToCountParty, 16);
         Offsets.OffsetToName               = Convert.ToInt32(offsetsFromDb.OffsetToName, 16);
         Offsets.OffsetToClassID            = Convert.ToInt32(offsetsFromDb.OffsetToClassID, 16);
         Offsets.OffsetToMiningState        = Convert.ToInt32(offsetsFromDb.OffsetToMiningState, 16);
         Offsets.OffsetToWidWin_QuickAction = Convert.ToInt32(offsetsFromDb.OffsetToWidWin_QuickAction, 16);
         Offsets.OffsetToX                  = Convert.ToInt32(offsetsFromDb.OffsetToX, 16);
         Offsets.OffsetToY                  = Convert.ToInt32(offsetsFromDb.OffsetToY, 16);
         Offsets.OffsetToZ                  = Convert.ToInt32(offsetsFromDb.OffsetToZ, 16);
         Offsets.OffsetToWalkMode           = Convert.ToInt32(offsetsFromDb.OffsetToWalkMode, 16);
         Offsets.OffsetToWid                = Convert.ToInt32(offsetsFromDb.OffsetToWid, 16);
         Offsets.OffsetToTargetWid          = Convert.ToInt32(offsetsFromDb.OffsetToTargetWid, 16);
         Offsets.OffsetToStructParty        = Convert.ToInt32(offsetsFromDb.OffsetToStructParty, 16);
         Offsets.OffsetToSkillsCount        = Convert.ToInt32(offsetsFromDb.OffsetToSkillsCount, 16);
         Offsets.OffsetToCdSkill            = Convert.ToInt32(offsetsFromDb.OffsetToCdSkill, 16);
         Offsets.OffsetToIdSkill            = Convert.ToInt32(offsetsFromDb.OffsetToIdSkill, 16);
         Offsets.OffsetToSkillsArray        = Convert.ToInt32(offsetsFromDb.OffsetToSkillsArray, 16);
         Offsets.OffsetsLocationName        = new Int32[5];
         Offsets.OffsetsLocationName[0]     = Convert.ToInt32(offsetsFromDb.OffsetsLocationName_0, 16);
         Offsets.OffsetsLocationName[1]     = Convert.ToInt32(offsetsFromDb.OffsetsLocationName_1, 16);
         Offsets.OffsetsLocationName[2]     = Convert.ToInt32(offsetsFromDb.OffsetsLocationName_2, 16);
         Offsets.OffsetsLocationName[3]     = Convert.ToInt32(offsetsFromDb.OffsetsLocationName_3, 16);
         Offsets.OffsetsLocationName[4]     = Convert.ToInt32(offsetsFromDb.OffsetsLocationName_4, 16);
         Offsets.OffsetToCurrentSkill       = Convert.ToInt32(offsetsFromDb.OffsetToCurrentSkill, 16);
         Offsets.OffsetToCountBufs          = Convert.ToInt32(offsetsFromDb.OffsetToCountBufs, 16);
         Offsets.OffsetToBufsArray          = Convert.ToInt32(offsetsFromDb.OffsetToBufsArray, 16);
         Offsets.OffsetToBeginMobsStruct    = Convert.ToInt32(offsetsFromDb.OffsetToBeginMobsStruct, 16);
         Offsets.OffsetToMobsCount          = Convert.ToInt32(offsetsFromDb.OffsetToMobsCount, 16);
         Offsets.OffsetToMobWid             = Convert.ToInt32(offsetsFromDb.OffsetToMobWid, 16);
         Offsets.OffsetToMobName            = Convert.ToInt32(offsetsFromDb.OffsetToMobName, 16);
         Offsets.OffsetToMobsStruct         = Convert.ToInt32(offsetsFromDb.OffsetToMobsStruct, 16);
         Offsets.OffsetToHashTables         = Convert.ToInt32(offsetsFromDb.OffsetToHashTables, 16);
         Offsets.OffsetToPlayersCount       = Convert.ToInt32(offsetsFromDb.OffsetToPlayersCount, 16);
         Offsets.OffsetToBeginPlayersStruct = Convert.ToInt32(offsetsFromDb.OffsetToBeginPlayersStruct, 16);
         Offsets.OffsetToPlayersStruct      = Convert.ToInt32(offsetsFromDb.OffsetToPlayersStruct, 16);
         Offsets.MsgId           = Convert.ToInt32(offsetsFromDb.MsgId, 16);
         Offsets.MsgType         = Convert.ToInt32(offsetsFromDb.MsgType, 16);
         Offsets.Msg_form1       = Convert.ToInt32(offsetsFromDb.Msg_form1, 16);
         Offsets.Msg_form2       = Convert.ToInt32(offsetsFromDb.Msg_form2, 16);
         Offsets.MsgWid          = Convert.ToInt32(offsetsFromDb.MsgWid, 16);
         Offsets.Invent_struct   = Convert.ToInt32(offsetsFromDb.Invent_struct, 16);
         Offsets.Invent_struct_2 = Convert.ToInt32(offsetsFromDb.Invent_struct_2, 16);
         Offsets.CellsCount      = Convert.ToInt32(offsetsFromDb.CellsCount, 16);
         Offsets.ItemInCellCount = Convert.ToInt32(offsetsFromDb.ItemInCellCount, 16);
         Offsets.ItemInCellID    = Convert.ToInt32(offsetsFromDb.ItemInCellID, 16);
         Offsets.ItemInCellName  = Convert.ToInt32(offsetsFromDb.ItemInCellName, 16);
         Offsets.ItemInCellPrice = Convert.ToInt32(offsetsFromDb.ItemInCellPrice, 16);
         Offsets.ItemInCellType  = Convert.ToInt32(offsetsFromDb.ItemInCellType, 16);
         //определяем цепочки смещений
         Offsets.RefreshOffsets();
     }
     catch (Exception ex)
     {
         CalcMethods.ViewException(ex.Message);
     }
 }