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; }
/// <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())); }
internal override Address GetDomainModule(ClrAppDomain appDomain) { return 0; }
internal abstract Address GetDomainModule(ClrAppDomain appDomain);
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; }
public MDAppDomain(ClrAppDomain ad) { m_appDomain = ad; }
/// <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);
/// <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);
/// <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);
/// <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);
/// <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)); }
/// <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);
/// <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);
/// <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)); }
virtual public object GetFieldValue(ClrAppDomain domain) { return GetValue(domain); }
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); } }
virtual public Address GetFieldAddress(ClrAppDomain domain) { return GetAddress(domain); }
virtual public Address GetFieldAddress(ClrAppDomain domain, ClrThread thread) { return GetAddress(domain, thread); }
/// <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); }
/// <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);
virtual public object GetFieldValue(ClrAppDomain domain, ClrThread thread) { return GetValue(domain, thread); }
/// <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);
/// <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); }
internal void AddMapping(ClrAppDomain domain, ulong domainModule) { DesktopAppDomain appDomain = (DesktopAppDomain)domain; _mapping[domain] = domainModule; }
/// <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);