public static GClass104.GEnum7 smethod_1(Stream stream_0) { byte[] buffer = new byte[4]; if (stream_0.Length > 68L) { stream_0.Seek(64L, SeekOrigin.Begin); stream_0.Read(buffer, 0, buffer.Length); if ((int)GClass27.ToUIntNetworkBytes(BitConverter.ToUInt32(buffer, 0)) == (int)GClass104.uint_1) { return(GClass104.GEnum7.const_1); } } if (stream_0.Length > 132L) { stream_0.Seek(128L, SeekOrigin.Begin); stream_0.Read(buffer, 0, buffer.Length); if ((int)GClass27.ToUIntNetworkBytes(BitConverter.ToUInt32(buffer, 0)) == (int)GClass104.uint_1) { return(GClass104.GEnum7.const_2); } } if (stream_0.Length > 4L) { stream_0.Seek(0L, SeekOrigin.Begin); stream_0.Read(buffer, 0, buffer.Length); if ((int)GClass27.ToUIntNetworkBytes(BitConverter.ToUInt32(buffer, 0)) == (int)GClass104.uint_0) { return(GClass104.GEnum7.const_3); } } return(GClass104.GEnum7.const_0); }
private void method_4(Stream stream_0) { stream_0.Seek(0L, SeekOrigin.Begin); stream_0.Write(BitConverter.GetBytes(GClass27.ToUIntNetworkBytes(this.uint_1)), 0, 4); stream_0.Write(BitConverter.GetBytes(GClass27.ToUIntNetworkBytes(this.uint_0)), 0, 4); stream_0.Write(this.byte_1, 0, this.byte_1.Length); stream_0.Write(this.byte_0, 0, this.byte_0.Length); }
public static GClass104.GEnum7 smethod_0(byte[] byte_0) { if (byte_0.Length > 68 && (int)GClass27.ToUIntNetworkBytes(BitConverter.ToUInt32(byte_0, 64)) == (int)GClass104.uint_1) { return(GClass104.GEnum7.const_1); } if (byte_0.Length > 132 && (int)GClass27.ToUIntNetworkBytes(BitConverter.ToUInt32(byte_0, 128)) == (int)GClass104.uint_1) { return(GClass104.GEnum7.const_2); } return(byte_0.Length > 4 && (int)GClass27.ToUIntNetworkBytes(BitConverter.ToUInt32(byte_0, 0)) == (int)GClass104.uint_0 ? GClass104.GEnum7.const_3 : GClass104.GEnum7.const_0); }
public void method_0(Stream stream_0) { stream_0.Seek(0L, SeekOrigin.Begin); stream_0.Write(BitConverter.GetBytes(GClass27.ToUIntNetworkBytes(this.uint_3)), 0, 4); stream_0.Write(BitConverter.GetBytes(GClass27.ToUIntNetworkBytes(this.uint_7)), 0, 4); stream_0.Write(BitConverter.GetBytes(GClass27.ToUIntNetworkBytes(this.uint_0)), 0, 4); stream_0.Write(BitConverter.GetBytes(GClass27.ToUIntNetworkBytes(this.uint_4)), 0, 4); stream_0.Write(BitConverter.GetBytes(GClass27.ToUIntNetworkBytes(this.uint_5)), 0, 4); stream_0.Write(BitConverter.GetBytes(GClass27.ToUIntNetworkBytes(this.uint_6)), 0, 4); stream_0.Write(BitConverter.GetBytes(GClass27.ToUIntNetworkBytes(this.uint_1)), 0, 4); stream_0.Write(BitConverter.GetBytes(GClass27.ToUIntNetworkBytes(this.uint_2)), 0, 4); }
private void method_2(Stream stream_0) { stream_0.Seek(0L, SeekOrigin.Begin); byte[] buffer1 = new byte[4]; if (!this.bool_1) { stream_0.Read(this.byte_0, 0, this.byte_0.Length); } stream_0.Read(this.byte_9, 0, this.byte_9.Length); stream_0.Read(buffer1, 0, 4); if ((int)GClass27.ToUIntNetworkBytes(BitConverter.ToUInt32(buffer1, 0)) != (int)this.uint_3) { throw new Exception("Invalid Magic!"); } stream_0.Read(buffer1, 0, 4); if ((int)GClass27.ToUIntNetworkBytes(BitConverter.ToUInt32(buffer1, 0)) != (int)this.uint_4) { throw new Exception("Invalid Header Size!"); } stream_0.Read(buffer1, 0, 4); this.uint_6 = GClass27.ToUIntNetworkBytes(BitConverter.ToUInt32(buffer1, 0)); stream_0.Read(buffer1, 0, 4); this.uint_2 = GClass27.ToUIntNetworkBytes(BitConverter.ToUInt32(buffer1, 0)); stream_0.Read(buffer1, 0, 4); this.uint_0 = GClass27.ToUIntNetworkBytes(BitConverter.ToUInt32(buffer1, 0)); stream_0.Read(buffer1, 0, 4); this.uint_5 = GClass27.ToUIntNetworkBytes(BitConverter.ToUInt32(buffer1, 0)); stream_0.Read(buffer1, 0, 4); this.uint_1 = GClass27.ToUIntNetworkBytes(BitConverter.ToUInt32(buffer1, 0)); stream_0.Read(this.byte_7, 0, this.byte_7.Length); stream_0.Read(this.byte_2, 0, this.byte_2.Length); stream_0.Read(this.byte_4, 0, this.byte_4.Length); stream_0.Read(this.byte_3, 0, this.byte_3.Length); stream_0.Read(this.byte_11, 0, this.byte_11.Length); stream_0.Read(this.byte_6, 0, this.byte_6.Length); stream_0.Read(this.byte_1, 0, this.byte_1.Length); stream_0.Read(this.byte_12, 0, this.byte_12.Length); stream_0.Read(this.byte_13, 0, this.byte_13.Length); stream_0.Read(this.byte_8, 0, this.byte_8.Length); stream_0.Read(this.byte_10, 0, this.byte_10.Length); stream_0.Read(this.byte_5, 0, this.byte_5.Length); stream_0.Seek(-16L, SeekOrigin.Current); stream_0.Write(new byte[16], 0, 16); byte[] buffer2 = new byte[stream_0.Length]; stream_0.Seek(0L, SeekOrigin.Begin); stream_0.Read(buffer2, 0, buffer2.Length); MD5 md5 = MD5.Create(); byte[] hash = md5.ComputeHash(buffer2, this.bool_1 ? 0 : 64, 1536); md5.Clear(); this.bool_0 = GClass27.smethod_1(hash, this.byte_5); }
private void method_3(Stream stream_0) { stream_0.Seek(0L, SeekOrigin.Begin); byte[] buffer = new byte[4]; stream_0.Read(buffer, 0, 4); if ((int)GClass27.ToUIntNetworkBytes(BitConverter.ToUInt32(buffer, 0)) != (int)this.uint_1) { throw new Exception("Invalid Magic!"); } stream_0.Read(buffer, 0, 4); this.uint_0 = GClass27.ToUIntNetworkBytes(BitConverter.ToUInt32(buffer, 0)); stream_0.Read(this.byte_1, 0, this.byte_1.Length); stream_0.Read(this.byte_0, 0, this.byte_0.Length); }
private void method_5(Stream stream_0) { stream_0.Seek(0L, SeekOrigin.Begin); if (!this.bool_1) { stream_0.Write(this.byte_0, 0, this.byte_0.Length); } stream_0.Write(this.byte_9, 0, this.byte_9.Length); stream_0.Write(BitConverter.GetBytes(GClass27.ToUIntNetworkBytes(this.uint_3)), 0, 4); stream_0.Write(BitConverter.GetBytes(GClass27.ToUIntNetworkBytes(this.uint_4)), 0, 4); stream_0.Write(BitConverter.GetBytes(GClass27.ToUIntNetworkBytes(this.uint_6)), 0, 4); stream_0.Write(BitConverter.GetBytes(GClass27.ToUIntNetworkBytes(this.uint_2)), 0, 4); stream_0.Write(BitConverter.GetBytes(GClass27.ToUIntNetworkBytes(this.uint_0)), 0, 4); stream_0.Write(BitConverter.GetBytes(GClass27.ToUIntNetworkBytes(this.uint_5)), 0, 4); stream_0.Write(BitConverter.GetBytes(GClass27.ToUIntNetworkBytes(this.uint_1)), 0, 4); stream_0.Write(this.byte_7, 0, this.byte_7.Length); stream_0.Write(this.byte_2, 0, this.byte_2.Length); stream_0.Write(this.byte_4, 0, this.byte_4.Length); stream_0.Write(this.byte_3, 0, this.byte_3.Length); stream_0.Write(this.byte_11, 0, this.byte_11.Length); stream_0.Write(this.byte_6, 0, this.byte_6.Length); stream_0.Write(this.byte_1, 0, this.byte_1.Length); stream_0.Write(this.byte_12, 0, this.byte_12.Length); stream_0.Write(this.byte_13, 0, this.byte_13.Length); stream_0.Write(this.byte_8, 0, this.byte_8.Length); stream_0.Write(this.byte_10, 0, this.byte_10.Length); int position = (int)stream_0.Position; this.byte_5 = new byte[16]; stream_0.Write(this.byte_5, 0, this.byte_5.Length); byte[] numArray = new byte[stream_0.Position]; stream_0.Seek(0L, SeekOrigin.Begin); stream_0.Read(numArray, 0, numArray.Length); this.method_1(numArray, this.bool_1 ? 0 : 64); stream_0.Seek((long)position, SeekOrigin.Begin); stream_0.Write(this.byte_5, 0, this.byte_5.Length); }
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); }