예제 #1
0
 public void CreateHero(int player)
 {
     if (NewHeroPtr != IntPtr.Zero)
     {
         MemoryApi.WriteMemoryPtrBytes(gameProcess, IntPtr.Add(NewHeroPtr, 0x8D), BitConverter.GetBytes(player));
     }
 }
예제 #2
0
 private void SetOpCode(IntPtr loc, byte[] code, bool Active)
 {
     byte[] check = MemoryApi.ReadMemoryPtr(gameProcess, loc, code.Length, out _);
     if (MatchingByteArray(check, code) && !Active)
     {
         MemoryApi.WriteMemoryPtrBytes(gameProcess, loc, NoOpCode(code.Length));
     }
     else if (MatchingByteArray(check, NoOpCode(code.Length)) && Active)
     {
         MemoryApi.WriteMemoryPtrBytes(gameProcess, loc, code);
     }
 }
예제 #3
0
 public void SetPlayerLevel(int player, int newLevel)
 {
     MemoryApi.WriteMemoryPtrBytes(gameProcess, GetPlayerLevelPtr(player), BitConverter.GetBytes(newLevel));
     if (newLevel > 10)
     {
         MemoryApi.WriteMemoryPtrBytes(gameProcess, GetPlayerXPPtr(player), BitConverter.GetBytes(PlayerXpValues[9]));
     }
     else
     {
         MemoryApi.WriteMemoryPtrBytes(gameProcess, GetPlayerXPPtr(player), BitConverter.GetBytes(PlayerXpValues[newLevel - 1]));
     }
 }
예제 #4
0
 public void SetBotShop(bool canShop)
 {
     if (canShop)
     {
         MemoryApi.WriteMemoryPtrBytes(gameProcess, GetBotLevelTest(), BitConverter.GetBytes(10));
         MemoryApi.WriteMemoryPtrBytes(gameProcess, GetBotTierTest(), BitConverter.GetBytes(99));
     }
     else
     {
         MemoryApi.WriteMemoryPtrBytes(gameProcess, GetBotLevelTest(), BitConverter.GetBytes(0));
         MemoryApi.WriteMemoryPtrBytes(gameProcess, GetBotTierTest(), BitConverter.GetBytes(0));
     }
 }
예제 #5
0
 public void SetHeroPositionSmart(int player, int index, int xPos, int yPos)
 {
     if (player == 0)
     {
         yPos = 3 - yPos;
     }
     else
     {
         xPos  = 7 - xPos;
         yPos -= 1;
     }
     MemoryApi.WriteMemoryPtrBytes(gameProcess, GetUnitXPtr(player, index), BitConverter.GetBytes(xPos));
     MemoryApi.WriteMemoryPtrBytes(gameProcess, GetUnitYPtr(player, index), BitConverter.GetBytes(yPos));
 }
예제 #6
0
        public void SetHeroID(int player, int index, int newID)
        {
            MemoryApi.WriteMemoryPtrBytes(gameProcess, GetUnitIDPtr(player, index), BitConverter.GetBytes(newID));
            SetHeroSupplyCount(player, index, 1);

            for (int i = 91; i < 95; i++)
            {
                if (newID == i)
                {
                    SetHeroSupplyCount(player, index, 0);
                    break;
                }
            }
        }
예제 #7
0
 public void SetPlayerGold(int player, int newGold)
 {
     MemoryApi.WriteMemoryPtrBytes(gameProcess, GetPlayerGoldPtr(player), BitConverter.GetBytes(newGold));
 }
예제 #8
0
 public void SetPlayerLife(int player, int newLife)
 {
     MemoryApi.WriteMemoryPtrBytes(gameProcess, GetPlayerLifePtr(player), BitConverter.GetBytes(newLife));
 }
예제 #9
0
 public void SetItemHolder(int player, int index, int HeroUID)
 {
     MemoryApi.WriteMemoryPtrBytes(gameProcess, GetItemHolderPtr(player, index), BitConverter.GetBytes(HeroUID));
 }
예제 #10
0
 public void SetItemID(int player, int index, int newID)
 {
     MemoryApi.WriteMemoryPtrBytes(gameProcess, GetItemIDPtr(player, index), BitConverter.GetBytes(newID));
 }
예제 #11
0
 public void SetHeroSupplyCount(int player, int index, int count)
 {
     MemoryApi.WriteMemoryPtrBytes(gameProcess, GetUnitSupplyCountPtr(player, index), BitConverter.GetBytes(count));
 }
예제 #12
0
 public void SetHeroKills(int player, int index, int kills)
 {
     MemoryApi.WriteMemoryPtrBytes(gameProcess, GetUnitKillsPtr(player, index), BitConverter.GetBytes(kills));
 }
예제 #13
0
 public void SetHeroLevel(int player, int index, int newLevel)
 {
     MemoryApi.WriteMemoryPtrBytes(gameProcess, GetUnitLevelPtr(player, index), BitConverter.GetBytes(newLevel));
 }
예제 #14
0
 public void SetHeroPosition(int player, int index, int xPos, int yPos)
 {
     MemoryApi.WriteMemoryPtrBytes(gameProcess, GetUnitXPtr(player, index), BitConverter.GetBytes(xPos));
     MemoryApi.WriteMemoryPtrBytes(gameProcess, GetUnitYPtr(player, index), BitConverter.GetBytes(yPos));
 }
예제 #15
0
        public bool CreateHeroInjection()
        {
            bool ByteCountError = false;

            Byte[] write;
            Dictionary <string, IntPtr> Locations = new Dictionary <string, IntPtr>();

            Locations.Add("herofunc", IntPtr.Add(serverAddress, 0xF6AA0 - 5));
            Locations.Add("returntick", IntPtr.Add(serverAddress, 0xE48A0 + 8 - 5));
            Locations.Add("tickfunc", IntPtr.Add(serverAddress, 0xE48A0));

            IntPtr target   = IntPtr.Subtract(serverAddress, 0x10000);
            int    trycount = 1000;
            IntPtr newMem   = IntPtr.Zero;

            while (newMem == IntPtr.Zero && trycount > 0)
            {
                trycount--;
                newMem = MemoryApi.MemoryAlloc(gameProcess, target, 0x100);
                target = IntPtr.Subtract(target, 0x10000);
            }
            if (newMem != IntPtr.Zero)
            {
                Assembly assembly = Assembly.GetExecutingAssembly(); //https://stackoverflow.com/questions/3314140/how-to-read-embedded-resource-text-file
                using (Stream stream = assembly.GetManifestResourceStream("UnderlordsTracker.TextFiles.AddHeroInjection.txt"))
                {
                    using (StreamReader sr = new StreamReader(stream))
                    {
                        string      line;
                        List <byte> code = new List <byte>();
                        while ((line = sr.ReadLine()) != null && !ByteCountError)
                        {
                            string[] split = line.Split('-');
                            split[0] = split[0].Replace(" ", "");
                            split[0] = split[0].Trim();
                            if (split[0].Contains("%"))
                            {
                                int      byteOffset   = code.Count;
                                string[] secondSplit  = split[0].Split('%');
                                byte[]   jumpDistance = GetByteDistance(IntPtr.Add(newMem, byteOffset), Locations[secondSplit[1]]);
                                code.Add(BitConverter.GetBytes(int.Parse(secondSplit[0], System.Globalization.NumberStyles.HexNumber))[0]);
                                code.AddRange(jumpDistance);
                            }
                            else
                            {
                                if (split[0].Length % 2 != 0)
                                {
                                    ByteCountError = true;
                                }
                                else
                                {
                                    for (int i = 0; i < split[0].Length / 2; i++)
                                    {
                                        code.Add(BitConverter.GetBytes(int.Parse(split[0].Substring(i * 2, 2), System.Globalization.NumberStyles.HexNumber))[0]);
                                    }
                                }
                            }
                        }
                        write = code.ToArray();
                    }
                }
                if (!ByteCountError)
                {
                    MemoryApi.WriteMemoryPtrBytes(gameProcess, newMem, write);
                    List <byte> code = new List <byte>();
                    code.Add(0xE9);
                    code.AddRange(GetByteDistance(Locations["tickfunc"], newMem - 5));
                    for (int i = 0; i < 3; i++)
                    {
                        code.Add(0x90);
                    }
                    MemoryApi.WriteMemoryPtrBytes(gameProcess, Locations["tickfunc"], code.ToArray());
                    NewHeroPtr = newMem;
                    return(true);
                }
            }
            return(false);
        }