예제 #1
0
        public static IntPtr Scan(Process process, byte?[] bytes, int offset)
        {
            var regions = GetRegions(process);
            var results = new List <IntPtr>();

            foreach (IntPtr baseAddress in regions.Keys)
            {
                byte[] bytesRead = regions[baseAddress];

                for (int i = 0; i < bytesRead.Length - bytes.Length; i++)
                {
                    bool found = true;

                    for (int j = 0; j < bytes.Length; j++)
                    {
                        if (bytes[j] != null && bytes[j] != bytesRead[i + j])
                        {
                            found = false;

                            break;
                        }
                    }

                    if (found)
                    {
                        results.Add(baseAddress + i);
                    }
                }
            }

            return((IntPtr)MemoryTools.ReadInt(process.Handle, results[0] + offset));
        }
예제 #2
0
        public BonfireStates GetBonfireState(BonfireFlags bonfire)
        {
            IntPtr pointer = (IntPtr)0x137E204;

            pointer = (IntPtr)MemoryTools.ReadInt(handle, pointer);
            pointer = (IntPtr)MemoryTools.ReadInt(handle, IntPtr.Add(pointer, 0xB48));
            pointer = (IntPtr)MemoryTools.ReadInt(handle, IntPtr.Add(pointer, 0x24));
            pointer = (IntPtr)MemoryTools.ReadInt(handle, pointer);

            IntPtr bonfirePointer = (IntPtr)MemoryTools.ReadInt(handle, IntPtr.Add(pointer, 0x8));

            while (bonfirePointer != IntPtr.Zero)
            {
                int bonfireId = MemoryTools.ReadInt(handle, IntPtr.Add(bonfirePointer, 0x4));

                if (bonfireId == (int)bonfire)
                {
                    int bonfireState = MemoryTools.ReadInt(handle, IntPtr.Add(bonfirePointer, 0x8));

                    return((BonfireStates)bonfireState);
                }

                pointer        = (IntPtr)MemoryTools.ReadInt(handle, pointer);
                bonfirePointer = (IntPtr)MemoryTools.ReadInt(handle, IntPtr.Add(pointer, 0x8));
            }

            return(BonfireStates.Undiscovered);
        }
예제 #3
0
        private bool GetEventFlagState(int id)
        {
            if (GetEventFlagAddress(id, out int address, out uint mask))
            {
                uint flags = (uint)MemoryTools.ReadInt(handle, (IntPtr)address);

                return((flags & mask) != 0);
            }

            return(false);
        }
예제 #4
0
        public int GetClearCount()
        {
            IntPtr pointer = (IntPtr)MemoryTools.ReadInt(handle, (IntPtr)0x1378700);

            if (pointer == IntPtr.Zero)
            {
                return(-1);
            }

            return(MemoryTools.ReadInt(handle, pointer + 0x3C));
        }
예제 #5
0
        public void Refresh(Process process)
        {
            IntPtr character = (IntPtr)MemoryTools.ReadInt(handle, (IntPtr)0x137DC70);

            character = (IntPtr)MemoryTools.ReadInt(handle, character + 0x4);
            character = (IntPtr)MemoryTools.ReadInt(handle, character);
            Character = character;

            IntPtr characterStats = (IntPtr)MemoryTools.ReadInt(handle, (IntPtr)0x1378700);

            characterStats = (IntPtr)MemoryTools.ReadInt(handle, characterStats + 0x8);
            CharacterStats = characterStats;

            CharacterMap      = (IntPtr)MemoryTools.ReadInt(handle, character + 0x28);
            CharacterPosition = (IntPtr)MemoryTools.ReadInt(handle, CharacterMap + 0x1C);

            IntPtr inventory = (IntPtr)MemoryTools.ReadInt(handle, (IntPtr)0x1378700);

            inventory = (IntPtr)MemoryTools.ReadInt(handle, inventory + 0x8);
            Inventory = inventory + 0x1B8;

            WorldState = (IntPtr)MemoryTools.ReadInt(handle, (IntPtr)0x13784A0);
            Zone       = (IntPtr)MemoryTools.ReadInt(handle, (IntPtr)0x137E204);
        }
예제 #6
0
        private bool GetEventFlagAddress(int id, out int address, out uint mask)
        {
            var eventFlagGroups = new Dictionary <string, int>
            {
                { "0", 0x00000 },
                { "1", 0x00500 },
                { "5", 0x05F00 },
                { "6", 0x0B900 },
                { "7", 0x11300 },
            };

            var eventFlagAreas = new Dictionary <string, int>
            {
                { "000", 00 },
                { "100", 01 },
                { "101", 02 },
                { "102", 03 },
                { "110", 04 },
                { "120", 05 },
                { "121", 06 },
                { "130", 07 },
                { "131", 08 },
                { "132", 09 },
                { "140", 10 },
                { "141", 11 },
                { "150", 12 },
                { "151", 13 },
                { "160", 14 },
                { "170", 15 },
                { "180", 16 },
                { "181", 17 },
            };

            string idString = id.ToString("D8");

            if (idString.Length == 8)
            {
                string group   = idString.Substring(0, 1);
                string area    = idString.Substring(1, 3);
                int    section = int.Parse(idString.Substring(4, 1));
                int    number  = int.Parse(idString.Substring(5, 3));

                if (eventFlagGroups.ContainsKey(group) && eventFlagAreas.ContainsKey(area))
                {
                    int offset = eventFlagGroups[group];
                    offset += eventFlagAreas[area] * 0x500;
                    offset += section * 128;
                    offset += (number - (number % 32)) / 8;

                    address  = MemoryTools.ReadInt(handle, (IntPtr)0x137D7D4);
                    address  = MemoryTools.ReadInt(handle, (IntPtr)address);
                    address += offset;

                    mask = 0x80000000 >> (number % 32);

                    return(true);
                }
            }

            address = 0;
            mask    = 0;

            return(false);
        }
예제 #7
0
 // Note that the last bonfire value doesn't always correspond to a valid bonfire ID.
 public int GetLastBonfire()
 {
     // For whatever reason, bonfire IDs retrieved in this way need to be corrected by a thousand to match the
     // bonfire flags array.
     return(MemoryTools.ReadInt(handle, pointers.WorldState + 0xB04) - 1000);
 }
예제 #8
0
 public int GetPlayerHP()
 {
     return(MemoryTools.ReadInt(handle, pointers.CharacterStats + 0xC));
 }
예제 #9
0
 public bool IsPlayerLoaded()
 {
     return(MemoryTools.ReadInt(handle, (IntPtr)0x137DC70) != 0);
 }
예제 #10
0
 // Every time the player uses an item that requires a yes/no confirmation box, the ID of the item can be
 // retreived. That ID remains in place until the item's animation is complete.
 public int GetPromptedItem()
 {
     return(MemoryTools.ReadInt(handle, pointers.Character + 0x62C));
 }
예제 #11
0
 public int GetForcedAnimation()
 {
     return(MemoryTools.ReadInt(handle, pointers.Character + 0xFC));
 }
예제 #12
0
        public int GetGameTimeInMilliseconds()
        {
            IntPtr pointer = (IntPtr)MemoryTools.ReadInt(handle, (IntPtr)0x1378700);

            return(MemoryTools.ReadInt(handle, IntPtr.Add(pointer, 0x68)));
        }