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; }
public static async Task <TmdMetadata> Load(IBinaryDataAccessor data) { var tmd = new TmdMetadata(data); await tmd.Initalize(); return(tmd); }