public dynamic GetValue(ClrAppDomain appDomain)
        {
            if (m_field.IsPrimitive())
            {
                object value = m_field.GetFieldValue(appDomain);
                if (value != null)
                    return new ClrPrimitiveValue(value, m_field.ElementType);
            }
            else if (m_field.IsValueClass())
            {
                ulong addr = m_field.GetFieldAddress(appDomain);
                if (addr != 0)
                    return new ClrObject(m_heap, m_field.Type, addr, true);
            }
            else if (m_field.ElementType == ClrElementType.String)
            {
                ulong addr = m_field.GetFieldAddress(appDomain);
                if (m_heap.GetRuntime().ReadPointer(addr, out addr))
                    return new ClrObject(m_heap, m_field.Type, addr);
            }
            else
            {
                object value = m_field.GetFieldValue(appDomain);
                if (value != null)
                    return new ClrObject(m_heap, m_field.Type, (ulong)value);
            }

            return new ClrNullValue(m_heap);
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="ClrAppDomainAdapter" /> class.
 /// </summary>
 /// <param name="appDomain">The application domain.</param>
 /// <exception cref="ArgumentNullException">appDomain</exception>
 /// <inheritdoc />
 public ClrAppDomainAdapter(IConverter converter, ClrMd.ClrAppDomain appDomain) : base(converter)
 {
     AppDomain         = appDomain ?? throw new ArgumentNullException(nameof(appDomain));
     Address           = AppDomain.Address;
     ApplicationBase   = AppDomain.ApplicationBase;
     ConfigurationFile = AppDomain.ConfigurationFile;
     Id   = AppDomain.Id;
     Name = AppDomain.Name;
 }
Example #3
0
        /// <summary>
        ///     Converts the specified application domain.
        /// </summary>
        /// <param name="appDomain">The application domain.</param>
        /// <returns>IClrAppDomain.</returns>
        public IClrAppDomain Convert(ClrMd.ClrAppDomain appDomain)
        {
            if (appDomain == null)
            {
                return(null);
            }
            var item = new ClrAppDomainAdapter(this, appDomain);

            return(Cache.GetOrAdd <IClrAppDomain>(appDomain, () => item, () => item.Setup()));
        }
Example #4
0
 internal override Address GetDomainModule(ClrAppDomain appDomain)
 {
     return 0;
 }
Example #5
0
 internal abstract Address GetDomainModule(ClrAppDomain appDomain);
Example #6
0
        internal override ulong GetDomainModule(ClrAppDomain domain)
        {
            _runtime.InitDomains();
            if (domain == null)
            {
                foreach (ulong addr in _mapping.Values)
                    return addr;

                return 0;
            }

            ulong value;
            if (_mapping.TryGetValue(domain, out value))
                return value;

            return 0;
        }
Example #7
0
 public MDAppDomain(ClrAppDomain ad)
 {
     m_appDomain = ad;
 }
Example #8
0
 /// <summary>
 /// Returns whether this static field has been initialized in a particular AppDomain
 /// or not.  If a static variable has not been initialized, then its class constructor
 /// may have not been run yet.  Calling GetFieldValue on an uninitialized static
 /// will result in returning either NULL or a value of 0.
 /// </summary>
 /// <param name="appDomain">The AppDomain to see if the variable has been initialized.</param>
 /// <returns>True if the field has been initialized (even if initialized to NULL or a default
 /// value), false if the runtime has not initialized this variable.</returns>
 abstract public bool IsInitialized(ClrAppDomain appDomain);
Example #9
0
 /// <summary>
 /// Returns the address of the static field's value in memory.
 /// </summary>
 /// <param name="appDomain">The AppDomain in which to get the field's address.</param>
 /// <returns>The address of the field's value.</returns>
 abstract public Address GetAddress(ClrAppDomain appDomain);
Example #10
0
 /// <summary>
 /// Returns whether this static field has been initialized in a particular AppDomain
 /// or not.  If a static variable has not been initialized, then its class constructor
 /// may have not been run yet.  Calling GetFieldValue on an uninitialized static
 /// will result in returning either NULL or a value of 0.
 /// </summary>
 /// <param name="appDomain">The AppDomain to see if the variable has been initialized.</param>
 /// <returns>True if the field has been initialized (even if initialized to NULL or a default
 /// value), false if the runtime has not initialized this variable.</returns>
 abstract public bool IsInitialized(ClrAppDomain appDomain);
Example #11
0
 /// <summary>
 /// Gets the value of the field.
 /// </summary>
 /// <param name="appDomain">The AppDomain in which to get the field's value.</param>
 /// <param name="thread">The thread on which to get the field's value.</param>
 /// <returns>The value of the field.</returns>
 abstract public object GetValue(ClrAppDomain appDomain, ClrThread thread);
Example #12
0
 /// <summary>
 /// Gets the value of the static field.
 /// </summary>
 /// <param name="appDomain">The AppDomain in which to get the value.</param>
 /// <returns>The value of this static field.</returns>
 abstract public object GetValue(ClrAppDomain appDomain);
Example #13
0
 /// <summary>
 /// Gets the value of the field.
 /// </summary>
 /// <param name="appDomain">The AppDomain in which to get the field's value.</param>
 /// <param name="thread">The thread on which to get the field's value.</param>
 /// <returns>The value of the field.</returns>
 virtual public object GetValue(ClrAppDomain appDomain, ClrThread thread)
 {
     return(GetValue(appDomain, thread, true));
 }
Example #14
0
 /// <summary>
 /// Returns the address of the static field's value in memory.
 /// </summary>
 /// <param name="appDomain">The AppDomain in which to get the field's address.</param>
 /// <returns>The address of the field's value.</returns>
 abstract public ulong GetAddress(ClrAppDomain appDomain);
Example #15
0
 /// <summary>
 /// Gets the value of the static field.
 /// </summary>
 /// <param name="appDomain">The AppDomain in which to get the value.</param>
 /// <param name="convertStrings">When true, the value of a string field will be
 /// returned as a System.String object; otherwise the address of the String object will be returned.</param>
 /// <returns>The value of this static field.</returns>
 abstract public object GetValue(ClrAppDomain appDomain, bool convertStrings);
Example #16
0
 /// <summary>
 /// Gets the value of the static field.
 /// </summary>
 /// <param name="appDomain">The AppDomain in which to get the value.</param>
 /// <returns>The value of this static field.</returns>
 virtual public object GetValue(ClrAppDomain appDomain)
 {
     return(GetValue(appDomain, true));
 }
Example #17
0
 virtual public object GetFieldValue(ClrAppDomain domain)
 {
     return GetValue(domain);
 }
Example #18
0
        internal ClrHandle(Microsoft.Diagnostics.Runtime.Desktop.V45Runtime clr, ClrHeap heap, Microsoft.Diagnostics.Runtime.Desktop.HandleData handleData)
        {
            Address obj;
            Address = handleData.Handle;
            clr.ReadPointer(Address, out obj);

            Object = obj;
            Type = heap.GetObjectType(obj);

            uint refCount = 0;

            if (handleData.Type == (int)HandleType.RefCount)
            {
                if (handleData.IsPegged != 0)
                    refCount = handleData.JupiterRefCount;

                if (refCount < handleData.RefCount)
                    refCount = handleData.RefCount;

                if (Type != null)
                {
                    if (Type.IsCCW(obj))
                    {
                        CcwData data = Type.GetCCWData(obj);
                        if (data != null && refCount < data.RefCount)
                            refCount = (uint)data.RefCount;
                    }
                    else if (Type.IsRCW(obj))
                    {
                        RcwData data = Type.GetRCWData(obj);
                        if (data != null && refCount < data.RefCount)
                            refCount = (uint)data.RefCount;
                    }
                }

                RefCount = refCount;
            }


            HandleType = (HandleType)handleData.Type;
            AppDomain = clr.GetAppDomainByAddress(handleData.AppDomain);

            if (HandleType == HandleType.Dependent)
            {
                DependentTarget = handleData.Secondary;
                DependentType = heap.GetObjectType(handleData.Secondary);
            }
        }
Example #19
0
 virtual public Address GetFieldAddress(ClrAppDomain domain)
 {
     return GetAddress(domain);
 }
Example #20
0
 virtual public Address GetFieldAddress(ClrAppDomain domain, ClrThread thread)
 {
     return GetAddress(domain, thread);
 }
Example #21
0
 /// <summary>
 /// Gets the value of the static field.
 /// </summary>
 /// <param name="appDomain">The AppDomain in which to get the value.</param>
 /// <returns>The value of this static field.</returns>
 virtual public object GetValue(ClrAppDomain appDomain)
 {
     return GetValue(appDomain, true);
 }
Example #22
0
 /// <summary>
 /// Gets the value of the field.
 /// </summary>
 /// <param name="appDomain">The AppDomain in which to get the field's value.</param>
 /// <param name="thread">The thread on which to get the field's value.</param>
 /// <param name="convertStrings">When true, the value of a string field will be 
 /// returned as a System.String object; otherwise the address of the String object will be returned.</param>
 /// <returns>The value of the field.</returns>
 abstract public object GetValue(ClrAppDomain appDomain, ClrThread thread, bool convertStrings);
Example #23
0
 virtual public object GetFieldValue(ClrAppDomain domain, ClrThread thread)
 {
     return GetValue(domain, thread);
 }
Example #24
0
 /// <summary>
 /// Gets the address of the field.
 /// </summary>
 /// <param name="appDomain">The AppDomain in which to get the field's address.</param>
 /// <param name="thread">The thread on which to get the field's address.</param>
 /// <returns>The address of the field.</returns>
 abstract public ulong GetAddress(ClrAppDomain appDomain, ClrThread thread);
Example #25
0
 /// <summary>
 /// Gets the value of the field.
 /// </summary>
 /// <param name="appDomain">The AppDomain in which to get the field's value.</param>
 /// <param name="thread">The thread on which to get the field's value.</param>
 /// <returns>The value of the field.</returns>
 virtual public object GetValue(ClrAppDomain appDomain, ClrThread thread)
 {
     return GetValue(appDomain, thread, true);
 }
Example #26
0
 internal void AddMapping(ClrAppDomain domain, ulong domainModule)
 {
     DesktopAppDomain appDomain = (DesktopAppDomain)domain;
     _mapping[domain] = domainModule;
 }
Example #27
0
 /// <summary>
 /// Gets the address of the field.
 /// </summary>
 /// <param name="appDomain">The AppDomain in which to get the field's address.</param>
 /// <param name="thread">The thread on which to get the field's address.</param>
 /// <returns>The address of the field.</returns>
 abstract public Address GetAddress(ClrAppDomain appDomain, ClrThread thread);
Example #28
0
 /// <summary>
 /// Returns the address of the static field's value in memory.
 /// </summary>
 /// <param name="appDomain">The AppDomain in which to get the field's address.</param>
 /// <returns>The address of the field's value.</returns>
 abstract public Address GetAddress(ClrAppDomain appDomain);