Ejemplo n.º 1
0
        void UpdateName(ProcessMemoryAccessor accessor)
        {
            if (accessor == null)
            {
                throw new ArgumentNullException("accessor");
            }

            string name = null;

            if (version != null && version.ContainsVariable(CharacterNameKey))
            {
                Debug.WriteLine($"Updating character name (pid={accessor.ProcessId})...");

                Stream stream = null;
                try
                {
                    stream = accessor.GetStream();
                    using (var reader = new BinaryReader(stream, Encoding.ASCII))
                    {
                        stream = null;

                        var nameVariable = version.GetVariable(CharacterNameKey);
                        nameVariable.TryReadString(reader, out name);
                    }
                }
                finally { stream?.Dispose(); }

                Debug.WriteLine($"CharacterName = {name}");
            }

            if (!string.IsNullOrWhiteSpace(name))
            {
                Name = name;
            }
        }
Ejemplo n.º 2
0
        bool UpdateSkillbookCooldownPointer(ClientVersion version, BinaryReader reader)
        {
            if (version == null)
            {
                return(false);
            }

            var position = reader.BaseStream.Position;

            try
            {
                var cooldownVariable = version.GetVariable(SkillCooldownsKey) as SearchMemoryVariable;
                if (cooldownVariable == null)
                {
                    return(false);
                }

                if (baseCooldownPointer != IntPtr.Zero)
                {
                    return(true);
                }

                var ptr = scanner.FindUInt32((uint)cooldownVariable.Address);

                if (ptr == IntPtr.Zero)
                {
                    return(false);
                }

                if (cooldownVariable.Offset.IsNegative)
                {
                    ptr = (IntPtr)((uint)ptr - (uint)cooldownVariable.Offset.Offset);
                }
                else
                {
                    ptr = (IntPtr)((uint)ptr + (uint)cooldownVariable.Offset.Offset);
                }

                var address = (long)ptr;

                reader.BaseStream.Position = address;
                address = reader.ReadUInt32();

                baseCooldownPointer = (IntPtr)address;
                return(true);
            }
            catch { baseCooldownPointer = IntPtr.Zero; return(false); }
            finally { reader.BaseStream.Position = position; }
        }
Ejemplo n.º 3
0
        bool IsSkillOnCooldown(int slot, ClientVersion version, BinaryReader reader)
        {
            if (version == null || !UpdateSkillbookCooldownPointer(version, reader))
            {
                return(false);
            }

            if (baseCooldownPointer == IntPtr.Zero)
            {
                return(false);
            }

            long position = reader.BaseStream.Position;

            try
            {
                var cooldownVariable = version.GetVariable(SkillCooldownsKey) as SearchMemoryVariable;

                if (cooldownVariable == null)
                {
                    return(false);
                }

                var offset = cooldownVariable.Offets.FirstOrDefault();

                if (offset == null)
                {
                    return(false);
                }

                var address = (long)baseCooldownPointer + (slot * cooldownVariable.Size);

                reader.BaseStream.Position = address;

                if (address < 0x15000000 || address > 0x30000000)
                {
                    return(false);
                }

                address = reader.ReadUInt32();

                if (address < 0x15000000 || address > 0x30000000)
                {
                    return(false);
                }

                if (offset.IsNegative)
                {
                    address -= offset.Offset;
                }
                else
                {
                    address += offset.Offset;
                }

                reader.BaseStream.Position = address;
                var isOnCooldown = reader.ReadBoolean();

                return(isOnCooldown);
            }
            catch
            {
                baseCooldownPointer = IntPtr.Zero;
                return(false);
            }
            finally { reader.BaseStream.Position = position; }
        }