godzcheater

SSX Save Format

Mar 2nd, 2012
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.98 KB | None | 0 0
  1. namespace SSX_Editor
  2. {
  3.     public class ssxvprofile
  4.     {
  5.         public XboxClasses.IO.IO IO;
  6.  
  7.         public Header Header = new Header();
  8.         public System.UInt32 Hash = 0;
  9.         public System.Collections.Generic.List<System.Byte[]> Blocks = new System.Collections.Generic.List<System.Byte[]>();
  10.         public System.UInt32 Unk = 0;//UInt24
  11.  
  12.         public ssxvprofile(XboxClasses.IO.IO _IO) { IO = _IO; }
  13.  
  14.         public void Read()
  15.         {
  16.             IO.Open(0);
  17.             Header.Read(ref IO);
  18.             Hash = IO.Reader.ReadUInt32();
  19.             System.Int32 BlockCount = IO.Reader.ReadInt32();
  20.             Blocks.Clear();
  21.             for (System.Int32 i = 0; i < BlockCount; i++)
  22.             {
  23.                 Blocks.Add(IO.Reader.ReadBytes(IO.Reader.ReadInt32()));
  24.             }
  25.             Unk = IO.Reader.ReadUInt32();
  26.         }
  27.         public void Write()
  28.         {
  29.             XboxClasses.IO.IO Data = new XboxClasses.IO.IO(new System.Byte[358396]);
  30.             Data.Open(0);
  31.             Data.Writer.WriteInt32(Blocks.Count);
  32.             for (System.Int32 i = 0; i < Blocks.Count; i++)
  33.             {
  34.                 Data.Writer.WriteInt32(Blocks[i].Length);
  35.                 Data.Writer.Write(Blocks[i]);
  36.             }
  37.             Data.Writer.WriteUInt32(Unk);
  38.             Data.Close();
  39.  
  40.             Hash = BZIP2.Compute(((System.IO.MemoryStream)Data.Stream).ToArray());//FixHash
  41.  
  42.             XboxClasses.IO.IO Body = new XboxClasses.IO.IO(new System.Byte[358400]);
  43.             Body.Open(0);
  44.             Body.Writer.WriteUInt32(Hash);
  45.             Body.Writer.Write(((System.IO.MemoryStream)Data.Stream).ToArray());
  46.             Body.Close();
  47.  
  48.             Header.Hash = CRC32.Compute(((System.IO.MemoryStream)Body.Stream).ToArray());//Correct Header Hash
  49.             //Write to file
  50.             IO.Open(0);
  51.             Header.Write(ref IO);
  52.             IO.Writer.Write(((System.IO.MemoryStream)Body.Stream).ToArray());
  53.             IO.Writer.Flush();
  54.         }
  55.     }
  56.     public class Header
  57.     {
  58.         public System.String Magic = "TXT_PROF_SAVEGR\0";
  59.         public System.UInt32 Hash = 0;
  60.         public System.UInt32 Unk = 73;
  61.         public System.UInt32 Unk2 = 0;
  62.  
  63.         public void Read(ref XboxClasses.IO.IO IO)
  64.         {
  65.             Magic = IO.Reader.ReadASCII(16);
  66.             if (Magic != "TXT_PROF_SAVEGR\0")
  67.             {
  68.                 throw new System.Exception("Invalid Magic: " + Magic);
  69.             }
  70.             Hash = IO.Reader.ReadUInt32();
  71.             Unk = IO.Reader.ReadUInt32();
  72.             Unk2 = IO.Reader.ReadUInt32();
  73.         }
  74.         public void Write(ref XboxClasses.IO.IO IO)
  75.         {
  76.             if (Magic != "TXT_PROF_SAVEGR\0")
  77.             {
  78.                 throw new System.Exception("Invalid Magic: " + Magic);
  79.             }
  80.             IO.Writer.WriteASCII(Magic);
  81.             IO.Writer.WriteUInt32(Hash);
  82.             IO.Writer.WriteUInt32(Unk);
  83.             IO.Writer.WriteUInt32(Unk2);
  84.         }
  85.     }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment