MemoryPINGui.LibraryResultsProcessor.LibraryResultsProcessor C# (CSharp) Method

LibraryResultsProcessor() public method

public LibraryResultsProcessor ( string filename ) : System
filename string
return System
        public LibraryResultsProcessor(string filename)
        {
            libraries = new List<Library>();
            libraries_string_interval = new Dictionary<string,Interval>();
            libraries_interval_string = new Dictionary<Interval, string>();

            Library nullLibrary = new Library();
            nullLibrary.Name = "Select to view only system calls";
            nullLibrary.Originaladdress = 0;
            nullLibrary.PeSupport = null;
            libraries.Add(nullLibrary);

            using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                using (StreamReader sr = new StreamReader(fs))
                {
                    while (!sr.EndOfStream)
                    {
                        string line = sr.ReadLine();
                        string[] entries = line.Split(new char[] { '|' });
                        Library library = new Library();
                        foreach (string s in entries)
                        {
                            string[] keyvalue = s.Split(new char[] { ':' });
                            if (keyvalue.Length < 2)
                                continue;
                            if (keyvalue.Length > 2)
                            {
                                // there is a colon besides the field delimeter
                                for (int i = 2; i < keyvalue.Length; i++)
                                {
                                    keyvalue[1] += ":" + keyvalue[i];
                                }
                            }

                            keyvalue[0] = keyvalue[0].Trim();
                            keyvalue[1] = keyvalue[1].Trim();

                            switch (keyvalue[0])
                            {
                                case "Library Name":
                                    library.Name = keyvalue[1].Trim();

                                    try
                                    {
                                        library.PeSupport = new PESupport(library.Name);
                                        library.Originaladdress = (uint)library.PeSupport.ImageBase;
                                    }
                                    catch (ApplicationException e)
                                    {
                                        library.PeSupport = new PESupport("C:\\Program Files\\Java\\jdk1.7.0_45\\bin\\jli.dll");
                                    }

                                    break;
                                case "Start Address":
                                    int addr;
                                    if (int.TryParse(keyvalue[1], out addr))
                                    {
                                        library.Loadaddress = (uint)addr;
                                    //    library.Originaladdress = (uint)addr;
                                    }
                                    else
                                    {
                                        library.Loadaddress = 0x1337BEEF;
                                    //    library.Originaladdress= 0;
                                    }
                                    break;
                                case "End Address":
                                    break;
                                case "Entry Address":
                                    break;
                                default:
                                    break;
                            }
                        }

                        Debug.WriteLine("Name: {0} Base: {1:X} End: {2:X}", library.Name, library.PeSupport.ImageBase, library.PeSupport.ImageBase + library.PeSupport.ImageSize);

                        Libraries.Add(library);
                    }
                }
            }

            foreach (Library l in this.libraries)
            {
                if (l.PeSupport != null)
                {
                    AddLibraryRange(l.Name, (int)l.Loadaddress, (int)(l.Loadaddress + l.PeSupport.ImageSize));
                }
            }
        }

Same methods

LibraryResultsProcessor::LibraryResultsProcessor ( IList libraries ) : System