Ejemplo n.º 1
0
        public static ClrType GetTypeFromEE(ClrRuntime Runtime, ulong EEClass)
        {
            ClrHeap heap = Runtime.Heap;
            //ClrType type = null;
            ulong mt = heap.GetMethodTableByEEClass(EEClass);

            if (mt == 0)
            {
                return(null);
            }
            return(heap.GetTypeByMethodTable(mt));

            /*
             * int max = heap.TypeIndexLimit;
             * if (max < 1)
             * {
             *  var objList = heap.EnumerateObjects().GetEnumerator();
             *  if (objList.MoveNext())
             *  {
             *      type = heap.GetObjectType(objList.Current);
             *  }
             * } else
             *  type = Runtime.GetHeap().GetTypeByIndex(0);
             * if (type == null)
             *  throw new NullReferenceException("There is no object in the heap");
             * ClrType EEType = (ClrType)RunMethod(type, "ConstructObjectType", EEClass);
             * return EEType;
             */
        }
Ejemplo n.º 2
0
        public void EETypeTest()
        {
            using DataTarget dt = TestTargets.AppDomains.LoadFullDump();
            ClrRuntime runtime = dt.ClrVersions.Single().CreateRuntime();
            ClrHeap    heap    = runtime.Heap;

            HashSet <ulong> methodTables = (from obj in heap.EnumerateObjectAddresses()
                                            let type = heap.GetObjectType(obj)
                                                       where !type.IsFree
                                                       select heap.GetMethodTable(obj)).Unique();

            Assert.DoesNotContain(0ul, methodTables);

            foreach (ulong mt in methodTables)
            {
                ClrType type    = heap.GetTypeByMethodTable(mt);
                ulong   eeclass = heap.GetEEClassByMethodTable(mt);
                Assert.NotEqual(0ul, eeclass);

                Assert.NotEqual(0ul, heap.GetMethodTableByEEClass(eeclass));
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 ///     Retrieves the MethodTable associated with the given EEClass.
 /// </summary>
 /// <param name="eeclass">The eeclass to get the method table from.</param>
 /// <returns>
 ///     The MethodTable for the given EEClass, 0 if eeclass is invalid
 ///     or does not exist.
 /// </returns>
 /// <inheritdoc />
 public ulong GetMethodTableByEEClass(ulong eeclass) => Heap.GetMethodTableByEEClass(eeclass);