Пример #1
0
        public static ArchiveFileLib FromStream(Stream stream)
        {
            ArchiveFileLib file = new ArchiveFileLib();

            byte[] buffer = new byte[Windows.Constants.IMAGE_ARCHIVE_START_SIZE];
            stream.Read(buffer, 0, Windows.Constants.IMAGE_ARCHIVE_START_SIZE);

            bool valid = Encoding.ASCII.GetString(buffer) == Windows.Constants.IMAGE_ARCHIVE_START;
            if (!valid) throw new InvalidDataException("Not a valid archive file");

            file.first.FromStream(stream);
            file.second.FromStream(stream);
            file.longnames.FromStream(stream);

            List<ObjectFileMember> objects = new List<ObjectFileMember>();

            while (stream.CanRead && (stream.Position < stream.Length))
            {
                try
                {
                    var ofm = new ObjectFileMember();
                    ofm.FromStream(stream);
                    objects.Add(ofm);
                }
                catch
                {
                    file.Errors = true;
                    break;
                }
            }

            file.objects = objects.ToArray();

            return file;
        }
        public ObjectFileViewModel(ObjectFileMember objectFileMember)
            : base(objectFileMember)
        {
            AddSymbols();
            AddSections();

            _headerView.ObjectFile = this;

            _filteredSymbols.Source = _symbols;
            _filteredSymbols.Filter += new FilterEventHandler(Filters.SymbolViewModel_HideLinkerSymbols);
            Filters.FilterUpdated += new EventHandler(RefreshView);
        }