Пример #1
0
        public Item GetItem(int player, int index)
        {
            Item i;

            i.player = player;
            i.index  = index;
            i.IID    = BitConverter.ToInt32(MemoryApi.ReadMemoryPtr(gameProcess, GetItemIDPtr(player, index), 4, out _), 0);
            i.UID    = BitConverter.ToInt32(MemoryApi.ReadMemoryPtr(gameProcess, GetItemHolderPtr(player, index), 4, out _), 0);
            return(i);
        }
Пример #2
0
        private IntPtr GetLayeredPointer(IntPtr ptr, int[] offset)//https://stackoverflow.com/questions/47481769/c-sharp-multi-level-pointers-memory-reading
        {
            IntPtr output = ptr;

            for (int i = 0; i < offset.Length - 1; i++)
            {
                output = IntPtr.Add(output, offset[i]);
                output = new IntPtr(BitConverter.ToInt64(MemoryApi.ReadMemoryPtr(gameProcess, output, 8, out _), 0));
            }
            output = IntPtr.Add(output, offset[offset.Length - 1]);
            return(output);
        }
Пример #3
0
 private bool IsOpCodeActive(IntPtr loc, int length)
 {
     byte[] check = MemoryApi.ReadMemoryPtr(gameProcess, loc, length, out _);
     if (MatchingByteArray(check, NoOpCode(length)))
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Пример #4
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);
     }
 }
Пример #5
0
        public Hero GetHero(int player, int index)
        {
            Hero h;

            h.player = player;
            h.index  = index;
            h.UID    = BitConverter.ToInt32(MemoryApi.ReadMemoryPtr(gameProcess, GetUnitUniqueIDPtr(player, index), 4, out _), 0);
            h.HID    = BitConverter.ToInt32(MemoryApi.ReadMemoryPtr(gameProcess, GetUnitIDPtr(player, index), 4, out _), 0);
            h.xPos   = BitConverter.ToInt32(MemoryApi.ReadMemoryPtr(gameProcess, GetUnitXPtr(player, index), 4, out _), 0);
            h.yPos   = BitConverter.ToInt32(MemoryApi.ReadMemoryPtr(gameProcess, GetUnitYPtr(player, index), 4, out _), 0);
            h.level  = BitConverter.ToInt32(MemoryApi.ReadMemoryPtr(gameProcess, GetUnitLevelPtr(player, index), 4, out _), 0);
            h.kills  = BitConverter.ToInt32(MemoryApi.ReadMemoryPtr(gameProcess, GetUnitKillsPtr(player, index), 4, out _), 0);
            return(h);
        }
Пример #6
0
        public bool HeroInjectionActive()
        {
            byte[] code = MemoryApi.ReadMemoryPtr(gameProcess, IntPtr.Add(serverAddress, TickOpOffset), 1, out _);
            if (code[0] == 0xE9)
            {
                code = MemoryApi.ReadMemoryPtr(gameProcess, IntPtr.Add(serverAddress, TickOpOffset + 1), 4, out _);
                int    offset  = BitConverter.ToInt32(code, 0);
                IntPtr testPtr = IntPtr.Add(serverAddress, TickOpOffset + 5 + offset);

                if (NewHeroPtr != testPtr)
                {
                    NewHeroPtr = testPtr;
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #7
0
 public bool MatchingOpCodes()
 {
     byte[] check = MemoryApi.ReadMemoryPtr(gameProcess, GetOpMovePtr(), MoveOpcodeBytes.Length, out _);
     if (!MatchingByteArray(check, MoveOpcodeBytes) && !MatchingByteArray(check, NoOpCode(MoveOpcodeBytes.Length)))
     {
         return(false);
     }
     check = MemoryApi.ReadMemoryPtr(gameProcess, GetOpSwapPtr(), SwapOpcodeBytes.Length, out _);
     if (!MatchingByteArray(check, SwapOpcodeBytes) && !MatchingByteArray(check, NoOpCode(SwapOpcodeBytes.Length)))
     {
         return(false);
     }
     check = MemoryApi.ReadMemoryPtr(gameProcess, GetOpBotLogicPtr(), BotOpcodeBytes.Length, out _);
     if (!MatchingByteArray(check, BotOpcodeBytes) && !MatchingByteArray(check, NoOpCode(BotOpcodeBytes.Length)))
     {
         return(false);
     }
     check = MemoryApi.ReadMemoryPtr(gameProcess, GetOpItemPtr(), ItemOpcodeBytes.Length, out _);
     if (!MatchingByteArray(check, ItemOpcodeBytes) && !MatchingByteArray(check, NoOpCode(ItemOpcodeBytes.Length)))
     {
         return(false);
     }
     return(true);
 }
Пример #8
0
        private void NewUpdate()
        {
            if (!ad.CheckGameStatus())
            {
                ah.ClearAlliances();
                ad = null;
            }
            else
            {
                int[] UnitCount = new int[2];
                UnitCount[0] = BitConverter.ToInt32(MemoryApi.ReadMemoryPtr(ad.gameProcess, ad.GetUnitCountPtr(0), 4, out _), 0);
                UnitCount[1] = BitConverter.ToInt32(MemoryApi.ReadMemoryPtr(ad.gameProcess, ad.GetUnitCountPtr(1), 4, out _), 0);

                for (int i = 0; i < 2; i++)
                {
                    #region hero update
                    for (int j = 0; j < UnitCount[i]; j++)
                    {
                        heroLists[i, 1].Add(ad.GetHero(i, j));
                    }
                    IEnumerable <Hero> removed   = heroLists[i, 0].Except(heroLists[i, 1]);
                    IEnumerable <Hero> newHeroes = heroLists[i, 1].Except(heroLists[i, 0]);

                    foreach (Hero h in removed)
                    {
                        PictureBox pb = GetHeroPictureBox(i, h.xPos, h.yPos);
                        pb.Tag             = null;
                        pb.BackgroundImage = null;
                        if (h.yPos != -1)
                        {
                            ah.RemoveAlliance(i, h.HID);
                        }
                        HeroUIDtoHID.Remove(h.UID);
                    }
                    foreach (Hero h in newHeroes)
                    {
                        PictureBox pb = GetHeroPictureBox(i, h.xPos, h.yPos);
                        pb.Tag = h;
                        if (ItemUIDtoIID.ContainsKey(h.UID)) //If an item has this hero's uid,
                        {
                            pb.BackgroundImage = IconHelper.CombineImagePair(IconHelper.GetImageByID(h.HID), IconHelper.GetMiniImageByID(ItemUIDtoIID[h.UID]));
                        }
                        else
                        {
                            pb.BackgroundImage = IconHelper.GetImageByID(h.HID);
                        }
                        if (h.yPos != -1)
                        {
                            ah.AddAlliance(i, h.HID);
                        }
                        HeroUIDtoHID.Add(h.UID, h.HID);
                    }
                    if (removed.Count() > 0 || newHeroes.Count() > 0)
                    {
                        tlpArray[i].Invalidate();
                        if (i == 0)
                        {
                            PlayerAlliancesRTB.Text = ah.GetAlliances(i);
                        }
                        else
                        {
                            BotAlliancesRTB.Text = ah.GetAlliances(i);
                        }
                    }


                    #endregion

                    #region items
                    for (int j = 0; j < 12; j++)
                    {
                        itemLists[i, 1].Add(ad.GetItem(i, j));
                        if (itemLists[i, 1][j].GetHashCode() != itemLists[i, 0][j].GetHashCode())
                        {
                            PictureBox pb = GetPBByUID(i, itemLists[i, 0][j].UID);
                            if (pb != null)
                            {
                                pb.BackgroundImage = IconHelper.GetImageByID(((Hero)pb.Tag).HID);
                            }
                            ItemUIDtoIID.Remove(itemLists[i, 0][j].UID);
                        }
                    }
                    for (int j = 0; j < 12; j++)
                    {
                        if (itemLists[i, 1][j].GetHashCode() != itemLists[i, 0][j].GetHashCode())
                        {
                            if (itemLists[i, 1][j].UID != 0)
                            {
                                ItemUIDtoIID.Add(itemLists[i, 1][j].UID, itemLists[i, 1][j].IID);
                            }
                            PictureBox pb = (PictureBox)tlpArray[2 + i].GetControlFromPosition(j / 6, j % 6);
                            pb.Tag = itemLists[i, 1][j];

                            if (HeroUIDtoHID.ContainsKey(itemLists[i, 1][j].UID))
                            {
                                //set item image pair
                                pb.BackgroundImage = IconHelper.CombineImagePair(IconHelper.GetImageByID(itemLists[i, 1][j].IID), IconHelper.GetMiniImageByID(HeroUIDtoHID[itemLists[i, 1][j].UID]));
                                //set hero image pair
                                pb = GetPBByUID(i, itemLists[i, 1][j].UID);
                                pb.BackgroundImage = IconHelper.CombineImagePair(IconHelper.GetImageByID(((Hero)pb.Tag).HID), IconHelper.GetMiniImageByID(ItemUIDtoIID[((Hero)pb.Tag).UID]));
                                //remove old hero image pair
                                pb = GetPBByUID(i, itemLists[i, 0][j].UID);
                                if (pb != null)
                                {
                                    pb.BackgroundImage = IconHelper.GetImageByID(((Hero)pb.Tag).HID);
                                }
                            }
                            else
                            {
                                pb.BackgroundImage = IconHelper.GetImageByID(itemLists[i, 1][j].IID);
                            }
                        }
                    }

                    #endregion

                    heroLists[i, 0] = new List <Hero>(heroLists[i, 1]);
                    heroLists[i, 1].Clear();
                    itemLists[i, 0] = new List <Item>(itemLists[i, 1]);
                    itemLists[i, 1].Clear();

                    UpdateControls(i);
                }
            }
        }
Пример #9
0
 public int GetPlayerLevel(int player)
 {
     return(BitConverter.ToInt32(MemoryApi.ReadMemoryPtr(gameProcess, GetPlayerLevelPtr(player), 4, out _), 0));
 }