public NintendoContentMetaXmlSource(NintendoContentMetaBase contentMetaBase, ISource metaHashSource, long metaSize)
        {
            this.m_contentMetaBase = contentMetaBase;
            this.m_MetaHashSource  = metaHashSource;
            NintendoContentMetaReader contentMetaReader = new NintendoContentMetaReader(contentMetaBase.GetBytes());
            ContentMetaModel          contentMetaModel1 = this.PrepareContentMetaModel(contentMetaBase.GetContentMetaDescryptor());

            contentMetaModel1.Type = contentMetaReader.GetType();
            contentMetaModel1.SetUInt64Id(contentMetaReader.GetId());
            contentMetaModel1.Version       = contentMetaReader.GetVersion();
            contentMetaModel1.AttributeList = ((ContentMetaAttribute)contentMetaReader.GetAttributes()).ToStringList();
            contentMetaModel1.RequiredDownloadSystemVersion = contentMetaReader.GetRequiredDownloadSystemVersion();
            byte[] bytes1 = new byte[NintendoContentMeta.GetDigestSize()];
            contentMetaModel1.SetDigestBytes(bytes1);
            List <NintendoContentInfo> contentInfoList = contentMetaReader.GetContentInfoList();

            if (contentInfoList.Count > 0)
            {
                contentMetaModel1.ContentList = new List <ContentModel>();
                foreach (NintendoContentInfo nintendoContentInfo in contentInfoList)
                {
                    ContentModel contentModel = new ContentModel();
                    contentModel.Type = nintendoContentInfo.Type;
                    contentModel.Size = nintendoContentInfo.Size;
                    byte[] bytes2 = new byte[NintendoContentMeta.GetContentInfoHashSize()];
                    contentModel.SetIdBytes(bytes2);
                    contentModel.SetHashBytes(bytes2);
                    contentMetaModel1.ContentList.Add(contentModel);
                }
            }
            contentMetaModel1.ContentList = contentMetaModel1.ContentList ?? new List <ContentModel>();
            this.m_MetaModel = new ContentModel();
            contentMetaModel1.ContentList.Add(this.m_MetaModel);
            this.m_MetaModel.Type = "Meta";
            this.m_MetaModel.Size = metaSize;
            byte[] bytes3 = new byte[NintendoContentMeta.GetContentInfoHashSize()];
            this.m_MetaModel.SetIdBytes(bytes3);
            this.m_MetaModel.SetHashBytes(bytes3);
            List <NintendoContentMetaInfo> contentMetaInfoList = contentMetaReader.GetContentMetaInfoList();

            if (contentMetaInfoList.Count > 0)
            {
                contentMetaModel1.ContentMetaList = new List <ContentMetaModel>();
                foreach (NintendoContentMetaInfo nintendoContentMetaInfo in contentMetaInfoList)
                {
                    ContentMetaModel contentMetaModel2 = new ContentMetaModel();
                    contentMetaModel2.Type = nintendoContentMetaInfo.Type;
                    contentMetaModel2.SetUInt64Id(nintendoContentMetaInfo.Id);
                    contentMetaModel2.Version       = nintendoContentMetaInfo.Version;
                    contentMetaModel2.AttributeList = ((ContentMetaAttribute)nintendoContentMetaInfo.Attributes).ToStringList();
                    contentMetaModel1.ContentMetaList.Add(contentMetaModel2);
                }
            }
            this.m_model = contentMetaModel1;
            this.Size    = (long)this.GetBytes().Length;
        }
        public ByteData PullData(long offset, int size)
        {
            ISource source = this.m_contentMetaBase.GetSource();
            NintendoContentMetaReader  contentMetaReader = new NintendoContentMetaReader(source.PullData(0L, (int)source.Size).Buffer.Array);
            List <NintendoContentInfo> contentInfoList   = contentMetaReader.GetContentInfoList();

            for (int index = 0; index < contentInfoList.Count; ++index)
            {
                NintendoContentInfo nintendoContentInfo = contentInfoList[index];
                this.m_model.ContentList[index].SetIdBytes(nintendoContentInfo.Id);
                this.m_model.ContentList[index].SetHashBytes(nintendoContentInfo.Hash);
            }
            this.m_model.SetDigestBytes(contentMetaReader.GetDigest());
            ByteData byteData = this.m_MetaHashSource.PullData(0L, NintendoContentMeta.GetContentInfoHashSize());

            this.m_MetaModel.SetIdBytes(byteData.Buffer.Array);
            this.m_MetaModel.SetHashBytes(byteData.Buffer.Array);
            byte[] bytes = this.GetBytes();
            return(new MemorySource(bytes, 0, bytes.Length).PullData(offset, size));
        }
Exemplo n.º 3
0
        internal NintendoContentMetaBase(List <Tuple <ISource, NintendoContentInfo> > contentSourceList, ContentMetaDescriptor descriptor, bool isProdEncryption)
        {
            this.m_contentSourceList = contentSourceList;
            this.m_descriptor        = descriptor;
            string type                  = this.m_descriptor.Type;
            ulong  id                    = this.m_descriptor.Id;
            uint   version               = this.m_descriptor.Version;
            byte   attributes            = this.m_descriptor.Attributes;
            long   applicationId         = (long)this.m_descriptor.ApplicationId;
            uint   downloadSystemVersion = this.m_descriptor.RequiredDownloadSystemVersion;
            List <NintendoContentInfo>     contentInfoList     = this.m_descriptor.ContentInfoList;
            List <NintendoContentMetaInfo> contentMetaInfoList = this.m_descriptor.ContentMetaInfoList;

            byte[] digest = this.m_descriptor.Digest;
            if (!(type == "Application"))
            {
                if (!(type == "AddOnContent"))
                {
                    if (type == "Patch")
                    {
                        NintendoPatchExtendedHeader extendedHeader = (NintendoPatchExtendedHeader)descriptor.ExtendedHeader;
                        this.m_contentMeta = NintendoContentMeta.CreatePatchMeta(id, version, attributes, downloadSystemVersion, extendedHeader, contentInfoList, contentMetaInfoList, digest);
                    }
                    else
                    {
                        this.m_contentMeta = NintendoContentMeta.CreateDefault(id, version, type, attributes, downloadSystemVersion, contentInfoList, contentMetaInfoList, digest);
                    }
                }
                else
                {
                    NintendoAddOnContentExtendedHeader extendedHeader = (NintendoAddOnContentExtendedHeader)descriptor.ExtendedHeader;
                    this.m_contentMeta = NintendoContentMeta.CreateAddOnContentMeta(id, version, attributes, downloadSystemVersion, extendedHeader, contentInfoList, contentMetaInfoList, digest);
                }
            }
            else
            {
                NintendoApplicationExtendedHeader extendedHeader = (NintendoApplicationExtendedHeader)descriptor.ExtendedHeader;
                this.m_contentMeta = NintendoContentMeta.CreateApplicationMeta(id, version, attributes, downloadSystemVersion, extendedHeader, contentInfoList, contentMetaInfoList, digest);
            }
            this.m_source = new NintendoContentMetaBaseSource(this, !isProdEncryption);
        }
Exemplo n.º 4
0
 public void SetDigestBytes(byte[] bytes)
 {
     this.Digest = BitConverter.ToString(bytes, 0, NintendoContentMeta.GetDigestSize()).Replace("-", string.Empty).ToLower();
 }
Exemplo n.º 5
0
 public void SetHashBytes(byte[] bytes)
 {
     this.Hash = BitConverter.ToString(bytes, 0, NintendoContentMeta.GetContentInfoHashSize()).Replace("-", string.Empty).ToLower();
 }
Exemplo n.º 6
0
 public void SetIdBytes(byte[] bytes)
 {
     this.Id = BitConverter.ToString(bytes, 0, NintendoContentMeta.GetContentInfoIdDataSize()).Replace("-", string.Empty).ToLower();
 }
Exemplo n.º 7
0
 public long GetContentInfoHashSize()
 {
     return((long)NintendoContentMeta.GetContentInfoHashSize());
 }
Exemplo n.º 8
0
        private static ContentMetaDescriptor ExtractContentMetaDescriptor(string type, string metaPath, List <NintendoContentInfo> contentInfoList)
        {
            ulong applicationId = 0;
            byte  attributes    = 0;
            NintendoExtendedHeader         extendedHeader      = (NintendoExtendedHeader)null;
            List <NintendoContentMetaInfo> contentMetaInfoList = new List <NintendoContentMetaInfo>();
            uint  num1 = NintendoContentMetaBase.GetDefaultDownloadSystemVersion();
            ulong id;
            uint  version;

            if (type.Equals("SystemUpdate"))
            {
                ContentMetaModel contentMeta1 = NintendoContentMetaBase.GetDeserializedModel <SystemUpdateModel>(metaPath, false).ContentMeta;
                if (contentMeta1.Type != "SystemUpdate")
                {
                    throw new ArgumentException("The content meta type is not SystemUpdate.");
                }
                id      = contentMeta1.GetUInt64Id();
                version = contentMeta1.Version;
                foreach (ContentMetaModel contentMeta2 in contentMeta1.ContentMetaList)
                {
                    contentMetaInfoList.Add(new NintendoContentMetaInfo(contentMeta2.Type, contentMeta2.GetUInt64Id(), contentMeta2.Version, (byte)ContentMetaAttributeExtension.FromStringList((IEnumerable <string>)contentMeta2.AttributeList)));
                }
            }
            else
            {
                DotMetaReader dotMetaReader = new DotMetaReader(metaPath);
                id         = dotMetaReader.GetContentMetaId();
                version    = dotMetaReader.GetVersion();
                attributes = dotMetaReader.GetContentMetaAttributes();
                num1       = dotMetaReader.GetRequiredDownloadSystemVersion().GetValueOrDefault(num1);
                if (!(type == "Application"))
                {
                    if (!(type == "AddOnContent"))
                    {
                        if (type == "Patch")
                        {
                            applicationId = dotMetaReader.GetApplicationId();
                            uint?requiredSystemVersion1 = dotMetaReader.GetRequiredSystemVersion();
                            uint requiredSystemVersion2 = requiredSystemVersion1.HasValue ? requiredSystemVersion1.Value : NintendoContentMeta.GetRequiredSystemVersion();
                            extendedHeader = (NintendoExtendedHeader) new NintendoPatchExtendedHeader(dotMetaReader.GetApplicationId(), requiredSystemVersion2);
                            version        = NintendoContentMetaBase.ShiftVersion(version, "Patch");
                        }
                    }
                    else
                    {
                        applicationId  = dotMetaReader.GetApplicationId();
                        extendedHeader = (NintendoExtendedHeader) new NintendoAddOnContentExtendedHeader(dotMetaReader.GetApplicationId(), dotMetaReader.GetRequiredApplicationVersion(), dotMetaReader.GetAddOnContentTag());
                        version        = NintendoContentMetaBase.ShiftVersion(version, "AddOnContent");
                    }
                }
                else
                {
                    long num2 = (long)id + 2048L;
                    uint?requiredSystemVersion = dotMetaReader.GetRequiredSystemVersion();
                    int  num3 = requiredSystemVersion.HasValue ? (int)requiredSystemVersion.Value : (int)NintendoContentMeta.GetRequiredSystemVersion();
                    extendedHeader = (NintendoExtendedHeader) new NintendoApplicationExtendedHeader((ulong)num2, (uint)num3);
                    version        = NintendoContentMetaBase.ShiftVersion(version, "Application");
                }
            }
            return(new ContentMetaDescriptor(type, id, version, attributes, applicationId, num1, contentInfoList, contentMetaInfoList, extendedHeader, new byte[NintendoContentMeta.GetDigestSize()]));
        }
Exemplo n.º 9
0
 public long GetDigestSize()
 {
     return((long)NintendoContentMeta.GetDigestSize());
 }