Exemplo n.º 1
0
        public static void ModifyArchive(Stream outStream, Stream inStream, Stream inEntryStream, string targetEntryPath, string descFilePath, bool isNsp, AuthoringConfiguration config)
        {
            SourceSinkDriver sourceSinkDriver = new SourceSinkDriver();

            sourceSinkDriver.Add(!isNsp ? (IConnector) new ModifiableNintendoContentArchive((IReadableSink) new StreamSink(outStream), new NintendoContentArchiveReader(inStream, config.GetKeyConfiguration().GetKeyAreaEncryptionKeys()), (ISource) new StreamSource(inEntryStream, 0L, inEntryStream.Length), targetEntryPath, descFilePath, config.GetKeyConfiguration()) : (IConnector) new ModifiableNintendoSubmissionPackageArchive((IReadableSink) new StreamSink(outStream), new NintendoSubmissionPackageReader(inStream), (ISource) new StreamSource(inEntryStream, 0L, inEntryStream.Length), targetEntryPath, descFilePath, config.GetKeyConfiguration()));
            sourceSinkDriver.Run();
        }
Exemplo n.º 2
0
        public static void MergeNintendoSubmissionPackageArchive(Stream outStream, List <Stream> inStreams)
        {
            SourceSinkDriver sourceSinkDriver = new SourceSinkDriver();
            ISource          source           = (ISource) new PartitionFsArchiveSource(ArchiveReconstructionUtils.GetMergedNspInfo(inStreams.Select <Stream, NintendoSubmissionPackageReader>((Func <Stream, NintendoSubmissionPackageReader>)(x => new NintendoSubmissionPackageReader(x))).ToList <NintendoSubmissionPackageReader>()));
            ISink            sink             = (ISink) new StreamSink(outStream);

            sink.SetSize(source.Size);
            sourceSinkDriver.Add(source, sink);
            sourceSinkDriver.Run();
        }
Exemplo n.º 3
0
 public static void EncryptXci(Stream outStream, Stream outXmlStream, Stream inStream, AuthoringConfiguration config)
 {
     try
     {
         SourceSinkDriver sourceSinkDriver = new SourceSinkDriver();
         sourceSinkDriver.Add((IConnector) new ProdEncryptedXciArchive((ISink) new StreamSink(outStream), (ISource) new StreamSource(inStream, 0L, inStream.Length), config.GetKeyConfiguration()));
         sourceSinkDriver.Run();
     }
     catch (Exception ex)
     {
         new ResultXmlGenerator(ex.Message + Environment.NewLine + ex.StackTrace).WriteToStream(outXmlStream);
         throw;
     }
 }
Exemplo n.º 4
0
 public static void ProdEncryptNintendoSubmissionPackageArchiveForXci(Stream outStream, Stream outXmlStream, Stream inStream, Stream inUppStream, Stream inPatchStream, byte launchFlags, AuthoringConfiguration config)
 {
     try
     {
         SourceSinkDriver sourceSinkDriver         = new SourceSinkDriver();
         NintendoSubmissionPackageReader uppReader = inUppStream != null ? new NintendoSubmissionPackageReader(inUppStream) : (NintendoSubmissionPackageReader)null;
         sourceSinkDriver.Add((IConnector) new ProdEncryptedXciArchive((IReadableSink) new StreamSink(outStream), new NintendoSubmissionPackageReader(inStream), uppReader, (NintendoSubmissionPackageReader)null, launchFlags, config.GetKeyConfiguration()));
         sourceSinkDriver.Run();
     }
     catch (Exception ex)
     {
         new ResultXmlGenerator(ex.Message + Environment.NewLine + ex.StackTrace).WriteToStream(outXmlStream);
         throw;
     }
 }
Exemplo n.º 5
0
 public static void ProdEncryptNintendoSubmissionPackageArchive(Stream outStream, Stream outXmlStream, Stream inStream, AuthoringConfiguration config)
 {
     try
     {
         SourceSinkDriver sourceSinkDriver = new SourceSinkDriver();
         sourceSinkDriver.Add((IConnector) new ProdEncryptedNintendoSubmissionPackageArchive((IReadableSink) new StreamSink(outStream), new NintendoSubmissionPackageReader(inStream), config.GetKeyConfiguration(), config.DebugConfig));
         sourceSinkDriver.Run();
     }
     catch (Exception ex)
     {
         new ResultXmlGenerator(ex.Message + Environment.NewLine + ex.StackTrace).WriteToStream(outXmlStream);
         throw;
     }
     new ResultXmlGenerator(outStream, false).WriteToStream(outXmlStream);
 }
Exemplo n.º 6
0
        public static void CreateArchiveFromAdf(Stream stream, string adfPath, AuthoringConfiguration config)
        {
            SourceSinkDriver sourceSinkDriver = new SourceSinkDriver();

            switch (ContentArchiveLibraryInterface.GetArchiveType(adfPath))
            {
            case ArchiveFormatType.NintendoContent:
                ISource source1 = (ISource) new NintendoContentArchiveSource(new NintendoContentAdfReader(adfPath).GetFileSystemInfo(), config.GetKeyConfiguration(), false);
                ISink   sink1   = (ISink) new StreamSink(stream);
                sink1.SetSize(source1.Size);
                sourceSinkDriver.Add(source1, sink1);
                break;

            case ArchiveFormatType.PartitionFs:
                ISource source2 = (ISource) new PartitionFsArchiveSource(new PartitionFsAdfReader(adfPath).GetFileSystemInfo());
                ISink   sink2   = (ISink) new StreamSink(stream);
                sink2.SetSize(source2.Size);
                sourceSinkDriver.Add(source2, sink2);
                break;

            case ArchiveFormatType.RomFs:
                ISource source3 = (ISource) new RomFsArchiveSource(new RomFsAdfReader(adfPath).GetFileSystemInfo());
                ISink   sink3   = (ISink) new StreamSink(stream);
                sink3.SetSize(source3.Size);
                sourceSinkDriver.Add(source3, sink3);
                break;

            case ArchiveFormatType.NintendoSubmissionPackage:
                NintendoSubmissionPackageAdfReader packageAdfReader = new NintendoSubmissionPackageAdfReader(adfPath);
                IConnector connector = (IConnector) new NintendoSubmissionPackageArchive((IReadableSink) new StreamSink(stream), packageAdfReader.GetFileSystemInfo(), config.GetKeyConfiguration());
                sourceSinkDriver.Add(connector);
                break;

            default:
                throw new NotImplementedException();
            }
            sourceSinkDriver.Run();
        }