Exemple #1
0
        public async Task Initalize()
        {
            var headerSize = await CiaData.ReadInt32Async(0);

            CiaHeader = new CiaHeader(await CiaData.ReadArrayAsync(0, headerSize));

            var certOffset    = BitMath.Align(headerSize, 64);
            var ticketOffset  = BitMath.Align(certOffset + CiaHeader.CertificateChainSize, 64);
            var tmdOffset     = BitMath.Align(ticketOffset + CiaHeader.TicketSize, 64);
            var contentOffset = BitMath.Align(tmdOffset + CiaHeader.TmdFileSize, 64);
            var metaOffset    = BitMath.Align(contentOffset + CiaHeader.ContentSize, 64);

            TmdMetadata = await TmdMetadata.Load(CiaData.GetReadOnlyDataReference(tmdOffset, CiaHeader.TmdFileSize));

            Partitions = new NcchPartition[TmdMetadata.ContentChunkRecords.Length];
            long partitionStart = contentOffset;

            for (var i = 0; i < TmdMetadata.ContentChunkRecords.Length; i++)
            {
                var chunkRecord     = TmdMetadata.ContentChunkRecords[i];
                var partitionLength = chunkRecord.ContentSize;
                int contentIndex    = chunkRecord.ContentIndex;

                Partitions[i] = await NcchPartition.Load(CiaData.GetReadOnlyDataReference(partitionStart, partitionLength));

                partitionStart += partitionLength;
            }

            IsDlcContainer = TmdMetadata.TitleId >> 32 == 0x0004008C;
        }
Exemple #2
0
        public async Task Initalize()
        {
            // To-do: determine which NCSD header to use
            Header = new CartridgeNcsdHeader(await NcsdData.ReadArrayAsync(0, 0x1500));

            Partitions = new NcchPartition[Header.Partitions.Length];

            await Task.WhenAll(Enumerable.Range(0, Header.Partitions.Length).Select(async i =>
            {
                var partitionStart  = (long)Header.Partitions[i].Offset * MediaUnitSize;
                var partitionLength = (long)Header.Partitions[i].Length * MediaUnitSize;
                Partitions[i]       = await NcchPartition.Load(NcsdData.GetReadOnlyDataReference(partitionStart, partitionLength));
            }));
        }
        public static async Task <NcsdFile> Load(IReadOnlyBinaryDataAccessor data)
        {
            var header     = new CartridgeNcsdHeader(await data.ReadArrayAsync(0, 0x1500));
            var partitions = new NcchPartition[header.Partitions.Length];

            await Task.WhenAll(Enumerable.Range(0, header.Partitions.Length).Select(async i =>
            {
                var partitionStart  = (long)header.Partitions[i].Offset * MediaUnitSize;
                var partitionLength = (long)header.Partitions[i].Length * MediaUnitSize;
                partitions[i]       = await NcchPartition.Load(data.Slice(partitionStart, partitionLength));
            }));

            return(new NcsdFile(header, partitions));
        }