Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace SSX_Editor
- {
- public class ssxvprofile
- {
- public XboxClasses.IO.IO IO;
- public Header Header = new Header();
- public System.UInt32 Hash = 0;
- public System.Collections.Generic.List<System.Byte[]> Blocks = new System.Collections.Generic.List<System.Byte[]>();
- public System.UInt32 Unk = 0;//UInt24
- public ssxvprofile(XboxClasses.IO.IO _IO) { IO = _IO; }
- public void Read()
- {
- IO.Open(0);
- Header.Read(ref IO);
- Hash = IO.Reader.ReadUInt32();
- System.Int32 BlockCount = IO.Reader.ReadInt32();
- Blocks.Clear();
- for (System.Int32 i = 0; i < BlockCount; i++)
- {
- Blocks.Add(IO.Reader.ReadBytes(IO.Reader.ReadInt32()));
- }
- Unk = IO.Reader.ReadUInt32();
- }
- public void Write()
- {
- XboxClasses.IO.IO Data = new XboxClasses.IO.IO(new System.Byte[358396]);
- Data.Open(0);
- Data.Writer.WriteInt32(Blocks.Count);
- for (System.Int32 i = 0; i < Blocks.Count; i++)
- {
- Data.Writer.WriteInt32(Blocks[i].Length);
- Data.Writer.Write(Blocks[i]);
- }
- Data.Writer.WriteUInt32(Unk);
- Data.Close();
- Hash = BZIP2.Compute(((System.IO.MemoryStream)Data.Stream).ToArray());//FixHash
- XboxClasses.IO.IO Body = new XboxClasses.IO.IO(new System.Byte[358400]);
- Body.Open(0);
- Body.Writer.WriteUInt32(Hash);
- Body.Writer.Write(((System.IO.MemoryStream)Data.Stream).ToArray());
- Body.Close();
- Header.Hash = CRC32.Compute(((System.IO.MemoryStream)Body.Stream).ToArray());//Correct Header Hash
- //Write to file
- IO.Open(0);
- Header.Write(ref IO);
- IO.Writer.Write(((System.IO.MemoryStream)Body.Stream).ToArray());
- IO.Writer.Flush();
- }
- }
- public class Header
- {
- public System.String Magic = "TXT_PROF_SAVEGR\0";
- public System.UInt32 Hash = 0;
- public System.UInt32 Unk = 73;
- public System.UInt32 Unk2 = 0;
- public void Read(ref XboxClasses.IO.IO IO)
- {
- Magic = IO.Reader.ReadASCII(16);
- if (Magic != "TXT_PROF_SAVEGR\0")
- {
- throw new System.Exception("Invalid Magic: " + Magic);
- }
- Hash = IO.Reader.ReadUInt32();
- Unk = IO.Reader.ReadUInt32();
- Unk2 = IO.Reader.ReadUInt32();
- }
- public void Write(ref XboxClasses.IO.IO IO)
- {
- if (Magic != "TXT_PROF_SAVEGR\0")
- {
- throw new System.Exception("Invalid Magic: " + Magic);
- }
- IO.Writer.WriteASCII(Magic);
- IO.Writer.WriteUInt32(Hash);
- IO.Writer.WriteUInt32(Unk);
- IO.Writer.WriteUInt32(Unk2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment