Esempio n. 1
0
        /// <summary>
        /// Get Random ASM line.
        /// </summary>
        /// <returns></returns>
        internal static string ProtectHook()
        {
            List <string> asm = new List <string> {
                "mov edx, edx", "mov edi, edi", "xchg ebp, ebp", "mov esp, esp", "xchg esp, esp", "xchg edx, edx", "mov edi, edi"
            };


            // asm.Add("nop");

            // asm.Add( "mov eax, eax");

            //   asm.Add("xchg eax, eax");

            try
            {
                int n = Others.Random(0, asm.Count - 1);
                return(asm[n]);
            }
            catch (Exception e)
            {
                Logging.WriteError("ProtectHook(): " + e);

                return("mov eax, eax");
            }
        }
Esempio n. 2
0
        public override void Run()
        {
            _lastTimeRunning = Others.Times;
            MovementManager.StopMove();
            Thread.Sleep(500);
            Tasks.MountTask.DismountMount();
            Logging.Write("Prospecting in progress");
            Timer timer = new Timer(15 * 60 * 1000);

            // Prospecting
            while (Prospecting.NeedRun(nManagerSetting.CurrentSetting.MineralsToProspect) && Products.Products.IsStarted &&
                   Usefuls.InGame &&
                   !ObjectManager.ObjectManager.Me.InCombat && !ObjectManager.ObjectManager.Me.IsDeadMe &&
                   !timer.IsReady)
            {
                Thread.Sleep(200);
                Prospecting.Pulse(nManagerSetting.CurrentSetting.MineralsToProspect);
                Thread.Sleep(750);
                while (ObjectManager.ObjectManager.Me.IsCast && Products.Products.IsStarted && Usefuls.InGame &&
                       !ObjectManager.ObjectManager.Me.InCombat && !ObjectManager.ObjectManager.Me.IsDeadMe &&
                       !timer.IsReady)
                {
                    Thread.Sleep(100);
                }

                Thread.Sleep(Others.Random(600, 1600) + Usefuls.Latency);
            }
        }
Esempio n. 3
0
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        Others.GridMouseOver(Session["ThemeChange"].ToString(), e);
        int Lower_Count = 0;

        LBL_GridStatus.Text = "Page(s): " + Convert.ToString(GridView1.PageIndex + 1) + "-" + GridView1.PageCount.ToString();
        if (GridView1.PageCount > 1)
        {
            DRP_LIST.Text = Convert.ToString(GridView1.PageIndex + 1);
        }

        if (GridView1.Rows.Count < 20)
        {
            LBL_RowStatus.Text = Convert.ToString((GridView1.PageIndex * Convert.ToInt16(Session["DEFAULT_ROWS"].ToString())) + GridView1.Rows.Count);
            Lower_Count        = ((GridView1.PageIndex * Convert.ToInt16(Session["DEFAULT_ROWS"].ToString())) + GridView1.Rows.Count) - (GridView1.Rows.Count + 1);
            Lower_Count        = Lower_Count + 2;
            LBL_RowStatus.Text = "Display Rows: " + Lower_Count.ToString() + "-" + LBL_RowStatus.Text;
        }
        else
        {
            LBL_RowStatus.Text = Convert.ToString((GridView1.PageIndex + 1) * Convert.ToInt16(GridView1.Rows.Count.ToString()));
            Lower_Count        = (GridView1.PageIndex + 1) * Convert.ToInt16(GridView1.Rows.Count.ToString()) - (GridView1.Rows.Count + 1);
            Lower_Count        = Lower_Count + 2;
            LBL_RowStatus.Text = "Display Rows: " + Lower_Count.ToString() + "-" + LBL_RowStatus.Text;
        }
        if (DRP_LIST.Items.Count == 0)
        {
            for (int A = 1; A <= GridView1.PageCount; A++)
            {
                DRP_LIST.Items.Add(A.ToString());
            }
        }
    }
Esempio n. 4
0
 public static string GetItemNameById(int entry)
 {
     try
     {
         if (ItemNameCache.ContainsKey(entry))
         {
             return(ItemNameCache[entry]);
         }
         lock (Locker)
         {
             string randomString = Others.GetRandomString(Others.Random(4, 10));
             Lua.LuaDoString(randomString + ",_,_,_,_,_,_,_,_,_,_ = GetItemInfo(" + entry + ")");
             string itemName = Lua.GetLocalizedText(randomString);
             if (!string.IsNullOrWhiteSpace(itemName))
             {
                 ItemNameCache.Add(entry, itemName);
             }
             return(itemName);
         }
     }
     catch (Exception exception)
     {
         Logging.WriteError("GetNameById(int entry): " + exception);
     }
     return("");
 }
Esempio n. 5
0
        public static void JoinGroup()
        {
            byte[] opCodeAndSize = new byte[2];
            byte[] buffer;
            string randomString = Others.GetRandomString(Others.Random(4, 10));

            Lua.LuaDoString(randomString + " = GetRealmName()");
            byte[] bufferName = MimesisHelpers.StringToBytes(ObjectManager.Me.Name + "-" + Lua.GetLocalizedText(randomString));
            opCodeAndSize[0] = (byte)MimesisHelpers.opCodes.RequestGrouping;
            opCodeAndSize[1] = (byte)bufferName.Length;
            NetworkStream clientStream = client.GetStream();

            clientStream.Write(opCodeAndSize, 0, 2);
            clientStream.Write(bufferName, 0, bufferName.Length); // It's hardcoded "PlayerName-RealmName"
            clientStream.Flush();
            // Now wait for an answer
            try
            {
                int bytesRead = clientStream.Read(opCodeAndSize, 0, 2);
                int len       = opCodeAndSize[1]; // It's 4 (one uint)
                buffer     = new byte[len];
                bytesRead += clientStream.Read(buffer, 0, len);
                RollId     = BitConverter.ToUInt32(buffer, 0);
            }
            catch (Exception e)
            {
                Logging.WriteError("MimesisClientCom > JoinGroup(): " + e);
                return;
            }
            EventsListener.UnHookEvent(WoWEventsType.GROUP_ROSTER_UPDATE, callback => CloseGroupPopup());
            EventsListener.HookEvent(WoWEventsType.GROUP_ROSTER_UPDATE, callback => CloseGroupPopup());
            System.Threading.Thread.Sleep(250 + 2 * Usefuls.Latency);
            Lua.LuaDoString("AcceptGroup()");
        }
Esempio n. 6
0
 private void Translate()
 {
     recordWayB.Text       = nManager.Translate.Get(nManager.Translate.Id.Record_Way);
     saveB.Text            = nManager.Translate.Get(nManager.Translate.Id.Save);
     labelX1.Text          = nManager.Translate.Get(nManager.Translate.Id.Separation_distance_record) + ":";
     delB.Text             = nManager.Translate.Get(nManager.Translate.Id.Del);
     delBlackRadius.Text   = nManager.Translate.Get(nManager.Translate.Id.Del);
     addBlackB.Text        = nManager.Translate.Get(nManager.Translate.Id.Add_this_position_to_Black_list_Radius);
     addNpcB.Text          = nManager.Translate.Get(nManager.Translate.Id.Add_Target_to_Npc_list);
     delNpcB.Text          = nManager.Translate.Get(nManager.Translate.Id.Del);
     loadB.Text            = nManager.Translate.Get(nManager.Translate.Id.Load);
     nameNpcTb.Text        = nManager.Translate.Get(nManager.Translate.Id.Name);
     addByNameNpcB.Text    = nManager.Translate.Get(nManager.Translate.Id.Add_by_Name_to_Npc_list);
     ListOfZonesLabel.Text = nManager.Translate.Get(nManager.Translate.Id.List_Zones) + ":";
     addZoneB.Text         = nManager.Translate.Get(nManager.Translate.Id.Add_Zone);
     delZoneB.Text         = nManager.Translate.Get(nManager.Translate.Id.Del_Zone);
     ZoneNameLabel.Text    = nManager.Translate.Get(nManager.Translate.Id.Zone_Name) + ":";
     ZoneMinLevel.Text     = nManager.Translate.Get(nManager.Translate.Id.Player_Lvl) + " " +
                             nManager.Translate.Get(nManager.Translate.Id.Min);
     ZoneMaxLevelLabel.Text   = nManager.Translate.Get(nManager.Translate.Id.Max);
     TargetMaxLevelLabel.Text = nManager.Translate.Get(nManager.Translate.Id.Max);
     TargetMinLevelLabel.Text = nManager.Translate.Get(nManager.Translate.Id.Target_Lvl) + " " +
                                nManager.Translate.Get(nManager.Translate.Id.Min);
     addTargetEntryB.Text = nManager.Translate.Get(nManager.Translate.Id.Add_Target);
     labelX8.Text         = nManager.Translate.Get(nManager.Translate.Id.Target_Ids);
     MainHeader.TitleText = nManager.Translate.Get(nManager.Translate.Id.Profile_Creator) + " - " + Information.MainTitle;
     this.Text            = Others.GetRandomString(Others.Random(4, 10));
 }
Esempio n. 7
0
        private void LoadButton_Click(object sender,
                                      EventArgs e)
        {
            try
            {
                string file =
                    Others.DialogBoxOpenFile(Application.StartupPath + "\\Profiles\\Battlegrounder\\",
                                             "Profile files (*.xml)|*.xml|All files (*.*)|*.*");

                if (File.Exists(file))
                {
                    _profile = new BattlegrounderProfile();
                    _profile = XmlSerializer.Deserialize <BattlegrounderProfile>(file);
                    RefreshListZones();
                    RefreshForm();
                }
            }
            catch (Exception ex)
            {
                Logging.WriteError(
                    "Battlegrounder > Bot > ProfileCreator > LoadButton_Click(object sender, EventArgs e): " +
                    ex);
                RefreshListZones();
                RefreshForm();
            }
        }
Esempio n. 8
0
        public static List <string> ExtractAllPathsTaxi()
        {
            string result = Others.GetRandomString(Others.Random(4, 10));

            Lua.LuaDoString(result + "= \"\"; nb = NumTaxiNodes(); for i=1,nb do n = TaxiNodeName(i); x,y = TaxiNodePosition(i); " + result + " = " + result +
                            ".. n .. \"#\" .. x .. \"^\" .. y  .. \"@\" .. GetNumRoutes(i) .. \"~\" .. TaxiNodeGetType(i) .. \"|\" end");
            string allPaths  = Lua.GetLocalizedText(result);
            var    ListPaths = new List <String>();

            for (int i = 0; i < allPaths.Split('|').Length - 1; i++)
            {
                ListPaths.Add(allPaths.Split('|')[i]);
            }
            var    listPathFinal = new List <string>();
            string lowerValue    = "";

            while (ListPaths.Count > 0)
            {
                foreach (string listPath in ListPaths)
                {
                    if (lowerValue == "")
                    {
                        lowerValue = listPath;
                    }
                    else if (Others.ToSingle(listPath.Split('^')[1].Split('@')[0].Trim()) < Others.ToSingle(lowerValue.Split('^')[1].Split('@')[0].Trim()))
                    {
                        lowerValue = listPath;
                    }
                }
                ListPaths.Remove(lowerValue);
                listPathFinal.Add(lowerValue);
                lowerValue = "";
            }
            return(listPathFinal); // listPathFinal;
        }
Esempio n. 9
0
        public static bool IsSpellUsableLUA(Spell spell)
        {
            try
            {
                if (IsSpellOnCooldown(spell.Id, spell.CategoryId, spell.StartRecoveryCategoryId))
                {
                    return(false);
                }

                if (IsSpellOnCooldown(spell.Ids, spell.CategoryId, spell.StartRecoveryCategoryId))
                {
                    return(false); // Some spell like Ascendance that has multiples Ids would fails the "Id" check.
                }
                // We only need LUA to check for ressources now.

                string luaVarUsable    = Others.GetRandomString(Others.Random(4, 10));
                string luaVarNoMana    = Others.GetRandomString(Others.Random(4, 10));
                string luaResultUsable = Others.GetRandomString(Others.Random(4, 10));

                string luaCode = luaVarUsable + "," + luaVarNoMana + "=IsUsableSpell(\"" + spell.NameInGame + "\"); ";
                luaCode += "if " + luaVarUsable + " and not " + luaVarNoMana + " then ";
                luaCode += luaResultUsable + "=\"1\" ";
                luaCode += "end ";

                Lua.LuaDoString(luaCode, false, false);
                string ret = Lua.GetLocalizedText(luaResultUsable);

                return(ret == "1");
            }
            catch (Exception exception)
            {
                Logging.WriteError("public static bool IsSpellUsableLUA(Spell spell): " + exception);
                return(false);
            }
        }
Esempio n. 10
0
        public OtherEditForm(Others other, List <Others> o)

        {
            _other     = other;
            ListOthers = o;
            InitializeComponent();
        }
Esempio n. 11
0
        private void AccountPanelTimer_Tick(object sender, EventArgs e)
        {
            string botOnline = Others.GetRequest("http://tech.thenoobbot.com/auth.php", "botOnline=true");

            if (LoginServer.IsFreeVersion)
            {
                int timeLeftSec = (LoginServer.StartTime + 1000 * 60 * 20) - Others.Times;
                AccountName.Text = LoginServer.Login;
                TimeLeft.Text    = Others.SecToHour(timeLeftSec / 1000);
                OnlineBot.Text   = botOnline;
            }
            else
            {
                string timeLeft = Others.GetReqWithAuthHeader("http://tech.thenoobbot.com/auth.php?TimeSubscription=true", LoginServer.Login, LoginServer.Password)[0];
                AccountName.Text           = LoginServer.Login;
                TimeLeft.Text              = timeLeft;
                OnlineBot.Text             = nManager.Translate.Get(nManager.Translate.Id.OnlineBots) + " " + botOnline;
                AccountPanelTimer.Interval = 5000;
            }
            if (Remote.RemoteActive)
            {
                RemoteSessionInfo.Text = nManager.Translate.Get(nManager.Translate.Id.SessionInfo) + " " + Remote.SessionKey;
            }
            else
            {
                RemoteSessionInfo.Text = "";
            }
        }
Esempio n. 12
0
        public static void DoTalents()
        {
            try
            {
                if (GetNumUnspentTalents() == 0)
                {
                    return;
                }
                if (Others.ExistFile(Application.StartupPath + "\\CombatClasses\\Talents\\" + ObjectManager.ObjectManager.Me.WowSpecialization() + ".talents.txt"))
                {
                    Lua.RunMacroText("/click PlayerTalentFrameCloseButton"); // Make sure it's already closed.
                    Thread.Sleep(400);
                    Lua.RunMacroText("/click TalentMicroButton");
                    string advised = Others.ReadFile(Application.StartupPath + "\\CombatClasses\\Talents\\" + ObjectManager.ObjectManager.Me.WowSpecialization() + ".talents.txt");
                    var    talents = advised.Split('|');
                    foreach (string s in talents)
                    {
                        Lua.LuaDoString("PlayerTalentFrame_SelectTalent(" + s + ")");
                    }

                    Lua.RunMacroText("/click PlayerTalentFrameTalentsLearnButton");
                    Thread.Sleep(400);
                    Lua.RunMacroText("/click PlayerTalentFrameCloseButton");
                }
            }
            catch (Exception exception)
            {
                Logging.WriteError("DoTalents(): " + exception);
            }
        }
Esempio n. 13
0
        private void close(object sender, RoutedEventArgs e)
        {
            Window others = new Others();

            others.Show();
            this.Close();
        }
Esempio n. 14
0
        public static bool HasToy(int entry)
        {
            string randomString = Others.GetRandomString(Others.Random(4, 10));

            Lua.LuaDoString(randomString + " = tostring(PlayerHasToy(" + entry + "));");
            return(Others.ToBoolean(Lua.GetLocalizedText(randomString)));
        }
Esempio n. 15
0
 public void AddActor(GameRolePlayActorInformations actor)
 {
     if (actor is GameRolePlayCharacterInformations character)
     {
         Players.Add(character);
         Console.WriteLine($@"(Player) {character.Name} en cellid ->  {character.Disposition.CellId}");
         return;
     }
     if (actor is GameRolePlayGroupMonsterInformations monster)
     {
         Monsters.Add(monster);
         var monsterName = FastD2IReader.Instance.GetText(ObjectDataManager.Instance
                                                          .Get <Monster>(monster.StaticInfos.MainCreatureLightInfos.CreatureGenericId).NameId);
         Console.WriteLine($@"(Monster) {monsterName} en cellid ->  {monster.Disposition.CellId}");
         return;
     }
     if (actor is GameRolePlayNpcInformations npc)
     {
         Npcs.Add(npc);
         var npcName =
             FastD2IReader.Instance.GetText(ObjectDataManager.Instance.Get <Npc>(npc.NpcId).NameId);
         Console.WriteLine($@"(Npc) {npcName} en cellid ->  {npc.Disposition.CellId}");
         return;
     }
     Others.Add(actor);
     Console.WriteLine($@"(Other) Aucune Idée en cellid -> {actor.Disposition.CellId}");
 }
Esempio n. 16
0
        public OtherEditForm(Others other)

        {
            _other = other;

            InitializeComponent();
        }
Esempio n. 17
0
 public void RefreshActor(double contextualId, short cellEnd)
 {
     if (Players.Find(p => p.ContextualId == contextualId) != null)
     {
         Players.Find(p => p.ContextualId == contextualId).Disposition.CellId = cellEnd;
         Console.WriteLine(
             $@"(Players) {
                     Players.Find(p => p.ContextualId == contextualId).Name
                 } se déplace sur la cellid -> {cellEnd}");
     }
     else if (Monsters.Find(p => p.ContextualId == contextualId) != null)
     {
         Monsters.Find(p => p.ContextualId == contextualId).Disposition.CellId = cellEnd;
         Console.WriteLine($@"(Monsters) se déplace sur la cellid -> {cellEnd}");
     }
     else if (Others.Find(p => p.ContextualId == contextualId) != null)
     {
         Others.Find(p => p.ContextualId == contextualId).Disposition.CellId = cellEnd;
         Console.WriteLine($@"(Others) se déplace sur la cellid -> {cellEnd}");
     }
     else if (Npcs.Find(p => p.ContextualId == contextualId) != null)
     {
         Npcs.Find(p => p.ContextualId == contextualId).Disposition.CellId = cellEnd;
         Console.WriteLine($@"(Npcs) se déplace sur la cellid -> {cellEnd}");
     }
     else
     {
         Console.WriteLine($@"Quelque chose se déplace sur la cellid -> {cellEnd}");
     }
 }
Esempio n. 18
0
 public void RemoveActor(double contextualId)
 {
     Players.RemoveAll(p => p.ContextualId == contextualId);
     Monsters.RemoveAll(p => p.ContextualId == contextualId);
     Npcs.RemoveAll(p => p.ContextualId == contextualId);
     Others.RemoveAll(p => p.ContextualId == contextualId);
 }
Esempio n. 19
0
        public override int GetHashCode()
        {
            int hashCode = -1002186340;

            hashCode = hashCode * -1521134295 + LabBookId.GetHashCode();
            hashCode = hashCode * -1521134295 + Solid.GetHashCode();
            hashCode = hashCode * -1521134295 + Ash450.GetHashCode();
            hashCode = hashCode * -1521134295 + Ash900.GetHashCode();
            hashCode = hashCode * -1521134295 + Organic.GetHashCode();
            hashCode = hashCode * -1521134295 + Titanium.GetHashCode();
            hashCode = hashCode * -1521134295 + Chalk.GetHashCode();
            hashCode = hashCode * -1521134295 + Others.GetHashCode();
            hashCode = hashCode * -1521134295 + VocCatId.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(VocAmount);

            hashCode = hashCode * -1521134295 + Crucible1.GetHashCode();
            hashCode = hashCode * -1521134295 + Crucible2.GetHashCode();
            hashCode = hashCode * -1521134295 + Crucible3.GetHashCode();
            hashCode = hashCode * -1521134295 + Paint1.GetHashCode();
            hashCode = hashCode * -1521134295 + Paint2.GetHashCode();
            hashCode = hashCode * -1521134295 + Paint3.GetHashCode();
            hashCode = hashCode * -1521134295 + Crucible105_1.GetHashCode();
            hashCode = hashCode * -1521134295 + Crucible105_2.GetHashCode();
            hashCode = hashCode * -1521134295 + Crucible105_3.GetHashCode();
            hashCode = hashCode * -1521134295 + Crucible405_1.GetHashCode();
            hashCode = hashCode * -1521134295 + Crucible405_2.GetHashCode();
            hashCode = hashCode * -1521134295 + Crucible405_3.GetHashCode();
            hashCode = hashCode * -1521134295 + Crucible900_1.GetHashCode();
            hashCode = hashCode * -1521134295 + Crucible900_2.GetHashCode();
            hashCode = hashCode * -1521134295 + Crucible900_3.GetHashCode();
            hashCode = hashCode * -1521134295 + Created.GetHashCode();
            hashCode = hashCode * -1521134295 + Updated.GetHashCode();
            return(hashCode);
        }
Esempio n. 20
0
 public static int GetItemIdByName(string name)
 {
     if (name == "")
     {
         return(0);
     }
     try
     {
         if (ItemIdCache.ContainsKey(name))
         {
             return(ItemIdCache[name]);
         }
         lock (Locker)
         {
             string randomString = Others.GetRandomString(Others.Random(4, 10));
             Lua.LuaDoString(
                 "local nameItem = \"" + name + "\" " +
                 "_,itemLink,_,_,_,_,_,_,_,_,_  = GetItemInfo(nameItem); " +
                 "if itemLink == nil then " + randomString + " = 0 else " +
                 "_,_," + randomString + " = string.find(itemLink, 'item:(%d+)') end");
             int itemEntry = Others.ToInt32(Lua.GetLocalizedText(randomString));
             if (itemEntry > 0)
             {
                 ItemIdCache.Add(name, itemEntry);
             }
             return(itemEntry);
         }
     }
     catch (Exception exception)
     {
         Logging.WriteError("GetIdByName(string name): " + exception);
     }
     return(0);
 }
Esempio n. 21
0
        protected BaseDictionaryElement(string fullForm, string[] others)
        {
            FullForm = fullForm;
            Others   = others.ToArray();

            AllForms = Others.Prepend(fullForm).ToArray();
        }
Esempio n. 22
0
 public static string GetItemSpell(int entry)
 {
     try
     {
         lock (ItemSpellCache)
         {
             if (ItemSpellCache.ContainsKey(entry))
             {
                 return(ItemSpellCache[entry]);
             }
             string randomString = Others.GetRandomString(Others.Random(4, 10));
             Lua.LuaDoString(randomString + ",_ = GetItemSpell(" + entry + ")");
             string sResult = Lua.GetLocalizedText(randomString);
             if (sResult != string.Empty && sResult != "nil")
             {
                 ItemSpellCache.Add(entry, sResult);
                 return(sResult);
             }
         }
     }
     catch (Exception exception)
     {
         Logging.WriteError("GetItemSpellByItemId(uint itemId): " + exception);
     }
     return("");
 }
Esempio n. 23
0
 private void LoadGrid(string filePath = "")
 {
     try
     {
         if (string.IsNullOrEmpty(filePath))
         {
             filePath = Others.DialogBoxOpenFile(Application.StartupPath + @"\Data\Lang\", "Langage files (*.xml)|*.xml");
         }
         if (File.Exists(filePath))
         {
             Translate.Language currentLangage = XmlSerializer.Deserialize <Translate.Language>(filePath);
             CheckIdListAndReOrganize(ref currentLangage);
             for (int i = 0; i <= _defaultLangage.Translations.Count - 1; i++)
             {
                 if (string.IsNullOrEmpty(currentLangage.Translations[i].Text) || currentLangage.Translations[i].Text == currentLangage.Translations[i].Id.ToString() ||
                     currentLangage.Translations[i].Text.Contains("_"))
                 {
                     currentLangage.Translations[i].Text = _defaultLangage.Translations[i].Text;
                 }
             }
             TranslationTable.Rows.Clear();
             for (int i = 0; i < _defaultLangage.Translations.Count; i++)
             {
                 Translate.Translation translation = _defaultLangage.Translations[i];
                 TranslationTable.Rows.Add(new object[] { translation.Id.ToString(), currentLangage.Translations[i].Text, translation.Text });
             }
         }
     }
     catch (Exception ex)
     {
         Logging.WriteError("Translate_Tools > LoadGrid(string filePath): " + ex);
     }
 }
Esempio n. 24
0
    public void PlayLooping(Others type, float volume = 1)
    {
        int index = (int)type;

        loopAudioSource.volume = volume;
        loopAudioSource.PlayOneShot(otherClips[index]);
    }
Esempio n. 25
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var account = Others.GetProcessOwner(Process.GetCurrentProcess().Id);
            var botFile = Others.ReadFileAllLines(Application.StartupPath + "\\Data\\Launcher.txt")[0].Trim();

            if (File.Exists(botFile))
            {
                string random = Others.GetRandomString(Others.Random(4, 10));
                string tnbExe = random + ".exe";
                var    sw     = new StreamWriter(Application.StartupPath + "\\Data\\Launcher.txt");
                sw.WriteLine(tnbExe);
                sw.Close();
                File.Move(botFile, tnbExe);
                if (File.Exists(botFile + ".config"))
                {
                    File.Move(botFile + ".config", tnbExe + ".config");
                }
                Others.AddFileSecurity(tnbExe, account, FileSystemRights.ReadData, AccessControlType.Allow);
                Others.RemoveFileSecurity(tnbExe, account, FileSystemRights.ReadData, AccessControlType.Deny);
                Process.Start(tnbExe);
                Process.GetCurrentProcess().Kill();
            }
            MessageBox.Show("Please do not modify the name of the executable by yourself. Restore the original name or re-download the software.");
            Process.GetCurrentProcess().Kill();
        }
Esempio n. 26
0
        private static int GetNumUnspentTalents()
        {
            string res        = Others.GetRandomString(Others.Random(4, 10));
            int    numUnspent = Others.ToInt32(Lua.LuaDoString(res + " = GetNumUnspentTalents()", res));

            return(numUnspent);
        }
Esempio n. 27
0
        private void InitializeProgram()
        {
            try
            {
                // File .exe.config
                Process tempsProcess = Process.GetCurrentProcess();
                if (!Others.ExistFile(Application.StartupPath + "\\" + tempsProcess.ProcessName + ".exe.config"))
                {
                    var sw = new StreamWriter(Application.StartupPath + "\\" + tempsProcess.ProcessName + ".exe.config");
                    sw.WriteLine("<?xml version=\"1.0\"?>");
                    sw.WriteLine("<configuration>");
                    sw.WriteLine("<startup>");
                    sw.WriteLine("<supportedRuntime version=\"v4.0\"/>");
                    sw.WriteLine("</startup>");
                    sw.WriteLine("<runtime>");
                    sw.WriteLine("<loadFromRemoteSources enabled=\"true\"/>");
                    sw.WriteLine("</runtime>");
                    sw.WriteLine("</configuration>");
                    sw.Close();

                    Process.Start(Application.StartupPath + "\\" + tempsProcess.ProcessName + ".exe");
                    tempsProcess.Kill();
                }

                LangSelection.DropDownStyle = ComboBoxStyle.DropDownList;
                Others.GetVisualStudioRedistribuable2013();
            }
            catch (Exception ex)
            {
                Logging.WriteError("Login > InitializeProgram(): " + ex);
            }
        }
Esempio n. 28
0
 private void SaveGroupedProfileAs_Click(object sender, EventArgs e)
 {
     if (GroupedProfilesList.Items.Count > 0)
     {
         _profile.Includes.Clear();
         foreach (string pathFile in GroupedProfilesList.Items)
         {
             string fullPathToFile = Application.StartupPath + "\\Profiles\\Quester\\" + pathFile;
             if (!string.IsNullOrWhiteSpace(pathFile) && File.Exists(fullPathToFile))
             {
                 _profile.Includes.Add(new Include {
                     PathFile = pathFile, ScriptCondition = ""
                 });
             }
         }
         string fileToSaveAs = Others.DialogBoxSaveFile(Application.StartupPath + "\\Profiles\\Quester\\Grouped\\",
                                                        nManager.Translate.Get(nManager.Translate.Id.GroupedQuestProfileFile) + " (*.xml)|*.xml");
         if (fileToSaveAs == "")
         {
             return;
         }
         if (XmlSerializer.Serialize(fileToSaveAs, _profile))
         {
             Close();
         }
     }
     else
     {
         MessageBox.Show(nManager.Translate.Get(nManager.Translate.Id.CantSaveEmptyGroupedNew));
     }
 }
Esempio n. 29
0
        public async Task ExceedMaxOpenFiles()
        {
            var streams       = new List <ManualStream> ();
            var streamCreated = new ReusableTaskCompletionSource <bool> ();
            Func <ITorrentFileInfo, FileAccess, ITorrentFileStream> creator = (file, access) => {
                var s = new ManualStream(file, access);
                s.WriteTcs = new ReusableTaskCompletionSource <int> ();
                streams.Add(s);
                streamCreated.SetResult(true);
                return(s);
            };

            using var writer = new DiskWriter(creator, 1);

            var writeTask = writer.WriteAsync(TorrentFile, 0, new byte[100], 0, 100);
            await streamCreated.Task.WithTimeout();

            // There's a limit of 1 concurrent read/write.
            var secondStreamWaiter = streamCreated.Task.AsTask();
            var secondStream       = writer.WriteAsync(Others.First(), 0, new byte[100], 0, 100);

            Assert.ThrowsAsync <TimeoutException> (() => secondStreamWaiter.WithTimeout(100));

            streams[0].WriteTcs.SetResult(1);
            await secondStreamWaiter.WithTimeout();

            streams[1].WriteTcs.SetResult(1);

            await secondStream.WithTimeout();

            Assert.IsTrue(streams[0].Disposed);
            Assert.IsFalse(streams[1].Disposed);
        }
Esempio n. 30
0
        public static bool SpellHasCharges(uint spellId)
        {
            string randomStringResult = Others.GetRandomString(Others.Random(4, 10));
            string ret = Lua.LuaDoString("_, " + randomStringResult + " = GetSpellCharges(" + spellId + ")", randomStringResult);

            return(Others.ToInt32(ret) > 0);
        }
        internal MobeelizerOperationError ProcessInputFile(Others.File inputFile, bool isAllSynchronization)
        {
            MobeelizerInputData inputData = null;
            try
            {
                inputData = new MobeelizerInputData(inputFile);
                application.GetFileService().AddFilesFromSync(inputData.GetFiles(), inputData);
                MobeelizerOperationError updateError = ((MobeelizerDatabase)application.GetDatabase()).UpdateEntitiesFromSync(inputData.GetInputData(), isAllSynchronization);
                if (updateError != null)
                {
                    return updateError;
                }

                application.GetFileService().DeleteFilesFromSync(inputData.GetDeletedFiles());
                return null;
            }
            catch (IOException e)
            {
                throw new InvalidOperationException(e.Message, e);
            }
            finally
            {
                if (inputData != null)
                {
                    inputData.Close();
                }
            }
        }
Esempio n. 32
0
 internal MobeelizerOutputData(Others.File file, Others.File tmpFile)
 {
     this.dataFile = tmpFile;
     outputStream = new StreamWriter(tmpFile.OpenToWrite());
     zip = new ZipOutputStream(file.OpenToWrite());
     zip.UseZip64 = UseZip64.Off;
     deletedFiles = new List<String>();
 }
Esempio n. 33
0
 internal MobeelizerInputData(Others.File inputFile)
 {
     MemoryStream tmpStream = new MemoryStream();
     using (IsolatedStorageFileStream stream = inputFile.OpenToRead())
     {
         stream.CopyTo(tmpStream);
     }
     this.zipFile = new ZipFile(tmpStream);
 }
        internal MobeelizerOperationError PrepareOutputFile(Others.File outputFile)
        {
            MobeelizerOutputData outputData = null;
            MobeelizerSyncEnumerable enumerable = null;
            MobeelizerSyncFileEnumerable filesToSync = null;
            try
            {
                outputData = new MobeelizerOutputData(outputFile, GetTmpOutputFile());
                enumerable = application.GetDatabase().GetEntitiesToSync();
                foreach(MobeelizerJsonEntity entity in enumerable)
                {
                    Log.i(TAG, "Add entity to sync: " + entity.ToString());
                    outputData.WriteEntity(entity);
                }

                filesToSync = application.GetDatabase().GetFilesToSync();
                foreach(var file in filesToSync)
                {
                    String guid = file.Guid;
                    using (Stream stream = file.GetStream())
                    {
                        if (stream == null)
                        {
                            continue;
                        }

                        outputData.WriteFile(guid, stream);
                        Log.i(TAG, "Add file to sync: " + guid);
                    }
                }

                return null;
            }
            catch (IOException e)
            {
                throw new InvalidOperationException(e.Message, e);
            }
            finally
            {
                if (outputData != null)
                {
                    outputData.Close();
                }
            }
        }
 public MobeelizerSyncResponse SendSyncDiffRequest(Others.File outputFile)
 {
     CheckNetworkAwailable();
     try
     {
         return connectionService.SendSyncDiffRequest(outputFile);
     }
     catch (IOException e)
     {
         throw new InvalidOperationException(e.Message, e);
     }
 }
        public MobeelizerSyncResponse SendSyncDiffRequest(Others.File outputFile)
        {
            String boundary = DateTime.Now.Ticks.ToString();

            WebRequest request = WebRequest.Create(GetUrl("/synchronize"));
            request.Method = "POST";
            request.ContentType = String.Format("multipart/form-data; boundary={0}",boundary);

            using (Stream requestStream = new Synchronizer().GetRequestStream(request))
            {
                String header = String.Format("--{0}\r\nContent-Disposition: form-data; name=\"file\"; filename=\"file\";\r\nContent-Type: application/octet-stream\r\n\r\n", boundary);
                requestStream.Write(Encoding.UTF8.GetBytes(header), 0, header.Length);
                using (IsolatedStorageFileStream stream = outputFile.OpenToRead())
                {
                    int lenght = (int)stream.Length;
                    byte[] bytes = new byte[lenght];
                    stream.Read(bytes, 0, lenght);
                    requestStream.Write(bytes, 0, lenght);
                }
                string footer = "\r\n--" + boundary + "--\r\n";
                byte[] footerbytes = Encoding.UTF8.GetBytes(footer);
                requestStream.Write(footerbytes, 0, footerbytes.Length);
            }

            SetHeaders(request, false, true);
            try
            {
                MobeelizerResponse response = new Synchronizer().GetResponse(request);
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    return new MobeelizerSyncResponse((response as MobeelizerTicketResponse).Ticket);
                }
                else if (response.StatusCode == HttpStatusCode.InternalServerError)
                {
                    return new MobeelizerSyncResponse(MobeelizerOperationError.ServerError((response as MobeelizerJsonResponse).Json));
                }
                else
                {
                    throw new IOException("Http connection status code: " + response.StatusCode.ToString());
                }
            }
            catch (NullReferenceException)
            {
                throw new IOException("Server not respond.");
            }
        }
 internal MobeelizerGetSyncDataOperationResult(Others.File inputFile)
 {
     this.InputFile = inputFile;
 }
Esempio n. 38
0
	void Start(){
		_others = GetComponent<Others>();
	}
 public MobeelizerSyncResponse SendSyncDiffRequest(Others.File outputFile)
 {
     throw new NotSupportedException(SYNC_IS_NOT_SUPPORTED_IN_DEVELOPMENT_MODE);
 }