ReadInt32() 공개 정적인 메소드

public static ReadInt32 ( System.Int64 address, int handle = -1 ) : Int32
address System.Int64
handle int
리턴 System.Int32
예제 #1
0
        public static List <TabStructure> FindTabStructures(Process p, Player player)
        {
            bool firstScan = ReadMemoryManager.TabStructureCount() == 0;
            List <TabStructure> structs = new List <TabStructure>();

            foreach (var tpl in ReadMemoryManager.ScanProcess(p))
            {
                int    length      = tpl.Item1.RegionSize;
                int    baseAddress = tpl.Item1.BaseAddress;
                byte[] bytes       = tpl.Item2;
                for (int i = 0; i < length - 20; i += 4)
                {
                    int value = BitConverter.ToInt32(bytes, i);

                    if (value > 0x40000 && value != baseAddress + i)
                    {
                        int messageptr = BitConverter.ToInt32(bytes, i + 4);
                        int maxsize    = BitConverter.ToInt32(bytes, i + 8);
                        int size       = BitConverter.ToInt32(bytes, i + 16);
                        if (messageptr > 0x40000 && IsPowerOfTwo(maxsize) && size < maxsize && maxsize < 10000 && size >= 0 && maxsize > 0)
                        {
                            if ((baseAddress + i) == MemoryReader.ReadInt32(value))
                            {
                                structs.Add(new TabStructure((uint)(baseAddress + i)));
                            }
                        }
                    }
                }
                if (!firstScan)
                {
                    System.Threading.Thread.Sleep(10);
                }
            }
            return(structs);
        }
예제 #2
0
        public string GetMessage(int i)
        {
            int chatMessages = MemoryReader.ReadInt32(address + 4);
            int chatMessage  = MemoryReader.ReadInt32(chatMessages + 4 * i);

            return(MemoryReader.ReadChatMessage(chatMessage));
        }
예제 #3
0
        public long GetAddress()
        {
            if (!MemoryReader.ModuleAddresses.ContainsKey(moduleName))
            {
                return(-1);
            }
            long currentAddress = MemoryReader.ModuleAddresses[moduleName] + moduleOffset;

            foreach (long jump in jumps)
            {
                currentAddress = MemoryReader.ReadInt32(currentAddress) + jump;
            }
            return(currentAddress);
        }
예제 #4
0
        public long GetValue()
        {
            switch (bytes)
            {
            case 1:
                return(MemoryReader.ReadInt8(GetAddress()));

            case 2:
                return(MemoryReader.ReadInt16(GetAddress()));

            case 4:
                return(MemoryReader.ReadInt32(GetAddress()));

            case 8:
                return(MemoryReader.ReadInt64(GetAddress()));
            }
            return(-1);
        }
예제 #5
0
        public IEnumerable <string> GetMessages()
        {
            int maxsize = MemoryReader.ReadInt32(address + 8);
            int size    = MemoryReader.ReadInt32(address + 16);

            if (size < 0 || size > maxsize || maxsize > 1200)
            {
                yield break;
            }
            for (int i = 0; i < maxsize; i++)
            {
                string msg = GetMessage(i);
                if (msg != null)
                {
                    yield return(msg);
                }
            }
            yield break;
        }
예제 #6
0
        public static void ReadMemoryInternal(Process process, ReadMemoryResults results)
        {
            int currentAddress = process.MainModule.BaseAddress.ToInt32();

            IntPtr ptr = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_WM_READ, false, process.Id);

            if (ptr == null)
            {
                return;
            }
            int processHandle = ptr.ToInt32();

            currentAddress += (int)MemoryReader.TabsBaseAddress;
            currentAddress  = MemoryReader.ReadInt32(currentAddress, processHandle);
            currentAddress  = MemoryReader.ReadInt32(currentAddress + 0x24, processHandle);
            currentAddress  = MemoryReader.ReadInt32(currentAddress + 0x10, processHandle);
            currentAddress  = MemoryReader.ReadInt32(currentAddress + 0x10, processHandle);
            int tabsAddress = MemoryReader.ReadInt32(currentAddress + 0x30, processHandle);

            //first tab node address is tabsAddress + 0x24
            int tabNodeAddress = MemoryReader.ReadInt32(tabsAddress + 0x24, processHandle);
            int tabCount       = 0;

            //repeat until tab node address = 0x0
            while (tabNodeAddress != 0x0)
            {
                tabCount++;

                //use 0x30 for longer name (possibly upto 30 bytes)
                //0x2C will use '...' for names longer than 15 chars
                int    tabNamePointer           = MemoryReader.ReadInt32(tabNodeAddress + 0x2C, processHandle);
                string tabName                  = MemoryReader.ReadString(tabNamePointer, 16, processHandle);
                int    tabMessagesDataStructure = MemoryReader.ReadInt32(tabNodeAddress + 0x24, processHandle);
                bool   serverLog                = tabName == "Server Log"; // only read log messages from the server log; only read chat messages from other tabs

                IEnumerable <string> tabMessages = ReadTabMessages(processHandle, tabMessagesDataStructure);
                SearchChunk(tabMessages, results, !serverLog, serverLog);

                //next tab node pointer is current tab node address + 0x10
                tabNodeAddress = MemoryReader.ReadInt32(tabNodeAddress + 0x10, processHandle);
            }
        }
예제 #7
0
        // SPECIAL THANKS TO tony902304 FOR MAKING THIS POSSIBLE //
        // For the C client: Read the server log messages from the internal Tab Messages structure, rather than scanning the entire process memory
        // This results in significantly faster performance and eliminates duplicate message issues in Tibia's memory
        // The only pitfall is that the base address has to be updated whenever Tibia is updated
        // We leave the old "scan everything" option as a setting for when Tibia gets updated and the base address has not been found yet
        public static IEnumerable <string> ReadTabMessages(int processHandle, int tabMessagesDataStructure)
        {
            int tabMessageNodeAddress = MemoryReader.ReadInt32(tabMessagesDataStructure + 0x10, processHandle);
            int messageCount          = 0;

            while (tabMessageNodeAddress != 0x0)
            {
                messageCount++;
                int tabMessageAddress = MemoryReader.ReadInt32(tabMessageNodeAddress + 0x4C, processHandle);
                //max message input is 255 characters, but the Advertising channel has 400+ character initial message
                string tabMessage = MemoryReader.ReadString(tabMessageAddress, 255, processHandle);
                if (tabMessage != null && tabMessage.Length > 5 && tabMessage[0].isDigit() && tabMessage[1].isDigit() && tabMessage[2] == ':' && tabMessage[3].isDigit() && tabMessage[4].isDigit())
                {
                    yield return(tabMessage);
                }

                //next tab messages node pointer is current tab messages node address + 0x5C
                tabMessageNodeAddress = MemoryReader.ReadInt32(tabMessageNodeAddress + 0x5C, processHandle);
            }
            yield break;
        }
예제 #8
0
        public static List <TabStructure> FindTabStructures(Process p, Player player)
        {
            bool firstScan = ReadMemoryManager.TabStructureCount() == 0;
            List <TabStructure> structs = new List <TabStructure>();

            /*int statsValue = -1, expValue = -1;
             * if (MemoryReader.MemorySettings.ContainsKey("tibia11statsvalue")) {
             *  int.TryParse(MemoryReader.MemorySettings["tibia11statsvalue"], out statsValue);
             * }
             * if (MemoryReader.MemorySettings.ContainsKey("tibia11expvalue")) {
             *  int.TryParse(MemoryReader.MemorySettings["tibia11expvalue"], out expValue);
             * }*/
            int  playerMaxLife = -1, playerMaxMana = -1, playerLevel = -1;
            long playerMinExperience = -1, playerMaxExperience = -1;

            if (player != null)
            {
                playerMaxLife       = player.MaxLife();
                playerMaxMana       = player.MaxMana();
                playerMinExperience = ExperienceBar.GetExperience(player.level - 1);
                playerMaxExperience = ExperienceBar.GetExperience(player.level);
                playerLevel         = player.level;
            }
            foreach (var tpl in ReadMemoryManager.ScanProcess(p))
            {
                int    length      = tpl.Item1.RegionSize;
                int    baseAddress = tpl.Item1.BaseAddress;
                byte[] bytes       = tpl.Item2;
                for (int i = 0; i < length - 20; i += 4)
                {
                    int value = BitConverter.ToInt32(bytes, i);

                    if (value > 0x40000 && value != baseAddress + i)
                    {
                        int messageptr = BitConverter.ToInt32(bytes, i + 4);
                        int maxsize    = BitConverter.ToInt32(bytes, i + 8);
                        int size       = BitConverter.ToInt32(bytes, i + 16);
                        if (messageptr > 0x40000 && IsPowerOfTwo(maxsize) && size < maxsize && maxsize < 10000 && size >= 0 && maxsize > 0)
                        {
                            if ((baseAddress + i) == MemoryReader.ReadInt32(value))
                            {
                                structs.Add(new TabStructure((uint)(baseAddress + i)));
                            }
                        }
                    }
                    if (player != null)
                    {
                        int maxhealth = BitConverter.ToInt32(bytes, i + 0x4);
                        int maxmana   = BitConverter.ToInt32(bytes, i + 0xC);
                        if (maxhealth == playerMaxLife && maxmana == playerMaxMana)
                        {
                            int health = BitConverter.ToInt32(bytes, i);
                            int mana   = BitConverter.ToInt32(bytes, i + 0x8);
                            if (health <= maxhealth && health >= 0 && mana <= maxmana && mana >= 0)
                            {
                                MemoryReader.SetStatsAddress((uint)(baseAddress + i - 0x24));
                            }
                        }
                        else
                        {
                            int  bla        = BitConverter.ToInt32(bytes, i);
                            long experience = BitConverter.ToInt64(bytes, i + 0x4);
                            if (bla == 0 && experience > playerMinExperience && experience < playerMaxExperience)
                            {
                                short level = BitConverter.ToInt16(bytes, i + 0xC);
                                if (level == playerLevel)
                                {
                                    double percentage = BitConverter.ToInt32(bytes, i + 0xE) / 100.0;
                                    long   diff       = playerMaxExperience - playerMinExperience;
                                    if (percentage >= 0 && percentage <= 1 && experience > playerMinExperience + diff * (percentage - 1) && experience < playerMinExperience + diff * (percentage + 1))
                                    {
                                        MemoryReader.SetExpAddress((uint)(baseAddress + i - 0x14));
                                    }
                                }
                            }
                        }
                    }
                }
                if (!firstScan)
                {
                    System.Threading.Thread.Sleep(10);
                }
            }
            return(structs);
        }