Exemple #1
0
        public Xci(Keyset keyset, Stream stream)
        {
            Header = new XciHeader(keyset, stream);
            var hfs0Stream = new SubStream(stream, Header.PartitionFsHeaderAddress);

            RootPartition = new XciPartition(hfs0Stream)
            {
                Name         = RootPartitionName,
                Offset       = Header.PartitionFsHeaderAddress,
                HashValidity = Header.PartitionFsHeaderValidity
            };

            Partitions.Add(RootPartition);

            foreach (PfsFileEntry file in RootPartition.Files)
            {
                Stream partitionStream = RootPartition.OpenFile(file);

                var partition = new XciPartition(partitionStream)
                {
                    Name         = file.Name,
                    Offset       = Header.PartitionFsHeaderAddress + RootPartition.HeaderSize + file.Offset,
                    HashValidity = file.HashValidity
                };

                Partitions.Add(partition);
            }

            UpdatePartition = Partitions.FirstOrDefault(x => x.Name == UpdatePartitionName);
            NormalPartition = Partitions.FirstOrDefault(x => x.Name == NormalPartitionName);
            SecurePartition = Partitions.FirstOrDefault(x => x.Name == SecurePartitionName);
            LogoPartition   = Partitions.FirstOrDefault(x => x.Name == LogoPartitionName);
        }
Exemple #2
0
        public XciPartition OpenPartition(XciPartitionType type)
        {
            XciPartition root = GetRootPartition();

            if (type == XciPartitionType.Root)
            {
                return(root);
            }

            root.OpenFile(out IFile partitionFile, type.GetFileName().ToU8Span(), OpenMode.Read).ThrowIfFailure();
            return(new XciPartition(partitionFile.AsStorage()));
        }
Exemple #3
0
        public XciPartition OpenPartition(XciPartitionType type)
        {
            XciPartition root = GetRootPartition();

            if (type == XciPartitionType.Root)
            {
                return(root);
            }

            IStorage partitionStorage = root.OpenFile(type.GetFileName(), OpenMode.Read).AsStorage();

            return(new XciPartition(partitionStorage));
        }
Exemple #4
0
        private void InitializeRootPartition()
        {
            lock (InitLocker)
            {
                if (RootPartition != null)
                {
                    return;
                }

                IStorage rootStorage = BaseStorage.Slice(Header.RootPartitionOffset);

                RootPartition = new XciPartition(rootStorage)
                {
                    Offset       = Header.RootPartitionOffset,
                    HashValidity = Header.PartitionFsHeaderValidity
                };
            }
        }