Exemple #1
0
        public void Execute(CommandExecutionContext context)
        {
            if (!CommandHelpers.VerifyValidObjectAddress(context, ObjectAddress))
            {
                return;
            }

            var type       = context.Heap.GetObjectType(ObjectAddress);
            var dynamicObj = context.Heap.GetDynamicObject(ObjectAddress);

            context.WriteLine("Type:   {0}", type.Name);
            if (type.IsArray || dynamicObj.IsList())
            {
                int length = dynamicObj.GetLength();
                context.WriteLine("Length: {0}", length);
                for (int i = 0; i < length; ++i)
                {
                    context.WriteLine("[{0}] {1}", i, dynamicObj[i]);
                }
            }
            else if (dynamicObj.IsDictionary())
            {
                context.WriteLine("Size:   {0}", dynamicObj.GetLength());
                context.WriteLine("{0,-40} {1,-40}", "Key", "Value");
                foreach (var kvp in dynamicObj.GetDictionaryItems())
                {
                    context.WriteLine("{0,-40} {1,-40}", kvp.Item1, kvp.Item2);
                }
            }
            else
            {
                context.WriteErrorLine("The specified object is not an array, list, or dictionary. " +
                                       "These are the only collection types that are currently supported. For other " +
                                       "collections, try using the !hq command to inspect the object's contents.");
                return;
            }
        }
Exemple #2
0
        public void Execute(CommandExecutionContext context)
        {
            if (!CommandHelpers.VerifyHasHeapIndex(context))
            {
                return;
            }

            if (!CommandHelpers.VerifyValidObjectAddress(context, ObjectAddress))
            {
                return;
            }

            var type = context.Heap.GetObjectType(ObjectAddress);

            context.WriteLine("Note: unrooted (dead) objects will not have any referencing objects displayed.");
            context.WriteLine("Object {0:x16} ({1}) is referenced by the following objects:", ObjectAddress, type.Name);
            foreach (var referencingObj in context.HeapIndex.FindRefs(ObjectAddress))
            {
                string refHex = String.Format("{0:x16}", referencingObj);
                context.WriteLink(refHex, "!do " + refHex);
                context.WriteLine(" ({0})", context.Heap.GetObjectType(referencingObj).Name);
            }

            context.WriteLine("Object {0:x16} ({1}) references the following objects:", ObjectAddress, type.Name);
            type.EnumerateRefsOfObject(ObjectAddress, (child, _) =>
            {
                var childType = context.Heap.GetObjectType(child);
                if (childType == null || String.IsNullOrEmpty(childType.Name))
                {
                    return;
                }

                string refHex = String.Format("{0:x16}", child);
                context.WriteLink(refHex, "!do " + refHex);
                context.WriteLine(" ({0})", childType.Name);
            });
        }
Exemple #3
0
        public void Execute(CommandExecutionContext context)
        {
            _context = context;

            if (!CommandHelpers.VerifyValidObjectAddress(context, ObjectAddress))
            {
                return;
            }

            _heap = context.Heap;
            if (!_heap.CanWalkHeap)
            {
                context.WriteError("The heap is not in a walkable state.");
                return;
            }

            var type = _heap.GetObjectType(ObjectAddress);

            _visitedObjects         = new ObjectSet(_heap);
            _targets[ObjectAddress] = new Node(ObjectAddress, type);
            FillRootDictionary();

            foreach (var root in _roots)
            {
                if (_visitedRoots.Contains(root) || _visitedObjects.Contains(root.Object))
                {
                    continue;
                }

                Node path = TryFindPathToTarget(root);
                if (path != null)
                {
                    PrintOnePath(path);
                }
            }
        }
Exemple #4
0
        public void Execute(CommandExecutionContext context)
        {
            if (!CommandHelpers.VerifyValidObjectAddress(context, ObjectAddress))
            {
                return;
            }

            var type = context.Heap.GetObjectType(ObjectAddress);

            if (!type.IsArray)
            {
                context.WriteError("The object at the specified address is not an array.");
                return;
            }

            var size   = type.GetSize(ObjectAddress);
            var length = type.GetArrayLength(ObjectAddress);

            context.WriteLine("Name:  {0}", type.Name);
            context.WriteLine("Size:  {0}(0x{1:x}) bytes", size, size);
            context.WriteLine("Array: Number of elements {0}, Type {1} {2}",
                              length, type.ArrayComponentType.Name,
                              type.ArrayComponentType.IsValueClass ? "(value type)" : "(reference type)");

            for (int i = 0; i < length; ++i)
            {
                context.Write("[{0}] ", i);

                object value;
                if (type.ArrayComponentType.IsValueClass)
                {
                    value = type.GetArrayElementAddress(ObjectAddress, i);
                    if (value != null)
                    {
                        context.WriteLink(
                            String.Format("{0:x16}", value),
                            String.Format("!do {0:x16} --type {1}", value, type.ArrayComponentType.Name)
                            );
                    }
                    else
                    {
                        context.Write("<null>");
                    }
                }
                else
                {
                    value = type.GetArrayElementValue(ObjectAddress, i);
                    ulong elementAddr = type.GetArrayElementAddress(ObjectAddress, i);
                    ulong elementRef;
                    if (context.Runtime.ReadPointer(elementAddr, out elementRef))
                    {
                        context.WriteLink(
                            String.Format("{0:x16}", value ?? "<null>"),
                            String.Format("!do {0:x16}", elementRef)
                            );
                    }
                    else
                    {
                        context.Write("{0:x16}", value ?? "<null>");
                    }
                }
                context.WriteLine();
            }
        }