private void ToString(StringBuilder builder)
        {
            if (IsUndefined())
            {
                builder.Append("#undefined");
                return;
            }

            if (HasSimpleValue)
            {
                builder.Append(SimpleValueHelper.GetSimpleValueString(this));
                return;
            }

            builder.Append('{');
            builder.Append(m_deobfuscator.OriginalName);

            if (!IsInterior)
            {
                builder.Append(" (");
                builder.Append(GetAddressString());
                builder.Append(")");
            }

            builder.Append("}");
        }
Example #2
0
        private object GetSimpleValueImpl(ulong address, ClrType type)
        {
            if (SimpleValueHelper.IsSimpleValue(type))
            {
                var value = SimpleValueHelper.GetSimpleValue(address, type, false);
                return(value);
            }

            return(address);
        }
Example #3
0
        public override void Init()
        {
            if (ClrDumpObject == null)
            {
                return;
            }

            mainFieldValues = FieldValueInformation.GetChildren(ClrDumpObject);
            SimpleValue     = ClrDump.Eval(() =>
            {
                return(SimpleValueHelper.IsSimpleValue(ClrDumpObject.ClrType)
                    ? SimpleValueHelper.GetSimpleValue(ClrDumpObject.Address, ClrDumpObject.ClrType)
                    : null);
            });
        }
Example #4
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);
        }
Example #5
0
 private static object GetSimpleValueImpl(ulong address, ClrType type) => SimpleValueHelper.IsSimpleValue(type) ? SimpleValueHelper.GetSimpleValue(address, type, false) : address;