public void Read() { if (!IsOpen || IsDisposed) { throw new Exception("XenonPatch.Read: The Xenon patch is not open."); } if (HasBeenRead) { throw new Exception("XenonPatch.Read: The Xenon patch has already been read."); } eio.SetPosition(0); Patches = new List <PatchEntry>(); //Just has Kernel+XAM. { var nextAddr = eio.Reader.ReadUInt32(); while (nextAddr != uint.MaxValue) { eio.SetPosition(-4, SeekOrigin.Current); var entry = new PatchEntry(); entry.Read(eio.Reader); Patches.Add(entry); nextAddr = eio.Reader.ReadUInt32(); } } HasBeenRead = true; }
public static CatalogFile Read(Stream input) { const Endian endian = Endian.Little; var magic1 = input.ReadValueU64(endian); var magic2 = input.ReadValueU64(endian); if (magic1 != Signature || magic2 != Signature) { throw new FormatException(); } var instance = new CatalogFile(); var normalCount = input.ReadValueU32(endian); var patchCount = input.ReadValueU32(endian); var encryptedCount = input.ReadValueU32(endian); var unknown1C = input.ReadValueS32(endian); // patch version related? var unknown20 = input.ReadValueS32(endian); // patch version related? var unknown24 = input.ReadValueS32(endian); // patch version related? instance.NormalEntries.Clear(); for (int i = 0; i < normalCount; i++) { var entry = NormalEntry.Read(input, endian); if (entry.IsEncrypted == true) { throw new FormatException(); } instance.NormalEntries.Add(entry); } instance.EncryptedEntries.Clear(); for (int i = 0; i < encryptedCount; i++) { var encryptedEntry = EncryptedChunkEntry.Read(input, endian); if (encryptedEntry.Entry.IsEncrypted == false) { throw new FormatException(); } if (encryptedEntry.Entry.Size != encryptedEntry.CryptoInfo.Size) { throw new FormatException(); } instance.EncryptedEntries.Add(encryptedEntry); } instance.PatchEntries.Clear(); for (int i = 0; i < patchCount; i++) { var entry = PatchEntry.Read(input, endian); instance.PatchEntries.Add(entry); } if (input.Position != input.Length) { throw new FormatException(); } return(instance); }