Esempio n. 1
0
        private void CreateApplications()
        {
            foreach (Title title in Titles.Values.Where(x => x.Metadata.Type >= TitleType.Application))
            {
                Cnmt  meta  = title.Metadata;
                ulong appId = meta.ApplicationTitleId;

                if (!Applications.TryGetValue(appId, out Application app))
                {
                    app = new Application();
                    Applications.Add(appId, app);
                }

                app.AddTitle(title);
            }

            foreach (Application app in Applications.Values)
            {
                Nca main  = app.Main?.MainNca;
                Nca patch = app.Patch?.MainNca;

                if (main != null)
                {
                    patch?.SetBaseNca(main);
                }
            }
        }
Esempio n. 2
0
        private void ReadTitles()
        {
            foreach (SwitchFsNca nca in Ncas.Values.Where(x => x.Nca.Header.ContentType == ContentType.Meta))
            {
                try
                {
                    var title = new Title();

                    IFileSystem fs       = nca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.ErrorOnInvalid);
                    string      cnmtPath = fs.EnumerateEntries("*.cnmt").Single().FullPath;

                    IFile file = fs.OpenFile(cnmtPath, OpenMode.Read);

                    var metadata = new Cnmt(file.AsStream());
                    title.Id       = metadata.TitleId;
                    title.Version  = metadata.TitleVersion;
                    title.Metadata = metadata;
                    title.MetaNca  = nca;
                    title.Ncas.Add(nca);

                    foreach (CnmtContentEntry content in metadata.ContentEntries)
                    {
                        string ncaId = content.NcaId.ToHexString();

                        if (Ncas.TryGetValue(ncaId, out SwitchFsNca contentNca))
                        {
                            title.Ncas.Add(contentNca);
                        }

                        switch (content.Type)
                        {
                        case CnmtContentType.Program:
                        case CnmtContentType.Data:
                            title.MainNca = contentNca;
                            break;

                        case CnmtContentType.Control:
                            title.ControlNca = contentNca;
                            break;
                        }
                    }

                    Titles[title.Id] = title;
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"{ex.Message} File: {nca.Filename}");
                }
            }
        }
Esempio n. 3
0
        private void ReadTitles()
        {
            foreach (Nca nca in Ncas.Values.Where(x => x.Header.ContentType == ContentType.Meta))
            {
                var title = new Title();

                // Meta contents always have 1 Partition FS section with 1 file in it
                IStorage sect = nca.OpenSection(0, false, IntegrityCheckLevel.ErrorOnInvalid, true);
                var      pfs0 = new PartitionFileSystem(sect);
                IFile    file = pfs0.OpenFile(pfs0.Files[0], OpenMode.Read);

                var metadata = new Cnmt(file.AsStream());
                title.Id       = metadata.TitleId;
                title.Version  = metadata.TitleVersion;
                title.Metadata = metadata;
                title.MetaNca  = nca;
                title.Ncas.Add(nca);

                foreach (CnmtContentEntry content in metadata.ContentEntries)
                {
                    string ncaId = content.NcaId.ToHexString();

                    if (Ncas.TryGetValue(ncaId, out Nca contentNca))
                    {
                        title.Ncas.Add(contentNca);
                    }

                    switch (content.Type)
                    {
                    case CnmtContentType.Program:
                    case CnmtContentType.Data:
                        title.MainNca = contentNca;
                        break;

                    case CnmtContentType.Control:
                        title.ControlNca = contentNca;
                        break;
                    }
                }

                Titles[title.Id] = title;
            }
        }