コード例 #1
0
        private ulong GetClrStaticFieldAddress(Tuple <int, string, int> input)
        {
            int            clrTypeId      = input.Item1;
            string         fieldName      = input.Item2;
            int            clrAppDomainId = input.Item3;
            ClrType        clrType        = clrTypesCache[clrTypeId];
            ClrStaticField clrStaticField = clrType.GetStaticFieldByName(fieldName);
            ClrAppDomain   clrAppDomain   = clrType.Module.Runtime.AppDomains.First(ad => ad.Id == clrAppDomainId);

            return(clrStaticField.GetAddress(clrAppDomain));
        }
コード例 #2
0
        public dynamic GetValue(ClrAppDomain appDomain)
        {
            if (m_field.IsPrimitive())
            {
                object value = m_field.GetValue(appDomain);
                if (value != null)
                {
                    return(new ClrPrimitiveValue(value, m_field.ElementType));
                }
            }
            else if (m_field.IsValueClass())
            {
                ulong addr = m_field.GetAddress(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.GetAddress(appDomain);
                if (m_heap.GetRuntime().ReadPointer(addr, out addr))
                {
                    return(new ClrObject(m_heap, m_field.Type, addr));
                }
            }
            else
            {
                object value = m_field.GetValue(appDomain);
                if (value != null)
                {
                    return(new ClrObject(m_heap, m_field.Type, (ulong)value));
                }
            }

            return(new ClrNullValue(m_heap));
        }
コード例 #3
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>
 /// <inheritdoc />
 public ulong GetAddress(IClrAppDomain appDomain) =>
 StaticField.GetAddress((appDomain as ClrAppDomainAdapter)?.AppDomain);