Exemplo n.º 1
0
        public UIntPtr GetAddressFromPointer(String s, out Boolean error)
        {
            error = true;
            var offsets = new UArrayManager <Int32>();
            var list    = new AStringArray();

            if (!ParseAsPointer(s, list))
            {
                return(UIntPtr.Zero);
            }
            UIntPtr baseAddress;

            try
            {
                baseAddress = GetAddressFromName(list[0]);
            }
            catch
            {
                return(UIntPtr.Zero);
            }
            offsets.SetLength(list.Length - 1);
            for (var i = 1; i < list.Length; i++) //start from the first offset
            {
                var off = AStringUtils.Copy(list[i], 1, list[i].Length);
                try
                {
                    offsets[i - 1] = (int)AStringUtils.StrToQWordEx("0x" + off);
                }
                catch
                {
                    return(UIntPtr.Zero);
                }
                if (list[i][0] == '-')
                {
                    offsets[i - 1] = -offsets[i - 1];
                }
            }
            //still here so notation was correct and baseAddress+offsets are filled in
            //now read
            var realAddress2 = baseAddress;

            for (var i = 0; i < offsets.Length; i++)
            {
                var realAddress = Process.Memory.Read <UIntPtr>(realAddress2.ToIntPtr());
                if (realAddress != UIntPtr.Zero)
                {
                    realAddress2 = realAddress + offsets[i];
                }
                else
                {
                    return(UIntPtr.Zero);
                }
            }
            error = false;
            return(realAddress2);
        }
Exemplo n.º 2
0
        public void AddUserDefinedSymbol(String addressString, String name)
        {
            if (UserDefinedSymbols.Contains(c => c.IsMatch(name)))
            {
                throw new Exception(name + " " + "already exists");
            }
            var address = GetAddressFromName(addressString);

            if (address == UIntPtr.Zero)
            {
                throw new Exception("You can''t add a symbol with a zero address");
            }
            UserDefinedSymbols.SetLength(UserDefinedSymbols.Length + 1);
            UserDefinedSymbols.Last.Address       = address;
            UserDefinedSymbols.Last.AddressString = addressString;
            UserDefinedSymbols.Last.Name          = name;
            UserDefinedSymbols.Last.AllocSize     = 0;
            UserDefinedSymbols.Last.ProcessId     = 0;
        }