Пример #1
0
        public override RcwData GetRCWData(ulong obj)
        {
            // Most types can't possibly be RCWs.
            if (_notRCW)
            {
                return(null);
            }

            // The dac cannot report this information prior to v4.5.
            if (DesktopHeap.DesktopRuntime.CLRVersion != DesktopVersion.v45)
            {
                _notRCW = true;
                return(null);
            }

            DesktopRCWData result = null;
            IObjectData    data   = DesktopHeap.GetObjectData(obj);

            if (data != null && data.RCW != 0)
            {
                IRCWData rcw = DesktopHeap.DesktopRuntime.GetRCWData(data.RCW);
                if (rcw != null)
                {
                    result = new DesktopRCWData(DesktopHeap, data.RCW, rcw);
                }
            }
            else if (!_checkedIfIsRCW)     // If the first time fails, we assume that all instances of this type can't be RCWs.
            {
                _notRCW = true;            // TODO FIX NOW review.  We really want to simply ask the runtime...
            }

            _checkedIfIsRCW = true;
            return(result);
        }
Пример #2
0
        public override CcwData GetCCWData(ulong obj)
        {
            if (_notCCW)
            {
                return(null);
            }

            // The dac cannot report this information prior to v4.5.
            if (DesktopHeap.DesktopRuntime.CLRVersion != DesktopVersion.v45)
            {
                return(null);
            }

            DesktopCCWData result = null;
            IObjectData    data   = DesktopHeap.GetObjectData(obj);

            if (data != null && data.CCW != 0)
            {
                ICCWData ccw = DesktopHeap.DesktopRuntime.GetCCWData(data.CCW);
                if (ccw != null)
                {
                    result = new DesktopCCWData(DesktopHeap, data.CCW, ccw);
                }
            }
            else if (!_checkedIfIsCCW)
            {
                _notCCW = true;
            }

            _checkedIfIsCCW = true;
            return(result);
        }
Пример #3
0
        public override ClrType GetRuntimeType(ulong obj)
        {
            if (!IsRuntimeType)
            {
                return(null);
            }

            ClrInstanceField field = GetFieldByName("m_handle");

            if (field == null)
            {
                return(null);
            }

            ulong methodTable = 0;

            if (field.ElementType == ClrElementType.NativeInt)
            {
                methodTable = (ulong)(long)field.GetValue(obj);
            }
            else if (field.ElementType == ClrElementType.Struct)
            {
                ClrInstanceField ptrField = field.Type.GetFieldByName("m_ptr");
                methodTable = (ulong)(long)ptrField.GetValue(field.GetAddress(obj, false), true);
            }

            return(DesktopHeap.GetTypeByMethodTable(methodTable, 0, obj));
        }
Пример #4
0
        public override object GetValue(ulong address)
        {
            if (IsPrimitive)
            {
                address += (ulong)DesktopHeap.PointerSize;
            }

            return(DesktopHeap.GetValueAtAddress(ElementType, address));
        }
Пример #5
0
        public override bool IsRCW(ulong obj)
        {
            if (_checkedIfIsRCW)
            {
                return(!_notRCW);
            }

            // The dac cannot report this information prior to v4.5.
            if (DesktopHeap.DesktopRuntime.CLRVersion != DesktopVersion.v45)
            {
                return(false);
            }

            IObjectData data = DesktopHeap.GetObjectData(obj);

            _notRCW         = !(data != null && data.RCW != 0);
            _checkedIfIsRCW = true;

            return(!_notRCW);
        }
Пример #6
0
        public override object GetArrayElementValue(ulong objRef, int index)
        {
            ulong addr = GetArrayElementAddress(objRef, index);

            if (addr == 0)
            {
                return(null);
            }

            ClrElementType cet           = ClrElementType.Unknown;
            var            componentType = this.ComponentType;

            if (componentType != null)
            {
                cet = componentType.ElementType;
            }
            else
            {
                // Slow path, we need to get the element type of the array.
                IObjectData data = DesktopHeap.DesktopRuntime.GetObjectData(objRef);
                if (data == null)
                {
                    return(null);
                }

                cet = data.ElementType;
            }

            if (cet == ClrElementType.Unknown)
            {
                return(null);
            }

            if (cet == ClrElementType.String && !DesktopHeap.MemoryReader.ReadPtr(addr, out addr))
            {
                return(null);
            }

            return(DesktopHeap.GetValueAtAddress(cet, addr));
        }
Пример #7
0
        public override void EnumerateRefsOfObjectCarefully(ulong objRef, Action <ulong, int> action) // TODO GET HELP
        {
            ClrType realType = DesktopHeap.GetObjectType(objRef);

            realType.EnumerateRefsOfObjectCarefully(objRef, action);
        }
Пример #8
0
        public override void EnumerateRefsOfObject(ulong objRef, Action <ulong, int> action)
        {
            ClrType realType = DesktopHeap.GetObjectType(objRef);

            realType.EnumerateRefsOfObject(objRef, action);
        }
Пример #9
0
        public override ulong GetSize(ulong objRef)
        {
            ClrType realType = DesktopHeap.GetObjectType(objRef);

            return(realType.GetSize(objRef));
        }
Пример #10
0
        public override bool IsFinalizeSuppressed(ulong obj)
        {
            bool result = DesktopHeap.GetObjectHeader(obj, out uint value);

            return(result && (value & FinalizationSuppressedFlag) == FinalizationSuppressedFlag);
        }