/// <summary>
        /// Returns the address to be used as memory context. This is used to get an address
        /// from an expression entered into Visual Studio's memory view's address text box.
        /// </summary>
        public static ulong?GetMemoryContextAddress(this RemoteValue remoteValue)
        {
            if (!IsValidValue(remoteValue))
            {
                return(null);
            }

            TypeFlags GetTypeFlags(RemoteValue value) =>
            remoteValue.GetTypeInfo().GetCanonicalType().GetTypeFlags();

            // If the value is an array, try to obtain its address.
            TypeFlags flags = GetTypeFlags(remoteValue);

            if (flags.HasFlag(TypeFlags.IS_ARRAY))
            {
                remoteValue = remoteValue.AddressOf();
                if (!IsValidValue(remoteValue))
                {
                    return(null);
                }
                flags = GetTypeFlags(remoteValue);
            }

            // Only interpret pointers, references and integers as addresses.
            if (!flags.HasFlag(TypeFlags.IS_REFERENCE) && !flags.HasFlag(TypeFlags.IS_POINTER) &&
                !flags.HasFlag(TypeFlags.IS_INTEGER))
            {
                return(null);
            }

            return(remoteValue.GetValueAsUnsigned());
        }
        private static bool TryGetAddressOf(RemoteValue remoteValue, out RemoteValue addressOf)
        {
            addressOf = null;

            var addressOfValue = remoteValue.AddressOf();

            if (addressOfValue == null || addressOfValue.GetError().Fail())
            {
                return(false);
            }
            addressOf = addressOfValue;
            return(true);
        }
 public virtual RemoteValue AddressOf()
 {
     return(value.AddressOf());
 }