Exemple #1
0
        private static void RunTask(Context ctx)
        {
            switch (ctx.Options.InFileType)
            {
            case FileType.Nca:
                ProcessNca.Process(ctx);
                break;

            case FileType.Pfs0:
            case FileType.Nsp:
                ProcessNsp.Process(ctx);
                break;

            case FileType.Romfs:
                ProcessRomfs.Process(ctx);
                break;

            case FileType.Nax0:
                break;

            case FileType.SwitchFs:
                ProcessSwitchFs.Process(ctx);
                break;

            case FileType.Save:
                ProcessSave.Process(ctx);
                break;

            case FileType.Xci:
                ProcessXci.Process(ctx);
                break;

            case FileType.Keygen:
                ProcessKeygen(ctx);
                break;

            case FileType.Pk11:
                ProcessPackage.ProcessPk11(ctx);
                break;

            case FileType.Pk21:
                ProcessPackage.ProcessPk21(ctx);
                break;

            case FileType.Kip1:
                ProcessKip.ProcessKip1(ctx);
                break;

            case FileType.Ini1:
                ProcessKip.ProcessIni1(ctx);
                break;

            case FileType.Bench:
                ProcessBench.Process(ctx);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #2
0
        public static void ProcessPk21(Context ctx)
        {
            using (var file = new CachedStorage(new LocalStorage(ctx.Options.InFile, FileAccess.Read), 0x4000, 4, false))
            {
                var package2 = new Package2StorageReader();
                package2.Initialize(ctx.Keyset, file).ThrowIfFailure();

                ctx.Logger.LogMessage(package2.Print());

                string outDir = ctx.Options.OutDir;
                string iniDir = ctx.Options.Ini1OutDir;

                if (iniDir == null && ctx.Options.ExtractIni1)
                {
                    iniDir = Path.Combine(outDir, "INI1");
                }

                if (outDir != null)
                {
                    Directory.CreateDirectory(outDir);

                    package2.OpenPayload(out IStorage kernelStorage, 0).ThrowIfFailure();
                    kernelStorage.WriteAllBytes(Path.Combine(outDir, "Kernel.bin"), ctx.Logger);

                    package2.OpenIni(out IStorage ini1Storage).ThrowIfFailure();
                    ini1Storage.WriteAllBytes(Path.Combine(outDir, "INI1.bin"), ctx.Logger);

                    package2.OpenDecryptedPackage(out IStorage decPackageStorage).ThrowIfFailure();
                    decPackageStorage.WriteAllBytes(Path.Combine(outDir, "Decrypted.bin"), ctx.Logger);
                }

                if (iniDir != null)
                {
                    Directory.CreateDirectory(iniDir);

                    package2.OpenIni(out IStorage ini1Storage).ThrowIfFailure();

                    ProcessKip.ExtractIni1(ini1Storage, iniDir);
                }
            }
        }