Exemplo n.º 1
0
 public SymbolFactor(SymbolFactor data)
 {
     Symbol  = data.Symbol;
     Address = data.Address;
     Offset  = data.Offset;
     Size    = data.Size;
 }
Exemplo n.º 2
0
        public static bool Interpret(string[] textArray, List <SymbolFactor> symbolList)
        {
            if (textArray[0].IndexOf(keyword) == -1)
            {
                return(false);
            }

            int offsetIndex = 0;

            for (int i = 1; i < textArray.Length; i++)
            {
                if (textArray[i].IndexOf("Symbol table") != -1)
                {
                    offsetIndex = i;
                    break;
                }
            }

            if (offsetIndex == 0)
            {
                return(false);
            }

            for (int i = offsetIndex; i < textArray.Length; i++)
            {
                var modifiedLine = Regex.Replace(textArray[i], @" +", " ");

                string[] splitLine = modifiedLine.Split(' ');

                if (splitLine.Length == 9)
                {
                    if (!string.IsNullOrEmpty(splitLine[8]) &&
                        Regex.IsMatch(splitLine[2], @"^[0-9a-fA-F]+$") &&
                        Regex.IsMatch(splitLine[3], @"^[0-9]+$"))
                    {
                        var data = new SymbolFactor();

                        data.Symbol  = splitLine[8];
                        data.Address = "0x" + splitLine[2];
                        data.Size    = splitLine[3];

                        symbolList.Add(data);
                    }
                }
            }

            if (symbolList.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        public static bool Interpret(string[] textArray, List <SymbolFactor> symbolList)
        {
            for (int i = 1; i < textArray.Length; i++)
            {
                string[] splitLine = textArray[i].Split(',');

                if (splitLine.Length == 4)
                {
                    if (splitLine[1].Length < 2)
                    {
                        continue;
                    }

                    if (splitLine[1].Substring(0, 2) == "0x")
                    {
                        splitLine[1] = splitLine[1].Remove(0, 2);
                    }

                    if (!string.IsNullOrEmpty(splitLine[0]) &&
                        Regex.IsMatch(splitLine[1], @"^[0-9a-fA-F]+$") &&
                        Regex.IsMatch(splitLine[2], @"^[0-9]+$") &&
                        Regex.IsMatch(splitLine[3], @"^[0-9]+$"))
                    {
                        var data = new SymbolFactor();

                        data.Symbol  = splitLine[0];
                        data.Address = "0x" + splitLine[1];
                        data.Offset  = splitLine[2];
                        data.Size    = splitLine[3];

                        symbolList.Add(data);
                    }
                }
            }

            if (symbolList.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        public static bool Interpret(string[] textArray, List <SymbolFactor> symbolList)
        {
            if (textArray[0].IndexOf(keyword) == -1)
            {
                return(false);
            }

            for (int i = 1; i < textArray.Length; i++)
            {
                if ((textArray[i].IndexOf(".bss") == -1) &&
                    (textArray[i].IndexOf(".rodata") == -1) &&
                    (textArray[i].IndexOf(".data") == -1))
                {
                    continue;
                }

                var modifiedLine = Regex.Replace(textArray[i], @" +", " ");

                var splitLine = modifiedLine.Split(' ');

                if (splitLine.Length == 5)
                {
                    var splietsplitLine = splitLine[1].Split('.');

                    if (splietsplitLine.Length > 2)
                    {
                        if (!string.IsNullOrEmpty(splietsplitLine[2]) &&
                            IsHexString(splitLine[2]) &&
                            IsHexString(splitLine[3]))
                        {
                            var data = new SymbolFactor();
                            data.Symbol  = splietsplitLine[2];
                            data.Address = splitLine[2];
                            data.Size    = Convert.ToInt64(splitLine[3], 16).ToString();

                            symbolList.Add(data);
                        }
                    }
                }
                else if (splitLine.Length == 2)
                {
                    var splietsplitLine = splitLine[1].Split('.');

                    if (splietsplitLine.Length > 2)
                    {
                        var name = splietsplitLine[2];

                        if (i < textArray.Length)
                        {
                            i++;
                        }
                        else
                        {
                            break;
                        }

                        modifiedLine = Regex.Replace(textArray[i], @" +", " ");
                        splitLine    = modifiedLine.Split(' ');

                        if (splitLine.Length > 2)
                        {
                            if (!string.IsNullOrEmpty(name) &&
                                IsHexString(splitLine[1]) &&
                                IsHexString(splitLine[2]))
                            {
                                var data = new SymbolFactor();
                                data.Symbol  = name;
                                data.Address = splitLine[1];
                                data.Size    = Convert.ToInt64(splitLine[2], 16).ToString();

                                symbolList.Add(data);
                            }
                        }
                    }
                }
            }

            if (symbolList.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }