Пример #1
0
        public static MinSym CheckAllSyms(ulong VA)
        {
            // TODO: synthetic thing... maybe we should avoid this heap allocation?
            // well see after profiling the hotness of this path ;)
            var check = new MinSym()
            {
                Address = VA, Length = 1
            };

            var idx = ListAllSymbols.FindIndex(0, 1, (x) => x.CompareTo(check) == 0);

            if (idx >= 0 && idx <= ListAllSymbols.Count)
            {
                return(ListAllSymbols[idx]);
            }

            return(null);
        }
Пример #2
0
        public List <MinSym> EnumSymsInFileWithVAOrder(string arg, ulong BaseVA, ulong Length)
        {
            IDiaSymbol Master = null;
            var        rv     = new List <MinSym>();

            var foo = new Dia2Lib.DiaSource();

            foo.loadDataForExe(arg, SymPath, null);
            foo.openSession(out Session);

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

            Session.loadAddress = BaseVA;

            var    CurrVA = BaseVA;
            var    End    = BaseVA + Length;
            MinSym last   = null;

            do
            {
                Session.findSymbolByVA(CurrVA, SymTagEnum.SymTagNull, out Master);
                var len = Master.length > 0 ? Master.length : 8;


                var s = new MinSym()
                {
                    Address = CurrVA,
                    Length  = len,
                    Name    = Master.name,
                    ID      = Master.symIndexId,
                    UDName  = (!string.IsNullOrWhiteSpace(Master.undecoratedName) && Master.name != Master.undecoratedName) ? Master.undecoratedName : string.Empty,
                };


                if (last != null
                    &&
                    // if the ID is the same
                    ((last.ID == s.ID)
                     ||
                     // also if the name and the last name are empty even if the ID is diff, treat them as the same
                     (string.IsNullOrWhiteSpace(s.Name) && string.IsNullOrWhiteSpace(last.Name))))
                {
                    // grow the length if the most recent symbol in the list
                    last.Length += s.Length;
                }
                else
                {
                    // otherwise add the new thing to the list
                    rv.Add(s);
                    last = s;
                }

                CurrVA += len;

#if DEBUGGING_STUFF
                /* DEBUGGING
                 * ForegroundColor = ConsoleColor.Cyan;
                 *
                 * Write($"Name: [{Master.name}] Address: [{CurrVA:X}] Length: [{Master.length}] ");
                 * if (string.IsNullOrWhiteSpace(Master.name) && Master.name != Master.undecoratedName)
                 * {
                 *  ForegroundColor = ConsoleColor.White;
                 *  WriteLine($"UDName: [{Master.undecoratedName}]");
                 * }
                 * else
                 *  WriteLine(String.Empty);
                 */
                //foreach (var pr in typeof(IDiaSymbol).LinqPublicProperties())
                //    WriteLine($"{pr.Name} = {pr.GetValue(Master)}");

                /*
                 * Session.findChildren(Master, SymTagEnum.SymTagNull, null, 0, out EnumSymbols);
                 * if (EnumSymbols == null)
                 *  continue;
                 *
                 * var tot1 = EnumSymbols.count;
                 * int cnt = 0;
                 *
                 * ForegroundColor = ConsoleColor.White;
                 *
                 * do {
                 *  cnt++;
                 *  EnumSymbols.Next(1, out Sub, out compileFetched);
                 *  if (Sub == null)
                 *      continue;
                 *
                 *  WriteLine($"Name: [{Sub.name}] UName: [{Sub.undecoratedName}] Length: [{Sub.length}]");
                 *
                 *  foreach (var pr in typeof(IDiaSymbol).LinqPublicProperties())
                 *      WriteLine($"{pr.Name} = {pr.GetValue(Sub)}");
                 *  foreach (var fn in typeof(IDiaSymbol).LinqPublicFunctions())
                 *  {
                 *     if (fn.Name.Contains("get"))
                 *      WriteLine($"{fn.Name} = {fn.Invoke(Sub, null)}");
                 *  }
                 * } while (cnt < tot1);
                 */
#endif
            } while (CurrVA < End);

            return(rv);
        }
Пример #3
0
 public static MinSym CheckAllSyms(MinSym check)
 {
     return(ListAllSymbols.Find((x) => x.CompareTo(check) == 0));
 }