示例#1
0
        public static IEnumerable <ClrDynamic> EnumerateDynamicObjects(this ClrHeap heap, string typeName)
        {
            if (!typeName.Contains("*"))
            {
                var type =
                    (from t in heap.EnumerateTypes()
                     let deobfuscator = ClrMDSession.Current.GetTypeDeobfuscator(t)
                                        where deobfuscator.OriginalName == typeName
                                        select t).First();

                return((ClrDynamic)heap.EnumerateObjects().First(item => item.Type == type));
            }

            var regex = new Regex($"^{Regex.Escape(typeName).Replace("\\*", ".*")}$",
                                  RegexOptions.Compiled | RegexOptions.IgnoreCase);

            var types =
                from type in heap.EnumerateTypes()
                let deobfuscator = ClrMDSession.Current.GetTypeDeobfuscator(type)
                                   where regex.IsMatch(deobfuscator.OriginalName)
                                   select type;

            var typeSet = new HashSet <ClrType>(types);

            return(heap.EnumerateObjects().Where(o => typeSet.Contains(o.Type)).Select(o => (ClrDynamic)o));
        }
示例#2
0
 public ClrNullValue(ClrHeap heap)
 {
     foreach (var type in heap.EnumerateTypes())
     {
         s_free = type;
         break;
     }
 }
        public static ClrType GetType(this ClrHeap heap, string name)
        {
            var type = heap.EnumerateTypes().FirstOrDefault(t => t.Name.EndsWith(name));

            if (type == null)
            {
                throw new Exception($"Type \"{name}\" wasn't found");
            }

            return(type);
        }
示例#4
0
        public static dynamic GetDynamicClass(this ClrHeap heap, string typeName)
        {
            ClrType type = (from t in heap.EnumerateTypes()
                            where t != null && t.Name == typeName
                            select t).FirstOrDefault();

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

            return(new ClrDynamicClass(heap, type));
        }
示例#5
0
    static void Main(string[] args)
    {
        //ClrRuntime runtime = CreateRuntime(@"C:\Users\leculver\Desktop\work\projects\rmd_test_data\dumps\v4.0.30319.239_x86.cab",
        //                                   @"C:\Users\leculver\Desktop\work\projects\rmd_test_data\dacs");
        //PrintDict(runtime, "0262b058");

        List <string> typeNames = new List <string>();
        ClrRuntime    runtime   = CreateRuntime(@"D:\work\03_09_ml\ml.dmp", @"D:\work\03_09_ml");
        ClrHeap       heap      = runtime.GetHeap();

        foreach (var type in heap.EnumerateTypes())
        {
            typeNames.Add(type.Name);
        }

        typeNames.Sort(delegate(string a, string b) { return(-a.Length.CompareTo(b.Length)); });

        for (int i = 0; i < 10; ++i)
        {
            Console.WriteLine("{0} {1}", typeNames[i].Length, typeNames[i]);
        }
    }
示例#6
0
 /// <summary>
 ///     Enumerates all types in the runtime.
 /// </summary>
 /// <returns>
 ///     An enumeration of all types in the target process.  May return null if it's unsupported for
 ///     that version of CLR.
 /// </returns>
 /// <inheritdoc />
 public IEnumerable <IClrType> EnumerateTypes() => Heap.EnumerateTypes().Select(Converter.Convert);