Esempio n. 1
0
        public SymbolMemberInfo ProcessMember(IDiaSymbol symbol)
        {
            if (symbol.symTag == (uint)SymTagEnum.SymTagVTable)
            {
                return(new SymbolMemberInfo(SymbolMemberInfo.MemberCategory.VTable, string.Empty, string.Empty, 8, 0, (ulong)symbol.offset, symbol.bitPosition));
            }

            if (symbol.isStatic != 0 || (symbol.symTag != (uint)SymTagEnum.SymTagData && symbol.symTag != (uint)SymTagEnum.SymTagBaseClass))
            {
                return(null);
            }

            // LocIsThisRel || LocIsNull || LocIsBitField
            if (symbol.locationType != 4 && symbol.locationType != 0 && symbol.locationType != 6)
            {
                return(null);
            }

            var typeSymbol = symbol.type;

            var typeName = GetType(typeSymbol);

            var symbolName = symbol.name;
            var category   = SymbolMemberInfo.MemberCategory.Member;

            if ((SymTagEnum)symbol.symTag == SymTagEnum.SymTagBaseClass)
            {
                category = SymbolMemberInfo.MemberCategory.Base;
            }
            else if ((SymTagEnum)typeSymbol.symTag == SymTagEnum.SymTagUDT)
            {
                category = SymbolMemberInfo.MemberCategory.UDT;
            }
            else if ((SymTagEnum)typeSymbol.symTag == SymTagEnum.SymTagPointerType)
            {
                category = SymbolMemberInfo.MemberCategory.Pointer;
            }

            var info = new SymbolMemberInfo(category, symbolName, typeName, typeSymbol.length, symbol.length, (ulong)symbol.offset, symbol.bitPosition);

            if (typeSymbol.volatileType == 1)
            {
                info.Volatile = true;
            }
            if (symbol.locationType == 6)
            {
                info.BitField = true;
            }

            return(info);
        }
Esempio n. 2
0
        private string GetType(IDiaSymbol typeSymbol)
        {
            switch ((SymTagEnum)typeSymbol.symTag)
            {
            case SymTagEnum.SymTagFunctionType:
                var returnType = GetType(typeSymbol.type);

                typeSymbol.findChildren(SymTagEnum.SymTagFunctionArgType, null, 0, out var syms);
                if (syms.count == 0)
                {
                    returnType += "(void)";
                }
                else
                {
                    var parameters = new List <string>();
                    foreach (IDiaSymbol argSym in syms)
                    {
                        parameters.Add(GetType(argSym.type));
                    }
                    returnType += "(" + string.Join(",", parameters) + ")";
                }
                return(returnType);

            case SymTagEnum.SymTagPointerType:
                return(typeSymbol.reference != 0 ? $"{GetType(typeSymbol.type)}&" : $"{GetType(typeSymbol.type)}*");

            case SymTagEnum.SymTagBaseType:
                if (typeSymbol.constType != 0)
                {
                    return("const " + SymbolMemberInfo.GetBaseType(typeSymbol));
                }
                return(SymbolMemberInfo.GetBaseType(typeSymbol));

            case SymTagEnum.SymTagArrayType:
                // get array dimension:
                var dimension = typeSymbol.count.ToString();
                return($"{GetType(typeSymbol.type)}[{dimension}]");

            case SymTagEnum.SymTagUDT:
                return(typeSymbol.name);

            case SymTagEnum.SymTagEnum:
                return($"enum {typeSymbol.name}");

            default:
                return(string.Empty);
            }
        }
 public static int CompareOffsets(SymbolMemberInfo a, SymbolMemberInfo b)
 {
     if (a.Offset != b.Offset)
     {
         return(a.Offset < b.Offset ? -1 : 1);
     }
     if (a.IsBase != b.IsBase)
     {
         return(a.IsBase ? -1 : 1);
     }
     if (a.BitPosition != b.BitPosition)
     {
         return(a.BitPosition < b.BitPosition ? -1 : 1);
     }
     if (a.Size != b.Size)
     {
         return(a.Size > b.Size ? -1 : 1);
     }
     return(0);
 }
Esempio n. 4
0
 private void AddMember(SymbolMemberInfo member)
 {
     Members.Add(member);
 }