Exemplo n.º 1
0
 private void method_0(Stream TMD_Stream, SystemType SystemType) //Information located: https://3dbrew.org/wiki/Title_metadata#Signature_Type
 {
     TMD_Stream.Seek(0L, SeekOrigin.Begin);
     byte[] buffer1 = new byte[8];
     TMD_Stream.Read(buffer1, 0, 4);
     this.TMD_Signature__Type_as_Int = GClass27.ToUIntNetworkBytes(BitConverter.ToUInt32(buffer1, 0));
     TMD_Stream.Read(this.TMD_Signature, 0, this.TMD_Signature.Length);
     TMD_Stream.Read(this.TMD_Signature_Padding, 0, this.TMD_Signature_Padding.Length);
     TMD_Stream.Read(this.SignatureIssuer, 0, this.SignatureIssuer.Length);
     TMD_Stream.Read(buffer1, 0, 4);
     this.Version            = buffer1[0];
     this.ca_crl_version     = buffer1[1];
     this.signer_crl_version = buffer1[2];
     this.Reserved           = buffer1[3];
     TMD_Stream.Read(buffer1, 0, 8);                                      //Skip System Version
     TMD_Stream.Read(buffer1, 0, 8);                                      //Read Title ID
     this.TitleId = GClass27.ToULongNetworkBytes(BitConverter.ToUInt64(buffer1, 0));
     TMD_Stream.Read(buffer1, 0, 4);                                      //Read Title Type (e.g. DSIWare, ESHOP, etc I think)
     this.TitleType = GClass27.ToUIntNetworkBytes(BitConverter.ToUInt32(buffer1, 0));
     TMD_Stream.Read(buffer1, 0, 2);                                      //Read Group ID
     this.GroupID = GClass27.ToUShortNetworkBytes(BitConverter.ToUInt16(buffer1, 0));
     TMD_Stream.Read(buffer1, 0, 2);                                      //Read half of Save Data Size (Bytes) (Also SRL Public Save Data Size)?
     this.Save_Data_Size_pt1 = GClass27.ToUShortNetworkBytes(BitConverter.ToUInt16(buffer1, 0));
     TMD_Stream.Read(buffer1, 0, 2);                                      //Read second half of Save Data Size (Bytes) (Also SRL Public Save Data Size)?
     this.Save_Data_Size_pt2 = GClass27.ToUShortNetworkBytes(BitConverter.ToUInt16(buffer1, 0));
     TMD_Stream.Read(this.SkippedSLRData, 0, this.SkippedSLRData.Length); //Skips SLR Private Save, Reserved, SLR Flag, and Reserved
     TMD_Stream.Read(buffer1, 0, 4);                                      //Reads Access Rights
     this.AccessRights = GClass27.ToUIntNetworkBytes(BitConverter.ToUInt32(buffer1, 0));
     TMD_Stream.Read(buffer1, 0, 8);                                      //Read Title Version, Content Count, Boot Content, and Padding
     this.TitleVersion  = GClass27.ToUShortNetworkBytes(BitConverter.ToUInt16(buffer1, 0));
     this.NumOfContents = GClass27.ToUShortNetworkBytes(BitConverter.ToUInt16(buffer1, 2));
     this.BootContent   = GClass27.ToUShortNetworkBytes(BitConverter.ToUInt16(buffer1, 4));
     this.Padding       = GClass27.ToUShortNetworkBytes(BitConverter.ToUInt16(buffer1, 6));
     if (SystemType != SystemType.SystemWii)
     {
         TMD_Stream.Position = 2820L; //Skips to Hex 0xB02
     }
     this.list_0 = new List <GClass101>();
     for (int index = 0; index < (int)this.NumOfContents; ++index)
     {
         GClass101 gclass101;
         if (SystemType != SystemType.SystemWiiU && SystemType != SystemType.SystemWii)
         {
             if (SystemType != SystemType.System3DS)
             {
                 throw new NotImplementedException();
             }
             A_3DS_CND_File_Hash A_3DS_CDN_File_Hash = new A_3DS_CND_File_Hash();
             A_3DS_CDN_File_Hash.Hash = new byte[32];
             gclass101 = (GClass101)A_3DS_CDN_File_Hash;
         }
         else
         {
             A_WiiU_CDN_File_Hash A_WiiU_CDN_File_Hash = new A_WiiU_CDN_File_Hash();
             A_WiiU_CDN_File_Hash.Hash = new byte[20];
             gclass101 = (GClass101)A_WiiU_CDN_File_Hash;
         }
         TMD_Stream.Read(buffer1, 0, 8);
         gclass101.ContentId   = GClass27.ToUIntNetworkBytes(BitConverter.ToUInt32(buffer1, 0));
         gclass101.Index       = GClass27.ToUShortNetworkBytes(BitConverter.ToUInt16(buffer1, 4));
         gclass101.ContentType = (GEnum6)GClass27.ToUShortNetworkBytes(BitConverter.ToUInt16(buffer1, 6));
         TMD_Stream.Read(buffer1, 0, 8);
         gclass101.ContentSize = new DataSize(GClass27.ToULongNetworkBytes(BitConverter.ToUInt64(buffer1, 0)));
         TMD_Stream.Read(gclass101.Hash, 0, gclass101.Hash.Length);
         this.list_0.Add(gclass101);
         if (SystemType == SystemType.SystemWiiU)
         {
             byte[] buffer2 = new byte[12];
             TMD_Stream.Read(buffer2, 0, 12);
         }
     }
     TMD_Stream.Read(this.Certificate1, 0, this.Certificate1.Length);
     TMD_Stream.Read(this.Certificate2, 0, this.Certificate2.Length);
 }