コード例 #1
1
        public static List<ClrType> GetDelegateTypes(ClrDump clrDump)
        {
            CancellationTokenSource token = new CancellationTokenSource();
            clrDump.MessageBus.BeginTask("Analyzing delegate types...", token);
            List<ClrType> delegates = new List<ClrType>();
            var delegateType = clrDump.GetClrType(typeof(MulticastDelegate).FullName);

            foreach(var type in  clrDump.AllTypes)
            {
                clrDump.MessageBus.Status($"Analyzing delegate type: {type.Name}");
                if (token.IsCancellationRequested)
                {
                    break;
                }

                if ( type.BaseType != null && type.BaseType == delegateType )
                {
                    clrDump.MessageBus.Status($"Analyzing delegate type: counting instances for {type.Name}");
                    int nb = clrDump.CountInstances(type);
                    if (nb > 0)
                    {
                        delegates.Add(type);
                    }
                }
            }

            clrDump.MessageBus.EndTask("Delegate types analyzed.");
            return delegates.GroupBy(t => t.Name).Select(g => g.First()).ToList();
        }
コード例 #2
0
        public static List <ClrType> GetDelegateTypes(ClrDump clrDump)
        {
            CancellationTokenSource token = new CancellationTokenSource();

            clrDump.MessageBus.BeginTask("Analyzing delegate types...", token);
            List <ClrType> delegates    = new List <ClrType>();
            var            delegateType = clrDump.GetClrType(typeof(MulticastDelegate).FullName);

            foreach (var type in clrDump.AllTypes)
            {
                clrDump.MessageBus.Status($"Analyzing delegate type: {type.Name}");
                if (token.IsCancellationRequested)
                {
                    break;
                }

                if (type.BaseType != null && type.BaseType == delegateType)
                {
                    clrDump.MessageBus.Status($"Analyzing delegate type: counting instances for {type.Name}");
                    int nb = clrDump.CountInstances(type);
                    if (nb > 0)
                    {
                        delegates.Add(type);
                    }
                }
            }

            clrDump.MessageBus.EndTask("Delegate types analyzed.");
            return(delegates.GroupBy(t => t.Name).Select(g => g.First()).ToList());
        }
コード例 #3
0
        internal static List<DisposableTypeInformation> GetDisposableTypeInformations(ClrDump clrDump)
        {
            CancellationTokenSource token = new CancellationTokenSource();
            clrDump.MessageBus.BeginTask("Analyzing IDisposable types...", token);

            List<DisposableTypeInformation> result = new List<DisposableTypeInformation>();

            foreach (var type in clrDump.AllTypes)
            {
                clrDump.MessageBus.Status($"Analyzing type: {type.Name}");
                if (token.IsCancellationRequested)
                {
                    clrDump.MessageBus.EndTask("Analyzing IDisposable types: cancelled.");
                    return result;
                }

                foreach (var interf in type.Interfaces)
                {
                    if( interf.Name == typeof(System.IDisposable).FullName)
                    {
                        clrDump.MessageBus.Status($"Analyzing IDisposable type: counting instances for {type.Name}");
                        int nb = clrDump.CountInstances(type);
                        result.Add(new DisposableTypeInformation(type, nb));
                    }
                }
            }
            clrDump.MessageBus.EndTask("IDisposable types analyzed.");
            return result;
        }
コード例 #4
0
        internal static List <DisposableTypeInformation> GetDisposableTypeInformations(ClrDump clrDump)
        {
            CancellationTokenSource token = new CancellationTokenSource();

            clrDump.MessageBus.BeginTask("Analyzing IDisposable types...", token);

            List <DisposableTypeInformation> result = new List <DisposableTypeInformation>();

            foreach (var type in clrDump.AllTypes)
            {
                clrDump.MessageBus.Status($"Analyzing type: {type.Name}");
                if (token.IsCancellationRequested)
                {
                    clrDump.MessageBus.EndTask("Analyzing IDisposable types: cancelled.");
                    return(result);
                }

                foreach (var interf in type.Interfaces)
                {
                    if (interf.Name == typeof(System.IDisposable).FullName)
                    {
                        clrDump.MessageBus.Status($"Analyzing IDisposable type: counting instances for {type.Name}");
                        int nb = clrDump.CountInstances(type);
                        result.Add(new DisposableTypeInformation(type, nb));
                    }
                }
            }
            clrDump.MessageBus.EndTask("IDisposable types analyzed.");
            return(result);
        }
コード例 #5
0
        internal static List <DelegateTypeInformation> GetDelegateTypeInformations(ClrDump clrDump)
        {
            var types            = GetDelegateTypes(clrDump);
            var typeInformations = new List <DelegateTypeInformation>();

            foreach (var type in types)
            {
                var count               = clrDump.CountInstances(type);
                var targets             = CountTargets(clrDump, type);
                var delegateInformation = new DelegateTypeInformation(clrDump, type, count, targets);
                typeInformations.Add(delegateInformation);
            }

            return(typeInformations);
        }
コード例 #6
0
        internal static List <StringInformation> Analyse(ClrDump clrDump, MessageBus msgBus)
        {
            var stringType      = clrDump.GetClrType(typeof(string).FullName);
            var stringInstances = clrDump.EnumerateInstances(stringType);
            int nbStrings       = clrDump.CountInstances(stringType);
            Dictionary <string, List <ulong> > result = new Dictionary <string, List <ulong> >();
            CancellationTokenSource            token  = new CancellationTokenSource();

            msgBus.BeginTask("Analyzing strings...", token);
            int n = 0;

            clrDump.Run(() =>
            {
                foreach (var address in stringInstances)
                {
                    if (token.IsCancellationRequested)
                    {
                        return;
                    }
                    n++;
                    var value = SimpleValueHelper.GetSimpleValue(address, stringType, false) as string;
                    if (value == null)
                    {
                        continue;
                    }
                    List <ulong> addresses;
                    if (!result.TryGetValue(value, out addresses))
                    {
                        addresses     = new List <ulong>();
                        result[value] = addresses;
                    }
                    addresses.Add(address);
                    if (n % 1024 == 0)
                    {
                        float pct = (float)n / nbStrings;
                        msgBus.Status($"Analyzing strings: {pct:p2}, n= {n:###,###,###,##0} / {nbStrings:###,###,###,##0}");
                    }
                }
            });
            msgBus.EndTask($"Strings analyzed. Instances: {n:###,###,###,##0}, unique values: {result.Count:###,###,###,##0}");

            var strings = result.Select(kvp => new StringInformation(kvp.Key, kvp.Value)).ToList();

            return(strings);
        }
コード例 #7
0
        internal static List<StringInformation> Analyse(ClrDump clrDump, MessageBus msgBus)
        {
            var stringType = clrDump.GetClrType(typeof(string).FullName);
            var stringInstances = clrDump.EnumerateInstances(stringType);
            int nbStrings = clrDump.CountInstances(stringType);
            Dictionary <string, List<ulong>> result = new Dictionary<string, List<ulong>>();
            CancellationTokenSource token = new CancellationTokenSource();
            msgBus.BeginTask("Analyzing strings...", token);
            int n = 0;
            clrDump.Run(() =>
            {
                foreach (var address in stringInstances)
                {
                    if( token.IsCancellationRequested)
                    {
                        return;
                    }
                    n++;
                    var value = SimpleValueHelper.GetSimpleValue(address, stringType, false) as string;
                    if (value == null)
                    {
                        continue;
                    }
                    List<ulong> addresses;
                    if( ! result.TryGetValue(value, out addresses))
                    {
                        addresses = new List<ulong>();
                        result[value] = addresses;
                    }
                    addresses.Add(address);
                    if( n  % 1024 == 0)
                    {
                        float pct = (float)n / nbStrings;
                        msgBus.Status($"Analyzing strings: {pct:p2}, n= {n:###,###,###,##0} / {nbStrings:###,###,###,##0}");
                    }
                }
            });
            msgBus.EndTask($"Strings analyzed. Instances: {n:###,###,###,##0}, unique values: {result.Count:###,###,###,##0}");

            var strings = result.Select(kvp => new StringInformation(kvp.Key, kvp.Value)).ToList();
            return strings;
        }
コード例 #8
0
        internal static List<DelegateTypeInformation> GetDelegateTypeInformations(ClrDump clrDump)
        {
            var types = GetDelegateTypes(clrDump);
            var typeInformations = new List<DelegateTypeInformation>();
            foreach(var type in types)
            {
                var count = clrDump.CountInstances(type);
                var targets = CountTargets(clrDump, type);
                var delegateInformation = new DelegateTypeInformation(clrDump, type, count, targets);
                typeInformations.Add(delegateInformation);
            }

            return typeInformations;
        }